Choreonoid  1.5
SceneWidget.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_SCENE_WIDGET_H
6 #define CNOID_BASE_SCENE_WIDGET_H
7 
8 #include <QWidget>
9 #include <cnoid/SceneGraph>
10 #include <QWidget>
11 #include <QBoxLayout>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class SceneWidgetImpl;
17 class SceneRenderer;
18 class Archive;
19 class MenuManager;
20 class SceneWidgetEvent;
21 class SceneWidgetEditable;
22 class SceneWidgetRoot;
23 class Menu;
24 class InteractiveCameraTransform;
25 
26 class CNOID_EXPORT SceneWidget : public QWidget
27 {
28 public:
29  static SignalProxy<void(SceneWidget*)> sigSceneWidgetCreated();
30 
31  SceneWidget();
32  ~SceneWidget();
33 
34  static void forEachInstance(SgNode* node, boost::function<void(SceneWidget* sceneWidget, const SgNodePath& path)> function);
35 
36  SceneWidgetRoot* sceneRoot();
37  SgGroup* scene();
38 
39  SceneRenderer& renderer();
40 
41  SignalProxy<void()> sigStateChanged() const;
42 
43  void setEditMode(bool on);
44  bool isEditMode() const;
45 
46  const SceneWidgetEvent& latestEvent() const;
47 
48  enum ViewpointControlMode { THIRD_PERSON_MODE, FIRST_PERSON_MODE };
49  void setViewpointControlMode(ViewpointControlMode mode);
50  ViewpointControlMode viewpointControlMode() const;
51 
52  SgPosTransform* builtinCameraTransform(void);
53  SgPerspectiveCamera* builtinPerspectiveCamera() const;
54  SgOrthographicCamera* builtinOrthographicCamera() const;
55  bool isBuiltinCameraCurrent() const;
56  InteractiveCameraTransform* findOwnerInteractiveCameraTransform(int cameraIndex);
57 
58  void startBuiltinCameraViewChange(const Vector3& center);
59  void rotateBuiltinCameraView(double dPitch, double dYaw);
60  void translateBuiltinCameraView(const Vector3& dp_local);
61 
62  bool unproject(double x, double y, double z, Vector3& out_projected) const;
63 
64  void viewAll();
65 
66  enum PolygonMode { FILL_MODE, LINE_MODE, POINT_MODE };
67  void setPolygonMode(PolygonMode mode);
68  PolygonMode polygonMode() const;
69 
70  void setCollisionLinesVisible(bool on);
71  bool collisionLinesVisible() const;
72 
73  void setHeadLightIntensity(double value);
74  void setWorldLightIntensity(double value);
75  void setWorldLightAmbient(double value);
76  void setFloorGridSpan(double value);
77  void setFloorGridInterval(double value);
78  void setLineWidth(double value);
79  void setPointSize(double value);
80  void setNormalLength(double value);
81 
82  void setHeadLightEnabled(bool on);
83  void setHeadLightLightingFromBack(bool on);
84  void setWorldLight(bool on);
85  void setAdditionalLights(bool on);
86  void setFloorGrid(bool on);
87  void setNormalVisualization(bool on);
88  void setCoordinateAxes(bool on);
89  void setShowFPS(bool on);
90  void setNewDisplayListDoubleRenderingEnabled(bool on);
91  void setUseBufferForPicking(bool on);
92 
93  void setBackgroundColor(const Vector3& color);
94  void setColor(const Vector4& color);
95 
96  void setCameraPosition(const Vector3& eye, const Vector3& direction, const Vector3& up);
97  void setFieldOfView(double value);
98  void setHeight(double value);
99  void setNear(double value);
100  void setFar(double value);
101 
102  bool setSceneFocus(const SgNodePath& path);
103 
107  //int setCursor(const QCursor cursor);
108  //void releaseCursor(int cursorId);
109 
110  void setCursor(const QCursor cursor);
111 
112  Menu* contextMenu();
113  void showContextMenu();
115 
116  void installEventFilter(SceneWidgetEditable* filter);
117  SceneWidgetEditable* activeEventFilter();
118  void removeEventFilter(SceneWidgetEditable* filter);
119 
120  void showConfigDialog();
121  QVBoxLayout* configDialogVBox();
122 
123  bool saveImage(const std::string& filename);
124  QImage getImage();
125  void setScreenSize(int width, int height);
126 
127  void updateIndicator(const std::string& text);
128  QWidget* indicator();
129 
130  bool storeState(Archive& archive);
131  bool restoreState(const Archive& archive);
132 
133  SignalProxy<void(bool isFocused)> sigWidgetFocusChanged();
134  SignalProxy<void()> sigAboutToBeDestroyed();
135 
136 #ifdef ENABLE_SIMULATION_PROFILING
137  std::vector<std::string> profilingNames;
138  std::vector<double> profilingTimes;
139  double worldTimeStep;
140 #endif
141 
142 private:
143  SceneWidgetImpl* impl;
144 };
145 
146 
148 {
149 public:
150  SceneWidget* sceneWidget() { return sceneWidget_; }
151 private:
152  SceneWidgetRoot(SceneWidget* sceneWidget);
153  SceneWidget* sceneWidget_;
154  SgGroupPtr systemGroup;
155  friend class SceneWidgetImpl;
156 };
158 
159 }
160 
161 #endif
Definition: SceneWidget.h:26
Definition: SceneGraph.h:142
Definition: Archive.h:21
SceneWidget * sceneWidget()
Definition: SceneWidget.h:150
ViewpointControlMode
Definition: SceneWidget.h:48
Definition: SceneWidgetEditable.h:74
ref_ptr< SceneWidgetRoot > SceneWidgetRootPtr
Definition: SceneWidget.h:157
PolygonMode
Definition: SceneWidget.h:66
Definition: InteractiveCameraTransform.h:13
std::vector< SgNode * > SgNodePath
Definition: SceneGraph.h:140
Definition: SceneRenderer.h:15
Definition: SceneGraph.h:279
Definition: SceneCameras.h:58
Definition: SceneGraph.h:160
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
Definition: SceneWidget.h:147
Definition: SceneCameras.h:81
Eigen::Vector3d Vector3
Definition: EigenTypes.h:58
Eigen::Vector4d Vector4
Definition: EigenTypes.h:61
Definition: Menu.h:14
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
Definition: Signal.h:380
Definition: SceneWidgetEditable.h:16