From: asl Date: Thu, 18 Jun 2015 10:45:33 +0000 (+0300) Subject: #refs 585: polylines operations GUI X-Git-Tag: v1.4.2~59 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=deff0cc196a4223cf478e3098468821d0f173641;p=modules%2Fhydro.git #refs 585: polylines operations GUI --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 2476f552..a54633a6 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -27,6 +27,7 @@ set(PROJECT_HEADERS HYDROData_ObstacleAltitude.h HYDROData_OperationsFactory.h HYDROData_Pipes.h + HYDROData_PolylineOperator.h HYDROData_PolylineXY.h HYDROData_Polyline3D.h HYDROData_PriorityQueue.h @@ -81,6 +82,7 @@ set(PROJECT_SOURCES HYDROData_ObstacleAltitude.cxx HYDROData_OperationsFactory.cxx HYDROData_Pipes.cxx + HYDROData_PolylineOperator.cxx HYDROData_PolylineXY.cxx HYDROData_Polyline3D.cxx HYDROData_PriorityQueue.cxx diff --git a/src/HYDROData/HYDROData_IPolyline.h b/src/HYDROData/HYDROData_IPolyline.h index 08cc1e66..1c472899 100644 --- a/src/HYDROData/HYDROData_IPolyline.h +++ b/src/HYDROData/HYDROData_IPolyline.h @@ -120,7 +120,7 @@ public: */ HYDRODATA_EXPORT virtual SectionType GetSectionType( const int theSectionIndex ) const = 0; - /** + /** * Set type for section with given index. * \param theSectionIndex index of section * \param theSectionType new section type diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx new file mode 100644 index 00000000..2256a906 --- /dev/null +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -0,0 +1,45 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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, or (at your option) any later version. +// +// 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 + +bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline, + const gp_Pnt2d& thePoint ) const +{ + //TODO + return true; +} + +bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline, + const Handle( HYDROData_PolylineXY )& theTool ) const +{ + //TODO + return true; +} + +bool HYDROData_PolylineOperator::Split( const HYDROData_SequenceOfObjects& thePolylines ) +{ + //TODO + return true; +} + +bool HYDROData_PolylineOperator::Merge( const HYDROData_SequenceOfObjects& thePolylines ) +{ + //TODO + return true; +} diff --git a/src/HYDROData/HYDROData_PolylineOperator.h b/src/HYDROData/HYDROData_PolylineOperator.h new file mode 100644 index 00000000..5157be0a --- /dev/null +++ b/src/HYDROData/HYDROData_PolylineOperator.h @@ -0,0 +1,37 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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, or (at your option) any later version. +// +// 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 HYDROData_PolylineOperator_HeaderFile +#define HYDROData_PolylineOperator_HeaderFile + +#include + +class gp_Pnt2d; + +class HYDROData_PolylineOperator +{ +public: + HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline, + const gp_Pnt2d& thePoint ) const; + HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline, + const Handle( HYDROData_PolylineXY )& theTool ) const; + HYDRODATA_EXPORT bool Split( const HYDROData_SequenceOfObjects& thePolylines ); + HYDRODATA_EXPORT bool Merge( const HYDROData_SequenceOfObjects& thePolylines ); +}; + +#endif diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index ef710104..a0172fd7 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -27,6 +27,7 @@ class QPainterPath; class QTransform; class TopoDS_Wire; class gp_XYZ; +class gp_Pnt; /**\class HYDROData_PolylineXY * \brief Class that stores/retreives information about the diff --git a/src/HYDROGUI/HYDROGUI_MergePolylinesOp.cxx b/src/HYDROGUI/HYDROGUI_MergePolylinesOp.cxx index dd1c271f..8c6f21be 100644 --- a/src/HYDROGUI/HYDROGUI_MergePolylinesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_MergePolylinesOp.cxx @@ -18,6 +18,8 @@ #include #include +#include +#include HYDROGUI_MergePolylinesOp::HYDROGUI_MergePolylinesOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) @@ -33,7 +35,12 @@ void HYDROGUI_MergePolylinesOp::startOperation() { HYDROGUI_Operation::startOperation(); - //TODO + HYDROGUI_MergePolylinesDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + aPanel->setPolylinesFromSelection(); } HYDROGUI_InputPanel* HYDROGUI_MergePolylinesOp::createInputPanel() const @@ -45,16 +52,14 @@ bool HYDROGUI_MergePolylinesOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) { - /* TODO: - HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + HYDROGUI_MergePolylinesDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return false; - double aLX = aPanel->GetLocalX(); - double aLY = aPanel->GetLocalY(); - doc()->SetLocalCS( aLX, aLY ); + HYDROData_SequenceOfObjects aPolylinesList = aPanel->selectedPolylines(); + HYDROData_PolylineOperator anOp; + anOp.Merge( aPolylinesList ); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; - */ return true; } diff --git a/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx index 6ead5e40..18639114 100644 --- a/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjComboBox.cxx @@ -82,7 +82,8 @@ void HYDROGUI_ObjComboBox::reset() myObject->blockSignals( true ); myObject->clear(); - myObject->addItems( objectNames() ); + myObjects.Clear(); + myObject->addItems( objectNames( myObjects ) ); myObject->setCurrentIndex( -1 ); myObject->blockSignals( block ); @@ -91,7 +92,7 @@ void HYDROGUI_ObjComboBox::reset() updateSelection(); } -void HYDROGUI_ObjComboBox::setSectedObject( const QString& theName ) +void HYDROGUI_ObjComboBox::setSelectedObject( const QString& theName ) { int aNewIdx = myObject->findText( theName ); if ( aNewIdx != myObject->currentIndex() ) @@ -115,7 +116,7 @@ SUIT_SelectionMgr* HYDROGUI_ObjComboBox::selectionMgr() const return aSelMgr; } -QStringList HYDROGUI_ObjComboBox::objectNames() const +QStringList HYDROGUI_ObjComboBox::objectNames( HYDROData_SequenceOfObjects& theObjects ) const { QStringList aNames; for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), objectType() ); it.More(); it.Next() ) @@ -153,3 +154,13 @@ void HYDROGUI_ObjComboBox::updateSelection() emit objectSelected( myObject->itemText( idx ) ); } } + +Handle( HYDROData_Entity ) HYDROGUI_ObjComboBox::GetObject() const +{ + int anIndex = myObject->currentIndex(); + if( anIndex>=0 && anIndexsetSectedObject( theName ); + myRiver->setSelectedObject( theName ); } QString HYDROGUI_ProfileInterpolateDlg::profileStart() const @@ -153,7 +153,7 @@ QString HYDROGUI_ProfileInterpolateDlg::profileStart() const void HYDROGUI_ProfileInterpolateDlg::setProfileStart( const QString& theName ) { - myProfileStart->setSectedObject( theName ); + myProfileStart->setSelectedObject( theName ); } QString HYDROGUI_ProfileInterpolateDlg::profileFinish() const @@ -163,7 +163,7 @@ QString HYDROGUI_ProfileInterpolateDlg::profileFinish() const void HYDROGUI_ProfileInterpolateDlg::setProfileFinish( const QString& theName ) { - myProfileFinish->setSectedObject( theName ); + myProfileFinish->setSelectedObject( theName ); } int HYDROGUI_ProfileInterpolateDlg::profileNumber() const diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx index 2ca6d905..55418b2b 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx @@ -71,7 +71,7 @@ QString HYDROGUI_RiverBottomDlg::getRiverName() const void HYDROGUI_RiverBottomDlg::setRiverName( const QString& theName ) { - myRivers->setSectedObject( theName ); + myRivers->setSelectedObject( theName ); } bool HYDROGUI_RiverBottomDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const diff --git a/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx b/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx index 47b52138..5a702d16 100644 --- a/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx @@ -17,8 +17,14 @@ // #include +#include +#include +#include +#include #include #include +#include +#include HYDROGUI_SplitPolylinesDlg::HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) @@ -29,9 +35,73 @@ HYDROGUI_SplitPolylinesDlg::HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModu QGridLayout* aLayout = new QGridLayout( aFrame ); aLayout->setMargin( 5 ); aLayout->setSpacing( 5 ); + + myTab = new QTabWidget( aFrame ); + aLayout->addWidget( myTab, 0, 0 ); + + QFrame* aPointPage = new QFrame(); + QGridLayout* aPointPageLayout = new QGridLayout( aPointPage ); + + myTab->addTab( aPointPage, tr( "BY_POINT" ) ); + + QFrame* aToolPage = new QFrame(); + myTab->addTab( aToolPage, tr( "BY_TOOL" ) ); + + QFrame* aSplitPage = new QFrame(); + myTab->addTab( aSplitPage, tr( "COMPLETE_SPLIT" ) ); } HYDROGUI_SplitPolylinesDlg::~HYDROGUI_SplitPolylinesDlg() { } +HYDROGUI_SplitPolylinesDlg::Mode HYDROGUI_SplitPolylinesDlg::GetMode() const +{ + return ( Mode )myTab->currentIndex(); +} + +Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetMainPolyline() const +{ + switch( GetMode() ) + { + case ByPoint: + return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline1->GetObject() ); + case ByTool: + return Handle( HYDROData_PolylineXY )::DownCast( myMainPolyline2->GetObject() ); + default: + return Handle( HYDROData_PolylineXY )(); + } +} + +Handle( HYDROData_PolylineXY ) HYDROGUI_SplitPolylinesDlg::GetToolPolyline() const +{ + if( GetMode()==ByTool ) + return Handle( HYDROData_PolylineXY )::DownCast( myToolPolyline->GetObject() ); + else + return Handle( HYDROData_PolylineXY )(); +} + +gp_Pnt2d HYDROGUI_SplitPolylinesDlg::GetPoint() const +{ + return gp_Pnt2d( myX->value(), myY->value() ); +} + +HYDROData_SequenceOfObjects HYDROGUI_SplitPolylinesDlg::GetPolylines() const +{ + if( GetMode()==Split ) + return myPolylines->selectedObjects(); + else + return HYDROData_SequenceOfObjects(); +} + +void HYDROGUI_SplitPolylinesDlg::setPolylinesFromSelection() +{ + Handle( HYDROData_Entity ) anObject = HYDROGUI_Tool::GetSelectedObject( module() ); + if( anObject.IsNull() || anObject->GetKind() != KIND_POLYLINEXY ) + return; + + QString aName = anObject->GetName(); + myMainPolyline1->setObjectName( aName ); + myMainPolyline2->setObjectName( aName ); + myPolylines->setObjectsFromSelection(); +} diff --git a/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.h b/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.h index 3dca4fba..0d09934e 100644 --- a/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.h +++ b/src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.h @@ -20,14 +20,41 @@ #define HYDROGUI_SplitPolylinesDlg_H #include "HYDROGUI_InputPanel.h" +#include + +class QTabWidget; +class QtxDoubleSpinBox; +class HYDROGUI_ObjComboBox; +class HYDROGUI_ObjListBox; +class gp_Pnt2d; class HYDROGUI_SplitPolylinesDlg : public HYDROGUI_InputPanel { Q_OBJECT +public: + enum Mode { ByPoint, ByTool, Split }; + public: HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_SplitPolylinesDlg(); + + Mode GetMode() const; + Handle( HYDROData_PolylineXY ) GetMainPolyline() const; + Handle( HYDROData_PolylineXY ) GetToolPolyline() const; + gp_Pnt2d GetPoint() const; + HYDROData_SequenceOfObjects GetPolylines() const; + + void setPolylinesFromSelection(); + +private: + QTabWidget* myTab; + QtxDoubleSpinBox* myX; + QtxDoubleSpinBox* myY; + HYDROGUI_ObjComboBox* myMainPolyline1; + HYDROGUI_ObjComboBox* myMainPolyline2; + HYDROGUI_ObjComboBox* myToolPolyline; + HYDROGUI_ObjListBox* myPolylines; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx index 233e79a3..07a49d3b 100644 --- a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx @@ -18,6 +18,9 @@ #include #include +#include +#include +#include HYDROGUI_SplitPolylinesOp::HYDROGUI_SplitPolylinesOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) @@ -33,7 +36,13 @@ void HYDROGUI_SplitPolylinesOp::startOperation() { HYDROGUI_Operation::startOperation(); - //TODO + HYDROGUI_SplitPolylinesDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + aPanel->setPolylinesFromSelection(); + } HYDROGUI_InputPanel* HYDROGUI_SplitPolylinesOp::createInputPanel() const @@ -45,16 +54,29 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) { - /*TODO: - HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + HYDROGUI_SplitPolylinesDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return false; - double aLX = aPanel->GetLocalX(); - double aLY = aPanel->GetLocalY(); - doc()->SetLocalCS( aLX, aLY ); + Handle( HYDROData_PolylineXY ) aMainPolyline = aPanel->GetMainPolyline(); + Handle( HYDROData_PolylineXY ) aToolPolyline = aPanel->GetToolPolyline(); + HYDROData_SequenceOfObjects aPolylinesList = aPanel->GetPolylines(); + gp_Pnt2d aPoint = aPanel->GetPoint(); + HYDROData_PolylineOperator anOp; + switch( aPanel->GetMode() ) + { + case HYDROGUI_SplitPolylinesDlg::ByPoint: + anOp.Split( aMainPolyline, aPoint ); + break; + case HYDROGUI_SplitPolylinesDlg::ByTool: + anOp.Split( aMainPolyline, aToolPolyline ); + break; + case HYDROGUI_SplitPolylinesDlg::Split: + anOp.Split( aPolylinesList ); + break; + } + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; - */ return true; } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index a33c7cf9..88c56649 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -946,6 +946,14 @@ Would you like to remove all references from the image? DSK_SPLIT_IMAGE Split image + + DSK_SPLIT_POLYLINES + Split polylines + + + DSK_MERGE_POLYLINES + Merge polylines + DSK_UNDO Undo @@ -1238,6 +1246,14 @@ Would you like to remove all references from the image? MEN_SPLIT_IMAGE Split image + + MEN_SPLIT_POLYLINES + Split polylines + + + MEN_MERGE_POLYLINES + Merge polylines + MEN_UNDO Undo @@ -1499,6 +1515,14 @@ Would you like to remove all references from the image? STB_SPLIT_IMAGE Split image + + STB_SPLIT_POLYLINES + Split polylines + + + STB_MERGE_POLYLINES + Merge polylines + STB_UNDO Undo @@ -2754,4 +2778,20 @@ Polyline should consist from one not closed curve. + + HYDROGUI_SplitPolylinesDlg + + POLYLINES + Polylines + + + INCLUDE + Include + + + EXCLUDE + Exclude + + +