From 0df953327ef66ec8f0d1ac3a625b569ba1a6a3c2 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 27 Mar 2015 17:44:06 +0300 Subject: [PATCH] Display river profiles in embedded viewer. --- src/HYDROGUI/HYDROGUI_InputPanel.cxx | 10 + src/HYDROGUI/HYDROGUI_InputPanel.h | 3 + src/HYDROGUI/HYDROGUI_ObjComboBox.cxx | 26 +- src/HYDROGUI/HYDROGUI_ObjComboBox.h | 3 + src/HYDROGUI/HYDROGUI_Operations.cxx | 6 + src/HYDROGUI/HYDROGUI_Operations.h | 3 +- src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 8 + src/HYDROGUI/HYDROGUI_ProfileDlg.h | 3 + .../HYDROGUI_ProfileInterpolateDlg.cxx | 322 +++++++------- src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h | 91 ++-- .../HYDROGUI_ProfileInterpolateOp.cxx | 418 +++++++++--------- src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h | 20 +- src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx | 16 + src/HYDROGUI/HYDROGUI_RiverBottomDlg.h | 8 +- src/HYDROGUI/HYDROGUI_ViewerDlg.cxx | 38 +- src/HYDROGUI/HYDROGUI_ViewerDlg.h | 12 +- src/HYDROGUI/resources/HYDROGUI_images.ts | 5 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 54 +++ 18 files changed, 642 insertions(+), 404 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 2ecb4c88..a496a82d 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -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(); diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 2c53aaef..b9dadee6 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -49,6 +49,9 @@ public: HYDROGUI_Module* module() const; + bool isApplyEnabled() const; + void setApplyEnabled( bool ); + signals: void panelApply(); void panelCancel(); diff --git a/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx index 8dff3a2f..d2f9d6e2 100644 --- a/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -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 ) ); + } } diff --git a/src/HYDROGUI/HYDROGUI_ObjComboBox.h b/src/HYDROGUI/HYDROGUI_ObjComboBox.h index c06e41d1..59502e28 100644 --- a/src/HYDROGUI/HYDROGUI_ObjComboBox.h +++ b/src/HYDROGUI/HYDROGUI_ObjComboBox.h @@ -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; }; diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index a5a4ea75..12106628 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -58,6 +58,7 @@ #include "HYDROGUI_ZLevelsOp.h" #include "HYDROGUI_LocalCSOp.h" #include "HYDROGUI_RiverBottomOp.h" +#include "HYDROGUI_ProfileInterpolateOp.h" #include #include @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 8745e107..84ffd714 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -107,7 +107,8 @@ enum OperationId SetZLevelId, EditLocalCSId, - RiverBottom + RiverBottom, + ProfileInterpolate }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index ea9bfd8a..52e94566 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -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; +} diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index 9f5969f4..d49f29f5 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -66,6 +66,9 @@ signals: void subOperationStarted(QWidget*); void subOperationFinished(QWidget*); +protected: + virtual Handle(AIS_Trihedron) trihedron(); + private: QLineEdit* myName; CurveCreator_Widget* myEditorWidget; diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx index 99d4ca5f..622a18af 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx @@ -22,13 +22,10 @@ #include "HYDROGUI_ProfileInterpolateDlg.h" -#include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" -#include "HYDROGUI_AISTrihedron.h" - -#include -#include -#include +#include "HYDROGUI_Module.h" +#include "HYDROGUI_ObjComboBox.h" +#include "HYDROGUI_OCCSelector.h" #include #include @@ -36,205 +33,230 @@ #include #include +#include #include #include -#include -#include #include +#include #include -#include +#include +#include +#include +#include + +#include +#include 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( 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 aSections; - aSections << 0; - myEditorWidget->setSelectedSections( aSections ); +QString HYDROGUI_ProfileInterpolateDlg::interpolatorParameters() const +{ + return myParams->text(); } -QList 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( 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( 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(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; } diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h index cac217c7..ec7ef984 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h @@ -23,19 +23,20 @@ #ifndef HYDROGUI_PROFILEINTERPOLATEDLG_H #define HYDROGUI_PROFILEINTERPOLATEDLG_H -#include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_ViewerDlg.h" + +#include "HYDROGUI_ObjComboBox.h" #include -class CurveCreator_Widget; -class CurveCreator_ICurve; -class OCCViewer_ViewManager; -class SUIT_ViewWindow; -class QGroupBox; +#include + +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 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 RiverProfiles; + +private: + HYDROGUI_ObjComboBox* myRiver; + QComboBox* myIntrp; + QTextEdit* myDescr; + QLineEdit* myParams; + + HYDROGUI_ObjComboBox* myProfileStart; + HYDROGUI_ObjComboBox* myProfileFinish; + QSpinBox* myProfileNumber; + + RiverProfiles myRiverProfiles; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx index c713bfab..6578a86d 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx @@ -20,261 +20,283 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include #include -#include -#include -#include -#include -#include + +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_DataObject.h" +#include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_ProfileInterpolateDlg.h" + +#include #include -#include -#include #include #include #include -#include #include +#include #include - #include -#include - -//static int ZValueIncrement = 0; +#include +#include -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( 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( 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( 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( 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( 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( 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( 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( 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(); } diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h index c3fe408f..241c0683 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h @@ -27,19 +27,16 @@ #include -class HYDROGUI_CurveCreatorProfile; +#include 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 diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx index 8a0c9094..7e93c158 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx @@ -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() ); +} diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h index 981d5f00..d0af4420 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h @@ -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; }; diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx index dd9b4e0d..3c51c100 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -34,7 +34,9 @@ #include #include #include + #include +#include #include #include @@ -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)(); +} diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.h b/src/HYDROGUI/HYDROGUI_ViewerDlg.h index 6d844c49..b806c520 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.h +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.h @@ -25,10 +25,14 @@ #include "HYDROGUI_InputPanel.h" +#include #include 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* ); diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index 9f5955f6..539367de 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -392,5 +392,10 @@ icon_river_bottom_image.png + + PROFILE_INTERPOLATE_ICO + icon_profile_interpolate_image.png + + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index ea7b2ede..ed61ffca 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1355,6 +1355,20 @@ Would you like to remove all references from the image? STB_CREATE_RIVER_BOTTOM Creates the river bottom polyline on selected river object + + + MEN_PROFILE_INTERPOLATE + River profiles interpolation + + + DSK_PROFILE_INTERPOLATE + Interpolate the river profiles + + + STB_PROFILE_INTERPOLATE + Creates the new river profiles using interpolation of selected ones + + @@ -2262,4 +2276,44 @@ Polyline should consist from one not closed curve. + + HYDROGUI_ProfileInterpolateDlg + + RIVER_OBJECT + River object + + + INTERPOLATOR + Interpolator + + + DESCRIPTION + Description + + + PROFILE_1 + Profile 1 + + + PROFILE_2 + Profile 2 + + + NUMBER_OF_PROFILES + Number of profiles + + + PARAMETERS + Parameters + + + + + HYDROGUI_ProfileInterpolateOp + + PROFILE_INTERPOLATION + Profile interpolation + + + -- 2.39.2