0024624: Lost word in license statement in source 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
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17//-Version
18
19//-Design Declaration des variables specifiques aux Type de traits
20
21//-Warning Un style est definie, soit par son type predefini TOL_...
22// soit par sa description en METRE
23
24//-References
25
26//-Language C++ 2.0
27
28//-Declarations
29
30// for the class
31#include <Aspect_LineStyle.ixx>
32#include <Aspect_Units.hxx>
33
34//-Aliases
35
36//-Global data definitions
37
38// MyLineType : TypeOfLine from Aspect;
39// MyLineDescriptor : HArray1OfReal from TColStd;
40
41//-Constructors
42
43//-Destructors
44
45//-Methods, in order
46
47Aspect_LineStyle::Aspect_LineStyle () : MyLineDescriptor(PredefinedStyle(Aspect_TOL_SOLID)) {
48}
49
50Aspect_LineStyle::Aspect_LineStyle (const Aspect_TypeOfLine Type) : MyLineDescriptor(PredefinedStyle(Type)) {
51}
52
53Aspect_LineStyle::Aspect_LineStyle (const TColQuantity_Array1OfLength& UserDefinedStyle) {
54Standard_Integer i ;
55
56 MyLineType = Aspect_TOL_USERDEFINED ;
57 // Modif CAL 8/2/95
58 MyLineDescriptor = new TColQuantity_HArray1OfLength
59 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
60
61 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
62 // Modif CAL 8/2/95
63 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
64 if( UserDefinedStyle(i) <= 0. )
65 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
66 }
67}
68
69Aspect_LineStyle& Aspect_LineStyle::Assign (const Aspect_LineStyle& Other) {
70Standard_Integer i ;
71
72 // Modif CAL 8/2/95
73 MyLineDescriptor = new TColQuantity_HArray1OfLength
74 ((Other.Values()).Lower(), (Other.Values()).Upper()) ;
75 MyLineType = Other.MyLineType ;
76
77 if( MyLineType != Aspect_TOL_SOLID ) {
78 for( i=MyLineDescriptor->Lower() ;
79 i<=MyLineDescriptor->Upper() ; i++ ){
80 // Modif CAL 8/2/95
81 MyLineDescriptor->SetValue(i, (Other.Values())(i)) ;
82 if( (Other.Values())(i) <= 0. )
83 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
84 }
85 }
86
87 return (*this);
88
89}
90
91void Aspect_LineStyle::SetValues (const Aspect_TypeOfLine Type) {
92
93 MyLineDescriptor = PredefinedStyle(Type) ;
94
95}
96
97void Aspect_LineStyle::SetValues (const TColQuantity_Array1OfLength& UserDefinedStyle) {
98Standard_Integer i ;
99
100 // Modif CAL 8/2/95
101 MyLineDescriptor = new TColQuantity_HArray1OfLength
102 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
103 MyLineType = Aspect_TOL_USERDEFINED ;
104
105 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
106 // Modif CAL 8/2/95
107 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
108 if( UserDefinedStyle(i) <= 0. )
109 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
110 }
111}
112
113Aspect_TypeOfLine Aspect_LineStyle::Style () const {
114
115 return (MyLineType);
116}
117
118Standard_Integer Aspect_LineStyle::Length () const {
119
120 if( MyLineDescriptor.IsNull() ) return (0) ;
121 else return (MyLineDescriptor->Length());
122}
123
124const TColQuantity_Array1OfLength& Aspect_LineStyle::Values () const {
125
126 return (MyLineDescriptor->Array1());
127}
128
129Handle(TColQuantity_HArray1OfLength) Aspect_LineStyle::PredefinedStyle(const Aspect_TypeOfLine Type) {
130Handle(TColQuantity_HArray1OfLength) descriptor ;
131
132 MyLineType = Type ;
133 switch ( Type ) {
134 case Aspect_TOL_USERDEFINED :
135 Aspect_LineStyleDefinitionError::Raise ("Bad Line Type Style");
136 case Aspect_TOL_SOLID :
137 descriptor = new TColQuantity_HArray1OfLength(1,1) ;
138 descriptor->SetValue(1,0.) ;
139 break ;
140 case Aspect_TOL_DASH :
141 descriptor = new TColQuantity_HArray1OfLength(1,2) ;
142 descriptor->SetValue(1,2.0 MILLIMETER) ;
143 descriptor->SetValue(2,1.0 MILLIMETER) ;
144 break ;
145 case Aspect_TOL_DOT :
146 descriptor = new TColQuantity_HArray1OfLength(1,2) ;
147 descriptor->SetValue(1,0.2 MILLIMETER) ;
148 descriptor->SetValue(2,0.5 MILLIMETER) ;
149 break ;
150 case Aspect_TOL_DOTDASH :
151 descriptor = new TColQuantity_HArray1OfLength(1,4) ;
152 descriptor->SetValue(1,10.0 MILLIMETER) ;
153 descriptor->SetValue(2,1.0 MILLIMETER) ;
154 descriptor->SetValue(3,2.0 MILLIMETER) ;
155 descriptor->SetValue(4,1.0 MILLIMETER) ;
156 break ;
157 default :
158 descriptor.Nullify() ;
159 }
160
161 return (descriptor) ;
162}
163
164Standard_Boolean Aspect_LineStyle::IsEqual(const Aspect_LineStyle& Other) const
165{
166 return (
167 (MyLineType == Other.MyLineType) &&
168 (MyLineDescriptor == Other.MyLineDescriptor));
169}
170
171Standard_Boolean Aspect_LineStyle::IsNotEqual(const Aspect_LineStyle& Other) const
172{
173 return !IsEqual(Other);
174}