virtual void moduleSelectionModes(int theModesType, QIntList& theModes) = 0;
/// Appends into container of filters module filters corresponded to the modes type
- /// \param theModesType combination of available selection filters
+ /// \param theFilterTypes container of available selection filters
/// \param theSelectionFilters [out] container to be extend by elements
- virtual void moduleSelectionFilters(int theModesType,
+ virtual void moduleSelectionFilters(const QIntList& theFilterTypes,
SelectMgr_ListOfFilter& theSelectionFilters) = 0;
+ /// Returns types of registered module selection filters
+ /// \param theSelectionFilters [out] container of type value
+ virtual QIntList selectionFilters() { return QIntList(); }
+
/// Return true if the custom presentation is activated
/// \param theFlag a flag of level of customization, which means that only part of sub-elements
/// \return boolean value
}
//**************************************************************
-void ModuleBase_ModelWidget::selectionFilters(int& theModuleSelectionFilters,
+void ModuleBase_ModelWidget::selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters)
{
- theModuleSelectionFilters = -1;
if (myWidgetValidator)
myWidgetValidator->selectionFilters(theModuleSelectionFilters, theSelectionFilters);
}
/// Appends into container of workshop selection filters
/// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
/// \param [out] theSelectionFilters selection filters
- virtual void selectionFilters(int& theModuleSelectionFilters,
+ virtual void selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters);
/// Returns true, if default value of the widget should be computed
//
#include <ModuleBase_WidgetValidated.h>
+#include <ModuleBase_IModule.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ISelection.h>
// it is not yet activated, so we need to activate/deactivate it manually
bool isActivated = isFilterActivated();
if (!isActivated) {
- int aModuleSelectionFilters = -1;
+ QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
SelectMgr_ListOfFilter aSelectionFilters;
selectionFilters(aModuleSelectionFilters, aSelectionFilters);
/// after validation, the selection filters should be restored
}
//********************************************************************
-void ModuleBase_WidgetValidated::selectionFilters(int& theModuleSelectionFilters,
+void ModuleBase_WidgetValidated::selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters)
{
- theModuleSelectionFilters = -1;
theSelectionFilters.Append(myWorkshop->validatorFilter());
}
/// Appends into container of workshop selection filters
/// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
/// \param [out] selection filters
- virtual void selectionFilters(int& theModuleSelectionFilters,
+ virtual void selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters);
/// Block the model flush of update and intialization of attribute
}
//********************************************************************
-void ModuleBase_WidgetValidator::selectionFilters(int& theModuleSelectionFilters,
+void ModuleBase_WidgetValidator::selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters)
{
- theModuleSelectionFilters = -1;
theSelectionFilters.Append(myWorkshop->validatorFilter());
}
/// Appends into container of workshop selection filters
/// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
/// \param [out] selection filters
- virtual void selectionFilters(int& theModuleSelectionFilters,
+ virtual void selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters);
/// Returns true if the validation is activated
PartSet_PreviewPlanes.h
PartSet_PreviewSketchPlane.h
PartSet_ResultSketchPrs.h
+ PartSet_SelectionFilterType.h
PartSet_SketcherMgr.h
PartSet_SketcherReentrantMgr.h
PartSet_Tools.h
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
- mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop));
- mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop));
+ registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
+ registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
setDefaultConstraintShown();
//******************************************************
PartSet_Module::~PartSet_Module()
{
- SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters);
- for (; aIt.More(); aIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = aIt.Value();
+ std::map<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
+ Handle(SelectMgr_Filter) aFilter = aFiltersIt->second;
if (!aFilter.IsNull())
aFilter.Nullify();
}
}
//******************************************************
-void PartSet_Module::moduleSelectionFilters(int theModesType,
+void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes,
SelectMgr_ListOfFilter& theSelectionFilters)
{
- //XGUI_Tools::workshop(myWorkshop)->selectionFilters(theSelectionFilters);
- //selectionFilters(theSelectionFilters);
+ bool isSketchActive = mySketchMgr->activeSketch();
- for (SelectMgr_ListOfFilter::Iterator aFiltersIt(mySelectionFilters); aFiltersIt.More();
- aFiltersIt.Next())
- theSelectionFilters.Append(aFiltersIt.Value());
+ std::map<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
+ int aFilterType = aFiltersIt->first;
+ // do not add not participating filters in given parameters
+ if (!theFilterTypes.contains(aFilterType))
+ continue;
- if (mySketchMgr->activeSketch())
- mySketchMgr->selectionFilters(theSelectionFilters);
+ // using sketch filters only if sketch operation is active
+ if (!isSketchActive &&
+ mySketchMgr->sketchSelectionFilter((PartSet_SelectionFilterType)aFilterType))
+ continue;
+
+ theSelectionFilters.Append(aFiltersIt->second);
+ }
+}
+
+//******************************************************
+QIntList PartSet_Module::selectionFilters()
+{
+ QIntList aTypes;
+
+ std::map<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ mySelectionFilters.begin();
+ for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++)
+ aTypes.append(aFiltersIt->first);
+
+ return aTypes;
+}
+
+//******************************************************
+void PartSet_Module::registerSelectionFilter(const PartSet_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter)
+{
+ mySelectionFilters[theFilterType] = theFilter;
+}
+
+//******************************************************
+Handle(SelectMgr_Filter) PartSet_Module::selectionFilter(
+ const PartSet_SelectionFilterType theFilterType)
+{
+ if (mySelectionFilters.find(theFilterType) != mySelectionFilters.end())
+ return mySelectionFilters[theFilterType];
+ else
+ return Handle(SelectMgr_Filter)();
}
//******************************************************
#include "PartSet.h"
#include "PartSet_Tools.h"
#include "PartSet_OverconstraintListener.h"
+#include "PartSet_SelectionFilterType.h"
#include "PartSet_SketcherMgr.h"
#include <ModuleBase_IModule.h>
//#include <StdSelect_FaceFilter.hxx>
#include <TopoDS_Shape.hxx>
#include <SelectMgr_ListOfFilter.hxx>
+#include <SelectMgr_Filter.hxx>
#include <QMap>
#include <QMenu>
#include <QObject>
#include <QModelIndex>
-#include <string>
-
+#include <map>
#include <memory>
+#include <string>
class ModuleBase_Operation;
class ModuleBase_IViewWindow;
virtual void moduleSelectionModes(int theModesType, QIntList& theModes);
/// Appends into container of filters module filters corresponded to the modes type
- /// \param theModesType combination of available selection filters
+ /// \param theFilterTypes container of available selection filters
/// \param theSelectionFilters [out] container to be extend by elements
- virtual void moduleSelectionFilters(int theModesType,
+ virtual void moduleSelectionFilters(const QIntList& theFilterTypes,
SelectMgr_ListOfFilter& theSelectionFilters);
+ /// Returns types of registered module selection filters
+ /// \param theSelectionFilters [out] container of type value
+ virtual QIntList selectionFilters();
+
+ /// Append selection filter into the module and type of the filter in internal container
+ /// \param theFilterType selection filter type
+ /// \param theFilter added filter
+ void registerSelectionFilter(const PartSet_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter);
+
+ /// Returns selection filter
+ /// \param theFilterType selection filter type
+ /// \param theFilter instance of filter
+ Handle(SelectMgr_Filter) selectionFilter(const PartSet_SelectionFilterType theFilterType);
+
/// Returns whether the mouse enter the viewer's window
/// \return true if items are added and there is no necessity to provide standard menu
bool isMouseOverWindow();
private:
bool myIsOperationIsLaunched; /// state of application between launch and stop operation
- SelectMgr_ListOfFilter mySelectionFilters;
+ std::map<PartSet_SelectionFilterType, Handle(SelectMgr_Filter)> mySelectionFilters;
PartSet_SketcherMgr* mySketchMgr;
PartSet_SketcherReentrantMgr* mySketchReentrantMgr;
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// 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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef PartSet_SelectionFilterType_H
+#define PartSet_SelectionFilterType_H
+
+/// Enumeration to specify module selection filters
+enum PartSet_SelectionFilterType {
+ SF_GlobalFilter, /// filter for different documents, group results
+ SF_FilterInfinite, /// filter for infinite construction results
+ SF_SketchCirclePointFilter, /// filter for selection circle points on current sketch
+ SF_SketchPlaneFilter /// filter for selection in the current sketch plane only
+};
+
+#endif
//
#include "PartSet_SketcherMgr.h"
+
+#include "PartSet_Filters.h"
#include "PartSet_SketcherReentrantMgr.h"
#include "PartSet_Module.h"
#include "PartSet_MouseProcessor.h"
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_ViewerFilters.h>
#include <GeomDataAPI_Point2D.h>
mySketchPlane = new PartSet_PreviewSketchPlane();
- myCirclePointFilter = new PartSet_CirclePointFilter(anIWorkshop);
- myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
+ registerSelectionFilter(SF_SketchCirclePointFilter, new PartSet_CirclePointFilter(anIWorkshop));
+ registerSelectionFilter(SF_SketchPlaneFilter, new ModuleBase_ShapeInPlaneFilter());
}
PartSet_SketcherMgr::~PartSet_SketcherMgr()
{
- myPlaneFilter.Nullify();
- myCirclePointFilter.Nullify();
}
void PartSet_SketcherMgr::onEnterViewPort()
bool aHasPlane = false;
std::shared_ptr<GeomAPI_Pln> aPln;
aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
- myPlaneFilter->setPlane(aPln);
+ Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull())
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
workshop()->selectionActivate()->updateSelectionFilters();
workshop()->selectionActivate()->updateSelectionModes();
}
}
-void PartSet_SketcherMgr::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const
+bool PartSet_SketcherMgr::sketchSelectionFilter(const PartSet_SelectionFilterType theFilterType)
{
- theSelectionFilters.Append(myCirclePointFilter);
- theSelectionFilters.Append(myPlaneFilter);
+ return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end();
+}
+
+void PartSet_SketcherMgr::registerSelectionFilter(const PartSet_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter)
+{
+ mySelectionFilterTypes.insert(theFilterType);
+ myModule->registerSelectionFilter(theFilterType, theFilter);
}
bool PartSet_SketcherMgr::operationActivatedByPreselection()
return isFoundObject;
}
-void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
+void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePlane)
{
- myPlaneFilter->setPlane(thePln);
+ Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull())
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(thePlane);
+
workshop()->selectionActivate()->updateSelectionModes();
}
#include "PartSet.h"
-#include "PartSet_Filters.h"
-#include "PartSet_Tools.h"
#include "PartSet_PreviewSketchPlane.h"
+#include "PartSet_SelectionFilterType.h"
+#include "PartSet_Tools.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Result.h>
-#include <ModuleBase_ViewerFilters.h>
#include <ModuleBase_Definitions.h>
#include <ModuleBase_ModelWidget.h>
#include <QList>
#include <QMap>
+#include <set>
+
class PartSet_Module;
class ModuleBase_IViewWindow;
class ModuleBase_ModelWidget;
/// \param theOperation a committed operation
void commitNestedSketch(ModuleBase_Operation* theOperation);
- /// Appends into container of workshop selection filters
- /// \param [out] selection filters
- virtual void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters) const;
+ /// Returns true if the filter is created by the sketch manager
+ /// \param theFilterType a checked type
+ /// \return boolean value
+ bool sketchSelectionFilter(const PartSet_SelectionFilterType theFilterType);
+
+ /// Append selection filter into the module and type of the filter in internal container
+ /// \param theFilterType selection filter type
+ /// \param theFilter added filter
+ void registerSelectionFilter(const PartSet_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter);
/// Commit the operation if it is possible. If the operation is dimention constraint,
/// it gives widget editor to input dimention value
CompositeFeaturePtr myCurrentSketch;
- Handle(PartSet_CirclePointFilter) myCirclePointFilter;
- Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
+ std::set<PartSet_SelectionFilterType> mySelectionFilterTypes;
+
FeatureToSelectionMap myCurrentSelection;
bool myPreviousUpdateViewerEnabled;
}
//********************************************************************
-void PartSet_WidgetShapeSelector::selectionFilters(int& theModuleSelectionFilters,
+void PartSet_WidgetShapeSelector::selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters)
{
ModuleBase_WidgetShapeSelector::selectionFilters(theModuleSelectionFilters, theSelectionFilters);
if (!myUseSketchPlane) {
- theModuleSelectionFilters = -1; // TODO!!!
-
- //XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
- //PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(aWorkshop->module());
- //bool isUsePlaneFilterOnly = !toActivate;
- //aModule->sketchMgr()->activatePlaneFilter(isUsePlaneFilterOnly);
+ if (theModuleSelectionFilters.contains(SF_SketchPlaneFilter))
+ theModuleSelectionFilters.removeAll(SF_SketchPlaneFilter);
}
}
/// Appends into container of workshop selection filters
/// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
/// \param [out] theSelectionFilters selection filters
- virtual void selectionFilters(int& theModuleSelectionFilters,
+ virtual void selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters);
protected:
theModes << TopAbs_FACE;
}
-void PartSet_WidgetSketchLabel::selectionFilters(int& theModuleSelectionFilters,
+void PartSet_WidgetSketchLabel::selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters)
{
- theModuleSelectionFilters = -1;
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
if (aPlane.get())
return;
/// Using widget selection filter only if plane is not defined.
/// \param [out] theModuleSelectionFilters module additional modes, -1 means all default modes
/// \param [out] selection filters
- virtual void selectionFilters(int& theModuleSelectionFilters,
+ virtual void selectionFilters(QIntList& theModuleSelectionFilters,
SelectMgr_ListOfFilter& theSelectionFilters);
/// Returns list of widget controls
SelectMgr_ListOfFilter aSelectionFilters;
switch (activeSelectionPlace()) {
case Workshop:
- myWorkshop->module()->moduleSelectionFilters(-1/*all filters*/, aSelectionFilters);
+ myWorkshop->module()->moduleSelectionFilters(myWorkshop->module()->selectionFilters(),
+ aSelectionFilters);
break;
case PropertyPanel: {
ModuleBase_ModelWidget* anActiveWidget = myWorkshop->module()->activeWidget();
- int aModuleSelectionFilters = -1;
+ QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
if (anActiveWidget)
anActiveWidget->selectionFilters(aModuleSelectionFilters, aSelectionFilters);
myWorkshop->module()->moduleSelectionFilters(aModuleSelectionFilters, aSelectionFilters);