DataControlPlugin.hh 8.84 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
//  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$
//
//=============================================================================




#ifndef COLORPLUGIN_HH
#define COLORPLUGIN_HH

#include <QObject>
#include <QMenuBar>
#include "DataControlPlugin.hh"

#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>
50
#include "Toolbox.hh"
Jan Möbius's avatar
 
Jan Möbius committed
51 52 53 54 55 56

//#include "QCheckBoxDelegate.hh"

#include "TreeModel.hh"


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

  signals:
    /// Force Examiner widget to update their views
Jan Möbius's avatar
 
Jan Möbius committed
72
    void updateView();
Jan Möbius's avatar
 
Jan Möbius committed
73

Jan Möbius's avatar
 
Jan Möbius committed
74
    /// Emit this Signal, if object list has changed (e.g. Source or Target changed)
Jan Möbius's avatar
 
Jan Möbius committed
75
    void updatedObject(int);
Jan Möbius's avatar
 
Jan Möbius committed
76

77 78
    void visibilityChanged( );

Jan Möbius's avatar
 
Jan Möbius committed
79
    void activeObjectChanged();
Jan Möbius's avatar
 
Jan Möbius committed
80

Jan Möbius's avatar
 
Jan Möbius committed
81 82
    void log(Logtype _type, QString _message);
    void log(QString _message);
Jan Möbius's avatar
 
Jan Möbius committed
83

Jan Möbius's avatar
 
Jan Möbius committed
84 85
    void addContextMenu(QMenu* _menu );
    void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
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);


Jan Möbius's avatar
 
Jan Möbius committed
91 92 93 94
   private slots :
      /// Updates the table widget
      void slotObjectUpdated( int _identifier );
      void slotActiveObjectChanged();
Jan Möbius's avatar
 
Jan Möbius committed
95

Jan Möbius's avatar
 
Jan Möbius committed
96
      void slotKeyEvent( QKeyEvent* _event );
Jan Möbius's avatar
 
Jan Möbius committed
97

Jan Möbius's avatar
 
Jan Möbius committed
98
      void loadIniFileOptionsLast( INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
99
      void saveIniFileOptions( INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
100

Jan Möbius's avatar
 
Jan Möbius committed
101
      void pluginsInitialized();
Dirk Wilden's avatar
Dirk Wilden committed
102
      void initializePlugin();
Jan Möbius's avatar
 
Jan Möbius committed
103
   public :
Jan Möbius's avatar
 
Jan Möbius committed
104

Jan Möbius's avatar
 
Jan Möbius committed
105 106 107 108 109 110
     ~DataControlPlugin() {};


     /** Initialize the toolbar (create a widget in the right side toolbox)\n
      *   Creates Table and buttons */
     bool initializeToolbox(QWidget*& _widget);
Jan Möbius's avatar
 
Jan Möbius committed
111 112

     /// Name of the Plugin
Jan Möbius's avatar
 
Jan Möbius committed
113
     QString name(){ return (QString("DataControl")); };
Jan Möbius's avatar
 
Jan Möbius committed
114

Jan Möbius's avatar
 
Jan Möbius committed
115 116
     /// Description of the Plugin
     QString description() { return (QString("Manages Data Objects")); };
Jan Möbius's avatar
 
Jan Möbius committed
117

Jan Möbius's avatar
 
Jan Möbius committed
118
     /// User selected plugins Toolbox
Jan Möbius's avatar
 
Jan Möbius committed
119 120
      void toolboxActivated( bool /* _activated */   ) { };

Jan Möbius's avatar
 
Jan Möbius committed
121 122
      /// Update the visualization of the active objects
      void update_active( );
Jan Möbius's avatar
 
Jan Möbius committed
123

Jan Möbius's avatar
 
Jan Möbius committed
124 125
   private :
      /// Widget for Toolbox
126
      DatacontrolToolboxWidget* tool_;
Jan Möbius's avatar
 
Jan Möbius committed
127

Jan Möbius's avatar
 
Jan Möbius committed
128 129
      /// Layout for Toolbox
      QGridLayout* MeshDialogLayout_;
Jan Möbius's avatar
 
Jan Möbius committed
130

Jan Möbius's avatar
 
Jan Möbius committed
131 132
      /// Table containing Mesh information and status
      QTableWidget* objectList_;
Jan Möbius's avatar
 
Jan Möbius committed
133

Jan Möbius's avatar
 
Jan Möbius committed
134 135
      /// 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
136

Jan Möbius's avatar
 
Jan Möbius committed
137
      /// The Treemodel organizing the data
Jan Möbius's avatar
 
Jan Möbius committed
138 139
      TreeModel* model_;

Jan Möbius's avatar
 
Jan Möbius committed
140 141
      ///Tree view
      QTreeView* view_;
Jan Möbius's avatar
 
Jan Möbius committed
142

Jan Möbius's avatar
 
Jan Möbius committed
143 144
      /// Pointer to the header to the view widget
      QHeaderView * viewHeader_;
Jan Möbius's avatar
 
Jan Möbius committed
145

Jan Möbius's avatar
 
Jan Möbius committed
146 147 148 149
      /// Delegate for boolean values
      //QCheckBoxDelegate* checkboxDelegate_;

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

Jan Möbius's avatar
 
Jan Möbius committed
151 152
      /// This slot is called when the mesh selection changed in the table
      void slotCellClicked(int _row, int _col);
Jan Möbius's avatar
 
Jan Möbius committed
153

Jan Möbius's avatar
 
Jan Möbius committed
154 155
      /// Vertical header of the list has been clicked
      void verticalHeaderClicked( int _row );
Jan Möbius's avatar
 
Jan Möbius committed
156 157 158 159

      void verticalCountClicked( int id , int old , int newc );


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

Jan Möbius's avatar
 
Jan Möbius committed
165 166
      /// 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
167

Jan Möbius's avatar
 
Jan Möbius committed
168 169
      /// called when an object is removed from the view
      void slotRowsRemoved ( const QModelIndex & _parent, int _start, int _end );
Jan Möbius's avatar
 
Jan Möbius committed
170 171 172

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
173 174 175 176 177 178 179
      //===========================================================================
      /** @name Popup Menu related
      * @{ */
      //===========================================================================
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
Jan Möbius's avatar
 
Jan Möbius committed
180

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

Jan Möbius's avatar
 
Jan Möbius committed
184 185
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
186

Jan Möbius's avatar
 
Jan Möbius committed
187 188
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
189

190 191 192
        /// Called by the popup menu to copy items
        void slotCopy();

Jan Möbius's avatar
 
Jan Möbius committed
193 194
        ///Called by the popup menu to rename items
        void slotRename ( );
Dirk Wilden's avatar
Dirk Wilden committed
195 196 197

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

Dirk Wilden's avatar
Dirk Wilden committed
199 200 201 202 203 204
        ///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
205 206 207
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
208

Jan Möbius's avatar
 
Jan Möbius committed
209
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
210

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

Jan Möbius's avatar
 
Jan Möbius committed
214 215 216
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
217 218 219

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
220 221 222 223
       //===========================================================================
      /** @name GL Area Context Menu related slots
      * @{ */
      //===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
224

Jan Möbius's avatar
 
Jan Möbius committed
225
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
226

Jan Möbius's avatar
 
Jan Möbius committed
227 228
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
229

Jan Möbius's avatar
 
Jan Möbius committed
230 231
        /// Target Selection
        void slotContextMenuTarget( );
Jan Möbius's avatar
 
Jan Möbius committed
232

Jan Möbius's avatar
 
Jan Möbius committed
233 234
        /// Source Selection
        void slotContextMenuSource( );
Jan Möbius's avatar
 
Jan Möbius committed
235

Jan Möbius's avatar
 
Jan Möbius committed
236 237
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
238

Jan Möbius's avatar
 
Jan Möbius committed
239 240 241
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Jan Möbius's avatar
 
Jan Möbius committed
242 243 244

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
245 246 247 248
      //===========================================================================
      /** @name Scripting functions
      * @{ */
      //===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
249

Dirk Wilden's avatar
Dirk Wilden committed
250 251 252
      private slots:
        void setDescriptions();

Jan Möbius's avatar
 
Jan Möbius committed
253 254 255
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
256

257 258 259
        /// Delete the given object
        void deleteObject(int objectId);

Jan Möbius's avatar
Jan Möbius committed
260 261 262
        /// Creates an object copy
        int copyObject( int objectId );

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

Jan Möbius's avatar
 
Jan Möbius committed
266 267
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
268

Jan Möbius's avatar
 
Jan Möbius committed
269
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
270 271
        void showObject( int objectId );

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 = "");

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

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

#endif //COLORPLUGIN_HH