From: stv Date: Thu, 26 Mar 2015 08:16:13 +0000 (+0300) Subject: Draft version of "Find River Bottom", new viewer dialog base class, new component... X-Git-Tag: BR_hydro_v_1_0_5~25^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=575363a8b27efeb72d97631bcf9644486b14f2dd;p=modules%2Fhydro.git Draft version of "Find River Bottom", new viewer dialog base class, new component object combobox. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 937afe37..53ee63d6 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -48,6 +48,8 @@ set(PROJECT_HEADERS HYDROGUI_PolylineOp.h HYDROGUI_ProfileDlg.h HYDROGUI_ProfileOp.h + HYDROGUI_ProfileInterpolateDlg.h + HYDROGUI_ProfileInterpolateOp.h HYDROGUI_Prs.h HYDROGUI_PrsDriver.h HYDROGUI_PrsImage.h @@ -100,7 +102,11 @@ set(PROJECT_HEADERS HYDROGUI_ListSelector.h HYDROGUI_ZLayers.h HYDROGUI_PriorityWidget.h - HYDROGUI_PriorityTableModel.h + HYDROGUI_PriorityTableModel.h + HYDROGUI_RiverBottomDlg.h + HYDROGUI_RiverBottomOp.h + HYDROGUI_ViewerDlg.h + HYDROGUI_ObjComboBox.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -151,6 +157,8 @@ set(PROJECT_SOURCES HYDROGUI_PolylineOp.cxx HYDROGUI_ProfileDlg.cxx HYDROGUI_ProfileOp.cxx + HYDROGUI_ProfileInterpolateDlg.cxx + HYDROGUI_ProfileInterpolateOp.cxx HYDROGUI_Prs.cxx HYDROGUI_PrsDriver.cxx HYDROGUI_PrsImage.cxx @@ -204,7 +212,11 @@ set(PROJECT_SOURCES HYDROGUI_ZLayers2.cxx HYDROGUI_ZLayers3.cxx HYDROGUI_PriorityWidget.cxx - HYDROGUI_PriorityTableModel.cxx + HYDROGUI_PriorityTableModel.cxx + HYDROGUI_RiverBottomDlg.cxx + HYDROGUI_RiverBottomOp.cxx + HYDROGUI_ViewerDlg.cxx + HYDROGUI_ObjComboBox.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx new file mode 100644 index 00000000..3b199309 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx @@ -0,0 +1,141 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_ObjComboBox.h" + +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_Module.h" + +#include +#include + +#include +#include +#include + +#include +#include + +HYDROGUI_ObjComboBox::HYDROGUI_ObjComboBox( HYDROGUI_Module* theModule, const QString& theTitle, const ObjectKind& theType, QWidget* theParent ) + : QWidget( theParent ), + myType( theType ), + myModule( theModule ), + myFilter( 0 ) +{ + QBoxLayout* base = new QHBoxLayout( this ); + base->setMargin( 0 ); + + base->addWidget( new QLabel( theTitle, this ) ); + base->addWidget( myObject = new QComboBox( this ) ); + + myObject->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); + + // Connect signals and slots + connect( myObject, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onIndexChanged( int ) ) ); + connect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); +} + +HYDROGUI_ObjComboBox::~HYDROGUI_ObjComboBox() +{ +} + +HYDROGUI_Module* HYDROGUI_ObjComboBox::module() const +{ + return myModule; +} + +ObjectKind HYDROGUI_ObjComboBox::objectType() const +{ + return myType; +} + +HYDROGUI_ObjComboBoxFilter* HYDROGUI_ObjComboBox::objectFilter() const +{ + return myFilter; +} + +void HYDROGUI_ObjComboBox::setObjectFilter( HYDROGUI_ObjComboBoxFilter* filter ) +{ + myFilter = filter; +} + +void HYDROGUI_ObjComboBox::reset() +{ + myObject->clear(); + myObject->addItems( objectNames() ); + onSelectionChanged(); +} + +void HYDROGUI_ObjComboBox::setSectedObject( const QString& theName ) +{ + int aNewIdx = myObject->findText( theName ); + if ( aNewIdx != myObject->currentIndex() ) + myObject->setCurrentIndex( aNewIdx ); +} + +QString HYDROGUI_ObjComboBox::selectedObject() const +{ + return myObject->currentText(); +} + +SUIT_SelectionMgr* HYDROGUI_ObjComboBox::selectionMgr() const +{ + SUIT_SelectionMgr* aSelMgr = 0; + if ( module() ) + { + LightApp_Application* app = module()->getApp(); + if ( app ) + aSelMgr = app->selectionMgr(); + } + return aSelMgr; +} + +QStringList HYDROGUI_ObjComboBox::objectNames() const +{ + QStringList aNames; + for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), objectType() ); it.More(); it.Next() ) + { + if ( !objectFilter() || objectFilter()->isOk( it.Current() ) ) + aNames.append( it.Current()->GetName() ); + } + return aNames; +} + +void HYDROGUI_ObjComboBox::onIndexChanged( int idx ) +{ + if ( idx < 0 ) + return; + + emit objectSelected( myObject->itemText( idx ) ); +} + +void HYDROGUI_ObjComboBox::onSelectionChanged() +{ + 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 ) + emit objectSelected( myObject->itemText( idx ) ); +} diff --git a/src/HYDROGUI/HYDROGUI_ObjComboBox.h b/src/HYDROGUI/HYDROGUI_ObjComboBox.h new file mode 100644 index 00000000..0cb5ca38 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ObjComboBox.h @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_OBJCOMBOBOX_H +#define HYDROGUI_OBJCOMBOBOX_H + +#include + +#include + +class HYDROGUI_Module; +class HYDROGUI_ObjComboBoxFilter; + +class SUIT_SelectionMgr; + +class HYDROGUI_ObjComboBox : public QWidget +{ + Q_OBJECT + +public: + HYDROGUI_ObjComboBox( HYDROGUI_Module* theModule, const QString& theTitle, const ObjectKind& = KIND_UNKNOWN, QWidget* = 0 ); + virtual ~HYDROGUI_ObjComboBox(); + + HYDROGUI_Module* module() const; + + ObjectKind objectType() const; + + HYDROGUI_ObjComboBoxFilter* objectFilter() const; + void setObjectFilter( HYDROGUI_ObjComboBoxFilter* ); + + QString selectedObject() const; + void setSectedObject( const QString& ); + + void reset(); + +signals: + void objectSelected( const QString& ); + +private slots: + void onSelectionChanged(); + void onIndexChanged( int ); + +protected: + QStringList objectNames() const; + SUIT_SelectionMgr* selectionMgr() const; + +private: + ObjectKind myType; + QComboBox* myObject; + HYDROGUI_Module* myModule; + HYDROGUI_ObjComboBoxFilter* myFilter; +}; + +class HYDROGUI_ObjComboBoxFilter +{ +public: + HYDROGUI_ObjComboBoxFilter() {}; + virtual ~HYDROGUI_ObjComboBoxFilter() {}; + + virtual bool isOk( const Handle(HYDROData_Entity)& ) const = 0; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 2f96689b..a5a4ea75 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -57,6 +57,7 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_ZLevelsOp.h" #include "HYDROGUI_LocalCSOp.h" +#include "HYDROGUI_RiverBottomOp.h" #include #include @@ -180,6 +181,8 @@ void HYDROGUI_Module::createActions() createAction( ShowAllId, "SHOW_ALL" ); createAction( HideId, "HIDE" ); createAction( HideAllId, "HIDE_ALL" ); + + createAction( RiverBottom, "CREATE_RIVER_BOTTOM", "CREATE_RIVER_BOTTOM_ICO" ); } void HYDROGUI_Module::createMenus() @@ -202,6 +205,7 @@ void HYDROGUI_Module::createMenus() createMenu( ImportBathymetryId, aHydroId, -1, -1 ); createMenu( CreatePolylineId, aHydroId, -1, -1 ); createMenu( CreatePolyline3DId, aHydroId, -1, -1 ); + createMenu( RiverBottom, aHydroId, -1, -1 ); createMenu( EditLocalCSId, aHydroId, -1, -1 ); int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 ); @@ -505,6 +509,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditLocalCSId: anOp = new HYDROGUI_LocalCSOp( aModule ); break; + case RiverBottom: + anOp = new HYDROGUI_RiverBottomOp( aModule ); + break; case ShowId: case ShowOnlyId: case ShowAllId: diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index e7c34834..8745e107 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -107,6 +107,7 @@ enum OperationId SetZLevelId, EditLocalCSId, + RiverBottom }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index d5460cc4..ea9bfd8a 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -46,7 +46,8 @@ #include HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL) +: HYDROGUI_ViewerDlg( theModule, theTitle ), + myName( NULL ) { QHBoxLayout* aNameLayout = new QHBoxLayout(); QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this); @@ -71,68 +72,17 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr anAddElementLayout->setMargin( 0 ); anAddElementLayout->setSpacing( 5 ); - myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); - OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( false /*erase trihedron*/); - - 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 ); + myEditorWidget->setOCCViewer( viewer() ); 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 ); - } - } - - myCoordLabel = new QLabel( this ); - QHBoxLayout* aCoordLayout = new QHBoxLayout(); - aCoordLayout->addWidget( myCoordLabel ); - aCoordLayout->addStretch(); - - addLayout( aCoordLayout ); } HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg() { - delete myViewManager; } void HYDROGUI_ProfileDlg::reset() @@ -141,12 +91,6 @@ void HYDROGUI_ProfileDlg::reset() myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode ); } -Handle(AIS_InteractiveContext) HYDROGUI_ProfileDlg::getAISContext() -{ - OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)myViewManager->getViewModel(); - return aViewer ? aViewer->getAISContext() : 0; -} - void HYDROGUI_ProfileDlg::setProfileName( const QString& theName ) { myName->setText(theName); @@ -210,31 +154,3 @@ void HYDROGUI_ProfileDlg::processFinishedSubOperation( QWidget* theWidget ) theWidget->hide(); myAddElementBox->hide(); } - -void HYDROGUI_ProfileDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent ) -{ - OCCViewer_ViewWindow* anOCCViewWindow = - dynamic_cast(theViewWindow); - if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) { - gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( - theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() ); - - // 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 ) ); - } -} - -bool HYDROGUI_ProfileDlg::eventFilter( QObject* theObj, QEvent* theEvent ) -{ - if ( theObj->inherits( "OCCViewer_ViewPort" ) ) - { - if ( theEvent->type() == QEvent::Leave ) - myCoordLabel->clear(); - - return false; - } - - return HYDROGUI_InputPanel::eventFilter( theObj, theEvent ); -} diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index d8ec36bb..9f5969f4 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -23,7 +23,7 @@ #ifndef HYDROGUI_PROFILEDLG_H #define HYDROGUI_PROFILEDLG_H -#include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_ViewerDlg.h" #include @@ -35,7 +35,7 @@ class QGroupBox; class QLineEdit; class QLabel; -class HYDROGUI_ProfileDlg : public HYDROGUI_InputPanel +class HYDROGUI_ProfileDlg : public HYDROGUI_ViewerDlg { Q_OBJECT @@ -43,8 +43,6 @@ public: HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_ProfileDlg(); - Handle(AIS_InteractiveContext) getAISContext(); - void setProfileName( const QString& theName ); QString getProfileName() const; @@ -57,27 +55,21 @@ public: void deleteSelected(); bool deleteEnabled(); -protected: - virtual bool eventFilter( QObject*, QEvent* ); - protected slots: void processStartedSubOperation( QWidget*, bool ); void processFinishedSubOperation( QWidget* ); - void onMouseMove( SUIT_ViewWindow*, QMouseEvent* ); - signals: void createPreview( QString ); void selectionChanged(); void widgetCreated(QWidget*); void subOperationStarted(QWidget*); void subOperationFinished(QWidget*); + private: QLineEdit* myName; CurveCreator_Widget* myEditorWidget; QGroupBox* myAddElementBox; - OCCViewer_ViewManager* myViewManager; - QLabel* myCoordLabel; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx new file mode 100644 index 00000000..04e6ceeb --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx @@ -0,0 +1,240 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_ProfileInterpolateDlg.h" + +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_AISTrihedron.h" + +#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 ); + } + } + + myCoordLabel = new QLabel( this ); + QHBoxLayout* aCoordLayout = new QHBoxLayout(); + aCoordLayout->addWidget( myCoordLabel ); + aCoordLayout->addStretch(); + + addLayout( aCoordLayout ); +} + +HYDROGUI_ProfileInterpolateDlg::~HYDROGUI_ProfileInterpolateDlg() +{ + delete myViewManager; +} + +void HYDROGUI_ProfileInterpolateDlg::reset() +{ + myEditorWidget->reset(); + myEditorWidget->setActionMode( CurveCreator_Widget::AdditionMode ); +} + +Handle(AIS_InteractiveContext) HYDROGUI_ProfileInterpolateDlg::getAISContext() +{ + OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)myViewManager->getViewModel(); + return aViewer ? aViewer->getAISContext() : 0; +} + +void HYDROGUI_ProfileInterpolateDlg::setProfileName( const QString& theName ) +{ + myName->setText(theName); +} + +QString HYDROGUI_ProfileInterpolateDlg::getProfileName() const +{ + return myName->text(); +} + +void HYDROGUI_ProfileInterpolateDlg::setProfile( CurveCreator_ICurve* theProfile ) +{ + myEditorWidget->setCurve( theProfile ); + + // select the single section by default + QList aSections; + aSections << 0; + myEditorWidget->setSelectedSections( aSections ); +} + +QList HYDROGUI_ProfileInterpolateDlg::getSelectedSections() +{ + return myEditorWidget->getSelectedSections(); +} + +/** + * Redirect the delete action to editor widget + */ +void HYDROGUI_ProfileInterpolateDlg::deleteSelected() +{ + myEditorWidget->removeSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_ProfileInterpolateDlg::deleteEnabled() +{ + return myEditorWidget->removeEnabled(); +} + +void HYDROGUI_ProfileInterpolateDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit ) +{ + myEditorWidget->setEnabled( false ); + + myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) ); + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->addWidget( theWidget ); + + theWidget->show(); + myAddElementBox->show(); +} + +void HYDROGUI_ProfileInterpolateDlg::processFinishedSubOperation( QWidget* theWidget ) +{ + myEditorWidget->setEnabled( true ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->removeWidget( theWidget ); + + theWidget->hide(); + myAddElementBox->hide(); +} + +void HYDROGUI_ProfileInterpolateDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent ) +{ + OCCViewer_ViewWindow* anOCCViewWindow = + dynamic_cast(theViewWindow); + if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) { + gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( + theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() ); + + // 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 ) ); + } +} + +bool HYDROGUI_ProfileInterpolateDlg::eventFilter( QObject* theObj, QEvent* theEvent ) +{ + if ( theObj->inherits( "OCCViewer_ViewPort" ) ) + { + if ( theEvent->type() == QEvent::Leave ) + myCoordLabel->clear(); + + return false; + } + + return HYDROGUI_InputPanel::eventFilter( theObj, theEvent ); +} diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h new file mode 100644 index 00000000..a20a92bb --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.h @@ -0,0 +1,83 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_PROFILEINTERPOLATEDLG_H +#define HYDROGUI_PROFILEINTERPOLATEDLG_H + +#include "HYDROGUI_InputPanel.h" + +#include + +class CurveCreator_Widget; +class CurveCreator_ICurve; +class OCCViewer_ViewManager; +class SUIT_ViewWindow; +class QGroupBox; +class QLineEdit; +class QLabel; + +class HYDROGUI_ProfileInterpolateDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_ProfileInterpolateDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ProfileInterpolateDlg(); + + Handle(AIS_InteractiveContext) getAISContext(); + + void setProfileName( const QString& theName ); + QString getProfileName() const; + + void setProfile( CurveCreator_ICurve* theProfile ); + + void reset(); + + QList getSelectedSections(); + + void deleteSelected(); + bool deleteEnabled(); + +protected: + virtual bool eventFilter( QObject*, QEvent* ); + +protected slots: + void processStartedSubOperation( QWidget*, bool ); + void processFinishedSubOperation( QWidget* ); + + void onMouseMove( SUIT_ViewWindow*, QMouseEvent* ); + +signals: + void createPreview( QString ); + void selectionChanged(); + void widgetCreated(QWidget*); + void subOperationStarted(QWidget*); + void subOperationFinished(QWidget*); +private: + QLineEdit* myName; + CurveCreator_Widget* myEditorWidget; + QGroupBox* myAddElementBox; + OCCViewer_ViewManager* myViewManager; + QLabel* myCoordLabel; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx new file mode 100644 index 00000000..169b6282 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx @@ -0,0 +1,279 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include + +//static int ZValueIncrement = 0; + +HYDROGUI_ProfileInterpolateOp::HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule, bool theIsEdit ) +: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myProfile(NULL) +{ + setName( theIsEdit ? tr( "EDIT_PROFILE" ) : tr( "CREATE_PROFILE" ) ); +} + +HYDROGUI_ProfileInterpolateOp::~HYDROGUI_ProfileInterpolateOp() +{ + erasePreview(); +} + +/** + * Redirect the delete action to input panel + */ +void HYDROGUI_ProfileInterpolateOp::deleteSelected() +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + aPanel->deleteSelected(); +} + +/** + * Checks whether there are some to delete + */ +bool HYDROGUI_ProfileInterpolateOp::deleteEnabled() +{ + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + return aPanel->deleteEnabled(); +} + +void HYDROGUI_ProfileInterpolateOp::startOperation() +{ + if( myProfile ) + delete myProfile; + + myProfile = new HYDROGUI_CurveCreatorProfile(); + + HYDROGUI_Operation::startOperation(); + + HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel(); + aPanel->reset(); + + 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(); +} + +void HYDROGUI_ProfileInterpolateOp::abortOperation() +{ + erasePreview(); + + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_ProfileInterpolateOp::commitOperation() +{ + erasePreview(); + + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_ProfileInterpolateOp::createInputPanel() const +{ + HYDROGUI_ProfileDlg* aDlg = new HYDROGUI_ProfileDlg( module(), getName() ); + return aDlg; +} + +bool HYDROGUI_ProfileInterpolateOp::processApply( int& theUpdateFlags, + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + 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; +} + +void HYDROGUI_ProfileInterpolateOp::displayPreview() +{ + 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 ); + } + } +} + +void HYDROGUI_ProfileInterpolateOp::erasePreview() +{ + 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() ) + { + aDisplayer->eraseAll( true ); + } + } +} diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h new file mode 100644 index 00000000..d437d55c --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.h @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_PROFILEINTERPOLATEOP_H +#define HYDROGUI_PROFILEINTERPOLATEOP_H + +#include "HYDROGUI_Operation.h" + +#include + +class HYDROGUI_CurveCreatorProfile; + +class HYDROGUI_ProfileInterpolateOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ProfileInterpolateOp( HYDROGUI_Module* theModule, bool isEdit ); + virtual ~HYDROGUI_ProfileInterpolateOp(); + + void deleteSelected(); + bool deleteEnabled(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + +private: + void displayPreview(); + void erasePreview(); + +private: + bool myIsEdit; + Handle(HYDROData_Profile) myEditedObject; + HYDROGUI_CurveCreatorProfile* myProfile; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx new file mode 100644 index 00000000..0922662b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_RiverBottomDlg.h" + +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_ObjComboBox.h" + +#include +#include +#include +#include + +HYDROGUI_RiverBottomDlg::HYDROGUI_RiverBottomDlg( HYDROGUI_Module* theModule, const QString& theTitle ) + : HYDROGUI_InputPanel( theModule, theTitle ) +{ + // Channel name + QGroupBox* group = new QGroupBox( mainFrame() ); + QBoxLayout* base = new QVBoxLayout( group ); + + base->addWidget( myRivers = new HYDROGUI_ObjComboBox( theModule, tr( "RIVER_OBJECT" ), KIND_STREAM, group ) ); + + addWidget( group ); + + addStretch(); +} + +HYDROGUI_RiverBottomDlg::~HYDROGUI_RiverBottomDlg() +{ +} + +void HYDROGUI_RiverBottomDlg::reset() +{ + bool isBlocked = blockSignals( true ); + + myRivers->reset(); + + blockSignals( isBlocked ); +} + +QString HYDROGUI_RiverBottomDlg::getRiverName() const +{ + return myRivers->selectedObject(); +} + +void HYDROGUI_RiverBottomDlg::setRiverName( const QString& theName ) +{ + myRivers->setSectedObject( theName ); +} diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h new file mode 100644 index 00000000..a59e71bc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_RIVERBOTTOMDlg_H +#define HYDROGUI_RIVERBOTTOMDlg_H + +#include "HYDROGUI_InputPanel.h" + +class QComboBox; +class HYDROGUI_ObjComboBox; + +class HYDROGUI_RiverBottomDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_RiverBottomDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_RiverBottomDlg(); + + void reset(); + + QString getRiverName() const; + void setRiverName( const QString& ); + +protected: + HYDROGUI_ObjComboBox* myRivers; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx new file mode 100644 index 00000000..f0312216 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx @@ -0,0 +1,149 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_RiverBottomOp.h" + +#include "HYDROGUI_RiverBottomDlg.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_DataObject.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Shape.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include + +/* +#include + +#include +#include + +#include +#include + +#include +*/ + +HYDROGUI_RiverBottomOp::HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "FIND_RIVER_BOTTOM" ) ); +} + +HYDROGUI_RiverBottomOp::~HYDROGUI_RiverBottomOp() +{ +} + +void HYDROGUI_RiverBottomOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast( inputPanel() ); + + aPanel->reset(); + /* + QString aRiver; + Handle(HYDROData_River) aRiverObj = Handle(HYDROData_River)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( !aRiverObj.IsNull() ) + aRiver = aRiverObj->GetName(); + + aPanel->setRiverName( aRiver ); + */ +} + +void HYDROGUI_RiverBottomOp::abortOperation() +{ +// erasePreview(); + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_RiverBottomOp::commitOperation() +{ +// erasePreview(); + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_RiverBottomOp::createInputPanel() const +{ + HYDROGUI_RiverBottomDlg* aPanel = new HYDROGUI_RiverBottomDlg( module(), getName() ); + return aPanel; +} + +bool HYDROGUI_RiverBottomOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + Handle(HYDROData_River) aRiver = riverObject( aPanel->getRiverName() ); + if ( aRiver.IsNull() ) + { + theErrorMsg = tr( "INCORRECT_RIVER_OBJECT" ); + return false; + } + + startDocOperation(); + +// Handle(HYDRO_RiverBottom) aBottom = createNewObject(); +// aBottom->SetName( QString( "%1_Bottom" ).arg( aRiver->GetName() ) ); + +// erasePreview(); + +// module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aBottom, true ); +// theBrowseObjectsEntries.append( HYDROGUI_DataObject::dataObjectEntry( aBottom ) ); + +// module()->setIsToUpdate( aBottom ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + + commitDocOperation(); + + return true; +} +/* +Handle(HYDROData_RiverBottom) HYDROGUI_RiverBottomOp::createNewObject() +{ + return Handle(HYDROData_RiverBottom)::DownCast( doc()->CreateObject( KIND_RIVERBOTTOM ) ); +} +*/ + +Handle(HYDROData_River) HYDROGUI_RiverBottomOp::riverObject( const QString& theName ) const +{ + return Handle(HYDROData_River)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) ); +} +QStringList HYDROGUI_RiverBottomOp::riverNames( bool all ) const +{ + QStringList aNames; +/* + for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), KIND_RIVER ); it.More(); it.Next() ) + { + it.Current(); + if ( !aRiver.IsNull() && ( all || !aRiver->HasBottom() ) + aNames.append( aRiver->GetName() ); + } +*/ + return aNames; +} diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomOp.h b/src/HYDROGUI/HYDROGUI_RiverBottomOp.h new file mode 100644 index 00000000..b99b666f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RiverBottomOp.h @@ -0,0 +1,56 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_RiverBottomOp_H +#define HYDROGUI_RiverBottomOp_H + +#include "HYDROGUI_Operation.h" + +#include + +class HYDROGUI_RiverBottomOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_RiverBottomOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + +private: + Handle(HYDROData_River) riverObject( const QString& ) const; + QStringList riverNames( bool all = false ) const; + +protected: +// Handle(HYDROData_RiverBottom) createNewObject() const; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx new file mode 100644 index 00000000..e2ca565f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -0,0 +1,160 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_ViewerDlg.h" + +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_AISTrihedron.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + QWidget* viewMain = new QWidget( mainFrame() ); + QVBoxLayout* viewBase = new QVBoxLayout( viewMain ); + viewBase->setMargin( 0 ); + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); + OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( false ); + + 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 ); + } + + viewBase->addWidget( aViewWin ); + + // 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 ); + } + + myCoordLabel = new QLabel( viewMain ); + viewBase->addWidget( myCoordLabel ); +} + +HYDROGUI_ViewerDlg::~HYDROGUI_ViewerDlg() +{ + delete myViewManager; +} + +bool HYDROGUI_ViewerDlg::event( QEvent* e ) +{ + if ( e->type() == QEvent::Polish ) + addWidget( myCoordLabel->parentWidget(), 4 ); + + return HYDROGUI_InputPanel::event( e ); +} + +Handle(AIS_InteractiveContext) HYDROGUI_ViewerDlg::getAISContext() +{ + OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)myViewManager->getViewModel(); + return aViewer ? aViewer->getAISContext() : 0; +} + +OCCViewer_Viewer* HYDROGUI_ViewerDlg::viewer() const +{ + return ::qobject_cast( myViewManager->getViewModel() ); +} + +OCCViewer_ViewManager* HYDROGUI_ViewerDlg::viewManager() const +{ + return myViewManager; +} + +void HYDROGUI_ViewerDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent ) +{ + OCCViewer_ViewWindow* anOCCViewWindow = + dynamic_cast(theViewWindow); + if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) + { + gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() ); + + // 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 ) ); + } +} + +bool HYDROGUI_ViewerDlg::eventFilter( QObject* theObj, QEvent* theEvent ) +{ + if ( theObj->inherits( "OCCViewer_ViewPort" ) ) + { + if ( theEvent->type() == QEvent::Leave ) + myCoordLabel->clear(); + + return false; + } + + return HYDROGUI_InputPanel::eventFilter( theObj, theEvent ); +} diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.h b/src/HYDROGUI/HYDROGUI_ViewerDlg.h new file mode 100644 index 00000000..2b8b50be --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.h @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_VIEWERDLG_H +#define HYDROGUI_VIEWERDLG_H + +#include "HYDROGUI_InputPanel.h" + +#include + +class QLabel; +class SUIT_ViewWindow; +class OCCViewer_Viewer; +class OCCViewer_ViewManager; + +class HYDROGUI_ViewerDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ViewerDlg(); + + Handle(AIS_InteractiveContext) getAISContext(); + + void deleteSelected(); + bool deleteEnabled(); + + virtual bool event( QEvent* ); + +protected: + OCCViewer_Viewer* viewer() const; + OCCViewer_ViewManager* viewManager() const; + virtual bool eventFilter( QObject*, QEvent* ); + +protected slots: + void onMouseMove( SUIT_ViewWindow*, QMouseEvent* ); + +private: + OCCViewer_ViewManager* myViewManager; + QLabel* myCoordLabel; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index 0bcb0c31..9f5955f6 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -386,6 +386,11 @@ EDIT_SPLITTED_IMAGE_ICO icon_edit_splitted_image.png - + + + CREATE_RIVER_BOTTOM_ICO + icon_river_bottom_image.png + + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e74f56c4..ea7b2ede 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1342,6 +1342,19 @@ Would you like to remove all references from the image? STB_EDIT_LOCAL_CS Change local CS + + + MEN_CREATE_RIVER_BOTTOM + Find bottom + + + DSK_CREATE_RIVER_BOTTOM + Create river bottom polyline + + + STB_CREATE_RIVER_BOTTOM + Creates the river bottom polyline on selected river object + @@ -1483,6 +1496,14 @@ Would you like to remove all references from the image? Bathymetry + + + HYDROGUI_ViewerDlg + + UZ_COORDINATES_INFO + U: %1, Z: %2 + + HYDROGUI_ProfileDlg @@ -1498,10 +1519,6 @@ Would you like to remove all references from the image? PROFILE_NAME_TLT Name - - UZ_COORDINATES_INFO - U: %1, Z: %2 - U_TITLE U @@ -2229,4 +2246,20 @@ Polyline should consist from one not closed curve. + + HYDROGUI_RiverBottomDlg + + RIVER_OBJECT + River object + + + + + HYDROGUI_RiverBottomOp + + FIND_RIVER_BOTTOM + Find river bottom + + +