From 8561f3707c2f377fe503e28cd0fbc04d0eb428af Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 8 Nov 2017 18:36:54 +0300 Subject: [PATCH] refs #1340 --- .../HYDROGUI_RegenerateRegionColorsOp.cxx | 61 +++++++++++++++++++ .../HYDROGUI_RegenerateRegionColorsOp.h | 43 +++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.h diff --git a/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.cxx b/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.cxx new file mode 100644 index 00000000..752cde64 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.cxx @@ -0,0 +1,61 @@ +// 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 +#include +#include +#include +#include + +HYDROGUI_RegenerateRegionColorsOp::HYDROGUI_RegenerateRegionColorsOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ +} + +HYDROGUI_RegenerateRegionColorsOp::~HYDROGUI_RegenerateRegionColorsOp() +{ +} + +void HYDROGUI_RegenerateRegionColorsOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + QString outStr; + if (HYDROGUI_Tool::IsSelectedPartOfCalcCase(module(), myCalcCase, outStr) && + outStr == HYDROGUI_DataModel::partitionName( KIND_REGION )) + onApply(); + else + onCancel(); +} + +bool HYDROGUI_RegenerateRegionColorsOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + theUpdateFlags = 0; + if( myCalcCase ) + { + const HYDROData_SequenceOfObjects& aRegions = myCalcCase->GetRegions(); + HYDROGUI_ZoneTool::AssignDefaultColors(aRegions, 100, 100); + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + return true; + } + return false; +} + diff --git a/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.h b/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.h new file mode 100644 index 00000000..b9881cd8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_RegenerateRegionColorsOp.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_REGENERATEREGIONCOLORSOP_H +#define HYDROGUI_REGENERATEREGIONCOLORSOP_H + +#include +#include +#include + +class HYDROGUI_RegenerateRegionColorsOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_RegenerateRegionColorsOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_RegenerateRegionColorsOp(); + +protected: + virtual void startOperation(); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + +private: + Handle(HYDROData_CalculationCase) myCalcCase; +}; + +#endif -- 2.39.2