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)
BUTTON ID_OBJECT_DISPLAYALL
SEPARATOR
BUTTON ID_OBJECT_REMOVE
+ BUTTON ID_OBJECT_DIM
END
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
END
MENUITEM "Transparency...", ID_OBJECT_TRANSPARENCY
END
+ POPUP "User cylinder"
+ BEGIN
+ MENUITEM "Change face color", ID_USERCYLINDER_CHANGEFACECOLOR
+ END
END
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
/////////////////////////////////////////////////////////////////////////////
// CViewer3dDoc construction/destruction
CViewer3dDoc::CViewer3dDoc()
+:OCC_3dDoc()
{
myCylinder.Nullify();
mySphere.Nullify();
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);
}
-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
--- /dev/null
+// AngleParamsVerticesPage.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "AngleParamsVerticesPage.h"
+#include "DimensionDlg.h"
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_AngleDimension.hxx>
+#include <BRep_Tool.hxx>
+#include <GC_MakePlane.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+
+// 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);
+}
--- /dev/null
+#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();
+};
--- /dev/null
+// 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 <Standard_Macro.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <AIS_LocalContext.hxx>
+#include <Quantity_Color.hxx>
+
+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 <Length> 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 <Angle> 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 <Diameter> 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 <Radius> 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;
+}
--- /dev/null
+#pragma once
+
+// DimensionDlg dialog
+
+#include <stdafx.h>
+
+#include "res\OCC_Resource.h"
+#include <Standard_Macro.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <Quantity_Color.hxx>
+
+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();
+};
--- /dev/null
+// LengthParamsEdgePage.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "LengthParamsEdgePage.h"
+#include "DimensionDlg.h"
+
+#include <Standard_Macro.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <GC_MakePlane.hxx>
+#include <TopExp.hxx>
+
+// 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);
+}
--- /dev/null
+#pragma once
+
+#include "res\OCC_Resource.h"
+#include <Standard_Macro.hxx>
+#include <AIS_InteractiveContext.hxx>
+
+// 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();
+};
--- /dev/null
+// LenghtParamsEdgesPage.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "LengthParamsEdgesPage.h"
+#include "DimensionDlg.h"
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_AngleDimension.hxx>
+#include <GC_MakePlane.hxx>
+// 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);
+}
--- /dev/null
+#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();
+};
--- /dev/null
+// LengthParamsVerticesPage.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "LengthParamsVerticesPage.h"
+#include "DimensionDlg.h"
+#include <Standard_Macro.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <GC_MakePlane.hxx>
+
+
+// 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;
+}
--- /dev/null
+#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();
+};
#include <res\OCC_Resource.h>
#include "ImportExport/ImportExport.h"
#include "AISDialogs.h"
+#include <AIS_LocalContext.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
BEGIN_MESSAGE_MAP(OCC_3dBaseDoc, OCC_BaseDoc)
//{{AFX_MSG_MAP(OCC_3dBaseDoc)
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)
//////////////////////////////////////////////////////////////////////
OCC_3dBaseDoc::OCC_3dBaseDoc()
+:myPopupMenuNumber(0),
+ myDimensionDlg()
{
AfxInitRichEdit();
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myAISContext = new AIS_InteractiveContext (myViewer);
+ myDimensionDlg.SetContext (myAISContext);
+ myDimensionDlg.Create(CDimensionDlg::IDD, NULL);
}
//-----------------------------------------------------------------------------------------
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 ())
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()
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)
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());
+}
+
+
#endif // _MSC_VER > 1000
#include "OCC_BaseDoc.h"
+#include "DimensionDlg.h"
#include <Standard_Macro.hxx>
class AFX_EXT_CLASS OCC_3dBaseDoc : public OCC_BaseDoc
{
+protected:
+ CDimensionDlg myDimensionDlg;
+ int myPopupMenuNumber;
public:
OCC_3dBaseDoc();
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()
};
--- /dev/null
+
+#include "stdafx.h"
+#include "RadiusParamsPage.h"
+#include "DimensionDlg.h"
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
+#include <AIS_RadiusDimension.hxx>
+#include <AIS_DiameterDimension.hxx>
+#include <ElCLib.hxx>
+#include <TopoDS_Shape.hxx>
+
+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);
+}
--- /dev/null
+#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();
+};
// 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
#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
#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
//
#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
// 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"
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
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
+
/////////////////////////////////////////////////////////////////////////////
//
BUTTON ID_OBJECT_DISPLAYALL
SEPARATOR
BUTTON ID_OBJECT_REMOVE
+ BUTTON ID_OBJECT_DIM
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
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
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
/////////////////////////////////////////////////////////////////////////////
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\AngleParamsVerticesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\DimensionDlg.cpp" />
<ClCompile Include="..\..\..\..\Common\ImportExport\ImportExport.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgePage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\LengthParamsVerticesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\RadiusParamsPage.cpp" />
<ClCompile Include="..\..\..\src\mfcsample.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\Common\AISDialogs.h" />
+ <ClInclude Include="..\..\..\..\Common\AngleParamsVerticesPage.h" />
+ <ClInclude Include="..\..\..\..\Common\DimensionDlg.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\ImportExport.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgePage.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgesPage.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsVerticesPage.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dChildFrame.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dDoc.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dView.h" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseDoc.h" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseView.h" />
<ClInclude Include="..\..\..\..\Common\OCC_MainFrame.h" />
+ <ClInclude Include="..\..\..\..\Common\RadiusParamsPage.h" />
<ClInclude Include="..\..\..\..\Common\res\OCC_Resource.h" />
<ClInclude Include="..\..\..\..\Common\ResultDialog.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.h" />
<ClCompile Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.cpp">
<Filter>Source Files\ISession2D-src</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\DimensionDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\AngleParamsVerticesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgePage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsVerticesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\RadiusParamsPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\Common\res\OCC_Resource.rc">
<ClInclude Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.h">
<Filter>Header Files\ISession2D-headers</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\Common\DimensionDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\AngleParamsVerticesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgePage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsVerticesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\RadiusParamsPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\Common\res\2dChildFrameTB.bmp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\AngleParamsVerticesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\DimensionDlg.cpp" />
<ClCompile Include="..\..\..\..\Common\ImportExport\ImportExport.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgePage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\LengthParamsVerticesPage.cpp" />
+ <ClCompile Include="..\..\..\..\Common\RadiusParamsPage.cpp" />
<ClCompile Include="..\..\..\src\mfcsample.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\Common\AISDialogs.h" />
+ <ClInclude Include="..\..\..\..\Common\AngleParamsVerticesPage.h" />
+ <ClInclude Include="..\..\..\..\Common\DimensionDlg.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\ImportExport.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgePage.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgesPage.h" />
+ <ClInclude Include="..\..\..\..\Common\LengthParamsVerticesPage.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dChildFrame.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dDoc.h" />
<ClInclude Include="..\..\..\..\Common\OCC_2dView.h" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseDoc.h" />
<ClInclude Include="..\..\..\..\Common\OCC_BaseView.h" />
<ClInclude Include="..\..\..\..\Common\OCC_MainFrame.h" />
+ <ClInclude Include="..\..\..\..\Common\RadiusParamsPage.h" />
<ClInclude Include="..\..\..\..\Common\res\OCC_Resource.h" />
<ClInclude Include="..\..\..\..\Common\ResultDialog.h" />
<ClInclude Include="..\..\..\..\Common\ImportExport\SaveCSFDBDlg.h" />
<ClCompile Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.cpp">
<Filter>Source Files\ISession2D-src</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\Common\DimensionDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\AngleParamsVerticesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgePage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsEdgesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\LengthParamsVerticesPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\Common\RadiusParamsPage.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\Common\res\OCC_Resource.rc">
<ClInclude Include="..\..\..\..\Common\ISession2D\ISession2D_Shape.h">
<Filter>Header Files\ISession2D-headers</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\Common\DimensionDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\AngleParamsVerticesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgePage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsEdgesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\LengthParamsVerticesPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\Common\RadiusParamsPage.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\..\Common\res\2dChildFrameTB.bmp">
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\AngleParamsVerticesPage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\DimensionDlg.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ImportExport\ImportExport.cpp"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgePage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgesPage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsVerticesPage.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\src\mfcsample.cpp"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ResultDialog.cpp"
>
RelativePath="..\..\..\..\Common\AISDialogs.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\AngleParamsVerticesPage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\DimensionDlg.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ImportExport\ImportExport.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgePage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgesPage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsVerticesPage.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\OCC_2dChildFrame.h"
>
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ResultDialog.h"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\AngleParamsVerticesPage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\DimensionDlg.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ImportExport\ImportExport.cpp"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgePage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgesPage.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsVerticesPage.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\src\mfcsample.cpp"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\RadiusParamsPage.cpp"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ResultDialog.cpp"
>
RelativePath="..\..\..\..\Common\AISDialogs.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\AngleParamsVerticesPage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\DimensionDlg.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ImportExport\ImportExport.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgePage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsEdgesPage.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\Common\LengthParamsVerticesPage.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\OCC_2dChildFrame.h"
>
RelativePath="..\..\..\..\Common\res\OCC_Resource.h"
>
</File>
+ <File
+ RelativePath="..\..\..\..\Common\RadiusParamsPage.h"
+ >
+ </File>
<File
RelativePath="..\..\..\..\Common\ResultDialog.h"
>
-- 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,
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,
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;
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;
//=======================================================================
//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, <WhatProj> = 0
//
// indexExt = 0 2 edges are in the current wp
// 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();
+++ /dev/null
--- 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 <aProjector>.
- -- This method should be used when the associated degenerated Presentations
- -- have been transformed by <aTrsf> which is not a Pure
- -- Translation. The HLR Prs can't be deducted automatically
- -- WARNING :<aTrsf> 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;
// 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 <Standard_NotImplemented.hxx>
-
-#include <AIS_AngleDimension.ixx>
+#include <AIS_AngleDimension.hxx>
#include <AIS.hxx>
+#include <AIS_Dimension.hxx>
#include <AIS_DimensionOwner.hxx>
#include <AIS_Drawer.hxx>
-
+#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
-#include <BRep_Tool.hxx>
+#include <BRepLib_MakeVertex.hxx>
#include <DsgPrs.hxx>
#include <DsgPrs_AnglePresentation.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
+#include <GC_MakeCircle.hxx>
+#include <GC_MakeConicalSurface.hxx>
+#include <gce_MakeLin.hxx>
+#include <gce_MakeLin2d.hxx>
+#include <gce_MakePln.hxx>
+#include <gce_MakeCirc.hxx>
+#include <gce_MakeCone.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
+#include <Geom2dAPI_ExtremaCurveCurve.hxx>
#include <GeomAPI.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_OffsetSurface.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <gp.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Cone.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec.hxx>
+#include <gp_XYZ.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
#include <IntAna2d_AnaIntersection.hxx>
#include <IntAna2d_IntPoint.hxx>
#include <IntAna_QuadQuadGeo.hxx>
#include <IntAna_ResultType.hxx>
-
+#include <Poly_Polygon3D.hxx>
#include <Precision.hxx>
-
#include <ProjLib.hxx>
-
-#include <Prs3d_AngleAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Drawer.hxx>
-
+#include <Prs3d_Root.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_DefineHandle.hxx>
#include <TColStd_Array1OfReal.hxx>
-
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
-
#include <UnitsAPI.hxx>
-#include <gp.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Cone.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Vec.hxx>
-#include <gp_XYZ.hxx>
-
-#include <GC_MakeCircle.hxx>
-#include <GC_MakeConicalSurface.hxx>
-#include <gce_MakePln.hxx>
-#include <gce_MakeCone.hxx>
-
+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
+// <thePlane> 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
+// <thePlane> 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 <theC> center is above of <theCMin> center;
+// 0 if <theC> center is between <theCMin> and
+// <theCMax> centers;
+// -1 if <theC> center is below <theCMax> 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 <aFirst> on <aLin>
+ gp_Pnt aFirst2 = ElCLib::Value (ElCLib::Parameter (aLin, aFirst1), aLin);
+ // Projection <aLast> on <aLin>
+ 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 <myWorkingPlane>
+ 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
+// <myIsInitialized> 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)<M_PI) {
- // test if uco is in the opposite sector
- if (uco > 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)<M_PI) {
- // test if uco is in the opposing sector
- if (uco > 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)<M_PI) {
- // test if uco is in the opposing sector
- if (uco > 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);
}
--- /dev/null
+// 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. <br>
+//! These displays are particularly useful in viewing draft prisms. <br>
+//! The angle displayed may define an intersection <br>
+//! can be between two edges or two faces of a shape <br>
+//! or a plane. The display consists of arrows and text. <br>
+
+#ifndef _AIS_AngleDimension_HeaderFile
+#define _AIS_AngleDimension_HeaderFile
+
+#include <AIS_Dimension.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Transformation.hxx>
+#include <gp.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Projector.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+
+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 <br>
+ //! 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 <ResetWorkingPlane ()> 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 <br>
+ //! 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 <theC> center is above of <theCMin> center;
+ //! 0 if <theC> center is between <theCMin> and <theCMax> centers;
+ //! -1 if <theC> center is below <theCMax> 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 <myFlyout> value.
+ //! The direction vector is counting using the working plane.
+ //! <myFlyout> value defined the size of flyout (radius of angle).
+ Standard_Real myFlyout;
+};
+
+#endif
+++ /dev/null
-// 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;
-}
#include <DsgPrs_Chamf2dPresentation.hxx>
#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
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
#include <DsgPrs_Chamf2dPresentation.hxx>
#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
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
+++ /dev/null
--- 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
--- <odl@sacadox.paris1.matra-dtv.fr>,
-
-
-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 <aProjector>.
- -- To be Used when the associated degenerated Presentations
- -- have been transformed by <aTrsf> which is not a Pure
- -- Translation. The HLR Prs can't be deducted automatically
- -- WARNING :<aTrsf> 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;
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
+#include <AIS_DiameterDimension.hxx>
-#include <Standard_NotImplemented.hxx>
-
-#include <AIS_DiameterDimension.ixx>
+#include <Adaptor3d_HCurve.hxx>
+#include <AIS.hxx>
+#include <AIS_Drawer.hxx>
#include <AIS_DimensionOwner.hxx>
#include <DsgPrs_DiameterPresentation.hxx>
#include <DsgPrs_RadiusPresentation.hxx>
-
-#include <TCollection_ExtendedString.hxx>
-
-#include <Prs3d_LengthAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_Text.hxx>
-
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
#include <ElCLib.hxx>
#include <ElSLib.hxx>
-
-#include <TopoDS.hxx>
-
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <Adaptor3d_HCurve.hxx>
-
-#include <Geom_Circle.hxx>
-#include <Geom_TrimmedCurve.hxx>
+#include <GC_MakeCircle.hxx>
+#include <gce_MakeDir.hxx>
#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
-
-#include <AIS.hxx>
-#include <AIS_Drawer.hxx>
-
-#include <GC_MakeCircle.hxx>
-
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Group.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_Text.hxx>
+#include <Prs3d_Root.hxx>
#include <Precision.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard_Macro.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TCollection_ExtendedString.hxx>
-#include <TopExp_Explorer.hxx>
+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);
}
//=======================================================================
//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"<<endl;
-
- gp_Pln aPln;
- Handle( Geom_Surface ) aBasisSurf;
- AIS_KindOfSurface aSurfType = AIS_KOS_OtherSurface;
- Standard_Real Offset;
- if( myAutomaticPosition )
- AIS::GetPlaneFromFace( TopoDS::Face( myFShape),
- aPln,
- aBasisSurf,
- aSurfType,
- Offset ) ;
-
- if ( aSurfType == AIS_KOS_Plane )
- ComputeOnePlanarFaceDiameter( aPresentation );
- else
- ComputeOneCylFaceDiameter( aPresentation, aSurfType, aBasisSurf );
-
+ myValue = myFirstPoint.Distance (mySecondPoint);
+ AIS_Dimension::computeValue();
}
-
//=======================================================================
-//function : ComputeOneCylFaceDiameter
+//function : countDefaultPlane
//purpose :
//=======================================================================
-void AIS_DiameterDimension::ComputeOneCylFaceDiameter
- (const Handle(Prs3d_Presentation)& aPresentation,
- const AIS_KindOfSurface aSurfType,
- const Handle( Geom_Surface )& aBasisSurf )
+void AIS_DiameterDimension::countDefaultPlane ()
{
- gp_Pnt curPos;
- if( myAutomaticPosition )
- {
- BRepAdaptor_Surface surf1(TopoDS::Face(myFShape));
- Standard_Real uFirst, uLast, vFirst, vLast;
- uFirst = surf1.FirstUParameter();
- uLast = surf1.LastUParameter();
- vFirst = surf1.FirstVParameter();
- vLast = surf1.LastVParameter();
- Standard_Real uMid = (uFirst + uLast)*0.5;
- Standard_Real vMid = (vFirst + vLast)*0.5;
- surf1.D0(uMid, vMid, curPos);
- Handle( Adaptor3d_HCurve ) BasisCurve;
- //Standard_Real Param;
- Standard_Boolean ExpectedType = Standard_False;
- if (aSurfType == AIS_KOS_Cylinder)
- {
- ExpectedType = Standard_True;
- }
- else
- if (aSurfType == AIS_KOS_Revolution)
- {
- BasisCurve = surf1.BasisCurve();
- if (BasisCurve->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"<<endl;
- if( myIsAnArc )
- DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
- myCircle, myFirstPar, myLastPar, mySymbolPrs, myDiamSymbol);
- else
- DsgPrs_DiameterPresentation::Add(aPresentation, myDrawer, myText, myPosition,
- myCircle, DsgPrs_AS_BOTHAR, myDiamSymbol);
-
-
+ // Compute normal of the default plane.
+ //gp_Vec aVec1(mySecondPoint, myFirstPoint),
+ // aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle));
+ myDefaultPlane = gp_Pln(gp_Ax3(myCircle.Position()));
+ // Set computed value to <myWorkingPlane>
+ 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;
}
-
--- /dev/null
+// 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 <AIS.hxx>
+#include <AIS_Dimension.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Circ.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_DefineHandle.hxx>
+
+DEFINE_STANDARD_HANDLE(AIS_DiameterDimension,AIS_Dimension)
+
+//! A framework to display diameter dimensions. <br>
+//! A diameter is displayed with arrows and text. The <br>
+//! text gives the length of the diameter. <br>
+//! The algorithm takes a length along a face and <br>
+//! analyzes it as an arc. It then reconstructs the circle <br>
+//! corresponding to the arc and calculates the <br>
+//! diameter of this circle. This diameter serves as a <br>
+//! relational reference in 3d presentations of the surface. <br>
+class AIS_DiameterDimension : public AIS_Dimension
+{
+public:
+ //! Constructs a diameter display object defined by the <br>
+ //! circle <theCircle>
+ Standard_EXPORT AIS_DiameterDimension(const gp_Circ& theCircle);
+ //! Consctructor that allows to set a attach point <br>
+ //! on the circle <theCircle> 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 <myFlyout> value.
+ //! The direction vector is counting using the working plane.
+ //! <myFlyout> value defined the size of flyout.
+ Standard_Real myFlyout;
+ gp_Circ myCircle;
+};
+#endif
+++ /dev/null
-// 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
-// <jpr> <szy>
-
-//=======================================================================
-//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;
-}
--- /dev/null
+// 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 <AIS.hxx>
+#include <AIS_Dimension.hxx>
+#include <AIS_DimensionDisplayMode.hxx>
+#include <AIS_DimensionOwner.hxx>
+#include <AIS_Drawer.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepBndLib.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <ElCLib.hxx>
+#include <Font_BRepFont.hxx>
+#include <GC_MakeCircle.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <gce_MakeDir.hxx>
+#include <gce_MakeLin.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_Text.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <Select3D_ListIteratorOfListOfSensitive.hxx>
+#include <Select3D_ListOfSensitive.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <Select3D_SensitiveCircle.hxx>
+#include <Select3D_SensitiveGroup.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+#include <Standard_CString.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <Units.hxx>
+#include <Units_UnitsDictionary.hxx>
+#include <UnitsAPI.hxx>
+#include <UnitsAPI_SystemUnits.hxx>
+
+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 <theMode> 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 <theMiddleArcPoint> and <theOppositeDiameterPoint> values from <theCircle>
+ 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);
+}
--- /dev/null
+// 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 <AIS_DimensionDisplayMode.hxx>
+#include <AIS_DisplaySpecialSymbol.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_KindOfInteractive.hxx>
+#include <AIS_KindOfDimension.hxx>
+#include <AIS_KindOfSurface.hxx>
+#include <Bnd_Box.hxx>
+#include <Geom_Curve.hxx>
+#include <gp_Pln.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_VerticalTextAlignment.hxx>
+#include <Select3D_ListOfSensitive.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+
+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 <myValue>.
+ 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 </br>
+ //! 3d text is oriented relative to the attachment points order </br>
+ //! By default, text direction vector is oriented from the first attachment point </br>
+ //! to the second one. This method checks if text direction is to be default or </br>
+ //! should be reversed.
+ Standard_EXPORT Standard_Boolean IsTextReversed() const;
+ //! Important! Only for 3d text
+ //! 3d text is oriented relative to the attachment points order </br>
+ //! By default, text direction vector is oriented from the first attachment point </br>
+ //! to the second one. This method sets value that shows if text direction </br>
+ //! 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 <myDefaultPlane> 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
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;
-
#include <AIS_DimensionOwner.ixx>
+#include <AIS_DimensionDisplayMode.hxx>
+#include <StdSelect_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
-//-----------------------------------------------------------------------
-// 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);
+}
+++ /dev/null
-// 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;
-}
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,
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
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;}
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;
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; }
{
return (myTypeOfHLR == Prs3d_TOH_NotSet) ? myLink->TypeOfHLR() : myTypeOfHLR;
}
+
+inline Standard_Boolean AIS_Drawer::HasDimensionAspect () const
+{ return !myDimensionAspect.IsNull();}
#include <BRep_Tool.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
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 ){
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)
}
- 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)
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)
#include <Select3D_SensitiveBox.hxx>
#include <Precision.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <AIS_Drawer.hxx>
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 --
#include <Prs3d_LineAspect.hxx>
#include <Aspect_AspectLine.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Prs3d_AngleAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
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();
+++ /dev/null
--- 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 <aProjector>.
- -- To be Used when the associated degenerated Presentations
- -- have been transformed by <aTrsf> which is not a Pure
- -- Translation. The HLR Prs can't be deducted automatically
- -- WARNING :<aTrsf> 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;
// 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
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
-#include <Standard_NotImplemented.hxx>
-#include <AIS_LengthDimension.ixx>
+
+#include <AIS_LengthDimension.hxx>
#include <AIS.hxx>
#include <AIS_DimensionOwner.hxx>
#include <AIS_Drawer.hxx>
-
+#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
-#include <BRep_Tool.hxx>
-
+#include <BRepGProp_Face.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
#include <DsgPrs.hxx>
#include <DsgPrs_LengthPresentation.hxx>
-
#include <ElCLib.hxx>
#include <ElSLib.hxx>
-
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_OffsetSurface.hxx>
-
+#include <gce_MakeDir.hxx>
+#include <gce_MakeLin.hxx>
+#include <Graphic3d_Group.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
-
#include <ProjLib.hxx>
-
+#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-
+#include <Prs3d_Text.hxx>
+#include <Prs3d_TextAspect.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <SelectMgr_EntityOwner.hxx>
-
#include <Standard_DomainError.hxx>
-
+#include <Standard_NotImplemented.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
-
-#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
-
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
-#include <gce_MakeDir.hxx>
-#include <gce_MakeLin.hxx>
-
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-
-#include <Prs3d_AngleAspect.hxx>
-
-#include <BRepGProp_Face.hxx>
-
+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 <aPoint1> from the reference <anEdge>.
+ // Find the second attachment point which belongs to the reference face
+ // Iterate over the edges of the face and find the point <aFacePoint1>.
+ // It is the closest point according to <aPoint1>.
+ 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) <theShape> 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;
}
--- /dev/null
+// 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 <AIS.hxx>
+#include <AIS_Dimension.hxx>
+#include <AIS_Drawer.hxx>
+#include <AIS_KindOfDimension.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Transformation.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+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. <br>
+//! These can be lengths along a face or edge, or <br>
+//! 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 <InitTwoShapesPoints()>
+ //! 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 <InitTwoShapesPoints()>
+ //! 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 <myFlyout> value.
+ //! The direction vector is counting using the working plane.
+ //! <myFlyout> value defined the size of flyout.
+ Standard_Real myFlyout;
+};
+
+#endif
+++ /dev/null
-// 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 <AIS.hxx>
-#include <TopoDS.hxx>
-
-
-//=======================================================================
-//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;
-}
#include <AIS_EllipseRadiusDimension.hxx>
#include <TCollection_ExtendedString.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
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
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
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <DsgPrs_MidPointPresentation.hxx>
#include <TopoDS_Vertex.hxx>
#include <AIS_EllipseRadiusDimension.hxx>
#include <TCollection_ExtendedString.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
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
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
#include <Precision.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveSegment.hxx>
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"<<endl;
arr->SetLength(myArrowSize);
- arr = la->Arrow2Aspect();
+ arr = la->ArrowAspect();
arr->SetLength(myArrowSize);
gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
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"<<endl;
arr->SetLength(myArrowSize);
- arr = la->Arrow2Aspect();
+ arr = la->ArrowAspect();
arr->SetLength(myArrowSize);
gp_Pnt myTFAttach = myFAttach.Transformed (aTrsf);
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
{
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;
+++ /dev/null
--- 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 <SZY> 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 <aProjector>.
- -- To be Used when the associated degenerated Presentations
- -- have been transformed by <aTrsf> which is not a Pure
- -- Translation. The HLR Prs can't be deducted automatically
- -- WARNING :<aTrsf> 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;
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// modified <SZY> 20-feb-98
-// <VBU> myFShape could be a wire.
-
-#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
-// if any in all dimensions.
-
#include <Standard_NotImplemented.hxx>
-#include <AIS_RadiusDimension.ixx>
+#include <AIS_RadiusDimension.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <DsgPrs_RadiusPresentation.hxx>
+#include <AIS.hxx>
+#include <AIS_Drawer.hxx>
+#include <AIS_KindOfDimension.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAdaptor_Curve.hxx>
#include <DsgPrs.hxx>
-
+#include <ElCLib.hxx>
+#include <GC_MakeCircle.hxx>
+#include <gce_MakeCirc.hxx>
+#include <gce_MakeDir.hxx>
+#include <gce_MakeLin.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Circle.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
-
#include <gp_Circ.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
-#include <ElCLib.hxx>
-#include <GC_MakeCircle.hxx>
-#include <gce_MakeLin.hxx>
-#include <gce_MakeCirc.hxx>
-
-#include <SelectMgr_EntityOwner.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Group.hxx>
#include <Precision.hxx>
-
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Root.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
#include <TopLoc_Location.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <Adaptor3d_HCurve.hxx>
-
-#include <Prs3d_AngleAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-
-
-#include <AIS.hxx>
-#include <AIS_Drawer.hxx>
-#include <gce_MakeDir.hxx>
-#include <Select3D_SensitiveBox.hxx>
-
-
-
-//======================================================================
-//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 <myWorkingPlane>
+ 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;
+}
--- /dev/null
+// 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. <br>
+//! These displays serve as relational references in 3D <br>
+//! presentations of surfaces, and are particularly useful <br>
+//! in viewing fillets. The display consists of arrows and <br>
+//! text giving the length of a radius. This display is <br>
+//! recalculated if the applicative owner shape changes <br>
+//! in dimension, and the text gives the modified length. <br>
+//! The algorithm analyzes a length along a face as an <br>
+//! arc. It then reconstructs the circle corresponding to <br>
+//! the arc and calculates the radius of this circle. <br>
+
+#ifndef _AIS_RadiusDimension_HeaderFile
+#define _AIS_RadiusDimension_HeaderFile
+
+#include <AIS.hxx>
+#include <AIS_Dimension.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Pnt.hxx>
+#include <Prs3d_DimensionAspect.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <TopoDS_Shape.hxx>
+
+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 <br>
+ //! 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 <myFlyout> value.
+ //! The direction vector is counting using the working plane.
+ //! <myFlyout> value defined the size of flyout.
+ Standard_Real myFlyout;
+ gp_Circ myCircle;
+};
+#endif
+++ /dev/null
-// 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;
-}
Presentation from Prs3d,
Curve from Geom,
NameOfColor from Quantity,
- Color from Quantity,
+ Color from Quantity,
TypeOfLine from Aspect,
TypeOfMarker from Aspect,
KindOfInteractive from AIS,
#include <Geom_CartesianPoint.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_AngleAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
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);
}
//=======================================================================
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());
}
#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <DsgPrs_SymmetricPresentation.hxx>
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,
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,
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
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.
--
-- 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,
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;
#include <gce_MakeLin.hxx>
-
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());
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:
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());
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());
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;
}
}
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_AngleAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
#include <Prs3d_Text.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
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;
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 )
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);
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;
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;
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);
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);
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));
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Text.hxx>
#include <gp_Dir.hxx>
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());
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);
}
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());
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_LineAspect.hxx>
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);
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_ArrowAspect.hxx>
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);
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;
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
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 );
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)
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)
#include <DsgPrs.hxx>
#include <Graphic3d_Group.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
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
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);
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;
#include <DsgPrs.hxx>
#include <Graphic3d_Group.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Prs3d_Root.hxx>
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);
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
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,
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_Vertex.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Root.hxx>
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);
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Text.hxx>
#include <TCollection_AsciiString.hxx>
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);
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);
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;
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;
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);
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Text.hxx>
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);
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();
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);
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,
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);
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();
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;
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,
{
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;
#include <Prs3d_Root.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Text.hxx>
//===================================================================
{
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);
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);
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);
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;
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <TCollection_AsciiString.hxx>
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);
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());
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;
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Text.hxx>
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);
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);
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);
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)
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_PointAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
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());
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Graphic3d_Vertex.hxx>
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);
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);
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;
#include <DsgPrs_SymbPresentation.ixx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Geom_CartesianPoint.hxx>
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);
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <TCollection_AsciiString.hxx>
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);
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 |
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());
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 |
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()))
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:
#include <Prs3d_Arrow.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Geom_CartesianPoint.hxx>
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);
// 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());
}
-- 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;
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
-- 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
----------------------------
Update ();
}
+
+void Graphic3d_Group::SetStencilTestOptions (const Standard_Boolean theIsEnabled)
+{
+ MyGraphicDriver->SetStencilTestOptions (MyCGroup, theIsEnabled);
+}
OpenGl_CappingPlaneResource.cxx
OpenGl_Clipping.hxx
OpenGl_Clipping.cxx
+OpenGl_StencilTest.hxx
+OpenGl_StencilTest.cxx
OpenGl_ShaderObject.hxx
OpenGl_ShaderObject.cxx
OpenGl_ShaderProgram.hxx
OpenGl_SceneGeometry.cxx
OpenGl_RaytraceTypes.hxx
OpenGl_RaytraceSource.cxx
-OpenGl_Workspace_Raytrace.cxx
\ No newline at end of file
+OpenGl_Workspace_Raytrace.cxx
#include <OpenGl_Group.hxx>
#include <OpenGl_CView.hxx>
#include <OpenGl_View.hxx>
+#include <OpenGl_StencilTest.hxx>
#include <OpenGl_Text.hxx>
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_Workspace.hxx>
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 :
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);
--- /dev/null
+// 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 <OpenGl_GlCore11.hxx>
+#include <OpenGl_StencilTest.hxx>
+
+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
--- /dev/null
+// 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 <OpenGl_Element.hxx>
+
+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
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;
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;
-- 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
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;
---Category: Basis construction elements.
- class LengthPresentation;
-
- class AnglePresentation;
-
class Text;
---Category: Class signatures.
+++ /dev/null
--- 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;
+++ /dev/null
-// 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.ixx>
-
-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;
-}
+++ /dev/null
--- 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;
+++ /dev/null
-// 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_AnglePresentation.ixx>
-#include <gp_Lin.hxx>
-#include <gp_Dir.hxx>
-#include <ElCLib.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Prs3d_Arrow.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_AngleAspect.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_Text.hxx>
-
-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));
-}
-- 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
+++ /dev/null
--- 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;
-
+++ /dev/null
-// 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_CompositeAspect.ixx>
-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
--- /dev/null
+-- 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;
--- /dev/null
+// 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 <Prs3d_DimensionAspect.hxx>
+
+#include <Aspect_TypeOfLine.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_ArrowAspect.hxx>
+#include <Quantity_Color.hxx>
+
+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;
+}
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,
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.
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;
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())
+++ /dev/null
--- 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;
+++ /dev/null
-// 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.ixx>
-
-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;
-}
+++ /dev/null
--- 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;
+++ /dev/null
-// 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_LengthPresentation.ixx>
-#include <gp_Lin.hxx>
-#include <gp_Dir.hxx>
-#include <ElCLib.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Prs3d_Arrow.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_LengthAspect.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <Prs3d_Text.hxx>
-
-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);
-}
-- 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
+++ /dev/null
--- 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;
+++ /dev/null
-// 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.ixx>
-
-Prs3d_RadiusAspect::Prs3d_RadiusAspect(const Quantity_NameOfColor /*aColor*/,
- const Aspect_TypeOfLine /*aType*/,
- const Standard_Real /*aWidth*/) {
-}
//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;
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.);
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;
}
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);
/***************************************/
//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;
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;
CSF_user32
CSF_gdi32
CSF_OpenGlLibs
+CSF_FREETYPE
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);
}
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;
}
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) {
#endif
return (Standard_False);
}
+
//=======================================================================
//function : ComputeAngle
//purpose :
//=======================================================================
+
void TPrsStd_ConstraintTools::ComputeAngle (const Handle(TDataXtd_Constraint)& aConst,
Handle(AIS_InteractiveObject)& anAIS)
{
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());
}
}
}
}
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;
}
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;
NullifyAIS(anAIS);
return;
}
- ais->SetPlane(aplane);
- ais->SetDrawFromCenter(Standard_False);
+ ais->SetWorkingPlane(aplane->Pln());
}
anAIS = ais;
}
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;
NullifyAIS(anAIS);
return;
}
- ais->SetPlane(aplane);
+ //ais->SetWorkingPlane(aplane);
}
anAIS = ais;
}
//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
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;
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;
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);
}
}
}
#include <AIS_InteractiveContext.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
-#include <AIS_AngleDimension.hxx>
#include <TCollection_ExtendedString.hxx>
#include <GC_MakePlane.hxx>
#include <gp_Circ.hxx>
# include <config.h>
#endif
+#include <AIS_AngleDimension.hxx>
+#include <AIS_Circle.hxx>
+#include <AIS_DiameterDimension.hxx>
+#include <AIS_DisplayMode.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <string.h>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_MapOfInteractive.hxx>
+#include <AIS_Point.hxx>
+#include <AIS_RadiusDimension.hxx>
+#include <AIS_Relation.hxx>
+#include <AIS_Shape.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw.hxx>
#include <Draw_Appli.hxx>
+#include <Draw_Window.hxx>
#include <DBRep.hxx>
-
-
+#include <ElSLib.hxx>
+#include <GC_MakePlane.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Pln.hxx>
+#include <IntAna_IntConicQuad.hxx>
+#include <IntAna_Quadric.hxx>
+#include <Precision.hxx>
+#include <Select3D_Projector.hxx>
+#include <StdSelect.hxx>
+#include <string.h>
#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TopAbs.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <V3d.hxx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_Point.hxx>
-#include <AIS_DisplayMode.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <AIS_MapOfInteractive.hxx>
#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
#include <ViewerTest_EventManager.hxx>
-#include <TopoDS_Solid.hxx>
-#include <BRepTools.hxx>
-#include <BRep_Builder.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-
-#include <TopAbs.hxx>
-#include <TopExp.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Face.hxx>
-
-#include <Draw_Window.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_DisplayMode.hxx>
-#include <ElSLib.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <StdSelect.hxx>
-
-
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
extern Handle(AIS_InteractiveContext)& TheAISContext ();
-
-#include <Geom_Plane.hxx>
-#include <gp_Pln.hxx>
-#include <AIS_AngleDimension.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <GC_MakePlane.hxx>
-#include <IntAna_IntConicQuad.hxx>
-#include <Select3D_Projector.hxx>
-#include <Precision.hxx>
-#include <IntAna_Quadric.hxx>
-
#ifdef HAVE_STRINGS_H
# include <strings.h>
#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;
//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);
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,
*/
}
+//=======================================================================
+//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<Handle(AIS_InteractiveObject)> 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();
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 );
//purpose : Display the diameter dimension of a face or an edge.
//Draw arg : vdiameterdim Name
//==============================================================================
-#include <AIS_DiameterDimension.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <gp_Circ.hxx>
-
static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
// 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 );
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]);
}
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]);
}
// 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 ) {
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]);
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]);
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]);
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]);
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]);
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]);
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 );
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 );
return 0;
}
+
//=======================================================================
//function : RelationsCommands
//purpose :
{
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);
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;
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;
#include <TCollection_ExtendedString.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_Text.hxx>
-#include <Prs3d_LengthAspect.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <Standard_ErrorHandler.hxx>
//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;
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
};
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
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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"