persp3d.cpp revision 2c5554708c6288076ab12e23fe57f430d58877c1
#define __PERSP3D_C__
/*
* Class modelling a 3D perspective as an SPObject
*
* Authors:
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#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 SPObjectClass *persp3d_parent_class;
static int global_counter = 0;
/**
* Registers Persp3d class and returns its type.
*/
{
if (!type) {
sizeof(Persp3DClass),
sizeof(Persp3D),
16,
NULL, /* value_table */
};
}
return type;
}
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
/**
* Callback to initialize Persp3D vtable.
*/
{
}
/**
* Callback to initialize Persp3D object.
*/
static void
{
}
/**
* Virtual build: set persp3d attributes from its associated XML node.
*/
{
/* calls sp_object_set for the respective attributes */
// The transformation matrix is updated according to the values we read for the VPs
if (repr) {
}
}
/**
* Virtual release of Persp3D members before destruction.
*/
}
/**
* Virtual set: set attribute to value.
*/
// FIXME: Currently we only read the finite positions of vanishing points;
// should we move VPs into their own repr (as it's done for SPStop, e.g.)?
static void
{
switch (key) {
case SP_ATTR_INKSCAPE_PERSP3D_VP_X: {
if (value) {
}
break;
}
case SP_ATTR_INKSCAPE_PERSP3D_VP_Y: {
if (value) {
break;
}
}
case SP_ATTR_INKSCAPE_PERSP3D_VP_Z: {
if (value) {
break;
}
}
case SP_ATTR_INKSCAPE_PERSP3D_ORIGIN: {
if (value) {
break;
}
}
default: {
break;
}
}
// FIXME: Is this the right place for resetting the draggers?
if (SP_IS_BOX3D_CONTEXT(ec)) {
}
}
static void
{
if (flags & SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG) {
/* TODO: Should we update anything here? */
}
}
Persp3D *
persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is given, copy the attributes over
if (dup) {
} else {
/* if no perspective is given, create a default one */
Proj::Pt2 proj_origin = Proj::Pt2 (sp_document_width(document)/2, sp_document_height(document)/2, 1.0);
}
/* Append the new persp3d to defs */
}
/**
* Virtual write: write object attributes to repr.
*/
{
// this is where we end up when saving as plain SVG (also in other circumstances?);
// hence we don't set the sodipodi:type attribute
}
if (flags & SP_OBJECT_WRITE_EXT) {
gchar *str = NULL; // FIXME: Should this be freed each time we set an attribute or only in the end or at all?
}
return repr;
}
/* convenience wrapper around persp3d_get_finite_dir() and persp3d_get_infinite_dir() */
} else {
}
}
}
}
}
double
}
bool
}
void
// FIXME: Remove this repr update and rely on vp_drag_sel_modified() to do this for us
// On the other hand, vp_drag_sel_modified() would update all boxes;
// here we can confine ourselves to the boxes of this particular perspective.
if (set_undo) {
_("Toggle vanishing point"));
}
}
/* toggle VPs for the same axis in all perspectives of a given list */
void
persp3d_toggle_VP((*i), axis, false);
}
_("Toggle multiple vanishing points"));
}
void
}
}
void
persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed) { // angle is in degrees
// FIXME: Most of this functionality should be moved to trans_mat_3x4.(h|cpp)
// don't rotate anything for finite VPs
return;
}
}
void
}
void
}
gchar *
{
}
void
if (!box) {
return;
}
return;
}
}
void
}
}
bool
// FIXME: For some reason, std::find() does not seem to compare pointers "correctly" (or do we need to
// provide a proper comparison function?), so we manually traverse the list.
if ((*i) == box) {
return true;
}
}
return false;
}
void
g_print ("Warning! In %s (%d): trying to add transform status for box %d twice when it's already listed as true.\n", SP_OBJECT_REPR(persp)->attribute("id"), persp->my_counter, box->my_counter);
return;
}
}
void
}
void
g_print ("Warning! In %s (%d): trying to set transform status for box %d, but it is not listed in the perspective!! Aborting.\n",
box->my_counter);
return;
}
}
bool
/* either the transform has not been applied to the single box associated to this perspective yet
or the transform was already reset; in both cases we need to return false because upcoming
transforms need to be applied */
(*persp->boxes_transformed.begin()).second = false; // make sure the box is marked as untransformed (in case more boxes are added later)
return false;
}
if ((*i).second == true) {
// at least one of the boxes in the perspective has already been transformed;
return true;
}
}
return false; // all boxes in the perspective are still untransformed; a pending transformation should be applied
}
bool
if ((*i).second == false) {
return false;
}
}
return true;
}
void
(*i).second = false;
}
}
void
return;
box3d_position_set(*i);
}
}
void
return;
box3d_set_z_orders(*i);
}
}
void
return;
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
// obsolete. We should do this.
}
return bx_lst;
}
bool
{
}
void
/* double check if we are called in sane situations */
// Note: We first need to copy the boxes of persp2 into a separate list;
// otherwise the loop below gets confused when perspectives are reattached.
}
}
static void
const gchar */*key*/,
const gchar */*oldval*/,
const gchar */*newval*/,
bool /*is_interactive*/,
void * data )
{
if (!data)
return;
}
/* returns a std::set() of all perspectives of the currently selected boxes */
if (SP_IS_BOX3D (i->data)) {
}
}
return p;
}
/* checks whether all boxes linked to this perspective are currently selected */
bool
// we have an unselected box in the perspective
return false;
}
}
return true;
}
}
}
return sel;
}
/* some debugging stuff follows */
void
for (int i = 0; i < 4; ++i) {
}
g_print (" Boxes: ");
}
g_print ("\n");
g_print ("========================\n");
}
void
for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_PERSP3D(child)) {
}
}
}
void
g_print ("\n======================================\n");
g_print ("Selected perspectives and their boxes:\n");
}
g_print ("\n");
}
g_print ("======================================\n\n");
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :