]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Display river profiles in embedded viewer.
authorstv <stv@opencascade.com>
Fri, 27 Mar 2015 14:44:06 +0000 (17:44 +0300)
committerstv <stv@opencascade.com>
Fri, 27 Mar 2015 14:44:06 +0000 (17:44 +0300)
18 files changed:
src/HYDROGUI/HYDROGUI_InputPanel.cxx
src/HYDROGUI/HYDROGUI_InputPanel.h
src/HYDROGUI/HYDROGUI_ObjComboBox.cxx
src/HYDROGUI/HYDROGUI_ObjComboBox.h
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_ProfileDlg.cxx
src/HYDROGUI/HYDROGUI_ProfileDlg.h
src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx
src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h
src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx
src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h
src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx
src/HYDROGUI/HYDROGUI_RiverBottomDlg.h
src/HYDROGUI/HYDROGUI_ViewerDlg.cxx
src/HYDROGUI/HYDROGUI_ViewerDlg.h
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 2ecb4c885b6d7a16c61106acb0bfeb5abcc28aa5..a496a82d7c416e31d2e9832ebab8dd8b45edd65f 100644 (file)
@@ -83,6 +83,16 @@ HYDROGUI_Module* HYDROGUI_InputPanel::module() const
   return myModule;
 }
 
+bool HYDROGUI_InputPanel::isApplyEnabled() const
+{
+    return myApply->isEnabled();
+}
+
+void HYDROGUI_InputPanel::setApplyEnabled( bool on )
+{
+    myApply->setEnabled( on );
+}
+
 void HYDROGUI_InputPanel::onApply()
 {
   emit panelApply(); 
index 2c53aaefb71352d0df13efd36619cbbd43757332..b9dadee6b6b5a91d09b97894bd66f8274c59442f 100644 (file)
@@ -49,6 +49,9 @@ public:
 
   HYDROGUI_Module* module() const;
 
+  bool             isApplyEnabled() const;
+  void             setApplyEnabled( bool );
+
 signals:
   void panelApply();
   void panelCancel();
index 8dff3a2f3d747acaa761b3d68d9a7c51ca8b5c38..d2f9d6e2ea2017b9b0f98d3b98ca13b64b378a40 100644 (file)
@@ -28,6 +28,7 @@
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <QTimer>
 #include <QLabel>
 #include <QLayout>
 #include <QComboBox>
@@ -44,7 +45,8 @@ HYDROGUI_ObjComboBox::HYDROGUI_ObjComboBox( HYDROGUI_Module* theModule, const QS
     QBoxLayout* base = new QHBoxLayout( this );
     base->setMargin( 0 );
 
-    base->addWidget( new QLabel( theTitle, this ) );
+    if ( !theTitle.isEmpty() )
+        base->addWidget( new QLabel( theTitle, this ) );
     base->addWidget( myObject = new QComboBox( this ) );
 
     myObject->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) );
@@ -80,9 +82,17 @@ void HYDROGUI_ObjComboBox::setObjectFilter( HYDROGUI_ObjComboBoxFilter* filter )
 
 void HYDROGUI_ObjComboBox::reset()
 {
+    bool block = myObject->signalsBlocked();
+    myObject->blockSignals( true );
+
     myObject->clear();
     myObject->addItems( objectNames() );
-    onSelectionChanged();
+    myObject->setCurrentIndex( -1 );
+
+    myObject->blockSignals( block );
+
+    onIndexChanged( myObject->currentIndex() );
+    updateSelection();
 }
 
 void HYDROGUI_ObjComboBox::setSectedObject( const QString& theName )
@@ -129,13 +139,21 @@ void HYDROGUI_ObjComboBox::onIndexChanged( int idx )
 }
 
 void HYDROGUI_ObjComboBox::onSelectionChanged()
+{
+    if ( !objectFilter() || objectFilter()->isActive( this ) )
+        QTimer::singleShot( 0, this, SLOT( updateSelection() ) );
+}
+
+void HYDROGUI_ObjComboBox::updateSelection()
 {
     int idx = -1;
     Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::GetSelectedObject( module() );
     if ( !anObject.IsNull() )
         idx = myObject->findText( anObject->GetName() );
 
-    myObject->setCurrentIndex( idx );
-    if ( idx >= 0 )
+    if ( idx >= 0 && myObject->currentIndex() != idx )
+    {
+        myObject->setCurrentIndex( idx );
         emit objectSelected( myObject->itemText( idx ) );
+    }
 }
index c06e41d15ab7ae39163d50929d84e52d513c630d..59502e28d96286fef55b2a9c6a5e456937c7e6bd 100644 (file)
@@ -59,6 +59,8 @@ private slots:
     void                        onSelectionChanged();
     void                        onIndexChanged( int );
 
+    void                        updateSelection();
+
 protected:
     QStringList                 objectNames() const;
     SUIT_SelectionMgr*          selectionMgr() const;
@@ -76,6 +78,7 @@ public:
     HYDROGUI_ObjComboBoxFilter() {};
     virtual ~HYDROGUI_ObjComboBoxFilter() {};
 
+    virtual bool isActive( HYDROGUI_ObjComboBox* ) const { return true; };
     virtual bool isOk( const Handle(HYDROData_Entity)& ) const = 0;
 };
 
index a5a4ea75dfff10c230e97ccba1910253186d1b44..12106628e9b83560b222905895e7ba4edbee6828 100644 (file)
@@ -58,6 +58,7 @@
 #include "HYDROGUI_ZLevelsOp.h"
 #include "HYDROGUI_LocalCSOp.h"
 #include "HYDROGUI_RiverBottomOp.h"
+#include "HYDROGUI_ProfileInterpolateOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -183,6 +184,7 @@ void HYDROGUI_Module::createActions()
   createAction( HideAllId, "HIDE_ALL" );
 
   createAction( RiverBottom, "CREATE_RIVER_BOTTOM", "CREATE_RIVER_BOTTOM_ICO" );
+  createAction( ProfileInterpolate, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -212,6 +214,7 @@ void HYDROGUI_Module::createMenus()
   createMenu( CreateProfileId, aNewProfileId, -1, -1 );
   createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
   createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
+  createMenu( ProfileInterpolate, aNewProfileId, -1, -1 );
 
   int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 );
   createMenu( CreateChannelId, anArtificialMenuId, -1, -1 );
@@ -423,6 +426,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditProfileId:
     anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
     break;
+  case ProfileInterpolate:
+    anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
+    break;
   case ImportProfilesId:
     anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
     break;
index 8745e1078c11c68c367c5751c576113673abe991..84ffd714ef05493c276055892e428e9e63d30962 100644 (file)
@@ -107,7 +107,8 @@ enum OperationId
   SetZLevelId,
   EditLocalCSId,
 
-  RiverBottom
+  RiverBottom,
+  ProfileInterpolate
 };
 
 #endif
index ea9bfd8a00c8f91149fe38c99c5edeee0949f317..52e945663706d17c560b047edca2dda84f502ef0 100644 (file)
@@ -154,3 +154,11 @@ void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget )
   theWidget->hide();
   myAddElementBox->hide();
 }
+
+Handle(AIS_Trihedron) HYDROGUI_ProfileDlg::trihedron()
+{
+    SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+    Handle(AIS_Trihedron) aTrihedron =
+        HYDROGUI_AISTrihedron::createTrihedron( aResMgr->doubleValue( "3DViewer", "trihedron_size", viewer()->trihedronSize() ) );
+    return aTrihedron;
+}
index 9f5969f425c864f2cf2409fc73390ad0d03bc6fb..d49f29f5842d48f2bc302106a7c39a3bb0f051a2 100644 (file)
@@ -66,6 +66,9 @@ signals:
   void                  subOperationStarted(QWidget*);
   void                  subOperationFinished(QWidget*);
 
+protected:
+  virtual Handle(AIS_Trihedron) trihedron();
+
 private:
   QLineEdit*             myName;
   CurveCreator_Widget*   myEditorWidget;
index 99d4ca5f1a0179c465acf3621e1eda86c1be8e7e..622a18af6772a7b667e6dd39ebe55c0ad2e89008 100644 (file)
 
 #include "HYDROGUI_ProfileInterpolateDlg.h"
 
-#include "HYDROGUI_Module.h"
 #include "HYDROGUI_Tool.h"
-#include "HYDROGUI_AISTrihedron.h"
-
-#include <CurveCreator_Widget.h>
-#include <CurveCreator_ICurve.hxx>
-#include <CurveCreator_Utils.hxx>
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_ObjComboBox.h"
+#include "HYDROGUI_OCCSelector.h"
 
 #include <OCCViewer_ViewPort3d.h>
 #include <OCCViewer_Utilities.h>
 #include <OCCViewer_ViewFrame.h>
 #include <LightApp_Application.h>
 
+#include <SUIT_Tools.h>
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 
-#include <QGroupBox>
-#include <QHBoxLayout>
 #include <QLabel>
+#include <QSpinBox>
 #include <QLineEdit>
-#include <QMouseEvent>
+#include <QTextEdit>
+#include <QGroupBox>
+#include <QComboBox>
+#include <QGridLayout>
+
+#include <HYDROData_Stream.h>
+#include <HYDROData_Profile.h>
 
 HYDROGUI_ProfileInterpolateDlg::HYDROGUI_ProfileInterpolateDlg( 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);
-
-  int anActionFlags = 
-    CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode |
-    CurveCreator_Widget::DisableClosedSection;
-  QStringList aCoordTitles;
-  aCoordTitles << tr( "U_TITLE" ) << tr( "Z_TITLE" );
-  myEditorWidget = new CurveCreator_Widget( this, NULL, anActionFlags, aCoordTitles );
-  addWidget( myEditorWidget, 3 );
-
-  myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );
-  addWidget( myAddElementBox, 2 );
-
-  QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
-  anAddElementLayout->setMargin( 0 );
-  anAddElementLayout->setSpacing( 5 );
-
-  myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 );
-  OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( false );
-
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-  aViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
-                     aResMgr->backgroundValue( "OCCViewer", "xz_background", aViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
-  aViewer->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
-                     aResMgr->backgroundValue( "OCCViewer", "yz_background", aViewer->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
-  aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
-                     aResMgr->backgroundValue( "OCCViewer", "xy_background", aViewer->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
-  aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
-                     aResMgr->backgroundValue( "OCCViewer", "background", aViewer->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
-
-  aViewer->setTrihedronSize( aResMgr->doubleValue( "3DViewer", "trihedron_size", aViewer->trihedronSize() ),
-                        aResMgr->booleanValue( "3DViewer", "relative_size", aViewer->trihedronRelative() ));
-  aViewer->setInteractionStyle( aResMgr->integerValue( "3DViewer", "navigation_mode", aViewer->interactionStyle() ) );
-  aViewer->setZoomingStyle( aResMgr->integerValue( "3DViewer", "zooming_mode", aViewer->zoomingStyle() ) );
-  aViewer->enablePreselection( aResMgr->booleanValue( "OCCViewer", "enable_preselection", aViewer->isPreselectionEnabled() ) );
-  aViewer->enableSelection( aResMgr->booleanValue( "OCCViewer", "enable_selection", aViewer->isSelectionEnabled() ) );
-
-  myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface
-  SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow();
-  aViewer->setStaticTrihedronDisplayed( false );
-  Handle(AIS_Trihedron) aTrihedron = HYDROGUI_AISTrihedron::createTrihedron(
-                         aResMgr->doubleValue( "3DViewer", "trihedron_size",
-                                               aViewer->trihedronSize() ));
-  Handle(AIS_InteractiveContext) anAISContext = aViewer->getAISContext();
-  if ( !anAISContext.IsNull() ) {
-    anAISContext->Display( aTrihedron );
-    anAISContext->Deactivate( aTrihedron );
-  }
-
-  addWidget( aViewWin, 4 );
-  myEditorWidget->setOCCViewer( aViewer );
-
-  connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
-  connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
-  connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
-
-  myAddElementBox->hide();
-
-  // Coordinates
-  connect( myViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
-           this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
-  if ( aViewWin ) {
-    OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWin );
-    if ( aViewFrame && aViewFrame->getViewPort() ) {
-      aViewFrame->getViewPort()->installEventFilter( this );
-    }
-  }
+    : HYDROGUI_ViewerDlg( theModule, theTitle )
+{
+    QWidget* main = new QGroupBox( mainFrame() );
+    QGridLayout* base = new QGridLayout( main );
+
+    addWidget( main );
+
+    base->addWidget( new QLabel( tr( "RIVER_OBJECT" ), main ), 0, 0, 1, 1 );
+    base->addWidget( myRiver = new HYDROGUI_ObjComboBox( theModule, QString::null, KIND_STREAM, main ), 0, 1, 1, 1 );
+
+    base->addWidget( new QLabel( tr( "INTERPOLATOR" ), main ), 1, 0, 1, 1 );
+    base->addWidget( myIntrp = new QComboBox( main ), 1, 1, 1, 1 );
+
+    base->addWidget( new QLabel( tr( "DESCRIPTION" ), main ), 2, 0, 1, 1 );
+    base->addWidget( myDescr = new QTextEdit( main ), 2, 1, 1, 1 );
+    myDescr->setReadOnly( true );
+
+    base->addWidget( new QLabel( tr( "PROFILE_1" ), main ), 3, 0, 1, 1 );
+    base->addWidget( myProfileStart = new HYDROGUI_ObjComboBox( theModule, QString::null, KIND_PROFILE, main ), 3, 1, 1, 1 );
+    myProfileStart->setObjectFilter( this );
+
+    base->addWidget( new QLabel( tr( "PROFILE_2" ), main ), 4, 0, 1, 1 );
+    base->addWidget( myProfileFinish = new HYDROGUI_ObjComboBox( theModule, QString::null, KIND_PROFILE, main ), 4, 1, 1, 1 );
+    myProfileFinish->setObjectFilter( this );
 
-  myCoordLabel = new QLabel( this );
-  QHBoxLayout* aCoordLayout = new QHBoxLayout();
-  aCoordLayout->addWidget( myCoordLabel );
-  aCoordLayout->addStretch();
+    base->addWidget( new QLabel( tr( "NUMBER_OF_PROFILES" ), main ), 5, 0, 1, 1 );
+    base->addWidget( myProfileNumber = new QSpinBox( main ), 5, 1, 1, 1 );
+    myProfileNumber->setRange( 1, 1000 );
 
-  addLayout( aCoordLayout );
+    base->addWidget( new QLabel( tr( "PARAMETERS" ), main ), 6, 0, 1, 1 );
+    base->addWidget( myParams = new QLineEdit( main ), 6, 1, 1, 1 );
+
+    connect( myRiver, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onRiverChanged( const QString& ) ) );
+    connect( myIntrp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onInterpolatorIndexChanged( int ) ) );
+
+    connect( myProfileStart, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onProfileChanged( const QString& ) ) );
+    connect( myProfileFinish, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onProfileChanged( const QString& ) ) );
+
+    connect( myProfileStart, SIGNAL( objectSelected( const QString& ) ), this, SIGNAL( profileStartChanged( const QString& ) ) );
+    connect( myProfileFinish, SIGNAL( objectSelected( const QString& ) ), this, SIGNAL( profileFinishChanged( const QString& ) ) );
+
+    connect( myProfileNumber, SIGNAL( valueChanged( int ) ), this, SIGNAL( profileNumberChanged( int ) ) );
+    connect( myParams, SIGNAL( myParams->textChanged( const QString& ) ), this, SIGNAL( interpolatorParametersChanged( const QString& ) ) );
+
+    new HYDROGUI_OCCSelector( module(), viewer(), selectionMgr() );
+
+    updateState();
 }
 
 HYDROGUI_ProfileInterpolateDlg::~HYDROGUI_ProfileInterpolateDlg()
 {
-  delete myViewManager;
 }
 
-void HYDROGUI_ProfileInterpolateDlg::reset()
+QString HYDROGUI_ProfileInterpolateDlg::interpolator() const
 {
-  myEditorWidget->reset();
-  myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode );
+    return myIntrp->currentText();
 }
 
-Handle(AIS_InteractiveContext) HYDROGUI_ProfileInterpolateDlg::getAISContext()
+void HYDROGUI_ProfileInterpolateDlg::setInterpolator( const QString& theInterp )
 {
-  OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)myViewManager->getViewModel();
-  return aViewer ? aViewer->getAISContext() : 0;
+    int idx = myIntrp->findText( theInterp );
+    if ( idx >= 0 )
+        myIntrp->setCurrentIndex( idx );
 }
 
-void HYDROGUI_ProfileInterpolateDlg::setProfileName( const QString& theName )
+void HYDROGUI_ProfileInterpolateDlg::setInterpolators( const QStringList& theList )
 {
-  myName->setText(theName);
+    myIntrp->clear();
+    myIntrp->addItems( theList );
 }
 
-QString HYDROGUI_ProfileInterpolateDlg::getProfileName() const
+QString HYDROGUI_ProfileInterpolateDlg::interpolatorDescription() const
 {
-  return myName->text();
+    return myDescr->toPlainText();
 }
 
-void HYDROGUI_ProfileInterpolateDlg::setProfile( CurveCreator_ICurve* theProfile )
+void HYDROGUI_ProfileInterpolateDlg::setInterpolatorDescription( const QString& theText )
 {
-  myEditorWidget->setCurve( theProfile );
+    myDescr->setText( theText );
+}
 
-  // select the single section by default
-  QList<int> aSections;
-  aSections << 0;
-  myEditorWidget->setSelectedSections( aSections );
+QString HYDROGUI_ProfileInterpolateDlg::interpolatorParameters() const
+{
+    return myParams->text();
 }
 
-QList<int> HYDROGUI_ProfileInterpolateDlg::getSelectedSections()
+void HYDROGUI_ProfileInterpolateDlg::setInterpolatorParameters( const QString& theLine )
 {
-  return myEditorWidget->getSelectedSections();
+    myParams->setText( theLine );
 }
 
-/**
- * Redirect the delete action to editor widget
- */
-void HYDROGUI_ProfileInterpolateDlg::deleteSelected()
+QString HYDROGUI_ProfileInterpolateDlg::river() const
 {
-  myEditorWidget->removeSelected();
+    return myRiver->selectedObject();
 }
 
-/**
- * Checks whether there are some to delete
- */
-bool HYDROGUI_ProfileInterpolateDlg::deleteEnabled()
+void HYDROGUI_ProfileInterpolateDlg::setRiver( const QString& theName )
 {
-  return myEditorWidget->removeEnabled();
+    myRiver->setSectedObject( theName );
 }
 
-void HYDROGUI_ProfileInterpolateDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
+QString HYDROGUI_ProfileInterpolateDlg::profileStart() const
 {
-  myEditorWidget->setEnabled( false );
+    return myProfileStart->selectedObject();
+}
 
-  myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
-  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
-  anAddElementLayout->addWidget( theWidget );
+void HYDROGUI_ProfileInterpolateDlg::setProfileStart( const QString& theName )
+{
+    myProfileStart->setSectedObject( theName );
+}
 
-  theWidget->show();
-  myAddElementBox->show();
+QString HYDROGUI_ProfileInterpolateDlg::profileFinish() const
+{
+    return myProfileFinish->selectedObject();
 }
 
-void HYDROGUI_ProfileInterpolateDlg::processFinishedSubOperation( QWidget* theWidget )
+void HYDROGUI_ProfileInterpolateDlg::setProfileFinish( const QString& theName )
 {
-  myEditorWidget->setEnabled( true );
+    myProfileFinish->setSectedObject( theName );
+}
+
+int HYDROGUI_ProfileInterpolateDlg::profileNumber() const
+{
+    return myProfileNumber->value();
+}
+
+void HYDROGUI_ProfileInterpolateDlg::setProfileNumber( int theNum )
+{
+    myProfileNumber->setValue( theNum );
+}
+
+bool HYDROGUI_ProfileInterpolateDlg::isActive( HYDROGUI_ObjComboBox* selector ) const
+{
+    return selector == activeProfile();
+}
+
+bool HYDROGUI_ProfileInterpolateDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
+{
+    if ( theEntity.IsNull() )
+        return false;
+
+    bool res = true;
+    if ( theEntity->GetKind() == KIND_PROFILE )
+    {
+        if ( myRiverProfiles.isEmpty() )
+        {
+            Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), river(), KIND_STREAM ) );
+            if ( !aStream.IsNull() )
+            {
+                HYDROData_SequenceOfObjects aProfiles = aStream->GetProfiles();
+                HYDROGUI_ProfileInterpolateDlg* that = (HYDROGUI_ProfileInterpolateDlg*)this;
+                for ( int i = aProfiles.Lower(); i <= aProfiles.Upper(); i++ )
+                    that->myRiverProfiles.insert( aProfiles.Value( i )->GetName() );
+            }
+        }
+        res = myRiverProfiles.contains( theEntity->GetName() );
+    }
+    return res;
+}
+
+void HYDROGUI_ProfileInterpolateDlg::reset()
+{
+    myRiverProfiles.clear();
 
-  QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
-  anAddElementLayout->removeWidget( theWidget );
+    myRiver->reset();
+    myProfileStart->reset();
+    myProfileFinish->reset();
 
-  theWidget->hide();
-  myAddElementBox->hide();
+    myDescr->setText( QString::null );
 }
 
-void HYDROGUI_ProfileInterpolateDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
+void HYDROGUI_ProfileInterpolateDlg::onRiverChanged( const QString& theName )
 {
-  OCCViewer_ViewWindow* anOCCViewWindow = 
-    dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
-  if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) {
-    gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( 
-      theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() );
+    myRiverProfiles.clear();
 
-    // Show the coordinates
-    QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X(), true );
-    QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y(), true );
-    myCoordLabel->setText( tr("UZ_COORDINATES_INFO").arg( aX ).arg( anY ) );
-  }
+    myProfileStart->reset();
+    myProfileFinish->reset();
+
+    updateState();
+
+    emit riverChanged( theName );
 }
 
-bool HYDROGUI_ProfileInterpolateDlg::eventFilter( QObject* theObj, QEvent* theEvent )
+void HYDROGUI_ProfileInterpolateDlg::onInterpolatorIndexChanged( int theIdx )
 {
-  if ( theObj->inherits( "OCCViewer_ViewPort" ) )
-  {
-    if ( theEvent->type() == QEvent::Leave )
-      myCoordLabel->clear();
+    emit interpolatorChanged( myIntrp->itemText( theIdx ) );
+}
 
-    return false;
-  }
+void HYDROGUI_ProfileInterpolateDlg::onProfileChanged( const QString& )
+{
+    updateState();
+}
+
+void HYDROGUI_ProfileInterpolateDlg::updateState()
+{
+    setApplyEnabled( !river().isEmpty() && !profileStart().isEmpty() && !profileFinish().isEmpty() );
+}
 
-  return HYDROGUI_InputPanel::eventFilter( theObj, theEvent );
+HYDROGUI_ObjComboBox* HYDROGUI_ProfileInterpolateDlg::activeProfile() const
+{
+    HYDROGUI_ObjComboBox* profile = myProfileFinish;
+    if ( myProfileStart->selectedObject().isEmpty() )
+        profile = myProfileStart;
+    else if ( myProfileFinish->selectedObject().isEmpty() )
+        profile = myProfileFinish;
+    else if ( SUIT_Tools::isParent( myProfileStart->parentWidget()->focusWidget(), myProfileStart ) )
+        profile = myProfileStart;
+    else if ( SUIT_Tools::isParent( myProfileFinish->parentWidget()->focusWidget(), myProfileFinish ) )
+        profile = myProfileFinish;
+    return profile;
 }
index cac217c7640e54dceeabc0ed9532f3705d106cfa..ec7ef984a4f539d49978d373882af34cae0ada3d 100644 (file)
 #ifndef HYDROGUI_PROFILEINTERPOLATEDLG_H
 #define HYDROGUI_PROFILEINTERPOLATEDLG_H
 
-#include "HYDROGUI_InputPanel.h"
+#include "HYDROGUI_ViewerDlg.h"
+
+#include "HYDROGUI_ObjComboBox.h"
 
 #include <AIS_InteractiveContext.hxx>
 
-class CurveCreator_Widget;
-class CurveCreator_ICurve;
-class OCCViewer_ViewManager;
-class SUIT_ViewWindow;
-class QGroupBox;
+#include <QSet>
+
+class QSpinBox;
 class QLineEdit;
-class QLabel;
+class QComboBox;
+class QTextEdit;
 
-class HYDROGUI_ProfileInterpolateDlg : public HYDROGUI_InputPanel
+class HYDROGUI_ProfileInterpolateDlg : public HYDROGUI_ViewerDlg, public HYDROGUI_ObjComboBoxFilter
 {
   Q_OBJECT
 
@@ -43,41 +44,65 @@ public:
   HYDROGUI_ProfileInterpolateDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_ProfileInterpolateDlg();
 
-  Handle(AIS_InteractiveContext) getAISContext();
+  QString                interpolator() const;
+  void                   setInterpolator( const QString& );
+  void                   setInterpolators( const QStringList& );
+
+  QString                interpolatorDescription() const;
+  void                   setInterpolatorDescription( const QString& );
 
-  void  setProfileName( const QString& theName );
-  QString getProfileName() const;
-       
-  void  setProfile( CurveCreator_ICurve* theProfile );
+  QString                interpolatorParameters() const;
+  void                   setInterpolatorParameters( const QString& );
 
-  void  reset();
+  QString                river() const;
+  void                   setRiver( const QString& );
 
-  QList<int> getSelectedSections();
+  QString                profileStart() const;
+  void                   setProfileStart( const QString& );
 
-  void  deleteSelected();
-  bool  deleteEnabled();
+  QString                profileFinish() const;
+  void                   setProfileFinish( const QString& );
 
-protected:
-  virtual bool eventFilter( QObject*, QEvent* );
+  int                    profileNumber() const;
+  void                   setProfileNumber( int );
 
-protected slots:
-  void processStartedSubOperation( QWidget*, bool );
-  void processFinishedSubOperation( QWidget* );
+  void                   reset();
 
-  void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
+  virtual bool           isActive( HYDROGUI_ObjComboBox* ) const;
+  virtual bool           isOk( const Handle(HYDROData_Entity)& ) const;
 
 signals:
-  void                  createPreview( QString );
-  void                  selectionChanged();
-  void                  widgetCreated(QWidget*);
-  void                  subOperationStarted(QWidget*);
-  void                  subOperationFinished(QWidget*);
+  void                   riverChanged( const QString& );
+  void                   interpolatorChanged( const QString& );
+  void                   interpolatorParametersChanged( const QString& );
+
+  void                   profileNumberChanged( int );
+  void                   profileStartChanged( const QString& );
+  void                   profileFinishChanged( const QString& );
+
+private slots:
+  void                   onRiverChanged( const QString& );
+  void                   onInterpolatorIndexChanged( int );
+  void                   onProfileChanged( const QString& );
+
 private:
-  QLineEdit*             myName;
-  CurveCreator_Widget*   myEditorWidget;
-  QGroupBox*             myAddElementBox;
-  OCCViewer_ViewManager* myViewManager;
-  QLabel*                myCoordLabel;
+  void                   updateState();
+  HYDROGUI_ObjComboBox*  activeProfile() const;
+
+private:
+  typedef QSet<QString> RiverProfiles;
+
+private:
+  HYDROGUI_ObjComboBox*  myRiver;
+  QComboBox*             myIntrp;
+  QTextEdit*             myDescr;
+  QLineEdit*             myParams;
+
+  HYDROGUI_ObjComboBox*  myProfileStart;
+  HYDROGUI_ObjComboBox*  myProfileFinish;
+  QSpinBox*              myProfileNumber;
+
+  RiverProfiles          myRiverProfiles;
 };
 
 #endif
index c713bfab1121756df44aaa42976cb7c046f38335..6578a86de6d1468a74934aba827c7b1dedf75508 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include <HYDROGUI_Module.h>
 #include <HYDROGUI_ProfileInterpolateOp.h>
-#include <HYDROGUI_ProfileDlg.h>
-#include <HYDROGUI_Tool.h>
-#include <HYDROGUI_UpdateFlags.h>
-#include <HYDROGUI_DataObject.h>
-#include <HYDROData_Document.h>
+
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_ProfileInterpolateDlg.h"
+
+#include <HYDROData_Stream.h>
 #include <HYDROData_Profile.h>
-#include <HYDROGUI_CurveCreatorProfile.h>
-#include <CurveCreator_Displayer.hxx>
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_UpdateFlags.h>
 
-#include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewWindow.h>
-
 #include <OCCViewer_AISSelector.h>
 
-#include <Precision.hxx>
-
-//static int ZValueIncrement = 0;
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
 
-HYDROGUI_ProfileInterpolateOp::HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule, bool theIsEdit )
-: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myProfile(NULL)
+HYDROGUI_ProfileInterpolateOp::HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule )
+    : HYDROGUI_Operation( theModule )
 {
-  setName( theIsEdit ? tr( "EDIT_PROFILE" ) : tr( "CREATE_PROFILE" ) );
+    setName( tr( "PROFILE_INTERPOLATION" ) );
 }
 
 HYDROGUI_ProfileInterpolateOp::~HYDROGUI_ProfileInterpolateOp()
 {
-  erasePreview();
 }
 
-/**
- * Redirect the delete action to input panel
- */
-void HYDROGUI_ProfileInterpolateOp::deleteSelected()
+void HYDROGUI_ProfileInterpolateOp::startOperation()
 {
-  HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();
-  aPanel->deleteSelected();
+    HYDROGUI_Operation::startOperation();
+
+    HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+    if ( aPanel )
+    {
+        aPanel->reset();
+        aPanel->setInterpolators( interpolators() );
+    }
+
+/*
+    if( myIsEdit )
+        myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+
+    QString aProfileName;
+    if( !myEditedObject.IsNull() )
+    {
+        Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ( false );
+        if ( !aProfileUZ.IsNull() )
+        {
+            CurveCreator::Coordinates aCurveCoords;
+            CurveCreator::SectionsMap aSectionsMap;
+
+            HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
+            CurveCreator::PosPointsList aPoints;
+            for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+            {
+                const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
+                aCurveCoords.clear();
+                aCurveCoords.push_back( aSectPoint.X() );
+                aCurveCoords.push_back( aSectPoint.Y() );
+
+                CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
+                aPoints.push_back( aPosPoint );
+            }
+
+            aSectionsMap[0] = aPoints;
+            myProfile->addPointsInternal( aSectionsMap );
+
+            HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 );
+
+            CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
+            if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE )
+                aCurveType = CurveCreator::Spline;
+
+            myProfile->setSectionType( 0, aCurveType );
+        }
+
+        aProfileName = myEditedObject->GetName();
+    }
+    else
+    {
+        aProfileName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_PROFILE_NAME" ) );
+    }
+
+    aPanel->setProfileName( aProfileName );
+    aPanel->setProfile( myProfile );
+*/
+//    displayPreview();
 }
 
-/**
- * Checks whether there are some to delete
- */
-bool HYDROGUI_ProfileInterpolateOp::deleteEnabled()
+void HYDROGUI_ProfileInterpolateOp::abortOperation()
 {
-  HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();
-  return aPanel->deleteEnabled();
+    HYDROGUI_Operation::abortOperation();
 }
 
-void HYDROGUI_ProfileInterpolateOp::startOperation()
+void HYDROGUI_ProfileInterpolateOp::commitOperation()
 {
-  if( myProfile )
-    delete myProfile;
+    HYDROGUI_Operation::commitOperation();
+}
 
-  myProfile = new HYDROGUI_CurveCreatorProfile();
+HYDROGUI_InputPanel* HYDROGUI_ProfileInterpolateOp::createInputPanel() const
+{
+    HYDROGUI_ProfileInterpolateDlg* aDlg = new HYDROGUI_ProfileInterpolateDlg( module(), getName() );
 
-  HYDROGUI_Operation::startOperation();
+    connect( aDlg, SIGNAL( riverChanged( const QString& ) ), this, SLOT( onRiverChanged( const QString& ) ) );
+    connect( aDlg, SIGNAL( interpolatorChanged( const QString& ) ), this, SLOT( onInterpolatorChanged( const QString& ) ) );
+    connect( aDlg, SIGNAL( interpolatorParametersChanged( const QString& ) ), this, SLOT( updatePreview() ) );
+    connect( aDlg, SIGNAL( profileNumberChanged( int ) ), this, SLOT( updatePreview() ) );
+    connect( aDlg, SIGNAL( profileStartChanged( const QString& ) ), this, SLOT( updatePreview() ) );
+    connect( aDlg, SIGNAL( profileFinishChanged( const QString& ) ), this, SLOT( updatePreview() ) );
 
-  HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();
-  aPanel->reset();
+    return aDlg;
+}
 
-  if( myIsEdit )
-    myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+bool HYDROGUI_ProfileInterpolateOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
+                                                  QStringList& theBrowseObjectsEntries )
+{
+    HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+    if ( !aPanel )
+        return false;
+/*
+    QString aProfileName = aPanel->getProfileName().simplified();
+    if ( aProfileName.isEmpty() )
+    {
+        theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+        return false;
+    }
 
-  QString aProfileName;
-  if( !myEditedObject.IsNull() )
-  {
-    Handle(HYDROData_ProfileUZ) aProfileUZ = myEditedObject->GetProfileUZ( false );
-    if ( !aProfileUZ.IsNull() )
+    if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aProfileName ) )
     {
-      CurveCreator::Coordinates aCurveCoords;
-      CurveCreator::SectionsMap aSectionsMap;
+        // check that there are no other objects with the same name in the document
+        Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aProfileName );
+        if( !anObject.IsNull() )
+        {
+            theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aProfileName );
+            return false;
+        }
+    }
 
-      HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
-      CurveCreator::PosPointsList aPoints;
-      for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
-      {
-        const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
-        aCurveCoords.clear();
-        aCurveCoords.push_back( aSectPoint.X() );
-        aCurveCoords.push_back( aSectPoint.Y() );
+    Handle(HYDROData_Profile) aProfileObj;
+    if( myIsEdit ){
+        aProfileObj = myEditedObject;
+    }
+    else{
+        aProfileObj = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+    }
 
-        CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
-        aPoints.push_back( aPosPoint );
-      }
+    if( aProfileObj.IsNull() )
+        return false;
 
-      aSectionsMap[0] = aPoints;
-      myProfile->addPointsInternal( aSectionsMap );
+    Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ();
+    if ( aProfileUZ.IsNull() )
+        return false;
 
-      HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 );
+    aProfileObj->SetName(aProfileName);
 
-      CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
-      if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE )
-        aCurveType = CurveCreator::Spline;
+    HYDROData_ProfileUZ::PointsList aProfileParamPoints;
 
-      myProfile->setSectionType( 0, aCurveType );
+    CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 );
+    if ( aCurveCoords.size() <= 2 )
+    {
+        theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" );
+        return false;
     }
 
-    aProfileName = myEditedObject->GetName();
-  }
-  else
-  {
-    aProfileName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_PROFILE_NAME" ) );
-  }
+    for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ )
+    {
+        HYDROData_ProfileUZ::Point aProfileParamPoint;
 
-  aPanel->setProfileName( aProfileName );
-  aPanel->setProfile( myProfile );
-  displayPreview();
-}
+        aProfileParamPoint.SetX( aCurveCoords.at( k ) );
+        k++;
+        aProfileParamPoint.SetY( aCurveCoords.at( k ) );
 
-void HYDROGUI_ProfileInterpolateOp::abortOperation()
-{
-  erasePreview();
+        aProfileParamPoints.Append( aProfileParamPoint );
+    }
+    aProfileObj->SetParametricPoints( aProfileParamPoints );
 
-  HYDROGUI_Operation::abortOperation();
-}
+    HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
+    if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline )
+        aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
 
-void HYDROGUI_ProfileInterpolateOp::commitOperation()
-{
-  erasePreview();
+    aProfileUZ->SetSectionType( 0, aSectType );
+
+    if ( !myIsEdit )
+    {
+        aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
+    }
+
+    // At first we update the child u,z profile object
+    aProfileUZ->SetToUpdate( true );
+    aProfileUZ->Update();
 
-  HYDROGUI_Operation::commitOperation();
+    // And now we update our edited object
+    aProfileObj->Update();
+    module()->setIsToUpdate( aProfileObj );
+
+    theUpdateFlags = UF_Model;
+    if ( myIsEdit )
+        theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+    else
+    {
+        QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aProfileObj );
+        theBrowseObjectsEntries.append( anEntry );
+    }
+
+    */
+    return true;
 }
 
-HYDROGUI_InputPanel* HYDROGUI_ProfileInterpolateOp::createInputPanel() const
+void HYDROGUI_ProfileInterpolateOp::updatePreview()
 {
-  HYDROGUI_ProfileDlg* aDlg = new HYDROGUI_ProfileDlg( module(), getName() );
-  return aDlg;
+    HYDROGUI_ProfileInterpolateDlg* aDlg = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+    if ( !aDlg )
+        return;
+
+    Handle(AIS_InteractiveContext) aCtx = aDlg->getAISContext();
+    if ( aCtx.IsNull() )
+        return;
+
+    aCtx->UpdateCurrentViewer();
 }
 
-bool HYDROGUI_ProfileInterpolateOp::processApply( int& theUpdateFlags,
-                                       QString& theErrorMsg,
-                                       QStringList& theBrowseObjectsEntries )
+QStringList HYDROGUI_ProfileInterpolateOp::interpolators() const
 {
-  HYDROGUI_ProfileDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
-  if ( !aPanel )
-    return false;
-
-  QString aProfileName = aPanel->getProfileName().simplified();
-  if ( aProfileName.isEmpty() )
-  {
-    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
-    return false;
-  }
-
-  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aProfileName ) )
-  {
-    // check that there are no other objects with the same name in the document
-    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aProfileName );
-    if( !anObject.IsNull() )
-    {
-      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aProfileName );
-      return false;
-    }
-  }
-
-  Handle(HYDROData_Profile) aProfileObj;
-  if( myIsEdit ){
-    aProfileObj = myEditedObject;
-  }
-  else{
-    aProfileObj = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
-  }
-
-  if( aProfileObj.IsNull() )
-    return false;
-
-  Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ();
-  if ( aProfileUZ.IsNull() )
-    return false;
-
-  aProfileObj->SetName(aProfileName);
-
-  HYDROData_ProfileUZ::PointsList aProfileParamPoints;
-
-  CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 );
-  if ( aCurveCoords.size() <= 2 )
-  {
-    theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" );
-    return false;
-  }
-
-  for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ )
-  {
-    HYDROData_ProfileUZ::Point aProfileParamPoint;
-
-    aProfileParamPoint.SetX( aCurveCoords.at( k ) );
-    k++;
-    aProfileParamPoint.SetY( aCurveCoords.at( k ) );
-
-    aProfileParamPoints.Append( aProfileParamPoint );
-  }
-  aProfileObj->SetParametricPoints( aProfileParamPoints );
-
-  HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
-  if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline )
-    aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
-
-  aProfileUZ->SetSectionType( 0, aSectType );
-
-  if ( !myIsEdit )
-  {
-    aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
-  }
-
-  // At first we update the child u,z profile object
-  aProfileUZ->SetToUpdate( true );
-  aProfileUZ->Update();
-
-  // And now we update our edited object
-  aProfileObj->Update();
-  module()->setIsToUpdate( aProfileObj );
-
-  theUpdateFlags = UF_Model;
-  if ( myIsEdit )
-    theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
-  else
-  {
-    QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aProfileObj );
-    theBrowseObjectsEntries.append( anEntry );
-  }
-
-  return true;
+    return QStringList() << "Linear interpolator" << "Spline interpolator";
 }
 
-void HYDROGUI_ProfileInterpolateOp::displayPreview()
+void HYDROGUI_ProfileInterpolateOp::onInterpolatorChanged( const QString& theInterpName )
 {
-  HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
-  if( aPanel )
-  {
-    Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
-    if( !aCtx.IsNull() )
-    {
-      CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
-      myProfile->setDisplayer( aDisplayer );
-      aDisplayer->display( myProfile->getAISObject( true ), true );
-    }
-  }
+    HYDROGUI_ProfileInterpolateDlg* aPanel = dynamic_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+    if ( !aPanel )
+        return;
+
+    aPanel->setInterpolatorDescription( QString( "Profile will be calculated used %1" ).arg( theInterpName ) );
+
+    updatePreview();
 }
 
-void HYDROGUI_ProfileInterpolateOp::erasePreview()
+void HYDROGUI_ProfileInterpolateOp::onRiverChanged( const QString& theRiver )
 {
-  HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
-  CurveCreator_Displayer* aDisplayer = myProfile ? myProfile->getDisplayer() : 0;
-  if( aPanel && aDisplayer )
-  {
-    Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
-    if( !aCtx.IsNull() )
+    HYDROGUI_ProfileInterpolateDlg* aDlg = ::qobject_cast<HYDROGUI_ProfileInterpolateDlg*>( inputPanel() );
+    if ( !aDlg )
+        return;
+
+    Handle(AIS_InteractiveContext) aCtx = aDlg->getAISContext();
+    if ( !aCtx.IsNull() )
     {
-      aDisplayer->eraseAll( true );
+        AIS_ListOfInteractive aList;
+        aCtx->DisplayedObjects( aList );
+        for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
+        {
+            Handle(AIS_Shape) anObj = Handle(AIS_Shape)::DownCast( it.Value() );
+            if ( !anObj.IsNull() )
+                aCtx->Remove( anObj, false );
+        }
+
+        Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theRiver, KIND_STREAM ) );
+        if ( !aStream.IsNull() )
+        {
+            HYDROData_SequenceOfObjects aSeq = aStream->GetProfiles();
+            for ( int i = aSeq.Lower(); i <= aSeq.Upper(); i++ )
+            {
+                Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aSeq.Value( i ) );
+                if ( !aProfile.IsNull() )
+                {
+                    Handle(AIS_Shape) aPrs = new AIS_Shape( aProfile->GetShape3D() );
+                    aPrs->SetOwner( aProfile );
+                    aPrs->SetColor( Quantity_NOC_BLACK );
+                    aCtx->Display( aPrs, 0, 0, false );
+                }
+            }
+        }
     }
-  }
+    updatePreview();
 }
index c3fe408fd7ed56ba67c2b461c221ded18d261c40..241c0683b4c48eef6888cc43f67ada57f839ea88 100644 (file)
 
 #include <HYDROData_Profile.h>
 
-class HYDROGUI_CurveCreatorProfile;
+#include <AIS_Shape.hxx>
 
 class HYDROGUI_ProfileInterpolateOp : public HYDROGUI_Operation
 {
   Q_OBJECT
 
 public:
-  HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule, bool isEdit );
+  HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule );
   virtual ~HYDROGUI_ProfileInterpolateOp();
 
-  void                       deleteSelected();
-  bool                       deleteEnabled();
-
 protected:
   virtual void               startOperation();
   virtual void               abortOperation();
@@ -50,14 +47,15 @@ protected:
   virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg,
                                            QStringList& theBrowseObjectsEntries );
 
-private:
-  void                       displayPreview();
-  void                       erasePreview();
+  QStringList                interpolators() const;
+
+private slots:
+  void                       updatePreview();
+  void                       onRiverChanged( const QString& );
+  void                       onInterpolatorChanged( const QString& );
 
 private:
-  bool                       myIsEdit;
-  Handle(HYDROData_Profile)  myEditedObject;
-  HYDROGUI_CurveCreatorProfile* myProfile;
+  Handle(AIS_Shape)          myPreview;
 };
 
 #endif
index 8a0c9094c840c274e54109a2cc3c979d61568afc..7e93c158fec7a212c76ddda5902e27b659671d32 100644 (file)
@@ -42,6 +42,10 @@ HYDROGUI_RiverBottomDlg::HYDROGUI_RiverBottomDlg( HYDROGUI_Module* theModule, co
     addWidget( group );
 
     addStretch();
+
+    connect( myRivers, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onRiverChanged( const QString& ) ) );
+
+    updateState();
 }
 
 HYDROGUI_RiverBottomDlg::~HYDROGUI_RiverBottomDlg()
@@ -55,6 +59,8 @@ void HYDROGUI_RiverBottomDlg::reset()
     myRivers->reset();
 
     blockSignals( isBlocked );
+
+    updateState();
 }
 
 QString HYDROGUI_RiverBottomDlg::getRiverName() const
@@ -66,3 +72,13 @@ void HYDROGUI_RiverBottomDlg::setRiverName( const QString& theName )
 {
     myRivers->setSectedObject( theName );
 }
+
+void HYDROGUI_RiverBottomDlg::onRiverChanged( const QString& )
+{
+    updateState();
+}
+
+void HYDROGUI_RiverBottomDlg::updateState()
+{
+    setApplyEnabled( !getRiverName().isEmpty() );
+}
index 981d5f0051de0fb94e2c86faae6e8156ae8b0522..d0af44202849f5ba5596db2e337814f30caa4a59 100644 (file)
@@ -41,7 +41,13 @@ public:
   QString                    getRiverName() const;
   void                       setRiverName( const QString& );
 
-protected:
+private slots:
+  void                       onRiverChanged( const QString& );
+
+private:
+  void                       updateState();
+
+private:
   HYDROGUI_ObjComboBox*      myRivers;
 };
 
index dd9b4e0d00e1f933f970b984978c51b2aad99a90..3c51c10097e55f8b6aa3137cd94d3d4164f3a94a 100644 (file)
@@ -34,7 +34,9 @@
 #include <OCCViewer_Utilities.h>
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewFrame.h>
+
 #include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
 
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
@@ -54,7 +56,7 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin
 
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 );
-  OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( false );
+  OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( true );
 
   aViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
                           aResMgr->backgroundValue( "OCCViewer", "xz_background", aViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
@@ -74,8 +76,11 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin
 
   myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface
 
+  aViewer->enableMultiselection( false );
+
   SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow();
   aViewer->setStaticTrihedronDisplayed( false );
+  /*
   Handle(AIS_Trihedron) aTrihedron =
       HYDROGUI_AISTrihedron::createTrihedron( aResMgr->doubleValue( "3DViewer", "trihedron_size", aViewer->trihedronSize() ) );
   Handle(AIS_InteractiveContext) anAISContext = aViewer->getAISContext();
@@ -84,7 +89,7 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin
     anAISContext->Display( aTrihedron );
     anAISContext->Deactivate( aTrihedron );
   }
-
+  */
   viewBase->addWidget( aViewWin );
 
   // Coordinates
@@ -104,14 +109,26 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin
 
 HYDROGUI_ViewerDlg::~HYDROGUI_ViewerDlg()
 {
+  myViewManager->closeAllViews();
   delete myViewManager;
 }
 
 bool HYDROGUI_ViewerDlg::event( QEvent* e )
 {
     if ( e->type() == QEvent::Polish )
+    {
         addWidget( myCoordLabel->parentWidget(), 4 );
 
+        Handle(AIS_Trihedron) aTrihedron = trihedron();
+        Handle(AIS_InteractiveContext) anAISContext = getAISContext();
+        if ( !anAISContext.IsNull() && !aTrihedron.IsNull() )
+        {
+            viewer()->setTrihedronShown( false );
+            anAISContext->Display( aTrihedron );
+            anAISContext->Deactivate( aTrihedron );
+        }
+    }
+
     return HYDROGUI_InputPanel::event( e );
 }
 
@@ -131,6 +148,18 @@ OCCViewer_ViewManager* HYDROGUI_ViewerDlg::viewManager() const
     return myViewManager;
 }
 
+SUIT_SelectionMgr* HYDROGUI_ViewerDlg::selectionMgr() const
+{
+    SUIT_SelectionMgr* aSelMgr = 0;
+    if ( module() )
+    {
+        LightApp_Application* app = module()->getApp();
+        if ( app )
+            aSelMgr = app->selectionMgr();
+    }
+    return aSelMgr;
+}
+
 void HYDROGUI_ViewerDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
 {
   OCCViewer_ViewWindow* anOCCViewWindow = 
@@ -158,3 +187,8 @@ bool HYDROGUI_ViewerDlg::eventFilter( QObject* theObj, QEvent* theEvent )
 
   return HYDROGUI_InputPanel::eventFilter( theObj, theEvent );
 }
+
+Handle(AIS_Trihedron) HYDROGUI_ViewerDlg::trihedron()
+{
+    return Handle(AIS_Trihedron)();
+}
index 6d844c49303a4a39bc1c23ee0054aefa0f0bf276..b806c520906d60940406fbcd2f5c2430dbf369dd 100644 (file)
 
 #include "HYDROGUI_InputPanel.h"
 
+#include <AIS_Trihedron.hxx>
 #include <AIS_InteractiveContext.hxx>
 
 class QLabel;
+
 class SUIT_ViewWindow;
+class SUIT_SelectionMgr;
+
 class OCCViewer_Viewer;
 class OCCViewer_ViewManager;
 
@@ -42,15 +46,15 @@ public:
 
   Handle(AIS_InteractiveContext) getAISContext();
 
-  void                           deleteSelected();
-  bool                           deleteEnabled();
-
   virtual bool                   event( QEvent* );
+  virtual bool                   eventFilter( QObject*, QEvent* );
 
 protected:
   OCCViewer_Viewer*              viewer() const;
   OCCViewer_ViewManager*         viewManager() const;
-  virtual bool                   eventFilter( QObject*, QEvent* );
+  SUIT_SelectionMgr*             selectionMgr() const;
+
+  virtual Handle(AIS_Trihedron)  trihedron();
 
 protected slots:
   void                           onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
index 9f5955f648b50209d0daec9a4cf47b98127e2a2b..539367dea50e4f76496899360f884bc233b020f2 100644 (file)
       <translation>icon_river_bottom_image.png</translation>
     </message>
 
+    <message>
+      <source>PROFILE_INTERPOLATE_ICO</source>
+      <translation>icon_profile_interpolate_image.png</translation>
+    </message>
+
   </context>
 </TS>
index ea7b2ede7f03e7727dbd80926c1c8ec705da46a1..ed61ffca7c72b7c4f0ef8a18d2b4b974af494250 100644 (file)
@@ -1355,6 +1355,20 @@ Would you like to remove all references from the image?</translation>
       <source>STB_CREATE_RIVER_BOTTOM</source>
       <translation>Creates the river bottom polyline on selected river object</translation>
     </message>
+
+    <message>
+      <source>MEN_PROFILE_INTERPOLATE</source>
+      <translation>River profiles interpolation</translation>
+    </message>
+    <message>
+      <source>DSK_PROFILE_INTERPOLATE</source>
+      <translation>Interpolate the river profiles</translation>
+    </message>
+    <message>
+      <source>STB_PROFILE_INTERPOLATE</source>
+      <translation>Creates the new river profiles using interpolation of selected ones</translation>
+    </message>
+
   </context>
   
   <context>
@@ -2262,4 +2276,44 @@ Polyline should consist from one not closed curve.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_ProfileInterpolateDlg</name>
+    <message>
+      <source>RIVER_OBJECT</source>
+      <translation>River object</translation>
+    </message>
+    <message>
+      <source>INTERPOLATOR</source>
+      <translation>Interpolator</translation>
+    </message>
+    <message>
+      <source>DESCRIPTION</source>
+      <translation>Description</translation>
+    </message>
+    <message>
+      <source>PROFILE_1</source>
+      <translation>Profile 1</translation>
+    </message>
+    <message>
+      <source>PROFILE_2</source>
+      <translation>Profile 2</translation>
+    </message>
+    <message>
+      <source>NUMBER_OF_PROFILES</source>
+      <translation>Number of profiles</translation>
+    </message>
+    <message>
+      <source>PARAMETERS</source>
+      <translation>Parameters</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ProfileInterpolateOp</name>
+    <message>
+      <source>PROFILE_INTERPOLATION</source>
+      <translation>Profile interpolation</translation>
+    </message>
+  </context>
+
 </TS>