From: vsv Date: Tue, 4 Jun 2019 11:55:00 +0000 (+0300) Subject: Add BelongsTo filter prototipe X-Git-Tag: VEDF2019Lot4~101^2~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=38f557fe5c90f6b272ddc70e22a06eacf0fb4b45;p=modules%2Fshaper.git Add BelongsTo filter prototipe --- diff --git a/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp b/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp new file mode 100644 index 000000000..0f4f9b58a --- /dev/null +++ b/src/FiltersPlugin/FiltersPlugin_BelongsTo.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2014-2019 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 +// + +#include "FiltersPlugin_BelongsTo.h" + +bool FiltersPlugin_BelongsTo::isSupported(GeomAPI_Shape::ShapeType theType) const +{ + return true; +} + +bool FiltersPlugin_BelongsTo::isOk(const GeomShapePtr& theShape, + const ModelAPI_FiltersArgs& theArgs) const +{ + return true; +} + +static std::string XMLRepresentation = +"" +""; + + +std::string FiltersPlugin_BelongsTo::xmlRepresentation() const +{ + return XMLRepresentation; +} \ No newline at end of file diff --git a/src/FiltersPlugin/FiltersPlugin_BelongsTo.h b/src/FiltersPlugin/FiltersPlugin_BelongsTo.h new file mode 100644 index 000000000..197626930 --- /dev/null +++ b/src/FiltersPlugin/FiltersPlugin_BelongsTo.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2019 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 +// + +#ifndef FILTERSPLUGIN_BELONGSTO_H_ +#define FILTERSPLUGIN_BELONGSTO_H_ + +#include "FiltersPlugin.h" + +#include + +/**\class FiltersPlugin_HorizontalFace +* \ingroup DataModel +* \brief Filter for horizontal faces only +*/ +class FiltersPlugin_BelongsTo : public ModelAPI_Filter +{ +public: + FiltersPlugin_BelongsTo() : ModelAPI_Filter() {} + + virtual const std::string& name() const { + static const std::string kName("Belongs to"); + return kName; + } + + /// Returns true for any type because it supports all selection types + virtual bool isSupported(GeomAPI_Shape::ShapeType theType) const override; + + /// This method should contain the filter logic. It returns true if the given shape + /// is accepted by the filter. + /// \param theShape the given shape + virtual bool isOk(const GeomShapePtr& theShape, + const ModelAPI_FiltersArgs& theArgs) const override; + + /// Returns XML string which represents GUI of the filter + virtual std::string xmlRepresentation() const override; +}; + +#endif \ No newline at end of file diff --git a/src/ModelAPI/ModelAPI_Filter.h b/src/ModelAPI/ModelAPI_Filter.h index 4399e1063..e313d9f24 100644 --- a/src/ModelAPI/ModelAPI_Filter.h +++ b/src/ModelAPI/ModelAPI_Filter.h @@ -73,6 +73,10 @@ public: /// \param theShape the given shape virtual bool isOk(const GeomShapePtr& theShape, const ModelAPI_FiltersArgs& theArgs) const = 0; + /// Returns XML string which represents GUI of the filter + /// By default it retrurns nothing (no GUI) + virtual std::string xmlRepresentation() const { return ""; } + private: bool myIsReverse; }; diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp index 9da94eb6c..d8b9233c8 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -128,6 +128,8 @@ ModuleBase_FilterItem::ModuleBase_FilterItem( : QWidget(theParent), myFilterID(theFilter), mySelection(std::dynamic_pointer_cast(theSelection)) { + std::string aXmlString = ModelAPI_Session::get()->filters()->filter(theFilter)->xmlRepresentation(); + QHBoxLayout* aLayout = new QHBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); @@ -155,11 +157,12 @@ ModuleBase_FilterItem::ModuleBase_FilterItem( void ModuleBase_FilterItem::onReverse(bool theCheck) { - //mySelection->setReversed(myFilterID, theCheck); + mySelection->setReversed(myFilterID, theCheck); if (theCheck) myRevBtn->setIcon(QIcon(":pictures/reverce.png")); else myRevBtn->setIcon(QIcon(":pictures/add.png")); + emit reversedItem(this); } void ModuleBase_FilterItem::onDelete() @@ -292,9 +295,11 @@ void ModuleBase_WidgetSelectionFilter::onAddFilter(int theIndex) if (!aFilter.empty()) { myUseFilters.push_back(aFilter); ModuleBase_FilterItem* aItem = - new ModuleBase_FilterItem(aFilter, mySelectorFeature, myFiltersWgt); + new ModuleBase_FilterItem(aFilter, myFeature, myFiltersWgt); connect(aItem, SIGNAL(deleteItem(ModuleBase_FilterItem*)), SLOT(onDeleteItem(ModuleBase_FilterItem*))); + connect(aItem, SIGNAL(reversedItem(ModuleBase_FilterItem*)), + SLOT(onReverseItem(ModuleBase_FilterItem*))); myFiltersLayout->addWidget(aItem); FiltersFeaturePtr aFiltersFeature = @@ -327,6 +332,13 @@ void ModuleBase_WidgetSelectionFilter::onDeleteItem(ModuleBase_FilterItem* theIt updateNumberSelected(); } +void ModuleBase_WidgetSelectionFilter::onReverseItem(ModuleBase_FilterItem* theItem) +{ + updateSelectBtn(); + clearCurrentSelection(true); + updateNumberSelected(); +} + void ModuleBase_WidgetSelectionFilter::onSelect() { if (myUseFilters.size() == 0) diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h index 39645d88b..381ed5f4b 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h @@ -74,8 +74,9 @@ public: signals: void deleteItem(ModuleBase_FilterItem* theItem); + void reversedItem(ModuleBase_FilterItem* theItem); - private slots: +private slots: void onReverse(bool theCheck); void onDelete(); @@ -113,6 +114,7 @@ protected: private slots: void onAddFilter(int); void onDeleteItem(ModuleBase_FilterItem* theItem); + void onReverseItem(ModuleBase_FilterItem* theItem); void onSelect(); void onShowOnly(bool theErase);