From: vsv Date: Fri, 6 Dec 2019 08:22:20 +0000 (+0300) Subject: Issue #3073: Show filters for Group feature in information panel. X-Git-Tag: V9_5_0a1~124 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e7c2106b3a1a502db995e8cde557a31759eac42;p=modules%2Fshaper.git Issue #3073: Show filters for Group feature in information panel. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 268dcaf22..4060181c0 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -313,6 +313,10 @@ Q_OBJECT /// Returns True if data of its attribute was modified virtual bool isModified() const { return false; } + virtual void setReadOnly(bool isReadOnly) { setEnabled(!isReadOnly); } + + virtual bool isReadOnly() const { return !isEnabled(); } + signals: /// The signal about widget values are to be changed void beforeValuesChanged(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 1ccee34fd..33f14a17e 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -114,7 +114,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen const Config_WidgetAPI* theData) : ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myIsSetSelectionBlocked(false), myCurrentHistoryIndex(-1), - myIsFirst(true), myFiltersWgt(0) + myIsFirst(true), myFiltersWgt(0), myShowOnlyBtn(0) { std::string aPropertyTypes = theData->getProperty("shape_types"); QString aTypesStr = aPropertyTypes.c_str(); @@ -125,8 +125,8 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen if (!aAllowedList.isEmpty()) myAllowedObjects = aAllowedList.split(' ', QString::SkipEmptyParts); - QVBoxLayout* aMainLay = new QVBoxLayout(this); - ModuleBase_Tools::adjustMargins(aMainLay); + myMainLayout = new QVBoxLayout(this); + ModuleBase_Tools::adjustMargins(myMainLayout); QStringList aIconsList = getIconsList(myShapeTypes); myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList); @@ -135,7 +135,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen myTypeCtrl->setValue(0); myDefMode = myShapeTypes.first().toStdString(); } - aMainLay->addWidget(myTypeCtrl); + myMainLayout->addWidget(myTypeCtrl); // There is no sense to parameterize list of types while we can not parameterize selection mode // if the xml definition contains one type, the controls to select a type should not be shown @@ -148,7 +148,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen QWidget* aLabelWgt = new QWidget(this); QHBoxLayout* aLabelLayout = new QHBoxLayout(aLabelWgt); aLabelLayout->setContentsMargins(0, 0, 0, 0); - aMainLay->addWidget(aLabelWgt); + myMainLayout->addWidget(aLabelWgt); QLabel* aListLabel = new QLabel(aLabelText, this); aLabelLayout->addWidget(aListLabel); @@ -172,32 +172,32 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem())); connect(myListView, SIGNAL(listActivated()), SLOT(onListActivated())); - aMainLay->addWidget(myListView->getControl()); + myMainLayout->addWidget(myListView->getControl()); connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged())); - std::string aUseFilters = theData->getProperty("use_filters"); - if (aUseFilters.length() > 0) { + myUseFilters = theData->getProperty("use_filters"); + if (myUseFilters.length() > 0) { QWidget* aFltrWgt = new QWidget(this); QHBoxLayout* aFltrLayout = new QHBoxLayout(aFltrWgt); - myFiltersWgt = new ModuleBase_FilterStarter(aUseFilters.c_str(), aFltrWgt, theWorkshop); + myFiltersWgt = new ModuleBase_FilterStarter(myUseFilters, aFltrWgt, theWorkshop); aFltrLayout->addWidget(myFiltersWgt); aFltrLayout->addStretch(); - QPushButton* aShowBtn = new QPushButton(tr("Show only"), aFltrWgt); - aShowBtn->setCheckable(true); - aShowBtn->setChecked(false); - connect(aShowBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool))); - aFltrLayout->addWidget(aShowBtn); + myShowOnlyBtn = new QPushButton(tr("Show only"), aFltrWgt); + myShowOnlyBtn->setCheckable(true); + myShowOnlyBtn->setChecked(false); + connect(myShowOnlyBtn, SIGNAL(toggled(bool)), SLOT(onShowOnly(bool))); + aFltrLayout->addWidget(myShowOnlyBtn); - aMainLay->addWidget(aFltrWgt); + myMainLayout->addWidget(aFltrWgt); } bool aSameTop = theData->getBooleanAttribute("same_topology", false); if (aSameTop) { myGeomCheck = new QCheckBox(tr("Add elements that share the same topology"), this); - aMainLay->addWidget(myGeomCheck); + myMainLayout->addWidget(myGeomCheck); connect(myGeomCheck, SIGNAL(toggled(bool)), SLOT(onSameTopology(bool))); } else @@ -1185,4 +1185,34 @@ void ModuleBase_WidgetMultiSelector::onShowOnly(bool theChecked) bool ModuleBase_WidgetMultiSelector::isModified() const { return myListView->getControl()->count() > 0; -} \ No newline at end of file +} + + +void ModuleBase_WidgetMultiSelector::setReadOnly(bool isReadOnly) +{ + ModuleBase_WidgetSelector::setReadOnly(isReadOnly); + if (myShowOnlyBtn) + myShowOnlyBtn->hide(); + if (myFiltersWgt) { + myFiltersWgt->hide(); + + AttributeSelectionListPtr aAttrList = feature()->selectionList(attributeID()); + if (aAttrList.get()) { + FiltersFeaturePtr aFilters = aAttrList->filters(); + if (aFilters.get()) { + ModuleBase_WidgetSelectionFilter::SelectorFeature = feature(); + ModuleBase_WidgetSelectionFilter::AttributeId = attributeID(); + + std::string aXmlCfg, aDescription; + myWorkshop->module()->getXMLRepresentation(myUseFilters, aXmlCfg, aDescription); + + ModuleBase_WidgetSelectionFilter* aWgt = + new ModuleBase_WidgetSelectionFilter(this, myWorkshop, + new Config_WidgetAPI(aDescription), true); + aWgt->setFeature(aFilters); + aWgt->restoreValue(); + myMainLayout->addWidget(aWgt); + } + } + } +} diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 08aa13a39..d54f557d5 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -37,7 +37,8 @@ class QWidget; class QCheckBox; -//class QComboBox; +class QPushButton; +class QVBoxLayout; class ModuleBase_ListView; class ModuleBase_IWorkshop; class ModuleBase_ChoiceCtrl; @@ -118,6 +119,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// Returns True if data of its feature was modified during operation virtual bool isModified() const; + virtual void setReadOnly(bool isReadOnly); + public slots: /// Slot is called on selection type changed void onSelectionTypeChanged(); @@ -256,12 +259,15 @@ protected: bool myIsFirst; std::string myDefMode; + QVBoxLayout* myMainLayout; QCheckBox* myGeomCheck; ModuleBase_FilterStarter* myFiltersWgt; + QPushButton* myShowOnlyBtn; QObjectPtrList myVisibleObjects; QStringList myAllowedObjects; QStringList myTmpAllowed; + std::string myUseFilters; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp index 963861a31..500bd5b68 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -55,8 +55,8 @@ #include #include -static FeaturePtr SelectorFeature; -static std::string AttributeId; +FeaturePtr ModuleBase_WidgetSelectionFilter::SelectorFeature; +std::string ModuleBase_WidgetSelectionFilter::AttributeId; GeomAPI_Shape::ShapeType selectionType(const QString& theType) @@ -118,14 +118,16 @@ void ModuleBase_FilterStarter::onFiltersLaunch() } if (!aSelector) return; - SelectorFeature = aSelector->feature(); - AttributeId = aSelector->attributeID(); + ModuleBase_WidgetSelectionFilter::SelectorFeature = aSelector->feature(); + ModuleBase_WidgetSelectionFilter::AttributeId = aSelector->attributeID(); // Launch Filters operation ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->module()->createOperation(myFeatureName)); - AttributeSelectionListPtr aAttrList = SelectorFeature->selectionList(AttributeId); + AttributeSelectionListPtr aAttrList = + ModuleBase_WidgetSelectionFilter::SelectorFeature->selectionList( + ModuleBase_WidgetSelectionFilter::AttributeId); FiltersFeaturePtr aFilters = aAttrList->filters(); if (aFilters.get()) aFOperation->setFeature(aFilters); @@ -225,16 +227,18 @@ void ModuleBase_FilterItem::onDelete() //***************************************************************************** //***************************************************************************** ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theParent, - ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData) + ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, bool theReadOnly) : ModuleBase_ModelWidget(theParent, theData), myWorkshop(theWorkshop), - mySelectorFeature(SelectorFeature), - mySelectorAttribute(AttributeId) + mySelectorFeature(ModuleBase_WidgetSelectionFilter::SelectorFeature), + mySelectorAttribute(ModuleBase_WidgetSelectionFilter::AttributeId) { // Clear Old selection - AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute); - mySelectionType = selectionType(aAttrList->selectionType().c_str()); - aAttrList->clear(); + AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute); + mySelectionType = selectionType(aAttrList->selectionType().c_str()); + if (!theReadOnly) { + aAttrList->clear(); + } // Define widgets QVBoxLayout* aMainLayout = new QVBoxLayout(this); @@ -300,6 +304,12 @@ ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theP aMainLayout->addStretch(1); updateSelectBtn(); + if (theReadOnly) { + myFiltersCombo->hide(); + mySelectBtn->hide(); + aLblWgt->hide(); + myShowBtn->hide(); + } } ModuleBase_WidgetSelectionFilter::~ModuleBase_WidgetSelectionFilter() @@ -645,28 +655,28 @@ bool ModuleBase_WidgetSelectionFilter::restoreValueCustom() { ModelAPI_FiltersFactory* aFactory = ModelAPI_Session::get()->filters(); FiltersFeaturePtr aFiltersFeature = std::dynamic_pointer_cast(myFeature); + + // Init filters member of the parent attribute + AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute); + if (aAttrList->filters() != aFiltersFeature) { + aAttrList->setFilters(aFiltersFeature); + } + std::list aFilters = aFiltersFeature->filters(); std::list::const_iterator aIt; for (aIt = aFilters.cbegin(); aIt != aFilters.cend(); aIt++) { std::string aStr = (*aIt); - onAddFilter(aStr); + ModuleBase_FilterItem* aItem = onAddFilter(aStr); FilterPtr aFilterObj = aFactory->filter(aStr); int aId = myFiltersCombo->findText(aFilterObj->name().c_str()); if (aId != -1) myFiltersCombo->removeItem(aId); - } - // Init filters member of the parent attribute - AttributeSelectionListPtr aAttrList = mySelectorFeature->selectionList(mySelectorAttribute); - if (aAttrList->filters() != aFiltersFeature) { - aAttrList->setFilters(aFiltersFeature); - } - QList aWidgets; - QList aItems = myFiltersLayout->findChildren(); - foreach(ModuleBase_FilterItem* aItem, aItems) { - QList aSubList = aItem->widgets(); - foreach(ModuleBase_ModelWidget* aWgt, aSubList) { - aWgt->restoreValue(); + if (aItem) { + QList aSubList = aItem->widgets(); + foreach(ModuleBase_ModelWidget* aWgt, aSubList) { + aWgt->restoreValue(); + } } } return true; diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h index 30eb1b342..4862581b8 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.h @@ -139,13 +139,16 @@ class ModuleBase_WidgetSelectionFilter : public ModuleBase_ModelWidget { Q_OBJECT public: + static FeaturePtr SelectorFeature; + static std::string AttributeId; + /// Constructor /// \param theParent the parent object /// \param theData the widget configuration. The attribute of the model widget is obtained from /// a low-level API for reading xml definitions of widgets ModuleBase_WidgetSelectionFilter(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, - const Config_WidgetAPI* theData); + const Config_WidgetAPI* theData, bool theReadOnly = false); /// Destructor ~ModuleBase_WidgetSelectionFilter(); diff --git a/src/XGUI/XGUI_InspectionPanel.cpp b/src/XGUI/XGUI_InspectionPanel.cpp index 038f5f172..95ae953a1 100644 --- a/src/XGUI/XGUI_InspectionPanel.cpp +++ b/src/XGUI/XGUI_InspectionPanel.cpp @@ -759,8 +759,8 @@ void XGUI_InspectionPanel::buildFeaturePane(const FeaturePtr& theFeature) } foreach(ModuleBase_ModelWidget* aWgt, aWidgets) { if (aWgt->isInformative()) { - aWgt->setEnabled(false); aWgt->setFeature(theFeature, false, false); + aWgt->setReadOnly(true); aWgt->setEditingMode(true); aWgt->restoreValue(); aWgt->showInformativePage();