+ LightApp_Operation::commitOperation();
+ closeInputPanel();
+}
+
+void HYDROGUI_Operation::stopOperation()
+{
+ LightApp_Operation::stopOperation();
+
+ // pop the operation from the cached map of active operations
+ QStack<HYDROGUI_Operation*>& anOperations = myModule->getActiveOperations();
+ if ( !anOperations.empty() ) {
+ if ( anOperations.top() == this )
+ anOperations.pop();
+ else
+ {
+ // find in the stack the current operation and remove it from the stack
+ QVectorIterator<HYDROGUI_Operation*> aVIt( anOperations );
+ aVIt.toBack();
+ aVIt.previous(); // skip the top show/hide operation
+ while ( aVIt.hasPrevious() )
+ {
+ HYDROGUI_Operation* anOp = aVIt.previous();
+ if ( anOp == this )
+ anOperations.remove( anOperations.lastIndexOf( anOp ) );
+ }
+ }
+ }
+ // release the preview manager with removing the added preview Z layer
+ setPreviewManager( 0 );
+}
+
+void HYDROGUI_Operation::setDialogActive( const bool active )
+{
+ LightApp_Operation::setDialogActive( active );
+ if( myPanel )
+ {
+ if( active )
+ {
+ myPanel->show();
+ }
+ }
+}
+
+HYDROGUI_InputPanel* HYDROGUI_Operation::createInputPanel() const
+{
+ return NULL;
+}
+
+void HYDROGUI_Operation::closeInputPanel()
+{
+ if( myPanel )
+ {
+ myModule->getApp()->desktop()->removeDockWidget( myPanel );
+ delete myPanel;
+ myPanel = 0;
+ }
+}
+
+bool HYDROGUI_Operation::processApply( int& theUpdateFlags,
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
+{
+ return false;
+}
+
+void HYDROGUI_Operation::processCancel()
+{
+}
+
+void HYDROGUI_Operation::startDocOperation()
+{
+ // Open transaction in the model document only if it not
+ // already opened by other operation (intended for nested operations)
+ if ( !doc()->IsOperation() )
+ {
+ doc()->StartOperation();
+ myIsTransactionOpened = true;
+ }
+}
+
+void HYDROGUI_Operation::abortDocOperation()
+{
+ // Abort transaction in the model document only if it was
+ // opened by this operation (intended for nested operations)
+ if ( myIsTransactionOpened && doc()->IsOperation() )
+ {
+ doc()->AbortOperation();
+ myIsTransactionOpened = false;
+ }
+}
+
+void HYDROGUI_Operation::commitDocOperation()
+{
+ // Commit transaction in the model document only if it was
+ // opened by this operation (intended for nested operations)
+ if ( myIsTransactionOpened && doc()->IsOperation() )
+ {
+ doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
+ myIsTransactionOpened = false;
+ }
+}
+
+Handle_HYDROData_Document HYDROGUI_Operation::doc() const
+{
+ return HYDROData_Document::Document( myModule->getStudyId() );
+}
+
+void HYDROGUI_Operation::onApply()
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ startDocOperation();
+
+ int anUpdateFlags = 0;
+ QString anErrorMsg;
+
+ bool aResult = false;
+ QStringList aBrowseObjectsEntries;
+
+ try
+ {
+ aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
+ }
+ catch ( Standard_Failure )
+ {
+ Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+ anErrorMsg = aFailure->GetMessageString();
+ aResult = false;
+ }
+ catch ( ... )
+ {
+ aResult = false;
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ if ( aResult )
+ {
+ module()->update( anUpdateFlags );
+ commitDocOperation();
+ commit();
+ browseObjects( aBrowseObjectsEntries );
+ }
+ else
+ {
+ // Abort document opeartion only if requested
+ if ( isToAbortOnApply() )
+ abortDocOperation();
+
+ printErrorMessage( anErrorMsg );
+
+ // If the operation has no input panel - do abort
+ if ( !inputPanel() ) {
+ abort();
+ }
+ }
+}
+
+void HYDROGUI_Operation::setPrintErrorMessage( const bool theIsPrint )
+{
+ myIsPrintErrorMessage = theIsPrint;
+}
+
+void HYDROGUI_Operation::printErrorMessage( const QString& theErrorMsg )
+{
+ if ( myIsPrintErrorMessage )
+ {
+ QString aMsg = tr( "INPUT_VALID_DATA" );
+ if( !theErrorMsg.isEmpty() )
+ aMsg.prepend( theErrorMsg + "\n" );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ tr( "INSUFFICIENT_INPUT_DATA" ),
+ aMsg );
+
+ }
+
+ myIsPrintErrorMessage = true;
+}
+
+void HYDROGUI_Operation::onCancel()
+{
+ processCancel();
+ abort();
+}
+
+void HYDROGUI_Operation::onHelp()
+{
+ emit helpContextModule( getHelpComponent(), getHelpFile(), getHelpContext() );
+}
+
+QString HYDROGUI_Operation::getHelpComponent() const
+{
+ return module()->moduleName();
+}
+
+QString HYDROGUI_Operation::getHelpFile() const
+{
+ QString aFileName = ((myName.isEmpty())? operationName() : myName);
+ return aFileName.replace(QRegExp("\\s"), "_").append(".html");
+}
+
+QString HYDROGUI_Operation::getHelpContext() const
+{
+ return QString();
+}
+
+void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries )
+{
+ bool isApplyAndClose = true;
+ bool isOptimizedBrowse = true;
+ module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse );