myUseSubShapes = theData->getBooleanAttribute("use_subshapes", false);
//TODO_END
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
+
activateSelection(true);
}
//********************************************************************
bool ModuleBase_WidgetMultiSelector::eventFilter(QObject* theObj, QEvent* theEvent)
{
- if (theObj == myListControl) {
- if (theEvent->type() == QEvent::FocusIn)
- activateSelection(true);
- }
+ //TODO: Remove maybe?
return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
}
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
+{
+ myIsActive = toActivate;
+ if (myIsActive) {
+ connect(myWorkshop, SIGNAL(selectionChanged()),
+ this, SLOT(onSelectionChanged()),
+ Qt::UniqueConnection);
+ activateShapeSelection();
+ } else {
+ disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+ myWorkshop->deactivateSubShapesSelection();
+ }
+}
+
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
+{
+ activateShapeSelection();
+ QList<ObjectPtr> anEmptyList;
+ myWorkshop->setSelected(anEmptyList);
+ // Clear mySelection, myListControl and storeValue()
+ onSelectionChanged();
+}
+
//********************************************************************
void ModuleBase_WidgetMultiSelector::onSelectionChanged()
{
emit valuesChanged();
}
-
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::updateSelectionList()
-{
- QString aType;
- if (myTypeCombo->currentText().toLower() == "vertices")
- aType = "vertex";
- else if (myTypeCombo->currentText().toLower() == "edges")
- aType = "edge";
- else if (myTypeCombo->currentText().toLower() == "faces")
- aType = "face";
- else if (myTypeCombo->currentText().toLower() == "solids")
- aType = "solid";
-
- myListControl->clear();
- int i = 1;
- foreach (GeomSelection aSel, mySelection) {
- QString aName(aSel.first->data()->name().c_str());
- aName += ":" + aType + QString("_%1").arg(i);
- myListControl->addItem(aName);
- i++;
- }
-}
-
-
//********************************************************************
void ModuleBase_WidgetMultiSelector::filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
NCollection_List<TopoDS_Shape>& theResult)
}
}
-
//********************************************************************
void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum theShapeType)
{
QString aShapeTypeName;
+
for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
aShapeTypeName = myTypeCombo->itemText(idx);
TopAbs_ShapeEnum aRefType = ModuleBase_WidgetShapeSelector::shapeType(aShapeTypeName);
if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
+ activateSelection(false);
bool isBlocked = myTypeCombo->blockSignals(true);
myTypeCombo->setCurrentIndex(idx);
myTypeCombo->blockSignals(isBlocked);
+ activateSelection(true);
break;
}
}
}
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
-{
- myIsActive = toActivate;
- if (myIsActive) {
- connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- activateShapeSelection();
- } else {
- disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- myWorkshop->deactivateSubShapesSelection();
- }
-}
-
void ModuleBase_WidgetMultiSelector::activateShapeSelection()
{
QString aNewType = myTypeCombo->currentText();
}
//********************************************************************
-void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
+void ModuleBase_WidgetMultiSelector::updateSelectionList()
{
- QList<ObjectPtr> anEmptyList;
- myWorkshop->setSelected(anEmptyList);
- activateShapeSelection();
- onSelectionChanged();
-}
+ QString aType;
+ if (myTypeCombo->currentText().toLower() == "vertices")
+ aType = "vertex";
+ else if (myTypeCombo->currentText().toLower() == "edges")
+ aType = "edge";
+ else if (myTypeCombo->currentText().toLower() == "faces")
+ aType = "face";
+ else if (myTypeCombo->currentText().toLower() == "solids")
+ aType = "solid";
+
+ myListControl->clear();
+ int i = 1;
+ foreach (GeomSelection aSel, mySelection) {
+ QString aName(aSel.first->data()->name().c_str());
+ aName += ":" + aType + QString("_%1").arg(i);
+ myListControl->addItem(aName);
+ i++;
+ }
+}
\ No newline at end of file