QPushButton* aLaunchBtn = new QPushButton(tr("Selection by filters"), this);
connect(aLaunchBtn, SIGNAL(clicked()), SLOT(onFiltersLaunch()));
aMainLayout->addWidget(aLaunchBtn);
-
- myFilterLbl = new QLabel(this);
- myFilterLbl->setPixmap(QPixmap(":pictures/filter.png"));
- aMainLayout->addWidget(myFilterLbl);
-
- myModifyLbl = new QLabel(this);
- myModifyLbl->setPixmap(QPixmap(":pictures/plus_minus.png"));
- aMainLayout->addWidget(myModifyLbl);
- aMainLayout->addStretch(1);
-
- myFilterLbl->hide();
- myModifyLbl->hide();
}
void ModuleBase_FilterStarter::onFiltersLaunch()
theParent, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)));
connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)));
+ connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated()));
}
aLayout->addWidget(aParamsWgt);
}
myFiltersCombo->setCurrentIndex(0);
myFiltersCombo->removeItem(theIndex);
+ updateObject(myFeature);
}
void ModuleBase_WidgetSelectionFilter::onAddFilter(const std::string& theFilter)
myWorkshop->selectionActivate()->updateSelectionModes();
myWorkshop->selectionActivate()->updateSelectionFilters();
redisplayFeature();
+ myFiltersCombo->setFocus();
+ updateObject(myFeature);
}
if (myValues.size() > 0)
updatePreview(aComp);
updateNumberSelected();
+ updateObject(myFeature);
}
void ModuleBase_WidgetSelectionFilter::updatePreview(const TopoDS_Shape& theShape)
void ModuleBase_WidgetSelectionFilter::updateNumberSelected()
{
- myNbLbl->setText(QString::number(myValues.size()));
+ int aNb = myValues.size();
+ myNbLbl->setText(QString::number(aNb));
+ //QString aErr = () ? tr("Selection is empty") : "";
+ if (aNb == 0)
+ myFeature->setError(tr("Selection is empty").toStdString(), false, false);
+ else {
+ myFeature->setError("", false, false);
+ myFeature->data()->execState(ModelAPI_StateDone);
+ }
}
+
QList<QWidget*> ModuleBase_WidgetSelectionFilter::getControls() const
{
QList<QWidget*> aWidgets;
aWidgets.append(aWgt);
}
}
+ aWidgets.append(myFiltersCombo);
return aWidgets;
}
ModuleBase_ModelWidget* aActive = myWorkshop->propertyPanel()->activeWidget();
if (aActive)
return aActive->storeValue();
+ updateObject(myFeature);
return true;
}
aAttrList->setFilters(aFiltersFeature);
}
- ModuleBase_ModelWidget* aActive = myWorkshop->propertyPanel()->activeWidget();
- if (aActive)
- return aActive->restoreValue();
QList<QWidget*> aWidgets;
QList<ModuleBase_FilterItem*> aItems = myFiltersWgt->findChildren<ModuleBase_FilterItem*>();
foreach(ModuleBase_FilterItem* aItem, aItems) {
}
return true;
}
+
+QString ModuleBase_WidgetSelectionFilter::getError(const bool theValueStateChecked) const
+{
+ QString aErrorMsg = ModuleBase_ModelWidget::getError(theValueStateChecked);
+ if (aErrorMsg.isEmpty()) {
+ if (myValues.size() == 0)
+ aErrorMsg = tr("Selection is empty");
+ }
+ return aErrorMsg;
+}
+
+void ModuleBase_WidgetSelectionFilter::onObjectUpdated()
+{
+ clearCurrentSelection(true);
+ updateNumberSelected();
+ updateObject(myFeature);
+}
class ModuleBase_IWorkshop;
+/**
+* \ingroup GUI
+* An object which lets to start a Filters operation as
+* a sub-operation of the current one.
+*/
class MODULEBASE_EXPORT ModuleBase_FilterStarter: public QWidget
{
Q_OBJECT
public:
+ /// Constructor
+ /// \param theFeature a name of feature for filtering
+ /// \param theParent a parent widget which will get control after filtering
+ /// \param theWorkshop a pointer on a current workshop
ModuleBase_FilterStarter(const std::string& theFeature, QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop);
+ /// Destructor
~ModuleBase_FilterStarter() {}
private slots:
+ /// A slot to launch filtering operation
void onFiltersLaunch();
private:
+ /// Name of filtering feature
std::string myFeatureName;
- ModuleBase_IWorkshop* myWorkshop;
- QLabel* myFilterLbl;
- QLabel* myModifyLbl;
+ /// A workshop
+ ModuleBase_IWorkshop* myWorkshop;
};
class ModuleBase_WidgetSelectionFilter;
-
+/**
+* \ingroup GUI
+* A widget which reperesents a one filter item in filters list
+* Also it includes filter GUI if it exists
+*/
class ModuleBase_FilterItem : public QWidget
{
Q_OBJECT
public:
+
+ /// Constructor
+ /// \param theFilter the filter ID
+ /// \param theParent a parent widget of ModuleBase_WidgetSelectionFilter class
ModuleBase_FilterItem(const std::string& theFilter, ModuleBase_WidgetSelectionFilter* theParent);
+ /// Returns filter Id
std::string filter() const { return myFilterID; }
/// Returns list of widget controls
/// \return a control list
QList<QWidget*> getControls() const;
+ /// Returns list of widgets which reperesent the current filter GUI
QList<ModuleBase_ModelWidget*> widgets() const {
return myWidgets;
}
signals:
+ /// The seignal is sent on deletion of the item
void deleteItem(ModuleBase_FilterItem* theItem);
+
+ /// The seignal is sent on reversing of the item
void reversedItem(ModuleBase_FilterItem* theItem);
private slots:
+ /// A slot to process reverse button click
+ /// \param theCheck a current state of the button
void onReverse(bool theCheck);
+
+ /// A slot to process delete button click
void onDelete();
private:
+ /// A function which adds standard widgets of the item
void addItemRow(QWidget* theParent);
+ /// Current filter Id
std::string myFilterID;
+
+ /// Filters feature
FiltersFeaturePtr mySelection;
+
+ /// Reverce button
QToolButton* myRevBtn;
+
+ /// A list of sub-widgets
QList<ModuleBase_ModelWidget*> myWidgets;
};
+/**
+* \ingroup GUI
+* A widget for selection by filters
+*/
class ModuleBase_WidgetSelectionFilter : public ModuleBase_ModelWidget
{
Q_OBJECT
public:
+
+ /// 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);
+ /// Destructor
~ModuleBase_WidgetSelectionFilter();
/// Returns list of widget controls
/// By default this slot does nothing
virtual void onFeatureAccepted();
+ /// Returns current workshop
ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
+ /// Returns a container widget for filter items
QWidget* filtersWidget() const { return myFiltersWgt; }
+ /// Returns error string
+ virtual QString getError(const bool theValueStateChecked = true) const;
+
protected:
/// Saves the internal parameters to the given feature (not ussed for this widget)
/// \return True in success
virtual bool restoreValueCustom();
private slots:
+ /// Add a filter by Id in combo box
void onAddFilter(int);
+
+ /// Add a filter by name
void onAddFilter(const std::string& theFilter);
+
+ /// Process deletion of a filter item
void onDeleteItem(ModuleBase_FilterItem* theItem);
+
+ /// Process reversion of a filter item
void onReverseItem(ModuleBase_FilterItem* theItem);
+
+ /// Process selection
void onSelect();
+
+ /// Show only selected objects
void onShowOnly(bool theErase);
+ /// Process update of a filter item
+ void onObjectUpdated();
+
private:
+ /// Update state of button State
void updateSelectBtn();
+
+ /// Update number of selected objects
void updateNumberSelected();
+
+ /// Clear selection
void clearCurrentSelection(bool toUpdate = false);
+
+ /// Update preview
+ /// \param theShape a preview shape
void updatePreview(const TopoDS_Shape& theShape);
+
+ /// Call to redisplay the fiter feature
void redisplayFeature();
private:
QLabel* myNbLbl;
QCheckBox* myShowBtn;
+ /// Type of selection mode
int mySelectionType;
+
+ /// List of non-used filters
std::list<std::string> myFilters;
+
+ /// List of used filters
std::list<std::string> myUseFilters;
+ /// Result of filtering
QList<ModuleBase_ViewerPrsPtr> myValues;
+
+ /// A preview shape
Handle(AIS_Shape) myPreview;
+ /// List of displayed objects before "Show only"
AIS_ListOfInteractive myListIO;
+ /// A Feature which will get result of filtering
FeaturePtr mySelectorFeature;
+
+ /// Attribute name which will get result of filtering
std::string mySelectorAttribute;
};