persp3d.cpp revision 5e1a030f60fc5f5753e30882711db9af56f763f5
#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::Document *doc, 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 void persp3d_update_with_point (Persp3DImpl *persp_impl, Proj::Axis const axis, Proj::Pt2 const &new_image);
static SPObjectClass *persp3d_parent_class;
static int global_counter = 0;
/* Constructor/destructor for the internal class */
Persp3DImpl::Persp3DImpl() {
my_counter = global_counter++;
}
/**
* 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.
*/
delete persp->perspective_impl;
}
/**
* 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, Persp3DImpl *dup) {// if dup is given, copy the attributes over
/* if no perspective is given, create a default one */
if (dup) {
}
/* Append the new persp3d to defs */
}
Persp3D *
for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_PERSP3D(child)) {
return SP_PERSP3D(child);
}
}
return NULL;
}
/**
* Virtual write: write object attributes to repr.
*/
persp3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
// 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
persp3d_update_with_point (Persp3DImpl *persp_impl, Proj::Axis const axis, Proj::Pt2 const &new_image) {
}
void
}
gchar *
{
}
void
if (!box) {
return;
}
if (std::find (persp_impl->boxes.begin(), persp_impl->boxes.end(), box) != persp_impl->boxes.end()) {
return;
}
}
void
std::vector<SPBox3D *>::iterator i = std::find (persp_impl->boxes.begin(), persp_impl->boxes.end(), box);
}
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.
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
if ((*i) == box) {
return true;
}
}
return false;
}
void
return;
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
box3d_position_set(*i);
}
}
void
if (!persp) {
// Hmm, is it an error if this happens?
return;
}
return;
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
box3d_set_z_orders(*i);
}
}
void
return;
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
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.
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
}
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;
}
/* checks whether all boxes linked to this perspective are currently selected */
bool
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
// we have an unselected box in the perspective
return false;
}
}
return true;
}
/* some debugging stuff follows */
void
for (int i = 0; i < 4; ++i) {
}
g_print (" Boxes: ");
for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) {
}
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 (" %s (%d): ", SP_OBJECT_REPR(persp)->attribute("id"), persp->perspective_impl->my_counter);
}
g_print ("\n");
}
g_print ("======================================\n\n");
}
g_print ("%s: current_persp3d is now %s\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 :