ArmarXWidgetController.cpp
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
24
25#include <QDialog>
26#include <QMainWindow>
27#include <QMessageBox>
28#include <QThread>
29#include <QToolBar>
30
32
33#include "QtUtil.h"
34#include <Inventor/nodes/SoNode.h>
35
36namespace armarx
37{
39 {
40 __appMainWindow = nullptr;
41 }
42
44 {
45 if (__widget && !__widget->parent())
46 {
47 delete __widget;
48 }
49
50 // ARMARX_VERBOSE << "Deleting WidgetController " ;
51 }
52
53 QPointer<QWidget>
55 {
56 if (!__widget)
57 {
58 __widget = new QWidget();
59 }
60
61 return __widget;
62 }
63
64 QPointer<QDialog>
66 {
67 return nullptr;
68 }
69
70 QPointer<QWidget>
72 {
73 return nullptr;
74 }
75
76 QIcon
78 {
79 return QIcon();
80 }
81
82 QIcon
84 {
85 return QIcon();
86 }
87
88 QIcon
90 {
91 return QIcon();
92 }
93
94 QIcon
96 {
97 return QIcon();
98 }
99
100 QPointer<QDialog>
102 {
103 return nullptr;
104 }
105
106 bool
108 {
109 if (instanceName.length() == 0)
110 {
111 throw LocalException("The instance name of the widget must not be empty");
112 }
113
114 if (__instanceName.length() > 0)
115 {
116 return false;
117 }
118
119 __instanceName = instanceName;
120 return true;
121 }
122
123 QString
125 {
126 return __instanceName;
127 }
128
129 void
131 {
132 __appMainWindow = mainWindow;
133 }
134
135 QMainWindow*
137 {
138 return __appMainWindow;
139 }
140
141 QPointer<TipDialog>
143 {
144 return tipDialog;
145 }
146
147 void
148 armarx::ArmarXWidgetController::setTipDialog(QPointer<TipDialog> tipDialog)
149 {
150 this->tipDialog = tipDialog;
151 }
152
153 void
155 {
156 this->mutex3D = mutex3D;
157 }
158
159 void
165
166 void
171
172 void
174 {
176 ARMARX_DEBUG << (enable ? "enabling" : "disabling") << " the main widget";
177
178 getWidget()->setEnabled(enable);
179 }
180
181 int
183 {
184 QMessageBox msgBox;
185 ARMARX_WARNING_S << "MessageBox says: " << msg.toStdString() << flush;
186 msgBox.setText(msg);
187 return msgBox.exec();
188 }
189
190 void
192 {
193 ARMARX_DEBUG << "Requesting to " << (enable ? "enable" : "disable") << " the main widget";
194 if (!QMetaObject::invokeMethod(this, "enableMainWidget", Q_ARG(bool, enable)))
195 {
196 ARMARX_WARNING << "Failed to invoke enable";
197 }
198 }
199
200 void
204
205 void
209} // namespace armarx
210
211std::ostream&
212std::operator<<(std::ostream& stream, const QString& string)
213{
214 stream << string.toStdString();
215 return stream;
216}
217
218std::ostream&
219std::operator<<(std::ostream& stream, const QPointF& point)
220{
221 stream << point.x() << ", " << point.y();
222 return stream;
223}
224
225std::ostream&
226std::operator<<(std::ostream& stream, const QRectF& rect)
227{
228 stream << "topleft: " << rect.topLeft() << ", bottomright:" << rect.bottomRight();
229 return stream;
230}
231
232std::ostream&
233std::operator<<(std::ostream& stream, const QSizeF& rect)
234{
235 stream << "SizeF: " << rect.width() << "x" << rect.height();
236 return stream;
237}
#define CHECK_QT_THREAD(qtObject)
Macro to check whether the current function is executed in the thread of the given Qt object.
Definition QtUtil.h:30
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
virtual QPointer< QDialog > getConfigDialog(QWidget *parent=0)
getConfigDialog returns a pointer to the a configuration widget of this controller.
virtual QPointer< QDialog > getSceneConfigDialog(QWidget *parent=nullptr)
Reimplementing this function and returning a QDialog* will enable a configuration button which opens ...
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
virtual QIcon getWidgetIcon() const
Implement this function to supply an icon for the menu.
std::shared_ptr< std::recursive_mutex > mutex3D
void enableMainWidgetAsync(bool enable)
This function enables/disables the main widget asynchronously (if called from a non qt thread).
void setTipDialog(QPointer< TipDialog > tipDialog)
virtual void configured()
This function must be implemented by the user, if he supplies a config dialog.
virtual QMainWindow * getMainWindow()
Returns the ArmarX MainWindow.
static QIcon GetWidgetCategoryIcon()
Implement this function to supply an icon for the menu (if you implemented static QString GetWidgetNa...
QPointer< TipDialog > getTipDialog() const
Returns the default instance for the TipDialog used by all widgets (if not set otherwise).
virtual void setMainWindow(QMainWindow *mainWindow)
virtual void setMutex3D(RecursiveMutexPtr const &mutex3D)
This mutex is used to protect 3d scene updates. Usually called by the ArmarXGui main window on creati...
bool setInstanceName(QString instanceName)
sets the name of this instance.
static int showMessageBox(const QString &msg)
static QIcon GetWidgetIcon()
Implement this function to supply an icon for the menu (if you implemented static QString GetWidgetNa...
virtual QIcon getWidgetCategoryIcon() const
Implement this function to supply an icon for the category.
virtual QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent=0)
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:213
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush
Definition LogSender.h:251
ARMARXCORE_IMPORT_EXPORT ostream & operator<<(ostream &stream, const armarx::RunningTaskIceBase &task)