]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implement launch/close filters operation
authorvsv <vsv@opencascade.com>
Mon, 12 Nov 2018 08:58:01 +0000 (11:58 +0300)
committervsv <vsv@opencascade.com>
Mon, 12 Nov 2018 08:58:01 +0000 (11:58 +0300)
12 files changed:
src/CollectionPlugin/CollectionPlugin_GroupFilters.h [new file with mode: 0644]
src/CollectionPlugin/CollectionPlugin_Plugin.cpp
src/CollectionPlugin/group_widget.xml
src/CollectionPlugin/plugin-Collection.xml
src/Config/Config_Keywords.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp
src/ModuleBase/ModuleBase_WidgetSelectionFilter.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

diff --git a/src/CollectionPlugin/CollectionPlugin_GroupFilters.h b/src/CollectionPlugin/CollectionPlugin_GroupFilters.h
new file mode 100644 (file)
index 0000000..a7ec756
--- /dev/null
@@ -0,0 +1,54 @@
+// 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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef COLLECTIONPLUGIN_GROUPFILTERS_H_
+#define COLLECTIONPLUGIN_GROUPFILTERS_H_
+
+#include "CollectionPlugin.h"
+#include <ModelAPI_Feature.h>
+
+class CollectionPlugin_GroupFilters : public ModelAPI_Feature
+{
+public:
+  /// Extrusion kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_GROUP_ID("GroupFilters");
+    return MY_GROUP_ID;
+  }
+
+  /// Returns the kind of a feature
+  COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = CollectionPlugin_GroupFilters::ID();
+    return MY_KIND;
+  }
+
+  /// Creates a new group result if needed
+  COLLECTIONPLUGIN_EXPORT virtual void execute() {}
+
+  /// Request for initialization of data model of the object: adding all attributes
+  virtual void initAttributes() {}
+
+  /// Use plugin manager for features creation
+  CollectionPlugin_GroupFilters() {}
+};
+
+#endif
\ No newline at end of file
index 9ef0bd736eded51dd68ea35738b17f59501db57c..f639d79c1fcc18d964ba20980191eff489b3b72e 100644 (file)
@@ -23,6 +23,7 @@
 #include <CollectionPlugin_Group.h>
 #include <CollectionPlugin_Field.h>
 #include <CollectionPlugin_Validators.h>
+#include <CollectionPlugin_GroupFilters.h>
 #include <ModelAPI_Session.h>
 
 #include <ModuleBase_WidgetCreatorFactory.h>
@@ -55,8 +56,10 @@ FeaturePtr CollectionPlugin_Plugin::createFeature(std::string theFeatureID)
 {
   if (theFeatureID == CollectionPlugin_Group::ID()) {
     return FeaturePtr(new CollectionPlugin_Group);
-  }else if (theFeatureID == CollectionPlugin_Field::ID()) {
+  } else if (theFeatureID == CollectionPlugin_Field::ID()) {
     return FeaturePtr(new CollectionPlugin_Field);
+  } else if (theFeatureID == CollectionPlugin_GroupFilters::ID()) {
+    return FeaturePtr(new CollectionPlugin_GroupFilters);
   }
 
 
index 7f1f874cd3924a1b3b9b7a97ac078322c1ba7a70..affd3562be3909e89c83ef7e3978848fc3413e7c 100644 (file)
@@ -28,7 +28,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
     tooltip="Select a set of objects"
     type_choice="Vertices Edges Faces Solids"
     use_choice="true"
-    use_filters="true"
+    use_filters="GroupFilters"
     clear_in_neutral_point="false"
     filter_points="false" >
     <validator id="GeomValidators_BodyShapes"/>
index 4adfdf2184c477afe35492945954b6494b048e15..cd6ab3914571b89b280d41e39a5611ab219accaf 100644 (file)
@@ -42,6 +42,13 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         </field-panel>
         <validator id="CollectionPlugin_FieldValidator"/>
       </feature>
+
+      <feature id="GroupFilters"
+               title="Selection filters"
+               internal="1">
+        <selection_filters>
+        </selection_filters>
+      </feature>
     </group>
   </workbench>
 </plugin>
index beb599b206d87450a827f5692f1d08c75881dc10..dc7f04b371f83bb250eec55ab90999b45650e947 100644 (file)
@@ -53,6 +53,7 @@ const static char* WDG_EXPR_EDITOR = "expr_editor";
 const static char* WDG_PLACE_HOLDER = "placeholder";
 const static char* WDG_ACTION = "action";
 const static char* WDG_POINT_INPUT = "point_input";
+const static char* WDG_SELECTION_FILTERS = "selection_filters";
 
 // Containers
 const static char* WDG_GROUP = "groupbox";
index af75ebd125bef3e64edd9aedf62c634a1d965e6f..29348226051e39b4bbe6a5e75d58f4dbc5af11d3 100644 (file)
@@ -51,6 +51,7 @@
 #include <ModuleBase_WidgetCreatorFactory.h>
 #include <ModuleBase_WidgetAction.h>
 #include <ModuleBase_WidgetPointInput.h>
+#include <ModuleBase_WidgetSelectionFilter.h>
 
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
@@ -345,6 +346,8 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::
     result = new ModuleBase_WidgetAction(theParent, myWidgetApi);
   } else if (theType == WDG_POINT_INPUT) {
     result = new ModuleBase_WidgetPointInput(theParent, myWorkshop, myWidgetApi);
+  } else if (theType == WDG_SELECTION_FILTERS) {
+    result = new ModuleBase_WidgetSelectionFilter(theParent, myWorkshop, myWidgetApi);
   } else {
     result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi);
     if (!result)
index 548342f58c348d0769662c59a804985b9844e476..450ce34660b70c0518c28d4389176d2be61c99ac 100755 (executable)
@@ -157,9 +157,9 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
       }
     }
   }
-  bool aUseFilters = theData->getBooleanAttribute("use_filters", false);
-  if (aUseFilters) {
-    myFiltersWgt = new ModuleBase_FilterStarter(this, theWorkshop);
+  std::string aUseFilters = theData->getProperty("use_filters");
+  if (aUseFilters.length() > 0) {
+    myFiltersWgt = new ModuleBase_FilterStarter(aUseFilters.c_str(), this, theWorkshop);
     aMainLay->addWidget(myFiltersWgt);
   }
 
index 3120487abf640aba11f462736cd2e64e615a506a..4e777a3379d7c3fc7199b65d18bc630393692530 100644 (file)
 #include "ModuleBase_WidgetSelectionFilter.h"
 #include "ModuleBase_Tools.h"
 #include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_IModule.h"
+#include "ModuleBase_IPropertyPanel.h"
+#include "ModuleBase_PageWidget.h"
 
 #include <QLayout>
 #include <QPushButton>
 #include <QLabel>
-#include <QPicture>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QDialog>
 
-ModuleBase_FilterStarter::ModuleBase_FilterStarter(QWidget* theParent,
-  ModuleBase_IWorkshop* theWorkshop)
+ModuleBase_FilterStarter::ModuleBase_FilterStarter(const std::string& theFeature,
+  QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
   : QWidget(theParent),
+  myFeatureName(theFeature),
   myWorkshop(theWorkshop)
 {
   QHBoxLayout* aMainLayout = new QHBoxLayout(this);
@@ -55,5 +61,56 @@ ModuleBase_FilterStarter::ModuleBase_FilterStarter(QWidget* theParent,
 
 void ModuleBase_FilterStarter::onFiltersLaunch()
 {
+ // ModuleBase_OperationFiltering* aOperation = new ModuleBase_OperationFiltering(myWorkshop, this);
+ // myWorkshop->processLaunchOperation(aOperation);
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+    (myWorkshop->module()->createOperation(myFeatureName));
+  myWorkshop->processLaunchOperation(aFOperation);
+}
+
+
+
+//*****************************************************************************
+//*****************************************************************************
+//*****************************************************************************
+ModuleBase_WidgetSelectionFilter::ModuleBase_WidgetSelectionFilter(QWidget* theParent,
+  ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData)
+  : ModuleBase_ModelWidget(theParent, theData),
+  myWorkshop(theWorkshop)
+{
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::adjustMargins(aMainLayout);
+
+  myFiltersGroup = new QGroupBox(tr("Dynamic Filters"), this);
+  QVBoxLayout* aGroupLayout = new QVBoxLayout(myFiltersGroup);
+
+  QWidget* aFiltersWgt = new QWidget(myFiltersGroup);
+  QHBoxLayout* aFiltersLay = new QHBoxLayout(aFiltersWgt);
+
+  QLabel* aFilterLbl = new QLabel(aFiltersWgt);
+  aFilterLbl->setPixmap(QPixmap(":pictures/filter.png"));
+
+  myFiltersCombo = new QComboBox(aFiltersWgt);
+
+  QPushButton* aAddBtn = new QPushButton(tr("Add"), aFiltersWgt);
+  connect(aAddBtn, SIGNAL(clicked()), SLOT(onAddFilter()));
 
-}
\ No newline at end of file
+  aFiltersLay->addWidget(aFilterLbl);
+  aFiltersLay->addWidget(myFiltersCombo);
+  aFiltersLay->addWidget(aAddBtn);
+
+  aGroupLayout->addWidget(aFiltersWgt);
+
+  aMainLayout->addWidget(myFiltersGroup);
+  aMainLayout->addStretch(1);
+}
+
+void ModuleBase_WidgetSelectionFilter::onAddFilter()
+{
+
+}
+
+QList<QWidget*> ModuleBase_WidgetSelectionFilter::getControls() const
+{
+  return QList<QWidget*>();
+}
index 24a01ee3af530ff463e807eef9deab14a6158cac..6be5cc0bed188656ddf089072580b821fe9020b6 100644 (file)
 #ifndef ModuleBase_WidgetSelectionFilter_H
 #define ModuleBase_WidgetSelectionFilter_H
 
-#include <ModuleBase.h>
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
 #include <QWidget>
 
 class QLabel;
+class QComboBox;
+class QGroupBox;
 class ModuleBase_IWorkshop;
 
 class MODULEBASE_EXPORT ModuleBase_FilterStarter: public QWidget
 {
   Q_OBJECT
 public:
-  ModuleBase_FilterStarter(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop);
+  ModuleBase_FilterStarter(const std::string& theFeature, QWidget* theParent,
+    ModuleBase_IWorkshop* theWorkshop);
 
   ~ModuleBase_FilterStarter() {}
 
@@ -39,11 +44,42 @@ private slots:
   void onFiltersLaunch();
 
 private:
+  std::string myFeatureName;
+  ModuleBase_IWorkshop* myWorkshop;
+
   QLabel* myFilterLbl;
   QLabel* myModifyLbl;
 
-  ModuleBase_IWorkshop* myWorkshop;
 };
 
 
+class ModuleBase_WidgetSelectionFilter : public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  ModuleBase_WidgetSelectionFilter(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+    const Config_WidgetAPI* theData);
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+protected:
+  /// Saves the internal parameters to the given feature (not ussed for this widget)
+  /// \return True in success
+  virtual bool storeValueCustom() { return true;  }
+
+  /// Restore value from attribute data to the widget's control (not ussed for this widget)
+  virtual bool restoreValueCustom() { return true; }
+
+private slots:
+  void onAddFilter();
+
+private:
+  ModuleBase_IWorkshop* myWorkshop;
+
+  QComboBox* myFiltersCombo;
+  QGroupBox* myFiltersGroup;
+};
+
 #endif
\ No newline at end of file
index 3ce0ed1713e41f3b2a26160b78c0b9e764042641..b93da6e5d0df257945006dbbdd4fe8e36025a1b7 100755 (executable)
@@ -226,10 +226,20 @@ void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
     /// Apply button should be update if the feature was modified by the panel
     myOperationMgr->onValidateOperation();
   }
-  std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
-    myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
-  if (aFeatureInfo.get())
-    findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
+  updateApplyPlusButton(theFeature);
+}
+
+void XGUI_PropertyPanel::updateApplyPlusButton(FeaturePtr theFeature)
+{
+  if (theFeature.get()) {
+    std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
+      myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
+    if (aFeatureInfo.get()) {
+      findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
+      return;
+    }
+  }
+  findButton(PROP_PANEL_OK_PLUS)->setVisible(false);
 }
 
 ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const
index 62b87e9be11736b34cba701cf84a7a483166bb26..053b71062381da583dafa7de4619090fb65c4090 100644 (file)
@@ -145,6 +145,8 @@ Q_OBJECT
   /// \param theWidget a widget control to store as internal active widget
   void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget);
 
+  void updateApplyPlusButton(FeaturePtr theFeature);
+
 public slots:
   /// \brief Update all widgets in property panel with values from the given feature
   /// \param theFeature a Feature to update values in widgets
index 2e135c8d93d7a3c9417f0a3c2e99568756fe1559..e13ddacc7f7219a3e3170d1bd3dec3ad4b0c2ec9 100755 (executable)
@@ -781,6 +781,12 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
   if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
     fillPropertyPanel(theOperation);
     connectToPropertyPanel(true);
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+      (theOperation);
+    if (aFOperation)
+      myPropertyPanel->updateApplyPlusButton(aFOperation->feature());
+    else
+      myPropertyPanel->updateApplyPlusButton(FeaturePtr());
   }
   updateCommandStatus();