DataControlPlugin.hh 8.17 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 46


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

#include "TreeModel.hh"


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

  signals:
Dirk Wilden's avatar
Dirk Wilden committed
66
    // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
67 68
    void updateView();
    void updatedObject(int);
Dirk Wilden's avatar
Dirk Wilden committed
69
    void visibilityChanged();
Jan Möbius's avatar
 
Jan Möbius committed
70
    void activeObjectChanged();
Jan Möbius's avatar
 
Jan Möbius committed
71

Dirk Wilden's avatar
Dirk Wilden committed
72 73 74 75
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);

    // LoggingInterface
Jan Möbius's avatar
 
Jan Möbius committed
76 77
    void log(Logtype _type, QString _message);
    void log(QString _message);
Dirk Wilden's avatar
Dirk Wilden committed
78
    // ContextMenuInterface
Jan Möbius's avatar
 
Jan Möbius committed
79 80
    void addContextMenu(QMenu* _menu );
    void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
Jan Möbius's avatar
 
Jan Möbius committed
81

Dirk Wilden's avatar
Dirk Wilden committed
82 83 84 85 86
  private slots :
    // BaseInterface
    void pluginsInitialized();
    void slotObjectUpdated( int _identifier );
    void slotActiveObjectChanged();
Jan Möbius's avatar
 
Jan Möbius committed
87

Dirk Wilden's avatar
Dirk Wilden committed
88 89
    // KeyInterface
    void slotKeyEvent( QKeyEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
90

Dirk Wilden's avatar
Dirk Wilden committed
91 92 93
    // INIInterface
    void loadIniFileOptionsLast( INIFile& _ini );
    void saveIniFileOptions( INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
94

Dirk Wilden's avatar
Dirk Wilden committed
95 96 97
  public :
    /// Destructor
    ~DataControlPlugin() {};
Jan Möbius's avatar
 
Jan Möbius committed
98

Dirk Wilden's avatar
Dirk Wilden committed
99 100
    /// Initialize the ToolBox
    bool initializeToolbox(QWidget*& _widget);
Jan Möbius's avatar
 
Jan Möbius committed
101

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

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

Dirk Wilden's avatar
Dirk Wilden committed
108 109 110
  private :
    /// Widget for Toolbox
    DatacontrolToolboxWidget* tool_;
Jan Möbius's avatar
 
Jan Möbius committed
111

Dirk Wilden's avatar
Dirk Wilden committed
112 113
    /// Layout for Toolbox
    QGridLayout* MeshDialogLayout_;
Jan Möbius's avatar
 
Jan Möbius committed
114

Dirk Wilden's avatar
Dirk Wilden committed
115 116
    /// Table containing Mesh information and status
    QTableWidget* objectList_;
Jan Möbius's avatar
 
Jan Möbius committed
117

Dirk Wilden's avatar
Dirk Wilden committed
118 119
    /// 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
120

Dirk Wilden's avatar
Dirk Wilden committed
121 122
    /// The Treemodel organizing the data
    TreeModel* model_;
Jan Möbius's avatar
 
Jan Möbius committed
123

Dirk Wilden's avatar
Dirk Wilden committed
124 125
    ///Tree view
    QTreeView* view_;
Jan Möbius's avatar
 
Jan Möbius committed
126

Dirk Wilden's avatar
Dirk Wilden committed
127 128
    /// Pointer to the header to the view widget
    QHeaderView * viewHeader_;
Jan Möbius's avatar
 
Jan Möbius committed
129

Dirk Wilden's avatar
Dirk Wilden committed
130 131 132 133
//===========================================================================
/** @name Slots which are called if data changed
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
134

Dirk Wilden's avatar
Dirk Wilden committed
135
  private slots:
Jan Möbius's avatar
 
Jan Möbius committed
136

Dirk Wilden's avatar
Dirk Wilden committed
137 138
    /// Gets called when the data in the table has changed
    void slotDataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
Jan Möbius's avatar
 
Jan Möbius committed
139

Dirk Wilden's avatar
Dirk Wilden committed
140
    void slotModelAboutToReset();
Jan Möbius's avatar
 
Jan Möbius committed
141

Dirk Wilden's avatar
Dirk Wilden committed
142
    void slotModelResetComplete();
Jan Möbius's avatar
 
Jan Möbius committed
143

Dirk Wilden's avatar
Dirk Wilden committed
144 145
  private:
    std::map< BaseObject*, bool > isExpanded_;
Jan Möbius's avatar
 
Jan Möbius committed
146

Dirk Wilden's avatar
Dirk Wilden committed
147
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
148

Dirk Wilden's avatar
Dirk Wilden committed
149 150 151 152
//===========================================================================
/** @name Popup Menu related
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
153 154 155
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
156

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

Jan Möbius's avatar
 
Jan Möbius committed
160 161
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
162

Jan Möbius's avatar
 
Jan Möbius committed
163 164
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
165

166 167 168
        /// Called by the popup menu to copy items
        void slotCopy();

Jan Möbius's avatar
 
Jan Möbius committed
169 170
        ///Called by the popup menu to rename items
        void slotRename ( );
Dirk Wilden's avatar
Dirk Wilden committed
171 172 173

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

Dirk Wilden's avatar
Dirk Wilden committed
175 176 177 178 179 180
        ///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
181 182 183
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
184

Jan Möbius's avatar
 
Jan Möbius committed
185
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
186

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

Jan Möbius's avatar
 
Jan Möbius committed
190 191 192
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
193

Dirk Wilden's avatar
Dirk Wilden committed
194
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
195

Dirk Wilden's avatar
Dirk Wilden committed
196 197 198 199
//===========================================================================
/** @name GL Area Context Menu related slots
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
200

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

Jan Möbius's avatar
 
Jan Möbius committed
203 204
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
205

Jan Möbius's avatar
 
Jan Möbius committed
206 207
        /// Target Selection
        void slotContextMenuTarget( );
Jan Möbius's avatar
 
Jan Möbius committed
208

Jan Möbius's avatar
 
Jan Möbius committed
209 210
        /// Source Selection
        void slotContextMenuSource( );
Jan Möbius's avatar
 
Jan Möbius committed
211

Jan Möbius's avatar
 
Jan Möbius committed
212 213
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
214

Jan Möbius's avatar
 
Jan Möbius committed
215 216 217
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Jan Möbius's avatar
 
Jan Möbius committed
218

Dirk Wilden's avatar
Dirk Wilden committed
219
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
220

Dirk Wilden's avatar
Dirk Wilden committed
221 222 223 224
//===========================================================================
/** @name Scripting functions
* @{ */
//===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
225

Dirk Wilden's avatar
Dirk Wilden committed
226 227 228
      private slots:
        void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
229 230 231
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
232

233 234 235
        /// Delete the given object
        void deleteObject(int objectId);

Jan Möbius's avatar
Jan Möbius committed
236 237 238
        /// Creates an object copy
        int copyObject( int objectId );

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

Jan Möbius's avatar
 
Jan Möbius committed
242 243
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
244

Jan Möbius's avatar
 
Jan Möbius committed
245
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
246 247
        void showObject( int objectId );

Dirk Wilden's avatar
Dirk Wilden committed
248 249 250 251 252 253 254 255 256
        /// 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
257 258
        /// Makes all available objects target
        void setAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
259

Jan Möbius's avatar
 
Jan Möbius committed
260 261
        /// Makes all available objects source
        void setAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
262

Jan Möbius's avatar
 
Jan Möbius committed
263 264
        /// Unselect all objects
        void clearAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
265

Jan Möbius's avatar
 
Jan Möbius committed
266 267
        /// remove source selection from all objects
        void clearAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
268

Jan Möbius's avatar
 
Jan Möbius committed
269 270
        /// Shows all objects
        void showAll();
Jan Möbius's avatar
 
Jan Möbius committed
271

Jan Möbius's avatar
 
Jan Möbius committed
272 273
        /// Hides all objects
        void hideAll();
Jan Möbius's avatar
 
Jan Möbius committed
274

Dirk Wilden's avatar
Dirk Wilden committed
275 276 277
        /// Group objects together
        void groupObjects(idList _objectIDs, QString _groupName = "");

Dirk Wilden's avatar
Dirk Wilden committed
278
/** @} */
Jan Möbius's avatar
 
Jan Möbius committed
279 280

  public slots:
Dirk Wilden's avatar
Dirk Wilden committed
281
    QString version() { return QString("1.03"); };
Jan Möbius's avatar
 
Jan Möbius committed
282 283
};

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