INT PAL 0052968: 'Mesh Information' dialog shows incorrect color of group built from geometry (edited)

This commit is contained in:
mpa 2015-11-30 13:31:21 +03:00
parent 8348eecb6b
commit aac6ba83a9
8 changed files with 47 additions and 13 deletions

View File

@ -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;
}
//=============================================================================

View File

@ -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

View File

@ -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() );

View File

@ -30,7 +30,6 @@
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include <SMESH_ActorUtils.h>
#include <GeometryGUI.h>
#include <GEOM_SelectionFilter.h>
@ -351,19 +350,11 @@ 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();
update( UF_ObjBrowser | UF_Model );

View File

@ -31,6 +31,7 @@
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESH_TypeFilter.hxx"
#include <SMESH_ActorUtils.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
@ -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();
}
/*!

View File

@ -88,6 +88,7 @@ protected:
SMESH::ListOfGroups* convert( const QList<SMESH::SMESH_GroupBase_var>& );
SALOMEDS::Color getColor() const;
void setDefaultGroupColor();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;

View File

@ -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<int> 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( "" );
}

View File

@ -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;