From: sln Date: Fri, 1 Jul 2005 06:27:43 +0000 (+0000) Subject: new files for dialog and operation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=949d8df2c51755f473198e1cd30a373caf75fe2a;p=modules%2Fsmesh.git new files for dialog and operation --- diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index 2833cf2a3..76b193bf3 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -106,7 +106,8 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_PrecisionDlg.cxx \ SMESHGUI_VTKUtils.cxx \ SMESHGUI_Selection.cxx \ - SMESHGUI_CreatePolyhedralVolumeDlg.cxx + SMESHGUI_CreatePolyhedralVolumeDlg.cxx \ + SMESHGUI_Operation.cxx LIB_MOC = \ SMESHGUI.h \ @@ -149,7 +150,8 @@ LIB_MOC = \ SMESHGUI_SewingDlg.h \ SMESHGUI_PrecisionDlg.h \ SMESHGUI_MergeNodesDlg.h \ - SMESHGUI_CreatePolyhedralVolumeDlg.h + SMESHGUI_CreatePolyhedralVolumeDlg.h \ + SMESHGUI_Operation.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 6a7cd010a..55224d159 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -99,6 +99,7 @@ #include "SalomeApp_Application.h" #include "SalomeApp_Preferences.h" #include "SalomeApp_VTKSelector.h" +#include "SalomeApp_Operation.h" #include "SalomeApp_ImportOperation.h" @@ -1099,6 +1100,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) if( !mgr ) return false; + SUIT_Operation* anOp = getOperation( theCommandID ); + if ( anOp != 0 ) + { + anOp->start(); + return true; + } + SUIT_ViewWindow* view = application()->desktop()->activeWindow(); SVTK_ViewWindow* vtkwnd = dynamic_cast( view ); @@ -3212,3 +3220,74 @@ void SMESHGUI::createPreferences() void SMESHGUI::preferencesChanged( const QString&, const QString& ) { } + +//======================================================================= +// function : onOperationCommited +// purpose : SLOT called when operation commited. Set default selection mode +//======================================================================= +void SMESHGUI::onOperationCommited( SUIT_Operation* ) +{ + SVTK_ViewWindow* vtkWnd = + dynamic_cast( application()->desktop()->activeWindow() ); + if ( vtkWnd ) + vtkWnd->SetSelectionMode( ActorSelection ); +} + +//======================================================================= +// function : onOperationAborted +// purpose : SLOT called when operation commited. Set default selection mode +//======================================================================= +void SMESHGUI::onOperationAborted( SUIT_Operation* ) +{ + SVTK_ViewWindow* vtkWnd = + dynamic_cast( application()->desktop()->activeWindow() ); + if ( vtkWnd ) + vtkWnd->SetSelectionMode( ActorSelection ); +} + +//======================================================================= +// function : getOperation +// purpose : Get operation corresponding to the given Id +//======================================================================= +SalomeApp_Operation* SMESHGUI::getOperation( const int theId ) +{ + if ( myOperations.contains( theId ) ) + return myOperations[ theId ]; + + // to do: + SalomeApp_Operation* anOp = 0; + /*switch( theId ) + { + case ... : + anOp = ...; + break; + }*/ + + if ( anOp != 0 ) + { + anOp->setModule( this ); + connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ), + this, SLOT( onOperationAborted( SUIT_Operation* ) ) ); + connect( anOp, SIGNAL( commited( SUIT_Operation* ) ), + this, SLOT( onOperationCommited( SUIT_Operation* ) ) ); + myOperations[ theId ] = anOp; + + } + + return anOp; +} + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 396de4b86..2c9680017 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -43,9 +43,11 @@ class SUIT_Study; class SUIT_ViewWindow; class SUIT_ResourceMgr; class SUIT_ViewManager; +class SUIT_Operation; class SalomeApp_Study; class SalomeApp_SelectionMgr; +class SalomeApp_Operation; //================================================================================= @@ -108,6 +110,8 @@ public slots: private slots: void OnGUIEvent(); void onViewManagerAdded( SUIT_ViewManager* ); + void onOperationCommited( SUIT_Operation* ); + void onOperationAborted( SUIT_Operation* ); signals: void SignalDeactivateActiveDialog() ; @@ -120,11 +124,14 @@ protected: void createPopupItem( const int, const QString&, const QString&, const QString& = QString::null, const int = -1 ); + SalomeApp_Operation* getOperation( const int ); + private : static SMESH::SMESH_Gen_var myComponentSMESH; QDialog* myActiveDialogBox; int myState; QMap myRules; + QMap myOperations; }; #endif diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx new file mode 100755 index 000000000..f9a19802f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -0,0 +1,35 @@ +// SALOME SMESHGUI +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : SMESHGUI_Operation.h +// Author : Sergey LITONIN +// Module : SALOME + +#include "SMESHGUI_Operation.h" + + +/* + Class : SMESHGUI_Operation + Description : Base class for all SMESH operations +*/ + +//======================================================================= +// name : SMESHGUI_Operation +// Purpose : Constructor +//======================================================================= +SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* theApp ) +: SalomeApp_Operation( theApp ) +{ + +} + +SMESHGUI_Operation::~SMESHGUI_Operation() +{ + +} + + + diff --git a/src/SMESHGUI/SMESHGUI_Operation.h b/src/SMESHGUI/SMESHGUI_Operation.h new file mode 100755 index 000000000..95e2ce03e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Operation.h @@ -0,0 +1,39 @@ +// SALOME SMESHGUI +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : SMESHGUI_Operation.h +// Author : Sergey LITONIN +// Module : SALOME + + +#ifndef SMESHGUI_Operation_H +#define SMESHGUI_Operation_H + +#include + +/* + Class : SMESHGUI_Operation + Description : Base class for all SMESH operations +*/ + +class SMESHGUI_Operation : public SalomeApp_Operation +{ + Q_OBJECT + +public: + + SMESHGUI_Operation( SalomeApp_Application* ); + virtual ~SMESHGUI_Operation(); + +}; + +#endif + + + + + +