]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Profile object realization.
authornds <nds@opencascade.com>
Mon, 25 Nov 2013 10:40:56 +0000 (10:40 +0000)
committernds <nds@opencascade.com>
Mon, 25 Nov 2013 10:40:56 +0000 (10:40 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_PolylineDlg.cxx
src/HYDROGUI/HYDROGUI_ProfileDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ProfileDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ProfileOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ProfileOp.h [new file with mode: 0644]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 52ad4000e54f163de93a598ed9088f90c92f043c..d3339b91e2b3d94621f4d09ac7da5afdf8f650ff 100644 (file)
@@ -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
index 05259c16e82dbe655945a87c6e067d754d6a644a..b0ccc7e65f840e1598527e81674d0f82aaa4ea3c 100644 (file)
@@ -35,6 +35,7 @@
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
+#include <HYDROData_Profile.h>
 #include <HYDROData_VisualState.h>
 #include <HYDROData_Region.h>
 #include <HYDROData_Zone.h>
@@ -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";
index acb420cd17b9569f9791de7ceee5cd5a2fc49a90..ccaa4c0d0c7999ce5b4d42151cfa4276a857554c 100644 (file)
@@ -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 ) );
index 87515c4d48ba324096c698cdea7c44b2a7d51b26..a7837f20976d8f2391a91fc2925e99e3394dccc9 100644 (file)
@@ -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;
index c27188a18aea85c3b1820cdb7947e570c2c83682..ceb6942165d848b7cd0465ca24a96df064267492 100644 (file)
@@ -46,6 +46,9 @@ enum OperationId
   CreatePolylineId,
   EditPolylineId,
   
+  CreateProfileId,
+  EditProfileId,
+  
   ImportBathymetryId,
   EditImportedBathymetryId,
 
index de14235fd5f3fefa5b1bdff0cbb6b0baf92e54d8..a643eb3433010a8a48191abd18be994d1a659b5c 100755 (executable)
@@ -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 (file)
index 0000000..25c2dea
--- /dev/null
@@ -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 <CurveCreator_Widget.h>
+#include <CurveCreator_ICurve.hxx>
+
+#include <OCCViewer_ViewModel.h>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+
+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<QBoxLayout*>( myAddElementBox->layout() );
+  anAddElementLayout->addWidget( theWidget );
+
+  theWidget->show();
+  myAddElementBox->show();
+}
+
+void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget )
+{
+  myEditorWidget->setEnabled( true );
+
+  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( 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<int> 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 (file)
index 0000000..589eb1d
--- /dev/null
@@ -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<int> 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 (file)
index 0000000..4ff533e
--- /dev/null
@@ -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 <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+#include <OCCViewer_AISSelector.h>
+
+#include <Precision.hxx>
+
+//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<OCCViewer_ViewManager*>( 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<PolylineSection> 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<PolylineSection> 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<int> 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 (file)
index 0000000..62df8af
--- /dev/null
@@ -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 <HYDROData_Profile.h>
+
+//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
index 9a6def622b94af2973b54c47d48236393a8adcef..762be79997c3ec03a59e83c3829c2beefd3334d2 100644 (file)
       <source>DEFAULT_POLYLINE_NAME</source>
       <translation>Polyline</translation>
     </message>
+    <message>
+      <source>DEFAULT_PROFILE_NAME</source>
+      <translation>Profile</translation>
+    </message>
     <message>
       <source>DEFAULT_VISUAL_STATE_NAME</source>
       <translation>Visual state</translation>
       <source>POLYLINES</source>
       <translation>POLYLINES</translation>
     </message>
+    <message>
+      <source>PROFILES</source>
+      <translation>PROFILES</translation>
+    </message>
     <message>
       <source>VISUAL_STATES</source>
       <translation>VISUAL STATES</translation>
@@ -452,6 +460,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>DSK_CREATE_PROFILE</source>
+      <translation>Create profile</translation>
+    </message>
     <message>
       <source>DSK_CREATE_IMMERSIBLE_ZONE</source>
       <translation>Create immersible zone</translation>
@@ -600,6 +612,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>MEN_CREATE_PROFILE</source>
+      <translation>Create profile</translation>
+    </message>
     <message>
       <source>MEN_CREATE_ZONE</source>
       <translation>Create zone</translation>
@@ -648,6 +664,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_EDIT_POLYLINE</source>
       <translation>Edit polyline</translation>
     </message>
+    <message>
+      <source>MEN_EDIT_PROFILE</source>
+      <translation>Edit profile</translation>
+    </message>
     <message>
       <source>MEN_EDIT_SPLITTED_IMAGE</source>
       <translation>Edit splitted image</translation>
@@ -756,6 +776,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_CREATE_POLYLINE</source>
       <translation>Create polyline</translation>
     </message>
+    <message>
+      <source>STB_CREATE_PROFILE</source>
+      <translation>Create profile</translation>
+    </message>
     <message>
       <source>STB_CREATE_IMMERSIBLE_ZONE</source>
       <translation>Create immersible zone</translation>
@@ -910,6 +934,18 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_ProfileOp</name>
+    <message>
+      <source>CREATE_PROFILE</source>
+      <translation>Create profile</translation>
+    </message>
+    <message>
+      <source>EDIT_PROFILE</source>
+      <translation>Edit profile</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_RemoveImageRefsOp</name>
     <message>
@@ -957,11 +993,23 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <translation>Add element</translation>
     </message>
     <message>
-      <source>CURVE_NAME_TLT</source>
+      <source>POLYLINE_NAME_TLT</source>
       <translation>Name</translation>
     </message>
   </context>
   
+  <context>
+    <name>HYDROGUI_ProfileDlg</name>
+    <message>
+      <source>ADD_ELEMENT</source>
+      <translation>Add element</translation>
+    </message>
+    <message>
+      <source>PROFILE_NAME_TLT</source>
+      <translation>Name</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_TwoImagesDlg</name>
     <message>