Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
e10b226d
Commit
e10b226d
authored
Aug 21, 2002
by
Will Schroeder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH:Added nifty translation mode
parent
8d722ee0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
Graphics/vtkCursor3D.cxx
Graphics/vtkCursor3D.cxx
+48
-3
Graphics/vtkCursor3D.h
Graphics/vtkCursor3D.h
+21
-2
No files found.
Graphics/vtkCursor3D.cxx
View file @
e10b226d
...
...
@@ -20,7 +20,7 @@
#include <math.h>
vtkCxxRevisionMacro
(
vtkCursor3D
,
"1.3
7
"
);
vtkCxxRevisionMacro
(
vtkCursor3D
,
"1.3
8
"
);
vtkStandardNewMacro
(
vtkCursor3D
);
// Construct with model bounds = (-1,1,-1,1,-1,1), focal point = (0,0,0),
...
...
@@ -53,6 +53,7 @@ vtkCursor3D::vtkCursor3D()
this
->
YShadows
=
1
;
this
->
ZShadows
=
1
;
this
->
Wrap
=
0
;
this
->
TranslationMode
=
0
;
}
vtkCursor3D
::~
vtkCursor3D
()
...
...
@@ -388,8 +389,9 @@ void vtkCursor3D::Execute()
}
// Set the boundary of the 3D cursor.
void
vtkCursor3D
::
SetModelBounds
(
float
xmin
,
float
xmax
,
float
ymin
,
float
ymax
,
float
zmin
,
float
zmax
)
void
vtkCursor3D
::
SetModelBounds
(
float
xmin
,
float
xmax
,
float
ymin
,
float
ymax
,
float
zmin
,
float
zmax
)
{
if
(
xmin
!=
this
->
ModelBounds
[
0
]
||
xmax
!=
this
->
ModelBounds
[
1
]
||
ymin
!=
this
->
ModelBounds
[
2
]
||
ymax
!=
this
->
ModelBounds
[
3
]
||
...
...
@@ -411,6 +413,47 @@ void vtkCursor3D::SetModelBounds(float xmin, float xmax, float ymin, float ymax,
}
}
void
vtkCursor3D
::
SetFocalPoint
(
float
x
[
3
])
{
if
(
x
[
0
]
==
this
->
FocalPoint
[
0
]
&&
x
[
1
]
==
this
->
FocalPoint
[
1
]
&&
x
[
2
]
==
this
->
FocalPoint
[
2
]
)
{
return
;
}
this
->
Modified
();
float
v
[
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
v
[
i
]
=
x
[
i
]
-
this
->
FocalPoint
[
i
];
this
->
FocalPoint
[
i
]
=
x
[
i
];
if
(
this
->
TranslationMode
)
{
this
->
ModelBounds
[
2
*
i
]
+=
v
[
i
];
this
->
ModelBounds
[
2
*
i
+
1
]
+=
v
[
i
];
}
else
if
(
this
->
Wrap
)
//wrap
{
this
->
FocalPoint
[
i
]
=
this
->
ModelBounds
[
2
*
i
]
+
fmod
((
double
)(
this
->
FocalPoint
[
i
]
-
this
->
ModelBounds
[
2
*
i
]),
(
double
)(
this
->
ModelBounds
[
2
*
i
+
1
]
-
this
->
ModelBounds
[
2
*
i
]));
}
else
//clamp
{
if
(
x
[
i
]
<
this
->
ModelBounds
[
2
*
i
]
)
{
this
->
FocalPoint
[
i
]
=
this
->
ModelBounds
[
2
*
i
];
}
if
(
x
[
i
]
>
this
->
ModelBounds
[
2
*
i
+
1
]
)
{
this
->
FocalPoint
[
i
]
=
this
->
ModelBounds
[
2
*
i
+
1
];
}
}
}
}
void
vtkCursor3D
::
SetModelBounds
(
float
bounds
[
6
])
{
this
->
SetModelBounds
(
bounds
[
0
],
bounds
[
1
],
bounds
[
2
],
bounds
[
3
],
bounds
[
4
],
...
...
@@ -456,4 +499,6 @@ void vtkCursor3D::PrintSelf(ostream& os, vtkIndent indent)
os
<<
indent
<<
"YShadows: "
<<
(
this
->
YShadows
?
"On
\n
"
:
"Off
\n
"
);
os
<<
indent
<<
"ZShadows: "
<<
(
this
->
ZShadows
?
"On
\n
"
:
"Off
\n
"
);
os
<<
indent
<<
"Wrap: "
<<
(
this
->
Wrap
?
"On
\n
"
:
"Off
\n
"
);
os
<<
indent
<<
"Translation Mode: "
<<
(
this
->
TranslationMode
?
"On
\n
"
:
"Off
\n
"
);
}
Graphics/vtkCursor3D.h
View file @
e10b226d
...
...
@@ -51,8 +51,17 @@ public:
vtkGetVectorMacro
(
ModelBounds
,
float
,
6
);
// Description:
// Specify the position of cursor focus.
vtkSetVector3Macro
(
FocalPoint
,
float
);
// Specify the position of cursor focus. If translation mode is on,
// then the entire cursor (including bounding box, cursor, and shadows)
// is translated. Otherwise, the focal point will either be clamped to the
// bounding box, or wrapped, if Wrap is on.
void
SetFocalPoint
(
float
x
[
3
]);
void
SetFocalPoint
(
float
x
,
float
y
,
float
z
)
{
float
xyz
[
3
];
xyz
[
0
]
=
x
;
xyz
[
1
]
=
y
;
xyz
[
2
]
=
z
;
this
->
SetFocalPoint
(
xyz
);
}
vtkGetVectorMacro
(
FocalPoint
,
float
,
3
);
// Description:
...
...
@@ -85,6 +94,14 @@ public:
vtkGetMacro
(
ZShadows
,
int
);
vtkBooleanMacro
(
ZShadows
,
int
);
// Description:
// Enable/disable the translation mode. If on, changes in cursor position
// cause the entire widget to translate along with the cursor.
// By default, translation mode is off.
vtkSetMacro
(
TranslationMode
,
int
);
vtkGetMacro
(
TranslationMode
,
int
);
vtkBooleanMacro
(
TranslationMode
,
int
);
// Description:
// Turn on/off cursor wrapping. If the cursor focus moves outside the
// specified bounds, the cursor will either be restrained against the
...
...
@@ -116,7 +133,9 @@ protected:
int
XShadows
;
int
YShadows
;
int
ZShadows
;
int
TranslationMode
;
int
Wrap
;
private:
vtkCursor3D
(
const
vtkCursor3D
&
);
// Not implemented.
void
operator
=
(
const
vtkCursor3D
&
);
// Not implemented.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment