summaryrefslogtreecommitdiff
path: root/src/Aspect/Aspect_WidthMapEntry.cxx
blob: 03dae4f25c29518f8dc2811b8c6dfa4dd35d557a (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
166
167
168
169
170
171
172
173
174
175
176
177
#include <Aspect_WidthMapEntry.ixx>
#include <Aspect_Units.hxx>

Aspect_WidthMapEntry::Aspect_WidthMapEntry() {

	SetPredefinedStyle(Aspect_WOL_THIN);
	MyIndexIsDef	= Standard_True;
	MyIndex		= 0;

}

Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Standard_Integer index, const Aspect_WidthOfLine style) {

	SetPredefinedStyle(style);
	MyIndexIsDef	= Standard_True;
	MyIndex		= index;

}

Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Standard_Integer index, const Quantity_Length width) {

	if( width < 0. )
		Aspect_BadAccess::Raise("Bad Line Width") ;

        MyType 		= Aspect_WOL_USERDEFINED ;
	MyTypeIsDef 	= Standard_True;
	MyIndexIsDef	= Standard_True;
	MyIndex		= index;
	MyWidth		= width;

}

Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Aspect_WidthMapEntry& entry) {

	if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) {
		Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ;
	}
	else {
		MyTypeIsDef	= Standard_True;
		MyIndexIsDef	= Standard_True;
		MyIndex		= entry.MyIndex;
		MyType		= entry.MyType;
		MyWidth		= entry.MyWidth;
	}
}

void Aspect_WidthMapEntry::SetValue (const Standard_Integer index, const Aspect_WidthOfLine style) {

	SetPredefinedStyle(style);
	MyIndexIsDef	= Standard_True;
	MyIndex		= index;

}

void Aspect_WidthMapEntry::SetValue (const Standard_Integer index, const Quantity_Length width) {

	if( width < 0. )
		Aspect_BadAccess::Raise("Bad Line Width") ;

        MyType 		= Aspect_WOL_USERDEFINED ;
	MyTypeIsDef 	= Standard_True;
	MyWidth		= width ;
	MyIndexIsDef	= Standard_True;
	MyIndex		= index;

}

void Aspect_WidthMapEntry::SetValue (const Aspect_WidthMapEntry& entry) {

	if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) {
		Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ;
	}
	else {
		MyTypeIsDef	= Standard_True;
		MyIndexIsDef	= Standard_True;
		MyIndex		= entry.MyIndex;
		MyType		= entry.MyType;
		MyWidth		= entry.MyWidth;
	}

}

void Aspect_WidthMapEntry::SetType (const Aspect_WidthOfLine style) {

	SetPredefinedStyle(style);

}

void Aspect_WidthMapEntry::SetWidth (const Quantity_Length width) {

	if( width < 0. )
		Aspect_BadAccess::Raise("Bad Line Width") ;

        MyType 		= Aspect_WOL_USERDEFINED ;
	MyTypeIsDef 	= Standard_True;
	MyWidth		= width ;

}

Aspect_WidthOfLine Aspect_WidthMapEntry::Type () const {

	if ( !MyTypeIsDef || !MyIndexIsDef ) 
		Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ;

	return MyType;

}

Standard_Real Aspect_WidthMapEntry::Width () const {

	if ( !MyTypeIsDef || !MyIndexIsDef ) 
		Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ;

	return MyWidth;

}

void Aspect_WidthMapEntry::SetIndex (const Standard_Integer index) {

	MyTypeIsDef	= Standard_True;
	MyIndex		= index;

}

Standard_Integer Aspect_WidthMapEntry::Index () const {

	if ( !MyTypeIsDef || !MyIndexIsDef ) 
		Aspect_BadAccess::Raise("Unallocated WidthMapEntry");

	return MyIndex;

}

Standard_Boolean Aspect_WidthMapEntry::IsAllocated () const {

	return ( MyTypeIsDef && MyIndexIsDef ) ; 

}

void Aspect_WidthMapEntry::Free () {

	MyTypeIsDef	= Standard_False;
	MyIndexIsDef	= Standard_False;

}

void Aspect_WidthMapEntry::Dump () const {

  cout << " Aspect_WidthMapEntry::Dump ()\n";
  cout << "      MyTypeIsDef : " << (MyTypeIsDef ? "True\n" : "False\n");
  cout << "      MyIndexIsDef : " << (MyIndexIsDef ? "True\n" : "False\n");
  cout << "      TypeOfWidth : " << (Standard_Integer) MyType << "\n";//WNT
  cout << "      LineWidth : " << MyWidth << "\n";
  cout << flush;
}

void Aspect_WidthMapEntry::SetPredefinedStyle(const Aspect_WidthOfLine Style) {

        MyType = Style ;
	MyTypeIsDef = Standard_True;
        switch ( Style ) {
            case Aspect_WOL_USERDEFINED :
		Aspect_BadAccess::Raise("Bad Predefined Line Width Style") ;
            case Aspect_WOL_THIN:
		MyWidth = 0.25 MILLIMETER ;
                break ;
            case Aspect_WOL_MEDIUM :
		MyWidth = 0.5 MILLIMETER ;
                break ;
            case Aspect_WOL_THICK :
		MyWidth = 0.7 MILLIMETER ;
                break ;
            case Aspect_WOL_VERYTHICK :
		MyWidth = 1.5 MILLIMETER ;
                break ;
        }
}