b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
7fd59977 |
19 | #include <gp_GTrsf.hxx> |
42cf5bc1 |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_XYZ.hxx> |
22 | #include <IGESDimen_FlagNote.hxx> |
23 | #include <IGESDimen_GeneralNote.hxx> |
24 | #include <IGESDimen_LeaderArrow.hxx> |
25 | #include <Standard_DimensionMismatch.hxx> |
26 | #include <Standard_OutOfRange.hxx> |
27 | #include <Standard_Type.hxx> |
7fd59977 |
28 | |
92efcf78 |
29 | IMPLEMENT_STANDARD_RTTIEXT(IGESDimen_FlagNote,IGESData_IGESEntity) |
30 | |
b311480e |
31 | IGESDimen_FlagNote::IGESDimen_FlagNote () { } |
7fd59977 |
32 | |
33 | void IGESDimen_FlagNote::Init |
34 | (const gp_XYZ& leftCorner, const Standard_Real anAngle, |
35 | const Handle(IGESDimen_GeneralNote)& aNote, |
36 | const Handle(IGESDimen_HArray1OfLeaderArrow)& someLeaders) |
37 | { |
38 | if (!someLeaders.IsNull()) |
39 | if (someLeaders->Lower() != 1) |
9775fa61 |
40 | throw Standard_DimensionMismatch("IGESDimen_FlagNote : Init"); |
7fd59977 |
41 | theLowerLeftcorner = leftCorner; |
42 | theAngle = anAngle; |
43 | theNote = aNote; |
44 | theLeaders = someLeaders; |
45 | InitTypeAndForm(208,0); |
46 | } |
47 | |
48 | gp_Pnt IGESDimen_FlagNote::LowerLeftCorner () const |
49 | { |
50 | gp_Pnt lowerleft(theLowerLeftcorner); |
51 | return lowerleft; |
52 | } |
53 | |
54 | gp_Pnt IGESDimen_FlagNote::TransformedLowerLeftCorner () const |
55 | { |
56 | gp_XYZ tempXYZ = theLowerLeftcorner; |
57 | if (HasTransf()) Location().Transforms(tempXYZ); |
58 | return gp_Pnt(tempXYZ); |
59 | } |
60 | |
61 | Standard_Real IGESDimen_FlagNote::Angle () const |
62 | { |
63 | return theAngle; |
64 | } |
65 | |
66 | Handle(IGESDimen_GeneralNote) IGESDimen_FlagNote::Note () const |
67 | { |
68 | return theNote; |
69 | } |
70 | |
71 | Standard_Integer IGESDimen_FlagNote::NbLeaders () const |
72 | { |
73 | return (theLeaders.IsNull() ? 0 : theLeaders->Length() ); |
74 | } |
75 | |
76 | Handle(IGESDimen_LeaderArrow) IGESDimen_FlagNote::Leader |
77 | (const Standard_Integer Index) const |
78 | { |
79 | return theLeaders->Value(Index); |
80 | } |
81 | |
82 | Standard_Real IGESDimen_FlagNote::Height () const |
83 | { |
84 | return (2 * CharacterHeight()); |
85 | } |
86 | |
87 | Standard_Real IGESDimen_FlagNote::CharacterHeight () const |
88 | { |
89 | Standard_Real Max = theNote->BoxHeight(1); |
90 | for(Standard_Integer i = 2; i <= theNote->NbStrings(); i++) |
91 | { |
92 | if (Max < theNote->BoxHeight(i)) |
93 | Max = theNote->BoxHeight(i); |
94 | } |
95 | return (Max); |
96 | } |
97 | |
98 | Standard_Real IGESDimen_FlagNote::Length () const |
99 | { |
100 | return (TextWidth() + (0.4 * CharacterHeight())); |
101 | } |
102 | |
103 | Standard_Real IGESDimen_FlagNote::TextWidth () const |
104 | { |
105 | Standard_Real width = 0; |
106 | for(Standard_Integer i = 1; i <= theNote->NbStrings(); i++) |
107 | width += theNote->BoxWidth(i); |
108 | return (width); |
109 | } |
110 | |
111 | Standard_Real IGESDimen_FlagNote::TipLength () const |
112 | { |
c6541a0c |
113 | return (0.5 * (Height()/Tan((35./180.)*M_PI))); |
7fd59977 |
114 | } |