]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
curveCreator :: allow selection of points of selected polyline(s) only
authorisn <isn@opencascade.com>
Wed, 9 Jan 2019 17:32:28 +0000 (20:32 +0300)
committerisn <isn@opencascade.com>
Fri, 11 Jan 2019 12:11:23 +0000 (15:11 +0300)
src/CurveCreator/CMakeLists.txt
src/CurveCreator/CurveCreator_Curve.cxx
src/CurveCreator/CurveCreator_Curve.hxx
src/CurveCreator/CurveCreator_Displayer.hxx
src/CurveCreator/CurveCreator_ShapeFilter.cxx [new file with mode: 0644]
src/CurveCreator/CurveCreator_ShapeFilter.hxx [new file with mode: 0644]
src/CurveCreator/CurveCreator_Utils.cxx
src/CurveCreator/CurveCreator_Utils.hxx
src/CurveCreator/CurveCreator_UtilsICurve.cxx
src/CurveCreator/CurveCreator_Widget.cxx

index ca96258752ed0421926720a85088767e661edf88..3263a1ca2fbb918fdb674a16d9779c3b300e3bce 100644 (file)
@@ -26,7 +26,7 @@ ENDIF(SALOME_BUILD_GUI)
 # additional include directories
 INCLUDE_DIRECTORIES(
   ${PTHREAD_INCLUDE_DIR}
-  ${OpenCASCADE_INCLUDE_DIR}
+  ${CAS_INCLUDE_DIRS}
   ${KERNEL_INCLUDE_DIRS}
   ${GUI_INCLUDE_DIRS}
   ${PROJECT_SOURCE_DIR}/src/GEOMUtils
@@ -34,12 +34,15 @@ INCLUDE_DIRECTORIES(
 
 # additional preprocessor / compiler flags
 ADD_DEFINITIONS(
+  ${CAS_DEFINITIONS}
   ${OpenCASCADE_DEFINITIONS}
   ${QT_DEFINITIONS}
 )
 
 # libraries to link to
 SET(_link_LIBRARIES
+  ${CAS_KERNEL}
+  ${CAS_TKernel}
   GEOMUtils
 )
 IF(SALOME_BUILD_GUI)
@@ -66,6 +69,7 @@ ENDIF(SALOME_BUILD_GUI)
 SET(_other_HEADERS
   CurveCreator.hxx
   CurveCreator_Curve.hxx
+  CurveCreator_ShapeFilter.hxx
   CurveCreator_Diff.hxx
   CurveCreator_Displayer.hxx
   CurveCreator_ICurve.hxx
@@ -92,6 +96,7 @@ SET(_other_SOURCES
   CurveCreator_Curve.cxx
   CurveCreator_Diff.cxx
   CurveCreator_Displayer.cxx
+  CurveCreator_ShapeFilter.cxx
   CurveCreator_Operation.cxx
   CurveCreator_Section.cxx
   CurveCreator_Utils.cxx
index 3408e49a9c2724de7a5b1a90dee693dd91c60cf8..ca421ef79f05c0bc07375b7572522e73617a297b 100644 (file)
@@ -36,6 +36,7 @@
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
 #include <AIS_ColoredShape.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <iostream>
@@ -1067,21 +1068,22 @@ void CurveCreator_Curve::constructAISObject()
 {
   //DEBTRACE("constructAISObject");
   TopoDS_Shape aShape;
-  std::map<CurveCreator_Section*, TopoDS_Shape> Sect2Wire;
-  CurveCreator_Utils::constructShape( this, aShape, &Sect2Wire );
+  mySect2Wire.Clear();
+  CurveCreator_Utils::constructShape( this, aShape, &mySect2Wire );
   myAISShape = new AIS_ColoredShape( aShape ); 
   AIS_ColoredShape* AISColoredShape = dynamic_cast<AIS_ColoredShape*>(myAISShape);
 
-  std::map<CurveCreator_Section*, TopoDS_Shape>::iterator it;
+  std::map<int, TopoDS_Shape>::iterator it;
 
-  for ( it = Sect2Wire.begin(); it != Sect2Wire.end(); it++ )
+  //for ( it = mySect2Wire.begin(); it != mySect2Wire.end(); it++ )
+  for (int i = 1; i <= mySect2Wire.Extent(); i++ )
   {
-    CurveCreator_Section* aSect = it->first;
+    CurveCreator_Section* aSect = (CurveCreator_Section*)getSection(mySect2Wire.FindKey(i));
     Quantity_Color aColor = aSect->myColor;
-    const TopoDS_Shape& aWire = it->second;
+    const TopoDS_Shape& aWire = mySect2Wire.FindFromIndex(i);
     AISColoredShape->SetCustomColor(aWire, aColor);
   }
-
+  
   // myAISShape->SetColor( myCurveColor );
   myAISShape->SetWidth( myLineWidth );
   Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
index e73a00883dba1cfbb502d961c96aeb9f3a330793..10bbc187084c10fa95580a180b6a7cb87e0a8459 100644 (file)
 
 #include <list>
 #include <map>
+#include <NCollection_IndexedDataMap.hxx>
 
 struct CurveCreator_Section;
 class CurveCreator_Displayer;
 class AIS_Shape;
 class AIS_InteractiveObject;
 class Quantity_Color;
+class TopoDS_Shape;
 
 /**
  *  The CurveCreator_Curve object is represented as one or more sets of
@@ -354,6 +356,8 @@ public:
   Quantity_Color myPointAspectColor;
   //Quantity_Color myCurveColor;
   double myLineWidth;
+  NCollection_IndexedDataMap<int, TopoDS_Shape> mySect2Wire;
+  std::vector<int> myCurSectInd;
 
 private:
 
index 9528c8616240cd2d70f322dd92c1f024b9d891ae..e43262e7b8af01cbb49ce31576ca531407bbc51a 100644 (file)
@@ -40,6 +40,12 @@ public:
   void eraseAll( bool isUpdate );
   void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
   void Update();
+
+  Handle(AIS_InteractiveContext) getContext() 
+  {
+    return myContext;
+  }
+
   //void highlight( const AISObjectsList& theObjects, bool isHL );
 
 protected:
diff --git a/src/CurveCreator/CurveCreator_ShapeFilter.cxx b/src/CurveCreator/CurveCreator_ShapeFilter.cxx
new file mode 100644 (file)
index 0000000..d3424b7
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2013-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File:        CurveCreator_ShapeFilter.cxx
+// Author:      Ilya Shchekin
+
+
+#include "CurveCreator_ShapeFilter.hxx"
+
+#include <SelectMgr_EntityOwner.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS_Vertex.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(CurveCreator_ShapeFilter,SelectMgr_Filter)
+
+CurveCreator_ShapeFilter::CurveCreator_ShapeFilter()
+: SelectMgr_Filter()
+{
+}
+
+CurveCreator_ShapeFilter::~CurveCreator_ShapeFilter()
+{
+}
+
+Standard_Boolean CurveCreator_ShapeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
+{
+  return (aType == TopAbs_VERTEX);
+}
+
+Standard_Boolean CurveCreator_ShapeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
+{
+  Handle(StdSelect_BRepOwner) aBO = Handle(StdSelect_BRepOwner)::DownCast(EO);
+  if (aBO.IsNull())
+    return Standard_False;
+
+  const TopoDS_Shape& aShape = aBO->Shape();
+
+  if(aShape.ShapeType()!= TopAbs_VERTEX)
+    return Standard_False;
+
+  return myShapes.Contains(aShape);
+}
+
+void CurveCreator_ShapeFilter::AddShape(const TopoDS_Shape& aShape)
+{
+  myShapes.Add(aShape);  
+}
+
+void CurveCreator_ShapeFilter::RemoveShape(const TopoDS_Shape& aShape)
+{
+  myShapes.Remove(aShape);
+}
+
+void CurveCreator_ShapeFilter::ClearShapes()
+{
+  myShapes.Clear();
+}
+
diff --git a/src/CurveCreator/CurveCreator_ShapeFilter.hxx b/src/CurveCreator/CurveCreator_ShapeFilter.hxx
new file mode 100644 (file)
index 0000000..cc4912e
--- /dev/null
@@ -0,0 +1,73 @@
+// Copyright (C) 2013-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File:        CurveCreator_ShapeFilter.hxx
+// Author:      Ilya Shchekin
+
+
+#ifndef _CurveCreator_ShapeFilter_HeaderFile
+#define _CurveCreator_ShapeFilter_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+#include <Basics_OCCTVersion.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <SelectMgr_Filter.hxx>
+#include <TopAbs_ShapeEnum.hxx> 
+#include <TopTools_MapOfShape.hxx>
+
+class SelectMgr_EntityOwner;
+class TopoDS_Shape;
+
+
+class CurveCreator_ShapeFilter : public SelectMgr_Filter
+{
+                               
+public:
+
+  
+  Standard_EXPORT CurveCreator_ShapeFilter();
+
+  Standard_EXPORT ~CurveCreator_ShapeFilter();
+  
+  Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
+  
+  Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
+  
+  Standard_EXPORT void AddShape (const TopoDS_Shape& aShape);
+  
+  Standard_EXPORT void RemoveShape (const TopoDS_Shape& aShape);
+
+  Standard_EXPORT void ClearShapes ();
+
+
+private:
+
+  TopTools_MapOfShape myShapes;
+
+public:
+
+  DEFINE_STANDARD_RTTIEXT(CurveCreator_ShapeFilter,SelectMgr_Filter)
+
+};
+
+DEFINE_STANDARD_HANDLE(CurveCreator_ShapeFilter, SelectMgr_Filter)
+
+#endif 
+                                               
\ No newline at end of file
index df5bdd714821a14e7efad5bc3bcf8d800499b98a..24c60320d5452165f1085e318d2cdb2054349cb5 100644 (file)
@@ -295,7 +295,7 @@ TopoDS_Wire CurveCreator_Utils::ConstructWire(
 //=======================================================================
 void CurveCreator_Utils::constructShape(
   const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape, 
-  std::map<CurveCreator_Section*, TopoDS_Shape>* theSect2Wire )
+  NCollection_IndexedDataMap<int, TopoDS_Shape>* theSect2Wire )
 {
   BRep_Builder aBuilder;
   TopoDS_Compound aShape;
@@ -329,8 +329,8 @@ void CurveCreator_Utils::constructShape(
       aBuilder.Add(aShape, aWire);
       if (theSect2Wire)
       {
-         CurveCreator_Section* aSection = (CurveCreator_Section*)theCurve->getSection(aSectionI);
-        (*theSect2Wire)[aSection] = aWire;
+         //CurveCreator_Section* aSection = (CurveCreator_Section*)theCurve->getSection(aSectionI);
+        (*theSect2Wire).Add(aSectionI, aWire);
       }
     }
   }
index 9110ed02a5bb2d23bb118871dd4d35f7bc231f07..f773f23171208b21f38150e7995043d3e471523d 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <list>
 #include <vector> // TODO: remove
+#include <NCollection_IndexedDataMap.hxx>
 
 class CurveCreator_Curve;
 
@@ -90,7 +91,7 @@ public:
    */
   CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
                                                   TopoDS_Shape& theShape,
-                                                  std::map<CurveCreator_Section*, TopoDS_Shape>* Sect2Wire = NULL);
+                                                  NCollection_IndexedDataMap<int, TopoDS_Shape>* Sect2Wire = NULL);
 
   /**
    * Generates a curve from a shape.
index e6e3f9b71d3def7c57b1e9550894f7f35c308b75..5264cf2136f8dfe967e126644223e89a869067f6 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "CurveCreator.hxx"
 #include <gp_Pnt.hxx>
+#include <TopoDS_Shape.hxx>
 
 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
 
index c40a1d0ee044db4aa02c5ff714caed6c450e2999..074f035778f32ef8b148388b257920a4b9fb0ae0 100644 (file)
@@ -33,6 +33,9 @@
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_ViewManager.h>
 
+#include <TopExp_Explorer.hxx>
+#include "CurveCreator_ShapeFilter.hxx"
+
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewPort3d.h>
 #include <OCCViewer_Utilities.h>
@@ -362,6 +365,11 @@ void CurveCreator_Widget::onSelectionChanged()
   updateActionsStates();
   updateUndoRedo();
   emit selectionChanged();
+  QList<int> selectedSections = mySectionView->getSelectedSections();
+  CurveCreator_Curve* Curve =  ((CurveCreator_Curve*)myCurve);
+  Curve->myCurSectInd.clear();
+  foreach (int sectInd, selectedSections)
+    Curve->myCurSectInd.push_back(sectInd);
 }
 
 void CurveCreator_Widget::updateActionsStates()
@@ -1158,6 +1166,28 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
     Handle(V3d_View) aView3d = aView->getViewPort()->getView();
     if ( !aView3d.IsNull() )
     {
+      CurveCreator_Curve* Curve =  ((CurveCreator_Curve*)myCurve);
+      //if (!Curve->myCurSectInd.empty())
+      //{
+        aCtx->RemoveFilters();
+        Handle(CurveCreator_ShapeFilter) filter = new CurveCreator_ShapeFilter();
+        for (int i=0; i<Curve->myCurSectInd.size(); i++)
+        {
+          int sectInd = Curve->myCurSectInd[i];
+          const TopoDS_Shape& W = Curve->mySect2Wire(sectInd+1);
+          TopExp_Explorer exp(W, TopAbs_VERTEX);
+          for (;exp.More();exp.Next())
+            filter->AddShape(exp.Current());    
+        }
+        aCtx->AddFilter(filter);
+        if (aCtx->HasOpenedContext())
+        {
+          Handle(AIS_LocalContext) aLctx = aCtx->LocalContext();
+          aLctx->Filter()->Clear();
+          aLctx->AddFilter(filter);
+        }
+      //}
+
       // Initialize the single selection if start and end points are equal,
       // otherwise a rectangular selection.
       if ( myStartPoint == myEndPoint )