b311480e |
1 | // Created by: DCB |
2 | // Copyright (c) 1998-1999 Matra Datavision |
3 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | #include <PlotMgt.hxx> |
22 | #include <PlotMgt_PlotterParameter.ixx> |
23 | #include <PlotMgt_PlotterTools.hxx> |
24 | |
25 | // Removes str at index <idx2> and puts it before <idx1> |
26 | #define SWAP_STR(idx1,idx2) \ |
27 | { \ |
28 | TCollection_AsciiString str; \ |
29 | str = myDescription -> Value(idx2); \ |
30 | myDescription -> Remove (idx2); \ |
31 | myDescription -> InsertBefore (idx1, str); \ |
32 | } |
33 | |
34 | #define STRING_TRIM(aString) \ |
35 | aString.LeftAdjust(); \ |
36 | aString.RightAdjust(); |
37 | |
38 | #define FLAG_DIALOG 0x00000001 |
39 | #define FLAG_MINVAL 0x00000002 |
40 | #define FLAG_MAXVAL 0x00000004 |
41 | #define FLAG_VALUES 0x00000008 |
42 | #define FLAG_LENGTH 0x00000010 |
43 | #define FLAG_DEFVAL 0x00000020 |
44 | #define FLAG_NTYPE 0x00000040 |
45 | |
46 | //============================================================================ |
47 | PlotMgt_PlotterParameter::PlotMgt_PlotterParameter (const TCollection_AsciiString& aName) |
48 | { |
49 | myName = aName; |
50 | myOldName = ""; |
51 | myType = PlotMgt_TOPP_Undefined; |
52 | myIndex = -1; |
53 | myState = Standard_False; |
54 | myConfigState = Standard_False; |
55 | myIsModified = Standard_False; |
56 | //-------------------------------------------------------------- |
57 | myFlags = 0; |
58 | myDialog = ""; |
59 | myMinValue = ""; |
60 | myMaxValue = ""; |
61 | myValues = ""; |
62 | myDefValue = ""; |
63 | myMapLength = 0; |
64 | myMap = new TColStd_HSequenceOfAsciiString (); |
65 | myDescription = new TColStd_HSequenceOfAsciiString (); |
66 | //---- Find parameter's index in __PossibleParameters array ---- |
67 | Standard_Integer i = 0; |
68 | while (__PossibleParameters[i]._new_name != NULL) { |
69 | if ( myName == __PossibleParameters[i]._new_name || |
70 | (__PossibleParameters[i]._old_name && myName == __PossibleParameters[i]._old_name)) |
71 | { |
72 | if (__PossibleParameters[i]._old_name) |
73 | myOldName = __PossibleParameters[i]._old_name; |
74 | myName = __PossibleParameters[i]._new_name; |
75 | myIndex = i; |
76 | break; |
77 | } |
78 | i++; |
79 | } |
80 | if (myIndex == -1) { |
81 | cout << "PlotMgt_PlotterParameter WARNING: Unknown parameter'" |
82 | << myName << "'\n" << flush; |
83 | return; |
84 | } |
85 | } |
86 | |
87 | //============================================================================ |
88 | #define PUT_INFO(aSign,aValue) { \ |
89 | sprintf(aBuffer,"%s%s%s%s\n", myName.ToCString(), (aSign), \ |
90 | _DELIM_SIGN, aValue.ToCString()); \ |
91 | aLine += aBuffer; } |
92 | |
93 | //============================================================================ |
94 | Standard_Boolean PlotMgt_PlotterParameter::Save (OSD_File& aFile) |
95 | { |
96 | char aBuffer [1024]; |
97 | TCollection_AsciiString aLine = ""; |
98 | if (NeedToBeSaved ()) { |
99 | //----------------------------------------------------- |
100 | if (!myOldName.IsEmpty ()) { |
101 | sprintf (aBuffer, "! %s (%s) parameter\n", myName.ToCString(), |
102 | myOldName.ToCString()); |
103 | aLine += aBuffer; |
104 | } |
105 | //------------ Write Type info ------------------------ |
106 | if (myFlags & FLAG_NTYPE ) PUT_INFO(_TYPE_SIGN, PlotMgt::StringFromType (myType)); |
107 | //------------ Write dialog info ---------------------- |
108 | if (myFlags & FLAG_DIALOG) PUT_INFO(_DIALOG_SIGN, myDialog); |
109 | //------------ Write minval info ---------------------- |
110 | if (myFlags & FLAG_MINVAL) PUT_INFO(_MINVAL_SIGN, myMinValue); |
111 | //------------ Write maxval info ---------------------- |
112 | if (myFlags & FLAG_MAXVAL) PUT_INFO(_MAXVAL_SIGN, myMaxValue); |
113 | //------------ Write values info ---------------------- |
114 | if (myFlags & FLAG_VALUES) PUT_INFO(_VALUES_SIGN, myValues); |
115 | //------------ Write defavl info ---------------------- |
116 | if (myFlags & FLAG_DEFVAL) PUT_INFO("", myDefValue); |
117 | //------------ Write map info ------------------------- |
118 | if (myFlags & FLAG_LENGTH && myMapLength && !myMap.IsNull()) { |
119 | Standard_Integer i, n = myMap -> Length(); |
120 | aLine += myName; aLine += _LENGTH_SIGN; |
121 | aLine += _DELIM_SIGN; aLine += TCollection_AsciiString (myMapLength); |
122 | aLine += "\n"; |
123 | for (i = 1; i <= n; i++) |
124 | PUT_INFO("", myMap -> Value (i)); |
125 | } |
126 | //------------ Append one new line -------------------- |
127 | aLine += "\n"; |
128 | aFile.Write (aLine, aLine.Length ()); |
129 | return (!aFile.Failed ()); |
130 | } |
131 | return Standard_True; |
132 | } |
133 | |
134 | //============================================================================ |
135 | void PlotMgt_PlotterParameter::SetType (const PlotMgt_TypeOfPlotterParameter aType) |
136 | { |
137 | myType = aType; |
138 | } |
139 | |
140 | //============================================================================ |
141 | void PlotMgt_PlotterParameter::SetState (const Standard_Boolean aState) |
142 | { |
143 | myState = aState; |
144 | } |
145 | |
146 | //============================================================================ |
147 | TCollection_AsciiString PlotMgt_PlotterParameter::Name () const |
148 | { |
149 | return myName; |
150 | } |
151 | |
152 | //============================================================================ |
153 | TCollection_AsciiString PlotMgt_PlotterParameter::OldName () const |
154 | { |
155 | return myOldName; |
156 | } |
157 | |
158 | //============================================================================ |
159 | Handle(TColStd_HSequenceOfAsciiString)& PlotMgt_PlotterParameter::Description () |
160 | { |
161 | return myDescription; |
162 | } |
163 | |
164 | //============================================================================ |
165 | Standard_Boolean PlotMgt_PlotterParameter::NeedToBeSaved () const |
166 | { |
167 | return (myConfigState && (myType != _T_UNK) && (myIsModified || myState)); |
168 | } |
169 | |
170 | //============================================================================ |
171 | void PlotMgt_PlotterParameter::Dump () const |
172 | { |
173 | if (!myState || (myType == _T_UNK) || |
174 | !myConfigState || !myIsModified) |
175 | return; |
176 | |
177 | cout << "!++++++++++++++++++++++++++++++++++++++++++++" << endl << flush; |
178 | cout << "! " << myName << " "; |
179 | if (!myOldName.IsEmpty()) |
180 | cout << "(" << myOldName << ") "; |
181 | cout << "parameter" << endl << flush; |
182 | cout << myName << _TYPE_SIGN << _DELIM_SIGN |
183 | << PlotMgt::StringFromType (myType) << endl << flush; |
184 | if (myFlags & FLAG_DIALOG) |
185 | cout << myName << _DIALOG_SIGN << _DELIM_SIGN << myDialog << endl << flush; |
186 | if (myFlags & FLAG_MINVAL) |
187 | cout << myName << _MINVAL_SIGN << _DELIM_SIGN << myMinValue << endl << flush; |
188 | if (myFlags & FLAG_MAXVAL) |
189 | cout << myName << _MAXVAL_SIGN << _DELIM_SIGN << myMaxValue << endl << flush; |
190 | if (myFlags & FLAG_VALUES && (myType == _T_LSTR)) |
191 | cout << myName << _VALUES_SIGN << _DELIM_SIGN << myValues << endl << flush; |
192 | if (myFlags & FLAG_DEFVAL) |
193 | cout << myName << _DELIM_SIGN << myDefValue << endl << flush; |
194 | if (myFlags & FLAG_LENGTH && myMapLength) { |
195 | cout << myName << _LENGTH_SIGN << _DELIM_SIGN << myMapLength << endl << flush; |
196 | Standard_Integer i, n = myMap -> Length(); |
197 | for (i = 1; i <= n; i++) |
198 | cout << myName << _DELIM_SIGN << myMap -> Value (i) << endl << flush; |
199 | } |
200 | cout << "!++++++++++++++++++++++++++++++++++++++++++++" << endl << flush; |
201 | cout << endl << flush; |
202 | } |
203 | |
204 | //============================================================================ |
205 | void PlotMgt_PlotterParameter::PutCommandInfo (const Aspect_FStream& outStream) const |
206 | { |
207 | #ifdef WNT |
208 | TCollection_AsciiString _setenv_ ("set Plot_"); |
209 | TCollection_AsciiString _comment_ ("REM ######### "); |
210 | TCollection_AsciiString _delim_ (" = "); |
211 | #else |
212 | TCollection_AsciiString _setenv_ ("setenv Plot_"); |
213 | TCollection_AsciiString _comment_ ("############# "); |
214 | TCollection_AsciiString _delim_ (" "); |
215 | #endif // WNT |
216 | *outStream << _comment_ << "Parameter '" << myName << "' of type '" |
217 | << PlotMgt::StringFromType (myType) << "'" << endl; |
218 | |
219 | if (myFlags & FLAG_DEFVAL) |
220 | *outStream << _setenv_ << myName << _delim_ << "'" << myDefValue << "'" << endl; |
221 | |
222 | if (myFlags & FLAG_LENGTH && myMapLength) { |
223 | *outStream << _setenv_ << myName << "_Length" << _delim_ << myMapLength << endl; |
224 | Standard_Integer i, n = myMap -> Length(); |
225 | for (i = 1; i <= n; i++) |
226 | *outStream << _setenv_ << myName << "_" << i << _delim_ << myMap -> Value (i) << endl; |
227 | } |
228 | } |
229 | |
230 | //============================================================================ |
231 | Standard_Boolean PlotMgt_PlotterParameter::CheckListValue () |
232 | { |
233 | if (!(myFlags & FLAG_VALUES)) { |
234 | cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName |
235 | << "' has type 'list_string', but does not have [.Values] " |
236 | << "descriptor" << endl << flush; |
237 | return Standard_False; |
238 | } |
239 | TCollection_AsciiString aValues = myValues, aToken, newValues; |
240 | Standard_Boolean commaFound, defValFound = Standard_False; |
241 | Standard_Integer idx, res; |
242 | STRING_TRIM(myDefValue); |
243 | STRING_TRIM(myValues); |
244 | if (myValues.IsEmpty()) { |
245 | if (!myDefValue.IsEmpty()) { |
246 | cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName |
247 | << "' has type 'list_string', but [.Values] descriptor " |
248 | << "is empty. Defaulting to '" << myDefValue << "'" << endl << flush; |
249 | myValues = myDefValue; |
250 | return Standard_True; |
251 | } else { |
252 | cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName |
253 | << "' has type 'list_string', but [.Values] descriptor " |
254 | << "and default values are empty." << endl << flush; |
255 | return Standard_False; |
256 | } |
257 | } |
258 | do { |
259 | idx = aValues.Search (","); |
260 | commaFound = (idx != -1); |
261 | if (commaFound) { |
262 | aToken = aValues.Token (",", 1); |
263 | res = aValues.Search (aToken); |
264 | if (res != 1) |
265 | aValues.Remove (1, res - 1); |
266 | aValues.Remove (1, aToken.Length() + 1); |
267 | } else { |
268 | aToken = aValues; |
269 | } |
270 | STRING_TRIM(aToken); |
271 | // Still trying to find default value |
272 | if (!defValFound) |
273 | defValFound = (aToken == myDefValue); |
274 | // Append new values with a token |
275 | if (!aToken.IsEmpty()) |
276 | newValues += aToken; |
277 | if (commaFound && !aToken.IsEmpty()) |
278 | newValues += ","; |
279 | } while (commaFound); |
280 | // Check the default value |
281 | if (!defValFound) { |
282 | cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName |
283 | << "' has type 'list_string'. "; |
284 | if (myFlags & FLAG_DEFVAL) |
285 | cout << "But the default value '" << myDefValue << "' is not found. "; |
286 | else |
287 | cout << "But does not have default value. "; |
288 | cout << "Defaulting to the first from the list." << endl << flush; |
289 | idx = newValues.Search (","); |
290 | if (idx != -1) myDefValue = newValues.Token (",", 1); |
291 | else myDefValue = newValues; |
292 | myFlags |= FLAG_DEFVAL; |
293 | } |
294 | // Use new values as default |
295 | myValues = newValues; |
296 | return Standard_True; |
297 | } |
298 | |
299 | //============================================================================ |
300 | void PlotMgt_PlotterParameter::ProcessParamVal ( |
301 | const Standard_CString aParamSign, |
302 | const Standard_Integer aFlag, |
303 | TCollection_AsciiString& aValue) |
304 | { |
305 | Standard_Integer i, n = myDescription -> Length (); |
306 | Standard_Boolean fFound = Standard_False; |
307 | TCollection_AsciiString searchStr = myName, aLine; |
308 | //JR/Hp |
309 | searchStr += (Standard_CString ) (aParamSign ? aParamSign : ""); |
310 | // searchStr += (aParamSign ? aParamSign : ""); |
311 | searchStr += _DELIM_SIGN; |
312 | |
313 | aValue = ""; |
314 | for (i = n; i >= 1; i--) { |
315 | aLine = myDescription -> Value(i); |
316 | Standard_Integer res = aLine.Search(searchStr); |
317 | if (res != -1) { |
318 | aLine.Remove (1, searchStr.Length()); |
319 | STRING_TRIM(aLine); |
320 | myFlags |= aFlag; |
321 | aValue = aLine; |
322 | fFound = Standard_True; |
323 | // Remove all other <aParamSign> strings |
324 | Standard_Integer j = 1; |
325 | while (j <= n) { |
326 | if (myDescription -> Value(j).Search(searchStr) != -1) { |
327 | myDescription -> Remove (j); |
328 | n--; |
329 | } else j++; |
330 | } |
331 | break; |
332 | } |
333 | } |
334 | } |
335 | |
336 | //============================================================================ |
337 | void PlotMgt_PlotterParameter::Normalize () |
338 | { |
339 | Standard_Integer n, i; |
340 | TCollection_AsciiString aMapLen; |
341 | // Quit if the parameter is not found in __PossibleParameters |
342 | if (myIndex == -1) |
343 | goto _CLEAR_AND_EXIT; |
344 | // Check parameter's type in __PossibleParameters array |
345 | if (myType == _T_UNK || myType != __PossibleParameters[myIndex]._type) { |
346 | cout << "PlotMgt_PlotterParameter WARNING: Incorrect type of '" |
347 | << myName << "' parameter : '" |
348 | << PlotMgt::StringFromType (myType) << "' instead of '" |
349 | << PlotMgt::StringFromType (__PossibleParameters[myIndex]._type) |
350 | << "'. Using right TYPE.\n" << flush; |
351 | myType = __PossibleParameters[myIndex]._type; |
352 | myFlags |= FLAG_NTYPE; |
353 | } |
354 | // Change old names to new ones (if any) |
355 | if (!myOldName.IsEmpty ()) { |
356 | n = myDescription -> Length (); |
357 | TCollection_AsciiString aLine; |
358 | for (i = 1; i <= n; i++) { |
359 | aLine = myDescription -> Value (i); |
360 | Standard_Integer res = aLine.Search (myOldName); |
361 | if (res != -1) { |
362 | aLine.Remove (1, myOldName.Length()); |
363 | aLine.Insert (1, myName); |
364 | myDescription -> SetValue (i, aLine); |
365 | } |
366 | } |
367 | } |
368 | // Normalize parameter (build all necessary values) |
369 | ProcessParamVal (_DIALOG_SIGN, FLAG_DIALOG, myDialog); |
370 | ProcessParamVal (_MINVAL_SIGN, FLAG_MINVAL, myMinValue); |
371 | ProcessParamVal (_MAXVAL_SIGN, FLAG_MAXVAL, myMaxValue); |
372 | ProcessParamVal (_VALUES_SIGN, FLAG_VALUES, myValues); |
373 | ProcessParamVal (_LENGTH_SIGN, FLAG_LENGTH, aMapLen); |
374 | if ((myFlags & FLAG_LENGTH) && aMapLen.IsIntegerValue()) |
375 | myMapLength = aMapLen.IntegerValue(); |
376 | switch (myType) { |
377 | case _T_INT: |
378 | case _T_REAL: |
379 | case _T_BOOL: |
380 | case _T_STR: { |
381 | if (!__PossibleParameters[myIndex]._ismap) { |
382 | ProcessParamVal (NULL, FLAG_DEFVAL, myDefValue); |
383 | } else { |
384 | n = myDescription -> Length (); |
385 | // There must me at least <myMapLen> of default values |
386 | if (myMapLength > n || myMapLength == 0) { |
387 | cout << "PlotMgt_PlotterParameter WARNING: Bad Map description: present " |
388 | << "only " << n << " instead of " << myMapLength << " values in '" |
389 | << myName << "'" << endl; |
390 | goto _CLEAR_AND_EXIT; |
391 | } |
392 | // Put lines from the end of description |
393 | for (i = n - myMapLength + 1; i <= n; i++) |
394 | myMap -> Append (myDescription -> Value (i)); |
395 | myFlags &= ~FLAG_DEFVAL; |
396 | // Leave only map values |
397 | TCollection_AsciiString remStr = (myName + _DELIM_SIGN), aLine; |
398 | n = myMap -> Length (); |
399 | for (i = 1; i <= n; i++) { |
400 | aLine = myMap -> Value (i); |
401 | if (aLine.Search(remStr) != -1) { |
402 | aLine.Remove (1, remStr.Length()); |
403 | myMap -> SetValue (i, aLine); |
404 | } |
405 | } |
406 | } |
407 | } break; |
408 | case _T_LSTR: { |
409 | ProcessParamVal (NULL, FLAG_DEFVAL, myDefValue); |
410 | } break; |
7fd59977 |
411 | default: |
412 | break ; |
7fd59977 |
413 | } |
414 | // Check the configuration |
415 | if (myFlags & FLAG_DEFVAL && myDefValue.IsEmpty()) |
416 | myFlags &= ~FLAG_DEFVAL; |
417 | if (myFlags & FLAG_DEFVAL && (myType == _T_INT)) { |
418 | if (!myDefValue.IsIntegerValue()) { |
419 | myDefValue = ""; |
420 | myFlags &= ~FLAG_DEFVAL; |
421 | } |
422 | } |
423 | if (myFlags & FLAG_DEFVAL && (myType == _T_REAL)) { |
424 | if (!myDefValue.IsRealValue()) { |
425 | myDefValue = ""; |
426 | myFlags &= ~FLAG_DEFVAL; |
427 | } |
428 | } |
429 | if (myFlags & FLAG_DEFVAL && (myType == _T_BOOL)) { |
430 | STRING_TRIM(myDefValue); |
431 | myDefValue.LowerCase (); |
432 | if (myDefValue.IsEmpty ()) |
433 | myFlags &= ~FLAG_DEFVAL; |
434 | } |
435 | if (myType == _T_LSTR && !CheckListValue ()) |
436 | goto _CLEAR_AND_EXIT; |
437 | // Indicate that parameter is configured properly |
438 | myConfigState = Standard_True; |
439 | _CLEAR_AND_EXIT: |
440 | //Dump (); |
441 | // We do not need it anymore |
442 | myDescription->Clear (); |
443 | myDescription.Nullify(); |
444 | } |
445 | |
446 | //============================================================================ |
447 | //============================================================================ |
448 | //============================================================================ |
449 | #define GET_BAD_TYPE_INFO(aGetType) \ |
450 | cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ |
451 | << "' of type '" << PlotMgt::StringFromType (myType) \ |
452 | << "' requested about " << aGetType << " value" \ |
453 | << endl << flush; |
454 | |
455 | #define GET_EMPTY_VALUE_INFO(aValue) \ |
456 | cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ |
457 | << "' of type '" << PlotMgt::StringFromType (myType) \ |
458 | << "' has no default value." \ |
459 | << "Defaulting to " << aValue << "." << endl << flush; |
460 | |
461 | //============================================================================ |
462 | void PlotMgt_PlotterParameter::SValue (TCollection_AsciiString& aValue) const |
463 | { |
464 | aValue = ""; |
465 | if ((myType == _T_STR) || (myType == _T_LSTR)) { |
466 | if (myFlags & FLAG_DEFVAL && !myDefValue.IsEmpty()) { |
467 | aValue = myDefValue; |
468 | } else |
469 | GET_EMPTY_VALUE_INFO("empty string"); |
470 | } else |
471 | GET_BAD_TYPE_INFO("STRING"); |
472 | } |
473 | |
474 | //============================================================================ |
475 | Standard_Boolean PlotMgt_PlotterParameter::BValue () const |
476 | { |
477 | if (myType == _T_BOOL) { |
478 | if (myFlags & FLAG_DEFVAL && !myDefValue.IsEmpty()) { |
479 | if (myDefValue.IsEqual("true") || |
480 | myDefValue.IsIntegerValue() && myDefValue.IntegerValue()) |
481 | return Standard_True; |
482 | } else |
483 | GET_EMPTY_VALUE_INFO("FALSE"); |
484 | } else |
485 | GET_BAD_TYPE_INFO("BOOLEAN"); |
486 | return Standard_False; |
487 | } |
488 | |
489 | //============================================================================ |
490 | Standard_Integer PlotMgt_PlotterParameter::IValue () const |
491 | { |
492 | if (myType == _T_INT) { |
493 | if (myFlags & FLAG_DEFVAL) { |
494 | return myDefValue.IntegerValue (); |
495 | } else |
496 | GET_EMPTY_VALUE_INFO("0"); |
497 | } else |
498 | GET_BAD_TYPE_INFO("INTEGER"); |
499 | return 0; |
500 | } |
501 | |
502 | //============================================================================ |
503 | Standard_Real PlotMgt_PlotterParameter::RValue () const |
504 | { |
505 | if (myType == _T_REAL) { |
506 | if (myFlags & FLAG_DEFVAL) { |
507 | return myDefValue.RealValue (); |
508 | } else |
509 | GET_EMPTY_VALUE_INFO("0.0"); |
510 | } else |
511 | GET_BAD_TYPE_INFO("REAL"); |
512 | return 0.0; |
513 | } |
514 | |
515 | //============================================================================ |
516 | void PlotMgt_PlotterParameter::LValues (Handle(TColStd_HSequenceOfAsciiString)& aList) const |
517 | { |
518 | if (!aList.IsNull ()) { |
519 | aList->Clear (); |
520 | aList.Nullify (); |
521 | } |
522 | aList = new TColStd_HSequenceOfAsciiString (); |
523 | if (myType != _T_LSTR) { |
524 | GET_BAD_TYPE_INFO("LIST_STRING"); |
525 | return; |
526 | } |
527 | TCollection_AsciiString aToken, aValues = myValues; |
528 | Standard_Boolean commaFound; |
529 | Standard_Integer idx; |
530 | do { |
531 | idx = aValues.Search (","); |
532 | commaFound = (idx != -1); |
533 | if (commaFound) { |
534 | aToken = aValues.Token (",", 1); |
535 | aValues.Remove (1, aToken.Length() + 1); |
536 | } else { |
537 | aToken = aValues; |
538 | } |
539 | aList -> Append (aToken); |
540 | } while (commaFound); |
541 | } |
542 | |
543 | //============================================================================ |
544 | Handle(TColStd_HSequenceOfAsciiString) PlotMgt_PlotterParameter::MValue () const |
545 | { |
546 | if (!(myFlags & FLAG_LENGTH && myMapLength)) |
547 | GET_BAD_TYPE_INFO("MAP_VALUE"); |
548 | return myMap; |
549 | } |
550 | |
551 | //============================================================================ |
552 | //============================================================================ |
553 | //============================================================================ |
554 | #define SET_VALUE() \ |
555 | myDefValue = aValue; \ |
556 | myFlags = FLAG_DEFVAL; \ |
557 | myIsModified = Standard_True; |
558 | // myFlags != FLAG_DEFVAL; |
559 | |
560 | #define SET_BAD_TYPE_INFO(aSetType) \ |
561 | { \ |
562 | cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ |
563 | << "' of type '" << PlotMgt::StringFromType (myType) \ |
564 | << "' requested to set " << aSetType << " value" \ |
565 | << endl << flush; \ |
566 | return; \ |
567 | } |
568 | |
569 | //============================================================================ |
570 | void PlotMgt_PlotterParameter::SetSValue (const TCollection_AsciiString& aValue) |
571 | { |
572 | if (myType != _T_STR && myType != _T_LSTR) |
573 | SET_BAD_TYPE_INFO("STRING"); |
574 | SET_VALUE(); |
575 | } |
576 | |
577 | //============================================================================ |
578 | void PlotMgt_PlotterParameter::SetBValue (const Standard_Boolean aValue) |
579 | { |
580 | if (myType != _T_BOOL) |
581 | SET_BAD_TYPE_INFO("BOOL"); |
582 | //JR/Hp |
583 | myDefValue = (Standard_CString ) (aValue ? "true" : "false"); |
584 | // myDefValue = (aValue ? "true" : "false"); |
585 | // myFlags != FLAG_DEFVAL; |
586 | myFlags = FLAG_DEFVAL; |
587 | myIsModified = Standard_True; |
588 | } |
589 | |
590 | //============================================================================ |
591 | void PlotMgt_PlotterParameter::SetIValue (const Standard_Integer aValue) |
592 | { |
593 | if (myType != _T_INT) |
594 | SET_BAD_TYPE_INFO("INTEGER"); |
595 | SET_VALUE(); |
596 | } |
597 | |
598 | //============================================================================ |
599 | void PlotMgt_PlotterParameter::SetRValue (const Standard_Real aValue) |
600 | { |
601 | if (myType != _T_REAL) |
602 | SET_BAD_TYPE_INFO("REAL"); |
603 | SET_VALUE(); |
604 | } |
605 | |
606 | //============================================================================ |
607 | void PlotMgt_PlotterParameter::SetMValue (const Handle(TColStd_HSequenceOfAsciiString)& aMap) |
608 | { |
609 | if (!(myFlags & FLAG_LENGTH && myMapLength)) |
610 | SET_BAD_TYPE_INFO("MAP_VALUE"); |
611 | myMap = aMap; |
612 | myMapLength = myMap -> Length (); |
613 | myIsModified = Standard_True; |
614 | } |