For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

About Dimension Sample

arlean's picture

the code in LengthParamsEdgePage.cpp :

void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn()
 if (!myAISContext->LocalContext()->MoreSelected())
    AfxMessageBox ( _T("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK);

  // Workaround for AIS_LocalContext::SelectedShape()
  TopoDS_Shape aSelShape = myAISContext->LocalContext()->SelectedShape();
//  TopoDS_Shape aSelShape = CDimensionDlg::SelectedShape();
  const TopoDS_Edge& anEdge = TopoDS::Edge (aSelShape);

  // myAISContext->ClearSelected();
  TopoDS_Vertex aFirstVertex, aSecondVertex;
  TopExp::Vertices (TopoDS::Edge (anEdge), aFirstVertex, aSecondVertex);

  gp_Pnt aP1 = BRep_Tool::Pnt (aFirstVertex);
  gp_Pnt aP2 = BRep_Tool::Pnt (aSecondVertex);
  gp_Pnt aP3 (aP2.X() + 10, aP2.Y() + 10, aP2.Z() + 10);

  GC_MakePlane aMkPlane (aP1,aP2,aP3);
  Handle(Geom_Plane) aPlane = aMkPlane.Value();

  CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner());

  Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (TopoDS::Edge (anEdge), aPlane->Pln());
  Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
  anAspect->MakeArrows3d (Standard_False);
  anAspect->MakeText3d (aDimDlg->GetTextType());
  anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight());
  anAspect->MakeTextShaded (aDimDlg->IsText3dShaded());
  anAspect->SetCommonColor (aDimDlg->GetDimensionColor());
  anAspect->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed());
  if (aDimDlg->IsUnitsDisplayed())
    aLenDim->SetDisplayUnits (aDimDlg->GetUnits());

  aLenDim->SetDimensionAspect (anAspect);
  aLenDim->SetFlyout (aDimDlg->GetFlyout());

  if (myAISContext->HasOpenedContext())
  myAISContext->Display (aLenDim); // error!!!

no display.


Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.