From: mpa Date: Mon, 30 Nov 2015 10:31:21 +0000 (+0300) Subject: INT PAL 0052968: 'Mesh Information' dialog shows incorrect color of group built from... X-Git-Tag: V8_0_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aac6ba83a954d30516057206ead49bf3f0c23e93;p=modules%2Fsmesh.git INT PAL 0052968: 'Mesh Information' dialog shows incorrect color of group built from geometry (edited) --- diff --git a/src/SMESHDS/SMESHDS_GroupBase.cxx b/src/SMESHDS/SMESHDS_GroupBase.cxx index a9c378fd6..ef2f2de4a 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.cxx +++ b/src/SMESHDS/SMESHDS_GroupBase.cxx @@ -32,6 +32,8 @@ using namespace std; +Quantity_Color SMESHDS_GroupBase::myDefaultColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB ); + //============================================================================= /*! * @@ -44,7 +46,7 @@ SMESHDS_GroupBase::SMESHDS_GroupBase (const int theID, myID(theID), myMesh(theMesh), myType(theType), myStoreName(""), myCurIndex(0), myCurID(-1) { - myColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB ); + myColor = myDefaultColor; } //============================================================================= diff --git a/src/SMESHDS/SMESHDS_GroupBase.hxx b/src/SMESHDS/SMESHDS_GroupBase.hxx index 959498e82..305ecb8c0 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.hxx +++ b/src/SMESHDS/SMESHDS_GroupBase.hxx @@ -85,6 +85,9 @@ class SMESHDS_EXPORT SMESHDS_GroupBase int GetColorGroup() const; + static void SetDefaultColor (const Quantity_Color& theColor) + { myDefaultColor = theColor;} + protected: const SMDS_MeshElement* findInMesh (const int theID) const; void resetIterator(); @@ -105,6 +108,8 @@ class SMESHDS_EXPORT SMESHDS_GroupBase int myCurIndex; int myCurID; SMDS_ElemIteratorPtr myIterator; + + static Quantity_Color myDefaultColor; }; #endif diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index b3d61a763..d72312ddb 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1951,7 +1951,7 @@ SalomeApp_Module( "SMESH" ) nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 ); myComponentSMESH->SetDefaultNbSegments( nbSeg ); - const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" }; + const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" }; for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i ) if ( aResourceMgr->hasValue( "SMESH", options[i] )) { @@ -5376,7 +5376,7 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name ) int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 ); myComponentSMESH->SetDefaultNbSegments( nbSeg ); } - else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif") + else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" ) { QString val = aResourceMgr->stringValue( "SMESH", name ); myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() ); diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index deeaad22f..258084e05 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -30,7 +30,6 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_GEOMGenUtils.h" -#include #include #include @@ -351,17 +350,9 @@ bool SMESHGUI_GroupOnShapeOp::onApply() //printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() ); group = mesh->CreateGroupFromGEOM( elemType, name.toLatin1().data(), geom ); - if( !group->_is_nil() ) { - // set default color for created group - QColor c = SMESH::GetColor( "SMESH", "default_grp_color" ); - SALOMEDS::Color aColor; - aColor.R = c.redF(); - aColor.G = c.greenF(); - aColor.B = c.blueF(); - group->SetColor(aColor); + if( !group->_is_nil() ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( group ) ) anEntryList.append( aSObject->GetID().c_str() ); - } } } SMESHGUI::Modified(); diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx index 69077f967..6f32383c0 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -31,6 +31,7 @@ #include "SMESHGUI_Utils.h" #include "SMESHGUI_VTKUtils.h" #include "SMESH_TypeFilter.hxx" +#include #include #include @@ -232,6 +233,8 @@ void SMESHGUI_GroupOpDlg::Init() if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) aViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP)); + + setDefaultGroupColor(); } /*! @@ -447,6 +450,14 @@ SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const return aColor; } +/*! + \brief Set default color for group +*/ +void SMESHGUI_GroupOpDlg::setDefaultGroupColor() +{ + myColorBtn->setColor( SMESH::GetColor( "SMESH", "default_grp_color", QColor( 255, 170, 0 ) ) ); +} + /*! \brief SLOT, called when selection is changed. Current implementation does nothing. The method should be redefined in derived classes to update @@ -505,6 +516,7 @@ void SMESHGUI_GroupOpDlg::reset() { myNameEdit->setText(""); myNameEdit->setFocus(); + setDefaultGroupColor(); } /*! diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h index 6f6b70175..f4191a942 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h @@ -88,6 +88,7 @@ protected: SMESH::ListOfGroups* convert( const QList& ); SALOMEDS::Color getColor() const; + void setDefaultGroupColor(); void setIsApplyAndClose( const bool theFlag ); bool isApplyAndClose() const; diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index a63597715..d069a3df8 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -953,6 +953,22 @@ void SMESH_Gen_i::SetOption(const char* name, const char* value) msgToGUI = "preferences/SMESH/forget_mesh_on_hyp_modif/"; msgToGUI += myToForgetMeshDataOnHypModif ? "true" : "false"; } + else if ( strcmp(name, "default_grp_color") == 0 ) + { + vector color; + string str = value; + if ( str.at(0) == '#' && str.length() == 7 ) // color should be presented as a string (#aaaaaa, 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 ) ); + 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; + msgToGUI = "preferences/SMESH/default_grp_color/"; + msgToGUI += value; + } + } // update preferences in case if SetOption() is invoked from python console if ( !msgToGUI.empty() ) @@ -983,6 +999,10 @@ char* SMESH_Gen_i::GetOption(const char* name) { return CORBA::string_dup( myToForgetMeshDataOnHypModif ? "true" : "false" ); } + if ( strcmp(name, "default_grp_color") == 0 ) + { + return CORBA::string_dup( myDefaultGroupColor.c_str() ); + } } return CORBA::string_dup( "" ); } diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 7f6427205..e2be6042d 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -679,6 +679,9 @@ private: SALOMEDS::Study_var myCurrentStudy; // Current study CORBA::Boolean myIsEmbeddedMode; // Current mode + // Default color of groups + std::string myDefaultGroupColor; + // To load full mesh data from study at hyp modification or not bool myToForgetMeshDataOnHypModif;