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