summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-07-03 18:38:27 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-07-03 18:38:27 +0000
commit91ec7fdec97678b9b403f5e6a823bb2062c43a41 (patch)
tree260db20d7e9b4aeef731058007d04b8222a82f73 /src
parentMake 3D axes correspond to places in binary representation (allows for more g... (diff)
downloadinkscape-91ec7fdec97678b9b403f5e6a823bb2062c43a41.tar.gz
inkscape-91ec7fdec97678b9b403f5e6a823bb2062c43a41.zip
More meaningful name for 3D axis directions
(bzr r3169)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-face.cpp4
-rw-r--r--src/box3d-face.h8
-rw-r--r--src/perspective-line.cpp2
-rw-r--r--src/perspective-line.h4
-rw-r--r--src/perspective3d.cpp12
-rw-r--r--src/perspective3d.h8
-rw-r--r--src/vanishing-point.cpp2
-rw-r--r--src/vanishing-point.h10
-rw-r--r--src/widgets/toolbox.cpp2
9 files changed, 27 insertions, 25 deletions
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 8b3b5d968..d038de84f 100644
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
@@ -22,7 +22,7 @@ Box3DFace::Box3DFace(SP3DBox *box3d) : dir1 (Box3D::NONE), dir2 (Box3D::NONE), p
}
void Box3DFace::set_shape(NR::Point const ul, NR::Point const lr,
- Box3D::PerspDir const dir1, Box3D::PerspDir const dir2,
+ Box3D::Axis const dir1, Box3D::Axis const dir2,
unsigned int shift_count, NR::Maybe<NR::Point> pt_align, bool align_along_PL)
{
corners[0] = ul;
@@ -30,7 +30,7 @@ void Box3DFace::set_shape(NR::Point const ul, NR::Point const lr,
corners[2] = lr;
} else {
if (align_along_PL) {
- Box3D::PerspDir dir3 = Box3D::third_axis_direction (dir1, dir2);
+ Box3D::Axis dir3 = Box3D::third_axis_direction (dir1, dir2);
Box3D::Line line1(*SP3DBoxContext::current_perspective->get_vanishing_point(dir1), lr);
Box3D::Line line2(*pt_align, *SP3DBoxContext::current_perspective->get_vanishing_point(dir3));
corners[2] = *line1.intersect(line2);
diff --git a/src/box3d-face.h b/src/box3d-face.h
index 124d51776..1b1eb451e 100644
--- a/src/box3d-face.h
+++ b/src/box3d-face.h
@@ -27,14 +27,14 @@ class Box3DFace {
public:
Box3DFace(SP3DBox *box3d);
//Box3DFace(SP3DBox *box3d, NR::Point const ul, NR::Point const lr,
- // Box3D::PerspDir const dir1, Box3D::PerspDir const dir2,
+ // Box3D::Axis const dir1, Box3D::Axis const dir2,
// unsigned int shift_count = 0, NR::Maybe<NR::Point> pt_align = NR::Nothing(), bool align_along_PL = false);
Box3DFace(Box3DFace const &box3dface);
NR::Point operator[](unsigned int i);
void draw(SP3DBox *box3d, SPCurve *c);
void set_shape(NR::Point const ul, NR::Point const lr,
- Box3D::PerspDir const dir1, Box3D::PerspDir const dir2,
+ Box3D::Axis const dir1, Box3D::Axis const dir2,
unsigned int shift_count = 0, NR::Maybe<NR::Point> pt_align = NR::Nothing(),
bool align_along_PL = false);
@@ -46,8 +46,8 @@ public:
private:
NR::Point corners[4];
- Box3D::PerspDir dir1;
- Box3D::PerspDir dir2;
+ Box3D::Axis dir1;
+ Box3D::Axis dir2;
SPPath *path;
SP3DBox *parent_box3d; // the parent box
diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp
index b2e4d2340..158ddd47b 100644
--- a/src/perspective-line.cpp
+++ b/src/perspective-line.cpp
@@ -15,7 +15,7 @@
namespace Box3D {
-PerspectiveLine::PerspectiveLine (NR::Point const &pt, PerspDir const axis, Perspective3D *perspective) :
+PerspectiveLine::PerspectiveLine (NR::Point const &pt, Box3D::Axis const axis, Perspective3D *perspective) :
Line (pt, *(perspective->get_vanishing_point(axis)), true)
{
g_assert (perspective != NULL);
diff --git a/src/perspective-line.h b/src/perspective-line.h
index a1c61c522..45a9b0be6 100644
--- a/src/perspective-line.h
+++ b/src/perspective-line.h
@@ -26,13 +26,13 @@ public:
* PL runs through it; otherwise it has the direction specified by the v_dir vector
* of the VP.
*/
- PerspectiveLine (NR::Point const &pt, PerspDir const axis,
+ PerspectiveLine (NR::Point const &pt, Box3D::Axis const axis,
Perspective3D *perspective = SP3DBoxContext::current_perspective);
NR::Maybe<NR::Point> intersect (Line const &line); // FIXME: Can we make this return only a NR::Point to remove the extra method meet()?
NR::Point meet (Line const &line);
private:
- PerspDir vp_dir; // direction of the associated VP
+ Box3D::Axis vp_dir; // direction of the associated VP
Perspective3D *persp;
};
diff --git a/src/perspective3d.cpp b/src/perspective3d.cpp
index 678b695d0..35558e832 100644
--- a/src/perspective3d.cpp
+++ b/src/perspective3d.cpp
@@ -22,7 +22,7 @@ namespace Box3D {
* vanishing points in the given directions.
*/
// FIXME: This has been moved to a virtual method inside PerspectiveLine; can probably be purged
-NR::Point perspective_intersection (NR::Point pt1, Box3D::PerspDir dir1, NR::Point pt2, Box3D::PerspDir dir2)
+NR::Point perspective_intersection (NR::Point pt1, Box3D::Axis dir1, NR::Point pt2, Box3D::Axis dir2)
{
VanishingPoint const *vp1 = SP3DBoxContext::current_perspective->get_vanishing_point(dir1);
VanishingPoint const *vp2 = SP3DBoxContext::current_perspective->get_vanishing_point(dir2);
@@ -36,7 +36,7 @@ NR::Point perspective_intersection (NR::Point pt1, Box3D::PerspDir dir1, NR::Poi
* Find the point on the perspective line from line_pt to the
* vanishing point in direction dir that is closest to ext_pt.
*/
-NR::Point perspective_line_snap (NR::Point line_pt, PerspDir dir, NR::Point ext_pt)
+NR::Point perspective_line_snap (NR::Point line_pt, Box3D::Axis dir, NR::Point ext_pt)
{
return PerspectiveLine(line_pt, dir).closest_to(ext_pt);
}
@@ -52,7 +52,7 @@ Perspective3D::Perspective3D (VanishingPoint const &pt_x, VanishingPoint const &
vp_z.draw(Z);
}
-VanishingPoint *Perspective3D::get_vanishing_point (PerspDir const dir)
+VanishingPoint *Perspective3D::get_vanishing_point (Box3D::Axis const dir)
{
// FIXME: Also handle value 'NONE' in switch
switch (dir) {
@@ -68,9 +68,8 @@ VanishingPoint *Perspective3D::get_vanishing_point (PerspDir const dir)
}
}
-void Perspective3D::set_vanishing_point (PerspDir const dir, VanishingPoint const &pt)
+void Perspective3D::set_vanishing_point (Box3D::Axis const dir, VanishingPoint const &pt)
{
- // FIXME: Also handle value 'NONE' in switch
switch (dir) {
case X:
vp_x = pt;
@@ -81,6 +80,9 @@ void Perspective3D::set_vanishing_point (PerspDir const dir, VanishingPoint cons
case Z:
vp_z = pt;
break;
+ case NONE:
+ // no vanishing point to set
+ break;
}
}
diff --git a/src/perspective3d.h b/src/perspective3d.h
index 9f033f80d..007b02df1 100644
--- a/src/perspective3d.h
+++ b/src/perspective3d.h
@@ -16,8 +16,8 @@
namespace Box3D {
-NR::Point perspective_intersection (NR::Point pt1, Box3D::PerspDir dir1, NR::Point pt2, Box3D::PerspDir dir2);
-NR::Point perspective_line_snap (NR::Point pt, PerspDir dir, NR::Point ext_pt);
+NR::Point perspective_intersection (NR::Point pt1, Box3D::Axis dir1, NR::Point pt2, Box3D::Axis dir2);
+NR::Point perspective_line_snap (NR::Point pt, Box3D::Axis dir, NR::Point ext_pt);
class PerspectiveLine;
@@ -25,8 +25,8 @@ class Perspective3D {
public:
Perspective3D(VanishingPoint const &pt_x, VanishingPoint const &pt_y, VanishingPoint const &pt_z);
- VanishingPoint *get_vanishing_point (PerspDir const dir);
- void set_vanishing_point (PerspDir const dir, VanishingPoint const &pt);
+ VanishingPoint *get_vanishing_point (Box3D::Axis const dir);
+ void set_vanishing_point (Box3D::Axis const dir, VanishingPoint const &pt);
private:
VanishingPoint vp_x;
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 7933fbeba..21bb7fa76 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -63,7 +63,7 @@ VPState VanishingPoint::toggle_parallel()
return this->state;
}
-void VanishingPoint::draw(PerspDir const axis)
+void VanishingPoint::draw(Box3D::Axis const axis)
{
switch (axis) {
case X:
diff --git a/src/vanishing-point.h b/src/vanishing-point.h
index de06002e4..3be5d085e 100644
--- a/src/vanishing-point.h
+++ b/src/vanishing-point.h
@@ -24,7 +24,7 @@ enum VPState {
// The X-/Y-/Z-axis corresponds to the first/second/third digit
// in binary representation, respectively.
-enum PerspDir {
+enum Axis {
X = 1,
Y = 2,
Z = 4,
@@ -33,12 +33,12 @@ enum PerspDir {
/** Given two axis directions out of {X, Y, Z}, returns the remaining one */
-inline Box3D::PerspDir third_axis_direction (Box3D::PerspDir dir1, Box3D::PerspDir dir2) {
- return (Box3D::PerspDir) ((dir1 + dir2) ^ 0x7);
+inline Box3D::Axis third_axis_direction (Box3D::Axis dir1, Box3D::Axis dir2) {
+ return (Box3D::Axis) ((dir1 + dir2) ^ 0x7);
}
-// FIXME: Store the PerspDir of the VP inside the class
+// FIXME: Store the Axis of the VP inside the class
class VanishingPoint : public NR::Point {
public:
inline VanishingPoint() : NR::Point() {};
@@ -63,7 +63,7 @@ public:
bool is_finite();
VPState toggle_parallel();
- void draw(PerspDir const axis); // Draws a point on the canvas if state == VP_FINITE
+ void draw(Box3D::Axis const axis); // Draws a point on the canvas if state == VP_FINITE
//inline VPState state() { return state; }
VPState state;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index aa5165d15..741f4aaca 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2107,7 +2107,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
static void sp_3dbox_toggle_vp_changed( GtkToggleAction *act, gpointer data )
{
guint dir = GPOINTER_TO_UINT(data);
- Box3D::PerspDir axis;// = (Box3D::PerspDir) data;
+ Box3D::Axis axis;// = (Box3D::Axis) data;
GString *pstring;
switch (dir) {