- // find selected presentation either in the viewer or in OB
- // the selection in OCC viewer - the selection of a sub-shapes in the viewer
- aSelectedPrs = theSelection->getSelected();
- if (aSelectedPrs.empty()) {
- // the selection in Object Browser
- QObjectPtrList anObjects = theSelection->selectedObjects();
- QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
- for (; anIt != aLast; anIt++) {
- ObjectPtr anObject = *anIt;
- if (anObject.get() != NULL) {
- aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
- }
+ aData->blockSendAttributeUpdated(true);
+ isAttributeSetInitializedBlocked = theAttribute->blockSetInitialized(true);
+ }
+ else {
+ aData->blockSendAttributeUpdated(false);
+ theAttribute->blockSetInitialized(isAttributeSetInitializedBlocked);
+ aLoop->activateFlushes(isFlushesActived);
+ }
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrsPtr& 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_ViewerPrsPtr& 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;
+}
+
+//********************************************************************
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetValidated::getFilteredSelected()
+{
+ QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
+ ModuleBase_ISelection::Viewer);
+
+ QList<ModuleBase_ViewerPrsPtr> anOBSelected = myWorkshop->selection()->getSelected(
+ ModuleBase_ISelection::Browser);
+ // filter the OB presentations
+ filterPresentations(anOBSelected);
+ if (!anOBSelected.isEmpty())
+ ModuleBase_ISelection::appendSelected(anOBSelected, aSelected);
+
+ filterCompSolids(aSelected);
+
+ return aSelected;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::filterPresentations(QList<ModuleBase_ViewerPrsPtr>& theValues)
+{
+ QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
+
+ QList<ModuleBase_ViewerPrsPtr>::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;
+ }
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrsPtr>& theValues)
+{
+ std::set<ResultCompSolidPtr> aCompSolids;
+ QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
+
+ // Collect compsolids.
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ for (; anIt != aLast; anIt++) {
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
+ ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
+ if(aResultCompSolid.get()) {
+ aCompSolids.insert(aResultCompSolid);
+ }
+ }
+
+ // Filter sub-solids of compsolids.
+ anIt = theValues.begin();
+ for (; anIt != aLast; anIt++) {
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult);
+ if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) {
+ // Skip sub-solid of compsolid.
+ continue;
+ } else {
+ aValidatedValues.append(*anIt);