]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #555 Make a number of shifted/rotated copies - selected object does not appear...
authornds <natalia.donis@opencascade.com>
Fri, 19 Jun 2015 05:29:34 +0000 (08:29 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 19 Jun 2015 05:29:34 +0000 (08:29 +0300)
Using infinite state to do not select inifinte objects(construction plane, axis).

src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_FilterInfinite.cpp [new file with mode: 0755]
src/PartSet/PartSet_FilterInfinite.h [new file with mode: 0755]
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index e97fba83eae285e28d621f9593b5f79eb0d82d59..8741df7dc16e0a359a3b5f8b545ae85d27f1b6f5 100644 (file)
@@ -96,5 +96,7 @@ bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObje
   isCustomized = thePrs->setLineStyle(3) || isCustomized;
   isCustomized = thePrs->setWidth(2) || isCustomized;
 
+  thePrs->setInfiniteState(true);
+
   return isCustomized;
 }
index c09d9a421d56aac93ae942bcebacaaeb72cae8d2..8c98c449c7e00649db5b8d681703c8d9b3db30bb 100644 (file)
@@ -392,6 +392,20 @@ 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)
 {
index 06bc2e9050705e5158656a341c5d1cbdf55627c2..6652a4279b46d9a7007aa3936dedd0f2b7f91cc2 100644 (file)
@@ -119,6 +119,13 @@ 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 5a243ebfbb32664d6ea5ff4321b4bfc5ebb0e6a4..8148df0a0eaedb6393f17694850f2fb6d5cd7e73 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetShapeSelector.h
        PartSet_WidgetFileSelector.h
        PartSet_Filters.h
+       PartSet_FilterInfinite.h
        PartSet_SketcherMgr.h
        PartSet_MenuMgr.h
     PartSet_DocumentDataModel.h
@@ -42,6 +43,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetShapeSelector.cpp
        PartSet_WidgetFileSelector.cpp
        PartSet_Filters.cpp
+       PartSet_FilterInfinite.cpp
        PartSet_SketcherMgr.cpp
        PartSet_MenuMgr.cpp
     PartSet_DocumentDataModel.cpp
diff --git a/src/PartSet/PartSet_FilterInfinite.cpp b/src/PartSet/PartSet_FilterInfinite.cpp
new file mode 100755 (executable)
index 0000000..28f6795
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Filters.cpp
+// Created:     19 Jun 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "PartSet_FilterInfinite.h"
+
+#include <AIS_InteractiveObject.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
+{
+  Handle(AIS_InteractiveObject) anAISObj =
+    Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+  if (!anAISObj.IsNull() && anAISObj->IsInfinite()) {
+    return Standard_False;
+  }
+  return Standard_True;
+}
diff --git a/src/PartSet/PartSet_FilterInfinite.h b/src/PartSet/PartSet_FilterInfinite.h
new file mode 100755 (executable)
index 0000000..8fe5305
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Filters.h
+// Created:     19 Jun 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_FilterInfinite_H
+#define PartSet_FilterInfinite_H
+
+#include <ModuleBase_ViewerFilters.h>
+
+#include <SelectMgr_Filter.hxx>
+
+/**
+* \class PartSet_FilterInfinite
+* \ingroup Modules
+* A class which filters AIS objects with the true infinite state
+*/
+DEFINE_STANDARD_HANDLE(PartSet_FilterInfinite, SelectMgr_Filter);
+class PartSet_FilterInfinite : public SelectMgr_Filter
+{
+public:
+  /// Constructor
+  /// \param theWorkshop a pointer to workshop
+  PartSet_FilterInfinite()
+    : SelectMgr_Filter() {}
+
+  /// Returns True if selected presentation can be selected
+  /// \param theOwner an owner of the persentation
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(PartSet_FilterInfinite)
+};
+
+#endif
\ No newline at end of file
index caf3218825096d347e4b7def4495a68105ef09dd..b1d45d56fe5ad54f1b2fef14617ea0af3a4c7c1c 100644 (file)
@@ -157,6 +157,9 @@ PartSet_SketcherMgr::~PartSet_SketcherMgr()
 {
   if (!myPlaneFilter.IsNull())
     myPlaneFilter.Nullify();
+  if (!myFilterInfinite.IsNull())
+    myFilterInfinite.Nullify();
+
 }
 
 void PartSet_SketcherMgr::onEnterViewPort()
@@ -298,7 +301,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
   if (aOperation && aOperation->isEditOperation()) {
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
     ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
-    // If the current widget is a selector, do do nothing, it processes the mouse press
+    // If the current widget is a selector, do nothing, it processes the mouse press
     if(aActiveWgt && aActiveWgt->isViewerSelector()) {
       return;
     }
@@ -715,7 +718,12 @@ 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()) {
     // If it is editing of sketch then it means that plane is already defined
@@ -747,6 +755,7 @@ 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();
@@ -778,6 +787,8 @@ 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));
   }
   // restore the module selection modes, which were changed on startSketch
index 973924a3e0d7a5e8702d16dde6700e2d4a786e86..e0a9e06f5debcc6bc90a26d7b9431783d6eb4bbc 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "PartSet.h"
 
+#include "PartSet_FilterInfinite.h"
+
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_CompositeFeature.h>
@@ -283,6 +285,7 @@ private:
   CompositeFeaturePtr myCurrentSketch;
 
   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
+  Handle(PartSet_FilterInfinite) myFilterInfinite;
   FeatureToSelectionMap myCurrentSelection;
   bool myPreviousUpdateViewerEnabled;