From: isn Date: Wed, 9 Jan 2019 17:32:28 +0000 (+0300) Subject: curveCreator :: allow selection of points of selected polyline(s) only X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0d3e4210ae5c8bd0938d64367d4019a544c52759;p=modules%2Fgeom.git curveCreator :: allow selection of points of selected polyline(s) only --- diff --git a/src/CurveCreator/CMakeLists.txt b/src/CurveCreator/CMakeLists.txt index ca9625875..3263a1ca2 100644 --- a/src/CurveCreator/CMakeLists.txt +++ b/src/CurveCreator/CMakeLists.txt @@ -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 diff --git a/src/CurveCreator/CurveCreator_Curve.cxx b/src/CurveCreator/CurveCreator_Curve.cxx index 3408e49a9..ca421ef79 100644 --- a/src/CurveCreator/CurveCreator_Curve.cxx +++ b/src/CurveCreator/CurveCreator_Curve.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1067,21 +1068,22 @@ void CurveCreator_Curve::constructAISObject() { //DEBTRACE("constructAISObject"); TopoDS_Shape aShape; - std::map 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(myAISShape); - std::map::iterator it; + std::map::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(); diff --git a/src/CurveCreator/CurveCreator_Curve.hxx b/src/CurveCreator/CurveCreator_Curve.hxx index e73a00883..10bbc1870 100644 --- a/src/CurveCreator/CurveCreator_Curve.hxx +++ b/src/CurveCreator/CurveCreator_Curve.hxx @@ -31,12 +31,14 @@ #include #include +#include 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 mySect2Wire; + std::vector myCurSectInd; private: diff --git a/src/CurveCreator/CurveCreator_Displayer.hxx b/src/CurveCreator/CurveCreator_Displayer.hxx index 9528c8616..e43262e7b 100644 --- a/src/CurveCreator/CurveCreator_Displayer.hxx +++ b/src/CurveCreator/CurveCreator_Displayer.hxx @@ -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 index 000000000..d3424b744 --- /dev/null +++ b/src/CurveCreator/CurveCreator_ShapeFilter.cxx @@ -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 +#include +#include + +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 index 000000000..cc4912e3a --- /dev/null +++ b/src/CurveCreator/CurveCreator_ShapeFilter.hxx @@ -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 +#include +#include +#include +#include +#include +#include + +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 diff --git a/src/CurveCreator/CurveCreator_Utils.cxx b/src/CurveCreator/CurveCreator_Utils.cxx index df5bdd714..24c60320d 100644 --- a/src/CurveCreator/CurveCreator_Utils.cxx +++ b/src/CurveCreator/CurveCreator_Utils.cxx @@ -295,7 +295,7 @@ TopoDS_Wire CurveCreator_Utils::ConstructWire( //======================================================================= void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape, - std::map* theSect2Wire ) + NCollection_IndexedDataMap* 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); } } } diff --git a/src/CurveCreator/CurveCreator_Utils.hxx b/src/CurveCreator/CurveCreator_Utils.hxx index 9110ed02a..f773f2317 100644 --- a/src/CurveCreator/CurveCreator_Utils.hxx +++ b/src/CurveCreator/CurveCreator_Utils.hxx @@ -36,6 +36,7 @@ #include #include // TODO: remove +#include class CurveCreator_Curve; @@ -90,7 +91,7 @@ public: */ CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape, - std::map* Sect2Wire = NULL); + NCollection_IndexedDataMap* Sect2Wire = NULL); /** * Generates a curve from a shape. diff --git a/src/CurveCreator/CurveCreator_UtilsICurve.cxx b/src/CurveCreator/CurveCreator_UtilsICurve.cxx index e6e3f9b71..5264cf213 100644 --- a/src/CurveCreator/CurveCreator_UtilsICurve.cxx +++ b/src/CurveCreator/CurveCreator_UtilsICurve.cxx @@ -21,6 +21,7 @@ #include "CurveCreator.hxx" #include +#include const double LOCAL_SELECTION_TOLERANCE = 0.0001; diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index c40a1d0ee..074f03577 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -33,6 +33,9 @@ #include #include +#include +#include "CurveCreator_ShapeFilter.hxx" + #include #include #include @@ -362,6 +365,11 @@ void CurveCreator_Widget::onSelectionChanged() updateActionsStates(); updateUndoRedo(); emit selectionChanged(); + QList 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; imyCurSectInd.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 )