1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
20 #include <IGESDraw_LabelDisplay.hxx>
21 #include <IGESDraw_PerspectiveView.hxx>
22 #include <IGESDraw_View.hxx>
23 #include <Interface_Macros.hxx>
24 #include <Standard_DimensionMismatch.hxx>
25 #include <Standard_Type.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(IGESDraw_LabelDisplay,IGESData_LabelDisplayEntity)
29 IGESDraw_LabelDisplay::IGESDraw_LabelDisplay () { }
31 void IGESDraw_LabelDisplay::Init
32 (const Handle(IGESDraw_HArray1OfViewKindEntity)& allViews,
33 const Handle(TColgp_HArray1OfXYZ)& allTextLocations,
34 const Handle(IGESDimen_HArray1OfLeaderArrow)& allLeaderEntities,
35 const Handle(TColStd_HArray1OfInteger)& allLabelLevels,
36 const Handle(IGESData_HArray1OfIGESEntity)& allDisplayedEntities)
38 Standard_Integer Ln = allViews->Length();
39 if ( allViews->Lower() != 1 ||
40 (allTextLocations->Lower() != 1 || allTextLocations->Length() != Ln) ||
41 (allLeaderEntities->Lower() != 1 || allLeaderEntities->Length() != Ln) ||
42 (allLabelLevels->Lower() != 1 || allLabelLevels->Length() != Ln) ||
43 (allDisplayedEntities->Lower() != 1 || allDisplayedEntities->Length() != Ln))
44 throw Standard_DimensionMismatch("IGESDraw_LabelDisplay : Init");
47 theTextLocations = allTextLocations;
48 theLeaderEntities = allLeaderEntities;
49 theLabelLevels = allLabelLevels;
50 theDisplayedEntities = allDisplayedEntities;
51 InitTypeAndForm(402,5);
54 Standard_Integer IGESDraw_LabelDisplay::NbLabels () const
56 return (theViews->Length());
59 Handle(IGESData_ViewKindEntity) IGESDraw_LabelDisplay::ViewItem
60 (const Standard_Integer ViewIndex) const
62 return (theViews->Value(ViewIndex));
65 gp_Pnt IGESDraw_LabelDisplay::TextLocation
66 (const Standard_Integer ViewIndex) const
68 return ( gp_Pnt (theTextLocations->Value(ViewIndex)) );
71 Handle(IGESDimen_LeaderArrow) IGESDraw_LabelDisplay::LeaderEntity
72 (const Standard_Integer ViewIndex) const
74 return (theLeaderEntities->Value(ViewIndex));
77 Standard_Integer IGESDraw_LabelDisplay::LabelLevel
78 (const Standard_Integer ViewIndex) const
80 return (theLabelLevels->Value(ViewIndex));
83 Handle(IGESData_IGESEntity) IGESDraw_LabelDisplay::DisplayedEntity
84 (const Standard_Integer EntityIndex) const
86 return (theDisplayedEntities->Value(EntityIndex));
89 gp_Pnt IGESDraw_LabelDisplay::TransformedTextLocation
90 (const Standard_Integer ViewIndex) const
93 gp_XYZ tempXYZ = theTextLocations->Value(ViewIndex);
95 Handle(IGESData_ViewKindEntity) tempView = theViews->Value(ViewIndex);
96 if (tempView->IsKind(STANDARD_TYPE(IGESDraw_View)))
98 DeclareAndCast(IGESDraw_View, thisView, tempView);
99 retXYZ = thisView->ModelToView( tempXYZ );
101 else if (tempView->IsKind(STANDARD_TYPE(IGESDraw_PerspectiveView)))
103 DeclareAndCast(IGESDraw_PerspectiveView, thisView, tempView);
104 retXYZ = thisView->ModelToView( tempXYZ );
106 return ( gp_Pnt(retXYZ) );