0023024: Update headers of OCCT files
[occt.git] / src / Aspect / Aspect_LineStyle.cxx
CommitLineData
b311480e 1// Created on: 1992-09-14
2// Created by: GG
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
7fd59977 22
7fd59977 23
24//-Version
25
26//-Design Declaration des variables specifiques aux Type de traits
27
28//-Warning Un style est definie, soit par son type predefini TOL_...
29// soit par sa description en METRE
30
31//-References
32
33//-Language C++ 2.0
34
35//-Declarations
36
37// for the class
38#include <Aspect_LineStyle.ixx>
39#include <Aspect_Units.hxx>
40
41//-Aliases
42
43//-Global data definitions
44
45// MyLineType : TypeOfLine from Aspect;
46// MyLineDescriptor : HArray1OfReal from TColStd;
47
48//-Constructors
49
50//-Destructors
51
52//-Methods, in order
53
54Aspect_LineStyle::Aspect_LineStyle () : MyLineDescriptor(PredefinedStyle(Aspect_TOL_SOLID)) {
55}
56
57Aspect_LineStyle::Aspect_LineStyle (const Aspect_TypeOfLine Type) : MyLineDescriptor(PredefinedStyle(Type)) {
58}
59
60Aspect_LineStyle::Aspect_LineStyle (const TColQuantity_Array1OfLength& UserDefinedStyle) {
61Standard_Integer i ;
62
63 MyLineType = Aspect_TOL_USERDEFINED ;
64 // Modif CAL 8/2/95
65 MyLineDescriptor = new TColQuantity_HArray1OfLength
66 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
67
68 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
69 // Modif CAL 8/2/95
70 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
71 if( UserDefinedStyle(i) <= 0. )
72 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
73 }
74}
75
76Aspect_LineStyle& Aspect_LineStyle::Assign (const Aspect_LineStyle& Other) {
77Standard_Integer i ;
78
79 // Modif CAL 8/2/95
80 MyLineDescriptor = new TColQuantity_HArray1OfLength
81 ((Other.Values()).Lower(), (Other.Values()).Upper()) ;
82 MyLineType = Other.MyLineType ;
83
84 if( MyLineType != Aspect_TOL_SOLID ) {
85 for( i=MyLineDescriptor->Lower() ;
86 i<=MyLineDescriptor->Upper() ; i++ ){
87 // Modif CAL 8/2/95
88 MyLineDescriptor->SetValue(i, (Other.Values())(i)) ;
89 if( (Other.Values())(i) <= 0. )
90 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
91 }
92 }
93
94 return (*this);
95
96}
97
98void Aspect_LineStyle::SetValues (const Aspect_TypeOfLine Type) {
99
100 MyLineDescriptor = PredefinedStyle(Type) ;
101
102}
103
104void Aspect_LineStyle::SetValues (const TColQuantity_Array1OfLength& UserDefinedStyle) {
105Standard_Integer i ;
106
107 // Modif CAL 8/2/95
108 MyLineDescriptor = new TColQuantity_HArray1OfLength
109 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
110 MyLineType = Aspect_TOL_USERDEFINED ;
111
112 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
113 // Modif CAL 8/2/95
114 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
115 if( UserDefinedStyle(i) <= 0. )
116 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
117 }
118}
119
120Aspect_TypeOfLine Aspect_LineStyle::Style () const {
121
122 return (MyLineType);
123}
124
125Standard_Integer Aspect_LineStyle::Length () const {
126
127 if( MyLineDescriptor.IsNull() ) return (0) ;
128 else return (MyLineDescriptor->Length());
129}
130
131const TColQuantity_Array1OfLength& Aspect_LineStyle::Values () const {
132
133 return (MyLineDescriptor->Array1());
134}
135
136Handle(TColQuantity_HArray1OfLength) Aspect_LineStyle::PredefinedStyle(const Aspect_TypeOfLine Type) {
137Handle(TColQuantity_HArray1OfLength) descriptor ;
138
139 MyLineType = Type ;
140 switch ( Type ) {
141 case Aspect_TOL_USERDEFINED :
142 Aspect_LineStyleDefinitionError::Raise ("Bad Line Type Style");
143 case Aspect_TOL_SOLID :
144 descriptor = new TColQuantity_HArray1OfLength(1,1) ;
145 descriptor->SetValue(1,0.) ;
146 break ;
147 case Aspect_TOL_DASH :
148 descriptor = new TColQuantity_HArray1OfLength(1,2) ;
149 descriptor->SetValue(1,2.0 MILLIMETER) ;
150 descriptor->SetValue(2,1.0 MILLIMETER) ;
151 break ;
152 case Aspect_TOL_DOT :
153 descriptor = new TColQuantity_HArray1OfLength(1,2) ;
154 descriptor->SetValue(1,0.2 MILLIMETER) ;
155 descriptor->SetValue(2,0.5 MILLIMETER) ;
156 break ;
157 case Aspect_TOL_DOTDASH :
158 descriptor = new TColQuantity_HArray1OfLength(1,4) ;
159 descriptor->SetValue(1,10.0 MILLIMETER) ;
160 descriptor->SetValue(2,1.0 MILLIMETER) ;
161 descriptor->SetValue(3,2.0 MILLIMETER) ;
162 descriptor->SetValue(4,1.0 MILLIMETER) ;
163 break ;
164 default :
165 descriptor.Nullify() ;
166 }
167
168 return (descriptor) ;
169}
170
171Standard_Boolean Aspect_LineStyle::IsEqual(const Aspect_LineStyle& Other) const
172{
173 return (
174 (MyLineType == Other.MyLineType) &&
175 (MyLineDescriptor == Other.MyLineDescriptor));
176}
177
178Standard_Boolean Aspect_LineStyle::IsNotEqual(const Aspect_LineStyle& Other) const
179{
180 return !IsEqual(Other);
181}