ScenegraphWidget.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SceneEditor
19  * @date 2015
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 /* Qt headers */
27 #include <QWidget>
28 #include <QDragMoveEvent>
29 #include <QDragEnterEvent>
30 #include <QDropEvent>
31 
32 /* coin headers */
33 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
34 #include <Inventor/nodes/SoPerspectiveCamera.h>
35 
36 #include "../controller/Controller.h"
37 #include "../scene3D/SceneViewer.h"
38 
39 using SceneViewerPtr = std::shared_ptr<scene3D::SceneViewer>;
40 
41 namespace gui
42 {
43  /**
44  * This class provides a widget which holds a scene3D::SceneViewer in which the scene graph is rendered.
45  *
46  * @see scene3D::SceneViewer
47  *
48  */
49  class ScenegraphWidget : public QWidget
50  {
51  Q_OBJECT
52  public:
53 
54  /**
55  * Constructor.
56  * Constructs a scene graph widget.
57  * Expects a controller::ControllerPtr.
58  *
59  * @param control shared pointer to controller::controller
60  * @param parent parent widget
61  *
62  */
63  explicit ScenegraphWidget(const controller::ControllerPtr control, QWidget* parent = 0);
64 
65  /**
66  * Destructor.
67  *
68  */
69  ~ScenegraphWidget() override;
70 
71  void postDocking();
72 
73  protected:
74 
75  /**
76  * Reimplements the function Qt::QWidget:dropEvent().
77  *
78  * This event handler is called when the drag is dropped on this widget.
79  * The event is passed in the <i>event</i> parameter.
80  *
81  * @param dropEvent Qt::DropEvent
82  * @see Qt::DropEvent
83  * @see Qt::QWidget:dropEvent()
84  *
85  */
86  void dropEvent(QDropEvent* de) override;
87 
88  /**
89  * Reimplements the function Qt::QWidget:dragMoveEvent();.
90  *
91  * This event handler is called if a drag is in progress, and when any of the following conditions occur:
92  * the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus.
93  * The event is passed in the <i>event</i> parameter.
94  *
95  * @param dropEvent Qt::QDragMoveEvent
96  * @see Qt::QDragMoveEvent
97  * @see Qt::QWidget:dragMoveEvent();
98  *
99  */
100  void dragMoveEvent(QDragMoveEvent* de) override;
101 
102  /**
103  * Reimplements the function Qt::QWidget:dragEnterEvent();.
104  *
105  * This event handler is called when a drag is in progress and the mouse enters this widget.
106  * The event is passed in the <i>event</i> parameter.
107  *
108  * @param dropEvent Qt::DragEnterEvent
109  * @see Qt::QDragEnterEvent
110  * @see Qt::QWidget:dragEnterEvent();
111  *
112  */
113  void dragEnterEvent(QDragEnterEvent* event) override;
114 
115  Q_SIGNALS:
116 
117  public Q_SLOTS:
118  void cameraViewAll();
119  void cameraViewFromX();
120  void cameraViewFromNegX();
121  void cameraViewFromY();
122  void cameraViewFromNegY();
123  void cameraViewFromZ();
124  void cameraViewFromNegZ();
125  void selectToggleAll();
126  void copy();
127  void paste();
128  void duplicate();
129  void resetRotation();
130  void resetTranslation();
131 
132  private:
134  SceneViewerPtr viewer;
135  SoPerspectiveCamera* camera;
136  controller::ControllerPtr mainController;
137 
138  std::shared_ptr<std::vector<controller::AddOperationPtr> > copyBuffer;
139  };
140 }
141 
gui::ScenegraphWidget::dropEvent
void dropEvent(QDropEvent *de) override
Reimplements the function Qt::QWidget:dropEvent().
Definition: ScenegraphWidget.cpp:422
gui::ScenegraphWidget::cameraViewFromX
void cameraViewFromX()
Definition: ScenegraphWidget.cpp:291
gui::ScenegraphWidget::cameraViewFromY
void cameraViewFromY()
Definition: ScenegraphWidget.cpp:313
gui::ScenegraphWidget::resetTranslation
void resetTranslation()
Definition: ScenegraphWidget.cpp:192
gui::ScenegraphWidget::cameraViewFromNegX
void cameraViewFromNegX()
Definition: ScenegraphWidget.cpp:302
gui::ScenegraphWidget::cameraViewAll
void cameraViewAll()
Definition: ScenegraphWidget.cpp:283
gui::ScenegraphWidget::dragMoveEvent
void dragMoveEvent(QDragMoveEvent *de) override
Reimplements the function Qt::QWidget:dragMoveEvent();.
Definition: ScenegraphWidget.cpp:403
controller::ControllerWeakPtr
std::weak_ptr< Controller > ControllerWeakPtr
Definition: ClassDefinitions.h:42
gui::ScenegraphWidget::cameraViewFromNegY
void cameraViewFromNegY()
Definition: ScenegraphWidget.cpp:324
gui::ScenegraphWidget::cameraViewFromNegZ
void cameraViewFromNegZ()
Definition: ScenegraphWidget.cpp:346
gui::ScenegraphWidget::selectToggleAll
void selectToggleAll()
Definition: ScenegraphWidget.cpp:357
controller::ControllerPtr
std::shared_ptr< Controller > ControllerPtr
Definition: ClassDefinitions.h:41
gui::ScenegraphWidget
This class provides a widget which holds a scene3D::SceneViewer in which the scene graph is rendered.
Definition: ScenegraphWidget.h:49
gui::ScenegraphWidget::paste
void paste()
Definition: ScenegraphWidget.cpp:231
gui::ScenegraphWidget::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Reimplements the function Qt::QWidget:dragEnterEvent();.
Definition: ScenegraphWidget.cpp:409
SceneViewerPtr
std::shared_ptr< scene3D::SceneViewer > SceneViewerPtr
Definition: ScenegraphWidget.h:39
gui::ScenegraphWidget::cameraViewFromZ
void cameraViewFromZ()
Definition: ScenegraphWidget.cpp:335
gui::ScenegraphWidget::duplicate
void duplicate()
Definition: ScenegraphWidget.cpp:260
gui::ScenegraphWidget::copy
void copy()
Definition: ScenegraphWidget.cpp:212
gui::ScenegraphWidget::postDocking
void postDocking()
Definition: ScenegraphWidget.cpp:149
gui::ScenegraphWidget::~ScenegraphWidget
~ScenegraphWidget() override
Destructor.
Definition: ScenegraphWidget.cpp:145
control
This file is part of ArmarX.
gui::ScenegraphWidget::resetRotation
void resetRotation()
Definition: ScenegraphWidget.cpp:171
gui::ScenegraphWidget::ScenegraphWidget
ScenegraphWidget(const controller::ControllerPtr control, QWidget *parent=0)
Constructor.
Definition: ScenegraphWidget.cpp:40