DataControlPlugin.hh 8.87 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  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.
Jan Möbius's avatar
 
Jan Möbius committed
15
//
Jan Möbius's avatar
 
Jan Möbius committed
16 17 18 19
//  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.
Jan Möbius's avatar
 
Jan Möbius committed
20
//
Jan Möbius's avatar
 
Jan Möbius committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




Dirk Wilden's avatar
Dirk Wilden committed
35 36
#ifndef DATACONTROLPLUGIN_HH
#define DATACONTROLPLUGIN_HH
Jan Möbius's avatar
 
Jan Möbius committed
37 38 39 40 41 42 43 44 45


#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
46
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
Jan Möbius's avatar
 
Jan Möbius committed
47
#include <OpenFlipper/common/Types.hh>
48
#include "Toolbox.hh"
Jan Möbius's avatar
 
Jan Möbius committed
49 50 51 52

#include "TreeModel.hh"


Jan Möbius's avatar
 
Jan Möbius committed
53
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
Jan Möbius's avatar
 
Jan Möbius committed
54
*/
Dirk Wilden's avatar
Dirk Wilden committed
55
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface, LoadSaveInterface
Jan Möbius's avatar
 
Jan Möbius committed
56 57 58 59 60 61 62 63
{
  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
64
  Q_INTERFACES(ScriptInterface)
Dirk Wilden's avatar
Dirk Wilden committed
65
  Q_INTERFACES(LoadSaveInterface)
Jan Möbius's avatar
 
Jan Möbius committed
66 67

  signals:
Dirk Wilden's avatar
Dirk Wilden committed
68
    // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
69 70
    void updateView();
    void updatedObject(int);
Dirk Wilden's avatar
Dirk Wilden committed
71 72 73
    void visibilityChanged(int);
    void objectSelectionChanged(int);
    void objectPropertiesChanged(int);
Jan Möbius's avatar
 
Jan Möbius committed
74

Dirk Wilden's avatar
Dirk Wilden committed
75 76 77 78
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);

    // LoggingInterface
Jan Möbius's avatar
 
Jan Möbius committed
79 80
    void log(Logtype _type, QString _message);
    void log(QString _message);
Dirk Wilden's avatar
Dirk Wilden committed
81
    // ContextMenuInterface
Jan Möbius's avatar
 
Jan Möbius committed
82 83
    void addContextMenuItem(QAction* _action , ContextMenuType _type);
    void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
84 85
    // LoadSaveInterface
    void deleteObject( int _id );
86
    void emptyObjectAdded( int _id );
87 88
    void copyObject( int _oldId, int& _newId);

Dirk Wilden's avatar
Dirk Wilden committed
89 90 91
  private slots :
    // BaseInterface
    void pluginsInitialized();
Dirk Wilden's avatar
Dirk Wilden committed
92 93 94 95
    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
96

Dirk Wilden's avatar
Dirk Wilden committed
97 98
    // KeyInterface
    void slotKeyEvent( QKeyEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
99

Dirk Wilden's avatar
Dirk Wilden committed
100 101 102
    // INIInterface
    void loadIniFileOptionsLast( INIFile& _ini );
    void saveIniFileOptions( INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
103

Dirk Wilden's avatar
Dirk Wilden committed
104 105 106
    // LoadSaveInterface
    void fileOpened(int _id);
    void addedEmptyObject(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
107
    void objectDeleted(int _id);
Dirk Wilden's avatar
Dirk Wilden committed
108

Dirk Wilden's avatar
Dirk Wilden committed
109 110 111
  public :
    /// Destructor
    ~DataControlPlugin() {};
Jan Möbius's avatar
 
Jan Möbius committed
112

Dirk Wilden's avatar
Dirk Wilden committed
113 114
    /// Initialize the ToolBox
    bool initializeToolbox(QWidget*& _widget);
Jan Möbius's avatar
 
Jan Möbius committed
115

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

Dirk Wilden's avatar
Dirk Wilden committed
119 120
    /// Description of the Plugin
    QString description() { return (QString("Manages Data Objects")); };
Jan Möbius's avatar
 
Jan Möbius committed
121

Dirk Wilden's avatar
Dirk Wilden committed
122 123 124
  private :
    /// Widget for Toolbox
    DatacontrolToolboxWidget* tool_;
Jan Möbius's avatar
 
Jan Möbius committed
125

Dirk Wilden's avatar
Dirk Wilden committed
126 127
    /// Layout for Toolbox
    QGridLayout* MeshDialogLayout_;
Jan Möbius's avatar
 
Jan Möbius committed
128

Dirk Wilden's avatar
Dirk Wilden committed
129 130
    /// Table containing Mesh information and status
    QTableWidget* objectList_;
Jan Möbius's avatar
 
Jan Möbius committed
131

Dirk Wilden's avatar
Dirk Wilden committed
132 133
    /// 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
134

Dirk Wilden's avatar
Dirk Wilden committed
135 136
    /// The Treemodel organizing the data
    TreeModel* model_;
Jan Möbius's avatar
 
Jan Möbius committed
137

Dirk Wilden's avatar
Dirk Wilden committed
138 139
    ///Tree view
    QTreeView* view_;
Jan Möbius's avatar
 
Jan Möbius committed
140

Dirk Wilden's avatar
Dirk Wilden committed
141 142
    /// Pointer to the header to the view widget
    QHeaderView * viewHeader_;
Jan Möbius's avatar
 
Jan Möbius committed
143

Dirk Wilden's avatar
Dirk Wilden committed
144

Dirk Wilden's avatar
Dirk Wilden committed
145 146 147 148
//===========================================================================
/** @name Slots which are called if data changed
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
149

Dirk Wilden's avatar
Dirk Wilden committed
150
  private slots:
Jan Möbius's avatar
 
Jan Möbius committed
151

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

Dirk Wilden's avatar
Dirk Wilden committed
155 156
    /// 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
157

Dirk Wilden's avatar
Dirk Wilden committed
158
  private:
Dirk Wilden's avatar
Dirk Wilden committed
159 160
    void propagateDownwards(BaseObject* _obj, int _column );
    void propagateUpwards(BaseObject* _obj, int _column );
Jan Möbius's avatar
 
Jan Möbius committed
161

Dirk Wilden's avatar
Dirk Wilden committed
162
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
163

Dirk Wilden's avatar
Dirk Wilden committed
164 165 166 167
//===========================================================================
/** @name Popup Menu related
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
168 169 170
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
171

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

Jan Möbius's avatar
 
Jan Möbius committed
175 176
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
177

Jan Möbius's avatar
 
Jan Möbius committed
178 179
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
180

181 182 183
        /// Called by the popup menu to copy items
        void slotCopy();

Jan Möbius's avatar
 
Jan Möbius committed
184 185
        ///Called by the popup menu to rename items
        void slotRename ( );
Dirk Wilden's avatar
Dirk Wilden committed
186 187 188

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

Dirk Wilden's avatar
Dirk Wilden committed
190 191 192 193 194 195
        ///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
196 197 198
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
199

Jan Möbius's avatar
 
Jan Möbius committed
200
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
201

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

Jan Möbius's avatar
 
Jan Möbius committed
205 206 207
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
208

Dirk Wilden's avatar
Dirk Wilden committed
209
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
210

Dirk Wilden's avatar
Dirk Wilden committed
211 212 213 214
//===========================================================================
/** @name GL Area Context Menu related slots
* @{ */
//===========================================================================
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
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
220

Jan Möbius's avatar
 
Jan Möbius committed
221 222
        /// Target Selection
        void slotContextMenuTarget( );
Jan Möbius's avatar
 
Jan Möbius committed
223

Jan Möbius's avatar
 
Jan Möbius committed
224 225
        /// Source Selection
        void slotContextMenuSource( );
Jan Möbius's avatar
 
Jan Möbius committed
226

Jan Möbius's avatar
 
Jan Möbius committed
227 228
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
229

Jan Möbius's avatar
 
Jan Möbius committed
230 231 232
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Jan Möbius's avatar
 
Jan Möbius committed
233

Dirk Wilden's avatar
Dirk Wilden committed
234
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
235

Dirk Wilden's avatar
Dirk Wilden committed
236 237 238 239
//===========================================================================
/** @name Scripting functions
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
240

Dirk Wilden's avatar
Dirk Wilden committed
241 242 243
      private slots:
        void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
244 245 246
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
247

248
        /// Delete the given object
249
        void objectDelete(int objectId);
250

Jan Möbius's avatar
Jan Möbius committed
251 252 253
        /// Creates an object copy
        int copyObject( int objectId );

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

Jan Möbius's avatar
 
Jan Möbius committed
257 258
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
259

Jan Möbius's avatar
 
Jan Möbius committed
260
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
261 262
        void showObject( int objectId );

Dirk Wilden's avatar
Dirk Wilden committed
263 264 265 266 267 268 269 270 271
        /// 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
272 273
        /// Makes all available objects target
        void setAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
274

Jan Möbius's avatar
 
Jan Möbius committed
275 276
        /// Makes all available objects source
        void setAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
277

Jan Möbius's avatar
 
Jan Möbius committed
278 279
        /// Unselect all objects
        void clearAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
280

Jan Möbius's avatar
 
Jan Möbius committed
281 282
        /// remove source selection from all objects
        void clearAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
283

Jan Möbius's avatar
 
Jan Möbius committed
284 285
        /// Shows all objects
        void showAll();
Jan Möbius's avatar
 
Jan Möbius committed
286

Jan Möbius's avatar
 
Jan Möbius committed
287 288
        /// Hides all objects
        void hideAll();
Jan Möbius's avatar
 
Jan Möbius committed
289

Dirk Wilden's avatar
Dirk Wilden committed
290 291 292
        /// Group objects together
        void groupObjects(idList _objectIDs, QString _groupName = "");

Dirk Wilden's avatar
Dirk Wilden committed
293
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
294 295

  public slots:
Dirk Wilden's avatar
Dirk Wilden committed
296
    QString version() { return QString("1.03"); };
Jan Möbius's avatar
 
Jan Möbius committed
297 298
};

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