From: isn Date: Mon, 30 Oct 2017 14:38:37 +0000 (+0300) Subject: refs #1340 X-Git-Tag: v2.1~58^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f2bba55908a17c19d1750b7ffddb3982bf922484;p=modules%2Fhydro.git refs #1340 --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index a35f02cf..0454e19f 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -148,6 +148,7 @@ set(PROJECT_HEADERS HYDROGUI_TransparencyDlg.h HYDROGUI_Overview.h HYDROGUI_ZoneTool.h + HYDROGUI_RegenerateRegionColorsOp.h ) QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -298,6 +299,7 @@ set(PROJECT_SOURCES HYDROGUI_TransparencyDlg.cxx HYDROGUI_Overview.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_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index d03db928..cf0954d9 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -568,6 +568,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 ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index b1c58801..14c473fe 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_RegenerateRegionColorsOp.h" #include #include @@ -241,6 +242,9 @@ void HYDROGUI_Module::createActions() createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" ); createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" ); + + createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" ); + } void HYDROGUI_Module::createMenus() @@ -714,6 +718,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 c558cfbd..e56315e8 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -143,6 +143,8 @@ enum OperationId BathymetryRescaleVisibleId, BathymetryRescaleUserId, BathymetryRescaleDefaultId, + + RegenerateRegionColorsId }; #endif 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_ZoneTool.cxx b/src/HYDROGUI/HYDROGUI_ZoneTool.cxx index b5b75c4f..be403406 100644 --- a/src/HYDROGUI/HYDROGUI_ZoneTool.cxx +++ b/src/HYDROGUI/HYDROGUI_ZoneTool.cxx @@ -65,5 +65,10 @@ void AssignDefaultColors( const Handle(HYDROData_Region)& theRegion, int theSMar } } +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 index b419544b..8db9c7d2 100644 --- a/src/HYDROGUI/HYDROGUI_ZoneTool.h +++ b/src/HYDROGUI/HYDROGUI_ZoneTool.h @@ -25,6 +25,7 @@ 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 ); }; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 64c41377..4c07b121 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1500,6 +1500,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