From: asl Date: Fri, 21 Aug 2015 12:23:29 +0000 (+0300) Subject: refs #639: the button to regenerate colors X-Git-Tag: BR_quadtree_20150925~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=512895a1eba53037471cc2aa63852321c0afc244;p=modules%2Fhydro.git refs #639: the button to regenerate colors --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 396e2c57..6a6e60f0 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -477,6 +477,9 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() { aLayout->addWidget( myBathymetryLabel, 2, 0 ); aLayout->addWidget( myBathymetryChoice, 2, 1 ); + QPushButton* aRegenerateBtn = new QPushButton( tr( "REGENERATE_COLORS" ), this ); + aLayout->addWidget( aRegenerateBtn, 3, 0 ); + aPage->setLayout( aLayout ); connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); @@ -487,7 +490,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() { SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), SLOT( onZonesDropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); connect( myBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewRegion() ) ); - + connect( aRegenerateBtn, SIGNAL( clicked() ), this, SIGNAL( regenerateColors() ) ); return aPage; } diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index c0e972c1..41f010ba 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -169,6 +169,8 @@ signals: void StricklerTableSelected( const QString & theObjName ); void setMergeStricklerType( int theMergeType, QString& theStricklerTypeName ); + void regenerateColors(); + protected: virtual bool acceptCurrent() const; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 2951e583..edce573b 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -248,6 +248,9 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), SLOT( onStricklerTableSelected( const QString & ) ) ); + connect( aPanel, SIGNAL( regenerateColors() ), this, + SLOT( onRegenerateColors() ) ); + return aPanel; } @@ -1329,29 +1332,13 @@ QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex, float theSaturation/* = 0.5*/, float theValue/* = 0.95*/ ) const { - float aGoldenRatioConjugate = (float)(360./582.); - float aHue = (float)(rand()%100); - aHue += aGoldenRatioConjugate*theIndex; - aHue -= floor(aHue); - - float aR = 0., aG = 0., aB = 0.; - int aHueInt = (int)(aHue*6.); - float aF = aHue*6. - aHueInt; - float aP = theValue * (1. - theSaturation); - float aQ = theValue * (1. - aF*theSaturation); - float aT = theValue * (1. - (1. - aF) * theSaturation); - switch (aHueInt) - { - case 0: { aR = theValue; aG = aT; aB = aP; break; } - case 1: { aR = aQ; aG = theValue; aB = aP; break; } - case 2: { aR = aP; aG = theValue; aB = aT; break; } - case 3: { aR = aP; aG = aQ; aB = theValue; break; } - case 4: { aR = aT; aG = aP; aB = theValue; break; } - case 5: { aR = theValue; aG = aP; aB = aQ; break; } - default: break; - } - - QColor aColor = QColor( (int)(aR*256.), (int)(aG*256.), (int)(aB*256.) ); + float aHue = ( rand()%1000 ) * 0.001f; + + QColor aColor; + aColor.setHsl( (int)(aHue*255.), 128, 128 ); + int r = aColor.red(); + int g = aColor.green(); + int b = aColor.blue(); return ( aColor.isValid() ? aColor : HYDROData_ImmersibleZone::DefaultFillingColor() ); } @@ -1798,3 +1785,11 @@ void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed ) if( isConfirmed ) myEditedObject->SetToUpdate( true ); } + +void HYDROGUI_CalculationOp::onRegenerateColors() +{ + // For geometry zones + AssignDefaultZonesColors( false ); + setZonesVisible( false, false ); + setZonesVisible( true, false ); +} diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index cefe99bf..1a5998ad 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -153,6 +153,8 @@ protected slots: void onRuleChanged( bool& isConfirmed ); void onRuleLandCoverChanged( bool& isConfirmed ); + void onRegenerateColors(); + private: void createPreview( const bool theLandCover); void closePreview( bool theRemoveViewManager = true ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 27f896be..b9ef26ae 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -377,6 +377,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) RESULTS_ON_LAND_COVERS Results on land covers + + REGENERATE_COLORS + Regenerate colors +