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
fa3d8465
Commit
fa3d8465
authored
Jan 11, 2010
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CHANGE] pickHandler can return the position as WPosition now.
parent
57ffaebd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
19 deletions
+42
-19
src/graphicsEngine/WGEViewer.cpp
src/graphicsEngine/WGEViewer.cpp
+3
-3
src/graphicsEngine/WGEViewer.h
src/graphicsEngine/WGEViewer.h
+3
-3
src/graphicsEngine/WPickHandler.cpp
src/graphicsEngine/WPickHandler.cpp
+10
-0
src/graphicsEngine/WPickHandler.h
src/graphicsEngine/WPickHandler.h
+18
-1
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
...s/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
+4
-12
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
...les/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
+4
-0
No files found.
src/graphicsEngine/WGEViewer.cpp
View file @
fa3d8465
...
...
@@ -70,8 +70,8 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, i
m_View
->
setLightingMode
(
osg
::
View
::
HEADLIGHT
);
// this is the default anyway
m_pickHandler
=
osg
::
ref_ptr
<
WPickHandler
>
(
new
WPickHandler
()
);
m_View
->
addEventHandler
(
m_pickHandler
);
m_pickHandler
=
boost
::
shared_ptr
<
WPickHandler
>
(
new
WPickHandler
()
);
m_View
->
addEventHandler
(
osg
::
ref_ptr
<
WPickHandler
>
(
m_pickHandler
.
get
()
)
);
}
catch
(
...
)
{
...
...
@@ -151,7 +151,7 @@ std::string WGEViewer::getName() const
return
m_name
;
}
osg
::
ref_ptr
<
WPickHandler
>
WGEViewer
::
getPickHandler
()
boost
::
shared_ptr
<
WPickHandler
>
WGEViewer
::
getPickHandler
()
{
return
m_pickHandler
;
}
src/graphicsEngine/WGEViewer.h
View file @
fa3d8465
...
...
@@ -160,7 +160,7 @@ public:
*
* \return the pick handler
*/
osg
::
ref_ptr
<
WPickHandler
>
getPickHandler
();
boost
::
shared_ptr
<
WPickHandler
>
getPickHandler
();
protected:
...
...
@@ -180,9 +180,9 @@ protected:
WGECamera
::
ProjectionMode
m_projectionMode
;
/**
*
Reference
to the pick handler of the viewer.
*
Pointer
to the pick handler of the viewer.
*/
osg
::
ref
_ptr
<
WPickHandler
>
m_pickHandler
;
boost
::
shared
_ptr
<
WPickHandler
>
m_pickHandler
;
private:
};
...
...
src/graphicsEngine/WPickHandler.cpp
View file @
fa3d8465
...
...
@@ -25,6 +25,8 @@
#include <iostream>
#include <string>
#include <osg/Vec3>
#include "WPickHandler.h"
WPickHandler
::~
WPickHandler
()
...
...
@@ -36,6 +38,11 @@ std::string WPickHandler::getHitResult()
return
m_hitResult
;
}
wmath
::
WPosition
WPickHandler
::
getHitPosition
()
{
return
m_hitPosGlobal
;
}
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
WPickHandler
::
getPickSignal
()
{
return
&
m_pickSignal
;
...
...
@@ -124,6 +131,9 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
os
<<
" world coords vertex("
<<
hitr
->
getWorldIntersectPoint
()
<<
")"
<<
" normal("
<<
hitr
->
getWorldIntersectNormal
()
<<
")"
<<
std
::
endl
;
m_hitResult
+=
os
.
str
();
osg
::
Vec3
globalHit
=
hitr
->
getWorldIntersectPoint
();
m_hitPosGlobal
=
wmath
::
WPosition
(
globalHit
[
0
],
globalHit
[
1
],
globalHit
[
2
]
);
}
m_pickSignal
(
getHitResult
()
);
}
src/graphicsEngine/WPickHandler.h
View file @
fa3d8465
...
...
@@ -44,9 +44,10 @@
#include <osg/Camera>
#include <osg/io_utils>
#include <osg/ShapeDrawable>
#include <osgText/Text>
#include "../math/WPosition.h"
/**
* class to handle events with a pick
*/
...
...
@@ -58,9 +59,19 @@ public:
*/
virtual
~
WPickHandler
();
/**
* Deals with the events found by the osg.
*/
bool
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
aa
);
/**
* Send a pick signal with the pick information as string
*/
virtual
void
pick
(
osgViewer
::
View
*
view
,
const
osgGA
::
GUIEventAdapter
&
ea
);
/**
* Send a pick signal with the string "unpick"
*/
virtual
void
unpick
();
/**
...
...
@@ -68,6 +79,11 @@ public:
*/
std
::
string
getHitResult
();
/**
* Returns the position where the first object was picked.
*/
wmath
::
WPosition
getHitPosition
();
/**
* returns the m_pickSignal to for registering to it.
*/
...
...
@@ -75,6 +91,7 @@ public:
protected:
std
::
string
m_hitResult
;
//!< Textual representation of the result of a pick.
wmath
::
WPosition
m_hitPosGlobal
;
//!< Global coordinates of the first hit of the pick.
private:
boost
::
signals2
::
signal1
<
void
,
std
::
string
>
m_pickSignal
;
//!< One can register to this signal to receive pick events.
...
...
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.cpp
View file @
fa3d8465
...
...
@@ -86,11 +86,13 @@ void WMPrototypeBoxManipulation::moduleMain()
{
// use the m_input "data changed" flag
m_moduleState
.
add
(
m_input
->
getDataChangedCondition
()
);
WKernel
::
getRunningKernel
()
->
getGui
()
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMPrototypeBoxManipulation
::
updateGFX
,
this
,
_1
)
);
// 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
)
);
m_pickHandler
=
viewer
->
getPickHandler
();
m_pickHandler
->
getPickSignal
()
->
connect
(
boost
::
bind
(
&
WMPrototypeBoxManipulation
::
updateGFX
,
this
,
_1
)
);
// signal ready state
ready
();
...
...
@@ -270,15 +272,6 @@ void WMPrototypeBoxManipulation::draw( wmath::WPosition minPos, wmath::WPosition
debugLog
()
<<
"Intial draw "
<<
std
::
endl
;
}
wmath
::
WPosition
getPosFromText
(
std
::
string
posText
)
{
std
::
vector
<
std
::
string
>
coordText
=
string_utils
::
tokenize
(
posText
);
double
x
=
boost
::
lexical_cast
<
double
>
(
coordText
[
0
]
);
double
y
=
boost
::
lexical_cast
<
double
>
(
coordText
[
1
]
);
double
z
=
boost
::
lexical_cast
<
double
>
(
coordText
[
2
]
);
return
wmath
::
WPosition
(
x
,
y
,
z
);
}
void
WMPrototypeBoxManipulation
::
updateGFX
(
std
::
string
text
)
{
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
;
...
...
@@ -287,8 +280,7 @@ void WMPrototypeBoxManipulation::updateGFX( std::string text )
if
(
text
.
find
(
"Object "
)
!=
std
::
string
::
npos
&&
text
.
find
(
"
\"
Box
\"
"
)
!=
std
::
string
::
npos
)
{
std
::
string
posText
=
string_utils
::
tokenize
(
text
,
"()"
)[
1
];
wmath
::
WPosition
newPos
=
getPosFromText
(
posText
);
wmath
::
WPosition
newPos
(
m_pickHandler
->
getHitPosition
()
);
if
(
m_isPicked
)
{
wmath
::
WVector3D
moveVec
=
m_pickedPosition
-
newPos
;
...
...
src/modules/prototypeBoxManipulation/WMPrototypeBoxManipulation.h
View file @
fa3d8465
...
...
@@ -38,6 +38,8 @@
#include "../../math/WVector3D.h"
class
WPickHandler
;
/**
* Prototype module
*/
...
...
@@ -121,6 +123,8 @@ private:
wmath
::
WPosition
m_pickedPosition
;
//!< Caches the old picked position to a allow for cmoparison
wmath
::
WPosition
m_minPos
;
//!< The minimum position of the box
wmath
::
WPosition
m_maxPos
;
//!< The maximum position of the box
boost
::
shared_ptr
<
WPickHandler
>
m_pickHandler
;
//!< A pointer to the pick handler used to get gui events for moving the box.
};
/**
...
...
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