ViewerWidget.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
27 
28 #include <QWidget>
29 
30 #define ARMARX_VIEWER_NAME "Visualization.3D Viewer"
31 
32 class SoSeparator;
33 
34 class QComboBox;
35 class QPushButton;
36 class QLabel;
37 class QToolBar;
38 class Ui_Viewer3DWidget;
39 class Ui_ViewerWidgetConfigDialog;
40 
41 namespace armarx
42 {
43  struct CameraPose
44  {
45  float position[3];
46  float orientation[4];
47  float focalDistance = 5.f;
48  };
49 
50  struct Viewer3DInfo;
51 
52  /**
53  * \brief The Viewer3DWidget class
54  */
56  {
57  Q_OBJECT
58 
59  public:
60  explicit Viewer3DWidget(QWidget* parent = 0);
61  ~Viewer3DWidget() override;
62 
63  // inherited from ArmarXWidgetController
64  QString getWidgetName() const override
65  {
66  return GetWidgetName();
67  }
68  static QString GetWidgetName()
69  {
70  return ARMARX_VIEWER_NAME;
71  }
72 
73  void loadSettings(QSettings* settings) override;
74  void saveSettings(QSettings* settings) override;
75  void setMainWindow(QMainWindow* mainWindow) override;
76 
77  void postDocking() override;
78 
79  /*!
80  * \brief This mutex is used to protect 3d scene updates.
81  * \param mutex3D
82  */
83  void setMutex3D(RecursiveMutexPtr const& mutex3D) override;
84 
85  QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent = 0) override;
86 
88  SoSeparator* emptyNode;
89  QPointer<QComboBox> cb3DViewers;
90  QPointer<QPushButton> sceneConfigDialogButton;
91  QPointer<QLabel> label;
92  void setNode(int index);
93 
94  public slots:
95  void select3DView(int index);
96  void sceneListUpdated(QMap<QString, Viewer3DInfo> sceneMap);
97  void configDialogOpen();
101  void configDialogPickColor(QColor color = QColor::Invalid);
102  void toggleViewingMode();
103  void viewAll();
104 
105  private:
106  Ui_Viewer3DWidget* ui;
107  QMap<QString, Viewer3DInfo> sceneMap;
108  std::vector<SoNode*> selectedViews;
109 
110  QToolBar* customToolbar;
111  QPointer<QDialog> configDialog;
112  Ui_ViewerWidgetConfigDialog* configDialogUi;
113  const std::string settingsFile;
114  QSettings settings;
115  QAction* viewingModeAction;
116 
117  std::map<QString, CameraPose> initialCameraPoses;
118 
119  // ArmarXWidgetController interface
120  public:
121  QIcon getWidgetIcon() const override
122  {
123  return GetWidgetIcon();
124  }
125  static QIcon GetWidgetIcon()
126  {
127  return QIcon(":icons/Outline-3D.png");
128  }
129 
130  // ManagedIceObject interface
131  protected:
132  void onInitComponent() override;
133  void onConnectComponent() override;
134  // ArmarXWidgetController interface
135  public:
136  void onLockWidget() override;
137  void onUnlockWidget() override;
138  };
140 }
141 
armarx::ArmarXWidgetController::mutex3D
std::shared_ptr< std::recursive_mutex > mutex3D
Definition: ArmarXWidgetController.h:301
armarx::Viewer3DWidget::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent=0) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: ViewerWidget.cpp:288
armarx::Viewer3DWidget::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ViewerWidget.cpp:512
armarx::Viewer3DWidget::setNode
void setNode(int index)
Definition: ViewerWidget.cpp:76
armarx::CameraPose
Definition: ViewerWidget.h:43
armarx::Viewer3DWidget::viewer
CoinViewerPtr viewer
Definition: ViewerWidget.h:87
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::Viewer3DWidget::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: ViewerWidget.cpp:119
armarx::Viewer3DWidget::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ViewerWidget.cpp:508
armarx::CameraPose::position
float position[3]
Definition: ViewerWidget.h:45
armarx::Viewer3DWidget::onLockWidget
void onLockWidget() override
Definition: ViewerWidget.cpp:516
armarx::Viewer3DWidget::Viewer3DWidget
Viewer3DWidget(QWidget *parent=0)
Definition: ViewerWidget.cpp:56
armarx::Viewer3DWidget
The Viewer3DWidget class.
Definition: ViewerWidget.h:55
ARMARX_VIEWER_NAME
#define ARMARX_VIEWER_NAME
Definition: ViewerWidget.h:30
armarx::Viewer3DWidget::sceneConfigDialogButton
QPointer< QPushButton > sceneConfigDialogButton
Definition: ViewerWidget.h:90
armarx::Viewer3DWidget::configDialogSaveSettings
void configDialogSaveSettings()
Definition: ViewerWidget.cpp:464
armarx::Viewer3DWidget::configDialogOpen
void configDialogOpen()
Definition: ViewerWidget.cpp:411
armarx::Viewer3DWidget::configDialogApplySettings
void configDialogApplySettings()
Definition: ViewerWidget.cpp:419
armarx::Viewer3DWidget::emptyNode
SoSeparator * emptyNode
Definition: ViewerWidget.h:88
armarx::ArmarXWidgetController::RecursiveMutexPtr
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition: ArmarXWidgetController.h:256
ArmarXComponentWidgetController.h
armarx::VariantType::Invalid
const VariantTypeId Invalid
Definition: Variant.h:914
armarx::Viewer3DWidget::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: ViewerWidget.cpp:158
armarx::Viewer3DWidget::~Viewer3DWidget
~Viewer3DWidget() override
Definition: ViewerWidget.cpp:67
armarx::Viewer3DWidget::toggleViewingMode
void toggleViewingMode()
Definition: ViewerWidget.cpp:395
armarx::Viewer3DWidget::label
QPointer< QLabel > label
Definition: ViewerWidget.h:91
armarx::Viewer3DWidget::viewAll
void viewAll()
Definition: ViewerWidget.cpp:403
armarx::Viewer3DWidget::setMutex3D
void setMutex3D(RecursiveMutexPtr const &mutex3D) override
This mutex is used to protect 3d scene updates.
Definition: ViewerWidget.cpp:279
armarx::Viewer3DWidget::select3DView
void select3DView(int index)
Definition: ViewerWidget.cpp:321
armarx::Viewer3DWidget::getWidgetName
QString getWidgetName() const override
Implement this function to specify the default name of your Widget.
Definition: ViewerWidget.h:64
armarx::CameraPose::orientation
float orientation[4]
Definition: ViewerWidget.h:46
armarx::Viewer3DWidget::setMainWindow
void setMainWindow(QMainWindow *mainWindow) override
Definition: ViewerWidget.cpp:188
armarx::Viewer3DWidget::configDialogLoadSettings
void configDialogLoadSettings()
Definition: ViewerWidget.cpp:487
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::Viewer3DWidget::GetWidgetName
static QString GetWidgetName()
Definition: ViewerWidget.h:68
armarx::CoinViewerPtr
std::shared_ptr< CoinViewer > CoinViewerPtr
Definition: CoinViewer.h:77
armarx::Viewer3DWidget::postDocking
void postDocking() override
postDocking is called after the widget has been docked into the main window.
Definition: ViewerWidget.cpp:196
armarx::Viewer3DWidget::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: ViewerWidget.h:125
armarx::ArmarXComponentWidgetController
Definition: ArmarXComponentWidgetController.h:39
armarx::Viewer3DWidget::getWidgetIcon
QIcon getWidgetIcon() const override
Implement this function to supply an icon for the menu.
Definition: ViewerWidget.h:121
armarx::Viewer3DWidget::cb3DViewers
QPointer< QComboBox > cb3DViewers
Definition: ViewerWidget.h:89
armarx::CameraPose::focalDistance
float focalDistance
Definition: ViewerWidget.h:47
armarx::Viewer3DInfo
Definition: ArmarXMainWindow.h:67
armarx::Viewer3DWidget::configDialogPickColor
void configDialogPickColor(QColor color=QColor::Invalid)
Definition: ViewerWidget.cpp:380
armarx::Viewer3DWidget::onUnlockWidget
void onUnlockWidget() override
Definition: ViewerWidget.cpp:523
CoinViewer.h
armarx::Viewer3DWidget::sceneListUpdated
void sceneListUpdated(QMap< QString, Viewer3DInfo > sceneMap)
Definition: ViewerWidget.cpp:338
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28