[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: simple rotate - patch



OK,
here the extremely simple patch that does this. The directions are only set if 
the connection point is on the boundary of the shape.

How about having the direction hints stored in the .dia file?
Or, if this is too drastical, how about trying to be smarter and give any 
connection point east of the center of the shape the DIR_EAST etc.?
Or being very ambitious and trying to figure out, which direction we should 
give by examining the lines in the shape.

The latter one could get hairy, though.

Martin

On Sunday 24 November 2002 15:24, Lars Clausen wrote:
> On Sun, 24 Nov 2002, Martin Hans wrote:
> > On Sunday 24 November 2002 03:41, Lars Clausen wrote:
> >> On Sun, 24 Nov 2002, Martin Hans wrote:
> >> > One other idea: How about having a version of the zig-zag line that is
> >> > rotated 90 degrees so that we'd get a down-left-down behaviour instead
> >> > of the current left-down-left, which is a bad choice in about half of
> >> > the cases.
> >>
> >> I have code in the CVS that will do this somewhat intelligently at
> >> object creation time, and there's a simple way to extend it to all.
> >>
> >> The Box and Ellipse objects sets up allowable directions for each
> >> connection point (in _update_data).  The Zigzagline, when created, looks
> >> at those directions and makes itself either down-left-down or
> >> left-down-left according to which are admissible.  To extend this to
> >> post-creation movement, we need to make sure that midpoints stay where
> >> they are.  My idea is to have it have one more segment when going
> >> horizontal at the end, and one less when going vertical.  That way only
> >> one midpoint will be affected.
> >
> > Just tried it out and it seems to work fine. I would'nt mind making those
> > changes to shapes as well if you could point me to the file where shapes
> > are loaded.
>
> Thank you much!  The shapes are defined in objects/custom/custom_object.c
> and related files.
>
> > Determining the allowed directions automatically should work reliably at
> > least if the connection points are on the border. I'll try to think about
> > how to do that.
>
> Generally, yes.  Some shapes might be too strange, but that's ok.  If we
> get the majority, we've come a long way.
>
> -Lars
--- custom_object.old.c	Sun Nov 24 18:47:02 2002
+++ custom_object.c	Sun Nov 24 18:43:12 2002
@@ -854,9 +854,23 @@
     g_free(txs);
   }
 
-  for (i = 0; i < info->nconnections; i++)
+  for (i = 0; i < info->nconnections; i++){
     transform_coord(custom, &info->connections[i],&custom->connections[i].pos);
 
+    /* Set the directions for the connection points as hints to the
+       zig-zag line. A hint is only set if the connection point is on
+       the boundary of the shape. */
+    custom->connections[i].directions = 0;
+    if(custom->info->connections[i].x == custom->info->shape_bounds.left)
+      custom->connections[i].directions |= DIR_WEST;
+    if(custom->info->connections[i].x == custom->info->shape_bounds.right)
+      custom->connections[i].directions |= DIR_EAST;
+    if(custom->info->connections[i].y == custom->info->shape_bounds.top)
+      custom->connections[i].directions |= DIR_NORTH;
+    if(custom->info->connections[i].y == custom->info->shape_bounds.bottom)
+      custom->connections[i].directions |= DIR_SOUTH;
+  }
+
 
   elem->extra_spacing.border_trans = 0; /*custom->border_width/2; */
   element_update_boundingbox(elem);
@@ -1173,6 +1187,7 @@
     newcustom->connections[i].object = newobj;
     newcustom->connections[i].connected = NULL;
     newcustom->connections[i].pos = custom->connections[i].pos;
+    newcustom->connections[i].directions = custom->connections[i].directions;
     newcustom->connections[i].last_pos = custom->connections[i].last_pos;
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK