summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0c30465)
raw | patch | inline | side by side (parent: 0c30465)
author | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 6 Aug 2007 06:25:56 +0000 (06:25 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 6 Aug 2007 06:25:56 +0000 (06:25 +0000) |
src/perspective3d.cpp | patch | blob | history | |
src/perspective3d.h | patch | blob | history | |
src/vanishing-point.cpp | patch | blob | history | |
src/vanishing-point.h | patch | blob | history |
diff --git a/src/perspective3d.cpp b/src/perspective3d.cpp
index 1ad910bfad249cd102f31bd320f4380ec2bbcda6..27366e564203e9134009adad5c7a40ed852861ec 100644 (file)
--- a/src/perspective3d.cpp
+++ b/src/perspective3d.cpp
@@ -61,18 +61,32 @@ perspective_line_snap (NR::Point line_pt, Box3D::Axis dir, NR::Point ext_pt, Per
Perspective3D::Perspective3D (VanishingPoint const &pt_x, VanishingPoint const &pt_y, VanishingPoint const &pt_z)
: desktop (NULL),
- vp_x (pt_x),
- vp_y (pt_y),
- vp_z (pt_z),
boxes (NULL)
{
+ vp_x = new VanishingPoint (pt_x);
+ vp_y = new VanishingPoint (pt_y);
+ vp_z = new VanishingPoint (pt_z);
}
+Perspective3D::Perspective3D (Perspective3D &other)
+ : desktop (other.desktop),
+ boxes (NULL) // FIXME: Should we add an option to copy the list of boxes?
+{
+ vp_x = new VanishingPoint (*other.vp_x);
+ vp_y = new VanishingPoint (*other.vp_y);
+ vp_z = new VanishingPoint (*other.vp_z);
+}
+
+
Perspective3D::~Perspective3D ()
{
g_assert (desktop != NULL);
desktop->remove_perspective (this);
+ delete vp_x;
+ delete vp_y;
+ delete vp_z;
+
g_slist_free (boxes);
}
VanishingPoint *
Perspective3D::get_vanishing_point (Box3D::Axis const dir)
{
- // FIXME: Also handle value 'NONE' in switch
switch (dir) {
case X:
- return &vp_x;
+ return vp_x;
break;
case Y:
- return &vp_y;
+ return vp_y;
break;
case Z:
- return &vp_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");
+ return get_vanishing_point (extract_first_axis_direction(dir));
break;
}
}
@@ -99,13 +120,13 @@ Perspective3D::set_vanishing_point (Box3D::Axis const dir, VanishingPoint const
{
switch (dir) {
case X:
- vp_x = pt;
+ (*vp_x) = pt;
break;
case Y:
- vp_y = pt;
+ (*vp_y) = pt;
break;
case Z:
- vp_z = pt;
+ (*vp_z) = pt;
break;
case NONE:
// no vanishing point to set
diff --git a/src/perspective3d.h b/src/perspective3d.h
index fa9eda65f1974a3da54f22219b799311a103569a..afecb2e48b88489d479b5ed35fc5c6fe8f3bc543 100644 (file)
--- a/src/perspective3d.h
+++ b/src/perspective3d.h
class Perspective3D {
public:
Perspective3D(VanishingPoint const &pt_x, VanishingPoint const &pt_y, VanishingPoint const &pt_z);
+ Perspective3D(Perspective3D &other);
~Perspective3D();
VanishingPoint *get_vanishing_point (Box3D::Axis const dir);
SPDesktop * desktop; // we need to store the perspective's desktop to be able to access it in the destructor
private:
- VanishingPoint vp_x;
- VanishingPoint vp_y;
- VanishingPoint vp_z;
+ VanishingPoint *vp_x;
+ VanishingPoint *vp_y;
+ VanishingPoint *vp_z;
GSList * boxes; // holds a list of boxes sharing this specific perspective
};
index 7d5b24a86b0bf1bcf9a6b9d37bd6e4df4a378463..20c67cb28d1d9c37956be9b7000ac5093699afe6 100644 (file)
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
}
-bool VanishingPoint::is_finite()
+bool VanishingPoint::is_finite() const
{
return this->state == VP_FINITE;
}
diff --git a/src/vanishing-point.h b/src/vanishing-point.h
index e6c106481f0063d625c8129a59245c5792a0dcee..85b7434e2dc6be07b1ff7712ac880c43fa44836b 100644 (file)
--- a/src/vanishing-point.h
+++ b/src/vanishing-point.h
VanishingPoint(NR::Coord x, NR::Coord y, NR::Coord dir_x, NR::Coord dir_y);
VanishingPoint(VanishingPoint const &rhs);
- bool is_finite();
+ bool is_finite() const;
VPState toggle_parallel();
void draw(Box3D::Axis const axis); // Draws a point on the canvas if state == VP_FINITE
//inline VPState state() { return state; }