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 <IGESData_IGESEntity.hxx>
21 #include <IGESData_ViewKindEntity.hxx>
22 #include <IGESDimen_LeaderArrow.hxx>
23 #include <IGESDraw_LabelDisplay.hxx>
24 #include <IGESDraw_PerspectiveView.hxx>
25 #include <IGESDraw_View.hxx>
26 #include <Interface_Macros.hxx>
27 #include <Standard_DimensionMismatch.hxx>
28 #include <Standard_OutOfRange.hxx>
29 #include <Standard_Type.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(IGESDraw_LabelDisplay,IGESData_LabelDisplayEntity)
33 IGESDraw_LabelDisplay::IGESDraw_LabelDisplay () { }
35 void IGESDraw_LabelDisplay::Init
36 (const Handle(IGESDraw_HArray1OfViewKindEntity)& allViews,
37 const Handle(TColgp_HArray1OfXYZ)& allTextLocations,
38 const Handle(IGESDimen_HArray1OfLeaderArrow)& allLeaderEntities,
39 const Handle(TColStd_HArray1OfInteger)& allLabelLevels,
40 const Handle(IGESData_HArray1OfIGESEntity)& allDisplayedEntities)
42 Standard_Integer Ln = allViews->Length();
43 if ( allViews->Lower() != 1 ||
44 (allTextLocations->Lower() != 1 || allTextLocations->Length() != Ln) ||
45 (allLeaderEntities->Lower() != 1 || allLeaderEntities->Length() != Ln) ||
46 (allLabelLevels->Lower() != 1 || allLabelLevels->Length() != Ln) ||
47 (allDisplayedEntities->Lower() != 1 || allDisplayedEntities->Length() != Ln))
48 throw Standard_DimensionMismatch("IGESDraw_LabelDisplay : Init");
51 theTextLocations = allTextLocations;
52 theLeaderEntities = allLeaderEntities;
53 theLabelLevels = allLabelLevels;
54 theDisplayedEntities = allDisplayedEntities;
55 InitTypeAndForm(402,5);
58 Standard_Integer IGESDraw_LabelDisplay::NbLabels () const
60 return (theViews->Length());
63 Handle(IGESData_ViewKindEntity) IGESDraw_LabelDisplay::ViewItem
64 (const Standard_Integer ViewIndex) const
66 return (theViews->Value(ViewIndex));
69 gp_Pnt IGESDraw_LabelDisplay::TextLocation
70 (const Standard_Integer ViewIndex) const
72 return ( gp_Pnt (theTextLocations->Value(ViewIndex)) );
75 Handle(IGESDimen_LeaderArrow) IGESDraw_LabelDisplay::LeaderEntity
76 (const Standard_Integer ViewIndex) const
78 return (theLeaderEntities->Value(ViewIndex));
81 Standard_Integer IGESDraw_LabelDisplay::LabelLevel
82 (const Standard_Integer ViewIndex) const
84 return (theLabelLevels->Value(ViewIndex));
87 Handle(IGESData_IGESEntity) IGESDraw_LabelDisplay::DisplayedEntity
88 (const Standard_Integer EntityIndex) const
90 return (theDisplayedEntities->Value(EntityIndex));
93 gp_Pnt IGESDraw_LabelDisplay::TransformedTextLocation
94 (const Standard_Integer ViewIndex) const
97 gp_XYZ tempXYZ = theTextLocations->Value(ViewIndex);
99 Handle(IGESData_ViewKindEntity) tempView = theViews->Value(ViewIndex);
100 if (tempView->IsKind(STANDARD_TYPE(IGESDraw_View)))
102 DeclareAndCast(IGESDraw_View, thisView, tempView);
103 retXYZ = thisView->ModelToView( tempXYZ );
105 else if (tempView->IsKind(STANDARD_TYPE(IGESDraw_PerspectiveView)))
107 DeclareAndCast(IGESDraw_PerspectiveView, thisView, tempView);
108 retXYZ = thisView->ModelToView( tempXYZ );
110 return ( gp_Pnt(retXYZ) );