Salome HOME
Copyright update: 2016
[modules/gui.git] / src / DDS / DDS_DicItem.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "DDS_DicItem.h"
24 #include "DDS_Dictionary.h"
25
26 #include <TColStd_SequenceOfInteger.hxx>
27 #include <TColStd_SequenceOfExtendedString.hxx>
28
29 #include <LDOM_Text.hxx>
30 #include <LDOMString.hxx>
31 #include <LDOM_Element.hxx>
32
33 #include <UnitsAPI.hxx>
34 #include <Units_Dimensions.hxx>
35
36 #include <TColStd_MapOfReal.hxx>
37 #include <TColStd_SequenceOfAsciiString.hxx>
38
39 IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
40 IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared)
41
42 /*!
43   \class DDS_DicItem
44   \brief This class provides an information about datum (phisical characteristic parameter).
45 */
46
47 /*!
48   \brief Constructor.
49
50   Creates the instance of empty dictionary item.
51 */
52 DDS_DicItem::DDS_DicItem()
53 : myType( 0 ),
54   myMax( 0 ),
55   myMin( 0 ),
56   myDefValue( 0 ),
57   myMinZoom( 0.1 ),
58   myMaxZoom( 10 ),
59   myZoomOrder( 2 )
60 {
61 }
62
63 /*!
64   \brief Copy constructor (put in private section to prevent object copying).
65 */
66 DDS_DicItem::DDS_DicItem( const DDS_DicItem& )
67 {
68 }
69
70 /*!
71   \brief Assignment operator (put in private section to prevent object copying).
72 */
73 void DDS_DicItem::operator=( const DDS_DicItem& )
74 {
75 }
76
77 /*!
78   \brief Get the identifier of parameter.
79   \return parameter ID
80 */
81 TCollection_AsciiString DDS_DicItem::GetId() const
82 {
83   return myId;
84 }
85
86 /*!
87   \brief Get the type of parameter.
88   \return parameter type
89 */
90 DDS_DicItem::Type DDS_DicItem::GetType() const
91 {
92   return (DDS_DicItem::Type)myType;
93 }
94
95 /*!
96   \brief Get the label of the parameter.
97   \return parameter label
98 */
99 TCollection_ExtendedString DDS_DicItem::GetLabel() const
100 {
101   return myLabel;
102 }
103
104 /*!
105   \brief Get the filter (regular expression) for the parameter values.
106   \return parameter filter
107 */
108 TCollection_ExtendedString DDS_DicItem::GetFilter() const
109 {
110   return myFilter;
111 }
112
113 /*!
114   \brief Get the Required attribute of the parameter.
115   \return Required attribute
116 */
117 TCollection_ExtendedString DDS_DicItem::GetRequired() const
118 {
119   return myRequired;
120 }
121
122 /*!
123   \brief Get the wrong value warning level of the parameter.
124   \return warning level
125 */
126 DDS_MsgType DDS_DicItem::GetWarningLevel() const
127 {
128   return (DDS_MsgType)myWarnLevel;
129 }
130
131 /*!
132   \brief Get the long description of the parameter.
133   \return long description
134 */
135 TCollection_ExtendedString DDS_DicItem::GetLongDescription() const
136 {
137   return myLongDescr;
138 }
139
140 /*!
141   \brief Get the short description of the parameter.
142   \return short description
143 */
144 TCollection_ExtendedString DDS_DicItem::GetShortDescription() const
145 {
146   return myShortDescr;
147 }
148
149 /*!
150   \brief Get the name of the component (parameter owner).
151   \return component name
152 */
153 TCollection_AsciiString DDS_DicItem::GetComponent() const
154 {
155   TCollection_AsciiString aCompName;
156   Handle(DDS_DicGroup) aComponent = Handle(DDS_DicGroup)::DownCast(myComponent);
157   if ( !aComponent.IsNull() )
158     aCompName = aComponent->GetName();
159   return aCompName;
160 }
161
162 /*!
163   \brief Get the parameter measure units for active units system.
164   \return parameter units
165 */
166 TCollection_AsciiString DDS_DicItem::GetUnits() const
167 {
168   return GetUnits( GetActiveUnitSystem() );
169 }
170
171 /*!
172   \brief Get the parameter measure units for specified units system \a theSystem.
173
174   If specified units system doesn't exist, empty string is returned.
175
176   \param theSystem units system
177   \return parameter units
178 */
179 TCollection_AsciiString DDS_DicItem::GetUnits( const UnitSystem& theSystem ) const
180 {
181   TCollection_AsciiString anUnits;
182   UnitData* unitData = GetUnitData( theSystem );
183   if ( unitData )
184     anUnits = unitData->myUnits;
185   return anUnits;
186 }
187
188 /*!
189   \brief Get the minimum value of the parameter for active units system.
190   
191   Returned value is converted to SI.
192   
193   \return minimum value
194 */
195 Standard_Real DDS_DicItem::GetMinValue() const
196 {
197   return GetMinValue( GetActiveUnitSystem() );
198 }
199
200 /*!
201   \brief Get the minimum value of the parameter for the specified 
202          units system \a theSystem.
203          
204   Returned value is converted to SI.
205
206   \param theUnitsSystem units system
207   \return minimum value
208 */
209 Standard_Real DDS_DicItem::GetMinValue( const UnitSystem& theUnitsSystem ) const
210 {
211   return FromSI( myMin, theUnitsSystem );
212 }
213
214 /*!
215   \brief Get the maximum value of the parameter for active units system.
216
217   Returned value converted to SI.
218   
219   \return maximum value
220 */
221 Standard_Real DDS_DicItem::GetMaxValue() const
222 {
223   return GetMaxValue( GetActiveUnitSystem() );
224 }
225
226 /*!
227   \brief Get the maximum value of the parameter for specified 
228          units system \a theSystem.
229  
230   Returned value converted to SI.
231   
232   \param theUnitsSystem units system
233   \return maximum value
234 */
235 Standard_Real DDS_DicItem::GetMaxValue( const UnitSystem& theUnitsSystem ) const
236 {
237   return FromSI( myMax, theUnitsSystem );
238 }
239
240 /*!
241   \brief Get the precision (number of digits after decimal point) 
242          of the parameter for active units system.
243   \return parameter precision
244 */
245 Standard_Integer DDS_DicItem::GetPrecision() const
246 {
247   return GetPrecision( GetActiveUnitSystem() );
248 }
249
250 /*!
251   \brief Get the precision (number of digits after decimal point) of the parameter
252   for specified units system \a theSystem. 
253
254   If specified units system doesn't exist, zero is returned.
255
256   \param theSystem units system
257   \return parameter precision
258 */
259 Standard_Integer DDS_DicItem::GetPrecision( const UnitSystem& theSystem ) const
260 {
261   Standard_Integer aRes = 0;
262   UnitData* unitData = GetUnitData( theSystem );
263   if ( unitData )
264     aRes = unitData->myPrecision;
265   return aRes;
266 }
267
268 /*!
269   \brief Get the default value of the parameter for active units system.
270   
271   Default value is returned as string.
272   If type of the value is numerical (Float or Integer) and default value
273   is defined, then the returning value is converted to SI.
274
275   \return default value
276 */
277 TCollection_ExtendedString DDS_DicItem::GetDefaultValue() const
278 {
279   return GetDefaultValue( GetActiveUnitSystem() );
280 }
281
282 /*!
283   \brief Get the default value of the parameter for specified 
284          units system \a theSystem.
285   
286   Default value is returned as string.
287   If type of the value is numerical (Float or Integer) and default value
288   is defined, then the returning value is converted to SI.
289
290   \param theSystem units system
291   \return default value
292 */
293 TCollection_ExtendedString DDS_DicItem::GetDefaultValue( const UnitSystem& theSystem ) const
294 {
295   if ( !myDefString.Length() )
296     return myDefString;
297
298   TCollection_ExtendedString aStr;
299
300   switch ( myType )
301   {
302   case Float:
303   case Integer:
304     aStr = FromSI( myDefValue, theSystem );
305     break;
306   case List:
307   case String:
308     aStr = myDefString;
309     break;
310   default:
311     break;
312   }
313   return aStr;
314 }
315
316 /*!
317   \brief Get the format string of the parameter for active units system.
318
319   If argument \a theCanonical is \c true, format string is reduced according
320   to the sprintf() specification (without extra non standard qualifiers).
321
322   \param theCanonical 'canonical form' flag
323   \return format string
324 */
325 TCollection_AsciiString DDS_DicItem::GetFormat( const Standard_Boolean theCanonical ) const
326 {
327   return GetFormat( GetActiveUnitSystem(), theCanonical );
328 }
329
330 /*!
331   \brief Get the format string of the parameter for specified 
332          units system \a theSystem.
333
334   If argument \a theCanonical is \c true, format string is reduced according
335   to the sprintf() specification (without extra non standard qualifiers).
336
337   \param theSystem units system
338   \param theCanonical 'canonical form' flag
339   \return format string
340 */
341 TCollection_AsciiString DDS_DicItem::GetFormat( const UnitSystem& theSystem,
342                                                 const Standard_Boolean theCanonical ) const
343 {
344   TCollection_AsciiString aFormat;
345   UnitData* unitData = GetUnitData( theSystem );
346   if ( unitData )
347     aFormat = unitData->myFormat;
348
349   if ( theCanonical && aFormat.Length() > 1 )
350   {
351     static TCollection_AsciiString f;
352     f = aFormat;
353     Standard_Boolean isRemoved = false;
354     while ( !isRemoved )
355     {
356       char ch = f.Value( f.Length() - 1 );
357       if ( ( ch != '%' && ch != '.' && !IsDigit( ch ) ) && f.Length() > 1 )
358         f.Remove( f.Length() - 1 );
359       else
360         isRemoved = true;
361     }
362     aFormat = f;
363   }
364
365   return aFormat;
366 }
367
368 /*!
369   \brief Get the name of a list referenced by the parameter.
370
371   This string is empty if the list reference is not defined.
372   In this case, other properties (Type, DefaultValue, MaxValue, MinValue)
373   should be used.
374   
375   \return referenced list name
376   \sa GetListOfValues()
377 */
378 TCollection_ExtendedString DDS_DicItem::GetNameOfValues() const
379 {
380   return myListName;
381 }
382
383 /*!
384   \brief Get item names and item identifiers of a list referenced
385          by the parameter.
386
387   These sequences are empty if the list reference is not defined.
388   In this case, other properties (Type, DefaultValue, MaxValue, MinValue)
389   should be used.
390
391   \param theStrings returning items names
392   \param theIntegers returning items identifiers
393   \return \c true if returning lists are not empty
394   \sa GetNameOfValues()
395 */
396 Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
397                                                Handle(TColStd_HArray1OfInteger)& theIntegers ) const
398 {
399   theStrings  = myListRef;
400   theIntegers = myListRefID;
401   return !theIntegers.IsNull() && !theStrings.IsNull();
402 }
403
404 /*!
405   \brief Get item names, item identifiers and item icons of a list
406          referenced by the parameter.
407
408   \overload
409
410   These sequences are empty if the list reference is not defined.
411   In this case, other properties (Type, DefaultValue, MaxValue, MinValue)
412   should be used.
413
414   \param theStrings returning items names
415   \param theIntegers returning items identifiers
416   \param theIcons returning items icons
417   \return \c true if returning lists are not empty
418   \sa GetNameOfValues()
419 */
420 Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
421                                                Handle(TColStd_HArray1OfInteger)& theIntegers,
422                                                Handle(TColStd_HArray1OfExtendedString)& theIcons ) const
423 {
424   theStrings  = myListRef;
425   theIntegers = myListRefID;
426   theIcons    = myListRefIcons;
427   return !theIntegers.IsNull() && !theStrings.IsNull() && !theIcons.IsNull();
428 }
429
430
431 /*!
432   \brief Get special values of the parameter.
433   \param theMap returning map of the special values
434   \return \c true if returning map is not empty
435 */
436 Standard_Boolean DDS_DicItem::GetSpecialValues( TColStd_MapOfReal& theMap ) const
437 {
438   theMap.Clear();
439   if ( !myListRef.IsNull() )
440   {
441     for ( Standard_Integer i = myListRef->Lower(); i <= myListRef->Upper(); i++ )
442     {
443       if ( myListRef->Value( i ).IsAscii() )
444       {
445         TCollection_AsciiString aStr( myListRef->Value( i ) );
446         if ( aStr.IsRealValue() )
447           theMap.Add( aStr.RealValue() );
448       }
449     }
450   }
451
452   return theMap.Extent() > 0;
453 }
454
455 /*!
456   \brief Get minimum value of lateral zooming.
457   \return lateral zooming minimum value
458 */
459 Standard_Real DDS_DicItem::GetMinZoom() const
460 {
461   return myMinZoom;
462 }
463
464 /*!
465   \brief Get maximum value of lateral zooming.
466   \return lateral zooming maximum value
467 */
468 Standard_Real DDS_DicItem::GetMaxZoom() const
469 {
470   return myMaxZoom;
471 }
472
473 /*!
474   \brief Get order of lateral zooming.
475   \return lateral zooming order
476 */
477 Standard_Real DDS_DicItem::GetZoomOrder() const
478 {
479   return myZoomOrder;
480 }
481
482 /*!
483   \brief Convert value \a theVal to the default SI units
484          according to the active units system.
485   \param theVal value being converted
486   \return value converted to SI
487 */
488 Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal ) const
489 {
490   return ToSI( theVal, GetActiveUnitSystem() );
491 }
492
493 /*!
494   \brief Convert value \a theVal from the default SI units
495          according to the active units system.
496   \param theVal value being converted
497   \return value converted from SI
498 */
499 Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal ) const
500 {
501   return FromSI( theVal, GetActiveUnitSystem() );
502 }
503
504 /*!
505   \brief Convert value to the default SI units according to the 
506          units system \a theUnitsSystem.
507   \param theVal value being converted
508   \param theUnitsSystem units system
509   \return value converted to the specified units system
510 */
511 Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
512 {
513   Standard_Real aRes = theVal;
514   UnitData* anUnitData = GetUnitData( theUnitsSystem );
515   if ( anUnitData )
516     aRes = anUnitData->myZero + aRes * anUnitData->myScale;
517   return aRes;
518 }
519
520 /*!
521   \brief Convert value from the default SI units according to the
522          units system \a theUnitsSystem.
523   \param theVal value being converted
524   \param theUnitsSystem units system
525   \return value converted from the specified units system
526 */
527 Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
528 {
529   Standard_Real aRes = theVal;
530   UnitData* anUnitData = GetUnitData( theUnitsSystem );
531   if ( anUnitData )
532     aRes = ( aRes - anUnitData->myZero ) / anUnitData->myScale;
533   return aRes;
534 }
535
536 /*!
537   \brief Check data existence.
538   \param flag data flag
539   \return \c true if data specified by \a flag exists
540 */
541 Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const
542 {
543   return ( myData & flag ) == flag;
544 }
545
546 /*!
547   \brief Get option for specified name \a name.
548   
549   If option is not found, empty string is returned.
550
551   \param name option name
552   \return option value
553 */
554 TCollection_ExtendedString DDS_DicItem::GetOption( const TCollection_AsciiString& name ) const
555 {
556   TCollection_ExtendedString res;
557   if ( myOptions.IsBound( name ) )
558     res = myOptions.Find( name );
559   return res;
560 }
561
562 /*!
563   \brief Get names of all existing options.
564   \param names returning list of options
565   \return \c true if list is not empty
566 */
567 Standard_Boolean DDS_DicItem::GetOptionNames( TColStd_SequenceOfAsciiString& names ) const
568 {
569   names.Clear();
570
571   for ( OptionsMap::Iterator it( myOptions ); it.More(); it.Next() )
572     names.Append( it.Key() );
573
574   return !names.IsEmpty();
575 }
576
577
578 /*!
579   \brief Parse record from XML file and retrieve information relevant for 
580          the dictionary item.
581   \param theID item identifier
582   \param theDatum datum XML node
583   \param theCompElement component XML node
584   \param theDocElement document XML node
585   \param theSystems units system names
586 */
587 void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element& theDatum,
588                                const LDOM_Element& theCompElement, const LDOM_Element& theDocElement,
589                                const TColStd_SequenceOfAsciiString& theSystems )
590 {
591   TCollection_AsciiString aLabel    = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_LABEL" ) );
592   TCollection_AsciiString aFormat   = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FORMAT" ) );
593   TCollection_AsciiString aFilter   = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_FILTER" ) );
594   TCollection_AsciiString aRequired = theDatum.getAttribute( DDS_Dictionary::KeyWord( "DATUM_REQUIRED" ) );
595
596   TCollection_AsciiString aBaseKeyWord = DDS_Dictionary::KeyWord( "DATUM_UNITS" );
597
598   for ( Standard_Integer j = 1; j <= theSystems.Length(); j++ )
599   {
600     UnitSystem anUnitSystem = theSystems.Value( j );
601     if ( !anUnitSystem.Length() )
602       continue;
603
604     TCollection_AsciiString aUnitKeyword = anUnitSystem + aBaseKeyWord;
605
606     if ( !myUnitData.IsBound( anUnitSystem ) )
607       myUnitData.Bind( anUnitSystem, UnitData() );
608
609     UnitData& anUnitData = myUnitData.ChangeFind( anUnitSystem );
610     anUnitData.myUnits = theDatum.getAttribute( LDOMString( aUnitKeyword.ToCString() ) );
611   }
612
613   if ( theSystems.Length() && myUnitData.IsBound( theSystems.First() ) &&
614        !myUnitData.Find( theSystems.First() ).myUnits.Length() )
615   {
616     TCollection_AsciiString units = theDatum.getAttribute( LDOMString( aBaseKeyWord.ToCString() ) );
617     if ( units.Length() )
618       myUnitData.ChangeFind( theSystems.First() ).myUnits = units;
619   }
620
621   TCollection_AsciiString units;
622   for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator iter( myUnitData ); iter.More() && units.IsEmpty(); iter.Next() )
623     units = iter.Value().myUnits;
624
625   for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator itr( myUnitData ); itr.More(); itr.Next() )
626   {
627     UnitData& dataUnits = itr.ChangeValue();
628     if ( dataUnits.myUnits.IsEmpty() )
629       dataUnits.myUnits = units;
630   }
631   
632   // 2. Elements ( domain, description )
633   Standard_Real aRealMinV = 0;
634   Standard_Real aRealMaxV = 0;
635   Standard_Real aRealDefV = 0;
636
637   TCollection_AsciiString aType;
638
639   DDS_MsgType aWrongValue = DDS_MT_NONE;
640   DDS_DicItem::Type aEnumType = DDS_DicItem::Unknown;
641
642   TCollection_AsciiString aMinV;
643   TCollection_AsciiString aMaxV;
644   TCollection_AsciiString aDefV;
645   TCollection_AsciiString aListName;
646
647   TCollection_AsciiString aLongD;
648   TCollection_AsciiString aShortD;
649
650   TColStd_SequenceOfInteger aSeqOfValueID;
651   TColStd_SequenceOfExtendedString aSeqOfValue;
652   TColStd_SequenceOfExtendedString aSeqOfValueIconName;
653
654   // Presentation
655   Standard_Real aMinZoom   = 0;
656   Standard_Real aMaxZoom   = 0;
657   Standard_Real aZoomOrder = 0;
658
659   // Datum::Reports tags (if any)
660   LDOM_Element aWLev = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "WARNING_LEVEL" ) );
661   if ( !aWLev.isNull() )
662   {
663     TCollection_AsciiString aWrongValWL = aWLev.getAttribute( DDS_Dictionary::KeyWord( "WRONG_VALUE" ) );
664     if ( aWrongValWL.IsEqual( "Info" ) )
665       aWrongValue = DDS_MT_INFO;
666     else if ( aWrongValWL.IsEqual( "Warning" ) )
667       aWrongValue = DDS_MT_WARNING;
668     else if ( aWrongValWL.IsEqual( "Alarm" ) )
669       aWrongValue = DDS_MT_ALARM;
670     else if ( aWrongValWL.IsEqual( "Error" ) )
671       aWrongValue = DDS_MT_ERROR;
672   }
673
674   // Datum::Presentation
675   LDOM_Element aPrs = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "PRS" ) );
676   if ( !aPrs.isNull() )
677   {
678     LDOM_Element aLateralZoom = aPrs.GetChildByTagName( DDS_Dictionary::KeyWord( "LATERAL_ZOOM" ) );
679     if ( !aLateralZoom.isNull() )
680     {
681       TCollection_AsciiString aMinZoomStr   = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_MINV" ) );
682       TCollection_AsciiString aMaxZoomStr   = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_MAXV" ) );
683       TCollection_AsciiString aZoomOrderStr = aLateralZoom.getAttribute( DDS_Dictionary::KeyWord( "LZ_ORDER" ) );
684       
685       aMinZoomStr.RemoveAll( ' ' );
686       if ( aMinZoomStr.IsRealValue() )
687         aMinZoom = aMinZoomStr.RealValue();
688
689       aMaxZoomStr.RemoveAll( ' ' );
690       if ( aMaxZoomStr.IsRealValue() )
691         aMaxZoom = aMaxZoomStr.RealValue();
692
693       aZoomOrderStr.RemoveAll( ' ' );
694       if ( aZoomOrderStr.IsRealValue() )
695         aZoomOrder = aZoomOrderStr.RealValue();
696     }
697   }
698
699   // Quantity::Domain record as the only child of that tag name
700   LDOM_Element aDomain = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "DY_DOMAIN" ) );
701   if ( !aDomain.isNull() )
702   {
703     LDOM_Element aValueDescr = aDomain.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_DESCR" ) );
704     if ( !aValueDescr.isNull() )
705     {
706       // read: valueDescr? (type?,min?,max?,default?)
707       aType = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_TYPE" ) );
708       if ( aType.IsEqual( "String" ) )
709         aEnumType = String;
710       else if ( aType.IsEqual( "Float" ) )
711         aEnumType = Float;
712       else if ( aType.IsEqual( "Integer" ) )
713         aEnumType = Integer;
714
715       if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MINV" ) ).isNull() )
716         myData |= MinValue;
717       aMinV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MINV" ) );
718       aMinV.RemoveAll( ' ' );
719       if ( aMinV.IsRealValue() )
720         aRealMinV = aMinV.RealValue();
721       if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MAXV" ) ).isNull() )
722         myData |= MaxValue;
723       aMaxV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MAXV" ) );
724       aMaxV.RemoveAll( ' ' );
725       if ( aMaxV.IsRealValue() )
726         aRealMaxV = aMaxV.RealValue();
727       aDefV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
728       if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_DEFV" ) ).isNull() )
729         myData |= DefaultValue;
730
731       aDefV.RemoveAll( ' ' );
732       if ( aDefV.IsRealValue() )
733         aRealDefV = aDefV.RealValue();
734
735       TCollection_AsciiString aSpecVal = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_SPEC" ) );
736       Split( aSpecVal, myListRef );
737     }
738     else
739     {
740       //  read: listRef? (list?)
741       LDOM_Element aListRef = aDomain.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_REF" ) );
742       if ( !aListRef.isNull() )
743       {
744         aType = "List";
745         aEnumType = List;                       
746         LDOMString aListId = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VLR_LIST" ) );
747         aDefV = aListRef.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
748         aDefV.RemoveAll( ' ' );
749         LDOM_Element foundListItem;
750         for ( LDOM_Element aListItem = theCompElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
751               aListItem != NULL && foundListItem == NULL; aListItem = aListItem.GetSiblingByTagName() )
752         {
753           if ( aListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
754             foundListItem = aListItem;
755
756         }
757         for ( LDOM_Element aLstItem = theDocElement.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST" ) );
758               aLstItem != NULL && foundListItem == NULL; aLstItem = aLstItem.GetSiblingByTagName() )
759         {
760           if ( aLstItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_ID" ) ).equals( aListId ) )
761             foundListItem = aLstItem;
762         }
763
764         if ( foundListItem != NULL )
765         {
766           //  The appropriate list of values is found: store the list name
767           aListName = foundListItem.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_NAME" ) );
768           //  Iteration through the list of values
769           LDOM_Element aListItemValue = foundListItem.GetChildByTagName( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUE" ) );
770           while ( aListItemValue != NULL )
771           {
772             // read value ID
773             TCollection_AsciiString aListValueID = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEID" ) );
774             if ( aListValueID.IsIntegerValue() )
775             {
776               //  Read the text in the element "value"
777               //LDOM_Text aListItemTxt = (const LDOM_Text&)aListItemValue.getFirstChild();
778               LDOM_Node aNode = aListItemValue.getFirstChild();
779               const LDOM_Text& aText = (const LDOM_Text&) aNode;
780               LDOM_Text aListItemTxt(aText);
781               if ( !aListItemTxt.isNull() )
782               {
783                 // adding ID and text value to sequence
784                 aSeqOfValueID.Append( aListValueID.IntegerValue() );
785                 aSeqOfValue.Append( aListItemTxt.getData() );
786                 // adding icon file name (optional) to sequence
787                 TCollection_ExtendedString aListValueIcon = aListItemValue.getAttribute( DDS_Dictionary::KeyWord( "VALUE_LIST_VALUEICON" ) );
788                 aSeqOfValueIconName.Append( aListValueIcon );
789               }
790               aListItemValue = aListItemValue.GetSiblingByTagName();
791             }
792           }
793         }
794       }
795     }
796   }
797
798   // Quantity::Description record as the only child of that tag name
799   LDOM_Element aDescr = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "DESCR" ) );
800   if ( !aDescr.isNull() )
801   {
802     // short description (#PCDATA)*
803     LDOM_Element aShDescr = aDescr.GetChildByTagName( DDS_Dictionary::KeyWord( "SHORT_D" ) );
804     if ( !aShDescr.isNull() )
805     {
806       // text is always a sub-node of element, containing it
807       //LDOM_Text aShDescrTxt = (const LDOM_Text&)aShDescr.getFirstChild();
808       LDOM_Node aNode = aShDescr.getFirstChild();
809       const LDOM_Text& aText = (const LDOM_Text&) aNode;
810       LDOM_Text aShDescrTxt(aText);
811       if ( !aShDescrTxt.isNull() )
812         aShortD = aShDescrTxt.getData();
813     }
814
815     // long description (#PCDATA)*
816     LDOM_Element aLDescr = aDescr.GetChildByTagName( DDS_Dictionary::KeyWord( "LONG_D" ) );
817     if ( !aLDescr.isNull() )
818     {
819       // text is always a sub-node of element, containing it
820       //LDOM_Text aLDescrTxt = (const LDOM_Text&)aLDescr.getFirstChild();
821       LDOM_Node aNode = aLDescr.getFirstChild();
822       const LDOM_Text& aText = (const LDOM_Text&) aNode;
823       LDOM_Text aLDescrTxt(aText);
824       if ( !aLDescrTxt.isNull() )
825         aLongD = aLDescrTxt.getData();
826     }
827   }
828
829   // Quantity::Options
830   LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
831   if ( !anOpt.isNull() )
832   {
833     LDOM_NodeList anOptions = anOpt.GetAttributesList();//anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
834     for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
835     {
836       LDOM_Node node = anOptions.item( oi );
837       LDOM_Node::NodeType t = node.getNodeType();
838
839       TCollection_AsciiString name;
840       TCollection_ExtendedString value;
841
842       if( t==LDOM_Node::ELEMENT_NODE )
843       {
844         const LDOM_Element& elem = ( const LDOM_Element& )node;
845         name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
846         
847         const LDOM_Node aNode = elem.getFirstChild();
848         LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) );
849         if ( !anOptTxt.isNull() )
850           value = anOptTxt.getData();
851       }
852       else if( t==LDOM_Node::ATTRIBUTE_NODE )
853       {
854         const LDOM_Attr& attr = ( const LDOM_Attr& )node;
855         name = ( Standard_CString )attr.getName().GetString();
856         LDOMString v = attr.getValue();
857         if( v.Type()==LDOMBasicString::LDOM_Integer )
858         {
859                 Standard_Integer ival;
860                 v.GetInteger( ival );
861                 value = TCollection_ExtendedString( ival );
862         }
863         else
864                 value = ( Standard_CString )v.GetString();
865       }
866       else
867         continue;
868
869       if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
870         myOptions.Bind( name, value );
871     }
872   }
873
874   NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)> aDimMap;
875
876   for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
877   {
878     UnitData& anUnitData = it.ChangeValue();
879
880     // check units
881     anUnitData.myZero  = 0.;
882     anUnitData.myScale = 1.;
883     try {
884       Standard_CString aUnitDataStr;
885       aUnitDataStr = (Standard_CString)anUnitData.myUnits.ToCString();
886       if ( anUnitData.myUnits.ToCString()[0] && strcmp( anUnitData.myUnits.ToCString(), "%" ) )
887       {
888         Handle(Units_Dimensions) aDim;
889         anUnitData.myZero  = UnitsAPI::AnyToSI( 0.0, aUnitDataStr, aDim );
890         anUnitData.myScale = UnitsAPI::AnyToSI( 1.0, aUnitDataStr, aDim ) - anUnitData.myZero;
891         UnitsAPI::AnyFromSI( 1.0, aUnitDataStr );
892         if ( !aDimMap.IsBound( it.Key() ) )
893           aDimMap.Bind( it.Key(), aDim );
894       }
895       else if ( anUnitData.myUnits.ToCString()[0] ) // treat '%' as unit with scale 100
896         anUnitData.myScale = 0.01;
897     }
898           catch( Standard_Failure ) {
899       anUnitData.myUnits.Clear();
900     }
901
902     Handle(Units_Dimensions) aPrev;
903     Standard_Boolean aStatus = Standard_True;
904     for ( NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)>::Iterator itr( aDimMap );
905           itr.More() && aStatus; itr.Next() )
906     {
907       if ( itr.Value().IsNull() )
908         continue;
909
910       if ( aPrev.IsNull() )
911         aPrev = itr.Value();
912
913       aStatus = aPrev->IsEqual( itr.Value() );
914     }
915
916     if ( !aStatus )
917       printf( "Error in DataDictionary: Different dimensions for %s item", theID.ToCString() );
918   }
919
920   myId                = theID;
921   myType              = aEnumType;
922   myWarnLevel         = aWrongValue;
923   myLabel             = aLabel.ToCString();
924   myFilter            = aFilter.ToCString();
925   myLongDescr         = aLongD.ToCString();
926   myShortDescr        = aShortD.ToCString();
927   myMin               = aRealMinV;
928   myMax               = aRealMaxV;
929   myDefValue          = aRealDefV;
930   myDefString         = aDefV.ToCString();
931   myRequired          = aRequired.ToCString();
932   myListName          = aListName.ToCString();
933   myMinZoom           = aMinZoom;
934   myMaxZoom           = aMaxZoom;
935   myZoomOrder         = aZoomOrder;
936
937   // prepare formats
938   PrepareFormats( aFormat );
939
940   const Standard_Integer aLength = aSeqOfValue.Length();
941   if ( aLength > 0 )
942   {
943     myListRef      = new TColStd_HArray1OfExtendedString( 1, aLength );
944     myListRefID    = new TColStd_HArray1OfInteger( 1, aLength );
945     myListRefIcons = new TColStd_HArray1OfExtendedString( 1, aLength );
946     for ( Standard_Integer i = aLength; i > 0; i-- )
947     {
948       myListRef->ChangeValue( i ) = aSeqOfValue.Value( i );
949       myListRefID->ChangeValue( i ) = aSeqOfValueID.Value( i );
950       myListRefIcons->ChangeValue( i ) = aSeqOfValueIconName.Value( i );
951     }
952   }
953
954   if ( myType == List && myDefString == "" && !myListRef.IsNull() && myListRef->Length() > 0 )
955     myDefString = myListRef->Value( myListRef->Lower() );
956 }
957
958 /*!
959   \brief Restore default formats for all the units systems.
960 */
961 void DDS_DicItem::GetDefaultFormat()
962 {
963   for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
964   {
965     UnitData& anUnitData = it.ChangeValue();
966
967     switch ( myType )
968     {
969     case Integer:
970       anUnitData.myFormat = "%d";
971       break;
972     case Float:
973       anUnitData.myFormat = "%g";
974       break;
975     case String:
976     default:
977       anUnitData.myFormat.Clear();
978       break;;
979     }
980   }
981 }
982
983 /*!
984   \brief Get format for the string.
985   \param theFlags format flags
986   \param theWidth field width
987   \param thePrecision precision
988   \param theTypePrefix type prefix
989   \param theFormat returning format string
990 */
991 void DDS_DicItem::GetStringFormat( const TCollection_AsciiString& theFlags,
992                                    const TCollection_AsciiString& theWidth,
993                                    const TCollection_AsciiString& thePrecision,
994                                    const TCollection_AsciiString& theTypePrefix,
995                                    TCollection_AsciiString& theFormat )
996 {
997   theFormat = "%";
998   theFormat += theFlags;
999   theFormat += theWidth;
1000
1001   if ( !thePrecision.IsEmpty() ) 
1002   {
1003     theFormat += ".";
1004     theFormat += thePrecision;
1005   }
1006
1007   theFormat += theTypePrefix;
1008   theFormat += "s";
1009 }
1010
1011 /*!
1012   \brief Get format for the integer.
1013   \param theFlags format flags
1014   \param theWidth field width
1015   \param thePrecision precision
1016   \param theTypePrefix type prefix
1017   \param theType integer value type 
1018   \param theFormat returning format string
1019 */
1020 void DDS_DicItem::GetIntegerFormat( const TCollection_AsciiString& theFlags,
1021                                     const TCollection_AsciiString& theWidth,
1022                                     const TCollection_AsciiString& thePrecision,
1023                                     const TCollection_AsciiString& theTypePrefix,
1024                                     const Standard_Character theType,
1025                                     TCollection_AsciiString& theFormat )
1026 {
1027   Standard_Integer aPrecision = 0;
1028   if ( !thePrecision.IsEmpty() )
1029     aPrecision = thePrecision.IntegerValue();
1030   Standard_Integer aWidth = 0;
1031
1032   if ( !theWidth.IsEmpty() )
1033     aWidth = theWidth.IntegerValue();
1034
1035   if ( !thePrecision.IsEmpty() && aPrecision < 0 )
1036   {
1037     // possible value 0.1 will be 10.0
1038     aWidth -= aPrecision;
1039     aPrecision = 0;
1040   }
1041
1042   if ( !thePrecision.IsEmpty() && aPrecision > ( aWidth - 2 ) )
1043     aWidth = aPrecision + 2;
1044
1045   theFormat = "%";
1046
1047   theFormat += theFlags;
1048   if ( !theWidth.IsEmpty() )
1049     theFormat += aWidth;
1050
1051   theFormat += theTypePrefix;
1052   theFormat += theType;
1053 }
1054
1055 /*!
1056   \brief Returns format for the float.
1057   \param theFlags format flags
1058   \param theWidth field width
1059   \param thePrecision precision
1060   \param theTypePrefix type prefix
1061   \param theType floating point value type 
1062   \param theFormat returning format string
1063 */
1064 void DDS_DicItem::GetFloatFormat( const TCollection_AsciiString& theFlags,
1065                                   const TCollection_AsciiString& theWidth,
1066                                   const TCollection_AsciiString& thePrecision,
1067                                   const TCollection_AsciiString& theTypePrefix,
1068                                   const Standard_Character theType,
1069                                   TCollection_AsciiString& theFormat )
1070 {
1071   Standard_Integer aPrecision = 0;
1072   if ( !thePrecision.IsEmpty() )
1073     aPrecision = thePrecision.IntegerValue();
1074   Standard_Integer aWidth = 0;
1075
1076   if (!theWidth.IsEmpty() )
1077     aWidth = theWidth.IntegerValue();
1078
1079   if (!thePrecision.IsEmpty() && aPrecision < 0 )
1080   {
1081     // possible value 0.1 will be 10.0
1082     aWidth -= aPrecision;
1083     aPrecision = 0;
1084   }
1085
1086   if ( !thePrecision.IsEmpty() && aPrecision > ( aWidth - 2 ) )
1087   {
1088     aWidth = aPrecision + 2;
1089   }
1090
1091   theFormat = "%";
1092   theFormat += theFlags;
1093
1094   if ( !theWidth.IsEmpty() ) 
1095     theFormat += aWidth;
1096
1097   if ( !thePrecision.IsEmpty() ) 
1098   {
1099     theFormat += ".";
1100     theFormat += aPrecision;
1101   }
1102
1103   theFormat += theTypePrefix;
1104   theFormat += theType;
1105 }
1106
1107 /*!
1108   \brief Prepare formats for all units systems.
1109   \param theFormat format string
1110 */
1111 void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat )
1112 {
1113   for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
1114   {
1115     UnitData& anUnitData = it.ChangeValue();
1116
1117     anUnitData.myFormat = theFormat;
1118     anUnitData.myPrecision = 0;
1119   }
1120
1121   TCollection_AsciiString aPrecisionStr;
1122   if ( theFormat.IsEmpty() && myType == List )
1123     return;
1124
1125   // checking % presenting
1126   if ( *theFormat.ToCString() != '%' )
1127   {
1128     GetDefaultFormat();
1129     return;
1130   }
1131
1132   TCollection_AsciiString aStr = ( theFormat.ToCString() + 1 );
1133   Standard_Character aType = aStr.Value( aStr.Length() );
1134
1135   if ( ( aType != 's' && myType == String ) ||
1136        ( aType != 'd' && myType == Integer ) ||
1137        ( aType != 'f' && aType != 'g' && aType != 'e' && aType != 'G' && aType != 'E' && myType == Float ) )
1138   {
1139     GetDefaultFormat();
1140     return;
1141   }
1142
1143   // removing type character
1144   aStr.Trunc( aStr.Length() - 1 );
1145
1146   TCollection_AsciiString aFlags;
1147   while ( !aStr.IsEmpty() && aStr.Value( 1 ) != '.' && ( aStr.Value( 1 ) < '0' || aStr.Value( 1 ) > '9' ) )
1148   {
1149     aFlags = aFlags + aStr.Value( 1 );
1150     aStr.Remove( 1 );
1151   }
1152
1153   Standard_Integer aPos = 1;
1154   while ( aPos <= aStr.Length() && ( aStr.Value( aPos ) == '.' ||
1155           ( aStr.Value( aPos ) >= '0' && aStr.Value( aPos ) <= '9' ) ) )
1156     aPos++;
1157
1158   TCollection_AsciiString aTypePrefix;
1159   if ( aPos <= aStr.Length() )
1160   {
1161     aTypePrefix = aStr.SubString( aPos, aStr.Length() );
1162     aStr.Trunc( aPos - 1 );
1163   }
1164
1165   Standard_Integer aBasePrecision = 0;
1166
1167   // taking width and precision
1168   TCollection_AsciiString aPrecision;
1169
1170   aPos = aStr.Search( "." );
1171   if ( aPos >= 0 ) 
1172   {
1173     // aPrecision is defined
1174     aPrecision = aStr.Split( aPos );
1175     aStr.Remove( aStr.Length() );
1176     if ( !aPrecision.IsEmpty() )
1177     {
1178       if ( !aPrecision.IsIntegerValue() ) 
1179       { 
1180         GetDefaultFormat();
1181         return;
1182       }
1183       else
1184       {
1185         aPrecisionStr  = aPrecision;
1186         aBasePrecision = aPrecision.IntegerValue();
1187       }
1188     }
1189   }
1190
1191   if ( !aStr.IsEmpty() && !aStr.IsIntegerValue() )
1192   {
1193     GetDefaultFormat();
1194     return;
1195   }
1196
1197   NCollection_DataMap<UnitSystem, UnitData>::Iterator itr;
1198
1199   switch ( myType )
1200   {
1201   case String:
1202     for ( itr.Initialize( myUnitData ); itr.More(); itr.Next() )
1203     {
1204       if ( aType != 'f' && aType != 'g' && aType != 'e' && aType != 'G' && aType != 'E' )
1205         GetStringFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, itr.ChangeValue().myFormat );
1206     }
1207     break;
1208   case Float:
1209   case Integer:
1210     for ( itr.Initialize( myUnitData ); itr.More(); itr.Next() )
1211     {
1212       UnitData& anUnitData = itr.ChangeValue();
1213       Standard_Integer aAmendment =
1214         (Standard_Integer)log10( 10.0 / DDS_Dictionary::FromSI( 10.0, anUnitData.myUnits.ToCString() ) );
1215       anUnitData.myPrecision = aBasePrecision + aAmendment;
1216       aPrecisionStr = TCollection_AsciiString( anUnitData.myPrecision );
1217
1218       // create a formats
1219       if ( myType == Integer )
1220         GetIntegerFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, aType, anUnitData.myFormat );
1221       else
1222         GetFloatFormat( aFlags, aStr, aPrecisionStr, aTypePrefix, aType, anUnitData.myFormat );
1223     }
1224     break;
1225   default:;
1226     GetDefaultFormat();
1227     break;
1228   }
1229 }
1230
1231 /*!
1232   \brief Split the string \a theStr separated by spaces.
1233   \param theStr source string
1234   \param aRes returning  substrings array
1235 */
1236 void DDS_DicItem::Split( const TCollection_AsciiString& theStr, Handle(TColStd_HArray1OfExtendedString)& aRes )
1237 {
1238   aRes.Nullify();
1239
1240   if ( theStr.Length() > 0 )
1241   {
1242     TCollection_AsciiString aStr = theStr;
1243     TColStd_SequenceOfAsciiString aSeq;
1244     Standard_Integer anIndex = aStr.SearchFromEnd( (Standard_CString)" " );
1245     while( anIndex > 1 )
1246     {
1247       TCollection_AsciiString tmpStr = aStr.Split( anIndex - 1 );
1248       tmpStr.RemoveAll( ( Standard_Character )' ' );
1249       if ( tmpStr.Length() > 0 )
1250         aSeq.Append( tmpStr );
1251       anIndex = aStr.SearchFromEnd( (Standard_CString)" " );
1252     }
1253
1254     aStr.RemoveAll( ( Standard_Character )' ' );
1255     if ( aStr.Length() > 0 )
1256       aSeq.Append( aStr );
1257
1258     if ( aSeq.Length() > 0 )
1259     {
1260       aRes = new TColStd_HArray1OfExtendedString( 1, aSeq.Length() );
1261       for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
1262         aRes->ChangeValue( i ) = aSeq( i );
1263     }
1264   }
1265 }
1266
1267 /*!
1268   \brief Get units structure for specified units system \a sys.
1269   \param sys units system
1270   \return units system information structure
1271 */
1272 DDS_DicItem::UnitData* DDS_DicItem::GetUnitData( const UnitSystem& sys ) const
1273 {
1274   UnitData* unit = 0;
1275
1276   if ( myUnitData.IsBound( sys ) )
1277     unit = (UnitData*)&myUnitData.Find( sys );
1278
1279   return unit;
1280 }
1281
1282 /*!
1283   \brief Get the active units system.
1284   \return active units system
1285 */
1286 DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const
1287 {
1288   UnitSystem aSystem;
1289   Handle(DDS_DicGroup) aComponent = Handle(DDS_DicGroup)::DownCast(myComponent);
1290   if ( !aComponent.IsNull() )
1291     aSystem = aComponent->GetActiveUnitSystem();
1292   return aSystem;
1293 }
1294
1295 /*!
1296   \brief Set item's identify string.
1297   \param theId identify string.
1298 */
1299 void DDS_DicItem::SetId( const TCollection_AsciiString& theId )
1300 {
1301   myId = theId;
1302 }
1303
1304 /*!
1305   \brief Set item's component pointer.
1306   \param theComponent component pointer.
1307 */
1308 void DDS_DicItem::SetComponent( const Handle(Standard_Transient)& theComponent )
1309 {
1310   myComponent = theComponent;
1311 }
1312
1313 /*!
1314   \brief Set item's label string.
1315   \param theLabel label string.
1316 */
1317 void DDS_DicItem::SetLabel( const TCollection_AsciiString& theLabel )
1318 {
1319   myLabel = theLabel;
1320 }
1321
1322 /*!
1323   \brief Set item's filter string.
1324   \param theFilter filter string.
1325 */
1326 void DDS_DicItem::SetFilter( const TCollection_AsciiString& theFilter )
1327 {
1328   myFilter = theFilter;
1329 }
1330
1331 /*!
1332   \brief Set item's required value.
1333   \param theRequired required value string.
1334 */
1335 void DDS_DicItem::SetRequired( const TCollection_AsciiString& theRequired )
1336 {
1337   myRequired = theRequired;
1338 }
1339
1340 /*!
1341   \brief Set item's warning level value.
1342   \param theWarningLevel warning level value.
1343 */
1344 void DDS_DicItem::SetWarningLevel( const Standard_Integer& theWarningLevel )
1345 {
1346   myWarnLevel = theWarningLevel;
1347 }
1348
1349 /*!
1350   \brief Set item's minimum zoom value.
1351   \param theMinZoom minimum zoom value.
1352 */
1353 void DDS_DicItem::SetMinZoom( const Standard_Real& theMinZoom )
1354 {
1355   myMinZoom = theMinZoom;
1356 }
1357
1358 /*!
1359   \brief Set item's maximum zoom value.
1360   \param theMaxZoom maximum zoom value.
1361 */
1362 void DDS_DicItem::SetMaxZoom( const Standard_Real& theMaxZoom )
1363 {
1364   myMaxZoom = theMaxZoom;
1365 }
1366
1367 /*!
1368   \brief Set item's zoom order value.
1369   \param theZoomOrder zoom order value.
1370 */
1371 void DDS_DicItem::SetZoomOrder( const Standard_Real& theZoomOrder )
1372 {
1373   myZoomOrder = theZoomOrder;
1374 }
1375
1376 /*!
1377   \brief Set item's short description.
1378   \param theShortDescr short description string.
1379 */
1380 void DDS_DicItem::SetShortDescription( const TCollection_ExtendedString& theShortDescr )
1381 {
1382   myShortDescr = theShortDescr;
1383 }
1384
1385 /*!
1386   \brief Set item's long description.
1387   \param theLongDescr long description string.
1388 */
1389 void DDS_DicItem::SetLongDescription( const TCollection_ExtendedString& theLongDescr )
1390 {
1391   myLongDescr = theLongDescr;
1392 }
1393
1394 /*!
1395   \brief Add item's option.
1396   \param theOptionName option name string.
1397   \param theOptionValue option value string.
1398 */
1399 bool DDS_DicItem::SetOption( const TCollection_AsciiString& theOptionName,
1400                              const TCollection_AsciiString& theOptionValue )
1401 {
1402   return myOptions.Bind( theOptionName, theOptionValue );
1403 }
1404
1405 /*!
1406   \brief Set item's type value.
1407   \param theType item value type.
1408 */
1409 void DDS_DicItem::SetType( const DDS_DicItem::Type& theType )
1410 {
1411   myType = theType;
1412 }
1413
1414 /*!
1415   \brief Set item's minimum value.
1416   \param theMinVal minimum possible value.
1417 */
1418 void DDS_DicItem::SetMin( const Standard_Real& theMinVal )
1419 {
1420   myData |= MinValue;
1421   myMin = theMinVal;
1422 }
1423
1424 /*!
1425   \brief Set item's maximum value.
1426   \param theMaxVal maximum possible value.
1427 */
1428 void DDS_DicItem::SetMax( const Standard_Real& theMaxVal )
1429 {
1430   myData |= MaxValue;
1431   myMax = theMaxVal;
1432 }
1433
1434 /*!
1435   \brief Set item's default value as a real number.
1436   \param theDefVal default value.
1437 */
1438 void DDS_DicItem::SetDefaultValue( const Standard_Real& theDefVal )
1439 {
1440   myData |= DefaultValue;
1441   myDefValue = theDefVal;
1442 }
1443
1444 /*!
1445   \brief Set item's default value as a string.
1446   \param theDefStr default value.
1447 */
1448 void DDS_DicItem::SetDefaultValue( const TCollection_AsciiString& theDefStr )
1449 {
1450   myDefString = theDefStr;
1451 }
1452
1453 /*!
1454   \brief Set item's value list.
1455   \param theStrings list of value strings.
1456   \param theIntegers list of integer values associated with string item.
1457 */
1458 void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings,
1459                                    const Handle(TColStd_HArray1OfInteger)& theIntegers )
1460 {
1461   myListRef   = theStrings;
1462   myListRefID = theIntegers;
1463 }
1464
1465 /*!
1466   \brief Set item's value list and icons.
1467   \param theStrings list of value strings.
1468   \param theIntegers list of integer values associated with string item.
1469   \param theIcons list of icons associated with string item.
1470 */
1471 void DDS_DicItem::SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)& theStrings,
1472                                    const Handle(TColStd_HArray1OfInteger)& theIntegers,
1473                                    const Handle(TColStd_HArray1OfExtendedString)& theIcons )
1474 {
1475   myListRef      = theStrings;
1476   myListRefID    = theIntegers;
1477   myListRefIcons = theIcons;
1478 }