gepetto-viewer 6.0.0
An user-friendly Graphical Interface
Loading...
Searching...
No Matches
window-manager.h
Go to the documentation of this file.
1//
2// window-manager.h
3// ScneViewer
4//
5// Created by Justin Carpentier, Mathieu Geisert in November 2014.
6// Copyright (c) 2014 LAAS-CNRS. All rights reserved.
7//
8
9#ifndef GEPETTO_VIEWER_WINDOWMANAGER_HH
10#define GEPETTO_VIEWER_WINDOWMANAGER_HH
11
13
14#include <osgGA/KeySwitchMatrixManipulator>
15#include <osgViewer/Viewer>
16#include <osgViewer/ViewerEventHandlers>
17
18namespace gepetto {
19namespace viewer {
20
21DEF_CLASS_SMART_PTR(WindowManager)
22
23
25class WindowManager : public GroupNode {
26 private:
27 const int nodeTrackerManipulatorIndex;
28
30 GroupNodePtr_t scene_ptr_;
31
33 ::osgViewer::ViewerRefPtr viewer_ptr_;
34
36 ::osg::CameraRefPtr main_camera_;
37 ::osg::GraphicsContextRefPtr gc_;
38
40 ::osg::CameraRefPtr bg_camera_;
41 ::osg::Vec4 bg_color1_;
42 ::osg::Vec4 bg_color2_;
43 ::osg::GeometryRefPtr bg_geom_;
44
45 /* OSG Screen capture handler */
46 osg::ref_ptr< ::osgViewer::ScreenCaptureHandler> screen_capture_ptr_;
47
49 ::osg::CameraRefPtr hud_camera_;
50 osg::ref_ptr<osgText::Text> texts_[3][3];
51 osg::ref_ptr<osg::Geode> textGeode_;
52 bool textActive_[3][3];
53
54 bool lastSceneWasDisrty_;
55
56 osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> manipulator_ptr;
58 WindowManagerWeakPtr weak_ptr_;
59
60 void createManipulator();
61
62 void createBackground();
63 void applyBackgroundColor();
64
65 void createHUDcamera();
66
67 void init(osg::GraphicsContext* gc);
68
69 void init(osgViewer::Viewer* v, osg::GraphicsContext* gc);
70
71 void init(const unsigned int& x, const unsigned int& y,
72 const unsigned int& width, const unsigned int& height);
73
75
76 WindowManager(osgViewer::Viewer* v, osg::GraphicsContext* gc);
77
78 WindowManager(osg::GraphicsContext* gc);
79
80 WindowManager(const unsigned int& x, const unsigned int& y,
81 const unsigned int& width, const unsigned int& height);
82
83 WindowManager(const WindowManager& other);
84
86 void initWeakPtr(WindowManagerWeakPtr other_weak_ptr);
87
88 protected:
89 public:
90 enum TextAlignment { TOP = 0, CENTER = 1, BOTTOM = 2, RIGHT = 0, LEFT = 2 };
91
94 static WindowManagerPtr_t create();
95
98 static WindowManagerPtr_t create(osg::GraphicsContext* gc);
99
100 static WindowManagerPtr_t create(osgViewer::Viewer* v,
101 osg::GraphicsContext* gc);
102
106 static WindowManagerPtr_t create(const unsigned int& x, const unsigned int& y,
107 const unsigned int& width,
108 const unsigned int& height);
109
112 static WindowManagerPtr_t createCopy(WindowManagerPtr_t other);
113
116 virtual WindowManagerPtr_t clone(void) const;
117
120 WindowManagerPtr_t self(void) const;
121
124 virtual bool addNode(NodePtr_t graphical_object_ptr);
125
128 virtual GroupNodePtr_t getScene() const { return self(); }
129
132 virtual bool done();
133
136 virtual bool frame();
137
140 virtual bool run();
141
145 virtual void setWindowDimension(const osgVector2& size);
146
150 virtual void setWindowPosition(const osgVector2& position);
151
154
157
158 std::string getText(TextAlignment verticalPos,
159 TextAlignment horizontalPos) const;
160
162 void setText(TextAlignment verticalPos, TextAlignment horizontalPos,
163 const std::string& text, float size = 20);
164
166 ::osgViewer::ViewerRefPtr getViewerClone();
167
168 virtual ~WindowManager();
169
170 void captureFrame(const std::string& filename);
171
172 void startCapture(const std::string& filename, const std::string& extension);
173
175
176 bool writeNodeFile(const std::string& filename);
177
178 void setBackgroundColor1(const osg::Vec4& color) {
179 bg_color1_ = color;
180 applyBackgroundColor();
181 }
182
183 void setBackgroundColor2(const osg::Vec4& color) {
184 bg_color2_ = color;
185 applyBackgroundColor();
186 }
187
188 void getCameraTransform(osg::Vec3d& pos, osg::Quat& rot);
189 void setCameraTransform(const osg::Vec3d& pos, const osg::Quat& rot);
190
191 void attachCameraToNode(NodePtr_t node);
193};
194} /* namespace viewer */
195} /* namespace gepetto */
196
197#endif /* GEPETTO_VIEWER_WINDOWMANAGER_HH */
Definition group-node.h:19
Definition window-manager.h:25
void attachCameraToNode(NodePtr_t node)
virtual void setWindowPosition(const osgVector2 &position)
virtual WindowManagerPtr_t clone(void) const
void setCameraTransform(const osg::Vec3d &pos, const osg::Quat &rot)
WindowManagerPtr_t self(void) const
void getCameraTransform(osg::Vec3d &pos, osg::Quat &rot)
static WindowManagerPtr_t create(osgViewer::Viewer *v, osg::GraphicsContext *gc)
bool writeNodeFile(const std::string &filename)
void setBackgroundColor2(const osg::Vec4 &color)
Definition window-manager.h:183
static WindowManagerPtr_t create()
::osgViewer::ViewerRefPtr getViewerClone()
void captureFrame(const std::string &filename)
static WindowManagerPtr_t create(const unsigned int &x, const unsigned int &y, const unsigned int &width, const unsigned int &height)
virtual void setWindowDimension(const osgVector2 &size)
void startCapture(const std::string &filename, const std::string &extension)
osgVector2 getWindowPosition() const
virtual bool addNode(NodePtr_t graphical_object_ptr)
virtual GroupNodePtr_t getScene() const
Definition window-manager.h:128
void setBackgroundColor1(const osg::Vec4 &color)
Definition window-manager.h:178
osgVector2 getWindowDimension() const
TextAlignment
Definition window-manager.h:90
static WindowManagerPtr_t createCopy(WindowManagerPtr_t other)
std::string getText(TextAlignment verticalPos, TextAlignment horizontalPos) const
static WindowManagerPtr_t create(osg::GraphicsContext *gc)
void setText(TextAlignment verticalPos, TextAlignment horizontalPos, const std::string &text, float size=20)
::osg::Vec2f osgVector2
Definition config-osg.h:98
#define DEF_CLASS_SMART_PTR(className)
Definition macros.h:51
Definition action-search-bar.hh:27