aPanel->reset();
- myEditedObject.Nullify();
+ if ( isApplyAndClose() )
+ myEditedObject.Nullify();
QString aSelectedGuideLine, aSelectedProfile;
QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) );
if ( myIsEdit )
{
- myEditedObject =
- Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject =
+ Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if ( !myEditedObject.IsNull() )
{
anObjectName = myEditedObject->GetName();
if ( myIsEdit )
{
- myEditedObject = Handle(HYDROData_ImmersibleZone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_ImmersibleZone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
{
anObjectName = myEditedObject->GetName();
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
{
QString aName = myEditedObject->GetName();
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
{
QImage anImage = myEditedObject->Image();
void HYDROGUI_ImportImageOp::commitOperation()
{
- closePreview();
+ if ( isApplyAndClose() )
+ closePreview();
HYDROGUI_Operation::commitOperation();
}
}
// must be done after all checks and before calling SetVisible() method below
- closePreview();
+ if ( isApplyAndClose() )
+ closePreview();
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
anImageObj->Update();
- theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
+ theUpdateFlags = UF_Model;
+ if ( isApplyAndClose() )
+ theUpdateFlags |= UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced;
+
return true;
}
return isCorrect;
}
-void HYDROGUI_ImportImageOp::onApply()
+void HYDROGUI_ImportImageOp::apply()
{
HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes;
}
if ( aCanApply )
- HYDROGUI_Operation::onApply();
+ HYDROGUI_Operation::apply();
else {
aPanel->setRefImageName( "" );
onRefImageActivated( aPanel->getRefImageName() );
QStringList& theBrowseObjectsEntries );
bool isReferenceCorrect() const;
-protected slots:
- virtual void onApply();
+ /**
+ * Apply changes done by this operation.
+ */
+ virtual void apply();
+protected slots:
void onCreatePreview( QImage );
void onActivatePointSelection( int );
void onPointCoordChanged( bool, int, bool, int );
aBtnsLayout->setMargin( 5 );
aBtnsLayout->setSpacing( 5 );
- myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
+ myCancel = new QPushButton( tr( "CLOSE" ), myBtnFrame );
myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
if ( doInitLayout ) {
+ myApplyAndClose = new QPushButton( tr( "APPLY_AND_CLOSE" ), myBtnFrame );
myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
+ aBtnsLayout->addWidget( myApplyAndClose, 0 );
aBtnsLayout->addWidget( myApply, 0 );
aBtnsLayout->addWidget( myCancel, 0 );
aBtnsLayout->addStretch( 1 );
aBtnsLayout->addWidget( myHelp, 0 );
+ connect( myApplyAndClose, SIGNAL( clicked() ), this, SLOT( onApplyAndClose() ) );
connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
}
connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
bool HYDROGUI_InputPanel::isApplyEnabled() const
{
- return myApply->isEnabled();
+ return myApply->isEnabled();
}
void HYDROGUI_InputPanel::setApplyEnabled( bool on )
{
- myApply->setEnabled( on );
+ myApplyAndClose->setEnabled( on );
+ myApply->setEnabled( on );
+}
+
+void HYDROGUI_InputPanel::onApplyAndClose()
+{
+ emit panelApplyAndClose();
}
void HYDROGUI_InputPanel::onApply()
void setApplyEnabled( bool );
signals:
+ void panelApplyAndClose();
void panelApply();
void panelCancel();
void panelHelp();
protected slots:
+ void onApplyAndClose();
void onApply();
void onCancel();
void onHelp();
HYDROGUI_Module* myModule;
QFrame* myMainFrame;
QFrame* myBtnFrame;
+ QPushButton* myApplyAndClose;
QPushButton* myApply;
};
myIsPrintErrorMessage( true ),
myIsTransactionOpened( false ),
myPreviewManager( 0 ),
- myPreviewZLayer( -1 )
+ myPreviewZLayer( -1 ),
+ myIsApplyAndClose( true )
{
connect( this, SIGNAL( helpContextModule( const QString&, const QString&,
const QString& ) ),
if( !myPanel )
{
( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel();
+ connect( myPanel, SIGNAL( panelApplyAndClose() ), this, SLOT( onApplyAndClose() ) );
connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) );
connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) );
connect( myPanel, SIGNAL( panelHelp() ), this, SLOT( onHelp() ) );
}
}
+void HYDROGUI_Operation::setIsApplyAndClose( const bool theFlag )
+{
+ myIsApplyAndClose = theFlag;
+}
+
+bool HYDROGUI_Operation::isApplyAndClose() const
+{
+ return myIsApplyAndClose;
+}
+
+void HYDROGUI_Operation::apply()
+{
+ 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, myIsApplyAndClose );
+
+ if ( !myIsApplyAndClose && inputPanel() )
+ start();
+ }
+ 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::startOperation()
{
LightApp_Operation::startOperation();
myModule->getActiveOperations().push( this );
- if( inputPanel() )
+ if( myIsApplyAndClose && inputPanel() )
{
myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() );
inputPanel()->show();
void HYDROGUI_Operation::commitOperation()
{
LightApp_Operation::commitOperation();
- closeInputPanel();
+ if ( myIsApplyAndClose )
+ closeInputPanel();
}
void HYDROGUI_Operation::stopOperation()
return HYDROData_Document::Document( myModule->getStudyId() );
}
-void HYDROGUI_Operation::onApply()
+void HYDROGUI_Operation::onApplyAndClose()
{
- 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();
+ myIsApplyAndClose = true;
+ apply();
+}
- printErrorMessage( anErrorMsg );
-
- // If the operation has no input panel - do abort
- if ( !inputPanel() ) {
- abort();
- }
- }
+void HYDROGUI_Operation::onApply()
+{
+ myIsApplyAndClose = false;
+ apply();
}
void HYDROGUI_Operation::setPrintErrorMessage( const bool theIsPrint )
{
processCancel();
abort();
+ if ( myPanel )
+ abortOperation();
+ myIsApplyAndClose = true;
}
void HYDROGUI_Operation::onHelp()
return QString();
}
-void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries )
+void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries,
+ const bool theIsApplyAndClose/* = true*/ )
{
- bool isApplyAndClose = true;
bool isOptimizedBrowse = true;
- module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse );
+ module()->getApp()->browseObjects( theBrowseObjectsEntries, theIsApplyAndClose, isOptimizedBrowse );
}
void printErrorMessage( const QString& theErrorMsg );
void setPrintErrorMessage( const bool theIsPrint );
- void browseObjects( const QStringList& theBrowseObjectsEntries );
+ void browseObjects( const QStringList& theBrowseObjectsEntries,
+ const bool theIsApplyAndClose = true );
protected slots:
+ virtual void onApplyAndClose();
virtual void onApply();
virtual void onCancel();
virtual void onHelp();
/**
* Set specific cursor chosen in preferences for edition operations.
*/
- virtual void setCursor();
+ virtual void setCursor();
/**
* Restore the default cursor.
*/
- virtual void restoreCursor();
+ virtual void restoreCursor();
+
+ /**
+ * Set flag indicating, if 'Apply and Close' button is clicked on input panel.
+ * @param theFlag a flag value to be set
+ */
+ virtual void setIsApplyAndClose( const bool theFlag );
+ /**
+ * Get flag indicating, if 'Apply and Close' button is clicked on input panel.
+ * \return a flag value
+ */
+ virtual bool isApplyAndClose() const;
+
+ /**
+ * Apply changes done by this operation.
+ */
+ virtual void apply();
private:
int myPreviewZLayer;
QCursor myCursor;
+
+ bool myIsApplyAndClose;
};
#endif
QString aPoly3DName;
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
aPoly3DName = myEditedObject->GetName();
}
{
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if ( !myEditedObject.IsNull() && !myEditedObject->IsEditable() )
{
// Polyline is imported from GEOM module an is not recognized as
aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
setPreviewManager( aViewManager );
- setCursor();
+ if ( isApplyAndClose() )
+ setCursor();
QString aPolylineName;
if( !myEditedObject.IsNull() )
void HYDROGUI_PolylineOp::commitOperation()
{
- restoreCursor();
+ if ( isApplyAndClose() )
+ {
+ restoreCursor();
+
+ HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+ if ( aPanel )
+ aPanel->setOCCViewer( 0 );
+ }
- HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
- if ( aPanel )
- aPanel->setOCCViewer( 0 );
erasePreview();
HYDROGUI_Operation::commitOperation();
{
HYDROGUI_Operation::startOperation();
- HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
- if ( aPanel )
+ if ( isApplyAndClose() )
{
+ HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+ if ( aPanel )
+ {
aPanel->reset();
aPanel->setInterpolators( interpolators() );
+ }
}
}
aPanel->reset();
if( myIsEdit )
- myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
QString aProfileName;
if( !myEditedObject.IsNull() )
{
HYDROGUI_Operation::startOperation();
- HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
+ if ( isApplyAndClose() )
+ {
+ HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
- aPanel->reset();
+ aPanel->reset();
+ }
}
void HYDROGUI_RiverBottomOp::abortOperation()
{
HYDROGUI_Operation::startOperation();
- myEditedObject.Nullify();
+ if ( !myIsEdit || isApplyAndClose() )
+ myEditedObject.Nullify();
myHydAxis.clear();
myProfiles.clear();
myProfileParams.clear();
QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STREAM_NAME" ) );
if ( myIsEdit )
{
- myEditedObject =
- Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject =
+ Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if ( !myEditedObject.IsNull() )
{
anObjectName = myEditedObject->GetName();
aPanel->reset();
// Get the edited object
- myEditedObject = Handle(HYDROData_Obstacle)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Obstacle)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if ( myEditedObject.IsNull() ) {
abort();
return;
QString anImageName;
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
anImageName = myEditedObject->GetName();
}
myAllObjects = new QCheckBox( tr( "ALL_OBJECTS" ) );
// Apply and close buttons
+ myApplyAndClose = new QPushButton( tr("APPLY_AND_CLOSE") );
+ myApplyAndClose->setDefault( true );
myApply = new QPushButton( tr("APPLY") );
- myApply->setDefault( true );
myClose = new QPushButton( tr("CLOSE") );
// Layout
// apply and close buttons
QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout();
+ aDlgButtonsLayout->addWidget( myApplyAndClose );
aDlgButtonsLayout->addWidget( myApply );
aDlgButtonsLayout->addWidget( myClose );
aDlgButtonsLayout->addStretch();
// Connections
connect( myAllObjects, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged() ) );
+ connect( myApplyAndClose, SIGNAL( clicked() ), this, SIGNAL( applyOrderAndClose() ) );
connect( myApply, SIGNAL( clicked() ), this, SIGNAL( applyOrder() ) );
connect( myClose, SIGNAL( clicked() ), this, SLOT( reject() ) );
HYDROGUI_ListModel::ObjectList getObjects() const;
signals:
+ void applyOrderAndClose();
void applyOrder();
private slots:
private:
HYDROGUI_OrderedListWidget* myListWidget; ///< the ordered list widget
- QCheckBox* myAllObjects; ///< the show all objects button
- QPushButton* myApply; ///< the apply changes button
- QPushButton* myClose; ///< the close dialog button
+ QCheckBox* myAllObjects; ///< the show all objects button
+ QPushButton* myApplyAndClose; ///< the apply changes and close dialog button
+ QPushButton* myApply; ///< the apply changes button
+ QPushButton* myClose; ///< the close dialog button
};
#endif
// Show the dialog
if ( !myDlg ) {
myDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() );
+ connect( myDlg, SIGNAL( applyOrderAndClose() ), this, SLOT( onApplyAndClose() ) );
connect( myDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) );
connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
}
delete myDlg;
myDlg = 0;
}
-}
\ No newline at end of file
+}
+
+void HYDROGUI_ZLevelsOp::onApplyAndClose()
+{
+ HYDROGUI_Operation::onApplyAndClose();
+ if ( myDlg )
+ myDlg->reject();
+}
QStringList& theBrowseObjectsEntries );
virtual void processCancel();
+protected slots:
+ virtual void onApplyAndClose();
+
private:
HYDROGUI_ZLevelsDlg* myDlg;
<context>
<name>HYDROGUI_InputPanel</name>
+ <message>
+ <source>APPLY_AND_CLOSE</source>
+ <translation>Apply and Close</translation>
+ </message>
<message>
<source>APPLY</source>
<translation>Apply</translation>
<source>CANCEL</source>
<translation>Cancel</translation>
</message>
+ <message>
+ <source>CLOSE</source>
+ <translation>Close</translation>
+ </message>
<message>
<source>HELP</source>
<translation>Help</translation>
<source>ALL_OBJECTS_CHECKED_TLT</source>
<translation>Exclude hidden objects from the list</translation>
</message>
+ <message>
+ <source>APPLY_AND_CLOSE</source>
+ <translation>Apply and Close</translation>
+ </message>
<message>
<source>APPLY</source>
<translation>Apply</translation>