From e3efb17a18662632d07559bb84851970c5661a30 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 1 Nov 2017 17:57:24 +0300 Subject: [PATCH] refs #1330: individual shape and size for polylines --- src/HYDROGUI/CMakeLists.txt | 4 + src/HYDROGUI/HYDROGUI_Module.cxx | 6 +- src/HYDROGUI/HYDROGUI_Operations.cxx | 6 ++ src/HYDROGUI/HYDROGUI_Operations.h | 2 + src/HYDROGUI/HYDROGUI_PolylineStyleDlg.cxx | 68 +++++++++++++ src/HYDROGUI/HYDROGUI_PolylineStyleDlg.h | 44 +++++++++ src/HYDROGUI/HYDROGUI_PolylineStyleOp.cxx | 108 +++++++++++++++++++++ src/HYDROGUI/HYDROGUI_PolylineStyleOp.h | 42 ++++++++ src/HYDROGUI/HYDROGUI_Shape.cxx | 12 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 44 ++++++--- 10 files changed, 321 insertions(+), 15 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_PolylineStyleDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_PolylineStyleDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_PolylineStyleOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_PolylineStyleOp.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index cdf4d761..3d0a3607 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -147,6 +147,8 @@ set(PROJECT_HEADERS HYDROGUI_SetTransparencyOp.h HYDROGUI_TransparencyDlg.h HYDROGUI_Overview.h + HYDROGUI_PolylineStyleOp.h + HYDROGUI_PolylineStyleDlg.h ) QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -296,6 +298,8 @@ set(PROJECT_SOURCES HYDROGUI_SetTransparencyOp.cxx HYDROGUI_TransparencyDlg.cxx HYDROGUI_Overview.cxx + HYDROGUI_PolylineStyleOp.cxx + HYDROGUI_PolylineStyleDlg.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index d03db928..42473a59 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -741,9 +741,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addSeparator(); } - bool anIsPoly = anIsPolyline || anIsPolyline3D; - if (anIsPoly && !anIsLandCoverMap) + bool isPoly = anIsPolyline || anIsPolyline3D; + if (isPoly && !anIsLandCoverMap) theMenu->addAction( action( ExportToShapeFileID ) ); + if( isPoly ) + theMenu->addAction( action( PolylineStyleId ) ); // Add copy action QAction* aCopyAction = action( CopyId ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index b1c58801..e9cf6580 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -72,6 +72,7 @@ #include "HYDROGUI_ImportLandCoverMapOp.h" #include "HYDROGUI_BathymetrySelectionOp.h" #include "HYDROGUI_BathymetryOp.h" +#include "HYDROGUI_PolylineStyleOp.h" #include #include @@ -241,6 +242,8 @@ void HYDROGUI_Module::createActions() createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" ); createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" ); + + createAction( PolylineStyleId, "POLYLINE_STYLE" ); } void HYDROGUI_Module::createMenus() @@ -714,6 +717,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case LandCoverScalarMapModeOffId: anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId ); break; + case PolylineStyleId: + anOp = new HYDROGUI_PolylineStyleOp( aModule ); + break; } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index c558cfbd..a2a18fe6 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -143,6 +143,8 @@ enum OperationId BathymetryRescaleVisibleId, BathymetryRescaleUserId, BathymetryRescaleDefaultId, + + PolylineStyleId, }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.cxx new file mode 100644 index 00000000..092d7e36 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.cxx @@ -0,0 +1,68 @@ +// 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 "HYDROGUI_PolylineStyleDlg.h" +#include +#include +#include +#include +#include +#include + +HYDROGUI_PolylineStyleDlg::HYDROGUI_PolylineStyleDlg( HYDROGUI_Module* theModule ) + : HYDROGUI_InputPanel( theModule, tr( "POLYLINE_STYLE" ) ) +{ + QGroupBox* group = new QGroupBox( tr( "POLYLINE_STYLE" ), mainFrame() ); + + QGridLayout* lay = new QGridLayout( group ); + + myShape = new QComboBox( mainFrame() ); + myShape->addItem( "???" ); + myShape->addItem( tr( "No" ) ); + myShape->addItem( tr( "Triangle" ) ); + myShape->addItem( tr( "Cone" ) ); + + mySize = new QSpinBox( mainFrame() ); + mySize->setRange( -1, 50 ); + mySize->setSpecialValueText( " " ); + + lay->addWidget( new QLabel( tr( "PREF_POLYLINE_ARROW" ) ), 0, 0 ); + lay->addWidget( myShape, 0, 1 ); + lay->addWidget( new QLabel( tr( "PREF_POLYLINE_ARROW_SIZE" ) ), 1, 0 ); + lay->addWidget( mySize, 1, 1 ); + lay->setRowStretch( 2, 1 ); + + addWidget( group ); +} + +HYDROGUI_PolylineStyleDlg::~HYDROGUI_PolylineStyleDlg() +{ +} + +void HYDROGUI_PolylineStyleDlg::getStyle( int& theShape, int& theSize ) const +{ + theShape = myShape->currentIndex(); + theSize = mySize->value(); +} + +void HYDROGUI_PolylineStyleDlg::setStyle( int theShape, int theSize ) +{ + myShape->setCurrentIndex( theShape ); + mySize->setValue( theSize ); +} + diff --git a/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.h b/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.h new file mode 100644 index 00000000..e529a73b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PolylineStyleDlg.h @@ -0,0 +1,44 @@ +// 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 HYDROGUI_PolylineStyleDlg_H +#define HYDROGUI_PolylineStyleDlg_H + +#include "HYDROGUI_InputPanel.h" + +class QComboBox; +class QSpinBox; + +class HYDROGUI_PolylineStyleDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_PolylineStyleDlg( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_PolylineStyleDlg(); + + void getStyle( int&, int& ) const; + void setStyle( int, int ); + +private: + QComboBox* myShape; + QSpinBox* mySize; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineStyleOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineStyleOp.cxx new file mode 100644 index 00000000..b57733e6 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PolylineStyleOp.cxx @@ -0,0 +1,108 @@ +// 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 +#include +#include +#include + +HYDROGUI_PolylineStyleOp::HYDROGUI_PolylineStyleOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ +} + +HYDROGUI_PolylineStyleOp::~HYDROGUI_PolylineStyleOp() +{ +} + +HYDROGUI_InputPanel* HYDROGUI_PolylineStyleOp::createInputPanel() const +{ + return new HYDROGUI_PolylineStyleDlg( module() ); +} + +Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule ); + +QList getSelectedArrows( HYDROGUI_Module* theModule ) +{ + QList arrows; + Handle(AIS_InteractiveContext) ctx = getContext( theModule ); + + AIS_ListOfInteractive objs; + ctx->DisplayedObjects( objs ); + AIS_ListIteratorOfListOfInteractive it( objs ); + for( ; it.More(); it.Next() ) + { + Handle(HYDROGUI_Arrow) arrow = Handle(HYDROGUI_Arrow)::DownCast( it.Value() ); + Handle(AIS_InteractiveObject) obj = arrow; + if( !obj.IsNull() && ctx->IsSelected( obj ) ) + arrows.append( arrow ); + } + return arrows; +} + +void HYDROGUI_PolylineStyleOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + myArrows = getSelectedArrows( module() ); + + int aCommonType=-1, aCommonSize=-1; + bool isInit = false; + foreach( Handle(HYDROGUI_Arrow) arrow, myArrows ) + { + if( !isInit ) + { + aCommonType = arrow->GetType(); + aCommonSize = arrow->GetSize(); + } + else + { + if( aCommonType != -1 && aCommonType != arrow->GetType() ) + aCommonType = -1; + if( aCommonSize != -1 && aCommonSize != arrow->GetSize() ) + aCommonSize = -1; + } + + isInit = true; + } + + HYDROGUI_PolylineStyleDlg* dlg = dynamic_cast( inputPanel() ); + dlg->setStyle( aCommonType+1, aCommonSize ); +} + +bool HYDROGUI_PolylineStyleOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + Handle(AIS_InteractiveContext) ctx = getContext( module() ); + + int aType, aSize; + HYDROGUI_PolylineStyleDlg* dlg = dynamic_cast( inputPanel() ); + dlg->getStyle( aType, aSize ); + aType--; + + foreach( Handle(HYDROGUI_Arrow) arrow, myArrows ) + { + if( aType>=0 ) + arrow->SetType( (HYDROGUI_Arrow::Type)aType ); + if( aSize>=0 ) + arrow->SetSize( aSize ); + ctx->Redisplay( arrow, Standard_False ); + } + theUpdateFlags = UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + return true; +} diff --git a/src/HYDROGUI/HYDROGUI_PolylineStyleOp.h b/src/HYDROGUI/HYDROGUI_PolylineStyleOp.h new file mode 100644 index 00000000..d855c0e9 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_PolylineStyleOp.h @@ -0,0 +1,42 @@ +// 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 HYDROGUI_POLYLINE_STYLE_OP_H +#define HYDROGUI_POLYLINE_STYLE_OP_H + +#include +#include + +class HYDROGUI_PolylineStyleOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_PolylineStyleOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_PolylineStyleOp(); + +protected: + virtual void startOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const; + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ); + +private: + QList myArrows; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 964df94c..36df440a 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -509,7 +509,17 @@ QList HYDROGUI_Shape::createShape() const int aType = -1; int aSize = -1; - if( aResMgr ) + + if( myShapes.length()>1 ) + { + Handle(HYDROGUI_Arrow) arrow = Handle(HYDROGUI_Arrow)::DownCast( myShapes[1] ); + if( !arrow.IsNull() ) + { + aType = arrow->GetType(); + aSize = arrow->GetSize(); + } + } + if( aResMgr && ( aType<0 || aSize < 0 ) ) { aResMgr->value( "polyline", "arrow_type", aType ); aResMgr->value( "polyline", "arrow_size", aSize ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 64c41377..812f1192 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -995,6 +995,10 @@ Would you like to remove all references from the image? DSK_BATHYMETRY_RESCALE_DEFAULT Default rescale bathymetry + + DSK_POLYLINE_STYLE + Polyline style + DSK_IMPORT_IMAGE Import image @@ -1364,6 +1368,10 @@ Would you like to remove all references from the image? MEN_BATHYMETRY_RESCALE_DEFAULT Default rescale bathymetry + + MEN_POLYLINE_STYLE + Polyline style + MEN_IMPORT_IMAGE Import image @@ -1678,27 +1686,23 @@ Would you like to remove all references from the image? Selection on bathymetry - - STB_BATHYMETRY_RESCALE_SELECTION - + STB_BATHYMETRY_RESCALE_SELECTION Rescale bathymetry by selection - - STB_BATHYMETRY_RESCALE_VISIBLE - + STB_POLYLINE_STYLE + Change polyline style + + + STB_BATHYMETRY_RESCALE_VISIBLE Rescale bathymetry by visible range - - STB_BATHYMETRY_RESCALE_USER - + STB_BATHYMETRY_RESCALE_USER Custom rescale bathymetry - - STB_BATHYMETRY_RESCALE_DEFAULT - + STB_BATHYMETRY_RESCALE_DEFAULT Default rescale bathymetry @@ -3495,4 +3499,20 @@ Polyline should consist from one not closed curve. + + HYDROGUI_PolylineStyleDlg + + POLYLINE_STYLE + Polyline style + + + PREF_POLYLINE_ARROW + Polyline arrow + + + PREF_POLYLINE_ARROW_SIZE + Polyline arrow size + + + -- 2.39.2