--- /dev/null
+// 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
#include <CollectionPlugin_Group.h>
#include <CollectionPlugin_Field.h>
#include <CollectionPlugin_Validators.h>
+#include <CollectionPlugin_GroupFilters.h>
#include <ModelAPI_Session.h>
#include <ModuleBase_WidgetCreatorFactory.h>
{
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);
}
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"/>
</field-panel>
<validator id="CollectionPlugin_FieldValidator"/>
</feature>
+
+ <feature id="GroupFilters"
+ title="Selection filters"
+ internal="1">
+ <selection_filters>
+ </selection_filters>
+ </feature>
</group>
</workbench>
</plugin>
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";
#include <ModuleBase_WidgetCreatorFactory.h>
#include <ModuleBase_WidgetAction.h>
#include <ModuleBase_WidgetPointInput.h>
+#include <ModuleBase_WidgetSelectionFilter.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
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)
}
}
}
- 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);
}
#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);
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*>();
+}
#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() {}
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
/// 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
/// \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
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();