// Author : Sergey LITONIN
// Module : SALOME
-#include <SMESHGUI_Operation.h>
+#include "SMESHGUI_Operation.h"
#include <SMESHGUI.h>
-#include <SMESHGUI_VTKUtils.h>
+#include <SMESHGUI_Dialog.h>
-#include <SVTK_ViewWindow.h>
-#include <SVTK_Selector.h>
+#include <SalomeApp_Study.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
/*
Class : SMESHGUI_Operation
// name : SMESHGUI_Operation
// Purpose : Constructor
//=======================================================================
-SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app )
-: SalomeApp_Operation( app ),
- myViewWindow( 0 ),
- mySelector( 0 )
+SMESHGUI_Operation::SMESHGUI_Operation()
+: SalomeApp_Operation()
{
-
}
+//=======================================================================
+// name : ~SMESHGUI_Operation
+// Purpose : Destructor
+//=======================================================================
SMESHGUI_Operation::~SMESHGUI_Operation()
{
+}
+
+//=======================================================================
+// name : getSMESHGUI
+// Purpose : Get SMESH module
+//=======================================================================
+SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
+{
+ return dynamic_cast<SMESHGUI*>( module() );
+}
+
+//=======================================================================
+// name : startOperation
+// Purpose : Start opeartion
+//=======================================================================
+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() ) );
+ disconnect( dlg(), SIGNAL( dlgClose() ), 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() ) );
+
+ //if( dlg()->testButtonFlags( QtxDialog::Close ) )
+ //if dialog hasn't close, cancel, no and etc buttons, dlgClose will be emitted when dialog is closed not by OK
+ connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+
+ initDialog();
+ }
+
+ SalomeApp_Operation::startOperation();
+}
+
+//=======================================================================
+// name : isReadyToStart
+// Purpose : Verify whether operation is ready to start
+//=======================================================================
+bool SMESHGUI_Operation::isReadyToStart() const
+{
+ if ( !SalomeApp_Operation::isReadyToStart() )
+ return false;
+ else if ( getSMESHGUI() == 0 )
+ {
+ SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
+ tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
+ return false;
+ }
+ return true;
}
-void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode )
+//=======================================================================
+// name : setDialogActive
+// Purpose :
+//=======================================================================
+void SMESHGUI_Operation::setDialogActive( const bool active )
{
- if( myViewWindow )
- myViewWindow->SetSelectionMode( mode );
+ SalomeApp_Operation::setDialogActive( active );
+
+ SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
+ if( d )
+ d->setContentActive( active );
+
}
-void SMESHGUI_Operation::highlight( const Handle( SALOME_InteractiveObject )& obj,
- const bool hilight, const bool immediately )
+//=======================================================================
+// name : studyDS
+// Purpose :
+//=======================================================================
+_PTR(Study) SMESHGUI_Operation::studyDS() const
{
- if( myViewWindow )
- myViewWindow->highlight( obj, hilight, immediately );
+ SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study() );
+ return s->studyDS();
}
-void SMESHGUI_Operation::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj,
- const TColStd_MapOfInteger& indices, const bool isModeShift )
+//=======================================================================
+// name : onOk
+// Purpose :
+//=======================================================================
+void SMESHGUI_Operation::onOk()
{
- if( mySelector )
- mySelector->AddOrRemoveIndex( obj, indices, isModeShift );
+ if( onApply() )
+ commit();
+ else
+ abort();
}
-SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
+//=======================================================================
+// name : onApply
+// Purpose :
+//=======================================================================
+bool SMESHGUI_Operation::onApply()
{
- return dynamic_cast<SMESHGUI*>( module() );
+ return false;
+}
+
+//=======================================================================
+// name : onClose
+// Purpose :
+//=======================================================================
+void SMESHGUI_Operation::onCancel()
+{
+ abort();
}
-SVTK_ViewWindow* SMESHGUI_Operation::getViewWindow() const
+//=======================================================================
+// name : initDialog
+// Purpose :
+//=======================================================================
+void SMESHGUI_Operation::initDialog()
{
- return myViewWindow;
}
-SVTK_Selector* SMESHGUI_Operation::getSelector() const
+/*!
+ * \brief Verifies whether study of operation is locked
+ * \param theMess - specifies whether message box must be shown if study is locked
+ * \return State of study.
+*
+* Verifies whether study of operation is locked. If second parameter is TRUE and study
+* is locked when corresponding message box appears
+*/
+bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const
{
- return mySelector;
+ if ( studyDS() )
+ {
+ if ( studyDS()->GetProperties()->IsLocked() )
+ {
+ if ( theMess )
+ SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "WRN_STUDY_LOCKED" ), QObject::tr( "BUT_OK" ) );
+ return true;
+ }
+ }
+
+ return false;
}
-void SMESHGUI_Operation::startOperation()
+//=======================================================================
+// name : isValid
+// Purpose :
+//=======================================================================
+bool SMESHGUI_Operation::isValid( SUIT_Operation* op ) const
{
- SalomeApp_Operation::startOperation();
- myViewWindow = SMESH::GetViewWindow( getSMESHGUI() );
- mySelector = myViewWindow ? myViewWindow->GetSelector() : 0;
+ return( op && op->inherits( "SMESHGUI_Operation" ) );
}