Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  private slots :
116  // BaseInterface
117  void initializePlugin();
118  void pluginsInitialized();
119  void slotVisibilityChanged ( int _identifier );
120  void slotObjectSelectionChanged ( int _identifier );
121  void slotObjectPropertiesChanged( int _identifier );
122  void slotObjectUpdated( int _identifier, const UpdateType& _type );
123 
124  // KeyInterface
125  void slotKeyEvent( QKeyEvent* _event );
126 
127  // INIInterface
128  void loadIniFileOptionsLast( INIFile& _ini );
129  void saveIniFileOptions( INIFile& _ini );
130  void saveOnExit(INIFile& _ini );
131 
132  // LoadSaveInterface
133  void fileOpened(int _id);
134  void addedEmptyObject(int _id);
135  void objectDeleted(int _id);
136 
137  // Tell system that this plugin runs without ui
138  void noguiSupported( ) {} ;
139 
140  public :
141 
144 
147 
149  QString name(){ return (QString("DataControl")); };
150 
152  QString description() { return (QString(tr("Manages Data Objects"))); };
153 
154  private :
157  QIcon* toolIcon_;
158 
160  QGridLayout* MeshDialogLayout_;
161 
163  QTableWidget* objectList_;
164 
166  bool locked;
167 
170 
172  QTreeView* view_;
173 
175  QHeaderView * viewHeader_;
176 
179 
180 
181 //===========================================================================
184 //===========================================================================
185 
186  private slots:
187 
189  void slotDataChanged (int _id, int _column, const QVariant& _value);
190 
192  void slotMoveBaseObject (int _id, int _newParentId);
193 
194  private:
195  void propagateDownwards(BaseObject* _obj, int _column );
196  void propagateUpwards(BaseObject* _obj, int _column );
197 
198  //variables to restrict propagation direction
200  int onlyUp_;
201  //defines, which selection column needs an update if not -1
202  // 2: source 3: target
204 
207 //===========================================================================
210 //===========================================================================
211  private slots:
213  void slotCustomContextMenuRequested ( const QPoint & _pos );
214 
216  void slotPopupRemove( );
217 
219  void slotUngroup ( );
220 
222  void slotGroup ( );
223 
225  void slotCopy();
226 
228  void slotRename ( );
229 
231  void slotZoomTo();
232 
234  void slotSwitchLight();
235 
237  void slotEditLight();
238 
240  void slotMaterialProperties();
241 
244 
247 
250 
256 
258  void slotShowLightSources( bool _state );
259  void slotShowLightSources();
260 
261  private :
263  QModelIndex popupIndex_;
264 
265  private slots:
266 
268  void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
269 
270  private:
273 
276 //===========================================================================
279 //===========================================================================
280 
281  private slots:
282 
284  void slotContextMenuHide( );
285 
287  void slotContextMenuTarget( );
288 
290  void slotContextMenuSource( );
291 
293  void slotContextMenuRemove( );
294 
296  void slotUpdateContextMenu( int _objectId);
297 
298  private :
299  QAction* targetAction_;
300  QAction* sourceAction_;
301  QAction* removeAction_;
302 
303  QToolButton *advancedSettingsBtn_;
304 
307 //===========================================================================
310 //===========================================================================
311 
312  private slots:
313 
315  void slotBoundingBoxChange( );
316 
317  private:
318 
320  void updateBoundingBox(BaseObjectData* _obj);
321 
324 //===========================================================================
327 //===========================================================================
328 
329  private slots:
330 
334  void setDescriptions();
335 
336  public slots:
338  QString getObjectName( int objectId );
339 
341  void objectDelete(int objectId);
342 
344  int copyObject( int objectId );
345 
347  int getObject( QString _name );
348 
350  DataType dataType( int objectId );
351 
353  void hideObject( int objectId );
354 
356  void showObject( int objectId );
357 
359  void setTarget( int objectId, bool _target );
360 
362  void setSource( int objectId, bool _source );
363 
365  void setObjectName( int objectId, QString _name );
366 
368  void setAllTarget();
369 
371  void setAllSource();
372 
374  void clearAllTarget();
375 
377  void clearAllSource();
378 
380  void showAll();
381 
383  void hideAll();
384 
394  int addEmptyGroup(QString _groupName = "", int _parentGroupId = 0);
395 
400  int groupObjects(IdList _objectIDs, QString _groupName = "");
401 
403  bool addObjectToGroup(int _objectId, int _groupId);
404 
409  bool unGroupObject(int _id);
410 
413 
416 
418  unsigned int groupCount() const;
419 
421  QStringList availableDataTypeNames() const;
422 
424  void printObjectInfoToLog();
425 
427  IdList getGroupElements(int _groupId);
428 
429  void showReducedUi(bool reduced);
430 
433  public slots:
434  QString version() { return QString("1.03"); };
435 };
436 
437 #endif //DATACONTROLPLUGIN_HH
void updateBoundingBox(BaseObjectData *_obj)
Updates bounding box.
Interface class from which all plugins have to be created.
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:157
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:110
QString description()
Description of the Plugin.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
Definition: Popup.cc:629
void slotObjectPropertiesChanged(int _identifier)
Update the model if properties of an object changed.
DataType dataType(int objectId)
Get the DataType of a given object.
Keyboard Event Interface.
Definition: KeyInterface.hh:76
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:81
Logtype
Log types for Message Window.
~DataControlPlugin()
Destructor.
void printObjectInfoToLog()
Print information about all open objects to the console.
void setAllSource()
Makes all available objects source.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:448
void addedEmptyObject(int _id)
Update the model if an empty object has been added.
TreeModel * model_
The Treemodel organizing the data.
QTreeView * view_
Tree view.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
Definition: Popup.cc:638
QModelIndex popupIndex_
Index where a popup has been opened.
Update type class.
Definition: UpdateType.hh:70
void slotContextMenuSource()
Source Selection.
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:696
IdList getGroupElements(int _groupId)
Get all elements of the given group.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:181
void fileOpened(int _id)
Update the model if a file has been opened.
void clearAllSource()
remove source selection from all objects
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:315
QAction * targetAction_
Hide an object.
void slotMoveBaseObject(int _id, int _newParentId)
Gets called when an object was moved via drag n drop.
void slotEditLight()
Called by the popup menu in order to edit lights.
Definition: Popup.cc:668
Interface for all Plugins which do logging to the logging window of the framework.
QAction * sourceAction_
Hide an object.
void slotKeyEvent(QKeyEvent *_event)
a key event occurred
int columnFromGUI_
Gets called when the data in the table has changed.
unsigned int groupCount() const
Returns the number of groups.
void showAll()
Shows all objects.
QToolButton * advancedSettingsBtn_
Hide an object.
QStringList availableDataTypeNames() const
Returns a list of all available DataTypes.
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
int onlyUp_
Gets called when the data in the table has changed.
DataControlPlugin()
Constructor.
void slotVisibilityChanged(int _identifier)
Update the model if the visibility of an object changed.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:536
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:496
QAction * removeAction_
Hide an object.
bool addObjectToGroup(int _objectId, int _groupId)
add an object to an existing group
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:577
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:418
DefaultObjectMarker objectMarker
Default marker to visualize "source" and "target" object flags.
Interface for all Plugins which provide scriptable Functions.
void showObject(int objectId)
Show the given Object.
int addEmptyGroup(QString _groupName="", int _parentGroupId=0)
Create new empty group.
QString name()
Name of the Plugin.
void loadIniFileOptionsLast(INIFile &_ini)
Load Groups from ini file.
void slotContextMenuTarget()
Target Selection.
QTableWidget * objectList_
Table containing Mesh information and status.
void slotDataChanged(int _id, int _column, const QVariant &_value)
Gets called when the data in the table has changed.
void hideAll()
Hides all objects.
Interface for all plugins which want to Load or Save files and create Objects.
IdList getTargetObjects(DataType _type)
Get all target objects of given type.
void hideObject(int objectId)
Hide the given Object.
void setTarget(int objectId, bool _target)
set the given Object as target
int headerPopupType_
Defines the section of the Popup.
QString getObjectName(int objectId)
Get the Objects name from the id.
void setAllTarget()
Makes all available objects target.
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:127
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:67
DatacontrolToolboxWidget * tool_
Widget for Toolbox.
void propagateDownwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
void saveIniFileOptions(INIFile &_ini)
Save groups to ini file.
void showReducedUi(bool reduced)
int onlyDown_
Gets called when the data in the table has changed.
void setSource(int objectId, bool _source)
set the given Object as source
Interface class for creating custom context menus.
void slotShowLightSources()
Index where a popup has been opened.
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Predefined datatypes.
Definition: DataTypes.hh:96
void slotObjectSelectionChanged(int _identifier)
update drawing of objects when the active object changed
void clearAllTarget()
Unselect all objects.
bool locked
Flag set to true if meshlist is updated, preventing signal for list udate to be called.
void saveOnExit(INIFile &_ini)
Save settings before application is closed.
void slotContextMenuHide()
Hide an object.
void objectDelete(int objectId)
Delete the given object.
void slotUpdateContextMenu(int _objectId)
Update the context Menus for the given id.
QGridLayout * MeshDialogLayout_
Layout for Toolbox.
void slotBoundingBoxChange()
Bounding box selection changed.
void objectDeleted(int _id)
an object was deleted. delete it internally
void setObjectName(int objectId, QString _name)
set the name of the given object
void propagateUpwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
void slotContextMenuRemove()
Remove Selected Item.
IdList getSourceObjects(DataType _type)
Get all source objects of given type.
void pluginsInitialized()
Plugin initialization.