perspective3d.cpp revision 3616fc4f881e624b50093cef5f017751ddf51b07
#define __PERSPECTIVE3D_C__
/*
* Class modelling a 3D perspective
*
* Authors:
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "box3d.h"
#include "box3d-context.h"
#include "perspective-line.h"
#include <iostream>
#include "perspective3d.h"
// can probably be removed later
#include "inkscape.h"
#include "knotholder.h"
namespace Box3D {
{
return (Perspective3D *) p->data;
}
g_warning ("Stray 3D box!\n");
}
{
return persp;
}
g_warning ("Stray vanishing point!\n");
}
/**
* Computes the intersection of the two perspective lines from pt1 and pt2 to the respective
* vanishing points in the given directions.
*/
// FIXME: This has been moved to a virtual method inside PerspectiveLine; can probably be purged
perspective_intersection (NR::Point pt1, Box3D::Axis dir1, NR::Point pt2, Box3D::Axis dir2, Perspective3D *persp)
{
// FIXME: How to handle parallel lines (also depends on the type of the VPs)?
return *meet;
}
/**
* Find the point on the perspective line from line_pt to the
* vanishing point in direction dir that is closest to ext_pt.
*/
{
}
Perspective3D::Perspective3D (VanishingPoint const &pt_x, VanishingPoint const &pt_y, VanishingPoint const &pt_z)
{
}
{
}
{
Perspective3D::remove_perspective (this);
// Remove the VPs from their draggers
if (SP_IS_3DBOX_CONTEXT (ec)) {
// we need to check if there are any draggers because the selection
// is temporarily empty during duplication of boxes, e.g.
/***
g_assert (bc->_vpdrag->getDraggerFor (*vp_x) != NULL);
g_assert (bc->_vpdrag->getDraggerFor (*vp_y) != NULL);
g_assert (bc->_vpdrag->getDraggerFor (*vp_z) != NULL);
bc->_vpdrag->getDraggerFor (*vp_x)->removeVP (vp_x);
bc->_vpdrag->getDraggerFor (*vp_y)->removeVP (vp_y);
bc->_vpdrag->getDraggerFor (*vp_z)->removeVP (vp_z);
***/
// TODO: the temporary perspective created when building boxes is not linked to any dragger, hence
// we need to do the following checks. Maybe it would be better to not create a temporary
// perspective at all but simply compare the VPs manually in sp_3dbox_build.
if (dragger)
if (dragger)
if (dragger)
}
}
delete vp_x;
delete vp_y;
delete vp_z;
}
bool
{
// Two perspectives are equal iff their vanishing points coincide and have identical states
}
bool
{
}
{
switch (dir) {
case X:
return vp_x;
break;
case Y:
return vp_y;
break;
case Z:
return vp_z;
break;
case NONE:
g_warning ("Axis direction must be specified. As a workaround we return the VP in X direction.\n");
return vp_x;
break;
default:
g_warning ("Single axis direction needed to determine corresponding vanishing point.\n");
break;
}
}
void
{
switch (dir) {
case X:
break;
case Y:
break;
case Z:
break;
case NONE:
// no vanishing point to set
break;
}
}
{
g_warning ("Vanishing point not present in the perspective.\n");
return NONE;
}
void
Perspective3D::set_vanishing_point (Box3D::Axis const dir, gdouble pt_x, gdouble pt_y, gdouble dir_x, gdouble dir_y, VPState st)
{
switch (dir) {
case X:
break;
case Y:
break;
case Z:
break;
case NONE:
// no vanishing point to set
return;
}
}
void
{
// Don't add the same box twice
g_warning ("Box already uses the current perspective. We don't add it again.\n");
return;
}
}
void
{
g_warning ("Could not find box that is to be removed in the current perspective.\n");
}
}
bool
{
}
bool
{
return false;
}
}
return true;
}
GSList *
{
}
}
// we reverse so as to retain the same order as in list_of_boxes
return g_slist_reverse (result);
}
/**
* Update the shape of a box after a handle was dragged or a VP was changed, according to the stored ratios.
*/
void
{
// TODO: Leave the "correct" corner fixed according to which face is supposed to be on front.
}
}
}
sp_3dbox_set_shape (box, true);
// FIXME: Is there a way update the knots without accessing the
// statically linked function knotholder_update_knots?
}
}
}
void
{
}
}
// swallow the list of boxes from the other perspective and delete it
void
{
g_return_if_fail (*this == *other);
// FIXME: Is copying necessary? Is other->boxes invalidated when other is deleted below?
// Should we delete the other perspective here or at the place from where absorb() is called?
delete other;
}
// FIXME: We get compiler errors when we try to move the code from sp_3dbox_get_perspective_string to this function
/***
gchar *
Perspective3D::svg_string ()
{
}
***/
void
{
// FIXME: Should we handle the case that the perspectives have equal VPs but are not identical?
// If so, we need to take care of relinking the boxes, etc.
}
void
{
}
// find an existing perspective whose VPs are equal to those of persp
{
}
}
return NULL; // perspective was not found
}
void
{
g_print ("====================================================\n");
g_print ("\nBoxes: ");
g_print ("none");
} else {
GSList *j;
}
if (j != NULL) {
}
}
}
g_print ("\n====================================================\n");
}
} // namespace Box3D
/*
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 :