#include(../../CMake/Common.cmake)
include(../../CMake/UseQT4EXT.cmake)
-
+
set(PROJECT_HEADERS
HYDROGUI.h
HYDROGUI_AbstractDisplayer.h
HYDROGUI_PolylineOp.h
HYDROGUI_ProfileDlg.h
HYDROGUI_ProfileOp.h
+ HYDROGUI_ProfileInterpolateDlg.h
+ HYDROGUI_ProfileInterpolateOp.h
HYDROGUI_Prs.h
HYDROGUI_PrsDriver.h
HYDROGUI_PrsImage.h
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})
HYDROGUI_PolylineOp.cxx
HYDROGUI_ProfileDlg.cxx
HYDROGUI_ProfileOp.cxx
+ HYDROGUI_ProfileInterpolateDlg.cxx
+ HYDROGUI_ProfileInterpolateOp.cxx
HYDROGUI_Prs.cxx
HYDROGUI_PrsDriver.cxx
HYDROGUI_PrsImage.cxx
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(
--- /dev/null
+// 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 <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <QLabel>
+#include <QLayout>
+#include <QComboBox>
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Document.h>
+
+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 ) );
+}
--- /dev/null
+// 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 <HYDROData_Entity.h>
+
+#include <QComboBox.h>
+
+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
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_ZLevelsOp.h"
#include "HYDROGUI_LocalCSOp.h"
+#include "HYDROGUI_RiverBottomOp.h"
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
createAction( ShowAllId, "SHOW_ALL" );
createAction( HideId, "HIDE" );
createAction( HideAllId, "HIDE_ALL" );
+
+ createAction( RiverBottom, "CREATE_RIVER_BOTTOM", "CREATE_RIVER_BOTTOM_ICO" );
}
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 );
case EditLocalCSId:
anOp = new HYDROGUI_LocalCSOp( aModule );
break;
+ case RiverBottom:
+ anOp = new HYDROGUI_RiverBottomOp( aModule );
+ break;
case ShowId:
case ShowOnlyId:
case ShowAllId:
SetZLevelId,
EditLocalCSId,
+ RiverBottom
};
#endif
#include <QMouseEvent>
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);
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<OCCViewer_ViewFrame*>( 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()
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);
theWidget->hide();
myAddElementBox->hide();
}
-
-void HYDROGUI_ProfileDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
-{
- OCCViewer_ViewWindow* anOCCViewWindow =
- dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
- if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) {
- gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint(
- theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() );
-
- // 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 );
-}
#ifndef HYDROGUI_PROFILEDLG_H
#define HYDROGUI_PROFILEDLG_H
-#include "HYDROGUI_InputPanel.h"
+#include "HYDROGUI_ViewerDlg.h"
#include <AIS_InteractiveContext.hxx>
class QLineEdit;
class QLabel;
-class HYDROGUI_ProfileDlg : public HYDROGUI_InputPanel
+class HYDROGUI_ProfileDlg : public HYDROGUI_ViewerDlg
{
Q_OBJECT
HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_ProfileDlg();
- Handle(AIS_InteractiveContext) getAISContext();
-
void setProfileName( const QString& theName );
QString getProfileName() const;
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
--- /dev/null
+// 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 <CurveCreator_Widget.h>
+#include <CurveCreator_ICurve.hxx>
+#include <CurveCreator_Utils.hxx>
+
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_Utilities.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewFrame.h>
+#include <LightApp_Application.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMouseEvent>
+
+HYDROGUI_ProfileInterpolateDlg::HYDROGUI_ProfileInterpolateDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL)
+{
+ QHBoxLayout* aNameLayout = new QHBoxLayout();
+ QLabel* aNameLabel = new QLabel(tr("PROFILE_NAME_TLT"), this);
+ aNameLayout->addWidget(aNameLabel);
+ myName = new QLineEdit(this);
+ aNameLayout->addWidget(myName);
+
+ addLayout(aNameLayout);
+
+ int anActionFlags =
+ CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode |
+ CurveCreator_Widget::DisableClosedSection;
+ QStringList aCoordTitles;
+ aCoordTitles << tr( "U_TITLE" ) << tr( "Z_TITLE" );
+ myEditorWidget = new CurveCreator_Widget( this, NULL, anActionFlags, aCoordTitles );
+ addWidget( myEditorWidget, 3 );
+
+ myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this );
+ addWidget( myAddElementBox, 2 );
+
+ QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
+ anAddElementLayout->setMargin( 0 );
+ anAddElementLayout->setSpacing( 5 );
+
+ myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 );
+ OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( false );
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ aViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
+ aResMgr->backgroundValue( "OCCViewer", "xz_background", aViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
+ aViewer->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
+ aResMgr->backgroundValue( "OCCViewer", "yz_background", aViewer->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
+ aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
+ aResMgr->backgroundValue( "OCCViewer", "xy_background", aViewer->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
+ aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
+ aResMgr->backgroundValue( "OCCViewer", "background", aViewer->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
+
+ aViewer->setTrihedronSize( aResMgr->doubleValue( "3DViewer", "trihedron_size", aViewer->trihedronSize() ),
+ aResMgr->booleanValue( "3DViewer", "relative_size", aViewer->trihedronRelative() ));
+ aViewer->setInteractionStyle( aResMgr->integerValue( "3DViewer", "navigation_mode", aViewer->interactionStyle() ) );
+ aViewer->setZoomingStyle( aResMgr->integerValue( "3DViewer", "zooming_mode", aViewer->zoomingStyle() ) );
+ aViewer->enablePreselection( aResMgr->booleanValue( "OCCViewer", "enable_preselection", aViewer->isPreselectionEnabled() ) );
+ aViewer->enableSelection( aResMgr->booleanValue( "OCCViewer", "enable_selection", aViewer->isSelectionEnabled() ) );
+
+ myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface
+ SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow();
+ aViewer->setStaticTrihedronDisplayed( false );
+ Handle(AIS_Trihedron) aTrihedron = HYDROGUI_AISTrihedron::createTrihedron(
+ aResMgr->doubleValue( "3DViewer", "trihedron_size",
+ aViewer->trihedronSize() ));
+ Handle(AIS_InteractiveContext) anAISContext = aViewer->getAISContext();
+ if ( !anAISContext.IsNull() ) {
+ anAISContext->Display( aTrihedron );
+ anAISContext->Deactivate( aTrihedron );
+ }
+
+ addWidget( aViewWin, 4 );
+ myEditorWidget->setOCCViewer( aViewer );
+
+ connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
+ connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*, bool) ), this, SLOT( processStartedSubOperation(QWidget*, bool) ) );
+ connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) );
+
+ myAddElementBox->hide();
+
+ // Coordinates
+ connect( myViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+ this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ if ( aViewWin ) {
+ OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWin );
+ if ( aViewFrame && aViewFrame->getViewPort() ) {
+ aViewFrame->getViewPort()->installEventFilter( this );
+ }
+ }
+
+ 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<int> aSections;
+ aSections << 0;
+ myEditorWidget->setSelectedSections( aSections );
+}
+
+QList<int> 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<QBoxLayout*>( myAddElementBox->layout() );
+ anAddElementLayout->addWidget( theWidget );
+
+ theWidget->show();
+ myAddElementBox->show();
+}
+
+void HYDROGUI_ProfileInterpolateDlg::processFinishedSubOperation( QWidget* theWidget )
+{
+ myEditorWidget->setEnabled( true );
+
+ QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
+ anAddElementLayout->removeWidget( theWidget );
+
+ theWidget->hide();
+ myAddElementBox->hide();
+}
+
+void HYDROGUI_ProfileInterpolateDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
+{
+ OCCViewer_ViewWindow* anOCCViewWindow =
+ dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
+ if ( anOCCViewWindow && anOCCViewWindow->getViewPort() ) {
+ gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint(
+ theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() );
+
+ // 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 );
+}
--- /dev/null
+// 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 <AIS_InteractiveContext.hxx>
+
+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<int> 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
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include <HYDROGUI_Module.h>
+#include <HYDROGUI_ProfileInterpolateOp.h>
+#include <HYDROGUI_ProfileDlg.h>
+#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_UpdateFlags.h>
+#include <HYDROGUI_DataObject.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_Profile.h>
+#include <HYDROGUI_CurveCreatorProfile.h>
+#include <CurveCreator_Displayer.hxx>
+
+#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+#include <OCCViewer_AISSelector.h>
+
+#include <Precision.hxx>
+
+//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<HYDROGUI_ProfileDlg*>( inputPanel() );
+ if ( !aPanel )
+ return false;
+
+ QString aProfileName = aPanel->getProfileName().simplified();
+ if ( aProfileName.isEmpty() )
+ {
+ theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+ return false;
+ }
+
+ if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aProfileName ) )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aProfileName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aProfileName );
+ return false;
+ }
+ }
+
+ Handle(HYDROData_Profile) aProfileObj;
+ if( myIsEdit ){
+ aProfileObj = myEditedObject;
+ }
+ else{
+ aProfileObj = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+ }
+
+ if( aProfileObj.IsNull() )
+ return false;
+
+ Handle(HYDROData_ProfileUZ) aProfileUZ = aProfileObj->GetProfileUZ();
+ if ( aProfileUZ.IsNull() )
+ return false;
+
+ aProfileObj->SetName(aProfileName);
+
+ HYDROData_ProfileUZ::PointsList aProfileParamPoints;
+
+ CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 );
+ if ( aCurveCoords.size() <= 2 )
+ {
+ theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" );
+ return false;
+ }
+
+ for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ )
+ {
+ HYDROData_ProfileUZ::Point aProfileParamPoint;
+
+ aProfileParamPoint.SetX( aCurveCoords.at( k ) );
+ k++;
+ aProfileParamPoint.SetY( aCurveCoords.at( k ) );
+
+ aProfileParamPoints.Append( aProfileParamPoint );
+ }
+ aProfileObj->SetParametricPoints( aProfileParamPoints );
+
+ HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
+ if ( myProfile->getSectionType( 0 ) == CurveCreator::Spline )
+ aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
+
+ aProfileUZ->SetSectionType( 0, aSectType );
+
+ if ( !myIsEdit )
+ {
+ aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
+ }
+
+ // At first we update the child u,z profile object
+ aProfileUZ->SetToUpdate( true );
+ aProfileUZ->Update();
+
+ // And now we update our edited object
+ aProfileObj->Update();
+ module()->setIsToUpdate( aProfileObj );
+
+ theUpdateFlags = UF_Model;
+ if ( myIsEdit )
+ theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+ else
+ {
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aProfileObj );
+ theBrowseObjectsEntries.append( anEntry );
+ }
+
+ return true;
+}
+
+void HYDROGUI_ProfileInterpolateOp::displayPreview()
+{
+ HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
+ if( aPanel )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
+ if( !aCtx.IsNull() )
+ {
+ CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
+ myProfile->setDisplayer( aDisplayer );
+ aDisplayer->display( myProfile->getAISObject( true ), true );
+ }
+ }
+}
+
+void HYDROGUI_ProfileInterpolateOp::erasePreview()
+{
+ HYDROGUI_ProfileDlg* aPanel = dynamic_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
+ CurveCreator_Displayer* aDisplayer = myProfile ? myProfile->getDisplayer() : 0;
+ if( aPanel && aDisplayer )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
+ if( !aCtx.IsNull() )
+ {
+ aDisplayer->eraseAll( true );
+ }
+ }
+}
--- /dev/null
+// 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 <HYDROData_Profile.h>
+
+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
--- /dev/null
+// 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 <QLabel>
+#include <QLayout>
+#include <QComboBox>
+#include <QGroupBox>
+
+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 );
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 <HYDROData_River.h>
+#include <HYDROData_Iterator.h>
+
+/*
+#include <HYDROData_Profile.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <TopoDS.hxx>
+*/
+
+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<HYDROGUI_RiverBottomDlg*>( 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<HYDROGUI_RiverBottomDlg*>( 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;
+}
--- /dev/null
+// 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 <HYDROData_River.h>
+
+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
--- /dev/null
+// 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 <CurveCreator_Widget.h>
+#include <CurveCreator_ICurve.hxx>
+#include <CurveCreator_Utils.hxx>
+
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_Utilities.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewFrame.h>
+#include <LightApp_Application.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMouseEvent>
+
+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<OCCViewer_ViewFrame*>( 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<OCCViewer_Viewer*>( myViewManager->getViewModel() );
+}
+
+OCCViewer_ViewManager* HYDROGUI_ViewerDlg::viewManager() const
+{
+ return myViewManager;
+}
+
+void HYDROGUI_ViewerDlg::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
+{
+ OCCViewer_ViewWindow* anOCCViewWindow =
+ dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
+ if ( anOCCViewWindow && anOCCViewWindow->getViewPort() )
+ {
+ gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(), anOCCViewWindow->getViewPort()->getView() );
+
+ // 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 );
+}
--- /dev/null
+// 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 <AIS_InteractiveContext.hxx>
+
+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
<source>EDIT_SPLITTED_IMAGE_ICO</source>
<translation>icon_edit_splitted_image.png</translation>
</message>
-
+
+ <message>
+ <source>CREATE_RIVER_BOTTOM_ICO</source>
+ <translation>icon_river_bottom_image.png</translation>
+ </message>
+
</context>
</TS>
<source>STB_EDIT_LOCAL_CS</source>
<translation>Change local CS</translation>
</message>
+
+ <message>
+ <source>MEN_CREATE_RIVER_BOTTOM</source>
+ <translation>Find bottom</translation>
+ </message>
+ <message>
+ <source>DSK_CREATE_RIVER_BOTTOM</source>
+ <translation>Create river bottom polyline</translation>
+ </message>
+ <message>
+ <source>STB_CREATE_RIVER_BOTTOM</source>
+ <translation>Creates the river bottom polyline on selected river object</translation>
+ </message>
</context>
<context>
<translation>Bathymetry</translation>
</message>
</context>
+
+ <context>
+ <name>HYDROGUI_ViewerDlg</name>
+ <message>
+ <source>UZ_COORDINATES_INFO</source>
+ <translation>U: %1, Z: %2</translation>
+ </message>
+ </context>
<context>
<name>HYDROGUI_ProfileDlg</name>
<source>PROFILE_NAME_TLT</source>
<translation>Name</translation>
</message>
- <message>
- <source>UZ_COORDINATES_INFO</source>
- <translation>U: %1, Z: %2</translation>
- </message>
<message>
<source>U_TITLE</source>
<translation>U</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_RiverBottomDlg</name>
+ <message>
+ <source>RIVER_OBJECT</source>
+ <translation>River object</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>HYDROGUI_RiverBottomOp</name>
+ <message>
+ <source>FIND_RIVER_BOTTOM</source>
+ <translation>Find river bottom</translation>
+ </message>
+ </context>
+
</TS>