X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Operation.cxx;h=d59c1a0133d4cca547748795845e61809a7c16d9;hp=95c3c5ce12d1d604710fcd46fe1c800e89ba951e;hb=f816f204d33b5250ee211247a798a1af42c528ea;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813 diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index 95c3c5ce1..d59c1a013 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -1,39 +1,43 @@ -// SMESH SMDS : implementaion of Salome mesh data structure +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// File : SMESHGUI_Operation.h -// Author : Sergey LITONIN -// Module : SALOME +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESHGUI_Operation.cxx +// Author : Sergey LITONIN, Open CASCADE S.A.S. #include "SMESHGUI_Operation.h" -#include -#include +#include "SMESHGUI.h" +#include "SMESHGUI_Dialog.h" + +// SALOME GUI includes #include #include #include #include #include +#include -#include +// Qt includes +#include /* Class : SMESHGUI_Operation @@ -45,7 +49,8 @@ // Purpose : Constructor //======================================================================= SMESHGUI_Operation::SMESHGUI_Operation() -: LightApp_Operation() +: LightApp_Operation(), + myIsApplyAndClose( false ) { myHelpFileName = ""; } @@ -69,7 +74,7 @@ SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const //======================================================================= // name : startOperation -// Purpose : Start opeartion +// Purpose : Start operation //======================================================================= void SMESHGUI_Operation::startOperation() { @@ -80,19 +85,19 @@ void SMESHGUI_Operation::startOperation() disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); disconnect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); disconnect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); - + 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::Help ) ) connect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); - + //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() ) ); @@ -113,19 +118,19 @@ bool SMESHGUI_Operation::isReadyToStart() const return false; else if ( getSMESHGUI() == 0 ) { - SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), - tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) ); + SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NO_MODULE" ) ); return false; } - else if ( isStudyLocked() ) + else if ( SMESHGUI::isStudyLocked() ) return false; - + return true; } //======================================================================= // name : setDialogActive -// Purpose : +// Purpose : //======================================================================= void SMESHGUI_Operation::setDialogActive( const bool active ) { @@ -137,24 +142,16 @@ void SMESHGUI_Operation::setDialogActive( const bool active ) } -//======================================================================= -// name : studyDS -// Purpose : -//======================================================================= -_PTR(Study) SMESHGUI_Operation::studyDS() const -{ - SalomeApp_Study* s = dynamic_cast( study() ); - return s->studyDS(); -} - //======================================================================= // name : onOk // Purpose : //======================================================================= void SMESHGUI_Operation::onOk() { + setIsApplyAndClose( true ); if( onApply() ) commit(); + setIsApplyAndClose( false ); //else // abort(); } @@ -184,19 +181,20 @@ void SMESHGUI_Operation::onCancel() void SMESHGUI_Operation::onHelp() { LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) + if (app) app->onHelpContextModule(getSMESHGUI() ? app->moduleName(getSMESHGUI()->moduleName()) : QString(""), myHelpFileName); else { - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName), - QObject::tr("BUT_OK")); + SUIT_MessageBox::warning( desktop(), tr("WRN_WARNING"), + tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", + platform)). + arg(myHelpFileName) ); } } @@ -208,28 +206,24 @@ void SMESHGUI_Operation::initDialog() { } -/*! - * \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 +//================================================================ +// name : setIsApplyAndClose +// Purpose : Set value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +void SMESHGUI_Operation::setIsApplyAndClose( const bool theFlag ) { - 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; + myIsApplyAndClose = theFlag; +} + +//================================================================ +// name : isApplyAndClose +// Purpose : Get value of the flag indicating that the dialog is +// accepted by Apply & Close button +//================================================================ +bool SMESHGUI_Operation::isApplyAndClose() const +{ + return myIsApplyAndClose; } /*! @@ -239,7 +233,7 @@ bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const * * Virtual method redefined from base class verifies whether given operator is valid for * this one (i.e. can be started "above" this operator). In current implementation method -* retuns false if theOtherOp operation is not intended for deleting objects or mesh +* returns false if theOtherOp operation is not intended for deleting objects or mesh * elements. */ bool SMESHGUI_Operation::isValid( SUIT_Operation* theOtherOp ) const @@ -251,20 +245,9 @@ bool SMESHGUI_Operation::isValid( SUIT_Operation* theOtherOp ) const // to do add other operations here } - return theOtherOp && theOtherOp->inherits( "SMESHGUI_Operation" ) && - ( !anOps.contains( theOtherOp->className() ) || anOps.contains( className() ) ); + return ( theOtherOp && + ( ( theOtherOp->inherits("SMESHGUI_Operation") && ( !anOps.contains(theOtherOp->metaObject()->className() ) || anOps.contains(metaObject()->className()) ) ) || + ( theOtherOp->inherits("LightApp_ShowHideOp") ) ) ); return true; } - - - - - - - - - - - -