From 9d74e559cfe55dea14f7bfdb6957c61829e98cf3 Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 8 Nov 2017 19:46:24 +0300 Subject: [PATCH] refs #1340 part.2 --- src/HYDROGUI/CMakeLists.txt | 6 ++- src/HYDROGUI/HYDROGUI_Module.cxx | 2 + src/HYDROGUI/HYDROGUI_Operations.cxx | 7 ++- src/HYDROGUI/HYDROGUI_Operations.h | 1 + src/HYDROGUI/HYDROGUI_ZoneSetColorOp.cxx | 66 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ZoneSetColorOp.h | 43 +++++++++++++++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 5 +- 7 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_ZoneSetColorOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ZoneSetColorOp.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 7a575a8f..a9605ebd 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -150,7 +150,8 @@ set(PROJECT_HEADERS HYDROGUI_PolylineStyleOp.h HYDROGUI_PolylineStyleDlg.h HYDROGUI_ZoneTool.h - HYDROGUI_RegenerateRegionColorsOp.h + HYDROGUI_RegenerateRegionColorsOp.h + HYDROGUI_ZoneSetColorOp.h ) QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -303,7 +304,8 @@ set(PROJECT_SOURCES HYDROGUI_PolylineStyleOp.cxx HYDROGUI_PolylineStyleDlg.cxx HYDROGUI_ZoneTool.cxx - HYDROGUI_RegenerateRegionColorsOp.cxx + HYDROGUI_RegenerateRegionColorsOp.cxx + HYDROGUI_ZoneSetColorOp.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 046a19a2..b8e744ad 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -726,6 +726,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( LoadVisualStateId ) ); theMenu->addSeparator(); } + else if (anIsZone) + theMenu->addAction( action( ZoneSetColorId ) ); if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle ) { diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index c14e7172..91d3dc86 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -74,7 +74,7 @@ #include "HYDROGUI_BathymetryOp.h" #include "HYDROGUI_RegenerateRegionColorsOp.h" #include "HYDROGUI_PolylineStyleOp.h" - +#include "HYDROGUI_ZoneSetColorOp.h" #include #include #include @@ -246,6 +246,7 @@ void HYDROGUI_Module::createActions() createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" ); createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" ); + createAction( ZoneSetColorId, "ZONE_SET_COLOR" ); createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" ); } @@ -768,7 +769,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId ); break; case RegenerateRegionColorsId: - anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule ); + anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule ); + case ZoneSetColorId: + anOp = new HYDROGUI_ZoneSetColorOp( aModule ); } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index f0ce5bea..519c68a7 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -146,6 +146,7 @@ enum OperationId BathymetryRescaleDefaultId, RegenerateRegionColorsId, ShowHideArrows, + ZoneSetColorId }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.cxx b/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.cxx new file mode 100644 index 00000000..a669fa49 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.cxx @@ -0,0 +1,66 @@ +// 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_ZoneSetColorOp.h" + +#include "HYDROGUI_Module.h" +#include +#include +#include +#include +#include +#include +#include + +HYDROGUI_ZoneSetColorOp::HYDROGUI_ZoneSetColorOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ + setName( tr( "ZONE_SET_COLOR" ) ); +} + +HYDROGUI_ZoneSetColorOp::~HYDROGUI_ZoneSetColorOp() +{ +} + +void HYDROGUI_ZoneSetColorOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + myZone = Handle(HYDROData_Zone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( !myZone.IsNull() ) + onApply(); + else + onCancel(); +} + +bool HYDROGUI_ZoneSetColorOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + theUpdateFlags = 0; + if(myZone) + { + QColor aZoneColor = myZone->GetColor(QColor(1,1,1)); + QApplication::restoreOverrideCursor(); + QColor aNewColor = QColorDialog::getColor( aZoneColor ); + myZone->SetColor(aNewColor); + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + return true; + } + return false; +} + + diff --git a/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.h b/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.h new file mode 100644 index 00000000..5b116fe1 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZoneSetColorOp.h @@ -0,0 +1,43 @@ +// 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_ZONESETCOLOROP_H +#define HYDROGUI_ZONESETCOLOROP_H + +#include "HYDROGUI_Operation.h" +#include ; + +class HYDROGUI_ZoneSetColorOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ZoneSetColorOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_ZoneSetColorOp(); + +protected: + virtual void startOperation(); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + + +private: + Handle(HYDROData_Zone) myZone; +}; + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index f5b1e222..a6b85eb2 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1536,7 +1536,10 @@ Would you like to remove all references from the image? MEN_REGENERATE_REGION_COLORS Regenerate region colors - + + MEN_ZONE_SET_COLOR + Set color + STB_CREATE_CALCULATION Create calculation case -- 2.39.2