PrsDim_Dimension

Hello, how to get dimensions visible?

TopoDS_Edge edge = TopoDS::Edge(shapes.at(0));
gp_Pln thePlane;
Handle(PrsDim_LengthDimension) lengthDimension = new PrsDim_LengthDimension(edge, thePlane);
lengthDimension->SetColor(Quantity_NOC_ANTIQUEWHITE3);
lengthDimension->SetDisplayUnits("units");
OccViewManager::instance()->myContext()->Display(lengthDimension, false);

no error but also nothing visible.

Thanks!

Daniel Duesentrieb's picture

Never mind, got it going

TopoDS_Shape selShape = shapes.at(0);
const TopoDS_Edge& edge = TopoDS::Edge (selShape);

OccViewManager::instance()->myContext()->ClearSelected (Standard_False);
TopoDS_Vertex vertex1, vertex2;
TopExp::Vertices (TopoDS::Edge (edge), vertex1, vertex2);

gp_Pnt p1 = BRep_Tool::Pnt (vertex1);
gp_Pnt p2 = BRep_Tool::Pnt (vertex2);
gp_Pnt p3 (p2.X() + 50, p2.Y() + 50, p2.Z() + 50);

GC_MakePlane aMkPlane (p1,p2,p3);
Handle(Geom_Plane) plane = aMkPlane.Value();
Handle(PrsDim_LengthDimension) lengthDimension = new PrsDim_LengthDimension(TopoDS::Edge (edge), plane->Pln());
Handle(Prs3d_DimensionAspect) dimensionAspect = new Prs3d_DimensionAspect();
dimensionAspect->MakeArrows3d (Standard_False);
dimensionAspect->MakeText3d (true);
dimensionAspect->TextAspect()->SetHeight (48);
dimensionAspect->MakeTextShaded (true);
dimensionAspect->SetCommonColor (Quantity_NOC_BLUE);
dimensionAspect->MakeUnitsDisplayed (true);

lengthDimension->SetDisplayUnits ("mm");
lengthDimension->SetDimensionAspect (dimensionAspect);
//lengthDimension->SetFlyout (aDimDlg->GetFlyout());

OccViewManager::instance()->myContext()->Display(lengthDimension, Standard_True);
OccViewManager::instance()->myContext()->Activate (AIS_Shape::SelectionMode (TopAbs_EDGE));