]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Chanel Create\Edit operation.
authoradv <adv@opencascade.com>
Tue, 3 Dec 2013 07:11:09 +0000 (07:11 +0000)
committeradv <adv@opencascade.com>
Tue, 3 Dec 2013 07:11:09 +0000 (07:11 +0000)
12 files changed:
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_ChannelDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ChannelDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ChannelOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ChannelOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 9d953b672922f04d26f23d74bc9b2ce1c624eb6e..a7f6b51658938f9a7a8d0937c63f62fbeaababc3 100644 (file)
@@ -6,6 +6,8 @@ set(PROJECT_HEADERS
     HYDROGUI_AbstractDisplayer.h
     HYDROGUI_CalculationDlg.h
     HYDROGUI_CalculationOp.h
+    HYDROGUI_ChannelDlg.h
+    HYDROGUI_ChannelOp.h
     HYDROGUI_ColorWidget.h
     HYDROGUI_CopyPasteOp.h
     HYDROGUI_DataBrowser.h
@@ -81,6 +83,8 @@ set(PROJECT_SOURCES
     HYDROGUI_AbstractDisplayer.cxx
     HYDROGUI_CalculationDlg.cxx
     HYDROGUI_CalculationOp.cxx
+    HYDROGUI_ChannelDlg.cxx
+    HYDROGUI_ChannelOp.cxx
     HYDROGUI_ColorWidget.cxx
     HYDROGUI_CopyPasteOp.cxx
     HYDROGUI_DataBrowser.cxx
diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx
new file mode 100644 (file)
index 0000000..3a76181
--- /dev/null
@@ -0,0 +1,167 @@
+// 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_ChannelDlg.h"
+
+#include "HYDROGUI_Tool.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+
+HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  // Channel name
+  myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
+
+  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 );
+
+  // Channel parameters
+  QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
+
+  //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
+  myGuideLines = new QComboBox( aParamGroup );
+  myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
+  myProfiles = new QComboBox( aParamGroup );
+  myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
+  aParamsLayout->setMargin( 5 );
+  aParamsLayout->setSpacing( 5 );
+  aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 );
+  aParamsLayout->addWidget( myGuideLines, 0, 1 );
+  aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 );
+  aParamsLayout->addWidget( myProfiles, 1, 1 );
+
+  // Common
+  addWidget( myObjectNameGroup );
+  addWidget( aParamGroup );
+
+  addStretch();
+
+  // Connect signals and slots
+  connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
+  connect( myProfiles, SIGNAL(  currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
+}
+
+HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
+{
+}
+
+void HYDROGUI_ChannelDlg::reset()
+{
+  bool isBlocked = blockSignals( true );
+
+  myObjectName->clear();
+
+  myGuideLines->clear();
+  myProfiles->clear();
+
+  blockSignals( isBlocked );
+
+  onChannelDefChanged();
+}
+
+void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
+{
+  myObjectName->setText( theName );
+}
+
+QString HYDROGUI_ChannelDlg::getObjectName() const
+{
+  return myObjectName->text();
+}
+
+void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
+{
+  bool isBlocked = blockSignals( true );
+
+  myGuideLines->clear();
+  myGuideLines->addItems( theGuideLines );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
+{
+  int aNewIdx = myGuideLines->findText( theGuideLine );
+  if ( aNewIdx != myGuideLines->currentIndex() )
+  {
+    myGuideLines->setCurrentIndex( aNewIdx );
+  }
+  else
+  {
+    onChannelDefChanged();
+  }
+}
+
+QString HYDROGUI_ChannelDlg::getGuideLineName() const
+{
+  return myGuideLines->currentText();
+}
+
+void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
+{
+  bool isBlocked = blockSignals( true );
+
+  myProfiles->clear();
+  myProfiles->addItems( theProfiles );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
+{
+  int aNewIdx = myProfiles->findText( theProfile );
+  if ( aNewIdx != myProfiles->currentIndex() )
+  {
+    myProfiles->setCurrentIndex( aNewIdx );
+  }
+  else
+  {
+    onChannelDefChanged();
+  }
+}
+
+QString HYDROGUI_ChannelDlg::getProfileName() const
+{
+  return myProfiles->currentText();
+}
+
+void HYDROGUI_ChannelDlg::onChannelDefChanged()
+{
+  if ( signalsBlocked() )
+    return;
+
+  emit CreatePreview();
+}
diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h
new file mode 100644 (file)
index 0000000..3e94720
--- /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_ChannelDlg_H
+#define HYDROGUI_ChannelDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+
+class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_ChannelDlg();
+
+  void                       reset();
+
+  void                       setObjectName( const QString& theName );
+  QString                    getObjectName() const;
+
+  void                       setGuideLineNames( const QStringList& theGuideLines );
+  void                       setGuideLineName( const QString& theGuideLine );
+  QString                    getGuideLineName() const;
+
+  void                       setProfileNames( const QStringList& theProfiles );
+  void                       setProfileName( const QString& theProfile );
+  QString                    getProfileName() const;
+
+signals:
+  void                       CreatePreview();
+
+private slots:
+  void                       onChannelDefChanged();
+
+private:
+
+  QGroupBox*                 myObjectNameGroup;
+  QLineEdit*                 myObjectName;
+
+  QComboBox*                 myGuideLines;
+  QComboBox*                 myProfiles;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx
new file mode 100644 (file)
index 0000000..720a364
--- /dev/null
@@ -0,0 +1,241 @@
+// 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_ChannelOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ChannelDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Polyline3D.h>
+#include <HYDROData_Profile.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+
+HYDROGUI_ChannelOp::HYDROGUI_ChannelOp( HYDROGUI_Module* theModule,
+                                       const bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+  myIsEdit( theIsEdit ),
+  myViewManager( 0 ),
+  myPreviewPrs( 0 )
+{
+  setName( theIsEdit ? tr( "EDIT_CHANNEL" ) : tr( "CREATE_CHANNEL" ) );
+}
+
+HYDROGUI_ChannelOp::~HYDROGUI_ChannelOp()
+{
+  erasePreview();
+}
+
+void HYDROGUI_ChannelOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  // We start operation in the document
+  startDocOperation();
+
+  HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
+
+  aPanel->blockSignals( true );
+
+  aPanel->reset();
+
+  if( myIsEdit )
+    myEditedObject = Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  else 
+    myEditedObject = Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) );
+
+  QString aSelectedGuideLine, aSelectedProfile;
+
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) );
+  if ( myIsEdit && !myEditedObject.IsNull() )
+  {
+    anObjectName = myEditedObject->GetName();
+
+    Handle(HYDROData_Polyline3D) aRefGuideLine = myEditedObject->GetGuideLine();
+    if ( !aRefGuideLine.IsNull() )
+      aSelectedGuideLine = aRefGuideLine->GetName();
+
+    Handle(HYDROData_Profile) aRefProfile = myEditedObject->GetProfile();
+    if ( !aRefProfile.IsNull() )
+      aSelectedProfile = aRefProfile->GetName();
+  }
+
+  // collect information about existing 3d polylines
+  QStringList aGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE );
+
+  // collect information about existing profiles
+  QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE );
+
+  aPanel->setObjectName( anObjectName );
+
+  aPanel->setGuideLineNames( aGuideLines );
+  aPanel->setProfileNames( aProfiles );
+
+  aPanel->setGuideLineName( aSelectedGuideLine );
+  aPanel->setProfileName( aSelectedProfile );
+
+  aPanel->blockSignals( false );
+
+  onCreatePreview( true );
+}
+
+void HYDROGUI_ChannelOp::abortOperation()
+{
+  erasePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ChannelOp::commitOperation()
+{
+  erasePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ChannelOp::createInputPanel() const
+{
+  HYDROGUI_ChannelDlg* aPanel = new HYDROGUI_ChannelDlg( module(), getName() );
+  connect( aPanel, SIGNAL( CreatePreview() ), this,   SLOT( onCreatePreview() ) );
+  return aPanel;
+}
+
+bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
+                                              QString& theErrorMsg )
+{
+  HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+  {
+    // check that there are no other objects with the same name in the document
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+    if( !anObject.IsNull() )
+    {
+      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+      return false;
+    }
+  }
+
+  if ( myEditedObject.IsNull() )
+    return false;
+
+  myEditedObject->SetName( anObjectName );
+
+  if ( !myIsEdit ) {
+    myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() );
+    myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() );
+  }
+
+  erasePreview();
+
+  if( !myIsEdit )
+    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+
+  return true;
+}
+
+void HYDROGUI_ChannelOp::onCreatePreview( const bool theIsInit )
+{
+  HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
+  if ( !aPanel || myEditedObject.IsNull() )
+    return;
+
+  QString aGuideLineName = aPanel->getGuideLineName();
+  QString aProfileName = aPanel->getProfileName();
+  if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() )
+  {
+    if ( !theIsInit )
+    {
+      myEditedObject->RemoveGuideLine();
+      myEditedObject->RemoveProfile();
+      myEditedObject->Update();
+    }
+
+    erasePreview();
+    return;
+  }
+
+  // Update channel data
+  if ( !theIsInit )
+  {
+    Handle(HYDROData_Polyline3D) aGuideLine = Handle(HYDROData_Polyline3D)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aGuideLineName, KIND_POLYLINE ) );
+    myEditedObject->SetGuideLine( aGuideLine );
+
+    Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+    myEditedObject->SetProfile( aProfile );
+
+    if ( myEditedObject->IsMustBeUpdated() )
+      myEditedObject->Update();
+  }
+
+  LightApp_Application* anApp = module()->getApp();
+  if ( !myViewManager )
+    myViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
+      anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+
+  if ( myViewManager && !myPreviewPrs )
+  {
+    if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+    {
+      Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+      if ( !aCtx.IsNull() )
+        myPreviewPrs = new HYDROGUI_Shape( aCtx, myEditedObject );
+    }
+  }
+
+  if ( !myViewManager || !myPreviewPrs )
+    return;
+
+  myPreviewPrs->update();
+}
+
+void HYDROGUI_ChannelOp::erasePreview()
+{
+  if( myPreviewPrs )
+  {
+    delete myPreviewPrs;
+    myPreviewPrs = 0;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.h b/src/HYDROGUI/HYDROGUI_ChannelOp.h
new file mode 100644 (file)
index 0000000..f1456ee
--- /dev/null
@@ -0,0 +1,66 @@
+// 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_ChannelOp_H
+#define HYDROGUI_ChannelOp_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Channel.h>
+
+class OCCViewer_ViewManager;
+
+class HYDROGUI_Shape;
+
+class HYDROGUI_ChannelOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ChannelOp( HYDROGUI_Module* theModule, const bool theIsEdit );
+  virtual ~HYDROGUI_ChannelOp();
+
+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                       onCreatePreview( const bool theIsInit = false );
+
+private:
+  void                       erasePreview();
+
+private:
+  bool                       myIsEdit;
+  Handle(HYDROData_Channel)  myEditedObject;
+
+  OCCViewer_ViewManager*     myViewManager;
+
+  HYDROGUI_Shape*            myPreviewPrs;
+};
+
+#endif
index cad9dc666008bdef9ea84852fb0e13ffd325ce31..8c8396d6624b33cc60e44e61f42c8f56f2aaec70 100644 (file)
@@ -267,6 +267,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsZone = false;
   bool anIsObstacle = false;
   bool anIsStream = false;
+  bool anIsChannel = false;
   bool anIsGeomObject = false;
 
   // check the selected GEOM objects
@@ -348,6 +349,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsObstacle = true;
       else if( anObjectKind == KIND_STREAM )
         anIsStream = true;
+      else if( anObjectKind == KIND_CHANNEL )
+        anIsChannel = true;
     }
 
     anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
@@ -372,6 +375,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
           theMenu->addAction( action( ImportBathymetryId ) );
           break;
         case KIND_ARTIFICIAL_OBJECT:
+          theMenu->addAction( action( CreateChannelId ) );
           break;
         case KIND_NATURAL_OBJECT:
           theMenu->addAction( action( CreateImmersibleZoneId ) );
@@ -475,6 +479,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( EditStreamId ) );
         theMenu->addSeparator();
       }
+      else if( anIsChannel )
+      {
+        theMenu->addAction( action( EditChannelId ) );
+        theMenu->addSeparator();
+      }
       else if( anIsVisualState && anIsObjectBrowser )
       {
         theMenu->addAction( action( SaveVisualStateId ) );
@@ -496,8 +505,10 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addAction( action( DeleteId ) );
     theMenu->addSeparator();
 
-    if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone || 
-        anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsValidProfile )
+    if( anIsImage || anIsPolyline || anIsPolyline3D || 
+        anIsImmersibleZone || anIsZone || anIsRegion ||
+        anIsBathymetry || anIsObstacle || anIsStream ||
+        anIsChannel || anIsValidProfile )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
index f702ecbfef8940d99c13c439139ddba49d11dac3..b9788afd9ed901299b1fdc17277dd6f0734a06c5 100644 (file)
@@ -107,7 +107,8 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
        anObjectKind != KIND_ZONE &&
        anObjectKind != KIND_OBSTACLE &&
        anObjectKind != KIND_PROFILE &&
-       anObjectKind != KIND_STREAM )
+       anObjectKind != KIND_STREAM &&
+       anObjectKind != KIND_CHANNEL )
     return aResShape;
 
   aResShape = new HYDROGUI_Shape( theContext, theObject );
index 6e1bc51ca7a06c39aad7d5c114953e0bd794f183..79622a50b0ae4b2fe1251c8b6a9d737e03c004a5 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "HYDROGUI_CopyPasteOp.h"
 #include "HYDROGUI_CalculationOp.h"
+#include "HYDROGUI_ChannelOp.h"
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_DeleteOp.h"
 #include "HYDROGUI_ExportImageOp.h"
@@ -126,6 +127,9 @@ void HYDROGUI_Module::createActions()
   createAction( CreateStreamId, "CREATE_STREAM" );
   createAction( EditStreamId, "EDIT_STREAM" );
 
+  createAction( CreateChannelId, "CREATE_CHANNEL" );
+  createAction( EditChannelId, "EDIT_CHANNEL" );
+
   createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE" );
   createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT" );
   createAction( CreateBoxId, "CREATE_BOX" );
@@ -177,18 +181,22 @@ void HYDROGUI_Module::createMenus()
   createMenu( CreatePolylineId, aHydroId, -1, -1 );
   createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
 
-  int aNewProfileId = createMenu( tr( "MEN_PROFILE" ), aHydroId, -1 );
+  int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
   createMenu( CreateProfileId, aNewProfileId, -1, -1 );
   createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
   createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
 
-  createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
-  createMenu( CreateStreamId, aHydroId, -1, -1 );
+  int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 );
+  createMenu( CreateImmersibleZoneId, anArtificialMenuId, -1, -1 );
+  createMenu( CreateStreamId, anArtificialMenuId, -1, -1 );
+
+  int aNaturalMenuId = createMenu( tr( "MEN_DESK_NATURAL" ), aHydroId, -1 );
+  createMenu( CreateChannelId, aNaturalMenuId, -1, -1 );
 
-  int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 );
-  createMenu( ImportObstacleFromFileId, aNewObstacleId, -1, -1 );
-  createMenu( CreateBoxId, aNewObstacleId, -1, -1 );
-  createMenu( CreateCylinderId, aNewObstacleId, -1, -1 );
+  int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
+  createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
+  createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
+  createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
 
   createMenu( CreateCalculationId, aHydroId, -1, -1 );
   createMenu( separator(), aHydroId );
@@ -374,6 +382,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditStreamId:
     anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
     break;
+  case CreateChannelId:
+  case EditChannelId:
+    anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
+    break;
   case CreateCalculationId:
   case EditCalculationId:
     anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
index 534d56caa108b9e7d172e44c346fa66c1eaa73a0..d892d67f518dcddace385121c84c389b36b0f336 100644 (file)
@@ -64,6 +64,9 @@ enum OperationId
   CreateStreamId,
   EditStreamId,
 
+  CreateChannelId,
+  EditChannelId,
+
   CreateCalculationId,
   EditCalculationId,
   ExportCalculationId,
index adbed36710e04d0a30fd0d3a854943331d80ab82..4ddd3b2dde6b17d497a192e5c6419cb0a788c40a 100644 (file)
@@ -37,6 +37,7 @@
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 
+#include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_ImmersibleZone.h>
@@ -317,6 +318,21 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       QColor aFillingColor = aStream->GetFillingColor();
       QColor aBorderColor = aStream->GetBorderColor();
 
+      setFillingColor( aFillingColor, false, false );
+      setBorderColor( aBorderColor, false, false );
+    }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) )
+    {
+      Handle(HYDROData_Channel) aChannel =
+        Handle(HYDROData_Channel)::DownCast( myObject );
+
+      TopoDS_Face aChannelShape = TopoDS::Face( aChannel->GetTopShape() );
+
+      setShape( aChannelShape, false, false );
+
+      QColor aFillingColor = aChannel->GetFillingColor();
+      QColor aBorderColor = aChannel->GetBorderColor();
+
       setFillingColor( aFillingColor, false, false );
       setBorderColor( aBorderColor, false, false );
     }
index 2189ebd1006427e3469ff5adb970195a3630d26a..007e855f6bbab0b7276915c588995065ece06b44 100644 (file)
@@ -223,7 +223,8 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
         ( anObject->GetKind() == KIND_ZONE ) ||
         ( anObject->GetKind() == KIND_OBSTACLE ) ||
         ( anObject->GetKind() == KIND_PROFILE ) ||
-        ( anObject->GetKind() == KIND_STREAM ) ) )
+        ( anObject->GetKind() == KIND_STREAM ) ||
+        ( anObject->GetKind() == KIND_CHANNEL ) ) )
       {
         theSeq.Append( anObject );
       }
index 7ffb7cdecbfb6f48ee0baeecf2efce2c05598e07..b94d2147ff4dadd8db4ffeaf1cb2dec7dc937d6f 100644 (file)
@@ -512,6 +512,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_EDIT_STREAM</source>
       <translation>Edit stream</translation>
     </message>
+    <message>
+      <source>DSK_CREATE_CHANNEL</source>
+      <translation>Create channel</translation>
+    </message>
+    <message>
+      <source>DSK_EDIT_CHANNEL</source>
+      <translation>Edit channel</translation>
+    </message>
     <message>
       <source>DSK_COPY</source>
       <translation>Copy</translation>
@@ -692,6 +700,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_EDIT_STREAM</source>
       <translation>Edit stream</translation>
     </message>
+    <message>
+      <source>MEN_CREATE_CHANNEL</source>
+      <translation>Create channel</translation>
+    </message>
+    <message>
+      <source>MEN_EDIT_CHANNEL</source>
+      <translation>Edit channel</translation>
+    </message>
     <message>
       <source>MEN_CUT_IMAGES</source>
       <translation>Cut images</translation>
@@ -700,10 +716,26 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_DELETE</source>
       <translation>Delete</translation>
     </message>
+    <message>
+      <source>MEN_DESK_ARTIFICIAL</source>
+      <translation>Artificial objects</translation>
+    </message>
     <message>
       <source>MEN_DESK_HYDRO</source>
       <translation>HYDRO</translation>
     </message>
+    <message>
+      <source>MEN_DESK_NATURAL</source>
+      <translation>Natural objects</translation>
+    </message>
+    <message>
+      <source>MEN_DESK_OBSTACLE</source>
+      <translation>Obstacle</translation>
+    </message>
+    <message>
+      <source>MEN_DESK_PROFILE</source>
+      <translation>Profile</translation>
+    </message>
     <message>
       <source>MEN_EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
@@ -812,14 +844,6 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_UPDATE_IMAGE</source>
       <translation>Update image</translation>
     </message>
-    <message>
-      <source>MEN_OBSTACLE</source>
-      <translation>Obstacle</translation>
-    </message>
-    <message>
-      <source>MEN_PROFILE</source>
-      <translation>Profile</translation>
-    </message>
     <message>
       <source>MEN_IMPORT_OBSTACLE_FROM_FILE</source>
       <translation>Import obstacle</translation>
@@ -880,6 +904,14 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_EDIT_STREAM</source>
       <translation>Edit stream</translation>
     </message>
+    <message>
+      <source>STB_CREATE_CHANNEL</source>
+      <translation>Create channel</translation>
+    </message>
+    <message>
+      <source>STB_EDIT_CHANNEL</source>
+      <translation>Edit channel</translation>
+    </message>
     <message>
       <source>STB_COPY</source>
       <translation>Copy</translation>
@@ -1529,4 +1561,44 @@ file cannot be correctly imported for an Obstacle definition.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_ChannelDlg</name>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+    <message>
+      <source>CHANNEL_NAME</source>
+      <translation>Channel name</translation>
+    </message>
+    <message>
+      <source>CHANNEL_PARAMETERS</source>
+      <translation>Parameters</translation>
+    </message>
+    <message>
+      <source>CHANNEL_GUIDE_LINE</source>
+      <translation>Guide line</translation>
+    </message>
+    <message>
+      <source>CHANNEL_PROFILE</source>
+      <translation>Profile</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ChannelOp</name>
+    <message>
+      <source>CREATE_CHANNEL</source>
+      <translation>Create channel</translation>
+    </message>
+    <message>
+      <source>EDIT_CHANNEL</source>
+      <translation>Edit channel</translation>
+    </message>
+    <message>
+      <source>DEFAULT_CHANNEL_NAME</source>
+      <translation>Channel</translation>
+    </message>
+  </context>
+
 </TS>