From 92a33041adf8916f345483dadc1f507a58e5ca8c Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 7 Nov 2013 08:59:47 +0000 Subject: [PATCH] Porting SALOME Geometry module to the new OCCT 6.7.0 beta version. --- src/EntityGUI/EntityGUI_3DSketcherDlg.cxx | 69 ++++++++++++++--------- src/MeasureGUI/MeasureGUI_AngleDlg.cxx | 29 +++++----- src/MeasureGUI/MeasureGUI_DistanceDlg.cxx | 26 +++++---- 3 files changed, 68 insertions(+), 56 deletions(-) diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx index c0ad5d1bb..343ee0939 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -65,9 +65,8 @@ #include #include #include -#include #include -#include +#include #if OCC_VERSION_LARGE > 0x06050300 #include #include @@ -1652,9 +1651,6 @@ Handle(AIS_LengthDimension) EntityGUI_3DSketcherDlg::createAISLengthDimension(do gp_Pnt P2, gp_Dir theNormal) { - // Convert length to string - std::string aLength_str = doubleToString(theLength); - // Plane construction gce_MakePln gce_MP(P1, theNormal); Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); @@ -1662,20 +1658,21 @@ Handle(AIS_LengthDimension) EntityGUI_3DSketcherDlg::createAISLengthDimension(do TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(P1); TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(P2); - Handle(AIS_LengthDimension) anIO = - new AIS_LengthDimension(aVert1, - aVert2, - aPlane, - theLength, - TCollection_ExtendedString(aLength_str.c_str())); - anIO->SetArrowSize(theLength/20); + Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension( aVert1, aVert2, aPlane->Pln() ); + + anIO->SetCustomValue( theLength ); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - Handle(Prs3d_LengthAspect) asp = new Prs3d_LengthAspect(); - asp->LineAspect()->SetWidth(w); - anIO->Attributes()->SetLengthAspect(asp); - + int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); + + Handle(Prs3d_DimensionAspect) aDimensionStyle = new Prs3d_DimensionAspect; + + aDimensionStyle->ArrowAspect()->SetLength( theLength / 20.0 ); + aDimensionStyle->LineAspect()->SetWidth( w ); + aDimensionStyle->SetHorizontalTextAlignment( Prs3d_HTA_Center ); + anIO->SetFlyout( 0.0 ); + anIO->SetDimensionAspect( aDimensionStyle ); + return anIO; } @@ -1711,18 +1708,34 @@ Handle(AIS_AngleDimension) EntityGUI_3DSketcherDlg::createAISAngleDimension(doub TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(V0, V1); TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(V0, V2); - Handle(AIS_AngleDimension) anIO = - new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle * M_PI / 180., - TCollection_ExtendedString(Angle_str.c_str())); - - anIO->SetArrowSize((theAngle * M_PI / 180) * (aLength/20)); - + //Handle(AIS_AngleDimension) anIO = + // new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle * M_PI / 180., + // TCollection_ExtendedString(Angle_str.c_str())); + // + //anIO->SetArrowSize((theAngle * M_PI / 180) * (aLength/20)); + // + //SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + //int w = resMgr->integerValue("Geometry", "measures_line_width", 1); + //Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect(); + //asp->LineAspect()->SetWidth(w); + //anIO->Attributes()->SetAngleAspect(asp); + + // todo : port + + Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension( anEdge1, anEdge2, aPlane->Pln() ); + + anIO->SetCustomValue( theAngle ); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect(); - asp->LineAspect()->SetWidth(w); - anIO->Attributes()->SetAngleAspect(asp); - + int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); + + Handle(Prs3d_DimensionAspect) aDimensionStyle = new Prs3d_DimensionAspect; + + aDimensionStyle->ArrowAspect()->SetLength( (theAngle * M_PI / 180.0) * (aLength / 20.0) ); + aDimensionStyle->LineAspect()->SetWidth( w ); + + anIO->SetDimensionAspect( aDimensionStyle ); + return anIO; } diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx index eb026c9c4..574b53c19 100644 --- a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx @@ -56,8 +56,7 @@ #include #include #include -#include -#include +#include // QT Includes #include @@ -348,13 +347,10 @@ SALOME_Prs* MeasureGUI_AngleDlg::buildPrs() gce_MakePln gce_MP(aP11, aP12, aP3); Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); - // Build the angle dimension presentation - QString aLabel; - aLabel.sprintf("%.1f", anAngle); + Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension( anEdge1, anEdge2, aPlane->Pln() ); + + Handle(Prs3d_DimensionAspect) aDimensionStyle = new Prs3d_DimensionAspect; - Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension - (anEdge1, anEdge2, aPlane, anAngle * M_PI / 180., - TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().data())); Handle(Geom_Line) geom_lin1,geom_lin2; gp_Pnt ptat11,ptat12,ptat21,ptat22; Standard_Boolean isInfinite1,isInfinite2; @@ -373,19 +369,20 @@ SALOME_Prs* MeasureGUI_AngleDlg::buildPrs() isInfinite1, isInfinite2, aPlane)) { - Standard_Real arrSize1 = anIO->ArrowSize(); - Standard_Real arrSize2 = anIO->ArrowSize(); + Standard_Real arrSize1 = aDimensionStyle->ArrowAspect()->Length(); + Standard_Real arrSize2 = aDimensionStyle->ArrowAspect()->Length(); if (!isInfinite1) arrSize1 = ptat11.Distance(ptat12)/10.; if (!isInfinite2) arrSize2 = ptat21.Distance(ptat22)/10.; - Standard_Real arrowSize = Max(arrSize1,arrSize2); - anIO->SetArrowSize(arrowSize); + aDimensionStyle->ArrowAspect()->SetLength( Max(arrSize1, arrSize2) ); } SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect(); - asp->LineAspect()->SetWidth(w); - anIO->Attributes()->SetAngleAspect(asp); + int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); + + aDimensionStyle->LineAspect()->SetWidth( w ); + aDimensionStyle->SetHorizontalTextAlignment( Prs3d_HTA_Center ); + + anIO->SetDimensionAspect( aDimensionStyle ); SOCC_Prs* aPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx index c8c206cd9..af2085805 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -362,8 +361,8 @@ SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(aPnt1); TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(aPnt2); - QString aLabel; - aLabel.sprintf("%.1f", aDist); + //QString aLabel; + //aLabel.sprintf("%.1f", aDist); gp_Pnt aPnt3 ((aPnt1.X() + aPnt2.X()) / 2, (aPnt1.Y() + aPnt2.Y()) / 2, @@ -380,16 +379,19 @@ SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() gce_MakePln gce_MP (aPnt1, aPnt2, aPnt3); Handle(Geom_Plane) P = new Geom_Plane (gce_MP.Value()); - Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension - (aVert1, aVert2, P, aDist, - TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().constData())); - anIO->SetArrowSize(aDist/20); - + Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension( aVert1, aVert2, P->Pln() ); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - Handle(Prs3d_LengthAspect) asp = new Prs3d_LengthAspect(); - asp->LineAspect()->SetWidth(w); - anIO->Attributes()->SetLengthAspect(asp); + int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); + + Handle(Prs3d_DimensionAspect) aDimensionStyle = new Prs3d_DimensionAspect; + + aDimensionStyle->ArrowAspect()->SetLength( aDist / 20.0 ); + aDimensionStyle->LineAspect()->SetWidth( w ); + aDimensionStyle->SetHorizontalTextAlignment( Prs3d_HTA_Center ); + + anIO->SetFlyout( 0.0 ); + anIO->SetDimensionAspect( aDimensionStyle ); SOCC_Prs* aPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); -- 2.39.2