From: asl Date: Tue, 7 Nov 2017 12:29:06 +0000 (+0300) Subject: Merge remote-tracking branch 'origin/BR_1323_0' into BR_2017 X-Git-Tag: v2.1~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=07c29bb9bda552734178a94c59e6c3cd6881b754;hp=77396ccfa6d8d3666005deafec6c55b929d59281;p=modules%2Fhydro.git Merge remote-tracking branch 'origin/BR_1323_0' into BR_2017 # Conflicts: # src/HYDROGUI/CMakeLists.txt # src/HYDROGUI/HYDROGUI_Operations.cxx # src/HYDROGUI/HYDROGUI_Operations.h --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 3d0a3607..e0909451 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -96,6 +96,7 @@ set(PROJECT_HEADERS HYDROGUI_StricklerTableOp.h HYDROGUI_StricklerTypeComboBox.h HYDROGUI_SubmersibleOp.h + HYDROGUI_UnSubmersibleOp.h HYDROGUI_Tool.h HYDROGUI_Tool2.h HYDROGUI_TwoImagesDlg.h @@ -149,6 +150,8 @@ set(PROJECT_HEADERS HYDROGUI_Overview.h HYDROGUI_PolylineStyleOp.h HYDROGUI_PolylineStyleDlg.h + HYDROGUI_ZoneTool.h + HYDROGUI_RegenerateRegionColorsOp.h ) QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -246,6 +249,7 @@ set(PROJECT_SOURCES HYDROGUI_SplitPolylinesDlg.cxx HYDROGUI_SplitPolylinesOp.cxx HYDROGUI_SubmersibleOp.cxx + HYDROGUI_UnSubmersibleOp.cxx HYDROGUI_Tool.cxx HYDROGUI_Tool2.cxx HYDROGUI_TwoImagesDlg.cxx @@ -300,6 +304,8 @@ set(PROJECT_SOURCES HYDROGUI_Overview.cxx HYDROGUI_PolylineStyleOp.cxx HYDROGUI_PolylineStyleDlg.cxx + HYDROGUI_ZoneTool.cxx + HYDROGUI_RegenerateRegionColorsOp.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 63249c73..95862a4d 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -713,6 +713,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS"; case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES"; case KIND_LAND_COVER_MAP: return "LAND_COVER_MAPS"; + case KIND_REGION: return "REGIONS"; default: break; } return QString(); diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index ffaefe83..116afcc2 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -19,7 +19,10 @@ #include "HYDROGUI_DataObject.h" #include +#include #include +#include +#include #include @@ -32,6 +35,7 @@ #include #include +#include HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, Handle(HYDROData_Entity) theData, @@ -144,6 +148,15 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const { QString anIcon; Handle(HYDROData_Entity) aDataObject = modelObject(); + Handle(HYDROData_Object) anObject; + Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aDataObject); + Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aDataObject); + + if (!anAObject.IsNull()) + anObject = anAObject; + if (!aNObject.IsNull()) + anObject = aNObject; + if( aDataObject.IsNull() ) { anIcon = QObject::tr( "HYDRO_TYPE0_ICO" ); // KIND_UNKNOWN @@ -153,6 +166,7 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const QString aNeedUpdate( aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ? "M_" : "" ); int anObjectKind = (int)aDataObject->GetKind(); + bool IsUnsImmZone = false; if ( anObjectKind == KIND_DUMMY_3D ) { Handle(HYDROData_DummyObject3D) anObject3D = @@ -162,8 +176,29 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const if ( !aFatherObj.IsNull() ) anObjectKind = aFatherObj->GetKind(); } - - anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); + else if ( !anObject.IsNull() ) + { + bool IsSubm = anObject->IsSubmersible(); + QString anIcon1 = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); + QString anIcon2; + if (IsSubm) + anIcon2 = QObject::tr( QString("HYDRO_SUBMERSIBLE16_ICO").toLatin1()); + else + anIcon2 = QObject::tr( QString("HYDRO_UNSUBMERSIBLE16_ICO").toLatin1()); + + QPixmap qpm1 = aResMgr->loadPixmap( "HYDRO", anIcon1 ); + QPixmap qpm2 = aResMgr->loadPixmap( "HYDRO", anIcon2 ); + QPixmap qpmD(32,16); + qpmD.fill(QColor(0,0,0)); + QPainter painter; + painter.begin(&qpmD); + painter.drawPixmap(0, 0, qpm1); + painter.drawPixmap(16, 0, qpm2); + painter.end(); + return qpmD; + } + else + anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); } return aResMgr->loadPixmap( "HYDRO", anIcon ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 3a3d2b64..c21abdfc 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include @@ -568,6 +570,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } theMenu->addSeparator(); } + else + { + Handle(HYDROData_CalculationCase) aCalcCase; + QString outStr; + HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr); + if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION )) + theMenu->addAction( action( RegenerateRegionColorsId ) ); + } } if( anIsSelectedDataObjects ) @@ -810,13 +820,32 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, { if( aSeq.Size() > 0 ) { - Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() ); + Handle( HYDROData_Entity ) aFirstEnt = aSeq.First(); + Handle(HYDROData_Object) anObject; + Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt); + Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt); + + if (!anAObject.IsNull()) + anObject = anAObject; + if (!aNObject.IsNull()) + anObject = aNObject; + if( !anObject.IsNull() ) { theMenu->addSeparator(); - theMenu->addAction( action( SubmersibleId ) ); - action( SubmersibleId )->setCheckable( true ); - action( SubmersibleId )->setChecked( anObject->IsSubmersible() ); + bool IsSubmersible = anObject->IsSubmersible(); + if (!IsSubmersible) + { + theMenu->addAction( action( SubmersibleId ) ); + action( SubmersibleId )->setCheckable(true); + action( SubmersibleId )->setChecked(true); + } + else + { + theMenu->addAction( action( UnSubmersibleId ) ); + action( UnSubmersibleId )->setCheckable(true); + action( UnSubmersibleId )->setChecked(true); + } } } } diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 8909b875..259ac301 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -60,6 +60,7 @@ #include "HYDROGUI_ProfileInterpolateOp.h" #include "HYDROGUI_RecognizeContoursOp.h" #include "HYDROGUI_SubmersibleOp.h" +#include "HYDROGUI_UnSubmersibleOp.h" #include "HYDROGUI_StricklerTableOp.h" #include "HYDROGUI_DuplicateOp.h" #include "HYDROGUI_LandCoverMapOp.h" @@ -73,6 +74,7 @@ #include "HYDROGUI_BathymetrySelectionOp.h" #include "HYDROGUI_BathymetryOp.h" #include "HYDROGUI_PolylineStyleOp.h" +#include "HYDROGUI_RegenerateRegionColorsOp.h" #include #include @@ -234,6 +236,7 @@ void HYDROGUI_Module::createActions() createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" ); createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" ); + createAction( UnSubmersibleId, "UNSUBMERSIBLE", "HYDRO_UNSUBMERSIBLE16_ICO" ); createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" ); createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" ); @@ -244,6 +247,8 @@ void HYDROGUI_Module::createActions() createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" ); createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" ); + createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" ); + } void HYDROGUI_Module::createMenus() @@ -748,6 +753,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case SubmersibleId: anOp = new HYDROGUI_SubmersibleOp( aModule ); break; + case UnSubmersibleId: + anOp = new HYDROGUI_UnSubmersibleOp( aModule ); + break; case PolylineExtractionId: anOp = new HYDROGUI_PolylineExtractionOp( aModule ); break; @@ -761,6 +769,8 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case LandCoverScalarMapModeOffId: anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId ); break; + case RegenerateRegionColorsId: + anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule ); } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index fdd3048d..88afbe3c 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -110,6 +110,7 @@ enum OperationId RecognizeContoursId, SubmersibleId, + UnSubmersibleId, ImportPolylineId, ImportSinusXId, ExportSinusXId, @@ -145,6 +146,7 @@ enum OperationId BathymetryRescaleDefaultId, ShowHideArrows, + RegenerateRegionColorsId }; #endif diff --git a/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx b/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx index 47ca42f6..af10438a 100644 --- a/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx @@ -46,7 +46,9 @@ bool HYDROGUI_SubmersibleOp::processApply( int& theUpdateFlags, QString& theErro theUpdateFlags = 0; if( isOK ) { - myObject->SetIsSubmersible( !myObject->IsSubmersible() ); + bool IsSubmersible = myObject->IsSubmersible(); + if (!IsSubmersible) + myObject->SetIsSubmersible( true ); theUpdateFlags = 0; } return isOK; diff --git a/src/HYDROGUI/HYDROGUI_Tool2.cxx b/src/HYDROGUI/HYDROGUI_Tool2.cxx index ef1962e8..3dda8c6b 100644 --- a/src/HYDROGUI/HYDROGUI_Tool2.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool2.cxx @@ -54,7 +54,28 @@ int HYDROGUI_Tool::GetActiveStudyId() return 0; } - +static bool GetCalCaseSubT(const QString& aHydroPref, + const QString& anEntry, + const QString& SubTPostFix, + HYDROGUI_DataModel* aModel, + Handle(HYDROData_CalculationCase)& theOutCalCase) +{ + int aFiB = anEntry.lastIndexOf(SubTPostFix, -1, Qt::CaseInsensitive); + if (aFiB != -1) + { + QString RightTruncEntry = anEntry.left(anEntry.length() - SubTPostFix.length()); + Handle(HYDROData_CalculationCase) CalCase = + Handle(HYDROData_CalculationCase)::DownCast (aModel->objectByEntry( RightTruncEntry, KIND_CALCULATION )); + if (CalCase) + { + theOutCalCase = CalCase; + return true; + } + else + return false; + } + return false; +} void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule, SUIT_ViewManager* theViewManager ) @@ -251,8 +272,71 @@ ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule ) return KIND_UNKNOWN; } +bool HYDROGUI_Tool::IsSelectedPartOfCalcCase( HYDROGUI_Module* theModule, Handle(HYDROData_CalculationCase)& theOutCalCase, + QString& theOutPart) +{ + HYDROGUI_DataModel* aModel = theModule->getDataModel(); + SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelectionMgr->selected( anOwners ); + if( anOwners.size() != 1 ) + return false; + + LightApp_DataOwner* anOwner = dynamic_cast( anOwners.first().operator->() ); + if( anOwner ) + { + QString anEntry = anOwner->entry(); + QString aHydroPref = "_" + HYDROGUI_DataObject::entryPrefix(); + // + QString aPostFixBoundary = aHydroPref + HYDROGUI_DataModel::tr("CASE_BOUNDARY"); + if (GetCalCaseSubT(anEntry, anEntry, aPostFixBoundary, aModel, theOutCalCase )) + { + theOutPart = HYDROGUI_DataModel::tr("CASE_BOUNDARY"); + theOutPart.toUpper(); + return true; + } + // + QString aPostFixAO = aHydroPref + + HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_ARTIFICIAL_OBJECT ).toLatin1().constData()); + if (GetCalCaseSubT(anEntry, anEntry, aPostFixAO, aModel, theOutCalCase )) + { + aPostFixAO.remove(0, aHydroPref.length()); + theOutPart = aPostFixAO; + return true; + } + // + QString aPostFixNO = aHydroPref + + HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_NATURAL_OBJECT ).toLatin1().constData()); + if (GetCalCaseSubT(anEntry, anEntry, aPostFixNO, aModel, theOutCalCase )) + { + aPostFixNO.remove(0, aHydroPref.length()); + theOutPart = aPostFixNO; + return true; + } + // + QString aPostFixLCM = aHydroPref + + HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_LAND_COVER_MAP ).toLatin1().constData()); + if (GetCalCaseSubT(anEntry, anEntry, aPostFixLCM, aModel, theOutCalCase )) + { + aPostFixLCM.remove(0, aHydroPref.length()); + theOutPart = aPostFixLCM; + return true; + } + // + QString aPostFixReg = aHydroPref + + HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_REGION ).toLatin1().constData()); + if (GetCalCaseSubT(anEntry, anEntry, aPostFixReg, aModel, theOutCalCase )) + { + aPostFixReg.remove(0, aHydroPref.length()); + theOutPart = aPostFixReg; + return true; + } + // + } + return false; +} QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule, QList theTypes ) diff --git a/src/HYDROGUI/HYDROGUI_Tool2.h b/src/HYDROGUI/HYDROGUI_Tool2.h index 980372ac..316f2ded 100644 --- a/src/HYDROGUI/HYDROGUI_Tool2.h +++ b/src/HYDROGUI/HYDROGUI_Tool2.h @@ -34,6 +34,7 @@ class SUIT_ViewManager; class GraphicsView_ViewPort; class OCCViewer_ViewFrame; class HYDROData_Document; +class HYDROData_CalculationCase; namespace HYDROGUI_Tool { @@ -61,6 +62,9 @@ namespace HYDROGUI_Tool ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule ); + bool IsSelectedPartOfCalcCase( HYDROGUI_Module* theModule, Handle(HYDROData_CalculationCase)& theOutCalCase, + QString& theOutPart); + Handle(HYDROData_Entity) FindObjectByName( HYDROGUI_Module* theModule, const QString& theName, const ObjectKind theObjectKind = KIND_UNKNOWN ); diff --git a/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.cxx b/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.cxx new file mode 100644 index 00000000..5fb28bfd --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.cxx @@ -0,0 +1,54 @@ +// 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 + +HYDROGUI_UnSubmersibleOp::HYDROGUI_UnSubmersibleOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ) +{ +} + +HYDROGUI_UnSubmersibleOp::~HYDROGUI_UnSubmersibleOp() +{ +} + +void HYDROGUI_UnSubmersibleOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + myObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if( myObject.IsNull() ) + onCancel(); + else + onApply(); +} + +bool HYDROGUI_UnSubmersibleOp::processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ) +{ + theUpdateFlags = 0; + if( !myObject.IsNull() ) + { + bool IsSubmersible = myObject->IsSubmersible(); + if (IsSubmersible) + myObject->SetIsSubmersible( false ); + return true; + } + return false; +} + diff --git a/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.h b/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.h new file mode 100644 index 00000000..6d0ffb94 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_UnSubmersibleOp.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_UNSubmersibleOP_H +#define HYDROGUI_UNSubmersibleOP_H + +#include +#include + +class HYDROGUI_UnSubmersibleOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_UnSubmersibleOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_UnSubmersibleOp(); + +protected: + virtual void startOperation(); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + +private: + Handle(HYDROData_Object) myObject; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ZoneTool.cxx b/src/HYDROGUI/HYDROGUI_ZoneTool.cxx new file mode 100644 index 00000000..be403406 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZoneTool.cxx @@ -0,0 +1,74 @@ +// 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 + +int randHue( int theHue ) +{ + if( theHue>=0 && theHue<360 ) + return theHue; + else + return rand()%360; +} + +int randValue( int theMin, int theMax ) +{ + return theMin + rand()%(theMax-theMin); +} + +void AssignDefaultColor( const Handle(HYDROData_Zone)& theZone, + int theHue, int theSMargin, int theBMargin ) +{ + int aHue = randHue( theHue ); + int aSat = randValue( theSMargin, 255 ); + int aBri = randValue( theBMargin, 255-theBMargin ); + + QColor aColor = QColor::fromHsl( aHue, aSat, aBri ); + theZone->SetColor( aColor ); +} + +namespace HYDROGUI_ZoneTool { + +void AssignDefaultColors( const QList& theRegions, int theSMargin, int theBMargin ) +{ + foreach( Handle(HYDROData_Region) region, theRegions ) + AssignDefaultColors( region, theSMargin, theBMargin ); +} + +void AssignDefaultColors( const Handle(HYDROData_Region)& theRegion, int theSMargin, int theBMargin ) +{ + int aHue = randHue( -1 ); + HYDROData_SequenceOfObjects zones = theRegion->GetZones(); + HYDROData_SequenceOfObjects::Iterator zonesIt( zones ); + for( ; zonesIt.More(); zonesIt.Next() ) + { + Handle(HYDROData_Zone) aZone = + Handle(HYDROData_Zone)::DownCast( zonesIt.Value() ); + AssignDefaultColor( aZone, aHue, theSMargin, theBMargin ); + } +} + +void AssignDefaultColors( const HYDROData_SequenceOfObjects& theRegions, int theSMargin, int theBMargin ) +{ + for ( int i = 1; i <= theRegions.Length(); i++ ) + AssignDefaultColors( Handle(HYDROData_Region)::DownCast(theRegions(i)), theSMargin, theBMargin ); +} + +}; diff --git a/src/HYDROGUI/HYDROGUI_ZoneTool.h b/src/HYDROGUI/HYDROGUI_ZoneTool.h new file mode 100644 index 00000000..8db9c7d2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZoneTool.h @@ -0,0 +1,32 @@ +// 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_ZoneTool_H +#define HYDROGUI_ZoneTool_H + +#include + +namespace HYDROGUI_ZoneTool +{ + void AssignDefaultColors( const QList&, int theSMargin = 128, int theBMargin = 90 ); + void AssignDefaultColors( const Handle(HYDROData_Region)&, int theSMargin = 128, int theBMargin = 90 ); + void AssignDefaultColors( const HYDROData_SequenceOfObjects& theRegions, int theSMargin = 128, int theBMargin = 90 ); +}; + + +#endif diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index df3ecb21..4a080b60 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -46,6 +46,18 @@ SUBMERSIBLE_ICO icon_submersible.png + + HYDRO_UNSUBMERSIBLE_ICO + icon_unsubmersible.png + + + HYDRO_UNSUBMERSIBLE16_ICO + icon_unsumb_16.png + + + HYDRO_SUBMERSIBLE16_ICO + icon_sumb_16.png + @@ -77,6 +89,10 @@ HYDRO_TYPE5_ICO icon_imm_zone.png + + HYDRO_TYPE5U_ICO + icon_imm_uns_zone.png + HYDRO_TYPE6_ICO icon_river.png @@ -175,6 +191,10 @@ HYDRO_M_TYPE5_ICO icon_mimm_zone.png + + HYDRO_M_TYPE5U_ICO + icon_mimm_uns_zone.png + HYDRO_M_TYPE6_ICO icon_mriver.png diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index ed690455..35ff9864 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1123,6 +1123,10 @@ Would you like to remove all references from the image? DSK_SUBMERSIBLE Submersible + + DSK_UNSUBMERSIBLE + Unsubmersible + DSK_EXPORT_TO_SHAPE_FILE Export @@ -1508,6 +1512,10 @@ Would you like to remove all references from the image? MEN_SUBMERSIBLE Submersible + + MEN_UNSUBMERSIBLE + Unsubmersible + MEN_EXPORT_TO_SHAPE_FILE Export @@ -1516,6 +1524,10 @@ Would you like to remove all references from the image? MEN_POLYLINE_EXTRACTION Polyline extraction + + MEN_REGENERATE_REGION_COLORS + Regenerate region colors + STB_CREATE_CALCULATION @@ -1854,6 +1866,10 @@ Would you like to remove all references from the image? STB_SUBMERSIBLE If the object is submersible + + STB_UNSUBMERSIBLE + If the object is non submersible + STB_EXPORT_TO_SHAPE_FILE Export diff --git a/src/HYDROGUI/resources/icon_imm_uns_zone.png b/src/HYDROGUI/resources/icon_imm_uns_zone.png new file mode 100644 index 00000000..49ccbbe0 Binary files /dev/null and b/src/HYDROGUI/resources/icon_imm_uns_zone.png differ diff --git a/src/HYDROGUI/resources/icon_mimm_uns_zone.png b/src/HYDROGUI/resources/icon_mimm_uns_zone.png new file mode 100644 index 00000000..60670936 Binary files /dev/null and b/src/HYDROGUI/resources/icon_mimm_uns_zone.png differ diff --git a/src/HYDROGUI/resources/icon_sumb_16.png b/src/HYDROGUI/resources/icon_sumb_16.png new file mode 100644 index 00000000..34a79149 Binary files /dev/null and b/src/HYDROGUI/resources/icon_sumb_16.png differ diff --git a/src/HYDROGUI/resources/icon_unsumb_16.png b/src/HYDROGUI/resources/icon_unsumb_16.png new file mode 100644 index 00000000..49ccbbe0 Binary files /dev/null and b/src/HYDROGUI/resources/icon_unsumb_16.png differ diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index 8bd6f0ef..2b207f3c 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -79,6 +79,7 @@ set( EXTERNAL_FILES ../HYDROGUI/HYDROGUI_ListSelector.cxx ../HYDROGUI/HYDROGUI_OrderedListWidget.cxx ../HYDROGUI/HYDROGUI_Overview.cxx + ../HYDROGUI/HYDROGUI_ZoneTool.cxx ../HYDROGUI/HYDROGUI_ProfileDlg.cxx ../HYDROGUI/HYDROGUI_ViewerDlg.cxx ../HYDROGUI/HYDROGUI_AISTrihedron.cxx @@ -92,6 +93,7 @@ set( MOC_HEADERS ../HYDROGUI/HYDROGUI_ListSelector.h ../HYDROGUI/HYDROGUI_OrderedListWidget.h ../HYDROGUI/HYDROGUI_Overview.h + ../HYDROGUI/HYDROGUI_ZoneTool.h ../HYDROGUI/HYDROGUI_ProfileDlg.h ../HYDROGUI/HYDROGUI_ViewerDlg.h ) diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index d16a4708..db653976 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -145,6 +145,7 @@ SET(REFERENCE_DATA bathy_rescaled_visible.png bathy_text_labels.png bathy_prs_fit_selected.png + zone_random_colors.png ) # Application tests diff --git a/src/HYDRO_tests/reference_data/zone_random_colors.png b/src/HYDRO_tests/reference_data/zone_random_colors.png new file mode 100644 index 00000000..1bf0ab4c Binary files /dev/null and b/src/HYDRO_tests/reference_data/zone_random_colors.png differ