-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
+// Below macro, when uncommented, switches on simplified (more performant) algorithm
+// of auto-color picking up
+#define SIMPLE_AUTOCOLOR
+
//namespace{
// Declarations
//=============================================================
anEntryList.append( aMeshSO->GetID().c_str() );
-#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
aMeshes[i]->UnRegister();
-#endif
}
else {
isEmpty = true;
if ( isDAT )
{
format = "DAT";
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
- notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
- notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
- notSupportedElemTypes.push_back( SMESH::Entity_Tetra );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Tetra );
- notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
- notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
- notSupportedElemTypes.push_back( SMESH::Entity_Penta );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
- notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
- notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
notSupportedElemTypes.push_back( SMESH::Entity_0D );
notSupportedElemTypes.push_back( SMESH::Entity_Ball );
}
{
format = "CGNS";
notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
}
else if ( isSAUV )
{
format = "SAUV";
notSupportedElemTypes.push_back( SMESH::Entity_Ball );
+ notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
{
format = "GMF";
notSupportedElemTypes.push_back( SMESH::Entity_0D );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
- notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
if ( !presentNotSupported.empty() )
{
QString typeNames;
- const char* typeMsg[SMESH::Entity_Last] = { "SMESH_NODES",
- "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES","SMESH_TRIANGLES",
- "SMESH_QUADRATIC_TRIANGLES","SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES",
- "SMESH_BIQUADRATIC_QUADRANGLES","SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
+ const char* typeMsg[SMESH::Entity_Last] = {
+ "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
+ "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
+ "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
+ "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
"SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
"SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
"SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
+ QList<SALOMEDS::Color> aReservedColors;
+
SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; 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);
if (aGroupSObject) {
QColor c;
vtkLookupTable* lookupTable =
static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
double * minmax = lookupTable->GetRange();
+ bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
std::vector<int> nbEvents;
std::vector<double> funValues;
- aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
+ aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
QString anInitialPath = "";
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentPath();
return;
}
case 1132: {
- vtkFloatingPointType color[3];
+ double color[3];
QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
QColor orientationColor, outlineColor, volumeColor;
int deltaF = 0, deltaV = 0;
int ballSize = 1;
int edgeWidth = 1;
int outlineWidth = 1;
- vtkFloatingPointType shrinkCoef = 0.0;
- vtkFloatingPointType orientationScale = 0.0;
+ double shrinkCoef = 0.0;
+ double orientationScale = 0.0;
bool orientation3d = false;
VTK::MarkerType markerType = VTK::MT_NONE;
VTK::MarkerScale markerScale = VTK::MS_NONE;
aControl = SMESH_Actor::eCoincidentElems3D;
break;
}
-
+
anActor->SetControlMode(aControl);
anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
SMESH::RepaintCurrentView();
}
}
+ // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
+ for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
+ {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
+ if ( !mesh->_is_nil() )
+ mesh->Clear();
+ }
+
// Treat SO's in the list starting from the back
aStudyBuilder->NewCommand(); // There is a transaction
for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
std::string anEntry = SO->GetID();
/** Erase graphical object **/
- if(SO->FindAttribute(anAttr, "AttributeIOR")){
- ViewManagerList aViewMenegers = anApp->viewManagers();
- ViewManagerList::const_iterator it = aViewMenegers.begin();
- for( ; it != aViewMenegers.end(); it++) {
- SUIT_ViewManager* vm = *it;
- int nbSf = vm ? vm->getViewsCount() : 0;
- if(vm) {
- QVector<SUIT_ViewWindow*> aViews = vm->getViews();
- for(int i = 0; i < nbSf; i++){
- SUIT_ViewWindow *sf = aViews[i];
- if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
- SMESH::RemoveActor(sf,anActor);
- }
- }
- }
- }
+ if(SO->FindAttribute(anAttr, "AttributeIOR")) {
+ SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
+ // ViewManagerList aViewMenegers = anApp->viewManagers();
+ // ViewManagerList::const_iterator it = aViewMenegers.begin();
+ // for( ; it != aViewMenegers.end(); it++) {
+ // SUIT_ViewManager* vm = *it;
+ // int nbSf = vm ? vm->getViewsCount() : 0;
+ // if(vm) {
+ // QVector<SUIT_ViewWindow*> aViews = vm->getViews();
+ // for(int i = 0; i < nbSf; i++){
+ // SUIT_ViewWindow *sf = aViews[i];
+ // if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
+ // SMESH::RemoveActor(sf,anActor);
+ // }
+ // }
+ // }
+ // }
}
/** Remove an object from data structures **/
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
*/
//=============================================================================
SMESHGUI::SMESHGUI() :
-SalomeApp_Module( "SMESH" ),
-LightApp_Module( "SMESH" )
+SalomeApp_Module( "SMESH" )
{
if ( CORBA::is_nil( myComponentSMESH ) )
{
myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
myPriority = 0.0;
- SMESH::GetFilterManager();
- SMESH::GetPattern();
- SMESH::GetMeasurements();
-
/* load resources for all available meshers */
SMESH::InitAvailableHypotheses();
}
//=============================================================================
SMESHGUI::~SMESHGUI()
{
-#ifdef WITHGENERICOBJ
- SMESH::GetFilterManager()->UnRegister();
- SMESH::GetMeasurements()->UnRegister();
-#endif
- SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
- SMESH::GetMeasurements() = SMESH::Measurements::_nil();
}
//=============================================================================
case 4035: // QUADRATIC TRIANGLE
case 4036: // QUADRATIC QUADRANGLE
case 4136: // BIQUADRATIC QUADRANGLE
+ case 4137: // BIQUADRATIC TRIANGLE
case 4037: // QUADRATIC TETRAHEDRON
case 4038: // QUADRATIC PYRAMID
case 4039: // QUADRATIC PENTAHEDRON
type = SMDSEntity_Quad_Quadrangle; break;
case 4136:
type = SMDSEntity_BiQuad_Quadrangle; break;
+ case 4137:
+ type = SMDSEntity_BiQuad_Triangle; break;
case 4037:
type = SMDSEntity_Quad_Tetra; break;
case 4038:
createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
+ createSMESHAction( 4137, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
createMenu( separator(), addId, -1 );
createMenu( 4034, addId, -1 );
createMenu( 4035, addId, -1 );
+ createMenu( 4137, addId, -1 );
createMenu( 4036, addId, -1 );
createMenu( 4136, addId, -1 );
createMenu( 4037, addId, -1 );
createTool( separator(), addRemTb );
createTool( 4034, addRemTb );
createTool( 4035, addRemTb );
+ createTool( 4137, addRemTb );
createTool( 4036, addRemTb );
createTool( 4136, addRemTb );
createTool( 4037, addRemTb );
int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
setPreferenceProperty( exportgroup, "columns", 2 );
addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
- addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+ //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
setPreferenceProperty( computeGroup, "columns", 2 );
setPreferenceProperty( notifyMode, "indexes", indices );
int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
- setPreferenceProperty( infoGroup, "columns", 4 );
+ setPreferenceProperty( infoGroup, "columns", 2 );
int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
modes.clear();
modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
setPreferenceProperty( nodesLim, "max", 10000000 );
setPreferenceProperty( nodesLim, "step", 10000 );
setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
+ addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
+ addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
+ addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
+ addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
setPreferenceProperty( segGroup, "columns", 2 );
setPreferenceProperty( shrink, "min", 0 );
setPreferenceProperty( shrink, "max", 100 );
+ int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
+ setPreferenceProperty( numGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
+ addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
+
+ addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
+ addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
+
int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
setPreferenceProperty( orientGroup, "columns", 1 );
QString val = aResourceMgr->stringValue( "SMESH", name );
myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
}
+ else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
+ SMESH::UpdateFontProp( this );
+ }
+ else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
+ SMESH::UpdateFontProp( this );
+ }
if(aWarning.size() != 0){
aWarning += "The default values are applied instead.";
ip->setParameter(entry, param, modeStr.toLatin1().data());
// Colors
- vtkFloatingPointType r, g, b;
+ double r, g, b;
int delta;
aSmeshActor->GetSufaceColor(r, g, b, delta);
typedef struct {
int Id;
vtkIdType Orientation;
- vtkFloatingPointType Distance;
- vtkFloatingPointType Angle[2];
+ double Distance;
+ double Angle[2];
} TPlaneData;
typedef std::list<TPlaneData> TPlaneDataList;
typedef std::map<int, TPlaneDataList> TPlaneDataMap;
if (val != "Off") {
SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
double aDistance = vals[1].toFloat();
- vtkFloatingPointType anAngle[2];
+ double anAngle[2];
anAngle[0] = vals[2].toFloat();
anAngle[1] = vals[3].toFloat();
\param param parameter
\return identifier of preferences
*/
-int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
+int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
{
int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
setPreferenceProperty( tfont, "fonts", fam );
int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
+ if ( needSize ) f = f | QtxFontEdit::Size;
setPreferenceProperty( tfont, "features", f );
return tfont;
}
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;
+}