]> mj.ucw.cz Git - leo.git/commitdiff
Labelling: Rotation computation improved and commented on
authorKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 10:05:24 +0000 (12:05 +0200)
committerKarryanna <karry@karryanna.cz>
Wed, 1 Jul 2015 10:05:24 +0000 (12:05 +0200)
lab-evolution.c
lab-lines.c

index ccf7515f1d3148519d1c3d006594676e1106e47a..197862495d85feae26767a8578b2da4825a4f028 100644 (file)
@@ -692,10 +692,17 @@ static void move_symbol_point(struct placement *p)
 
 static void move_symbol_segment(struct placement *p)
 {
+  struct request_segment *rs = (struct request_segment *) p->request;
   double m = gen_movement_uniform();
-  // CHECK ME
-  p->x += m;
-  p->y += m * ((struct request_segment *) p->request)->slope;
+  if (fabs(rs->x2 - rs->x1) > 0.01)
+  {
+    p->x += m;
+    p->y += m * rs->slope;
+  }
+  else
+  {
+    p->x += m;
+  }
 }
 
 static void hide_segment_labels(struct individual *individual)
index 35f9f457c53c3b9d7a9e53fe6a80ed20c0b23a2f..a0fc3c79a48141d09ded41e608db0dd0c9832c0b 100644 (file)
@@ -505,8 +505,18 @@ static void make_segments(void)
       rs->x2 = e->n2->o->x;
       rs->y2 = e->n2->o->y;
 
-      rs->slope = (rs->y2 - rs->y1) / (rs->x2 - rs->x1);
-      ((struct sym_text *) rs->label)->rotate = convert_to_deg(atan(rs->slope));
+      if (fabs(rs->x2 - rs->x1) > 0.01)
+      {
+        rs->slope = (rs->y2 - rs->y1) / (rs->x2 - rs->x1);
+        // This works a little bit magically :)
+        // It's possible not to care about quadrants as it "just works" as expected
+        ((struct sym_text *) rs->label)->rotate = convert_to_deg(atan(rs->slope));
+      }
+      else
+      {
+        rs->slope = 142; // Magic!
+        ((struct sym_text *) rs->label)->rotate = 1;
+      }
       struct variant *v = GARY_PUSH(rs->request.variants);
       make_bitmap(v, rs->label);