]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
It should not be possible to use the circle/arc line in the distance operation.
authornds <natalia.donis@opencascade.com>
Mon, 12 Jan 2015 08:29:43 +0000 (11:29 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 12 Jan 2015 08:29:43 +0000 (11:29 +0300)
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_FilterMulti.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterMulti.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterShapeType.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterShapeType.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/SketchPlugin/plugin-Sketch.xml

index a7d3cc5007cc72490c14671c837df19b9d793ec2..149ae47970144176f6e8d610b843808e4009e629 100644 (file)
@@ -9,6 +9,8 @@ SET(PROJECT_HEADERS
        ModuleBase_FilterFace.h
        ModuleBase_FilterFactory.h
        ModuleBase_FilterLinearEdge.h
+    ModuleBase_FilterMulti.h
+    ModuleBase_FilterShapeType.h
        ModuleBase_Tools.h
        ModuleBase_IModule.h
        ModuleBase_Operation.h
@@ -45,6 +47,8 @@ SET(PROJECT_SOURCES
        ModuleBase_FilterFace.cpp
        ModuleBase_FilterFactory.cpp
        ModuleBase_FilterLinearEdge.cpp
+    ModuleBase_FilterMulti.cpp
+    ModuleBase_FilterShapeType.cpp
        ModuleBase_Tools.cpp
        ModuleBase_IModule.cpp
        ModuleBase_IWorkshop.cpp
diff --git a/src/ModuleBase/ModuleBase_FilterMulti.cpp b/src/ModuleBase/ModuleBase_FilterMulti.cpp
new file mode 100644 (file)
index 0000000..6fcab0a
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterMulti.cpp
+// Created:     12 Jan 2015
+// Author:      Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterMulti.h"
+
+#include "ModuleBase_FilterLinearEdge.h"
+#include "ModuleBase_FilterShapeType.h"
+
+#include <SelectMgr_OrFilter.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+ModuleBase_Filter* ModuleBase_FilterMulti::findFilter(const std::string& theType)
+{
+  ModuleBase_Filter* aFilter = 0;
+
+  if (theType == "line") {
+    aFilter = new ModuleBase_FilterLinearEdge();
+    std::list<std::string> anArguments;
+    anArguments.push_back(theType);
+    aFilter->setArguments(anArguments);
+  }
+  if (theType == "vertex") {
+    aFilter = new ModuleBase_FilterShapeType();
+    std::list<std::string> anArguments;
+    anArguments.push_back(theType);
+    aFilter->setArguments(anArguments);
+  }
+
+  return aFilter;
+}
+
+void ModuleBase_FilterMulti::createFilter()
+{
+  myFilter = new SelectMgr_OrFilter();
+
+  // set filter arguments
+  Handle(SelectMgr_OrFilter) anOrFilter = Handle(SelectMgr_OrFilter)::DownCast(myFilter);
+  if (anOrFilter.IsNull())
+    return;
+
+  std::list<std::string>::const_iterator anIt = myArguments.begin(),
+                                         aLast = myArguments.end();
+  for (; anIt != aLast; ++anIt) {
+    std::string aType = *anIt;
+    ModuleBase_Filter* aFilter = findFilter(aType);
+    if (aFilter) {
+      anOrFilter->Add(aFilter->getFilter());
+    }
+  }
+}
+
+void ModuleBase_FilterMulti::setArguments(const std::list<std::string>& theArguments)
+{
+  myArguments.clear();
+  myArguments = theArguments;
+}
diff --git a/src/ModuleBase/ModuleBase_FilterMulti.h b/src/ModuleBase/ModuleBase_FilterMulti.h
new file mode 100644 (file)
index 0000000..e7ba0f1
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterMulti.h
+// Created:     12 Jan 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterMulti_H
+#define ModuleBase_FilterMulti_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfFace.hxx>
+
+class ModuleBase_FilterMulti: public ModuleBase_Filter
+{
+  /**
+   * Creates a new filter according to the given type
+   * It is only for internal use.
+   * This class creates the sub-filters now. It is possible to use the filter factory for this.
+   * \param theType a type of the created filter
+   */
+  ModuleBase_Filter* findFilter(const std::string& theType);
+  
+public:
+  MODULEBASE_EXPORT ModuleBase_FilterMulti(): 
+      ModuleBase_Filter() {}
+
+  /**
+   * Sets the arguments to the filter.
+   * \param theArguments a list of arguments
+   */
+  MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+  /**
+   * It creates an OCC face filter
+   */
+  virtual void createFilter();
+
+protected:
+  std::list<std::string> myArguments; /// the filter arguments
+};
+
+#endif //ModuleBase_FilterMulti
diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.cpp b/src/ModuleBase/ModuleBase_FilterShapeType.cpp
new file mode 100644 (file)
index 0000000..2b981f7
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterShapeType.cpp
+// Created:     12 Jan 2015
+// Author:      Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterShapeType.h"
+
+#include <StdSelect_ShapeTypeFilter.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+typedef QMap<QString, TopAbs_ShapeEnum> FaceTypes;
+static FaceTypes MyShapeTypes;
+
+TopAbs_ShapeEnum ModuleBase_FilterShapeType::shapeType(const std::string& theType)
+{
+  if (MyShapeTypes.count() == 0) {
+    MyShapeTypes["vertex"] = TopAbs_VERTEX;
+  }
+  QString aType = QString(theType.c_str()).toLower();
+  if (MyShapeTypes.contains(aType))
+    return MyShapeTypes[aType];
+  Events_Error::send("Shape type defined in XML is not implemented!");
+  return TopAbs_SHAPE;
+}
+
+ModuleBase_FilterShapeType::ModuleBase_FilterShapeType()
+: ModuleBase_Filter(), myShapeType(TopAbs_SHAPE)
+{
+}
+
+void ModuleBase_FilterShapeType::createFilter()
+{
+  myFilter = new StdSelect_ShapeTypeFilter(myShapeType);
+}
+
+void ModuleBase_FilterShapeType::setArguments(const std::list<std::string>& theArguments)
+{
+  if (theArguments.size()!= 1)
+    return;
+  myShapeType = shapeType(theArguments.front());
+}
diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.h b/src/ModuleBase/ModuleBase_FilterShapeType.h
new file mode 100644 (file)
index 0000000..2b20a29
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterShapeType.h
+// Created:     12 Jan 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterShapeType_H
+#define ModuleBase_FilterShapeType_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfFace.hxx>
+
+class ModuleBase_FilterShapeType: public ModuleBase_Filter
+{
+public:
+  static MODULEBASE_EXPORT TopAbs_ShapeEnum shapeType(const std::string& theType);
+
+  MODULEBASE_EXPORT ModuleBase_FilterShapeType();
+
+  /**
+   * Sets the arguments to the filter.
+   * \param theArguments a list of arguments
+   */
+  MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+  /**
+   * It creates an OCC face filter
+   */
+  virtual void createFilter();
+
+private:
+  TopAbs_ShapeEnum myShapeType; /// the shape type of the filter
+};
+
+#endif //ModuleBase_FilterShapeType
index 9714f41a54fd2fc31dcf91f8146006516d36a403..d5f96e489e9d191e8fed9c98b59fe79e9642ca0c 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModuleBase_FilterFactory.h>
 #include <ModuleBase_FilterLinearEdge.h>
 #include <ModuleBase_FilterFace.h>
+#include <ModuleBase_FilterMulti.h>
 
 
 #include <ModelAPI_Object.h>
@@ -124,6 +125,7 @@ void PartSet_Module::registerFilters()
 
   aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
   aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
+  aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti);
 }
 
 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
index e8dce9b054fda73c96867dd59382767aff957152..7937a60c337249dc43e58308367d78e723b3951f 100644 (file)
@@ -530,6 +530,9 @@ void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
         continue;
       Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(
                                                                         aBRepOwner->Selectable());
+      if (anIO != anAISIO)
+        continue;
+
       if (aBRepOwner->HasShape()) {
         const TopoDS_Shape& aShape = aBRepOwner->Shape();
         TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
@@ -552,8 +555,6 @@ void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
 void PartSet_SketcherMgr::getSelectionOwners(const FeaturePtr& theFeature,
                                              const FeaturePtr& theSketch,
                                              ModuleBase_IWorkshop* theWorkshop,
-                                             //const std::set<AttributePtr>& theSelectedAttributes,
-                                             //const std::set<ResultPtr>& theSelectedResults,
                                              const FeatureToSelectionMap& theSelection,
                                              SelectMgr_IndexedMapOfOwner& anOwnersToSelect)
 {
index e249eb240afe69ca42eb6e953d2fe700b1f9eb35..712efa2829f58bd02cb97d496634e4821582890c 100644 (file)
         tooltip="Set fixed distance from a point to an object"
         icon=":icons/distance.png">
         <label title="Select objects for distance definition. Following objects can be accepted: point, line or arc end point, center of circle or arc."/>
-               <sketch_shape_selector 
-          id="ConstraintEntityA" 
-          label="First object" 
-          tooltip="Select point, line end point, line, center of circle or arc."
-          shape_types="edge vertex"/>
+        <sketch_shape_selector
+              id="ConstraintEntityA"
+              label="First object"
+              tooltip="Select point, line end point, line, center of circle or arc."
+              shape_types="edge vertex">
+          <selection_filter id="MultiFilter" parameters="line,vertex"/>
+        </sketch_shape_selector>/>
                <sketch_shape_selector 
           id="ConstraintEntityB" 
           label="Last object" 
           tooltip="Select point, line end point, line, center of circle or arc." 
                            shape_types="edge vertex">
                        <validator id="SketchPlugin_DifferentObjects"/>
-               </sketch_shape_selector>
+      <selection_filter id="MultiFilter" parameters="line,vertex"/>
+    </sketch_shape_selector>
                
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>