From: vsv Date: Thu, 8 Nov 2018 15:08:04 +0000 (+0300) Subject: Create filtering launch widget X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c1db53e7dcd345197dbe2e65721d20657d9029d1;p=modules%2Fshaper.git Create filtering launch widget --- 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 000000000..036428b97 Binary files /dev/null and b/src/XGUI/pictures/filter.png differ diff --git a/src/XGUI/pictures/plus_minus.png b/src/XGUI/pictures/plus_minus.png new file mode 100644 index 000000000..9e25d17f0 Binary files /dev/null and b/src/XGUI/pictures/plus_minus.png differ