DataControlPlugin.hh 8.69 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 15 16 17 18 19 20 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
//=============================================================================
//
//                               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.
// 
//  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.
// 
//  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"


/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection 
*/
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)
  Q_INTERFACES(ScriptInterface)      

  signals:
    /// Force Examiner widget to update their views
    void update_view();
    
    /// Emit this Signal, if object list has changed (e.g. Source or Target changed)
    void updated_objects(int);
    
    void activeObjectChanged();
    
    void log(Logtype _type, QString _message);
    void log(QString _message);
    
    void addContextMenu(QMenu* _menu );
    void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
      
   private slots :
      /// Updates the table widget
      void slotObjectUpdated( int _identifier );
      void slotActiveObjectChanged();
      
      void slotKeyEvent( QKeyEvent* _event );
      
      void loadIniFileOptions( INIFile& _ini );
      void saveIniFileOptions( INIFile& _ini );
      
      void pluginsInitialized();
      
   public :
 
     ~DataControlPlugin() {};


     /** Initialize the toolbar (create a widget in the right side toolbox)\n
      *   Creates Table and buttons */
     bool initializeToolbox(QWidget*& _widget);
     
     /// Sets examiner Widget (dummy here, using update_view signal here)
     void set_examiner(ACG::QtWidgets::QtExaminerViewer*  /* _examiner_widget */ ) { };
     
     /// Name of the Plugin 
     QString name(){ return (QString("DataControl")); };
     
     /// Description of the Plugin
     QString description() { return (QString("Manages Data Objects")); };
     
     /// User selected plugins Toolbox
      void toolboxActivated( bool /* _activated */   ) { }; 
      
      /// Update the visualization of the active objects
      void update_active( );
     
   private :
      /// Widget for Toolbox
      QWidget* tool_;
      
      /// Layout for Toolbox
      QGridLayout* MeshDialogLayout_;
      
      /// Table containing Mesh information and status
      QTableWidget* objectList_;
      
      /// Flag set to true if meshlist is updated, preventing signal for list udate to be called
      bool locked;
      
      /// The Treemodel organizing the data
      TreeModel* model_;   
         
      ///Tree view
      QTreeView* view_;
      
      /// Pointer to the header to the view widget
      QHeaderView * viewHeader_;
      
      /// Delegate for boolean values
      //QCheckBoxDelegate* checkboxDelegate_;
      

      
      ACG::QtWidgets::QtExaminerViewer*  examiner_widget_;
  
   private slots:
      
      /// This slot is called when the mesh selection changed in the table
      void slotCellClicked(int _row, int _col);
      
      /// Vertical header of the list has been clicked
      void verticalHeaderClicked( int _row );
      
      void verticalCountClicked( int id , int old , int newc ); 
      
      
      //===========================================================================
      /** @name Slots which are called if data changed
      * @{ */
      //===========================================================================
      
      /// Gets called when the data in the table has changed
      void slotDataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
      
      /// called when an object is removed from the view
      void slotRowsRemoved ( const QModelIndex & _parent, int _start, int _end );
      
      /** @} */ 
      
      //===========================================================================
      /** @name Popup Menu related
      * @{ */
      //===========================================================================
      private slots:
        /// Display a custom context window for the TreeView
        void slotCustomContextMenuRequested ( const QPoint & _pos );
        
        /// Called by the popup menu to remove an object/group
        void slotPopupRemove( );
        
        /// Called by the popup menu to ungroup items
        void slotUngroup ( );
    
        /// Called by the popup menu to group items
        void slotGroup ( );
        
        ///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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
      
      private :
        /// Index where a popup has been opened
        QModelIndex popupIndex_;
      
      private slots:
        
        /// Display a custom context window for the TreeViews header
        void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
        
      private:
        /// Defines the section of the Popup
        int headerPopupType_;
      
      /** @} */ 
      
       //===========================================================================
      /** @name GL Area Context Menu related slots
      * @{ */
      //===========================================================================
      
      private slots:
        
        /// Hide an object
        void slotContextMenuHide( );
        
        /// Target Selection
        void slotContextMenuTarget( );
        
        /// Source Selection
        void slotContextMenuSource( );
        
        /// Update the context Menus for the given id
        void slotUpdateContextMenu( int _objectId);
      
      private :
        QAction* targetAction_;
        QAction* sourceAction_;
        
      /** @} */ 
        
      //===========================================================================
      /** @name Scripting functions
      * @{ */
      //===========================================================================
      
      public slots:
        /// Get the Objects name from the id
        QString getObjectName( int objectId );
        
        /// Get the id of an object by its name
        int getObject( QString _name );
        
        /// Hide the given Object
        void hideObject( int objectId );
        
        /// Show the given Object
        void showObject( int objectId );        
        
        /// Makes all available objects target
        void setAllTarget();
        
        /// Makes all available objects source
        void setAllSource();
        
        /// Unselect all objects
        void clearAllTarget();
        
        /// remove source selection from all objects
        void clearAllSource();
        
        /// Shows all objects
        void showAll();
        
        /// Hides all objects
        void hideAll();
        
      /** @} */         
};

#endif //COLORPLUGIN_HH