Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GEOMGUI_DimensionProperty.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 // File : GEOMGUI_DimensionProperty.h
24 // Author : Anton POLETAEV, Open CASCADE S.A.S.
25 //
26 
27 #ifndef GEOMGUI_DIMENSIONPROPERTY_H
28 #define GEOMGUI_DIMENSIONPROPERTY_H
29 
30 // OCCT includes
31 #include <AIS_DiameterDimension.hxx>
32 #include <AIS_LengthDimension.hxx>
33 #include <AIS_AngleDimension.hxx>
34 #include <gp_Ax3.hxx>
35 #include <QVariant>
36 #include <QVector>
37 #include <QSharedPointer>
38 
39 #include <string>
40 #include <vector>
41 #include <list>
42 
43 class SalomeApp_Study;
44 
46 typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
47 
63 class Standard_EXPORT GEOMGUI_DimensionProperty
64 {
65 public:
66 
71  {
74  DimensionType_Angle
75  };
76 
80  struct Length;
81  struct Diameter;
82  struct Angle;
83  struct Record
84  {
85  public:
86  Record( const DimensionType theType )
87  : myType( theType )
88  {}
89 
91  {
92  return myType;
93  }
94 
95  Length* AsLength() { return static_cast<Length*>( this ); }
96  Diameter* AsDiameter() { return static_cast<Diameter*>( this ); }
97  Angle* AsAngle() { return static_cast<Angle*>( this ); }
98 
99  virtual void ToValues(std::vector<double>& theValues) const = 0;
100  virtual void FromValues(int& theIt, const std::vector<double>& theValues) = 0;
101 
102  private:
104  };
105 
109  struct Standard_EXPORT Length : public Record
110  {
111  Length() :
112  Record( DimensionType_Length ),
113  FirstPoint( gp::Origin() ),
114  SecondPoint( gp::Origin() ),
115  Plane( gp::XOY() ),
116  Flyout( 0.0 ),
117  TextHPos( Prs3d_DTHP_Fit ),
118  TextVPos( Prs3d_DTVP_Center ),
119  ArrowPos( Prs3d_DAO_Fit )
120  {}
121 
122  Length( const Length& theOther ) :
123  Record( DimensionType_Length ),
124  FirstPoint( theOther.FirstPoint ),
125  SecondPoint( theOther.SecondPoint ),
126  Plane( theOther.Plane ),
127  Flyout( theOther.Flyout ),
128  TextHPos( theOther.TextHPos ),
129  TextVPos( theOther.TextVPos ),
130  ArrowPos( theOther.ArrowPos )
131  {}
132 
133  ~Length() {}
134 
140  void Init( const Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS );
141 
147  void Update( Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS );
148 
153  void ToValues(std::vector<double>& theValues) const;
154 
160  void FromValues(int& theIt, const std::vector<double>& theValues);
161 
165  bool operator == (const Length &theOther) const;
166  bool operator != (const Length &theOther) const { return !(operator == (theOther)); }
167 
168  gp_Pnt FirstPoint;
169  gp_Pnt SecondPoint;
170  gp_Pln Plane;
171  double Flyout;
172  Prs3d_DimensionTextHorizontalPosition TextHPos;
173  Prs3d_DimensionTextVerticalPosition TextVPos;
174  Prs3d_DimensionArrowOrientation ArrowPos;
175  };
176 
180  struct Standard_EXPORT Diameter : public Record
181  {
183  Record( DimensionType_Diameter ),
184  Plane( gp::XOY() ),
185  Flyout( 0.0 ),
186  TextHPos( Prs3d_DTHP_Fit ),
187  TextVPos( Prs3d_DTVP_Center ),
188  ArrowPos( Prs3d_DAO_Fit )
189  {}
190 
191  Diameter( const Diameter& theOther ) :
192  Record( DimensionType_Diameter ),
193  Circle( theOther.Circle ),
194  Plane( theOther.Plane ),
195  Flyout( theOther.Flyout ),
196  TextHPos( theOther.TextHPos ),
197  TextVPos( theOther.TextVPos ),
198  ArrowPos( theOther.ArrowPos )
199  {}
200 
202 
208  void Init( const Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS );
209 
215  void Update( Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS );
216 
221  void ToValues(std::vector<double>& theValues) const;
222 
228  void FromValues(int& theIt, const std::vector<double>& theValues);
229 
233  bool operator == (const Diameter &theOther) const;
234  bool operator != (const Diameter &theOther) const { return !(operator == (theOther)); }
235 
236  gp_Circ Circle;
237  gp_Pln Plane;
238  double Flyout;
239  Prs3d_DimensionTextHorizontalPosition TextHPos;
240  Prs3d_DimensionTextVerticalPosition TextVPos;
241  Prs3d_DimensionArrowOrientation ArrowPos;
242  };
243 
247  struct Standard_EXPORT Angle : public Record
248  {
249  Angle() :
250  Record( DimensionType_Angle ),
251  FirstPoint( gp::Origin() ),
252  SecondPoint( gp::Origin() ),
253  CenterPoint( gp::Origin() ),
254  Flyout( 0.0 ),
255  TextHPos( Prs3d_DTHP_Fit ),
256  TextVPos( Prs3d_DTVP_Center ),
257  ArrowPos( Prs3d_DAO_Fit )
258  {}
259 
260  Angle( const Angle& theOther ) :
261  Record( DimensionType_Angle ),
262  FirstPoint( theOther.FirstPoint ),
263  SecondPoint( theOther.SecondPoint ),
264  CenterPoint( theOther.CenterPoint ),
265  Flyout( theOther.Flyout ),
266  TextHPos( theOther.TextHPos ),
267  TextVPos( theOther.TextVPos ),
268  ArrowPos( theOther.ArrowPos )
269  {}
270 
271  ~Angle() {}
272 
278  void Init( const Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS );
279 
285  void Update( Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS );
286 
291  void ToValues(std::vector<double>& theValues) const;
292 
298  void FromValues(int& theIt, const std::vector<double>& theValues);
299 
303  bool operator == (const Angle &theOther) const;
304  bool operator != (const Angle &theOther) const { return !(operator == (theOther)); }
305 
306  gp_Pnt FirstPoint;
307  gp_Pnt SecondPoint;
308  gp_Pnt CenterPoint;
309  double Flyout;
310  Prs3d_DimensionTextHorizontalPosition TextHPos;
311  Prs3d_DimensionTextVerticalPosition TextVPos;
312  Prs3d_DimensionArrowOrientation ArrowPos;
313  };
314 
315  typedef QSharedPointer<Record> RecordPtr;
316 
317 public:
318 
323 
328 
332  GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy, const std::string& theEntry );
333 
337  GEOMGUI_DimensionProperty( const QString& theProperty );
338 
343 
347  operator QVariant() const;
348 
352  operator QString() const;
353 
357  bool operator == (const GEOMGUI_DimensionProperty &theOther) const;
358 
362  bool operator != (const GEOMGUI_DimensionProperty &theOther) const
363  {
364  return !(operator == (theOther));
365  }
366 
367 public:
368 
372  int GetNumber() const;
373 
379  void AddRecord( const Handle(AIS_Dimension)& theIO, const gp_Ax3& theLCS );
380 
385  void AddRecord( const RecordPtr& theRecord );
386 
393  void SetRecord( const int theIndex,
394  const Handle(AIS_Dimension)& theIO,
395  const gp_Ax3& theLCS );
396 
402  void SetRecord( const int theIndex, const RecordPtr& theRecord );
403 
408  const RecordPtr& GetRecord( const int theIndex ) const;
409 
414  void RemoveRecord( const int theIndex );
415 
419  void Clear();
420 
421 public:
422 
428  bool IsVisible( const int theIndex ) const;
429 
436  void SetVisible( const int theIndex, const bool theIsVisible );
437 
443  QString GetName( const int theIndex ) const;
444 
451  void SetName( const int theIndex, const QString& theName );
452 
456  int GetType( const int theIndex ) const;
457 
458 public:
459 
465  void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
466 
472  void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
473 
474 private:
475 
479  int TypeFromIO( const Handle(AIS_Dimension)& theIO ) const;
480 
481 private:
482 
483  typedef QVector<bool> VectorOfVisibility;
484  typedef QVector<QString> VectorOfNames;
485  typedef QVector<RecordPtr> VectorOfRecords;
486 
487 private:
488 
492 };
493 
495 
496 #endif