]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update of GUI
authorvsv <vsv@opencascade.com>
Mon, 3 Jun 2019 13:05:43 +0000 (16:05 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Jun 2019 13:05:43 +0000 (16:05 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp
src/ModuleBase/ModuleBase_WidgetSelectionFilter.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/add.png
src/XGUI/pictures/delete.png
src/XGUI/pictures/reverce.png [new file with mode: 0644]

index 33fdafa0aeb9c2fb0a13a075cbf37dadaba72b2f..11c502778c71fce36d3cd975b53af32620064191 100644 (file)
@@ -63,6 +63,7 @@
 #include <QTimer>
 #include <QMainWindow>
 #include <QCheckBox>
+#include <QPushButton>
 
 #include <memory>
 #include <string>
@@ -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()
+{
+
+}
index b77ea969fee5ae2590218f35fbe9471f50ed3f32..651526ea8d1de2809881d1a00bda405386a784fe 100644 (file)
@@ -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();
index 5112ba68bcaed95001dbb34d3385a96acc3236ba..9da94eb6ccacce135d14b5e598a44cd57692bcf4 100644 (file)
@@ -43,6 +43,7 @@
 #include <QGroupBox>
 #include <QDialog>
 #include <QToolButton>
+#include <QCheckBox>
 
 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<ModuleBase_WidgetMultiSelector*>(parent());
+    dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
+  while (!aSelector) {
+    aParent = aParent->parentWidget();
+    aSelector = dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);
+  }
+  if (!aSelector)
+    return;
   SelectorFeature = aSelector->feature();
   AttributeId = aSelector->attributeID();
 
@@ -121,14 +129,14 @@ ModuleBase_FilterItem::ModuleBase_FilterItem(
     mySelection(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(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<FilterPtr> 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<std::string>::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<ModelAPI_FiltersFeature>(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<ModelAPI_FiltersFeature>(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);
index 2fe5b05dab6061b2f0b0610a09fb6c5ecc3edeea..39645d88b506ff26450d629732c7ce55ecf7e529 100644 (file)
@@ -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<std::string> myFilters;
index 11b4af9deff66e6d68606004e9115472a465f9b2..b8163172b4a4379ee5d8c26ee97f72bdaeb1381b 100644 (file)
@@ -86,7 +86,6 @@
      <file>pictures/arrow-down.png</file>
      <file>pictures/configure_toolbars.png</file>
      <file>pictures/add.png</file>
-     <file>pictures/accept.png</file>
-     <file>pictures/stop.png</file>
+     <file>pictures/reverce.png</file>
  </qresource>
  </RCC>
index 5b051f647fecd43ea4ed665486734acb38eaa952..388f8ffed3ed1d1a8cff3ae8b81bd0a24e891f34 100644 (file)
Binary files a/src/XGUI/pictures/add.png and b/src/XGUI/pictures/add.png differ
index 8bc7506aa2962d07854eac6c97cc7ac1b80c4e20..6d2aea896730f72445e4121699dad5a875889490 100644 (file)
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 (file)
index 0000000..40239ad
Binary files /dev/null and b/src/XGUI/pictures/reverce.png differ