From 14440f49669dab69af74c1fb39526daae2bad91b Mon Sep 17 00:00:00 2001 From: mpa Date: Wed, 23 Dec 2015 14:00:59 +0300 Subject: [PATCH] INT PAL 0052968: 'Mesh Information' dialog shows incorrect color of group built from geometry. (added a new form for defining color) --- src/SMESH_I/SMESH_Gen_i.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index d069a3df8..fe64ce7b7 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -957,11 +957,23 @@ void SMESH_Gen_i::SetOption(const char* name, const char* value) { vector color; string str = value; - if ( str.at(0) == '#' && str.length() == 7 ) // color should be presented as a string (#aaaaaa, for example) + // color must be presented as a string of next form: + if ( str.at(0) == '#' && str.length() == 7 ) { // hexadecimal color ("#ffaa00", for example) str = str.substr(1); for ( int i = 0; i < str.length()/2; i++ ) if ( str.at(i*2) >= '0' && str.at(i*2) <= 'f' && str.at(i*2+1) >= '0' && str.at(i*2+1) <= 'f' ) color.push_back( strtol( str.substr( i*2, 2 ).c_str(), NULL, 16 ) ); + } + else { // rgb color ("255,170,0", for example) + char* tempValue = strdup( value ); + char* colorValue = strtok( tempValue, "," ); + while ( colorValue != NULL ) { + int c_value = atoi( colorValue ); + if ( c_value >= 0 && c_value <= 255 ) + color.push_back( c_value ); + colorValue = strtok( NULL, "," ); + } + } if ( color.size() == 3 ) { // color must have three valid component SMESHDS_GroupBase::SetDefaultColor( Quantity_Color( color[0]/255., color[1]/255., color[2]/255., Quantity_TOC_RGB ) ); myDefaultGroupColor = value; -- 2.39.2