Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ObjectController.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef OBJECTCONTROLLER_H
27 #define OBJECTCONTROLLER_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 
32 // -- QT stuff
33 #include <QtGui/QWidget>
34 #include <QtVariantProperty>
35 #include <QPushButton>
36 #include <QVBoxLayout>
37 #include <QScrollArea>
38 #include <QMetaEnum>
39 #include <signal.h>
40 
41 
42 namespace camitk
43 {
44 class ObjectControllerPrivate;
45 
46 
163 class CAMITK_API ObjectController : public QWidget {
164  Q_OBJECT
165  Q_ENUMS(ViewMode); // so that it can be used in property editor
166 
167 public:
168  // [CAMITK ADDED]
173  enum ViewMode {
176  BUTTON
177  };
178 
180  ObjectController ( QWidget *parent = 0, ViewMode viewMode = TREE );
181 
183  ~ObjectController();
184 
186  void setObject ( QObject *object );
187 
189  QObject *object() const;
190 
192  void setAutoUpdateProperty(bool);
193 
194  // [CAMITK ADDED]
196  void setViewMode ( ViewMode viewMode );
197 
198  // [CAMITK ADDED]
200  ViewMode getViewMode() const;
201 
202  // [CAMITK ADDED]
204  bool isModified ();
205 
206 public slots:
207  // [CAMITK ADDED]
209  void apply();
210 
211  // [CAMITK ADDED]
213  void revert();
214 
215 private:
218  Q_DECLARE_PRIVATE ( ObjectController )
219  Q_DISABLE_COPY ( ObjectController )
220 
221  // [CAMITK CHANGED]
222  Q_PRIVATE_SLOT ( d_func(), void saveChange ( QtProperty *, const QVariant & ) )
223  Q_PRIVATE_SLOT ( d_func(), void valueChanged ( QtProperty *, const QVariant & ) )
224 
225  // [CAMITK ADDED]
227  ViewMode currentViewMode;
228 
229  // [CAMITK ADDED]
231  void initViewMode();
232 
234  QVBoxLayout *layout;
235 
237  QScrollArea *scroll;
238 
239 };
240 
243  Q_DECLARE_PUBLIC ( ObjectController )
244 public:
245 
246  void addClassProperties ( const QMetaObject *metaObject );
247  void addDynamicProperties ( QObject *edited );
248  void updateClassProperties ( const QMetaObject *metaObject, bool recursive );
249  void updateDynamicProperties ( const QObject * edited);
250  void saveExpandedState();
251  void restoreExpandedState();
252  void valueChanged ( QtProperty *property, const QVariant value );
253  //CAMITK ADDED
254  void saveChange ( QtProperty *property, const QVariant &value );
255  void applyChange();
256  //
257  int enumToInt ( const QMetaEnum &metaEnum, int enumValue ) const;
258  int intToEnum ( const QMetaEnum &metaEnum, int intValue ) const;
259  int flagToInt ( const QMetaEnum &metaEnum, int flagValue ) const;
260  int intToFlag ( const QMetaEnum &metaEnum, int intValue ) const;
261  bool isSubValue ( int value, int subValue ) const;
262  bool isPowerOf2 ( int value ) const;
263 
265  QObject *m_object;
266 
267  /* [CAMITK REMOVED]
268  QMap<const QMetaObject *, QtProperty *> m_classToProperty;
269  QMap<QtProperty *, const QMetaObject *> m_propertyToClass;
270  */
272  QMap<QtProperty *, int> m_classPropertyToIndex;
274  QMap<const QMetaObject *, QMap<int, QtVariantProperty *> > m_classToIndexToProperty;
275 
277  QMap<int, QtVariantProperty *> m_indexToDynamicProperty;
279  QMap<QtProperty *, int> m_dynamicPropertyToIndex;
280 
282  QMap<QtProperty *, bool> m_propertyToExpanded;
283 
285  QList<QtProperty *> m_topLevelProperties;
286 
288  QMap<QtProperty *, QVariant> saveChangeValue;
289 
292 
295 
297  QtVariantPropertyManager *m_readOnlyManager;
298 
299  // [CAMITK ADDED]
301  QtVariantProperty * buildQtVariantProperty(QString name, QMetaType::Type type, QVariant value, bool isReadable, bool isWritable, bool isEnumType, bool isFlagType, bool isDesignable, QMetaEnum * metaEnum = NULL);
302 
304  QMap<QString, QtProperty*> groupProperties;
305 };
306 
307 }
308 
309 #endif
Definition: qtpropertybrowser.h:268
Definition: qtvariantproperty.h:84
Definition: ObjectController.h:241
Definition: Action.h:40
#define CAMITK_API
Definition: CamiTKAPI.h:49
ObjectControllerPrivate * d_ptr
private object controller wich contains pointer about object, browser and more
Definition: ObjectController.h:217
It is like the TREE but with a delimitation to indicate the arborescence of the property type...
Definition: ObjectController.h:175
ViewMode
The property browser can be shown in different view mode.
Definition: ObjectController.h:173
The description of this class will come soon !
Definition: qtvariantproperty.h:64
The description of this class will come soon !
Definition: qtpropertybrowser.h:74
The property browser can be shown like a QListView.
Definition: ObjectController.h:174
The object controller class.
Definition: ObjectController.h:163
ObjectController * q_ptr
Definition: ObjectController.h:242