#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <AIS_GraphicTool.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
Handle(PrsMgr_Presentation3d)::DownCast( myPresentations(i).Presentation() );
if ( !aPrs3d.IsNull() ) {
aStruct = Handle(Graphic3d_Structure)::DownCast( aPrs3d->Presentation() );
- if( !aStruct.IsNull() )
+ if( !aStruct.IsNull() ) {
aStruct->SetPrimitivesAspect( myDrawer->ShadingAspect()->Aspect() );
+ // Workaround for issue 23115: Need to update also groups, because their
+ // face aspect ALWAYS overrides the structure's.
+ const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
+ Standard_Integer aGroupIndex = 1, aGroupNb = aGroups.Length();
+ for ( ; aGroupIndex <= aGroupNb; aGroupIndex++ ) {
+ Handle(Graphic3d_Group) aGrp = aGroups.Value(aGroupIndex);
+ if ( !aGrp.IsNull() && aGrp->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA) ) {
+ Handle(Graphic3d_AspectFillArea3d) aFaceAsp = new Graphic3d_AspectFillArea3d();
+ Handle(Graphic3d_AspectLine3d) aLineAsp = new Graphic3d_AspectLine3d();
+ Handle(Graphic3d_AspectMarker3d) aPntAsp = new Graphic3d_AspectMarker3d();
+ Handle(Graphic3d_AspectText3d) aTextAsp = new Graphic3d_AspectText3d();
+ // TODO: Add methods for retrieving individual aspects from Graphic3d_Group
+ aGrp->GroupPrimitivesAspect(aLineAsp, aTextAsp, aPntAsp, aFaceAsp);
+ aFaceAsp->SetPolygonOffsets(aMode, aFactor, aUnits);
+ aGrp->SetGroupPrimitivesAspect(aFaceAsp);
+ }
+ }
+ }
}
}
}
return 0;
}
+//=======================================================================
+//function : VPolygonOffset
+//purpose : Set or get polygon offset parameters
+//=======================================================================
+static Standard_Integer VPolygonOffset(Draw_Interpretor& di,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ std::cout << argv[0] << " Call 'vinit' before!\n";
+ return 1;
+ }
+
+ if (argc > 2 && argc != 5)
+ {
+ std::cout << "Usage : " << argv[0] << " [object [mode factor units]] - sets/gets polygon offset parameters for an object,"
+ "without arguments prints the default values" << std::endl;
+ return 1;
+ }
+
+ // find object
+ Handle(AIS_InteractiveObject) anInterObj;
+ if (argc >= 2)
+ {
+ TCollection_AsciiString aName (argv[1]);
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ if (!aMap.IsBound2 (aName))
+ {
+ std::cout << "Use 'vdisplay' before" << std::endl;
+ return 1;
+ }
+
+ // find interactive object
+ Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
+ anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
+ if (anInterObj.IsNull())
+ {
+ std::cout << "Not an AIS interactive object!" << std::endl;
+ return 1;
+ }
+ }
+
+ Standard_Integer aMode;
+ Standard_Real aFactor, aUnits;
+ if (argc == 5)
+ {
+ aMode = atoi(argv[2]);
+ aFactor = atof(argv[3]);
+ aUnits = atof(argv[4]);
+
+ anInterObj->SetPolygonOffsets(aMode, aFactor, aUnits);
+ aContext->UpdateCurrentViewer();
+ return 0;
+ }
+ else if (argc == 2)
+ {
+ if (anInterObj->HasPolygonOffsets())
+ {
+ anInterObj->PolygonOffsets(aMode, aFactor, aUnits);
+ std::cout << "Current polygon offset parameters for " << argv[1] << ":" << std::endl;
+ std::cout << "\tMode: " << aMode << std::endl;
+ std::cout << "\tFactor: " << aFactor << std::endl;
+ std::cout << "\tUnits: " << aUnits << std::endl;
+ return 0;
+ }
+ else
+ {
+ std::cout << "Specific polygon offset parameters are not set for " << argv[1] << std::endl;
+ }
+ }
+
+ std::cout << "Default polygon offset parameters:" << std::endl;
+ aContext->DefaultDrawer()->ShadingAspect()->Aspect()->PolygonOffsets(aMode, aFactor, aUnits);
+ std::cout << "\tMode: " << aMode << std::endl;
+ std::cout << "\tFactor: " << aFactor << std::endl;
+ std::cout << "\tUnits: " << aUnits << std::endl;
+
+ return 0;
+}
+
//=======================================================================
//function : ObjectsCommands
//purpose :
theCommands.Add("vobjzlayer",
"vobjzlayer : set/get object [layerid] - set or get z layer id for the interactive object",
__FILE__, VObjZLayer, group);
+
+ theCommands.Add("vpolygonoffset",
+ "vpolygonoffset : [object [mode factor units]] - sets/gets polygon offset parameters for an object, without arguments prints the default values",
+ __FILE__, VPolygonOffset, group);
}