From: nds Date: Tue, 20 Jan 2015 12:18:25 +0000 (+0300) Subject: Issue #336 Create/Edit Line -filter for first and last point fields X-Git-Tag: V_1.0.0~22^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c83711b84608b7bcc43251790268b4e3d268e328;p=modules%2Fshaper.git Issue #336 Create/Edit Line -filter for first and last point fields It creates a new custom filter to ignore the global selected construction results with an exception of the sketch feature(a composite feature). --- diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index 7729b2a9e..364fa2b3c 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -6,11 +6,13 @@ icon=":icons/point.png" tooltip="Select a first point" shape_types="vertex"> + + diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 149ae4797..6d7fc7cf2 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -6,11 +6,13 @@ 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_FilterShapeType.h + ModuleBase_FilterMulti.h + ModuleBase_FilterNoConsructionSubShapes.h + ModuleBase_FilterShapeType.h ModuleBase_Tools.h ModuleBase_IModule.h ModuleBase_Operation.h @@ -44,11 +46,13 @@ 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_FilterShapeType.cpp + ModuleBase_FilterMulti.cpp + ModuleBase_FilterNoConsructionSubShapes.cpp + ModuleBase_FilterShapeType.cpp ModuleBase_Tools.cpp ModuleBase_IModule.cpp ModuleBase_IWorkshop.cpp @@ -73,11 +77,11 @@ SET(PROJECT_SOURCES ) SET(PROJECT_LIBRARIES - Config - ModelAPI + Config + ModelAPI GeomAPI GeomAlgoAPI - ${QT_LIBRARIES} + ${QT_LIBRARIES} ${CAS_VIEWER} ${CAS_KERNEL} ${CAS_SHAPE} diff --git a/src/ModuleBase/ModuleBase_FilterCustom.cpp b/src/ModuleBase/ModuleBase_FilterCustom.cpp new file mode 100644 index 000000000..49ea31e14 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterCustom.cpp @@ -0,0 +1,30 @@ +// 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 new file mode 100644 index 000000000..6683207cc --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterCustom.h @@ -0,0 +1,44 @@ +// 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" + +/** +* 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_FilterNoConsructionSubShapes.cpp b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp new file mode 100644 index 000000000..feaac1c18 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.cpp @@ -0,0 +1,63 @@ +// 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; + } + } + } + return Standard_False; +} + diff --git a/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h new file mode 100644 index 000000000..49b112799 --- /dev/null +++ b/src/ModuleBase/ModuleBase_FilterNoConsructionSubShapes.h @@ -0,0 +1,44 @@ +// 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; + +/** +* 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: + 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: + ModuleBase_IWorkshop* myWorkshop; +}; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index e57640745..361f6383d 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -366,11 +366,15 @@ bool ModuleBase_WidgetShapeSelector::acceptObjectType(const ObjectPtr theObject) void ModuleBase_WidgetShapeSelector::updateSelectionName() { DataPtr aData = myFeature->data(); - AttributeSelectionPtr aSelect = aData->selection(attributeID()); - if (aSelect) { - myTextLine->setText(QString::fromStdString(aSelect->namingName())); + bool isNameUpdated = false; + if (aData.get() != NULL) { + AttributeSelectionPtr aSelect = aData->selection(attributeID()); + if (aSelect) { + myTextLine->setText(QString::fromStdString(aSelect->namingName())); + isNameUpdated = true; + } } - else { + if (!isNameUpdated) { if (mySelectedObject) { std::string aName = mySelectedObject->data()->name(); myTextLine->setText(QString::fromStdString(aName)); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index d5f96e489..797fcd116 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -18,7 +18,8 @@ #include #include #include - +#include +#include #include #include @@ -126,6 +127,9 @@ void PartSet_Module::registerFilters() 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)); } void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)