Version: 9.16.0
GEOMGUI_DimensionProperty.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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#include <Basics_OCCTVersion.hxx>
31
32// OCCT includes
33#include <AIS_Dimension.hxx>
34#include <AIS_DiameterDimension.hxx>
35#if OCC_VERSION_LARGE >= 0x070400ff
36#include <PrsDim_LengthDimension.hxx>
37#else
38#include <AIS_LengthDimension.hxx>
39#endif
40#include <AIS_AngleDimension.hxx>
41#include <gp_Ax3.hxx>
42#include <QVariant>
43#include <QVector>
44#include <QSharedPointer>
45
46#include <string>
47#include <vector>
48#include <list>
49
50class SalomeApp_Study;
51
53typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
54
70class Standard_EXPORT GEOMGUI_DimensionProperty
71{
72public:
73
78 {
81 DimensionType_Angle
82 };
83
87 struct Length;
88 struct Diameter;
89 struct Angle;
90 struct Record
91 {
92 public:
93 Record( const DimensionType theType )
94 : myType( theType )
95 {}
96
98 {
99 return myType;
100 }
101
102 Length* AsLength() { return static_cast<Length*>( this ); }
103 Diameter* AsDiameter() { return static_cast<Diameter*>( this ); }
104 Angle* AsAngle() { return static_cast<Angle*>( this ); }
105
106 virtual void ToValues(std::vector<double>& theValues) const = 0;
107 virtual void FromValues(int& theIt, const std::vector<double>& theValues) = 0;
108
109 private:
111 };
112
116 struct Standard_EXPORT Length : public Record
117 {
119 Record( DimensionType_Length ),
120 FirstPoint( gp::Origin() ),
121 SecondPoint( gp::Origin() ),
122 Plane( gp::XOY() ),
123 Flyout( 0.0 ),
124 TextHPos( Prs3d_DTHP_Fit ),
125 TextVPos( Prs3d_DTVP_Center ),
126 ArrowPos( Prs3d_DAO_Fit )
127 {}
128
129 Length( const Length& theOther ) :
130 Record( DimensionType_Length ),
131 FirstPoint( theOther.FirstPoint ),
132 SecondPoint( theOther.SecondPoint ),
133 Plane( theOther.Plane ),
134 Flyout( theOther.Flyout ),
135 TextHPos( theOther.TextHPos ),
136 TextVPos( theOther.TextVPos ),
137 ArrowPos( theOther.ArrowPos )
138 {}
139
141
147#if OCC_VERSION_LARGE >= 0x070400ff
148 void Init( const Handle(PrsDim_LengthDimension)& theIO, const gp_Ax3& theLCS );
149#else
150 void Init( const Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS );
151#endif
152
158#if OCC_VERSION_LARGE >= 0x070400ff
159 void Update( Handle(PrsDim_LengthDimension)& theIO, const gp_Ax3& theLCS );
160#else
161 void Update( Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS );
162#endif
163
168 void ToValues(std::vector<double>& theValues) const;
169
175 void FromValues(int& theIt, const std::vector<double>& theValues);
176
180 bool operator == (const Length &theOther) const;
181 bool operator != (const Length &theOther) const { return !(operator == (theOther)); }
182
185 gp_Pln Plane;
186 double Flyout;
187 Prs3d_DimensionTextHorizontalPosition TextHPos;
188 Prs3d_DimensionTextVerticalPosition TextVPos;
189 Prs3d_DimensionArrowOrientation ArrowPos;
190 };
191
195 struct Standard_EXPORT Diameter : public Record
196 {
198 Record( DimensionType_Diameter ),
199 Plane( gp::XOY() ),
200 Flyout( 0.0 ),
201 TextHPos( Prs3d_DTHP_Fit ),
202 TextVPos( Prs3d_DTVP_Center ),
203 ArrowPos( Prs3d_DAO_Fit )
204 {}
205
206 Diameter( const Diameter& theOther ) :
207 Record( DimensionType_Diameter ),
208 Circle( theOther.Circle ),
209 Plane( theOther.Plane ),
210 Flyout( theOther.Flyout ),
211 TextHPos( theOther.TextHPos ),
212 TextVPos( theOther.TextVPos ),
213 ArrowPos( theOther.ArrowPos )
214 {}
215
217
223 void Init( const Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS );
224
230 void Update( Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS );
231
236 void ToValues(std::vector<double>& theValues) const;
237
243 void FromValues(int& theIt, const std::vector<double>& theValues);
244
248 bool operator == (const Diameter &theOther) const;
249 bool operator != (const Diameter &theOther) const { return !(operator == (theOther)); }
250
251 gp_Circ Circle;
252 gp_Pln Plane;
253 double Flyout;
254 Prs3d_DimensionTextHorizontalPosition TextHPos;
255 Prs3d_DimensionTextVerticalPosition TextVPos;
256 Prs3d_DimensionArrowOrientation ArrowPos;
257 };
258
262 struct Standard_EXPORT Angle : public Record
263 {
265 Record( DimensionType_Angle ),
266 FirstPoint( gp::Origin() ),
267 SecondPoint( gp::Origin() ),
268 CenterPoint( gp::Origin() ),
269 Flyout( 0.0 ),
270 TextHPos( Prs3d_DTHP_Fit ),
271 TextVPos( Prs3d_DTVP_Center ),
272 ArrowPos( Prs3d_DAO_Fit )
273 {}
274
275 Angle( const Angle& theOther ) :
276 Record( DimensionType_Angle ),
277 FirstPoint( theOther.FirstPoint ),
278 SecondPoint( theOther.SecondPoint ),
279 CenterPoint( theOther.CenterPoint ),
280 Flyout( theOther.Flyout ),
281 TextHPos( theOther.TextHPos ),
282 TextVPos( theOther.TextVPos ),
283 ArrowPos( theOther.ArrowPos )
284 {}
285
287
293 void Init( const Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS );
294
300 void Update( Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS );
301
306 void ToValues(std::vector<double>& theValues) const;
307
313 void FromValues(int& theIt, const std::vector<double>& theValues);
314
318 bool operator == (const Angle &theOther) const;
319 bool operator != (const Angle &theOther) const { return !(operator == (theOther)); }
320
324 double Flyout;
325 Prs3d_DimensionTextHorizontalPosition TextHPos;
326 Prs3d_DimensionTextVerticalPosition TextVPos;
327 Prs3d_DimensionArrowOrientation ArrowPos;
328 };
329
330 typedef QSharedPointer<Record> RecordPtr;
331
332public:
333
338
343
347 GEOMGUI_DimensionProperty( const std::string& theEntry );
348
352 GEOMGUI_DimensionProperty( const QString& theProperty );
353
358
362 operator QVariant() const;
363
367 operator QString() const;
368
372 bool operator == (const GEOMGUI_DimensionProperty &theOther) const;
373
377 bool operator != (const GEOMGUI_DimensionProperty &theOther) const
378 {
379 return !(operator == (theOther));
380 }
381
382public:
383
387 int GetNumber() const;
388
394 void AddRecord( const Handle(AIS_Dimension)& theIO, const gp_Ax3& theLCS );
395
400 void AddRecord( const RecordPtr& theRecord );
401
408 void SetRecord( const int theIndex,
409 const Handle(AIS_Dimension)& theIO,
410 const gp_Ax3& theLCS );
411
417 void SetRecord( const int theIndex, const RecordPtr& theRecord );
418
423 const RecordPtr& GetRecord( const int theIndex ) const;
424
429 void RemoveRecord( const int theIndex );
430
434 void Clear();
435
436public:
437
443 bool IsVisible( const int theIndex ) const;
444
451 void SetVisible( const int theIndex, const bool theIsVisible );
452
458 QString GetName( const int theIndex ) const;
459
466 void SetName( const int theIndex, const QString& theName );
467
471 int GetType( const int theIndex ) const;
472
473public:
474
479 void LoadFromAttribute( const std::string& theEntry );
480
485 void SaveToAttribute( const std::string& theEntry );
486
487private:
488
492 int TypeFromIO( const Handle(AIS_Dimension)& theIO ) const;
493
494private:
495
496 typedef QVector<bool> VectorOfVisibility;
497 typedef QVector<QString> VectorOfNames;
498 typedef QVector<RecordPtr> VectorOfRecords;
499
500private:
501
505};
506
507Q_DECLARE_METATYPE(GEOMGUI_DimensionProperty)
508
509#endif
Handle(TColStd_HSequenceOfTransient) AdvancedEngine_IOperations
Create a T-shape object with specified caracteristics for the main and the incident pipes (radius,...
Definition: AdvancedEngine_IOperations.cxx:1907
QSharedPointer< GEOMGUI_DimensionProperty > DimensionPropertyPtr
Definition: GEOMGUI_DimensionProperty.h:53
Utility class to unpack/pack dimension presentations as object property of study.
Definition: GEOMGUI_DimensionProperty.h:71
VectorOfVisibility myVisibility
Definition: GEOMGUI_DimensionProperty.h:502
QVector< RecordPtr > VectorOfRecords
Definition: GEOMGUI_DimensionProperty.h:498
DimensionType
Type of packed presentation.
Definition: GEOMGUI_DimensionProperty.h:78
@ DimensionType_Diameter
Definition: GEOMGUI_DimensionProperty.h:80
@ DimensionType_Length
Definition: GEOMGUI_DimensionProperty.h:79
QSharedPointer< Record > RecordPtr
Definition: GEOMGUI_DimensionProperty.h:330
QVector< bool > VectorOfVisibility
Definition: GEOMGUI_DimensionProperty.h:496
VectorOfRecords myRecords
Definition: GEOMGUI_DimensionProperty.h:504
VectorOfNames myNames
Definition: GEOMGUI_DimensionProperty.h:503
QVector< QString > VectorOfNames
Definition: GEOMGUI_DimensionProperty.h:497
Declaration of properties for angle dimensions.
Definition: GEOMGUI_DimensionProperty.h:263
Angle(const Angle &theOther)
Definition: GEOMGUI_DimensionProperty.h:275
Prs3d_DimensionArrowOrientation ArrowPos
Definition: GEOMGUI_DimensionProperty.h:327
double Flyout
Definition: GEOMGUI_DimensionProperty.h:324
gp_Pnt SecondPoint
Definition: GEOMGUI_DimensionProperty.h:322
Angle()
Definition: GEOMGUI_DimensionProperty.h:264
~Angle()
Definition: GEOMGUI_DimensionProperty.h:286
Prs3d_DimensionTextHorizontalPosition TextHPos
Definition: GEOMGUI_DimensionProperty.h:325
Prs3d_DimensionTextVerticalPosition TextVPos
Definition: GEOMGUI_DimensionProperty.h:326
gp_Pnt FirstPoint
Definition: GEOMGUI_DimensionProperty.h:321
gp_Pnt CenterPoint
Definition: GEOMGUI_DimensionProperty.h:323
Declaration of properties for diameter dimensions.
Definition: GEOMGUI_DimensionProperty.h:196
Diameter(const Diameter &theOther)
Definition: GEOMGUI_DimensionProperty.h:206
double Flyout
Definition: GEOMGUI_DimensionProperty.h:253
gp_Circ Circle
Definition: GEOMGUI_DimensionProperty.h:251
Diameter()
Definition: GEOMGUI_DimensionProperty.h:197
Prs3d_DimensionTextVerticalPosition TextVPos
Definition: GEOMGUI_DimensionProperty.h:255
~Diameter()
Definition: GEOMGUI_DimensionProperty.h:216
Prs3d_DimensionTextHorizontalPosition TextHPos
Definition: GEOMGUI_DimensionProperty.h:254
gp_Pln Plane
Definition: GEOMGUI_DimensionProperty.h:252
Prs3d_DimensionArrowOrientation ArrowPos
Definition: GEOMGUI_DimensionProperty.h:256
Declaration of properties for length dimensions.
Definition: GEOMGUI_DimensionProperty.h:117
Prs3d_DimensionArrowOrientation ArrowPos
Definition: GEOMGUI_DimensionProperty.h:189
Prs3d_DimensionTextHorizontalPosition TextHPos
Definition: GEOMGUI_DimensionProperty.h:187
gp_Pnt FirstPoint
Definition: GEOMGUI_DimensionProperty.h:183
Length()
Definition: GEOMGUI_DimensionProperty.h:118
gp_Pln Plane
Definition: GEOMGUI_DimensionProperty.h:185
Prs3d_DimensionTextVerticalPosition TextVPos
Definition: GEOMGUI_DimensionProperty.h:188
double Flyout
Definition: GEOMGUI_DimensionProperty.h:186
gp_Pnt SecondPoint
Definition: GEOMGUI_DimensionProperty.h:184
Length(const Length &theOther)
Definition: GEOMGUI_DimensionProperty.h:129
~Length()
Definition: GEOMGUI_DimensionProperty.h:140
Definition: GEOMGUI_DimensionProperty.h:91
DimensionType Type() const
Definition: GEOMGUI_DimensionProperty.h:97
Length * AsLength()
Definition: GEOMGUI_DimensionProperty.h:102
Diameter * AsDiameter()
Definition: GEOMGUI_DimensionProperty.h:103
Record(const DimensionType theType)
Definition: GEOMGUI_DimensionProperty.h:93
DimensionType myType
Definition: GEOMGUI_DimensionProperty.h:110
Angle * AsAngle()
Definition: GEOMGUI_DimensionProperty.h:104
virtual void ToValues(std::vector< double > &theValues) const =0
virtual void FromValues(int &theIt, const std::vector< double > &theValues)=0