From: nds Date: Mon, 13 Apr 2015 06:22:08 +0000 (+0300) Subject: It corrects the validator parameter from the entrity to viewerprs in order to validat... X-Git-Tag: V_1.1.0~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=05b2338e0d6dd63e13c05476973f231284f5297a;p=modules%2Fshaper.git It corrects the validator parameter from the entrity to viewerprs in order to validate the objects in OB. These objects are Sketch result for extrusion and the main plane for Sketch. It removes filters. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index fd7878d10..f74124ea6 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -6,14 +6,7 @@ SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS ModuleBase.h ModuleBase_Filter.h - ModuleBase_FilterCustom.h - ModuleBase_FilterFace.h ModuleBase_FilterFactory.h - ModuleBase_FilterLinearEdge.h - ModuleBase_FilterMulti.h - ModuleBase_FilterNoConsructionSubShapes.h - ModuleBase_FilterNoDegeneratedEdge.h - ModuleBase_FilterShapeType.h ModuleBase_FilterValidated.h ModuleBase_Tools.h ModuleBase_IModule.h @@ -57,14 +50,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES ModuleBase_Filter.cpp - ModuleBase_FilterCustom.cpp - ModuleBase_FilterFace.cpp ModuleBase_FilterFactory.cpp - ModuleBase_FilterLinearEdge.cpp - ModuleBase_FilterMulti.cpp - ModuleBase_FilterNoConsructionSubShapes.cpp - ModuleBase_FilterNoDegeneratedEdge.cpp - ModuleBase_FilterShapeType.cpp ModuleBase_FilterValidated.cpp ModuleBase_Tools.cpp ModuleBase_IModule.cpp diff --git a/src/ModuleBase/ModuleBase_FilterCustom.cpp b/src/ModuleBase/ModuleBase_FilterCustom.cpp deleted file mode 100644 index 49ea31e14..000000000 --- a/src/ModuleBase/ModuleBase_FilterCustom.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterCustom.cpp -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - - -#include "ModuleBase_FilterCustom.h" - -#include -#include - -#include - -#include -#include - -ModuleBase_FilterCustom::ModuleBase_FilterCustom(Handle(SelectMgr_Filter) theFilter) -: ModuleBase_Filter() -{ - myFilter = theFilter; -} - -void ModuleBase_FilterCustom::createFilter() -{ -} - -void ModuleBase_FilterCustom::setArguments(const std::list& theArguments) -{ -} diff --git a/src/ModuleBase/ModuleBase_FilterCustom.h b/src/ModuleBase/ModuleBase_FilterCustom.h deleted file mode 100644 index 6de1620cc..000000000 --- a/src/ModuleBase/ModuleBase_FilterCustom.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterCustom.h -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - -#ifndef ModuleBase_FilterCustom_H -#define ModuleBase_FilterCustom_H - -#include "ModuleBase.h" - -#include "ModuleBase_Filter.h" - -/** -* \ingroup GUI -* This is a child of ModuleBase_Filter to be used in the factory of filters. Despite of other -* child it does not create the internal filter itself, it get it from the constructor argument. -* This is useful for custom filters, which are not the standard OCC filters. It is not necessary -* to redefine the ModuleBase_Filter. The filter is realized and put here as the class parameter. -*/ - -class ModuleBase_FilterCustom: public ModuleBase_Filter -{ -public: - /** - * Constructor - * \param theFilter an OCC filter to be used in the parent base filter - */ - MODULEBASE_EXPORT ModuleBase_FilterCustom(Handle(SelectMgr_Filter) theFilter); - - /** - * Sets the arguments to the filter. Currently it is not used in this filter. - * \param theArguments a list of arguments - */ - MODULEBASE_EXPORT virtual void setArguments(const std::list& theArguments); - -protected: - /** - * It creates an OCC filter. The realization is empty because the filter is set through the constructor - */ - virtual void createFilter(); - -}; - -#endif //ModuleBase_FilterCustom diff --git a/src/ModuleBase/ModuleBase_FilterFace.cpp b/src/ModuleBase/ModuleBase_FilterFace.cpp deleted file mode 100644 index 3e6544557..000000000 --- a/src/ModuleBase/ModuleBase_FilterFace.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterFace.cpp -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - - -#include "ModuleBase_FilterFace.h" - -#include -#include - -#include - -#include -#include - -typedef QMap FaceTypes; -static FaceTypes MyFaceTypes; - -StdSelect_TypeOfFace ModuleBase_FilterFace::faceType(const std::string& theType) -{ - if (MyFaceTypes.count() == 0) { - MyFaceTypes["plane"] = StdSelect_Plane; - MyFaceTypes["cylinder"] = StdSelect_Cylinder; - } - QString aType = QString(theType.c_str()).toLower(); - if (MyFaceTypes.contains(aType)) - return MyFaceTypes[aType]; - Events_Error::send("Face type defined in XML is not implemented!"); - return StdSelect_AnyFace; -} - -void ModuleBase_FilterFace::createFilter() -{ - myFilter = new StdSelect_FaceFilter(StdSelect_AnyFace); -} - -void ModuleBase_FilterFace::setArguments(const std::list& theArguments) -{ - if (theArguments.size()!= 1) - return; - - std::string anArgument = theArguments.front(); - Handle(StdSelect_FaceFilter) aFilter = Handle(StdSelect_FaceFilter)::DownCast(getFilter()); - if (!aFilter.IsNull()) - aFilter->SetType(faceType(anArgument)); -} diff --git a/src/ModuleBase/ModuleBase_FilterFace.h b/src/ModuleBase/ModuleBase_FilterFace.h deleted file mode 100644 index f3a6ef427..000000000 --- a/src/ModuleBase/ModuleBase_FilterFace.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterFace.h -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - -#ifndef ModuleBase_FilterFace_H -#define ModuleBase_FilterFace_H - -#include "ModuleBase.h" - -#include "ModuleBase_Filter.h" - -#include - -/** -* \ingroup GUI -* A class of a viewer filter by faces -*/ -class ModuleBase_FilterFace: public ModuleBase_Filter -{ -public: - /// Convert string to StdSelect_TypeOfFace value - /// \param theType a string value - static MODULEBASE_EXPORT StdSelect_TypeOfFace faceType(const std::string& theType); - - /// Constructor - MODULEBASE_EXPORT ModuleBase_FilterFace(): - ModuleBase_Filter() {} - - /** - * Sets the arguments to the filter. - * \param theArguments a list of arguments - */ - MODULEBASE_EXPORT virtual void setArguments(const std::list& theArguments); - -protected: - /** - * It creates an OCC face filter - */ - virtual void createFilter(); - -}; - -#endif //ModuleBase_FilterFace diff --git a/src/ModuleBase/ModuleBase_FilterLinearEdge.cpp b/src/ModuleBase/ModuleBase_FilterLinearEdge.cpp deleted file mode 100644 index a5634cba4..000000000 --- a/src/ModuleBase/ModuleBase_FilterLinearEdge.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterLinearEdge.cpp -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - - -#include "ModuleBase_FilterLinearEdge.h" - -#include -#include - -#include - -#include -#include - -typedef QMap EdgeTypes; -static EdgeTypes MyEdgeTypes; - -StdSelect_TypeOfEdge ModuleBase_FilterLinearEdge::edgeType(const std::string& theType) -{ - if (MyEdgeTypes.count() == 0) { - MyEdgeTypes["line"] = StdSelect_Line; - MyEdgeTypes["circle"] = StdSelect_Circle; - } - QString aType = QString(theType.c_str()).toLower(); - if (MyEdgeTypes.contains(aType)) - return MyEdgeTypes[aType]; - Events_Error::send("Edge type defined in XML is not implemented!"); - return StdSelect_AnyEdge; -} - -void ModuleBase_FilterLinearEdge::createFilter() -{ - myFilter = new StdSelect_EdgeFilter(StdSelect_AnyEdge); -} - -void ModuleBase_FilterLinearEdge::setArguments(const std::list& theArguments) -{ - if (theArguments.size()!= 1) - return; - - std::string anArgument = theArguments.front(); - Handle(StdSelect_EdgeFilter) aFilter = Handle(StdSelect_EdgeFilter)::DownCast(getFilter()); - if (!aFilter.IsNull()) - aFilter->SetType(edgeType(anArgument)); -} diff --git a/src/ModuleBase/ModuleBase_FilterLinearEdge.h b/src/ModuleBase/ModuleBase_FilterLinearEdge.h deleted file mode 100644 index 0efb1a545..000000000 --- a/src/ModuleBase/ModuleBase_FilterLinearEdge.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_FilterLinearEdge.h -// Created: 10 Dec 2014 -// Author: Natalia ERMOLAEVA - -#ifndef ModuleBase_FilterLinearEdge_H -#define ModuleBase_FilterLinearEdge_H - -#include "ModuleBase.h" - -#include "ModuleBase_Filter.h" - -#include - -/** -* \ingroup GUI -* A class of a viewer filter by linear edges -*/ -class ModuleBase_FilterLinearEdge: public ModuleBase_Filter -{ -public: - /// Convert string to StdSelect_TypeOfFace value - /// \param theType a string value - static MODULEBASE_EXPORT StdSelect_TypeOfEdge edgeType(const std::string& theType); - - /// Constructor - MODULEBASE_EXPORT ModuleBase_FilterLinearEdge(): - ModuleBase_Filter() {} - - /** - * Sets the arguments to the filter. - * \param theArguments a list of arguments - */ - MODULEBASE_EXPORT virtual void setArguments(const std::list& theArguments); - -protected: - /** - * It creates an OCC edge filter - */ - virtual void createFilter(); - -}; - -#endif //ModuleBase_FilterLinearEdge diff --git a/src/ModuleBase/ModuleBase_FilterMulti.cpp b/src/ModuleBase/ModuleBase_FilterMulti.cpp deleted file mode 100644 index 6fcab0a7b..000000000 --- a/src/ModuleBase/ModuleBase_FilterMulti.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// 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 - -#include - -#include -#include - -ModuleBase_Filter* ModuleBase_FilterMulti::findFilter(const std::string& theType) -{ - ModuleBase_Filter* aFilter = 0; - - if (theType == "line") { - aFilter = new ModuleBase_FilterLinearEdge(); - std::list anArguments; - anArguments.push_back(theType); - aFilter->setArguments(anArguments); - } - if (theType == "vertex") { - aFilter = new ModuleBase_FilterShapeType(); - std::list 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::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& theArguments) -{ - myArguments.clear(); - myArguments = theArguments; -} diff --git a/src/ModuleBase/ModuleBase_FilterMulti.h b/src/ModuleBase/ModuleBase_FilterMulti.h deleted file mode 100644 index 5b9e7dd01..000000000 --- a/src/ModuleBase/ModuleBase_FilterMulti.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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 - -/** -* \ingroup GUI -* An implementation of filter which support using of several filters according to OR statement -*/ -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& theArguments); - -protected: - /** - * It creates an OCC face filter - */ - virtual void createFilter(); - -protected: - /// the filter arguments - std::list myArguments; -}; - -#endif //ModuleBase_FilterMulti diff --git a/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp deleted file mode 100644 index c9c49f76b..000000000 --- a/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_ViewerFilters.cpp -// Created: 07 Okt 2014 -// Author: Vitaly SMETANNIKOV - - -#include "ModuleBase_FilterNoConsructionSubShapes.h" -#include "ModuleBase_IWorkshop.h" - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - - -IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter); -IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter); - -Standard_Boolean ModuleBase_FilterNoConsructionSubShapes::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const -{ - // global selection should be ignored, the filter processes only selected sub-shapes - Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); - if (!aShapeOwner.IsNull()) { - if (!aShapeOwner->ComesFromDecomposition()) - return Standard_True; - } - - if (theOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) aAisObj = - Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); - if (!aAisObj.IsNull()) { - std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); - aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); - ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); - - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(aObj); - if (aConstr != NULL) { - // it provides selection only on compositie features, construction without composite - // feature is not selectable - FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr); - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aFeature); - return aComposite && aComposite->numberOfSubs() > 0; - } - else - return Standard_True; - } - } - return Standard_False; -} - diff --git a/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h deleted file mode 100644 index e2d4cbf1d..000000000 --- a/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_ViewerFilters.h -// Created: 07 Okt 2014 -// Author: Vitaly SMETANNIKOV - - -#ifndef ModuleBase_FilterNoConsructionSubShapes_H -#define ModuleBase_FilterNoConsructionSubShapes_H - -#include - -#include -#include - -class ModuleBase_IWorkshop; - -/** -* \ingroup GUI -* \class ModuleBase_FilterNoConsructionSubShapes -* A filter which provides filtering of selection in 3d viewer. -* Installing of this filter lets to select objects which belong to -* currently active document or to global document -*/ -DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoConsructionSubShapes, SelectMgr_Filter); -class ModuleBase_FilterNoConsructionSubShapes: public SelectMgr_Filter -{ -public: - /// Constructor - /// \param theWorkshop instance of workshop interface - Standard_EXPORT ModuleBase_FilterNoConsructionSubShapes(ModuleBase_IWorkshop* theWorkshop): - SelectMgr_Filter(), myWorkshop(theWorkshop) {} - - /** - * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes) - * of if the selected result is a construction and the result feature is composite and has sub-elements. - * \param theOwner the result of selection - * \return whether the owner is selectable in the viewer - */ - Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; - - DEFINE_STANDARD_RTTI(ModuleBase_FilterNoConsructionSubShapes) - -protected: - /// Instance of workshop interface - ModuleBase_IWorkshop* myWorkshop; -}; - -#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp b/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp deleted file mode 100644 index 1fb5a5736..000000000 --- a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_ViewerFilters.cpp -// Created: 10 Feb 2015 -// Author: Natalia ERMOLAEVA - - -#include "ModuleBase_FilterNoDegeneratedEdge.h" - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter); -IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter); - -ModuleBase_FilterNoDegeneratedEdge::ModuleBase_FilterNoDegeneratedEdge() -: StdSelect_EdgeFilter(StdSelect_AnyEdge) -{ -} - -Standard_Boolean ModuleBase_FilterNoDegeneratedEdge::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const -{ - bool isEdge = StdSelect_EdgeFilter::IsOk(theOwner); - if (isEdge) { - Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); - if (!anOwner.IsNull() && anOwner->HasShape()) { - const TopoDS_Shape& aShape = anOwner->Shape(); - if (BRep_Tool::Degenerated(TopoDS::Edge(aShape))) - return Standard_False; - } - } - return isEdge; -} - diff --git a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h b/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h deleted file mode 100644 index b61f0017e..000000000 --- a/src/ModuleBase/ModuleBase_FilterNoDegeneratedEdge.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_ViewerFilters.h -// Created: 10 Feb 2015 -// Author: Natalia ERMOLAEVA - - -#ifndef ModuleBase_FilterNoDegeneratedEdge_H -#define ModuleBase_FilterNoDegeneratedEdge_H - -#include - -#include -#include - -/** -* \ingroup GUI -* \class ModuleBase_FilterNoDegeneratedEdge -* An edge filter, which additionally filters degenerative edges. -*/ -DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter); -class ModuleBase_FilterNoDegeneratedEdge: public StdSelect_EdgeFilter -{ -public: - /// Constructor - Standard_EXPORT ModuleBase_FilterNoDegeneratedEdge(); - - /** - * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes) - * of if the selected result is a construction and the result feature is composite and has sub-elements. - * \param theOwner the result of selection - * \return whether the owner is selectable in the viewer - */ - Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; - - DEFINE_STANDARD_RTTI(ModuleBase_FilterNoDegeneratedEdge) - -protected: -}; - -#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.cpp b/src/ModuleBase/ModuleBase_FilterShapeType.cpp deleted file mode 100644 index 2b981f785..000000000 --- a/src/ModuleBase/ModuleBase_FilterShapeType.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// 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 -#include - -#include - -#include -#include - -typedef QMap 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& theArguments) -{ - if (theArguments.size()!= 1) - return; - myShapeType = shapeType(theArguments.front()); -} diff --git a/src/ModuleBase/ModuleBase_FilterShapeType.h b/src/ModuleBase/ModuleBase_FilterShapeType.h deleted file mode 100644 index 771217cd7..000000000 --- a/src/ModuleBase/ModuleBase_FilterShapeType.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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 - -/** -* \ingroup GUI -* A class of a viewer filter by shape type -*/ -class ModuleBase_FilterShapeType: public ModuleBase_Filter -{ -public: - /// Constructor - /// \param theType type of shape - 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& theArguments); - -protected: - /** - * It creates an OCC face filter - */ - virtual void createFilter(); - -private: - /// the shape type of the filter - TopAbs_ShapeEnum myShapeType; -}; - -#endif //ModuleBase_FilterShapeType diff --git a/src/ModuleBase/ModuleBase_FilterValidated.cpp b/src/ModuleBase/ModuleBase_FilterValidated.cpp index 5bb26dac5..28a43c3d7 100644 --- a/src/ModuleBase/ModuleBase_FilterValidated.cpp +++ b/src/ModuleBase/ModuleBase_FilterValidated.cpp @@ -9,8 +9,10 @@ #include #include +#include #include #include +#include IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter); @@ -25,6 +27,9 @@ Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityO ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget(); ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast (anActiveWidget); - return !aWidgetValidated || aWidgetValidated->isValid(theOwner); + ModuleBase_ViewerPrs aPrs; + myWorkshop->selection()->fillPresentation(aPrs, theOwner); + + return !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs); } diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.cpp b/src/ModuleBase/ModuleBase_ViewerFilters.cpp index 1e56112a7..81f84dda6 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.cpp +++ b/src/ModuleBase/ModuleBase_ViewerFilters.cpp @@ -92,32 +92,3 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti } return Standard_False; } - - -IMPLEMENT_STANDARD_HANDLE(ModuleBase_ObjectTypesFilter, SelectMgr_Filter); -IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ObjectTypesFilter, SelectMgr_Filter); - - -//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340) -Standard_Boolean ModuleBase_ObjectTypesFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const -{ - Standard_Boolean isOk = ModuleBase_ShapeDocumentFilter::IsOk(theOwner); - if (isOk && theOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) aAisObj = - Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); - if (!aAisObj.IsNull()) { - std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); - aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); - ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); - - foreach (QString aType, myTypes) { - if (aType.toLower() == "construction") { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(aObj); - return (aConstr != NULL); - } // ToDo: Process other types of objects - } - } - } - return Standard_False; -} diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.h b/src/ModuleBase/ModuleBase_ViewerFilters.h index 1a215a4fc..a5d404ee8 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.h +++ b/src/ModuleBase/ModuleBase_ViewerFilters.h @@ -75,33 +75,4 @@ private: gp_Pln myPlane; }; - -/** -* \class ModuleBase_ObjectTypesFilter -* \ingroup GUI -* A filter which provides filtering of selection in 3d viewer. -* Installing of this filter lets to select only object of requested type -* Accepts following objects types: -* - "construction" - to select ModelAPI_ResultConstruction objects -*/ -DEFINE_STANDARD_HANDLE(ModuleBase_ObjectTypesFilter, SelectMgr_Filter); -class ModuleBase_ObjectTypesFilter: public ModuleBase_ShapeDocumentFilter -{ -public: - /// Constructor - /// \param theWorkshop instance of workshop interface - /// \param theTypes list of object types - Standard_EXPORT ModuleBase_ObjectTypesFilter(ModuleBase_IWorkshop* theWorkshop, const QStringList& theTypes): - ModuleBase_ShapeDocumentFilter(theWorkshop), myTypes(theTypes) {} - - /// Returns True if the given owner is acceptable for selection - /// \param theOwner the selected owner - Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; - - DEFINE_STANDARD_RTTI(ModuleBase_ObjectTypesFilter) -private: - /// List of object types - QStringList myTypes; -}; - -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index cd8751fe7..ebc274981 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -47,7 +47,7 @@ class ModuleBase_ViewerPrs /// Sets the object. /// \param theResult an object instance - void setFeature(ObjectPtr theResult) + void setObject(ObjectPtr theResult) { myResult = theResult; } @@ -100,6 +100,14 @@ class ModuleBase_ViewerPrs return myInteractive; } + /// Returns true if all presentation fields are empty + /// \return boolean value + bool isEmpty() const + { + return myShape.IsNull() && + myOwner.IsNull() && !myResult.get(); + } + /// Returns True if the current object is equal to the given one /// \param thePrs an object to compare bool operator==(const ModuleBase_ViewerPrs& thePrs) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 53f035275..6ae74c061 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -196,19 +196,15 @@ void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/) } //******************************************************************** -bool ModuleBase_WidgetMultiSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { - ModuleBase_ViewerPrs aPrs; - ModuleBase_ISelection* aSelection = myWorkshop->selection(); - aSelection->fillPresentation(aPrs, theOwner); - - const TopoDS_Shape& aTDSShape = aPrs.shape(); + const TopoDS_Shape& aTDSShape = thePrs.shape(); if (aTDSShape.IsNull()) return false; GeomShapePtr aShape = std::shared_ptr(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aTDSShape)); - ObjectPtr anObject = aSelection->getSelectableObject(theOwner); + ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner()); ResultPtr aResult = std::dynamic_pointer_cast(anObject); if (myFeature) { // We can not select a result of our feature @@ -276,9 +272,8 @@ void ModuleBase_WidgetMultiSelector::onSelectionChanged() aSelectionListAttr->clear(); if (aSelected.size() > 0) { foreach (ModuleBase_ViewerPrs aPrs, aSelected) { - Handle(SelectMgr_EntityOwner) anOwner = aPrs.owner(); - if (isValid(anOwner)) { - setSelection(anOwner); + if (isValidSelection(aPrs)) { + setSelectionCustom(aPrs); } } } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 49ae66b6b..5f2bf3498 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -74,7 +74,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner - virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner); + virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); public slots: /// Slot is called on selection type changed diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 34eb3e189..fcd1e26c2 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -215,9 +215,8 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations(); QList aSelected = myWorkshop->selection()->getSelected(); if (aSelected.size() > 0) { - Handle(SelectMgr_EntityOwner) anOwner = aSelected.first().owner(); - if (isValid(anOwner)) { - setSelection(anOwner); + if (isValidSelection(aSelected.first())) { + setSelectionCustom(aSelected.first()); // the updateObject method should be called to flush the updated sigal. The workshop listens it, // calls validators for the feature and, as a result, updates the Apply button state. updateObject(myFeature); @@ -401,14 +400,12 @@ void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid) } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { bool isDone = false; - ModuleBase_ViewerPrs aPrs; - myWorkshop->selection()->fillPresentation(aPrs, theOwner); // It should be checked by corresponded validator - ObjectPtr aObject = aPrs.object(); + ObjectPtr aObject = thePrs.object(); ObjectPtr aCurrentObject = GeomValidators_Tools::getObject(myFeature->attribute(attributeID())); /* if ((!aCurrentObject) && (!aObject)) @@ -444,9 +441,9 @@ bool ModuleBase_WidgetShapeSelector::setSelection(const Handle_SelectMgr_EntityO return false; // Get sub-shapes from local selection - if (!aPrs.shape().IsNull()) { + if (!thePrs.shape().IsNull()) { aShape = std::shared_ptr(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aPrs.shape())); + aShape->setImpl(new TopoDS_Shape(thePrs.shape())); } // Check that the selection corresponds to selection type if (!acceptSubShape(aShape)) diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index fe28323b1..8890912da 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -84,7 +84,7 @@ Q_OBJECT /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner - virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner); + virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// The methiod called when widget is deactivated virtual void deactivate(); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 445190ae5..0c84fa8e9 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -31,9 +31,8 @@ bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) { bool isDone = false; - Handle(SelectMgr_EntityOwner) anOwner = theValue.owner(); - if (isValid(anOwner)) { - isDone = setSelection(anOwner); + if (isValidSelection(theValue)) { + isDone = setSelectionCustom(theValue); updateObject(myFeature); emit valuesChanged(); } @@ -41,7 +40,7 @@ bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue) } //******************************************************************** -bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& theOwner) +bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue) { DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); @@ -57,7 +56,7 @@ bool ModuleBase_WidgetValidated::isValid(const Handle_SelectMgr_EntityOwner& the storeAttributeValue(); // saves the owner value to the widget attribute - bool aValid = setSelection(theOwner); + bool aValid = setSelectionCustom(theValue); if (aValid) // checks the attribute validity diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 31e7b81ac..eb0f8fa7f 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -41,7 +41,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg /// Checks all widget validator if the owner is valid /// \param theOwner a selected owner in the view /// \return a boolean value - bool isValid(const Handle_SelectMgr_EntityOwner& theOwner); + bool isValidSelection(const ModuleBase_ViewerPrs& theValue); /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs @@ -64,7 +64,7 @@ protected: /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner - virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner) = 0; + virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0; virtual void removePresentations() {}; diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 76fc4c119..58d1a210c 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -16,7 +16,6 @@ SET(PROJECT_HEADERS PartSet_WidgetPoint2dDistance.h PartSet_WidgetShapeSelector.h PartSet_Filters.h - PartSet_FilterSketchEntity.h PartSet_SketcherMgr.h PartSet_MenuMgr.h ) @@ -31,7 +30,6 @@ SET(PROJECT_SOURCES PartSet_WidgetPoint2dDistance.cpp PartSet_WidgetShapeSelector.cpp PartSet_Filters.cpp - PartSet_FilterSketchEntity.cpp PartSet_SketcherMgr.cpp PartSet_MenuMgr.cpp ) diff --git a/src/PartSet/PartSet_FilterSketchEntity.cpp b/src/PartSet/PartSet_FilterSketchEntity.cpp deleted file mode 100644 index 04b5f4f3e..000000000 --- a/src/PartSet/PartSet_FilterSketchEntity.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_FilterSketchEntity.cpp -// Created: 13 Mar 2015 -// Author: Natalia ERMOLAEVA - -#include "PartSet_FilterSketchEntity.h" - -#include - -#include -#include - -#include - -#include -#include - - -IMPLEMENT_STANDARD_HANDLE(PartSet_FilterSketchEntity, ModuleBase_ShapeDocumentFilter); -IMPLEMENT_STANDARD_RTTIEXT(PartSet_FilterSketchEntity, ModuleBase_ShapeDocumentFilter); - -Standard_Boolean PartSet_FilterSketchEntity::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const -{ - if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) { - if (theOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) aAisObj = - Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); - if (!aAisObj.IsNull()) { - std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); - aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); - ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); - if (aObj) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - - if (aFeature->getKind() == SketchPlugin_Sketch::ID()) - return Standard_True; - } - } - } - } - return Standard_False; -} diff --git a/src/PartSet/PartSet_FilterSketchEntity.h b/src/PartSet/PartSet_FilterSketchEntity.h deleted file mode 100644 index 62849e6f8..000000000 --- a/src/PartSet/PartSet_FilterSketchEntity.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_FilterSketchEntity.h -// Created: 13 Mar 2015 -// Author: Natalia ERMOLAEVA - -#ifndef PartSet_FilterSketchEntity_H -#define PartSet_FilterSketchEntity_H - -#include - -/** -* \class PartSet_FilterSketchEntity -* \ingroup Modules -* A class which filters groups object in addition to documents (see issue #310) -*/ -DEFINE_STANDARD_HANDLE(PartSet_FilterSketchEntity, ModuleBase_ShapeDocumentFilter); -class PartSet_FilterSketchEntity: public ModuleBase_ShapeDocumentFilter -{ -public: - /// Constructor - /// \param theWorkshop a pointer to workshop - PartSet_FilterSketchEntity(ModuleBase_IWorkshop* theWorkshop) - : ModuleBase_ShapeDocumentFilter(theWorkshop) {} - - /// 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_FilterSketchEntity) -}; - -#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 60ab634a7..a38f41b65 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -17,17 +17,11 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include #include -#include #include #include @@ -163,15 +157,6 @@ void PartSet_Module::registerFilters() //Registering of selection filters XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters(); - - //aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge); - //aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace); - //aFactory->registerFilter("MultiFilter", new ModuleBase_FilterMulti); - //Handle(SelectMgr_Filter) aSelectFilter = new ModuleBase_FilterNoConsructionSubShapes(workshop()); - //aFactory->registerFilter("NoConstructionSubShapesFilter", - // new ModuleBase_FilterCustom(aSelectFilter)); - //Handle(SelectMgr_Filter) aSelectFilter = new PartSet_FilterSketchEntity(workshop()); - //aFactory->registerFilter("SketchEntityFilter", new ModuleBase_FilterCustom(aSelectFilter)); } void PartSet_Module::registerProperties() diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 99c9b3e38..207aee541 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -71,6 +71,7 @@ #include #include +//#define DEBUG_DO_NOT_BY_ENTER /// Returns list of unique objects by sum of objects from List1 and List2 /*QList getSumList(const QList& theList1, @@ -166,8 +167,11 @@ void PartSet_SketcherMgr::onEnterViewPort() myIsMouseOverWindow = true; myIsPropertyPanelValueChanged = false; - if (!isNestedCreateOperation(getCurrentOperation())) - return; + #ifdef DEBUG_DO_NOT_BY_ENTER + return; + #endif + //if (!isNestedCreateOperation(getCurrentOperation())) + // return; } void PartSet_SketcherMgr::onLeaveViewPort() @@ -176,6 +180,10 @@ void PartSet_SketcherMgr::onLeaveViewPort() myIsMouseOverWindow = false; myIsPropertyPanelValueChanged = false; + #ifdef DEBUG_DO_NOT_BY_ENTER + return; + #endif + if (!isNestedCreateOperation(getCurrentOperation())) return; // the method should be performed if the popup menu is called, @@ -790,7 +798,7 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const aCanDisplay = false; } else { // there are no an active sketch - // 2. sketch sub-features should not visualized if the sketch operatio is not active + // 2. sketch sub-features should not visualized if the sketch operation is not active FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); if (aFeature.get() != NULL) { std::shared_ptr aSketchFeature = @@ -806,6 +814,7 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const // a. the property panel values modification // b. the popup menu activated // c. widget editor control + #ifndef DEBUG_DO_NOT_BY_ENTER if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) { ModuleBase_Operation* aOperation = getCurrentOperation(); ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); @@ -819,6 +828,7 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow; } } + #endif return aCanDisplay; } @@ -991,6 +1001,10 @@ ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay) { + #ifdef DEBUG_DO_NOT_BY_ENTER + return; + #endif + if (!theOperation || theOperation->isEditOperation()) return; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 557018299..42d4cd3ed 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -21,6 +21,9 @@ #include #include +#include +#include + #include #include #include @@ -89,55 +92,70 @@ QList PartSet_WidgetSketchLabel::getControls() const return aResult; } -void PartSet_WidgetSketchLabel::onPlaneSelected() +void PartSet_WidgetSketchLabel::onSelectionChanged() { - + ModuleBase_ViewerPrs aPrs; + // 1. find selected presentation either in the viewer or in OB XGUI_Selection* aSelection = myWorkshop->selector()->selection(); QList aSelected = aSelection->getSelected(); + // the selection in OCC viewer - the selection of a face in the viewer + // it can be th main plane's face of a face on a visualized body if (!aSelected.empty()) { - ModuleBase_ViewerPrs aPrs = aSelected.first(); - Handle(SelectMgr_EntityOwner) anOwner = aSelected.first().owner(); - if (isValid(anOwner)) { - setSelection(anOwner); - - TopoDS_Shape aShape = aPrs.shape(); - if (!aShape.IsNull()) { - erasePreviewPlanes(); - DataPtr aData = feature()->data(); - AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - if (aSelAttr) { - GeomShapePtr aShapePtr = aSelAttr->value(); - if (aShapePtr.get() == NULL || aShapePtr->isNull()) { - std::shared_ptr aGShape(new GeomAPI_Shape); - aGShape->setImpl(new TopoDS_Shape(aShape)); - // get plane parameters - std::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); - std::shared_ptr aDir = aPlane->direction(); - - myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z()); - } - } + aPrs = aSelected.first(); + } + else { + // the selection in Object Browser: the plane object can be used as sketch plane + QObjectPtrList anObjects = aSelection->selectedObjects(); + if (!anObjects.empty()) { + aPrs.setObject(anObjects.first()); + } + } + if (aPrs.isEmpty()) + return; - // Clear text in the label - myLabel->setText(""); - myLabel->setToolTip(""); - disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), - this, SLOT(onPlaneSelected())); - activateFilters(myWorkshop->module()->workshop(), false); - - // Clear selection mode and define sketching mode - //XGUI_Displayer* aDisp = myWorkshop->displayer(); - //aDisp->closeLocalContexts(); - emit planeSelected(plane()); - //setSketchingMode(); - - // Update sketcher actions - XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr(); - anActMgr->update(); - myWorkshop->viewer()->update(); + if (isValidSelection(aPrs)) { + // 2. set the selection to sketch + setSelectionCustom(aPrs); + // 3. hide main planes if they have been displayed + erasePreviewPlanes(); + // 4. if the planes were displayed, change the view projection + TopoDS_Shape aShape = aPrs.shape(); + if (!aShape.IsNull()) { + DataPtr aData = feature()->data(); + AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + if (aSelAttr) { + GeomShapePtr aShapePtr = aSelAttr->value(); + if (aShapePtr.get() == NULL || aShapePtr->isNull()) { + //TopoDS_Shape aShape = aShapePtr->impl(); + std::shared_ptr aGShape(new GeomAPI_Shape); + aGShape->setImpl(new TopoDS_Shape(aShape)); + // get plane parameters + std::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); + std::shared_ptr aDir = aPlane->direction(); + + myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z()); + } } } + // 5. Clear text in the label + myLabel->setText(""); + myLabel->setToolTip(""); + disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), + this, SLOT(onSelectionChanged())); + // 6. deactivate face selection filter + activateFilters(myWorkshop->module()->workshop(), false); + + // 7. Clear selection mode and define sketching mode + //XGUI_Displayer* aDisp = myWorkshop->displayer(); + //aDisp->closeLocalContexts(); + emit planeSelected(plane()); + //setSketchingMode(); + + // 8. Update sketcher actions + XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr(); + anActMgr->update(); + myWorkshop->viewer()->update(); } } @@ -176,26 +194,28 @@ void PartSet_WidgetSketchLabel::restoreAttributeValue(const bool theValid) } } -bool PartSet_WidgetSketchLabel::setSelection(const Handle_SelectMgr_EntityOwner& theOwner) +bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { bool isOwnerSet = false; - ModuleBase_ViewerPrs aPrs; - myWorkshop->selector()->selection()->fillPresentation(aPrs, theOwner); - - const TopoDS_Shape& aShape = aPrs.shape(); + const TopoDS_Shape& aShape = thePrs.shape(); std::shared_ptr aDir; - if (aPrs.object() && (feature() != aPrs.object())) { + if (thePrs.object() && (feature() != thePrs.object())) { DataPtr aData = feature()->data(); AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); if (aSelAttr) { - ResultPtr aRes = std::dynamic_pointer_cast(aPrs.object()); + ResultPtr aRes = std::dynamic_pointer_cast(thePrs.object()); if (aRes) { GeomShapePtr aShapePtr(new GeomAPI_Shape()); - aShapePtr->setImpl(new TopoDS_Shape(aShape)); + if (aShape.IsNull()) { + aShapePtr = ModelAPI_Tools::shape(aRes); + } + else { + aShapePtr->setImpl(new TopoDS_Shape(aShape)); + } aSelAttr->setValue(aRes, aShapePtr); isOwnerSet = true; } @@ -211,31 +231,40 @@ bool PartSet_WidgetSketchLabel::setSelection(const Handle_SelectMgr_EntityOwner& void PartSet_WidgetSketchLabel::activateCustom() { std::shared_ptr aPlane = plane(); - if (aPlane) { + bool aBodyIsVisualized = false; + XGUI_Displayer* aDisp = myWorkshop->displayer(); + QObjectPtrList aDisplayed = aDisp->displayedObjects(); + foreach (ObjectPtr anObj, aDisplayed) { + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if (aResult.get() != NULL) { + aBodyIsVisualized = aResult->groupName() == ModelAPI_ResultBody::group(); + if (aBodyIsVisualized) + break; + } + } + + if (aPlane || aBodyIsVisualized) { //setSketchingMode(); // In order to avoid Opening/Closing of context too often // it can be useful for a delay on the property panel filling // it is possible that it is not necessary anymore, but it requires a check //mySelectionTimer->start(20); + //setSketchingMode(); } else { // We have to select a plane before any operation showPreviewPlanes(); + } + QIntList aModes; + aModes << TopAbs_FACE; + aDisp->activateObjects(aModes); - XGUI_Displayer* aDisp = myWorkshop->displayer(); - //aDisp->openLocalContext(); - //aDisp->activateObjects(QIntList()); - QIntList aModes; - aModes << TopAbs_FACE; - aDisp->activateObjects(aModes); - - myLabel->setText(myText); - myLabel->setToolTip(myTooltip); + myLabel->setText(myText); + myLabel->setToolTip(myTooltip); - connect(myWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onPlaneSelected())); - activateFilters(myWorkshop->module()->workshop(), true); + connect(myWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + activateFilters(myWorkshop->module()->workshop(), true); - aDisp->updateViewer(); - } + aDisp->updateViewer(); } void PartSet_WidgetSketchLabel::deactivate() diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 0207199bb..ab7cd18eb 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -97,7 +97,7 @@ protected: /// Fills the attribute with the value of the selected owner /// \param theOwner a selected owner - virtual bool setSelection(const Handle_SelectMgr_EntityOwner& theOwner); + virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); /// Saves the internal parameters to the given feature /// \return True in success @@ -110,8 +110,8 @@ protected: virtual void activateCustom(); private slots: - /// Slot on plane selection - void onPlaneSelected(); + /// Slot on change selection + void onSelectionChanged(); /// Set sketch specific mode of selection //void setSketchingMode(); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 0eff27bb2..c30e93d56 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -243,7 +243,6 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) const TopoDS_Shape& aShape = aShapePrs->Shape(); std::shared_ptr anAISShapePtr(new GeomAPI_Shape()); anAISShapePtr->setImpl(new TopoDS_Shape(aShape)); - isEqualShapes = aShapePtr->isEqual(anAISShapePtr); } } @@ -251,8 +250,8 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) // Customization of presentation bool isCustomized = customizeObject(theObject); #ifdef DEBUG_FEATURE_REDISPLAY - qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3"). - arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).toStdString().c_str()); + //qDebug(QString("Redisplay: %1, isEqualShapes=%2, isCustomized=%3"). + // arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).toStdString().c_str()); #endif if (!isEqualShapes || isCustomized) { aContext->Redisplay(aAISIO, false); diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 56eea5db5..3f93b29ac 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -93,7 +93,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, XGUI_Displayer* aDisplayer = myWorkshop->displayer(); ObjectPtr aFeature = aDisplayer->getObject(anIO); - thePrs.setFeature(aFeature); + thePrs.setObject(aFeature); } QList XGUI_Selection::getHighlighted() const @@ -115,7 +115,7 @@ QList XGUI_Selection::getHighlighted() const ObjectPtr aResult = aDisplayer->getObject(anIO); // we should not check the appearance of this feature because there can be some selected shapes // for one feature - aPrs.setFeature(aResult); + aPrs.setObject(aResult); if (aContext->HasOpenedContext()) { TopoDS_Shape aShape = aContext->DetectedShape(); if (!aShape.IsNull()) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 7571de5f1..08d66b704 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -93,8 +93,8 @@ #include #endif -//#define DEBUG_FEATURE_CREATED -//#define DEBUG_FEATURE_REDISPLAY +#define DEBUG_FEATURE_CREATED +#define DEBUG_FEATURE_REDISPLAY QMap XGUI_Workshop::myIcons; @@ -565,6 +565,10 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptrcurrentOperation(); if (aOperation && aOperation->hasObject(aObj)) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + #ifdef DEBUG_FEATURE_REDISPLAY + QString anObjInfo = ModuleBase_Tools::objectInfo((aObj)); + qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str()); + #endif if (displayObject(aObj)) { // Deactivate object of current operation from selection if (myDisplayer->isActive(aObj))