mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-08 10:47:27 +05:00
0021941: [CEA 699] Use for Auto Color method on mesh group the same algorithm that this one in GEOM which define colors.
This commit is contained in:
parent
57a7fd817d
commit
e87a86a68d
@ -174,6 +174,10 @@
|
|||||||
//Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
|
//Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
|
||||||
#define WITHGENERICOBJ
|
#define WITHGENERICOBJ
|
||||||
|
|
||||||
|
// Below macro, when uncommented, switches on simplified (more performant) algorithm
|
||||||
|
// of auto-color picking up
|
||||||
|
#define SIMPLE_AUTOCOLOR
|
||||||
|
|
||||||
//namespace{
|
//namespace{
|
||||||
// Declarations
|
// Declarations
|
||||||
//=============================================================
|
//=============================================================
|
||||||
@ -969,11 +973,21 @@
|
|||||||
|
|
||||||
aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
|
aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
|
||||||
|
|
||||||
|
QList<SALOMEDS::Color> aReservedColors;
|
||||||
|
|
||||||
SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
|
SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
|
||||||
for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
|
for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
|
||||||
{
|
{
|
||||||
SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
|
SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
|
||||||
SALOMEDS::Color aColor = aGroupObject->GetColor();
|
//SALOMEDS::Color aColor = aGroupObject->GetColor();
|
||||||
|
|
||||||
|
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
|
||||||
|
SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
|
||||||
|
#else // old algorithm for auto-colors
|
||||||
|
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
|
||||||
|
aReservedColors.append( aColor );
|
||||||
|
#endif // SIMPLE_AUTOCOLOR
|
||||||
|
|
||||||
_PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
|
_PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
|
||||||
if (aGroupSObject) {
|
if (aGroupSObject) {
|
||||||
QColor c;
|
QColor c;
|
||||||
@ -6539,3 +6553,33 @@ bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
|
||||||
|
{
|
||||||
|
static QList<QColor> colors;
|
||||||
|
|
||||||
|
if ( colors.isEmpty() ) {
|
||||||
|
|
||||||
|
for (int s = 0; s < 2 ; s++)
|
||||||
|
{
|
||||||
|
for (int v = 100; v >= 40; v = v - 20)
|
||||||
|
{
|
||||||
|
for (int h = 0; h < 359 ; h = h + 60)
|
||||||
|
{
|
||||||
|
colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static int currentColor = 0;
|
||||||
|
|
||||||
|
SALOMEDS::Color color;
|
||||||
|
color.R = (double)colors[currentColor].red() / 255.0;
|
||||||
|
color.G = (double)colors[currentColor].green() / 255.0;
|
||||||
|
color.B = (double)colors[currentColor].blue() / 255.0;
|
||||||
|
|
||||||
|
currentColor = (currentColor+1) % colors.count();
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
@ -142,6 +142,7 @@ public :
|
|||||||
virtual void update( const int );
|
virtual void update( const int );
|
||||||
|
|
||||||
static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
|
static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
|
||||||
|
static SALOMEDS::Color getPredefinedUniqueColor();
|
||||||
|
|
||||||
virtual void storeVisualParameters (int savePoint);
|
virtual void storeVisualParameters (int savePoint);
|
||||||
virtual void restoreVisualParameters(int savePoint);
|
virtual void restoreVisualParameters(int savePoint);
|
||||||
|
@ -1142,6 +1142,8 @@ bool SMESHGUI_GroupDlg::onApply()
|
|||||||
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
|
myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
|
||||||
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
|
myGroupOnFilter = SMESH::SMESH_GroupOnFilter::_nil();
|
||||||
myFilter = SMESH::Filter::_nil();
|
myFilter = SMESH::Filter::_nil();
|
||||||
|
|
||||||
|
setDefaultGroupColor(); // reset color for case if 'auto-color' feature is enabled.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2454,15 +2456,20 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor()
|
|||||||
|
|
||||||
bool isAutoColor = myMesh->GetAutoColor();
|
bool isAutoColor = myMesh->GetAutoColor();
|
||||||
|
|
||||||
QColor aQColor;
|
QColor aQColor = myColorBtn->color();
|
||||||
if( !isAutoColor )
|
if( !isAutoColor )
|
||||||
{
|
{
|
||||||
int r = 0, g = 0, b = 0;
|
if ( !aQColor.isValid() ) {
|
||||||
SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
|
int r = 0, g = 0, b = 0;
|
||||||
aQColor.setRgb( r, g, b );
|
SMESH::GetColor( "SMESH", "default_grp_color", r, g, b, QColor( 255, 170, 0 ) );
|
||||||
|
aQColor.setRgb( r, g, b );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
|
||||||
|
SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
|
||||||
|
#else // old algorithm for auto-colors
|
||||||
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
|
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
|
||||||
|
|
||||||
QList<SALOMEDS::Color> aReservedColors;
|
QList<SALOMEDS::Color> aReservedColors;
|
||||||
@ -2474,6 +2481,8 @@ void SMESHGUI_GroupDlg::setDefaultGroupColor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
|
SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
|
||||||
|
#endif // SIMPLE_AUTOCOLOR
|
||||||
|
|
||||||
aQColor.setRgb( (int)( aColor.R * 255.0 ),
|
aQColor.setRgb( (int)( aColor.R * 255.0 ),
|
||||||
(int)( aColor.G * 255.0 ),
|
(int)( aColor.G * 255.0 ),
|
||||||
(int)( aColor.B * 255.0 ) );
|
(int)( aColor.B * 255.0 ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user