+ clearValidState();
+ }
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid)
+{
+ bool aValidPrs = myInvalidPrs.contains(theValue);
+ bool anInvalidPrs = myInvalidPrs.contains(theValue);
+
+ if (theValid) {
+ if (!aValidPrs)
+ myValidPrs.append(theValue);
+ // the commented code will be useful when the valid state of the presentation
+ // will be changable between activate/deactivate. Currently it does not happen.
+ //if (anInvalidPrs)
+ // myInvalidPrs.removeOne(theValue);
+ }
+ else { // !theValid
+ if (!anInvalidPrs)
+ myInvalidPrs.append(theValue);
+ //if (!aValidPrs)
+ // myValidPrs.removeOne(theValue);
+ }
+#ifdef DEBUG_VALID_STATE
+ qDebug(QString("storeValidState: myValidPrs.size() = %1, myInvalidPrs.size() = %2").arg(myValidPrs.count())
+ .arg(myInvalidPrs.count()).toStdString().c_str());
+#endif
+}
+
+//********************************************************************
+bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid)
+{
+ bool aValidPrs = myValidPrs.contains(theValue);
+ bool anInvalidPrs = myInvalidPrs.contains(theValue);
+
+ if (aValidPrs)
+ theValid = true;
+ else if (anInvalidPrs)
+ theValid = false;
+
+ return aValidPrs || anInvalidPrs;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::clearValidState()
+{
+#ifdef DEBUG_VALID_STATE
+ qDebug("clearValidState");
+#endif
+ myValidPrs.clear();
+ myInvalidPrs.clear();
+}
+
+//********************************************************************
+QList<ModuleBase_ViewerPrs> ModuleBase_WidgetValidated::getFilteredSelected()
+{
+ QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected(
+ ModuleBase_ISelection::Viewer);
+
+ QList<ModuleBase_ViewerPrs> anOBSelected = myWorkshop->selection()->getSelected(
+ ModuleBase_ISelection::Browser);
+ // filter the OB presentations
+ filterPresentations(anOBSelected);
+ if (!anOBSelected.isEmpty())
+ ModuleBase_ISelection::appendSelected(anOBSelected, aSelected);
+
+ return aSelected;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::filterPresentations(QList<ModuleBase_ViewerPrs>& theValues)
+{
+ QList<ModuleBase_ViewerPrs> aValidatedValues;
+
+ QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ bool isDone = false;
+ for (; anIt != aLast; anIt++) {
+ if (isValidInFilters(*anIt))
+ aValidatedValues.append(*anIt);
+ }
+ if (aValidatedValues.size() != theValues.size()) {
+ theValues.clear();
+ theValues = aValidatedValues;
+ }