--- /dev/null
+// 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 =
+"<filter id = \"Belongs to\""
+" <multi_selector id=\"Belongs to\""
+" label = \"Objects:\""
+" tooltip = \"Select objects to limit selection.\""
+" type_choice = \"objects\""
+" </multi_selector>"
+"</filter>";
+
+
+std::string FiltersPlugin_BelongsTo::xmlRepresentation() const
+{
+ return XMLRepresentation;
+}
\ No newline at end of file
--- /dev/null
+// 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 <ModelAPI_Filter.h>
+
+/**\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
/// \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;
};
: QWidget(theParent), myFilterID(theFilter),
mySelection(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theSelection))
{
+ std::string aXmlString = ModelAPI_Session::get()->filters()->filter(theFilter)->xmlRepresentation();
+
QHBoxLayout* aLayout = new QHBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
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()
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 =
updateNumberSelected();
}
+void ModuleBase_WidgetSelectionFilter::onReverseItem(ModuleBase_FilterItem* theItem)
+{
+ updateSelectBtn();
+ clearCurrentSelection(true);
+ updateNumberSelected();
+}
+
void ModuleBase_WidgetSelectionFilter::onSelect()
{
if (myUseFilters.size() == 0)
signals:
void deleteItem(ModuleBase_FilterItem* theItem);
+ void reversedItem(ModuleBase_FilterItem* theItem);
- private slots:
+private slots:
void onReverse(bool theCheck);
void onDelete();
private slots:
void onAddFilter(int);
void onDeleteItem(ModuleBase_FilterItem* theItem);
+ void onReverseItem(ModuleBase_FilterItem* theItem);
void onSelect();
void onShowOnly(bool theErase);