From fb713e3a078af48f10315ff4078469a353d6146a Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 1 Jul 2005 08:23:24 +0000 Subject: [PATCH] Update flags and update() method added --- src/SalomeApp/Makefile.in | 7 ++-- src/SalomeApp/SalomeApp_Module.cxx | 59 +++++++++++++++++++++++++++ src/SalomeApp/SalomeApp_Module.h | 18 +++++--- src/SalomeApp/SalomeApp_Operation.cxx | 11 ++++- src/SalomeApp/SalomeApp_Operation.h | 3 ++ src/SalomeApp/SalomeApp_UpdateFlags.h | 37 +++++++++++++++++ 6 files changed, 125 insertions(+), 10 deletions(-) create mode 100755 src/SalomeApp/SalomeApp_UpdateFlags.h diff --git a/src/SalomeApp/Makefile.in b/src/SalomeApp/Makefile.in index 832308710..f5f7ac834 100755 --- a/src/SalomeApp/Makefile.in +++ b/src/SalomeApp/Makefile.in @@ -42,7 +42,8 @@ EXPORT_HEADERS= SalomeApp.h \ SalomeApp_StudyPropertiesDlg.h \ SalomeApp_CheckFileDlg.h \ SalomeApp_Operation.h \ - SalomeApp_Dialog.h + SalomeApp_Dialog.h \ + SalomeApp_UpdateFlags.h # .po files to transform in .qm PO_FILES = SalomeApp_images.po \ @@ -51,7 +52,8 @@ PO_FILES = SalomeApp_images.po \ # Libraries targets LIB = libSalomeApp.la -LIB_SRC= SalomeApp_AboutDlg.cxx \ +LIB_SRC= SalomeApp_Module.cxx \ + SalomeApp_AboutDlg.cxx \ SalomeApp_Application.cxx \ SalomeApp_DataModel.cxx \ SalomeApp_DataObject.cxx \ @@ -60,7 +62,6 @@ LIB_SRC= SalomeApp_AboutDlg.cxx \ SalomeApp_VTKSelector.cxx \ SalomeApp_OBSelector.cxx \ SalomeApp_GLSelector.cxx \ - SalomeApp_Module.cxx \ SalomeApp_Study.cxx \ SalomeApp_WidgetContainer.cxx \ SalomeApp_ExceptionHandler.cxx \ diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 75e3a8491..caa39a156 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -9,6 +9,7 @@ #include "SalomeApp_DataModel.h" #include "SalomeApp_Application.h" #include "SalomeApp_Preferences.h" +#include "SalomeApp_UpdateFlags.h" #include @@ -19,6 +20,13 @@ #include +#include +#include +#include +#include +#include +#include + SalomeApp_Module::SalomeApp_Module( const QString& name ) : CAM_Module( name ), myPopupMgr( 0 ) @@ -174,3 +182,54 @@ void SalomeApp_Module::setPreferenceProperty( const int id, const QString& prop, if ( pref ) pref->setProperty( id, prop, var ); } + +void SalomeApp_Module::update( const int flags ) +{ + if ( flags & UF_Model ) + { + if( CAM_DataModel* aDataModel = dataModel() ) + if( SalomeApp_DataModel* aModel = dynamic_cast( aDataModel ) ) + aModel->update( 0, dynamic_cast( getApp()->activeStudy() ) ); + } + else if ( flags & UF_ObjBrowser ) + getApp()->objectBrowser()->updateTree( 0 ); + else if ( flags & UF_Controls ) + updateControls(); + else if ( flags & UF_Viewer ) + { + if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() ) + if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() ) + { + if ( viewWnd->inherits( "SVTK_ViewWindow" ) ) + ( (SVTK_ViewWindow*)viewWnd )->Repaint(); + else if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) + ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate(); + else if ( viewWnd->inherits( "Plot2d_ViewWindow" ) ) + ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint(); + else if ( viewWnd->inherits( "GLViewer_ViewFrame" ) ) + ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate(); + } + } + +} + +void SalomeApp_Module::updateControls() +{ +} + + + + + + + + + + + + + + + + + diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 7ac602462..4ae6bea4c 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -58,12 +58,19 @@ public: virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); virtual void createPreferences(); - + // Convenient shortcuts SalomeApp_Application* getApp() const; - - void updateObjBrowser( bool = true, SUIT_DataObject* = 0 ); + virtual void update( const int ); + // Update viewer or/and object browser etc. in accordance with update flags + // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method + // for their own purposes + + void updateObjBrowser( bool = true, SUIT_DataObject* = 0 ); + // Update object bropwser ( for updating model or whole object browser use update() method + // can be used ) + virtual void selectionChanged(); virtual void preferencesChanged( const QString&, const QString& ); @@ -86,11 +93,12 @@ protected: virtual CAM_DataModel* createDataModel(); virtual SalomeApp_Selection* createSelection() const; + virtual void updateControls(); int addPreference( const QString& label ); int addPreference( const QString& label, const int pId, const int = -1, - const QString& section = QString::null, - const QString& param = QString::null ); + const QString& section = QString::null, + const QString& param = QString::null ); QVariant preferenceProperty( const int, const QString& ) const; void setPreferenceProperty( const int, const QString&, const QVariant& ); diff --git a/src/SalomeApp/SalomeApp_Operation.cxx b/src/SalomeApp/SalomeApp_Operation.cxx index b9d32c464..d5ca2fea7 100755 --- a/src/SalomeApp/SalomeApp_Operation.cxx +++ b/src/SalomeApp/SalomeApp_Operation.cxx @@ -208,8 +208,15 @@ bool SalomeApp_Operation::eventFilter( QObject* obj, QEvent* e ) return SUIT_Operation::eventFilter( obj, e ); } - - +//======================================================================= +// name : eventFilter +// Purpose : Block mouse and key events if operator is not active one +//======================================================================= +void SalomeApp_Operation::update( const int flags ) +{ + if ( myModule != 0 ) + myModule->update( flags ); +} diff --git a/src/SalomeApp/SalomeApp_Operation.h b/src/SalomeApp/SalomeApp_Operation.h index 0f767ad81..c6c1875b7 100755 --- a/src/SalomeApp/SalomeApp_Operation.h +++ b/src/SalomeApp/SalomeApp_Operation.h @@ -89,6 +89,9 @@ protected: SalomeApp_SelectionMgr* selectionMgr() const; // Get selection manager + void update( const int ); + // Call update() method of module ( see SalomeApp_Module for description ) + private slots: virtual void onSelectionDone(); diff --git a/src/SalomeApp/SalomeApp_UpdateFlags.h b/src/SalomeApp/SalomeApp_UpdateFlags.h new file mode 100755 index 000000000..7943ac23e --- /dev/null +++ b/src/SalomeApp/SalomeApp_UpdateFlags.h @@ -0,0 +1,37 @@ +// SALOME SalomeApp +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : SalomeApp_UpdateFlags.h +// Author : Sergey LITONIN +// Module : SALOME + + +#ifndef SalomeApp_UpdateFlags_H +#define SalomeApp_UpdateFlags_H + +/* + Enum : UpdateFlags + Description : Enumeration for update flags. First byte is reserved for SalomeApp_Module. + Modules derived from this model must use other 3 bytes to define their + own update flags +*/ + +typedef enum +{ + UF_Forced = 0x00000001, + UF_Model = 0x00000002, + UF_Viewer = 0x00000004, + UF_ObjBrowser = 0x00000008, + UF_Controls = 0x00000010, +} UpdateFlags; + +#endif + + + + + + -- 2.39.2