//********************************************************************
-bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes)
+void ModuleBase_ResultPrs::setSubShapeHidden(const TopoDS_ListOfShape& theShapes)
{
bool isModified = false;
BRep_Builder aBBuilder;
aBBuilder.MakeCompound (aCompound);
- TopoDS_Compound aShownComp;
- if (myIsSubstituted)
- aShownComp = TopoDS::Compound(Shape());
+ myHiddenSubShapes = theShapes;
+ collectSubShapes(aBBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
+ myVisibleCompound = aCompound;
- // restore hidden shapes if there are not the shapes in parameter container
- NCollection_List<TopoDS_Shape> aVisibleSubShapes;
- NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes);
- for (; aHiddenIt.More(); aHiddenIt.Next()) {
- if (!theShapes.Contains(aHiddenIt.Value())) {
- aVisibleSubShapes.Append(aHiddenIt.Value());
- }
- else {
- aBBuilder.Add(aCompound, aHiddenIt.Value());
- if (!aShownComp.IsNull())
- aBBuilder.Remove(aShownComp, aHiddenIt.Value());
- }
- }
- isModified = !aVisibleSubShapes.IsEmpty();
- NCollection_List<TopoDS_Shape>::Iterator aVisibleIt(aVisibleSubShapes);
- for (; aVisibleIt.More(); aVisibleIt.Next()) {
- if (myHiddenSubShapes.Contains(aVisibleIt.Value())) {
- myHiddenSubShapes.Remove(aVisibleIt.Value());
- if (!aShownComp.IsNull())
- aBBuilder.Add(aShownComp, aVisibleIt.Value());
- }
- }
- // append hidden shapes into internal container if there are not these shapes
- NCollection_List<TopoDS_Shape>::Iterator aShapeIt(theShapes);
- for (; aShapeIt.More(); aShapeIt.Next()) {
- if (aShapeIt.Value().ShapeType() != TopAbs_FACE) // only face shape can be hidden
- continue;
-
- if (!myHiddenSubShapes.Contains(aShapeIt.Value())) {
- myHiddenSubShapes.Append(aShapeIt.Value());
- aBBuilder.Add (aCompound, aShapeIt.Value());
- if (!aShownComp.IsNull())
- aBBuilder.Remove(aShownComp, aShapeIt.Value());
- isModified = true;
- }
+ aBBuilder.MakeCompound (aCompound);
+ TopoDS_ListOfShape::Iterator aIt(myHiddenSubShapes);
+ for (; aIt.More(); aIt.Next()) {
+ aBBuilder.Add(aCompound, aIt.Value());
}
myHiddenCompound = aCompound;
- return isModified;
}
//********************************************************************
return false;
// orientation of parameter shape(come from selection) may be wrong, check isEqual() to be sure
- for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(myHiddenSubShapes); aShapeIt.More();
- aShapeIt.Next())
- {
+ TopoDS_ListOfShape::Iterator aShapeIt(myHiddenSubShapes);
+ for (; aShapeIt.More(); aShapeIt.Next()) {
if (theShape.IsSame(aShapeIt.Value()))
return true;
}
//********************************************************************
bool ModuleBase_ResultPrs::hasSubShapeVisible(
- const NCollection_List<TopoDS_Shape>& theShapesToSkip)
+ const TopoDS_ListOfShape& theShapesToSkip)
{
TopoDS_Compound aCompound;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aCompound);
- NCollection_List<TopoDS_Shape> aShapesToSkip;
- aShapesToSkip.Append(myHiddenSubShapes);
- for (NCollection_List<TopoDS_Shape>::Iterator anIt(theShapesToSkip); anIt.More(); anIt.Next())
+ TopoDS_ListOfShape aShapesToSkip;
+ TopoDS_ListOfShape aHiddenCopy(myHiddenSubShapes);
+ aShapesToSkip.Append(aHiddenCopy);
+ for (TopoDS_ListOfShape::Iterator anIt(theShapesToSkip); anIt.More(); anIt.Next())
aShapesToSkip.Append(anIt.Value());
collectSubShapes(aBuilder, aCompound, myOriginalShape, aShapesToSkip);
}
}
else { // convert shape into SHELL
- TopoDS_Compound aCompound;
- if (!myIsSubstituted) {
- BRep_Builder aBuilder;
- aBuilder.MakeCompound(aCompound);
- collectSubShapes(aBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
- }
- else {
- aCompound = TopoDS::Compound(Shape());
- }
- bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
- Set(aCompound);
+ bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(myVisibleCompound);
+ Set(myVisibleCompound);
myIsSubstituted = true;
if (isEmptyShape)
aReadyToDisplay = false;
//********************************************************************
void ModuleBase_ResultPrs::collectSubShapes(BRep_Builder& theBuilder,
TopoDS_Shape& theCompound, const TopoDS_Shape& theShape,
- const NCollection_List<TopoDS_Shape>& theHiddenSubShapes)
+ const TopoDS_ListOfShape& theHiddenSubShapes)
{
switch (theShape.ShapeType()) {
case TopAbs_COMPSOLID:
#include "XGUI_FacesPanel.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
#include "XGUI_Tools.h"
#include "XGUI_Workshop.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_ViewerProxy.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_ISelection.h>
#include <Config_PropManager.h>
#include <Events_Loop.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAPI_Shape.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultGroup.h>
+#include <ModelAPI_AttributeSelectionList.h>
#include <QAction>
#include <QCheckBox>
static const int LayoutMargin = 3;
//********************************************************************
-XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
+XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
: QDockWidget(theParent), myIsActive(false), myWorkshop(theWorkshop)
{
setWindowTitle(tr("Hide Faces"));
if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset
return;
- // clear internal containers
- myListView->getControl()->clear();
- myItems.clear();
+ std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+ QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
+ for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+ getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
+ }
- // restore previous view of presentations
- bool isModified = redisplayObjects(myItemObjects);
- std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
- isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects) || isModified;
- if (isModified)// && isToFlushRedisplay) // flush signal immediatelly until container is filled
+ std::set<ObjectPtr> aObjects;
+ TopoDS_ListOfShape anEmpty;
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
+ for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
+ aObjects.insert(aPrsIt->first);
+ aPrsIt->second->setSubShapeHidden(anEmpty);
+ }
+ std::set<std::shared_ptr<ModelAPI_Object> >::const_iterator aGrpIt;
+ for (aGrpIt = myHiddenGroups.cbegin(); aGrpIt != myHiddenGroups.cend(); aGrpIt++)
+ (*aGrpIt)->setDisplayed(true);
+ myHiddenGroups.clear();
+
+ if (redisplayObjects(aObjects))
flushRedisplay();
+ // clear internal containers
+ myListView->getControl()->clear();
+ myItems.clear();
updateProcessedObjects(myItems, myItemObjects);
- myHiddenObjects.clear();
myLastItemIndex = 0; // it should be after redisplay as flag used in customize
+ myHiddenObjects.clear();
}
//********************************************************************
ModuleBase_IModule* aModule = myWorkshop->module();
QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
- theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter));
+ // The global filter makes problem for groups selection when any operation is launched
+ // theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter));
theSelectionFilters.Append(aModule->selectionFilter(SF_FilterInfinite));
theSelectionFilters.Append(aModule->selectionFilter(SF_ResultGroupNameFilter));
}
// selection should be cleared after emit of signal to do not process selection change
// event by the previous selector
// the selection is cleared by activating selection control
- XGUI_Tools::workshop(myWorkshop)->selector()->clearSelection();
+ myWorkshop->selector()->clearSelection();
}
else
emit deactivated();
return myHiddenOrTransparent->isChecked();
}
+//********************************************************************
+double XGUI_FacesPanel::transparency() const
+{
+ return useTransparency() ?
+ Config_PropManager::real("Visualization", "hidden_face_transparency") : 1;
+}
+
+
//********************************************************************
void XGUI_FacesPanel::restoreObjects(const std::set<ObjectPtr>& theHiddenObjects)
{
}
}
+//********************************************************************
+void XGUI_FacesPanel::getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
+ std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
+{
+ ObjectPtr anObject = thePrs->object();
+ if (!anObject.get())
+ return;
+
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+ if (aResGroup.get()) {
+ // Process a grouip result
+ FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
+ AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+ AISObjectPtr aPrs;
+ for (int i = 0; i < aSelectionList->size(); i++) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(i);
+ ResultPtr aRes = aSelection->context();
+ aPrs = aDisplayer->getAISObject(aRes);
+ if (aPrs.get()) {
+ Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+ aPrs->impl<Handle(AIS_InteractiveObject)>());
+ if (!aResultPrs.IsNull()) {
+ GeomShapePtr aShape = aSelection->value();
+ if (theObjectToShapes.find(aRes) != theObjectToShapes.end())
+ theObjectToShapes.at(aRes).Append(aShape->impl<TopoDS_Shape>());
+ else {
+ TopoDS_ListOfShape aListOfShapes;
+ aListOfShapes.Append(aShape->impl<TopoDS_Shape>());
+ theObjectToShapes[aRes] = aListOfShapes;
+ theObjectToPrs[aRes] = aResultPrs;
+ }
+ }
+ }
+ }
+ }
+ else {
+ // Process bodies
+ Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+ thePrs->interactive());
+ if (aResultPrs.IsNull())
+ return;
+
+ if (theObjectToShapes.find(anObject) != theObjectToShapes.end())
+ theObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(thePrs));
+ else {
+ TopoDS_ListOfShape aListOfShapes;
+ aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(thePrs));
+ theObjectToShapes[anObject] = aListOfShapes;
+ theObjectToPrs[anObject] = aResultPrs;
+ }
+ }
+}
+
//********************************************************************
void XGUI_FacesPanel::processSelection()
{
- QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
- ModuleBase_ISelection::Viewer);
+ QList<ModuleBase_ViewerPrsPtr> aSelected =
+ myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Viewer);
+
bool isModified = false;
static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
+ std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+ std::set<int> aToRemove;
+
for (int i = 0; i < aSelected.size(); i++) {
ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
ObjectPtr anObject = aPrs->object();
if (!anObject.get())
continue;
- if (ModuleBase_Tools::getSelectedShape(aPrs).ShapeType() != TopAbs_FACE)
- continue;
- Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
- aPrs->interactive());
- if (aResultPrs.IsNull())
- continue;
- QString aItemName = XGUI_Tools::generateName(aPrs);
+ ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+ if (!aResGroup.get()) {
+ GeomShapePtr aShapePtr = aPrs->shape();
+ if (!aShapePtr.get() || !aShapePtr->isFace())
+ return;
+ }
+
+ QString aItemName = aResGroup.get()?
+ aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs);
if (myListView->hasItem(aItemName))
return;
+ getObjectsMapFromPrs(aPrs, anObjectToShapes, anObjectToPrs);
+ if (aResGroup.get() && aResGroup->isDisplayed()) {
+ aResGroup->setDisplayed(false);
+ myHiddenGroups.insert(aResGroup);
+ }
+
+ // The code is dedicated to remove already selected items if they are selected twice
+ // It can happen in case of groups selection
+ QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator aIt;
+ for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+ ModuleBase_ViewerPrsPtr aPrs = aIt.value();
+ ObjectPtr aObject = aPrs->object();
+ ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObject);
+ if (aResGroup.get())
+ continue;
+ if (anObjectToShapes.find(aObject) != anObjectToShapes.end()) {
+ TopoDS_ListOfShape aShapes = anObjectToShapes[aObject];
+ GeomShapePtr aShapePtr = aPrs->shape();
+ if (aShapes.Contains(aShapePtr->impl<TopoDS_Shape>())) {
+ aToRemove.insert(aIt.key());
+ }
+ }
+ }
+
myItems.insert(myLastItemIndex, aPrs);
myListView->addItem(aItemName, myLastItemIndex);
myLastItemIndex++;
isModified = true;
-
- if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
- anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
- else {
- NCollection_List<TopoDS_Shape> aListOfShapes;
- aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
- anObjectToShapes[anObject] = aListOfShapes;
- anObjectToPrs[anObject] = aResultPrs;
- }
}
- for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator
- anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
+
+ // Hide fully hidden shapes
+ std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator anIt;
+ for (anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
ObjectPtr anObject = anIt->first;
if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
continue;
}
ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
}
+
+ // Process selected presentations
+ double aTransp = transparency();
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::iterator aPrsIt;
+ for (aPrsIt = anObjectToPrs.begin(); aPrsIt != anObjectToPrs.end(); aPrsIt++) {
+ ObjectPtr anObject = aPrsIt->first;
+ Handle(ModuleBase_ResultPrs) aPrs = aPrsIt->second;
+ TopoDS_ListOfShape aAlreadyHidden = aPrs->hiddenSubShapes();
+ TopoDS_ListOfShape aListOfShapes = anObjectToShapes[anObject];
+ TopoDS_ListOfShape::Iterator aShapesIt(aListOfShapes);
+ for (; aShapesIt.More(); aShapesIt.Next()) {
+ if (!aAlreadyHidden.Contains(aShapesIt.Value()))
+ aAlreadyHidden.Append(aShapesIt.Value());
+ }
+ aPrs->setSubShapeHidden(aAlreadyHidden);
+ aPrs->setHiddenSubShapeTransparency(aTransp);
+ }
+
+ // Remove duplicate items
+ if (aToRemove.size() > 0) {
+ myListView->removeItems(aToRemove);
+ std::set<int>::const_iterator aIntIt;
+ for (aIntIt = aToRemove.cbegin(); aIntIt != aToRemove.cend(); aIntIt++)
+ myItems.remove(*aIntIt);
+ }
if (isModified) {
updateProcessedObjects(myItems, myItemObjects);
flushRedisplay();
}
- onTransparencyChanged();
}
//********************************************************************
return false;
bool isModified = false;
- std::set<ObjectPtr> aRestoredObjects;
- for (std::set<int>::const_iterator anIt = aSelectedIds.begin(); anIt != aSelectedIds.end();
- anIt++) {
+ std::set<ModuleBase_ViewerPrsPtr> aRestored;
+ std::set<int>::const_iterator anIt;
+ for (anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); anIt++) {
ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt];
- if (aRestoredObjects.find(aPrs->object()) == aRestoredObjects.end())
- aRestoredObjects.insert(aPrs->object());
- myItems.remove(*anIt);
- isModified = true;
+ if (aRestored.find(aPrs) == aRestored.end()) {
+ aRestored.insert(aPrs);
+ myItems.remove(*anIt);
+ isModified = true;
+ }
}
- if (isModified) {
- bool isRedisplayed = redisplayObjects(aRestoredObjects);
- isRedisplayed = displayHiddenObjects(aRestoredObjects, myHiddenObjects)
- || isRedisplayed;
- if (isRedisplayed) {
- flushRedisplay();
- myWorkshop->viewer()->update();
+ std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+
+ std::set<ModuleBase_ViewerPrsPtr>::const_iterator aIt;
+ for (aIt = aRestored.cbegin(); aIt != aRestored.cend(); aIt++) {
+ getObjectsMapFromPrs((*aIt), anObjectToShapes, anObjectToPrs);
+ ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>((*aIt)->object());
+ if (aResGroup.get()) {
+ std::set<std::shared_ptr<ModelAPI_Object> >::iterator aGrpIt = myHiddenGroups.find(aResGroup);
+ if (aGrpIt != myHiddenGroups.end()) {
+ aResGroup->setDisplayed(true);
+ myHiddenGroups.erase(aGrpIt);
+ }
}
- // should be after flush of redisplay to have items object to be updated
- updateProcessedObjects(myItems, myItemObjects);
+ }
+ std::set<ObjectPtr> aRestoredObjects;
+ std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator aShapesIt;
+ for (aShapesIt = anObjectToShapes.begin(); aShapesIt != anObjectToShapes.end(); aShapesIt++) {
+ TopoDS_ListOfShape aShapes = aShapesIt->second;
+ aRestoredObjects.insert(aShapesIt->first);
+ Handle(ModuleBase_ResultPrs) aPrs = anObjectToPrs[aShapesIt->first];
+ TopoDS_ListOfShape aHiddenShapes = aPrs->hiddenSubShapes();
+ TopoDS_ListOfShape::Iterator aSubShapesIt(aShapes);
+ for (; aSubShapesIt.More(); aSubShapesIt.Next()) {
+ if (aHiddenShapes.Contains(aSubShapesIt.Value()))
+ aHiddenShapes.Remove(aSubShapesIt.Value());
+ }
+ aPrs->setSubShapeHidden(aHiddenShapes);
}
+ if (redisplayObjects(aRestoredObjects))
+ flushRedisplay();
myListView->removeSelectedItems();
- // Restore selection
- myListView->restoreSelection(anIndices);
- //appendSelectionInHistory();
return true;
}
return isModified;
}
-//********************************************************************
-bool XGUI_FacesPanel::displayHiddenObjects(
- const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
- std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects)
-{
- if (theObjects.empty())
- return false;
-
- bool isModified = false;
- static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-
- for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(); anIt != theObjects.end();
- anIt++)
- {
- ObjectPtr anObject = *anIt;
- // if the object was hidden by this panel
- if (anObject->isDisplayed() || theHiddenObjects.find(anObject) == theHiddenObjects.end())
- continue;
- theHiddenObjects.erase(anObject);
- anObject->setDisplayed(true); // it means that the object is hidden by hide all faces
- ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
- isModified = true;
- }
- return isModified;
-}
-
-//********************************************************************
-bool XGUI_FacesPanel::hideEmptyObjects()
-{
- bool isModified = false;
- static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
- std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
-
- for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
- anIt != myItems.end(); anIt++) {
- ModuleBase_ViewerPrsPtr aPrs = anIt.value();
- ObjectPtr anObject = aPrs->object();
- if (!anObject.get() || !anObject->isDisplayed())
- continue;
-
- Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
- aPrs->interactive());
- if (aResultPrs.IsNull())
- continue;
-
- if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
- anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
- else {
- NCollection_List<TopoDS_Shape> aListOfShapes;
- aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
- anObjectToShapes[anObject] = aListOfShapes;
- anObjectToPrs[anObject] = aResultPrs;
- }
- }
- for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator
- anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
- ObjectPtr anObject = anIt->first;
- if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
- continue;
- Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
-
- if (!aResultPrs->hasSubShapeVisible(anIt->second)) {
- // erase object because it is entirely hidden
- anObject->setDisplayed(false);
- myHiddenObjects.insert(anObject);
- ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
- isModified = true;
- }
- }
- return isModified;
-}
-
//********************************************************************
void XGUI_FacesPanel::updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr> theItems,
std::set<ObjectPtr>& theObjects)
anIt != theItems.end(); anIt++) {
ModuleBase_ViewerPrsPtr aPrs = anIt.value();
ObjectPtr anObject = aPrs.get() ? aPrs->object() : ObjectPtr();
- if (anObject.get() && theObjects.find(anObject) != theObjects.end())
- continue;
- theObjects.insert(anObject);
+ if (anObject.get()) {
+ ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+ if (aResGroup.get()) {
+ FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
+ AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+ for (int i = 0; i < aSelectionList->size(); i++) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(i);
+ ResultPtr aRes = aSelection->context();
+ if (theObjects.find(aRes) == theObjects.end())
+ theObjects.insert(aRes);
+ }
+ }
+ else {
+ if (theObjects.find(anObject) == theObjects.end())
+ theObjects.insert(anObject);
+ }
+ }
}
}
//********************************************************************
bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject,
- const AISObjectPtr& thePresentation)
+ const AISObjectPtr& thePresentation)
{
- if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset
- return false;
-
- if (thePresentation.get() == NULL)
- return false;
-
- if (myItemObjects.find(theObject) == myItemObjects.end()) // not found
- return false;
-
- // if the object is displayed, the hidden faces are collected and set to the presentation
- bool isModified = false;
- NCollection_List<TopoDS_Shape> aHiddenSubShapes;
- for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
- anIt != myItems.end(); anIt++) {
- ModuleBase_ViewerPrsPtr aPrs = anIt.value();
- if (aPrs.get() && aPrs->object() != theObject)
- continue;
- TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
- if (!aHiddenSubShapes.Contains(aShape))
- aHiddenSubShapes.Append(aShape);
- }
-
- Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
- thePresentation->impl<Handle(AIS_InteractiveObject)>());
- if (aResultPrs.IsNull())
- return false;
-
- isModified = aResultPrs->setSubShapeHidden(aHiddenSubShapes);
-
- double aTransparency = !useTransparency() ? 1
- : Config_PropManager::real("Visualization", "hidden_face_transparency");
- isModified = aResultPrs->setHiddenSubShapeTransparency(aTransparency) || isModified;
-
- return isModified;
+ return myItems.size() > 0;
}
//********************************************************************
//********************************************************************
void XGUI_FacesPanel::onTransparencyChanged()
{
- bool isModified = false;
- if (useTransparency()) {
- std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
- isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects);
+ std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+ QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
+ for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+ getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
}
- else
- isModified = hideEmptyObjects();
- isModified = redisplayObjects(myItemObjects) || isModified;
- if (isModified)
+ double aTransp = Config_PropManager::real("Visualization", "hidden_face_transparency");
+ std::set<ObjectPtr> aObjects;
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
+ for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
+ aObjects.insert(aPrsIt->first);
+ aPrsIt->second->setHiddenSubShapeTransparency(useTransparency()? aTransp : 1);
+ }
+ if (redisplayObjects(aObjects))
flushRedisplay();
}
{
Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
// Necessary for update visibility icons in ObjectBrowser
- XGUI_ObjectsBrowser* anObjectBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
+ XGUI_ObjectsBrowser* anObjectBrowser = myWorkshop->objectBrowser();
if (anObjectBrowser)
anObjectBrowser->updateAllIndexes();
+ myWorkshop->viewer()->update();
}
#include <ModuleBase_ActionType.h>
#include <ModuleBase_Definitions.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ResultPrs.h>
#include <SelectMgr_ListOfFilter.hxx>
+#include <TopoDS_Shape.hxx>
#include <QDockWidget>
#include <QObject>
class GeomAPI_AISObject;
-class ModuleBase_IWorkshop;
+class XGUI_Workshop;
class ModuleBase_ListView;
class QAction;
public:
/// Constructor
/// \param theParent is a parent of the property panel
- XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop);
+ XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop);
~XGUI_FacesPanel() {}
/// Clear content of list widget
/// \param theIsActive state whether the panel should be activated or deactivated
void setActivePanel(const bool theIsActive);
- /// Returns true if transparency choice is checked
- /// \return boolean value
- bool useTransparency() const;
-
/// Returns true if the object is in internal container of hidden objects by this panel
/// \param theObject a checked object
/// \return boolean value
bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject,
const std::shared_ptr<GeomAPI_AISObject>& thePresentation);
+
+ XGUI_Workshop* workshop() const { return myWorkshop; }
+
+
protected:
/// Reimplementation to emit a signal about the panel close
virtual void closeEvent(QCloseEvent* theEvent);
/// \return true if some of objects was redisplayed
static bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
- /// Display objects if the objects are in a container of hidden by this pane.
- /// \param theObjects container of objects
- /// \param theHiddenObjects hidden objects, if object is in the container, it should be removed
- /// \return true if some of objects was redisplayed
- static bool displayHiddenObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
- std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects);
-
- /// Iterates by items and hide objects where all sub-shapes are hidden
- /// \return true if some of objects was redisplayed
- bool hideEmptyObjects();
-
/// Container of objects participating in the panel, it is filled by internal container
/// \param theItems container of selected values
/// \param theObjects [out] container of objects
static void updateProcessedObjects(QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > theItems,
std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
+ /// Returns maps of shapes and presentations. If object is a body result then it returns
+ /// its ruslts. If it is a group then it returns result of shapes included into the gropup
+ /// The function doesn't clear content of input maps.
+ /// \param thePrs a selected presintation
+ /// \param theObjectsToShapes map of objects to shapes list
+ /// \param theObjectToPrs map of objects to presentations
+ void getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
+ std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectsToShapes,
+ std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs);
+
+ /// Returns true if transparency choice is checked
+ /// \return boolean value
+ bool useTransparency() const;
+
+ double transparency() const;
+
protected slots:
/// Deletes element in list of items
void onDeleteItem();
protected:
QCheckBox* myHiddenOrTransparent; ///< if checked - transparent, else hidden
ModuleBase_ListView* myListView; ///< list control of processed faces
- ModuleBase_IWorkshop* myWorkshop; ///< workshop
+ XGUI_Workshop* myWorkshop; ///< workshop
bool myIsActive; ///< current state about the panel is active
int myLastItemIndex; ///< last index to be used in the map of items for the next added item
- QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > myItems; ///< selected face items
+ QMap<int, ModuleBase_ViewerPrsPtr> myItems; ///< selected face items
std::set<std::shared_ptr<ModelAPI_Object> > myItemObjects; ///< cached objects of myItems
std::set<std::shared_ptr<ModelAPI_Object> > myHiddenObjects; ///< hidden objects
+ std::set<std::shared_ptr<ModelAPI_Object> > myHiddenGroups; ///< hidden objects
};
#endif
\ No newline at end of file