DataControlPlugin.hh 8.67 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 50 51 52 53 54 55 56 57
//  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/GlobalAccessInterface.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 <ACG/QtWidgets/QtExaminerViewer.hh>
#include <OpenFlipper/common/Types.hh>

//#include "QCheckBoxDelegate.hh"

#include "TreeModel.hh"


Jan Möbius's avatar
 
Jan Möbius committed
58
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
Jan Möbius's avatar
 
Jan Möbius committed
59 60 61 62 63 64 65 66 67 68 69
*/
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, GlobalAccessInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(GlobalAccessInterface)
  Q_INTERFACES(KeyInterface)
  Q_INTERFACES(LoggingInterface)
  Q_INTERFACES(INIInterface)
  Q_INTERFACES(ContextMenuInterface)
Jan Möbius's avatar
 
Jan Möbius committed
70
  Q_INTERFACES(ScriptInterface)
Jan Möbius's avatar
 
Jan Möbius committed
71 72 73 74

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

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

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 99
      void loadIniFileOptions( INIFile& _ini );
      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

Jan Möbius's avatar
 
Jan Möbius committed
112 113
     /// Sets examiner Widget (dummy here, using update_view signal here)
     void set_examiner(ACG::QtWidgets::QtExaminerViewer*  /* _examiner_widget */ ) { };
Jan Möbius's avatar
 
Jan Möbius committed
114 115

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

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

Jan Möbius's avatar
 
Jan Möbius committed
121
     /// User selected plugins Toolbox
Jan Möbius's avatar
 
Jan Möbius committed
122 123
      void toolboxActivated( bool /* _activated */   ) { };

Jan Möbius's avatar
 
Jan Möbius committed
124 125
      /// Update the visualization of the active objects
      void update_active( );
Jan Möbius's avatar
 
Jan Möbius committed
126

Jan Möbius's avatar
 
Jan Möbius committed
127 128 129
   private :
      /// Widget for Toolbox
      QWidget* tool_;
Jan Möbius's avatar
 
Jan Möbius committed
130

Jan Möbius's avatar
 
Jan Möbius committed
131 132
      /// Layout for Toolbox
      QGridLayout* MeshDialogLayout_;
Jan Möbius's avatar
 
Jan Möbius committed
133

Jan Möbius's avatar
 
Jan Möbius committed
134 135
      /// Table containing Mesh information and status
      QTableWidget* objectList_;
Jan Möbius's avatar
 
Jan Möbius committed
136

Jan Möbius's avatar
 
Jan Möbius committed
137 138
      /// 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
139

Jan Möbius's avatar
 
Jan Möbius committed
140
      /// The Treemodel organizing the data
Jan Möbius's avatar
 
Jan Möbius committed
141 142
      TreeModel* model_;

Jan Möbius's avatar
 
Jan Möbius committed
143 144
      ///Tree view
      QTreeView* view_;
Jan Möbius's avatar
 
Jan Möbius committed
145

Jan Möbius's avatar
 
Jan Möbius committed
146 147
      /// Pointer to the header to the view widget
      QHeaderView * viewHeader_;
Jan Möbius's avatar
 
Jan Möbius committed
148

Jan Möbius's avatar
 
Jan Möbius committed
149 150 151
      /// Delegate for boolean values
      //QCheckBoxDelegate* checkboxDelegate_;

Jan Möbius's avatar
 
Jan Möbius committed
152 153


Jan Möbius's avatar
 
Jan Möbius committed
154
      ACG::QtWidgets::QtExaminerViewer*  examiner_widget_;
Jan Möbius's avatar
 
Jan Möbius committed
155

Jan Möbius's avatar
 
Jan Möbius committed
156
   private slots:
Jan Möbius's avatar
 
Jan Möbius committed
157

Jan Möbius's avatar
 
Jan Möbius committed
158 159
      /// 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
160

Jan Möbius's avatar
 
Jan Möbius committed
161 162
      /// Vertical header of the list has been clicked
      void verticalHeaderClicked( int _row );
Jan Möbius's avatar
 
Jan Möbius committed
163 164 165 166

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


Jan Möbius's avatar
 
Jan Möbius committed
167 168 169 170
      //===========================================================================
      /** @name Slots which are called if data changed
      * @{ */
      //===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
171

Jan Möbius's avatar
 
Jan Möbius committed
172 173
      /// 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
174

Jan Möbius's avatar
 
Jan Möbius committed
175 176
      /// 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
177 178 179

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
180 181 182 183 184 185 186
      //===========================================================================
      /** @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
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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
203 204 205
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
206

Jan Möbius's avatar
 
Jan Möbius committed
207
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
208

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

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

      /** @} */

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

Jan Möbius's avatar
 
Jan Möbius committed
223
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
224

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

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

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

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

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

      /** @} */

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

Dirk Wilden's avatar
Dirk Wilden committed
248 249 250
      private slots:
        void setDescriptions();

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

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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
264 265
        /// Makes all available objects target
        void setAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
266

Jan Möbius's avatar
 
Jan Möbius committed
267 268
        /// Makes all available objects source
        void setAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
269

Jan Möbius's avatar
 
Jan Möbius committed
270 271
        /// Unselect all objects
        void clearAllTarget();
Jan Möbius's avatar
 
Jan Möbius committed
272

Jan Möbius's avatar
 
Jan Möbius committed
273 274
        /// remove source selection from all objects
        void clearAllSource();
Jan Möbius's avatar
 
Jan Möbius committed
275

Jan Möbius's avatar
 
Jan Möbius committed
276 277
        /// Shows all objects
        void showAll();
Jan Möbius's avatar
 
Jan Möbius committed
278

Jan Möbius's avatar
 
Jan Möbius committed
279 280
        /// Hides all objects
        void hideAll();
Jan Möbius's avatar
 
Jan Möbius committed
281

Dirk Wilden's avatar
Dirk Wilden committed
282 283 284
        /// Group objects together
        void groupObjects(idList _objectIDs, QString _groupName = "");

Jan Möbius's avatar
 
Jan Möbius committed
285 286 287 288
      /** @} */

  public slots:
    QString version() { return QString("1.0"); };
Jan Möbius's avatar
 
Jan Möbius committed
289 290 291
};

#endif //COLORPLUGIN_HH