0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / IGESDraw / IGESDraw_LabelDisplay.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_Pnt.hxx>
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>
30
31 IMPLEMENT_STANDARD_RTTIEXT(IGESDraw_LabelDisplay,IGESData_LabelDisplayEntity)
32
33 IGESDraw_LabelDisplay::IGESDraw_LabelDisplay ()    {  }
34
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)
41 {
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");
49
50   theViews             = allViews; 
51   theTextLocations     = allTextLocations; 
52   theLeaderEntities    = allLeaderEntities; 
53   theLabelLevels       = allLabelLevels; 
54   theDisplayedEntities = allDisplayedEntities; 
55   InitTypeAndForm(402,5);
56 }
57
58     Standard_Integer IGESDraw_LabelDisplay::NbLabels () const
59 {
60   return (theViews->Length());
61 }
62
63     Handle(IGESData_ViewKindEntity) IGESDraw_LabelDisplay::ViewItem
64   (const Standard_Integer ViewIndex) const
65 {
66   return (theViews->Value(ViewIndex));
67 }
68
69     gp_Pnt IGESDraw_LabelDisplay::TextLocation
70   (const Standard_Integer ViewIndex) const
71 {
72   return ( gp_Pnt (theTextLocations->Value(ViewIndex)) );
73 }
74
75     Handle(IGESDimen_LeaderArrow) IGESDraw_LabelDisplay::LeaderEntity
76   (const Standard_Integer ViewIndex) const
77 {
78   return (theLeaderEntities->Value(ViewIndex));
79 }
80
81     Standard_Integer IGESDraw_LabelDisplay::LabelLevel
82   (const Standard_Integer ViewIndex) const
83 {
84   return (theLabelLevels->Value(ViewIndex));
85 }
86
87     Handle(IGESData_IGESEntity) IGESDraw_LabelDisplay::DisplayedEntity
88   (const Standard_Integer EntityIndex) const
89 {
90   return (theDisplayedEntities->Value(EntityIndex));
91 }
92
93     gp_Pnt IGESDraw_LabelDisplay::TransformedTextLocation
94   (const Standard_Integer ViewIndex) const
95 {
96   gp_XYZ retXYZ;
97   gp_XYZ tempXYZ = theTextLocations->Value(ViewIndex);
98
99   Handle(IGESData_ViewKindEntity) tempView = theViews->Value(ViewIndex);
100   if (tempView->IsKind(STANDARD_TYPE(IGESDraw_View)))
101     {
102       DeclareAndCast(IGESDraw_View, thisView, tempView);
103       retXYZ = thisView->ModelToView( tempXYZ );
104     }
105   else if (tempView->IsKind(STANDARD_TYPE(IGESDraw_PerspectiveView)))
106     {
107       DeclareAndCast(IGESDraw_PerspectiveView, thisView, tempView);
108       retXYZ = thisView->ModelToView( tempXYZ );
109     }
110   return ( gp_Pnt(retXYZ) );
111 }