From: nds Date: Mon, 25 Nov 2013 10:40:56 +0000 (+0000) Subject: Profile object realization. X-Git-Tag: issue_132_11_28~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=47929e267bad89edb95ce8e9b1e545a9f5ec7d58;p=modules%2Fhydro.git Profile object realization. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 52ad4000..d3339b91 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -32,6 +32,8 @@ set(PROJECT_HEADERS HYDROGUI_Operations.h HYDROGUI_PolylineDlg.h HYDROGUI_PolylineOp.h + HYDROGUI_ProfileDlg.h + HYDROGUI_ProfileOp.h HYDROGUI_Prs.h HYDROGUI_PrsDriver.h HYDROGUI_PrsImage.h @@ -98,6 +100,8 @@ set(PROJECT_SOURCES HYDROGUI_Operations.cxx HYDROGUI_PolylineDlg.cxx HYDROGUI_PolylineOp.cxx + HYDROGUI_ProfileDlg.cxx + HYDROGUI_ProfileOp.cxx HYDROGUI_Prs.cxx HYDROGUI_PrsDriver.cxx HYDROGUI_PrsImage.cxx diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 05259c16..b0ccc7e6 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -258,6 +259,17 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( aPolylineRootObj, aPolylineObj ); } + LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) ); + + anIterator = HYDROData_Iterator( aDocument, KIND_PROFILE ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Profile) aProfileObj = + Handle(HYDROData_Profile)::DownCast( anIterator.Current() ); + if( !aProfileObj.IsNull() ) + createObject( aProfileRootObj, aProfileObj ); + } + LightApp_DataObject* aZonesRootObj = createObject( aRootObj, tr( partitionName( KIND_IMMERSIBLE_ZONE ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE ); @@ -448,6 +460,7 @@ bool HYDROGUI_DataModel::canCopy() ObjectKind aKind = anObject->GetKind(); if( aKind == KIND_IMAGE || aKind == KIND_POLYLINE || + aKind == KIND_PROFILE || aKind == KIND_CALCULATION ) return true; @@ -521,6 +534,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) { case KIND_IMAGE: return "IMAGES"; case KIND_POLYLINE: return "POLYLINES"; + case KIND_PROFILE: return "PROFILES"; case KIND_VISUAL_STATE: return "VISUAL_STATES"; case KIND_BATHYMETRY: return "BATHYMETRIES"; case KIND_CALCULATION: return "CALCULATION_CASES"; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index acb420cd..ccaa4c0d 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -223,6 +223,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsSplittedImage = false; bool anIsMustBeUpdatedImage = false; bool anIsPolyline = false; + bool anIsProfile = false; bool anIsBathymetry = false; bool anIsCalculation = false; bool anIsImmersibleZone = false; @@ -280,6 +281,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } else if( anObject->GetKind() == KIND_POLYLINE ) anIsPolyline = true; + else if( anObject->GetKind() == KIND_PROFILE ) + anIsProfile = true; else if( anObject->GetKind() == KIND_CALCULATION ) anIsCalculation = true; else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) @@ -313,6 +316,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, case KIND_POLYLINE: theMenu->addAction( action( CreatePolylineId ) ); break; + case KIND_PROFILE: + theMenu->addAction( action( CreateProfileId ) ); + break; case KIND_VISUAL_STATE: theMenu->addAction( action( SaveVisualStateId ) ); break; @@ -379,6 +385,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( EditPolylineId ) ); theMenu->addSeparator(); } + else if( anIsProfile ) + { + theMenu->addAction( action( EditProfileId ) ); + theMenu->addSeparator(); + } else if( anIsCalculation ) { theMenu->addAction( action( EditCalculationId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 87515c4d..a7837f20 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -33,6 +33,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_ObserveImageOp.h" #include "HYDROGUI_PolylineOp.h" +#include "HYDROGUI_ProfileOp.h" #include "HYDROGUI_RemoveImageRefsOp.h" #include "HYDROGUI_ShowHideOp.h" #include "HYDROData_SplitToZonesTool.h" @@ -104,6 +105,9 @@ void HYDROGUI_Module::createActions() createAction( CreatePolylineId, "CREATE_POLYLINE" ); createAction( EditPolylineId, "EDIT_POLYLINE" ); + createAction( CreateProfileId, "CREATE_PROFILE" ); + createAction( EditProfileId, "EDIT_PROFILE" ); + createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B ); createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE" ); @@ -158,6 +162,7 @@ void HYDROGUI_Module::createMenus() createMenu( ImportImageId, aHydroId, -1, -1 ); createMenu( ImportBathymetryId, aHydroId, -1, -1 ); createMenu( CreatePolylineId, aHydroId, -1, -1 ); + createMenu( CreateProfileId, aHydroId, -1, -1 ); createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 ); int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 ); @@ -321,6 +326,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditPolylineId: anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId ); break; + case CreateProfileId: + case EditProfileId: + anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId ); + break; case ImportBathymetryId: anOp = new HYDROGUI_ImportBathymetryOp( aModule ); break; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index c27188a1..ceb69421 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -46,6 +46,9 @@ enum OperationId CreatePolylineId, EditPolylineId, + CreateProfileId, + EditProfileId, + ImportBathymetryId, EditImportedBathymetryId, diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index de14235f..a643eb34 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -37,7 +37,7 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QS : HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL) { QHBoxLayout* aNameLayout = new QHBoxLayout(); - QLabel* aNameLabel = new QLabel(tr("CURVE_NAME_TLT"), this); + QLabel* aNameLabel = new QLabel(tr("POLYLINE_NAME_TLT"), this); aNameLayout->addWidget(aNameLabel); myName = new QLineEdit(this); aNameLayout->addWidget(myName); diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx new file mode 100644 index 00000000..25c2deaa --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -0,0 +1,138 @@ +// 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_ProfileDlg.h" + +#include "HYDROGUI_Module.h" +#include +#include + +#include + +#include +#include +#include +#include + +HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL) +{ + QHBoxLayout* aNameLayout = new QHBoxLayout(); + QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this); + aNameLayout->addWidget(aNameLabel); + myName = new QLineEdit(this); + aNameLayout->addWidget(myName); + + addLayout(aNameLayout); + + myEditorWidget = new CurveCreator_Widget( this, NULL ); + addWidget( myEditorWidget, 3 ); + + myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this ); + addWidget( myAddElementBox, 2 ); + + QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox ); + anAddElementLayout->setMargin( 0 ); + anAddElementLayout->setSpacing( 5 ); + + connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); + connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*) ), this, SLOT( processStartedSubOperation(QWidget*) ) ); + connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) ); + + myAddElementBox->hide(); +} + +HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg() +{ +} + +void HYDROGUI_ProfileDlg::setOCCViewer( OCCViewer_Viewer* theViewer ) +{ + myEditorWidget->setOCCViewer( theViewer ); +} + +void HYDROGUI_ProfileDlg::processStartedSubOperation( QWidget* theWidget ) +{ + myEditorWidget->setEnabled( false ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->addWidget( theWidget ); + + theWidget->show(); + myAddElementBox->show(); +} + +void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget ) +{ + myEditorWidget->setEnabled( true ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->removeWidget( theWidget ); + + theWidget->hide(); + myAddElementBox->hide(); +} + +void HYDROGUI_ProfileDlg::reset() +{ +} + +void HYDROGUI_ProfileDlg::setProfileName( const QString& theName ) +{ + myName->setText(theName); +} + +QString HYDROGUI_ProfileDlg::getProfileName() const +{ + return myName->text(); +} + +void HYDROGUI_ProfileDlg::setCurve( CurveCreator_ICurve* theCurve ) +{ + myEditorWidget->setCurve( theCurve ); +} + +QList HYDROGUI_ProfileDlg::getSelectedSections() +{ + return myEditorWidget->getSelectedSections(); +} + +QList< QPair< int, int > > HYDROGUI_ProfileDlg::getSelectedPoints() +{ + return myEditorWidget->getSelectedPoints(); +} + +/** + * Redirect the delete action to editor widget + */ +void HYDROGUI_ProfileDlg::deleteSelected() +{ + myEditorWidget->removeSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_ProfileDlg::deleteEnabled() +{ + return myEditorWidget->removeEnabled(); +} diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h new file mode 100644 index 00000000..589eb1d8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -0,0 +1,72 @@ +// 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_PROFILEDLG_H +#define HYDROGUI_PROFILEDLG_H + +#include "HYDROGUI_InputPanel.h" + +class QGroupBox; +class QLineEdit; +class CurveCreator_Widget; +class CurveCreator_ICurve; +class OCCViewer_Viewer; + +class HYDROGUI_ProfileDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ProfileDlg(); + + void setOCCViewer( OCCViewer_Viewer* theViewer ); + + void setProfileName( const QString& theName ); + QString getProfileName() const; + + void setCurve( CurveCreator_ICurve* theCurve ); + + void reset(); + + QList getSelectedSections(); + QList< QPair< int, int > > getSelectedPoints(); + + void deleteSelected(); + bool deleteEnabled(); + +protected slots: + void processStartedSubOperation( QWidget* ); + void processFinishedSubOperation( QWidget* ); +signals: + void createPreview( QString ); + void selectionChanged(); + void widgetCreated(QWidget*); + void subOperationStarted(QWidget*); + void subOperationFinished(QWidget*); +private: + QLineEdit* myName; + CurveCreator_Widget* myEditorWidget; + QGroupBox* myAddElementBox; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx new file mode 100644 index 00000000..4ff533ed --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -0,0 +1,270 @@ +// 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_Module.h" +#include "HYDROGUI_ProfileOp.h" +#include "HYDROGUI_ProfileDlg.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" + +#include "HYDROData_Document.h" +#include "HYDROData_Profile.h" +#include "CurveCreator_Curve.hxx" +#include "CurveCreator_Displayer.h" + +#include +#include +#include + +#include +#include +#include + +#include + +#include + +//static int ZValueIncrement = 0; + +HYDROGUI_ProfileOp::HYDROGUI_ProfileOp( HYDROGUI_Module* theModule, bool theIsEdit ) +: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL)//, + //myViewManager(NULL) +{ + setName( theIsEdit ? tr( "EDIT_PROFILE" ) : tr( "CREATE_PROFILE" ) ); +} + +HYDROGUI_ProfileOp::~HYDROGUI_ProfileOp() +{ + //erasePreview(); +} + +/** + * Redirect the delete action to input panel + */ +void HYDROGUI_ProfileOp::deleteSelected() +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + aPanel->deleteSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_ProfileOp::deleteEnabled() +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + return aPanel->deleteEnabled(); +} + +void HYDROGUI_ProfileOp::startOperation() +{ + if( myCurve ) + { + delete myCurve; + myCurve = 0; + } + + HYDROGUI_Operation::startOperation(); + + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + aPanel->reset(); + + //LightApp_Application* anApp = module()->getApp(); + //myViewManager = + // dynamic_cast( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ); + //aPanel->setOCCViewer( myViewManager ? myViewManager->getOCCViewer() : 0 ); + + if( myIsEdit ) + myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !myEditedObject.IsNull() ) + { + /*int anIntDim = myEditedObject->GetDimension(); + CurveCreator::Dimension aDim = CurveCreator::Dim3d; + if( anIntDim == 2 ) + aDim = CurveCreator::Dim2d; + myCurve = new CurveCreator_Curve(aDim); + QList aPolylineData = myEditedObject->GetPolylineData(); + + for( int i = 0 ; i < aPolylineData.size() ; i++ ){ + std::string aName = HYDROGUI_Tool::ToQString(aPolylineData[i].mySectionName).toStdString(); + bool isClosed = aPolylineData[i].myIsClosed; + CurveCreator::SectionType aType = CurveCreator::Polyline; + if( aPolylineData[i].myType == PolylineSection::SECTION_SPLINE ){ + aType = CurveCreator::Spline; + } + CurveCreator::Coordinates aCoords; + for( int j = 0 ; j < aPolylineData[i].myCoords.size() ; j++ ){ + aCoords.push_back(aPolylineData[i].myCoords[j]); + } + myCurve->addSectionInternal( aName, aType, isClosed, aCoords ); + } + aPanel->setProfileName( myEditedObject->GetName() ); + */ + } + else{ + /*myCurve = new CurveCreator_Curve(CurveCreator::Dim2d);*/ + //aPanel->setCurve(myCurve); + QString aNewName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_PROFILE_NAME" ) ); + aPanel->setProfileName(aNewName); + } + /*aPanel->setCurve(myCurve);*/ + //displayPreview(); +} + +void HYDROGUI_ProfileOp::abortOperation() +{ + //HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + //if ( aPanel ) + // aPanel->setOCCViewer( 0 ); + //erasePreview(); + + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_ProfileOp::commitOperation() +{ + //HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + //if ( aPanel ) + // aPanel->setOCCViewer( 0 ); + //erasePreview(); + + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_ProfileOp::createInputPanel() const +{ + HYDROGUI_ProfileDlg* aDlg = new HYDROGUI_ProfileDlg( module(), getName() ); + //connect( aDlg, SIGNAL( selectionChanged() ), this, SLOT( onEditorSelectionChanged() ) ); + return aDlg; +} + +bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, + QString& theErrorMsg ) +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + + int aStudyId = module()->getStudyId(); + bool aHasDoc = HYDROData_Document::HasDocument(aStudyId); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + if( aDocument.IsNull() ) + return false; + + Handle(HYDROData_Profile) aProfileObj; + if( myIsEdit ){ + aProfileObj = myEditedObject; + } + else{ + aProfileObj = Handle(HYDROData_Profile)::DownCast( aDocument->CreateObject( KIND_PROFILE ) ); + + //double aZValue = double( ++ZValueIncrement ) * 1e-2; // empiric value, to be revised + //aProfileObj->SetZValue( aZValue ); + } + + if( aProfileObj.IsNull() ) + return false; + + QString aProfileName = aPanel->getProfileName(); + aProfileObj->SetName(aProfileName); + /* + int aDimInt = 3; + if( myCurve->getDimension() == CurveCreator::Dim2d ) + aDimInt = 2; + aProfileObj->SetDimension(aDimInt); + QList aPolylineData; + for( int i=0 ; i < myCurve->getNbSections() ; i++ ){ + PolylineSection aSect; + aSect.mySectionName = HYDROGUI_Tool::ToExtString( QString::fromLocal8Bit(myCurve->getSectionName(i).c_str())); + aSect.myIsClosed = myCurve->isClosed(i); + aSect.myType = PolylineSection::SECTION_POLYLINE; + if( myCurve->getSectionType(i) == CurveCreator::Spline ){ + aSect.myType = PolylineSection::SECTION_SPLINE; + } + CurveCreator::Coordinates aCoords = myCurve->getPoints(i); + for( int j = 0 ; j < aCoords.size() ; j++ ){ + aSect.myCoords << aCoords.at(j); + } + aPolylineData << aSect; + } + aProfileObj->SetPolylineData(aPolylineData); + + // the viewer should be release from the widget before the module update it + // because it has an opened local context and updated presentation should not be displayed in it + //if ( aPanel ) + // aPanel->setOCCViewer( 0 ); + + if( !myIsEdit ) + module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aProfileObj, true ); +*/ + theUpdateFlags = UF_Model; + return true; +} + +/*void HYDROGUI_ProfileOp::onEditorSelectionChanged() +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + if( !aPanel ) + return; + if( !myCurve ) + return; + CurveCreator_Displayer* aDisplayer = myCurve->getDisplayer(); + if( !aDisplayer ) + return; + QList aSelSections = aPanel->getSelectedSections(); + for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){ + bool aIsHl = false; + if( aSelSections.contains(i) ){ + aDisplayer->highlight( myCurve->constructSection(i), aIsHl ); + } + } +}*/ + +/*void HYDROGUI_ProfileOp::displayPreview() +{ + if( myViewManager ) + { + if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if( !aCtx.IsNull() ) + { + CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); + myCurve->setDisplayer( aDisplayer ); + aDisplayer->display( myCurve->constructWire() ); + } + } + } +}*/ + +/*void HYDROGUI_ProfileOp::erasePreview() +{ + CurveCreator_Displayer* aDisplayer = myCurve ? myCurve->getDisplayer() : 0; + if( myViewManager && aDisplayer ) + { + if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if( !aCtx.IsNull() ) + { + aDisplayer->erase(); + } + } + } +}*/ diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.h b/src/HYDROGUI/HYDROGUI_ProfileOp.h new file mode 100644 index 00000000..62df8afc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.h @@ -0,0 +1,68 @@ +// 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_PROFILEOP_H +#define HYDROGUI_PROFILEOP_H + +#include "HYDROGUI_Operation.h" + +#include + +//class OCCViewer_ViewManager; +class CurveCreator_Curve; + +class HYDROGUI_ProfileOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ProfileOp( HYDROGUI_Module* theModule, bool isEdit ); + virtual ~HYDROGUI_ProfileOp(); + + void deleteSelected(); + bool deleteEnabled(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + +//protected slots: +// void onEditorSelectionChanged(); + +//private: + //void displayPreview(); + //void erasePreview(); + +private: + //OCCViewer_ViewManager* myViewManager; + + bool myIsEdit; + Handle(HYDROData_Profile) myEditedObject; + CurveCreator_Curve* myCurve; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 9a6def62..762be799 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -11,6 +11,10 @@ DEFAULT_POLYLINE_NAME Polyline + + DEFAULT_PROFILE_NAME + Profile + DEFAULT_VISUAL_STATE_NAME Visual state @@ -35,6 +39,10 @@ POLYLINES POLYLINES + + PROFILES + PROFILES + VISUAL_STATES VISUAL STATES @@ -452,6 +460,10 @@ file cannot be correctly imported for a Bathymetry definition. DSK_CREATE_POLYLINE Create polyline + + DSK_CREATE_PROFILE + Create profile + DSK_CREATE_IMMERSIBLE_ZONE Create immersible zone @@ -600,6 +612,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_CREATE_POLYLINE Create polyline + + MEN_CREATE_PROFILE + Create profile + MEN_CREATE_ZONE Create zone @@ -648,6 +664,10 @@ file cannot be correctly imported for a Bathymetry definition. MEN_EDIT_POLYLINE Edit polyline + + MEN_EDIT_PROFILE + Edit profile + MEN_EDIT_SPLITTED_IMAGE Edit splitted image @@ -756,6 +776,10 @@ file cannot be correctly imported for a Bathymetry definition. STB_CREATE_POLYLINE Create polyline + + STB_CREATE_PROFILE + Create profile + STB_CREATE_IMMERSIBLE_ZONE Create immersible zone @@ -910,6 +934,18 @@ file cannot be correctly imported for a Bathymetry definition. + + HYDROGUI_ProfileOp + + CREATE_PROFILE + Create profile + + + EDIT_PROFILE + Edit profile + + + HYDROGUI_RemoveImageRefsOp @@ -957,11 +993,23 @@ file cannot be correctly imported for a Bathymetry definition. Add element - CURVE_NAME_TLT + POLYLINE_NAME_TLT Name + + HYDROGUI_ProfileDlg + + ADD_ELEMENT + Add element + + + PROFILE_NAME_TLT + Name + + + HYDROGUI_TwoImagesDlg