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