From: aba Date: Thu, 31 Oct 2013 12:49:38 +0000 (+0400) Subject: 0024133: Development of improvement of dimensions implementation; new length, radius... X-Git-Tag: V6_7_0_beta~25 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=a6eb515f9d6430bce09c4dcc0f088bcfea6bb6c6 0024133: Development of improvement of dimensions implementation; new length, radius,diameter and angle dimensions. Some corrections; test cases were added; coding standards in MFC samples & presentations Request stencil buffer for Linux. correct test cases; correct compilation errors compilation warnings (gcc/Linux) --- diff --git a/samples/mfc/standard/04_Viewer3d/res/AIS_TB.bmp b/samples/mfc/standard/04_Viewer3d/res/AIS_TB.bmp index ccf7af13cb..d99e3aeafd 100755 Binary files a/samples/mfc/standard/04_Viewer3d/res/AIS_TB.bmp and b/samples/mfc/standard/04_Viewer3d/res/AIS_TB.bmp differ diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3d.rc b/samples/mfc/standard/04_Viewer3d/src/Viewer3d.rc index f8012b0c7b..94113f4959 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3d.rc +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3d.rc @@ -303,6 +303,7 @@ BEGIN BUTTON ID_OBJECT_DISPLAYALL SEPARATOR BUTTON ID_OBJECT_REMOVE + BUTTON ID_OBJECT_DIM END @@ -371,10 +372,6 @@ BEGIN BEGIN MENUITEM "Background Color...", ID_Modify_ChangeBackground END - POPUP "User cylinder" - BEGIN - MENUITEM "Change face color", ID_USERCYLINDER_CHANGEFACECOLOR - END POPUP "Object(s)" BEGIN MENUITEM "Erase", ID_OBJECT_ERASE @@ -408,6 +405,10 @@ BEGIN END MENUITEM "Transparency...", ID_OBJECT_TRANSPARENCY END + POPUP "User cylinder" + BEGIN + MENUITEM "Change face color", ID_USERCYLINDER_CHANGEFACECOLOR + END END @@ -514,6 +515,12 @@ BEGIN ID_TEXTURE_ON "Run texture example\nRun texture example" END +STRINGTABLE +BEGIN + ID_OBJECT_DIMENSIONS "Add dimensions" + ID_LOCALCONTEXT_ADDDIMENSION "Add new dimension for selected objetcs" +END + #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp index afb33e7e2c..a535dbd931 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp @@ -77,6 +77,7 @@ END_MESSAGE_MAP() // CViewer3dDoc construction/destruction CViewer3dDoc::CViewer3dDoc() +:OCC_3dDoc() { myCylinder.Nullify(); mySphere.Nullify(); @@ -86,21 +87,9 @@ CViewer3dDoc::CViewer3dDoc() myOverlappedBox.Nullify(); myOffsetDlg = NULL; myStaticTrihedronAxisIsDisplayed = FALSE; - myState = -1; isTextureSampleStarted = FALSE; -/* - // TODO: add one-time construction code here - Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = - ((CViewer3dApp*)AfxGetApp())->GetGraphicDevice(); - - myViewer = new V3d_Viewer(theGraphicDevice,(short *) "Visu3D"); - myViewer->SetDefaultLights(); - myViewer->SetLightOn(); -*/ - -// myViewer->SetDefaultBackgroundColor(Quantity_TOC_RGB, 0.,0.,0.); myPresentation = OCCDemo_Presentation::Current; myPresentation->SetDocument(this); @@ -702,39 +691,22 @@ void CViewer3dDoc::OnUpdateOptionsTrihedronStaticTrihedron(CCmdUI* pCmdUI) } -void CViewer3dDoc::Popup( const Standard_Integer x, - const Standard_Integer y , - const Handle(V3d_View)& aView ) +void CViewer3dDoc::Popup (const Standard_Integer x, + const Standard_Integer y , + const Handle(V3d_View)& aView) { - Standard_Integer PopupMenuNumber=0; - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) { - if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder))) - return; - else - PopupMenuNumber = 1; - } - - CMenu menu; - VERIFY(menu.LoadMenu(IDR_Popup3D)); - CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber); - - ASSERT(pPopup != NULL); - if (PopupMenuNumber == 1) // more than 1 object. + myPopupMenuNumber=0; + // Specified check for context menu number to call + myAISContext->InitCurrent(); + if (myAISContext->MoreCurrent()) { - bool OneOrMoreInShading = false; - for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) - if (myAISContext->IsDisplayed(myAISContext->Current(),1)) OneOrMoreInShading=true; - if(!OneOrMoreInShading) - pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); - } - - POINT winCoord = { x , y }; - Handle(WNT_Window) aWNTWindow= - Handle(WNT_Window)::DownCast(aView->Window()); - ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord); - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , - AfxGetMainWnd()); + if (myAISContext->Current()->IsKind(STANDARD_TYPE(User_Cylinder))) + { + myPopupMenuNumber = 2; + //return; + } + } + OCC_3dBaseDoc::Popup(x,y, aView); } //Set faces selection mode diff --git a/samples/mfc/standard/05_ImportExport/res/ImportExport.aps b/samples/mfc/standard/05_ImportExport/res/ImportExport.aps index be2896c690..56f8a48400 100755 Binary files a/samples/mfc/standard/05_ImportExport/res/ImportExport.aps and b/samples/mfc/standard/05_ImportExport/res/ImportExport.aps differ diff --git a/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp b/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp new file mode 100644 index 0000000000..62f6c30ec9 --- /dev/null +++ b/samples/mfc/standard/Common/AngleParamsVerticesPage.cpp @@ -0,0 +1,163 @@ +// AngleParamsVerticesPage.cpp : implementation file +// + +#include "stdafx.h" +#include "AngleParamsVerticesPage.h" +#include "DimensionDlg.h" + +#include +#include +#include +#include +#include +#include +#include + +// CAngleParamsVerticesPage dialog + +IMPLEMENT_DYNAMIC(CAngleParamsVerticesPage, CDialog) + +//======================================================================= +//function : CAngleParamsVerticesPage +//purpose : +//======================================================================= + +CAngleParamsVerticesPage::CAngleParamsVerticesPage (Handle(AIS_InteractiveContext) theAISContext, + CWnd* pParent /*=NULL*/) +: CDialog(CAngleParamsVerticesPage::IDD, pParent) +{ + myAISContext = theAISContext; +} + +//======================================================================= +//function : ~CAngleParamsVerticesPage +//purpose : +//======================================================================= + +CAngleParamsVerticesPage::~CAngleParamsVerticesPage() +{ +} + +//======================================================================= +//function : DoDataExchange +//purpose : +//======================================================================= + +void CAngleParamsVerticesPage::DoDataExchange (CDataExchange* pDX) +{ + CDialog::DoDataExchange (pDX); +} + + +BEGIN_MESSAGE_MAP(CAngleParamsVerticesPage, CDialog) + ON_BN_CLICKED(IDC_BUTTON1, &CAngleParamsVerticesPage::OnBnClickedVertex1Btn) + ON_BN_CLICKED(IDC_BUTTON3, &CAngleParamsVerticesPage::OnBnClickedVertex2Btn) + ON_BN_CLICKED(IDC_BUTTON4, &CAngleParamsVerticesPage::OnBnClickedVertex3Btn) +END_MESSAGE_MAP() + + +//======================================================================= +//function : OnBnClickedVertex1Btn +//purpose : +//======================================================================= + +void CAngleParamsVerticesPage::OnBnClickedVertex1Btn() +{ + // Open local context and choose the vertex for angle dimensions + if (!myAISContext->HasOpenedContext()) + { + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode(TopAbs_VERTEX); + AfxMessageBox (_T ("Local context was not opened. Choose the edge and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + // Now it's ok, local context is opened and edge selection mode is activated + // Check if some vertex is selected + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T ("Choose the vertex and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + myFirstVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); +} + +//======================================================================= +//function : OnBnClickedVertex2Btn +//purpose : +//======================================================================= + +void CAngleParamsVerticesPage::OnBnClickedVertex2Btn() +{ + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox ( _T("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + mySecondVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + + myAISContext->LocalContext()->ClearSelected(); +} + +//======================================================================= +//function : OnBnClickedVertex3Btn +//purpose : +//======================================================================= + +void CAngleParamsVerticesPage::OnBnClickedVertex3Btn() +{ + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + myThirdVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); + + //Build dimension here + TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge (myFirstVertex, mySecondVertex); + TopoDS_Edge anEdge23 = BRepBuilderAPI_MakeEdge (mySecondVertex, myThirdVertex); + + CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); + + gp_Pnt aP1 = BRep_Tool::Pnt (myFirstVertex), + aP2 = BRep_Tool::Pnt (mySecondVertex), + aP3 = BRep_Tool::Pnt (myThirdVertex); + GC_MakePlane aPlaneBuilder (aP1,aP2,aP3); + + Handle(Geom_Plane) aPlane = aPlaneBuilder.Value(); + Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (aP1,aP2,aP3); + 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()); + anAngleDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (anAngleDim->IsUnitsDisplayed()) + { + anAngleDim->SetDisplayUnits (aDimDlg->GetUnits()); + if ((anAngleDim->DisplayUnits().IsEqual (TCollection_AsciiString ("deg")))) + { + anAngleDim->MakeUnitsDisplayed (Standard_False); + } + else + { + anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No); + } + } + anAngleDim->SetDimensionAspect (anAspect); + myAISContext->CloseAllContexts(); + myAISContext->Display (anAngleDim); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_VERTEX); +} diff --git a/samples/mfc/standard/Common/AngleParamsVerticesPage.h b/samples/mfc/standard/Common/AngleParamsVerticesPage.h new file mode 100644 index 0000000000..88edc13f6b --- /dev/null +++ b/samples/mfc/standard/Common/AngleParamsVerticesPage.h @@ -0,0 +1,31 @@ +#pragma once + +#include "res\OCC_Resource.h" + +// CAngleParamsVerticesPage dialog + +class CAngleParamsVerticesPage : public CDialog +{ + DECLARE_DYNAMIC(CAngleParamsVerticesPage) +private: + Handle(AIS_InteractiveContext) myAISContext; + TopoDS_Vertex myFirstVertex; + TopoDS_Vertex mySecondVertex; + TopoDS_Vertex myThirdVertex; +public: + CAngleParamsVerticesPage(Handle (AIS_InteractiveContext) theAISContext, + CWnd* pParent = NULL); // standard constructor + virtual ~CAngleParamsVerticesPage(); + +// Dialog Data + enum { IDD = IDD_AngleParamsVerticesPage }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedVertex1Btn(); + afx_msg void OnBnClickedVertex2Btn(); + afx_msg void OnBnClickedVertex3Btn(); +}; diff --git a/samples/mfc/standard/Common/DimensionDlg.cpp b/samples/mfc/standard/Common/DimensionDlg.cpp new file mode 100644 index 0000000000..1ae8cf7645 --- /dev/null +++ b/samples/mfc/standard/Common/DimensionDlg.cpp @@ -0,0 +1,686 @@ +// CDimensionDlg.cpp : implementation file +// + +#include "stdafx.h" + +#include "DimensionDlg.h" +#include "LengthParamsEdgePage.h" +#include "LengthParamsVerticesPage.h" +#include "LengthParamsEdgesPage.h" +#include "AngleParamsVerticesPage.h" +#include "RadiusParamsPage.h" +#include +#include +#include +#include +#include +#include + +BEGIN_MESSAGE_MAP(CDimensionDlg, CDialog) + ON_BN_CLICKED(IDOK, &CDimensionDlg::OnBnClickedOk) + ON_BN_CLICKED(IDC_DimLength, &CDimensionDlg::OnBnClickedDimLength) + ON_BN_CLICKED(IDC_DimAngle, &CDimensionDlg::OnBnClickedDimAngle) + ON_BN_CLICKED(IDC_DimRadius, &CDimensionDlg::OnBnClickedDimRadius) + ON_NOTIFY(TCN_SELCHANGE, IDC_LengthTab, &CDimensionDlg::OnTcnSelChangeLengthTab) + ON_NOTIFY(TCN_SELCHANGING, IDC_LengthTab, &CDimensionDlg::OnTcnSelChangingLengthTab) + ON_WM_DESTROY() + ON_NOTIFY(TCN_SELCHANGE, IDC_AngleTab, &CDimensionDlg::OnTcnSelChangeAngleTab) + ON_NOTIFY(TCN_SELCHANGING, IDC_AngleTab, &CDimensionDlg::OnTcnSelChangingAngleTab) + ON_BN_CLICKED(IDC_DimDiameter, &CDimensionDlg::OnBnClickedDimDiameter) + ON_BN_CLICKED(IDC_2DText, &CDimensionDlg::OnBnClicked2dText) + ON_BN_CLICKED(IDC_3DText, &CDimensionDlg::OnBnClicked3dText) + ON_BN_CLICKED(IDC_DimensionColor, &CDimensionDlg::OnBnClickedDimensionColor) +END_MESSAGE_MAP() + +//======================================================================= +//function : CDimensionDlg +//purpose : +//======================================================================= + +CDimensionDlg::CDimensionDlg(CWnd* pParent /*=NULL*/) + : CDialog(CDimensionDlg::IDD, pParent), + mySelectedDimType(0), + myFontSize (10), + myDimensionColor (Quantity_NOC_LAWNGREEN) +{ +} + +//======================================================================= +//function : CDimensionDlg +//purpose : +//======================================================================= + +CDimensionDlg::CDimensionDlg (Handle(AIS_InteractiveContext) &theAISContext, + CWnd* pParent) +: CDialog(CDimensionDlg::IDD, pParent), + mySelectedDimType(0), + myFontSize (10), + myDimensionColor (Quantity_NOC_LAWNGREEN) +{ + myAISContext = theAISContext; +} + +//======================================================================= +//function : ~CDimensionDlg +//purpose : +//======================================================================= + +CDimensionDlg::~CDimensionDlg() +{ +} + +//======================================================================= +//function : SetContext +//purpose : +//======================================================================= + +void CDimensionDlg::SetContext (const Handle(AIS_InteractiveContext) theContext) +{ + myAISContext = theContext; +} + +//======================================================================= +//function : OnInitDialog +//purpose : Initialization of dialog fields and parameters +//======================================================================= + +BOOL CDimensionDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + myLengthParams = (CTabCtrl*) GetDlgItem (IDC_LengthTab); + myAngleParams = (CTabCtrl*) GetDlgItem (IDC_AngleTab); + myRadiusParams = (CTabCtrl*) GetDlgItem (IDC_RadiusTab); + myDiameterParams = (CTabCtrl*) GetDlgItem (IDC_DiameterTab); + + CreateLengthParamsTab(); + CreateAngleParamsTab(); + CreateRadiusParamsTab(); + CreateDiameterParamsTab( ); + + myLengthParams->ShowWindow (SW_SHOW); + myAngleParams->ShowWindow (SW_HIDE); + myRadiusParams->ShowWindow (SW_HIDE); + myDiameterParams->ShowWindow (SW_HIDE); + + // Setting default values + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetRange (-30,30,true); + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetPos (15); + UpdateUnitsListForLength (); + ((CComboBox*)GetDlgItem (IDC_DisplayUnits))->SetCurSel (1); + CheckRadioButton (IDC_2DText, IDC_3DText, IDC_2DText); + SetTextModeControlsVisible (false); + CComboBox* aCombo =(CComboBox* )GetDlgItem (IDC_FontSize); + aCombo->SelectString (0,"10"); + + UpdateData (FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +//======================================================================= +//function : DoDataExchange +//purpose : Updating of dialog data if it's needed +//======================================================================= + +void CDimensionDlg::DoDataExchange (CDataExchange* pDX) +{ + CDialog::DoDataExchange (pDX); + + DDX_Radio (pDX, IDC_DimLength, mySelectedDimType); +} + +//======================================================================= +//function : OnBnClickedOk +//purpose : Reset all local contexts and close the dimension dialog +//======================================================================= + +void CDimensionDlg::OnBnClickedOk() +{ + if (myAISContext->HasOpenedContext()) + { + myAISContext->CloseAllContexts(); + } + + OnOK(); +} + +//======================================================================= +//function : GetFlyout +//purpose : Only for length dimensions! Gets flyout value +//======================================================================= + +const Standard_Real CDimensionDlg::GetFlyout() const +{ + return ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->GetPos(); +} + +//======================================================================= +//function : CreateLengthParamsTab +//purpose : Fill tab control for length dimensions +//======================================================================= + +void CDimensionDlg::CreateLengthParamsTab() +{ + TC_ITEM aTabItem; + aTabItem.mask = TCIF_TEXT; + aTabItem.pszText = "Edge"; + myLengthParams->InsertItem (0, &aTabItem); + aTabItem.pszText = "Vertices"; + myLengthParams->InsertItem (1, &aTabItem); + aTabItem.pszText = "Parallel edges"; + myLengthParams->InsertItem (2, &aTabItem); + + CLengthParamsEdgePage *aPage1 = new CLengthParamsEdgePage (myAISContext); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage1; + myLengthParams->SetItem (0, &aTabItem); + VERIFY (aPage1->Create (CLengthParamsEdgePage::IDD,myLengthParams)); + aPage1->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); + aPage1->ShowWindow (SW_SHOW); + + CLengthParamsVerticesPage *aPage2 = new CLengthParamsVerticesPage (myAISContext); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage2; + myLengthParams->SetItem (1, &aTabItem); + VERIFY (aPage2->Create (CLengthParamsVerticesPage::IDD,myLengthParams)); + aPage2->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); + + CLengthParamsEdgesPage *aPage3 = new CLengthParamsEdgesPage (myAISContext); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage3; + myLengthParams->SetItem (2, &aTabItem); + VERIFY (aPage3->Create (CLengthParamsEdgesPage::IDD,myLengthParams)); + aPage3->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); +} + +//======================================================================= +//function : CreateAngleParamsTab +//purpose : Fill tab control for angle dimensions +//======================================================================= + +void CDimensionDlg::CreateAngleParamsTab() +{ + TC_ITEM aTabItem; + aTabItem.mask = TCIF_TEXT; + aTabItem.pszText = "Two edges"; + myAngleParams->InsertItem (0, &aTabItem); + aTabItem.pszText = "Three vertices"; + myAngleParams->InsertItem (1, &aTabItem); + + CLengthParamsEdgesPage *aPage1 = new CLengthParamsEdgesPage (myAISContext, true); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage1; + myAngleParams->SetItem (0, &aTabItem); + VERIFY (aPage1->Create (CLengthParamsEdgesPage::IDD,myAngleParams)); + aPage1->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); + aPage1->ShowWindow (SW_SHOW); + + CAngleParamsVerticesPage *aPage2 = new CAngleParamsVerticesPage (myAISContext); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage2; + myAngleParams->SetItem (1, &aTabItem); + VERIFY (aPage2->Create (CAngleParamsVerticesPage::IDD,myAngleParams)); + aPage2->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); +} + +//======================================================================= +//function : CreateRadiusParamsTab +//purpose : Fill tab control for radius dimensions +//======================================================================= + +void CDimensionDlg::CreateRadiusParamsTab() +{ + TC_ITEM aTabItem; + aTabItem.mask = TCIF_TEXT; + aTabItem.pszText = "Circle or arc"; + myRadiusParams->InsertItem (0, &aTabItem); + CRadiusParamsPage *aPage1 = new CRadiusParamsPage (myAISContext); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage1; + myRadiusParams->SetItem (0, &aTabItem); + VERIFY (aPage1->Create (CRadiusParamsPage::IDD,myRadiusParams)); + aPage1->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); + aPage1->ShowWindow (SW_SHOW); +} + +//======================================================================= +//function : CreateDiameterParamsTab +//purpose : Fill tab control for diameter dimensions +//======================================================================= + +void CDimensionDlg::CreateDiameterParamsTab() +{ + TC_ITEM aTabItem; + aTabItem.mask = TCIF_TEXT; + aTabItem.pszText = "Circle or arc"; + myDiameterParams->InsertItem (0, &aTabItem); + CRadiusParamsPage *aPage1 = new CRadiusParamsPage (myAISContext,Standard_True); + aTabItem.mask = TCIF_PARAM; + aTabItem.lParam = (LPARAM)aPage1; + myRadiusParams->SetItem (0, &aTabItem); + VERIFY (aPage1->Create (CRadiusParamsPage::IDD,myDiameterParams)); + aPage1->SetWindowPos (NULL,10,30,0,0,SWP_NOSIZE | SWP_NOZORDER); + aPage1->ShowWindow (SW_SHOW); +} + +//======================================================================= +//function : UpdateStandardModeForAngle +//purpose : +//======================================================================= + +void CDimensionDlg::UpdateStandardModeForAngle() +{ + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetCurSel(); + myAISContext->CloseAllContexts(); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (aTabNum == 1 ? TopAbs_VERTEX : TopAbs_EDGE); +} + +//======================================================================= +//function : UpdateStandardModeForLength +//purpose : +//======================================================================= + +void CDimensionDlg::UpdateStandardModeForLength() +{ + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetCurSel(); + myAISContext->CloseAllContexts(); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (aTabNum == 1 ? TopAbs_VERTEX : TopAbs_EDGE); +} + +//======================================================================= +//function : UpdateStandardModeForLength +//purpose : +//======================================================================= + +void CDimensionDlg::UpdateStandardMode() +{ + int aCurIndex = GetCheckedRadioButton (IDC_DimLength, IDC_DimDiameter); + switch (aCurIndex) + { + case IDC_DimLength: + UpdateStandardModeForLength(); + break; + case IDC_DimAngle: + UpdateStandardModeForAngle(); + break; + case IDC_DimRadius: + case IDC_DimDiameter: + { + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); + } + break; + } +} + +//======================================================================= +//function : OnBnClickedDimLength +//purpose : it is called when radio button is chosen +//======================================================================= + +void CDimensionDlg::OnBnClickedDimLength() +{ + // Update parameters + UpdateStandardModeForLength (); + (CTabCtrl*) GetDlgItem (IDC_LengthTab)->ShowWindow (SW_SHOW); + (CTabCtrl*) GetDlgItem (IDC_AngleTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_RadiusTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_DiameterTab)->ShowWindow (SW_HIDE); + + UpdateUnitsListForLength (); + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetPos (15); +} + +//======================================================================= +//function : OnBnClickedDimAngle +//purpose : it is called when radio button is chosen +//======================================================================= + +void CDimensionDlg::OnBnClickedDimAngle() +{ + // Update parameters + UpdateStandardModeForAngle(); + (CTabCtrl*) GetDlgItem (IDC_LengthTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_AngleTab)->ShowWindow (SW_SHOW); + (CTabCtrl*) GetDlgItem (IDC_RadiusTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_DiameterTab)->ShowWindow (SW_HIDE); + + UpdateUnitsListForAngle(); + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetPos (15); +} + +//======================================================================= +//function : OnBnClickedDimDiameter +//purpose : it is called when radio button is chosen +//======================================================================= + +void CDimensionDlg::OnBnClickedDimDiameter() +{ + // Update parameters + myAISContext->CloseAllContexts(); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); + + (CTabCtrl*) GetDlgItem (IDC_LengthTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_AngleTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_RadiusTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_DiameterTab)->ShowWindow (SW_SHOW); + + UpdateUnitsListForLength(); + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetPos (0); +} + +//======================================================================= +//function : OnBnClickedDimRadius +//purpose : it is called when radio button is chosen +//======================================================================= + +void CDimensionDlg::OnBnClickedDimRadius() +{ + // Update parameters + myAISContext->CloseAllContexts(); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); + (CTabCtrl*) GetDlgItem (IDC_LengthTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_AngleTab)->ShowWindow (SW_HIDE); + (CTabCtrl*) GetDlgItem (IDC_RadiusTab)->ShowWindow (SW_SHOW); + (CTabCtrl*) GetDlgItem (IDC_DiameterTab)->ShowWindow (SW_HIDE); + + UpdateUnitsListForLength(); + ((CSliderCtrl*)GetDlgItem(IDC_Flyout))->SetPos (0); +} + +//======================================================================= +//function : OnTcnSelChangeLengthTab +//purpose : it is called when in Length tab control current tab was changed +//======================================================================= + +void CDimensionDlg::OnTcnSelChangeLengthTab (NMHDR *pNMHDR, LRESULT *pResult) +{ + // Show this chosen tab page + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetCurSel(); + TC_ITEM anItem; + anItem.mask = TCIF_PARAM; + ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetItem (aTabNum, &anItem); + ASSERT(anItem.lParam); + CWnd *aWnd = (CWnd*)anItem.lParam; + aWnd->ShowWindow (SW_SHOW); + UpdateStandardModeForLength(); + *pResult = 0; +} + +//======================================================================= +//function : OnTcnSelChangingLengthTab +//purpose : it is called when in Length tab control current tab +// is changing +// It is used to hide the current tab here to prevent collisions. +//======================================================================= + +void CDimensionDlg::OnTcnSelChangingLengthTab (NMHDR *pNMHDR, LRESULT *pResult) +{ + // Hide current tab page + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetCurSel(); + TC_ITEM anItem; + anItem.mask = TCIF_PARAM; + ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetItem (aTabNum, &anItem); + ASSERT (anItem.lParam); + CWnd *aWnd = (CWnd*)anItem.lParam; + aWnd->ShowWindow (SW_HIDE); + *pResult = 0; +} + +//======================================================================= +//function : OnTcnSelChangeAngleTab +//purpose : it is called when in Angle tab control current tab was changed +//======================================================================= + +void CDimensionDlg::OnTcnSelChangeAngleTab (NMHDR *pNMHDR, LRESULT *pResult) +{ + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetCurSel(); + TC_ITEM anItem; + anItem.mask = TCIF_PARAM; + ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetItem (aTabNum, &anItem); + ASSERT (anItem.lParam); + CWnd *aWnd = (CWnd*)anItem.lParam; + aWnd->ShowWindow (SW_SHOW); + UpdateStandardModeForAngle(); + *pResult = 0; +} + +//======================================================================= +//function : OnTcnSelChangingAngleTab +//purpose : it is called when in Angle tab control current tab +// is changing +// It is used to hide the current tab here to prevent collisions. +//======================================================================= + +void CDimensionDlg::OnTcnSelChangingAngleTab (NMHDR *pNMHDR, LRESULT *pResult) +{ + int aTabNum = ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetCurSel(); + TC_ITEM anItem; + anItem.mask = TCIF_PARAM; + ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetItem (aTabNum, &anItem); + ASSERT (anItem.lParam); + CWnd *aWnd = (CWnd*)anItem.lParam; + aWnd->ShowWindow (SW_HIDE); + *pResult = 0; +} + +//======================================================================= +//function : DeactivateAllStandardModes +//purpose : +//======================================================================= + +void CDimensionDlg::DeactivateAllStandardModes() +{ + if (myAISContext->HasOpenedContext()) + { + myAISContext->CloseAllContexts(); + for (TColStd_ListIteratorOfListOfInteger anIt (myAISContext->LocalContext()->StandardModes()); + anIt.More(); + anIt.Next()) + { + myAISContext->LocalContext()->DeactivateStandardMode ((TopAbs_ShapeEnum)anIt.Value()); + } + } +} + +//======================================================================= +//function : OnDestroy +//purpose : +//======================================================================= + +void CDimensionDlg::OnDestroy() +{ + if (myAISContext->HasOpenedContext()) + { + myAISContext->CloseAllContexts(); + } + // Destroy length tab + CWnd *aWnd; + TC_ITEM anItem; + anItem.mask = TCIF_PARAM; + for (int i = 2; i >= 0; --i) + { + ((CTabCtrl*) GetDlgItem (IDC_LengthTab))->GetItem (i, &anItem); + ASSERT (anItem.lParam); + aWnd = (CWnd*) anItem.lParam; + aWnd->DestroyWindow(); + delete aWnd; + } + // Destroy angle tab + for (int i = 1; i >= 0; --i) + { + ((CTabCtrl*) GetDlgItem (IDC_AngleTab))->GetItem (i, &anItem); + ASSERT(anItem.lParam); + aWnd = (CWnd*) anItem.lParam; + aWnd->DestroyWindow(); + delete aWnd; + } + + CDialog::OnDestroy(); +} + +//======================================================================= +//function : GetTextType +//purpose : Returns true if 3d text is to be used +// and false in the case of 2d text. +//======================================================================= + +const Standard_Boolean CDimensionDlg::GetTextType() const +{ + CButton* a3DButton = (CButton*)GetDlgItem (IDC_3DText); + return a3DButton->GetCheck(); +} + +//======================================================================= +//function : GetFontHeight +//purpose : Returns font height +//======================================================================= + +const Standard_Real CDimensionDlg::GetFontHeight() const +{ + CComboBox *aComboBox = (CComboBox*)GetDlgItem (IDC_FontSize); + CString aStr; + aComboBox->GetWindowTextA (aStr); + return (Standard_Real)atof (aStr); +} + +//======================================================================= +//function : IsText3dShaded +//purpose : Only for 3d text; returns true if shaded 3d text is to be used +//======================================================================= + +const Standard_Boolean CDimensionDlg::IsText3dShaded() const +{ + CComboBox *aComboBox = (CComboBox*)GetDlgItem (IDC_TextDisplayMode); + int aCurIndex = aComboBox->GetCurSel(); + return aCurIndex == 0 ? Standard_False : Standard_True; +} + +//======================================================================= +//function : SetTextModeControlsVisible +//purpose : for the dialog updating +//======================================================================= + +void CDimensionDlg::SetTextModeControlsVisible (bool isVisible) +{ + GetDlgItem (IDC_TextDisplayMode)->ShowWindow (isVisible ? SW_SHOW : SW_HIDE); + GetDlgItem (IDC_TextDisplayModeStatic)->ShowWindow (isVisible ? SW_SHOW : SW_HIDE); +} + +//======================================================================= +//function : OnBnClicked2dText +//purpose : for the dialog updating when 2d text radio button was chosen +//======================================================================= + +void CDimensionDlg::OnBnClicked2dText() +{ + SetTextModeControlsVisible (false); +} + +//======================================================================= +//function : OnBnClicked3dText +//purpose : for the dialog updating when 3d text radio button was chosen +//======================================================================= + +void CDimensionDlg::OnBnClicked3dText() +{ + SetTextModeControlsVisible (true); +} + +//======================================================================= +//function : UpdateUnitsListForLength +//purpose : for the dialog updating when 3d text radio button was chosen +//======================================================================= + +void CDimensionDlg::UpdateUnitsListForLength() +{ + CComboBox *aCombo = (CComboBox*)GetDlgItem (IDC_DisplayUnits); + aCombo->ResetContent(); + aCombo->AddString ("No"); + aCombo->AddString ("m"); + aCombo->AddString ("mm"); + aCombo->AddString ("in"); + aCombo->SetCurSel (1); +} + +//======================================================================= +//function : UpdateUnitsListForAngle +//purpose : for the dialog updating when 3d text radio button was chosen +//======================================================================= + +void CDimensionDlg::UpdateUnitsListForAngle() +{ + CComboBox *aCombo = (CComboBox*)GetDlgItem (IDC_DisplayUnits); + aCombo->ResetContent(); + aCombo->AddString ("No"); + aCombo->AddString ("deg"); + aCombo->AddString ("rad"); + aCombo->SetCurSel (1); +} + +//======================================================================= +//function : IsUnitsDisplayed +//purpose : returns true if the units is to be displayed +//======================================================================= + +const Standard_Boolean CDimensionDlg::IsUnitsDisplayed() const +{ + CString aStr; + GetDlgItem (IDC_DisplayUnits)->GetWindowTextA (aStr); + return !aStr.IsEmpty() && aStr != "No"; +} + +//======================================================================= +//function : GetUnits +//purpose : returns display quantity units for current dimension +//======================================================================= + +const TCollection_AsciiString CDimensionDlg::GetUnits() const +{ + if (!IsUnitsDisplayed()) + return TCollection_AsciiString(); + CString aStr; + GetDlgItem (IDC_DisplayUnits)->GetWindowTextA (aStr); + Standard_CString aChars = (LPCSTR)aStr; + return TCollection_AsciiString (aChars); +} + +//======================================================================= +//function : OnBnClickedDimensionColor +//purpose : returns display quantity units for current dimension +//======================================================================= + +void CDimensionDlg::OnBnClickedDimensionColor() +{ + Standard_Real aR; + Standard_Real aG; + Standard_Real aB; + myDimensionColor.Values (aR,aG,aB, Quantity_TOC_RGB); + COLORREF aColor = RGB (aR*255, aG*255, aB*255); + + CColorDialog aDlgColor (aColor); + if (aDlgColor.DoModal() == IDOK) + { + aColor = aDlgColor.GetColor(); + aR = GetRValue(aColor) / 255.0; + aG = GetGValue(aColor) / 255.0; + aB = GetBValue(aColor) / 255.0; + myDimensionColor = Quantity_Color (aR, aG, aB, Quantity_TOC_RGB); + } +} + +//======================================================================= +//function : GetDimensionColor +//purpose : returns current dimension color +//======================================================================= + +const Quantity_Color CDimensionDlg::GetDimensionColor() const +{ + return myDimensionColor; +} diff --git a/samples/mfc/standard/Common/DimensionDlg.h b/samples/mfc/standard/Common/DimensionDlg.h new file mode 100644 index 0000000000..5a5e4796bf --- /dev/null +++ b/samples/mfc/standard/Common/DimensionDlg.h @@ -0,0 +1,79 @@ +#pragma once + +// DimensionDlg dialog + +#include + +#include "res\OCC_Resource.h" +#include +#include +#include +#include + +class CDimensionDlg : public CDialog +{ +public: + /// Construction & termination + CDimensionDlg (CWnd* pParent = NULL); // standard constructor + CDimensionDlg (Handle(AIS_InteractiveContext) &theAISContext, + CWnd* pParent = NULL); + virtual ~CDimensionDlg(); + + // Methods for data operation + void SetContext (const Handle(AIS_InteractiveContext) theContext); + void SetTextModeControlsVisible (bool isVisible); + void UpdateUnitsListForLength(); + void UpdateUnitsListForAngle(); + void Empty(); + void DeactivateAllStandardModes(); + void UpdateStandardModeForAngle (); + void UpdateStandardModeForLength (); + void UpdateStandardMode (); + const Standard_Real GetFlyout () const; + const Standard_Boolean GetTextType() const; + const Standard_Real GetFontHeight() const; + const Standard_Boolean IsText3dShaded() const; + const Standard_Boolean IsUnitsDisplayed() const; + const TCollection_AsciiString GetUnits() const; + const Quantity_Color GetDimensionColor() const; + + // Dialog Data + enum { IDD = IDD_Dimension }; + // Initialization of dialog +protected: + virtual BOOL OnInitDialog(); + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + + //Attributes +private: + Handle (AIS_InteractiveContext) myAISContext; + int mySelectedDimType; + int myFontSize; + Quantity_Color myDimensionColor; + CTabCtrl *myLengthParams; + CTabCtrl *myAngleParams; + CTabCtrl *myRadiusParams; + CTabCtrl *myDiameterParams; + + void CreateLengthParamsTab(); + void CreateAngleParamsTab(); + void CreateRadiusParamsTab(); + void CreateDiameterParamsTab(); + +public: + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedDimLength(); + afx_msg void OnBnClickedDimAngle(); + afx_msg void OnBnClickedDimRadius(); + afx_msg void OnTcnSelChangeLengthTab(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnTcnSelChangingLengthTab(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnDestroy(); + afx_msg void OnTcnSelChangeAngleTab(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnTcnSelChangingAngleTab(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnBnClickedDimDiameter(); + afx_msg void OnBnClicked2dText(); + afx_msg void OnBnClicked3dText(); + afx_msg void OnBnClickedDimensionColor(); +}; diff --git a/samples/mfc/standard/Common/LengthParamsEdgePage.cpp b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp new file mode 100644 index 0000000000..1fac26fa15 --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsEdgePage.cpp @@ -0,0 +1,112 @@ +// LengthParamsEdgePage.cpp : implementation file +// + +#include "stdafx.h" +#include "LengthParamsEdgePage.h" +#include "DimensionDlg.h" + +#include +#include +#include +#include +#include +#include + +// CLengthParamsEdgePage dialog + +IMPLEMENT_DYNAMIC(CLengthParamsEdgePage, CDialog) + +//======================================================================= +//function : CLengthParamsEdgePage +//purpose : +//======================================================================= + +CLengthParamsEdgePage::CLengthParamsEdgePage (Handle(AIS_InteractiveContext) theContext,CWnd* pParent /*=NULL*/) +: CDialog (CLengthParamsEdgePage::IDD, pParent) +{ + myAISContext = theContext; +} + +//======================================================================= +//function : ~CLengthParamsEdgePage +//purpose : +//======================================================================= + +CLengthParamsEdgePage::~CLengthParamsEdgePage() +{ +} + +//======================================================================= +//function : DoDataExchange +//purpose : +//======================================================================= + +void CLengthParamsEdgePage::DoDataExchange (CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP (CLengthParamsEdgePage, CDialog) + ON_BN_CLICKED (IDC_ChooseEdgeBtn, &CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn) +END_MESSAGE_MAP() + +//======================================================================= +//function : GetButton +//purpose : +//======================================================================= + +CButton* CLengthParamsEdgePage::GetButton() +{ + return (CButton*)GetDlgItem (IDC_ChooseEdgeBtn); +} + +//======================================================================= +//function : OnBnClickedChooseEdgeBtn +//purpose : +//======================================================================= + +void CLengthParamsEdgePage::OnBnClickedChooseEdgeBtn() +{ + myAISContext->LocalContext()->InitSelected(); + + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox ( _T("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + TopoDS_Edge anEdge = TopoDS::Edge(myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); + TopoDS_Vertex aFirstVertex, aSecondVertex; + TopExp::Vertices (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 (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()); + aLenDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (aLenDim->IsUnitsDisplayed()) + { + aLenDim->SetDisplayUnits (aDimDlg->GetUnits()); + } + + aLenDim->SetDimensionAspect (anAspect); + aLenDim->SetFlyout (aDimDlg->GetFlyout()); + + myAISContext->CloseAllContexts(); + myAISContext->Display (aLenDim); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode(TopAbs_EDGE); +} diff --git a/samples/mfc/standard/Common/LengthParamsEdgePage.h b/samples/mfc/standard/Common/LengthParamsEdgePage.h new file mode 100644 index 0000000000..1594ba5452 --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsEdgePage.h @@ -0,0 +1,29 @@ +#pragma once + +#include "res\OCC_Resource.h" +#include +#include + +// CLengthParamsEdgePage dialog + +class CLengthParamsEdgePage : public CDialog +{ + DECLARE_DYNAMIC(CLengthParamsEdgePage) + +public: + CLengthParamsEdgePage(Handle(AIS_InteractiveContext) theAISContext,CWnd* pParent = NULL); // standard constructor + virtual ~CLengthParamsEdgePage(); + CButton* GetButton(); + +// Dialog Data + enum { IDD = IDD_LengthParamsEdgePage }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +private: + Handle(AIS_InteractiveContext) myAISContext; +public: + afx_msg void OnBnClickedChooseEdgeBtn(); +}; diff --git a/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp new file mode 100644 index 0000000000..1c126b0adb --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsEdgesPage.cpp @@ -0,0 +1,163 @@ +// LenghtParamsEdgesPage.cpp : implementation file +// + +#include "stdafx.h" +#include "LengthParamsEdgesPage.h" +#include "DimensionDlg.h" +#include +#include +#include +#include +#include +// CLengthParamsEdgesPage dialog + +//======================================================================= +//function : CLengthParamsEdgesPage +//purpose : +//======================================================================= + +CLengthParamsEdgesPage::CLengthParamsEdgesPage (Handle(AIS_InteractiveContext) theAISContext, + bool isAngleDimension /*= false*/, + CWnd* pParent /*=NULL*/) +: CDialog(CLengthParamsEdgesPage::IDD, pParent) +{ + myAISContext = theAISContext; + myIsAngleDimension = isAngleDimension; +} + +//======================================================================= +//function : ~CLengthParamsEdgesPage +//purpose : +//======================================================================= + +CLengthParamsEdgesPage::~CLengthParamsEdgesPage() +{ +} + +//======================================================================= +//function : DoDataExchange +//purpose : +//======================================================================= + +void CLengthParamsEdgesPage::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CLengthParamsEdgesPage, CDialog) + ON_BN_CLICKED(IDC_BUTTON1, &CLengthParamsEdgesPage::OnBnClickedEdge1Btn) + ON_BN_CLICKED(IDC_BUTTON3, &CLengthParamsEdgesPage::OnBnClickedEdge2Btn) +END_MESSAGE_MAP() + + +//======================================================================= +//function : OnBnClickedEdge1Btn +//purpose : +//======================================================================= + +void CLengthParamsEdgesPage::OnBnClickedEdge1Btn() +{ + // Open local context and choose the edge for length dimensions + if (!myAISContext->HasOpenedContext()) + { + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); + AfxMessageBox (_T("Local context was not opened. Choose the edge and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + // Now it's ok, local context is opened and edge selection mode is activated + // Check if some edge is selected + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox(_T("Choose the edge and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + myFirstEdge = TopoDS::Edge (myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); +} + +//======================================================================= +//function : OnBnClickedEdge2Btn +//purpose : +//======================================================================= + +void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() +{ + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T("Choose the edge and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + mySecondEdge = TopoDS::Edge (myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); + + // Build plane through three points + BRepAdaptor_Curve aCurve1 (myFirstEdge); + BRepAdaptor_Curve aCurve2 (mySecondEdge); + + gp_Pnt aP1=aCurve1.Value (0.1); + gp_Pnt aP2=aCurve1.Value (0.9); + gp_Pnt aP3=aCurve2.Value (0.5); + + GC_MakePlane aMkPlane (aP1,aP2,aP3); + + Handle(Geom_Plane) aPlane = aMkPlane.Value(); + + CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); + + myAISContext->CloseAllContexts(); + + 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()); + if (myIsAngleDimension) + { + // Build an angle dimension between two non-parallel edges + Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstEdge, mySecondEdge); + anAngleDim->SetDimensionAspect (anAspect); + anAngleDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (anAngleDim->IsUnitsDisplayed()) + { + anAngleDim->SetDisplayUnits (aDimDlg->GetUnits ()); + if ((anAngleDim->DisplayUnits().IsEqual (TCollection_AsciiString ("deg")))) + { + anAngleDim->MakeUnitsDisplayed (Standard_False); + } + else + { + anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No); + } + } + + anAngleDim->SetFlyout (aDimDlg->GetFlyout()); + myAISContext->Display (anAngleDim); + } + else + { + Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstEdge, mySecondEdge, aPlane->Pln()); + aLenDim->SetDimensionAspect (anAspect); + aLenDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (aLenDim->IsUnitsDisplayed()) + { + aLenDim->SetFlyout (aDimDlg->GetFlyout()); + aLenDim->SetDisplayUnits (aDimDlg->GetUnits()); + } + + myAISContext->Display (aLenDim); + } + + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); +} diff --git a/samples/mfc/standard/Common/LengthParamsEdgesPage.h b/samples/mfc/standard/Common/LengthParamsEdgesPage.h new file mode 100644 index 0000000000..aa9b37b91b --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsEdgesPage.h @@ -0,0 +1,30 @@ +#pragma once + +#include "res\OCC_Resource.h" + +// CLenghtParamsEdgesPage dialog + +class CLengthParamsEdgesPage : public CDialog +{ +private: + Handle(AIS_InteractiveContext) myAISContext; + bool myIsAngleDimension; + TopoDS_Edge myFirstEdge; + TopoDS_Edge mySecondEdge; +public: + CLengthParamsEdgesPage (Handle(AIS_InteractiveContext) theAISContext, + bool isAngleDimension = false, + CWnd* pParent = NULL); // standard constructor + virtual ~CLengthParamsEdgesPage(); + +// Dialog Data + enum { IDD = IDD_LengthParamsEdgesPage }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedEdge1Btn(); + afx_msg void OnBnClickedEdge2Btn(); +}; diff --git a/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp b/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp new file mode 100644 index 0000000000..ca51dd758a --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsVerticesPage.cpp @@ -0,0 +1,153 @@ +// LengthParamsVerticesPage.cpp : implementation file +// + +#include "stdafx.h" +#include "LengthParamsVerticesPage.h" +#include "DimensionDlg.h" +#include +#include +#include +#include +#include + + +// CLengthParamsVerticesPage dialog + +IMPLEMENT_DYNAMIC(CLengthParamsVerticesPage, CDialog) + +//======================================================================= +//function : CLengthParamsVerticesPage +//purpose : +//======================================================================= + +CLengthParamsVerticesPage::CLengthParamsVerticesPage (Handle(AIS_InteractiveContext) theAISContext, CWnd* pParent /*=NULL*/) +: CDialog (CLengthParamsVerticesPage::IDD, pParent) +{ + myAISContext = theAISContext; +} + +//======================================================================= +//function : ~CLengthParamsVerticesPage +//purpose : +//======================================================================= + +CLengthParamsVerticesPage::~CLengthParamsVerticesPage() +{ +} + +//======================================================================= +//function : DoDataExchange +//purpose : +//======================================================================= + +void CLengthParamsVerticesPage::DoDataExchange (CDataExchange* pDX) +{ + CDialog::DoDataExchange (pDX); +} + + +BEGIN_MESSAGE_MAP(CLengthParamsVerticesPage, CDialog) + ON_BN_CLICKED(IDC_BUTTON1, &CLengthParamsVerticesPage::OnBnClickedVertex1Btn) + ON_BN_CLICKED(IDC_BUTTON2, &CLengthParamsVerticesPage::OnBnClickedVertex2Btn) +END_MESSAGE_MAP() + + +//======================================================================= +//function : OnBnClickedVertex1Btn +//purpose : +//======================================================================= + +void CLengthParamsVerticesPage::OnBnClickedVertex1Btn() +{ + // Open local context and choose the edge for length dimensions + if (!myAISContext->HasOpenedContext()) + { + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode(TopAbs_VERTEX); + AfxMessageBox(_T("Local context was not opened. Choose the vertices and press the button again"), + MB_ICONINFORMATION | MB_OK); + return; + } + + // Now it's ok, local context is opened and edge selection mode is activated + // Check if some edge is selected + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + myFirstVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + + myAISContext->LocalContext()->ClearSelected(); +} + +//======================================================================= +//function : OnBnClickedVertex2Btn +//purpose : +//======================================================================= + +void CLengthParamsVerticesPage::OnBnClickedVertex2Btn() +{ + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + mySecondVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); + myAISContext->LocalContext()->ClearSelected(); + + //Build dimension here + gp_Pnt aP1=BRep_Tool::Pnt (myFirstVertex); + gp_Pnt aP2=BRep_Tool::Pnt (mySecondVertex); + 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*)(this->GetParentOwner()); + + Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, 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()); + aLenDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (aLenDim->IsUnitsDisplayed ()) + { + aLenDim->SetDisplayUnits (aDimDlg->GetUnits ()); + } + + aLenDim->SetDimensionAspect (anAspect); + aLenDim->SetFlyout (aDimDlg->GetFlyout()); + + myAISContext->CloseAllContexts(); + myAISContext->Display (aLenDim); + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_VERTEX); +} + +//======================================================================= +//function : getFirstVertex +//purpose : +//======================================================================= + +const TopoDS_Vertex& CLengthParamsVerticesPage::getFirstVertex() const +{ + return myFirstVertex; +} + +//======================================================================= +//function : getSecondVertex +//purpose : +//======================================================================= + +const TopoDS_Vertex& CLengthParamsVerticesPage::getSecondVertex() const +{ + return mySecondVertex; +} diff --git a/samples/mfc/standard/Common/LengthParamsVerticesPage.h b/samples/mfc/standard/Common/LengthParamsVerticesPage.h new file mode 100644 index 0000000000..315dc323ff --- /dev/null +++ b/samples/mfc/standard/Common/LengthParamsVerticesPage.h @@ -0,0 +1,29 @@ +#pragma once + +#include "res\OCC_Resource.h" + +// CLengthParamsVerticesPage dialog + +class CLengthParamsVerticesPage : public CDialog +{ + DECLARE_DYNAMIC(CLengthParamsVerticesPage) + +public: + CLengthParamsVerticesPage(Handle(AIS_InteractiveContext) theAISContext,CWnd* pParent = NULL); // standard constructor + virtual ~CLengthParamsVerticesPage(); + const TopoDS_Vertex& getFirstVertex() const; + const TopoDS_Vertex& getSecondVertex() const; +// Dialog Data + enum { IDD = IDD_LengthParamsVerticesPage }; +private: + Handle(AIS_InteractiveContext) myAISContext; + TopoDS_Vertex myFirstVertex; + TopoDS_Vertex mySecondVertex; +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedVertex1Btn(); + afx_msg void OnBnClickedVertex2Btn(); +}; diff --git a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp index e7246c9ab5..b66e3e7a81 100755 --- a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp +++ b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp @@ -11,8 +11,12 @@ #include #include "ImportExport/ImportExport.h" #include "AISDialogs.h" +#include #include #include +#include +#include +#include BEGIN_MESSAGE_MAP(OCC_3dBaseDoc, OCC_BaseDoc) //{{AFX_MSG_MAP(OCC_3dBaseDoc) @@ -34,6 +38,9 @@ BEGIN_MESSAGE_MAP(OCC_3dBaseDoc, OCC_BaseDoc) ON_UPDATE_COMMAND_UI(ID_OBJECT_DISPLAYALL, OnUpdateObjectDisplayall) ON_COMMAND(ID_OBJECT_REMOVE, OnObjectRemove) ON_UPDATE_COMMAND_UI(ID_OBJECT_REMOVE, OnUpdateObjectRemove) + ON_COMMAND(ID_OBJECT_DIM, OnObjectAddDimensions) + ON_UPDATE_COMMAND_UI(ID_OBJECT_DIM, OnUpdateObjectAddDimensions) + //}}AFX_MSG_MAP ON_COMMAND_EX_RANGE(ID_OBJECT_MATERIAL_BRASS,ID_OBJECT_MATERIAL_DEFAULT, OnObjectMaterialRange) ON_UPDATE_COMMAND_UI_RANGE(ID_OBJECT_MATERIAL_BRASS,ID_OBJECT_MATERIAL_DEFAULT, OnUpdateObjectMaterialRange) @@ -45,6 +52,8 @@ END_MESSAGE_MAP() ////////////////////////////////////////////////////////////////////// OCC_3dBaseDoc::OCC_3dBaseDoc() +:myPopupMenuNumber(0), + myDimensionDlg() { AfxInitRichEdit(); @@ -55,6 +64,8 @@ OCC_3dBaseDoc::OCC_3dBaseDoc() myViewer->SetDefaultLights(); myViewer->SetLightOn(); myAISContext = new AIS_InteractiveContext (myViewer); + myDimensionDlg.SetContext (myAISContext); + myDimensionDlg.Create(CDimensionDlg::IDD, NULL); } //----------------------------------------------------------------------------------------- @@ -167,17 +178,20 @@ void OCC_3dBaseDoc::Popup (const Standard_Integer theMouseX, const Standard_Integer theMouseY, const Handle(V3d_View)& theView) { - Standard_Integer PopupMenuNumber=0; - myAISContext->InitCurrent(); - if (myAISContext->MoreCurrent()) - PopupMenuNumber=1; + // Base check which context menu to call + if (!myPopupMenuNumber) + { + myAISContext->InitCurrent(); + if (myAISContext->MoreCurrent()) + myPopupMenuNumber=1; + } CMenu menu; VERIFY(menu.LoadMenu(IDR_Popup3D)); - CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber); + CMenu* pPopup = menu.GetSubMenu(myPopupMenuNumber); ASSERT(pPopup != NULL); - if (PopupMenuNumber == 1) // more than 1 object. + if (myPopupMenuNumber == 1) // more than 1 object. { bool OneOrMoreInShading = false; for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) @@ -190,8 +204,10 @@ void OCC_3dBaseDoc::Popup (const Standard_Integer theMouseX, Handle(WNT_Window) aWNTWindow= Handle(WNT_Window)::DownCast(theView->Window()); ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord); - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y , - AfxGetMainWnd()); + pPopup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, + winCoord.x, + winCoord.y, + AfxGetMainWnd()); } void OCC_3dBaseDoc::Fit() @@ -392,7 +408,7 @@ void OCC_3dBaseDoc::OnUpdateObjectRemove(CCmdUI* pCmdUI) bool OneOrMoreIsDisplayed = false; for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ()) if (myAISContext->IsDisplayed(myAISContext->Current())) OneOrMoreIsDisplayed=true; - pCmdUI->Enable (OneOrMoreIsDisplayed); + pCmdUI->Enable (OneOrMoreIsDisplayed); } void OCC_3dBaseDoc::SetMaterial(Graphic3d_NameOfMaterial Material) @@ -401,3 +417,18 @@ void OCC_3dBaseDoc::SetMaterial(Graphic3d_NameOfMaterial Material) myAISContext->SetMaterial (myAISContext->Current(), (Graphic3d_NameOfMaterial)(Material)); } + +void OCC_3dBaseDoc::OnObjectAddDimensions() +{ + //Add dimentions dialog is opened here + myDimensionDlg.ShowWindow(SW_SHOW); + myDimensionDlg.UpdateStandardMode (); +} + +void OCC_3dBaseDoc::OnUpdateObjectAddDimensions(CCmdUI* pCmdUI) +{ + // Check if local context is opened + //pCmdUI->Enable (myAISContext->HasOpenedContext()); +} + + diff --git a/samples/mfc/standard/Common/OCC_3dBaseDoc.h b/samples/mfc/standard/Common/OCC_3dBaseDoc.h index 283d8b5afd..2434cb6ff8 100755 --- a/samples/mfc/standard/Common/OCC_3dBaseDoc.h +++ b/samples/mfc/standard/Common/OCC_3dBaseDoc.h @@ -10,10 +10,14 @@ #endif // _MSC_VER > 1000 #include "OCC_BaseDoc.h" +#include "DimensionDlg.h" #include class AFX_EXT_CLASS OCC_3dBaseDoc : public OCC_BaseDoc { +protected: + CDimensionDlg myDimensionDlg; + int myPopupMenuNumber; public: OCC_3dBaseDoc(); @@ -78,6 +82,9 @@ protected: afx_msg void OnUpdateObjectDisplayall(CCmdUI* pCmdUI); afx_msg void OnObjectRemove(); afx_msg void OnUpdateObjectRemove(CCmdUI* pCmdUI); + afx_msg void OnObjectAddDimensions(); + afx_msg void OnUpdateObjectAddDimensions(CCmdUI* pCmdUI); + //}}AFX_MSG DECLARE_MESSAGE_MAP() }; diff --git a/samples/mfc/standard/Common/RadiusParamsPage.cpp b/samples/mfc/standard/Common/RadiusParamsPage.cpp new file mode 100644 index 0000000000..c810a164d1 --- /dev/null +++ b/samples/mfc/standard/Common/RadiusParamsPage.cpp @@ -0,0 +1,133 @@ + +#include "stdafx.h" +#include "RadiusParamsPage.h" +#include "DimensionDlg.h" + +#include +#include +#include +#include +#include +#include + +IMPLEMENT_DYNAMIC(CRadiusParamsPage, CDialog) + +//======================================================================= +//function : CRadiusParamsPage +//purpose : +//======================================================================= + +CRadiusParamsPage::CRadiusParamsPage (const Handle(AIS_InteractiveContext)& theAISContext, + const Standard_Boolean isDiameterDimension /* =Standard_False*/, + CWnd* pParent /*=NULL*/) + : CDialog (CRadiusParamsPage::IDD, pParent) +{ + myAISContext = theAISContext; + myIsDiameterDimension = isDiameterDimension; +} + +//======================================================================= +//function : ~CRadiusParamsPage +//purpose : +//======================================================================= + +CRadiusParamsPage::~CRadiusParamsPage() +{ +} + +//======================================================================= +//function : DoDataExchange +//purpose : +//======================================================================= + +void CRadiusParamsPage::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CRadiusParamsPage, CDialog) + ON_BN_CLICKED(IDC_BUTTON1, &CRadiusParamsPage::OnBnClickedObjectBtn) +END_MESSAGE_MAP() + +//======================================================================= +//function : OnBnClickedObjectBtn +//purpose : +//======================================================================= + +void CRadiusParamsPage::OnBnClickedObjectBtn() +{ + //Build dimension here + myAISContext->LocalContext()->InitSelected(); + if (!myAISContext->LocalContext()->MoreSelected()) + { + AfxMessageBox (_T ("Choose the edge and press the button again"), MB_ICONINFORMATION | MB_OK); + return; + } + + gp_Circ aCircle; + Standard_Boolean isAttachPoint = Standard_False; + Standard_Real aFirstPar = 0, aLastPar = 0; + + TopoDS_Shape aSelShape = myAISContext->LocalContext()->SelectedShape(); + if (aSelShape.ShapeType() != TopAbs_EDGE && + aSelShape.ShapeType() != TopAbs_FACE && + aSelShape.ShapeType() != TopAbs_WIRE) + return; + + if (aSelShape.ShapeType() == TopAbs_EDGE) + { + BRepAdaptor_Curve aCurve (TopoDS::Edge (aSelShape)); + if (aCurve.GetType() != GeomAbs_Circle) + { + return; + } + + aCircle = aCurve.Circle(); + if (aCurve.FirstParameter() != 0 && aCurve.LastParameter() != M_PI * 2) + { + isAttachPoint = Standard_True; + aFirstPar = aCurve.FirstParameter(); + aLastPar = aCurve.LastParameter(); + } + } + + myAISContext->LocalContext()->ClearSelected(); + CDimensionDlg *aDimDlg = (CDimensionDlg*)(this->GetParentOwner()); + // Try to create dimension if it is possible + Handle(AIS_Dimension) aDim; + if (myIsDiameterDimension) + { + aDim = isAttachPoint ? new AIS_DiameterDimension (aCircle, ElCLib::Value ((aFirstPar + aLastPar) / 2.0, aCircle)) + : new AIS_DiameterDimension (aCircle); + Handle(AIS_DiameterDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout()); + } + else + { + aDim = isAttachPoint ? new AIS_RadiusDimension (aCircle, ElCLib::Value ((aFirstPar + aLastPar) / 2.0, aCircle)) + : new AIS_RadiusDimension (aCircle); + Handle(AIS_RadiusDimension)::DownCast(aDim)->SetFlyout (aDimDlg->GetFlyout()); + } + + 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()); + aDim->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); + if (aDim->IsUnitsDisplayed()) + { + aDim->SetDisplayUnits (aDimDlg->GetUnits()); + } + + aDim->SetDimensionAspect (anAspect); + + // Display dimension in the neutral point + myAISContext->CloseAllContexts(); + + myAISContext->Display (aDim); + + myAISContext->OpenLocalContext(); + myAISContext->ActivateStandardMode (TopAbs_EDGE); +} diff --git a/samples/mfc/standard/Common/RadiusParamsPage.h b/samples/mfc/standard/Common/RadiusParamsPage.h new file mode 100644 index 0000000000..0c28f4275d --- /dev/null +++ b/samples/mfc/standard/Common/RadiusParamsPage.h @@ -0,0 +1,27 @@ +#pragma once + +#include "res\OCC_Resource.h" +// CRadiusParamsPage dialog + +class CRadiusParamsPage : public CDialog +{ + DECLARE_DYNAMIC(CRadiusParamsPage) +private: + Handle(AIS_InteractiveContext) myAISContext; + Standard_Boolean myIsDiameterDimension; +public: + CRadiusParamsPage(const Handle(AIS_InteractiveContext)& theAISContext, + const Standard_Boolean isDiameterDimension = Standard_False, + CWnd* pParent = NULL); // standard constructor + virtual ~CRadiusParamsPage(); + +// Dialog Data + enum { IDD = IDD_RadiusParamsPage }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedObjectBtn(); +}; diff --git a/samples/mfc/standard/Common/res/AIS_TB.bmp b/samples/mfc/standard/Common/res/AIS_TB.bmp index e509bd08ab..edb1f3728e 100755 Binary files a/samples/mfc/standard/Common/res/AIS_TB.bmp and b/samples/mfc/standard/Common/res/AIS_TB.bmp differ diff --git a/samples/mfc/standard/Common/res/OCC_Resource.aps b/samples/mfc/standard/Common/res/OCC_Resource.aps index 82b47ae135..f404b3228c 100755 Binary files a/samples/mfc/standard/Common/res/OCC_Resource.aps and b/samples/mfc/standard/Common/res/OCC_Resource.aps differ diff --git a/samples/mfc/standard/Common/res/OCC_Resource.h b/samples/mfc/standard/Common/res/OCC_Resource.h index 8d82a087b1..3e31ed78b0 100755 --- a/samples/mfc/standard/Common/res/OCC_Resource.h +++ b/samples/mfc/standard/Common/res/OCC_Resource.h @@ -3,7 +3,13 @@ // Used by OCC_Resource.rc // #define IDR_POPUP 116 +#define IDD_Dimension 119 +#define IDD_LengthParamsEdgePage 122 +#define IDD_LengthParamsVerticesPage 123 +#define IDD_LengthParamsEdgesPage 125 +#define IDD_AngleParamsVerticesPage 126 #define IDR_MAINFRAME 128 +#define IDD_RadiusParamsPage 128 #define IDR_2DTYPE 129 #define IDR_3DTYPE 131 #define ID_FILE_EXPORT_IMAGE 132 @@ -20,8 +26,41 @@ #define IDD_COLORMESH 552 #define IDB_coloredmesh 554 #define IDC_RICHEDIT_ResultDialog 1001 -#define IDC_EDIT1 1004 -#define IDC_README 1005 +#define IDC_ResultNameEdit 1003 +#define IDC_README 1004 +#define IDC_DimensionGroupbox 1005 +#define IDD_DIMENSIONDLG 1006 +#define IDC_TextParamGroupbox 1007 +#define IDC_DimensionParametersGroupbox 1010 +#define IDC_TAB1 1011 +#define IDC_LengthTab 1014 +#define IDC_AngleTab 1015 +#define IDC_BUTTON1 1016 +#define IDC_XPOS 1017 +#define IDC_BUTTON2 1018 +#define IDC_BUTTON3 1019 +#define IDC_YPOS 1020 +#define IDC_BUTTON4 1021 +#define IDC_RadiusTab 1022 +#define IDC_ZPOS 1023 +#define IDC_ChooseEdgeBtn 1025 +#define IDC_ChooseEdgeEdit 1026 +#define IDC_Flyout 1028 +#define IDC_DiameterTab 1031 +#define IDC_DimLength 1032 +#define IDC_DimAngle 1033 +#define IDC_DimRadius 1034 +#define IDC_DimDiameter 1035 +#define IDC_2DText 1036 +#define IDC_3DText 1037 +#define IDC_FontSize 1038 +#define IDC_FontSizeStatic 1039 +#define IDC_FlyoutStatic 1044 +#define IDC_DisplayUnits 1045 +#define IDC_DisplayUnitsStatic 1046 +#define IDC_TextDisplayMode 1047 +#define IDC_TextDisplayModeStatic 1048 +#define IDC_DimensionColor 1049 #define ID_WINDOW_NEW3D 1151 #define ID_OBJECT_DISPLAYALL 1201 #define ID_OBJECT_MATERIAL 1205 @@ -93,6 +132,9 @@ #define ID_BUTTONTop 40016 #define ID_BUTTON40017 40017 #define ID_BUTTON40033 40033 +#define ID_OBJECT_DIMENSIONS 40035 +#define ID_OBJECT_DIM 40036 +#define ID_LOCALCONTEXT_ADDDIMENSION 40037 #define ID_FILE_IMPORT_CSFDB 40100 #define ID_FILE_IMPORT_BREP 40101 #define ID_FILE_IMPORT_STEP 40102 @@ -132,9 +174,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 119 -#define _APS_NEXT_COMMAND_VALUE 40034 -#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_RESOURCE_VALUE 131 +#define _APS_NEXT_COMMAND_VALUE 40038 +#define _APS_NEXT_CONTROL_VALUE 1052 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/samples/mfc/standard/Common/res/OCC_Resource.rc b/samples/mfc/standard/Common/res/OCC_Resource.rc index 04fe07f78e..c6951ea22f 100755 --- a/samples/mfc/standard/Common/res/OCC_Resource.rc +++ b/samples/mfc/standard/Common/res/OCC_Resource.rc @@ -73,6 +73,52 @@ IDB_coloredmesh BITMAP "coloredm.bmp" // Dialog // +IDD_RadiusParamsPage DIALOGEX 0, 0, 121, 46 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Click to set up selected circle or arc",IDC_BUTTON1,26,10,70,25,BS_MULTILINE +END + +IDD_AngleParamsVerticesPage DIALOGEX 0, 0, 126, 69 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Set up selected vertex",IDC_BUTTON1,39,7,83,18,BS_MULTILINE + LTEXT "Vertex1",IDC_STATIC,10,12,26,8 + PUSHBUTTON "Set up selected vertex",IDC_BUTTON3,39,26,83,17 + LTEXT "Vertex2",IDC_STATIC,9,30,26,8 + PUSHBUTTON "Set up selected vertex",IDC_BUTTON4,39,44,83,18 + LTEXT "Vertex3",IDC_STATIC,9,47,26,8 +END + +IDD_LengthParamsEdgePage DIALOGEX 0, 0, 70, 35 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Click to set up selected edge",IDC_ChooseEdgeBtn,1,1,66,30,BS_MULTILINE +END + +IDD_LengthParamsVerticesPage DIALOGEX 0, 0, 135, 55 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Vertex1",IDC_STATIC,7,11,26,8 + LTEXT "Vertex2",IDC_STATIC,7,35,26,8 + PUSHBUTTON "Click to set up selected vertex",IDC_BUTTON1,39,4,74,21,BS_MULTILINE + PUSHBUTTON "Click to set up selected vertex",IDC_BUTTON2,39,31,74,20,BS_MULTILINE +END + +IDD_LengthParamsEdgesPage DIALOGEX 0, 0, 128, 60 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Click to set up selected edge",IDC_BUTTON1,33,1,82,26,BS_MULTILINE + PUSHBUTTON "Click to set up selected edge",IDC_BUTTON3,34,30,81,26,BS_MULTILINE + LTEXT "Edge1",IDC_STATIC,6,12,21,8 + LTEXT "Edge2",IDC_STATIC,6,33,21,8 +END + IDD_OCC_ABOUTBOX DIALOGEX 34, 22, 284, 257 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About" @@ -90,7 +136,7 @@ IDD_ResultDialog DIALOG 0, 0, 212, 202 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU FONT 8, "MS Sans Serif" BEGIN - CONTROL "",IDC_RICHEDIT_ResultDialog,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,0,10,210,160 + CONTROL "",IDC_RICHEDIT_ResultDialog,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,2,9,207,162 PUSHBUTTON "Copy selection to clipboard",IDC_CopySelectionToClipboard,5,176,100,15 PUSHBUTTON "Copy all to clipboard",IDC_CopyAllToClipboard,107,176,100,15 END @@ -204,6 +250,37 @@ BEGIN GROUPBOX "",IDC_STATIC,115,86,8,73 END +IDD_Dimension DIALOGEX 0, 0, 236, 337 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Add dimension" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,97,311,50,14 + GROUPBOX "Dimension",IDC_DimensionGroupbox,8,9,64,85 + CONTROL "",IDC_LengthTab,"SysTabControl32",0x0,11,205,194,95 + CONTROL "",IDC_AngleTab,"SysTabControl32",NOT WS_VISIBLE,10,205,193,94 + CONTROL "",IDC_RadiusTab,"SysTabControl32",0x0,10,205,193,93 + GROUPBOX "Dimension parameters",IDC_DimensionParametersGroupbox,9,103,209,84,WS_GROUP + CONTROL "",IDC_DiameterTab,"SysTabControl32",0x0,10,205,194,92 + CONTROL "Length",IDC_DimLength,"Button",BS_AUTORADIOBUTTON | WS_GROUP,20,26,38,10 + CONTROL "Angle",IDC_DimAngle,"Button",BS_AUTORADIOBUTTON,20,38,34,10 + CONTROL "Radius",IDC_DimRadius,"Button",BS_AUTORADIOBUTTON,20,50,37,10 + CONTROL "Diameter",IDC_DimDiameter,"Button",BS_AUTORADIOBUTTON,20,63,45,10 + GROUPBOX "Text parameters",IDC_TextParamGroupbox,80,9,139,84 + CONTROL "2D Text",IDC_2DText,"Button",BS_AUTORADIOBUTTON | WS_GROUP,162,20,41,10 + CONTROL "3D Text",IDC_3DText,"Button",BS_AUTORADIOBUTTON,162,33,41,10 + LTEXT "Text type:",IDC_STATIC,86,22,47,8 + LTEXT "Font Size:",IDC_FontSizeStatic,87,51,33,8 + COMBOBOX IDC_FontSize,157,51,48,57,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Flyout value",IDC_FlyoutStatic,25,117,40,8 + LTEXT "Display units",IDC_DisplayUnitsStatic,25,138,41,8 + COMBOBOX IDC_DisplayUnits,105,138,64,59,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "Text display mode:",IDC_TextDisplayModeStatic,86,74,62,8 + COMBOBOX IDC_TextDisplayMode,157,71,48,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Change dimension color",IDC_DimensionColor,105,156,63,24,BS_MULTILINE + CONTROL "",IDC_Flyout,"msctls_trackbar32",TBS_TOP | TBS_TOOLTIPS | WS_TABSTOP,73,112,100,20 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -275,6 +352,7 @@ BEGIN BUTTON ID_OBJECT_DISPLAYALL SEPARATOR BUTTON ID_OBJECT_REMOVE + BUTTON ID_OBJECT_DIM END @@ -352,6 +430,29 @@ END #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN + IDD_RadiusParamsPage, DIALOG + BEGIN + RIGHTMARGIN, 120 + BOTTOMMARGIN, 45 + END + + IDD_AngleParamsVerticesPage, DIALOG + BEGIN + RIGHTMARGIN, 80 + BOTTOMMARGIN, 66 + END + + IDD_LengthParamsVerticesPage, DIALOG + BEGIN + BOTTOMMARGIN, 51 + END + + IDD_LengthParamsEdgesPage, DIALOG + BEGIN + RIGHTMARGIN, 115 + BOTTOMMARGIN, 58 + END + IDD_OCC_ABOUTBOX, DIALOG BEGIN BOTTOMMARGIN, 256 @@ -367,10 +468,48 @@ BEGIN RIGHTMARGIN, 67 BOTTOMMARGIN, 219 END + + IDD_Dimension, DIALOG + BEGIN + RIGHTMARGIN, 235 + BOTTOMMARGIN, 336 + HORZGUIDE, 336 + END END #endif // APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +IDD_Dimension DLGINIT +BEGIN + IDC_FontSize, 0x403, 2, 0 +0x0037, + IDC_FontSize, 0x403, 2, 0 +0x0038, + IDC_FontSize, 0x403, 2, 0 +0x0039, + IDC_FontSize, 0x403, 3, 0 +0x3031, "\000" + IDC_FontSize, 0x403, 3, 0 +0x3131, "\000" + IDC_FontSize, 0x403, 3, 0 +0x3231, "\000" + IDC_FontSize, 0x403, 3, 0 +0x3331, "\000" + IDC_FontSize, 0x403, 3, 0 +0x3431, "\000" + IDC_TextDisplayMode, 0x403, 10, 0 +0x6957, 0x6572, 0x7266, 0x6d61, 0x0065, + IDC_TextDisplayMode, 0x403, 9, 0 +0x5320, 0x6168, 0x6964, 0x676e, "\000" + 0 +END + + ///////////////////////////////////////////////////////////////////////////// // // String Table @@ -494,6 +633,12 @@ BEGIN ID_OBJECT_WIREFRAME "Put selection in wireframe\nWireframe" END +STRINGTABLE +BEGIN + ID_OBJECT_DIMENSIONS "Add dimensions" + ID_LOCALCONTEXT_ADDDIMENSION "Add new dimension for selected objetcs" +END + #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj b/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj index 2fe42c8802..1b3fc7338f 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj +++ b/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj @@ -274,6 +274,8 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + + Disabled %(AdditionalIncludeDirectories) @@ -290,6 +292,10 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + + + + Disabled %(AdditionalIncludeDirectories) @@ -714,7 +720,12 @@ + + + + + @@ -727,6 +738,7 @@ + diff --git a/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj.filters b/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj.filters index ab0406a92f..2163d8af40 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj.filters +++ b/samples/mfc/standard/mfcsample/adm/win/vc10/mfcsample.vcxproj.filters @@ -120,6 +120,24 @@ Source Files\ISession2D-src + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -211,6 +229,24 @@ Header Files\ISession2D-headers + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj b/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj index e1d17fe81e..7bf98fc7f4 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj +++ b/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj @@ -278,6 +278,8 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + + Disabled %(AdditionalIncludeDirectories) @@ -294,6 +296,10 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + + + + Disabled %(AdditionalIncludeDirectories) @@ -718,7 +724,12 @@ + + + + + @@ -731,6 +742,7 @@ + diff --git a/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj.filters b/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj.filters index ab0406a92f..2163d8af40 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj.filters +++ b/samples/mfc/standard/mfcsample/adm/win/vc11/mfcsample.vcxproj.filters @@ -120,6 +120,24 @@ Source Files\ISession2D-src + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -211,6 +229,24 @@ Header Files\ISession2D-headers + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/samples/mfc/standard/mfcsample/adm/win/vc8/mfcsample.vcproj b/samples/mfc/standard/mfcsample/adm/win/vc8/mfcsample.vcproj index 9dcd89dd36..5a68460e09 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc8/mfcsample.vcproj +++ b/samples/mfc/standard/mfcsample/adm/win/vc8/mfcsample.vcproj @@ -464,6 +464,14 @@ /> + + + + @@ -510,6 +518,18 @@ /> + + + + + + @@ -1148,6 +1168,10 @@ /> + + @@ -1735,10 +1759,30 @@ RelativePath="..\..\..\..\Common\AISDialogs.h" > + + + + + + + + + + @@ -1791,6 +1835,10 @@ RelativePath="..\..\..\..\Common\res\OCC_Resource.h" > + + diff --git a/samples/mfc/standard/mfcsample/adm/win/vc9/mfcsample.vcproj b/samples/mfc/standard/mfcsample/adm/win/vc9/mfcsample.vcproj index 9dfd4f56d5..59369194d1 100644 --- a/samples/mfc/standard/mfcsample/adm/win/vc9/mfcsample.vcproj +++ b/samples/mfc/standard/mfcsample/adm/win/vc9/mfcsample.vcproj @@ -461,6 +461,14 @@ /> + + + + @@ -507,6 +515,18 @@ /> + + + + + + @@ -1145,6 +1165,10 @@ /> + + @@ -1732,10 +1756,30 @@ RelativePath="..\..\..\..\Common\AISDialogs.h" > + + + + + + + + + + @@ -1788,6 +1832,10 @@ RelativePath="..\..\..\..\Common\res\OCC_Resource.h" > + + diff --git a/src/AIS/AIS.cdl b/src/AIS/AIS.cdl index 66cfab96c4..318badff80 100755 --- a/src/AIS/AIS.cdl +++ b/src/AIS/AIS.cdl @@ -275,7 +275,7 @@ is -- for example, are only created for the selection -- process. By means of these enumerations, they can -- be cleared from local context. - + enumeration KindOfUnit is TOU_LENGTH, TOU_SURFACE, @@ -285,19 +285,19 @@ is TOU_MASS, TOU_FORCE, TOU_TIME; - ---Purpose: Declares the type of Interactive Object unit. - + ---Purpose: Declares the type of Interactive Object unit. + enumeration TypeOfAxis is TOAX_Unknown,TOAX_XAxis,TOAX_YAxis,TOAX_ZAxis; - ---Purpose: Declares the type of axis. - + ---Purpose: Declares the type of axis. + enumeration TypeOfPlane is TOPL_Unknown,TOPL_XYPlane,TOPL_XZPlane,TOPL_YZPlane; - ---Purpose: Declares the type of plane. + ---Purpose: Declares the type of plane. enumeration TypeOfDist is TOD_Unknown,TOD_Horizontal,TOD_Vertical; ----Purpose: To declare the type of distance. - + ---Purpose: To declare the type of distance. + enumeration TypeOfAttribute is TOA_Line, - TOA_Angle, + TOA_Dimension, TOA_Wire, TOA_Plane, TOA_Vector, @@ -311,16 +311,21 @@ is TOA_FirstAxis, TOA_SecondAxis, TOA_ThirdAxis; - - enumeration StandardDatum is SD_None,SD_Point,SD_Axis,SD_Trihedron,SD_PlaneTrihedron,SD_Line,SD_Circle,SD_Plane; - --- Purpose: Declares the type of standard datum of an Interactive Object. --- New ------------------------------------------------ + enumeration StandardDatum is SD_None,SD_Point,SD_Axis,SD_Trihedron,SD_PlaneTrihedron,SD_Line,SD_Circle,SD_Plane; + --- Purpose: Declares the type of standard datum of an Interactive Object. enumeration KindOfSurface is KOS_Plane, KOS_Cylinder, KOS_Cone, KOS_Sphere, KOS_Torus, - KOS_Revolution, KOS_Extrusion, KOS_OtherSurface; -------------------------------------------------------- - + KOS_Revolution, KOS_Extrusion, KOS_OtherSurface; + +-- Enumerations for dimensions management -- + + enumeration DisplaySpecialSymbol is DSS_No, DSS_Before, DSS_After; + ---Purpose: Specifies dimension special symbol display options + + enumeration DimensionDisplayMode is DDM_All, DDM_Line, DDM_Text; + ---Purpose: Specifies dimension display modes for advanced highlighting and selection. + class Triangulation; class TexturedShape; @@ -374,10 +379,10 @@ is deferred class EllipseRadiusDimension; class MaxRadiusDimension; class MinRadiusDimension; - class LengthDimension; - class AngleDimension; - class RadiusDimension; - class DiameterDimension; + imported LengthDimension; + imported AngleDimension; + imported RadiusDimension; + imported DiameterDimension; class Chamf2dDimension; class Chamf3dDimension; class OffsetDimension; diff --git a/src/AIS/AIS.cxx b/src/AIS/AIS.cxx index 0c7e02fa70..68b04f44c6 100755 --- a/src/AIS/AIS.cxx +++ b/src/AIS/AIS.cxx @@ -384,10 +384,10 @@ Standard_Boolean AIS::ComputeGeometry(const TopoDS_Edge& anEdge1, //======================================================================= //function : ComputeGeometry //purpose : Computes the geometry of the 2 edges in the current wp -// and the 'rigth' geometry of the edges if one doesn't -// belong to the currentworkingplane. +// and the 'right' geometry of the edges if one doesn't +// belong to the current working plane. // There may be only one curve that can't belong to the -// current workingplane ( attachement constraint) +// current working plane ( attachement constraint) // if the 2 edges belong to the current WP, = 0 // // indexExt = 0 2 edges are in the current wp @@ -397,19 +397,19 @@ Standard_Boolean AIS::ComputeGeometry(const TopoDS_Edge& anEdge1, // it returns Standard_False //======================================================================= -Standard_Boolean AIS::ComputeGeometry(const TopoDS_Edge& anEdge1, - const TopoDS_Edge& anEdge2, - Standard_Integer& indexExt, - Handle(Geom_Curve)& aCurve1, - Handle(Geom_Curve)& aCurve2, - gp_Pnt& FirstPnt1, - gp_Pnt& LastPnt1, - gp_Pnt& FirstPnt2, - gp_Pnt& LastPnt2, - Handle(Geom_Curve)& extCurve, - Standard_Boolean& isInfinite1, - Standard_Boolean& isInfinite2, - const Handle(Geom_Plane)& aPlane) +Standard_Boolean AIS::ComputeGeometry (const TopoDS_Edge& anEdge1, + const TopoDS_Edge& anEdge2, + Standard_Integer& indexExt, + Handle(Geom_Curve)& aCurve1, + Handle(Geom_Curve)& aCurve2, + gp_Pnt& FirstPnt1, + gp_Pnt& LastPnt1, + gp_Pnt& FirstPnt2, + gp_Pnt& LastPnt2, + Handle(Geom_Curve)& extCurve, + Standard_Boolean& isInfinite1, + Standard_Boolean& isInfinite2, + const Handle(Geom_Plane)& aPlane) { if (aPlane.IsNull()) return Standard_False; extCurve.Nullify(); diff --git a/src/AIS/AIS_AngleDimension.cdl b/src/AIS/AIS_AngleDimension.cdl deleted file mode 100755 index c0be9ef6fd..0000000000 --- a/src/AIS/AIS_AngleDimension.cdl +++ /dev/null @@ -1,287 +0,0 @@ --- Created on: 1996-12-03 --- Created by: Arnaud BOUZY/Odile Olivier --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class AngleDimension from AIS inherits Relation from AIS - - - ---Purpose: A framework to define display of angles. - -- These displays are particularly useful in viewing draft prisms. - -- The angle displayed may define an intersection - -- can be between two edges or two faces of a shape - -- or a plane. The display consists of arrows and text. - -uses Shape from TopoDS, - Presentation from Prs3d, - PresentationManager3d from PrsMgr, - Selection from SelectMgr, - Pnt from gp, - Dir from gp, - Circ from gp, - Line from Geom, - Ax1 from gp, - Projector from Prs3d, - Transformation from Geom, - Plane from Geom, - Surface from Geom, - ExtendedString from TCollection, - ArrowSide from DsgPrs, - KindOfDimension from AIS, - Edge from TopoDS, - Face from TopoDS -is - - Create (aFirstEdge : Edge from TopoDS; - aSecondEdge : Edge from TopoDS; - aPlane : Plane from Geom; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: Constructs the angle display object defined by the - -- shapes aFShape, aSShape, the plane aPlane, the - -- value aVal and the text aText. - -- aFShape and aSShape are edges. - returns mutable AngleDimension from AIS; - - - Create (aFirstEdge : Edge from TopoDS; - aSecondEdge : Edge from TopoDS; - aPlane : Plane from Geom; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.0) - ---Purpose: Constructs the angle display object defined by the - -- shapes aFShape, aSShape, the plane aPlane, the - -- value aVal, the text aText, the point aPosition, the - -- type of arrow aSymbolPrs, and the arrow length anArrowSize. - -- aFShape and aSShape are edges. - returns mutable AngleDimension from AIS; - - Create (aCone : Face from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: Angle of cone - returns mutable AngleDimension from AIS; - - - Create (aCone : Face from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.01 ) - ---Purpose: Angle of cone - returns mutable AngleDimension from AIS; - --=================================================================== - - Create (aFirstFace : Face from TopoDS; - aSecondFace : Face from TopoDS; - anAxis : Ax1 from gp; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: TwoPlanarFaceAngle dimension - returns mutable AngleDimension from AIS; - - Create (aFirstFace : Face from TopoDS; - aSecondFace : Face from TopoDS; - anAxis : Ax1 from gp; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.0) - ---Purpose: TwoPlanarFacesAngle dimension with position - -- and text Face can be Plane or Extrusion of line - -- or Offset of those - returns mutable AngleDimension from AIS; - - - Create (aFFace : Face from TopoDS; - aSFace : Face from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: Angle dimension between two curvilinear faces - -- Warning: - -- Requaired 0 <= aVal < PI, - -- aVal must be defined exactly. - returns mutable AngleDimension from AIS; - - Create (aFFace : Face from TopoDS; - aSFace : Face from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.001) - ---Purpose: Angle dimension between two curvilinear faces - -- with position and text. Face can be Cone, Cylinder - -- Offset of Cone, Offset of Cylinder - returns mutable AngleDimension from AIS; - - - Axis (me) - ---Purpose: - -- Returns the axis set by the SetAxis method, which - -- serves to locate the angle between two faces. - ---C++: return const & - ---C++: inline - returns Ax1 from gp - is static; - - SetAxis(me: mutable;anAxis : Ax1 from gp) - ---C++: inline - ---Purpose: - -- Sets the axis, anAxis, which serves to locate the - -- angle between two faces. - is static; - - SetConeFace( me: mutable; aConeFace : Face from TopoDS ) - is static; - - SetFirstShape( me: mutable; aFShape : Shape from TopoDS ) - is redefined static; - - SetSecondShape( me: mutable; aSShape : Shape from TopoDS ) - is redefined static; - - - KindOfDimension(me) - ---Purpose: Returns PLANEANGLE as the kind of dimension. - ---C++: inline - returns KindOfDimension from AIS - is redefined; - - IsMovable(me) returns Boolean from Standard - ---C++: inline - ---Purpose: Returns true if the angle dimension is movable. - - is redefined; - - -- Methods from PresentableObject - - Compute(me : mutable; - aPresentationManager: PresentationManager3d from PrsMgr; - aPresentation : mutable Presentation from Prs3d; - aMode : Integer from Standard= 0) - is redefined static private; - - Compute(me:mutable; - aProjector: Projector from Prs3d; - aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation : mutable Presentation from Prs3d) - is redefined; - ---Purpose: Computes the presentation according to a point of view - -- given by . - -- This method should be used when the associated degenerated Presentations - -- have been transformed by which is not a Pure - -- Translation. The HLR Prs can't be deducted automatically - -- WARNING : must be applied - -- to the object to display before computation !!! - --- Methods from SelectableObject - - ComputeSelection(me : mutable; - aSelection : mutable Selection from SelectMgr; - aMode : Integer from Standard) - is redefined private; - - --- --- Computation private methods --- - - ComputeConeAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeTwoFacesAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeTwoPlanarFacesAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeTwoCurvilinearFacesAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeTwoEdgesAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - ComputeTwoEdgesNullAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d; - l1 : Line from Geom; - l2 : Line from Geom; - ptat11 : Pnt from gp; - ptat12 : Pnt from gp; - ptat21 : Pnt from gp; - ptat22 : Pnt from gp; - isInf1 : Boolean from Standard; - isInf2 : Boolean from Standard ) - is private; - - ComputeTwoEdgesNotNullAngle(me: mutable; - aPresentation : mutable Presentation from Prs3d; - l1 : Line from Geom; - l2 : Line from Geom; - ptat11 : Pnt from gp; - ptat12 : Pnt from gp; - ptat21 : Pnt from gp; - ptat22 : Pnt from gp; - isInf1 : Boolean from Standard; - isInf2 : Boolean from Standard ) - is private; - - Compute3DSelection(me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - - Compute2DSelection(me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - ComputeNull2DSelection(me : mutable; - aSelection : mutable Selection from SelectMgr; - distFS : Real from Standard) - is private; - - ComputeConeAngleSelection(me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - -fields - - myNbShape : Integer from Standard; - myCenter : Pnt from gp; - myFAttach : Pnt from gp; - mySAttach : Pnt from gp; - myFDir : Dir from gp; - mySDir : Dir from gp; - myAxis : Ax1 from gp; - myCone : Face from TopoDS; - -end AngleDimension; diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx index 9736e2c597..9327a58b7b 100755 --- a/src/AIS/AIS_AngleDimension.cxx +++ b/src/AIS/AIS_AngleDimension.cxx @@ -18,25 +18,17 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - -#define BUC60655 //GG 22/03/00 Enable to compute correctly -// the arrow size at object creation time. - -#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size -// if any in all dimensions. - -#include - -#include +#include #include +#include #include #include - +#include #include #include #include -#include +#include #include #include @@ -44,9 +36,17 @@ #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include #include #include @@ -58,1978 +58,972 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include - +#include #include - #include - -#include #include +#include #include - +#include +#include #include #include #include #include +#include +#include +#include +#include +#include #include - #include #include #include #include #include - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - +IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) +IMPLEMENT_STANDARD_RTTIEXT (AIS_AngleDimension, AIS_Dimension) //======================================================================= -//function : Constructor -//purpose : ConeAngle dimension +//function : init +//purpose : Private constructor for default initialization //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aCone, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide /*aSymbolPrs*/, - const Standard_Real anArrowSize): -myNbShape(1) +void AIS_AngleDimension::init() { - myCone = aCone; - myVal = aVal; - myText = aText; - myPosition = aPosition; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif + // Default values of units + UnitsAPI::SetLocalSystem (UnitsAPI_SI); + SetUnitsQuantity ("PLANE ANGLE"); + SetModelUnits ("rad"); + SetDisplayUnits ("deg"); + SetSpecialSymbol (0x00B0); + SetDisplaySpecialSymbol (AIS_DSS_After); + MakeUnitsDisplayed (Standard_False); } //======================================================================= //function : Constructor -//purpose : ConeAngle dimension +//purpose : Two edges dimension //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aCone, - const Standard_Real aVal, - const TCollection_ExtendedString& aText): -myNbShape(1) +AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge) +: AIS_Dimension(), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -//#ifdef DEB - cout << "Call new AngleDimension for cone's angle" << endl; -//#endif - - gp_Pnt tmpPnt(0., 0., 0.); - - myCone = aCone; - myVal = aVal; - myText = aText; - myPosition = tmpPnt; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - myArrowSize = 0.0; - + init(); + myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstShape = theFirstEdge; + mySecondShape = theSecondEdge; } - //======================================================================= //function : Constructor -//purpose : TwoEdgesAngle dimension +//purpose : Two edges dimension +// is used in case of Angle=PI //======================================================================= - -AIS_AngleDimension::AIS_AngleDimension(const TopoDS_Edge& aFirstEdge, - const TopoDS_Edge& aSecondEdge, - const Handle (Geom_Plane)& aPlane, - const Standard_Real aVal, - const TCollection_ExtendedString& aText) -:AIS_Relation(), - myNbShape(2) +AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge, + const gp_Pln& thePlane) +: AIS_Dimension(), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for edges, default" << endl; -#endif - - myFShape = aFirstEdge; - mySShape = aSecondEdge; - myVal = aVal; - myPlane = aPlane; - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - myArrowSize = myVal / 100.; + init(); + myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstShape = theFirstEdge; + mySecondShape = theSecondEdge; + SetWorkingPlane (thePlane); } //======================================================================= //function : Constructor -//purpose : TwoEdgesAngle dimension (avec position et texte) +//purpose : Two edges dimension with aspect +// is used in case of Angle=PI //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Edge& aFirstEdge, - const TopoDS_Edge& aSecondEdge, - const Handle (Geom_Plane)& aPlane, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Real anArrowSize): -myNbShape(2) +AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge, + const gp_Pln& thePlane, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize) +: AIS_Dimension (theDimensionAspect,theExtensionSize), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for edges" << endl; -#endif - - myFShape = aFirstEdge; - mySShape = aSecondEdge; - myVal = aVal; - myPlane = aPlane; - myText = aText; - mySymbolPrs = aSymbolPrs; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myPosition = aPosition; - + myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstShape = theFirstEdge; + mySecondShape = theSecondEdge; + SetWorkingPlane (thePlane); } //======================================================================= //function : Constructor -//purpose : TwoPlanarFacesAngle dimension +//purpose : Three points dimension //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aFirstFace, - const TopoDS_Face& aSecondFace, - const gp_Ax1& anAxis, - const Standard_Real aVal, - const TCollection_ExtendedString& aText): -myNbShape(2), -myAxis(anAxis) +AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theThirdPoint) +: AIS_Dimension(), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for planar faces, default" << endl; -#endif - - myFShape = aFirstFace; - mySShape = aSecondFace; - - AIS::GetPlaneFromFace( aFirstFace, myFirstPlane, myFirstBasisSurf, myFirstSurfType, myFirstOffset ); - AIS::GetPlaneFromFace( aSecondFace, mySecondPlane, mySecondBasisSurf, mySecondSurfType, mySecondOffset ); - -//POP init champ myPlane - myPlane = new Geom_Plane(myFirstPlane); - - myVal = aVal; - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - myArrowSize = myVal / 100.; + init(); + myIsInitialized = Standard_True; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstPoint = theFirstPoint; + myCenter = theSecondPoint; + mySecondPoint = theThirdPoint; + myShapesNumber = 3; } //======================================================================= //function : Constructor -//purpose : TwoPlanarFacesAngle dimension (avec position et texte) +//purpose : Three points dimension //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aFirstFace, - const TopoDS_Face& aSecondFace, - const gp_Ax1& anAxis, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Real anArrowSize): -myNbShape(2), -myAxis(anAxis) +AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theThirdPoint, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize) +: AIS_Dimension (theDimensionAspect,theExtensionSize), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for planar faces" << endl; -#endif - - myFShape = aFirstFace; - mySShape = aSecondFace; - - AIS::GetPlaneFromFace( aFirstFace, myFirstPlane, myFirstBasisSurf, myFirstSurfType, myFirstOffset ); - AIS::GetPlaneFromFace( aSecondFace, mySecondPlane, mySecondBasisSurf, mySecondSurfType, mySecondOffset ); - -//POP init champ myPlane - myPlane = new Geom_Plane(myFirstPlane); - - myVal = aVal; - myText = aText; - mySymbolPrs = aSymbolPrs; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myPosition = aPosition; + myIsInitialized = Standard_True; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstPoint = theFirstPoint; + myCenter = theSecondPoint; + mySecondPoint = theThirdPoint; + myShapesNumber =3; } - //======================================================================= -//function : AIS_AngleDimension -//purpose : Two curvilinear faces dimension +//function : Constructor +//purpose : Cone dimension //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aFFace, - const TopoDS_Face& aSFace, - const Standard_Real aVal, - const TCollection_ExtendedString& aText ): -myNbShape(2) +AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone) +: AIS_Dimension(), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for curvilinear faces, default" << endl; -#endif - - SetFirstShape( aFFace ); - SetSecondShape( aSFace ); - myVal = aVal; - - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - myArrowSize = myVal / 100.; + init(); + myIsInitialized = Standard_False; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstShape = theCone; + myShapesNumber = 1; } //======================================================================= -//function : AIS_AngleDimension -//purpose : +//function : Constructor +//purpose : Two faces dimension //======================================================================= -AIS_AngleDimension::AIS_AngleDimension( const TopoDS_Face& aFFace, - const TopoDS_Face& aSFace, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Real anArrowSize): -myNbShape(2) +AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, + const TopoDS_Face& theSecondFace, + const gp_Ax1& theAxis) +: AIS_Dimension(), + myIsFlyoutLines (Standard_True), + myFlyout (15.0) { -#ifdef DEB - cout << endl << "Call new AngleDimension for curvilinear faces" << endl; -#endif - - SetFirstShape( aFFace ); - SetSecondShape( aSFace ); - myVal = aVal; - - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - mySymbolPrs = aSymbolPrs; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myPosition = aPosition; + init(); + myIsInitialized = Standard_False; + SetKindOfDimension (AIS_KOD_PLANEANGLE); + myFirstShape = theFirstFace; + mySecondShape = theSecondFace; + myShapesNumber = 2; + gp_Pln aPlane; + aPlane.SetAxis (theAxis); + SetWorkingPlane (aPlane); } - //======================================================================= -//function : SetConeFace +//function : SetFirstShape //purpose : //======================================================================= -void AIS_AngleDimension::SetConeFace( const TopoDS_Face& aConeFace ) +void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape, + const Standard_Boolean isSingleShape /*= Standard_False*/) { - myCone = aConeFace; - myAutomaticPosition = Standard_True; + AIS_Dimension::SetFirstShape (theShape); + if (isSingleShape) + myShapesNumber = 1; } - //======================================================================= -//function : SetFirstShape -//purpose : +//function : aboveInBelowCone +//purpose : Returns 1 if center is above of center; +// 0 if center is between and +// centers; +// -1 if center is below center. //======================================================================= -void AIS_AngleDimension::SetFirstShape( const TopoDS_Shape& aFShape ) +Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax, + const gp_Circ &theCMin, + const gp_Circ &theC) { - myFShape = aFShape; - - if (myFShape.ShapeType() == TopAbs_FACE) - { - AIS::GetPlaneFromFace( TopoDS::Face( myFShape ), - myFirstPlane, - myFirstBasisSurf, - myFirstSurfType, - myFirstOffset ); - - if (myFirstSurfType == AIS_KOS_Cylinder) - myAxis = (Handle( Geom_CylindricalSurface )::DownCast( myFirstBasisSurf ))->Cylinder().Axis(); - else if (myFirstSurfType == AIS_KOS_Cone) - myAxis = (Handle( Geom_ConicalSurface )::DownCast( myFirstBasisSurf ))->Cone().Axis(); - else if (myFirstSurfType == AIS_KOS_Revolution) - myAxis = (Handle( Geom_SurfaceOfRevolution )::DownCast( myFirstBasisSurf ))->Axis(); - else if (myFirstSurfType == AIS_KOS_Extrusion) - { - myAxis.SetDirection((Handle( Geom_SurfaceOfLinearExtrusion )::DownCast( myFirstBasisSurf )) - ->Direction() ); - //myAxis.SetLocation( ??? ); - } - } + const Standard_Real aD = theCMax.Location().Distance (theCMin.Location()); + const Standard_Real aD1 = theCMax.Location().Distance (theC.Location()); + const Standard_Real aD2 = theCMin.Location().Distance (theC.Location()); + + if (aD >= aD1 && aD >= aD2) return 0; + if (aD < aD2 && aD1 < aD2) return -1; + if (aD < aD1 && aD2 < aD1) return 1; + return 0; } //======================================================================= -//function : SetSecondShape -//purpose : +//function : initConeAngle +//purpose : initialization of the cone angle //======================================================================= -void AIS_AngleDimension::SetSecondShape( const TopoDS_Shape& aSShape ) +Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone) { - mySShape = aSShape; - - if (myFShape.ShapeType() == TopAbs_FACE) - AIS::GetPlaneFromFace( TopoDS::Face( mySShape ), - mySecondPlane, - mySecondBasisSurf, - mySecondSurfType, - mySecondOffset ); -} - - + if (theCone.IsNull ()) + return Standard_False; + gp_Pln aPln; + gp_Cone aCone; + gp_Circ aCircle; + // A surface from the Face + Handle(Geom_Surface) aSurf; + Handle(Geom_OffsetSurface) aOffsetSurf; + Handle(Geom_ConicalSurface) aConicalSurf; + Handle(Geom_SurfaceOfRevolution) aRevSurf; + Handle(Geom_Line) aLine; + BRepAdaptor_Surface aConeAdaptor (theCone); + TopoDS_Face aFace; + AIS_KindOfSurface aSurfType; + Standard_Real anOffset = 0.; + Handle(Standard_Type) aType; -///======================================================================= -//function : Compute -//purpose : -//======================================================================= + Standard_Real aMaxV = aConeAdaptor.FirstVParameter(); + Standard_Real aMinV = aConeAdaptor.LastVParameter(); -void AIS_AngleDimension::Compute(const Handle(PrsMgr_PresentationManager3d)&, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer) -{ - aPresentation->Clear(); + AIS::GetPlaneFromFace(theCone, aPln, aSurf, aSurfType, anOffset); - if( myNbShape == 1 ) - { - // cout << "Computing for cone' angle " << endl; - ComputeConeAngle(aPresentation); - return; - } - switch (myFShape.ShapeType()) { - case TopAbs_FACE : - { - // cas angle entre deux faces - ComputeTwoFacesAngle(aPresentation); - } - break; - case TopAbs_EDGE : + if (aSurfType == AIS_KOS_Revolution) + { + // Surface of revolution + aRevSurf = Handle(Geom_SurfaceOfRevolution)::DownCast(aSurf); + gp_Lin aLin (aRevSurf->Axis()); + Handle(Geom_Curve) aBasisCurve = aRevSurf->BasisCurve(); + //Must be a part of line (basis curve should be linear) + if (aBasisCurve ->DynamicType() != STANDARD_TYPE(Geom_Line)) + return Standard_False; + + gp_Pnt aFirst1 = aConeAdaptor.Value (0., aMinV); + gp_Pnt aLast1 = aConeAdaptor.Value (0., aMaxV); + gp_Vec aVec1 (aFirst1, aLast1); + + //Projection on + gp_Pnt aFirst2 = ElCLib::Value (ElCLib::Parameter (aLin, aFirst1), aLin); + // Projection on + gp_Pnt aLast2 = ElCLib::Value (ElCLib::Parameter (aLin, aLast1), aLin); + + gp_Vec aVec2 (aFirst2, aLast2); + + // Check if two parts of revolution are parallel (it's a cylinder) or normal (it's a circle). + if (aVec1.IsParallel (aVec2, Precision::Angular()) + || aVec1.IsNormal (aVec2,Precision::Angular())) + return Standard_False; + + gce_MakeCone aMkCone (aRevSurf->Axis(), aFirst1, aLast1); + aCone = aMkCone.Value(); + myCenter = aCone.Apex(); + } + else + { + aType = aSurf->DynamicType(); + if (aType == STANDARD_TYPE(Geom_OffsetSurface) || anOffset > 0.01) { - // cas angle entre deux edges - ComputeTwoEdgesAngle(aPresentation); + // Offset surface + aOffsetSurf = new Geom_OffsetSurface (aSurf, anOffset); + aSurf = aOffsetSurf->Surface(); + BRepBuilderAPI_MakeFace aMkFace(aSurf, Precision::Confusion()); + aMkFace.Build(); + if (!aMkFace.IsDone()) + return Standard_False; + aConeAdaptor.Initialize (aMkFace.Face()); } - break; - default: - break; + aCone = aConeAdaptor.Cone(); + aConicalSurf = Handle(Geom_ConicalSurface)::DownCast (aSurf); + myCenter = aConicalSurf->Apex(); } - -} - -//======================================================================= -//function : Compute -//purpose : : to avoid warning -//======================================================================= -void AIS_AngleDimension::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) -{ -// Standard_NotImplemented::Raise("AIS_AngleDimension::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; -} + // A circle where the angle is drawn + Handle(Geom_Curve) aCurve; + Standard_Real aMidV = ( aMinV + aMaxV ) / 2.5; + aCurve = aSurf->VIso (aMidV); + aCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ(); -void AIS_AngleDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) -{ -// Standard_NotImplemented::Raise("AIS_AngleDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; -} + aCurve = aSurf->VIso(aMaxV); + gp_Circ aCircVmax = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); + aCurve = aSurf->VIso(aMinV); + gp_Circ aCircVmin = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); -//======================================================================= -//function : ComputeSelection -//purpose : -//======================================================================= - -void AIS_AngleDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer) -{ - if ( myNbShape == 1 ) - { - // cout << "Computing selection for cone's angle " << endl; - ComputeConeAngleSelection(aSelection); - return; - } - - - if (myFShape.IsNull()) return; + if (aCircVmax.Radius() < aCircVmin.Radius()) + { + gp_Circ aTmpCirc = aCircVmax; + aCircVmax = aCircVmin; + aCircVmin = aTmpCirc; + } - if (myFShape.ShapeType() == TopAbs_FACE ) - Compute3DSelection(aSelection); - else - Compute2DSelection(aSelection); - - // Text - Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 ); - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + size, - myPosition.Y() + size, - myPosition.Z() + size); - aSelection->Add(box); + myFirstPoint = ElCLib::Value (0, aCircle); + mySecondPoint = ElCLib::Value (M_PI, aCircle); + return Standard_True; } //======================================================================= -//function : ComputeConeAngle -//purpose : +//function : initTwoFacesAngle +//purpose : initialization of angle dimension between two faces //======================================================================= -void AIS_AngleDimension::ComputeConeAngle(const Handle(Prs3d_Presentation)& aPresentation) +Standard_Boolean AIS_AngleDimension::initTwoFacesAngle () { - if( myCone.IsNull() ) return; + TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape); + TopoDS_Face aSecondFace = TopoDS::Face (mySecondShape); + gp_Dir aFirstDir, aSecondDir; + gp_Pln aFirstPlane, aSecondPlane; + Handle(Geom_Surface) aFirstBasisSurf, aSecondBasisSurf; + AIS_KindOfSurface aFirstSurfType, aSecondSurfType; + Standard_Real aFirstOffset, aSecondOffset; - gp_Pln aPln; - gp_Cone aCone; - gp_Circ myCircle; - gp_Pnt Apex; - Handle( Geom_Surface ) aSurf; //a surface from the Face - Handle( Geom_OffsetSurface ) aOffsetSurf; - Handle( Geom_ConicalSurface ) aConicalSurf; - Handle( Geom_SurfaceOfRevolution ) aRevSurf; - Handle( Geom_Line ) aLine; - BRepAdaptor_Surface tmpSurf(myCone); - TopoDS_Face aFace; - AIS_KindOfSurface aSurfType; - Standard_Real Offset = 0. ; - Handle( Standard_Type ) aType; - - Standard_Real maxV = tmpSurf.FirstVParameter(); - Standard_Real minV = tmpSurf.LastVParameter(); - - - AIS::GetPlaneFromFace( myCone, aPln, aSurf, aSurfType, Offset ); - - if ( aSurfType == AIS_KOS_Revolution ) { //surface of revolution - - aRevSurf = Handle( Geom_SurfaceOfRevolution )::DownCast( aSurf ); - gp_Lin ln( aRevSurf->Axis() ); - Handle( Geom_Curve ) tmpCrv = aRevSurf->BasisCurve(); - if ( tmpCrv ->DynamicType() != STANDARD_TYPE(Geom_Line) ) return; //Must be a part of line - - Standard_Real par; - gp_Pnt fst = tmpSurf.Value(0., minV); - gp_Pnt lst = tmpSurf.Value(0., maxV); - - gp_Vec vec1(fst, lst); - - par = ElCLib::Parameter( ln, fst ); - gp_Pnt fst2 = ElCLib::Value( par, ln ); //projection fst on ln - par = ElCLib::Parameter( ln, lst ); - gp_Pnt lst2 = ElCLib::Value( par, ln ); //projection lst on ln - - gp_Vec vec2(fst2, lst2); - - // Check if two parts of revolution are parallel ( it's a cylinder ) or normal (it's a circle ) - if( vec1.IsParallel( vec2,Precision::Angular() ) || vec1.IsNormal( vec2,Precision::Angular() ) ) return; - - gce_MakeCone mkCone(aRevSurf->Axis(), fst, lst); - aCone = mkCone.Value(); - Apex = aCone.Apex(); - } - else { - aType = aSurf->DynamicType(); - if ( aType == STANDARD_TYPE(Geom_OffsetSurface) || Offset > 0.01 ) { //offset surface - aOffsetSurf = new Geom_OffsetSurface (aSurf, Offset); - aSurf = aOffsetSurf->Surface(); - BRepBuilderAPI_MakeFace mkFace(aSurf, Precision::Confusion()); - mkFace.Build(); - if( !mkFace.IsDone() ) return; - tmpSurf.Initialize( mkFace.Face() ); - } - - aCone = tmpSurf.Cone(); - aConicalSurf = Handle( Geom_ConicalSurface)::DownCast( aSurf ); - Apex = aConicalSurf->Apex(); - } - - Handle(Geom_Curve) aCurve; //A circle where the angle is drawn - if ( myAutomaticPosition ) { - Standard_Real midV = ( minV + maxV ) / 2.5; - - aCurve = aSurf->VIso(midV); - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - - myPosition = ElCLib::Value(M_PI / 2.0, myCircle); - myAutomaticPosition = Standard_False; - } - else { - Standard_Real U, V; - ElSLib::Parameters(aCone, myPosition, U, V); - aCurve = aSurf->VIso(V); - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); + AIS::GetPlaneFromFace (aFirstFace, aFirstPlane, + aFirstBasisSurf,aFirstSurfType,aFirstOffset); + AIS::GetPlaneFromFace (aSecondFace, aSecondPlane, + aSecondBasisSurf, aSecondSurfType, aSecondOffset); + + if (aFirstSurfType == AIS_KOS_Plane) + { + //Planar faces angle + AIS::ComputeAngleBetweenPlanarFaces (aFirstFace, + aSecondFace, + aSecondBasisSurf, + GetWorkingPlane().Axis(), + myValue, + Standard_True, + myGeom.myTextPosition, + myCenter, + myFirstPoint, + mySecondPoint, + aFirstDir, + aSecondDir); } - - //__________________________________________________________________ - aCurve = aSurf->VIso(maxV); - gp_Circ CircVmax = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - aCurve = aSurf->VIso(minV); - gp_Circ CircVmin = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - //__________________________________________________________________ - - if( CircVmax.Radius() < CircVmin.Radius() ) { - gp_Circ tmpCirc = CircVmax; - CircVmax = CircVmin; - CircVmin = tmpCirc; + else + { + // Curvilinear faces angle + Handle(Geom_Plane) aPlane = new Geom_Plane (GetWorkingPlane()); + AIS::ComputeAngleBetweenCurvilinearFaces (aFirstFace, + aSecondFace, + aFirstBasisSurf, + aSecondBasisSurf, + aFirstSurfType, + aSecondSurfType, + GetWorkingPlane().Axis(), + myValue, + Standard_True, + myGeom.myTextPosition, + myCenter, + myFirstPoint, + mySecondPoint, + aFirstDir, + aSecondDir, + aPlane); + SetWorkingPlane (aPlane->Pln()); } - - DsgPrs_AnglePresentation::Add(aPresentation, myDrawer, myVal, - myText, myCircle, myPosition, Apex, CircVmin, CircVmax, myArrowSize); -// cout << "ComputeConeAngle is over" << endl; + return Standard_True; } - //======================================================================= -//function : ComputeTwoFacesAngle +//function : SetFlyout //purpose : //======================================================================= -void AIS_AngleDimension::ComputeTwoFacesAngle(const Handle(Prs3d_Presentation)& aPresentation) +void AIS_AngleDimension::SetFlyout (const Standard_Real theFlyout) { - if (myFirstSurfType == AIS_KOS_Plane) - ComputeTwoPlanarFacesAngle( aPresentation ); - else - ComputeTwoCurvilinearFacesAngle( aPresentation ); + myFlyout = theFlyout; } //======================================================================= -//function : ComputeTwoCurvilinearFacesAngle +//function : GetFlyout //purpose : //======================================================================= -void AIS_AngleDimension::ComputeTwoCurvilinearFacesAngle(const Handle(Prs3d_Presentation)& aPresentation) +Standard_Real AIS_AngleDimension::GetFlyout () const { - AIS::ComputeAngleBetweenCurvilinearFaces( TopoDS::Face( myFShape ), - TopoDS::Face( mySShape ), - myFirstBasisSurf, - mySecondBasisSurf, - myFirstSurfType, - mySecondSurfType, - myAxis, - myVal, - myAutomaticPosition, - myPosition, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - myPlane ); - if (myAutomaticPosition && myIsSetBndBox) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCenter, myPosition ) ), myBndBox ); - - Handle(Prs3d_AngleAspect) la = myDrawer->AngleAspect(); - Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { -#endif - Standard_Real arrsize = myCenter.Distance( myPosition ); - - if ( (myArrowSize-arrsize) < 0.1 ) arrsize = myArrowSize; - if (arrsize == 0.) arrsize = 1.; -#ifdef BUC60915 - myArrowSize = arrsize; - } - arr->SetLength( myArrowSize ); -#else - arr->SetLength(arrsize); -#endif - - - if (myVal <= Precision::Angular() || Abs( M_PI-myVal ) <= Precision::Angular()) - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - myPlane->Pln().Axis().Direction(), - Standard_False, // not plane - myAxis, - myPosition, - mySymbolPrs); - else - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - myFDir ^ mySDir, - Standard_False, // not plane - myAxis, - myPosition, - mySymbolPrs); + return myFlyout; } //======================================================================= -//function : ComputeTwoPlanarFacesAngle +//function : countDefaultPlane //purpose : //======================================================================= -void AIS_AngleDimension::ComputeTwoPlanarFacesAngle( const Handle( Prs3d_Presentation )& aPresentation ) +void AIS_AngleDimension::countDefaultPlane () { - AIS::ComputeAngleBetweenPlanarFaces( TopoDS::Face( myFShape ), - TopoDS::Face( mySShape ), - mySecondBasisSurf, - myAxis, - myVal, - myAutomaticPosition, - myPosition, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir ); - if (myAutomaticPosition && myIsSetBndBox) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCenter, myPosition ) ), myBndBox ); - - Handle(Prs3d_AngleAspect) la = myDrawer->AngleAspect(); - Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { -#endif - Standard_Real arrsize = myCenter.Distance( myPosition ); - - if ( (myArrowSize-arrsize) < 0.1 ) arrsize = myArrowSize; - if (arrsize == 0.) arrsize = 1.; -#ifdef BUC60915 - myArrowSize = arrsize; - } - arr->SetLength( myArrowSize ); -#else - arr->SetLength(arrsize); -#endif - - - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - myAxis.Direction(), - Standard_True, - myAxis, - myPosition, - mySymbolPrs); - + if (!myIsInitialized) + return; + // Compute normal of the default plane. + gp_Vec aVec1(myCenter, myFirstPoint), + aVec2(myCenter, mySecondPoint); + myDefaultPlane = gp_Pln(myCenter, aVec1^aVec2); + // Set computed value to + ResetWorkingPlane (); } //======================================================================= -//function : ComputeTwoEdgesAngle +//function : computeValue //purpose : //======================================================================= -void AIS_AngleDimension::ComputeTwoEdgesAngle(const Handle(Prs3d_Presentation)& aPresentation) +void AIS_AngleDimension::computeValue () { - BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); - BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape)); - if ((cu1.GetType() != GeomAbs_Line) || (cu2.GetType() != GeomAbs_Line)) return; - - // current face - BRepBuilderAPI_MakeFace makeface(myPlane->Pln()); - TopoDS_Face face(makeface.Face()); - BRepAdaptor_Surface adp(makeface.Face()); - - // 3d lines - Handle(Geom_Line) geom_lin1,geom_lin2; - gp_Pnt ptat11,ptat12,ptat21,ptat22;//,pint3d; - Standard_Boolean isInfinite1,isInfinite2; - Handle(Geom_Curve) extCurv; - Standard_Integer copyOfMyExtShape = myExtShape; - if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape), - TopoDS::Edge(mySShape), - myExtShape, - geom_lin1, - geom_lin2, - ptat11, - ptat12, - ptat21, - ptat22, - extCurv, - isInfinite1, - isInfinite2, - myPlane)) { - return; - } - // Temporary: computation of myVal - // myVal = Abs(geom_lin1->Lin().Angle( geom_lin2->Lin())); // Pb with angles JPR - - if (copyOfMyExtShape != 0) myExtShape = copyOfMyExtShape; - - // 2d lines => projection of 3d on current plane - -//POP pour NT - Handle(Geom2d_Curve) geoC1 = GeomAPI::To2d(geom_lin1,myPlane->Pln()); - Handle(Geom2d_Line) lin1_2d = *((Handle(Geom2d_Line)*)& geoC1); - Handle(Geom2d_Curve) geoC2 = GeomAPI::To2d(geom_lin2,myPlane->Pln()); - Handle(Geom2d_Line) lin2_2d = *((Handle(Geom2d_Line)*)& geoC2); - -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { -#endif - Standard_Real arrSize1(myArrowSize),arrSize2(myArrowSize); - if (!isInfinite1) arrSize1 = ptat11.Distance(ptat12)/100.; - if (!isInfinite2) arrSize2 = ptat21.Distance(ptat22)/100.; -#ifdef BUC60655 - myArrowSize = Min(myArrowSize,Max(arrSize1,arrSize2)); -#else - myArrowSize = Min(myArrowSize,Min(arrSize1,arrSize2)); -#endif -#ifdef BUC60915 - } -#endif - - - // Processing in case of 2 parallel straight lines - if (lin1_2d->Lin2d().Direction() - .IsParallel(lin2_2d->Lin2d().Direction(),Precision::Angular())) { - ComputeTwoEdgesNullAngle(aPresentation, - geom_lin1, - geom_lin2, - ptat11,ptat12, - ptat21,ptat22, - isInfinite1,isInfinite2); - } - - // Processing in case of 2 non-parallel straight lines - else { - ComputeTwoEdgesNotNullAngle(aPresentation, - geom_lin1, - geom_lin2, - ptat11, - ptat12, - ptat21, - ptat22, - isInfinite1,isInfinite2); - } - if ( (myExtShape != 0) && !extCurv.IsNull()) { - gp_Pnt pf, pl; - if ( myExtShape == 1 ) { - if (!isInfinite1) { - pf = ptat11; - pl = ptat12; - } - aPresentation->SetInfiniteState(isInfinite1); - ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(myFShape),geom_lin1,pf,pl); - } - else { - if (!isInfinite2) { - pf = ptat21; - pl = ptat22; - } - aPresentation->SetInfiniteState(isInfinite2); - ComputeProjEdgePresentation(aPresentation,TopoDS::Edge(mySShape),geom_lin2,pf,pl); - } - } + gp_Vec aVec1 (myCenter, myFirstPoint), + aVec2 (myCenter, mySecondPoint); + myValue = aVec1.Angle (aVec2); + // To model units + AIS_Dimension::computeValue(); } - //======================================================================= -//function : ComputeTwoEdgesNotNullAngle -//purpose : +//function : initTwoEdgesAngle +//purpose : Fill gp_Pnt fields for further presentation computation +// If intersection between two edges doesn't exist +// is set to false //======================================================================= -void AIS_AngleDimension::ComputeTwoEdgesNotNullAngle(const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Geom_Line)& l1, - const Handle(Geom_Line)& l2, - const gp_Pnt& ptat11, - const gp_Pnt& ptat12, - const gp_Pnt& ptat21, - const gp_Pnt& ptat22, - const Standard_Boolean isInfinite1, - const Standard_Boolean isInfinite2) +Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle () { - // current face - BRepBuilderAPI_MakeFace makeface(myPlane->Pln()); - TopoDS_Face face(makeface.Face()); - BRepAdaptor_Surface adp(makeface.Face()); - // 2d lines => projection of 3d on current plane - Handle(Geom2d_Curve) geoC1 = GeomAPI::To2d(l1,myPlane->Pln()); - const Handle(Geom2d_Line)& l1_2d = *((Handle(Geom2d_Line)*)& geoC1); - Handle(Geom2d_Curve) geoC2 = GeomAPI::To2d(l2,myPlane->Pln()); - const Handle(Geom2d_Line)& l2_2d = *((Handle(Geom2d_Line)*)& geoC2); - - //---------------------------------------------------------- - // Computation of myCenter - //---------------------------------------------------------- - IntAna2d_AnaIntersection inter(l1_2d->Lin2d(),l2_2d->Lin2d()); - if (!inter.IsDone()) return; - if (!inter.NbPoints()) return; - - gp_Pnt2d pint(inter.Point(1).Value()); - myCenter = adp.Value(pint.X(),pint.Y()); - - //---------------------------------------------------------- - // Computation of the 2 directions - //---------------------------------------------------------- - gp_Dir d1,d2; - if (!isInfinite1) { - if (myCenter.SquareDistance(ptat11) > myCenter.SquareDistance(ptat12)) d1 = gp_Dir(gp_Vec(myCenter,ptat11)); - else d1 = gp_Dir(gp_Vec(myCenter,ptat12)); - } - else d1 = l1->Lin().Direction(); - - if (!isInfinite2) { - if (myCenter.SquareDistance(ptat21) > myCenter.SquareDistance(ptat22)) d2 = gp_Dir(gp_Vec(myCenter,ptat21)); - else d2 = gp_Dir(gp_Vec(myCenter,ptat22)); - } - else d2 = l2->Lin().Direction(); - if (!isInfinite1) { - Standard_Boolean In1(Standard_False); - Standard_Boolean In2(Standard_False); - if ( !(Abs(d1.Angle(d2) - Abs(myVal)) <= Precision::Confusion()) - && (Abs(myVal) < M_PI) ) { - Standard_Real parcent1 = ElCLib::Parameter(l1->Lin(), myCenter); - Standard_Real par11 = ElCLib::Parameter(l1->Lin(), ptat11); - Standard_Real par12 = ElCLib::Parameter(l1->Lin(), ptat12); - if ( par11 < par12) { - if ( ( parcent1> par11) && (parcent1< par12)) { - In1 = Standard_True; - d1.Reverse(); - } - } - else { - if ( ( parcent1> par12) && (parcent1< par11)) { - In1 = Standard_True; - d1.Reverse(); - } - } - if ( !In1) { - In2 = Standard_True; - d2.Reverse(); - } - } - } - - myFDir = d1; - mySDir = d2; - gp_Lin theaxis; - gp_Lin gpl1 = l1->Lin(); - gp_Lin gpl2 = l2->Lin(); - theaxis = gp_Lin(myCenter,myFDir^mySDir); + // Data initialization + TopoDS_Edge aFirstEdge = TopoDS::Edge (myFirstShape); + TopoDS_Edge aSecondEdge = TopoDS::Edge (mySecondShape); + BRepAdaptor_Curve aMakeFirstLine (aFirstEdge); + BRepAdaptor_Curve aMakeSecondLine (aSecondEdge); - if (myVal > M_PI) { - theaxis.Reverse(); - } - - gp_Pnt curpos; - TColStd_Array1OfReal tabdist(1,4); - if (!isInfinite1) { - tabdist(1) = theaxis.Distance(ptat11); - tabdist(2) = theaxis.Distance(ptat12); - } - else { - tabdist(1) = tabdist(2) = 0.; - } - - if (!isInfinite2) { - tabdist(3) = theaxis.Distance(ptat21); - tabdist(4) = theaxis.Distance(ptat22); - } - else { - tabdist(3) = tabdist(4) = 0.; + if (aMakeFirstLine.GetType() != GeomAbs_Line || aMakeSecondLine.GetType() != GeomAbs_Line) + { + return Standard_False; } - if (myAutomaticPosition) { - Standard_Real length_1(RealLast()); - if (!isInfinite1) length_1 = .75*Abs(tabdist(2)-tabdist(1))+Min(tabdist(1),tabdist(2)); - - Standard_Real length_2(RealLast()); - if (!isInfinite2) length_2 = .75*Abs(tabdist(4)-tabdist(3))+Min(tabdist(3),tabdist(4)); - Standard_Real theLength(Min(length_1,length_2)); - if (Precision::IsInfinite(theLength)) theLength = 50.; - - myFAttach = myCenter.Translated(gp_Vec(d1)*theLength); - mySAttach = myCenter.Translated(gp_Vec(d2)*theLength); - - if (!isInfinite1) { - Standard_Real par_p1_attach(ElCLib::Parameter(gpl1,myFAttach)); - Standard_Real par11 = ElCLib::Parameter(gpl1,ptat11); - Standard_Real par12 = ElCLib::Parameter(gpl1,ptat12); - if (par_p1_attach > par11 && par_p1_attach > par12) { - par_p1_attach = Max(par11,par12); - myFAttach = ElCLib::Value(par_p1_attach,gpl1); - } - else if (par_p1_attach < par11 && par_p1_attach < par12) { - par_p1_attach = Min(par11,par12); - myFAttach = ElCLib::Value(par_p1_attach,gpl1); - } - } - - if (!isInfinite2) { - Standard_Real par_p2_attach(ElCLib::Parameter(gpl2,mySAttach)); - Standard_Real par21 = ElCLib::Parameter(gpl2,ptat21); - Standard_Real par22 = ElCLib::Parameter(gpl2,ptat22); - if (par_p2_attach > par21 && par_p2_attach > par22) { - par_p2_attach = Max(par21,par22); - mySAttach = ElCLib::Value(par_p2_attach,gpl2); - } - else if (par_p2_attach < par21 && par_p2_attach < par22) { - par_p2_attach = Min(par21,par22); - mySAttach = ElCLib::Value(par_p2_attach,gpl2); - } - } - if ( myVal < M_PI) curpos.SetXYZ(.5*(myFAttach.XYZ()+mySAttach.XYZ())); - else { - curpos.SetXYZ(.5*(myFAttach.XYZ()+mySAttach.XYZ())); - gp_Vec transl(curpos, myCenter); - transl*= 2; - curpos.Translate(transl); - } + Handle(Geom_Line) aFirstLine = new Geom_Line (aMakeFirstLine.Line()); + Handle(Geom_Line) aSecondLine = new Geom_Line (aMakeSecondLine.Line()); - gp_Ax2 ax(myCenter,myFDir.Crossed(mySDir),myFDir); - gp_Circ circle(ax,theLength); - Standard_Real par = ElCLib::Parameter(circle,curpos); - curpos = ElCLib::Value(par,circle); - - // small offset like in LengthDimension - gp_Vec transl(myCenter, curpos); - transl*= 0.3; - curpos.Translate(transl); - - if (myIsSetBndBox) - curpos = AIS::TranslatePointToBound( curpos, gp_Dir( gp_Vec( myCenter, curpos ) ), myBndBox ); - - myPosition = curpos; - myAutomaticPosition = Standard_True; + gp_Lin aFirstLin = aFirstLine->Lin (); + gp_Lin aSecondLin = aSecondLine->Lin (); + gp_Lin2d aFirstLin2d, aSecondLin2d; + Standard_Boolean isParallelLines = aFirstLin.Direction().IsParallel (aSecondLin.Direction(), Precision::Angular()); + Standard_Boolean isSameLines = isParallelLines && aFirstLin.Distance (aSecondLin.Location()) <= Precision::Confusion(); + // In case where we can't compute plane automatically + if ((isParallelLines || isSameLines) && !myIsWorkingPlaneCustom) + { + return Standard_False; } - else { - // point is projected on the plane - gp_Pnt2d pointOnPln(ProjLib::Project(myPlane->Pln(),myPosition)); - myPosition = BRepAdaptor_Surface(BRepBuilderAPI_MakeFace(myPlane->Pln()).Face()).Value(pointOnPln.X(),pointOnPln.Y()); - curpos = myPosition; - Standard_Real dist(curpos.Distance(myCenter)); - if (dist<=Precision::Confusion()) { - gp_XYZ delta(1.,1.,1.); - curpos.SetXYZ(curpos.XYZ()+delta); - dist = curpos.Distance(myCenter); - } - // To learn if it is necessary to take distance -dist or not - // it is necessary to know if we are in the sector opposite to the angle - // if not : we are in the opposite sector if the coordinates - // of curpos in point (d1,d2) are negative - gp_Ax2 ax(myCenter,myFDir.Crossed(mySDir),myFDir); - gp_Circ circle(ax,dist); -#ifdef DEB -// gp_Pnt p1(myCenter.Translated(gp_Vec(d1)*dist)); -#endif - gp_Pnt p2(myCenter.Translated(gp_Vec(d2)*dist)); - Standard_Real uc1 = 0; - Standard_Real uc2 = ElCLib::Parameter(circle, p2 ); - Standard_Real uco = ElCLib::Parameter(circle, curpos ); - Standard_Real udeb = uc1; - Standard_Real ufin = uc2; - if (uco > ufin) { - if (Abs(myVal) udeb+M_PI && uco < ufin+M_PI){ - dist = -dist; - } - } - } - - gp_Pnt p1_attach(myCenter.Translated(gp_Vec(d1)*dist)); - gp_Pnt p2_attach(myCenter.Translated(gp_Vec(d2)*dist)); - - if (!isInfinite1) { - Standard_Real par_p1_attach(ElCLib::Parameter(gpl1,p1_attach)); - Standard_Real par11 = ElCLib::Parameter(gpl1,ptat11); - Standard_Real par12 = ElCLib::Parameter(gpl1,ptat12); - if (par_p1_attach > par11 && par_p1_attach > par12) { - par_p1_attach = Max(par11,par12); - p1_attach = ElCLib::Value(par_p1_attach,gpl1); - } - else if (par_p1_attach < par11 && par_p1_attach < par12) { - par_p1_attach = Min(par11,par12); - p1_attach = ElCLib::Value(par_p1_attach,gpl1); - } - } - myFAttach = p1_attach; - - if (!isInfinite2) { - Standard_Real par_p2_attach(ElCLib::Parameter(gpl2,p2_attach)); - Standard_Real par21 = ElCLib::Parameter(gpl2,ptat21); - Standard_Real par22 = ElCLib::Parameter(gpl2,ptat22); - if (par_p2_attach > par21 && par_p2_attach > par22) { - par_p2_attach = Max(par21,par22); - p2_attach = ElCLib::Value(par_p2_attach,gpl2); - } - else if (par_p2_attach < par21 && par_p2_attach < par22) { - par_p2_attach = Min(par21,par22); - p2_attach = ElCLib::Value(par_p2_attach,gpl2); - } - } - mySAttach = p2_attach; - } - myAxis = theaxis.Position(); - - //-------------------------------------------------------- - // Computation of the presentation - //-------------------------------------------------------- - Handle(Prs3d_AngleAspect) la = myDrawer->AngleAspect(); - Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); - - arr->SetLength(myArrowSize); - - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - curpos, - mySymbolPrs); -} - - - -//======================================================================= -//function : ComputeTwoEdgesNullAngle -//purpose : compute the presentation of a angle dimension if it's null. -// -> the aim of the computation is to have a constant radius -// during the dimension moving : the radius is independant -// of the cursor position, it's equal to a arbitrary value -//======================================================================= + gp_Pln aPlane; -void AIS_AngleDimension::ComputeTwoEdgesNullAngle(const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Geom_Line)& l1, - const Handle(Geom_Line)& l2, - const gp_Pnt& ptat11, - const gp_Pnt& ptat12, - const gp_Pnt& ptat21, - const gp_Pnt& ptat22, - const Standard_Boolean isInfinite1, - const Standard_Boolean isInfinite2) -{ - // current face - BRepBuilderAPI_MakeFace makeface(myPlane->Pln()); - TopoDS_Face face(makeface.Face()); - BRepAdaptor_Surface adp(makeface.Face()); - // 2d lines => projection of 3d on current plane - Handle(Geom2d_Curve) geoC1 = GeomAPI::To2d(l1,myPlane->Pln()); - Handle(Geom2d_Line) l1_2d = *((Handle(Geom2d_Line)*)& geoC1); - Handle(Geom2d_Curve) geoC2 = GeomAPI::To2d(l2,myPlane->Pln()); - Handle(Geom2d_Line) l2_2d = *((Handle(Geom2d_Line)*)& geoC2); - - gp_Lin gpl1 = l1->Lin(); - gp_Lin gpl2 = l2->Lin(); - - //------------------------------------------------------------ - // Computation of myCenter - // -> Point located on the median of 2 straight lines, - // is calculated as located between 2 closest points - // of each straight line. - //----------------------------------------------------------- - // theLength : radius of the future circle - Standard_Real theLength = gpl1.Distance(gpl2.Location()); - // processing of the particular case when 2 straight lines are coincident - Standard_Boolean SameLines(Standard_False); - if ( theLength <= Precision::Confusion()) { - SameLines = Standard_True; - if (!isInfinite1) { - if (!isInfinite2) theLength = 0.75 * Max( ptat11.Distance(ptat12), ptat21.Distance(ptat22)); - else theLength = 0.75*ptat11.Distance(ptat12); - } - else { - if (!isInfinite2) theLength = 0.75*ptat21.Distance(ptat22); - else theLength = 50.; - } - } - else theLength = theLength*8/10; - - gp_Pnt pmin1 ,pmin2; - if (!isInfinite1 && !isInfinite2) { - pmin1 = ptat11; pmin2 = ptat21; - Standard_Real dis = ptat11.Distance(ptat21); - Standard_Real dis2 = ptat11.Distance(ptat22); - if ( dis2 < dis) { - pmin1 = ptat11; - pmin2 = ptat22; - dis = dis2; - } - dis2 = ptat12.Distance(ptat22); - if ( dis2 < dis) { - pmin1 = ptat12; - pmin2 = ptat22; - dis = dis2; - } - dis2 = ptat12.Distance(ptat21); - if ( dis2 < dis) { - pmin1 = ptat12; - pmin2 = ptat21; - dis = dis2; - } - myCenter.SetXYZ( (pmin1.XYZ() + pmin2.XYZ()) / 2. ); + /// PART 1 is for automatic plane computation from two edges if it is possible + // Build plane + if (!myIsWorkingPlaneCustom) + { + gp_Pnt aPoint = aFirstLine->Value (0.); + gp_Dir aNormal = isParallelLines + ? gp_Vec(aSecondLin.Normal (aPoint).Direction()) ^ gp_Vec (aSecondLin.Direction()) + : gp_Vec (aFirstLin.Direction()) ^ gp_Vec (aSecondLin.Direction()); + aPlane = gp_Pln (aPoint, aNormal); + resetWorkingPlane (aPlane); } - else { - gp_Pnt pntOnl1 = gpl1.Location(); - gp_Pnt pntOnl2 = ElCLib::Value(ElCLib::Parameter(gpl1,pntOnl1),gpl2); - myCenter.SetXYZ( (pntOnl1.XYZ() + pntOnl2.XYZ()) / 2. ); + else + { + aPlane = GetWorkingPlane(); } - - // directions - gp_Dir d1,d2; - if (!isInfinite1) { - if (myCenter.SquareDistance(ptat11) > myCenter.SquareDistance(ptat12)) d1 = gp_Dir(gp_Vec(myCenter,ptat11)); - else d1 = gp_Dir(gp_Vec(myCenter,ptat12)); - } - else d1 = gpl1.Direction(); - - if (!isInfinite2) { - if (myCenter.SquareDistance(ptat21) > myCenter.SquareDistance(ptat22)) d2 = gp_Dir(gp_Vec(myCenter,ptat21)); - else d2 = gp_Dir(gp_Vec(myCenter,ptat22)); - } - else d2 = gpl2.Direction(); - - gp_Dir theaxis; - if ( SameLines ) theaxis = myPlane->Pln().Axis().Direction(); - else { - theaxis = gp_Dir(d1^d2); - gp_Vec V1(d1); gp_Vec V2(d2); - if ( V1.CrossMagnitude(V2) < 0 ) theaxis.Reverse(); + // Compute geometry for this plane and edges + Standard_Boolean isInfinite1,isInfinite2; + gp_Pnt aFirstPoint1, aLastPoint1, aFirstPoint2, aLastPoint2; + Standard_Integer anExtIndex = -1; + Handle(Geom_Curve) anExtCurve; + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane); + if (!AIS::ComputeGeometry (aFirstEdge, aSecondEdge, + anExtIndex, + aFirstLine, aSecondLine, + aFirstPoint1, aLastPoint1, + aFirstPoint2, aLastPoint2, + anExtCurve, + isInfinite1, isInfinite2, + aGeomPlane)) + { + return Standard_False; } - gp_Pnt curpos; // cursor position - TColStd_Array1OfReal tabdist(1,4); - gp_Pnt P1, P2; // points at intersection of the circle with 2 straight lines - - if (myAutomaticPosition) { - if (!isInfinite1) { - tabdist(1) = myCenter.Distance(ptat11); - tabdist(2) = myCenter.Distance(ptat12); - } - else { - tabdist(1) = tabdist(2) = 0.; - } - if (!isInfinite2) { - tabdist(3) = myCenter.Distance(ptat21); - tabdist(4) = myCenter.Distance(ptat22); - } - else { - tabdist(3) = tabdist(4) = 0.; - } - if ( SameLines ) { - Standard_Real dist1(RealLast()); - if (!isInfinite1) dist1 = Max(tabdist(1),tabdist(2)); - Standard_Real dist2(RealLast()); - if (!isInfinite2) dist2 = Max(tabdist(3),tabdist(4)); - - myFAttach = myCenter; - mySAttach = myCenter; - P1 = myFAttach; - P2 = mySAttach; - - myCenter.Translate(gp_Vec(d1)*theLength); - - // calculate attachments of the face - // -> they are points of intersection if - // intersection is outside of the edges - Standard_Real pparam = ElCLib::Parameter(gpl1,myFAttach); - Standard_Real pparam1 = ElCLib::Parameter(gpl1,ptat11); - Standard_Real pparam2 = ElCLib::Parameter(gpl1,ptat12); - if (!isInfinite1) { - if ( pparam1 < pparam2 ) { - if ( pparam < pparam1 ) myFAttach = ptat11; - else if ( pparam > pparam2) myFAttach = ptat12; - } - else { - if ( pparam < pparam2) myFAttach = ptat12; - else if ( pparam > pparam1) myFAttach = ptat11; - } - } - if (!isInfinite2) { - pparam = ElCLib::Parameter(gpl2,myFAttach); - pparam1 = ElCLib::Parameter(gpl2,ptat21); - pparam2 = ElCLib::Parameter(gpl2,ptat22); - if ( pparam1 < pparam2 ) { - if ( pparam < pparam1 ) mySAttach = ptat21; - else if ( pparam > pparam2) mySAttach = ptat22; - } - else { - if ( pparam < pparam2) mySAttach = ptat22; - else if ( pparam > pparam1) mySAttach = ptat21; - } - } - } - // Case of disconneted lines - else { - gp_Ax2 AX(myCenter,theaxis,d1); - Handle(Geom_Circle) circle = new Geom_Circle(AX,theLength); - Handle(Geom2d_Curve) geoCurve = GeomAPI::To2d(circle,myPlane->Pln()); - Handle(Geom2d_Circle) c2d = *((Handle(Geom2d_Circle)*)& geoCurve); - // calculate the intersection of circle with l1 - Standard_Real pparam; // parameter of the point of intersection on l1 - IntAna2d_AnaIntersection inter(l1_2d->Lin2d(),c2d->Circ2d()); - gp_Pnt2d pint1(inter.Point(1).Value()); - gp_Pnt2d pint2(inter.Point(2).Value()); - - gp_Pnt Int1 = adp.Value(pint1.X(),pint1.Y()); - gp_Pnt Int2 = adp.Value(pint2.X(),pint2.Y()); - gp_Dir I1I2(gp_Vec(Int1,Int2)); - if ( d1*I1I2 > 0 ) { - myFAttach = Int2; - pparam = inter.Point(2).ParamOnFirst(); - } - else { - myFAttach = Int1; - pparam = inter.Point(1).ParamOnFirst(); - } - P1 = myFAttach; - - Standard_Real pparam1; - Standard_Real pparam2; - if (!isInfinite1) { - pparam1 = ElCLib::Parameter(gpl1,ptat11); - pparam2 = ElCLib::Parameter(gpl1,ptat12); - if ( pparam1 < pparam2 ) { - if ( pparam < pparam1 ) myFAttach = ptat11; - else if ( pparam > pparam2) myFAttach = ptat12; - } - else { - if ( pparam < pparam2) myFAttach = ptat12; - else if ( pparam > pparam1) myFAttach = ptat11; - } + // Check if both edges are on this plane + if (!anExtCurve.IsNull()) + { + if (anExtIndex == 1) // First curve is out of the plane + { + // Project curve on the plane + if (myIsWorkingPlaneCustom) + { + aFirstLin2d = ProjLib::Project (aPlane, aFirstLin); + aFirstLin = ElCLib::To3d (aPlane.Position().Ax2(), aFirstLin2d); } - pparam = ElCLib::Parameter(gpl2,P1); - mySAttach = ElCLib::Value(pparam, gpl2); - P2 = mySAttach; - - if (!isInfinite2) { - pparam1 = ElCLib::Parameter(gpl2,ptat21); - pparam2 = ElCLib::Parameter(gpl2,ptat22); - if ( pparam1 < pparam2 ) { - if ( pparam < pparam1 ) mySAttach = ptat21; - else if ( pparam > pparam2) mySAttach = ptat22; - } - else { - if ( pparam < pparam2) mySAttach = ptat22; - else if ( pparam > pparam1) mySAttach = ptat21; - } + else + { + aFirstLin.Translate (gp_Vec (aFirstLin.Location(), aSecondLin.Location())); } - } - curpos.SetXYZ(.5*(P1.XYZ()+P2.XYZ())); - - gp_Ax2 ax(myCenter,theaxis,d1); - gp_Circ circle(ax,theLength); - Standard_Real par = ElCLib::Parameter(circle,curpos); - curpos = ElCLib::Value(par,circle); - if (myIsSetBndBox) - curpos = AIS::TranslatePointToBound( curpos, gp_Dir( gp_Vec( myCenter, curpos ) ), myBndBox ); - myPosition =curpos; - myAutomaticPosition = Standard_True; - } - else { - curpos = myPosition; - gp_Lin Media(myCenter, gpl1.Direction()); - Standard_Real pcurpos = ElCLib::Parameter(Media, curpos); - myCenter = ElCLib::Value(pcurpos, Media); - // the centre is translated to avoid a constant radius! - myCenter.Translate(-theLength*gp_Vec(gpl1.Direction())); - gp_Ax2 AX(myCenter,theaxis,gpl1.Direction()); - Handle(Geom_Circle) circle = new Geom_Circle(AX,theLength); - - // re-update curpos - pcurpos = ElCLib::Parameter(circle->Circ(), curpos); - curpos = ElCLib::Value(pcurpos, circle->Circ()); - - Handle(Geom2d_Curve) geoCurve = GeomAPI::To2d(circle,myPlane->Pln()); - Handle(Geom2d_Circle) c2d = *((Handle(Geom2d_Circle)*)& geoCurve); - // calculate the point of intersection of circle with l1 - IntAna2d_AnaIntersection inter(l1_2d->Lin2d(),c2d->Circ2d()); - gp_Pnt2d pint1(inter.Point(1).Value()); - gp_Pnt2d pint2(inter.Point(2).Value()); - gp_Pnt Int1 = adp.Value(pint1.X(),pint1.Y()); - gp_Pnt Int2 = adp.Value(pint2.X(),pint2.Y()); - if ( curpos.SquareDistance(Int1) < curpos.SquareDistance(Int2)) myFAttach = Int1; - else myFAttach = Int2; - P1 = myFAttach; - - // calculate the point of intersection of circle with l2 - // -> this is the projection because the centre of circle - // is in the middle of l1 and l2 - Standard_Real pparam = ElCLib::Parameter(gpl2,myFAttach); - mySAttach = ElCLib::Value(pparam, gpl2); - - P2 = mySAttach; - - Standard_Real par_attach(ElCLib::Parameter(gpl1,myFAttach)); - Standard_Real par1,par2; - if (!isInfinite1) { - par1 = ElCLib::Parameter(gpl1,ptat11); - par2 = ElCLib::Parameter(gpl1,ptat12); - if (par1 < par2) { - if ( par_attach < par1 ) myFAttach = ptat11; - else if ( par_attach > par2) myFAttach = ptat12; - } - else { - if ( par_attach < par2 ) myFAttach = ptat12; - else if ( par_attach > par1) myFAttach = ptat11; - } + aFirstLine = new Geom_Line (aFirstLin); } - par_attach = ElCLib::Parameter(gpl2,mySAttach); - if (!isInfinite2) { - par1 = ElCLib::Parameter(gpl2,ptat21); - par2 = ElCLib::Parameter(gpl2,ptat22); - if (par1 < par2) { - if ( par_attach < par1 ) mySAttach = ptat21; - else if ( par_attach > par2) mySAttach = ptat22; + else if (anExtIndex == 2) // Second curve is out of the plane + { + if (myIsWorkingPlaneCustom) + { + aSecondLin2d = ProjLib::Project (aPlane, aSecondLin); + aSecondLin = ElCLib::To3d (aPlane.Position().Ax2(), aSecondLin2d); } - else { - if ( par_attach < par2 ) mySAttach = ptat22; - else if ( par_attach > par1) mySAttach = ptat21; + else + { + aSecondLin.Translate (gp_Vec (aSecondLin.Location(), aFirstLin.Location())); } + + aSecondLine = new Geom_Line (aSecondLin); } } - myFDir = gp_Dir(gp_Vec(myCenter,P1)); - mySDir = gp_Dir(gp_Vec(myCenter,P2)); - - //-------------------------------------------------------- - // Computation of the presentation - //-------------------------------------------------------- - Handle(Prs3d_AngleAspect) la = myDrawer->AngleAspect(); - Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); - - arr->SetLength(myArrowSize); - - if (SameLines) - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - theaxis, - Standard_True, - myAxis, - curpos, - DsgPrs_AS_NONE); - else - DsgPrs_AnglePresentation::Add(aPresentation, - myDrawer, - myVal, - myText, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - curpos, - mySymbolPrs); -} - + /// PART 2 is for dimension computation using the working plane -//======================================================================= -//function : Compute3DSelection -// purpose : compute the zones of selection for an angle dimension -// between 2 faces -//======================================================================= - -void AIS_AngleDimension::Compute3DSelection( const Handle( SelectMgr_Selection )& aSelection ) -{ - gp_Circ AngleCirc, AttachCirc; - Standard_Real FirstParAngleCirc, LastParAngleCirc, FirstParAttachCirc, LastParAttachCirc; - gp_Pnt EndOfArrow1, EndOfArrow2, ProjAttachPoint2; - gp_Dir DirOfArrow1, DirOfArrow2; - gp_Dir axisdir = (myVal <= Precision::Angular() || Abs( M_PI-myVal ) <= Precision::Angular())? - myPlane->Pln().Axis().Direction() : (myFDir ^ mySDir); - Standard_Boolean isPlane = (myFirstSurfType == AIS_KOS_Plane)? Standard_True : Standard_False; - - Standard_Real ArrowLength = myDrawer->AngleAspect()->ArrowAspect()->Length(); - DsgPrs::ComputeFacesAnglePresentation( ArrowLength, - myVal, - myCenter, - myFAttach, - mySAttach, - myFDir, - mySDir, - axisdir, - isPlane, - myAxis, - myPosition, - AngleCirc, - FirstParAngleCirc, - LastParAngleCirc, - EndOfArrow1, - EndOfArrow2, - DirOfArrow1, - DirOfArrow2, - ProjAttachPoint2, - AttachCirc, - FirstParAttachCirc, - LastParAttachCirc ); - - Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 ); - Handle( Select3D_SensitiveSegment ) seg; - Handle( Geom_TrimmedCurve ) curve; - Handle( Select3D_SensitiveCurve ) SensCurve; + if (aFirstLin.Direction ().IsParallel (aSecondLin.Direction (), Precision::Angular ())) + { + // Parallel lines + isSameLines = aFirstLin.Distance(aSecondLin.Location()) <= Precision::Confusion(); + if (!isSameLines) + return Standard_False; + + myFirstPoint = aFirstLin.Location(); + mySecondPoint = ElCLib::Value (ElCLib::Parameter (aFirstLin, myFirstPoint), aSecondLin); + if (mySecondPoint.Distance (mySecondPoint) <= Precision::Confusion ()) + mySecondPoint.Translate (gp_Vec (aSecondLin.Direction ())*Abs(GetFlyout())); + myCenter.SetXYZ( (myFirstPoint.XYZ() + mySecondPoint.XYZ()) / 2. ); + } + else + { + // Find intersection + aFirstLin2d = ProjLib::Project (aPlane, aFirstLin); + aSecondLin2d = ProjLib::Project (aPlane, aSecondLin); - // Angle's arc or line - if (myVal > Precision::Angular() && Abs( M_PI-myVal ) > Precision::Angular()) + IntAna2d_AnaIntersection anInt2d (aFirstLin2d, aSecondLin2d); + gp_Pnt2d anIntersectPoint; + if (!anInt2d.IsDone() || anInt2d.IsEmpty()) { - curve = new Geom_TrimmedCurve( new Geom_Circle( AngleCirc ), FirstParAngleCirc, LastParAngleCirc ); - SensCurve = new Select3D_SensitiveCurve( own, curve ); - aSelection->Add( SensCurve ); - } - else // angle's line - { - gp_Vec ArrowVec( DirOfArrow1 ); - ArrowVec *= ArrowLength; - gp_Pnt FirstPoint, LastPoint; - - if (myPosition.Distance( EndOfArrow1 ) > ArrowLength) - { - FirstPoint = myPosition; - LastPoint = EndOfArrow1.Translated( ArrowVec ); - if (myPosition.SquareDistance( LastPoint ) < myPosition.SquareDistance( EndOfArrow1 )) - LastPoint = EndOfArrow1.Translated( -ArrowVec ); - } - else - { - FirstPoint = EndOfArrow1.Translated( ArrowVec ); - LastPoint = EndOfArrow1.Translated( -ArrowVec ); - } - seg = new Select3D_SensitiveSegment( own, FirstPoint, LastPoint ); - aSelection->Add( seg ); + return Standard_False; } - if (! myFAttach.IsEqual( EndOfArrow1, Precision::Confusion() )) - { - seg = new Select3D_SensitiveSegment( own, myFAttach, EndOfArrow1 ); - aSelection->Add( seg ); - } - if (! ProjAttachPoint2.IsEqual( EndOfArrow2, Precision::Confusion() )) - { - seg = new Select3D_SensitiveSegment( own, ProjAttachPoint2, EndOfArrow2 ); - aSelection->Add( seg ); - } + anIntersectPoint = gp_Pnt2d (anInt2d.Point(1).Value()); + myCenter = ElCLib::To3d(aPlane.Position().Ax2(), anIntersectPoint); - // Line or arc from mySAttach to its "projection" - if (! mySAttach.IsEqual( ProjAttachPoint2, Precision::Confusion() )) + if (isInfinite1 || isInfinite2) { - if (isPlane) - { - seg = new Select3D_SensitiveSegment( own, mySAttach, ProjAttachPoint2 ); - aSelection->Add( seg ); - } - else - { - curve = new Geom_TrimmedCurve( new Geom_Circle( AttachCirc ), - FirstParAttachCirc, - LastParAttachCirc ); - SensCurve = new Select3D_SensitiveCurve( own, curve ); - aSelection->Add( SensCurve ); - } + myFirstPoint = myCenter.Translated (gp_Vec (aFirstLin.Direction())*Abs (GetFlyout())); + mySecondPoint = myCenter.Translated (gp_Vec (aSecondLin.Direction())*Abs (GetFlyout())); + return Standard_True; } - // Text - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + size, - myPosition.Y() + size, - myPosition.Z() + size); - aSelection->Add(box); + // | + // | <- dimension should be here + // *---- + myFirstPoint = myCenter.Distance (aFirstPoint1) > myCenter.Distance (aLastPoint1) ? aFirstPoint1 : aLastPoint1; + mySecondPoint = myCenter.Distance (aFirstPoint2) > myCenter.Distance (aLastPoint2) ? aFirstPoint2 : aLastPoint2; + } + return Standard_True; } //======================================================================= -//function : Compute2DSelection -//purpose : compute zones of selection on a side of angle between 2 edges -// Special processing of zero angles! +//function : canTextBeInCenter +//purpose : Auxiliary method to arrange text and arrows //======================================================================= -void AIS_AngleDimension::Compute2DSelection(const Handle(SelectMgr_Selection)& aSelection) +Standard_Boolean AIS_AngleDimension::canTextBeInCenter (const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const Quantity_Length& theTextLength, + const Quantity_Length& theArrowLength) { - BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); - BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape)); - - gp_Lin l1(cu1.Line()); - gp_Lin l2(cu2.Line()); - - // it is patch! - if (Abs( myVal ) <= Precision::Angular() || Abs( M_PI - myVal ) <= Precision::Angular()) -/* - //--------------------------------------------------------- - // Cas de droites paralleles ( <=> angle nul a M_PI pres) - if ((Abs(l1.Angle(l2)) < Precision::Angular()) || - (Abs((l1.Angle(l2) - M_PI)) < Precision::Angular()) ) -*/ - { - - Standard_Real distLL= l1.Distance(l2); - if ( Abs(distLL) <= Precision::Confusion() ) { - gp_Pnt ptat11 = cu1.Value(cu1.FirstParameter()); - gp_Pnt ptat12 = cu1.Value(cu1.LastParameter()); - gp_Pnt ptat21 = cu2.Value(cu2.FirstParameter()); - gp_Pnt ptat22 = cu2.Value(cu2.LastParameter()); - distLL = 0.75 * Max( ptat11.Distance(ptat12), ptat21.Distance(ptat22)); - ComputeNull2DSelection(aSelection, distLL); - } - else { - ComputeNull2DSelection(aSelection, distLL*8/10); - } - } - - //---------------------------------------------------------- - // Classic case ( angle != 0 ) - else { - - if (myFDir.IsParallel(mySDir,Precision::Angular())) { - Standard_Real distLL= l1.Distance(l2); - if ( Abs(distLL) <= Precision::Confusion() ) { - gp_Pnt ptat11 = cu1.Value(cu1.FirstParameter()); - gp_Pnt ptat12 = cu1.Value(cu1.LastParameter()); - gp_Pnt ptat21 = cu2.Value(cu2.FirstParameter()); - gp_Pnt ptat22 = cu2.Value(cu2.LastParameter()); - distLL = 0.75 * Max( ptat11.Distance(ptat12), ptat21.Distance(ptat22)); - ComputeNull2DSelection(aSelection, distLL*8/10); - } - } - else { - gp_Dir Norm = myFDir.Crossed(mySDir); - - gp_Ax2 ax(myCenter,Norm,myFDir); - gp_Circ cer(ax,myCenter.Distance(myPosition)); - gp_Vec vec1(myFDir); - - Standard_Boolean nullrad(Standard_False); - if (cer.Radius() == 0.) { - cer.SetRadius(1.); - nullrad = Standard_True; - } - vec1 *= cer.Radius(); - gp_Pnt p1 = myCenter.Translated(vec1); - gp_Vec vec2(mySDir); - vec2 *= cer.Radius(); - gp_Pnt p2 = myCenter.Translated(vec2); - - Standard_Real uc1 = 0.; - Standard_Real uc2 = ElCLib::Parameter(cer,p2); - Standard_Real uco; - if (nullrad) uco = ElCLib::Parameter(cer,p1); - else uco = ElCLib::Parameter(cer,myPosition); - - Standard_Real udeb = uc1; - Standard_Real ufin = uc2; - - if (uco > ufin) { - if (Abs(myVal) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; - } - } - } - if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) ufin = uco; - else udeb = uco - 2*M_PI; - } - p1 = ElCLib::Value(udeb,cer); - p2 = ElCLib::Value(ufin,cer); - - //Create 2 owners for each part of the arrow - Handle(AIS_DimensionOwner) own1 = new AIS_DimensionOwner(this,7); - Handle(AIS_DimensionOwner) own2 = new AIS_DimensionOwner(this,7); - if (myExtShape != 0) { - if (myExtShape == 1) { - own1->SetShape(mySShape); - own2->SetShape(mySShape); - } - else { - own1->SetShape(myFShape); - own2->SetShape(myFShape); - } - } - else { - own1->SetShape(myFShape); - own2->SetShape(mySShape); - } - - Handle(Geom_Circle) thecirc = new Geom_Circle(cer); - - Handle(Geom_TrimmedCurve) thecu1 = new Geom_TrimmedCurve(thecirc,udeb,(udeb+ufin)/2); - Handle(Geom_TrimmedCurve) thecu2 = new Geom_TrimmedCurve(thecirc,(udeb+ufin)/2,ufin); - - Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own1,thecu1); - aSelection->Add(scurv); - scurv = new Select3D_SensitiveCurve(own2,thecu2); - aSelection->Add(scurv); - - Handle(Select3D_SensitiveSegment) seg; - if (!myFAttach.IsEqual(p1,Precision::Confusion())) { - seg = new Select3D_SensitiveSegment(own1,myFAttach,p1); - aSelection->Add(seg); - } - if (!mySAttach.IsEqual(p2,Precision::Confusion())) { - seg = new Select3D_SensitiveSegment(own2,mySAttach,p2); - aSelection->Add(seg); - } - } - } + gp_Vec anAttachVector (theFirstAttach, theSecondAttach); + Standard_Real aValue = anAttachVector.Magnitude(); + return (aValue < theTextLength + 2.*theArrowLength) ? Standard_False : Standard_True; +} +//======================================================================= +//function: getCenterOnArc +//purpose : +//======================================================================= +gp_Pnt AIS_AngleDimension::getCenterOnArc (const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach) +{ + gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter), + aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach), + aSecondAttach2d = ProjLib::Project (GetWorkingPlane(), theSecondAttach); + gp_Lin2d anAttachLine2d = gce_MakeLin2d (aFirstAttach2d, aSecondAttach2d); + + // Getting text center + gp_Pnt2d aTextCenterPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) + ElCLib::Parameter (anAttachLine2d, aSecondAttach2d)) / 2., anAttachLine2d); + gp_Lin2d aCenterToTextCenterLin = gce_MakeLin2d (aCenter2d, aTextCenterPnt); + + // Drawing circle + Standard_Real aRadius = theFirstAttach.Distance (myCenter); + gp_Circ2d aCircle (gp_Ax22d (aCenter2d, gp_Dir2d (1, 0)), aRadius); + + // Getting text position in the center of arc + IntAna2d_AnaIntersection anInt2d (aCenterToTextCenterLin, aCircle); + gp_Pnt2d aTextCenterOnArc2d; + if (anInt2d.IsDone()) + if (!anInt2d.IsEmpty()) + aTextCenterOnArc2d = gp_Pnt2d (anInt2d.Point (1).Value()); + gp_Pnt aCenterOnArc = ElCLib::To3d (GetWorkingPlane().Position().Ax2(), aTextCenterOnArc2d); + return aCenterOnArc; } + //======================================================================= -//function : Compute2DNullSelection -//purpose : for dimension of null angle +//function: drawArcWithText +//purpose : //======================================================================= -void AIS_AngleDimension::ComputeNull2DSelection( - const Handle(SelectMgr_Selection)& aSelection, - const Standard_Real distLL) +void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const TCollection_ExtendedString& theText, + const AIS_DimensionDisplayMode theMode) { - gp_Dir Norm; - if ( myFDir.IsParallel(mySDir, Precision::Angular()) ) { - Norm = myPlane->Pln().Axis().Direction(); + gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter), + aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach), + aSecondAttach2d = ProjLib::Project (GetWorkingPlane(), theSecondAttach); + gp_Lin2d anAttachLine2d = gce_MakeLin2d (aFirstAttach2d, aSecondAttach2d); + + // Getting text center + gp_Pnt2d aTextCenterPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) + ElCLib::Parameter (anAttachLine2d, aSecondAttach2d)) / 2., anAttachLine2d); + gp_Lin2d aCenterToTextCenterLin = gce_MakeLin2d (aCenter2d, aTextCenterPnt); + + // Drawing circle + Standard_Real aRadius = theFirstAttach.Distance (myCenter); + gp_Circ2d aCircle (gp_Ax22d (aCenter2d, gp_Dir2d (1, 0)), aRadius); + + // Getting text position in the center of arc + IntAna2d_AnaIntersection anInt2d (aCenterToTextCenterLin, aCircle); + gp_Pnt2d aTextCenterOnArc2d; + if (anInt2d.IsDone()) + if (!anInt2d.IsEmpty()) + aTextCenterOnArc2d = gp_Pnt2d (anInt2d.Point (1).Value()); + myGeom.myTextPosition = ElCLib::To3d (GetWorkingPlane().Position().Ax2(), aTextCenterOnArc2d); + + // Drawing text + gp_Vec aVec (theFirstAttach, theSecondAttach); + Standard_Real aTextWidth = drawText (thePresentation, + myIsTextReversed ? aVec.Reversed() : aVec, + theText,theMode); + + // Getting text begin and end points + gp_Pnt2d aTextBeginPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) + + ElCLib::Parameter (anAttachLine2d, aSecondAttach2d) - + aTextWidth) / 2., anAttachLine2d), + aTextEndPnt = ElCLib::Value (ElCLib::Parameter (anAttachLine2d,aTextBeginPnt) + aTextWidth, anAttachLine2d); + + + gp_Lin2d aCenterToTextBeginLin = gce_MakeLin2d (aCenter2d, aTextBeginPnt), + aCenterToTextEndLin = gce_MakeLin2d (aCenter2d, aTextEndPnt); + + // Text begin and end on the dimension arc + gp_Pnt2d aTextBeginOnArc2d, aTextEndOnArc2d; + anInt2d.Perform (aCenterToTextBeginLin, aCircle); + if (anInt2d.IsDone()) + if (!anInt2d.IsEmpty()) + aTextBeginOnArc2d = gp_Pnt2d (anInt2d.Point (1).Value()); + + anInt2d.Perform (aCenterToTextEndLin, aCircle); + if (anInt2d.IsDone()) + if (!anInt2d.IsEmpty()) + aTextEndOnArc2d = gp_Pnt2d (anInt2d.Point (1).Value()); + + gp_Pnt aTextBeginOnArc = ElCLib::To3d (GetWorkingPlane().Position().Ax2(), aTextBeginOnArc2d); + gp_Pnt aTextEndOnArc = ElCLib::To3d (GetWorkingPlane().Position().Ax2(), aTextEndOnArc2d); + + // Drawing arcs + if (theMode != AIS_DDM_Text) + { + drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode); + drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode); } - else - Norm = myFDir.Crossed(mySDir); - gp_Ax2 ax(myCenter,Norm,myFDir); - gp_Circ cer(ax,distLL); - - gp_Vec vec1(myFDir); - vec1 *= cer.Radius(); - gp_Pnt p1 = myCenter.Translated(vec1); - gp_Vec vec2(mySDir); - vec2 *= cer.Radius(); - gp_Pnt p2 = myCenter.Translated(vec2); - - // calcul de parametres de debut et de fin des extremites de l'arc - Standard_Real uc1 = 0.; - Standard_Real uc2 = ElCLib::Parameter(cer,p2); - Standard_Real uco = ElCLib::Parameter(cer,myPosition); - - Standard_Real udeb = uc1; - Standard_Real ufin = uc2; - - if (uco > ufin) { - if (Abs(myVal) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; - } - } - } +} - if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) { - ufin = uco; - } - else { - udeb = uco - 2*M_PI; - } - } +//======================================================================= +//function : drawArc +//purpose : draws the arc between two attach points +//======================================================================= - //Create 2 owners for each part of the arrow - Handle(AIS_DimensionOwner) own1 = new AIS_DimensionOwner(this,7); - Handle(AIS_DimensionOwner) own2 = new AIS_DimensionOwner(this,7); - if (myExtShape != 0) { - if (myExtShape == 1) { - own1->SetShape(mySShape); - own2->SetShape(mySShape); - } - else { - own1->SetShape(myFShape); - own2->SetShape(myFShape); - } - } - else { - own1->SetShape(myFShape); - own2->SetShape(mySShape); +void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const gp_Pnt& theCenter, + const Standard_Real theRadius, + const AIS_DimensionDisplayMode theMode) +{ + Handle(SelectMgr_EntityOwner) anEmptyOwner; + Prs3d_Root::CurrentGroup (thePresentation)-> + SetPrimitivesAspect(myDrawer->DimensionAspect()->LineAspect()->Aspect()); + + gp_Vec aCenterToFirstVec (theCenter,theFirstAttach); + gp_Vec aCenterToSecondVec (theCenter,theSecondAttach); + gp_Dir aCenterToFirstDir (aCenterToFirstVec); + gp_Dir aPlaneNormal = GetWorkingPlane().Axis().Direction(); + gp_Dir aCenterToSecondDir = aPlaneNormal.Crossed (aCenterToFirstDir); + + const Standard_Real anAngle = aCenterToFirstVec.Angle(aCenterToSecondVec); + const Standard_Integer aPointsOnArc = Max (4 , Standard_Integer (50. * anAngle / M_PI)); + const Standard_Real anAngleStep = anAngle / (aPointsOnArc - 1); + TColgp_Array1OfPnt aPointArray (0,aPointsOnArc-1); + Handle(Graphic3d_ArrayOfPolylines) aPrimSegments = new Graphic3d_ArrayOfPolylines (aPointsOnArc,2); + aPrimSegments->AddVertex (theFirstAttach); + aPointArray.SetValue(0, theFirstAttach); + gp_Pnt aPoint = theFirstAttach; + gp_Vec aVector; + + for (Standard_Integer anI = 1; anI < aPointsOnArc - 1; ++anI) + { + aVector = (gp_Vec(aCenterToFirstDir) * Cos ( (anI - 1) * anAngleStep) + gp_Vec(aCenterToSecondDir) * Sin ( (anI - 1) * anAngleStep)) * theRadius; + aPoint = theCenter.Translated(aVector); + aPrimSegments->AddVertex(aPoint); + aPointArray.SetValue (anI,aPoint); } - - Handle(Geom_Circle) thecirc = new Geom_Circle(cer); - - if ( udeb != ufin ) { - Handle(Geom_TrimmedCurve) thecu1 = new Geom_TrimmedCurve(thecirc,udeb,(udeb+ufin)/2); - Handle(Geom_TrimmedCurve) thecu2 = new Geom_TrimmedCurve(thecirc,(udeb+ufin)/2,ufin); + aPrimSegments->AddVertex (theSecondAttach); + aPointArray.SetValue (aPointsOnArc - 1,theSecondAttach); - Handle(Select3D_SensitiveCurve) scurv = new Select3D_SensitiveCurve(own1,thecu1); - aSelection->Add(scurv); - scurv = new Select3D_SensitiveCurve(own2,thecu2); - aSelection->Add(scurv); - } - else { - // find end of segment to allow selection - gp_Vec VTrans(myFDir.Crossed(Norm)); - Handle(Select3D_SensitiveSegment) seg1; - seg1 = new Select3D_SensitiveSegment(own1, - p1, - p1.Translated( VTrans*distLL/10 ) ); - aSelection->Add(seg1); - seg1 = new Select3D_SensitiveSegment(own2, - p2, - p2.Translated(-VTrans*distLL/10 ) ); - aSelection->Add(seg1); - } + // Fill sensitive list + myGeom.mySensitiveSegments.Append(new Select3D_SensitiveCurve(anEmptyOwner,aPointArray)); - Handle(Select3D_SensitiveSegment) seg; - if (!myFAttach.IsEqual(p1,Precision::Confusion())) { - seg = new Select3D_SensitiveSegment(own1,myFAttach,p1); - aSelection->Add(seg); + // Fill display presentation + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); } - - if (!mySAttach.IsEqual(p2,Precision::Confusion())) { - seg = new Select3D_SensitiveSegment(own2,mySAttach,p2); - aSelection->Add(seg); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); } } - //======================================================================= -//function : ComputeConeAngleSelection -//purpose : for cone angle +//function : Compute +//purpose : Having three gp_Pnt points compute presentation //======================================================================= -void AIS_AngleDimension::ComputeConeAngleSelection(const Handle(SelectMgr_Selection)& aSelection) -{ - if( myCone.IsNull() ) return; - - Handle( SelectMgr_EntityOwner ) owner = new SelectMgr_EntityOwner( this, 7 ); - Handle( Select3D_SensitiveSegment ) seg; - - gp_Pln aPln; - gp_Cone aCone; - gp_Circ myCircle; - gp_Pnt Apex; - Handle( Geom_Surface ) aSurf; //a surface from the Face - Handle( Geom_OffsetSurface ) aOffsetSurf; - Handle( Geom_ConicalSurface ) aConicalSurf; - Handle( Geom_SurfaceOfRevolution ) aRevSurf; - Handle( Geom_Line ) aLine; - BRepAdaptor_Surface tmpSurf(myCone); - TopoDS_Face aFace; - AIS_KindOfSurface aSurfType; - Standard_Real Offset = 0. ; - Handle( Standard_Type ) aType; - - Standard_Real maxV = tmpSurf.FirstVParameter(); - Standard_Real minV = tmpSurf.LastVParameter(); +void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) +{ + thePresentation->Clear(); + myGeom.mySensitiveSegments.Clear(); + Handle(SelectMgr_EntityOwner) anEmptyOwner; - AIS::GetPlaneFromFace( myCone, aPln, aSurf, aSurfType, Offset ); - - if ( aSurfType == AIS_KOS_Revolution ) { //surface of revolution - - aRevSurf = Handle( Geom_SurfaceOfRevolution )::DownCast( aSurf ); - gp_Lin ln( aRevSurf->Axis() ); - Handle( Geom_Curve ) tmpCrv = aRevSurf->BasisCurve(); - if ( tmpCrv ->DynamicType() != STANDARD_TYPE(Geom_Line) ) return; //Must be a part of line - - Standard_Real par; - gp_Pnt fst = tmpSurf.Value(0., minV); - gp_Pnt lst = tmpSurf.Value(0., maxV); - - gp_Vec vec1(fst, lst); - - par = ElCLib::Parameter( ln, fst ); - gp_Pnt fst2 = ElCLib::Value( par, ln ); //projection fst on ln - par = ElCLib::Parameter( ln, lst ); - gp_Pnt lst2 = ElCLib::Value( par, ln ); //projection lst on ln - - gp_Vec vec2(fst2, lst2); - - // Check if two parts of revolution are parallel ( it's a cylinder ) or normal (it's a circle ) - if( vec1.IsParallel( vec2,Precision::Angular() ) || vec1.IsNormal( vec2,Precision::Angular() ) ) return; - - gce_MakeCone mkCone(aRevSurf->Axis(), fst, lst); - aCone = mkCone.Value(); - Apex = aCone.Apex(); - } - else { - aType = aSurf->DynamicType(); - if ( aType == STANDARD_TYPE(Geom_OffsetSurface) || Offset > 0.01 ) { //offset surface - aOffsetSurf = new Geom_OffsetSurface (aSurf, Offset); - aSurf = aOffsetSurf->Surface(); - BRepBuilderAPI_MakeFace mkFace(aSurf, Precision::Confusion()); - mkFace.Build(); - if( !mkFace.IsDone() ) return; - tmpSurf.Initialize( mkFace.Face() ); - } - - aCone = tmpSurf.Cone(); - aConicalSurf = Handle( Geom_ConicalSurface)::DownCast( aSurf ); - Apex = aConicalSurf->Apex(); + if (!myIsInitialized) + { + if (myShapesNumber == 1) + { + myIsInitialized = initConeAngle (TopoDS::Face (myFirstShape)); + } + else if (myShapesNumber == 2) + { + switch (myFirstShape.ShapeType()) + { + case TopAbs_FACE: + { + myIsInitialized = initTwoFacesAngle (); + } + break; + case TopAbs_EDGE: + { + myIsInitialized = initTwoEdgesAngle (); + } + break; + default: + return; + } + } + else + return; } - Handle(Geom_Curve) aCurve; //A circle where the angle is drawn - - if ( myAutomaticPosition ) { - Standard_Real midV = ( minV + maxV ) / 2.5; + // If initialization failed + if (!myIsInitialized) + return; - aCurve = aSurf->VIso(midV); - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); + // Parameters for presentation + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Prs3d_Root::CurrentGroup(thePresentation)-> + SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect()); + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + if (!myIsValueCustom) + computeValue (); + TCollection_ExtendedString aValueString; + Standard_Real aTextLength; + getTextWidthAndString (aTextLength, aValueString); + if (!myIsWorkingPlaneCustom) + countDefaultPlane(); + gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout()); + gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).Normalized() * GetFlyout()); + // Attach points and radius + if (aDimensionAspect->HorizontalTextAlignment () == Prs3d_HTA_Center) + { + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal); - myPosition = ElCLib::Value(M_PI / 2.0, myCircle); - myAutomaticPosition = Standard_False; - } - else { - Standard_Real U, V; - ElSLib::Parameters(aCone, myPosition, U, V); - aCurve = aSurf->VIso(V); - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - } - //__________________________________________________________________ - aCurve = aSurf->VIso(maxV); - gp_Circ CircVmax = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - aCurve = aSurf->VIso(minV); - gp_Circ CircVmin = Handle(Geom_Circle)::DownCast(aCurve)->Circ(); - //__________________________________________________________________ - - if( CircVmax.Radius() < CircVmin.Radius() ) { - gp_Circ tmpCirc = CircVmax; - CircVmax = CircVmin; - CircVmin = tmpCirc; + if (!canTextBeInCenter (aFirstAttach, aSecondAttach, aTextLength, anArrowLength)) + { + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); + aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left); + } } - - Standard_Boolean IsArrowOut = Standard_True; //Is arrows inside or outside of the cone - //Standard_Real PntOnMainAxis = 0; //Is projection of aPosition inside of the cone = 0, above = 1, or below = -1 - Standard_Boolean IsConeTrimmed = Standard_False; - - if( CircVmin.Radius() > 0.01 ) IsConeTrimmed = Standard_True; - - gp_Pnt AttachmentPnt; - gp_Pnt OppositePnt; - - Standard_Real param = ElCLib::Parameter(myCircle, myPosition); + else + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); - gp_Pnt aPnt = Apex; - gp_Pnt P1 = ElCLib::Value(0., myCircle); - gp_Pnt P2 = ElCLib::Value(M_PI, myCircle); + //Arrows positions and directions + gp_Vec aFirstArrowVec = (gp_Vec(myCenter, aFirstAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized().Reversed()*anArrowLength; + gp_Vec aSecondArrowVec = (gp_Vec(myCenter, aSecondAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized()*anArrowLength; - gce_MakePln mkPln(P1, P2, aPnt); // create a plane whitch defines plane for projection aPosition on it + gp_Pnt aFirstArrowBegin, + aFirstArrowEnd, + aSecondArrowBegin, + aSecondArrowEnd; - aPnt = AIS::ProjectPointOnPlane(myPosition, mkPln.Value()); - gp_Pnt tmpPnt = aPnt; + if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External) + { + aFirstArrowVec.Reverse(); + aSecondArrowVec.Reverse(); - if( aPnt.Distance(P1) < aPnt.Distance(P2) ){ - AttachmentPnt = P1; - OppositePnt = P2; + aFirstArrowBegin = aFirstAttach.Translated (aFirstArrowVec); + aFirstArrowEnd = aFirstAttach; + aSecondArrowBegin = aSecondAttach; + aSecondArrowEnd = aSecondAttach.Translated (aSecondArrowVec); } - else { - AttachmentPnt = P2; - OppositePnt = P1; + else + { + aFirstArrowBegin = aFirstAttach; + aFirstArrowEnd = aFirstAttach.Translated (aFirstArrowVec); + aSecondArrowBegin = aSecondAttach.Translated (aSecondArrowVec); + aSecondArrowEnd = aSecondAttach; } - - aPnt = AttachmentPnt ; // Creating of circle whitch defines a plane for a dimension arc - gp_Vec Vec(AttachmentPnt, Apex); // Dimension arc is a part of the circle - Vec.Scale(2); - aPnt.Translate(Vec); - GC_MakeCircle mkCirc(AttachmentPnt, OppositePnt, aPnt); - gp_Circ aCircle2 = mkCirc.Value()->Circ(); - - - Standard_Integer i; - Standard_Real AttParam = ElCLib::Parameter(aCircle2, AttachmentPnt); - Standard_Real OppParam = ElCLib::Parameter(aCircle2, OppositePnt); - - while ( AttParam >= 2 * M_PI ) AttParam -= 2 * M_PI; - while ( OppParam >= 2 * M_PI ) OppParam -= 2 * M_PI; - - if( myPosition.Distance( myCircle.Location() ) <= myCircle.Radius() ) - if( 2 * myCircle.Radius() > aCircle2.Radius() * 0.4 ) IsArrowOut = Standard_False; //four times more than an arrow size - - param = AttParam; - Standard_Real angle = OppParam - AttParam; - if(IsArrowOut) + // Fill presentation + Handle(Graphic3d_ArrayOfSegments) aPrimSegments; + Standard_Boolean isTextInCenter = aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center; + if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center) { - angle += M_PI / 6; //An angle between AttParam and OppParam + 30 degrees - param -= M_PI / 12; //out parts of dimension line are 15 degrees + // Important! Current implementation doesn't draw the extensions here + aPrimSegments = new Graphic3d_ArrayOfSegments (4); + // Get text begin and end positions (text is positioned in the center between two attach points) + gp_Pnt aTextBeginOnArc, aTextEndOnArc, anArcCenter; + if (isTextInCenter && aDimensionAspect->IsText3d()) + { + drawArcWithText (thePresentation, aFirstAttach, aSecondAttach, aValueString, (AIS_DimensionDisplayMode)theMode); + } + else + { + gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin); + myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin); + drawText (thePresentation, + myIsTextReversed ? aTextDir.Reversed() : aTextDir, + aValueString, (AIS_DimensionDisplayMode)theMode); + if (theMode != AIS_DDM_Text) + drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs (GetFlyout()), (AIS_DimensionDisplayMode)theMode); + } } + else + { + // Lines for extensions + gp_Lin aLeftExtension (aFirstAttach,gp_Dir(aFirstArrowVec)); + gp_Lin aRightExtension (aSecondAttach, gp_Dir(aSecondArrowVec)); + aPrimSegments = new Graphic3d_ArrayOfSegments (6); + gp_Pnt aStartPoint; + if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Left) + { + aStartPoint = aFirstArrowBegin; + // Short extension + aPrimSegments->AddVertex (aSecondArrowEnd); + aPrimSegments->AddVertex (aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength)); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner, + aSecondArrowEnd, + aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength))); + + // Long extension + drawExtensionWithText (thePresentation, aStartPoint, aLeftExtension, aValueString, (AIS_DimensionDisplayMode)theMode); + } + else // Prs3d_HTA_Right + { + aStartPoint = aSecondArrowEnd; + // Short extension + aPrimSegments->AddVertex (aFirstArrowBegin); + aPrimSegments->AddVertex (aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength)); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner, + aFirstArrowBegin, + aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength))); + + // Long extension + drawExtensionWithText (thePresentation, aStartPoint, aRightExtension, aValueString, (AIS_DimensionDisplayMode)theMode); + } - while ( angle > 2. * M_PI ) angle -= 2. * M_PI; + if (theMode != AIS_DDM_Text) + { + // Draw main arc + drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs(GetFlyout ()), (AIS_DimensionDisplayMode)theMode); + } + } - gp_Pnt Vprev = ElCLib::Value(param, aCircle2); - for( i = 1; i <= 11; i++ ) //calculating of arc + // Draw flyout lines and arrows in new group. + Prs3d_Root::NewGroup (thePresentation) + ->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect()); + if (theMode == AIS_DDM_All && myIsFlyoutLines) + { + aPrimSegments->AddVertex (myCenter); + aPrimSegments->AddVertex (aFirstAttach); + aPrimSegments->AddVertex (myCenter); + aPrimSegments->AddVertex (aSecondAttach); + } + if (theMode != AIS_DDM_Text) { - gp_Pnt Vcur = ElCLib::Value(param + angle/11 * i, aCircle2); - seg = new Select3D_SensitiveSegment(owner, Vprev, Vcur); - aSelection->Add(seg); - Vprev = Vcur; + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec)); + drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec)); } - tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -2)); - - const Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( owner, - tmpPnt.X(), - tmpPnt.Y(), - tmpPnt.Z(), - tmpPnt.X() + size, - tmpPnt.Y() + size, - tmpPnt.Z() + size); - aSelection->Add(box); + setComputed (Standard_True); } diff --git a/src/AIS/AIS_AngleDimension.hxx b/src/AIS/AIS_AngleDimension.hxx new file mode 100644 index 0000000000..d783959482 --- /dev/null +++ b/src/AIS/AIS_AngleDimension.hxx @@ -0,0 +1,177 @@ +// Copyright (c) 1995-1999 Matra Datavision +// Copyright (c) 1999-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//! A framework to define display of angles.
+//! These displays are particularly useful in viewing draft prisms.
+//! The angle displayed may define an intersection
+//! can be between two edges or two faces of a shape
+//! or a plane. The display consists of arrows and text.
+ +#ifndef _AIS_AngleDimension_HeaderFile +#define _AIS_AngleDimension_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) + +class AIS_AngleDimension : public AIS_Dimension +{ +public: + //! Constructs angle dimension between two edges + //! with automatic working plane computing + //! if it is possible. In case of PI angle please + //! set custom working plane or use constructor with 3 parameters. + Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge); + //! Constructs the angle display object defined by the
+ //! two edges and custom working plane. + //! ATTENTION :In case if the working plane is custom and one edge is out of the + //! working plane it tries to project this edge line on the plane. + //! To avoid this case you can reset the working plane + //! using method. + Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge, + const gp_Pln& thePlane); + + //! Constructs the angle display object defined by the
+ //! two edges and custom working plane and dimension aspect. + Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge, + const gp_Pln& thePlane, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize = 1.0); + + //! Constructs the angle display object defined by three points. + Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theThirdPoint); + + //! Constructs the angle display object defined by three points + //! and dimension aspect that defines line, arrow and text aspect. + Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pnt& theThirdPoint, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize = 1.0); + + //! Angle of cone + Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone); + + //! TwoPlanarFaceAngle dimension + Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theFirstFace, + const TopoDS_Face& theSecondFace, + const gp_Ax1& theAxis); + + //! Sets the flyout. + Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); + + //! Returns flyout value. If value > 0 the dimension is to be displayed inside the angle. + //! Otherwise it is displayed outside one. + Standard_EXPORT Standard_Real GetFlyout() const; + + //! Sets first shape + Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape, + const Standard_Boolean isSingleShape = Standard_False); + + DEFINE_STANDARD_RTTI(AIS_AngleDimension) + +protected: + + //! Computes dimension value in display units + Standard_EXPORT virtual void computeValue(); + + Standard_EXPORT void init(); + + Standard_EXPORT gp_Pnt getCenterOnArc (const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach); + + Standard_EXPORT void drawArc (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const gp_Pnt& theCenter, + const Standard_Real theRadius, + const AIS_DimensionDisplayMode theMode); + + Standard_EXPORT void drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const TCollection_ExtendedString& theText, + const AIS_DimensionDisplayMode theMode); + + Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0); + + Standard_EXPORT Standard_Boolean initConeAngle (const TopoDS_Face& theCone); + + Standard_EXPORT Standard_Boolean initTwoFacesAngle(); + + Standard_EXPORT Standard_Boolean initTwoEdgesAngle(); + + //! Auxiliary method to get position of the angle dimension + //! if the cone is trimmed + //! Returns 1 if center is above of center; + //! 0 if center is between and centers; + //! -1 if center is below center. + Standard_EXPORT Standard_Integer aboveInBelowCone (const gp_Circ &theCMax, + const gp_Circ &theCMin, + const gp_Circ &theC); + + //! Auxiliary method to arrange text and arrows + Standard_EXPORT Standard_Boolean canTextBeInCenter (const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const Quantity_Length& theTextLength, + const Quantity_Length& theArrowLength); + + //! Fills default plane object if it is possible to count plane automatically. + Standard_EXPORT virtual void countDefaultPlane (); + +protected: + + //! Shows if there is necessarily to draw extensions on angle dimension + //! It is set to the true value if the attachment point are out of the edges. + Standard_Boolean myIsFlyoutLines; + + //! The center of dimension arc + gp_Pnt myCenter; + + //! Defines flyout lines and direction + //! Flyout direction in the working plane (stored in the base AIS_Dimension). + //! can be negative , or positive and is defined by the sign of value. + //! The direction vector is counting using the working plane. + //! value defined the size of flyout (radius of angle). + Standard_Real myFlyout; +}; + +#endif diff --git a/src/AIS/AIS_AngleDimension.lxx b/src/AIS/AIS_AngleDimension.lxx deleted file mode 100755 index 06fc371c2f..0000000000 --- a/src/AIS/AIS_AngleDimension.lxx +++ /dev/null @@ -1,55 +0,0 @@ -// Created on: 1997-02-28 -// Created by: Jean-Pierre COMBE -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//======================================================================= -//function : KindOfDimension -//purpose : -//======================================================================= -inline AIS_KindOfDimension AIS_AngleDimension::KindOfDimension() const -{ - return AIS_KOD_PLANEANGLE; -} - -//======================================================================= -//function : IsMovable -//purpose : -//======================================================================= -inline Standard_Boolean AIS_AngleDimension::IsMovable() const -{ - return Standard_True; -} - -//======================================================================= -//function : Axis -//purpose : -//======================================================================= -inline const gp_Ax1& AIS_AngleDimension::Axis() const -{ - return myAxis; -} - -//======================================================================= -//function : SetAxis -//purpose : -//======================================================================= -inline void AIS_AngleDimension::SetAxis(const gp_Ax1& anAxis) -{ - myAxis = anAxis; -} diff --git a/src/AIS/AIS_Chamf2dDimension.cxx b/src/AIS/AIS_Chamf2dDimension.cxx index 043d72a901..946eff0ec9 100755 --- a/src/AIS/AIS_Chamf2dDimension.cxx +++ b/src/AIS/AIS_Chamf2dDimension.cxx @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -194,8 +194,8 @@ void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& , myPosition = curpos; } - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); //------------------------------------------------- //Calcul de la boite englobante du component pour diff --git a/src/AIS/AIS_Chamf3dDimension.cxx b/src/AIS/AIS_Chamf3dDimension.cxx index 0b3bfd77ce..aea7224beb 100755 --- a/src/AIS/AIS_Chamf3dDimension.cxx +++ b/src/AIS/AIS_Chamf3dDimension.cxx @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include @@ -170,8 +170,8 @@ void AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& , myPosition = curpos; } - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); //------------------------------------------------- //Calcul de la boite englobante du component pour diff --git a/src/AIS/AIS_DiameterDimension.cdl b/src/AIS/AIS_DiameterDimension.cdl deleted file mode 100755 index 7dae78c2aa..0000000000 --- a/src/AIS/AIS_DiameterDimension.cdl +++ /dev/null @@ -1,192 +0,0 @@ --- Created on: 1996-12-05 --- Created by: Jacques MINOT/Odile Olivier/Serguei ZARITCHNY --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified Mon 12-january-98 --- , - - -class DiameterDimension from AIS inherits Relation from AIS - - - ---Purpose: A framework to display diameter dimensions. - -- A diameter is displayed with arrows and text. The - -- text gives the length of the diameter. - -- The algorithm takes a length along a face and - -- analyzes it as an arc. It then reconstructs the circle - -- corresponding to the arc and calculates the - -- diameter of this circle. This diameter serves as a - -- relational reference in 3d presentations of the surface. - -uses - - Shape from TopoDS, - Circ from gp, - Pnt from gp, - Pln from gp, - Plane from Geom, - Surface from Geom, - Presentation from Prs3d, - PresentationManager3d from PrsMgr, - Selection from SelectMgr, - Projector from Prs3d, - Transformation from Geom, - ExtendedString from TCollection, - ArrowSide from DsgPrs, - KindOfSurface from AIS, - KindOfDimension from AIS - -raises ConstructionError from Standard - -is - Create (aShape : Shape from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: Constructs a diameter display object defined by the - -- shape aFShape, the dimension aVal and the text aText. - returns mutable DiameterDimension from AIS; - - Create (aShape : Shape from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - aDiamSymbol : Boolean from Standard; - anArrowSize : Real from Standard = 0.0) - ---Purpose: Constructs a diameter display object defined by the - -- shape aFShape, the dimension aVal and the text - -- aText, the point of origin of the diameter aPosition, - -- and the type of arrow aSymbolPrs with the size anArrowSize. - -- If the Boolean aDiamSymbol is true. - returns mutable DiameterDimension from AIS; - - KindOfDimension(me) returns KindOfDimension from AIS - ---C++: inline - ---Purpose: - -- Indicates that we are concerned with a length. - is redefined; - - IsMovable(me) returns Boolean from Standard - ---C++: inline - ---Purpose: - -- Returns true if the diameter dimension is movable - is redefined; - - DiamSymbol(me: mutable) returns Boolean from Standard - ---C++: inline - ---Purpose: - -- Returns the symbol for diameter dimension. This will - -- be either arrow, text, or a combination of both. - is static; - - SetDiamSymbol(me: mutable;aDiamSymbol: Boolean from Standard) - ---C++: inline - ---Purpose: - -- Sets the symbol for diameter dimension aDiamSymbol. - -- This can be an arrow, a text or both. - is static; - --- SetPlane(me: mutable; aPlane : Plane from Geom) --- is static; --- ---C++: inline - --- Plane(me) returns any Plane from Geom --- is static; --- ---C++: inline --- ---C++: return const & - - --- Methods from PresentableObject - - Compute(me : mutable; - aPresentationManager: PresentationManager3d from PrsMgr; - aPresentation : mutable Presentation from Prs3d; - aMode : Integer from Standard= 0) - is redefined private; - - Compute(me:mutable; - aProjector: Projector from Prs3d; - aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation : mutable Presentation from Prs3d) - is redefined; - ---Purpose: computes the presentation according to a point of view - -- given by . - -- To be Used when the associated degenerated Presentations - -- have been transformed by which is not a Pure - -- Translation. The HLR Prs can't be deducted automatically - -- WARNING : must be applied - -- to the object to display before computation !!! - --- Methods from SelectableObject - - ComputeSelection(me : mutable; - aSelection : mutable Selection from SelectMgr; - aMode : Integer from Standard) - is redefined private; - --- --- Computation private methods --- - - ComputeOneFaceDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeOneCylFaceDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d; - aSurfType : KindOfSurface from AIS; - aSurf : Surface from Geom ) - is private; - - ComputeOnePlanarFaceDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d ) - is private; - - ComputeOneEdgeDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeCircleDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeArcDiameter(me: mutable; - aPresentation : mutable Presentation from Prs3d; - ptFirst : Pnt from gp; - ptend : Pnt from gp) - is private; - - ComputeArcSelection(me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - -fields - - myCircle : Circ from gp; - myIsAnArc : Boolean from Standard; - myDiamSymbol : Boolean from Standard; - myFirstPar : Real from Standard; - myLastPar : Real from Standard; - -end DiameterDimension; diff --git a/src/AIS/AIS_DiameterDimension.cxx b/src/AIS/AIS_DiameterDimension.cxx index a51fa6bab4..8070b19f9f 100755 --- a/src/AIS/AIS_DiameterDimension.cxx +++ b/src/AIS/AIS_DiameterDimension.cxx @@ -24,78 +24,63 @@ #define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size // if any in all dimensions. +#include -#include - -#include +#include +#include +#include #include #include #include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - #include #include - -#include - -#include -#include -#include - -#include -#include +#include +#include #include -#include -#include -#include -#include -#include - #include #include #include #include #include #include - -#include -#include - -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include -#include +IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension) +IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension) //======================================================================= //function : Constructor //purpose : //======================================================================= -AIS_DiameterDimension::AIS_DiameterDimension(const TopoDS_Shape& aShape, - const Standard_Real aVal, - const TCollection_ExtendedString& aText) -:AIS_Relation(), - myDiamSymbol(Standard_True) +AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle) +: AIS_Dimension(), + myFlyout (0.0), + myCircle (theCircle) { - myPosition = gp_Pnt(0.,0.,0.); - myFShape = aShape; - myVal = aVal; - myText = aText; - mySymbolPrs = DsgPrs_AS_LASTAR; - myAutomaticPosition = Standard_True; - myArrowSize = myVal / 100.; + SetKindOfDimension(AIS_KOD_DIAMETER); + myIsInitialized = Standard_True; + SetSpecialSymbol (0x00D8); + SetDisplaySpecialSymbol (AIS_DSS_Before); + // Count attach points + myFirstPoint = ElCLib::Value (0, myCircle); + mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2); } //======================================================================= @@ -103,618 +88,162 @@ AIS_DiameterDimension::AIS_DiameterDimension(const TopoDS_Shape& aShape, //purpose : //======================================================================= -AIS_DiameterDimension::AIS_DiameterDimension(const TopoDS_Shape& aShape, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Boolean aDiamSymbol, - const Standard_Real anArrowSize) -:AIS_Relation(), - myDiamSymbol(aDiamSymbol) +AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_Pnt& theAttachPoint) +: AIS_Dimension(), + myFlyout (0.0), + myCircle (theCircle) { - myFShape = aShape; - myVal = aVal; - myText = aText; - mySymbolPrs = aSymbolPrs; - myPosition = aPosition; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif + SetKindOfDimension(AIS_KOD_DIAMETER); + SetSpecialSymbol (0x00D8); + SetDisplaySpecialSymbol (AIS_DSS_Before); + myFirstPoint = theAttachPoint; + // Count the second point + if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion()) + { + mySecondPoint = myFirstPoint.Translated(gp_Vec(myFirstPoint, theCircle.Location())*2); + } + else + { + myFirstPoint = ElCLib::Value(0, myCircle); + mySecondPoint = myFirstPoint.Translated(gp_Vec(myFirstPoint, theCircle.Location())*2); + } + myIsInitialized = Standard_True; } //======================================================================= -//function : Compute +//function : Constructor //purpose : //======================================================================= -void AIS_DiameterDimension::Compute( - const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer /*aMode*/) +AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle, + const Handle(Prs3d_DimensionAspect)& theDimensionStyle, + const Standard_Real theExtensionSize /*= 1.0*/) +: AIS_Dimension (theExtensionSize), + myFlyout (0.0), + myCircle (theCircle) { - aPresentation->Clear(); - - switch (myFShape.ShapeType()) { - case TopAbs_FACE : - { - // compute one face case - ComputeOneFaceDiameter (aPresentation); - break; - } - case TopAbs_EDGE: - { - ComputeOneEdgeDiameter (aPresentation); - break; - } - default: - break; - } - + SetKindOfDimension(AIS_KOD_DIAMETER); + SetSpecialSymbol (0x00D8); + SetDisplaySpecialSymbol(AIS_DSS_Before); + myDrawer->SetDimensionAspect(theDimensionStyle); + myIsInitialized = Standard_True; } //======================================================================= -//function : Compute -//purpose : to avoid warning +//function : Constructor +//purpose : Universal constructor for diameter dimension of shape //======================================================================= -void AIS_DiameterDimension::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) -{ -// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; -} - -void AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) +AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape) +: AIS_Dimension (), + myFlyout (0.) { -// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; + SetKindOfDimension(AIS_KOD_DIAMETER); + SetSpecialSymbol (0x00D8); + SetDisplaySpecialSymbol(AIS_DSS_Before); + myFirstShape = theShape; + myIsInitialized = Standard_False; } //======================================================================= -//function : ComputeSelection +//function : Compute //purpose : //======================================================================= -void AIS_DiameterDimension::ComputeSelection( - const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer /*aMode*/) +void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) { - Handle(AIS_DimensionOwner) own = new AIS_DimensionOwner(this,7); - own->SetShape(myFShape); - - if (!myIsAnArc) { - gp_Pnt AttachmentPoint = myPosition; - Standard_Real parat = ElCLib::Parameter(myCircle,AttachmentPoint); - gp_Pnt ptoncirc = ElCLib::Value (parat,myCircle); - - // ligne de cote - - gp_Pnt center = myCircle.Location(); - gp_Vec vecrap (ptoncirc,center); - - Standard_Real dist = center.Distance(AttachmentPoint); - Standard_Real aRadius = myCircle.Radius(); - Standard_Real inside = Standard_False; - - gp_Pnt pt1 = AttachmentPoint; - if (dist < aRadius) { - pt1 = ptoncirc; - dist = aRadius; - inside = Standard_True; - } - vecrap.Normalize(); - vecrap *= (dist+aRadius); - gp_Pnt OppositePoint = pt1.Translated(vecrap); - - if ( pt1.Distance(OppositePoint)>=Precision::Confusion()) { - Handle(Select3D_SensitiveSegment) - seg = new Select3D_SensitiveSegment(own,pt1 ,OppositePoint); - aSelection->Add(seg); - } + thePresentation->Clear(); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + + if (!myIsInitialized) + { + if (!initCircularDimension (myFirstShape, myCircle, + myFirstPoint, mySecondPoint)) + return; + else + myIsInitialized = Standard_True; } - else - ComputeArcSelection(aSelection); - - // Text - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + size, - myPosition.Y() + size, - myPosition.Z() + size); - aSelection->Add(box); -} -//========================================================================== -// function : ComputeArcSelection -// purpose : -// -//========================================================================== + if (!myIsWorkingPlaneCustom) + countDefaultPlane(); -void AIS_DiameterDimension::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection) -{ + //Count flyout direction + gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); + // Count a flyout direction vector. + gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; + gp_Ax3 aLocalSystem (myFirstPoint, aTargetPointsVector, aFlyoutVector); - Standard_Real fpara; - Standard_Real lpara; - fpara = myFirstPar; - lpara = myLastPar; + // Create lines for layouts + gp_Lin aLine1 (myFirstPoint, aFlyoutVector); + gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7); - gp_Pnt theCenter = myCircle.Location(); - while (lpara > 2*M_PI) { - fpara -= 2*M_PI; - lpara -= 2*M_PI; - } - Standard_Real parat = ElCLib::Parameter(myCircle,myPosition); - Standard_Boolean otherside(Standard_False); - gp_Pnt attpoint = myPosition; - - if (!AIS::InDomain(fpara,lpara,parat)) { - Standard_Real otherpar = parat + M_PI; - if (otherpar > 2*M_PI) otherpar -= 2*M_PI; - if (AIS::InDomain(fpara,lpara,otherpar)) { - parat = otherpar; - otherside = Standard_True; - } - else { - Standard_Real ecartpar = Min(Abs(fpara-parat), - Abs(lpara-parat)); - Standard_Real ecartoth = Min(Abs(fpara-otherpar), - Abs(lpara-otherpar)); - if (ecartpar <= ecartoth) { - if (parat < fpara) parat = fpara; - else parat = lpara; - } - else { - otherside = Standard_True; - if (otherpar < fpara) parat = fpara; - else parat = lpara; - } - gp_Pnt ptdir = ElCLib::Value(parat,myCircle); - gp_Lin lsup(theCenter, - gp_Dir(ptdir.XYZ()-theCenter.XYZ())); - Standard_Real parpos = ElCLib::Parameter(lsup,myPosition); - attpoint = ElCLib::Value(parpos,lsup); - } - } - gp_Pnt ptoncirc = ElCLib::Value(parat,myCircle); - gp_Lin L (theCenter,gp_Dir(attpoint.XYZ()-theCenter.XYZ())); - gp_Pnt firstpoint = attpoint; - gp_Pnt drawtopoint = ptoncirc; - - if (!otherside) { - Standard_Real uatt = ElCLib::Parameter(L,attpoint); - Standard_Real uptc = ElCLib::Parameter(L,ptoncirc); - if (Abs(uatt) > Abs(uptc)) { - drawtopoint = theCenter; - } - else { - firstpoint = theCenter; - } + // Get flyout end points + gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); + + // Add layout lines to graphic group + // Common to all type of dimension placement. + if (theMode == 0) + { + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); + aPrimSegments->AddVertex (myFirstPoint); + aPrimSegments->AddVertex (aFlyoutEnd1); + + aPrimSegments->AddVertex (mySecondPoint); + aPrimSegments->AddVertex (aFlyoutEnd2); + + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); } - Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(own,firstpoint,drawtopoint); - aSelection->Add(seg); + drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode); } //======================================================================= -//function : ComputeOneFaceDiameter +//function : computeValue //purpose : //======================================================================= -void AIS_DiameterDimension::ComputeOneFaceDiameter( - const Handle(Prs3d_Presentation)& aPresentation) +void AIS_DiameterDimension::computeValue () { - //cout<<"AIS_DiameterDimension::ComputeOneFaceDiameter"<GetType() == GeomAbs_Line) - ExpectedType = Standard_True; - } - else if (aSurfType == AIS_KOS_Extrusion) - { - BasisCurve = surf1.BasisCurve(); - if ( BasisCurve->GetType() == GeomAbs_Circle ) - ExpectedType = Standard_True; - } - if(!ExpectedType) { - Standard_ConstructionError::Raise("AIS:: Not expected type of surface") ; - return; - } - // - Handle(Geom_Curve) aCurve; - aCurve = aBasisSurf->VIso(vMid); - if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) - { - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();//gp_Circ - } - else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { - Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve); - aCurve = tCurve->BasisCurve(); - uFirst = tCurve->FirstParameter(); - uLast = tCurve->LastParameter(); - if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();//gp_Circ - } - else { - // compute a circle from 3 points on "aCurve" - gp_Pnt P1, P2; - surf1.D0(uFirst, vMid, P1); - surf1.D0(uLast, vMid, P2); - GC_MakeCircle mkCirc(P1, curPos, P2); - myCircle = mkCirc.Value()->Circ(); - } - myCircle.SetRadius(myVal/2.); - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ - gp_Vec v1(myCircle.Location(), curPos); - v1.Normalize(); - v1 = v1 * myVal*1.2; - myPosition = myCircle.Location().Translated(v1); -// IsArc ? - gp_Pnt p1, p2; - p1 = ElCLib::Value (uFirst, myCircle); - p2 = ElCLib::Value (uLast, myCircle); - if ( p1.IsEqual(p2, Precision::Confusion()) ) - myIsAnArc = Standard_False; - else myIsAnArc = Standard_True; - myFirstPar = uFirst; - myLastPar = uLast; -// myPosition = curPos; - myAutomaticPosition = Standard_True; - if ( myIsSetBndBox ) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(), - myPosition ) ), myBndBox ); - } - else { // !AutomaticPosition - curPos = myPosition; - curPos = AIS::ProjectPointOnPlane( curPos, myPlane->Pln() ); - myPosition = curPos; - } - - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - - // size -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { - myArrowSize = Min(myArrowSize,myCircle.Radius()/5.); - } - arr->SetLength(myArrowSize); -#else - if (myCircle.Radius()/5. > myArrowSize) { - arr->SetLength(myArrowSize); - } - else { - arr->SetLength(myCircle.Radius()/5.); - } -#endif - - //cout<<"AIS_DiameterDimension:: add Prs"< + ResetWorkingPlane (); } - //======================================================================= -//function : ComputeCircleDiameter +//function : SetFlyout //purpose : //======================================================================= -void AIS_DiameterDimension::ComputeCircleDiameter(const Handle(Prs3d_Presentation)& aPresentation) +void AIS_DiameterDimension::SetFlyout (const Standard_Real theFlyout) { - gp_Pnt center = myCircle.Location(); - Standard_Real rad = myCircle.Radius(); - gp_Pnt curpos; - - if (myAutomaticPosition) { -// we compute 1 point on the circle - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ - gp_Dir xdir = myCircle.XAxis().Direction(); - Standard_Real deport = rad *1.2; - curpos = center.Translated( gp_Vec(xdir)*deport ); - SetPosition (curpos);// myPosition = curpos - myAutomaticPosition = Standard_True; - if (myIsSetBndBox) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(), - myPosition ) ), myBndBox ); - } - else { - curpos = myPosition; - // VRO (2007-05-17) inserted this IF. - if (myPlane.IsNull()) - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position()))); - myPosition = AIS::ProjectPointOnPlane( curpos, myPlane->Pln() ); - } - - // size - Handle(Prs3d_LengthAspect) LA = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = LA->Arrow1Aspect(); - -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { - myArrowSize = Min(myArrowSize,myCircle.Radius()/5.); - } - arr->SetLength(myArrowSize); -#else - if (myCircle.Radius()/5. > myArrowSize) { - arr->SetLength(myArrowSize); - } - else { - arr->SetLength(myCircle.Radius()/5.); - } -#endif - - DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition, myCircle, - DsgPrs_AS_BOTHAR, myDiamSymbol ); - + myFlyout = theFlyout; } -//========================================================================== -// function : ComputeArcDiameter -// purpose : -// -//========================================================================== - -void AIS_DiameterDimension::ComputeArcDiameter( - const Handle(Prs3d_Presentation)& aPresentation, - const gp_Pnt& pfirst, - const gp_Pnt& pend) -{ - - gp_Pnt center = myCircle.Location(); - Standard_Real rad = myCircle.Radius(); - - gp_Pnt curpos; - Standard_Real parfirst, parend; - - parfirst = ElCLib::Parameter(myCircle, pfirst); - parend = ElCLib::Parameter(myCircle, pend); - myFirstPar = parfirst; - myLastPar = parend; - if ( parfirst > parend) { - parfirst -= 2*M_PI; - } - if (myAutomaticPosition) { - Standard_Real pcurpos = (parfirst + parend)/2.; - curpos = ElCLib::Value(pcurpos, myCircle); - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ - gp_Dir vdir(gp_Vec(myCircle.Location(),curpos)); - Standard_Real deport = rad * 1.2; - curpos = center.Translated( gp_Vec(vdir)*deport ); - - SetPosition (curpos); - myAutomaticPosition = Standard_True; - - if ( myIsSetBndBox ) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(), - myPosition ) ), myBndBox ); - - } - else { - curpos = myPosition; - myPosition = AIS::ProjectPointOnPlane( curpos, myPlane->Pln() ); - } - - // size - - Handle(Prs3d_LengthAspect) LA = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = LA->Arrow1Aspect(); - -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { - myArrowSize = Min(myArrowSize,myCircle.Radius()/5.); - } - arr->SetLength(myArrowSize); -#else - if (myCircle.Radius()/5. > myArrowSize) { - arr->SetLength(myArrowSize); - } - else { - arr->SetLength(myCircle.Radius()/5.); - } -#endif - - // Display - DsgPrs_DiameterPresentation::Add (aPresentation, myDrawer, myText, myPosition, myCircle, - parfirst, parend, mySymbolPrs, myDiamSymbol); - -} - - -//========================================================================== -// function : ComputeOneEdgeDiameter -// purpose : -// -//========================================================================== - -void AIS_DiameterDimension::ComputeOneEdgeDiameter(const Handle(Prs3d_Presentation)& aPresentation) -{ - gp_Pnt ptfirst,ptend; - Handle(Geom_Curve) curv; - if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),curv,ptfirst,ptend)) return; - - Handle(Geom_Circle) circ = Handle(Geom_Circle)::DownCast(curv); - if ( circ.IsNull()) return; - - myCircle = circ->Circ(); - myCircle.SetRadius(myVal/2.); - if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) { - myIsAnArc = Standard_False; - ComputeCircleDiameter(aPresentation); - } - else { - myIsAnArc = Standard_True; - ComputeArcDiameter(aPresentation,ptfirst,ptend ); - } -} - -//=================================================================== -//function : CircleFromPlanarFace -//purpose : if possible computes circle from planar face //======================================================================= -static Standard_Boolean CircleFromPlanarFace(const TopoDS_Face& aFace, - Handle(Geom_Curve)& aCurve, - gp_Pnt & ptfirst, gp_Pnt & ptend) -{ - TopExp_Explorer ExploEd( aFace, TopAbs_EDGE ); - for ( ; ExploEd.More(); ExploEd.Next()) - { - TopoDS_Edge curedge = TopoDS::Edge( ExploEd.Current() ); - if (AIS::ComputeGeometry(curedge, aCurve, ptfirst, ptend)) - if(aCurve->IsInstance(STANDARD_TYPE(Geom_Circle)) && - !Handle(Geom_Circle)::DownCast(aCurve).IsNull()) - return Standard_True; - } - return Standard_False; -} - -//======================================================================= -//function : ComputeOnePlanarFaceDiameter +//function : GetFlyout //purpose : //======================================================================= -void AIS_DiameterDimension::ComputeOnePlanarFaceDiameter(const Handle(Prs3d_Presentation)& aPresentation) +Standard_Real AIS_DiameterDimension::GetFlyout () const { - gp_Pnt curPos ; - Standard_Real parfirst =0., parend =0.; - if (myAutomaticPosition) { - Handle(Geom_Curve) curv; - gp_Pnt ptfirst,ptend; - - if( !CircleFromPlanarFace( TopoDS::Face( myFShape ), curv, ptfirst, ptend) ) { - Standard_ConstructionError::Raise("AIS:: Curve is not a circle or is Null") ; - return; - } - - myCircle = Handle(Geom_Circle)::DownCast(curv)->Circ(); - if ( ptfirst.IsEqual(ptend, Precision::Confusion()) ) - myIsAnArc = Standard_False; - else - myIsAnArc = Standard_True; - myCircle.SetRadius(myVal/2.);// - BRepAdaptor_Surface surfAlgo (TopoDS::Face(myFShape)); - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position())));//gp_Circ - gp_Pnt center = myCircle.Location(); - Standard_Real rad = myCircle.Radius(); - Standard_Real deport = rad * 1.2; - if(! myIsAnArc ) { // Circle - gp_Dir xdir = myCircle.XAxis().Direction(); - curPos = center.Translated( gp_Vec(xdir)*deport ); - } - else { // Arc - parfirst = ElCLib::Parameter(myCircle, ptfirst); - parend = ElCLib::Parameter(myCircle, ptend); - if ( parfirst > parend) { - parfirst -= 2*M_PI; - } - Standard_Real parcurPos = (parfirst + parend) * 0.5; - curPos = ElCLib::Value(parcurPos, myCircle); - gp_Vec v1( center, curPos ); - v1.Normalize(); - curPos = center.Translated( v1 * deport ); - } - myFirstPar = parfirst; - myLastPar = parend; - myPosition = curPos; - myAutomaticPosition = Standard_True; - if ( myIsSetBndBox ) - myPosition = AIS::TranslatePointToBound( myPosition, gp_Dir( gp_Vec( myCircle.Location(), - myPosition ) ), myBndBox ); - } else - { - // !myAutomaticPosition - // Project point on the plane of face - curPos = myPosition; - curPos = AIS::ProjectPointOnPlane( curPos, myPlane->Pln() ); - myPosition = curPos; - } - - - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - - // size -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { - myArrowSize = Min(myArrowSize,myCircle.Radius()/5.); - } - arr->SetLength(myArrowSize); -#else - if (myCircle.Radius()/5. > myArrowSize) { - arr->SetLength(myArrowSize); - } - else { - arr->SetLength(myCircle.Radius()/5.); - } -#endif - - if(! myIsAnArc ) - DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition, - myCircle, DsgPrs_AS_BOTHAR, myDiamSymbol); - else - DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition, - myCircle, myFirstPar, myLastPar, mySymbolPrs, myDiamSymbol ); + return myFlyout; } - diff --git a/src/AIS/AIS_DiameterDimension.hxx b/src/AIS/AIS_DiameterDimension.hxx new file mode 100644 index 0000000000..e2efbc14b4 --- /dev/null +++ b/src/AIS/AIS_DiameterDimension.hxx @@ -0,0 +1,85 @@ +// Copyright (c) 1995-1999 Matra Datavision +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. +#ifndef _AIS_DiameterDimension_HeaderFile +#define _AIS_DiameterDimension_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(AIS_DiameterDimension,AIS_Dimension) + +//! A framework to display diameter dimensions.
+//! A diameter is displayed with arrows and text. The
+//! text gives the length of the diameter.
+//! The algorithm takes a length along a face and
+//! analyzes it as an arc. It then reconstructs the circle
+//! corresponding to the arc and calculates the
+//! diameter of this circle. This diameter serves as a
+//! relational reference in 3d presentations of the surface.
+class AIS_DiameterDimension : public AIS_Dimension +{ +public: + //! Constructs a diameter display object defined by the
+ //! circle + Standard_EXPORT AIS_DiameterDimension(const gp_Circ& theCircle); + //! Consctructor that allows to set a attach point
+ //! on the circle where to attach dimension + Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, + const gp_Pnt& theAttachPoint); + + Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, + const Handle(Prs3d_DimensionAspect)& theDimensionStyle, + const Standard_Real theExtensionSize = 1.0); + + Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape); + + + Standard_EXPORT void SetFlyout(const Standard_Real theFlyout); + + Standard_EXPORT Standard_Real GetFlyout () const; + + DEFINE_STANDARD_RTTI(AIS_DiameterDimension) + +protected: + + Standard_EXPORT virtual void computeValue (); + //! Fills default plane object if it is possible to count plane automatically. + Standard_EXPORT virtual void countDefaultPlane (); + +private: + + virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0); + +// Fields + + //! Defines flyout lines and direction + //! Flyout direction in the working plane (stored in the base AIS_Dimension). + //! can be negative , or positive and is defined by the sign of value. + //! The direction vector is counting using the working plane. + //! value defined the size of flyout. + Standard_Real myFlyout; + gp_Circ myCircle; +}; +#endif diff --git a/src/AIS/AIS_DiameterDimension.lxx b/src/AIS/AIS_DiameterDimension.lxx deleted file mode 100755 index 9c364611b8..0000000000 --- a/src/AIS/AIS_DiameterDimension.lxx +++ /dev/null @@ -1,61 +0,0 @@ -// Created on: 1997-02-28 -// Created by: Jean-Pierre COMBE, Serguei ZARITCHNY -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified Mon 12-january-98 -// - -//======================================================================= -//function : KindOfDimension -//purpose : -//======================================================================= -inline AIS_KindOfDimension AIS_DiameterDimension::KindOfDimension() const -{ - return AIS_KOD_DIAMETER; -} - -//======================================================================= -//function : IsMovable -//purpose : -//======================================================================= -inline Standard_Boolean AIS_DiameterDimension::IsMovable() const -{ - return Standard_True; -} - -//======================================================================= -//function : DiamSymbol -//purpose : -//======================================================================= - -inline Standard_Boolean AIS_DiameterDimension::DiamSymbol() -{ - return myDiamSymbol; -} - - -//======================================================================= -//function : SetDiamSymbol -//purpose : -//======================================================================= - -inline void AIS_DiameterDimension::SetDiamSymbol(const Standard_Boolean aDiamSymbol) -{ - myDiamSymbol = aDiamSymbol; -} diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx new file mode 100644 index 0000000000..c4be69592e --- /dev/null +++ b/src/AIS/AIS_Dimension.cxx @@ -0,0 +1,1344 @@ +// Copyright (c) 1999-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) +IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension, AIS_InteractiveObject) + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= + +AIS_Dimension::AIS_Dimension (const Standard_Real theExtensionSize /*= 1.0*/) +: AIS_InteractiveObject(), + myDefaultPlane (gp_Pln (gp::XOY())), + myIsWorkingPlaneCustom (Standard_False), + myValue (0.0), + myIsValueCustom (Standard_False), + myUnitsQuantity (TCollection_AsciiString("LENGTH")), + myToDisplayUnits (Standard_False), + mySpecialSymbol (' '), + myDisplaySpecialSymbol (AIS_DSS_No), + myIsTextReversed (Standard_False), + myTextOffset (DimensionAspect()->ArrowAspect()->Length()), + myIsInitialized (Standard_False), + myKindOfDimension (AIS_KOD_NONE), + myExtensionSize (theExtensionSize) +{ + ResetWorkingPlane(); + // Units default settings + UnitsAPI::SetLocalSystem (UnitsAPI_SI); + myModelUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); + myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); +} + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= + +AIS_Dimension::AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect, + const Standard_Real theExtensionSize /*= 1.0*/) +: AIS_InteractiveObject(), + myDefaultPlane (gp_Pln (gp::XOY())), + myIsWorkingPlaneCustom (Standard_False), + myValue (0.0), + myIsValueCustom (Standard_False), + myUnitsQuantity (TCollection_AsciiString("LENGTH")), + myToDisplayUnits (Standard_False), + mySpecialSymbol (' '), + myDisplaySpecialSymbol (AIS_DSS_No), + myIsTextReversed (Standard_False), + myTextOffset (DimensionAspect()->ArrowAspect()->Length()), + myIsInitialized (Standard_False), + myKindOfDimension (AIS_KOD_NONE), + myExtensionSize (theExtensionSize) +{ + ResetWorkingPlane(); + // Units default settings + UnitsAPI::SetLocalSystem (UnitsAPI_SI); + myModelUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); + myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); + SetDimensionAspect (theAspect); +} + +//======================================================================= +//function : AcceptDisplayMode +//purpose : Checks if display mode is allowed to display object. +//======================================================================= + +Standard_Boolean AIS_Dimension::AcceptDisplayMode (const Standard_Integer theMode) const +{ + return theMode == 0 ? Standard_True : Standard_False; +} + +//======================================================================= +//function : computeValue +//purpose : Computes dimension value in display units. +//======================================================================= + +void AIS_Dimension::computeValue() +{ + UnitsAPI::SetCurrentUnit (myUnitsQuantity.ToCString(), myModelUnits.ToCString()); + myValue = UnitsAPI::CurrentFromLS (myValue, myUnitsQuantity.ToCString()); + myValue = valueToDisplayUnits(); +} + +//======================================================================= +//function : countDefaultPlane +//purpose : +//======================================================================= + +void AIS_Dimension::countDefaultPlane() +{ +} + +//======================================================================= +//function : GetWorkingPlane +//purpose : +//======================================================================= + +const gp_Pln& AIS_Dimension::GetWorkingPlane() const +{ + return myWorkingPlane; +} + +//======================================================================= +//function : SetWorkingPlane +//purpose : +//======================================================================= + +void AIS_Dimension::SetWorkingPlane (const gp_Pln& thePlane) +{ + myWorkingPlane = thePlane; + myIsWorkingPlaneCustom = Standard_True; +} + +//======================================================================= +//function : ResetWorkingPlane +//purpose : Set default value of working plane +//======================================================================= + +void AIS_Dimension::ResetWorkingPlane() +{ + myWorkingPlane = myDefaultPlane; + myIsWorkingPlaneCustom = Standard_False; +} + +//======================================================================= +//function : resetWorkingPlane +//purpose : Set default value of working plane +// Only for internal use. +//======================================================================= + +void AIS_Dimension::resetWorkingPlane (const gp_Pln& theNewDefaultPlane) +{ + myDefaultPlane = theNewDefaultPlane; + ResetWorkingPlane(); +} + +//======================================================================= +//function : valueInDisplayUnits +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::valueToDisplayUnits() +{ + return UnitsAPI::AnyToAny (myValue, + myModelUnits.ToCString(), + myDisplayUnits.ToCString()); +} + +//======================================================================= +//function : KindOfDimension +//purpose : +//======================================================================= + +AIS_KindOfDimension AIS_Dimension::KindOfDimension() const +{ + return myKindOfDimension; +} + +//======================================================================= +//function : SetKindOfDimension +//purpose : +//======================================================================= + +void AIS_Dimension::SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension) +{ + myKindOfDimension = theKindOfDimension; +} + +//======================================================================= +//function : SetExtensionSize +//purpose : +//======================================================================= + +void AIS_Dimension::SetExtensionSize (const Standard_Real theExtensionSize) +{ + myExtensionSize = theExtensionSize; +} + +//======================================================================= +//function : GetExtensionSize +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::GetExtensionSize() const +{ + return myExtensionSize; +} + +//======================================================================= +//function : GetValue +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::GetValue() const + { + return myValue; + } + +//======================================================================= +//function : SetCustomValue +//purpose : +//======================================================================= + +void AIS_Dimension::SetCustomValue (const Standard_Real theValue) +{ + myValue = theValue; + myIsValueCustom = Standard_True; +} + +//======================================================================= +//function : SetFirstShape +//purpose : +//======================================================================= + +void AIS_Dimension::SetFirstShape (const TopoDS_Shape& theShape) +{ + myFirstShape = theShape; + myIsInitialized = Standard_False; + resetGeom(); +} + +//======================================================================= +//function : SetSecondShape +//purpose : +//======================================================================= + +void AIS_Dimension::SetSecondShape (const TopoDS_Shape& theShape) +{ + mySecondShape = theShape; + myIsInitialized = Standard_False; + resetGeom(); +} + +//======================================================================= +//function : getTextWidthAndString +//purpose : +//======================================================================= + +void AIS_Dimension::getTextWidthAndString (Quantity_Length& theWidth, + TCollection_ExtendedString& theString) const +{ + char aValueSimpleStr[25]; + sprintf (aValueSimpleStr, "%g", GetValue()); + theString = TCollection_ExtendedString (aValueSimpleStr); + + if (IsUnitsDisplayed()) + { + theString += " "; + theString += TCollection_ExtendedString (myDisplayUnits); + } + + if (myDisplaySpecialSymbol == AIS_DSS_Before) + { + theString = TCollection_ExtendedString (mySpecialSymbol) + theString; + } + else if (myDisplaySpecialSymbol == AIS_DSS_After) + { + theString += TCollection_ExtendedString (mySpecialSymbol); + } + + // Get font length + // Get expansion ratio for getting a width of symbols + Quantity_Color aColor; + Standard_CString aFont; + Standard_Real aFactor; + Standard_Real aSpace; + myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFont, aFactor, aSpace); + theWidth = (myDrawer->DimensionAspect()->TextAspect()->Height() / aFactor) * theString.Length(); +} + +//======================================================================= +//function : drawArrow +//purpose : +//======================================================================= + +void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theLocation, + const gp_Dir& theDirection) +{ + Prs3d_Root::NewGroup (thePresentation); + Quantity_Length anArrowLength = myDrawer->DimensionAspect()->ArrowAspect()->Length(); + + if (myDrawer->DimensionAspect()->IsArrows3d()) + { + Prs3d_Arrow::Draw (thePresentation, + theLocation, + theDirection.Reversed(), + myDrawer->DimensionAspect()->ArrowAspect()->Angle(), + anArrowLength); + } + else + { + gp_Vec anArrowDir (theDirection); + Quantity_Length theCathetusLength = anArrowLength / Cos (M_PI / 9.0); + Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3); + gp_Pnt aLeftPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI / 9.0) * theCathetusLength)); + gp_Pnt aRightPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI * 17.0 / 9.0) * theCathetusLength)); + + anArrow->AddVertex (aLeftPoint); + anArrow->AddVertex (theLocation); + anArrow->AddVertex (aRightPoint); + + // Set aspect for arrow triangles + Quantity_Color aColor; + Aspect_TypeOfLine aTOL; + Standard_Real aWidth; + myDrawer->DimensionAspect()->ArrowAspect()->Aspect()->Values (aColor, aTOL, aWidth); + Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); + myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor); + myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor); + myDrawer->ShadingAspect()->SetMaterial (aShadeMat); + Prs3d_Root::CurrentGroup(thePresentation)->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); + Prs3d_Root::CurrentGroup(thePresentation)->AddPrimitiveArray (anArrow); + } +} + +//======================================================================= +//function : drawText +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Dir& theTextDir, + const TCollection_ExtendedString theText, + const AIS_DimensionDisplayMode theMode) +{ + Standard_Real aTextWidth (0.0), aTextHeight (0.0); + if (theMode == AIS_DDM_Line) + return aTextWidth; + // Creating new group for text + Prs3d_Root::NewGroup (thePresentation); + + if (myDrawer->DimensionAspect()->IsText3d()) + { + // Getting font parameters + Quantity_Color aColor; + Standard_CString aFontName; + Standard_Real anExpansionFactor; + Standard_Real aSpace; + myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, anExpansionFactor, aSpace); + Font_FontAspect aFontAspect = myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect(); + Standard_Real aHeight = myDrawer->DimensionAspect()->TextAspect()->Height(); + + // Creating TopoDS_Shape for text + Font_BRepFont aFont (aFontName, aFontAspect, aHeight); + NCollection_String aText = (Standard_Utf16Char* )theText.ToExtString(); + TopoDS_Shape aTextShape = aFont.RenderText (aText); + + // Formating text position in XOY plane + Bnd_Box aTextBndBox; + BRepBndLib::AddClose (aTextShape, aTextBndBox); + Standard_Real aXMin, anYMin, aZMin, aXMax, anYMax, aZMax; + aTextBndBox.Get (aXMin, anYMin, aZMin, aXMax, anYMax, aZMax); + aTextWidth = aXMax - aXMin; + aTextHeight = anYMax - anYMin; + gp_Dir aTextDir (theTextDir); + Standard_Real aHorizontalOffset (0.0), aVerticalOffset (0.0); + switch (myDrawer->DimensionAspect()->HorizontalTextAlignment()) + { + case Prs3d_HTA_Left: + aTextDir.Reverse(); + aHorizontalOffset = -aTextWidth; + break; + case Prs3d_HTA_Center: + aHorizontalOffset = -(aTextWidth / 2.0); + break; + case Prs3d_HTA_Right: + aHorizontalOffset = 0.0; + break; + } + switch (myDrawer->DimensionAspect()->VerticalTextAlignment()) + { + case Prs3d_VTA_Top: + aVerticalOffset = 0.0; + break; + case Prs3d_VTA_Center: + aVerticalOffset = -(aTextHeight / 2.0); + break; + case Prs3d_VTA_Bottom: + aVerticalOffset = -aTextHeight; + break; + } + gp_Trsf aTrsf; + aTrsf.SetTranslation (gp_Pnt (), gp_Pnt (aHorizontalOffset, aVerticalOffset, 0.0)); + aTextShape.Move (aTrsf); + + // Transform text to myWorkingPlane coordinate system + gp_Ax3 aPenAx3 (myGeom.myTextPosition, myWorkingPlane.Axis().Direction(), aTextDir); + aTrsf.SetTransformation (aPenAx3, gp_Ax3 (gp::XOY())); + aTextShape.Move (aTrsf); + + // Set display parameters for advanced selection + BRepBndLib::AddClose (aTextShape, myGeom.myTextBndBox); + // Drawing text + if (myDrawer->DimensionAspect()->IsTextShaded()) + { + // Setting text shading and color parameters + Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); + aShadeMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); + myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor); + myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor); + myDrawer->ShadingAspect()->SetMaterial (aShadeMat); + + // Drawing text + StdPrs_ShadedShape::Add (thePresentation, aTextShape, myDrawer); + } + else + { + // Setting color for text + myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor); + // Drawing text + StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer); + } + // Creating new group for lines + Prs3d_Root::NewGroup (thePresentation); + } + else + { + myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION); + Prs3d_Text::Draw (thePresentation, + myDrawer->DimensionAspect()->TextAspect(), + theText, + myGeom.myTextPosition); + + // For 2d text we don not create new group for lines and draw them in the same group with text + // for the proper handling of stencil test buffer. + } + + return aTextWidth; +} + + //======================================================================= +//function : drawExtensionWithText +//purpose : +//======================================================================= + +void AIS_Dimension::drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theStartPoint, + const gp_Lin& theDimensionLine, + const TCollection_ExtendedString& theValueString, + const AIS_DimensionDisplayMode theMode) +{ + Handle(SelectMgr_EntityOwner) anEmptyOwner; + Standard_Boolean isGapInCenter = (myDrawer->DimensionAspect()->VerticalTextAlignment() == Prs3d_VTA_Center + && myDrawer->DimensionAspect()->IsText3d()); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isGapInCenter ? 4 : 2); + + gp_Dir anAttachPointsVector = myWorkingPlane.Axis().Direction() ^ gce_MakeDir (myFirstPoint, mySecondPoint); + Standard_Real aGap = 1.; + Standard_Real aStartParam = ElCLib::Parameter (theDimensionLine, theStartPoint); + + // Text + Standard_Real aTextParam = isGapInCenter ? aStartParam + myTextOffset + aGap : aStartParam + myTextOffset; + myGeom.myTextPosition = ElCLib::Value (aTextParam, theDimensionLine); + Standard_Real aTextWidth = drawText (thePresentation, + myIsTextReversed ? theDimensionLine.Direction().Reversed() + : theDimensionLine.Direction(), + theValueString, + theMode); + gp_Pnt aFirstPoint, aLastPoint; + aFirstPoint = theStartPoint; + Standard_Real aParam = isGapInCenter ? aTextParam + aTextWidth + aGap : aTextParam + aTextWidth; + + // If text separates dimension line into two parts (4 points) + if (isGapInCenter) + { + aLastPoint = ElCLib::Value (aStartParam + myTextOffset, theDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + aFirstPoint = ElCLib::Value (aParam, theDimensionLine); + } + + // Draw additional line segment only after 3D text + if (myDrawer->DimensionAspect()->IsText3d()) + { + aParam += myTextOffset; + } + + aLastPoint = ElCLib::Value (aParam, theDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + + // Extension line in the same group + if (theMode != AIS_DDM_Text) + { + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); + } + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); + } + } +} + +//======================================================================= +//function : SetDimensionAspect +//purpose : +//======================================================================= + +void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect) +{ + myDrawer->SetDimensionAspect (theDimensionAspect); +} + +//======================================================================= +//function : DimensionAspect +//purpose : +//======================================================================= + +Handle(Prs3d_DimensionAspect) AIS_Dimension::DimensionAspect() const +{ + return myDrawer->DimensionAspect(); +} + +//======================================================================= +//function : SetTextOffset +//purpose : +//======================================================================= + +void AIS_Dimension::SetTextOffset (const Standard_Real theOffset) +{ + myTextOffset = theOffset; +} + +//======================================================================= +//function : TextOffset +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::TextOffset() const +{ + return myTextOffset; +} + +//======================================================================= +//function : drawLinearDimension +//purpose : +//======================================================================= + +void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const AIS_DimensionDisplayMode theMode, + const Standard_Boolean isOneSideDimension/* = Standard_False*/) +{ + // Don't build any dimension for equal points + if (myFirstPoint.IsEqual (mySecondPoint, Precision::Confusion())) + { + setComputed (Standard_False); + return; + } + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Handle(SelectMgr_EntityOwner) anEmptyOwner; + myGeom.mySensitiveSegments.Clear(); + + gp_Dir aAttachPointsVector = GetWorkingPlane().Axis().Direction()^gce_MakeDir (myFirstPoint, mySecondPoint); + // Get line of the dimension + gp_Lin aDimensionLine = gce_MakeLin (theFirstAttach, theSecondAttach); + + // Get parameters on dimension line of two layout points + Standard_Real aParam1 = ElCLib::Parameter (aDimensionLine, theFirstAttach); + Standard_Real aParam2 = ElCLib::Parameter (aDimensionLine, theSecondAttach); + + // For extensions we need to know arrow size and text size, get it from aspect + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + // Set line parameters + Standard_Real aGap = 0.; // gap between line and text if AIS_VTA_Center + if (!myIsValueCustom) + { + computeValue(); + } + + TCollection_ExtendedString aValueString; + Standard_Real aTextLength; + getTextWidthAndString (aTextLength, aValueString); + + // Automatical text and arrow placement + Standard_Real aValue = myFirstPoint.Distance (mySecondPoint); + if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center) + { + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal); + if (aValue < aTextLength + (isOneSideDimension ? anArrowLength : 2.0 * anArrowLength)) + { + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); + aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left); + } + } + else + { + aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); + } + + // Arrows positions and directions + gp_Pnt aFirstArrowPosition = ElCLib::Value (aParam1, aDimensionLine); + gp_Pnt aSecondArrowPosition = ElCLib::Value (aParam2, aDimensionLine); + gp_Dir aFirstArrowDir = aDimensionLine.Direction(); + gp_Dir aSecondArrowDir = aDimensionLine.Direction().Reversed(); + Standard_Real aFirstArrowBegin, aFirstArrowEnd, aSecondArrowBegin, aSecondArrowEnd; + + if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External) + { + aFirstArrowDir.Reverse(); + aSecondArrowDir.Reverse(); + + aFirstArrowBegin = aParam1 - anArrowLength; + aFirstArrowEnd = aParam1; + aSecondArrowBegin = aParam2; + aSecondArrowEnd = aParam2 + anArrowLength; + } + else + { + aFirstArrowBegin = aParam1; + aFirstArrowEnd = aParam1 + anArrowLength; + aSecondArrowBegin = aParam2 - anArrowLength; + aSecondArrowEnd = aParam2; + } + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments; + gp_Pnt aFirstPoint, aLastPoint; + // Take into account vertical text alignment: + // only for 3D text! subtract the text length if it is in the center. + Standard_Boolean isGapInCenter = (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center + && aDimensionAspect->IsText3d()); + if (isGapInCenter) + { + aGap = 1.0; + } + + switch (aDimensionAspect->HorizontalTextAlignment()) + { + // Default case - text is to be in the center of length dimension line + case Prs3d_HTA_Center: + { + // Group1: arrows + if (theMode != AIS_DDM_Text) + { + drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); + if (!isOneSideDimension) + { + drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); + } + } + + // Group 2: Text and dimension line + aPrimSegments = new Graphic3d_ArrayOfSegments (isGapInCenter ? 4 : 2); + myGeom.myTextPosition = ElCLib::Value ((aParam1 + aParam2) / 2.0, aDimensionLine); + + gp_Vec aTextDir (myFirstPoint, mySecondPoint); + Standard_Real aTextWidth = drawText (thePresentation, + myIsTextReversed ? aTextDir.Reversed() : aTextDir, + aValueString, + theMode); + + aFirstPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); + if (isGapInCenter) + { + aLastPoint = ElCLib::Value (ElCLib::Parameter (aDimensionLine,myGeom.myTextPosition) - aGap - (aTextWidth / 2.0), aDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner,aFirstPoint,aLastPoint)); + aFirstPoint = ElCLib::Value (ElCLib::Parameter(aDimensionLine,myGeom.myTextPosition) + (aTextWidth / 2.0) + aGap, aDimensionLine); + } + else if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Top) + { + aDimensionAspect->TextAspect()->SetVerticalJustification (Graphic3d_VTA_BOTTOM); + } + else if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Bottom) + { + aDimensionAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_TOP); + } + + aLastPoint = isOneSideDimension ? theSecondAttach : ElCLib::Value (aSecondArrowBegin, aDimensionLine); + + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + + // Main dimension line, short extension + if (theMode != AIS_DDM_Text) + { + if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); + } + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); + } + } + break; + } + // Text is disposed from the left side of length dimension (after the left flyout line) + // Needs to create extensions: left for text and right for proper view of dimensions. + case Prs3d_HTA_Left: + { + aPrimSegments = new Graphic3d_ArrayOfSegments (4); + + gp_Pnt aFirstArrowBeginPnt = ElCLib::Value (aFirstArrowBegin, aDimensionLine); + gp_Lin aLongExtLine (aDimensionLine.Location(), aDimensionLine.Direction().Reversed()); + gp_Pnt aStartPoint = ElCLib::Value (aFirstArrowBegin, aDimensionLine); + // Left extension with the text + drawExtensionWithText (thePresentation, aStartPoint, aLongExtLine, aValueString, theMode); + + // Central(main) dimension line + aFirstPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); + aLastPoint = isOneSideDimension ? theSecondAttach : ElCLib::Value (aSecondArrowBegin, aDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + + // Right extension + if (!isOneSideDimension) + { + aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine); + aLastPoint = ElCLib::Value (aSecondArrowEnd + anArrowLength, aDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append(new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + } + if (theMode != AIS_DDM_Text) + { + // Main dimension line, short extension + Prs3d_Root::NewGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + // Group1: Add arrows to a group + drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); + if (!isOneSideDimension) + { + drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); + } + } + break; + } + case Prs3d_HTA_Right: + { + aPrimSegments = new Graphic3d_ArrayOfSegments (4); + // Left extension + if (!isOneSideDimension) + { + aFirstPoint = ElCLib::Value (aFirstArrowBegin - anArrowLength, aDimensionLine); + aLastPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + } + + // Central(main) dimension line + aFirstPoint = isOneSideDimension ? theFirstAttach : ElCLib::Value (aFirstArrowEnd, aDimensionLine); + aLastPoint = ElCLib::Value (aSecondArrowBegin, aDimensionLine); + aPrimSegments->AddVertex (aFirstPoint); + aPrimSegments->AddVertex (aLastPoint); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + + // Right extension with text + aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine); + drawExtensionWithText (thePresentation, aFirstPoint, aDimensionLine, aValueString, theMode); + + if (theMode != AIS_DDM_Text) + { + // Main dimension line, short extension + Prs3d_Root::NewGroup(thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup(thePresentation)->AddPrimitiveArray (aPrimSegments); + // Group1, 2: Add arrows to a group + if (!isOneSideDimension) + { + drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); + } + + drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); + } + break; + } + } + + setComputed (Standard_True); +} + +//======================================================================= +//function : SetFirstPoint +//purpose : +//======================================================================= + +void AIS_Dimension::SetFirstPoint (const gp_Pnt& thePoint) +{ + myFirstPoint = thePoint; +} + +//======================================================================= +//function : SetSecondPoint +//purpose : +//======================================================================= + +void AIS_Dimension::SetSecondPoint (const gp_Pnt& thePoint) +{ + mySecondPoint = thePoint; +} + +//======================================================================= +//function : Type +//purpose : +//======================================================================= + +AIS_KindOfInteractive AIS_Dimension::Type() const +{ + return AIS_KOI_Relation; +} + +//======================================================================= +//function : circleFromPlanarFace +//purpose : if possible computes circle from planar face +//======================================================================= + +Standard_Boolean AIS_Dimension::circleFromPlanarFace (const TopoDS_Face& theFace, + Handle(Geom_Curve)& theCurve, + gp_Pnt & theFirstPoint, + gp_Pnt & theLastPoint) +{ + TopExp_Explorer anIt (theFace, TopAbs_EDGE); + for ( ; anIt.More(); anIt.Next()) + { + TopoDS_Edge aCurEdge = TopoDS::Edge (anIt.Current()); + if (AIS::ComputeGeometry (aCurEdge, theCurve, theFirstPoint, theLastPoint)) + { + if (theCurve->IsInstance (STANDARD_TYPE(Geom_Circle))) + { + return Standard_True; + } + } + } + return Standard_False; +} + +//======================================================================= +//function : initCircularDimension +//purpose : if it's possible computes circle from planar face +//======================================================================= + +Standard_Boolean AIS_Dimension::initCircularDimension (const TopoDS_Shape& theShape, + gp_Circ& theCircle, + gp_Pnt& theMiddleArcPoint, + gp_Pnt& theOppositeDiameterPoint) +{ + gp_Pln aPln; + Handle(Geom_Surface) aBasisSurf; + AIS_KindOfSurface aSurfType = AIS_KOS_OtherSurface; + gp_Pnt aFirstPoint, aLastPoint; + Standard_Real anOffset = 0.0; + Standard_Real aFirstParam = 0.0; + Standard_Real aLastParam = 0.0; + Standard_Boolean isAnArc = Standard_False; + + if (theShape.ShapeType() == TopAbs_FACE) + { + AIS::GetPlaneFromFace (TopoDS::Face (theShape), aPln, aBasisSurf, aSurfType, anOffset); + + if (aSurfType == AIS_KOS_Plane) + { + Handle(Geom_Curve) aCurve; + if (!circleFromPlanarFace (TopoDS::Face (theShape), aCurve, aFirstPoint, aLastPoint)) + { + Standard_ConstructionError::Raise ("AIS_Dimension:: Curve is not a circle or is Null") ; + return Standard_False; + } + + theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ(); + isAnArc = !(aFirstPoint.IsEqual (aLastPoint, Precision::Confusion())); + } + else + { + gp_Pnt aCurPos; + BRepAdaptor_Surface aSurf1 (TopoDS::Face (theShape)); + Standard_Real aFirstU = aSurf1.FirstUParameter(); + Standard_Real aLastU = aSurf1.LastUParameter(); + Standard_Real aFirstV = aSurf1.FirstVParameter(); + Standard_Real aLastV = aSurf1.LastVParameter(); + Standard_Real aMidU = (aFirstU + aLastU) * 0.5; + Standard_Real aMidV = (aFirstV + aLastV) * 0.5; + aSurf1.D0(aMidU, aMidV, aCurPos); + Handle (Adaptor3d_HCurve) aBasisCurve; + Standard_Boolean isExpectedType = Standard_False; + if (aSurfType == AIS_KOS_Cylinder) + { + isExpectedType = Standard_True; + } + else + { + if (aSurfType == AIS_KOS_Revolution) + { + aBasisCurve = aSurf1.BasisCurve(); + if (aBasisCurve->GetType() == GeomAbs_Line) + { + isExpectedType = Standard_True; + } + } + else if (aSurfType == AIS_KOS_Extrusion) + { + aBasisCurve = aSurf1.BasisCurve(); + if (aBasisCurve->GetType() == GeomAbs_Circle) + { + isExpectedType = Standard_True; + } + } + } + + if (!isExpectedType) + { + Standard_ConstructionError::Raise ("AIS_Dimension:: Unexpected type of surface") ; + return Standard_False; + } + Handle(Geom_Curve) aCurve; + aCurve = aBasisSurf->VIso(aMidV); + if (aCurve->DynamicType() == STANDARD_TYPE (Geom_Circle)) + { + theCircle = Handle(Geom_Circle)::DownCast (aCurve)->Circ(); + } + else if (aCurve->DynamicType() == STANDARD_TYPE (Geom_TrimmedCurve)) + { + Handle(Geom_TrimmedCurve) aTrimmedCurve = Handle(Geom_TrimmedCurve)::DownCast (aCurve); + aFirstU = aTrimmedCurve->FirstParameter(); + aLastU = aTrimmedCurve->LastParameter(); + if (aTrimmedCurve->DynamicType() == STANDARD_TYPE (Geom_Circle)) + { + theCircle = Handle(Geom_Circle)::DownCast(aTrimmedCurve)->Circ(); + } + } + else + { + // Compute a circle from 3 points on "aCurve" + gp_Pnt aP1, aP2; + aSurf1.D0 (aFirstU, aMidV, aP1); + aSurf1.D0 (aLastU, aMidV, aP2); + GC_MakeCircle aMkCirc (aP1, aCurPos, aP2); + theCircle = aMkCirc.Value()->Circ(); + } + + gp_Vec aVec = gp_Vec (theCircle.Location(), aCurPos).Normalized(); + aFirstPoint = ElCLib::Value (aFirstU, theCircle); + aLastPoint = ElCLib::Value (aLastU, theCircle); + } + } + else // TopAbs_EDGE | TopAbs_WIRE + { + TopoDS_Edge anEdge; + if (theShape.ShapeType() == TopAbs_WIRE) + { + TopExp_Explorer anIt (theShape, TopAbs_EDGE); + if (anIt.More()) + { + anEdge = TopoDS::Edge (anIt.Current()); + } + } + else if (theShape.ShapeType() == TopAbs_EDGE) + { + anEdge = TopoDS::Edge (theShape); + } + else // Unexpected type of shape + { + Standard_ConstructionError::Raise ("AIS_Dimension:: Unexpected type of shape"); + return Standard_False; + } + BRepAdaptor_Curve anAdaptedCurve (anEdge); + if (!anAdaptedCurve.GetType() == GeomAbs_Circle) + { + return Standard_False; + } + theCircle = anAdaptedCurve.Circle(); + aFirstPoint = anAdaptedCurve.Value (anAdaptedCurve.FirstParameter()); + aLastPoint = anAdaptedCurve.Value (anAdaptedCurve.LastParameter()); + } + // Get and values from + isAnArc = !(aFirstPoint.IsEqual (aLastPoint, Precision::Confusion())); + gp_Pnt aCenter = theCircle.Location(); + if (!isAnArc) + { + // Circle + gp_Dir anXDir = theCircle.XAxis().Direction(); + theMiddleArcPoint = aCenter.Translated (gp_Vec (anXDir) * theCircle.Radius()); + theOppositeDiameterPoint = aCenter.Translated (-gp_Vec (anXDir) * theCircle.Radius()); + } + else + { + // Arc + aFirstParam = ElCLib::Parameter (theCircle, aFirstPoint); + aLastParam = ElCLib::Parameter (theCircle, aLastPoint); + if (aFirstParam > aLastParam) + { + aFirstParam -= 2.0 * M_PI; + } + Standard_Real aParCurPos = (aFirstParam + aLastParam) * 0.5; + gp_Vec aVec = gp_Vec (aCenter, ElCLib::Value (aParCurPos, theCircle)).Normalized () * theCircle.Radius (); + theMiddleArcPoint = aCenter.Translated (aVec); + theOppositeDiameterPoint = aCenter.Translated (-aVec); + } + + return Standard_True; +} + +//======================================================================= +//function : SetDisplaySpecialSymbol +//purpose : specifies dimension special symbol display options +//======================================================================= + +void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol) +{ + myDisplaySpecialSymbol = theDisplaySpecSymbol; +} + +//======================================================================= +//function : DisplaySpecialSymbol +//purpose : shows dimension special symbol display options +//======================================================================= + +AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const +{ + return myDisplaySpecialSymbol; +} + +//======================================================================= +//function : SetSpecialSymbol +//purpose : specifies special symbol +//======================================================================= + +void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol) +{ + mySpecialSymbol = theSpecialSymbol; +} + +//======================================================================= +//function : SpecialSymbol +//purpose : returns special symbol +//======================================================================= + +Standard_ExtCharacter AIS_Dimension::SpecialSymbol() const +{ + return mySpecialSymbol; +} + +//======================================================================= +//function : IsUnitsDisplayed +//purpose : shows if Units are to be displayed along with dimension value +//======================================================================= + +Standard_Boolean AIS_Dimension::IsUnitsDisplayed() const +{ + return myToDisplayUnits; +} + +//======================================================================= +//function : MakeUnitsDisplayed +//purpose : sets to display units along with the dimension value or no +//======================================================================= + +void AIS_Dimension::MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits) +{ + myToDisplayUnits = toDisplayUnits; +} + +//======================================================================= +//function : MakeUnitsDisplayed +//purpose : returns the current type of units +//======================================================================= + +TCollection_AsciiString AIS_Dimension::UnitsQuantity() const +{ + return myUnitsQuantity; +} + +//======================================================================= +//function : SetUnitsQuantity +//purpose : sets the current type of units +//======================================================================= + +void AIS_Dimension::SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity) +{ + myUnitsQuantity = theUnitsQuantity; +} + +//======================================================================= +//function : ModelUnits +//purpose : returns the current model units +//======================================================================= + +TCollection_AsciiString AIS_Dimension::ModelUnits() const +{ + return myModelUnits; +} + +//======================================================================= +//function : SetModelUnits +//purpose : sets the current model units +//======================================================================= + +void AIS_Dimension::SetModelUnits (const TCollection_AsciiString& theUnits) +{ + myModelUnits = theUnits; +} + +//======================================================================= +//function : DisplayUnits +//purpose : returns the current display units +//======================================================================= + +TCollection_AsciiString AIS_Dimension::DisplayUnits() const +{ + return myDisplayUnits; +} + +//======================================================================= +//function : SetDisplayUnits +//purpose : sets the current display units +//======================================================================= + +void AIS_Dimension::SetDisplayUnits (const TCollection_AsciiString& theUnits) +{ + myDisplayUnits = theUnits; +} + +//======================================================================= +//function : isComputed +//purpose : +//======================================================================= + +Standard_Boolean AIS_Dimension::isComputed() const +{ + return myGeom.myIsComputed; +} + +//======================================================================= +//function : setComputed +//purpose : +//======================================================================= + +void AIS_Dimension::setComputed (Standard_Boolean isComputed) +{ + myGeom.myIsComputed = isComputed; +} + +//======================================================================= +//function : textPosition +//purpose : +//======================================================================= + +gp_Pnt AIS_Dimension::textPosition() const +{ + return myGeom.myTextPosition; +} + +//======================================================================= +//function : setTextPosition +//purpose : +//======================================================================= + +void AIS_Dimension::setTextPosition (const gp_Pnt thePosition) +{ + myGeom.myTextPosition = thePosition; +} + +//======================================================================= +//function : resetGeom +//purpose : +//======================================================================= + +void AIS_Dimension::resetGeom() +{ + setComputed (Standard_False); +} + +//======================================================================= +//function : IsTextReversed +//purpose : +//======================================================================= + +Standard_Boolean AIS_Dimension::IsTextReversed() const +{ + return myIsTextReversed; +} + +//======================================================================= +//function : MakeTextReversed +//purpose : +//======================================================================= + +void AIS_Dimension::MakeTextReversed (const Standard_Boolean isTextReversed) +{ + myIsTextReversed = isTextReversed; +} + +//======================================================================= +//function : SetSelToleranceForText2d +//purpose : +//======================================================================= + +void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol) +{ + myGeom.mySelToleranceForText2d = theTol; +} + +//======================================================================= +//function : SelToleranceForText2d +//purpose : +//======================================================================= + +Standard_Real AIS_Dimension::SelToleranceForText2d() const +{ + return myGeom.mySelToleranceForText2d; +} + +//======================================================================= +//function : ComputeSelection +//purpose : +//======================================================================= + +void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode) +{ + if (!isComputed()) + { + return; + } + + Handle( Select3D_SensitiveGroup) aSensitiveForLine; + Handle(Select3D_SensitiveEntity) aSensitiveForText; + Select3D_ListOfSensitive aSensitiveList; + aSensitiveList.Assign (myGeom.mySensitiveSegments); + + // Full dimension selection + Handle(AIS_DimensionOwner) anOwner = new AIS_DimensionOwner (this, AIS_DDM_All, theMode == 0 ? 5 : 6); + for (Select3D_ListIteratorOfListOfSensitive anIt (aSensitiveList); anIt.More(); anIt.Next()) + { + anIt.Value()->Set (anOwner); + } + aSensitiveForLine = new Select3D_SensitiveGroup (anOwner, aSensitiveList); + + // Text + if (myDrawer->DimensionAspect()->IsText3d()) + { + aSensitiveForText = new Select3D_SensitiveBox (anOwner,myGeom.myTextBndBox); + } + else + { + Handle(Geom_Circle) aSensitiveGeom = new Geom_Circle (gp_Circ (gp_Ax2 (myGeom.myTextPosition, + myWorkingPlane.Position().XDirection()), + myGeom.mySelToleranceForText2d != 0 + ? myGeom.mySelToleranceForText2d : 1.0)); + aSensitiveForText = new Select3D_SensitiveCircle (anOwner, aSensitiveGeom, Standard_True); + } + if (theMode > 0) + { + anOwner->SetDisplayMode (AIS_DDM_Line); + Handle(AIS_DimensionOwner) aTextOwner = new AIS_DimensionOwner (this, AIS_DDM_Text, 7); + aSensitiveForText->Set (aTextOwner); + } + + theSelection->Add (aSensitiveForLine); + theSelection->Add (aSensitiveForText); +} diff --git a/src/AIS/AIS_Dimension.hxx b/src/AIS/AIS_Dimension.hxx new file mode 100644 index 0000000000..37b2494f1b --- /dev/null +++ b/src/AIS/AIS_Dimension.hxx @@ -0,0 +1,317 @@ +// Copyright (c) 1998-1999 Matra Datavision +// Copyright (c) 1999-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef _AIS_Dimension_Headerfile +#define _AIS_Dimension_Headerfile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) + +class AIS_Dimension : public AIS_InteractiveObject +{ +public: + //! Constructor with default parameters values + Standard_EXPORT AIS_Dimension (const Standard_Real theExtensionSize = 1.0); + //! Constructor to set aspect of dimension + Standard_EXPORT AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect, + const Standard_Real theExtensionSize = 1.0); + //! Gets dimension value + Standard_EXPORT Standard_Real GetValue () const; + + //! Sets dimension value + //! Attention! This method is used ONLY to set custom value. + //! To set value internally, use . + Standard_EXPORT void SetCustomValue (const Standard_Real theValue); + + //! Gets working plane. + Standard_EXPORT const gp_Pln& GetWorkingPlane() const; + + //! Sets working plane. + Standard_EXPORT void SetWorkingPlane (const gp_Pln& thePlane); + + //! Sets extension size. + Standard_EXPORT void SetExtensionSize (const Standard_Real theExtensionSize); + + //! Gets extension size. + Standard_EXPORT Standard_Real GetExtensionSize() const; + + Standard_EXPORT void SetFirstPoint (const gp_Pnt& thePoint); + + Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint); + + Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theFirstShape); + + Standard_EXPORT void SetSecondShape (const TopoDS_Shape& theSecondShape); + + //! Gets the dimension aspect from AIS object drawer. + //! Dimension aspect contains aspects of line, text and arrows for dimension presentation. + Standard_EXPORT Handle(Prs3d_DimensionAspect) DimensionAspect() const; + + //! Sets new length aspect in the interactive object drawer. + Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect); + + //! Returns the kind of dimension + Standard_EXPORT AIS_KindOfDimension KindOfDimension() const; + + //! Returns the kind of interactive + Standard_EXPORT virtual AIS_KindOfInteractive Type() const; + + //! Sets the kind of dimension + Standard_EXPORT virtual void SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension); + + //! Returns true if the class of objects accepts the display mode theMode. + //! The interactive context can have a default mode of + //! representation for the set of Interactive Objects. This + //! mode may not be accepted by object + Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const; + // Selection computing if it is needed here + Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, + const Standard_Integer theMode); + //! Reset working plane to default. + Standard_EXPORT void ResetWorkingPlane(); + //! specifies dimension special symbol display options + Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol); + //! shows dimension special symbol display options + Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const; + //! specifies special symbol + Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol); + //! returns special symbol + Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const; + //! shows if Units are to be displayed along with dimension value + Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const; + //! sets to display units along with the dimansion value or no + Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits); + //! returns the current type of units + Standard_EXPORT TCollection_AsciiString UnitsQuantity() const; + //! sets the current type of units + Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity); + //! returns the current model units + Standard_EXPORT TCollection_AsciiString ModelUnits() const; + //! sets the current model units + Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits); + //! returns the current display units + Standard_EXPORT TCollection_AsciiString DisplayUnits() const; + //! sets the current display units + Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits); + //! sets the text offset: distance from attach point to the text on the extension + //! in case if text isn't in center of the dimension line + Standard_EXPORT void SetTextOffset (const Standard_Real theOffset); + //! returns the text offset: distance from attach point to the text on the extension + //! in case if text isn't in center of the dimension line + Standard_EXPORT Standard_Real TextOffset() const; + //! Important! Only for 3d text
+ //! 3d text is oriented relative to the attachment points order
+ //! By default, text direction vector is oriented from the first attachment point
+ //! to the second one. This method checks if text direction is to be default or
+ //! should be reversed. + Standard_EXPORT Standard_Boolean IsTextReversed() const; + //! Important! Only for 3d text + //! 3d text is oriented relative to the attachment points order
+ //! By default, text direction vector is oriented from the first attachment point
+ //! to the second one. This method sets value that shows if text direction
+ //! should be reversed or not. + Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed); + //! Sets selection tolerance for text2d: + //! For 2d text selection detection sensitive point with tolerance is used + //! to change this tolerance use this method + //! Important! Only for 2d text + Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol); + //! Returns selection tolerance for text2d: + //! For 2d text selection detection sensitive point with tolerance is used + //! Important! Only for 2d text + Standard_EXPORT Standard_Real SelToleranceForText2d() const; + + + DEFINE_STANDARD_RTTI(AIS_Dimension) + +protected: + Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth, + TCollection_ExtendedString& theString) const; + + Standard_EXPORT Standard_Real valueToDisplayUnits(); + + //! Reset working plane to default. + Standard_EXPORT void resetWorkingPlane (const gp_Pln& theNewDefaultPlane); + + //! Count default plane + Standard_EXPORT virtual void countDefaultPlane(); + + //! Computes dimension value in display units + Standard_EXPORT virtual void computeValue(); + + //! Performs drawing of 2d or 3d arrows on the working plane + Standard_EXPORT void drawArrow (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theLocation, + const gp_Dir& theDirection); + + //! Performs drawing of 2d or 3d text on the working plane + //! @return text width relative to the dimension working plane. For 2d text this value will be zero. + Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Dir& theTextDir, + const TCollection_ExtendedString theText, + const AIS_DimensionDisplayMode theMode); + + //! Performs computing of dimension linear extension with text + Standard_EXPORT virtual void drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theStartPoint, + const gp_Lin& theDimensionLine, + const TCollection_ExtendedString& theValueString, + const AIS_DimensionDisplayMode theMode); + + //! Performs computing of linear dimension (for length, diameter, radius and so on) + Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, + const gp_Pnt& theFirstAttach, + const gp_Pnt& theSecondAttach, + const AIS_DimensionDisplayMode theMode, + const Standard_Boolean isOneSideDimension = Standard_False); + + //! If it's possible computes circle from planar face + Standard_EXPORT Standard_Boolean circleFromPlanarFace (const TopoDS_Face& theFace, + Handle(Geom_Curve)& theCurve, + gp_Pnt & theFirstPoint, + gp_Pnt & theLastPoint); + + //! Performs initialization of circle and points from given shape + //! (for radius, diameter and so on) + Standard_EXPORT Standard_Boolean initCircularDimension (const TopoDS_Shape& theShape, + gp_Circ& theCircle, + gp_Pnt& theMiddleArcPoint, + gp_Pnt& theOppositeDiameterPoint); + Standard_EXPORT Standard_Boolean isComputed() const; + + Standard_EXPORT void setComputed (Standard_Boolean isComputed); + + Standard_EXPORT gp_Pnt textPosition() const; + + Standard_EXPORT void setTextPosition (const gp_Pnt thePosition); + + Standard_EXPORT void resetGeom(); + + // Fields +protected: + + /// WORKING PLANE PROPERTIES + + //! Dimension default plane + gp_Pln myDefaultPlane; + //! Shows if working plane is set custom + Standard_Boolean myIsWorkingPlaneCustom; + + /// VALUE PROPERTIES + + //! Dimension value which is displayed with dimension lines + Standard_Real myValue; + //! Shows if the value is set by user and is no need to count it automatically + Standard_Boolean myIsValueCustom; + + /// UNITS PROPERTIES + + //! The quantity of units for the value computation + TCollection_AsciiString myUnitsQuantity; + //! Units of the model + TCollection_AsciiString myModelUnits; + //! Units in which the displayed value will be converted + TCollection_AsciiString myDisplayUnits; + //! Determines if units is to be displayed along with the value + Standard_Boolean myToDisplayUnits; + //! Special symbol for some kind of dimensions (for diameter, radius and so on) + Standard_ExtCharacter mySpecialSymbol; + //! Special symbol display options + AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; + + /// GEOMETRY PROPERTIES + + //! Geometry of dimensions, needs for advanced selection + //! Geometry is computed in Compute() method and is used + //! in ComputeSelection() method. + //! If it is computed successfully, myIsComputed = Standard_True. + //! to check computing result use IsComputed() method + struct DimensionGeom + { + //! Text position + gp_Pnt myTextPosition; + //! Text bounding box, stored for advanced selection + Bnd_Box myTextBndBox; + //! Sensitive point tolerance for 2d text selection + Standard_Real mySelToleranceForText2d; + //! For advanced dimension line selection + Select3D_ListOfSensitive mySensitiveSegments; + //! Shows if attachment points were computed + Standard_Boolean myIsComputed; + public: + DimensionGeom () + : myIsComputed (Standard_False) + { } + }; + + //! Shows if text is inverted + Standard_Boolean myIsTextReversed; + //! Determines distance from attach point to the text on the extension + //! in case if text isn't in center of the dimension line + Standard_Real myTextOffset; + //! Points that are base for dimension. + //! My first point of dimension attach (belongs to shape for which dimension is computed) + gp_Pnt myFirstPoint; + //! My second point of dimension attach (belongs to shape for which dimension is computed) + gp_Pnt mySecondPoint; + //! Shows if attach points are initialized correctly + Standard_Boolean myIsInitialized; + //! First shape (can be vertex, edge or face) + TopoDS_Shape myFirstShape; + //! Second shape (can be vertex, edge or face) + TopoDS_Shape mySecondShape; + //! Number of shapes + Standard_Integer myShapesNumber; + //! Geometry of dimensions, needs for advanced selection + //! Geometry is computed in Compute() method and is used + //! in ComputeSelection() method. + //! If it is computed successfully, myIsComputed = Standard_True. + //! to check computing result use IsComputed() method + DimensionGeom myGeom; +private: + //! Type of dimension + AIS_KindOfDimension myKindOfDimension; + //! Dimension working plane, is equal to if it can be computed automatically. + gp_Pln myWorkingPlane; + //! Extension size in model measure units. + //! No inclined or curved extension line is now supported. + Standard_Real myExtensionSize; +}; +#endif diff --git a/src/AIS/AIS_DimensionOwner.cdl b/src/AIS/AIS_DimensionOwner.cdl index c52f2a42e7..bc96076a56 100755 --- a/src/AIS/AIS_DimensionOwner.cdl +++ b/src/AIS/AIS_DimensionOwner.cdl @@ -21,49 +21,64 @@ class DimensionOwner from AIS inherits EntityOwner from SelectMgr - ---Purpose: The owner is the entity which makes it possible to link - -- the sensitive primitives and the reference shapes that - -- you want to detect. It stocks the various pieces of - -- information which make it possible to find objects. An - -- owner has a priority which you can modulate, so as to - -- make one entity more selectable than another. You - -- might want to make edges more selectable than - -- faces, for example. In that case, you could attribute sa - -- higher priority to the one compared to the other. An - -- edge, could have priority 5, for example, and a face, - -- priority 4. The default priority is 5. + ---Purpose: The owner is the entity which makes it possible to link + -- the sensitive primitives and the reference shapes that + -- you want to detect. It stocks the various pieces of + -- information which make it possible to find objects. An + -- owner has a priority which you can modulate, so as to + -- make one entity more selectable than another. You + -- might want to make edges more selectable than + -- faces, for example. In that case, you could attribute sa + -- higher priority to the one compared to the other. An + -- edge, could have priority 5, for example, and a face, + -- priority 4. The default priority is 5. uses - SelectableObject from SelectMgr, - Shape from TopoDS + SelectableObject from SelectMgr, + PresentationManager from PrsMgr, + PresentationManager3d from PrsMgr, + NameOfColor from Quantity, + DimensionDisplayMode from AIS is - Create ( aSO : SelectableObject; - aPriority : Integer from Standard =0) + Create (theSelObject : SelectableObject; + theDisplayMode : DimensionDisplayMode from AIS; + thePriority : Integer from Standard = 0) returns mutable DimensionOwner from AIS; - ---Purpose: - -- Initializes the dimension owner, aSO, and attributes it - -- the priority, aPriority. - - SetShape(me : mutable; aShape : Shape from TopoDS); - ---C++: inline - ---Purpose: - -- Constructs the reference shape owner aShape for - -- presentation primitives. - - FixedShape(me) - ---C++: return const & - ---C++: inline - ---Purpose: - -- Returns the owner shape whose primitives we are concerned with. - returns Shape from TopoDS; - + ---Purpose: + -- Initializes the dimension owner, theSO, and attributes it + -- the priority, thePriority. + SetDisplayMode (me : mutable; theMode : DimensionDisplayMode from AIS); + + DisplayMode (me) + returns DimensionDisplayMode from AIS; + + HilightWithColor (me : mutable; + thePM : PresentationManager3d from PrsMgr; + theColor : NameOfColor from Quantity; + theMode : Integer from Standard = 0) + is redefined virtual; + + IsHilighted (me; + thePM : PresentationManager from PrsMgr; + theMode : Integer from Standard =0) + returns Boolean from Standard is redefined virtual; + ---Purpose: Returns true if an object with the selection mode + -- aMode is highlighted in the presentation manager aPM. + + Hilight(me : mutable; + thePM : PresentationManager from PrsMgr; + theMode : Integer from Standard =0) is redefined virtual; + + Unhilight(me : mutable; + thePM : PresentationManager from PrsMgr; + theMode : Integer from Standard =0) is redefined virtual; + ---Purpose: Removes highlighting from the selected part of dimension. fields - myFixedShape : Shape from TopoDS; + myDisplayMode : DimensionDisplayMode from AIS; end DimensionOwner; - diff --git a/src/AIS/AIS_DimensionOwner.cxx b/src/AIS/AIS_DimensionOwner.cxx index 9441ccdcfa..93d186d79b 100755 --- a/src/AIS/AIS_DimensionOwner.cxx +++ b/src/AIS/AIS_DimensionOwner.cxx @@ -21,15 +21,105 @@ #include +#include +#include +#include +#include -//----------------------------------------------------------------------- -// function : create -// purpose : -//----------------------------------------------------------------------- +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= -AIS_DimensionOwner::AIS_DimensionOwner(const Handle(SelectMgr_SelectableObject)& aSO, - const Standard_Integer aPriority) -:SelectMgr_EntityOwner(aSO,aPriority) +AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, + const AIS_DimensionDisplayMode theMode, + const Standard_Integer thePriority) +: SelectMgr_EntityOwner(theSelObject, thePriority), + myDisplayMode (theMode) { } + +//======================================================================= +//function : SetDisplayMode +//purpose : +//======================================================================= + +void AIS_DimensionOwner::SetDisplayMode (const AIS_DimensionDisplayMode theMode) +{ + myDisplayMode = theMode; +} + +//======================================================================= +//function : DisplayMode +//purpose : +//======================================================================= + +AIS_DimensionDisplayMode AIS_DimensionOwner::DisplayMode () const +{ + return myDisplayMode; +} + +//======================================================================= +//function : IsHilighted +//purpose : +//======================================================================= + +Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) const +{ + if (HasSelectable()) + { + Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; + return thePM->IsHighlighted(Selectable (), aMode); + } + return Standard_False; +} + +//======================================================================= +//function : Hilight +//purpose : +//======================================================================= + +void AIS_DimensionOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) +{ + if (HasSelectable()) + { + Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; + thePM->Highlight (Selectable(),aMode); + } +} + +//======================================================================= +//function : Unhilight +//purpose : +//======================================================================= + +void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, + const Standard_Integer theMode) +{ + if (HasSelectable()) + { + Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; + thePM->Unhighlight(Selectable(),aMode); + } +} + +//======================================================================= +//function : HilightWithColor +//purpose : +//======================================================================= + +void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, + const Quantity_NameOfColor theColor, + const Standard_Integer theMode) +{ + // Highlight selectable part of dimension with color + if (myDisplayMode != 0) + { + thePM->Color (Selectable(), theColor, myDisplayMode); + } + else + thePM->Color (Selectable(), theColor, theMode); +} diff --git a/src/AIS/AIS_DimensionOwner.lxx b/src/AIS/AIS_DimensionOwner.lxx deleted file mode 100755 index 55b94c8b8b..0000000000 --- a/src/AIS/AIS_DimensionOwner.lxx +++ /dev/null @@ -1,38 +0,0 @@ -// Created on: 1997-03-03 -// Created by: Jean-Pierre COMBE -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -//======================================================================= -//function : SetShape -//purpose : -//======================================================================= -inline void AIS_DimensionOwner::SetShape(const TopoDS_Shape& aShape) -{ - myFixedShape = aShape; -} - -//======================================================================= -//function : FixedShape -//purpose : -//======================================================================= -inline const TopoDS_Shape& AIS_DimensionOwner::FixedShape() const -{ - return myFixedShape; -} diff --git a/src/AIS/AIS_Drawer.cdl b/src/AIS/AIS_Drawer.cdl index c314945be5..0a947c49ef 100755 --- a/src/AIS/AIS_Drawer.cdl +++ b/src/AIS/AIS_Drawer.cdl @@ -57,10 +57,8 @@ uses PointAspect from Prs3d, ShadingAspect from Prs3d, IsoAspect from Prs3d, - LengthAspect from Prs3d, - AngleAspect from Prs3d, + DimensionAspect from Prs3d, PlaneAspect from Prs3d, - RadiusAspect from Prs3d, ArrowAspect from Prs3d, TypeOfDeflection from Aspect, NameOfColor from Quantity, @@ -541,43 +539,19 @@ is is redefined static; -- --- Attributes for the presentation of a Length. +-- Attributes for the presentation of a dimensions. -- - LengthAspect(me:mutable) returns mutable LengthAspect from Prs3d - ---Purpose: Returns a link with Prs3d_Drawer_LengthAspect, --- which provides settings for the appearance of lengths. + DimensionAspect(me:mutable) returns mutable DimensionAspect from Prs3d + ---Purpose: Returns a link with Prs3d_Drawer_DimensionAspect, +-- which provides settings for the appearance of dimensions. is redefined static; - HasLengthAspect (me) returns Boolean from Standard + HasDimensionAspect (me) returns Boolean from Standard ---C++: inline - ---Purpose: Returns true if the Drawer has a length aspect setting active. + ---Purpose: Returns true if the Drawer has a dimension aspect setting active. is static; --- --- Attributes for the presentation of a Angle. --- - - AngleAspect(me:mutable) returns mutable AngleAspect from Prs3d - ---Purpose: Returns a link with Prs3d_Drawer_AngleAspect, - -- which provides settings for lines used to display angles. - is redefined static; - - HasAngleAspect (me) returns Boolean from Standard - ---C++: inline - ---Purpose: Returns true if the Drawer has an angle aspect - -- setting active. - is static; - --- --- Attributes for the presentation of a Radius. --- - - RadiusAspect(me) returns mutable RadiusAspect from Prs3d - ---Purpose: Returns a link with Prs3d_Drawer_RadiusAspect, - -- which provides settings for lines which serve to display radii. - is redefined static; - -- Attributes for the sections SectionAspect (me:mutable) returns mutable LineAspect from Prs3d diff --git a/src/AIS/AIS_Drawer.cxx b/src/AIS/AIS_Drawer.cxx index d810c4f19e..6404e505a4 100755 --- a/src/AIS/AIS_Drawer.cxx +++ b/src/AIS/AIS_Drawer.cxx @@ -216,17 +216,8 @@ Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect () Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect () {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;} -Handle (Prs3d_LengthAspect) AIS_Drawer::LengthAspect () -{return myLengthAspect.IsNull()? myLink->LengthAspect () : myLengthAspect ;} - - -Handle (Prs3d_AngleAspect) AIS_Drawer::AngleAspect () -{return myAngleAspect.IsNull()? myLink->AngleAspect () :myAngleAspect ;} - - -Handle (Prs3d_RadiusAspect) AIS_Drawer::RadiusAspect () const -{return myRadiusAspect.IsNull()? myLink->RadiusAspect():myRadiusAspect; } - +Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect () +{return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect ;} Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect () {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;} @@ -258,9 +249,7 @@ void AIS_Drawer::ClearLocalAttributes() if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify(); if(!myVectorAspect.IsNull()) myVectorAspect .Nullify(); if(!myDatumAspect.IsNull()) myDatumAspect.Nullify(); - if(!myLengthAspect.IsNull()) myLengthAspect.Nullify(); - if(!myAngleAspect.IsNull()) myAngleAspect.Nullify(); - if(!myRadiusAspect.IsNull()) myRadiusAspect.Nullify(); + if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify(); if(!mySectionAspect.IsNull()) mySectionAspect.Nullify(); if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False; if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False; diff --git a/src/AIS/AIS_Drawer.lxx b/src/AIS/AIS_Drawer.lxx index 6d1cdbd251..e488ce27e7 100755 --- a/src/AIS/AIS_Drawer.lxx +++ b/src/AIS/AIS_Drawer.lxx @@ -82,18 +82,12 @@ inline Standard_Boolean AIS_Drawer::HasShadingAspect () const inline Standard_Boolean AIS_Drawer::HasPointAspect () const { return !myPointAspect.IsNull();} -inline Standard_Boolean AIS_Drawer::HasAngleAspect () const -{ return !myAngleAspect.IsNull();} - inline Standard_Boolean AIS_Drawer::HasDatumAspect () const { return !myDatumAspect.IsNull();} inline Standard_Boolean AIS_Drawer::HasPlaneAspect () const { return !myPlaneAspect.IsNull();} -inline Standard_Boolean AIS_Drawer::HasLengthAspect () const -{ return !myLengthAspect.IsNull();} - inline Standard_Boolean AIS_Drawer::IsOwnFaceBoundaryDraw () const { return myHasOwnFaceBoundaryDraw; } @@ -109,3 +103,6 @@ inline Prs3d_TypeOfHLR AIS_Drawer::TypeOfHLR ( ) const { return (myTypeOfHLR == Prs3d_TOH_NotSet) ? myLink->TypeOfHLR() : myTypeOfHLR; } + +inline Standard_Boolean AIS_Drawer::HasDimensionAspect () const +{ return !myDimensionAspect.IsNull();} diff --git a/src/AIS/AIS_EqualDistanceRelation.cxx b/src/AIS/AIS_EqualDistanceRelation.cxx index 4064c87a9c..acd180f949 100755 --- a/src/AIS/AIS_EqualDistanceRelation.cxx +++ b/src/AIS/AIS_EqualDistanceRelation.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -84,8 +84,8 @@ void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManage gp_Pnt Position12 = myPosition, Position34 = myPosition; - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(myArrowSize); // -- ota -- begin if (!myAutomaticPosition ){ @@ -477,10 +477,10 @@ void AIS_EqualDistanceRelation::ComputeTwoEdgesLength( const Handle( Prs3d_Prese if (arrsize < confusion) arrsize = Val*0.1; if (Abs(Val) <= confusion) {arrsize = 0.;} - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(arrsize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(arrsize); if (AutomaticPos && IsSetBndBox) @@ -659,10 +659,10 @@ void AIS_EqualDistanceRelation::ComputeTwoVerticesLength( const Handle( Prs3d_Pr } - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(ArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(ArrowSize); if (AutomaticPos && IsSetBndBox) @@ -768,10 +768,10 @@ void AIS_EqualDistanceRelation::ComputeOneEdgeOneVertexLength( const Handle( Prs SecondAttach = ElCLib::Value(ElCLib::Parameter(l,Position),l); } - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = aDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(arrsize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(arrsize); if (AutomaticPos && IsSetBndBox) diff --git a/src/AIS/AIS_EqualRadiusRelation.cxx b/src/AIS/AIS_EqualRadiusRelation.cxx index 50704c867c..58f68ee37c 100755 --- a/src/AIS/AIS_EqualRadiusRelation.cxx +++ b/src/AIS/AIS_EqualRadiusRelation.cxx @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include @@ -142,8 +142,8 @@ void AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager3 myArrowSize = (Min(myFirstCenter.Distance(myFirstPoint), mySecondCenter.Distance(mySecondPoint)))*0.05; - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(myArrowSize); //ota -- end -- diff --git a/src/AIS/AIS_GraphicTool.cxx b/src/AIS/AIS_GraphicTool.cxx index 56712aefd0..4f12a13e66 100755 --- a/src/AIS/AIS_GraphicTool.cxx +++ b/src/AIS/AIS_GraphicTool.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,8 +46,8 @@ static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr, case AIS_TOA_Line: return Dr->LineAspect(); break; - case AIS_TOA_Angle: - return Dr->AngleAspect()->LineAspect(); + case AIS_TOA_Dimension: + return Dr->DimensionAspect()->LineAspect(); break; case AIS_TOA_Wire: return Dr->WireAspect(); diff --git a/src/AIS/AIS_LengthDimension.cdl b/src/AIS/AIS_LengthDimension.cdl deleted file mode 100755 index 67522444ef..0000000000 --- a/src/AIS/AIS_LengthDimension.cdl +++ /dev/null @@ -1,274 +0,0 @@ --- Created on: 1996-12-03 --- Created by: Arnaud BOUZY/Odile Olivier --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class LengthDimension from AIS inherits Relation from AIS - - ---Purpose: A framework to display lengths. - -- These can be lengths along a face or edge, or - -- between two faces or two edges. - -- The value of the length is given in a text figuring in this display. - -uses Shape from TopoDS, - Face from TopoDS, - Presentation from Prs3d, - PresentationManager3d from PrsMgr, - Selection from SelectMgr, - Dir from gp, - Pnt from gp, - Projector from Prs3d, - Transformation from Geom, - ExtendedString from TCollection, - Plane from Geom, - TypeOfDist from AIS, - ArrowSide from DsgPrs, - KindOfDimension from AIS, - Drawer from Prs3d, - Edge from TopoDS, - Box from Bnd, - Drawer from AIS, - Vertex from TopoDS -is - - - - Create (aFirstFace : Face from TopoDS; - aSecondFace : Face from TopoDS; - aVal : Real from Standard; -- is defined while first compute, may be any Real - aText : ExtendedString from TCollection) - ---Purpose: Constructs a length display object defined by the first - -- face aFShape, the second face aSShape, the dimension aVal, and the text aText. - - returns mutable LengthDimension from AIS; - - Create (aFirstFace : Face from TopoDS; - aSecondFace : Face from TopoDS; - aVal : Real from Standard; -- is defined while first compute, may be any Real - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.0) - ---Purpose: Constructs a length display object defined by the first - -- face aFShape, the second face aSShape, the - -- dimension aVal, the position aPosition, the arrow - -- aSymbolPrs with the size anArrowSize and the text aText. - returns mutable LengthDimension from AIS; - - Create (Face : Face from TopoDS; - Edge : Edge from TopoDS; - Val : Real from Standard; - Text : ExtendedString from TCollection) - ---Purpose: Constructs a length display object defined by the first - -- edge or vertex aFShape, the second edge or vertex - -- aSShape, the dimension aVal,and the plane aPlane. - returns mutable LengthDimension from AIS; - - Create (aFShape : Shape from TopoDS; - aSShape : Shape from TopoDS; - aPlane : Plane from Geom; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: -- Constructs a length display object defined by the first - -- edge or vertex aFShape, the second edge or vertex - -- aSShape, the dimension aVal,and the plane aPlane. - returns mutable LengthDimension from AIS; - - Create (aFShape : Shape from TopoDS; - aSShape : Shape from TopoDS; - aPlane : Plane from Geom; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - aTypeDist : TypeOfDist from AIS; - anArrowSize : Real from Standard = 0.0) - ---Purpose: Constructs a length display object defined by the first - -- edge or vertex aFShape, the second edge or vertex - -- aSShape, the dimension aVal, the position aPosition, - -- the type of distance aTypeDist, the type of arrow - -- aSymbolPrs with the size anArrowSize, and the plane aPlane. - returns mutable LengthDimension from AIS; - - SetFirstShape( me: mutable; aFShape : Shape from TopoDS ) - is redefined static; - - SetSecondShape( me: mutable; aSShape : Shape from TopoDS ) - is redefined static; - - KindOfDimension(me) - returns KindOfDimension from AIS - is redefined; - ---Purpose: Indicates that we are concerned with a length. - - IsMovable(me) returns Boolean from Standard - is redefined; - ---Purpose: Returns true if the length dimension is movable. - - TypeOfDist (me) - ---C++: inline - --- Purpose: - -- Returns the type of distance of the length primitive. - returns TypeOfDist from AIS - is static; - - SetTypeOfDist(me: mutable;aTypeDist: TypeOfDist from AIS) - ---C++: inline - --- Purpose: - -- Returns true if the length dimension is movable. - is static; - - - -- Methods from PresentableObject - - Compute(me : mutable; - aPresentationManager : PresentationManager3d from PrsMgr; - aPresentation : mutable Presentation from Prs3d; - aMode : Integer from Standard= 0) - is redefined private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aPresentation : mutable Presentation from Prs3d) - is redefined static private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation : mutable Presentation from Prs3d) - is redefined; - ---Purpose: computes the presentation according to a point of view - -- given by . - -- To be Used when the associated degenerated Presentations - -- have been transformed by which is not a Pure - -- Translation. The HLR Prs can't be deducted automatically - -- WARNING : must be applied - -- to the object to display before computation !!! - - - -- Methods from SelectableObject - - ComputeSelection(me : mutable; - aSelection : mutable Selection from SelectMgr; - aMode : Integer from Standard) - is redefined private; - - - - -- Computation private methods - - ComputeOneFaceLength(me : mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeOneEdgeLength(me : mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - ComputeTwoFacesLength(me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - - ComputeEdgeFaceLength (me: mutable; - aPresentation : mutable Presentation from Prs3d) - is private; - - - ComputeTwoEdgesLength (myclass; - aPresentation : mutable Presentation from Prs3d; - aDrawer : Drawer from AIS; - aText : ExtendedString from TCollection; - ArrowSize : Real from Standard; - FirstEdge : Edge from TopoDS; - SecondEdge : Edge from TopoDS; - Plane : Plane from Geom; - AutomaticPos : Boolean from Standard; - IsSetBndBox : Boolean from Standard; - BndBox : Box from Bnd; - ExtShape : out Integer from Standard; - Val : out Real from Standard; - DirAttach : out Dir from gp; - Position : out Pnt from gp; - FirstAttach : out Pnt from gp; - SecondAttach : out Pnt from gp; - SymbolPrs : out ArrowSide from DsgPrs ); - - ComputeOneEdgeOneVertexLength(myclass; - aPresentation : mutable Presentation from Prs3d; - aDrawer : Drawer from AIS; - aText : ExtendedString from TCollection; - ArrowSize : Real from Standard; - FirstShape : Shape from TopoDS; - SecondShape : Shape from TopoDS; - Plane : Plane from Geom; - AutomaticPos : Boolean from Standard; - IsSetBndBox : Boolean from Standard; - BndBox : Box from Bnd; - ExtShape : out Integer from Standard; - Val : out Real from Standard; - DirAttach : out Dir from gp; - Position : out Pnt from gp; - FirstAttach : out Pnt from gp; - SecondAttach : out Pnt from gp; - SymbolPrs : out ArrowSide from DsgPrs ); - - ComputeTwoVerticesLength(myclass; - aPresentation : mutable Presentation from Prs3d; - aDrawer : Drawer from AIS; - aText : ExtendedString from TCollection; - ArrowSize : Real from Standard; - FirstVertex : Vertex from TopoDS; - SecondVertex : Vertex from TopoDS; - Plane : Plane from Geom; - AutomaticPos : Boolean from Standard; - IsSetBndBox : Boolean from Standard; - BndBox : Box from Bnd; - TypeDist : TypeOfDist from AIS; - ExtShape : out Integer from Standard; - Val : out Real from Standard; - DirAttach : out Dir from gp; - Position : out Pnt from gp; - FirstAttach : out Pnt from gp; - SecondAttach : out Pnt from gp; - SymbolPrs : out ArrowSide from DsgPrs ); - - --- --- Computation Selection private methods --- - - ComputeFaceSelection(me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - - ComputeEdgeVertexSelection( me : mutable; - aSelection : mutable Selection from SelectMgr) - is private; - - -fields - - myNbShape : Integer from Standard; - myFAttach : Pnt from gp; - mySAttach : Pnt from gp; - myDirAttach: Dir from gp; - myTypeDist : TypeOfDist from AIS; - -end LengthDimension; diff --git a/src/AIS/AIS_LengthDimension.cxx b/src/AIS/AIS_LengthDimension.cxx index 34a8c581c0..9a8f6d3808 100755 --- a/src/AIS/AIS_LengthDimension.cxx +++ b/src/AIS/AIS_LengthDimension.cxx @@ -1,7 +1,7 @@ // Created on: 1996-12-05 // Created by: Arnaud BOUZY/Odile Olivier // Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS +// Copyright (c) 1999-2013 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file @@ -22,1226 +22,619 @@ #define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size // if any in all dimensions. -#include -#include + +#include #include #include #include - +#include #include #include -#include - +#include +#include +#include #include #include - #include #include - #include #include #include #include #include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - #include - +#include #include #include -#include #include - +#include +#include #include #include #include #include - #include - +#include #include - -#include #include - #include #include #include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - +IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension) +IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension) //======================================================================= //function : Constructor -//purpose : TwoFacesLength dimension +//purpose : Dimension between two points //======================================================================= -AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& aFirstFace, - const TopoDS_Face& aSecondFace, - const Standard_Real aVal, - const TCollection_ExtendedString& aText) -:AIS_Relation(), - myNbShape(2) +AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pln& theDimensionPlane, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize /*= 1.0*/) + :AIS_Dimension (theDimensionAspect,theExtensionSize), + myFlyout (15.) { - SetFirstShape( aFirstFace ); - SetSecondShape( aSecondFace ); - myVal = aVal; - - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - - myArrowSize = myVal / 10.; + myIsInitialized = Standard_True; + myFirstPoint = theFirstPoint; + mySecondPoint = theSecondPoint; + myShapesNumber = 2; + myFirstShape = BRepLib_MakeVertex (myFirstPoint); + mySecondShape = BRepLib_MakeVertex (mySecondPoint); + SetKindOfDimension(AIS_KOD_LENGTH); + SetWorkingPlane (theDimensionPlane); } //======================================================================= //function : Constructor -//purpose : TwoFacesLength dimension (with position and text) +//purpose : Dimension between two points //======================================================================= -AIS_LengthDimension::AIS_LengthDimension(const TopoDS_Face& aFirstFace, - const TopoDS_Face& aSecondFace, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Real anArrowSize) -:AIS_Relation(), - myNbShape(2) +AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pln& theDimensionPlane) +: AIS_Dimension (), + myFlyout (15.) { - SetFirstShape( aFirstFace ); - SetSecondShape( aSecondFace ); - myVal = aVal; - - myText = aText; - mySymbolPrs = aSymbolPrs; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myPosition = aPosition; + myIsInitialized = Standard_True; + myFirstPoint = theFirstPoint; + mySecondPoint = theSecondPoint; + myFirstShape = BRepLib_MakeVertex (myFirstPoint); + mySecondShape = BRepLib_MakeVertex (mySecondPoint); + myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_LENGTH); + SetWorkingPlane (theDimensionPlane); } - - -//======================================================================= -//function : AIS_LengthDimension -//purpose : Distance Face - Edge for chamfer 3D -//======================================================================= - -AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& Face,const TopoDS_Edge& Edge,const Standard_Real Val,const TCollection_ExtendedString& Text) - -:AIS_Relation (), - myNbShape (2) -{ - SetFirstShape (Face); - SetSecondShape (Edge); - myText = Text; - myVal = Val; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - myArrowSize = myVal/10.0; -} - - - //======================================================================= //function : Constructor -//purpose : TwoEdgesLength dimension or OneEdgeOneVertexLength dimension or TwoVerticesLength dimension +//purpose : Dimension between two shape //======================================================================= -AIS_LengthDimension::AIS_LengthDimension(const TopoDS_Shape& aFShape, - const TopoDS_Shape& aSShape, - const Handle(Geom_Plane)& aPlane, - const Standard_Real aVal, - const TCollection_ExtendedString& aText) -:AIS_Relation(), - myNbShape(2), - myTypeDist(AIS_TOD_Unknown) +AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape, + const TopoDS_Shape& theSecondShape, + const gp_Pln& theWorkingPlane) +: AIS_Dimension (), + myFlyout (15.) { - myFShape = aFShape; - mySShape = aSShape; - myVal = aVal; - myText = aText; - mySymbolPrs = DsgPrs_AS_BOTHAR; - myAutomaticPosition = Standard_True; - myPlane =aPlane; - myArrowSize = myVal / 10.; + myIsInitialized = Standard_False; + myFirstShape = theFirstShape; + mySecondShape = theSecondShape; + myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_LENGTH); + SetWorkingPlane (theWorkingPlane); } //======================================================================= //function : Constructor -//purpose : TwoEdgesLength dimension or OneEdgeOneVertexLength dimension or TwoVerticesLength dimension +//purpose : Dimension of one edge //======================================================================= -AIS_LengthDimension::AIS_LengthDimension(const TopoDS_Shape& aFShape, - const TopoDS_Shape& aSShape, - const Handle(Geom_Plane)& aPlane, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const AIS_TypeOfDist aTypeDist, - const Standard_Real anArrowSize) -:AIS_Relation(), - myNbShape(2), - myTypeDist(aTypeDist) +AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge, + const gp_Pln& theWorkingPlane) +: AIS_Dimension (), + myFlyout (15.) { - myFShape = aFShape; - mySShape = aSShape; - myVal = aVal; - myPlane = aPlane; - myText = aText; - mySymbolPrs = aSymbolPrs; - myAutomaticPosition = Standard_False; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myPosition = aPosition; + myIsInitialized = Standard_False; + myFirstShape = theEdge; + myShapesNumber = 1; + SetKindOfDimension (AIS_KOD_LENGTH); + SetWorkingPlane (theWorkingPlane); } - - //======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager3d)&, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer) -{ - aPresentation->Clear(); - - if (myNbShape == 1) { - switch (myFShape.ShapeType()) { - case TopAbs_FACE: - { - // case length on a face - ComputeOneFaceLength(aPresentation); - } - break; - case TopAbs_EDGE: - { - // case length of an edge - ComputeOneEdgeLength(aPresentation); - } - break; - default: - break; - } - } - else if (myNbShape == 2) { - switch (myFShape.ShapeType()) { - case TopAbs_FACE: - { - if (mySShape.ShapeType () == TopAbs_FACE) { - // case length between two faces - ComputeTwoFacesLength(aPresentation); - } - else if (mySShape.ShapeType () == TopAbs_EDGE) { - ComputeEdgeFaceLength (aPresentation); - } - } - break; - case TopAbs_EDGE: - { - if (mySShape.ShapeType() == TopAbs_VERTEX) { -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) -#endif - myArrowSize = Abs(myVal)/100.; - ComputeOneEdgeOneVertexLength( aPresentation, - myDrawer, - myText, - myArrowSize, - myFShape, - mySShape, - myPlane, - myAutomaticPosition, - myIsSetBndBox, - myBndBox, - myExtShape, - myVal, - myDirAttach, - myPosition, - myFAttach, - mySAttach, - mySymbolPrs ); - } - else if (mySShape.ShapeType() == TopAbs_EDGE) { - // case length between two edges -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) -#endif - myArrowSize = Abs(myVal)/100.; - ComputeTwoEdgesLength( aPresentation, - myDrawer, - myText, - myArrowSize, - TopoDS::Edge( myFShape ), - TopoDS::Edge( mySShape ), - myPlane, - myAutomaticPosition, - myIsSetBndBox, - myBndBox, - myExtShape, - myVal, - myDirAttach, - myPosition, - myFAttach, - mySAttach, - mySymbolPrs ); - } - } - break; - - case TopAbs_VERTEX: - { - if (mySShape.ShapeType() == TopAbs_VERTEX) { -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) -#endif - myArrowSize = Abs(myVal)/100.; - ComputeTwoVerticesLength( aPresentation, - myDrawer, - myText, - myArrowSize, - TopoDS::Vertex( myFShape ), - TopoDS::Vertex( mySShape ), - myPlane, - myAutomaticPosition, - myIsSetBndBox, - myBndBox, - myTypeDist, - myExtShape, - myVal, - myDirAttach, - myPosition, - myFAttach, - mySAttach, - mySymbolPrs ); - } - else if (mySShape.ShapeType() == TopAbs_EDGE) { -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) -#endif - myArrowSize = Abs(myVal)/100.; - ComputeOneEdgeOneVertexLength( aPresentation, - myDrawer, - myText, - myArrowSize, - myFShape, - mySShape, - myPlane, - myAutomaticPosition, - myIsSetBndBox, - myBndBox, - myExtShape, - myVal, - myDirAttach, - myPosition, - myFAttach, - mySAttach, - mySymbolPrs ); - } - } - break; - default: - break; - } - } - -} - -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_LengthDimension::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) -{ -// Standard_NotImplemented::Raise("AIS_LengthDimension::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; -} - -void AIS_LengthDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) -{ -// Standard_NotImplemented::Raise("AIS_LengthDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; -} - -//======================================================================= -//function : ComputeSelection -//purpose : -//======================================================================= - -void AIS_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer) -{ - if (myFShape.IsNull() && mySShape.IsNull()) return; - if (myFShape.ShapeType() == TopAbs_FACE) ComputeFaceSelection(aSelection); - else ComputeEdgeVertexSelection(aSelection); - - // Text - Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 ); - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + size, - myPosition.Y() + size, - myPosition.Z() + size); - aSelection->Add(box); -} - - -//======================================================================= -//function : ComputeOneFaceLength -//purpose : +//function : Constructor +//purpose : Dimension between two faces //======================================================================= -void AIS_LengthDimension::ComputeOneFaceLength(const Handle(Prs3d_Presentation)&) +AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace, + const TopoDS_Face& theSecondFace) +: AIS_Dimension (), + myFlyout (15.) { - Standard_DomainError::Raise("AIS_LengthDimension::ComputeOneFaceLength : Not implemented"); + myIsInitialized = Standard_False; + myFirstShape = theFirstFace; + mySecondShape = theSecondFace; + myShapesNumber = 2; + SetKindOfDimension(AIS_KOD_LENGTH); } //======================================================================= -//function : ComputeOneOneEdgeLength -//purpose : +//function : Constructor +//purpose : Dimension between two shape //======================================================================= -void AIS_LengthDimension::ComputeOneEdgeLength(const Handle(Prs3d_Presentation)&) +AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge) + : AIS_Dimension (), + myFlyout (15.) { - Standard_DomainError::Raise("AIS_LengthDimension::ComputeOneEdgeLength : Not implemented"); + SetKindOfDimension(AIS_KOD_LENGTH); + myIsInitialized = Standard_False; + myFirstShape = theFace; + mySecondShape = theEdge; + myShapesNumber = 2; } //======================================================================= -//function : ComputeTwoFacesLength -//purpose : +//function : initTwoEdgesLength +//purpose : Initialization of dimanesion between two linear edges //======================================================================= -void AIS_LengthDimension::ComputeTwoFacesLength( const Handle( Prs3d_Presentation )& aPresentation ) +Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & theFirstEdge, + const TopoDS_Edge& theSecondEdge, + gp_Dir& theDirAttach) { - if (myFShape.ShapeType() == TopAbs_COMPOUND) { //rob debug from vbu? - TopExp_Explorer E (myFShape,TopAbs_FACE); - if (E.More()) SetFirstShape(E.Current()); + Standard_Integer anExtShapeIndex = 0; + BRepAdaptor_Curve aFirstCurveAdapt (theFirstEdge); + if (aFirstCurveAdapt.GetType() != GeomAbs_Line) + return Standard_False; + BRepAdaptor_Curve aSecondCurveAdapt (theSecondEdge); + if (aSecondCurveAdapt.GetType() != GeomAbs_Line) + return Standard_False; + Handle(Geom_Curve) aFirstCurve, aSecondCurve; + gp_Pnt aPoint11,aPoint12,aPoint21,aPoint22; + Standard_Boolean isFirstInfinite (Standard_False), + isSecondInfinite (Standard_False); + Handle(Geom_Curve) anExtCurve; + + if (!AIS::ComputeGeometry (theFirstEdge, theSecondEdge,anExtShapeIndex, + aFirstCurve, aSecondCurve, aPoint11, aPoint12, + aPoint21, aPoint22, anExtCurve, isFirstInfinite, + isSecondInfinite, new Geom_Plane(GetWorkingPlane()))) + return Standard_False; + + const Handle(Geom_Line)& aGeomLine1 = (Handle(Geom_Line)&) aFirstCurve; + const Handle(Geom_Line)& aGeomLine2 = (Handle(Geom_Line)&) aSecondCurve; + const gp_Lin& aLin1 = aGeomLine1->Lin(); + const gp_Lin& aLin2 = aGeomLine2->Lin(); + + myValue = aLin1.Distance (aLin2); + theDirAttach = aLin1.Direction(); + + gp_Pnt aCurPos; + if (!isFirstInfinite) + { + gp_Pnt aPoint2 = ElCLib::Value(ElCLib::Parameter (aLin2, aPoint11), aLin2); + aCurPos.SetXYZ((aPoint11.XYZ() + aPoint2.XYZ()) / 2.); + } + else if (!isSecondInfinite) + { + gp_Pnt aPoint2 = ElCLib::Value (ElCLib::Parameter (aLin1, aPoint21), aLin1); + aCurPos.SetXYZ ((aPoint21.XYZ() + aPoint2.XYZ()) / 2.); } - if (mySShape.ShapeType() == TopAbs_COMPOUND) { - TopExp_Explorer E (mySShape,TopAbs_FACE); - if (E.More()) SetSecondShape(E.Current()); // rob debug from vbu? + else + aCurPos.SetXYZ((aLin1.Location().XYZ() + aLin2.Location().XYZ()) / 2.); + + // Offset to avoid confusion Edge and Dimension + gp_Vec anOffset(theDirAttach); + anOffset = anOffset*myDrawer->DimensionAspect()->ArrowAspect()->Length()*(-10.); + aCurPos.Translate(anOffset); + myGeom.myTextPosition = aCurPos; + // Find attachment points + if (!isFirstInfinite) + { + if (myGeom.myTextPosition.Distance(aPoint11) > myGeom.myTextPosition.Distance(aPoint12)) + myFirstPoint = aPoint12; + else + myFirstPoint = aPoint11; } + else + myFirstPoint = ElCLib::Value(ElCLib::Parameter(aLin1,myGeom.myTextPosition), aLin1); - if (myFirstSurfType == AIS_KOS_Plane) - { - AIS::ComputeLengthBetweenPlanarFaces( TopoDS::Face(myFShape), - TopoDS::Face(mySShape), - myFirstPlane, - mySecondPlane, - myVal, - myFAttach, - mySAttach, - myDirAttach, - myAutomaticPosition, - myPosition ); - if (myAutomaticPosition && myIsSetBndBox) - myPosition = AIS::TranslatePointToBound( myPosition, myDirAttach, myBndBox ); - - myDrawer->LengthAspect()->Arrow1Aspect()->SetLength( myArrowSize ); - myDrawer->LengthAspect()->Arrow2Aspect()->SetLength( myArrowSize ); - - // Find text of the face - - DsgPrs_LengthPresentation::Add( aPresentation, - myDrawer, - myText, - myFAttach, - mySAttach, - myFirstPlane, - myDirAttach, - myPosition, - mySymbolPrs ); - } + if (!isSecondInfinite) + { + if (myGeom.myTextPosition.Distance(aPoint21) > myGeom.myTextPosition.Distance(aPoint22)) + mySecondPoint = aPoint22; + else + mySecondPoint = aPoint21; + } else - { - AIS::ComputeLengthBetweenCurvilinearFaces( TopoDS::Face(myFShape), - TopoDS::Face(mySShape), - myFirstBasisSurf, - mySecondBasisSurf, - myAutomaticPosition, - myVal, - myPosition, - myFAttach, - mySAttach, - myDirAttach ); - if (myAutomaticPosition && myIsSetBndBox) - myPosition = AIS::TranslatePointToBound( myPosition, myDirAttach, myBndBox ); + mySecondPoint = ElCLib::Value(ElCLib::Parameter(aLin2, myGeom.myTextPosition), aLin2); - DsgPrs_LengthPresentation::Add( aPresentation, - myDrawer, - myText, - mySecondBasisSurf, - myFAttach, - mySAttach, - myDirAttach, - myPosition, - mySymbolPrs ); - } + return Standard_True; } - //======================================================================= -//function : ComputeEdgeFaceLength -//purpose : Jean-Claude Vauthier 17/06/98 -// A quick implementation in order to edit the constraint of -// distance for a chamfer 3D. +//function : initEdgeVertexLength +//purpose : for first edge and second vertex shapes //======================================================================= -void AIS_LengthDimension::ComputeEdgeFaceLength (const Handle(Prs3d_Presentation )& aPresentation ) +Standard_Boolean AIS_LengthDimension::initEdgeVertexLength (const TopoDS_Edge & theEdge, + const TopoDS_Vertex & theVertex, + gp_Dir & theDirAttach, + Standard_Boolean isInfinite) { - - //The first attachment point is P1 from the reference Edge - //Find the second attachment point which belongs to the reference face - //Iterate over the edges of the face and find the point FP1... - //....it is the closest point according to P1 - - const TopoDS_Edge& E = TopoDS::Edge (mySShape); //The reference edge - const TopoDS_Face& F = TopoDS::Face (myFShape); //The reference face - TopoDS_Vertex V1, V2; - TopExp::Vertices (E, V1, V2); - myFAttach = BRep_Tool::Pnt (V1); - gp_Pnt P = BRep_Tool::Pnt (V2); - - TopExp_Explorer It (F, TopAbs_EDGE); - gp_Pnt2d FP1uv, FP2uv; - Standard_Real Dist1 = RealLast (); - Standard_Real Dist2 = RealLast (); - for (; It.More (); It.Next ()) { - const TopoDS_Edge FE = TopoDS::Edge(It.Current ()); - TopExp::Vertices (FE, V1, V2); - gp_Pnt FP1c = BRep_Tool::Pnt (V1); - gp_Pnt FP2c = BRep_Tool::Pnt (V2); - Standard_Real Dc1 = myFAttach.SquareDistance (FP1c); - Standard_Real Dc2 = myFAttach.SquareDistance (FP2c); - if (Dc1 <= Dc2) { - if (Dc1 <= Dist1) { - Dc2 = P.SquareDistance (FP2c); - if (Dc2 <= Dist2) { - mySAttach = FP1c; - Dist1 = Dc1; - Dist2 = Dc2; - BRep_Tool::UVPoints (FE, F, FP1uv, FP2uv); - } - } - } - else { - if (Dc2 <= Dist1) { - Dc1 = P.SquareDistance (FP1c); - if (Dc1 <= Dist2) { - mySAttach = FP2c; - Dist1 = Dc2; - Dist2 = Dc1; - BRep_Tool::UVPoints (FE, F, FP2uv, FP1uv); - } - } - } - } - - gp_Vec OffsetDirection (0.0, 0.0, 0.0); - - //The offset direction is the normal to the face at the point FP1 - BRepGProp_Face GF; - GF.Load (F); - GF.Normal (FP1uv.X(), FP1uv.Y(), P, OffsetDirection); - - if (OffsetDirection.Magnitude () > Precision::Confusion ()) { - myDirAttach = gp_Dir (OffsetDirection); + gp_Pnt anEdgePoint1,anEdgePoint2; + Handle(Geom_Curve) aCurve; + Handle(Geom_Curve) anExtCurve; + Standard_Boolean isEdgeOnPlane, isVertexOnPlane; + if (!AIS::ComputeGeometry(theEdge,aCurve,anEdgePoint1,anEdgePoint2, + anExtCurve,isInfinite,isEdgeOnPlane, new Geom_Plane (GetWorkingPlane()))) + return Standard_False; + AIS::ComputeGeometry (theVertex, myFirstPoint, new Geom_Plane(GetWorkingPlane()), isVertexOnPlane); + + const Handle(Geom_Line)& aGeomLine = (Handle(Geom_Line)&) aCurve; + const gp_Lin& aLin = aGeomLine->Lin(); + + myValue = aLin.Distance( myFirstPoint); + theDirAttach = aLin.Direction(); + + gp_Pnt aPoint = ElCLib::Value(ElCLib::Parameter(aLin,myFirstPoint),aLin); + gp_Pnt aCurPos((myFirstPoint.XYZ() + aPoint.XYZ())/2.); + + if (!isInfinite) + { + if (myGeom.myTextPosition.Distance(anEdgePoint1) > myGeom.myTextPosition.Distance(anEdgePoint2)) + mySecondPoint = anEdgePoint2; + else + mySecondPoint = anEdgePoint1; } - else myDirAttach = gp::DZ (); - - - gp_Vec Vt (myDirAttach); - Vt.Multiply (1.5 * myVal); - myPosition = mySAttach.Translated (Vt); - - DsgPrs_LengthPresentation::Add(aPresentation, - myDrawer, - myText, - myFAttach, - mySAttach, - myDirAttach, - myPosition, - mySymbolPrs); - + else + mySecondPoint = ElCLib::Value(ElCLib::Parameter(aLin,myGeom.myTextPosition),aLin); + return Standard_True; } - //======================================================================= -//function : ComputeTwoEdgesLength +//function : initEdgeVertexLength //purpose : //======================================================================= -void AIS_LengthDimension::ComputeTwoEdgesLength( const Handle( Prs3d_Presentation )& aPresentation, - const Handle( AIS_Drawer )& aDrawer, - const TCollection_ExtendedString & aText, - const Standard_Real ArrowSize, - const TopoDS_Edge & FirstEdge, - const TopoDS_Edge & SecondEdge, - const Handle( Geom_Plane )& Plane, - const Standard_Boolean AutomaticPos, - const Standard_Boolean IsSetBndBox, - const Bnd_Box & BndBox, - Standard_Integer & ExtShape, - Standard_Real & Val, - gp_Dir & DirAttach, - gp_Pnt & Position, - gp_Pnt & FirstAttach, - gp_Pnt & SecondAttach, - DsgPrs_ArrowSide & SymbolPrs ) +Standard_Boolean AIS_LengthDimension::initEdgeFaceLength (const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + gp_Dir& theDirAttach) { - BRepAdaptor_Curve cu1( FirstEdge ); - if (cu1.GetType() != GeomAbs_Line) return; - BRepAdaptor_Curve cu2( SecondEdge ); - if (cu2.GetType() != GeomAbs_Line) return; - - // 3d lines - Handle(Geom_Curve) geom1,geom2; - gp_Pnt ptat11,ptat12,ptat21,ptat22;//,pint3d; - - Standard_Boolean isInfinite1(Standard_False),isInfinite2(Standard_False); - Standard_Integer ext(ExtShape); - Handle(Geom_Curve) extCurv; - if (!AIS::ComputeGeometry(FirstEdge, - SecondEdge, - ExtShape, - geom1, - geom2, - ptat11, - ptat12, - ptat21, - ptat22, - extCurv, - isInfinite1, - isInfinite2, - Plane)) + // The first attachment point is from the reference . + // Find the second attachment point which belongs to the reference face + // Iterate over the edges of the face and find the point . + // It is the closest point according to . + TopoDS_Vertex aVertex1, aVertex2; + TopExp::Vertices (theEdge, aVertex1, aVertex2); + myFirstPoint = BRep_Tool::Pnt (aVertex1); + gp_Pnt aPoint = BRep_Tool::Pnt (aVertex2); + gp_Pnt2d aFacePoint1uv, aFacePoint2uv; + Standard_Real aDist1 = RealLast (); + Standard_Real aDist2 = RealLast (); + + TopExp_Explorer anIt (theFace, TopAbs_EDGE); + for (; anIt.More (); anIt.Next ()) + { + const TopoDS_Edge aFaceEdge = TopoDS::Edge(anIt.Current ()); + if (aFaceEdge == theEdge) + return Standard_False; + TopExp::Vertices (aFaceEdge, aVertex1, aVertex2); + gp_Pnt aFacePoint1c = BRep_Tool::Pnt (aVertex1); + gp_Pnt aFacePoint2c = BRep_Tool::Pnt (aVertex2); + Standard_Real aDistc1 = myFirstPoint.SquareDistance (aFacePoint1c); + Standard_Real aDistc2 = myFirstPoint.SquareDistance (aFacePoint2c); + if (aDistc1 <= aDistc2) { - return; - } - ExtShape = ext; - aPresentation->SetInfiniteState(isInfinite1 || isInfinite2); - const Handle(Geom_Line)& geom_lin1 = (Handle(Geom_Line)&) geom1; - const Handle(Geom_Line)& geom_lin2 = (Handle(Geom_Line)&) geom2; - const gp_Lin& l1 = geom_lin1->Lin(); - const gp_Lin& l2 = geom_lin2->Lin(); - - // New: computation of myVal - Val = l1.Distance( l2 ); - - DirAttach = l1.Direction(); - - // size - Standard_Real arrsize = ArrowSize; - - if (AutomaticPos) { - gp_Pnt curpos; - if ( !isInfinite1 ) { - gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l2,ptat11),l2); - curpos.SetXYZ((ptat11.XYZ()+p2.XYZ())/2.); - } - else if (!isInfinite2) { - gp_Pnt p2 = ElCLib::Value(ElCLib::Parameter(l1,ptat21),l1); - curpos.SetXYZ((ptat21.XYZ()+p2.XYZ())/2.); - } - else { - curpos.SetXYZ((l1.Location().XYZ()+l2.Location().XYZ())/2.); - } - // offset to avoid confusion Edge and Dimension - gp_Vec offset(DirAttach); - offset = offset*ArrowSize*(-10.); - curpos.Translate(offset); - Position = curpos; - } - else { // the point is projected in the plane - // it is patch! - Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() ); - } - - // find attachment points - if (!isInfinite1) { - if (Position.Distance(ptat11) > Position.Distance(ptat12)) FirstAttach = ptat12; - else FirstAttach = ptat11; - } - else { - FirstAttach = ElCLib::Value(ElCLib::Parameter(l1,Position),l1); - } - - if (!isInfinite2) { - if (Position.Distance(ptat21) > Position.Distance(ptat22)) SecondAttach = ptat22; - else SecondAttach = ptat21; - } - else { - SecondAttach = ElCLib::Value(ElCLib::Parameter(l2,Position),l2); - } - - Standard_Real confusion(Precision::Confusion()); - if (arrsize < confusion) arrsize = Val/10.; - if (Abs(Val) <= confusion) {arrsize = 0.;} - - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - arr->SetLength(arrsize); - arr = la->Arrow2Aspect(); - arr->SetLength(arrsize); - - if ( ExtShape == 1) - SymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR; - else if ( ExtShape == 2) - SymbolPrs = DsgPrs_AS_FIRSTAR_LASTPT; - - if (AutomaticPos && IsSetBndBox) - Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox ); - - DsgPrs_LengthPresentation::Add(aPresentation, - aDrawer, - aText, - FirstAttach, - SecondAttach, - DirAttach, - Position, - SymbolPrs); - - if ( (ExtShape != 0) && !extCurv.IsNull()) { - gp_Pnt pf, pl; - if ( ExtShape == 1 ) { - if (!isInfinite1) { - pf = ptat11; - pl = ptat12; + if (aDistc1 <= aDist1) + { + aDistc2 = aPoint.SquareDistance (aFacePoint2c); + if (aDistc2 <= aDist2) + { + mySecondPoint = aFacePoint1c; + aDist1 = aDistc1; + aDist2 = aDistc2; + BRep_Tool::UVPoints (aFaceEdge, theFace, aFacePoint1uv, aFacePoint2uv); + } } - AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, FirstEdge, geom_lin1, pf, pl ); } - else { - if (!isInfinite2) { - pf = ptat21; - pl = ptat22; + else + { + if (aDistc2 <= aDist1) + { + aDistc1 = aPoint.SquareDistance (aFacePoint1c); + if (aDistc1 <= aDist2) + { + mySecondPoint = aFacePoint2c; + aDist1 = aDistc2; + aDist2 = aDistc1; + BRep_Tool::UVPoints (aFaceEdge, theFace, aFacePoint2uv, aFacePoint1uv); + } } - AIS::ComputeProjEdgePresentation( aPresentation, aDrawer, SecondEdge, geom_lin2, pf, pl ); } } -} - -//======================================================================= -//function : ComputeOneEdgeOneVertexLength -//purpose : -//======================================================================= - -void AIS_LengthDimension::ComputeOneEdgeOneVertexLength( const Handle( Prs3d_Presentation )& aPresentation, - const Handle( AIS_Drawer )& aDrawer, - const TCollection_ExtendedString & aText, - const Standard_Real ArrowSize, - const TopoDS_Shape & FirstShape, - const TopoDS_Shape & SecondShape, - const Handle( Geom_Plane )& Plane, - const Standard_Boolean AutomaticPos, - const Standard_Boolean IsSetBndBox, - const Bnd_Box & BndBox, - Standard_Integer & ExtShape, - Standard_Real & Val, - gp_Dir & DirAttach, - gp_Pnt & Position, - gp_Pnt & FirstAttach, - gp_Pnt & SecondAttach, - DsgPrs_ArrowSide & SymbolPrs ) -{ - TopoDS_Vertex thevertex; - TopoDS_Edge theedge; - Standard_Integer numedge; - - if (FirstShape.ShapeType() == TopAbs_VERTEX) { - thevertex = TopoDS::Vertex(FirstShape); - theedge = TopoDS::Edge(SecondShape); - numedge = 2;// edge = 2nd shape - } - else { - thevertex = TopoDS::Vertex(SecondShape); - theedge = TopoDS::Edge(FirstShape); - numedge = 1; // edge = 1st shape - } - - gp_Pnt ptonedge1,ptonedge2; - Handle(Geom_Curve) aCurve; - Handle(Geom_Curve) extCurv; - Standard_Boolean isInfinite; - Standard_Boolean isOnPlanEdge, isOnPlanVertex; - if (!AIS::ComputeGeometry(theedge,aCurve,ptonedge1,ptonedge2,extCurv,isInfinite,isOnPlanEdge,Plane)) - return; - aPresentation->SetInfiniteState(isInfinite); - AIS::ComputeGeometry(thevertex, FirstAttach, Plane, isOnPlanVertex); - // take into consideration that only the curve can be projected - if (!isOnPlanEdge && !isOnPlanVertex) - return; + gp_Vec anOffsetDirection (0.0, 0.0, 0.0); - if (!isOnPlanEdge) { - if (numedge == 1) ExtShape = 1; - else ExtShape = 2; - } - else if (!isOnPlanVertex) { - if (numedge == 1) ExtShape = 2; - else ExtShape = 1; - } - - - const Handle(Geom_Line)& geom_lin = (Handle(Geom_Line)&) aCurve; - const gp_Lin& l = geom_lin->Lin(); - - // New: computation of Val - Val = l.Distance( FirstAttach ); - - DirAttach = l.Direction(); - // size - Standard_Real arrsize = ArrowSize; - if (Abs(Val) <= Precision::Confusion()) {arrsize = 0.;} - - if (AutomaticPos) { - gp_Pnt p = ElCLib::Value(ElCLib::Parameter(l,FirstAttach),l); - gp_Pnt curpos((FirstAttach.XYZ()+p.XYZ())/2.); - // offset to avoid confusion Edge and Dimension - gp_Vec offset(DirAttach); - offset = offset*ArrowSize*(-10.); - curpos.Translate(offset); - Position = curpos; - } - else { // the point is projected in the plane - // it is patch! - Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() ); - - /* - Standard_Real u,v; - ElSLib::Parameters(Plane->Pln() , Position, u, v); - Position = ElSLib::Value(u,v,Plane->Pln()); - */ - } - - if (!isInfinite) { - if (Position.Distance(ptonedge1) > Position.Distance(ptonedge2)) SecondAttach = ptonedge2; - else SecondAttach = ptonedge1; - } - else { - SecondAttach = ElCLib::Value(ElCLib::Parameter(l,Position),l); - } - - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - arr->SetLength(arrsize); - arr = la->Arrow2Aspect(); - arr->SetLength(arrsize); - - if (AutomaticPos && IsSetBndBox) - Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox ); - - DsgPrs_LengthPresentation::Add(aPresentation, - aDrawer, - aText, - FirstAttach, - SecondAttach, - DirAttach, - Position, - SymbolPrs); - - //Display the pieces connecting to the curve if it is not in the WP - if (ExtShape != 0) { - - if (!extCurv.IsNull()) { // this is the edge that is not in the WP - AIS::ComputeProjEdgePresentation(aPresentation,aDrawer,theedge,geom_lin,ptonedge1,ptonedge2); - } - else { // this is the point that is not in the WP - AIS::ComputeProjVertexPresentation(aPresentation,aDrawer,thevertex,FirstAttach); - } - } -} - -//======================================================================= -//function : ComputeTwoVerticesLength -//purpose : -//======================================================================= - -void AIS_LengthDimension::ComputeTwoVerticesLength( const Handle( Prs3d_Presentation )& aPresentation, - const Handle( AIS_Drawer )& aDrawer, - const TCollection_ExtendedString& aText, - const Standard_Real ArrowSize, - const TopoDS_Vertex& FirstVertex, - const TopoDS_Vertex& SecondVertex, - const Handle( Geom_Plane )& Plane, - const Standard_Boolean AutomaticPos, - const Standard_Boolean IsSetBndBox, - const Bnd_Box& BndBox, - const AIS_TypeOfDist TypeDist, - Standard_Integer& ExtShape, - Standard_Real& Val, - gp_Dir& DirAttach, - gp_Pnt& Position, - gp_Pnt& FirstAttach, - gp_Pnt& SecondAttach, - DsgPrs_ArrowSide& SymbolPrs ) -{ - Standard_Boolean isOnPlane1, isOnPlane2; - - AIS::ComputeGeometry( FirstVertex, FirstAttach, Plane, isOnPlane1); - AIS::ComputeGeometry( SecondVertex, SecondAttach, Plane, isOnPlane2); - - // New: computation of Val - Val = FirstAttach.Distance( SecondAttach ); - - if (ExtShape == 0) { - if (isOnPlane1 && isOnPlane2) - ExtShape = 0; - else if ( isOnPlane1 && !isOnPlane2) - ExtShape = 2; - else if (!isOnPlane1 && isOnPlane2) - ExtShape = 1; - else - return ; - } - Standard_Real confusion(Precision::Confusion()); - Standard_Boolean samePoint(FirstAttach.IsEqual(SecondAttach,confusion)); - - if (TypeDist == AIS_TOD_Vertical) DirAttach = Plane->Pln().XAxis().Direction(); - else if (TypeDist == AIS_TOD_Horizontal) DirAttach = Plane->Pln().YAxis().Direction(); - else { - if (!samePoint) { - DirAttach = gce_MakeDir(FirstAttach,SecondAttach); - DirAttach.Rotate(Plane->Pln().Axis(),M_PI/2.); - } - } - - // size - //Standard_Real arrsize = ArrowSize; - //if (Abs(Val) <= confusion) arrsize =0.; + //The offset direction is the normal to the face at the point FP1 + BRepGProp_Face aGFace; + aGFace.Load (theFace); + aGFace.Normal (aFacePoint1uv.X(), aFacePoint1uv.Y(), aPoint, anOffsetDirection); - if (AutomaticPos) { - if (!samePoint) { - gp_Pnt curpos((FirstAttach.XYZ()+SecondAttach.XYZ())/2.); - // offset to avoid confusion Edge and Dimension - gp_Vec offset(DirAttach); - offset = offset*ArrowSize*(-10.); - curpos.Translate(offset); - Position = curpos; - } - else { - Position = gp_Pnt(FirstAttach.XYZ()+gp_XYZ(1.,1.,1.)); - // it is patch! - Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() ); - DirAttach = gce_MakeDir(FirstAttach,Position); - } + if (anOffsetDirection.Magnitude () > Precision::Confusion ()) + { + theDirAttach = gp_Dir (anOffsetDirection); } - else { - // it is patch! - Position = AIS::ProjectPointOnPlane( Position, Plane->Pln() ); - } - - - Handle(Prs3d_LengthAspect) la = aDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - arr->SetLength(ArrowSize); - arr = la->Arrow2Aspect(); - arr->SetLength(ArrowSize); - - // Type of arrows - if ( ExtShape == 1) SymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR; - else if (ExtShape == 2) SymbolPrs = DsgPrs_AS_FIRSTAR_LASTPT; - - if (AutomaticPos && IsSetBndBox) - Position = AIS::TranslatePointToBound( Position, DirAttach, BndBox ); - - DsgPrs_LengthPresentation::Add(aPresentation, - aDrawer, - aText, - FirstAttach, - SecondAttach, - DirAttach, - Position, - SymbolPrs); + else theDirAttach = gp::DZ (); - // Calculate the projection of the vertex - if ( ExtShape == 1) - AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, FirstVertex, FirstAttach); - else if ( ExtShape == 2) - AIS::ComputeProjVertexPresentation(aPresentation, aDrawer, SecondVertex, SecondAttach); + gp_Vec aVector (theDirAttach); + aVector.Multiply (1.5 * myValue); + myGeom.myTextPosition = mySecondPoint.Translated (aVector); + return Standard_True; } //======================================================================= -//function : ComputeTwoFaceSelection -//purpose : +//function : initTwoShapesPoints +//purpose : Initialization of two points where dimension layouts +// will be attached //======================================================================= -void AIS_LengthDimension::ComputeFaceSelection( const Handle( SelectMgr_Selection )& aSelection ) +Standard_Boolean AIS_LengthDimension::initTwoShapesPoints (const TopoDS_Shape& theFirstShape, + const TopoDS_Shape& theSecondShape) { - Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 ); - Handle( Select3D_SensitiveSegment ) seg; - Handle( Geom_TrimmedCurve ) curve; - Handle( Select3D_SensitiveCurve ) SensCurve; - - Standard_Real ArrowLength = myDrawer->AngleAspect()->ArrowAspect()->Length(); - - gp_Pnt EndOfArrow1, EndOfArrow2; - gp_Dir DirOfArrow1; - - if (myFirstSurfType == AIS_KOS_Plane) + gp_Dir aDirAttach; + Standard_Boolean isInfinite = Standard_False; + Standard_Boolean isSuccess = Standard_False; + switch (theFirstShape.ShapeType()) + { + case TopAbs_FACE: { - DsgPrs::ComputePlanarFacesLengthPresentation( ArrowLength, - ArrowLength, - myFAttach, - mySAttach, - myDirAttach, - myPosition, - myFirstPlane, - EndOfArrow1, - EndOfArrow2, - DirOfArrow1 ); - //Add attach lines - seg = new Select3D_SensitiveSegment( own, myFAttach, EndOfArrow1 ); - aSelection->Add( seg ); - - seg = new Select3D_SensitiveSegment( own, mySAttach, EndOfArrow2 ); - aSelection->Add( seg ); - } - else // curvilinear case - { - if(mySecondBasisSurf.IsNull()) - return; - - Handle( Geom_Curve ) VCurve, UCurve; - Standard_Real FirstU, deltaU = 0.0e0, FirstV, deltaV = 0.0e0; - - EndOfArrow1 = myFAttach; - DsgPrs::ComputeCurvilinearFacesLengthPresentation( ArrowLength, - ArrowLength, - mySecondBasisSurf, - myFAttach, - mySAttach, - myDirAttach, - EndOfArrow2, - DirOfArrow1, - VCurve, - UCurve, - FirstU, deltaU, - FirstV, deltaV ); - // Add attach curves - if (Abs( deltaU ) > Precision::PConfusion()) + // Initialization for face + gp_Pln aFirstPlane; + Handle(Geom_Surface) aFirstSurface; + AIS_KindOfSurface aFirstSurfKind; + Standard_Real aFirstOffset; + TopoDS_Face aFirstFace = TopoDS::Face (theFirstShape); + AIS::InitFaceLength (TopoDS::Face (theFirstShape), aFirstPlane, + aFirstSurface,aFirstSurfKind, aFirstOffset); + + if (theSecondShape.ShapeType () == TopAbs_FACE) + { + // Initialization for face + gp_Pln aSecondPlane; + Handle(Geom_Surface) aSecondSurface; + AIS_KindOfSurface aSecondSurfKind; + Standard_Real aSecondOffset; + TopoDS_Face aSecondFace = TopoDS::Face (theSecondShape); + AIS::InitFaceLength (aSecondFace, aSecondPlane, + aSecondSurface, aSecondSurfKind, aSecondOffset); + if (aFirstSurfKind == AIS_KOS_Plane) { - if (deltaU > 0.0) - curve = new Geom_TrimmedCurve( VCurve, FirstU, FirstU + deltaU ); - else - curve = new Geom_TrimmedCurve( VCurve, FirstU + deltaU, FirstU ); - SensCurve = new Select3D_SensitiveCurve( own, curve ); - aSelection->Add( SensCurve ); + TopExp_Explorer anExplorer (theFirstShape, TopAbs_VERTEX); + // In case of infinite planes + if (!anExplorer.More()) + myFirstPoint = aFirstPlane.Location(); + else myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (anExplorer.Current())); + mySecondPoint = AIS::ProjectPointOnPlane (myFirstPoint, aSecondPlane); + + gp_Dir aLengthDir = aFirstPlane.Axis().Direction(); + gp_Dir aDirAttach = aFirstPlane.Position().XDirection(); + Quantity_Parameter anU, aV; + ElSLib::Parameters (aSecondPlane, mySecondPoint, anU, aV); + BRepTopAdaptor_FClass2d aClassifier (aSecondFace, Precision::Confusion()); + TopAbs_State aState = aClassifier.Perform (gp_Pnt2d (anU, aV), Standard_False); + if (aState == TopAbs_OUT || aState == TopAbs_UNKNOWN) + { + mySecondPoint = AIS::Nearest(aSecondFace, myFirstPoint); + if (myFirstPoint.Distance(mySecondPoint) > Precision::Confusion()) + { + gp_Vec aVec = gp_Vec(myFirstPoint, mySecondPoint) ^ aLengthDir; + if (aVec.SquareMagnitude() > Precision::SquareConfusion()) + aDirAttach = aVec ^ aLengthDir; + } + } + isSuccess = Standard_True; } - if (Abs( deltaV ) > Precision::PConfusion()) + else // curvilinear faces { - if (deltaV > 0.0) - curve = new Geom_TrimmedCurve( UCurve, FirstV, FirstV + deltaV ); - else - curve = new Geom_TrimmedCurve( UCurve, FirstV + deltaV, FirstV ); - SensCurve = new Select3D_SensitiveCurve( own, curve ); - aSelection->Add( SensCurve ); + AIS::ComputeLengthBetweenCurvilinearFaces (aFirstFace, aSecondFace, aFirstSurface, + aSecondSurface,Standard_True, myValue, + myGeom.myTextPosition,myFirstPoint,mySecondPoint,aDirAttach); + isSuccess = Standard_True; } + } + else if (theFirstShape.ShapeType() == TopAbs_EDGE) + { + isSuccess = initEdgeFaceLength (TopoDS::Edge (theFirstShape), + TopoDS::Face (theSecondShape), + aDirAttach); + } + if (!myIsWorkingPlaneCustom) + resetWorkingPlane(gp_Pln(myFirstPoint, aDirAttach)); } - - // Add the length's line - gp_Pnt FirstPoint, LastPoint; // ends of length's line - gp_Vec ArrowVec( DirOfArrow1 ); - ArrowVec *= ArrowLength; - if (myVal <= Precision::Confusion()) + break; + case TopAbs_EDGE: { - if (myPosition.SquareDistance( EndOfArrow1 ) > ArrowLength*ArrowLength) - { - FirstPoint = myPosition; - LastPoint = EndOfArrow1.Translated( ArrowVec ); - if (myPosition.SquareDistance( LastPoint ) < myPosition.SquareDistance( EndOfArrow1 )) - LastPoint = EndOfArrow1.Translated( -ArrowVec ); - } - else - { - FirstPoint = EndOfArrow1.Translated( ArrowVec ); - LastPoint = EndOfArrow1.Translated( -ArrowVec ); - } + if (theSecondShape.ShapeType() == TopAbs_VERTEX) + { + return initEdgeVertexLength (TopoDS::Edge(theFirstShape), + TopoDS::Vertex(theSecondShape), + aDirAttach, isInfinite); + } + else if (theSecondShape.ShapeType() == TopAbs_EDGE) + { + return initTwoEdgesLength (TopoDS::Edge(theFirstShape), + TopoDS::Edge(theSecondShape), + aDirAttach); + } } - else + break; + case TopAbs_VERTEX: { - gp_Lin LengthLine( myPosition, DirOfArrow1 ); - Standard_Real Par1 = ElCLib::Parameter( LengthLine, EndOfArrow1 ); - Standard_Real Par2 = ElCLib::Parameter( LengthLine, EndOfArrow2 ); - if ((Par1 > 0.0 && Par2 > 0.0) || (Par1 < 0.0 && Par2 < 0.0)) - { - FirstPoint = myPosition; - LastPoint = (Abs( Par1 ) > Abs( Par2 ))? EndOfArrow1 : EndOfArrow2; - LastPoint.Translate( ((Abs( Par1 ) > Abs( Par2 ))? -ArrowVec : ArrowVec) ); - } - else - { - FirstPoint = EndOfArrow1; - LastPoint = EndOfArrow2; - } + if (theSecondShape.ShapeType() == TopAbs_VERTEX) + { + myFirstPoint = BRep_Tool::Pnt (TopoDS::Vertex (theFirstShape)); + mySecondPoint = BRep_Tool::Pnt (TopoDS::Vertex (theSecondShape)); + isSuccess = Standard_True; + } + else if (theSecondShape.ShapeType() == TopAbs_EDGE) + { + return initEdgeVertexLength (TopoDS::Edge(theSecondShape), + TopoDS::Vertex(theFirstShape), + aDirAttach, isInfinite); + } } - seg = new Select3D_SensitiveSegment( own, FirstPoint, LastPoint ); - aSelection->Add( seg ); + break; + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + case TopAbs_SOLID: + case TopAbs_SHELL: + case TopAbs_WIRE: + case TopAbs_SHAPE: + // nothing to do for these kinds + break; + } + return isSuccess; } //======================================================================= -//function : ComputeEdgeVertexSelection -//purpose : +//function : initOneShapePoints +//purpose : Initialization of two points where dimension layouts +// will be attached +// Attention: 1) can be only the edge in currect implementation +// 2) No length for infinite edge //======================================================================= -void AIS_LengthDimension::ComputeEdgeVertexSelection(const Handle(SelectMgr_Selection)& aSelection) +Standard_Boolean AIS_LengthDimension::initOneShapePoints (const TopoDS_Shape& theShape) { - // ********** NB -> - // in the case of a constraint relatively to the border of a face - // only the shape of this contour is valid + if (theShape.ShapeType() == TopAbs_EDGE) + { + TopoDS_Edge anEdge = TopoDS::Edge (theShape); + BRepAdaptor_Curve aBrepCurve(anEdge); + Standard_Real aFirst = aBrepCurve.FirstParameter(), + aLast = aBrepCurve.LastParameter(); + Standard_Boolean isInfinite = (Precision::IsInfinite (aFirst) + || Precision::IsInfinite (aLast)); + if (isInfinite) + return Standard_False; + + myFirstPoint = aBrepCurve.Value (aBrepCurve.FirstParameter()); + mySecondPoint = aBrepCurve.Value (aBrepCurve.LastParameter()); + } + else // Some other kinds of shapes + return Standard_False; + return Standard_True; +} - // Create 2 owner for edition of constraints - Handle(AIS_DimensionOwner) own1 = new AIS_DimensionOwner(this,7); - Handle(AIS_DimensionOwner) own2 = new AIS_DimensionOwner(this,7); +//======================================================================= +//function : Compute +//purpose : +//======================================================================= - if (myExtShape != 0) { - if (myExtShape == 1) { - own1->SetShape(mySShape); - own2->SetShape(mySShape); - } - else { - own1->SetShape(myFShape); - own2->SetShape(myFShape); - } - } - else { - own1->SetShape(myFShape); - own2->SetShape(mySShape); +void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) +{ + // Initialization of points, if they are not set + if (!myIsInitialized) + { + if (myShapesNumber == 1) + myIsInitialized = initOneShapePoints(myFirstShape); + else if (myShapesNumber == 2) + myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape); + else + return; } + // If initialization failed + if (!myIsInitialized) + return; - gp_Lin L1 (myFAttach,myDirAttach); - gp_Lin L2 (mySAttach,myDirAttach); - gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,myPosition),L1); - gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,myPosition),L2); - gp_Lin L3; - - Standard_Real confusion(Precision::Confusion()); - - if (!Proj1.IsEqual(Proj2,confusion)) L3 = gce_MakeLin(Proj1,Proj2); - else { - // cas of zero dimension - // own1 is chosen by default - L3 = gce_MakeLin(Proj1,myDirAttach); - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle(Select3D_SensitiveBox) box = new Select3D_SensitiveBox(own1,myPosition.X(),myPosition.Y(),myPosition.Z(), - myPosition.X()+size, - myPosition.Y()+size, - myPosition.Z()+size); - aSelection->Add(box); - } + thePresentation->Clear(); + // Get length dimension aspect from AIS object drawer + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); - Standard_Real parmin,parmax,parcur; - parmin = ElCLib::Parameter(L3,Proj1); - parmax = parmin; - - parcur = ElCLib::Parameter(L3,Proj2); - parmin = Min(parmin,parcur); - parmax = Max(parmax,parcur); + //Count flyout direction + gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); + // Count a flyout direction vector. + gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; + gp_Ax3 aLocalSystem (myFirstPoint, aTargetPointsVector, aFlyoutVector); - parcur = ElCLib::Parameter(L3,myPosition); - parmin = Min(parmin,parcur); - parmax = Max(parmax,parcur); + // Create lines for layouts + gp_Lin aLine1 (myFirstPoint, aFlyoutVector); + gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - gp_Pnt PointMin = ElCLib::Value(parmin,L3); - gp_Pnt PointMax = ElCLib::Value(parmax,L3); + // Get flyout end points + gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); - Handle(Select3D_SensitiveSegment) seg; + // Add layout lines to graphic group + // Common to all type of dimension placement. + if (theMode == 0) + { + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); + aPrimSegments->AddVertex (myFirstPoint); + aPrimSegments->AddVertex (aFlyoutEnd1); - if (myFAttach.IsEqual(mySAttach,confusion) && !myPosition.IsEqual(mySAttach,confusion)) { - seg = new Select3D_SensitiveSegment(own1,mySAttach,myPosition); - aSelection->Add(seg); - } - if (!PointMin.IsEqual(PointMax,confusion)) { - gp_Pnt MiddlePoint( (PointMin.XYZ() + PointMax.XYZ())/2); - seg = new Select3D_SensitiveSegment(own1,PointMin,MiddlePoint); - aSelection->Add(seg); - seg = new Select3D_SensitiveSegment(own2,MiddlePoint, PointMax); - aSelection->Add(seg); - } + aPrimSegments->AddVertex (mySecondPoint); + aPrimSegments->AddVertex (aFlyoutEnd2); - if (!myFAttach.IsEqual(Proj1,confusion)) { - seg = new Select3D_SensitiveSegment(own1,myFAttach,Proj1); - aSelection->Add(seg); - } - if (!mySAttach.IsEqual(Proj2,confusion)) { - seg = new Select3D_SensitiveSegment(own2,mySAttach,Proj2); - aSelection->Add(seg); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); } + drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode); } - - - //======================================================================= -//function : KindOfDimension +//function : ComputeValue //purpose : //======================================================================= - AIS_KindOfDimension AIS_LengthDimension::KindOfDimension() const -{ - return AIS_KOD_LENGTH; -} -//======================================================================= -//function : IsMovable -//purpose : -//======================================================================= - Standard_Boolean AIS_LengthDimension::IsMovable() const +void AIS_LengthDimension::computeValue () { - return Standard_True; + myValue = myFirstPoint.Distance (mySecondPoint); + AIS_Dimension::computeValue (); } //======================================================================= -//function : SetFirstShape +//function : SetFlyout //purpose : //======================================================================= -void AIS_LengthDimension::SetFirstShape( const TopoDS_Shape& aFShape ) -{ - myFShape = aFShape; - if (myFShape.ShapeType() == TopAbs_FACE) - AIS::InitFaceLength( TopoDS::Face( myFShape ), myFirstPlane, myFirstBasisSurf, myFirstSurfType, myFirstOffset ); +void AIS_LengthDimension::SetFlyout (const Standard_Real theFlyout) +{ + myFlyout = theFlyout; } //======================================================================= -//function : SetSecondShape +//function : GetFlyout //purpose : //======================================================================= -void AIS_LengthDimension::SetSecondShape( const TopoDS_Shape& aSShape ) -{ - mySShape = aSShape; - if (mySShape.ShapeType() == TopAbs_FACE) - AIS::InitFaceLength( TopoDS::Face( mySShape ), mySecondPlane, mySecondBasisSurf, mySecondSurfType, mySecondOffset ); +Standard_Real AIS_LengthDimension::GetFlyout () const +{ + return myFlyout; } diff --git a/src/AIS/AIS_LengthDimension.hxx b/src/AIS/AIS_LengthDimension.hxx new file mode 100644 index 0000000000..c705da576a --- /dev/null +++ b/src/AIS/AIS_LengthDimension.hxx @@ -0,0 +1,139 @@ +// Copyright (c) 1999-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef _AIS_LengthDimension_HeaderFile +#define _AIS_LengthDimension_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class TopoDS_Face; +class TCollection_ExtendedString; +class gp_Pnt; +class TopoDS_Edge; +class TopoDS_Shape; +class Geom_Plane; +class PrsMgr_PresentationManager3d; +class Prs3d_Presentation; +class Prs3d_Projector; +class Geom_Transformation; +class SelectMgr_Selection; +class AIS_Drawer; +class Bnd_Box; +class gp_Dir; +class TopoDS_Vertex; +class Standard_Transient; +class Handle(Standard_Type); +class Handle(AIS_Relation); +class AIS_LengthDimension; + +DEFINE_STANDARD_HANDLE(AIS_LengthDimension,AIS_Dimension) + +//! A dimention to display lengths.
+//! These can be lengths along a face or edge, or
+//! between two faces or two edges. +class AIS_LengthDimension : public AIS_Dimension +{ +public: + + //! Constructor with full parameter list. + //! Construct dimension between two vertices. + //! Style of line, arrow and text can be set by default. + Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pln& theDimensionPlane, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize = 1.0); + + Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint, + const gp_Pnt& theSecondPoint, + const gp_Pln& theDimensionPlane); + + //! Constructs a length dimension between two shapes(vertices, edges, shapes) with custom working plane + Standard_EXPORT AIS_LengthDimension (const TopoDS_Shape& theFirstShape, + const TopoDS_Shape& theSecondShape, + const gp_Pln& theWorkingPlane); + + Standard_EXPORT AIS_LengthDimension (const TopoDS_Edge& theEdge, + const gp_Pln& theWorkingPlane); + + Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFirstFace, + const TopoDS_Face& theSecondFace); + + Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge); + + Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); + + Standard_EXPORT Standard_Real GetFlyout () const; + + DEFINE_STANDARD_RTTI(AIS_LengthDimension) +private: + Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge, + const TopoDS_Edge& theSecondEdge, + gp_Dir& theDirAttach); + //! Auxiliary method for + //! in case of the distance between edge and vertex + Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge, + const TopoDS_Vertex & theVertex, + gp_Dir & theDirAttach, + Standard_Boolean isInfinite); + //! Auxiliary method for + //! in case of the distance between face and edge + Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + gp_Dir& theDirAttach); + //! Initialization of two attach points in case of two owner shapes + Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape, + const TopoDS_Shape& theSecondShape); + //! Initialization of two attach points in case of one owner shape + Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape); + + //! Compute length in display units. + virtual void computeValue (); + + virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0) ; + // Fields + + //! Defines flyout lines and direction + //! Flyout direction in the working plane (stored in the base AIS_Dimension). + //! can be negative , or positive and is defined by the sign of value. + //! The direction vector is counting using the working plane. + //! value defined the size of flyout. + Standard_Real myFlyout; +}; + +#endif diff --git a/src/AIS/AIS_LengthDimension.lxx b/src/AIS/AIS_LengthDimension.lxx deleted file mode 100755 index 4c2633081a..0000000000 --- a/src/AIS/AIS_LengthDimension.lxx +++ /dev/null @@ -1,43 +0,0 @@ -// Created on: 1997-02-28 -// Created by: Jean-Pierre COMBE -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - - -//======================================================================= -//function : TypeOfDist -//purpose : -//======================================================================= -inline AIS_TypeOfDist AIS_LengthDimension::TypeOfDist() const -{ - return myTypeDist; -} - -//======================================================================= -//function : SetTypeOfDist -//purpose : -//======================================================================= - -inline void AIS_LengthDimension::SetTypeOfDist(const AIS_TypeOfDist aTypeDist) -{ - myTypeDist = aTypeDist; -} diff --git a/src/AIS/AIS_MaxRadiusDimension.cxx b/src/AIS/AIS_MaxRadiusDimension.cxx index a5cf43bdaa..bcd7790ece 100755 --- a/src/AIS/AIS_MaxRadiusDimension.cxx +++ b/src/AIS/AIS_MaxRadiusDimension.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -168,8 +168,8 @@ void AIS_MaxRadiusDimension::Compute(const Handle_Prs3d_Projector& aProjector, void AIS_MaxRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation) { - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); // size #ifdef BUC60915 @@ -226,8 +226,8 @@ void AIS_MaxRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aP void AIS_MaxRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation) { - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); // size #ifdef BUC60915 diff --git a/src/AIS/AIS_MidPointRelation.cxx b/src/AIS/AIS_MidPointRelation.cxx index ced1fa084c..a2a9ad583c 100755 --- a/src/AIS/AIS_MidPointRelation.cxx +++ b/src/AIS/AIS_MidPointRelation.cxx @@ -55,7 +55,7 @@ #include #include -#include +#include #include #include diff --git a/src/AIS/AIS_MinRadiusDimension.cxx b/src/AIS/AIS_MinRadiusDimension.cxx index 0053a0ad69..a37004aedd 100755 --- a/src/AIS/AIS_MinRadiusDimension.cxx +++ b/src/AIS/AIS_MinRadiusDimension.cxx @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -169,8 +169,8 @@ void AIS_MinRadiusDimension::Compute(const Handle_Prs3d_Projector& aProjector, void AIS_MinRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aPresentation) { - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); // size #ifdef BUC60915 @@ -228,8 +228,8 @@ void AIS_MinRadiusDimension::ComputeEllipse(const Handle(Prs3d_Presentation)& aP void AIS_MinRadiusDimension::ComputeArcOfEllipse(const Handle(Prs3d_Presentation)& aPresentation) { - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); // size #ifdef BUC60915 diff --git a/src/AIS/AIS_OffsetDimension.cxx b/src/AIS/AIS_OffsetDimension.cxx index 7e690d2bfd..5dc9f233d6 100755 --- a/src/AIS/AIS_OffsetDimension.cxx +++ b/src/AIS/AIS_OffsetDimension.cxx @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -327,11 +327,11 @@ void AIS_OffsetDimension::ComputeTwoAxesOffset(const Handle(Prs3d_Presentation)& mySAttach = P2LastProj; - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); //cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<SetLength(myArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(myArrowSize); gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf); @@ -433,11 +433,11 @@ void AIS_OffsetDimension::ComputeTwoFacesOffset(const Handle(Prs3d_Presentation) myDirAttach2.SetCoord (avec.X(),avec.Y(),avec.Z()); } - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); //cout<<"AIS_OffsetDimension::AIS_OffsetDimension " << myArrowSize << " myArrowSize"<SetLength(myArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(myArrowSize); gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf); diff --git a/src/AIS/AIS_ParallelRelation.cxx b/src/AIS/AIS_ParallelRelation.cxx index 6b3d6a6680..a2fbd5de40 100755 --- a/src/AIS/AIS_ParallelRelation.cxx +++ b/src/AIS/AIS_ParallelRelation.cxx @@ -36,7 +36,7 @@ #include #include -#include +#include #include #include @@ -379,10 +379,10 @@ void AIS_ParallelRelation::ComputeTwoEdgesParallel(const Handle(Prs3d_Presentati { myArrowSize = 0.; } - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(myArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(myArrowSize); if ( myExtShape == 1) mySymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR; diff --git a/src/AIS/AIS_RadiusDimension.cdl b/src/AIS/AIS_RadiusDimension.cdl deleted file mode 100755 index e8c8dc37db..0000000000 --- a/src/AIS/AIS_RadiusDimension.cdl +++ /dev/null @@ -1,158 +0,0 @@ --- Created on: 1996-12-03 --- Created by: Jean-Pierre COMBE/Odile Olivier --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- modified by feb-20-98 - - -class RadiusDimension from AIS inherits Relation from AIS - - ---Purpose: A framework to define display of radii. - -- These displays serve as relational references in 3D - -- presentations of surfaces, and are particularly useful - -- in viewing fillets. The display consists of arrows and - -- text giving the length of a radius. This display is - -- recalculated if the applicative owner shape changes - -- in dimension, and the text gives the modified length. - -- The algorithm analyzes a length along a face as an - -- arc. It then reconstructs the circle corresponding to - -- the arc and calculates the radius of this circle. - -uses Shape from TopoDS, - Presentation from Prs3d, - PresentationManager3d from PrsMgr, - Selection from SelectMgr, - Pnt from gp, - Lin from gp, - Circ from gp, - Projector from Prs3d, - Transformation from Geom, - ExtendedString from TCollection, - ArrowSide from DsgPrs, - KindOfDimension from AIS - -is - Create (aShape : Shape from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection) - ---Purpose: Constructs the radius display object defined by the - -- shape aShape, the dimension aVal, and the text aText. - - returns mutable RadiusDimension from AIS; - - Create (aShape : Shape from TopoDS; - aVal : Real from Standard; - aText : ExtendedString from TCollection; - aPosition : Pnt from gp; - aSymbolPrs : ArrowSide from DsgPrs; - anArrowSize : Real from Standard = 0.0) - ---Purpose: Constructs radius display object defined by the shape - -- aShape, the dimension aVal, the position aPosition, - -- the type of arrow aSymbolPrs, the arrow length - -- anArrowSize and the text aText. - returns mutable RadiusDimension from AIS; - - SetFirstShape( me: mutable; aFShape : Shape from TopoDS ) - is redefined static; - - KindOfDimension(me) - ---Purpose: Indicates that the dimension selected is a radius. - ---C++: inline - returns KindOfDimension from AIS - is redefined; - - IsMovable(me) returns Boolean from Standard - ---C++: inline - ---Purpose: Returns true if the radius selected is movable. - is redefined; - - DrawFromCenter(me) returns Boolean from Standard - ---Purpose: - -- Draws an arrowhead pointing towards the center of - -- the shape aShape defined at construction time if - -- false, and away from the center if true. - ---C++: inline - is static; - - SetDrawFromCenter(me: mutable; - drawfromcenter : Boolean from Standard) - ---C++: inline - ---Purpose: - -- Sets the Boolean drawfromcenter to true or false. - -- If drawfromcenter is false, the arrowhead will point - -- towards the center of the shape aShape defined at - -- construction time. - is static; - - -- Methods from PresentableObject - - Compute(me : mutable; - aPresentationManager: PresentationManager3d from PrsMgr; - aPresentation : mutable Presentation from Prs3d; - aMode : Integer from Standard= 0) - is redefined private; - - Compute(me:mutable; - aProjector: Projector from Prs3d; - aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me : mutable; - aProjector : Projector from Prs3d; - aTrsf : Transformation from Geom; - aPresentation : mutable Presentation from Prs3d) - is redefined; - ---Purpose: computes the presentation according to a point of view - -- given by . - -- To be Used when the associated degenerated Presentations - -- have been transformed by which is not a Pure - -- Translation. The HLR Prs can't be deducted automatically - -- WARNING : must be applied - -- to the object to display before computation !!! - --- Methods from SelectableObject - - ComputeSelection(me : mutable; - aSelection : mutable Selection from SelectMgr; - aMode : Integer from Standard) - is redefined private; - - --- --- Computation private methods --- - - ComputeRadius( me: mutable; aPresentation : mutable Presentation from Prs3d ) - is private; - - InitFirstShape( me: mutable) - is static private; - -fields - - myCircle : Circ from gp; - myFirstPar : Real from Standard; - myLastPar : Real from Standard; - myCenter : Pnt from gp; - myEndOfArrow : Pnt from gp; - myFirstLine : Lin from gp; - myLastLine : Lin from gp; - mydrawFromCenter : Boolean from Standard; - -end RadiusDimension; diff --git a/src/AIS/AIS_RadiusDimension.cxx b/src/AIS/AIS_RadiusDimension.cxx index afbb4d836a..058547e430 100755 --- a/src/AIS/AIS_RadiusDimension.cxx +++ b/src/AIS/AIS_RadiusDimension.cxx @@ -18,20 +18,23 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -// modified 20-feb-98 -// myFShape could be a wire. - -#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size -// if any in all dimensions. - #include -#include +#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include #include #include #include @@ -40,381 +43,222 @@ #include #include #include - #include #include #include -#include -#include -#include -#include - -#include -#include - +#include +#include #include - +#include +#include +#include +#include +#include +#include +#include #include #include #include #include #include #include +#include #include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - - -#include -#include -#include -#include - - - -//====================================================================== -//function : CircleFromPlanarFace -//purpose : if possible gets circle from planar face -//======================================================================= -static Standard_Boolean CircleFromPlanarFace (const TopoDS_Shape& aFace, - Handle(Geom_Curve)& aCurve, - gp_Pnt & ptfirst, - gp_Pnt & ptend) -{ - TopExp_Explorer ExploEd (aFace, TopAbs_EDGE); - for ( ; ExploEd.More(); ExploEd.Next()) - { - TopoDS_Edge curedge = TopoDS::Edge (ExploEd.Current()); - if (AIS::ComputeGeometry (curedge, aCurve, ptfirst, ptend)) - if (aCurve->IsInstance (STANDARD_TYPE(Geom_Circle)) && - !Handle(Geom_Circle)::DownCast(aCurve).IsNull()) - return Standard_True; - } - return Standard_False; -} +IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension) +IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension) //======================================================================= //function : Constructor //purpose : //======================================================================= -AIS_RadiusDimension::AIS_RadiusDimension(const TopoDS_Shape& aShape, - const Standard_Real aVal, - const TCollection_ExtendedString& aText) -:mydrawFromCenter(Standard_True) + +AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle) +: AIS_Dimension(), + myFlyout (0.0), + myCircle (theCircle) { - myFShape = aShape; - myVal = aVal; - myText = aText; - mySymbolPrs = DsgPrs_AS_FIRSTPT_LASTAR; - myAutomaticPosition = Standard_True; - - myArrowSize = myVal / 100.; - InitFirstShape(); + myFirstPoint = ElCLib::Value(0, myCircle); + mySecondPoint = theCircle.Location(); + myIsInitialized = Standard_True; + SetSpecialSymbol ('R'); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetKindOfDimension(AIS_KOD_RADIUS); +} + +AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, + const gp_Pnt& theAttachPoint) +: AIS_Dimension(), + myFlyout (0.0), + myCircle (theCircle) +{ + myFirstPoint = theAttachPoint; + mySecondPoint = theCircle.Location(); + myIsInitialized = Standard_True; + SetSpecialSymbol ('R'); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetKindOfDimension (AIS_KOD_RADIUS); } //======================================================================= //function : Constructor -//purpose :(avec position et texte) +//purpose : //======================================================================= -AIS_RadiusDimension::AIS_RadiusDimension( const TopoDS_Shape& aShape, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Pnt& aPosition, - const DsgPrs_ArrowSide aSymbolPrs, - const Standard_Real anArrowSize ) -:mydrawFromCenter(Standard_True) + +AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape) +: AIS_Dimension (), + myFlyout (0.0) { - myFShape = aShape; - myVal = aVal; - myText = aText; - myPosition = aPosition; - mySymbolPrs = aSymbolPrs; -#ifdef BUC60915 - SetArrowSize( anArrowSize ); -#else - myArrowSize = anArrowSize; -#endif - myAutomaticPosition = Standard_False; - InitFirstShape(); + myFirstShape = theShape; + myIsInitialized = Standard_False; + SetSpecialSymbol ('R'); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetKindOfDimension (AIS_KOD_RADIUS); } //======================================================================= -//function : InitFirstShape +//function : Constructor //purpose : //======================================================================= -void AIS_RadiusDimension::InitFirstShape() + +AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize/* = 1.0*/) + +: AIS_Dimension (theDimensionAspect,theExtensionSize), + myFlyout (0.0), + myCircle (theCircle) { - if (myFShape.ShapeType() == TopAbs_FACE) - { - BRepAdaptor_Surface surfAlgo( TopoDS::Face( myFShape ) ); - Standard_Real uFirst, uLast, vFirst, vLast; - uFirst = surfAlgo.FirstUParameter(); - uLast = surfAlgo.LastUParameter(); - vFirst = surfAlgo.FirstVParameter(); - vLast = surfAlgo.LastVParameter(); - Standard_Real uMoy = (uFirst + uLast)/2; - Standard_Real vMoy = (vFirst + vLast)/2; - Handle( Geom_Surface ) surf = surfAlgo.Surface().Surface(); - surf = Handle( Geom_Surface )::DownCast( surf->Transformed( surfAlgo.Trsf() ) ); - Handle( Geom_Curve ) aCurve; - - if (surf->DynamicType() == STANDARD_TYPE(Geom_ToroidalSurface)) - { - aCurve = surf->UIso( uMoy ); - uFirst = vFirst; - uLast = vLast; - } - else if (surf->DynamicType() == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) - { - Handle( Adaptor3d_HCurve ) BasisCurve = surfAlgo.BasisCurve(); - if ( BasisCurve->GetType() == GeomAbs_Circle ) - aCurve = surf->VIso( vMoy ); - else return; - } - else if (surf->DynamicType() == STANDARD_TYPE(Geom_Plane)) - { - gp_Pnt FirstPnt, LastPnt; - if (CircleFromPlanarFace (TopoDS::Face(myFShape), aCurve, FirstPnt, LastPnt)) -// if (CircleFromPlanarFace (myFShape, aCurve, FirstPnt, LastPnt)) - { - uFirst = ElCLib::Parameter ((Handle(Geom_Circle)::DownCast( aCurve ))->Circ(), FirstPnt); - uLast = ElCLib::Parameter ((Handle(Geom_Circle)::DownCast( aCurve ))->Circ(), LastPnt); - } - else return; - } - else - aCurve = surf->VIso( vMoy ); - - if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) - myCircle = (Handle( Geom_Circle )::DownCast( aCurve ))->Circ(); - else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_TrimmedCurve)) { - Handle(Geom_TrimmedCurve) tCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve); - aCurve = tCurve->BasisCurve(); - uFirst = tCurve->FirstParameter(); - uLast = tCurve->LastParameter(); - if (aCurve->DynamicType() == STANDARD_TYPE(Geom_Circle)) - myCircle = Handle(Geom_Circle)::DownCast(aCurve)->Circ();//gp_Circ - else return; - } - else if (aCurve->DynamicType() == STANDARD_TYPE(Geom_BSplineCurve)) { - gp_Pnt P1,P2,P3; - aCurve->D0(uFirst,P1); - aCurve->D0((uFirst+uLast)/2,P2); - aCurve->D0(uLast,P3); - gce_MakeCirc MakeCirc = gce_MakeCirc(P1,P2,P3); - myCircle = MakeCirc.Value(); - uFirst = ElCLib::Parameter(myCircle,P1); - uLast = ElCLib::Parameter(myCircle,P2); - } - - myFirstPar = uFirst; - myLastPar = uLast; - } // TopAbs_FACE - - else // it is edge or a wire - { - TopoDS_Edge anEdge; - if (myFShape.ShapeType() == TopAbs_WIRE) { - TopExp_Explorer exp (myFShape,TopAbs_EDGE); - if (exp.More()) anEdge = TopoDS::Edge (exp.Current()); - } - else { - if ( myFShape.ShapeType() == TopAbs_EDGE) { - anEdge = TopoDS::Edge (myFShape); - BRepAdaptor_Curve AdaptedCurve (anEdge); - if (!AdaptedCurve.GetType() == GeomAbs_Circle) return; - - myCircle = AdaptedCurve.Circle(); - myFirstPar = AdaptedCurve.FirstParameter(); - myLastPar = AdaptedCurve.LastParameter(); - } -#ifdef DEB - else { - cout << "AIS_RadiusDimension::InitFirstShape ==> myFShape.ShapeType() == " << myFShape.ShapeType() << endl; - } -#endif - } - } - - myCenter = myCircle.Location(); - myCircle.SetRadius(myVal); - while (myFirstPar > 2*M_PI) myFirstPar -= 2*M_PI; - while (myFirstPar < 0.0 ) myFirstPar += 2*M_PI; - while (myLastPar > 2*M_PI) myLastPar -= 2*M_PI; - while (myLastPar < 0.0 ) myLastPar += 2*M_PI; - myPlane = new Geom_Plane(gp_Pln(gp_Ax3(myCircle.Position()))); - myFirstLine = gce_MakeLin( myCenter, ElCLib::Value( myFirstPar, myCircle ) ); - myLastLine = gce_MakeLin( myCenter, ElCLib::Value( myLastPar, myCircle ) ); + myFirstPoint = ElCLib::Value(0, myCircle); + mySecondPoint = theCircle.Location(); + SetSpecialSymbol ('R'); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetKindOfDimension (AIS_KOD_RADIUS); } //======================================================================= -//function : SetFirstShape +//function : Constructor //purpose : //======================================================================= -void AIS_RadiusDimension::SetFirstShape( const TopoDS_Shape& aFShape ) + +AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, + const gp_Pnt& theAttachPoint, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize/* = 1.0*/) +: AIS_Dimension (theDimensionAspect,theExtensionSize), + myFlyout (0.0), + myCircle (theCircle) { - myFShape = aFShape; - InitFirstShape(); + myFirstPoint = theAttachPoint; + mySecondPoint = theCircle.Location(); + SetSpecialSymbol ('R'); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetKindOfDimension (AIS_KOD_RADIUS); } //======================================================================= //function : Compute //purpose : //======================================================================= -void AIS_RadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, - const Handle(Prs3d_Presentation)& aPresentation, - const Standard_Integer /*aMode*/) -{ - aPresentation->Clear(); - ComputeRadius( aPresentation ); +void AIS_RadiusDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) +{ + thePresentation->Clear(); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + + if (!myIsInitialized) + { + gp_Pnt aLastPoint; + if (!initCircularDimension (myFirstShape, myCircle, + myFirstPoint, aLastPoint)) + return; + else + { + mySecondPoint = myCircle.Location(); + myIsInitialized = Standard_True; + } + } + if (!myIsWorkingPlaneCustom) + countDefaultPlane(); + + //Count flyout direction + gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); + // Count a flyout direction vector. + gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; + gp_Ax3 aLocalSystem (myFirstPoint, aTargetPointsVector, aFlyoutVector); + + // Create lines for layouts + gp_Lin aLine1 (myFirstPoint, aFlyoutVector); + gp_Lin aLine2 (mySecondPoint, aFlyoutVector); + + // Get flyout end points + gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); + + // Add layout lines to graphic group + // Common to all type of dimension placement. + if (theMode == 0) + { + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); + aPrimSegments->AddVertex (myFirstPoint); + aPrimSegments->AddVertex (aFlyoutEnd1); + + aPrimSegments->AddVertex (mySecondPoint); + aPrimSegments->AddVertex (aFlyoutEnd2); + + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + } + + drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode, Standard_True); } //======================================================================= -//function : Compute -//purpose : to avoid warning +//function : computeValue +//purpose : //======================================================================= -void AIS_RadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, - const Handle(Prs3d_Presentation)& aPresentation) + +void AIS_RadiusDimension::computeValue () { -// Standard_NotImplemented::Raise("AIS_RadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector,const Handle(Prs3d_Presentation)& aPresentation)"); - PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; + myValue = myFirstPoint.Distance (mySecondPoint); + AIS_Dimension::computeValue (); } //======================================================================= -//function : Compute +//function : countDefaultPlane //purpose : //======================================================================= -void AIS_RadiusDimension::Compute(const Handle_Prs3d_Projector& aProjector, - const Handle_Geom_Transformation& aTransformation, - const Handle_Prs3d_Presentation& aPresentation) +void AIS_RadiusDimension::countDefaultPlane () { -// Standard_NotImplemented::Raise("AIS_RadiusDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; + // Compute normal of the default plane. + gp_Vec aVec1(mySecondPoint, myFirstPoint), + aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle)); + myDefaultPlane = gp_Pln(myCircle.Location(), aVec1^aVec2); + // Set computed value to + ResetWorkingPlane (); } //======================================================================= -//function : ComputeSelection +//function : SetFlyout //purpose : //======================================================================= -void AIS_RadiusDimension::ComputeSelection( const Handle(SelectMgr_Selection)& aSelection, - const Standard_Integer ) + +void AIS_RadiusDimension::SetFlyout (const Standard_Real theFlyout) { - gp_Pnt LineOrigin, LineEnd; - DsgPrs::ComputeRadiusLine( myCenter, myEndOfArrow, myPosition, mydrawFromCenter, - LineOrigin,LineEnd); - Handle(AIS_DimensionOwner) own = new AIS_DimensionOwner(this,7); - own->SetShape(myFShape); - Handle( Select3D_SensitiveSegment ) seg = new Select3D_SensitiveSegment( own, LineOrigin, LineEnd ); - aSelection->Add( seg ); - - // Text - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); - Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own, - myPosition.X(), - myPosition.Y(), - myPosition.Z(), - myPosition.X() + size, - myPosition.Y() + size, - myPosition.Z() + size ); - aSelection->Add(box); + myFlyout = theFlyout; } //======================================================================= -//function : ComputeRadius +//function : GetFlyout //purpose : //======================================================================= -void AIS_RadiusDimension::ComputeRadius( const Handle( Prs3d_Presentation )& aPresentation ) +Standard_Real AIS_RadiusDimension::GetFlyout () const { - if (myAutomaticPosition) - { - InitFirstShape(); - myEndOfArrow = ElCLib::Value( (myFirstPar + myLastPar)/2, myCircle ); - if(mydrawFromCenter) { - myPosition = myCenter; - } - else - { - gp_Vec v1(myCenter, myEndOfArrow); - myPosition = myCenter.Translated(v1 * 1.2); - } - myAutomaticPosition = Standard_True; - - if (myIsSetBndBox) - myPosition = AIS::TranslatePointToBound(myPosition, gce_MakeDir( myCenter, myEndOfArrow ), - myBndBox ); - } - else - { - //!Automaticposition - myPosition = AIS::ProjectPointOnPlane( myPosition, myPlane->Pln() ); - Standard_Real PosPar = ElCLib::Parameter( myCircle, myPosition ); - if (!AIS::InDomain(myFirstPar, myLastPar, PosPar)) - { // not in domain - Standard_Real otherpar = PosPar + M_PI; - if (otherpar > 2*M_PI) otherpar -= 2*M_PI; - if (AIS::InDomain(myFirstPar, myLastPar, otherpar)){ - PosPar = otherpar;// parameter on circle - myEndOfArrow = ElCLib::Value( PosPar, myCircle ); - } - else { - Standard_Real Teta1 = Abs( PosPar - myFirstPar ), Teta2 = Abs( PosPar - myLastPar ); - if (Teta1 > M_PI) - Teta1 = 2.0*M_PI - Teta1; - if (Teta2 > M_PI) - Teta2 = 2.0*M_PI - Teta2; - if (Teta1 < Teta2) - { - if(myFirstLine.Contains(myPosition,Precision::Confusion())) - PosPar = myFirstPar; - else - PosPar = myLastPar; - } - else - { - if(myLastLine.Contains(myPosition,Precision::Confusion())) - PosPar = myLastPar; - else - PosPar = myFirstPar; - } - myEndOfArrow = ElCLib::Value( PosPar, myCircle ); - gp_Lin RadiusLine = gce_MakeLin( myCenter, myEndOfArrow ); - // project on radius line - myPosition = ElCLib::Value( ElCLib::Parameter( RadiusLine, myPosition ), RadiusLine ); - } - } - else - myEndOfArrow = ElCLib::Value( PosPar, myCircle ); - } - - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); - // size -#ifdef BUC60915 - if( !myArrowSizeIsDefined ) { - myArrowSize = Min(myArrowSize,myVal/5.); - } - arr->SetLength(myArrowSize); -#else - if (myVal/5. > myArrowSize) - arr->SetLength(myArrowSize); - else - arr->SetLength(myVal/5.); -#endif - - DsgPrs_RadiusPresentation::Add( aPresentation, myDrawer, myText, myPosition, - myCenter, myEndOfArrow, mySymbolPrs, mydrawFromCenter ); - } + return myFlyout; +} diff --git a/src/AIS/AIS_RadiusDimension.hxx b/src/AIS/AIS_RadiusDimension.hxx new file mode 100644 index 0000000000..8ce04ef3fe --- /dev/null +++ b/src/AIS/AIS_RadiusDimension.hxx @@ -0,0 +1,91 @@ +// Copyright (c) 1995-1999 Matra Datavision +// Copyright (c) 1999-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +//! A framework to define display of radii.
+//! These displays serve as relational references in 3D
+//! presentations of surfaces, and are particularly useful
+//! in viewing fillets. The display consists of arrows and
+//! text giving the length of a radius. This display is
+//! recalculated if the applicative owner shape changes
+//! in dimension, and the text gives the modified length.
+//! The algorithm analyzes a length along a face as an
+//! arc. It then reconstructs the circle corresponding to
+//! the arc and calculates the radius of this circle.
+ +#ifndef _AIS_RadiusDimension_HeaderFile +#define _AIS_RadiusDimension_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension) + +class AIS_RadiusDimension : public AIS_Dimension +{ +public: + Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle); + + Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, + const gp_Pnt& theAttachPoint); + + Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize = 1.0); + + Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, + const gp_Pnt& theAttachPoint, + const Handle(Prs3d_DimensionAspect)& theDimensionAspect, + const Standard_Real theExtensionSize = 1.0); + //! Constructs the radius display object defined by the
+ //! shape aShape, the dimension aVal, and the text aText. + Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape); + + Standard_EXPORT void SetFlyout (const Standard_Real theFlyoutSize); + + Standard_EXPORT Standard_Real GetFlyout () const; + + DEFINE_STANDARD_RTTI(AIS_RadiusDimension) + +protected: + //! Computes dimension value in display units + Standard_EXPORT virtual void computeValue (); + //! Fills default plane object if it is possible to count plane automatically. + Standard_EXPORT virtual void countDefaultPlane (); + +private: + virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0); + +// Fields + + //! Defines flyout lines and direction + //! Flyout direction in the working plane (stored in the base AIS_Dimension). + //! can be negative , or positive and is defined by the sign of value. + //! The direction vector is counting using the working plane. + //! value defined the size of flyout. + Standard_Real myFlyout; + gp_Circ myCircle; +}; +#endif diff --git a/src/AIS/AIS_RadiusDimension.lxx b/src/AIS/AIS_RadiusDimension.lxx deleted file mode 100755 index f4b2a8c0ee..0000000000 --- a/src/AIS/AIS_RadiusDimension.lxx +++ /dev/null @@ -1,52 +0,0 @@ -// Created on: 1997-02-28 -// Created by: Jean-Pierre COMBE -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -//======================================================================= -//function : KindOfDimension -//purpose : -//======================================================================= -inline AIS_KindOfDimension AIS_RadiusDimension::KindOfDimension() const -{ - return AIS_KOD_RADIUS; -} -//======================================================================= -//function : IsMovable -//purpose : -//======================================================================= -inline Standard_Boolean AIS_RadiusDimension::IsMovable() const -{ - return Standard_True; -} - -//======================================================================= -//function : DrawFromCenter -//purpose : -//======================================================================= - -inline Standard_Boolean AIS_RadiusDimension::DrawFromCenter() const -{ - return mydrawFromCenter; -} - -inline void AIS_RadiusDimension::SetDrawFromCenter(const Standard_Boolean drawfromcenter) -{ - mydrawFromCenter = drawfromcenter; -} diff --git a/src/AIS/AIS_Relation.cdl b/src/AIS/AIS_Relation.cdl index 44defebe4f..d6e8edbc9e 100755 --- a/src/AIS/AIS_Relation.cdl +++ b/src/AIS/AIS_Relation.cdl @@ -48,7 +48,7 @@ uses Presentation from Prs3d, Curve from Geom, NameOfColor from Quantity, - Color from Quantity, + Color from Quantity, TypeOfLine from Aspect, TypeOfMarker from Aspect, KindOfInteractive from AIS, diff --git a/src/AIS/AIS_Relation.cxx b/src/AIS/AIS_Relation.cxx index 7427f9ff18..88ff105cc4 100755 --- a/src/AIS/AIS_Relation.cxx +++ b/src/AIS/AIS_Relation.cxx @@ -38,9 +38,8 @@ #include #include -#include +#include #include -#include #include #include @@ -237,22 +236,17 @@ void AIS_Relation::SetColor(const Quantity_Color &aCol) if (!myDrawer->HasLineAspect()) { myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); } - if (!myDrawer->HasLengthAspect()) { - myDrawer->SetLengthAspect(new Prs3d_LengthAspect); - } - if (!myDrawer->HasAngleAspect()) { - myDrawer->SetAngleAspect(new Prs3d_AngleAspect); + if (!myDrawer->HasDimensionAspect()) { + myDrawer->SetDimensionAspect(new Prs3d_DimensionAspect); } + myDrawer->LineAspect()->SetColor(aCol); - const Handle(Prs3d_LengthAspect)& LENGTH = myDrawer->LengthAspect(); - const Handle(Prs3d_AngleAspect)& ANGLE = myDrawer->AngleAspect(); + const Handle(Prs3d_DimensionAspect)& DIMENSION = myDrawer->DimensionAspect(); const Handle(Prs3d_LineAspect)& LINE = myDrawer->LineAspect(); const Handle(Prs3d_TextAspect)& TEXT = myDrawer->TextAspect(); - LENGTH->SetLineAspect(LINE); - LENGTH->SetTextAspect(TEXT); - ANGLE->SetLineAspect(LINE); - ANGLE->SetTextAspect(TEXT); + DIMENSION->SetLineAspect(LINE); + DIMENSION->SetTextAspect(TEXT); } //======================================================================= @@ -267,8 +261,7 @@ void AIS_Relation::UnsetColor() Quantity_Color CC; AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); LA->SetColor(CC); - myDrawer->AngleAspect()->SetLineAspect(LA); - myDrawer->LengthAspect()->SetLineAspect(LA); + myDrawer->DimensionAspect()->SetLineAspect(LA); myDrawer->SetTextAspect(myDrawer->Link()->TextAspect()); } diff --git a/src/AIS/AIS_SymmetricRelation.cxx b/src/AIS/AIS_SymmetricRelation.cxx index 1d6620a29d..bf46555399 100755 --- a/src/AIS/AIS_SymmetricRelation.cxx +++ b/src/AIS/AIS_SymmetricRelation.cxx @@ -54,7 +54,7 @@ #include #include #include -#include +#include #include @@ -541,10 +541,10 @@ void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presenta gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis); if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion()) myArrowSize = 0.; - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(myArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(myArrowSize); if(cu1.GetType() == GeomAbs_Line) DsgPrs_SymmetricPresentation::Add(aprs, @@ -632,10 +632,10 @@ void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Prese myPosition = curpos; } if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.; - Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect(); - Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect(); + Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); + Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); arr->SetLength(myArrowSize); - arr = la->Arrow2Aspect(); + arr = la->ArrowAspect(); arr->SetLength(myArrowSize); DsgPrs_SymmetricPresentation::Add(aprs, myDrawer, diff --git a/src/AIS/FILES b/src/AIS/FILES index 34c753a71e..44b3f064ad 100755 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -7,3 +7,13 @@ AIS_NListIteratorOfListTransient.hxx AIS_NDataMapOfTransientIteratorOfListTransient.hxx AIS_Triangulation.cdl AIS_Triangulation.cxx +AIS_Dimension.hxx +AIS_Dimension.cxx +AIS_LengthDimension.hxx +AIS_LengthDimension.cxx +AIS_AngleDimension.hxx +AIS_AngleDimension.cxx +AIS_DiameterDimension.hxx +AIS_DiameterDimension.cxx +AIS_RadiusDimension.hxx +AIS_RadiusDimension.cxx diff --git a/src/Aspect/Aspect.cdl b/src/Aspect/Aspect.cdl index 52566c6fb2..6d4927dad6 100755 --- a/src/Aspect/Aspect.cdl +++ b/src/Aspect/Aspect.cdl @@ -538,7 +538,8 @@ is enumeration TypeOfDisplayText is TODT_NORMAL, TODT_SUBTITLE, TODT_DEKALE, - TODT_BLEND + TODT_BLEND, + TODT_DIMENSION end TypeOfDisplayText; ---Purpose: Define the display type of the text. -- @@ -546,6 +547,7 @@ is -- TODT_SUBTITLE There is a subtitle under the text. -- TODT_DEKALE The text is displayed with a 3D style. -- TODT_BLEND The text is displayed in XOR. + -- TODT_DIMENSION Dimension line under text will be invisible. ---Category: Enumerations enumeration TypeOfMarker is TOM_POINT, diff --git a/src/DsgPrs/DsgPrs.cdl b/src/DsgPrs/DsgPrs.cdl index 60b9e09a1d..3d700f683d 100755 --- a/src/DsgPrs/DsgPrs.cdl +++ b/src/DsgPrs/DsgPrs.cdl @@ -86,15 +86,7 @@ AS_FIRSTAR_LASTPT,AS_FIRSTPT_LASTAR; imported DatumPrs; ComputeSymbol(aPresentation: Presentation from Prs3d; - anAspect: AngleAspect from Prs3d; - pt1,pt2:Pnt from gp; - dir1,dir2: Dir from gp; - ArrowSide: ArrowSide from DsgPrs); - ---Purpose: draws symbols ((one or two) arrows,(one or two)points - -- at thebeginning and at the end of the dimension - - ComputeSymbol(aPresentation: Presentation from Prs3d; - anAspect: LengthAspect from Prs3d; + anAspect: DimensionAspect from Prs3d; pt1,pt2:Pnt from gp; dir1,dir2: Dir from gp; ArrowSide: ArrowSide from DsgPrs; diff --git a/src/DsgPrs/DsgPrs.cxx b/src/DsgPrs/DsgPrs.cxx index d830f34d4a..2f5c00fd62 100755 --- a/src/DsgPrs/DsgPrs.cxx +++ b/src/DsgPrs/DsgPrs.cxx @@ -47,14 +47,14 @@ #include - void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_AngleAspect)& LA, + const Handle(Prs3d_DimensionAspect)& LA, const gp_Pnt& pt1, const gp_Pnt& pt2, const gp_Dir& dir1, const gp_Dir& dir2, - const DsgPrs_ArrowSide ArrowSide) + const DsgPrs_ArrowSide ArrowSide, + const Standard_Boolean drawFromCenter) { Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -64,6 +64,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); switch(ArrowSide) { case DsgPrs_AS_NONE: @@ -109,127 +110,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, case DsgPrs_AS_FIRSTPT: { - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); - break; - } - - case DsgPrs_AS_LASTPT: - { - // On dessine un rond - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); - break; - } - - case DsgPrs_AS_BOTHPT: - { - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints1->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1); - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2); - break; - } - - case DsgPrs_AS_FIRSTAR_LASTPT: - { - // an Arrow - Prs3d_Arrow::Draw(aPresentation, - pt1, - dir1, - LA->ArrowAspect()->Angle(), - LA->ArrowAspect()->Length()); - // a Round - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); - break; - } - - case DsgPrs_AS_FIRSTPT_LASTAR: - { - // a Round - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); - - // an Arrow - Prs3d_Arrow::Draw(aPresentation, - pt2, - dir2, - LA->ArrowAspect()->Angle(), - LA->ArrowAspect()->Length()); - break; - } - } -} - -void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_LengthAspect)& LA, - const gp_Pnt& pt1, - const gp_Pnt& pt2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const DsgPrs_ArrowSide ArrowSide, - const Standard_Boolean drawFromCenter) -{ - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Standard_Real aWidth; - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - LA->LineAspect()->Aspect()->Values(aColor, aType, aWidth); - Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); - - switch(ArrowSide) { - case DsgPrs_AS_NONE: - { - break; - } - case DsgPrs_AS_FIRSTAR: - { - - Prs3d_Arrow::Draw(aPresentation, - pt1, - dir1, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - break; - } - case DsgPrs_AS_LASTAR: - { - - Prs3d_Arrow::Draw(aPresentation, - pt2, - dir2, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - break; - } - - case DsgPrs_AS_BOTHAR: - { - Prs3d_Arrow::Draw(aPresentation, - pt1, - dir1, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - Prs3d_Arrow::Draw(aPresentation, - pt2, - dir2, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - - break; - } - - case DsgPrs_AS_FIRSTPT: - { - if (drawFromCenter) + if(drawFromCenter) { Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); @@ -249,26 +130,29 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, case DsgPrs_AS_BOTHPT: { - if (drawFromCenter) + if(drawFromCenter) { Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1); anArrayOfPoints1->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1); } - Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1); - anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2); + if(drawFromCenter) + { + Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1); + anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2); + } break; } case DsgPrs_AS_FIRSTAR_LASTPT: { // an Arrow - Prs3d_Arrow::Draw (aPresentation, - pt1, - dir1, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation, + pt1, + dir1, + LA->ArrowAspect()->Angle(), + LA->ArrowAspect()->Length()); // a Round Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z()); @@ -279,18 +163,18 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation, case DsgPrs_AS_FIRSTPT_LASTAR: { // a Round - if (drawFromCenter) + if(drawFromCenter) { Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z()); Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); } // an Arrow - Prs3d_Arrow::Draw (aPresentation, - pt2, - dir2, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation, + pt2, + dir2, + LA->ArrowAspect()->Angle(), + LA->ArrowAspect()->Length()); break; } } diff --git a/src/DsgPrs/DsgPrs_AnglePresentation.cxx b/src/DsgPrs/DsgPrs_AnglePresentation.cxx index 3baab53217..2629488819 100755 --- a/src/DsgPrs/DsgPrs_AnglePresentation.cxx +++ b/src/DsgPrs/DsgPrs_AnglePresentation.cxx @@ -24,11 +24,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include #include @@ -87,14 +86,13 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Circ& VmaxCircle, const Standard_Real aArrowSize) { - Handle(Prs3d_AngleAspect) anAngleAspect = aDrawer->AngleAspect(); - Handle(Prs3d_LengthAspect) aLengthAspect = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) aDimensionAspect = aDrawer->DimensionAspect(); TCollection_ExtendedString txt(aText); const Standard_Real myArrowSize = ( aArrowSize == 0.0 )? (0.1 * aCircle.Radius()) : aArrowSize; - anAngleAspect->ArrowAspect()->SetLength(myArrowSize); + aDimensionAspect->ArrowAspect()->SetLength(myArrowSize); aDrawer->ArrowAspect()->SetLength(myArrowSize); Standard_Boolean IsConeTrimmed = Standard_False; @@ -175,15 +173,15 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat aPrims->AddVertex(ElCLib::Value(param + angle/11 * i, aCircle2)); Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, AttachmentPnt, + DsgPrs::ComputeSymbol(aPresentation, aDimensionAspect, AttachmentPnt, AttachmentPnt, aDir, aDir, DsgPrs_AS_LASTAR); - DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, OppositePnt, + DsgPrs::ComputeSymbol(aPresentation, aDimensionAspect, OppositePnt, OppositePnt, aDir2, aDir2, DsgPrs_AS_LASTAR); param = ElCLib::Parameter(aCircle2, tmpPnt); tmpPnt = ElCLib::Value(param, aCircle2); tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -2)); - Prs3d_Text::Draw(aPresentation, aLengthAspect->TextAspect(), txt, tmpPnt); //add the TCollection_ExtendedString + Prs3d_Text::Draw(aPresentation, aDimensionAspect->TextAspect(), txt, tmpPnt); //add the TCollection_ExtendedString angle = 2. * M_PI - param ; if( param > OppParam ) @@ -241,7 +239,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat char valcar[80]; sprintf(valcar,"%5.2f",theval); - Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Ax2 ax(CenterPoint,axisdir,dir1); @@ -353,7 +351,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat char valcar[80]; sprintf(valcar,"%5.2f",theval); - Handle( Prs3d_AngleAspect ) LA = aDrawer->AngleAspect(); + Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); gp_Circ AngleCirc, AttachCirc; @@ -467,7 +465,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat char valcar[80]; sprintf(valcar,"%5.2f",theval); - Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Dir Norm; @@ -586,7 +584,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat char valcar[80]; sprintf(valcar,"%5.2f",theval); - Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Dir Norm = dir1.Crossed(dir2); @@ -702,7 +700,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat TCollection_AsciiString valas(valcar); TCollection_ExtendedString aText(valas); - Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Dir Norm = dir1.Crossed(dir2); @@ -801,7 +799,7 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Ax1& theAxe, const DsgPrs_ArrowSide ArrowSide) { - Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Dir dir1(gp_Vec(CenterPoint, AttachmentPoint1)); diff --git a/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx b/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx index d8a157d344..55d634b770 100755 --- a/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx +++ b/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ void DsgPrs_Chamf2dPresentation::Add( const gp_Pnt& aPntEnd, const TCollection_ExtendedString& aText) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -52,7 +52,7 @@ void DsgPrs_Chamf2dPresentation::Add( Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ()); - Prs3d_Arrow::Draw(aPresentation,aPntAttach,ArrowDir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,aPntAttach,ArrowDir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntEnd); } @@ -71,7 +71,7 @@ void DsgPrs_Chamf2dPresentation::Add( const TCollection_ExtendedString& aText, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); diff --git a/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx b/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx index 5f34a563e1..65e7cb6797 100755 --- a/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx +++ b/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -43,7 +43,7 @@ void DsgPrs_ConcentricPresentation::Add( const gp_Dir& aNorm, const gp_Pnt& aPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); //Creation et discretisation du plus gros cercle gp_Circ Circ(gp_Ax2(aCenter,aNorm), aRadius); diff --git a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx index 99dab747cf..25110369cb 100755 --- a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx +++ b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -60,7 +60,7 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen const DsgPrs_ArrowSide ArrowPrs, const Standard_Boolean IsDiamSymbol ) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real parat = ElCLib::Parameter(aCircle, AttachmentPoint); @@ -156,7 +156,7 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen lpara -= 2.*M_PI; } - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real parEndOfArrow = ElCLib::Parameter(aCircle,AttachmentPoint); gp_Pnt EndOfArrow; diff --git a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx index 9c70bedfca..2273a6bdfa 100755 --- a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,7 +66,7 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); const Standard_Real dist = aCenter.Distance( aPosition ); @@ -108,7 +108,7 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); if(!IsInDomain) @@ -150,7 +150,7 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); if(!IsInDomain) diff --git a/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx b/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx index a75e065ff3..bbac2bb99a 100755 --- a/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx +++ b/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& const gp_Pnt& Point4, const Handle( Geom_Plane )& Plane ) { - Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); + Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); // Line between two middles @@ -132,7 +132,7 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& gp_Pnt& aProj1, gp_Pnt& aProj2) { - const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + const Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (aPoint1,aDirection); @@ -170,7 +170,7 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& const gp_Pnt& aPoint4, const DsgPrs_ArrowSide anArrowSide) { - const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + const Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real aPar11, aPar12, aPar21, aPar22; diff --git a/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx index e4afdb16de..8e20b30d3f 100755 --- a/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ void DsgPrs_EqualRadiusPresentation::Add( const Handle( Prs3d_Presentation )& aP const gp_Pnt& SecondPoint, const Handle( Geom_Plane )& Plane ) { - Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); + Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); diff --git a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx index d9ee636c30..186ec5b920 100755 --- a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -84,10 +84,10 @@ void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPr gp_Dir DirOfArrow; gp_Circ FilletCirc; // gp_Pnt NewPosition, EndOfArrow; - Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); + Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); - Standard_Real ArrowLength = LA->Arrow1Aspect()->Length(); + Standard_Real ArrowLength = LA->ArrowAspect()->Length(); DsgPrs::ComputeFilletRadiusPresentation( ArrowLength, theval, aPosition, diff --git a/src/DsgPrs/DsgPrs_FixPresentation.cxx b/src/DsgPrs/DsgPrs_FixPresentation.cxx index 98a59b8d89..1eb6f2ee94 100755 --- a/src/DsgPrs/DsgPrs_FixPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FixPresentation.cxx @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -56,7 +56,7 @@ void DsgPrs_FixPresentation::Add( const gp_Dir& aNormPln, const Standard_Real symbsize) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(10); diff --git a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx index 73dbf05263..9c5046ffad 100755 --- a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx +++ b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent const gp_Pnt& aPntAttach, const gp_Pnt& aPntOffset) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); @@ -82,7 +82,7 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent const gp_Pnt& aSAttach, const gp_Pnt& aPntOffset) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(4); @@ -120,7 +120,7 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& aSAttach, const gp_Pnt& aPntOffset) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Ax2 ax = theAxe; @@ -169,7 +169,7 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& aPntOffset, const gp_Pnt& aPntOnCirc) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Ax2 ax = theAxe; @@ -218,7 +218,7 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& aPntOffset, const gp_Pnt& aPntOnElli) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real pFAttach = ElCLib::Parameter(anEllipse, aFAttach); diff --git a/src/DsgPrs/DsgPrs_LengthPresentation.cxx b/src/DsgPrs/DsgPrs_LengthPresentation.cxx index 9bde8b97f2..54a165212e 100755 --- a/src/DsgPrs/DsgPrs_LengthPresentation.cxx +++ b/src/DsgPrs/DsgPrs_LengthPresentation.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta const gp_Dir& aDirection, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); @@ -88,7 +88,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta aPrims->AddVertex(PointMin); aPrims->AddVertex(PointMax); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); @@ -96,13 +96,13 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta arrdir.Reverse(); // arrow 1 : 2nd group - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, LA->Arrow1Aspect()->Angle(), LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // arrow 2 : 3rd group - Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(), LA->Arrow2Aspect()->Angle(), LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); Prs3d_Root::NewGroup(aPresentation); @@ -137,14 +137,14 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& OffsetPoint, const DsgPrs_ArrowSide ArrowPrs ) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Pnt EndOfArrow1, EndOfArrow2; gp_Dir DirOfArrow1; - DsgPrs::ComputePlanarFacesLengthPresentation( LA->Arrow1Aspect()->Length(), - LA->Arrow2Aspect()->Length(), + DsgPrs::ComputePlanarFacesLengthPresentation( LA->ArrowAspect()->Length(), + LA->ArrowAspect()->Length(), AttachmentPoint1, AttachmentPoint2, aDirection, @@ -208,7 +208,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& OffsetPoint, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); @@ -245,7 +245,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta aPrims->AddVertex(PointMin); aPrims->AddVertex(PointMax); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); @@ -285,7 +285,7 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& OffsetPoint, const DsgPrs_ArrowSide ArrowPrs ) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Pnt EndOfArrow2; @@ -293,8 +293,8 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta Handle( Geom_Curve ) VCurve, UCurve; Standard_Real FirstU, deltaU = 0.0e0, FirstV, deltaV = 0.0e0; - DsgPrs::ComputeCurvilinearFacesLengthPresentation( LA->Arrow1Aspect()->Length(), - LA->Arrow2Aspect()->Length(), + DsgPrs::ComputeCurvilinearFacesLengthPresentation( LA->ArrowAspect()->Length(), + LA->ArrowAspect()->Length(), SecondSurf, AttachmentPoint1, AttachmentPoint2, @@ -381,22 +381,22 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPrs, { case DsgPrs_AS_LASTAR: Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(gp_Vec(Pt1,Pt2)), - aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), - aDrawer->LengthAspect()->Arrow1Aspect()->Length()); + aDrawer->DimensionAspect()->ArrowAspect()->Angle(), + aDrawer->DimensionAspect()->ArrowAspect()->Length()); break; case DsgPrs_AS_FIRSTAR: Prs3d_Arrow::Draw(aPrs,Pt1,gp_Dir(gp_Vec(Pt2,Pt1)), - aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), - aDrawer->LengthAspect()->Arrow1Aspect()->Length()); + aDrawer->DimensionAspect()->ArrowAspect()->Angle(), + aDrawer->DimensionAspect()->ArrowAspect()->Length()); break; case DsgPrs_AS_BOTHAR: V = gp_Vec(Pt1,Pt2); Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(V), - aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), - aDrawer->LengthAspect()->Arrow1Aspect()->Length()); + aDrawer->DimensionAspect()->ArrowAspect()->Angle(), + aDrawer->DimensionAspect()->ArrowAspect()->Length()); Prs3d_Arrow::Draw(aPrs,Pt1,gp_Dir(V.Reversed()), - aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), - aDrawer->LengthAspect()->Arrow1Aspect()->Length()); + aDrawer->DimensionAspect()->ArrowAspect()->Angle(), + aDrawer->DimensionAspect()->ArrowAspect()->Length()); break; default: break; diff --git a/src/DsgPrs/DsgPrs_MidPointPresentation.cxx b/src/DsgPrs/DsgPrs_MidPointPresentation.cxx index 352a62e5f1..199af059b8 100755 --- a/src/DsgPrs/DsgPrs_MidPointPresentation.cxx +++ b/src/DsgPrs/DsgPrs_MidPointPresentation.cxx @@ -40,7 +40,7 @@ #include #include -#include +#include #include //=================================================================== @@ -57,7 +57,7 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen { Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0; - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); gp_Ax2 ax = theAxe; ax.SetLocation(MidPoint); @@ -123,7 +123,7 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0; if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); gp_Ax2 ax = theAxe; ax.SetLocation(MidPoint); @@ -189,7 +189,7 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0; if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); gp_Ax2 ax = aCircle.Position(); ax.SetLocation(MidPoint); @@ -263,7 +263,7 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0; if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); gp_Pnt Ptmp,ptcur; diff --git a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx index 2c4c1d0a71..eadf5cc7a0 100755 --- a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx +++ b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include @@ -61,7 +61,7 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta const gp_Dir& aDirection2, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); @@ -114,19 +114,19 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta if (DimNulle) { - Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); - Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction().Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction().Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); } else { - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // fleche 1 : 2eme groupe - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -177,7 +177,7 @@ void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPres gp_Lin L2 (AttachmentPoint2,aDirection); gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2); - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Quantity_Color acolor; Aspect_TypeOfLine atype; Standard_Real awidth; diff --git a/src/DsgPrs/DsgPrs_ParalPresentation.cxx b/src/DsgPrs/DsgPrs_ParalPresentation.cxx index d4258db6d5..b7d1c9e6d9 100755 --- a/src/DsgPrs/DsgPrs_ParalPresentation.cxx +++ b/src/DsgPrs/DsgPrs_ParalPresentation.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Dir& aDirection, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); gp_Lin L2 (AttachmentPoint2,aDirection); @@ -80,20 +80,20 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 : 2nd group - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // arrow 2 : 3rd group - Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); Prs3d_Root::NewGroup(aPresentation); @@ -127,7 +127,7 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Pnt& OffsetPoint, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); @@ -163,7 +163,7 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat aPrims->AddVertex(PointMin); aPrims->AddVertex(PointMax); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) diff --git a/src/DsgPrs/DsgPrs_PerpenPresentation.cxx b/src/DsgPrs/DsgPrs_PerpenPresentation.cxx index 7275c1f293..f7931d7c15 100755 --- a/src/DsgPrs/DsgPrs_PerpenPresentation.cxx +++ b/src/DsgPrs/DsgPrs_PerpenPresentation.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,7 +53,7 @@ void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta const Standard_Boolean intOut1, const Standard_Boolean intOut2) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); diff --git a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx index 736fa27a76..e7b2c77326 100755 --- a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ void DsgPrs_RadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta fpara -= 2.*M_PI; lpara -= 2.*M_PI; } - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real parat = ElCLib::Parameter(aCircle,AttachmentPoint); @@ -131,7 +131,7 @@ void DsgPrs_RadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta arrdir.Reverse(); // fleche - Prs3d_Arrow::Draw(aPresentation,ptoncirc,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,ptoncirc,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,attpoint); @@ -153,7 +153,7 @@ void DsgPrs_RadiusPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta const Standard_Boolean drawFromCenter, const Standard_Boolean reverseArrow) { - Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); + Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); gp_Pnt LineOrigin, LineEnd; diff --git a/src/DsgPrs/DsgPrs_SymbPresentation.cxx b/src/DsgPrs/DsgPrs_SymbPresentation.cxx index 7f10bdd840..5494f7f61c 100755 --- a/src/DsgPrs/DsgPrs_SymbPresentation.cxx +++ b/src/DsgPrs/DsgPrs_SymbPresentation.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -37,7 +37,7 @@ void DsgPrs_SymbPresentation::Add (const Handle(Prs3d_Presentation)& aPresentati const TCollection_ExtendedString& aText, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Handle(Prs3d_TextAspect) TA = LA->TextAspect(); TA->SetColor(Quantity_NOC_GREEN); Prs3d_Text::Draw(aPresentation,TA,aText, OffsetPoint); diff --git a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx index 0a9f4c8bab..83135a26d6 100755 --- a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx +++ b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include @@ -73,7 +73,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese const gp_Lin& aAxis, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis); @@ -344,14 +344,14 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); //------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -456,7 +456,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese const gp_Lin& aAxis, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Pnt OffsetPnt(OffsetPoint.X(),OffsetPoint.Y(),OffsetPoint.Z()); @@ -591,14 +591,14 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); //------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -694,7 +694,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese const gp_Lin& aAxis, const gp_Pnt& OffsetPoint) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); if (AttachmentPoint1.IsEqual(AttachmentPoint2,Precision::Confusion())) @@ -810,14 +810,14 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); //==== ARROWS ================ - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; + if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); //==== POINTS ================ //Marker of localization of attachment points: diff --git a/src/DsgPrs/DsgPrs_TangentPresentation.cxx b/src/DsgPrs/DsgPrs_TangentPresentation.cxx index a0dbbae5fe..8bca750dd9 100755 --- a/src/DsgPrs/DsgPrs_TangentPresentation.cxx +++ b/src/DsgPrs/DsgPrs_TangentPresentation.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,10 +46,10 @@ void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresent gp_Pnt p2 = OffsetPoint.Translated(vec2); // Aspect - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); + Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); - Handle(Prs3d_ArrowAspect) ARR1 = LA->Arrow1Aspect(); - Handle(Prs3d_ArrowAspect) ARR2 = LA->Arrow2Aspect(); + Handle(Prs3d_ArrowAspect) ARR1 = LA->ArrowAspect(); + Handle(Prs3d_ArrowAspect) ARR2 = LA->ArrowAspect(); ARR1->SetLength(length/5); ARR2->SetLength(length/5); @@ -64,10 +64,10 @@ void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresent // fleche 1 : Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,p1,aDirection,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,p1,aDirection,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); // fleche 2 Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length()); } diff --git a/src/Graphic3d/Graphic3d_AspectText3d.cdl b/src/Graphic3d/Graphic3d_AspectText3d.cdl index 758ebf25e6..62550ffe7d 100755 --- a/src/Graphic3d/Graphic3d_AspectText3d.cdl +++ b/src/Graphic3d/Graphic3d_AspectText3d.cdl @@ -138,6 +138,7 @@ is -- TODT_SUBTITLE There is a subtitle under the text. -- TODT_DEKALE The text is displayed with a 3D style. -- TODT_BLEND The text is displayed in XOR. + -- TODT_DIMENSION Dimension line under text will be invisible. ---Category: Methods to modify the class definition SetColorSubTitle ( me : mutable; diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index 9f693ab973..235fa629f9 100755 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -451,6 +451,12 @@ is is deferred; ---Purpose: + SetStencilTestOptions ( me : mutable; + theCGroup : CGroup from Graphic3d; + theIsEnabled: Boolean from Standard) + is deferred; + ---Purpose: sets the stencil test to theIsEnabled state; + ---------------------------------------- -- Category: Methods to create Text -- for Purpose : see Graphic3d_Group.cdl diff --git a/src/Graphic3d/Graphic3d_Group.cdl b/src/Graphic3d/Graphic3d_Group.cdl index 0c936630d3..9c805ec4d9 100755 --- a/src/Graphic3d/Graphic3d_Group.cdl +++ b/src/Graphic3d/Graphic3d_Group.cdl @@ -369,6 +369,10 @@ class Group from Graphic3d inherits TShared -- Warning: Raises GroupDefinitionError if ... raises GroupDefinitionError from Graphic3d is static; + SetStencilTestOptions (me : mutable; + theIsEnabled: Boolean from Standard); + ---Purpose: sets the stencil test to theIsEnabled state; + ---------------------------- -- Category: Inquire methods ---------------------------- diff --git a/src/Graphic3d/Graphic3d_Group_13.cxx b/src/Graphic3d/Graphic3d_Group_13.cxx index f1f67154a9..52f797be43 100755 --- a/src/Graphic3d/Graphic3d_Group_13.cxx +++ b/src/Graphic3d/Graphic3d_Group_13.cxx @@ -82,3 +82,8 @@ void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject, Update (); } + +void Graphic3d_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled) +{ + MyGraphicDriver->SetStencilTestOptions (MyCGroup, theIsEnabled); +} diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index a1686f8f35..95eea4e6b1 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -122,6 +122,8 @@ OpenGl_CappingPlaneResource.hxx OpenGl_CappingPlaneResource.cxx OpenGl_Clipping.hxx OpenGl_Clipping.cxx +OpenGl_StencilTest.hxx +OpenGl_StencilTest.cxx OpenGl_ShaderObject.hxx OpenGl_ShaderObject.cxx OpenGl_ShaderProgram.hxx @@ -140,4 +142,4 @@ OpenGl_SceneGeometry.hxx OpenGl_SceneGeometry.cxx OpenGl_RaytraceTypes.hxx OpenGl_RaytraceSource.cxx -OpenGl_Workspace_Raytrace.cxx \ No newline at end of file +OpenGl_Workspace_Raytrace.cxx diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index 18ca913a3d..aa303085c6 100755 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -330,6 +331,14 @@ Standard_Boolean OpenGl_GraphicDriver::Print (const Graphic3d_CView& theCView, return isPrinted; } +void OpenGl_GraphicDriver::SetStencilTestOptions (const Graphic3d_CGroup& theCGroup, + const Standard_Boolean theIsEnabled) +{ + OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest(); + aStencilTest->SetOptions (theIsEnabled); + ((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aStencilTest); +} + // ======================================================================= // function : Text // purpose : diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index a09ad544e9..1037a39dfa 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -158,6 +158,7 @@ public: Standard_EXPORT void ViewMapping (const Graphic3d_CView& ACView, const Standard_Boolean AWait); Standard_EXPORT void ViewOrientation (const Graphic3d_CView& ACView,const Standard_Boolean AWait); Standard_EXPORT void Environment (const Graphic3d_CView& ACView); + Standard_EXPORT void SetStencilTestOptions (const Graphic3d_CGroup& theCGroup, const Standard_Boolean theIsEnabled); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True); diff --git a/src/OpenGl/OpenGl_StencilTest.cxx b/src/OpenGl/OpenGl_StencilTest.cxx new file mode 100644 index 0000000000..54c6460ff6 --- /dev/null +++ b/src/OpenGl/OpenGl_StencilTest.cxx @@ -0,0 +1,70 @@ +// Created on: 2013-09-26 +// Created by: Dmitry BOBYLEV +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include + +OpenGl_StencilTest::OpenGl_StencilTest() +{ + // +} + +// ======================================================================= +// function : Render +// purpose : +// ======================================================================= +void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)&) const +{ + if (myIsEnabled) + { + glEnable (GL_STENCIL_TEST); + glStencilFunc (GL_NOTEQUAL, 1, 0xFF); + } + else + { + glDisable (GL_STENCIL_TEST); + } +} + +// ======================================================================= +// function : Release +// purpose : +// ======================================================================= +void OpenGl_StencilTest::Release (const Handle(OpenGl_Context)&) +{ + // +} + +// ======================================================================= +// function : SetStencilTestState +// purpose : +// ======================================================================= +void OpenGl_StencilTest::SetOptions (const Standard_Boolean theIsEnabled) +{ + myIsEnabled = theIsEnabled; +} + +// ======================================================================= +// function : ~OpenGl_StencilTest +// purpose : +// ======================================================================= +OpenGl_StencilTest::~OpenGl_StencilTest() +{ + // +} \ No newline at end of file diff --git a/src/OpenGl/OpenGl_StencilTest.hxx b/src/OpenGl/OpenGl_StencilTest.hxx new file mode 100644 index 0000000000..fd412137a1 --- /dev/null +++ b/src/OpenGl/OpenGl_StencilTest.hxx @@ -0,0 +1,52 @@ +// Created on: 2013-09-26 +// Created by: Dmitry BOBYLEV +// Copyright (c) 2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef OpenGl_StencilTest_Header +#define OpenGl_StencilTest_Header + +#include + +class OpenGl_StencilTest : public OpenGl_Element +{ +public: + + //! Default constructor + OpenGl_StencilTest (); + + //! Render primitives to the window + virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; + + virtual void Release (const Handle(OpenGl_Context)& theContext); + + void SetOptions (const Standard_Boolean theIsEnabled); + +protected: + + //! Destructor + virtual ~OpenGl_StencilTest(); + +private: + Standard_Boolean myIsEnabled; + +public: + + DEFINE_STANDARD_ALLOC +}; + +#endif //OpenGl_StencilOptions_Header \ No newline at end of file diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 5d78def968..3c35c9b14e 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -783,6 +783,35 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, drawText (thePrintCtx, theCtx, theTextAspect); break; } + case Aspect_TODT_DIMENSION: + { + setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f)); + + glDisable (GL_DEPTH_TEST); + glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + glClear (GL_STENCIL_BUFFER_BIT); + glEnable (GL_STENCIL_TEST); + glStencilFunc (GL_ALWAYS, 1, 0x00); + glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); + + glBegin (GL_QUADS); + glVertex2f (myBndBox.Left, myBndBox.Top); + glVertex2f (myBndBox.Right, myBndBox.Top); + glVertex2f (myBndBox.Right, myBndBox.Bottom); + glVertex2f (myBndBox.Left, myBndBox.Bottom); + glEnd(); + + glStencilFunc (GL_ALWAYS, 0, 0xFF); + glDisable (GL_STENCIL_TEST); + + if (!myIs2d) + { + glEnable (GL_DEPTH_TEST); + } + glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + break; + } case Aspect_TODT_NORMAL: { break; diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index eaea9aeef2..78fa3b987f 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -416,7 +416,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_Display)& theDisplay, if (glXGetConfig (aDisp, aVis, GLX_STENCIL_SIZE, &aStencilSize) != 0) aStencilSize = 0; - if (!isGl || !aDepthSize || !isRGBA || (isDoubleBuffer ? 1 : 0) != (myDisplay->DBuffer()? 1 : 0)) + if (!isGl || !aDepthSize || !aStencilSize || !isRGBA || (isDoubleBuffer ? 1 : 0) != (myDisplay->DBuffer()? 1 : 0)) { XFree (aVis); aVis = NULL; diff --git a/src/Prs3d/Prs3d.cdl b/src/Prs3d/Prs3d.cdl index 3eab570629..218f6026e3 100755 --- a/src/Prs3d/Prs3d.cdl +++ b/src/Prs3d/Prs3d.cdl @@ -74,6 +74,19 @@ is -- TOH_NotSet is used by AIS_Drawer class, it means that the drawer should return the global value. -- For more details see AIS_Drawer class, AIS_Shape::Compute() method and -- HLRAlgo package from TKHLR toolkit. + + enumeration HorizontalTextAlignment is HTA_Left, HTA_Right, HTA_Center; + ---Purpose: To declare horisontal alignment for dimension text. + + enumeration VerticalTextAlignment is VTA_Top, VTA_Bottom, VTA_Center; + ---Purpose: To declare vertical alignment for dimension text label. + + enumeration DimensionArrowOrientation is DAO_Internal, DAO_External; + ---Purpose: To declare arrow orientation for dimenation. + -- External orientation means that dimension has extension parts outside the measured area. + --Internal orientation means the dimension arrows are in the measured area, and no extension parts are needed. + + class Presentation; ---Purpose: defines the presentation object. This object can be @@ -92,13 +105,10 @@ is class LineAspect; class ShadingAspect; class TextAspect; - deferred class CompositeAspect; class IsoAspect; + class ArrowAspect; class PlaneAspect; - class ArrowAspect; - class LengthAspect; - class AngleAspect; - class RadiusAspect; + class DimensionAspect; class DatumAspect; class Drawer; @@ -123,10 +133,6 @@ is ---Category: Basis construction elements. - class LengthPresentation; - - class AnglePresentation; - class Text; ---Category: Class signatures. diff --git a/src/Prs3d/Prs3d_AngleAspect.cdl b/src/Prs3d/Prs3d_AngleAspect.cdl deleted file mode 100755 index 17cf994a69..0000000000 --- a/src/Prs3d/Prs3d_AngleAspect.cdl +++ /dev/null @@ -1,74 +0,0 @@ --- Created on: 1993-06-03 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AngleAspect from Prs3d inherits CompositeAspect from Prs3d - - ---Purpose: A framework for defining how an angle will be - -- displayed in a presentation. Aspects of angle display include: - -- - display of the arrow pointing to the angle - -- - display of the line making up the shaft of the arrow - -- - display of the text referring to the angle. - -- The definition set by this class is then passed to the - -- attribute manager Prs3d_Drawer. - -- Any object which requires a value for angle aspect as - -- an argument may then be given the attribute manager - -- as a substitute argument in the form of a field such as - -- myDrawer for example. - -uses - - LineAspect from Prs3d, - TextAspect from Prs3d, - ArrowAspect from Prs3d - -is - --- --- Attributes for the lines. --- - Create returns mutable AngleAspect from Prs3d; - - LineAspect(me) returns mutable LineAspect from Prs3d; - --- Purpose: Returns the setting determining how the line making - -- up the shaft of the arrow will be displayed. - - SetLineAspect(me: mutable; anAspect: LineAspect from Prs3d); - ---Purpose: Sets how the line making up the shaft of an arrow will be displayed. - TextAspect(me) returns mutable TextAspect from Prs3d is static; - --- Purpose: Returns the setting determining how text in the - -- presentation of an angle will be displayed. - - SetTextAspect(me:mutable; anAspect: TextAspect from Prs3d) is static; - ---Purpose: Sets how text in the presentation of an angle will be displayed. - ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static; - ---Purpose: Returns the setting determining how an arrow head - -- which points to an angle will be displayed. - - SetArrowAspect(me: mutable; anAspect: ArrowAspect from Prs3d) is static; - ---Purpose: Sets how an arrow head which points to an angle will be displayed. - -fields - - myLineAspect: LineAspect from Prs3d; - myArrowAspect: ArrowAspect from Prs3d; - myTextAspect: TextAspect from Prs3d; - -end AngleAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_AngleAspect.cxx b/src/Prs3d/Prs3d_AngleAspect.cxx deleted file mode 100755 index 7f10bbbe9d..0000000000 --- a/src/Prs3d/Prs3d_AngleAspect.cxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs3d_AngleAspect::Prs3d_AngleAspect() { - myLineAspect = new Prs3d_LineAspect - (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); - myArrowAspect = new Prs3d_ArrowAspect; - myTextAspect = new Prs3d_TextAspect; -} - -Handle (Prs3d_LineAspect) Prs3d_AngleAspect::LineAspect () const { - return myLineAspect;} - -void Prs3d_AngleAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& anAspect) { - myLineAspect = anAspect;} - -Handle(Prs3d_ArrowAspect) Prs3d_AngleAspect::ArrowAspect () const { - return myArrowAspect;} - -void Prs3d_AngleAspect::SetArrowAspect ( - const Handle(Prs3d_ArrowAspect)& anAspect) { - myArrowAspect = anAspect; -} - -Handle(Prs3d_TextAspect) Prs3d_AngleAspect::TextAspect () const { - return myTextAspect;} - -void Prs3d_AngleAspect::SetTextAspect ( - const Handle(Prs3d_TextAspect)& anAspect) { - myTextAspect = anAspect; -} diff --git a/src/Prs3d/Prs3d_AnglePresentation.cdl b/src/Prs3d/Prs3d_AnglePresentation.cdl deleted file mode 100755 index 14aea9277a..0000000000 --- a/src/Prs3d/Prs3d_AnglePresentation.cdl +++ /dev/null @@ -1,48 +0,0 @@ --- Created on: 1994-02-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1994-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AnglePresentation from Prs3d inherits Root from Prs3d - ---Purpose: A framework to define the display of angles. -uses - Presentation from Prs3d, - Pnt from gp, - Drawer from Prs3d, - ExtendedString from TCollection - -is - Draw( myclass; aPresentation: Presentation from Prs3d; - aDrawer: Drawer from Prs3d; - aText: ExtendedString from TCollection; - AttachmentPoint1: Pnt from gp; - AttachmentPoint2: Pnt from gp; - AttachmentPoint3: Pnt from gp; - OffsetPoint: Pnt from gp); - ---Purpose: Defines the representation of the angle between the - -- line defined by the points AttachmentPoint1 and - -- AttachmentPoint2 and the line defined by the points - -- AttachmentPoint1 and AttachmentPoint3. - -- The text aText is displayed at the point OffsetPoint, - -- and the drawer aDrawer specifies the display - -- attributes which angles will have. - -- The presentation object aPresentation stores the - -- information defined in this framework. - -end AnglePresentation from Prs3d; diff --git a/src/Prs3d/Prs3d_AnglePresentation.cxx b/src/Prs3d/Prs3d_AnglePresentation.cxx deleted file mode 100755 index 234f3659a7..0000000000 --- a/src/Prs3d/Prs3d_AnglePresentation.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void Prs3d_AnglePresentation::Draw ( - const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const TCollection_ExtendedString& aText, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Pnt& AttachmentPoint3, - const gp_Pnt& OffsetPoint) -{ - Handle(Prs3d_AngleAspect) AA = aDrawer->AngleAspect(); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AA->LineAspect()->Aspect()); - - gp_Vec V1 (AttachmentPoint1,AttachmentPoint2); - gp_Vec V2 (AttachmentPoint1,AttachmentPoint3); - const Standard_Real alpha = V1.Angle(V2); - const Standard_Real ray = AttachmentPoint1.Distance(OffsetPoint); - - gp_Dir I (V1); - gp_Dir K = I.Crossed(gp_Dir(V2)); - gp_Dir J = K.Crossed(I); - - const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - const Standard_Real dteta = alpha/(nbp-1); - gp_Vec u; - gp_Pnt p1, p2; - - Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+2); - aPrims->AddVertex(AttachmentPoint2); - for (Standard_Integer i = 1; i<=nbp; i++) - { - u = (gp_Vec(I) * Cos ( (i-1) * dteta) - + gp_Vec(J) * Sin ( (i-1) * dteta)) * ray ; - p2 = AttachmentPoint1.Translated(u); - aPrims->AddVertex(p2); - if( i == nbp ) { - gp_Dir dir( gp_Vec(p1,p2) ); - Prs3d_Arrow::Draw(aPresentation,p2,dir,AA->ArrowAspect()->Angle(),AA->ArrowAspect()->Length()); - } - p1 = p2; - } - aPrims->AddVertex(AttachmentPoint3); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - - u = (gp_Vec(I) * Cos (0.5*alpha) - + gp_Vec(J) * Sin (0.5*alpha)) * ray ; - Prs3d_Text::Draw(aPresentation,AA->TextAspect(),aText,AttachmentPoint1.Translated(u)); -} diff --git a/src/Prs3d/Prs3d_ArrowAspect.cdl b/src/Prs3d/Prs3d_ArrowAspect.cdl index 59bcd12176..f2074bed47 100755 --- a/src/Prs3d/Prs3d_ArrowAspect.cdl +++ b/src/Prs3d/Prs3d_ArrowAspect.cdl @@ -21,7 +21,7 @@ -- Modified GG : GER61351 01/02/00 Add SetColor() & Aspect() methods -class ArrowAspect from Prs3d inherits CompositeAspect from Prs3d +class ArrowAspect from Prs3d inherits BasicAspect from Prs3d ---Purpose: A framework for displaying arrows in representations -- of dimensions and relations. uses diff --git a/src/Prs3d/Prs3d_CompositeAspect.cdl b/src/Prs3d/Prs3d_CompositeAspect.cdl deleted file mode 100755 index 4e6022ceac..0000000000 --- a/src/Prs3d/Prs3d_CompositeAspect.cdl +++ /dev/null @@ -1,28 +0,0 @@ --- Created on: 2000-02-15 --- Created by: Gerard GRAS --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - ----Purpose All composite Prs3d_xxxAspect must inherits from this class - -deferred class CompositeAspect from Prs3d inherits TShared from MMgt - -is - -end CompositeAspect from Prs3d; - diff --git a/src/Prs3d/Prs3d_CompositeAspect.cxx b/src/Prs3d/Prs3d_CompositeAspect.cxx deleted file mode 100755 index f59f945158..0000000000 --- a/src/Prs3d/Prs3d_CompositeAspect.cxx +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include diff --git a/src/Prs3d/Prs3d_DatumAspect.cdl b/src/Prs3d/Prs3d_DatumAspect.cdl index 4683d57c1e..3a19b56cae 100755 --- a/src/Prs3d/Prs3d_DatumAspect.cdl +++ b/src/Prs3d/Prs3d_DatumAspect.cdl @@ -20,7 +20,7 @@ -class DatumAspect from Prs3d inherits CompositeAspect from Prs3d +class DatumAspect from Prs3d inherits BasicAspect from Prs3d ---Purpose: A framework to define the display of datums. uses diff --git a/src/Prs3d/Prs3d_DimensionAspect.cdl b/src/Prs3d/Prs3d_DimensionAspect.cdl new file mode 100644 index 0000000000..573bef8543 --- /dev/null +++ b/src/Prs3d/Prs3d_DimensionAspect.cdl @@ -0,0 +1,118 @@ +-- Copyright (c) 1993-1999 Matra Datavision +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class DimensionAspect from Prs3d inherits BasicAspect from Prs3d + + ---Purpose: defines the attributes when drawing a Length Presentation. +uses + HorizontalTextAlignment from Prs3d, + VerticalTextAlignment from Prs3d, + DimensionArrowOrientation from Prs3d, + AspectLine3d from Graphic3d, + ArrowAspect from Prs3d, + LineAspect from Prs3d, + TextAspect from Prs3d, + NameOfColor from Quantity, + Color from Quantity, + TypeOfLine from Aspect, + PlaneAngle from Quantity, + TypeOfLine from Aspect +is + + Create returns mutable DimensionAspect from Prs3d; + --- Purpose: Constructs an empty framework to define the display of dimensions. + + LineAspect(me) returns mutable LineAspect from Prs3d; + ---Purpose: Returns the settings for the display of lines used in presentation of dimensions. + + SetLineAspect(me: mutable; theAspect: LineAspect from Prs3d); + ---Purpose: Sets the display attributes of lines used in presentation of dimensions. + + TextAspect(me) returns mutable TextAspect from Prs3d is static; + --- Purpose: Returns the settings for the display of text used in presentation of dimensions. + + SetTextAspect(me:mutable; theAspect: TextAspect from Prs3d) is static; + ---Purpose: Sets the display attributes of text used in presentation of dimensions. + + IsText3d(me) returns Boolean from Standard; + --- Purpose: Check if text for dimension label is 3d. + + MakeText3d (me:mutable; isText3d: Boolean from Standard); + ---Purpose: Sets type of text. + + IsTextShaded (me) returns Boolean from Standard; + --- Purpose: Check if 3d text for dimension label is shaded. + + MakeTextShaded (me: mutable; isTextShaded: Boolean from Standard); + --- Purpose: Turns on/off text shading for 3d text. + + IsArrows3d(me) returns Boolean from Standard; + --- Purpose: Gets type of arrows. + + MakeArrows3d (me:mutable; isArrows3d: Boolean from Standard); + ---Purpose: Sets type of arrows. + + SetArrowOrientation(me: mutable; theArrowOrient: DimensionArrowOrientation from Prs3d); + --- Purpose: Sets orientation of arrows (external or internal). + -- By default orientation is chosen automatically according to situation and text label size. + + GetArrowOrientation (me) returns DimensionArrowOrientation from Prs3d; + --- Purpose: Gets orientation of arrows (external or internal). + + SetVerticalTextAlignment(me: mutable; theVertTextAlignment: VerticalTextAlignment from Prs3d); + --- Purpose: Sets vertical text alignment for text label. + + VerticalTextAlignment (me) returns VerticalTextAlignment from Prs3d; + --- Purpose: Gets vertical text alignment for text label. + + SetHorizontalTextAlignment (me: mutable; theHorTextAlignment: HorizontalTextAlignment from Prs3d); + --- Purpose: Sets horizontal text alignment for text label. + + HorizontalTextAlignment (me) returns HorizontalTextAlignment from Prs3d; + --- Purpose: Gets horizontal text alignment for text label. + + ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static; + --- Purpose: Returns the settings for displaying arrows. + + SetArrowAspect(me: mutable; theAspect: ArrowAspect from Prs3d) is static; + ---Purpose: Sets the display attributes of arrows used in presentation of dimensions. + + SetCommonColor(me:mutable; theColor: Color from Quantity) is static; + ---Purpose: Sets the same color for all parts of dimension: lines, arrows and text. + +fields + + myLineAspect: LineAspect from Prs3d; + ---Purpose: Text style. The size for 3d (or 2d) text is also inside here. + myTextAspect: TextAspect from Prs3d; + myArrowAspect : ArrowAspect from Prs3d; + myIsText3d : Boolean from Standard; + myIsTextShaded : Boolean from Standard; + myIsArrows3d: Boolean from Standard; + myArrowOrientation : DimensionArrowOrientation from Prs3d; + ---Purpose: Dimension arrow orientation + -- By default, it is computed automatically. Its value depends on the text + -- bouning rectangle size and distance between two flyouts. + -- By default, it is internal one. + myHorTextAlignment: HorizontalTextAlignment from Prs3d; + ---Purpose:Horizontal text alignment (Prs3d_HTA_Left/Prs3d_HTA_Right/Prs3d_HTA_Center). + -- Defines horizontal position of text value label, by default it is center. + myVerTextAlignment: VerticalTextAlignment from Prs3d; + ---Purpose: Vertical text alignment (Prs3d_VTA_Top, Prs3d_VTA_Bottom/Prs3d_VTA_Center) + -- Defines vertical position of text value lable, by default it is center. +end DimensionAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_DimensionAspect.cxx b/src/Prs3d/Prs3d_DimensionAspect.cxx new file mode 100644 index 0000000000..b5c2abc617 --- /dev/null +++ b/src/Prs3d/Prs3d_DimensionAspect.cxx @@ -0,0 +1,242 @@ +// Copyright (c) 1998-1999 Matra Datavision +// Copyright (c) 1999-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include + +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect) +IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect) + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= + +Prs3d_DimensionAspect::Prs3d_DimensionAspect () +{ + // Text alignment + myHorTextAlignment = Prs3d_HTA_Center; + myVerTextAlignment = Prs3d_VTA_Center; + // Arrow orientation, will be computed on further steps, by default it is internal. + myArrowOrientation = Prs3d_DAO_Internal; + myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); + myTextAspect = new Prs3d_TextAspect; + myTextAspect->Aspect()->SetTextZoomable (Standard_False); + myTextAspect->SetColor (Quantity_NOC_LAWNGREEN); + myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER); + myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); + myArrowAspect = new Prs3d_ArrowAspect; + myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN); + myArrowAspect->SetLength (6.); +} + +//======================================================================= +//function : SetCommonColor +//purpose : Sets the same color for all parts of dimension: +// lines, arrows and text. +//======================================================================= + +void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor) +{ + myLineAspect->SetColor (theColor); + myTextAspect->SetColor (theColor); + myArrowAspect->SetColor (theColor); +} + +//======================================================================= +//function : LineAspect +//purpose : +//======================================================================= + +Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const +{ + return myLineAspect; +} + +//======================================================================= +//function : SetLineAspect +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect) +{ + myLineAspect = theAspect; +} + +//======================================================================= +//function : TextAspect +//purpose : +//======================================================================= + +Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const +{ + return myTextAspect; +} + +//======================================================================= +//function : SetTextAspect +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) +{ + myTextAspect = theAspect; +} + +//======================================================================= +//function : MakeArrows3D +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d) +{ + myIsArrows3d = isArrows3d; +} + +//======================================================================= +//function : IsArrows3D +//purpose : +//======================================================================= +Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const +{ + return myIsArrows3d; +} + +//======================================================================= +//function : MakeText3D +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d) +{ + myIsText3d = isText3d; +} + +//======================================================================= +//function : IsText3D +//purpose : +//======================================================================= +Standard_Boolean Prs3d_DimensionAspect::IsText3d () const +{ + return myIsText3d; +} + +//======================================================================= +//function : IsTextShaded +//purpose : +//======================================================================= +Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const +{ + return myIsTextShaded; +} + +//======================================================================= +//function : MakeTextShaded +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded) +{ + myIsTextShaded = isTextShaded; +} + +//======================================================================= +//function : SetArrowOrientation +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) +{ + myArrowOrientation = theArrowOrient; +} + +//======================================================================= +//function : GetArrowOrientation +//purpose : +//======================================================================= + +Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const +{ + return myArrowOrientation; +} + +//======================================================================= +//function : VerticalTextAlignment +//purpose : +//======================================================================= + +Prs3d_VerticalTextAlignment Prs3d_DimensionAspect::VerticalTextAlignment () const +{ + return myVerTextAlignment; +} + +//======================================================================= +//function : SetVerticalTextAlignment +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetVerticalTextAlignment (const Prs3d_VerticalTextAlignment theVertTextAlignment) +{ + myVerTextAlignment = theVertTextAlignment; +} + +//======================================================================= +//function : HorizontalTextAlignment +//purpose : +//======================================================================= + +Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const +{ + return myHorTextAlignment; +} + +//======================================================================= +//function : SetHorizontalTextAlignment +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment) +{ + myHorTextAlignment = theHorTextAlignment; +} + +//======================================================================= +//function : ArrowAspect +//purpose : +//======================================================================= + +Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const +{ + return myArrowAspect; +} + +//======================================================================= +//function : SetArrowAspect +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) +{ + myArrowAspect = theAspect; +} diff --git a/src/Prs3d/Prs3d_Drawer.cdl b/src/Prs3d/Prs3d_Drawer.cdl index 9220196e28..82cfeb369e 100755 --- a/src/Prs3d/Prs3d_Drawer.cdl +++ b/src/Prs3d/Prs3d_Drawer.cdl @@ -39,10 +39,8 @@ uses PointAspect from Prs3d, ShadingAspect from Prs3d, IsoAspect from Prs3d, - LengthAspect from Prs3d, - AngleAspect from Prs3d, + DimensionAspect from Prs3d, PlaneAspect from Prs3d, - RadiusAspect from Prs3d, ArrowAspect from Prs3d, TypeOfDeflection from Aspect, NameOfColor from Quantity, @@ -474,30 +472,13 @@ is is virtual; ---Purpose: Sets the modality anAspect for the display of datums. - LengthAspect(me:mutable) returns mutable LengthAspect from Prs3d - ---Purpose: Returns settings for the appearance of lengths. + DimensionAspect(me:mutable) returns mutable DimensionAspect from Prs3d + ---Purpose: Returns settings for the appearance of dimensions. is virtual; - SetLengthAspect(me:mutable; anAspect: LengthAspect from Prs3d) + SetDimensionAspect(me:mutable; theAspect: DimensionAspect from Prs3d) is virtual; - - ---Purpose: Sets the modality anAspect for display of lengths. - - AngleAspect(me:mutable) returns mutable AngleAspect from Prs3d - ---Purpose: Returns settings for lines used to display angles. - is virtual; - - SetAngleAspect(me:mutable; anAspect: AngleAspect from Prs3d) - is virtual; - ---Purpose: Sets the modality anAspect for the display of angles. - - RadiusAspect(me) returns mutable RadiusAspect from Prs3d - ---Purpose: Returns settings for lines which serve to display radii. - is virtual; - - SetRadiusAspect(me:mutable; anAspect: RadiusAspect from Prs3d) - is virtual; - --- Purpose: Sets the parameter anAspect for display attributes of radii. + ---Purpose: Sets the modality anAspect for display of dimensions. SectionAspect (me:mutable) returns mutable LineAspect from Prs3d ---Purpose: The LineAspect for the wire can be edited. @@ -568,9 +549,7 @@ fields myVectorAspect: LineAspect from Prs3d is protected; myDatumAspect: DatumAspect from Prs3d is protected; myDatumScale: Real from Standard is protected; - myLengthAspect: LengthAspect from Prs3d is protected; - myAngleAspect: AngleAspect from Prs3d is protected; - myRadiusAspect: RadiusAspect from Prs3d is protected; + myDimensionAspect: DimensionAspect from Prs3d is protected; mySectionAspect: LineAspect from Prs3d is protected; myFaceBoundaryDraw : Boolean from Standard is protected; myFaceBoundaryAspect : LineAspect from Prs3d is protected; diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index ff44b2bd51..a8de0c4a68 100755 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -397,37 +397,19 @@ void Prs3d_Drawer::SetPlaneAspect ( const Handle(Prs3d_PlaneAspect)& anAspect) { myPlaneAspect = anAspect; } -Handle (Prs3d_LengthAspect) Prs3d_Drawer::LengthAspect () { - if (myLengthAspect.IsNull()) - myLengthAspect = new Prs3d_LengthAspect; - - return myLengthAspect; -} - -void Prs3d_Drawer::SetLengthAspect ( const Handle(Prs3d_LengthAspect)& anAspect) { - myLengthAspect = anAspect; -} - - - -Handle (Prs3d_AngleAspect) Prs3d_Drawer::AngleAspect () { - if (myAngleAspect.IsNull()) - myAngleAspect = new Prs3d_AngleAspect; - - return myAngleAspect; -} +Handle (Prs3d_DimensionAspect) Prs3d_Drawer::DimensionAspect () +{ + if (myDimensionAspect.IsNull()) + myDimensionAspect = new Prs3d_DimensionAspect; -void Prs3d_Drawer::SetAngleAspect ( const Handle(Prs3d_AngleAspect)& anAspect) { - myAngleAspect = anAspect; + return myDimensionAspect; } -Handle (Prs3d_RadiusAspect) Prs3d_Drawer::RadiusAspect () const { - return myRadiusAspect; +void Prs3d_Drawer::SetDimensionAspect ( const Handle(Prs3d_DimensionAspect)& theAspect) +{ + myDimensionAspect = theAspect; } -void Prs3d_Drawer::SetRadiusAspect ( const Handle(Prs3d_RadiusAspect)& anAspect) { - myRadiusAspect = anAspect; -} Handle (Prs3d_LineAspect) Prs3d_Drawer::SectionAspect () { if (mySectionAspect.IsNull()) diff --git a/src/Prs3d/Prs3d_LengthAspect.cdl b/src/Prs3d/Prs3d_LengthAspect.cdl deleted file mode 100755 index bd2d760a37..0000000000 --- a/src/Prs3d/Prs3d_LengthAspect.cdl +++ /dev/null @@ -1,87 +0,0 @@ --- Created on: 1993-06-03 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class LengthAspect from Prs3d inherits CompositeAspect from Prs3d - - ---Purpose: defines the attributes when drawing a Length Presentation. -uses - - AspectLine3d from Graphic3d, - ArrowAspect from Prs3d, - LineAspect from Prs3d, - TextAspect from Prs3d, - NameOfColor from Quantity, - TypeOfLine from Aspect, - PlaneAngle from Quantity - -is - --- --- Attributes for the lines. --- - Create returns mutable LengthAspect from Prs3d; - --- Purpose: Constructs an empty framework to define the display of lengths. - - LineAspect(me) returns mutable LineAspect from Prs3d; - ---Purpose: Returns the settings for the display of lines used in presentation of lengths. - - SetLineAspect(me: mutable; anAspect: LineAspect from Prs3d); - ---Purpose: Sets the display attributes of lines used in presentation of lengths. - - Arrow1Aspect(me) returns mutable ArrowAspect from Prs3d is static; - --- Purpose: Returns the settings for displaying a right-pointing arrow. - - SetArrow1Aspect(me: mutable; anAspect: ArrowAspect from Prs3d) is static; - ---Purpose: Sets the display attributes of the first arrow used in presentation of lengths. - - Arrow2Aspect(me) returns mutable ArrowAspect from Prs3d is static; - --- Purpose: Returns the settings for displaying a left-pointing arrow. - - SetArrow2Aspect(me: mutable ; anAspect: ArrowAspect from Prs3d) is static; - ---Purpose: Sets the display attributes of the second arrow used in presentation of lengths. - - TextAspect(me) returns mutable TextAspect from Prs3d is static; - --- Purpose: Returns the settings for the display of text used in presentation of lengths. - - SetTextAspect(me:mutable; anAspect: TextAspect from Prs3d) is static; - ---Purpose: Sets the display attributes of text used in presentation of lengths. - - SetDrawFirstArrow(me: mutable; draw: Boolean from Standard) is static; - --- Purpose: Sets the DrawFirstArrow attributes to active. - - DrawFirstArrow(me) returns Boolean from Standard is static; - ---Purpose: Returns true if the first arrow can be drawn. - SetDrawSecondArrow(me: mutable; draw: Boolean from Standard) is static; - ---Purpose: Sets the DrawSecondArrow attributes to active. - - DrawSecondArrow(me) returns Boolean from Standard is static; - ---Purpose: Returns true if the second arrow can be drawn. - -fields - - myLineAspect: LineAspect from Prs3d; - myArrow1Aspect: ArrowAspect from Prs3d; - myArrow2Aspect: ArrowAspect from Prs3d; - myTextAspect: TextAspect from Prs3d; - myDrawFirstArrow: Boolean from Standard; - myDrawSecondArrow: Boolean from Standard; - -end LengthAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_LengthAspect.cxx b/src/Prs3d/Prs3d_LengthAspect.cxx deleted file mode 100755 index 1302cf8504..0000000000 --- a/src/Prs3d/Prs3d_LengthAspect.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs3d_LengthAspect::Prs3d_LengthAspect() { - myLineAspect = new Prs3d_LineAspect - (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); - myArrow1Aspect = new Prs3d_ArrowAspect; - myArrow2Aspect = new Prs3d_ArrowAspect; - myTextAspect = new Prs3d_TextAspect; - myDrawFirstArrow = Standard_True; - myDrawSecondArrow = Standard_True; -} - -Handle (Prs3d_LineAspect) Prs3d_LengthAspect::LineAspect () const { - return myLineAspect;} - -void Prs3d_LengthAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& anAspect) { - myLineAspect = anAspect;} - -Handle(Prs3d_ArrowAspect) Prs3d_LengthAspect::Arrow1Aspect () const { - return myArrow1Aspect;} - -void Prs3d_LengthAspect::SetArrow1Aspect ( - const Handle(Prs3d_ArrowAspect)& anAspect) { - myArrow1Aspect = anAspect; -} -Handle(Prs3d_ArrowAspect) Prs3d_LengthAspect::Arrow2Aspect () const { - return myArrow2Aspect;} - -void Prs3d_LengthAspect::SetArrow2Aspect ( - const Handle(Prs3d_ArrowAspect)& anAspect) { - myArrow2Aspect = anAspect; -} - -Handle(Prs3d_TextAspect) Prs3d_LengthAspect::TextAspect () const { - return myTextAspect;} - -void Prs3d_LengthAspect::SetTextAspect ( - const Handle(Prs3d_TextAspect)& anAspect) { - myTextAspect = anAspect; -} -void Prs3d_LengthAspect::SetDrawFirstArrow (const Standard_Boolean draw) { - myDrawFirstArrow = draw; -} -Standard_Boolean Prs3d_LengthAspect::DrawFirstArrow () const { - return myDrawFirstArrow; -} - -void Prs3d_LengthAspect::SetDrawSecondArrow (const Standard_Boolean draw) { - myDrawSecondArrow = draw; -} -Standard_Boolean Prs3d_LengthAspect::DrawSecondArrow () const { - return myDrawSecondArrow; -} diff --git a/src/Prs3d/Prs3d_LengthPresentation.cdl b/src/Prs3d/Prs3d_LengthPresentation.cdl deleted file mode 100755 index 613e93307d..0000000000 --- a/src/Prs3d/Prs3d_LengthPresentation.cdl +++ /dev/null @@ -1,46 +0,0 @@ --- Created on: 1993-06-03 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class LengthPresentation from Prs3d inherits Root from Prs3d - ---Purpose: A framework to define the display of lengths. -uses - Presentation from Prs3d, - Pnt from gp, - Drawer from Prs3d, - ExtendedString from TCollection - -is - Draw( myclass; aPresentation: Presentation from Prs3d; - aDrawer: Drawer from Prs3d; - aText: ExtendedString from TCollection; - AttachmentPoint1: Pnt from gp; - AttachmentPoint2: Pnt from gp; - OffsetPoint: Pnt from gp); - ---Purpose: Defines the display of the length between the points - -- AttachmentPoint1 and AttachmentPoint2. - -- The text aText is displayed at the point OffsetPoint, - -- and the drawer aDrawer specifies the display - -- attributes which lengths will have. - -- The presentation object aPresentation stores the - -- information defined in this framework. -end LengthPresentation from Prs3d; diff --git a/src/Prs3d/Prs3d_LengthPresentation.cxx b/src/Prs3d/Prs3d_LengthPresentation.cxx deleted file mode 100755 index 478c154eef..0000000000 --- a/src/Prs3d/Prs3d_LengthPresentation.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void Prs3d_LengthPresentation::Draw ( - const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const TCollection_ExtendedString& aText, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Pnt& OffsetPoint) -{ - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - - gp_Dir D (gp_Vec(AttachmentPoint1,AttachmentPoint2)); - gp_Lin L (OffsetPoint,D); - gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint1),L); - gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint2),L); - - Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); - aPrims->AddVertex(AttachmentPoint1); - aPrims->AddVertex(Proj1); - aPrims->AddVertex(Proj2); - aPrims->AddVertex(AttachmentPoint2); - Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - - Quantity_Length X,Y,Z; - Proj1.Coord(X,Y,Z); - if (LA->DrawFirstArrow()) - Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); - - Quantity_Length X2,Y2,Z2; - Proj2.Coord(X2,Y2,Z2); - if (LA->DrawSecondArrow()) - Prs3d_Arrow::Draw(aPresentation,Proj2,D,LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); - - gp_Pnt p( .5*(X+X2), .5*(Y+Y2), .5*(Z+Z2) ); - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,p); -} diff --git a/src/Prs3d/Prs3d_PlaneAspect.cdl b/src/Prs3d/Prs3d_PlaneAspect.cdl index ebfe3536aa..487f8db782 100755 --- a/src/Prs3d/Prs3d_PlaneAspect.cdl +++ b/src/Prs3d/Prs3d_PlaneAspect.cdl @@ -19,7 +19,7 @@ -- and conditions governing the rights and limitations under the License. -class PlaneAspect from Prs3d inherits CompositeAspect from Prs3d +class PlaneAspect from Prs3d inherits BasicAspect from Prs3d ---Purpose: A framework to define the display of planes. uses diff --git a/src/Prs3d/Prs3d_RadiusAspect.cdl b/src/Prs3d/Prs3d_RadiusAspect.cdl deleted file mode 100755 index a78258bd3c..0000000000 --- a/src/Prs3d/Prs3d_RadiusAspect.cdl +++ /dev/null @@ -1,47 +0,0 @@ --- Created on: 1993-06-03 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class RadiusAspect from Prs3d inherits CompositeAspect from Prs3d - - ---Purpose: defines the attributes when drawing a Radius Presentation. -uses - - AspectLine3d from Graphic3d, - NameOfColor from Quantity, - TypeOfLine from Aspect - -is - --- --- Attributes for the lines. --- - Create (aColor: NameOfColor from Quantity; - aType: TypeOfLine from Aspect; - aWidth: Real from Standard) - returns mutable RadiusAspect from Prs3d; - ---Purpose: Constructs the framework to define the display of radii. - -- This consists of the attributes: - -- - the color aColor - -- - the type of line aType and - -- - the width aWidth of the line. - - -end RadiusAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_RadiusAspect.cxx b/src/Prs3d/Prs3d_RadiusAspect.cxx deleted file mode 100755 index 7003e6264b..0000000000 --- a/src/Prs3d/Prs3d_RadiusAspect.cxx +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs3d_RadiusAspect::Prs3d_RadiusAspect(const Quantity_NameOfColor /*aColor*/, - const Aspect_TypeOfLine /*aType*/, - const Standard_Real /*aWidth*/) { -} diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index c6d0af328b..4c4f8e37a6 100755 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -254,7 +254,7 @@ static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, c //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n"; di << argv[5] << " " << Draw::Atof(argv[4]) << "\n"; - Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane, Draw::Atof(argv[4]), aText); + Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane->Pln()); aContext->Display(aDim); return 0; @@ -683,15 +683,13 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con di << "use 'vinit' command before " << argv[0] << "\n"; return 1; } - if ( argc != 5 ) { - di << "Usage : " << argv[0] << " X Y Z ArrowSize" << "\n"; + if ( argc != 3 ) { + di << "Usage : " << argv[0] << " ArcRadius ArrowSize" << "\n"; return 1; } - Standard_Real X = Draw::Atof(argv[1]); - Standard_Real Y = Draw::Atof(argv[2]); - Standard_Real Z = Draw::Atof(argv[3]); - Standard_Real ArrowSize = Draw::Atof(argv[4]); + Standard_Real aRadius = Draw::Atof(argv[1]); + Standard_Real anArrowSize = Draw::Atof(argv[2]); gp_Pnt p1 = gp_Pnt(10.,10.,0.); gp_Pnt p2 = gp_Pnt(50.,10.,0.); @@ -707,12 +705,17 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con gp_Dir plndir(0, 0, 1); Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir); - Handle(AIS_AngleDimension) AngleDimension = new AIS_AngleDimension(E2, E1, pln, -3.14/2., "Angle"); - - AngleDimension->SetPosition(gp_Pnt(X, Y, Z)); - AngleDimension->SetArrowSize(ArrowSize); - - context->Display(AngleDimension); + Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3); + + Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect; + anAspect->MakeArrows3d (Standard_True); + anAspect->ArrowAspect()->SetLength (anArrowSize); + anAspect->SetHorizontalTextAlignment (Prs3d_HTA_Right); + anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW); + anAngleDimension->SetDimensionAspect (anAspect); + // Another position of dimension + anAngleDimension->SetFlyout (aRadius); + context->Display (anAngleDimension, 0); return 0; } @@ -864,7 +867,7 @@ void QABugs::Commands_16(Draw_Interpretor& theCommands) { theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group); theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group); theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group); - theCommands.Add ("OCC301", "OCC301 X Y Z ArrowSize", __FILE__, OCC301, group); + theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group); theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group); theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group); theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group); diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 8b83dea17b..c0df0217ce 100755 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -328,49 +328,38 @@ static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, /***************************************/ //dimension "L 502.51" /***************************************/ - Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln, 502.51, "502.51"); - len->SetPosition(gp_Pnt(350, 250, 0)); - len->SetTypeOfDist(AIS_TOD_Horizontal); - len->SetArrowSize(30.0); + Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln()); context->Display(len); /***************************************/ //dimension "L 90" /***************************************/ - Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln, 90, "90"); - len1->SetPosition(gp_Pnt(70, 120, 0)); - len1->SetTypeOfDist(AIS_TOD_Vertical); - len1->SetArrowSize(100.0); + Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln->Pln()); context->Display(len1); /***************************************/ //dimension "L 150" /***************************************/ - Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln, 150, "150",gp_Pnt(650, 120, 0),DsgPrs_AS_BOTHAR, - AIS_TOD_Vertical, 100.0 ); - //len2->SetPosition(gp_Pnt(650, 120, 0)); - //len2->SetTypeOfDist(AIS_TOD_Vertical); - //len1->SetArrowSize(100.0); + Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln()); context->Display(len2); /***************************************/ //dimension "R 88.58" /***************************************/ gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58); TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) ); - Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1,88.58, "R 88.58",gp_Pnt(-30.0, -80.0, 0.0),DsgPrs_AS_BOTHAR, - 100.0 ); + Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1); context->Display(dim1); /***************************************/ //dimension "R 43.80" /***************************************/ gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80); TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1); - dim1 = new AIS_RadiusDimension(E_cir1,43.80, "R 43.80",gp_Pnt(0.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 60.0 ); + dim1 = new AIS_RadiusDimension(E_cir1); context->Display(dim1); /***************************************/ //dimension "R 17.86" /***************************************/ gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86); TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2); - dim1 = new AIS_RadiusDimension(E_cir2,17.86, "R 17.86",gp_Pnt(600.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 40.0 ); + dim1 = new AIS_RadiusDimension(E_cir2); context->Display(dim1); return 0; diff --git a/src/QABugs/QABugs_3.cxx b/src/QABugs/QABugs_3.cxx index 1685155955..c75cad750e 100644 --- a/src/QABugs/QABugs_3.cxx +++ b/src/QABugs/QABugs_3.cxx @@ -580,13 +580,22 @@ static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, c Handle(AIS_Shape) Ve1 = new AIS_Shape(V1); Handle(AIS_Shape) Ve2 = new AIS_Shape(V2); - myAIScontext->Display(Ve1); - myAIScontext->Display(Ve2); + myAIScontext->Display(Ve1); + myAIScontext->Display(Ve2); Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1)); TCollection_ExtendedString Ext1("Dim1"); - Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,Draw::Atof(a[2]),Ext1); - + Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln()); + Dim1->SetCustomValue (Draw::Atof(a[2])); + + Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); + anAspect->MakeArrows3d (Standard_False); + anAspect->MakeText3d (Standard_True); + anAspect->MakeTextShaded (Standard_True); + anAspect->TextAspect()->SetHeight (2.5); + anAspect->ArrowAspect()->SetLength (1.0); + Dim1->SetDimensionAspect (anAspect); + myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1])); myAIScontext->Display(Dim1); return 0; diff --git a/src/TKV3d/EXTERNLIB b/src/TKV3d/EXTERNLIB index a0787ed5e2..42ef1b94d2 100755 --- a/src/TKV3d/EXTERNLIB +++ b/src/TKV3d/EXTERNLIB @@ -12,3 +12,4 @@ TKHLR CSF_user32 CSF_gdi32 CSF_OpenGlLibs +CSF_FREETYPE diff --git a/src/TPrsStd/TPrsStd_ConstraintTools.cxx b/src/TPrsStd/TPrsStd_ConstraintTools.cxx index 4288da55bb..843afc3f98 100755 --- a/src/TPrsStd/TPrsStd_ConstraintTools.cxx +++ b/src/TPrsStd/TPrsStd_ConstraintTools.cxx @@ -370,16 +370,17 @@ void TPrsStd_ConstraintTools::ComputeDistance (const Handle(TDataXtd_Constraint) gp_Pnt P2 = BRep_Tool::Pnt( TopoDS::Vertex(shape2) ); gp_Pnt P3(P1.Y()-1., P2.X()+1., 0.); GC_MakePlane mkPlane(P1, P2, P3); - ais = new AIS_LengthDimension (shape1, shape2, mkPlane.Value(), val1,txt); + ais = new AIS_LengthDimension (P1, P2, mkPlane.Value()->Pln()); } - else if (isface) { - ais = new AIS_LengthDimension (GetFace(shape1),GetFace(shape2),val1,txt); + else if (isface) + { + ais = new AIS_LengthDimension (GetFace(shape1),GetFace(shape2),aplane->Pln()); } else if (isedgeface) { - ais = new AIS_LengthDimension (GetFace(shape1),GetEdge(shape2),val1,txt); + ais = new AIS_LengthDimension (GetFace(shape1),GetEdge(shape2),aplane->Pln()); } else { - ais = new AIS_LengthDimension (shape1,shape2,aplane,val1,txt); + ais = new AIS_LengthDimension (shape1,shape2,aplane->Pln()); } if( SaveDrw ) ais->SetAttributes(aDrawer); } @@ -397,21 +398,15 @@ void TPrsStd_ConstraintTools::ComputeDistance (const Handle(TDataXtd_Constraint) gp_Pnt P2 = BRep_Tool::Pnt( TopoDS::Vertex(shape2) ); gp_Pnt P3(P1.Y()-1., P2.X()+1., 0.); GC_MakePlane mkPlane(P1, P2, P3); - ais->SetPlane( mkPlane.Value() ); + ais->SetWorkingPlane( mkPlane.Value()->Pln() ); } - ais->SetValue (val1); - ais->SetText (txt); + ais->SetCustomValue (val1); } - if (is_planar) { - Standard_Integer extShape (0); -#ifndef BUC60846 - FindExternalShape (aConst,extShape); -#endif - ais->SetPlane (aplane); - ais->SetTypeOfDist (typedist); - ais->SetExtShape (extShape); + if (is_planar) + { + ais->SetWorkingPlane (aplane->Pln()); } anAIS = ais; } @@ -774,23 +769,25 @@ void TPrsStd_ConstraintTools::ComputeAngleForOneFace (const Handle(TDataXtd_Cons ais = Handle(AIS_AngleDimension)::DownCast(anAIS); if(ais.IsNull()) { face = TopoDS::Face( shape ); - ais = new AIS_AngleDimension ( face, val1, txt); + ais = new AIS_AngleDimension (face); } else { - ais->SetConeFace(TopoDS::Face( shape )); - ais->SetValue(val1); - ais->SetText(txt); + ais->SetFirstShape(TopoDS::Face( shape ), Standard_True); } } else { - face = TopoDS::Face( shape ); - ais = new AIS_AngleDimension ( face, val1, txt); + face = TopoDS::Face (shape); + ais = new AIS_AngleDimension (face); } anAIS = ais; } -//==================================================================== +//======================================================================= +//function : CheckIsShapeCompound +//purpose : +//======================================================================= + static Standard_Boolean CheckIsShapeCompound(TopoDS_Shape& shape, TopoDS_Face& aFace) { if (shape.ShapeType() == TopAbs_COMPOUND) { @@ -810,10 +807,12 @@ static Standard_Boolean CheckIsShapeCompound(TopoDS_Shape& shape, TopoDS_Face& a #endif return (Standard_False); } + //======================================================================= //function : ComputeAngle //purpose : //======================================================================= + void TPrsStd_ConstraintTools::ComputeAngle (const Handle(TDataXtd_Constraint)& aConst, Handle(AIS_InteractiveObject)& anAIS) { @@ -1003,19 +1002,19 @@ void TPrsStd_ConstraintTools::ComputeAngle (const Handle(TDataXtd_Constraint)& a GetGoodShape(shape2); ais = new AIS_AngleDimension (TopoDS::Edge(shape1), TopoDS::Edge(shape2), - (Handle(Geom_Plane)&) ageom3,val1,txt); - ais->SetExtShape(ExtShape); + ((Handle(Geom_Plane)&) ageom3)->Pln()); } } else { if (isCurvilinear) { - ais = new AIS_AngleDimension (TopoDS::Face(shape1), - TopoDS::Face(shape2),val1,txt); + ais = new AIS_AngleDimension (TopoDS::Face(shape1), + TopoDS::Face(shape2), + ((Handle(Geom_Line)&) ageom3)->Position()); } else if (isface) { - ais = new AIS_AngleDimension (TopoDS::Face(shape1), - TopoDS::Face(shape2), - ((Handle(Geom_Line)&) ageom3)->Position(),val1,txt); + ais = new AIS_AngleDimension (TopoDS::Face(shape1), + TopoDS::Face(shape2), + ((Handle(Geom_Line)&) ageom3)->Position()); } } } @@ -1027,12 +1026,14 @@ void TPrsStd_ConstraintTools::ComputeAngle (const Handle(TDataXtd_Constraint)& a } ais->SetFirstShape(shape1); ais->SetSecondShape(shape2); - ais->SetValue(val1); - ais->SetText(txt); if (isplan) - ais->SetPlane ((Handle(Geom_Plane)&) ageom3); + ais->SetWorkingPlane (((Handle(Geom_Plane)&) ageom3)->Pln()); else if (!isCurvilinear) - ais->SetAxis (((Handle(Geom_Line)&) ageom3)->Position()); + { + gp_Pln aPlane; + aPlane.SetAxis (((Handle(Geom_Line)&) ageom3)->Position()); + ais->SetWorkingPlane (aPlane); + } } anAIS = ais; } @@ -1161,15 +1162,13 @@ void TPrsStd_ConstraintTools::ComputeRadius (const Handle(TDataXtd_Constraint)& if (!anAIS.IsNull()) { ais = Handle(AIS_RadiusDimension)::DownCast(anAIS); if (ais.IsNull()) { - ais = new AIS_RadiusDimension (shape1,val1,txt); + ais = new AIS_RadiusDimension (shape1); } else { - ais->SetValue(val1); ais->SetFirstShape(shape1); - ais->SetText(txt); } } - else ais = new AIS_RadiusDimension (shape1,val1,txt); + else ais = new AIS_RadiusDimension (shape1); if (isplanar) { Handle(Geom_Geometry) ageom2; @@ -1182,8 +1181,7 @@ void TPrsStd_ConstraintTools::ComputeRadius (const Handle(TDataXtd_Constraint)& NullifyAIS(anAIS); return; } - ais->SetPlane(aplane); - ais->SetDrawFromCenter(Standard_False); + ais->SetWorkingPlane(aplane->Pln()); } anAIS = ais; } @@ -1625,15 +1623,13 @@ void TPrsStd_ConstraintTools::ComputeDiameter(const Handle(TDataXtd_Constraint)& if (!anAIS.IsNull()) { ais = Handle(AIS_DiameterDimension)::DownCast(anAIS); if (ais.IsNull()) { - ais = new AIS_DiameterDimension (shape1,val1,txt); + ais = new AIS_DiameterDimension (shape1); } else { ais->SetFirstShape(shape1); - ais->SetValue(val1); - ais->SetText(txt); } } - else ais = new AIS_DiameterDimension (shape1,val1,txt); + else ais = new AIS_DiameterDimension (shape1); if (IsPlanar) { Handle(Geom_Geometry) ageom2; @@ -1646,7 +1642,7 @@ void TPrsStd_ConstraintTools::ComputeDiameter(const Handle(TDataXtd_Constraint)& NullifyAIS(anAIS); return; } - ais->SetPlane(aplane); + //ais->SetWorkingPlane(aplane); } anAIS = ais; } @@ -1767,29 +1763,31 @@ void TPrsStd_ConstraintTools::ComputeOffset (const Handle(TDataXtd_Constraint)& //Handle(AIS_Drawer) aDrawer; Standard_Boolean NotNull = Standard_False; - if (nbgeom == 1) { - + if (nbgeom == 1) + { ComputeTextAndValue (aConst,val1,txt,Standard_False); - - if (!anAIS.IsNull()) { + if (!anAIS.IsNull()) + { ais = Handle(AIS_LengthDimension)::DownCast(anAIS); NotNull = Standard_True; } - - if (S1.ShapeType() == TopAbs_FACE && S2.ShapeType() == TopAbs_FACE) { - if (ais.IsNull()) { - ais = new AIS_LengthDimension (TopoDS::Face(S1),TopoDS::Face(S2), - val1,txt); + + if (S1.ShapeType() == TopAbs_FACE && S2.ShapeType() == TopAbs_FACE) + { + if (ais.IsNull()) + { + ais = new AIS_LengthDimension (TopoDS::Face(S1),TopoDS::Face(S2)); } - else { - ais->SetFirstShape(S1); - ais->SetSecondShape(S2); - ais->SetValue(val1); - ais->SetText(txt); + else + { + ais->SetFirstShape(S1); + ais->SetSecondShape(S2); + ais->SetCustomValue(val1); } - if (is_planar) ais->SetPlane (aplane); - anAIS = ais; + if (is_planar) + ais->SetWorkingPlane (aplane->Pln()); + anAIS = ais; return; } else @@ -1817,14 +1815,14 @@ void TPrsStd_ConstraintTools::ComputeOffset (const Handle(TDataXtd_Constraint)& aplane = new Geom_Plane (NLin.Location(),NLin.Direction()^TDir); if (ais.IsNull()) { - ais = new AIS_LengthDimension (S1,S2,aplane,val1,txt); + ais = new AIS_LengthDimension (S1,S2,aplane->Pln()); } else { ais->SetFirstShape(S1); ais->SetSecondShape(S2); - ais->SetValue(val1); - ais->SetText(txt); - ais->SetPlane(aplane); + ais->SetCustomValue(val1); + + ais->SetWorkingPlane (aplane->Pln()); } anAIS = ais; return; @@ -1890,14 +1888,13 @@ void TPrsStd_ConstraintTools::ComputeOffset (const Handle(TDataXtd_Constraint)& if( !anAIS.IsNull() ) NotNull = Standard_True; ais = Handle(AIS_LengthDimension)::DownCast(anAIS); if (ais.IsNull()) { - ais = new AIS_LengthDimension (S1,S2,aplane,val1,txt); + ais = new AIS_LengthDimension (S1,S2,aplane->Pln()); } else { ais->SetFirstShape (S1); ais->SetSecondShape (S2); - ais->SetValue(val1); - ais->SetText(txt); - ais->SetPlane(aplane); + ais->SetCustomValue (val1); + ais->SetWorkingPlane (aplane->Pln ()); } anAIS = ais; return; @@ -2146,16 +2143,14 @@ void TPrsStd_ConstraintTools::ComputeRound(const Handle(TDataXtd_Constraint)& aC try { OCC_CATCH_SIGNALS if (anAIS.IsNull()) ais = - new AIS_RadiusDimension(shape1,val1,txt); + new AIS_RadiusDimension(shape1); else { ais = Handle(AIS_RadiusDimension)::DownCast(anAIS); if (ais.IsNull()) { - ais = new AIS_RadiusDimension(shape1,val1,txt); + ais = new AIS_RadiusDimension(shape1); } else { - ais->SetValue(val1); - ais->SetText(txt); - ais->SetFirstShape(shape1); + ais->SetFirstShape(shape1); } } } diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index af6b11261b..fe6aa739ef 100755 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ViewerTest/ViewerTest_RelationCommands.cxx b/src/ViewerTest/ViewerTest_RelationCommands.cxx index 78692caaaf..68172125ca 100755 --- a/src/ViewerTest/ViewerTest_RelationCommands.cxx +++ b/src/ViewerTest/ViewerTest_RelationCommands.cxx @@ -25,77 +25,70 @@ # include #endif +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include - - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include - -#include -#include -#include -#include -#include -#include #include #include #include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); extern int ViewerMainLoop(Standard_Integer argc, const char** argv); extern Handle(AIS_InteractiveContext)& TheAISContext (); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef HAVE_STRINGS_H # include #endif - - #define VertexMask 0x01 #define EdgeMask 0x02 #define FaceMask 0x04 - static Standard_Boolean ComputeIntersection(const gp_Lin& L,const gp_Pln& ThePl, gp_Pnt& TheInter) { static IntAna_Quadric TheQuad; @@ -116,7 +109,9 @@ static Standard_Boolean ComputeIntersection(const gp_Lin& L,const gp_Pln& ThePl, //purpose : calcul du point 3D correspondant a la position souris dans le plan de // la vue... //======================================================================= -static gp_Pnt Get3DPointAtMousePosition(){ + +static gp_Pnt Get3DPointAtMousePosition () +{ Handle(V3d_View) aview = ViewerTest::CurrentView(); static Select3D_Projector prj; prj.SetView(aview); @@ -138,15 +133,14 @@ static gp_Pnt Get3DPointAtMousePosition(){ return P; } - - //======================================================================= //function : ComputeNewPlaneForDim //purpose : //======================================================================= -static void ComputeNewPlaneForDim(const Handle(AIS_Relation)& R, - gp_Pln& , - gp_Pnt& ) + +static void ComputeNewPlaneForDim (const Handle(AIS_Relation)& R, + gp_Pln& , + gp_Pnt&) { // 0 COMPOUND, // 1 COMPSOLID, @@ -195,15 +189,244 @@ static void ComputeNewPlaneForDim(const Handle(AIS_Relation)& R, */ } +//======================================================================= +//function : VDimBuilder +//purpose : Command for updated dimenasions: angle, length, radius, diameter +//draw args : vdim -{angle|length|radius|diameter} -name={Dim_Name} +// shape1 [shape2 [shape3]] [-text={2d|3d} -plane={xoy|yoz|zox}] +//======================================================================= + +static int VDimBuilder(Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgs) +{ + if (theArgsNb < 2) + { + theDi << theArgs[0] << ": command argument is required. Type help for more information.\n"; + return 1; + } + + // Parse parameters + TCollection_AsciiString aDimType(theArgs[1]); + AIS_KindOfDimension aKindOfDimension; + if (aDimType == "-length") + { + aKindOfDimension = AIS_KOD_LENGTH; + } + else if (aDimType == "-angle") + { + aKindOfDimension = AIS_KOD_PLANEANGLE; + } + else if (aDimType == "-radius") + { + aKindOfDimension = AIS_KOD_RADIUS; + } + else if (aDimType == "-diameter" || aDimType == "-diam") + { + aKindOfDimension = AIS_KOD_DIAMETER; + } + else + { + theDi << theArgs[0] << ": wrong type of dimension. Type help for more information.\n"; + return 1; + } + NCollection_List aShapes; + Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect; + Standard_Boolean isPlaneCustom = Standard_False; + TCollection_AsciiString aName; + gp_Pln aWorkingPlane; + for (Standard_Integer anIt = 2; anIt < theArgsNb; ++anIt) + { + TCollection_AsciiString aParam (theArgs[anIt]); + if (aParam.Search("-text") == 1) + { + anAspect->MakeText3d(aParam.Search("3d") != -1 ? Standard_True : Standard_False); + } + else if (aParam.Search("-name") == 1) + { + Standard_Integer aParamNameEnd = aParam.FirstLocationInSet("=",1, aParam.Length()); + if (aParamNameEnd == 0) + { + theDi << theArgs[0] << ": no name for dimension.\n"; + return 1; + } + aName = aParam.Split(aParamNameEnd); + } + else if (aParam.Search("-plane") == 1) + { + isPlaneCustom = Standard_True; + if (aParam.Search("xoy") != -1) + aWorkingPlane = gp_Pln (gp_Ax3(gp::XOY())); + else if (aParam.Search("zox") != -1) + aWorkingPlane = gp_Pln (gp_Ax3(gp::ZOX())); + else if (aParam.Search("yoz") != -1) + aWorkingPlane = gp_Pln (gp_Ax3(gp::YOZ())); + else + { + theDi << theArgs[0] << ": wrong plane.\n"; + return 1; + } + } + else if (aParam.Search("-") != 1) // Shape + { + if (!GetMapOfAIS().IsBound2 (aParam)) + { + theDi << theArgs[0] << ": wrong name of shape. May be here is a wrong parameter.\n"; + return 1; + } + Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aParam)); + if (aShape.IsNull()) + return 1; + aShapes.Append (aShape); + } + } + + // Build dimension + Handle(AIS_Dimension) aDim; + switch (aKindOfDimension) + { + case AIS_KOD_LENGTH: + { + if (!isPlaneCustom) + { + theDi << theArgs[0] << ": can build dimension without working plane.\n"; + return 1; + } + if (aShapes.Extent() == 1) + { + if (aShapes.First()->Type() == AIS_KOI_Shape + && (Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape().ShapeType() != TopAbs_EDGE) + { + theDi << theArgs[0] << ": wrong shape type.\n"; + return 1; + } + aDim = new AIS_LengthDimension (TopoDS::Edge ((Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape()), aWorkingPlane); + } + else if (aShapes.Extent() == 2) + { + if (aShapes.First()->Type() == AIS_KOI_Shape && aShapes.Last()->Type() == AIS_KOI_Shape) + aDim = new AIS_LengthDimension ((Handle(AIS_Shape)::DownCast(aShapes.First ()))->Shape(), + (Handle(AIS_Shape)::DownCast(aShapes.Last ()))->Shape(), + aWorkingPlane); + else// AIS_Point + { + Handle(AIS_Point) aPoint1 = Handle(AIS_Point)::DownCast(aShapes.First ()); + Handle(AIS_Point) aPoint2 = Handle(AIS_Point)::DownCast(aShapes.Last ()); + aDim = new AIS_LengthDimension (aPoint1->Component()->Pnt(), + aPoint2->Component()->Pnt(), + aWorkingPlane); + } + } + else + { + theDi << theArgs[0] << ": wrong number of shapes to build dimension.\n"; + return 1; + } + } + break; + case AIS_KOD_PLANEANGLE: + { + if (aShapes.Extent() == 1 && aShapes.First()->Type()==AIS_KOI_Shape) + { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aShapes.First()); + if (aShape->Shape().ShapeType() == TopAbs_FACE) + aDim = new AIS_AngleDimension (TopoDS::Face(aShape->Shape())); + } + if (aShapes.Extent() == 2) + { + Handle(AIS_Shape) aShape1 = Handle(AIS_Shape)::DownCast(aShapes.First()); + Handle(AIS_Shape) aShape2 = Handle(AIS_Shape)::DownCast(aShapes.Last()); + if (!aShape1.IsNull() && !aShape2.IsNull() + && aShape1->Shape().ShapeType() == TopAbs_EDGE + && aShape2->Shape().ShapeType() == TopAbs_EDGE) + aDim = new AIS_AngleDimension (TopoDS::Edge(aShape1->Shape()),TopoDS::Edge(aShape2->Shape())); + else + { + theDi << theArgs[0] << ": wrong shapes for angle dimension.\n"; + return 1; + } + } + else if (aShapes.Extent() == 3) + { + gp_Pnt aP1, aP2, aP3; + Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast (aShapes.First()); + if (aPoint.IsNull()) + return 1; + aP1 = aPoint->Component()->Pnt(); + aShapes.RemoveFirst(); + aPoint = Handle(AIS_Point)::DownCast (aShapes.First()); + if (aPoint.IsNull()) + return 1; + aP2 = aPoint->Component()->Pnt(); + aShapes.RemoveFirst(); + aPoint = Handle(AIS_Point)::DownCast (aShapes.First()); + if (aPoint.IsNull()) + return 1; + aP3 = aPoint->Component()->Pnt(); + aDim = new AIS_AngleDimension (aP1, aP2, aP3); + } + else + { + theDi << theArgs[0] << ": wrong number of shapes to build dimension.\n"; + return 1; + } + } + break; + case AIS_KOD_RADIUS: // radius of the circle + { + if (aShapes.Extent() == 1) + { + Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First()); + gp_Circ aCircle = aShape->Circle()->Circ(); + aDim = new AIS_RadiusDimension (aCircle); + } + else + { + theDi << theArgs[0] << ": wrong number of shapes to build dimension.\n"; + return 1; + } + } + break; + case AIS_KOD_DIAMETER: + { + if (aShapes.Extent() == 1) + { + Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First()); + gp_Circ aCircle = aShape->Circle()->Circ(); + aDim = new AIS_DiameterDimension (aCircle); + } + else + { + theDi << theArgs[0] << ": wrong number of shapes to build dimension.\n"; + return 1; + } + } + break; + default: + { + theDi << theArgs[0] << ": wrong type of dimension. Type help for more information.\n"; + return 1; + } + } + aDim->SetDimensionAspect (anAspect); + if (GetMapOfAIS().IsBound2(aName)) + { + theDi << theArgs[0] << ": shape with name " << aName.ToCString ()<< " already exists. It will be replaced\n"; + Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName)); + TheAISContext()->Remove(anObj, Standard_False); + GetMapOfAIS().UnBind2(aName); + } + GetMapOfAIS().Bind (aDim,aName); + return 0; +} //======================================================================= //function : VAngleDimBuilder //purpose : //======================================================================= + static int VAngleDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { Standard_Integer myCurrentIndex; - if (argc!=2) {di<<" vangledim error."<<"\n";return 1;} TheAISContext()->CloseAllContexts(); TheAISContext()->OpenLocalContext(); @@ -258,7 +481,7 @@ static int VAngleDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const c TheAISContext()->CloseLocalContext(myCurrentIndex); // Construction de l'AIS dimension - Handle (AIS_AngleDimension) myAISDim= new AIS_AngleDimension (TopoDS::Edge(ShapeA) ,TopoDS::Edge(ShapeB) ,theGeomPlane ,M_PI/2.0 ,TheMessage_Str ); + Handle (AIS_AngleDimension) myAISDim= new AIS_AngleDimension (TopoDS::Edge(ShapeA) ,TopoDS::Edge(ShapeB) ,theGeomPlane->Pln()); GetMapOfAIS().Bind (myAISDim,argv[1]); TheAISContext()->Display(myAISDim ); @@ -276,11 +499,6 @@ else { //purpose : Display the diameter dimension of a face or an edge. //Draw arg : vdiameterdim Name //============================================================================== -#include -#include -#include -#include - static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { @@ -326,7 +544,7 @@ static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, cons // Construction de L'AIS_AngleDimension. TheAISContext()->CloseLocalContext(myCurrentIndex); - Handle (AIS_DiameterDimension) myDiamDim= new AIS_DiameterDimension(ShapeA ,theRadius ,TheMessage_Str ); + Handle (AIS_DiameterDimension) myDiamDim= new AIS_DiameterDimension(ShapeA); GetMapOfAIS().Bind (myDiamDim,argv[1]); TheAISContext()->Display(myDiamDim ); @@ -977,7 +1195,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TheAISContext()->CloseLocalContext(myCurrentIndex); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,EdgeB,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,EdgeB,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); } @@ -1003,7 +1221,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); TheAISContext()->CloseLocalContext(myCurrentIndex); - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,VertexB,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,VertexB,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1011,28 +1229,20 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c } // Si ShapeB est une Face - else { - + else + { TopoDS_Face FaceB=TopoDS::Face(ShapeB); BRepExtrema_ExtCF myDeltaEdgeFace (EdgeA,FaceB ); // On verifie que l'edge est bien parallele a la face. if (!myDeltaEdgeFace.IsParallel() ) {di<<"vdistdim error: the edge isn't parallel to the face;can't compute the distance. "<<"\n";return 1; } - - // On saisit la distance et on l'arrondit! - theDist=Round (sqrt (myDeltaEdgeFace.SquareDistance(1))*10. )/10.; - - // Construction du texte. - TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); - + // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceB,EdgeA,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceB,EdgeA); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); - } - } - + // ShapeA est un vertex // ==================== if (ShapeA.ShapeType()==TopAbs_VERTEX ) { @@ -1062,7 +1272,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeB,VertexA,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeB,VertexA,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1089,7 +1299,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexB,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexB,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1137,7 +1347,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexAproj,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexAproj,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1165,7 +1375,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,EdgeB,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,EdgeB); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1210,7 +1420,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension mais en utilisant le constructeur Vertex Vertex. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexB,VertexBproj,theGeomPlane,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexB,VertexBproj,theGeomPlane->Pln()); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1232,7 +1442,7 @@ static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const c TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) ); // on construit l'AISLenghtDimension. - Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,FaceB,theDist,TheMessage_Str ); + Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,FaceB); TheAISContext()->Display(myLenghtDim ); GetMapOfAIS().Bind (myLenghtDim ,argv[1]); @@ -1312,7 +1522,7 @@ static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const TheAISContext()->CloseLocalContext(myCurrentIndex); // Construction de L'AIS_RadiusDimension. - Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA ,theRadius ,TheMessage_Str ); + Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA); GetMapOfAIS().Bind (myRadDim,argv[1]); TheAISContext()->Display(myRadDim ); @@ -1345,8 +1555,7 @@ static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const TheAISContext()->CloseLocalContext(myCurrentIndex); // Construction de L'AIS_RadiusDimension. - Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA ,theRadius ,TheMessage_Str ); - //Handle (AIS_MinRadiusDimension) myRadDim= new AIS_MinRadiusDimension(EdgeFromA ,theRadius ,TheMessage_Str ); + Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA); GetMapOfAIS().Bind (myRadDim,argv[1]); TheAISContext()->Display(myRadDim ); @@ -2154,6 +2363,7 @@ static int VMoveDim(Draw_Interpretor& di, Standard_Integer argc, const char** ar return 0; } + //======================================================================= //function : RelationsCommands //purpose : @@ -2164,7 +2374,13 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands) { const char *group = "AISRelations"; - + theCommands.Add("vdim", + "vdim -{angle|length|radius|diameter} -name={Dim_Name}" + " shape1 [shape2 [shape3]] [-text={2d|3d} -plane={xoy|yoz|zox}]" + " -Build a angle, length, radius and diameter dimensions;" + " -Workis only with interactive objects", + __FILE__,VDimBuilder,group); + theCommands.Add("vangledim", "vangledim Name:Selection in the viewer only ", __FILE__,VAngleDimBuilder,group); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index e32241fe0e..c466b68559 100755 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -3606,7 +3606,7 @@ static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char di << " height - pixel height of the text (default=10.0)\n"; di << " font_name - name of font (default=courier)\n"; di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n"; - di << " display_type = {normal/subtitle/decal/blend}, (default=normal)\n"; + di << " display_type = {normal/subtitle/decal/blend/dimension}, (default=normal)\n"; di << " background_color- R G B values used for subtitle and decal text\n"; di << "(default=255.0 255.0 255.0)\n"; return 1; @@ -3645,6 +3645,8 @@ static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char aTextType = Aspect_TODT_DEKALE; else if (aDispStr.IsEqual ("blend")) aTextType = Aspect_TODT_BLEND; + else if (aDispStr.IsEqual ("dimension")) + aTextType = Aspect_TODT_DIMENSION; // subtitle color Quantity_Parameter aSubRed = 1.0; diff --git a/src/XCAFPrs/XCAFPrs_AISObject.cxx b/src/XCAFPrs/XCAFPrs_AISObject.cxx index 69ed2045c0..048d5c9a4a 100755 --- a/src/XCAFPrs/XCAFPrs_AISObject.cxx +++ b/src/XCAFPrs/XCAFPrs_AISObject.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -464,7 +464,7 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr //cout << "Now display name of shapes" << endl; #endif aPrs->SetDisplayPriority(10); - DisplayText (myLabel, aPrs, Attributes()->LengthAspect()->TextAspect(), TopLoc_Location());//no location + DisplayText (myLabel, aPrs, Attributes()->DimensionAspect()->TextAspect(), TopLoc_Location());//no location } #ifdef DEB //cout << "Compute finished" << endl; diff --git a/src/Xw/Xw_Window.cxx b/src/Xw/Xw_Window.cxx index a3c0801b2d..7233d9df71 100644 --- a/src/Xw/Xw_Window.cxx +++ b/src/Xw/Xw_Window.cxx @@ -29,11 +29,13 @@ namespace { - //! Search for RGBA double-buffered visual + //! Search for RGBA double-buffered visual with stencil buffer. + //! Each size property should be a nonnegative minimum specification. static int TheDoubleBuff[] = { GLX_RGBA, GLX_DEPTH_SIZE, 16, + GLX_STENCIL_SIZE, 1, GLX_DOUBLEBUFFER, None }; diff --git a/tests/bugs/vis/buc60632_1 b/tests/bugs/vis/buc60632_1 index d787ba1c36..0016b34d4d 100755 --- a/tests/bugs/vis/buc60632_1 +++ b/tests/bugs/vis/buc60632_1 @@ -14,18 +14,17 @@ puts "================" vinit BUC60632 0 100 vfit -vmoveto 313 254 +vmoveto 126 143 puts "Highlighting by 'Move To' command in wireframe mode" -set x_coord 315 -set y_coord 256 +set x_coord 129 +set y_coord 143 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { puts "Error : Highlighting by Move To command in wireframe mode is WRONG." } - set only_screen 1 diff --git a/tests/bugs/vis/buc60632_2 b/tests/bugs/vis/buc60632_2 index a31a9af828..606d90c313 100755 --- a/tests/bugs/vis/buc60632_2 +++ b/tests/bugs/vis/buc60632_2 @@ -14,11 +14,11 @@ puts "================" vinit BUC60632 1 100 vfit -vmoveto 313 254 +vmoveto 126 143 puts "Highlighting by 'Move To' command in shading mode" -set x_coord 315 -set y_coord 256 +set x_coord 128 +set y_coord 143 checkcolor $x_coord $y_coord 0 1 1 diff --git a/tests/bugs/vis/bug24133_1 b/tests/bugs/vis/bug24133_1 new file mode 100644 index 0000000000..3c7509aa61 --- /dev/null +++ b/tests/bugs/vis/bug24133_1 @@ -0,0 +1,26 @@ +puts "============" +puts "CR24133" +puts "============" +puts "" +####################################################################### +# Development of improvement of dimensions implementation +# Length dimension +####################################################################### +pload VISUALIZATION + +vinit +vpoint lengthP1 0 0 0 +vpoint lengthP2 50 50 50 +vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2 +vdisplay dim1 +vfit +vmoveto 82 268 + +set x_coord 337 +set y_coord 130 +checkcolor $x_coord $y_coord 0 1 1 +if { $stat != 1 } { + puts "Error : Highlighting of length dimension is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug24133_2 b/tests/bugs/vis/bug24133_2 new file mode 100644 index 0000000000..3242426bbd --- /dev/null +++ b/tests/bugs/vis/bug24133_2 @@ -0,0 +1,43 @@ +puts "============" +puts "CR24133" +puts "============" +puts "" +####################################################################### +# Development of improvement of dimensions implementation +# Angle dimension +####################################################################### +pload VISUALIZATION + +vinit +vpoint angleP1 0 0 0 +vpoint angleP2 50 50 50 +vpoint angleP3 50 50 100 +vdim -angle -name=dim1 angleP1 angleP2 angleP3 +vdisplay dim1 +vfit +vmoveto 249 206 + +set x_coord 249 +set y_coord 200 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of angle dimension with 2d text is wrong." +} +verase dim1 +vdim -angle -name=dim2 -text=3d angleP1 angleP2 angleP3 +vdisplay dim2 +vfit +vmoveto 263 251 + +set x_coord 332 +set y_coord 326 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of angle dimension with 3d text is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug24133_3 b/tests/bugs/vis/bug24133_3 new file mode 100644 index 0000000000..2b9d57cf13 --- /dev/null +++ b/tests/bugs/vis/bug24133_3 @@ -0,0 +1,46 @@ +puts "============" +puts "CR24133" +puts "============" +puts "" +####################################################################### +# Development of improvement of dimensions implementation +# Radius dimension +####################################################################### +pload VISUALIZATION + +vinit +vpoint radP1 0 0 0 +vpoint radP2 50 50 0 +vpoint radP3 100 0 0 +vcircle circle radP1 radP2 radP3 0 +verase radP1 radP2 radP3 +vdim -radius -name=dim3 circle +vdisplay dim3 +vfit +vmoveto 102 144 + +set x_coord 172 +set y_coord 186 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 2d text is wrong." +} + +verase dim3 +vdim -radius -name=dim3 -text=3d circle +vdisplay dim3 +vfit +vmoveto 102 144 + +set x_coord 172 +set y_coord 186 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of radius dimension with 3d text is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug24133_4 b/tests/bugs/vis/bug24133_4 new file mode 100644 index 0000000000..edb7bd7918 --- /dev/null +++ b/tests/bugs/vis/bug24133_4 @@ -0,0 +1,46 @@ +puts "============" +puts "CR24133" +puts "============" +puts "" +####################################################################### +# Development of improvement of dimensions implementation +# Diameter dimension +####################################################################### +pload VISUALIZATION + +vinit +vpoint diamP1 0 0 0 +vpoint diamP2 50 50 0 +vpoint diamP3 100 0 0 +vcircle circle diamP1 diamP2 diamP3 0 +verase diamP1 diamP2 diamP3 +vdim -diam -name=dim4 circle +vdisplay dim4 +vfit +vmoveto 208 205 + +set x_coord 296 +set y_coord 257 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of diameter dimension with 2d text is wrong." +} + +verase dim4 +vdim -diam -name=dim4 -text=3d circle +vdisplay dim4 +vfit +vmoveto 208 205 + +set x_coord 296 +set y_coord 257 + +checkcolor $x_coord $y_coord 0 1 1 + +if { $stat != 1 } { + puts "Error : Highlighting of diameter dimension with 3d text is wrong." +} + +set only_screen 1 diff --git a/tests/bugs/vis/bug301 b/tests/bugs/vis/bug301 index 81921a068e..e89f6abfb4 100644 --- a/tests/bugs/vis/bug301 +++ b/tests/bugs/vis/bug301 @@ -5,8 +5,8 @@ puts "========" puts "" vinit -OCC301 50 50 0 5 -OCC301 50 30 0 3 +OCC301 50 5 +OCC301 30 3 vtop vfit puts "Angle dimensions have different arrow sizes"