From c1db53e7dcd345197dbe2e65721d20657d9029d1 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 8 Nov 2018 18:08:04 +0300 Subject: [PATCH] Create filtering launch widget --- src/CollectionPlugin/group_widget.xml | 1 + src/ModuleBase/CMakeLists.txt | 3 + src/ModuleBase/ModuleBase_ChoiceCtrl.cpp | 2 +- .../ModuleBase_WidgetMultiSelector.cpp | 45 +++++++------ .../ModuleBase_WidgetMultiSelector.h | 3 + .../ModuleBase_WidgetSelectionFilter.cpp | 59 ++++++++++++++++++ .../ModuleBase_WidgetSelectionFilter.h | 49 +++++++++++++++ src/PartSet/PartSet_WidgetSketchCreator.cpp | 4 -- src/XGUI/XGUI_pictures.qrc | 3 + src/XGUI/pictures/filter.png | Bin 0 -> 437 bytes src/XGUI/pictures/plus_minus.png | Bin 0 -> 505 bytes 11 files changed, 146 insertions(+), 23 deletions(-) create mode 100644 src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp create mode 100644 src/ModuleBase/ModuleBase_WidgetSelectionFilter.h create mode 100644 src/XGUI/pictures/filter.png create mode 100644 src/XGUI/pictures/plus_minus.png diff --git a/src/CollectionPlugin/group_widget.xml b/src/CollectionPlugin/group_widget.xml index 4696d9e79..7f1f874cd 100644 --- a/src/CollectionPlugin/group_widget.xml +++ b/src/CollectionPlugin/group_widget.xml @@ -28,6 +28,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index ee79fe186..be394b094 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -104,6 +104,7 @@ SET(PROJECT_HEADERS ModuleBase_WidgetRadiobox.h ModuleBase_WidgetPointInput.h ModuleBase_ITreeNode.h + ModuleBase_WidgetSelectionFilter.h ) SET(PROJECT_MOC_HEADERS @@ -153,6 +154,7 @@ SET(PROJECT_MOC_HEADERS ModuleBase_WidgetNameEdit.h ModuleBase_WidgetRadiobox.h ModuleBase_WidgetPointInput.h + ModuleBase_WidgetSelectionFilter.h ) SET(PROJECT_SOURCES @@ -221,6 +223,7 @@ SET(PROJECT_SOURCES ModuleBase_WidgetNameEdit.cpp ModuleBase_WidgetRadiobox.cpp ModuleBase_WidgetPointInput.cpp + ModuleBase_WidgetSelectionFilter.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/ModuleBase/ModuleBase_ChoiceCtrl.cpp b/src/ModuleBase/ModuleBase_ChoiceCtrl.cpp index 67b5b6f18..2f35c0e0a 100644 --- a/src/ModuleBase/ModuleBase_ChoiceCtrl.cpp +++ b/src/ModuleBase/ModuleBase_ChoiceCtrl.cpp @@ -38,7 +38,7 @@ ModuleBase_ChoiceCtrl::ModuleBase_ChoiceCtrl(QWidget* theParent, : QWidget(theParent), myType(theType) { QHBoxLayout* aLayout = new QHBoxLayout(this); - ModuleBase_Tools::adjustMargins(aLayout); + aLayout->setContentsMargins(0, 0, 0, 0); switch (myType) { case RadioButtons: diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index d81556ac1..548342f58 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -119,14 +120,14 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen myShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts); myIsUseChoice = theData->getBooleanAttribute("use_choice", false); - QGridLayout* aMainLay = new QGridLayout(this); + QVBoxLayout* aMainLay = new QVBoxLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); QStringList aIconsList = getIconsList(myShapeTypes); myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList); myTypeCtrl->setLabel(tr("Type")); myTypeCtrl->setValue(0); - aMainLay->addWidget(myTypeCtrl, 0, 0, 1, 2); + aMainLay->addWidget(myTypeCtrl); myDefMode = myShapeTypes.first().toStdString(); // There is no sense to parameterize list of types while we can not parameterize selection mode @@ -136,18 +137,30 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen } QString aLabelText = translate(theData->getProperty("label")); - QLabel* aListLabel = new QLabel(aLabelText, this); - aMainLay->addWidget(aListLabel, 1, 0); - // if the xml definition contains one type, an information label - // should be shown near to the latest - if (myShapeTypes.size() <= 1) { - QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); - if (!aLabelIcon.isEmpty()) { - QLabel* aSelectedLabel = new QLabel("", this); - aSelectedLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon)); - aMainLay->addWidget(aSelectedLabel, 1, 1); + if (aLabelText.size() > 0) { + QWidget* aLabelWgt = new QWidget(this); + QHBoxLayout* aLabelLayout = new QHBoxLayout(aLabelWgt); + aLabelLayout->setContentsMargins(0, 0, 0, 0); + aMainLay->addWidget(aLabelWgt); + + QLabel* aListLabel = new QLabel(aLabelText, this); + aLabelLayout->addWidget(aListLabel); + // if the xml definition contains one type, an information label + // should be shown near to the latest + if (myShapeTypes.size() <= 1) { + QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); + if (!aLabelIcon.isEmpty()) { + QLabel* aSelectedLabel = new QLabel("", this); + aSelectedLabel->setPixmap(ModuleBase_IconFactory::loadPixmap(aLabelIcon)); + aLabelLayout->addWidget(aSelectedLabel); + aLabelLayout->addStretch(1); + } } - aMainLay->setColumnStretch(2, 1); + } + bool aUseFilters = theData->getBooleanAttribute("use_filters", false); + if (aUseFilters) { + myFiltersWgt = new ModuleBase_FilterStarter(this, theWorkshop); + aMainLay->addWidget(myFiltersWgt); } QString aToolTip = QString::fromStdString(theData->widgetTooltip()); @@ -157,11 +170,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem())); connect(myListView, SIGNAL(listActivated()), SLOT(onListActivated())); - aMainLay->addWidget(myListView->getControl(), 2, 0, 1, -1); - aMainLay->setRowStretch(2, 1); - //aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)??? - //aMainLay->setRowMinimumHeight(3, 20); - //this->setLayout(aMainLay); + aMainLay->addWidget(myListView->getControl()); connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged())); myIsNeutralPointClear = theData->getBooleanAttribute("clear_in_neutral_point", true); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 1a40c1303..ec6612c1b 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -41,6 +41,7 @@ class QWidget; class ModuleBase_ListView; class ModuleBase_IWorkshop; class ModuleBase_ChoiceCtrl; +class ModuleBase_FilterStarter; /** * \ingroup GUI @@ -247,6 +248,8 @@ protected: bool myIsFirst; std::string myDefMode; + + ModuleBase_FilterStarter* myFiltersWgt; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp new file mode 100644 index 000000000..3120487ab --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -0,0 +1,59 @@ +// 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 +// + +#include "ModuleBase_WidgetSelectionFilter.h" +#include "ModuleBase_Tools.h" +#include "ModuleBase_IWorkshop.h" + +#include +#include +#include +#include + +ModuleBase_FilterStarter::ModuleBase_FilterStarter(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop) + : QWidget(theParent), + myWorkshop(theWorkshop) +{ + QHBoxLayout* aMainLayout = new QHBoxLayout(this); + ModuleBase_Tools::adjustMargins(aMainLayout); + + aMainLayout->addStretch(1); + QPushButton* aLaunchBtn = new QPushButton(tr("Selection by filters"), this); + connect(aLaunchBtn, SIGNAL(clicked()), SLOT(onFiltersLaunch())); + aMainLayout->addWidget(aLaunchBtn); + + myFilterLbl = new QLabel(this); + myFilterLbl->setPixmap(QPixmap(":pictures/filter.png")); + aMainLayout->addWidget(myFilterLbl); + + myModifyLbl = new QLabel(this); + myModifyLbl->setPixmap(QPixmap(":pictures/plus_minus.png")); + aMainLayout->addWidget(myModifyLbl); + aMainLayout->addStretch(1); + + myFilterLbl->hide(); + myModifyLbl->hide(); +} + +void ModuleBase_FilterStarter::onFiltersLaunch() +{ + +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h new file mode 100644 index 000000000..24a01ee3a --- /dev/null +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h @@ -0,0 +1,49 @@ +// 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 +// + +#ifndef ModuleBase_WidgetSelectionFilter_H +#define ModuleBase_WidgetSelectionFilter_H + +#include +#include + +class QLabel; +class ModuleBase_IWorkshop; + +class MODULEBASE_EXPORT ModuleBase_FilterStarter: public QWidget +{ + Q_OBJECT +public: + ModuleBase_FilterStarter(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop); + + ~ModuleBase_FilterStarter() {} + +private slots: + void onFiltersLaunch(); + +private: + QLabel* myFilterLbl; + QLabel* myModifyLbl; + + ModuleBase_IWorkshop* myWorkshop; +}; + + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 7f9fc5ada..9768badfd 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -383,10 +383,6 @@ bool PartSet_WidgetSketchCreator::startSketchOperation( bool aHidePreview = myPreviewPlanes->isPreviewDisplayed(); myPreviewPlanes->erasePreviewPlanes(myWorkshop); - // Launch Sketch operation - CompositeFeaturePtr aCompFeature = - std::dynamic_pointer_cast(myFeature); - // start edit operation for the sketch ModuleBase_OperationFeature* aFOperation = dynamic_cast (myModule->createOperation("Sketch")); diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index ea9614f94..ace18607c 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -77,5 +77,8 @@ pictures/autoapply_start.png pictures/autoapply_stop.png pictures/whatis.png + + pictures/filter.png + pictures/plus_minus.png diff --git a/src/XGUI/pictures/filter.png b/src/XGUI/pictures/filter.png new file mode 100644 index 0000000000000000000000000000000000000000..036428b97f6eaa1f0de04bb6c5755d18580f55fa GIT binary patch literal 437 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?&q9iy!t)x7$D3zfgF*C13FE6!3!9>qc z&$w6RZ#vLWHBT4E5DWk02Vnu3fm|Iw^F`+Snz6lPpLv*p$*FA``s#{C8$8UN%}*R(Er{Y^W{lk&yooPPKJBe#Y(w6Hb>Szt zC)k8&esl=9U(?tXeL?(s)2;soIrD-Tc#PXa15}qVcb|Atd}1B*$Av*p8UvZ#n;H+8 zY!{jm@7wfvonOR${kUt_zH)?gDJf{INH2>zru}CBiq^~3D=bYP d0|yuw-p;Rce9H0g5HM63JYD@<);T3K0RVx3sfqvq literal 0 HcmV?d00001 diff --git a/src/XGUI/pictures/plus_minus.png b/src/XGUI/pictures/plus_minus.png new file mode 100644 index 0000000000000000000000000000000000000000..9e25d17f0335fc3b647ea7d28c12279a1d4972bc GIT binary patch literal 505 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y9E;EfJ{bv9G0cuG^K~y+TrIbBN15p%(Bcu?5SVow^LL@~x z%XD@+Ger=b2cm+NLMkiKMzl&{W#a+_Yg_l=4qSksV38G!=RDq(m;0_}z`&PD&N=y# z$zP{wntzj*t_QYw+Z<$NeVbQqXmy$(djaoYlniiLLNUv#`b2jc?3ROU2HwCR8Ho^_ z=`IF+7d(comoZO z=bm!^(vOS!8OLiJFZhJ=0Ay3&m+lK}OD@da@qwIjRUhjP`Bfwv>z<^62n%-<=g1~O zMobw=14D@Wr;%(D?=@z)xqG-Gw;>n