Additional improvement for the issue 0020985 (handling point marker of the compound of vertices)

This commit is contained in:
vsr 2010-10-01 13:54:22 +00:00
parent d47a7b9c3a
commit decdafe51b
4 changed files with 72 additions and 7 deletions

View File

@ -98,6 +98,8 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const
return QVariant( hasHiddenChildren( ind ) );
else if ( p == "hasShownChildren" )
return QVariant( hasShownChildren( ind ) );
else if ( p == "compoundOfVertices" )
return QVariant( compoundOfVertices( ind ) );
else
return LightApp_Selection::parameter( ind, p );
}
@ -274,6 +276,29 @@ bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
return exp;
}
bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
{
bool ret = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
(SUIT_Session::session()->activeApplication()->activeStudy());
if ( appStudy && !CORBA::is_nil( obj ) && obj->GetShapeType() == GEOM::COMPOUND ) {
GEOM::GEOM_IMeasureOperations_var anOper = GeometryGUI::GetGeomGen()->GetIMeasureOperations( appStudy->id() );
QString whatIs = anOper->WhatIs( obj );
QStringList data = whatIs.split( "\n", QString::SkipEmptyParts );
int nbVertices = 0, nbCompounds = 0, nbOther = 0;
foreach ( QString s, data ) {
QString type = s.section( ":", 0, 0 ).trimmed().toLower();
int cnt = s.section( ":", 1, 1 ).trimmed().toInt();
if ( type == "vertex" ) nbVertices += cnt;
else if ( type == "compound" ) nbCompounds += cnt;
else if ( type != "shape" ) nbOther += cnt;
}
ret = nbVertices > 0 && nbCompounds == 1 && nbOther == 0;
anOper->Destroy();
}
return ret;
}
bool GEOMGUI_Selection::hasHiddenChildren( const int index ) const
{
bool OK = false;
@ -310,6 +335,11 @@ bool GEOMGUI_Selection::hasShownChildren( const int index ) const
return OK;
}
bool GEOMGUI_Selection::compoundOfVertices( const int index ) const
{
return isCompoundOfVertices( getObject( index ) );
}
bool GEOMGUI_Selection::isComponent( const int index ) const
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>

View File

@ -48,6 +48,10 @@ public:
virtual bool processOwner( const LightApp_DataOwner* );
static bool hasChildren( const _PTR(SObject)& );
static bool expandable( const _PTR(SObject)& );
static bool isCompoundOfVertices( GEOM::GEOM_Object_ptr );
private:
bool isVisible( const int ) const;
bool isAutoColor( const int ) const;
@ -58,9 +62,7 @@ private:
bool isVectorsMode( const int ) const;
bool hasHiddenChildren( const int ) const;
bool hasShownChildren( const int ) const;
static bool hasChildren( const _PTR(SObject)& );
static bool expandable( const _PTR(SObject)& );
bool compoundOfVertices( const int ) const;
bool isComponent( const int ) const;
GEOM::GEOM_Object_ptr getObject( const int ) const;

View File

@ -81,6 +81,9 @@
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TopoDS_Iterator.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
// VTK Includes
#include <vtkActorCollection.h>
@ -126,6 +129,36 @@ static inline int getTopAbsMode( const int implType )
}
}
static bool isCompoundOfVertices( const TopoDS_Shape& theShape )
{
bool ret = false;
if ( !theShape.IsNull() ) {
int iType, nbTypes [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)
nbTypes[iType] = 0;
nbTypes[theShape.ShapeType()]++;
TopTools_MapOfShape aMapOfShape;
aMapOfShape.Add(theShape);
TopTools_ListOfShape aListOfShape;
aListOfShape.Append(theShape);
TopTools_ListIteratorOfListOfShape itL (aListOfShape);
for (; itL.More(); itL.Next()) {
TopoDS_Iterator it (itL.Value());
for (; it.More(); it.Next()) {
TopoDS_Shape s = it.Value();
if (aMapOfShape.Add(s)) {
aListOfShape.Append(s);
nbTypes[s.ShapeType()]++;
}
}
}
ret = nbTypes[TopAbs_VERTEX] > 0 && nbTypes[TopAbs_COMPOUND] == 1;
}
return ret;
}
//================================================================
// Function : getFilter
// Purpose : Get filter corresponding to the type of object
@ -579,7 +612,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
if ( myShape.ShapeType() == TopAbs_VERTEX )
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
{
anAspect->SetScale( myScaleOfMarker );
anAspect->SetTypeOfMarker( myTypeOfMarker );
@ -588,7 +621,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
}
else
{
if ( myShape.ShapeType() == TopAbs_VERTEX )
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
{
col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
aColor = SalomeApp_Tools::color( col );
@ -727,7 +760,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
AISShape->SetColor( aQuanColor );
AISShape->SetShadingColor( aQuanColor );
if ( myShape.ShapeType() == TopAbs_VERTEX ) {
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) ) {
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
anAspect->SetColor( aQuanColor );
anAspect->SetScale( myScaleOfMarker );

View File

@ -1121,7 +1121,7 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1 %2}" ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );