Salome HOME
Additional improvement for the issue 0020985 (handling point marker of the compound...
authorvsr <vsr@opencascade.com>
Fri, 1 Oct 2010 13:54:22 +0000 (13:54 +0000)
committervsr <vsr@opencascade.com>
Fri, 1 Oct 2010 13:54:22 +0000 (13:54 +0000)
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GeometryGUI.cxx

index e30f447a98b12b114d02b300cc5591499b8726bf..f4aeb8ccfec76545ed58681fcbc389bf00cfee68 100644 (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*>
index e6cb762e8b2e44562a79218b2f7c7f47a661650c..9911ad4dfa34bd1af28fc2a92c9fd866c62a2899 100644 (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;
index 82853c712ff04441591de18bf7fd9352b4790a13..3196289e5fb2b854a5e38850812ab4f6c0438131 100644 (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 );
index 740792c7b4f6c7f8ed58de511c2ddee5919ef781..3ee06d2df0446cf0429fa66da9abdc63f5048206 100644 (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 );