mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-15 08:40:33 +05:00
Additional improvement for the issue 0020985 (handling point marker of the compound of vertices)
This commit is contained in:
parent
d47a7b9c3a
commit
decdafe51b
@ -98,6 +98,8 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const
|
|||||||
return QVariant( hasHiddenChildren( ind ) );
|
return QVariant( hasHiddenChildren( ind ) );
|
||||||
else if ( p == "hasShownChildren" )
|
else if ( p == "hasShownChildren" )
|
||||||
return QVariant( hasShownChildren( ind ) );
|
return QVariant( hasShownChildren( ind ) );
|
||||||
|
else if ( p == "compoundOfVertices" )
|
||||||
|
return QVariant( compoundOfVertices( ind ) );
|
||||||
else
|
else
|
||||||
return LightApp_Selection::parameter( ind, p );
|
return LightApp_Selection::parameter( ind, p );
|
||||||
}
|
}
|
||||||
@ -274,6 +276,29 @@ bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
|
|||||||
return exp;
|
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 GEOMGUI_Selection::hasHiddenChildren( const int index ) const
|
||||||
{
|
{
|
||||||
bool OK = false;
|
bool OK = false;
|
||||||
@ -310,6 +335,11 @@ bool GEOMGUI_Selection::hasShownChildren( const int index ) const
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GEOMGUI_Selection::compoundOfVertices( const int index ) const
|
||||||
|
{
|
||||||
|
return isCompoundOfVertices( getObject( index ) );
|
||||||
|
}
|
||||||
|
|
||||||
bool GEOMGUI_Selection::isComponent( const int index ) const
|
bool GEOMGUI_Selection::isComponent( const int index ) const
|
||||||
{
|
{
|
||||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
|
||||||
|
@ -48,6 +48,10 @@ public:
|
|||||||
|
|
||||||
virtual bool processOwner( const LightApp_DataOwner* );
|
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:
|
private:
|
||||||
bool isVisible( const int ) const;
|
bool isVisible( const int ) const;
|
||||||
bool isAutoColor( const int ) const;
|
bool isAutoColor( const int ) const;
|
||||||
@ -58,9 +62,7 @@ private:
|
|||||||
bool isVectorsMode( const int ) const;
|
bool isVectorsMode( const int ) const;
|
||||||
bool hasHiddenChildren( const int ) const;
|
bool hasHiddenChildren( const int ) const;
|
||||||
bool hasShownChildren( const int ) const;
|
bool hasShownChildren( const int ) const;
|
||||||
|
bool compoundOfVertices( const int ) const;
|
||||||
static bool hasChildren( const _PTR(SObject)& );
|
|
||||||
static bool expandable( const _PTR(SObject)& );
|
|
||||||
|
|
||||||
bool isComponent( const int ) const;
|
bool isComponent( const int ) const;
|
||||||
GEOM::GEOM_Object_ptr getObject( const int ) const;
|
GEOM::GEOM_Object_ptr getObject( const int ) const;
|
||||||
|
@ -81,6 +81,9 @@
|
|||||||
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
||||||
#include <TopoDS_Iterator.hxx>
|
#include <TopoDS_Iterator.hxx>
|
||||||
#include <Graphic3d_AspectMarker3d.hxx>
|
#include <Graphic3d_AspectMarker3d.hxx>
|
||||||
|
#include <TopTools_MapOfShape.hxx>
|
||||||
|
#include <TopTools_ListOfShape.hxx>
|
||||||
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
|
||||||
// VTK Includes
|
// VTK Includes
|
||||||
#include <vtkActorCollection.h>
|
#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
|
// Function : getFilter
|
||||||
// Purpose : Get filter corresponding to the type of object
|
// 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() );
|
AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
|
||||||
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
|
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
|
||||||
anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
|
anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
|
||||||
if ( myShape.ShapeType() == TopAbs_VERTEX )
|
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
|
||||||
{
|
{
|
||||||
anAspect->SetScale( myScaleOfMarker );
|
anAspect->SetScale( myScaleOfMarker );
|
||||||
anAspect->SetTypeOfMarker( myTypeOfMarker );
|
anAspect->SetTypeOfMarker( myTypeOfMarker );
|
||||||
@ -588,7 +621,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( myShape.ShapeType() == TopAbs_VERTEX )
|
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
|
||||||
{
|
{
|
||||||
col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
|
col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
|
||||||
aColor = SalomeApp_Tools::color( col );
|
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 );
|
Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
|
||||||
AISShape->SetColor( aQuanColor );
|
AISShape->SetColor( aQuanColor );
|
||||||
AISShape->SetShadingColor( aQuanColor );
|
AISShape->SetShadingColor( aQuanColor );
|
||||||
if ( myShape.ShapeType() == TopAbs_VERTEX ) {
|
if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) ) {
|
||||||
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
|
Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
|
||||||
anAspect->SetColor( aQuanColor );
|
anAspect->SetColor( aQuanColor );
|
||||||
anAspect->SetScale( myScaleOfMarker );
|
anAspect->SetScale( myScaleOfMarker );
|
||||||
|
@ -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->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
|
||||||
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
|
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}" ).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( separator(), -1, -1 ); // -----------
|
||||||
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
|
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
|
||||||
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
|
||||||
|
Loading…
Reference in New Issue
Block a user