#include <Events_InfoMessage.h>
#include <Events_Loop.h>
+#include <AIS_ColoredDrawer.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Selection.hxx>
#include <BRep_Builder.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
-#include <TopoDS_Builder.hxx>
-#include <TopoDS.hxx>
+#include <Prs3d_ShadingAspect.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectionManager.hxx>
#include <StdPrs_WFShape.hxx>
+#include <StdPrs_ShadedShape.hxx>
#include <StdSelect_BRepSelectionTool.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Selection.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Builder.hxx>
//*******************************************************************************************
+//********************************************************************
ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
- : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0)
+ : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0),
+ myTransparency(1)
{
std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
SetAutoHilight(aCompSolid.get() == NULL);
+ myHiddenSubShapesDrawer = new AIS_ColoredDrawer (myDrawer);
+ Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
+ aShadingAspect->SetMaterial(Graphic3d_NOM_BRASS); //default value of context material
+ myHiddenSubShapesDrawer->SetShadingAspect(aShadingAspect);
+
ModuleBase_Tools::setPointBallHighlighting(this);
}
+//********************************************************************
void ModuleBase_ResultPrs::setAdditionalSelectionPriority(const int thePriority)
{
myAdditionalSelectionPriority = thePriority;
}
+//********************************************************************
+void ModuleBase_ResultPrs::SetColor (const Quantity_Color& theColor)
+{
+ ViewerData_AISShape::SetColor(theColor);
+ myHiddenSubShapesDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
+}
+
+//********************************************************************
bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes)
{
bool isModified = false;
+ TopoDS_Compound aCompound;
+ BRep_Builder aBBuilder;
+ aBBuilder.MakeCompound (aCompound);
// restore hidden shapes if there are not the shapes in parameter container
NCollection_List<TopoDS_Shape> aVisibleSubShapes;
for (NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes); aHiddenIt.More();
aHiddenIt.Next()) {
if (!theShapes.Contains(aHiddenIt.Value()))
aVisibleSubShapes.Append(aHiddenIt.Value());
+ else
+ aBBuilder.Add (aCompound, aHiddenIt.Value());
}
isModified = !aVisibleSubShapes.IsEmpty();
for (NCollection_List<TopoDS_Shape>::Iterator aVisibleIt(aVisibleSubShapes); aVisibleIt.More();
if (!myHiddenSubShapes.Contains(aShapeIt.Value())) {
myHiddenSubShapes.Append(aShapeIt.Value());
+ aBBuilder.Add (aCompound, aShapeIt.Value());
isModified = true;
}
}
+ myHiddenCompound = aCompound;
return isModified;
}
+//********************************************************************
bool ModuleBase_ResultPrs::hasSubShapeVisible(const TopoDS_Shape& theShape)
{
int aNbOfHiddenSubShapes = myHiddenSubShapes.Size();
return aHasVisibleShape;
}
+//********************************************************************
+bool ModuleBase_ResultPrs::setHiddenSubShapeTransparency(double theTransparency)
+{
+ if (theTransparency > 1 || theTransparency < 0)
+ return false;
+
+ myTransparency = theTransparency;
+ myHiddenSubShapesDrawer->ShadingAspect()->SetTransparency (theTransparency, myCurrentFacingModel);
+ return true;
+}
+
+//********************************************************************
void ModuleBase_ResultPrs::Compute(
const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
//ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+ // visualize hidden sub-shapes transparent
+ if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
+ {
+ StdPrs_ShadedShape::Add (thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
+ }
+
if (!aReadyToDisplay) {
Events_InfoMessage("ModuleBase_ResultPrs",
"An empty AIS presentation: ModuleBase_ResultPrs").send();
}
}
+//********************************************************************
void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode)
{
}
}
+//********************************************************************
bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode)
{
return false;
}
+//********************************************************************
void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
const SelectMgr_SequenceOfOwner& theOwners)
{
}
}
+//********************************************************************
void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Graphic3d_HighlightStyle)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
#include <NCollection_List.hxx>
#include <ViewerData_AISShape.hxx>
#include <Standard_DefineHandle.hxx>
+#include <TopoDS_Compound.hxx>
#include <QMap>
+class AIS_ColoredDrawer;
+class AIS_InteractiveContext;
+
DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape)
/**
/// \param thePriority a new priority value
Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
+ //! Updates color of sub shape drawer
+ Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor);
+
/// Change presentation to have given shape hidden.
/// It suports FACE type of the shape to be hidden.
/// If presentation type is greater than FACE, the SHELL with be shown with the FACE hidden
/// \return boolean value
Standard_EXPORT bool hasSubShapeVisible(const TopoDS_Shape& theShapeToSkip);
+ /// Set transparency of hidden sub shapes: if value is 1, shapes are entirely hidden
+ /// \param theTransparency transparency value
+ /// \return false if parameter is out of [0, 1]
+ Standard_EXPORT bool setHiddenSubShapeTransparency(double theTransparency);
+
DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
protected:
/// Container of original Shape sub shape to be hidden and not selectable
NCollection_List<TopoDS_Shape> myHiddenSubShapes;
+ TopoDS_Compound myHiddenCompound; /// compound of hidden sub shapes
+ double myTransparency; ///< transparency of hidden shapes, where 0 - there is no transparency
+ Handle(AIS_ColoredDrawer) myHiddenSubShapesDrawer; ///< drawer for hidden sub shapes
/// selection priority that will be added to the standard
/// selection priority of the selection entity
#include "XGUI_FacesPanel.h"
+#include <Config_PropManager.h>
#include <Events_Loop.h>
-#include "GeomAlgoAPI_CompoundBuilder.h"
+#include <GeomAlgoAPI_CompoundBuilder.h>
#include <ModelAPI_Events.h>
myHiddenOrTransparent = new QCheckBox(tr("Transparent"), aContent);
myListView = new ModuleBase_ListView(aContent, "", "Hidden/transparent faces in 3D view");
- connect(myListView->getControl(), SIGNAL(itemSelectionChanged()), SLOT(onListSelection()));
connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem()));
aMainLayout->addWidget(myHiddenOrTransparent, 0, 0);
}
}
+//********************************************************************
+bool XGUI_FacesPanel::useTransparency() const
+{
+ return myHiddenOrTransparent->isChecked();
+}
+
//********************************************************************
void XGUI_FacesPanel::restoreObjects(const std::set<ObjectPtr>& theHiddenObjects)
{
aHiddenSubShapes.Append(aShape);
}
isModified = aResultPrs->setSubShapeHidden(aHiddenSubShapes);
+ double aTransparency = !useTransparency() ? 1
+ : Config_PropManager::real("Visualization", "hidden_face_transparency");
+ aResultPrs->setHiddenSubShapeTransparency(aTransparency);
return isModified;
}