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 );
}
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;
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*>
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;
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;
#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>
}
}
+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
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 );
}
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 );
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 );
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 );