From: adv Date: Thu, 12 Sep 2013 12:04:54 +0000 (+0000) Subject: GUI base operations implemented for Calculation Case object (Feature #10). X-Git-Tag: BR_hydro_v_0_1~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e1739ce97c68eccf2cd6599c4440e0cb935abbc;p=modules%2Fhydro.git GUI base operations implemented for Calculation Case object (Feature #10). --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 74bdc168..17b7c093 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -4,6 +4,8 @@ include(../../CMake/UseQT4EXT.cmake) set(PROJECT_HEADERS HYDROGUI.h HYDROGUI_AISCurve.h + HYDROGUI_CalculationDlg.h + HYDROGUI_CalculationOp.h HYDROGUI_ColorWidget.h HYDROGUI_DataModel.h HYDROGUI_DataObject.h @@ -43,6 +45,8 @@ QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) set(PROJECT_SOURCES HYDROGUI_AISCurve.cxx + HYDROGUI_CalculationDlg.cxx + HYDROGUI_CalculationOp.cxx HYDROGUI_ColorWidget.cxx HYDROGUI_DataModel.cxx HYDROGUI_DataObject.cxx diff --git a/src/HYDROGUI/HYDROGUI.vcproj b/src/HYDROGUI/HYDROGUI.vcproj index 6394a14c..dd4d2ad6 100644 --- a/src/HYDROGUI/HYDROGUI.vcproj +++ b/src/HYDROGUI/HYDROGUI.vcproj @@ -130,6 +130,14 @@ RelativePath=".\HYDROGUI_AISCurve.cxx" > + + + + @@ -291,6 +299,34 @@ RelativePath=".\HYDROGUI_AISCurve.h" > + + + + + + + + + + @@ -767,6 +803,14 @@ + + + + diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx new file mode 100644 index 00000000..5ecbbd43 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -0,0 +1,78 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "HYDROGUI_CalculationDlg.h" + +#include "HYDROGUI_Tool.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + // Calculation name + myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ) ); + + myObjectName = new QLineEdit( myObjectNameGroup ); + + QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup ); + aNameLayout->setMargin( 5 ); + aNameLayout->setSpacing( 5 ); + aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) ); + aNameLayout->addWidget( myObjectName ); + + // Common + addWidget( myObjectNameGroup ); + addStretch(); +} + +HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg() +{ +} + +void HYDROGUI_CalculationDlg::reset() +{ + myObjectName->clear(); +} + +void HYDROGUI_CalculationDlg::setObjectName( const QString& theName ) +{ + myObjectName->setText( theName ); +} + +QString HYDROGUI_CalculationDlg::getObjectName() const +{ + return myObjectName->text(); +} + + + + diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h new file mode 100644 index 00000000..44b1b8ca --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#ifndef HYDROGUI_CALCULATIONDLG_H +#define HYDROGUI_CALCULATIONDLG_H + +#include "HYDROGUI_InputPanel.h" + +class QGroupBox; +class QLineEdit; + +class HYDROGUI_CalculationDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_CalculationDlg(); + + void reset(); + + void setObjectName( const QString& theName ); + QString getObjectName() const; + +private: + QGroupBox* myObjectNameGroup; + QLineEdit* myObjectName; + +}; + +#endif + diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx new file mode 100644 index 00000000..25aac271 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -0,0 +1,120 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "HYDROGUI_CalculationOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_CalculationDlg.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include + +HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ) +: HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ) +{ + setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) ); +} + +HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp() +{ +} + +void HYDROGUI_CalculationOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + aPanel->reset(); + + QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" ); + + myEditedObject.Nullify(); + if ( myIsEdit ) + { + myEditedObject = Handle(HYDROData_Calculation)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( !myEditedObject.IsNull() ) + anObjectName = myEditedObject->GetName(); + } + + aPanel->setObjectName( anObjectName ); +} + +void HYDROGUI_CalculationOp::abortOperation() +{ + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_CalculationOp::commitOperation() +{ + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const +{ + HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() ); + return aPanel; +} + +bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, + QString& theErrorMsg ) +{ + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + QString anObjectName = aPanel->getObjectName().simplified(); + if ( anObjectName.isEmpty() ) + { + theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); + return false; + } + + // check that there are no other objects with the same name in the document + Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); + if ( !anObject.IsNull() ) + { + theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); + return false; + } + + Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject : + Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) ); + if ( aCalculObj.IsNull() ) + return false; + + aCalculObj->SetName( anObjectName ); + + theUpdateFlags = UF_Model; + + return true; +} + + diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h new file mode 100644 index 00000000..0ca60d2f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#ifndef HYDROGUI_CALCULATIONOP_H +#define HYDROGUI_CALCULATIONOP_H + +#include "HYDROGUI_Operation.h" + +#include + +class HYDROGUI_CalculationOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ); + virtual ~HYDROGUI_CalculationOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + +private: + bool myIsEdit; + Handle(HYDROData_Calculation) myEditedObject; + +}; + +#endif + + diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index e72d9488..d1fff032 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_Tool.h" #include +#include #include #include #include @@ -248,6 +249,17 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( aBathymetryRootObj, aBathymetryObj ); } + LightApp_DataObject* aCalculRootObj = createObject( aRootObj, "CALCULATION CASES" ); + + anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Calculation) aCalculObj = + Handle(HYDROData_Calculation)::DownCast( anIterator.Current() ); + if( !aCalculObj.IsNull() ) + createObject( aCalculRootObj, aCalculObj ); + } + LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" ); anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index c355b51c..62eb052e 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -168,6 +168,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsSplittedImage = false; bool anIsMustBeUpdatedImage = false; bool anIsPolyline = false; + bool anIsCalculation = false; bool anIsVisualState = false; HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this ); @@ -207,6 +208,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } else if( anObject->GetKind() == KIND_POLYLINE ) anIsPolyline = true; + else if( anObject->GetKind() == KIND_CALCULATION ) + anIsCalculation = true; else if( anObject->GetKind() == KIND_VISUAL_STATE ) anIsVisualState = true; } @@ -249,6 +252,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( EditPolylineId ) ); theMenu->addSeparator(); } + else if( anIsCalculation ) + { + theMenu->addAction( action( EditCalculationId ) ); + theMenu->addSeparator(); + } else if( anIsVisualState ) { theMenu->addAction( action( SaveVisualStateId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 9133cb72..b0f255bd 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_ExportImageOp.h" #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_ImportBathymetryOp.h" +#include "HYDROGUI_CalculationOp.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_ObserveImageOp.h" #include "HYDROGUI_PolylineOp.h" @@ -81,6 +82,9 @@ void HYDROGUI_Module::createActions() createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::SHIFT + Qt::Key_I ); + createAction( CreateCalculationId, "CREATE_CALCULATION" ); + createAction( EditCalculationId, "EDIT_CALCULATION" ); + createAction( FuseImagesId, "FUSE_IMAGES" ); createAction( EditFusedImageId, "EDIT_FUSED_IMAGE" ); @@ -115,6 +119,7 @@ void HYDROGUI_Module::createMenus() createMenu( ImportImageId, aHydroId, -1, -1 ); createMenu( ImportBathymetryId, aHydroId, -1, -1 ); createMenu( CreatePolylineId, aHydroId, -1, -1 ); + createMenu( CreateCalculationId, aHydroId, -1, -1 ); createMenu( FuseImagesId, aHydroId, -1, -1 ); createMenu( CutImagesId, aHydroId, -1, -1 ); createMenu( SplitImageId, aHydroId, -1, -1 ); @@ -254,6 +259,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case ImportBathymetryId: anOp = new HYDROGUI_ImportBathymetryOp( aModule ); break; + case CreateCalculationId: + case EditCalculationId: + anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId ); + break; case FuseImagesId: case EditFusedImageId: anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 77ddc3f8..008e2526 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -45,6 +45,9 @@ enum OperationId ImportBathymetryId, EditImportedBathymetryId, + CreateCalculationId, + EditCalculationId, + FuseImagesId, EditFusedImageId, diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 2eae424e..b3a98771 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -37,7 +37,31 @@ does not exist or you have not enough permissions to open it. Object with name '%1' already exists in the document. - + + + HYDROGUI_CalculationDlg + + CALCULATION_NAME + Calculation Case name + + + NAME + Name + + + + + HYDROGUI_CalculationOp + + CREATE_CALCULATION + Create calculation Case + + + EDIT_CALCULATION + Edit calculation Case + + + HYDROGUI_DataModel @@ -215,6 +239,10 @@ file cannot be correctly imported for a Bathymetry definition. HYDROGUI_Module + + DSK_CREATE_CALCULATION + Create calculation Case + DSK_CREATE_POLYLINE Create polyline @@ -227,6 +255,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_DELETE Delete + + DSK_EDIT_CALCULATION + Edit calculation Case + DSK_EDIT_CUT_IMAGE Edit cut image @@ -311,6 +343,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_UPDATE_IMAGE Update image + + MEN_CREATE_CALCULATION + Create new calculation Case + MEN_CREATE_POLYLINE Create polyline @@ -327,6 +363,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_DESK_HYDRO HYDRO + + MEN_EDIT_CALCULATION + Edit calculation Case + MEN_EDIT_CUT_IMAGE Edit cut image @@ -411,6 +451,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_UPDATE_IMAGE Update image + + STB_CREATE_CALCULATION + Create new calculation Case + STB_CREATE_POLYLINE Create polyline @@ -423,6 +467,10 @@ file cannot be correctly imported for a Bathymetry definition. STB_DELETE Delete + + STB_EDIT_CALCULATION + Edit calculation Case + STB_EDIT_CUT_IMAGE Edit cut image