PATCH: ellipse.c : central connection point



Hello,
as I often need to connect an arrow from the center of a circle (e.g. to draw graphs), I send you this patch.
It is a patch against the latest CVS sources.
I tested this patch, it is backward compatible: Dia is still able to load old ellipses (with 8 connection points) and an old version is able to load new ellipses: it produces an Error message saying a connection point does not exist but the ellipse shows up in the diagram.

--
Grégoire Dooms
Index: objects/standard/ellipse.c
===================================================================
RCS file: /cvs/gnome/dia/objects/standard/ellipse.c,v
retrieving revision 1.35
diff -c -r1.35 ellipse.c
*** objects/standard/ellipse.c  20 Aug 2003 05:52:35 -0000      1.35
--- objects/standard/ellipse.c  3 Mar 2004 15:51:14 -0000
***************
*** 44,50 ****
  struct _Ellipse {
    Element element;
  
!   ConnectionPoint connections[8];
    
    real border_width;
    Color border_color;
--- 44,50 ----
  struct _Ellipse {
    Element element;
  
!   ConnectionPoint connections[9];
    
    real border_width;
    Color border_color;
***************
*** 272,277 ****
--- 272,279 ----
    ellipse->connections[6].pos.y = elem->corner.y + elem->height;
    ellipse->connections[7].pos.x = center.x + half_x;
    ellipse->connections[7].pos.y = center.y + half_y;
+   ellipse->connections[8].pos.x = center.x;
+   ellipse->connections[8].pos.y = center.y;
  
    /* Update directions -- if the ellipse is very thin, these may not be good */
    ellipse->connections[0].directions = DIR_NORTH|DIR_WEST;
***************
*** 282,287 ****
--- 284,290 ----
    ellipse->connections[5].directions = DIR_SOUTH|DIR_WEST;
    ellipse->connections[6].directions = DIR_SOUTH;
    ellipse->connections[7].directions = DIR_SOUTH|DIR_EAST;
+   ellipse->connections[8].directions = DIR_NORTH|DIR_WEST|DIR_SOUTH|DIR_EAST;
  
    extra->border_trans = ellipse->border_width / 2.0;
    element_update_boundingbox(elem);
***************
*** 322,330 ****
                                    &ellipse->dashlength);
    ellipse->show_background = default_properties.show_background;
  
!   element_init(elem, 8, 8);
  
!   for (i=0;i<8;i++) {
      obj->connections[i] = &ellipse->connections[i];
      ellipse->connections[i].object = obj;
      ellipse->connections[i].connected = NULL;
--- 325,333 ----
                                    &ellipse->dashlength);
    ellipse->show_background = default_properties.show_background;
  
!   element_init(elem, 8, 9);
  
!   for (i=0;i<9;i++) {
      obj->connections[i] = &ellipse->connections[i];
      ellipse->connections[i].object = obj;
      ellipse->connections[i].connected = NULL;
***************
*** 365,371 ****
    newellipse->show_background = ellipse->show_background;
    newellipse->line_style = ellipse->line_style;
  
!   for (i=0;i<8;i++) {
      newobj->connections[i] = &newellipse->connections[i];
      newellipse->connections[i].object = newobj;
      newellipse->connections[i].connected = NULL;
--- 368,374 ----
    newellipse->show_background = ellipse->show_background;
    newellipse->line_style = ellipse->line_style;
  
!   for (i=0;i<9;i++) {
      newobj->connections[i] = &newellipse->connections[i];
      newellipse->connections[i].object = newobj;
      newellipse->connections[i].connected = NULL;
***************
*** 455,463 ****
    if (attr != NULL)
          ellipse->dashlength = data_real(attribute_first_data(attr));
  
!   element_init(elem, 8, 8);
  
!   for (i=0;i<8;i++) {
      obj->connections[i] = &ellipse->connections[i];
      ellipse->connections[i].object = obj;
      ellipse->connections[i].connected = NULL;
--- 458,466 ----
    if (attr != NULL)
          ellipse->dashlength = data_real(attribute_first_data(attr));
  
!   element_init(elem, 8, 9);
  
!   for (i=0;i<9;i++) {
      obj->connections[i] = &ellipse->connections[i];
      ellipse->connections[i].object = obj;
      ellipse->connections[i].connected = NULL;


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