Developer Documentation
DataControlPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 
47 #ifndef DATACONTROLPLUGIN_HH
48 #define DATACONTROLPLUGIN_HH
49 
50 
57 #include <OpenFlipper/BasePlugin/INIInterface.hh>
62 #include "Toolbox.hh"
63 
64 #include "TreeModel.hh"
65 #include "DefaultObjectMarker.hh"
66 
67 
71 {
72  Q_OBJECT
73  Q_INTERFACES(BaseInterface)
74  Q_INTERFACES(ToolboxInterface)
75  Q_INTERFACES(KeyInterface)
76  Q_INTERFACES(LoggingInterface)
77  Q_INTERFACES(INIInterface)
78  Q_INTERFACES(ContextMenuInterface)
79  Q_INTERFACES(ScriptInterface)
80  Q_INTERFACES(LoadSaveInterface)
81  Q_INTERFACES(PythonInterface)
82 
83  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-DataControl")
84 
85  signals:
86  // BaseInterface
87  void updateView();
88  void updatedObject(int _it, const UpdateType& _type);
89 
90  void setSlotDescription(QString _slotName, QString _slotDescription,
91  QStringList _parameters, QStringList _descriptions);
92 
93  // LoggingInterface
94  void log(Logtype _type, QString _message);
95  void log(QString _message);
96 
97  // ContextMenuInterface
98  void addContextMenuItem(QAction* _action , ContextMenuType _type);
99  void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
100 
101  // LoadSaveInterface
102  void deleteObject( int _id );
103  void emptyObjectAdded( int _id );
104  void copyObject( int _oldId, int& _newId);
105 
106  // ToolboxInterface
107  void addToolbox( QString _name , QWidget* _widget, QIcon* _icon, QWidget *_headerAreaWidget);
108 
109  void objectsGrouped(IdList);
110 
111  private slots :
112  // BaseInterface
113  void initializePlugin();
114  void pluginsInitialized();
115  void slotVisibilityChanged ( int _identifier );
116  void slotObjectSelectionChanged ( int _identifier );
117  void slotObjectPropertiesChanged( int _identifier );
118  void slotObjectUpdated( int _identifier, const UpdateType& _type );
119 
120  // KeyInterface
121  void slotKeyEvent( QKeyEvent* _event );
122 
123  // INIInterface
124  void loadIniFileOptionsLast( INIFile& _ini );
125  void saveIniFileOptions( INIFile& _ini );
126  void saveOnExit(INIFile& _ini );
127 
128  // LoadSaveInterface
129  void fileOpened(int _id);
130  void addedEmptyObject(int _id);
131  void objectDeleted(int _id);
132 
133  // Tell system that this plugin runs without ui
134  void noguiSupported( ) {} ;
135 
136  void slotObjectsGrouped(IdList _lst);
137 
138  public :
139 
142 
145 
147  QString name(){ return (QString("DataControl")); };
148 
150  QString description() { return (QString(tr("Manages Data Objects"))); };
151 
152  private :
155  QIcon* toolIcon_;
156 
158  QGridLayout* MeshDialogLayout_;
159 
161  QTableWidget* objectList_;
162 
164  bool locked;
165 
168 
170  QTreeView* view_;
171 
173  QHeaderView * viewHeader_;
174 
177 
178 
179 //===========================================================================
182 //===========================================================================
183 
184  private slots:
185 
187  void slotDataChanged (int _id, int _column, const QVariant& _value);
188 
190  void slotMoveBaseObject (int _id, int _newParentId);
191 
192  private:
193  void propagateDownwards(BaseObject* _obj, int _column );
194  void propagateUpwards(BaseObject* _obj, int _column );
195 
196  //variables to restrict propagation direction
198  int onlyUp_;
199  //defines, which selection column needs an update if not -1
200  // 2: source 3: target
202 
205 //===========================================================================
208 //===========================================================================
209  private slots:
211  void slotCustomContextMenuRequested ( const QPoint & _pos );
212 
214  void slotPopupRemove( );
215 
217  void slotUngroup ( );
218 
220  void slotGroup ( );
221 
223  void slotCopy();
224 
226  void slotRename ( );
227 
229  void slotZoomTo();
230 
232  void slotSwitchLight();
233 
235  void slotEditLight();
236 
238  void slotMaterialProperties();
239 
242 
245 
248 
254 
256  void slotShowLightSources( bool _state );
257  void slotShowLightSources();
258 
259  private :
261  QModelIndex popupIndex_;
262 
263  private slots:
264 
266  void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
267 
268  private:
271 
274 //===========================================================================
277 //===========================================================================
278 
279  private slots:
280 
282  void slotContextMenuHide( );
283 
285  void slotContextMenuTarget( );
286 
288  void slotContextMenuSource( );
289 
291  void slotContextMenuRemove( );
292 
294  void slotUpdateContextMenu( int _objectId);
295 
296  private :
297  QAction* targetAction_;
298  QAction* sourceAction_;
299  QAction* removeAction_;
300 
301  QToolButton *advancedSettingsBtn_;
302 
305 //===========================================================================
308 //===========================================================================
309 
310  private slots:
311 
313  void slotBoundingBoxChange( );
314 
315  private:
316 
318  void updateBoundingBox(BaseObjectData* _obj);
319 
322 //===========================================================================
325 //===========================================================================
326 
327  private slots:
328 
332  void setDescriptions();
333 
334  public slots:
336  QString getObjectName( int objectId );
337 
339  void objectDelete(int objectId);
340 
342  int copyObject( int objectId );
343 
345  int getObject( QString _name );
346 
348  DataType dataType( int objectId );
349 
351  void hideObject( int objectId );
352 
354  void showObject( int objectId );
355 
357  void setTarget( int objectId, bool _target );
358 
360  void setSource( int objectId, bool _source );
361 
363  void setObjectName( int objectId, QString _name );
364 
366  void setAllTarget();
367 
369  void setAllSource();
370 
372  void clearAllTarget();
373 
375  void clearAllSource();
376 
378  void showAll();
379 
381  void hideAll();
382 
392  int addEmptyGroup(QString _groupName = "", int _parentGroupId = 0);
393 
398  int groupObjects(IdList _objectIDs, QString _groupName = "");
399 
401  bool addObjectToGroup(int _objectId, int _groupId);
402 
407  bool unGroupObject(int _id);
408 
411 
414 
416  unsigned int groupCount() const;
417 
419  QString availableDataTypeNames() const;
420 
422  void printObjectInfoToLog();
423 
425  IdList getGroupElements(int _groupId);
426 
428  void showReducedUi(bool reduced);
429 
432  public slots:
433  QString version() { return QString("1.03"); };
434 };
435 
436 #endif //DATACONTROLPLUGIN_HH
void slotKeyEvent(QKeyEvent *_event)
a key event occurred
void slotVisibilityChanged(int _identifier)
Update the model if the visibility of an object changed.
void hideAll()
Hides all objects.
void slotUpdateContextMenu(int _objectId)
Update the context Menus for the given id.
void propagateUpwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
void saveIniFileOptions(INIFile &_ini)
Save groups to ini file.
IdList getSourceObjects(DataType _type)
Get all source objects of given type.
void hideObject(int objectId)
Hide the given Object.
void showAll()
Shows all objects.
void slotBoundingBoxChange()
Bounding box selection changed.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
int columnFromGUI_
Gets called when the data in the table has changed.
void setSource(int objectId, bool _source)
set the given Object as source
bool addObjectToGroup(int _objectId, int _groupId)
add an object to an existing group
void setTarget(int objectId, bool _target)
set the given Object as target
void loadIniFileOptionsLast(INIFile &_ini)
Load Groups from ini file.
Interface class for exporting functions to python.
DefaultObjectMarker objectMarker
Default marker to visualize "source" and "target" object flags.
int onlyUp_
Gets called when the data in the table has changed.
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
Definition: Popup.cc:636
void slotContextMenuTarget()
Target Selection.
QModelIndex popupIndex_
Index where a popup has been opened.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:446
void objectDeleted(int _id)
an object was deleted. delete it internally
QAction * targetAction_
Hide an object.
void slotObjectPropertiesChanged(int _identifier)
Update the model if properties of an object changed.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
Definition: Popup.cc:627
IdList getTargetObjects(DataType _type)
Get all target objects of given type.
void clearAllTarget()
Unselect all objects.
Logtype
Log types for Message Window.
~DataControlPlugin()
Destructor.
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:122
DataControlPlugin()
Constructor.
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:494
void setAllTarget()
Makes all available objects target.
QAction * removeAction_
Hide an object.
void showReducedUi(bool reduced)
Show or hide the extended ui interface in the datacontrol toolbox.
void slotDataChanged(int _id, int _column, const QVariant &_value)
Gets called when the data in the table has changed.
QAction * sourceAction_
Hide an object.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:313
QToolButton * advancedSettingsBtn_
Hide an object.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
bool locked
Flag set to true if meshlist is updated, preventing signal for list udate to be called.
TreeModel * model_
The Treemodel organizing the data.
QTreeView * view_
Tree view.
QString getObjectName(int objectId)
Get the Objects name from the id.
QTableWidget * objectList_
Table containing Mesh information and status.
void slotMoveBaseObject(int _id, int _newParentId)
Gets called when an object was moved via drag n drop.
void slotContextMenuRemove()
Remove Selected Item.
void setAllSource()
Makes all available objects source.
unsigned int groupCount() const
Returns the number of groups.
DataType dataType(int objectId)
Get the DataType of a given object.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:179
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:105
IdList getGroupElements(int _groupId)
Get all elements of the given group.
Update type class.
Definition: UpdateType.hh:60
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:152
QString name()
Name of the Plugin.
DatacontrolToolboxWidget * tool_
Widget for Toolbox.
void fileOpened(int _id)
Update the model if a file has been opened.
QGridLayout * MeshDialogLayout_
Layout for Toolbox.
void slotContextMenuSource()
Source Selection.
Keyboard Event Interface.
Definition: KeyInterface.hh:59
int onlyDown_
Gets called when the data in the table has changed.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
void slotShowLightSources()
Index where a popup has been opened.
void slotObjectsGrouped(IdList _lst)
update objects when they have been grouped
void printObjectInfoToLog()
Print information about all open objects to the console.
void slotContextMenuHide()
Hide an object.
QString description()
Description of the Plugin.
void objectDelete(int objectId)
Delete the given object.
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
void saveOnExit(INIFile &_ini)
Save settings before application is closed.
void slotObjectSelectionChanged(int _identifier)
update drawing of objects when the active object changed
int getObject(QString _name)
Get the id of an object by its name.
void slotZoomTo()
Called by the popup menu to zoom to an object.
Definition: Popup.cc:694
Interface for all Plugins which provide scriptable Functions.
void addedEmptyObject(int _id)
Update the model if an empty object has been added.
void clearAllSource()
remove source selection from all objects
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:575
int headerPopupType_
Defines the section of the Popup.
void propagateDownwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
void updateBoundingBox(BaseObjectData *_obj)
Updates bounding box.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:534
Interface class for creating custom context menus.
void slotEditLight()
Called by the popup menu in order to edit lights.
Definition: Popup.cc:666
void pluginsInitialized()
Plugin initialization.
void setObjectName(int objectId, QString _name)
set the name of the given object
Interface class from which all plugins have to be created.
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:416
Interface for all plugins which want to Load or Save files and create Objects.
int addEmptyGroup(QString _groupName="", int _parentGroupId=0)
Create new empty group.
QString availableDataTypeNames() const
Returns a list of all available DataTypes.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:62
void showObject(int objectId)
Show the given Object.