DataControlPlugin.hh 8.32 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

Jan Möbius's avatar
 
Jan Möbius committed
87 88 89 90
   private slots :
      /// Updates the table widget
      void slotObjectUpdated( int _identifier );
      void slotActiveObjectChanged();
Jan Möbius's avatar
 
Jan Möbius committed
91

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

Jan Möbius's avatar
 
Jan Möbius committed
94 95
      void loadIniFileOptions( INIFile& _ini );
      void saveIniFileOptions( INIFile& _ini );
Jan Möbius's avatar
 
Jan Möbius committed
96

Jan Möbius's avatar
 
Jan Möbius committed
97
      void pluginsInitialized();
Jan Möbius's avatar
 
Jan Möbius committed
98

Jan Möbius's avatar
 
Jan Möbius committed
99
   public :
Jan Möbius's avatar
 
Jan Möbius committed
100

Jan Möbius's avatar
 
Jan Möbius committed
101 102 103 104 105 106
     ~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
107

Jan Möbius's avatar
 
Jan Möbius committed
108 109
     /// 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
110 111

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

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

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

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

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

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

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

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

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

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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
148 149


Jan Möbius's avatar
 
Jan Möbius committed
150
      ACG::QtWidgets::QtExaminerViewer*  examiner_widget_;
Jan Möbius's avatar
 
Jan Möbius committed
151

Jan Möbius's avatar
 
Jan Möbius committed
152
   private slots:
Jan Möbius's avatar
 
Jan Möbius committed
153

Jan Möbius's avatar
 
Jan Möbius committed
154 155
      /// 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
156

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

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


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

Jan Möbius's avatar
 
Jan Möbius committed
168 169
      /// 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
170

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

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
176 177 178 179 180 181 182
      //===========================================================================
      /** @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
183

Jan Möbius's avatar
 
Jan Möbius committed
184 185
        /// Called by the popup menu to remove an object/group
        void slotPopupRemove( );
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 ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
189

Jan Möbius's avatar
 
Jan Möbius committed
190 191
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
192

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

Jan Möbius's avatar
 
Jan Möbius committed
199 200 201
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
Jan Möbius's avatar
 
Jan Möbius committed
202

Jan Möbius's avatar
 
Jan Möbius committed
203
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
204

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

Jan Möbius's avatar
 
Jan Möbius committed
208 209 210
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
Jan Möbius's avatar
 
Jan Möbius committed
211 212 213

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
214 215 216 217
       //===========================================================================
      /** @name GL Area Context Menu related slots
      * @{ */
      //===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
218

Jan Möbius's avatar
 
Jan Möbius committed
219
      private slots:
Jan Möbius's avatar
 
Jan Möbius committed
220

Jan Möbius's avatar
 
Jan Möbius committed
221 222
        /// Hide an object
        void slotContextMenuHide( );
Jan Möbius's avatar
 
Jan Möbius committed
223

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

Jan Möbius's avatar
 
Jan Möbius committed
227 228
        /// Source Selection
        void slotContextMenuSource( );
Jan Möbius's avatar
 
Jan Möbius committed
229

Jan Möbius's avatar
 
Jan Möbius committed
230 231
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
Jan Möbius's avatar
 
Jan Möbius committed
232

Jan Möbius's avatar
 
Jan Möbius committed
233 234 235
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
Jan Möbius's avatar
 
Jan Möbius committed
236 237 238

      /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
239 240 241 242
      //===========================================================================
      /** @name Scripting functions
      * @{ */
      //===========================================================================
Jan Möbius's avatar
 
Jan Möbius committed
243

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

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

Jan Möbius's avatar
 
Jan Möbius committed
251 252
        /// Hide the given Object
        void hideObject( int objectId );
Jan Möbius's avatar
 
Jan Möbius committed
253

Jan Möbius's avatar
 
Jan Möbius committed
254
        /// Show the given Object
Jan Möbius's avatar
 
Jan Möbius committed
255 256
        void showObject( int objectId );

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 275 276 277 278

      /** @} */

  public slots:
    QString version() { return QString("1.0"); };
Jan Möbius's avatar
 
Jan Möbius committed
279 280 281
};

#endif //COLORPLUGIN_HH