DataControlPlugin.hh 8.71 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
//  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>
52
#include "Toolbox.hh"
Jan Möbius's avatar
 
Jan Möbius committed
53 54 55 56 57 58

//#include "QCheckBoxDelegate.hh"

#include "TreeModel.hh"


Jan Möbius's avatar
 
Jan Möbius committed
59
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
Jan Möbius's avatar
 
Jan Möbius committed
60 61 62 63 64 65 66 67 68 69 70
*/
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
71
  Q_INTERFACES(ScriptInterface)
Jan Möbius's avatar
 
Jan Möbius committed
72 73 74 75

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

Jan Möbius's avatar
 
Jan Möbius committed
77 78
    /// 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
79

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

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

Jan Möbius's avatar
 
Jan Möbius committed
85 86
    void addContextMenu(QMenu* _menu );
    void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
Jan Möbius's avatar
 
Jan Möbius committed
87

Dirk Wilden's avatar
Dirk Wilden committed
88 89 90 91
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);


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

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

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

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

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

Jan Möbius's avatar
 
Jan Möbius committed
113 114
     /// 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
115 116

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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


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

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

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

      /** @} */

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

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

Jan Möbius's avatar
 
Jan Möbius committed
192 193
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
194

Jan Möbius's avatar
 
Jan Möbius committed
195 196
        /// Called by the popup menu to group items
        void slotGroup ( );
Jan Möbius's avatar
 
Jan Möbius committed
197

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

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

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

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

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

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

      /** @} */

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

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

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

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

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

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

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

      /** @} */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#endif //COLORPLUGIN_HH