using namespace std;
+Quantity_Color SMESHDS_GroupBase::myDefaultColor = Quantity_Color( 0.0, 0.0, 0.0, Quantity_TOC_RGB );
+
//=============================================================================
/*!
*
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;
}
//=============================================================================
int GetColorGroup() const;
+ static void SetDefaultColor (const Quantity_Color& theColor)
+ { myDefaultColor = theColor;}
+
protected:
const SMDS_MeshElement* findInMesh (const int theID) const;
void resetIterator();
int myCurIndex;
int myCurID;
SMDS_ElemIteratorPtr myIterator;
+
+ static Quantity_Color myDefaultColor;
};
#endif
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] ))
{
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() );
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
-#include <SMESH_ActorUtils.h>
#include <GeometryGUI.h>
#include <GEOM_SelectionFilter.h>
//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();
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESH_TypeFilter.hxx"
+#include <SMESH_ActorUtils.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
+
+ setDefaultGroupColor();
}
/*!
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
{
myNameEdit->setText("");
myNameEdit->setFocus();
+ setDefaultGroupColor();
}
/*!
SMESH::ListOfGroups* convert( const QList<SMESH::SMESH_GroupBase_var>& );
SALOMEDS::Color getColor() const;
+ void setDefaultGroupColor();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
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() )
{
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( "" );
}
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;