X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetMultiSelector.cpp;h=11c502778c71fce36d3cd975b53af32620064191;hb=c155919c16327dae7e09cd1e6a5b6d166e844767;hp=9a2007cd9f97174a00c3c898e953887035b85b6f;hpb=4e677bdcfd9ebe4b467a1cc4cc274bcfbe5fb8ca;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp old mode 100755 new mode 100644 index 9a2007cd9..11c502778 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// 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 @@ -12,10 +12,9 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -38,6 +37,7 @@ #include #include #include +#include #include #include @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -113,21 +114,21 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen const Config_WidgetAPI* theData) : ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myIsSetSelectionBlocked(false), myCurrentHistoryIndex(-1), - myIsFirst(true) + myIsFirst(true), myFiltersWgt(0) { std::string aPropertyTypes = theData->getProperty("type_choice"); QString aTypesStr = aPropertyTypes.c_str(); 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 @@ -137,18 +138,25 @@ 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); } QString aToolTip = QString::fromStdString(theData->widgetTooltip()); @@ -158,13 +166,26 @@ 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())); + 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); @@ -250,9 +271,9 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() return false; AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); std::string aType = anAttribute->attributeType(); if (aType == ModelAPI_AttributeSelectionList::typeId()) { - AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); // Restore shape type std::string aSelectionType = aSelectionListAttr->selectionType().c_str(); if (!aSelectionType.empty()) { @@ -261,6 +282,8 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() myIsFirst = false; } } + if (myGeomCheck) + myGeomCheck->setChecked(aSelectionListAttr->isGeometricalSelection()); updateSelectionList(); return true; } @@ -500,6 +523,7 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() { // Clear current selection in order to avoid updating of object browser with obsolete indexes // which can appear because of results deletetion after changing a type of selection + QString aSelectionType = myTypeCtrl->textValue(); QList aEmptyList; myWorkshop->setSelected(aEmptyList); @@ -513,7 +537,7 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() std::string aType = anAttribute->attributeType(); if (aType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); - aSelectionListAttr->setSelectionType(myTypeCtrl->textValue().toStdString()); + aSelectionListAttr->setSelectionType(aSelectionType.toStdString()); } // clear attribute values @@ -949,6 +973,8 @@ bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject, const std::map >& theGeomSelection, ModuleBase_IWorkshop* theWorkshop) { + if (!theObject.get()) + return false; // issue #2154: we should not remove from list objects hidden in the viewer if selection // was done with SHIFT button if (theWorkshop->hasSHIFTPressed() && !theObject->isDisplayed()) @@ -1058,8 +1084,12 @@ void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn) std::string aType = anAttribute->attributeType(); if (aType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); - //TODO: set same topology flag aSelectionListAttr->setGeometricalSelection(theOn); updateObject(myFeature); } } + +void ModuleBase_WidgetMultiSelector::onShowOnly() +{ + +}