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
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
f5015eb1
Commit
f5015eb1
authored
Apr 05, 2013
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
1fef425c
6a22740f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
1 deletion
+141
-1
src/core/gui/WCustomWidget.cpp
src/core/gui/WCustomWidget.cpp
+20
-1
src/core/gui/WCustomWidget.h
src/core/gui/WCustomWidget.h
+92
-0
src/qt4gui/WQtCustomDockWidget.cpp
src/qt4gui/WQtCustomDockWidget.cpp
+15
-0
src/qt4gui/WQtCustomDockWidget.h
src/qt4gui/WQtCustomDockWidget.h
+14
-0
No files found.
src/core/gui/WCustomWidget.cpp
View file @
f5015eb1
...
...
@@ -27,7 +27,8 @@
#include "WCustomWidget.h"
WCustomWidget
::
WCustomWidget
(
std
::
string
title
)
:
m_title
(
title
)
m_title
(
title
),
m_eventOccured
(
new
WBoolFlag
(
WCondition
::
SPtr
(
new
WCondition
()
),
false
)
)
{
}
...
...
@@ -40,3 +41,21 @@ std::string WCustomWidget::getTitle() const
return
m_title
;
}
const
osgGA
::
GUIEventAdapter
&
WCustomWidget
::
getEvent
(
bool
reset
)
{
if
(
reset
)
{
m_eventOccured
->
set
(
false
,
true
);
// reset and suppress condition notification
}
return
*
m_event
;
}
WCondition
::
SPtr
WCustomWidget
::
getCondition
()
const
{
return
m_eventOccured
->
getCondition
();
}
bool
WCustomWidget
::
eventOccured
()
const
{
return
m_eventOccured
->
get
(
false
);
// don't eat change
}
src/core/gui/WCustomWidget.h
View file @
f5015eb1
...
...
@@ -32,6 +32,7 @@
#include <osg/ref_ptr>
#include "../graphicsEngine/WGEViewer.h"
#include "../common/WFlag.h"
class
WGEGroupNode
;
...
...
@@ -84,12 +85,103 @@ public:
*/
virtual
std
::
string
getTitle
()
const
;
/**
* Returns the height of the viewport of the camera.
*
* \return Height in pixels.
*/
virtual
size_t
height
()
const
=
0
;
/**
* Returns the width of the viewport of the camera.
*
* \return Width in pixels.
*/
virtual
size_t
width
()
const
=
0
;
/**
* Returns the type of the last event captured by eventOccured. Meanwhile other events may have occured you may miss.
*
* \param reset If set to true, the flag is reset and the widget is ready for new events. Otherwise its just queried.
*
* \return OSG GUI event.
*/
virtual
const
osgGA
::
GUIEventAdapter
&
getEvent
(
bool
reset
=
false
);
/**
* This condition fires whenever a new event has to be handled and there was no old event left.
*
* \return \c WCondition as event notifier.
*/
virtual
WCondition
::
SPtr
getCondition
()
const
;
/**
* True when there is an unhandled event left. False otherwise.
*
* \return Bool indicating unhandled events.
*/
virtual
bool
eventOccured
()
const
;
protected:
/**
* \class WindowHandler
*
* An event handler for a custom widget.
*/
class
WindowHandler
:
public
osgGA
::
GUIEventHandler
{
public:
/**
* Constructor.
*
* \param widget The custom widget which should be notified.
*/
explicit
WindowHandler
(
WCustomWidget
*
widget
)
:
m_widget
(
widget
)
{
}
/**
* Deals with the events found by the osg.
*
* \param ea Event class for storing Keyboard, mouse and window events.
*
* \return true if the event was handled.
*/
bool
handle
(
const
osgGA
::
GUIEventAdapter
&
ea
,
osgGA
::
GUIActionAdapter
&
/* aa */
)
{
if
(
m_widget
->
eventOccured
()
)
// if there is an unhandled event proceed
{
return
false
;
}
m_widget
->
m_event
=
new
osgGA
::
GUIEventAdapter
(
ea
);
m_widget
->
m_eventOccured
->
set
(
true
);
return
true
;
}
private:
/**
* Reference to the WCustomWidget which has the condition for such events and needs to be notified.
*/
WCustomWidget
*
const
m_widget
;
};
private:
/**
* The widget's title string.
*/
std
::
string
m_title
;
/**
* Flag indicating if an GUI event has occured. If so it is stored in m_lastEventType.
*/
WBoolFlag
::
SPtr
m_eventOccured
;
/**
* Stores last GUI event.
*/
osg
::
ref_ptr
<
osgGA
::
GUIEventAdapter
>
m_event
;
};
#endif // WCUSTOMWIDGET_H
src/qt4gui/WQtCustomDockWidget.cpp
View file @
f5015eb1
...
...
@@ -42,6 +42,9 @@ WQtCustomDockWidget::WQtCustomDockWidget( std::string title, QWidget* parent, WG
// send mouse move events even if no button is pressed
getGLWidget
()
->
setMouseTracking
(
true
);
// register event handler for updating event condition
getViewer
()
->
getView
()
->
addEventHandler
(
new
WindowHandler
(
this
)
);
// register an event handler to update change conditions and event types
}
osg
::
ref_ptr
<
WGEGroupNode
>
WQtCustomDockWidget
::
getScene
()
const
...
...
@@ -69,3 +72,15 @@ bool WQtCustomDockWidget::decreaseUseCount()
}
return
shouldClose
;
}
size_t
WQtCustomDockWidget
::
height
()
const
{
return
static_cast
<
size_t
>
(
getViewer
()
->
getCamera
()
->
getViewport
()
->
height
()
);
}
size_t
WQtCustomDockWidget
::
width
()
const
{
return
static_cast
<
size_t
>
(
getViewer
()
->
getCamera
()
->
getViewport
()
->
width
()
);
}
src/qt4gui/WQtCustomDockWidget.h
View file @
f5015eb1
...
...
@@ -77,6 +77,20 @@ public:
*/
bool
decreaseUseCount
();
/**
* Returns the height of the viewport of the camera.
*
* \return Height in pixels.
*/
virtual
size_t
height
()
const
;
/**
* Returns the width of the viewport of the camera.
*
* \return Width in pixels.
*/
virtual
size_t
width
()
const
;
protected:
private:
/**
...
...
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