Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
0123a060
Commit
0123a060
authored
Jan 09, 2010
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX
#214
] get pick signal directly from GE now. Thus we do not have the
pick delay anymore.
parent
ead0ee25
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
15 deletions
+46
-15
src/graphicsEngine/WPickHandler.cpp
src/graphicsEngine/WPickHandler.cpp
+10
-6
src/graphicsEngine/WPickHandler.h
src/graphicsEngine/WPickHandler.h
+17
-4
src/modules/hud/WMHud.cpp
src/modules/hud/WMHud.cpp
+4
-1
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
...s/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
+12
-2
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
...les/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
+3
-2
No files found.
src/graphicsEngine/WPickHandler.cpp
View file @
0123a060
...
...
@@ -27,10 +27,6 @@
#include "WPickHandler.h"
WPickHandler
::
WPickHandler
()
{
}
WPickHandler
::~
WPickHandler
()
{
}
...
...
@@ -40,18 +36,25 @@ std::string WPickHandler::getHitResult()
return
m_hitResult
;
}
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
WPickHandler
::
getPickSignal
()
{
return
&
m_pickSignal
;
}
bool
WPickHandler
::
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
)
{
switch
(
ea
.
getEventType
()
)
{
case
(
osgGA
::
GUIEventAdapter
::
PUSH
):
case
osgGA
::
GUIEventAdapter
::
PUSH
:
// Mousebutton pushed
{
osgViewer
::
View
*
view
=
static_cast
<
osgViewer
::
View
*
>
(
&
aa
);
if
(
view
)
{
pick
(
view
,
ea
);
}
return
false
;
}
case
(
osgGA
::
GUIEventAdapter
::
KEYDOWN
):
case
osgGA
::
GUIEventAdapter
::
KEYDOWN
:
// Key on keyboard pushed.
{
if
(
ea
.
getKey
()
==
'c'
)
{
...
...
@@ -99,4 +102,5 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
<<
std
::
endl
;
m_hitResult
+=
os
.
str
();
}
m_pickSignal
(
getHitResult
()
);
}
src/graphicsEngine/WPickHandler.h
View file @
0123a060
...
...
@@ -28,6 +28,8 @@
#include <sstream>
#include <string>
#include <boost/signals2/signal.hpp>
#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
...
...
@@ -51,19 +53,30 @@
class
WPickHandler
:
public
osgGA
::
GUIEventHandler
{
public:
WPickHandler
();
/**
* Virtual destructor needed because of virtual fuction.
*/
virtual
~
WPickHandler
();
bool
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
);
virtual
void
pick
(
osgViewer
::
View
*
view
,
const
osgGA
::
GUIEventAdapter
&
ea
);
/**
* Gives information about the picked object.
*/
std
::
string
getHitResult
();
/**
* returns the m_pickSignal to for registering to it.
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getPickSignal
();
protected:
std
::
string
m_hitResult
;
std
::
string
m_hitResult
;
//!< Textual representation of the result of a pick.
private:
boost
::
signals2
::
signal1
<
void
,
std
::
string
>
m_pickSignal
;
//!< One can register to this signal to receive pick events.
};
#endif // WPICKHANDLER_H
src/modules/hud/WMHud.cpp
View file @
0123a060
...
...
@@ -186,7 +186,10 @@ void WMHud::init()
m_rootNode
->
setNodeMask
(
0x0
);
}
WKernel
::
getRunningKernel
()
->
getGui
()
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMHud
::
updatePickText
,
this
,
_1
)
);
// connect updateGFX with picking
boost
::
shared_ptr
<
WGEViewer
>
viewer
=
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getViewerByName
(
"main"
);
assert
(
viewer
);
viewer
->
getPickHandler
()
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMHud
::
updatePickText
,
this
,
_1
)
);
}
void
WMHud
::
updatePickText
(
std
::
string
text
)
...
...
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
View file @
0123a060
...
...
@@ -82,6 +82,11 @@ void WMPrototypeBoxManipulation::moduleMain()
// use the m_input "data changed" flag
m_moduleState
.
add
(
m_input
->
getDataChangedCondition
()
);
// connect updateGFX with picking
boost
::
shared_ptr
<
WGEViewer
>
viewer
=
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getViewerByName
(
"main"
);
assert
(
viewer
);
viewer
->
getPickHandler
()
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMPrototypeBoxManipulation
::
updateGFX
,
this
,
_1
)
);
// signal ready state
ready
();
...
...
@@ -253,17 +258,22 @@ void WMPrototypeBoxManipulation::draw()
osg
::
ref_ptr
<
osg
::
LightModel
>
lightModel
=
new
osg
::
LightModel
();
lightModel
->
setTwoSided
(
true
);
state
->
setAttributeAndModes
(
lightModel
.
get
(),
osg
::
StateAttribute
::
ON
);
state
->
setMode
(
GL_BLEND
,
osg
::
StateAttribute
::
ON
);
state
->
setMode
(
GL_BLEND
,
osg
::
StateAttribute
::
ON
);
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
addChild
(
m_geode
);
debugLog
()
<<
"Intial draw "
<<
std
::
endl
;
}
void
WMPrototypeBoxManipulation
::
updateGFX
()
void
WMPrototypeBoxManipulation
::
updateGFX
(
std
::
string
text
)
{
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
;
slock
=
boost
::
shared_lock
<
boost
::
shared_mutex
>
(
m_updateLock
);
if
(
text
.
find
(
"Object "
)
!=
std
::
string
::
npos
&&
text
.
find
(
"
\"
Box
\"
"
)
!=
std
::
string
::
npos
)
{
std
::
cout
<<
"Picked Box with Info: "
<<
text
<<
std
::
endl
;
}
slock
.
unlock
();
}
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
View file @
0123a060
...
...
@@ -81,8 +81,9 @@ public:
/**
* updates the graphics
* \param text text info from pick
*/
void
updateGFX
();
void
updateGFX
(
std
::
string
text
);
protected:
/**
...
...
@@ -146,7 +147,7 @@ inline void BoxNodeCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
{
if
(
m_module
)
{
m_module
->
updateGFX
();
m_module
->
updateGFX
(
"..."
);
}
traverse
(
node
,
nv
);
}
...
...
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