Question about the polyline object...
- From: "Michael H. Voase" <mvoase midcoast com au>
- To: dia-list gnome org
- Subject: Question about the polyline object...
- Date: Tue, 27 Aug 2002 13:47:21 +1000
Gday,
First up, thanks for creating a great tool. I am currently using it for
schematic diagrams and I find dia quite usefull.
However, the niceties aside, I am trying to get the xfig importer back
into shape but I have run across a snag. Currenly the xfig importer
doesnt *seem* to import xfig polylines. The reson, as it appears to me,
is that there doesnt seem to be an appropriate API to permit the loading
of the actual polyline points into the polyline object. I understand how
to create an instance of a polyline (using
ObjectType->ops->Create(...) etc) BUT, loading the actual points into
the object seems to be impossible. All I get is the two default points,
one at the point given to create() and another at px+1 and py+1.
The same problem seems to apply to beziergons and just about any object
that can have a variable number of points.
So my question, have I missed something? Is there a specifical call to
manipulate the points stored in an object? If not, then what are the
current plans on the table for implementing point manipulation
interfaces in dia objects?
Secondly, I have also attached a patch to 0.88.1 to permit the setting of
the zigzag line orientation. I have already sent this patch to Alex
Larsson but I have not recieved any comment on it, so I am sending it to
the list.
'Ave fun...
Cheers Mik.
diff -ur dia-0.88.1/lib/orth_conn.c dia-0.88.1mv/lib/orth_conn.c
--- dia-0.88.1/lib/orth_conn.c Mon Mar 26 11:05:21 2001
+++ dia-0.88.1mv/lib/orth_conn.c Sun Aug 25 15:07:26 2002
@@ -30,9 +30,13 @@
enum change_type {
TYPE_ADD_SEGMENT,
- TYPE_REMOVE_SEGMENT
+ TYPE_REMOVE_SEGMENT,
+ TYPE_ORIENT_VERT,
+ TYPE_ORIENT_HORIZ
};
+static enum change_type orthconn_orientation = TYPE_ORIENT_HORIZ;
+
static ObjectChange *
midsegment_create_change(OrthConn *orth, enum change_type type,
int segment,
@@ -88,6 +92,17 @@
remove segment */
};
+static ObjectChange *
+orient_change_create(OrthConn *orth, enum change_type change);
+
+struct OrientChange
+{
+ ObjectChange obj_change;
+ enum change_type type;
+ int applied;
+ enum change_type previous_value;
+};
+
static void set_midpoint(Point *point, OrthConn *orth, int segment)
{
@@ -399,18 +414,33 @@
obj->handles[2] = orth->handles[2];
/* Just so we have some position: */
- orth->points[0] = *startpoint;
- orth->points[1].x = startpoint->x;
- orth->points[1].y = startpoint->y + 1.0;
- orth->points[2].x = startpoint->x + 1.0;
- orth->points[2].y = startpoint->y + 1.0;
- orth->points[3].x = startpoint->x + 2.0;
- orth->points[3].y = startpoint->y + 1.0;
-
- orth->orientation[0] = VERTICAL;
- orth->orientation[1] = HORIZONTAL;
- orth->orientation[2] = VERTICAL;
-
+ if (orthconn_orientation == TYPE_ORIENT_HORIZ)
+ {
+ orth->points[0] = *startpoint;
+ orth->points[1].x = startpoint->x;
+ orth->points[1].y = startpoint->y + 1.0;
+ orth->points[2].x = startpoint->x + 1.0;
+ orth->points[2].y = startpoint->y + 1.0;
+ orth->points[3].x = startpoint->x + 2.0;
+ orth->points[3].y = startpoint->y + 1.0;
+
+ orth->orientation[0] = VERTICAL;
+ orth->orientation[1] = HORIZONTAL;
+ orth->orientation[2] = VERTICAL;
+ } else
+ {
+ orth->points[0] = *startpoint;
+ orth->points[1].x = startpoint->x + 1.0;
+ orth->points[1].y = startpoint->y;
+ orth->points[2].x = startpoint->x + 1.0;
+ orth->points[2].y = startpoint->y + 1.0;
+ orth->points[3].x = startpoint->x + 1.0;
+ orth->points[3].y = startpoint->y + 2.0;
+
+ orth->orientation[0] = HORIZONTAL;
+ orth->orientation[1] = VERTICAL;
+ orth->orientation[2] = HORIZONTAL;
+ }
orthconn_update_data(orth);
}
@@ -662,6 +692,26 @@
return change;
}
+ObjectChange *
+orthconn_orient_vert(OrthConn *orth, Point *clicked)
+{
+ ObjectChange *change = NULL;
+
+ change = orient_change_create(orth, TYPE_ORIENT_VERT);
+ change->apply(change, (Object *) orth);
+ return change;
+}
+
+ObjectChange *
+orthconn_orient_horiz(OrthConn *orth, Point *clicked)
+{
+ ObjectChange *change = NULL;
+
+ change = orient_change_create(orth, TYPE_ORIENT_HORIZ);
+ change->apply(change, (Object *) orth);
+ return change;
+}
+
static void
delete_point(OrthConn *orth, int pos)
{
@@ -790,6 +840,8 @@
HANDLE_MOVE_ENDPOINT);
}
break;
+ default:
+ break;
}
}
@@ -831,6 +883,8 @@
if (change->cp)
object_connect(obj, change->old_end_handle, change->cp);
break;
+ default:
+ break;
}
change->applied = 0;
}
@@ -903,6 +957,8 @@
orth->points[change->segment].y = change->points[0].y;
}
break;
+ default:
+ break;
}
}
@@ -931,6 +987,8 @@
insert_handle(orth, change->segment, change->handles[0],
FLIP_ORIENT(orth->orientation[change->segment-1]) );
break;
+ default:
+ break;
}
change->applied = 0;
}
@@ -961,5 +1019,47 @@
}
+static void orient_change_free(struct OrientChange *change)
+{
+}
+
+static void orient_change_apply(struct OrientChange *change, Object *obj)
+{
+ change->applied = 1;
+
+ switch (change->type)
+ {
+ case TYPE_ORIENT_HORIZ:
+ orthconn_orientation = TYPE_ORIENT_HORIZ;
+ break;
+ case TYPE_ORIENT_VERT:
+ orthconn_orientation = TYPE_ORIENT_VERT;
+ break;
+ default:
+ break;
+ }
+
+}
+static void orient_change_revert(struct OrientChange *change, Object *obj)
+{
+ change->applied = 0;
+ orthconn_orientation = change->previous_value;
+}
+static ObjectChange *
+orient_change_create(OrthConn *orth, enum change_type type)
+{
+ struct OrientChange *change;
+
+ change = g_new(struct OrientChange, 1);
+
+ change->obj_change.apply = (ObjectChangeApplyFunc) orient_change_apply;
+ change->obj_change.revert = (ObjectChangeRevertFunc) orient_change_revert;
+ change->obj_change.free = (ObjectChangeFreeFunc) orient_change_free;
+
+ change->type = type;
+ change->previous_value = orthconn_orientation;
+ change->applied = 0;
+ return (ObjectChange *)change;
+}
diff -ur dia-0.88.1/lib/orth_conn.h dia-0.88.1mv/lib/orth_conn.h
--- dia-0.88.1/lib/orth_conn.h Sat Feb 24 01:45:45 2001
+++ dia-0.88.1mv/lib/orth_conn.h Sun Aug 25 14:35:01 2002
@@ -78,6 +78,8 @@
int orthconn_can_add_segment(OrthConn *orth, Point *clickedpoint);
ObjectChange *orthconn_delete_segment(OrthConn *orth, Point *clickedpoint);
ObjectChange *orthconn_add_segment(OrthConn *orth, Point *clickedpoint);
+ObjectChange *orthconn_orient_vert(OrthConn *orth, Point *clickedpoint);
+ObjectChange *orthconn_orient_horiz(OrthConn *orth, Point *clickedpoint);
#endif /* ORTH_CONN_H */
Only in dia-0.88.1mv: libtool
diff -ur dia-0.88.1/objects/standard/zigzagline.c dia-0.88.1mv/objects/standard/zigzagline.c
--- dia-0.88.1/objects/standard/zigzagline.c Tue May 1 10:56:01 2001
+++ dia-0.88.1mv/objects/standard/zigzagline.c Sun Aug 25 14:58:35 2002
@@ -335,9 +335,29 @@
return change;
}
+static ObjectChange *
+zigzagline_vertical_callback(Object *obj, Point *clicked, gpointer data)
+{
+ ObjectChange *change = NULL;
+ change = orthconn_orient_vert((OrthConn *)obj, clicked);
+ return change;
+}
+
+static ObjectChange *
+zigzagline_horizontal_callback(Object *obj, Point *clicked, gpointer data)
+{
+ ObjectChange *change = NULL;
+ change = orthconn_orient_horiz((OrthConn *)obj, clicked);
+ return change;
+}
+
+
static DiaMenuItem object_menu_items[] = {
{ N_("Add segment"), zigzagline_add_segment_callback, NULL, 1 },
{ N_("Delete segment"), zigzagline_delete_segment_callback, NULL, 1 },
+ { NULL, NULL, NULL, 1 },
+ { N_("Vertical Orientation"), zigzagline_vertical_callback, NULL, 1 },
+ { N_("Horizontal Orientation"), zigzagline_horizontal_callback, NULL, 1 }
};
static DiaMenu object_menu = {
diff -ur dia-0.88.1/po/en_GB.po dia-0.88.1mv/po/en_GB.po
--- dia-0.88.1/po/en_GB.po Sat May 19 16:34:47 2001
+++ dia-0.88.1mv/po/en_GB.po Sun Aug 25 16:20:00 2002
@@ -201,7 +201,7 @@
#: app/dia-props.c:189
#, fuzzy
msgid "Background Colour"
-msgstr "Background colour:"
+msgstr "Background Colour:"
#: app/dia-props.c:200 lib/diagramdata.c:59
msgid "Background"
Only in dia-0.88.1/sheets: sheet-translation-report
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]