summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd077ad)
raw | patch | inline | side by side (parent: dd077ad)
author | cilix42 <cilix42@users.sourceforge.net> | |
Sat, 14 Jul 2007 16:46:20 +0000 (16:46 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Sat, 14 Jul 2007 16:46:20 +0000 (16:46 +0000) |
src/box3d-context.cpp | patch | blob | history | |
src/box3d.cpp | patch | blob | history |
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 0bcf9ffa46ccbbaaca3558fa189985b057778674..ada272acd2f88157d70d0758a84b55f5e36f74cc 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -203,14 +203,6 @@ void sp_3dbox_context_selection_changed(Inkscape::Selection *selection, gpointer
ec->shape_repr = shape_repr;
Inkscape::GC::anchor(shape_repr);
sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
-
- // FIXME: The following really belongs in sp_3dbox_build. But when undoing & redoing the
- // creation of a 3D box, we have no means of accessing the recreated paths, which
- // seem to be built after the box itself. Thus we need to check for untracked paths
- // here and hook them to the box if the latter was created by a redo operation.
- if (SP_IS_3DBOX(item)) {
- sp_3dbox_link_to_existing_paths (SP_3DBOX(item), shape_repr);
- }
}
}
}
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 101cce5650bc8c718b5e88cc64248c4e45b3dc20..eb67269ce3975acec57e4340b3f6b0207ec9be81 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
//static void sp_3dbox_set_shape(SPShape *shape);
static void sp_3dbox_set_shape(SP3DBox *box3d);
+static void sp_3dbox_update_corner_with_value_from_svg (SPObject *object, guint corner_id, const gchar *value);
static gchar * sp_3dbox_get_corner_coords_string (SP3DBox *box, guint id);
static std::pair<gdouble, gdouble> sp_3dbox_get_coord_pair_from_string (const gchar *);
}
*/
-static void
-sp_3dbox_update_corner_with_value_from_svg (SPObject *object, guint corner_id, const gchar *value)
-{
- if (value == NULL) return;
- SP3DBox *box = SP_3DBOX(object);
-
- std::pair<gdouble, gdouble> coord_pair = sp_3dbox_get_coord_pair_from_string (value);
- box->corners[corner_id] = NR::Point (coord_pair.first, coord_pair.second);
- sp_3dbox_recompute_corners (box, box->corners[2], box->corners[1], box->corners[5]);
- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
-}
-
static void sp_3dbox_set(SPObject *object, unsigned int key, const gchar *value)
{
switch (key) {
@@ -177,6 +166,11 @@ static void sp_3dbox_set(SPObject *object, unsigned int key, const gchar *value)
static void
sp_3dbox_update(SPObject *object, SPCtx *ctx, guint flags)
{
+ if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
+ SP3DBox *box = SP_3DBOX(object);
+ sp_3dbox_link_to_existing_paths (box, SP_OBJECT_REPR(object));
+ }
+
/* Invoke parent method */
if (((SPObjectClass *) (parent_class))->update)
((SPObjectClass *) (parent_class))->update(object, ctx, flags);
}
}
+/**
+ * In some situations (e.g., after cloning boxes, undo & redo, or reading boxes from a file) there are
+ * paths already present in the document which correspond to the faces of newly created boxes, but their
+ * 'path' members don't link to them yet. The following function corrects this if necessary.
+ */
void
sp_3dbox_link_to_existing_paths (SP3DBox *box, Inkscape::XML::Node *repr) {
// TODO: We should probably destroy the existing paths and recreate them because we don't know
return std::make_pair(coord1, coord2);
}
+// auxiliary function
+static void
+sp_3dbox_update_corner_with_value_from_svg (SPObject *object, guint corner_id, const gchar *value)
+{
+ if (value == NULL) return;
+ SP3DBox *box = SP_3DBOX(object);
+
+ std::pair<gdouble, gdouble> coord_pair = sp_3dbox_get_coord_pair_from_string (value);
+ box->corners[corner_id] = NR::Point (coord_pair.first, coord_pair.second);
+ sp_3dbox_recompute_corners (box, box->corners[2], box->corners[1], box->corners[5]);
+ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+}
+
/*
Local Variables:
mode:c++