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
This commit is contained in:
asl 2005-07-07 09:05:05 +00:00
parent 4e65ec6527
commit 3c9a866223
2 changed files with 120 additions and 18 deletions

View File

@ -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<SMESHGUI_Dialog*>( dlg() );
if( d )
d->setContentActive( active );
}
//=======================================================================
// name : studyDS
// Purpose :
//=======================================================================
_PTR(Study) SMESHGUI_Operation::studyDS() const
{
SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( 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();
}

View File

@ -13,9 +13,12 @@
#define SMESHGUI_Operation_H
#include <SalomeApp_Operation.h>
#include <SMESHGUI_Dialog.h>
#include <SALOME_InteractiveObject.hxx>
#include <SVTK_Selection.h>
#include <SALOMEDSClient.hxx>
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 <entry> and <id> in string id representation. By default, '#'
virtual QChar idChar() const;
// Char using to divide <entry> and <id> 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