Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDS_DicItem.h
Go to the documentation of this file.
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 #ifndef DDS_DICITEM_H
24 #define DDS_DICITEM_H
25 
26 #include "DDS.h"
27 
28 #include <MMgt_TShared.hxx>
29 
30 #include <TCollection_AsciiString.hxx>
31 
32 #include <TColStd_HArray1OfInteger.hxx>
33 #include <TColStd_HArray1OfExtendedString.hxx>
34 
35 #include <NCollection_DataMap.hxx>
36 #include <NCollection_DefineIndexedDataMap.hxx>
37 
38 #include <TColStd_MapOfReal.hxx>
39 #include <TColStd_SequenceOfInteger.hxx>
40 #include <TColStd_SequenceOfAsciiString.hxx>
41 #include <TColStd_SequenceOfExtendedString.hxx>
42 
43 class LDOM_Element;
44 class DDS_Dictionary;
45 
46 // Class, containing all information about one parameter:
47 // unique : id
48 // obligative: label, type, short description, required
49 // optional : format, units,
50 // min value, max value, default value.
51 
52 class DDS_DicItem : public MMgt_TShared
53 {
54 public:
56  enum Type
57  {
61  List,
63  };
64 
66  enum Data
67  {
68  MinValue = 0x01,
69  MaxValue = 0x02,
70  DefaultValue = 0x04
71  };
72 
73  // This struct is intended for map of Format, Units, Precision and Scale
74  struct UnitData
75  {
76  Standard_Real myZero;
77  Standard_Real myScale;
78  TCollection_AsciiString myUnits;
79  TCollection_AsciiString myFormat;
80  Standard_Integer myPrecision;
81  };
82 
83  typedef TCollection_AsciiString UnitSystem;
84 
85 public:
86  Standard_EXPORT DDS_DicItem();
87 
88  Standard_EXPORT TCollection_AsciiString GetId() const;
89  Standard_EXPORT DDS_DicItem::Type GetType() const;
90  Standard_EXPORT TCollection_ExtendedString GetLabel() const;
91  Standard_EXPORT TCollection_ExtendedString GetFilter() const;
92  Standard_EXPORT TCollection_ExtendedString GetRequired() const;
93  Standard_EXPORT DDS_MsgType GetWarningLevel() const;
94  Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
95  Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
96  Standard_EXPORT TCollection_AsciiString GetComponent() const;
97 
98  Standard_EXPORT virtual TCollection_AsciiString GetUnits() const;
99  Standard_EXPORT virtual TCollection_AsciiString GetUnits( const UnitSystem& ) const;
100 
101  Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
102  Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
103 
104  Standard_EXPORT Standard_Real GetMinValue() const;
105  Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const;
106 
107  Standard_EXPORT Standard_Real GetMaxValue() const;
108  Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const;
109 
110  Standard_EXPORT virtual Standard_Integer GetPrecision() const;
111  Standard_EXPORT virtual Standard_Integer GetPrecision( const UnitSystem& ) const;
112 
113  Standard_EXPORT virtual TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const;
114  Standard_EXPORT virtual TCollection_AsciiString GetFormat( const UnitSystem&,
115  const Standard_Boolean = Standard_True ) const;
116  Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
117  Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
118  Handle(TColStd_HArray1OfInteger)& ) const;
119  Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
120  Handle(TColStd_HArray1OfInteger)&,
121  Handle(TColStd_HArray1OfExtendedString)& ) const;
122  Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const;
123 
124  Standard_EXPORT Standard_Real GetMinZoom() const;
125  Standard_EXPORT Standard_Real GetMaxZoom() const;
126  Standard_EXPORT Standard_Real GetZoomOrder() const;
127 
128  Standard_EXPORT virtual Standard_Real ToSI( const Standard_Real ) const;
129  Standard_EXPORT virtual Standard_Real FromSI( const Standard_Real ) const;
130 
131  Standard_EXPORT virtual Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
132  Standard_EXPORT virtual Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
133 
134  Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
135 
136  Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
137  Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
138 
139 protected:
140 
141  Standard_EXPORT void SetId( const TCollection_AsciiString& );
142 
143  Standard_EXPORT void SetComponent( const Handle(Standard_Transient)& );
144 
145  Standard_EXPORT void SetLabel( const TCollection_AsciiString& );
146 
147  Standard_EXPORT void SetFilter( const TCollection_AsciiString& );
148 
149  Standard_EXPORT void SetRequired( const TCollection_AsciiString& );
150 
151  Standard_EXPORT void SetWarningLevel( const Standard_Integer& );
152 
153  Standard_EXPORT void SetMinZoom( const Standard_Real& );
154  Standard_EXPORT void SetMaxZoom( const Standard_Real& );
155  Standard_EXPORT void SetZoomOrder( const Standard_Real& );
156 
157  Standard_EXPORT void SetShortDescription( const TCollection_ExtendedString& );
158  Standard_EXPORT void SetLongDescription( const TCollection_ExtendedString& );
159 
160  Standard_EXPORT bool SetOption( const TCollection_AsciiString&, const TCollection_AsciiString& );
161  Standard_EXPORT void SetType( const DDS_DicItem::Type& );
162 
163  Standard_EXPORT void SetMin( const Standard_Real& );
164  Standard_EXPORT void SetMax( const Standard_Real& );
165 
166  Standard_EXPORT void SetDefaultValue( const Standard_Real& );
167  Standard_EXPORT void SetDefaultValue( const TCollection_AsciiString& );
168 
169  Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
170  const Handle(TColStd_HArray1OfInteger)& );
171  Standard_EXPORT void SetListOfValues( const Handle(TColStd_HArray1OfExtendedString)&,
172  const Handle(TColStd_HArray1OfInteger)&,
173  const Handle(TColStd_HArray1OfExtendedString)& );
174 
175 protected:
176 
177  Standard_EXPORT DDS_DicItem( const DDS_DicItem& );
178 
179  Standard_EXPORT void operator=( const DDS_DicItem& );
180 
181  Standard_EXPORT virtual void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
182  const LDOM_Element&, const LDOM_Element&,
183  const TColStd_SequenceOfAsciiString& );
184 
185 private:
186 
187  Standard_EXPORT void PrepareFormats( const TCollection_AsciiString& );
188  Standard_EXPORT void GetDefaultFormat();
189  Standard_EXPORT UnitSystem GetActiveUnitSystem() const;
190 
191  Standard_EXPORT void GetStringFormat( const TCollection_AsciiString&,
192  const TCollection_AsciiString&,
193  const TCollection_AsciiString&,
194  const TCollection_AsciiString&,
195  TCollection_AsciiString& );
196  Standard_EXPORT void GetIntegerFormat( const TCollection_AsciiString&,
197  const TCollection_AsciiString&,
198  const TCollection_AsciiString&,
199  const TCollection_AsciiString&,
200  const Standard_Character,
201  TCollection_AsciiString& );
202  Standard_EXPORT void GetFloatFormat( const TCollection_AsciiString&,
203  const TCollection_AsciiString&,
204  const TCollection_AsciiString&,
205  const TCollection_AsciiString&,
206  const Standard_Character,
207  TCollection_AsciiString& );
208  Standard_EXPORT void Split( const TCollection_AsciiString&,
209  Handle(TColStd_HArray1OfExtendedString)& );
210 
211  Standard_EXPORT UnitData* GetUnitData( const UnitSystem& ) const;
212 
213 private:
214  typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
215 
216 private:
217  TCollection_AsciiString myId;
218  TCollection_ExtendedString myLabel;
219  TCollection_ExtendedString myFilter;
220  TCollection_ExtendedString myRequired;
221 
222  Standard_Integer myType;
223  Standard_Integer myWarnLevel;
224 
225  TCollection_ExtendedString myLongDescr;
226  TCollection_ExtendedString myShortDescr;
227 
228  Standard_Real myMax;
229  Standard_Real myMin;
230  Standard_Real myDefValue;
231  TCollection_ExtendedString myDefString;
232 
233  Standard_Integer myData;
234 
235  // valueList
236  TCollection_ExtendedString myListName;
237 
238  Handle(TColStd_HArray1OfExtendedString) myListRef;
239  Handle(TColStd_HArray1OfInteger) myListRefID;
240  Handle(TColStd_HArray1OfExtendedString) myListRefIcons;
241 
242  // presentation
243  Standard_Real myMinZoom;
244  Standard_Real myMaxZoom;
245  Standard_Real myZoomOrder;
246 
247  Handle(Standard_Transient) myComponent;
248 
250  // unitData
251  NCollection_DataMap<UnitSystem, UnitData> myUnitData;
252 
253  friend class DDS_DicGroup;
254 
255 public:
257 };
258 
259 DEFINE_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
260 
261 typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DDS_DicItem)> DDS_IndexedDataMapOfDicItems;
262 
263 #endif