summaryrefslogtreecommitdiff
path: root/src/Aspect/Aspect_LineStyle.cxx
blob: 025320c57432a49189e4157dfb1b0fed824ab33f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165

// File		Aspect_LineStyle.cxx
// Created	Septembre 1992
// Author	GG

//-Copyright	MatraDatavision 1991,1992

//-Version	

//-Design	Declaration des variables specifiques aux Type de traits

//-Warning	Un style est definie, soit par son type predefini TOL_...
//		soit par sa description en METRE

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Aspect_LineStyle.ixx>
#include <Aspect_Units.hxx>

//-Aliases

//-Global data definitions

//	MyLineType	 	: TypeOfLine from Aspect;
//	MyLineDescriptor	: HArray1OfReal from TColStd;

//-Constructors

//-Destructors

//-Methods, in order

Aspect_LineStyle::Aspect_LineStyle () : MyLineDescriptor(PredefinedStyle(Aspect_TOL_SOLID)) {
}

Aspect_LineStyle::Aspect_LineStyle (const Aspect_TypeOfLine Type) : MyLineDescriptor(PredefinedStyle(Type)) {
}

Aspect_LineStyle::Aspect_LineStyle (const TColQuantity_Array1OfLength& UserDefinedStyle) {
Standard_Integer i ;

	MyLineType = Aspect_TOL_USERDEFINED ;
	// Modif CAL 8/2/95
	MyLineDescriptor = new TColQuantity_HArray1OfLength
		(UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;

	for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
	    // Modif CAL 8/2/95
	    MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
	    if( UserDefinedStyle(i) <= 0. )
		Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
	}
}

Aspect_LineStyle& Aspect_LineStyle::Assign (const Aspect_LineStyle& Other) {
Standard_Integer i ;

	// Modif CAL 8/2/95
	MyLineDescriptor = new TColQuantity_HArray1OfLength
		((Other.Values()).Lower(), (Other.Values()).Upper()) ;
	MyLineType = Other.MyLineType ;

	if( MyLineType != Aspect_TOL_SOLID ) {
	  for( i=MyLineDescriptor->Lower() ; 
				i<=MyLineDescriptor->Upper() ; i++ ){
	    // Modif CAL 8/2/95
	    MyLineDescriptor->SetValue(i, (Other.Values())(i)) ;
	    if( (Other.Values())(i) <= 0. )
		Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
	  }
	}

	return (*this);

}

void Aspect_LineStyle::SetValues (const Aspect_TypeOfLine Type) {

	MyLineDescriptor = PredefinedStyle(Type) ;

}

void Aspect_LineStyle::SetValues (const TColQuantity_Array1OfLength& UserDefinedStyle) {
Standard_Integer i ;

	// Modif CAL 8/2/95
	MyLineDescriptor = new TColQuantity_HArray1OfLength
		(UserDefinedStyle.Lower(), UserDefinedStyle.Upper()) ;
	MyLineType = Aspect_TOL_USERDEFINED ;

	for( i=UserDefinedStyle.Lower() ; i<=UserDefinedStyle.Upper() ; i++ ) {
	    // Modif CAL 8/2/95
	    MyLineDescriptor->SetValue(i, UserDefinedStyle(i)) ;
	    if( UserDefinedStyle(i) <= 0. )
		Aspect_LineStyleDefinitionError::Raise ("Bad Descriptor") ;
	}
}

Aspect_TypeOfLine Aspect_LineStyle::Style () const {

	return (MyLineType);
}

Standard_Integer Aspect_LineStyle::Length () const {

	if( MyLineDescriptor.IsNull() ) return (0) ;
	else return (MyLineDescriptor->Length());
}

const TColQuantity_Array1OfLength& Aspect_LineStyle::Values () const {

	return (MyLineDescriptor->Array1());
}

Handle(TColQuantity_HArray1OfLength) Aspect_LineStyle::PredefinedStyle(const Aspect_TypeOfLine Type) {
Handle(TColQuantity_HArray1OfLength) descriptor ; 

	MyLineType	= Type ;
	switch ( Type ) {
	    case Aspect_TOL_USERDEFINED :
		Aspect_LineStyleDefinitionError::Raise ("Bad Line Type Style");
	    case Aspect_TOL_SOLID :
		descriptor = new TColQuantity_HArray1OfLength(1,1) ;
		descriptor->SetValue(1,0.) ;
		break ;
	    case Aspect_TOL_DASH :
		descriptor = new TColQuantity_HArray1OfLength(1,2) ;
		descriptor->SetValue(1,2.0 MILLIMETER) ;
		descriptor->SetValue(2,1.0 MILLIMETER) ;
		break ;
	    case Aspect_TOL_DOT :
		descriptor = new TColQuantity_HArray1OfLength(1,2) ;
		descriptor->SetValue(1,0.2 MILLIMETER) ;
		descriptor->SetValue(2,0.5 MILLIMETER) ;
		break ;
	    case Aspect_TOL_DOTDASH :
		descriptor = new TColQuantity_HArray1OfLength(1,4) ;
		descriptor->SetValue(1,10.0 MILLIMETER) ;
		descriptor->SetValue(2,1.0 MILLIMETER) ;
		descriptor->SetValue(3,2.0 MILLIMETER) ;
		descriptor->SetValue(4,1.0 MILLIMETER) ;
		break ;
	    default :
		descriptor.Nullify() ;
	}

	return (descriptor) ;
}

Standard_Boolean Aspect_LineStyle::IsEqual(const Aspect_LineStyle& Other) const
{
  return (
	  (MyLineType == Other.MyLineType) &&
	  (MyLineDescriptor == Other.MyLineDescriptor));
}

Standard_Boolean Aspect_LineStyle::IsNotEqual(const Aspect_LineStyle& Other) const
{
  return !IsEqual(Other);
}