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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 #ifndef DATACONTROLPLUGIN_HH
54 #define DATACONTROLPLUGIN_HH
55 
56 
63 #include <OpenFlipper/BasePlugin/INIInterface.hh>
67 #include "Toolbox.hh"
68 
69 #include "TreeModel.hh"
70 #include "DefaultObjectMarker.hh"
71 
72 
76 {
77  Q_OBJECT
78  Q_INTERFACES(BaseInterface)
79  Q_INTERFACES(ToolboxInterface)
80  Q_INTERFACES(KeyInterface)
81  Q_INTERFACES(LoggingInterface)
82  Q_INTERFACES(INIInterface)
83  Q_INTERFACES(ContextMenuInterface)
84  Q_INTERFACES(ScriptInterface)
85  Q_INTERFACES(LoadSaveInterface)
86 
87 #if QT_VERSION >= 0x050000
88  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-DataControl")
89 #endif
90 
91  signals:
92  // BaseInterface
93  void updateView();
94  void updatedObject(int _it, const UpdateType& _type);
95 
96  void setSlotDescription(QString _slotName, QString _slotDescription,
97  QStringList _parameters, QStringList _descriptions);
98 
99  // LoggingInterface
100  void log(Logtype _type, QString _message);
101  void log(QString _message);
102 
103  // ContextMenuInterface
104  void addContextMenuItem(QAction* _action , ContextMenuType _type);
105  void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
106 
107  // LoadSaveInterface
108  void deleteObject( int _id );
109  void emptyObjectAdded( int _id );
110  void copyObject( int _oldId, int& _newId);
111 
112  // ToolboxInterface
113  void addToolbox( QString _name , QWidget* _widget, QIcon* _icon, QWidget *_headerAreaWidget);
114 
115  void objectsGrouped(IdList);
116 
117  private slots :
118  // BaseInterface
119  void initializePlugin();
120  void pluginsInitialized();
121  void slotVisibilityChanged ( int _identifier );
122  void slotObjectSelectionChanged ( int _identifier );
123  void slotObjectPropertiesChanged( int _identifier );
124  void slotObjectUpdated( int _identifier, const UpdateType& _type );
125 
126  // KeyInterface
127  void slotKeyEvent( QKeyEvent* _event );
128 
129  // INIInterface
130  void loadIniFileOptionsLast( INIFile& _ini );
131  void saveIniFileOptions( INIFile& _ini );
132  void saveOnExit(INIFile& _ini );
133 
134  // LoadSaveInterface
135  void fileOpened(int _id);
136  void addedEmptyObject(int _id);
137  void objectDeleted(int _id);
138 
139  // Tell system that this plugin runs without ui
140  void noguiSupported( ) {} ;
141 
142  void slotObjectsGrouped(IdList _lst);
143 
144  public :
145 
148 
151 
153  QString name(){ return (QString("DataControl")); };
154 
156  QString description() { return (QString(tr("Manages Data Objects"))); };
157 
158  private :
161  QIcon* toolIcon_;
162 
164  QGridLayout* MeshDialogLayout_;
165 
167  QTableWidget* objectList_;
168 
170  bool locked;
171 
174 
176  QTreeView* view_;
177 
179  QHeaderView * viewHeader_;
180 
183 
184 
185 //===========================================================================
188 //===========================================================================
189 
190  private slots:
191 
193  void slotDataChanged (int _id, int _column, const QVariant& _value);
194 
196  void slotMoveBaseObject (int _id, int _newParentId);
197 
198  private:
199  void propagateDownwards(BaseObject* _obj, int _column );
200  void propagateUpwards(BaseObject* _obj, int _column );
201 
202  //variables to restrict propagation direction
204  int onlyUp_;
205  //defines, which selection column needs an update if not -1
206  // 2: source 3: target
208 
211 //===========================================================================
214 //===========================================================================
215  private slots:
217  void slotCustomContextMenuRequested ( const QPoint & _pos );
218 
220  void slotPopupRemove( );
221 
223  void slotUngroup ( );
224 
226  void slotGroup ( );
227 
229  void slotCopy();
230 
232  void slotRename ( );
233 
235  void slotZoomTo();
236 
238  void slotSwitchLight();
239 
241  void slotEditLight();
242 
244  void slotMaterialProperties();
245 
248 
251 
254 
260 
262  void slotShowLightSources( bool _state );
263  void slotShowLightSources();
264 
265  private :
267  QModelIndex popupIndex_;
268 
269  private slots:
270 
272  void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
273 
274  private:
277 
280 //===========================================================================
283 //===========================================================================
284 
285  private slots:
286 
288  void slotContextMenuHide( );
289 
291  void slotContextMenuTarget( );
292 
294  void slotContextMenuSource( );
295 
297  void slotContextMenuRemove( );
298 
300  void slotUpdateContextMenu( int _objectId);
301 
302  private :
303  QAction* targetAction_;
304  QAction* sourceAction_;
305  QAction* removeAction_;
306 
307  QToolButton *advancedSettingsBtn_;
308 
311 //===========================================================================
314 //===========================================================================
315 
316  private slots:
317 
319  void slotBoundingBoxChange( );
320 
321  private:
322 
324  void updateBoundingBox(BaseObjectData* _obj);
325 
328 //===========================================================================
331 //===========================================================================
332 
333  private slots:
334 
338  void setDescriptions();
339 
340  public slots:
342  QString getObjectName( int objectId );
343 
345  void objectDelete(int objectId);
346 
348  int copyObject( int objectId );
349 
351  int getObject( QString _name );
352 
354  DataType dataType( int objectId );
355 
357  void hideObject( int objectId );
358 
360  void showObject( int objectId );
361 
363  void setTarget( int objectId, bool _target );
364 
366  void setSource( int objectId, bool _source );
367 
369  void setObjectName( int objectId, QString _name );
370 
372  void setAllTarget();
373 
375  void setAllSource();
376 
378  void clearAllTarget();
379 
381  void clearAllSource();
382 
384  void showAll();
385 
387  void hideAll();
388 
398  int addEmptyGroup(QString _groupName = "", int _parentGroupId = 0);
399 
404  int groupObjects(IdList _objectIDs, QString _groupName = "");
405 
407  bool addObjectToGroup(int _objectId, int _groupId);
408 
413  bool unGroupObject(int _id);
414 
417 
420 
422  unsigned int groupCount() const;
423 
425  QStringList availableDataTypeNames() const;
426 
428  void printObjectInfoToLog();
429 
431  IdList getGroupElements(int _groupId);
432 
433  void showReducedUi(bool reduced);
434 
437  public slots:
438  QString version() { return QString("1.03"); };
439 };
440 
441 #endif //DATACONTROLPLUGIN_HH
void slotKeyEvent(QKeyEvent *_event)
a key event occurred
QAction * targetAction_
Hide an object.
Interface class for creating custom context menus.
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:579
void pluginsInitialized()
Plugin initialization.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:450
Predefined datatypes.
Definition: DataTypes.hh:96
void slotObjectPropertiesChanged(int _identifier)
Update the model if properties of an object changed.
QTableWidget * objectList_
Table containing Mesh information and status.
void saveOnExit(INIFile &_ini)
Save settings before application is closed.
bool locked
Flag set to true if meshlist is updated, preventing signal for list udate to be called.
Logtype
Log types for Message Window.
void slotShowLightSources()
Index where a popup has been opened.
int headerPopupType_
Defines the section of the Popup.
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:698
void saveIniFileOptions(INIFile &_ini)
Save groups to ini file.
QToolButton * advancedSettingsBtn_
Hide an object.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
Definition: Popup.cc:640
void updateBoundingBox(BaseObjectData *_obj)
Updates bounding box.
void slotContextMenuHide()
Hide an object.
Keyboard Event Interface.
Definition: KeyInterface.hh:76
void hideObject(int objectId)
Hide the given Object.
void slotDataChanged(int _id, int _column, const QVariant &_value)
Gets called when the data in the table has changed.
void setSource(int objectId, bool _source)
set the given Object as source
void printObjectInfoToLog()
Print information about all open objects to the console.
QAction * removeAction_
Hide an object.
void objectDeleted(int _id)
an object was deleted. delete it internally
TreeModel * model_
The Treemodel organizing the data.
IdList getTargetObjects(DataType _type)
Get all target objects of given type.
QGridLayout * MeshDialogLayout_
Layout for Toolbox.
void showAll()
Shows all objects.
int onlyUp_
Gets called when the data in the table has changed.
void propagateDownwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
Interface for all Plugins which provide scriptable Functions.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:81
DefaultObjectMarker objectMarker
Default marker to visualize "source" and "target" object flags.
void clearAllSource()
remove source selection from all objects
Interface class from which all plugins have to be created.
DataType dataType(int objectId)
Get the DataType of a given object.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
Definition: Popup.cc:631
Update type class.
Definition: UpdateType.hh:70
void slotUpdateContextMenu(int _objectId)
Update the context Menus for the given id.
QString description()
Description of the Plugin.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:317
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
void slotMoveBaseObject(int _id, int _newParentId)
Gets called when an object was moved via drag n drop.
Interface for all Plugins which do logging to the logging window of the framework.
DataControlPlugin()
Constructor.
void setObjectName(int objectId, QString _name)
set the name of the given object
void setAllSource()
Makes all available objects source.
void slotContextMenuTarget()
Target Selection.
void setAllTarget()
Makes all available objects target.
void slotObjectSelectionChanged(int _identifier)
update drawing of objects when the active object changed
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:538
void clearAllTarget()
Unselect all objects.
~DataControlPlugin()
Destructor.
void fileOpened(int _id)
Update the model if a file has been opened.
void showReducedUi(bool reduced)
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:156
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
QTreeView * view_
Tree view.
void slotVisibilityChanged(int _identifier)
Update the model if the visibility of an object changed.
bool addObjectToGroup(int _objectId, int _groupId)
add an object to an existing group
int onlyDown_
Gets called when the data in the table has changed.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
QModelIndex popupIndex_
Index where a popup has been opened.
QString getObjectName(int objectId)
Get the Objects name from the id.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:183
QHeaderView * viewHeader_
Pointer to the header to the view widget.
int addEmptyGroup(QString _groupName="", int _parentGroupId=0)
Create new empty group.
IdList getSourceObjects(DataType _type)
Get all source objects of given type.
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:420
void propagateUpwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
Interface for all plugins which want to Load or Save files and create Objects.
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:109
DatacontrolToolboxWidget * tool_
Widget for Toolbox.
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:126
QAction * sourceAction_
Hide an object.
int columnFromGUI_
Gets called when the data in the table has changed.
void setTarget(int objectId, bool _target)
set the given Object as target
void objectDelete(int objectId)
Delete the given object.
IdList getGroupElements(int _groupId)
Get all elements of the given group.
void slotBoundingBoxChange()
Bounding box selection changed.
void slotObjectsGrouped(IdList _lst)
update objects when they have been grouped
void slotContextMenuSource()
Source Selection.
void slotEditLight()
Called by the popup menu in order to edit lights.
Definition: Popup.cc:670
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
void addedEmptyObject(int _id)
Update the model if an empty object has been added.
void hideAll()
Hides all objects.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:66
unsigned int groupCount() const
Returns the number of groups.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:498
void loadIniFileOptionsLast(INIFile &_ini)
Load Groups from ini file.
QStringList availableDataTypeNames() const
Returns a list of all available DataTypes.
QString name()
Name of the Plugin.
void slotContextMenuRemove()
Remove Selected Item.
void showObject(int objectId)
Show the given Object.