Issue 0019818: EDF 703 SMESH VISU : Display Mesh Groups names in viewer (as a caption)

This commit is contained in:
ouv 2009-05-27 12:05:48 +00:00
parent e85139c53f
commit 9df276244b
4 changed files with 35 additions and 6 deletions

View File

@ -1458,6 +1458,9 @@ vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
mySurfaceProp->SetColor(r,g,b); mySurfaceProp->SetColor(r,g,b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Face ||
aGroupObj->GetElementType() == SMDSAbs_Volume )
myNameActor->SetBackgroundColor(r,g,b); myNameActor->SetBackgroundColor(r,g,b);
Modified(); Modified();
} }
@ -1480,6 +1483,9 @@ void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,
myEdgeProp->SetColor(r,g,b); myEdgeProp->SetColor(r,g,b);
my1DProp->SetColor(r,g,b); my1DProp->SetColor(r,g,b);
my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b); my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Edge )
myNameActor->SetBackgroundColor(r,g,b);
Modified(); Modified();
} }
@ -1490,6 +1496,9 @@ void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType&
void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myNodeProp->SetColor(r,g,b); myNodeProp->SetColor(r,g,b);
myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b); myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Node )
myNameActor->SetBackgroundColor(r,g,b);
Modified(); Modified();
} }

View File

@ -748,6 +748,15 @@ bool SMESH_GroupObj::IsNodePrs() const
return myGroupServer->GetType() == SMESH::NODE; return myGroupServer->GetType() == SMESH::NODE;
} }
//=================================================================================
// function : GetElementType
// purpose : Return type of elements of group
//=================================================================================
SMDSAbs_ElementType SMESH_GroupObj::GetElementType() const
{
return SMDSAbs_ElementType(myGroupServer->GetType());
}
//================================================================================= //=================================================================================
// function : getNodesFromElems // function : getNodesFromElems
// purpose : Retrieve nodes from elements // purpose : Retrieve nodes from elements

View File

@ -168,6 +168,8 @@ public:
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const; virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
virtual bool IsNodePrs() const; virtual bool IsNodePrs() const;
virtual SMDSAbs_ElementType GetElementType() const;
private: private:
SMESH::SMESH_GroupBase_var myGroupServer; SMESH::SMESH_GroupBase_var myGroupServer;

View File

@ -727,11 +727,20 @@
SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject); SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
if( !aGroupObject->_is_nil() ) if( !aGroupObject->_is_nil() )
{ {
SALOMEDS::Color aColor; SMESH::ElementType anElementType = aGroupObject->GetType();
aColor.R = (float)color.red() / 255.0; QColor aColor;
aColor.G = (float)color.green() / 255.0; switch( anElementType )
aColor.B = (float)color.blue() / 255.0; {
aGroupObject->SetColor( aColor ); case SMESH::NODE: aColor = nodecolor; break;
case SMESH::EDGE: aColor = edgecolor; break;
default: aColor = color; break;
}
SALOMEDS::Color aGroupColor;
aGroupColor.R = (float)aColor.red() / 255.0;
aGroupColor.G = (float)aColor.green() / 255.0;
aGroupColor.B = (float)aColor.blue() / 255.0;
aGroupObject->SetColor( aGroupColor );
} }
delete aDlg; delete aDlg;