DataControlPlugin.hh 11.3 KB
Newer Older
1 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 33 34 35 36
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 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/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
Jan Möbius's avatar
Jan Möbius committed
37
 *   $Revision$                                                       *
38 39 40 41
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
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 "Toolbox.hh"
Jan Möbius's avatar
 
Jan Möbius committed
60 61

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


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

  signals:
Dirk Wilden's avatar
Dirk Wilden committed
80
    // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
81 82
    void updateView();
    void updatedObject(int);
Dirk Wilden's avatar
Dirk Wilden committed
83 84 85
    void visibilityChanged(int);
    void objectSelectionChanged(int);
    void objectPropertiesChanged(int);
Jan Möbius's avatar
 
Jan Möbius committed
86

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

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

Dirk Wilden's avatar
Dirk Wilden committed
101 102 103
  private slots :
    // BaseInterface
    void pluginsInitialized();
Dirk Wilden's avatar
Dirk Wilden committed
104 105 106 107
    void slotObjectUpdated          ( int _identifier );
    void slotVisibilityChanged      ( int _identifier );
    void slotObjectSelectionChanged ( int _identifier );
    void slotObjectPropertiesChanged( int _identifier );
Jan Möbius's avatar
 
Jan Möbius committed
108

Dirk Wilden's avatar
Dirk Wilden committed
109 110
    // KeyInterface
    void slotKeyEvent( QKeyEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
111

Dirk Wilden's avatar
Dirk Wilden committed
112 113 114
    // INIInterface
    void loadIniFileOptionsLast( INIFile& _ini );
    void saveIniFileOptions( INIFile& _ini );
115
    void saveOnExit(INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
116

Dirk Wilden's avatar
Dirk Wilden committed
117 118 119
    // LoadSaveInterface
    void fileOpened(int _id);
    void addedEmptyObject(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
120
    void objectDeleted(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
121

Dirk Wilden's avatar
Dirk Wilden committed
122 123 124
  public :
    /// Destructor
    ~DataControlPlugin() {};
Jan Möbius's avatar
 
Jan Möbius committed
125

Dirk Wilden's avatar
Dirk Wilden committed
126 127
    /// Initialize the ToolBox
    bool initializeToolbox(QWidget*& _widget);
Jan Möbius's avatar
 
Jan Möbius committed
128

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

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

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

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

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

Dirk Wilden's avatar
Dirk Wilden committed
145 146
    /// 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
147

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

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

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

157 158 159
    /// Default marker to visualize "source" and "target" object flags
    DefaultObjectMarker objectMarker;

Dirk Wilden's avatar
Dirk Wilden committed
160

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

Dirk Wilden's avatar
Dirk Wilden committed
166
  private slots:
Jan Möbius's avatar
 
Jan Möbius committed
167

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

Dirk Wilden's avatar
Dirk Wilden committed
171 172
    /// 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
173

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

Dirk Wilden's avatar
Dirk Wilden committed
178
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
179

Dirk Wilden's avatar
Dirk Wilden committed
180 181 182 183
//===========================================================================
/** @name Popup Menu related
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
184 185 186
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
187

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

Jan Möbius's avatar
 
Jan Möbius committed
191 192
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
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 group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
196

197 198 199
        /// Called by the popup menu to copy items
        void slotCopy();

Jan Möbius's avatar
 
Jan Möbius committed
200 201
        ///Called by the popup menu to rename items
        void slotRename ( );
Dirk Wilden's avatar
Dirk Wilden committed
202 203 204

        ///Called by the popup menu to zoom to an object
        void slotZoomTo();
Jan Möbius's avatar
 
Jan Möbius committed
205

Dirk Wilden's avatar
Dirk Wilden committed
206 207 208 209 210 211
        ///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 );

Jan Möbius's avatar
 
Jan Möbius committed
212 213 214
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
215

Jan Möbius's avatar
 
Jan Möbius committed
216
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
217

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

Jan Möbius's avatar
 
Jan Möbius committed
221 222 223
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
224

Dirk Wilden's avatar
Dirk Wilden committed
225
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
226

Dirk Wilden's avatar
Dirk Wilden committed
227 228 229 230
//===========================================================================
/** @name GL Area Context Menu related slots
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
231

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

Jan Möbius's avatar
 
Jan Möbius committed
234 235
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
236

Jan Möbius's avatar
 
Jan Möbius committed
237 238
        /// Target Selection
        void slotContextMenuTarget( );
Jan Möbius's avatar
 
Jan Möbius committed
239

Jan Möbius's avatar
 
Jan Möbius committed
240 241
        /// Source Selection
        void slotContextMenuSource( );
Jan Möbius's avatar
 
Jan Möbius committed
242

Jan Möbius's avatar
 
Jan Möbius committed
243 244
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
245

Jan Möbius's avatar
 
Jan Möbius committed
246 247 248
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Jan Möbius's avatar
 
Jan Möbius committed
249

Dirk Wilden's avatar
Dirk Wilden committed
250
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
251

252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
//===========================================================================
/** @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
269 270 271 272
//===========================================================================
/** @name Scripting functions
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
273

Dirk Wilden's avatar
Dirk Wilden committed
274 275 276
      private slots:
        void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
277 278 279
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
280

281
        /// Delete the given object
282
        void objectDelete(int objectId);
283

Jan Möbius's avatar
Jan Möbius committed
284 285 286
        /// Creates an object copy
        int copyObject( int objectId );

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

Jan Möbius's avatar
 
Jan Möbius committed
290 291
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
292

Jan Möbius's avatar
 
Jan Möbius committed
293
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
294 295
        void showObject( int objectId );

Dirk Wilden's avatar
Dirk Wilden committed
296 297 298 299 300 301 302 303 304
        /// 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
305 306
        /// Makes all available objects target
        void setAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
307

Jan Möbius's avatar
 
Jan Möbius committed
308 309
        /// Makes all available objects source
        void setAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
310

Jan Möbius's avatar
 
Jan Möbius committed
311 312
        /// Unselect all objects
        void clearAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
313

Jan Möbius's avatar
 
Jan Möbius committed
314 315
        /// remove source selection from all objects
        void clearAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
316

Jan Möbius's avatar
 
Jan Möbius committed
317 318
        /// Shows all objects
        void showAll();
Jan Möbius's avatar
 
Jan Möbius committed
319

Jan Möbius's avatar
 
Jan Möbius committed
320 321
        /// Hides all objects
        void hideAll();
Jan Möbius's avatar
 
Jan Möbius committed
322

Dirk Wilden's avatar
Dirk Wilden committed
323 324 325
        /// Group objects together
        void groupObjects(idList _objectIDs, QString _groupName = "");

Dirk Wilden's avatar
Dirk Wilden committed
326
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
327 328

  public slots:
Dirk Wilden's avatar
Dirk Wilden committed
329
    QString version() { return QString("1.03"); };
Jan Möbius's avatar
 
Jan Möbius committed
330 331
};

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