From: isn Date: Tue, 20 Oct 2015 09:25:45 +0000 (+0300) Subject: another way to get colors; X-Git-Tag: v1.5~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d143d9fbeb31ba0e60c4dcf41988e4c2c7b0ad84;p=modules%2Fhydro.git another way to get colors; get rid of random.h --- diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 50708823..a1c314f3 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -19,7 +19,6 @@ set(PROJECT_HEADERS TestViewer.h TestLib_Listener.h TestLib_Runner.h - random.h ) set(PROJECT_SOURCES @@ -41,7 +40,6 @@ set(PROJECT_SOURCES TestViewer.cxx TestLib_Listener.cxx TestLib_Runner.cxx - random.cxx ) add_definitions( diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index ebd8d3fc..7dcec1aa 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -1,6 +1,6 @@ #include -#include +//#include #include #ifdef WIN32 #pragma warning ( disable: 4251 ) @@ -65,13 +65,17 @@ Handle(AIS_InteractiveContext) context() return TestViewer::viewer()->getAISContext(); } -QColor randomColor() +QColor TestViewer::GetColor(int i) { - int r = test_rand(); - int aHue = r%255; - //std::cout << "hue: " << aHue << std::endl; - QColor aColor = QColor::fromHsl( aHue, 255, 128 ); - return aColor; + QVector aCV; + aCV << QColor(0,0,255) + << QColor(0,255,0) + << QColor(255,0,0) + << QColor(255,255,20) + << QColor(20,255,255) + << QColor(100,100,20) + << QColor(10,100,150); + return aCV[i]; } void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ) @@ -97,15 +101,15 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, context()->EraseAll(); myKey = theKey; - test_srand( 0 ); + int i = 0; if( theShape.ShapeType()==TopAbs_SHELL ) { TopoDS_Iterator anIt( theShape ); - for( ; anIt.More(); anIt.Next() ) - show( anIt.Value(), theMode, false, randomColor() ); + for( ; anIt.More(); anIt.Next(), i++ ) + show( anIt.Value(), theMode, false, GetColor(i) ); } else - show( theShape, theMode, false, randomColor() ); + show( theShape, theMode, false, GetColor(0) ); if( isFitAll ) { diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index 9768982a..64438b6c 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -18,6 +18,7 @@ public: static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ); static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey ); static bool AssertImages( QString& theMessage ); + static QColor GetColor(int i); private: static OCCViewer_ViewManager* myViewManager; diff --git a/src/HYDRO_tests/random.cxx b/src/HYDRO_tests/random.cxx deleted file mode 100644 index c829b20a..00000000 --- a/src/HYDRO_tests/random.cxx +++ /dev/null @@ -1,15 +0,0 @@ - -#include - -quint32 next = 1; - -void test_srand( quint32 theValue ) -{ - next = theValue + 1; -} - -quint32 test_rand() -{ - next = next * 1103515245 + 12345; - return next % ( 1 << 24 ); -} diff --git a/src/HYDRO_tests/random.h b/src/HYDRO_tests/random.h deleted file mode 100644 index d6901117..00000000 --- a/src/HYDRO_tests/random.h +++ /dev/null @@ -1,7 +0,0 @@ - -#pragma once - -#include - -void test_srand( quint32 theValue ); -quint32 test_rand(); diff --git a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx index 9b6535f3..a4ccd342 100644 --- a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx +++ b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 4248b219..74bb9315 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -29,12 +29,9 @@ #include #include #include -#include int main( int argc, char* argv[] ) { - test_srand( 0 ); - QApplication anApp( argc, argv ); SUIT_Session aSession;