DataControlPlugin.hh 12.3 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
*                                                                            *
*                              OpenFlipper                                   *
*      Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen       *
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37 38 39 40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45




Dirk Wilden's avatar
Dirk Wilden committed
46 47
#ifndef DATACONTROLPLUGIN_HH
#define DATACONTROLPLUGIN_HH
Jan Möbius's avatar
 
Jan Möbius committed
48 49 50 51 52 53 54 55 56


#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/INIInterface.hh>
Dirk Wilden's avatar
Dirk Wilden committed
57
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
Jan Möbius's avatar
 
Jan Möbius committed
58
#include <OpenFlipper/common/Types.hh>
59
#include <ObjectTypes/Light/Light.hh>
60
#include "Toolbox.hh"
Jan Möbius's avatar
 
Jan Möbius committed
61 62

#include "TreeModel.hh"
63
#include "DefaultObjectMarker.hh"
Jan Möbius's avatar
 
Jan Möbius committed
64 65


Jan Möbius's avatar
 
Jan Möbius committed
66
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
Jan Möbius's avatar
 
Jan Möbius committed
67
*/
Dirk Wilden's avatar
Dirk Wilden committed
68
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface, LoadSaveInterface
Jan Möbius's avatar
 
Jan Möbius committed
69 70 71 72 73 74 75 76
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(KeyInterface)
  Q_INTERFACES(LoggingInterface)
  Q_INTERFACES(INIInterface)
  Q_INTERFACES(ContextMenuInterface)
Jan Möbius's avatar
 
Jan Möbius committed
77
  Q_INTERFACES(ScriptInterface)
Dirk Wilden's avatar
Dirk Wilden committed
78
  Q_INTERFACES(LoadSaveInterface)
Jan Möbius's avatar
 
Jan Möbius committed
79 80

  signals:
Dirk Wilden's avatar
Dirk Wilden committed
81
    // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
82
    void updateView();
83
    void updatedObject(int _it, const UpdateType _type);
Jan Möbius's avatar
 
Jan Möbius committed
84

Dirk Wilden's avatar
Dirk Wilden committed
85 86 87 88
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);

    // LoggingInterface
Jan Möbius's avatar
 
Jan Möbius committed
89 90
    void log(Logtype _type, QString _message);
    void log(QString _message);
91
    
Dirk Wilden's avatar
Dirk Wilden committed
92
    // ContextMenuInterface
Jan Möbius's avatar
 
Jan Möbius committed
93 94
    void addContextMenuItem(QAction* _action , ContextMenuType _type);
    void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
95
    
96 97
    // LoadSaveInterface
    void deleteObject( int _id );
98
    void emptyObjectAdded( int _id );
99
    void copyObject( int _oldId, int& _newId);
100 101
    
    // ToolboxInterface
Dirk Wilden's avatar
Dirk Wilden committed
102
    void addToolbox( QString _name  , QWidget* _widget, QIcon* _icon );
103

Dirk Wilden's avatar
Dirk Wilden committed
104 105
  private slots :
    // BaseInterface
106
    void initializePlugin();
Dirk Wilden's avatar
Dirk Wilden committed
107
    void pluginsInitialized();
108
    void slotObjectUpdated          ( int _identifier , const UpdateType _type);
Dirk Wilden's avatar
Dirk Wilden committed
109 110 111
    void slotVisibilityChanged      ( int _identifier );
    void slotObjectSelectionChanged ( int _identifier );
    void slotObjectPropertiesChanged( int _identifier );
Jan Möbius's avatar
 
Jan Möbius committed
112

Dirk Wilden's avatar
Dirk Wilden committed
113 114
    // KeyInterface
    void slotKeyEvent( QKeyEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
115

Dirk Wilden's avatar
Dirk Wilden committed
116 117 118
    // INIInterface
    void loadIniFileOptionsLast( INIFile& _ini );
    void saveIniFileOptions( INIFile& _ini );
119
    void saveOnExit(INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
120

Dirk Wilden's avatar
Dirk Wilden committed
121 122 123
    // LoadSaveInterface
    void fileOpened(int _id);
    void addedEmptyObject(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
124
    void objectDeleted(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
125

Dirk Wilden's avatar
Dirk Wilden committed
126 127 128
  public :
    /// Destructor
    ~DataControlPlugin() {};
Jan Möbius's avatar
 
Jan Möbius committed
129

Dirk Wilden's avatar
Dirk Wilden committed
130 131
    /// Name of the Plugin
    QString name(){ return (QString("DataControl")); };
Jan Möbius's avatar
 
Jan Möbius committed
132

Dirk Wilden's avatar
Dirk Wilden committed
133
    /// Description of the Plugin
Jan Möbius's avatar
Jan Möbius committed
134
    QString description() { return (QString(tr("Manages Data Objects"))); };
Jan Möbius's avatar
 
Jan Möbius committed
135

Dirk Wilden's avatar
Dirk Wilden committed
136 137 138
  private :
    /// Widget for Toolbox
    DatacontrolToolboxWidget* tool_;
Dirk Wilden's avatar
Dirk Wilden committed
139
    QIcon* toolIcon_;
Jan Möbius's avatar
 
Jan Möbius committed
140

Dirk Wilden's avatar
Dirk Wilden committed
141 142
    /// Layout for Toolbox
    QGridLayout* MeshDialogLayout_;
Jan Möbius's avatar
 
Jan Möbius committed
143

Dirk Wilden's avatar
Dirk Wilden committed
144 145
    /// Table containing Mesh information and status
    QTableWidget* objectList_;
Jan Möbius's avatar
 
Jan Möbius committed
146

Dirk Wilden's avatar
Dirk Wilden committed
147 148
    /// Flag set to true if meshlist is updated, preventing signal for list udate to be called
    bool locked;
Jan Möbius's avatar
 
Jan Möbius committed
149

Dirk Wilden's avatar
Dirk Wilden committed
150 151
    /// The Treemodel organizing the data
    TreeModel* model_;
Jan Möbius's avatar
 
Jan Möbius committed
152

Dirk Wilden's avatar
Dirk Wilden committed
153 154
    ///Tree view
    QTreeView* view_;
Jan Möbius's avatar
 
Jan Möbius committed
155

Dirk Wilden's avatar
Dirk Wilden committed
156 157
    /// Pointer to the header to the view widget
    QHeaderView * viewHeader_;
Jan Möbius's avatar
 
Jan Möbius committed
158

159 160 161
    /// Default marker to visualize "source" and "target" object flags
    DefaultObjectMarker objectMarker;

Dirk Wilden's avatar
Dirk Wilden committed
162

Dirk Wilden's avatar
Dirk Wilden committed
163 164 165 166
//===========================================================================
/** @name Slots which are called if data changed
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
167

Dirk Wilden's avatar
Dirk Wilden committed
168
  private slots:
Jan Möbius's avatar
 
Jan Möbius committed
169

Dirk Wilden's avatar
Dirk Wilden committed
170
    /// Gets called when the data in the table has changed
Dirk Wilden's avatar
Dirk Wilden committed
171
    void slotDataChanged (int _id, int _column, const QVariant& _value);
Jan Möbius's avatar
 
Jan Möbius committed
172

Dirk Wilden's avatar
Dirk Wilden committed
173 174
    /// Gets called when an object was moved via drag n drop
    void slotMoveBaseObject (int _id, int _newParentId);
Jan Möbius's avatar
 
Jan Möbius committed
175

Dirk Wilden's avatar
Dirk Wilden committed
176
  private:
Dirk Wilden's avatar
Dirk Wilden committed
177 178
    void propagateDownwards(BaseObject* _obj, int _column );
    void propagateUpwards(BaseObject* _obj, int _column );
Jan Möbius's avatar
 
Jan Möbius committed
179

180 181 182 183
    //variables to restrict propagation direction
    int onlyDown_;
    int onlyUp_;
    
Dirk Wilden's avatar
Dirk Wilden committed
184
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
185

Dirk Wilden's avatar
Dirk Wilden committed
186 187 188 189
//===========================================================================
/** @name Popup Menu related
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
190 191 192
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
193

Jan Möbius's avatar
 
Jan Möbius committed
194 195
        /// Called by the popup menu to remove an object/group
        void slotPopupRemove( );
Jan Möbius's avatar
 
Jan Möbius committed
196

Jan Möbius's avatar
 
Jan Möbius committed
197 198
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
199

Jan Möbius's avatar
 
Jan Möbius committed
200 201
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
202

203 204 205
        /// Called by the popup menu to copy items
        void slotCopy();

Jan Möbius's avatar
 
Jan Möbius committed
206 207
        ///Called by the popup menu to rename items
        void slotRename ( );
Dirk Wilden's avatar
Dirk Wilden committed
208 209 210

        ///Called by the popup menu to zoom to an object
        void slotZoomTo();
211 212 213
        
        /// Called by the popup menu in order to turn lights on/off
        void slotSwitchLight();
214 215 216
        
        /// Called by the popup menu in order to edit lights
        void slotEditLight();
Jan Möbius's avatar
 
Jan Möbius committed
217

Dirk Wilden's avatar
Dirk Wilden committed
218 219 220 221 222
        ///Called by the popup menu to set material properties
        void slotMaterialProperties();

        ///Called when the material properties were changed inside the material dialog
        void slotNodeChanged( ACG::SceneGraph::BaseNode* _node );
223 224 225
        
        /// Hide/Show all light sources if checkbox has been checked
        void slotShowLightSources( int _state );
Dirk Wilden's avatar
Dirk Wilden committed
226

Jan Möbius's avatar
 
Jan Möbius committed
227 228 229
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
230

Jan Möbius's avatar
 
Jan Möbius committed
231
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
232

Jan Möbius's avatar
 
Jan Möbius committed
233 234
        /// Display a custom context window for the TreeViews header
        void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
235

Jan Möbius's avatar
 
Jan Möbius committed
236 237 238
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
239

Dirk Wilden's avatar
Dirk Wilden committed
240
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
241

Dirk Wilden's avatar
Dirk Wilden committed
242 243 244 245
//===========================================================================
/** @name GL Area Context Menu related slots
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
246

Jan Möbius's avatar
 
Jan Möbius committed
247
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
248

Jan Möbius's avatar
 
Jan Möbius committed
249 250
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
251

Jan Möbius's avatar
 
Jan Möbius committed
252 253
        /// Target Selection
        void slotContextMenuTarget( );
Jan Möbius's avatar
 
Jan Möbius committed
254

Jan Möbius's avatar
 
Jan Möbius committed
255 256
        /// Source Selection
        void slotContextMenuSource( );
Dirk Wilden's avatar
 
Dirk Wilden committed
257 258 259
        
        /// Remove Selected Item
        void slotContextMenuRemove( );
Jan Möbius's avatar
 
Jan Möbius committed
260

Jan Möbius's avatar
 
Jan Möbius committed
261 262
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
263

Jan Möbius's avatar
 
Jan Möbius committed
264 265 266
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Dirk Wilden's avatar
 
Dirk Wilden committed
267
        QAction* removeAction_;
Jan Möbius's avatar
 
Jan Möbius committed
268

Dirk Wilden's avatar
Dirk Wilden committed
269
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
270

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
//===========================================================================
/** @name Bounding box related slots/functions
* @{ */
//===========================================================================

      private slots:

        /// Bounding box selection changed
        void slotBoundingBoxChange( );

     private:

        /// Updates bounding box
        void updateBoundingBox(BaseObjectData* _obj);

/** @} */

Dirk Wilden's avatar
Dirk Wilden committed
288 289 290 291
//===========================================================================
/** @name Scripting functions
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
292

Dirk Wilden's avatar
Dirk Wilden committed
293 294 295
      private slots:
        void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
296 297 298
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
299

300
        /// Delete the given object
301
        void objectDelete(int objectId);
302

Jan Möbius's avatar
Jan Möbius committed
303 304 305
        /// Creates an object copy
        int copyObject( int objectId );

Jan Möbius's avatar
 
Jan Möbius committed
306 307
        /// Get the id of an object by its name
        int getObject( QString _name );
Jan Möbius's avatar
 
Jan Möbius committed
308

Jan Möbius's avatar
 
Jan Möbius committed
309 310
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
311

Jan Möbius's avatar
 
Jan Möbius committed
312
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
313 314
        void showObject( int objectId );

Dirk Wilden's avatar
Dirk Wilden committed
315 316 317 318 319 320 321 322 323
        /// set the given Object as target
        void setTarget( int objectId, bool _target );

        /// set the given Object as source
        void setSource( int objectId, bool _source );

        /// set the name of the given object
        void setObjectName( int objectId, QString _name );

Jan Möbius's avatar
 
Jan Möbius committed
324 325
        /// Makes all available objects target
        void setAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
326

Jan Möbius's avatar
 
Jan Möbius committed
327 328
        /// Makes all available objects source
        void setAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
329

Jan Möbius's avatar
 
Jan Möbius committed
330 331
        /// Unselect all objects
        void clearAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
332

Jan Möbius's avatar
 
Jan Möbius committed
333 334
        /// remove source selection from all objects
        void clearAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
335

Jan Möbius's avatar
 
Jan Möbius committed
336 337
        /// Shows all objects
        void showAll();
Jan Möbius's avatar
 
Jan Möbius committed
338

Jan Möbius's avatar
 
Jan Möbius committed
339 340
        /// Hides all objects
        void hideAll();
Jan Möbius's avatar
 
Jan Möbius committed
341

342 343 344 345
        /** Group objects together
        *
        * @return object id of new group or -1 if failed
        */
Jan Möbius's avatar
Jan Möbius committed
346
        int groupObjects(IdList _objectIDs, QString _groupName = "");
347 348 349 350 351 352
        
        /** remove an object from its group and place it at the toplevel group
        *
        * @return successfull
        */
        bool unGroupObject(int _id);
353 354 355 356 357 358
        
        /// Get all target objects of given type
        IdList getTargetObjects(DataType _type);
        
        /// Get all source objects of given type
        IdList getSourceObjects(DataType _type);
Dirk Wilden's avatar
Dirk Wilden committed
359

Dirk Wilden's avatar
Dirk Wilden committed
360
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
361 362

  public slots:
Dirk Wilden's avatar
Dirk Wilden committed
363
    QString version() { return QString("1.03"); };
Jan Möbius's avatar
 
Jan Möbius committed
364 365
};

Dirk Wilden's avatar
Dirk Wilden committed
366
#endif //DATACONTROLPLUGIN_HH