Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VTK Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VTK
VTK Examples
Commits
1ff5b837
Commit
1ff5b837
authored
9 months ago
by
Andrew Maclean
Browse files
Options
Downloads
Patches
Plain Diff
Updated ContourWidget
parent
11ded159
No related branches found
Branches containing commit
No related tags found
2 merge requests
!353
Create VTK hyperlinks in one pass and remove #details from the link
,
!352
Draft: Classes in python not in pythonic api 08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/PythonicAPI/Widgets/ContourWidget.py
+35
-2
35 additions, 2 deletions
src/PythonicAPI/Widgets/ContourWidget.py
with
35 additions
and
2 deletions
src/PythonicAPI/Widgets/ContourWidget.py
+
35
−
2
View file @
1ff5b837
...
@@ -8,6 +8,7 @@ import vtkmodules.vtkInteractionStyle
...
@@ -8,6 +8,7 @@ import vtkmodules.vtkInteractionStyle
import
vtkmodules.vtkRenderingOpenGL2
import
vtkmodules.vtkRenderingOpenGL2
from
vtkmodules.vtkCommonColor
import
vtkNamedColors
from
vtkmodules.vtkCommonColor
import
vtkNamedColors
from
vtkmodules.vtkCommonCore
import
(
from
vtkmodules.vtkCommonCore
import
(
vtkCommand
,
vtkPoints
vtkPoints
)
)
from
vtkmodules.vtkCommonDataModel
import
(
from
vtkmodules.vtkCommonDataModel
import
(
...
@@ -16,7 +17,8 @@ from vtkmodules.vtkCommonDataModel import (
...
@@ -16,7 +17,8 @@ from vtkmodules.vtkCommonDataModel import (
)
)
from
vtkmodules.vtkInteractionWidgets
import
(
from
vtkmodules.vtkInteractionWidgets
import
(
vtkContourWidget
,
vtkContourWidget
,
vtkOrientedGlyphContourRepresentation
vtkOrientedGlyphContourRepresentation
,
vtkWidgetEvent
)
)
from
vtkmodules.vtkRenderingCore
import
(
from
vtkmodules.vtkRenderingCore
import
(
vtkRenderWindow
,
vtkRenderWindow
,
...
@@ -25,11 +27,29 @@ from vtkmodules.vtkRenderingCore import (
...
@@ -25,11 +27,29 @@ from vtkmodules.vtkRenderingCore import (
)
)
def
get_program_parameters
():
import
argparse
description
=
'
Contour widget.
'
epilogue
=
'''
The options -Shift or -Scale demonstrate how to override the left button press event.
If either of these are set, you cannot change the shape of the circle.
'''
parser
=
argparse
.
ArgumentParser
(
description
=
description
,
epilog
=
epilogue
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
group
=
parser
.
add_mutually_exclusive_group
()
group
.
add_argument
(
'
-Shift
'
,
action
=
'
store_true
'
,
help
=
'
Pressing the left button on a point will shift the whole circle.
'
)
group
.
add_argument
(
'
-Scale
'
,
action
=
'
store_true
'
,
help
=
'
Pressing the left button on a point will scale the whole circle.
'
)
return
parser
.
parse_args
()
def
main
():
def
main
():
colors
=
vtkNamedColors
()
colors
=
vtkNamedColors
()
# colors.SetColor('bkg', [0.1, 0.2, 0.4, 1.0])
# colors.SetColor('bkg', [0.1, 0.2, 0.4, 1.0])
args
=
get_program_parameters
()
# Create the RenderWindow, Renderer and both Actors
# Create the RenderWindow, Renderer and both Actors
renderer
=
vtkRenderer
(
background
=
colors
.
GetColor3d
(
'
MidnightBlue
'
))
renderer
=
vtkRenderer
(
background
=
colors
.
GetColor3d
(
'
MidnightBlue
'
))
render_window
=
vtkRenderWindow
(
size
=
(
600
,
600
),
window_name
=
'
ContourWidget
'
)
render_window
=
vtkRenderWindow
(
size
=
(
600
,
600
),
window_name
=
'
ContourWidget
'
)
...
@@ -45,6 +65,19 @@ def main():
...
@@ -45,6 +65,19 @@ def main():
contour_widget
=
vtkContourWidget
(
interactor
=
interactor
,
representation
=
contour_rep
)
contour_widget
=
vtkContourWidget
(
interactor
=
interactor
,
representation
=
contour_rep
)
contour_widget
.
On
()
contour_widget
.
On
()
if
args
.
Shift
:
contour_widget
.
event_translator
.
RemoveTranslation
(
vtkCommand
.
LeftButtonPressEvent
)
contour_widget
.
event_translator
.
SetTranslation
(
vtkCommand
.
LeftButtonPressEvent
,
vtkWidgetEvent
.
Translate
)
if
args
.
Scale
:
contour_widget
.
event_translator
.
RemoveTranslation
(
vtkCommand
.
LeftButtonPressEvent
)
contour_widget
.
event_translator
.
SetTranslation
(
vtkCommand
.
LeftButtonPressEvent
,
vtkWidgetEvent
.
Scale
)
# Generate a set of points arranged in a circle.
# Generate a set of points arranged in a circle.
points
=
vtkPoints
()
points
=
vtkPoints
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment