[dia] [transform] Transformed Group has no visible/usable connection points
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [transform] Transformed Group has no visible/usable connection points
- Date: Wed, 6 Oct 2010 21:59:54 +0000 (UTC)
commit 997f15f29f0f0e1c1128bd49a33766e697f96d1b
Author: Hans Breuer <hans breuer org>
Date: Sat Sep 25 20:08:16 2010 +0200
[transform] Transformed Group has no visible/usable connection points
Basic problems:
- connections (respectively handle and connection point position) are
not managed on the object level, but a lot of object internals are
exposed to adjust connected positions
- it is unclear where to best do the coordinate transformation, especially
for two connected objects living in different transformations
- it gets more complicated by gap adjustments, which too assume same
coordinate system
Easy solution for now: transformed objects can not be connected.
app/connectionpoint_ops.c | 4 ++--
app/object_ops.c | 6 +++---
app/select.c | 4 ++--
lib/group.c | 25 ++++++++++++++++++++-----
lib/libdia.def | 1 +
lib/object.h | 2 ++
6 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/app/connectionpoint_ops.c b/app/connectionpoint_ops.c
index 8bce042..83f033b 100644
--- a/app/connectionpoint_ops.c
+++ b/app/connectionpoint_ops.c
@@ -63,7 +63,7 @@ object_draw_connectionpoints(DiaObject *obj, DDisplay *ddisp)
int i;
static Color midpoint_color = { 1.0, 0.0, 0.0 };
- for (i=0;i<obj->num_connections;i++) {
+ for (i=0;i<dia_object_get_num_connections(obj);i++) {
if ((obj->connections[i]->flags & CP_FLAG_ANYPLACE) == 0)
connectionpoint_draw(obj->connections[i], ddisp, &connectionpoint_color);
else if (!ddisp->mainpoint_magnetism)
@@ -113,7 +113,7 @@ diagram_update_connections_object(Diagram *dia, DiaObject *obj,
DiaObject *connected_obj;
Handle *handle;
- for (i=0;i<obj->num_connections;i++) {
+ for (i=0;i<dia_object_get_num_connections(obj);i++) {
cp = obj->connections[i];
if ((update_nonmoved) ||
(distance_point_point_manhattan(&cp->pos, &cp->last_pos) > CHANGED_TRESHOLD)) {
diff --git a/app/object_ops.c b/app/object_ops.c
index 906b82b..97c7da6 100644
--- a/app/object_ops.c
+++ b/app/object_ops.c
@@ -48,7 +48,7 @@ object_add_updates(DiaObject *obj, Diagram *dia)
}
/* Connection points */
- for (i=0;i<obj->num_connections;i++) {
+ for (i=0;i<dia_object_get_num_connections(obj);++i) {
connectionpoint_add_update(obj->connections[i], dia);
}
@@ -105,7 +105,7 @@ object_find_connectpoint_display(DDisplay *ddisp, Point *pos,
obj_here = diagram_find_clicked_object_except(ddisp->diagram, pos, 0.00001, avoid);
if (obj_here != NULL) {
int i;
- for (i = 0; i < obj_here->num_connections; i++) {
+ for (i = 0; i < dia_object_get_num_connections(obj_here); ++i) {
if (obj_here->connections[i]->flags & CP_FLAG_ANYPLACE) {
g_list_free(avoid);
return obj_here->connections[i];
@@ -485,7 +485,7 @@ object_list_align_connected (GList *objects, Diagram *dia, int align)
list = objects;
while (list != NULL) {
obj = list->data;
- for (i = 0; i < obj->num_connections; ++i) {
+ for (i = 0; i < dia_object_get_num_connections(obj); ++i) {
ConnectionPoint *cp = obj->connections[i];
connected = cp->connected;
/* first of all remember the objects connected to anything */
diff --git a/app/select.c b/app/select.c
index cdba9d4..99e0054 100644
--- a/app/select.c
+++ b/app/select.c
@@ -135,7 +135,7 @@ select_connected_callback(gpointer data, guint action, GtkWidget *widget)
DiaObject *obj = (DiaObject *)tmp->data;
int i;
- for (i = 0; i < obj->num_connections; i++) {
+ for (i = 0; i < dia_object_get_num_connections(obj); i++) {
ConnectionPoint *connection = obj->connections[i];
GList *conns = connection->connected;
@@ -175,7 +175,7 @@ select_transitively(Diagram *dia, DiaObject *obj)
}
}
- for (i = 0; i < obj->num_connections; i++) {
+ for (i = 0; i < dia_object_get_num_connections(obj); i++) {
ConnectionPoint *connection = obj->connections[i];
GList *conns = connection->connected;
diff --git a/lib/group.c b/lib/group.c
index dc05980..a237016 100644
--- a/lib/group.c
+++ b/lib/group.c
@@ -175,13 +175,12 @@ group_update_handles(Group *group)
static void
group_update_connectionpoints(Group *group)
{
+#if 0
/* FIXME: can't do it this way - lines are transformed twice than */
/* Also can't do it by just copying the original connection points
* into this object, e.g. connect() must work on the original cp.
* So time for some serious interface update ...
*/
- return;
-
if (group->matrix) {
DiaObject *obj = &group->object;
int i;
@@ -195,6 +194,7 @@ group_update_connectionpoints(Group *group)
cp->pos.y = p.x * m->yx + p.y * m->yy + m->y0;
}
}
+#endif
}
static ObjectChange*
@@ -339,6 +339,21 @@ group_destroy(Group *group)
object_destroy(obj);
}
+/*! Accessor for visible/usable number of connections for app/
+ *
+ * Should probably become a DiaObject member when more objects need
+ * such special handling.
+ */
+int
+dia_object_get_num_connections (DiaObject *obj)
+{
+ if (IS_GROUP(obj)) {
+ if (((Group*)obj)->matrix)
+ return 0;
+ }
+
+ return obj->num_connections;
+}
static DiaObject *
group_copy(Group *group)
@@ -371,7 +386,7 @@ group_copy(Group *group)
while (list != NULL) {
listobj = (DiaObject *) list->data;
- for (i=0;i<listobj->num_connections;i++) {
+ for (i=0;i<dia_object_get_num_connections(listobj);i++) {
/* Make connectionpoints be that of the 'inner' objects: */
newobj->connections[num_conn++] = listobj->connections[i];
}
@@ -493,7 +508,7 @@ group_create(GList *objects)
while (list != NULL) {
part_obj = (DiaObject *) list->data;
- num_conn += part_obj->num_connections;
+ num_conn += dia_object_get_num_connections(part_obj);
list = g_list_next(list);
}
@@ -506,7 +521,7 @@ group_create(GList *objects)
while (list != NULL) {
part_obj = (DiaObject *) list->data;
- for (i=0;i<part_obj->num_connections;i++) {
+ for (i=0;i<dia_object_get_num_connections(part_obj);i++) {
obj->connections[num_conn++] = part_obj->connections[i];
}
diff --git a/lib/libdia.def b/lib/libdia.def
index dba0248..628af46 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -307,6 +307,7 @@ EXPORTS
dia_object_set_meta
dia_object_get_meta
dia_object_set_pixbuf
+ dia_object_get_num_connections
dia_plugin_can_unload
dia_plugin_check_version
diff --git a/lib/object.h b/lib/object.h
index bd391d6..fcbd0e9 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -569,6 +569,8 @@ gboolean dia_object_sanity_check(const DiaObject *obj, const gchar *msg);
void dia_object_set_meta (DiaObject *obj, const gchar *key, const gchar *value);
gchar *dia_object_get_meta (DiaObject *obj, const gchar *key);
+int dia_object_get_num_connections (DiaObject *obj);
+
G_END_DECLS
#endif /* OBJECT_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]