//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//********************************************************************
ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
: ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0),
//********************************************************************
ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
: ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myAdditionalSelectionPriority(0),
// Set own free boundaries aspect in order to have free
// and unfree boundaries with different colors
Handle(Prs3d_Drawer) aDrawer = Attributes();
// Set own free boundaries aspect in order to have free
// and unfree boundaries with different colors
Handle(Prs3d_Drawer) aDrawer = Attributes();
- // Activate individual repaintng if this is a part of compsolid
- ResultBodyPtr aResOwner = ModelAPI_Tools::bodyOwner(myResult);
- SetAutoHilight(aResOwner.get() == NULL);
-
- myHiddenSubShapesDrawer = new AIS_ColoredDrawer (myDrawer);
+ 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);
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
aShadingAspect->SetMaterial(Graphic3d_NOM_BRASS); //default value of context material
myHiddenSubShapesDrawer->SetShadingAspect(aShadingAspect);
- AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
-
- if (!aHasColor) {
- Handle(Prs3d_Drawer) aDrawer = Attributes();
- Handle(Prs3d_LineAspect) anAspect; // = aDrawer->LineAspect();
- //anAspect->SetColor(Quantity_NOC_YELLOW);
- //aDrawer->SetLineAspect(anAspect);
-
- // - unfree boundaries color
- anAspect = aDrawer->UnFreeBoundaryAspect();
- anAspect->SetColor(Quantity_NOC_YELLOW);
- aDrawer->SetUnFreeBoundaryAspect(anAspect);
- aDrawer->SetUnFreeBoundaryDraw(true);
-
- // - free boundaries color
- anAspect = aDrawer->FreeBoundaryAspect();
- anAspect->SetColor(Quantity_NOC_GREEN);
- aDrawer->SetFreeBoundaryAspect(anAspect);
- aDrawer->SetFreeBoundaryDraw(true);
-
- // - standalone edges color
- anAspect = aDrawer->WireAspect();
- anAspect->SetColor(Quantity_NOC_RED);
- aDrawer->SetWireAspect(anAspect);
+ if (myResult.get()) {
+ AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
+
+ if (!aHasColor) {
+ Handle(Prs3d_Drawer) aDrawer = Attributes();
+ Handle(Prs3d_LineAspect) anAspect; // = aDrawer->LineAspect();
+ //anAspect->SetColor(Quantity_NOC_YELLOW);
+ //aDrawer->SetLineAspect(anAspect);
+
+ // - unfree boundaries color
+ anAspect = aDrawer->UnFreeBoundaryAspect();
+ anAspect->SetColor(Quantity_NOC_YELLOW);
+ aDrawer->SetUnFreeBoundaryAspect(anAspect);
+ aDrawer->SetUnFreeBoundaryDraw(true);
+
+ // - free boundaries color
+ anAspect = aDrawer->FreeBoundaryAspect();
+ anAspect->SetColor(Quantity_NOC_GREEN);
+ aDrawer->SetFreeBoundaryAspect(anAspect);
+ aDrawer->SetFreeBoundaryDraw(true);
+
+ // - standalone edges color
+ anAspect = aDrawer->WireAspect();
+ anAspect->SetColor(Quantity_NOC_RED);
+ aDrawer->SetWireAspect(anAspect);
+ }
- for (NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes); aHiddenIt.More();
- aHiddenIt.Next()) {
- if (!theShapes.Contains(aHiddenIt.Value()))
+ NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes);
+ for (; aHiddenIt.More(); aHiddenIt.Next()) {
+ if (!theShapes.Contains(aHiddenIt.Value())) {
- else
- aBBuilder.Add (aCompound, aHiddenIt.Value());
+ }
+ else {
+ aBBuilder.Add(aCompound, aHiddenIt.Value());
+ if (!aShownComp.IsNull())
+ aBBuilder.Remove(aShownComp, aHiddenIt.Value());
+ }
- for (NCollection_List<TopoDS_Shape>::Iterator aVisibleIt(aVisibleSubShapes); aVisibleIt.More();
- aVisibleIt.Next())
- myHiddenSubShapes.Remove(aVisibleIt.Value());
-
+ 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());
+ }
+ }
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 (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());
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
bool aReadyToDisplay = aShapePtr.get();
if (aReadyToDisplay) {
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
if (myHiddenSubShapes.IsEmpty() || myOriginalShape.ShapeType() > TopAbs_FACE ) {
bool aReadyToDisplay = aShapePtr.get();
if (aReadyToDisplay) {
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
if (myHiddenSubShapes.IsEmpty() || myOriginalShape.ShapeType() > TopAbs_FACE ) {
- BRep_Builder aBuilder;
- aBuilder.MakeCompound (aCompound);
- collectSubShapes(aBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
+ if (!myIsSubstituted) {
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(aCompound);
+ collectSubShapes(aBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
+ }
+ else {
+ aCompound = TopoDS::Compound(Shape());
+ }
- if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
- {
- StdPrs_ShadedShape::Add (thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
- aReadyToDisplay = true;
- }
+ if (myResult.get()) {
+ if (myTransparency < 1 && !myHiddenSubShapes.IsEmpty())
+ {
+ StdPrs_ShadedShape::Add(thePresentation, myHiddenCompound, myHiddenSubShapesDrawer);
+ aReadyToDisplay = true;
+ }
- if (!aReadyToDisplay) {
- Events_InfoMessage("ModuleBase_ResultPrs",
- "An empty AIS presentation: ModuleBase_ResultPrs").send();
- static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
- ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
+ if (!aReadyToDisplay) {
+ Events_InfoMessage("ModuleBase_ResultPrs",
+ "An empty AIS presentation: ModuleBase_ResultPrs").send();
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
+ ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
+ }