1 // Created on: 1992-09-14
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public version 2.1 as published
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 //-Design Declaration des variables specifiques aux Type de traits
21 //-Warning Un style est definie, soit par son type predefini TOL_...
22 // soit par sa description en METRE
31 #include <Aspect_LineStyle.ixx>
32 #include <Aspect_Units.hxx>
36 //-Global data definitions
38 // MyLineType : TypeOfLine from Aspect;
39 // MyLineDescriptor : HArray1OfReal from TColStd;
47 Aspect_LineStyle::Aspect_LineStyle () : MyLineDescriptor(PredefinedStyle(Aspect_TOL_SOLID)) {
50 Aspect_LineStyle::Aspect_LineStyle (const Aspect_TypeOfLine Type) : MyLineDescriptor(PredefinedStyle(Type)) {
53 Aspect_LineStyle::Aspect_LineStyle (const TColQuantity_Array1OfLength& UserDefinedStyle) {
56 MyLineType = Aspect_TOL_USERDEFINED ;
58 MyLineDescriptor = new TColQuantity_HArray1OfLength
59 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
61 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
63 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
64 if( UserDefinedStyle(i) <= 0. )
65 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
69 Aspect_LineStyle& Aspect_LineStyle::Assign (const Aspect_LineStyle& Other) {
73 MyLineDescriptor = new TColQuantity_HArray1OfLength
74 ((Other.Values()).Lower(), (Other.Values()).Upper()) ;
75 MyLineType = Other.MyLineType ;
77 if( MyLineType != Aspect_TOL_SOLID ) {
78 for( i=MyLineDescriptor->Lower() ;
79 i<=MyLineDescriptor->Upper() ; i++ ){
81 MyLineDescriptor->SetValue(i, (Other.Values())(i)) ;
82 if( (Other.Values())(i) <= 0. )
83 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
91 void Aspect_LineStyle::SetValues (const Aspect_TypeOfLine Type) {
93 MyLineDescriptor = PredefinedStyle(Type) ;
97 void Aspect_LineStyle::SetValues (const TColQuantity_Array1OfLength& UserDefinedStyle) {
101 MyLineDescriptor = new TColQuantity_HArray1OfLength
102 (UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
103 MyLineType = Aspect_TOL_USERDEFINED ;
105 for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
107 MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
108 if( UserDefinedStyle(i) <= 0. )
109 Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
113 Aspect_TypeOfLine Aspect_LineStyle::Style () const {
118 Standard_Integer Aspect_LineStyle::Length () const {
120 if( MyLineDescriptor.IsNull() ) return (0) ;
121 else return (MyLineDescriptor->Length());
124 const TColQuantity_Array1OfLength& Aspect_LineStyle::Values () const {
126 return (MyLineDescriptor->Array1());
129 Handle(TColQuantity_HArray1OfLength) Aspect_LineStyle::PredefinedStyle(const Aspect_TypeOfLine Type) {
130 Handle(TColQuantity_HArray1OfLength) descriptor ;
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.) ;
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) ;
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) ;
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) ;
158 descriptor.Nullify() ;
161 return (descriptor) ;
164 Standard_Boolean Aspect_LineStyle::IsEqual(const Aspect_LineStyle& Other) const
167 (MyLineType == Other.MyLineType) &&
168 (MyLineDescriptor == Other.MyLineDescriptor));
171 Standard_Boolean Aspect_LineStyle::IsNotEqual(const Aspect_LineStyle& Other) const
173 return !IsEqual(Other);