Computer Assited Medical Intervention Tool Kit  version 5.0
camitk::ObjectController Class Reference

The object controller class. More...

#include <ObjectController.h>

+ Inheritance diagram for camitk::ObjectController:
+ Collaboration diagram for camitk::ObjectController:

Public Types

enum  ViewMode { TREE, GROUPBOX, BUTTON }
 

Public Slots

void apply ()
 slot to apply change made by the user in the property editor More...
 
void revert ()
 slot to revert the values of all properties (revert to values in memory) More...
 

Public Member Functions

ViewMode getViewMode () const
 accessorMethod of the view mode More...
 
bool isModified ()
 call this to check if a modification was done More...
 
QObject * object () const
 accessorMethod of the object contains in the property browser More...
 
 ObjectController (QWidget *parent=nullptr, ViewMode viewMode=TREE)
 constructor of object controller with in parameters the parent widget and the view mode (default : TREE) More...
 
 Q_ENUM (ViewMode)
 
void setAutoUpdateProperty (bool)
 if set, the properties are immediatly updated in the managed object (default false) More...
 
void setObject (QObject *object)
 mutatorMethod of the object at unroll in the property browser More...
 
void setViewMode (ViewMode viewMode)
 mutator Method of the view mode More...
 
 ~ObjectController () override
 destructor of object controller More...
 

Private Member Functions

void initViewMode ()
 initialize the view mode depending on currentViewMode More...
 
 Q_PRIVATE_SLOT (d_func(), void saveChange(QtProperty *, const QVariant &)) Q_PRIVATE_SLOT(d_func()
 
void valueChanged (QtProperty *, const QVariant &)) ViewMode currentViewMode
 variable to choose the type of property browser More...
 

Private Attributes

ObjectControllerPrivated_ptr
 private object controller wich contains pointer about object, browser and more More...
 
QVBoxLayout * layout
 layout which will contains the propertybrowser and, in view mode GROUPBOX and BUTTON, the scroll More...
 
QScrollArea * scroll
 scroll add to navigate in the property browser More...
 

Detailed Description

The object controller class.

This is a special "magical" widget. It allows one to show the meta properties and dynamic property (see Qt Object Model / Property for lmore information on these). This class also automatically manage camitk::Property for components and actions. It is STRONGLY recommanded to use camitk::Property instead of Qt Meta Object property.

Note
In order to benefit from the camitk::Property decoration, the class that needs to be edited by the ObjectController have to declare a getProperty() method using the Q_INVOKABLE macro. E.g.: Q_INVOKABLE virtual Property* getProperty(QString name);

A complete example that show the usability of object controller is available in applications "objectcontroller". The best way to learn how to use this Core facility is to look at this application and the given TestClass. The class PropComponent and PropAction in the tutorials demonstrates how to use camitk::Property instead of Qt Meta Object Property.

An object controller is a sort of property browser where each line represents a property. The object controller automatically build a GUI to access and optionally changed the properties you defined.

There could be many different types of properties, and as many as you want.

In order to handle a list of specific properties for your class, you have three choices:

  • use camitk::Property (in Components or Actions): this is the recommanded way. camitk:Property overcomes the limitation of dynamic Qt Meta Object Properties.
  • write a new class inheriting from QObject and declare as many Q_PROPERTY as needed. When send to the ObjectController class the Q_PROPERTY list will be read and the GUI interfaces build.
  • generate dynamic properties on-the-fly

The first choice is the best as you can specify description, have read only property, define min and max values and step for numeric properties as well as precision for float/double. A camitk::Property is necessarily dynamic. For component and action properties, this is the way to go.

For a class that is neither a component or an action, you can still use the second and third method. The third method does even not need a new class. You have to create a new QObject instance, and add as many dynamic properties as you wish using QObject::setProperty method. You also have to install an event monitor in your class to be notified when a property has changed (see TestClass in "objectcontroller" application).

Three different view mode are available to represent/interact with the property values:

  • TREE based on a list view
  • GROUPBOX same as TREE, but each group of properties are viewed in a group box
  • BUTTON same as GROUPBOX, but buttons allow the user to show/hide the sub properties

The view mode can be changed at any time, even at run-time (see the "objectcontroller" application).

How to use this class:

Note
And... that's it! This method is easier, but does not work well for Q_ENUMS (enumerator). If you have an enum/Q_ENUMS property, you have to use the second method below.

The available property type are (see example in the "objectcontroller" application (tutorials), the tutorial class PropComponent and PropAction and (if you feel adventurous) also QtVariantProperty in tools/qpropertybrowser for a complete list of associated constraints):

Property Type Property Type Id
int QVariant::Int
double QVariant::Double
bool QVariant::Bool
QString QVariant::String
QVector3D QVariant::QVector3D
QColor QVariant::Color
QDate QVariant::Date
QTime QVariant::Time
QChar QVariant::Char
QDateTime QVariant::DateTime
QPoint Variant::Point
QPointF QVariant::PointF
QKeySequence QVariant::KeySequence
QLocale QVariant::Locale
QSize QVariant::Size
QSizeF QVariant::SizeF
QRect QVariant::Rect
QRectF QVariant::RectF
QSizePolicy QVariant::SizePolicy
QFont QVariant::Font
QCursor QVariant::Cursor
enum enumTypeId()
flag flagTypeId()
group groupTypeId()
Note
in Q_PROPERTY if you don't specify a WRITE method, then the property is set as read only.

Member Enumeration Documentation

◆ ViewMode

The property browser can be shown in different view mode. Use getViewMode() to get the information about the view mode.

Note
the view mode can be NULL; the default value is TREE.
Enumerator
TREE 

The property browser can be shown like a QListView.

GROUPBOX 

It is like the TREE but with a delimitation to indicate the arborescence of the property type.

BUTTON 

It is like the GROUPBOX but the buttons allow the user to control the comput display of arborescence.

Constructor & Destructor Documentation

◆ ObjectController()

ObjectController::ObjectController ( QWidget *  parent = nullptr,
ViewMode  viewMode = TREE 
)

constructor of object controller with in parameters the parent widget and the view mode (default : TREE)

◆ ~ObjectController()

ObjectController::~ObjectController ( )
override

destructor of object controller

Member Function Documentation

◆ apply

void ObjectController::apply ( )
slot

slot to apply change made by the user in the property editor

◆ getViewMode()

ObjectController::ViewMode ObjectController::getViewMode ( ) const

accessorMethod of the view mode

◆ initViewMode()

void ObjectController::initViewMode ( )
private

initialize the view mode depending on currentViewMode

◆ isModified()

bool ObjectController::isModified ( )

call this to check if a modification was done

◆ object()

QObject * ObjectController::object ( ) const

accessorMethod of the object contains in the property browser

References d_ptr, layout, and camitk::ObjectControllerPrivate::m_browser.

◆ Q_ENUM()

camitk::ObjectController::Q_ENUM ( ViewMode  )

◆ Q_PRIVATE_SLOT()

camitk::ObjectController::Q_PRIVATE_SLOT ( d_func()  ,
void   saveChangeQtProperty *, const QVariant & 
)
private

◆ revert

void ObjectController::revert ( )
slot

slot to revert the values of all properties (revert to values in memory)

◆ setAutoUpdateProperty()

void ObjectController::setAutoUpdateProperty ( bool  autoUpdate)

if set, the properties are immediatly updated in the managed object (default false)

◆ setObject()

void ObjectController::setObject ( QObject *  object)

mutatorMethod of the object at unroll in the property browser

Referenced by PMLExplorerWidget::createNewProperty(), PropertyExplorer::refresh(), PMLExplorerWidget::updateProperty(), and PMLExplorerWidget::updateTarget().

+ Here is the caller graph for this function:

◆ setViewMode()

void ObjectController::setViewMode ( ViewMode  viewMode)

mutator Method of the view mode

Referenced by PropertyExplorer::eventFilter().

+ Here is the caller graph for this function:

◆ valueChanged()

void camitk::ObjectController::valueChanged ( QtProperty ,
const QVariant &   
)
private

variable to choose the type of property browser

Member Data Documentation

◆ d_ptr

ObjectControllerPrivate* camitk::ObjectController::d_ptr
private

private object controller wich contains pointer about object, browser and more

Referenced by object().

◆ layout

QVBoxLayout* camitk::ObjectController::layout
private

layout which will contains the propertybrowser and, in view mode GROUPBOX and BUTTON, the scroll

Referenced by object().

◆ scroll

QScrollArea* camitk::ObjectController::scroll
private

scroll add to navigate in the property browser


The documentation for this class was generated from the following files:
ObjectController
Definition: objectcontroller.h:47
ObjectController::setObject
void setObject(QObject *object)
Definition: objectcontroller.cpp:375
camitk::ObjectController::BUTTON
@ BUTTON
It is like the GROUPBOX but the buttons allow the user to control the comput display of arborescence.
Definition: ObjectController.h:197
camitk::ObjectController::ObjectController
ObjectController(QWidget *parent=nullptr, ViewMode viewMode=TREE)
constructor of object controller with in parameters the parent widget and the view mode (default : TR...
Definition: ObjectController.cpp:543
camitk::ObjectController::GROUPBOX
@ GROUPBOX
It is like the TREE but with a delimitation to indicate the arborescence of the property type.
Definition: ObjectController.h:196