From: asl Date: Thu, 7 Jul 2005 09:05:05 +0000 (+0000) Subject: new methods: X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3c9a86622345c5bf6d020834850f9b4e5affc246;p=modules%2Fsmesh.git new methods: 1) selected - returns the selection ready to pass to dialog::selectObject 2) prefix - returns the int prefix for types corresponding to some groups (GEOM, SMESH, for example) 3) setDialogActive - allows to set dialog content enable or disable 4) slots onOk, onApply, onCancel - they will be connected automatically in startOperation if dialog has corresponding buttons --- diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index b2af6a075..256a7aee8 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -35,10 +35,9 @@ // name : SMESHGUI_Operation // Purpose : Constructor //======================================================================= -SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app ) -: SalomeApp_Operation( app ) +SMESHGUI_Operation::SMESHGUI_Operation() +: SalomeApp_Operation() { - } SMESHGUI_Operation::~SMESHGUI_Operation() @@ -116,6 +115,22 @@ SVTK_Selector* SMESHGUI_Operation::selector() const //======================================================================= void SMESHGUI_Operation::startOperation() { + if( dlg() ) + { + disconnect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + disconnect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); + disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + + if( dlg()->testButtonFlags( QtxDialog::OK ) ) + connect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + + if( dlg()->testButtonFlags( QtxDialog::Apply ) ) + connect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); + + if( dlg()->testButtonFlags( QtxDialog::Cancel ) ) + connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + } + SalomeApp_Operation::startOperation(); } @@ -175,7 +190,7 @@ int SMESHGUI_Operation::typeById( const QString& str, const SelectedObjectType o else { int pos = str.find( idChar() ); - QString entry = str.left( pos-1 ), + QString entry = str.left( pos ), _id = str.mid( pos+1 ); bool ok; int id = _id.toInt( &ok ); @@ -199,7 +214,7 @@ int SMESHGUI_Operation::typeById( const QString& str, const SelectedObjectType o // name : prefix // Purpose : Get prefix for module types //======================================================================= -int SMESHGUI_Operation::prefix( const QString& name ) const +int SMESHGUI_Operation::prefix( const QString& name ) { if( name == "GEOM" ) return 100; @@ -260,3 +275,78 @@ QChar SMESHGUI_Operation::idChar() const { return '#'; } + +//======================================================================= +// name : setDialogActive +// Purpose : +//======================================================================= +void SMESHGUI_Operation::setDialogActive( const bool active ) +{ + SalomeApp_Operation::setDialogActive( active ); + + SMESHGUI_Dialog* d = dynamic_cast( dlg() ); + if( d ) + d->setContentActive( active ); + +} + +//======================================================================= +// name : studyDS +// Purpose : +//======================================================================= +_PTR(Study) SMESHGUI_Operation::studyDS() const +{ + SalomeApp_Study* s = dynamic_cast( study() ); + if( s ) + return s->studyDS(); +} + +//======================================================================= +// name : onOk +// Purpose : +//======================================================================= +void SMESHGUI_Operation::onOk() +{ + if( onApply() ) + commit(); + else + abort(); +} + +//======================================================================= +// name : onApply +// Purpose : +//======================================================================= +bool SMESHGUI_Operation::onApply() +{ + return false; +} + +//======================================================================= +// name : onClose +// Purpose : +//======================================================================= +void SMESHGUI_Operation::onCancel() +{ + abort(); +} + +//======================================================================= +// name : commitOperation +// Purpose : +//======================================================================= +void SMESHGUI_Operation::commitOperation() +{ + selectionMgr()->clearFilters(); + SalomeApp_Operation::commitOperation(); +} + +//======================================================================= +// name : abortOperation +// Purpose : +//======================================================================= +void SMESHGUI_Operation::abortOperation() +{ + selectionMgr()->clearFilters(); + SalomeApp_Operation::abortOperation(); +} diff --git a/src/SMESHGUI/SMESHGUI_Operation.h b/src/SMESHGUI/SMESHGUI_Operation.h index a0af7f0b2..110357b33 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.h +++ b/src/SMESHGUI/SMESHGUI_Operation.h @@ -13,9 +13,12 @@ #define SMESHGUI_Operation_H #include +#include #include #include +#include + class SMESHGUI; class SVTK_ViewWindow; class SVTK_Selector; @@ -32,9 +35,12 @@ class SMESHGUI_Operation : public SalomeApp_Operation Q_OBJECT public: - SMESHGUI_Operation( SalomeApp_Application* ); + SMESHGUI_Operation(); virtual ~SMESHGUI_Operation(); + static int prefix( const QString& ); + // Return hard-coded prefix using to differ intersecting types + protected: typedef enum { @@ -52,27 +58,33 @@ protected: const TColStd_MapOfInteger&, const bool ); virtual void startOperation(); + virtual void commitOperation(); + virtual void abortOperation(); virtual bool isReadyToStart(); SMESHGUI* getSMESHGUI() const; SVTK_ViewWindow* viewWindow() const; SVTK_Selector* selector() const; + _PTR(Study) studyDS() const; - virtual int prefix( const QString& ) const; - // Return hard-coded prefix using to differ intersecting types - - virtual void selected( QStringList&, SalomeApp_Dialog::TypesList&, QStringList& ) const; - // Get names, types and ids of selected objects - + //! Get names, types and ids of selected objects + virtual void selected( QStringList&, SMESHGUI_Dialog::TypesList&, QStringList& ) const; + + //! Find type by id virtual int typeById( const QString&, const SelectedObjectType ) const; - // Find type by id - + + //! Char using to divide and in string id representation. By default, '#' virtual QChar idChar() const; - // Char using to divide and in string id representation - // By default, '#' + //! Set accroding dialog active or inactive + virtual void setDialogActive( const bool ); + +protected slots: + virtual void onOk(); + virtual bool onApply(); + virtual void onCancel(); }; #endif