Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
ef840dc6
Commit
ef840dc6
authored
Apr 12, 2010
by
Alexander Wiebel
Browse files
[ADD
#289
] added progress and avoided unnecessary update of the graphics
parent
b65dda88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
13 deletions
+24
-13
src/modules/vectorPlot/WMVectorPlot.cpp
src/modules/vectorPlot/WMVectorPlot.cpp
+23
-7
src/modules/vectorPlot/WMVectorPlot.h
src/modules/vectorPlot/WMVectorPlot.h
+1
-6
No files found.
src/modules/vectorPlot/WMVectorPlot.cpp
View file @
ef840dc6
...
...
@@ -128,6 +128,9 @@ void WMVectorPlot::moduleMain()
break
;
}
boost
::
shared_ptr
<
WProgress
>
progress
=
boost
::
shared_ptr
<
WProgress
>
(
new
WProgress
(
"Vector Plot"
,
2
)
);
m_progress
->
addSubProgress
(
progress
);
boost
::
shared_ptr
<
WDataSetVector
>
newDataSet
=
m_input
->
getData
();
bool
dataChanged
=
(
m_dataSet
!=
newDataSet
);
bool
dataValid
=
(
newDataSet
);
...
...
@@ -144,6 +147,8 @@ void WMVectorPlot::moduleMain()
newRootNode
->
addDrawable
(
buildPlotSlices
()
);
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
remove
(
m_rootNode
);
++*
progress
;
m_rootNode
=
newRootNode
;
m_rootNode
->
setNodeMask
(
m_active
->
get
()
?
0xFFFFFFFF
:
0x0
);
m_rootNode
->
addUpdateCallback
(
new
SafeUpdateCallback
(
this
)
);
...
...
@@ -152,6 +157,7 @@ void WMVectorPlot::moduleMain()
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
insert
(
m_rootNode
);
}
progress
->
finish
();
}
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
remove
(
m_rootNode
);
...
...
@@ -159,6 +165,9 @@ void WMVectorPlot::moduleMain()
osg
::
ref_ptr
<
osg
::
Geometry
>
WMVectorPlot
::
buildPlotSlices
()
{
boost
::
shared_ptr
<
WProgress
>
progress
=
boost
::
shared_ptr
<
WProgress
>
(
new
WProgress
(
"Vector Plot"
,
4
)
);
m_progress
->
addSubProgress
(
progress
);
wmath
::
WPosition
current
=
WKernel
::
getRunningKernel
()
->
getSelectionManager
()
->
getCrosshair
()
->
getPosition
();
int
xPos
=
current
[
0
];
...
...
@@ -209,7 +218,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
-
xx
,
y
+
0.5
f
-
yy
,
zPos
+
0.5
f
-
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
y
+
0.5
f
+
yy
,
zPos
+
0.5
f
+
zz
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -226,7 +235,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
y
+
0.5
f
+
yy
,
zPos
+
0.4
f
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
-
xx
,
y
+
0.5
f
-
yy
,
zPos
+
0.6
f
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
y
+
0.5
f
+
yy
,
zPos
+
0.6
f
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -245,6 +254,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*
progress
;
if
(
m_showonY
->
get
()
)
{
for
(
int
x
=
0
;
x
<
maxX
;
++
x
)
...
...
@@ -259,7 +270,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
-
xx
,
yPos
+
0.5
f
-
yy
,
z
+
0.5
f
-
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
yPos
+
0.5
f
+
yy
,
z
+
0.5
f
+
zz
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -276,7 +287,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
yPos
+
0.4
f
,
z
+
0.5
f
+
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
-
xx
,
yPos
+
0.6
f
,
z
+
0.5
f
-
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
x
+
0.5
f
+
xx
,
yPos
+
0.6
f
,
z
+
0.5
f
+
zz
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -295,6 +306,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*
progress
;
if
(
m_showonX
->
get
()
)
{
for
(
int
y
=
0
;
y
<
maxY
;
++
y
)
...
...
@@ -309,7 +322,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
{
vertices
->
push_back
(
osg
::
Vec3
(
xPos
+
0.5
f
+
xx
,
y
+
0.5
f
+
yy
,
z
+
0.5
f
+
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
xPos
+
0.5
f
-
xx
,
y
+
0.5
f
-
yy
,
z
+
0.5
f
-
zz
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -326,7 +339,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
vertices
->
push_back
(
osg
::
Vec3
(
xPos
+
0.4
f
,
y
+
0.5
f
-
yy
,
z
+
0.5
f
-
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
xPos
+
0.6
f
,
y
+
0.5
f
+
yy
,
z
+
0.5
f
+
zz
)
);
vertices
->
push_back
(
osg
::
Vec3
(
xPos
+
0.6
f
,
y
+
0.5
f
-
yy
,
z
+
0.5
f
-
zz
)
);
if
(
m_coloringMode
->
get
()
)
if
(
m_coloringMode
->
get
(
true
)
)
{
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
colors
->
push_back
(
osg
::
Vec4
(
fabs
(
xx
),
fabs
(
yy
),
fabs
(
zz
),
1.0
)
);
...
...
@@ -345,6 +358,7 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
}
}
++*
progress
;
for
(
size_t
i
=
0
;
i
<
vertices
->
size
();
++
i
)
{
...
...
@@ -360,6 +374,8 @@ osg::ref_ptr<osg::Geometry> WMVectorPlot::buildPlotSlices()
geometry
->
setColorArray
(
colors
);
geometry
->
setColorBinding
(
osg
::
Geometry
::
BIND_PER_VERTEX
);
progress
->
finish
();
return
geometry
;
}
...
...
@@ -369,7 +385,7 @@ void WMVectorPlot::SafeUpdateCallback::operator()( osg::Node* node, osg::NodeVis
wmath
::
WPosition
current
=
WKernel
::
getRunningKernel
()
->
getSelectionManager
()
->
getCrosshair
()
->
getPosition
();
wmath
::
WPosition
old
(
m_module
->
m_xPos
->
get
(),
m_module
->
m_yPos
->
get
(),
m_module
->
m_zPos
->
get
()
);
if
(
(
old
!=
current
)
||
m_module
->
m_coloringMode
->
changed
()
||
m_module
->
m_aColor
->
changed
()
||
m_initialUpdate
)
if
(
(
old
!=
current
)
||
m_module
->
m_coloringMode
->
changed
()
||
m_module
->
m_aColor
->
changed
()
)
{
osg
::
ref_ptr
<
osg
::
Drawable
>
old
=
osg
::
ref_ptr
<
osg
::
Drawable
>
(
m_module
->
m_rootNode
->
getDrawable
(
0
)
);
m_module
->
m_rootNode
->
removeDrawable
(
old
);
...
...
src/modules/vectorPlot/WMVectorPlot.h
View file @
ef840dc6
...
...
@@ -165,7 +165,7 @@ private:
*
* \param module just set the creating module as pointer for later reference.
*/
explicit
SafeUpdateCallback
(
WMVectorPlot
*
module
)
:
m_module
(
module
)
,
m_initialUpdate
(
true
)
explicit
SafeUpdateCallback
(
WMVectorPlot
*
module
)
:
m_module
(
module
)
{
};
...
...
@@ -181,11 +181,6 @@ private:
* Pointer used to access members of the module to modify the node.
*/
WMVectorPlot
*
m_module
;
/**
* Denotes whether the update callback is called the first time.
*/
bool
m_initialUpdate
;
};
};
...
...
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