Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
1118440f
Commit
1118440f
authored
Jul 14, 2015
by
David C. Lonie
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ScalarBarRepresentation orientation set-able.
Change the auto-orientation functionality to be optional.
parent
23dff2bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
33 deletions
+65
-33
Interaction/Widgets/vtkScalarBarRepresentation.cxx
Interaction/Widgets/vtkScalarBarRepresentation.cxx
+52
-33
Interaction/Widgets/vtkScalarBarRepresentation.h
Interaction/Widgets/vtkScalarBarRepresentation.h
+13
-0
No files found.
Interaction/Widgets/vtkScalarBarRepresentation.cxx
View file @
1118440f
...
...
@@ -40,6 +40,8 @@ vtkScalarBarRepresentation::vtkScalarBarRepresentation()
this
->
PositionCoordinate
->
SetValue
(
0.82
,
0.1
);
this
->
Position2Coordinate
->
SetValue
(
0.17
,
0.8
);
this
->
AutoOrient
=
true
;
this
->
ScalarBarActor
=
NULL
;
vtkScalarBarActor
*
actor
=
vtkScalarBarActor
::
New
();
this
->
SetScalarBarActor
(
actor
);
...
...
@@ -90,9 +92,10 @@ void vtkScalarBarRepresentation::PrintSelf(ostream &os, vtkIndent indent)
//-----------------------------------------------------------------------------
void
vtkScalarBarRepresentation
::
SetOrientation
(
int
orientation
)
{
if
(
this
->
ScalarBarActor
)
if
(
this
->
ScalarBarActor
&&
this
->
ScalarBarActor
->
GetOrientation
()
!=
orientation
)
{
this
->
S
calarBarActor
->
Set
Orientation
(
orientation
);
this
->
S
wap
Orientation
();
}
}
...
...
@@ -126,6 +129,36 @@ void vtkScalarBarRepresentation::WidgetInteraction(double eventPos[2])
this
->
Superclass
::
WidgetInteraction
(
eventPos
);
// Check to see if we need to change the orientation.
if
(
this
->
AutoOrient
)
{
double
*
fpos1
=
this
->
PositionCoordinate
->
GetValue
();
double
*
fpos2
=
this
->
Position2Coordinate
->
GetValue
();
double
center
[
2
];
center
[
0
]
=
fpos1
[
0
]
+
0.5
*
fpos2
[
0
];
center
[
1
]
=
fpos1
[
1
]
+
0.5
*
fpos2
[
1
];
if
(
fabs
(
center
[
0
]
-
0.5
)
>
0.2
+
fabs
(
center
[
1
]
-
0.5
))
{
// Close enough to left/right to be swapped to vertical
if
(
this
->
ScalarBarActor
->
GetOrientation
()
==
VTK_ORIENT_HORIZONTAL
)
{
this
->
SwapOrientation
();
}
}
else
if
(
fabs
(
center
[
1
]
-
0.5
)
>
0.2
+
fabs
(
center
[
0
]
-
0.5
))
{
// Close enough to left/right to be swapped to horizontal
if
(
this
->
ScalarBarActor
->
GetOrientation
()
==
VTK_ORIENT_VERTICAL
)
{
this
->
SwapOrientation
();
}
}
}
// if this->AutoOrient
}
//-----------------------------------------------------------------------------
void
vtkScalarBarRepresentation
::
SwapOrientation
()
{
double
*
fpos1
=
this
->
PositionCoordinate
->
GetValue
();
double
*
fpos2
=
this
->
Position2Coordinate
->
GetValue
();
double
par1
[
2
];
...
...
@@ -137,43 +170,30 @@ void vtkScalarBarRepresentation::WidgetInteraction(double eventPos[2])
double
center
[
2
];
center
[
0
]
=
fpos1
[
0
]
+
0.5
*
fpos2
[
0
];
center
[
1
]
=
fpos1
[
1
]
+
0.5
*
fpos2
[
1
];
bool
orientationSwapped
=
false
;
if
(
fabs
(
center
[
0
]
-
0.5
)
>
0.2
+
fabs
(
center
[
1
]
-
0.5
))
// Change the corners to effectively rotate 90 degrees.
par2
[
0
]
=
center
[
0
]
+
center
[
1
]
-
par1
[
1
];
par2
[
1
]
=
center
[
1
]
+
center
[
0
]
-
par1
[
0
];
par1
[
0
]
=
2
*
center
[
0
]
-
par2
[
0
];
par1
[
1
]
=
2
*
center
[
1
]
-
par2
[
1
];
if
(
this
->
ScalarBarActor
->
GetOrientation
()
==
VTK_ORIENT_HORIZONTAL
)
{
// Close enough to left/right to be swapped to vertical
if
(
this
->
ScalarBarActor
->
GetOrientation
()
==
VTK_ORIENT_HORIZONTAL
)
{
this
->
ScalarBarActor
->
SetOrientation
(
VTK_ORIENT_VERTICAL
);
orientationSwapped
=
true
;
}
this
->
ScalarBarActor
->
SetOrientation
(
VTK_ORIENT_VERTICAL
);
}
else
if
(
fabs
(
center
[
1
]
-
0.5
)
>
0.2
+
fabs
(
center
[
0
]
-
0.5
))
else
{
// Close enough to left/right to be swapped to horizontal
if
(
this
->
ScalarBarActor
->
GetOrientation
()
==
VTK_ORIENT_VERTICAL
)
{
this
->
ScalarBarActor
->
SetOrientation
(
VTK_ORIENT_HORIZONTAL
);
orientationSwapped
=
true
;
}
this
->
ScalarBarActor
->
SetOrientation
(
VTK_ORIENT_HORIZONTAL
);
}
if
(
orientationSwapped
)
{
// Change the corners to effectively rotate 90 degrees.
par2
[
0
]
=
center
[
0
]
+
center
[
1
]
-
par1
[
1
];
par2
[
1
]
=
center
[
1
]
+
center
[
0
]
-
par1
[
0
];
par1
[
0
]
=
2
*
center
[
0
]
-
par2
[
0
];
par1
[
1
]
=
2
*
center
[
1
]
-
par2
[
1
];
this
->
PositionCoordinate
->
SetValue
(
par1
[
0
],
par1
[
1
]);
this
->
Position2Coordinate
->
SetValue
(
par2
[
0
]
-
par1
[
0
],
par2
[
1
]
-
par1
[
1
]);
this
->
PositionCoordinate
->
SetValue
(
par1
[
0
],
par1
[
1
]);
this
->
Position2Coordinate
->
SetValue
(
par2
[
0
]
-
par1
[
0
],
par2
[
1
]
-
par1
[
1
]);
std
::
swap
(
this
->
ShowHorizontalBorder
,
this
->
ShowVerticalBorder
);
std
::
swap
(
this
->
ShowHorizontalBorder
,
this
->
ShowVerticalBorder
);
this
->
Modified
();
this
->
UpdateShowBorder
();
this
->
BuildRepresentation
();
}
this
->
Modified
();
this
->
UpdateShowBorder
();
this
->
BuildRepresentation
();
}
//-----------------------------------------------------------------------------
...
...
@@ -253,4 +273,3 @@ int vtkScalarBarRepresentation::HasTranslucentPolygonalGeometry()
}
return
result
;
}
Interaction/Widgets/vtkScalarBarRepresentation.h
View file @
1118440f
...
...
@@ -76,6 +76,12 @@ public:
virtual
int
RenderTranslucentPolygonalGeometry
(
vtkViewport
*
);
virtual
int
HasTranslucentPolygonalGeometry
();
// Description:
// If true, the orientation will be updated based on the widget's position.
// Default is true.
vtkSetMacro
(
AutoOrient
,
bool
)
vtkGetMacro
(
AutoOrient
,
bool
)
// Description:
// Get/Set the orientation.
void
SetOrientation
(
int
orient
);
...
...
@@ -85,7 +91,14 @@ protected:
vtkScalarBarRepresentation
();
~
vtkScalarBarRepresentation
();
// Description:
// Change horizontal <--> vertical orientation, rotate the corners of the
// bar to preserve size, and swap the resize handle locations.
void
SwapOrientation
();
vtkScalarBarActor
*
ScalarBarActor
;
bool
AutoOrient
;
private:
vtkScalarBarRepresentation
(
const
vtkScalarBarRepresentation
&
);
// Not implemented
void
operator
=
(
const
vtkScalarBarRepresentation
&
);
// Not implemented
...
...
Allison Vacanti
@allisonvacanti
mentioned in commit
8b3acf1a
·
Jul 20, 2015
mentioned in commit
8b3acf1a
mentioned in commit 8b3acf1a67973c2c8f7aee0084c38c1b059b8c19
Toggle commit list
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