]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #555 - Make a number of shifted/rotated copies - selected object does not appea...
authornds <natalia.donis@opencascade.com>
Mon, 22 Jun 2015 11:03:45 +0000 (14:03 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 22 Jun 2015 11:03:45 +0000 (14:03 +0300)
It provides an infinite state for plane/axis shapes.

12 files changed:
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h
src/PartSet/PartSet_FilterInfinite.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index 8741df7dc16e0a359a3b5f8b545ae85d27f1b6f5..60b9833c35c7a9e4f45515aa940f4e41d6a05aa0 100644 (file)
@@ -53,7 +53,7 @@ void ConstructionPlugin_Axis::createAxisByTwoPoints()
       std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
       std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aShape2);
       if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) {
-        std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+        std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd, true);
 
         ResultConstructionPtr aConstr = document()->createConstruction(data());
         aConstr->setShape(anEdge);
@@ -96,7 +96,5 @@ bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObje
   isCustomized = thePrs->setLineStyle(3) || isCustomized;
   isCustomized = thePrs->setWidth(2) || isCustomized;
 
-  thePrs->setInfiniteState(true);
-
   return isCustomized;
 }
index 8c98c449c7e00649db5b8d681703c8d9b3db30bb..681926a68d3439c3235d0657e34e8bfa949167aa 100644 (file)
@@ -392,21 +392,6 @@ bool GeomAPI_AISObject::setLineStyle(int theStyle)
   return isChanged;
 }
 
-bool GeomAPI_AISObject::setInfiniteState(const bool theState)
-{
-  bool isChanged = false;
-  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
-  if (!anAIS.IsNull() && anAIS->IsInfinite() != theState) {
-    anAIS->SetInfiniteState(theState);
-    isChanged = true;
-
-    bool isInfinite = anAIS->IsInfinite();
-    int aValue = 9;
-  }
-  return isChanged;
-}
-
-
 bool GeomAPI_AISObject::setTransparensy(double theVal)
 {
   bool isChanged = false;
index 6652a4279b46d9a7007aa3936dedd0f2b7f91cc2..06bc2e9050705e5158656a341c5d1cbdf55627c2 100644 (file)
@@ -119,13 +119,6 @@ class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface
   /// \returns true if the object value differs from the current
   bool setLineStyle(int theStyle);
 
-  //! Sets the infinite state flag aFlage.
-  //! considered as infinite, i.e. its graphic presentations
-  //! are not taken in account for View FitAll...
-  //! \param theState a state
-  /// \returns true if the object value differs from the current
-  bool setInfiniteState(const bool theState);
-
   /// Set transparency of the presentation (theVal = 0 ... 1)
   /// \returns true if the object value differs from the current
   bool setTransparensy(double theVal);
index 0de55a60f36502506bd813eb21528fe3398daf64..fcf8dbb2be7716928915272dcb2fd5182c58687c 100644 (file)
@@ -18,7 +18,8 @@
 #include <gp_Circ.hxx>
 
 std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
-    std::shared_ptr<GeomAPI_Pnt> theStart, std::shared_ptr<GeomAPI_Pnt> theEnd)
+    std::shared_ptr<GeomAPI_Pnt> theStart, std::shared_ptr<GeomAPI_Pnt> theEnd,
+    const bool theInfinite)
 {
   const gp_Pnt& aStart = theStart->impl<gp_Pnt>();
   const gp_Pnt& anEnd = theEnd->impl<gp_Pnt>();
@@ -30,6 +31,8 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
   BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
   std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  if (theInfinite)
+    anEdge.Infinite(Standard_True);
   aRes->setImpl(new TopoDS_Shape(anEdge));
   return aRes;
 }
@@ -60,6 +63,8 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::cylinderAxis(
   BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
   std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  // an axis is an infinite object
+  anEdge.Infinite(Standard_True);
   aRes->setImpl(new TopoDS_Shape(anEdge));
   return aRes;
 }
index 0bd67621bc66ffeeb8b0b286949902e7a87f9dfe..1de252482a5414598ace8332c6646ad6bf3dee7b 100644 (file)
 class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder
 {
  public:
-  /// Creates linear edge by two points
+  /// Creates linear edge by two points.
+  /// \param theStart a first point of an edge
+  /// \param theEnd an end point of an edge
+  /// \param theInfinite if true, the shape of the edge is infinite. It is used for axis edge.
   static std::shared_ptr<GeomAPI_Edge> line(std::shared_ptr<GeomAPI_Pnt> theStart,
-                                            std::shared_ptr<GeomAPI_Pnt> theEnd);
-  /// Creates edge - axis of the given cylindrical face
+                                            std::shared_ptr<GeomAPI_Pnt> theEnd,
+                                            const bool theInfinite = false);
+  /// Creates edge - axis of the given cylindrical face. The result axis edge is infinite
   static std::shared_ptr<GeomAPI_Edge> cylinderAxis(
     std::shared_ptr<GeomAPI_Shape> theCylindricalFace);
 
index c197873082d41d554107f2006be01495ce820bd6..9e687d6d296aa65d1b726313f7338747d5cecaab 100644 (file)
@@ -31,14 +31,18 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
 
 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
     std::shared_ptr<GeomAPI_Pln> thePlane,
-    const double theSize)
+    const double theSize,
+    const bool theInfinite)
 {
   // half of the size in each direction from the center
   BRepBuilderAPI_MakeFace aFaceBuilder(thePlane->impl<gp_Pln>(),
                                        -theSize / 2., theSize / 2.,
                                        -theSize / 2., theSize / 2.);
   std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
-  aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
+  TopoDS_Shape aFace = aFaceBuilder.Face();
+  if (theInfinite)
+    aFace.Infinite(Standard_True);
+  aRes->setImpl(new TopoDS_Shape(aFace/*aFaceBuilder.Face()*/));
   return aRes;
 }
 
index 49ec19c3084da7dea685cc74fd7bcfd497f60111..7b68fadcbb3f8548e84170e7d3b578632e659ec2 100644 (file)
@@ -30,7 +30,8 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_FaceBuilder
   /// Creates square planar face by given point of the center,
   /// normal to the plane and size of square
   static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pln> thePlane,
-                                               const double theSize);
+                                               const double theSize,
+                                               const bool theInfinite = false);
 
   /// Returns the plane of the planar face. If it is not planar, returns empty ptr.
   static std::shared_ptr<GeomAPI_Pln> plane(std::shared_ptr<GeomAPI_Shape> theFace);
index 28f6795504dae192cf0e85178db55c7a3f93851a..015701265747e0b6bd397b2a482c2bda04737861 100755 (executable)
@@ -7,16 +7,39 @@
 #include "PartSet_FilterInfinite.h"
 
 #include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <StdSelect_BRepOwner.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(PartSet_FilterInfinite, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(PartSet_FilterInfinite, SelectMgr_Filter);
 
 Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  Standard_Boolean aValid = Standard_True;
   Handle(AIS_InteractiveObject) anAISObj =
     Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-  if (!anAISObj.IsNull() && anAISObj->IsInfinite()) {
-    return Standard_False;
+  if (!anAISObj.IsNull()) {
+    Handle(AIS_InteractiveObject) anObj = 
+        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anObj);
+    if (!aAISShape.IsNull()) {
+      TopoDS_Shape anAISShape = aAISShape->Shape();
+      if (!anAISShape.IsNull() && anAISShape.Infinite()) {
+        aValid = Standard_False;
+        // for infinite object, the selection is possible only for shapes of owners, which are coincide
+        // to the shape of corresponded AIS object. In other words, for axis, only edge can be selected
+        // (vertices are not selectable), for planes, only faces can be selected (not edges or vertices)
+        TopoDS_Shape anOwnerShape;
+        Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+        if( !aBRO.IsNull() ) {
+          anOwnerShape = aBRO->Shape();
+          if (!anOwnerShape.IsNull()) {
+            aValid = anAISShape.ShapeType() == anOwnerShape.ShapeType();
+          }
+        }
+      }
+    }
   }
-  return Standard_True;
+  return aValid;
 }
index 6939718d0803198f78e1f150618cc66fd3d34da8..c5852a61c4d974688676604aa76afec5b3f9779e 100644 (file)
@@ -127,12 +127,18 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
+
+  if (myFilterInfinite.IsNull())
+    myFilterInfinite = new PartSet_FilterInfinite();
+  myWorkshop->viewer()->addSelectionFilter(myFilterInfinite);
 }
 
 PartSet_Module::~PartSet_Module()
 {
   if (!myDocumentShapeFilter.IsNull())
     myDocumentShapeFilter.Nullify();
+  if (!myFilterInfinite.IsNull())
+    myFilterInfinite.Nullify();
 }
 
 void PartSet_Module::registerValidators()
index d711f072e7ebc27372e2fb669f328998bfb7bf85..f4b2b978cba07dc2308d29a4f2f6ed2cd4135b71 100644 (file)
@@ -6,6 +6,7 @@
 #include "PartSet.h"
 #include "PartSet_Filters.h"
 #include "PartSet_DocumentDataModel.h"
+#include "PartSet_FilterInfinite.h"
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
@@ -210,6 +211,7 @@ protected slots:
 
   /// A filter which provides selection within a current document or whole PartSet
   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
+  Handle(PartSet_FilterInfinite) myFilterInfinite;
 
   PartSet_SketcherMgr* mySketchMgr;
 
index b1d45d56fe5ad54f1b2fef14617ea0af3a4c7c1c..216df94a9fcae8b5e082a57e2cd85f2f00c01708 100644 (file)
@@ -157,9 +157,6 @@ PartSet_SketcherMgr::~PartSet_SketcherMgr()
 {
   if (!myPlaneFilter.IsNull())
     myPlaneFilter.Nullify();
-  if (!myFilterInfinite.IsNull())
-    myFilterInfinite.Nullify();
-
 }
 
 void PartSet_SketcherMgr::onEnterViewPort()
@@ -718,11 +715,7 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   if (myPlaneFilter.IsNull()) 
     myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
 
-  if (myFilterInfinite.IsNull())
-    myFilterInfinite = new PartSet_FilterInfinite();
-
   myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
-  myModule->workshop()->viewer()->addSelectionFilter(myFilterInfinite);
 
   bool aHasPlane = false;
   if (theOperation->isEditOperation()) {
@@ -755,7 +748,6 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
     // The sketch was aborted
     myCurrentSketch = CompositeFeaturePtr();
     myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
-    myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
 
     // Erase all sketcher objects
     QStringList aSketchIds = sketchOperationIdList();
@@ -787,7 +779,6 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
     
   myCurrentSketch = CompositeFeaturePtr();
   myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
-  myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
 
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   }
index e0a9e06f5debcc6bc90a26d7b9431783d6eb4bbc..973924a3e0d7a5e8702d16dde6700e2d4a786e86 100644 (file)
@@ -9,8 +9,6 @@
 
 #include "PartSet.h"
 
-#include "PartSet_FilterInfinite.h"
-
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_CompositeFeature.h>
@@ -285,7 +283,6 @@ private:
   CompositeFeaturePtr myCurrentSketch;
 
   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
-  Handle(PartSet_FilterInfinite) myFilterInfinite;
   FeatureToSelectionMap myCurrentSelection;
   bool myPreviousUpdateViewerEnabled;