persp3d.cpp revision 13223d251a0eca100512280a15dc9b2213a28809
#define __PERSP3D_C__
#include "persp3d.h"
#include "perspective-line.h"
#include "attributes.h"
#include "document-private.h"
#include "vanishing-point.h"
#include "box3d-context.h"
#include "box3d.h"
#include "xml/document.h"
#include "xml/node-event-vector.h"
#include "desktop-handles.h"
static Inkscape::XML::Node *persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
static int global_counter = 0;
if (!type) {
sizeof(Persp3DClass),
sizeof(Persp3D),
return type;
if (repr) {
switch (key) {
case SP_ATTR_INKSCAPE_PERSP3D_VP_X: {
if (value) {
case SP_ATTR_INKSCAPE_PERSP3D_VP_Y: {
if (value) {
case SP_ATTR_INKSCAPE_PERSP3D_VP_Z: {
if (value) {
case SP_ATTR_INKSCAPE_PERSP3D_ORIGIN: {
if (value) {
if (flags & SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG) {
Persp3D *
persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is given, copy the attributes over
if (dup) {
gchar *str = NULL; // FIXME: Should this be freed each time we set an attribute or only in the end or at all?
return repr;
if (set_undo) {
persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed) { // angle is in degrees
gchar *
if (!box) {
//SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", SP_OBJECT_REPR(persp)->attribute("id"));
// FIXME: For some reason, std::find() does not seem to compare pointers "correctly" (or do we need to
if ((*i) == box) {
g_print ("Warning! In %s (%d): trying to add transform status for box %d twice when it's already listed as true.\n",
g_print ("Warning! In %s (%d): trying to set transform status for box %d, but it is not listed in the perspective!! Aborting.\n",
(*persp->boxes_transformed.begin()).second = false; // make sure the box is marked as untransformed (in case more boxes are added later)
if ((*i).second == true) {
return false; // all boxes in the perspective are still untransformed; a pending transformation should be applied
if ((*i).second == false) {
(*i).second = false;
//g_print ("Requesting display update for %d boxes in the perspective.\n", persp->boxes.size());
box3d_position_set(*i);
//g_print ("Requesting repr update for %d boxes in the perspective.\n", persp->boxes.size());
box3d_set_z_orders(*i);
// FIXME: For some reason we seem to require a vector instead of a list in Persp3D, but in vp_knot_moved_handler()
// we need a list of boxes. If we can store a list in Persp3D right from the start, this function becomes
return bx_lst;
void * data )
//g_print("persp3d_on_repr_attr_changed!!!! TODO: Do we need to trigger any further updates than the box reprs?");
if (!data)
return sel;
for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {