From: vsv Date: Mon, 3 Jun 2019 13:05:43 +0000 (+0300) Subject: Update of GUI X-Git-Tag: VEDF2019Lot4~101^2~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3db5cdff1249e4f7186d8779ff191d511fc1e3b9;p=modules%2Fshaper.git Update of GUI --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 33fdafa0a..11c502778 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -157,11 +158,6 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen } } } - std::string aUseFilters = theData->getProperty("use_filters"); - if (aUseFilters.length() > 0) { - myFiltersWgt = new ModuleBase_FilterStarter(aUseFilters.c_str(), this, theWorkshop); - aMainLay->addWidget(myFiltersWgt); - } QString aToolTip = QString::fromStdString(theData->widgetTooltip()); QString anObjName = QString::fromStdString(attributeID()); @@ -173,6 +169,23 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen aMainLay->addWidget(myListView->getControl()); connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged())); + std::string aUseFilters = theData->getProperty("use_filters"); + if (aUseFilters.length() > 0) { + QWidget* aFltrWgt = new QWidget(this); + QHBoxLayout* aFltrLayout = new QHBoxLayout(aFltrWgt); + + myFiltersWgt = new ModuleBase_FilterStarter(aUseFilters.c_str(), aFltrWgt, theWorkshop); + aFltrLayout->addWidget(myFiltersWgt); + + aFltrLayout->addStretch(); + + QPushButton* aShowBtn = new QPushButton(tr("Show only"), aFltrWgt); + connect(aShowBtn, SIGNAL(clicked(bool)), SLOT(onShowOnly())); + aFltrLayout->addWidget(aShowBtn); + + aMainLay->addWidget(aFltrWgt); + } + bool aSameTop = theData->getBooleanAttribute("same_topology", false); if (aSameTop) { myGeomCheck = new QCheckBox(tr("Add elements that share the same topology"), this); @@ -1075,3 +1088,8 @@ void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn) updateObject(myFeature); } } + +void ModuleBase_WidgetMultiSelector::onShowOnly() +{ + +} diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index b77ea969f..651526ea8 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -135,6 +135,8 @@ protected slots: void onSameTopology(bool theOn); + void onShowOnly(); + protected: /// Returns true if the event is processed. The default implementation is empty, returns false. virtual bool processDelete(); diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp index 5112ba68b..9da94eb6c 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -43,6 +43,7 @@ #include #include #include +#include static FeaturePtr SelectorFeature; static std::string AttributeId; @@ -101,8 +102,15 @@ ModuleBase_FilterStarter::ModuleBase_FilterStarter(const std::string& theFeature void ModuleBase_FilterStarter::onFiltersLaunch() { + QWidget* aParent = parentWidget(); ModuleBase_WidgetMultiSelector* aSelector = - dynamic_cast(parent()); + dynamic_cast(aParent); + while (!aSelector) { + aParent = aParent->parentWidget(); + aSelector = dynamic_cast(aParent); + } + if (!aSelector) + return; SelectorFeature = aSelector->feature(); AttributeId = aSelector->attributeID(); @@ -121,14 +129,14 @@ ModuleBase_FilterItem::ModuleBase_FilterItem( mySelection(std::dynamic_pointer_cast(theSelection)) { QHBoxLayout* aLayout = new QHBoxLayout(this); - aLayout->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::zeroMargins(aLayout); // Reverse filter button myRevBtn = new QToolButton(this); myRevBtn->setCheckable(true); myRevBtn->setChecked(false); myRevBtn->setAutoRaise(true); - myRevBtn->setIcon(QIcon(":pictures/accept.png")); + myRevBtn->setIcon(QIcon(":pictures/add.png")); myRevBtn->setToolTip(tr("Reverse the filter")); connect(myRevBtn, SIGNAL(toggled(bool)), SLOT(onReverse(bool))); aLayout->addWidget(myRevBtn); @@ -137,23 +145,21 @@ ModuleBase_FilterItem::ModuleBase_FilterItem( aLayout->addWidget(new QLabel(aFilterName.c_str(), this), 1); QToolButton* aDelBtn = new QToolButton(this); - aDelBtn->setIcon(QIcon(":pictures/button_cancel.png")); + aDelBtn->setIcon(QIcon(":pictures/delete.png")); aDelBtn->setAutoRaise(true); aDelBtn->setToolTip(tr("Delete the filter")); connect(aDelBtn, SIGNAL(clicked(bool)), SLOT(onDelete())); aLayout->addWidget(aDelBtn); - - myRevBtn->setChecked(mySelection->isReversed(myFilterID)); } void ModuleBase_FilterItem::onReverse(bool theCheck) { - mySelection->setReversed(myFilterID, theCheck); + //mySelection->setReversed(myFilterID, theCheck); if (theCheck) - myRevBtn->setIcon(QIcon(":pictures/stop.png")); + myRevBtn->setIcon(QIcon(":pictures/reverce.png")); else - myRevBtn->setIcon(QIcon(":pictures/accept.png")); + myRevBtn->setIcon(QIcon(":pictures/add.png")); } void ModuleBase_FilterItem::onDelete() @@ -183,19 +189,18 @@ ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theP QVBoxLayout* aMainLayout = new QVBoxLayout(this); ModuleBase_Tools::adjustMargins(aMainLayout); - myFiltersGroup = new QGroupBox(tr("Dynamic Filters"), this); - myGroupLayout = new QVBoxLayout(myFiltersGroup); - myGroupLayout->setContentsMargins(0, 0, 0, 0); - myGroupLayout->setSpacing(0); - - QWidget* aFiltersWgt = new QWidget(myFiltersGroup); - QHBoxLayout* aFiltersLay = new QHBoxLayout(aFiltersWgt); - ModuleBase_Tools::adjustMargins(aFiltersLay); + QGroupBox* aFiltersGroup = new QGroupBox(tr("Filters"), this); + QVBoxLayout* aGroupLayout = new QVBoxLayout(aFiltersGroup); + aGroupLayout->setContentsMargins(0, 0, 0, 0); + aGroupLayout->setSpacing(0); - QLabel* aFilterLbl = new QLabel(aFiltersWgt); - aFilterLbl->setPixmap(QPixmap(":pictures/filter.png")); + myFiltersWgt = new QWidget(); + myFiltersLayout = new QVBoxLayout(myFiltersWgt); + myFiltersLayout->setContentsMargins(0, 0, 0, 0); + aGroupLayout->addWidget(myFiltersWgt); - myFiltersCombo = new QComboBox(aFiltersWgt); + myFiltersCombo = new QComboBox(aFiltersGroup); + myFiltersCombo->addItem(tr("Add new filter...")); SessionPtr aSession = ModelAPI_Session::get(); std::list allFilters = aSession->filters()->filters((GeomAPI_Shape::ShapeType) mySelectionType); @@ -206,20 +211,10 @@ ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theP myFilters.push_back(aSession->filters()->id(*aIt)); } myFiltersCombo->addItems(aItems); + connect(myFiltersCombo, SIGNAL(currentIndexChanged(int)), SLOT(onAddFilter(int))); - QToolButton* aAddBtn = new QToolButton(aFiltersWgt); - aAddBtn->setIcon(QIcon(":pictures/add.png")); - aAddBtn->setAutoRaise(true); - aAddBtn->setToolTip(tr("Add the current filter")); - connect(aAddBtn, SIGNAL(clicked()), SLOT(onAddItem())); - - aFiltersLay->addWidget(aFilterLbl); - aFiltersLay->addWidget(myFiltersCombo, 1); - aFiltersLay->addWidget(aAddBtn); - - myGroupLayout->addWidget(aFiltersWgt); - - aMainLayout->addWidget(myFiltersGroup); + aGroupLayout->addWidget(myFiltersCombo); + aMainLayout->addWidget(aFiltersGroup); // Select Button QWidget* aBtnWgt = new QWidget(this); @@ -237,28 +232,19 @@ ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theP // Label widgets QWidget* aLblWgt = new QWidget(this); QHBoxLayout* aLblLayout = new QHBoxLayout(aLblWgt); - ModuleBase_Tools::adjustMargins(aLblLayout); + ModuleBase_Tools::zeroMargins(aLblLayout); aLblLayout->addWidget(new QLabel(tr("Number of selected objects:"), aLblWgt)); myNbLbl = new QLabel("0", aLblWgt); aLblLayout->addWidget(myNbLbl); - aMainLayout->addWidget(aLblWgt); - // Show only button - QWidget* aBtn2Wgt = new QWidget(this); - QHBoxLayout* aBtn2Layout = new QHBoxLayout(aBtn2Wgt); - ModuleBase_Tools::adjustMargins(aBtn2Layout); - - aBtn2Layout->addStretch(1); - - myShowBtn = new QPushButton(tr("Show only"), aBtn2Wgt); - myShowBtn->setCheckable(true); + myShowBtn = new QCheckBox(tr("Show only"), this); connect(myShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool))); - aBtn2Layout->addWidget(myShowBtn); + aLblLayout->addWidget(myShowBtn); - aMainLayout->addWidget(aBtn2Wgt); + aMainLayout->addWidget(aLblWgt); aMainLayout->addStretch(1); @@ -288,16 +274,16 @@ ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter() AttributeId = ""; } -void ModuleBase_WidgetSelectionFilter::onAddItem() +void ModuleBase_WidgetSelectionFilter::onAddFilter(int theIndex) { - int aId = myFiltersCombo->currentIndex(); - myFiltersCombo->removeItem(aId); + if (theIndex == 0) + return; std::list::iterator aIt; int i; std::string aFilter; for (aIt = myFilters.begin(), i = 0; aIt != myFilters.cend(); i++, aIt++) { - if (i == aId) { + if (i == (theIndex - 1)) { aFilter = (*aIt); myFilters.erase(aIt); break; @@ -306,26 +292,36 @@ void ModuleBase_WidgetSelectionFilter::onAddItem() if (!aFilter.empty()) { myUseFilters.push_back(aFilter); ModuleBase_FilterItem* aItem = - new ModuleBase_FilterItem(aFilter, mySelectorFeature, myFiltersGroup); + new ModuleBase_FilterItem(aFilter, mySelectorFeature, myFiltersWgt); connect(aItem, SIGNAL(deleteItem(ModuleBase_FilterItem*)), SLOT(onDeleteItem(ModuleBase_FilterItem*))); - myGroupLayout->addWidget(aItem); + myFiltersLayout->addWidget(aItem); + + FiltersFeaturePtr aFiltersFeature = + std::dynamic_pointer_cast(myFeature); + aFiltersFeature->addFilter(aFilter); } updateSelectBtn(); clearCurrentSelection(true); updateNumberSelected(); + myFiltersCombo->setCurrentIndex(0); + myFiltersCombo->removeItem(theIndex); } void ModuleBase_WidgetSelectionFilter::onDeleteItem(ModuleBase_FilterItem* theItem) { std::string aFilter = theItem->filter(); - myGroupLayout->removeWidget(theItem); + myFiltersLayout->removeWidget(theItem); theItem->deleteLater(); myUseFilters.remove(aFilter); myFilters.push_back(aFilter); myFiltersCombo->addItem(ModelAPI_Session::get()->filters()->filter(aFilter)->name().c_str()); + FiltersFeaturePtr aFiltersFeature = + std::dynamic_pointer_cast(myFeature); + aFiltersFeature->removeFilter(aFilter); + updateSelectBtn(); clearCurrentSelection(true); updateNumberSelected(); @@ -402,13 +398,13 @@ void ModuleBase_WidgetSelectionFilter::updatePreview(const TopoDS_Shape& theShap } -void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theErase) +void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theShow) { if (myPreview.IsNull()) return; Handle(AIS_InteractiveContext) aCtx = myWorkshop->viewer()->AISContext(); - if (theErase) { + if (theShow) { aCtx->SetDisplayMode(myPreview, AIS_Shaded, false); myListIO.Clear(); aCtx->DisplayedObjects(AIS_KOI_Shape, -1, myListIO); @@ -422,7 +418,7 @@ void ModuleBase_WidgetSelectionFilter::onShowOnly(bool theErase) for (aIt = myListIO.cbegin(); aIt != myListIO.cend(); aIt++) { aShapeIO = Handle(AIS_Shape)::DownCast(*aIt); if (!aShapeIO.IsNull()) { - if (theErase) + if (theShow) aCtx->Erase(aShapeIO, false); else aCtx->Display(aShapeIO, false); diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h index 2fe5b05da..39645d88b 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h @@ -39,6 +39,7 @@ class QGroupBox; class QToolButton; class QVBoxLayout; class QPushButton; +class QCheckBox; class ModuleBase_IWorkshop; @@ -110,7 +111,7 @@ protected: virtual bool restoreValueCustom() { return true; } private slots: - void onAddItem(); + void onAddFilter(int); void onDeleteItem(ModuleBase_FilterItem* theItem); void onSelect(); void onShowOnly(bool theErase); @@ -124,12 +125,13 @@ private: private: ModuleBase_IWorkshop* myWorkshop; + QWidget* myFiltersWgt; + QVBoxLayout* myFiltersLayout; + QComboBox* myFiltersCombo; - QGroupBox* myFiltersGroup; - QVBoxLayout* myGroupLayout; QPushButton* mySelectBtn; QLabel* myNbLbl; - QPushButton* myShowBtn; + QCheckBox* myShowBtn; int mySelectionType; std::list myFilters; diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 11b4af9de..b8163172b 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -86,7 +86,6 @@ pictures/arrow-down.png pictures/configure_toolbars.png pictures/add.png - pictures/accept.png - pictures/stop.png + pictures/reverce.png diff --git a/src/XGUI/pictures/add.png b/src/XGUI/pictures/add.png index 5b051f647..388f8ffed 100644 Binary files a/src/XGUI/pictures/add.png and b/src/XGUI/pictures/add.png differ diff --git a/src/XGUI/pictures/delete.png b/src/XGUI/pictures/delete.png index 8bc7506aa..6d2aea896 100644 Binary files a/src/XGUI/pictures/delete.png and b/src/XGUI/pictures/delete.png differ diff --git a/src/XGUI/pictures/reverce.png b/src/XGUI/pictures/reverce.png new file mode 100644 index 000000000..40239ade4 Binary files /dev/null and b/src/XGUI/pictures/reverce.png differ