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
Sudhanshu Sane
VTK-m
Commits
80081f2a
Commit
80081f2a
authored
Jan 18, 2018
by
Matt Larsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding finer grain control over color bar and scalar field label
parent
3de1717b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
5 deletions
+72
-5
vtkm/rendering/ColorBarAnnotation.cxx
vtkm/rendering/ColorBarAnnotation.cxx
+59
-5
vtkm/rendering/ColorBarAnnotation.h
vtkm/rendering/ColorBarAnnotation.h
+11
-0
vtkm/rendering/View2D.cxx
vtkm/rendering/View2D.cxx
+1
-0
vtkm/rendering/View3D.cxx
vtkm/rendering/View3D.cxx
+1
-0
No files found.
vtkm/rendering/ColorBarAnnotation.cxx
View file @
80081f2a
...
...
@@ -19,6 +19,7 @@
//============================================================================
#include <vtkm/rendering/ColorBarAnnotation.h>
#include <vtkm/rendering/TextAnnotationScreen.h>
namespace
vtkm
{
...
...
@@ -27,12 +28,32 @@ namespace rendering
ColorBarAnnotation
::
ColorBarAnnotation
()
{
vtkm
::
Bounds
bounds
(
vtkm
::
Range
(
-
0.88
,
+
0.88
),
vtkm
::
Range
(
+
0.87
,
+
0.92
),
vtkm
::
Range
(
0
,
0
));
Position
=
bounds
;
Horizontal
=
true
;
FieldName
=
""
;
}
ColorBarAnnotation
::~
ColorBarAnnotation
()
{
}
void
ColorBarAnnotation
::
SetFieldName
(
const
std
::
string
&
fieldName
)
{
FieldName
=
fieldName
;
}
void
ColorBarAnnotation
::
SetPosition
(
const
vtkm
::
Bounds
&
position
)
{
Position
=
position
;
vtkm
::
Float64
x
=
Position
.
X
.
Length
();
vtkm
::
Float64
y
=
Position
.
Y
.
Length
();
if
(
x
>
y
)
Horizontal
=
true
;
else
Horizontal
=
false
;
}
void
ColorBarAnnotation
::
SetRange
(
const
vtkm
::
Range
&
range
,
vtkm
::
IdComponent
numTicks
)
{
std
::
vector
<
vtkm
::
Float64
>
positions
,
proportions
;
...
...
@@ -52,17 +73,50 @@ void ColorBarAnnotation::Render(const vtkm::rendering::Camera& camera,
const
vtkm
::
rendering
::
WorldAnnotator
&
worldAnnotator
,
vtkm
::
rendering
::
Canvas
&
canvas
)
{
vtkm
::
Bounds
bounds
(
vtkm
::
Range
(
-
0.88
,
+
0.88
),
vtkm
::
Range
(
+
0.87
,
+
0.92
),
vtkm
::
Range
(
0
,
0
));
canvas
.
AddColorBar
(
bounds
,
this
->
ColorTable
,
true
);
canvas
.
AddColorBar
(
Position
,
this
->
ColorTable
,
Horizontal
);
this
->
Axis
.
SetColor
(
canvas
.
GetForegroundColor
());
this
->
Axis
.
SetLineWidth
(
1
);
this
->
Axis
.
SetScreenPosition
(
bounds
.
X
.
Min
,
bounds
.
Y
.
Min
,
bounds
.
X
.
Max
,
bounds
.
Y
.
Min
);
this
->
Axis
.
SetMajorTickSize
(
0
,
.02
,
1.0
);
if
(
Horizontal
)
{
this
->
Axis
.
SetScreenPosition
(
Position
.
X
.
Min
,
Position
.
Y
.
Min
,
Position
.
X
.
Max
,
Position
.
Y
.
Min
);
this
->
Axis
.
SetLabelAlignment
(
TextAnnotation
::
HCenter
,
TextAnnotation
::
Top
);
this
->
Axis
.
SetMajorTickSize
(
0
,
.02
,
1.0
);
}
else
{
this
->
Axis
.
SetScreenPosition
(
Position
.
X
.
Min
,
Position
.
Y
.
Min
,
Position
.
X
.
Min
,
Position
.
Y
.
Max
);
this
->
Axis
.
SetLabelAlignment
(
TextAnnotation
::
Right
,
TextAnnotation
::
VCenter
);
this
->
Axis
.
SetMajorTickSize
(
.02
,
0.0
,
1.0
);
}
this
->
Axis
.
SetMinorTickSize
(
0
,
0
,
0
);
// no minor ticks
this
->
Axis
.
SetLabelAlignment
(
TextAnnotation
::
HCenter
,
TextAnnotation
::
Top
);
this
->
Axis
.
Render
(
camera
,
worldAnnotator
,
canvas
);
if
(
FieldName
!=
""
)
{
vtkm
::
Vec
<
vtkm
::
Float32
,
2
>
labelPos
;
if
(
Horizontal
)
{
labelPos
[
0
]
=
vtkm
::
Float32
(
Position
.
X
.
Min
);
labelPos
[
1
]
=
vtkm
::
Float32
(
Position
.
Y
.
Max
);
}
else
{
labelPos
[
0
]
=
vtkm
::
Float32
(
Position
.
X
.
Min
-
0.07
);
labelPos
[
1
]
=
vtkm
::
Float32
(
Position
.
Y
.
Max
+
0.03
);
}
vtkm
::
rendering
::
TextAnnotationScreen
var
(
FieldName
,
canvas
.
GetForegroundColor
(),
.045
f
,
// font scale
labelPos
,
0.
f
);
// rotation
var
.
Render
(
camera
,
worldAnnotator
,
canvas
);
}
}
}
}
// namespace vtkm::rendering
vtkm/rendering/ColorBarAnnotation.h
View file @
80081f2a
...
...
@@ -38,6 +38,9 @@ class VTKM_RENDERING_EXPORT ColorBarAnnotation
protected:
vtkm
::
rendering
::
ColorTable
ColorTable
;
vtkm
::
rendering
::
AxisAnnotation2D
Axis
;
vtkm
::
Bounds
Position
;
bool
Horizontal
;
std
::
string
FieldName
;
public:
ColorBarAnnotation
();
...
...
@@ -50,14 +53,22 @@ public:
this
->
ColorTable
=
colorTable
;
}
VTKM_CONT
void
SetRange
(
const
vtkm
::
Range
&
range
,
vtkm
::
IdComponent
numTicks
);
VTKM_CONT
void
SetFieldName
(
const
std
::
string
&
fieldName
);
VTKM_CONT
void
SetRange
(
vtkm
::
Float64
l
,
vtkm
::
Float64
h
,
vtkm
::
IdComponent
numTicks
)
{
this
->
SetRange
(
vtkm
::
Range
(
l
,
h
),
numTicks
);
}
VTKM_CONT
void
SetPosition
(
const
vtkm
::
Bounds
&
position
);
virtual
void
Render
(
const
vtkm
::
rendering
::
Camera
&
camera
,
const
vtkm
::
rendering
::
WorldAnnotator
&
worldAnnotator
,
vtkm
::
rendering
::
Canvas
&
canvas
);
...
...
vtkm/rendering/View2D.cxx
View file @
80081f2a
...
...
@@ -102,6 +102,7 @@ void View2D::RenderScreenAnnotations()
if
(
scene
.
GetNumberOfActors
()
>
0
)
{
//this->ColorBarAnnotation.SetAxisColor(vtkm::rendering::Color(1,1,1));
this
->
ColorBarAnnotation
.
SetFieldName
(
scene
.
GetActor
(
0
).
GetScalarField
().
GetName
());
this
->
ColorBarAnnotation
.
SetRange
(
scene
.
GetActor
(
0
).
GetScalarRange
().
Min
,
scene
.
GetActor
(
0
).
GetScalarRange
().
Max
,
5
);
this
->
ColorBarAnnotation
.
SetColorTable
(
scene
.
GetActor
(
0
).
GetColorTable
());
...
...
vtkm/rendering/View3D.cxx
View file @
80081f2a
...
...
@@ -69,6 +69,7 @@ void View3D::RenderScreenAnnotations()
if
(
this
->
GetScene
().
GetNumberOfActors
()
>
0
)
{
//this->ColorBarAnnotation.SetAxisColor(vtkm::rendering::Color(1,1,1));
this
->
ColorBarAnnotation
.
SetFieldName
(
this
->
GetScene
().
GetActor
(
0
).
GetScalarField
().
GetName
());
this
->
ColorBarAnnotation
.
SetRange
(
this
->
GetScene
().
GetActor
(
0
).
GetScalarRange
(),
5
);
this
->
ColorBarAnnotation
.
SetColorTable
(
this
->
GetScene
().
GetActor
(
0
).
GetColorTable
());
this
->
ColorBarAnnotation
.
Render
(
...
...
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