1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : GEOMGUI_DimensionProperty.cxx
24 // Author : Anton POLETAEV, Open CASCADE S.A.S.
27 #include "GEOMGUI_DimensionProperty.h"
30 #include <Standard_ProgramError.hxx>
31 #include <gp_Trsf.hxx>
33 #include <SalomeApp_Study.h>
35 //=================================================================================
36 // function : Length::Init
38 //=================================================================================
39 void GEOMGUI_DimensionProperty::Length::Init( const Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS )
42 aFromLCS.SetTransformation( gp_Ax3(), theLCS );
44 FirstPoint = theIO->FirstPoint().Transformed( aFromLCS );
45 SecondPoint = theIO->SecondPoint().Transformed( aFromLCS );
46 Plane = theIO->GetPlane().Transformed( aFromLCS );
47 Flyout = theIO->GetFlyout();
48 TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
49 TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
52 //=================================================================================
53 // function : Length::Update
55 //=================================================================================
56 void GEOMGUI_DimensionProperty::Length::Update( Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS )
59 aToLCS.SetTransformation( theLCS, gp_Ax3() );
61 gp_Pnt aPoint1 = FirstPoint.Transformed( aToLCS );
62 gp_Pnt aPoint2 = SecondPoint.Transformed( aToLCS );
63 gp_Pln aPlane = Plane.Transformed( aToLCS );
65 theIO->SetMeasuredGeometry( aPoint1, aPoint2, aPlane );
66 theIO->SetFlyout( Flyout );
68 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
69 aStyle->SetTextHorizontalPosition( TextHPos );
70 aStyle->SetTextVerticalPosition( TextVPos );
71 theIO->SetDimensionAspect( aStyle );
74 //=================================================================================
75 // function : Length::operator ==
77 //=================================================================================
78 bool GEOMGUI_DimensionProperty::Length::operator == (const Length& theOther) const
80 if ( FirstPoint.X() != theOther.FirstPoint.X()
81 || FirstPoint.Y() != theOther.FirstPoint.Y()
82 || FirstPoint.Z() != theOther.FirstPoint.Z()
83 || SecondPoint.X() != theOther.SecondPoint.X()
84 || SecondPoint.Y() != theOther.SecondPoint.Y()
85 || SecondPoint.Z() != theOther.SecondPoint.Z() )
90 if ( Plane.Location().X() != theOther.Plane.Location().X()
91 || Plane.Location().Y() != theOther.Plane.Location().Y()
92 || Plane.Location().Z() != theOther.Plane.Location().Z()
93 || Plane.Axis().Direction().X() != theOther.Plane.Axis().Direction().X()
94 || Plane.Axis().Direction().Y() != theOther.Plane.Axis().Direction().Y()
95 || Plane.Axis().Direction().Z() != theOther.Plane.Axis().Direction().Z() )
100 if ( Flyout != theOther.Flyout
101 || TextHPos != theOther.TextHPos
102 || TextVPos != theOther.TextVPos )
110 //=================================================================================
111 // function : Diameter::Init
113 //=================================================================================
114 void GEOMGUI_DimensionProperty::Diameter::Init( const Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS )
117 aFromLCS.SetTransformation( gp_Ax3(), theLCS );
119 Circle = theIO->Circle().Transformed( aFromLCS );
120 Plane = theIO->GetPlane().Transformed( aFromLCS );
121 Flyout = theIO->GetFlyout();
122 TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
123 TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
126 //=================================================================================
127 // function : Diameter::Update
129 //=================================================================================
130 void GEOMGUI_DimensionProperty::Diameter::Update( Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS )
133 aToLCS.SetTransformation( theLCS, gp_Ax3() );
135 gp_Circ aCircle = Circle.Transformed( aToLCS );
136 gp_Pln aPlane = Plane.Transformed( aToLCS );
138 Standard_Boolean isParallel =
139 aCircle.Axis().Direction().IsParallel( aPlane.Axis().Direction(), Precision::Angular() );
143 theIO->UnsetCustomPlane();
144 theIO->SetMeasuredGeometry( aCircle );
148 theIO->SetCustomPlane( aPlane );
149 theIO->SetMeasuredGeometry( aCircle );
152 theIO->SetFlyout( Flyout );
154 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
155 aStyle->SetTextHorizontalPosition( TextHPos );
156 aStyle->SetTextVerticalPosition( TextVPos );
157 theIO->SetDimensionAspect( aStyle );
160 //=================================================================================
161 // function : Diameter::operator ==
163 //=================================================================================
164 bool GEOMGUI_DimensionProperty::Diameter::operator == (const Diameter& theOther) const
166 if ( Circle.Location().X() != theOther.Circle.Location().X()
167 || Circle.Location().Y() != theOther.Circle.Location().Y()
168 || Circle.Location().Z() != theOther.Circle.Location().Z()
169 || Circle.Axis().Direction().X() != theOther.Circle.Axis().Direction().X()
170 || Circle.Axis().Direction().Y() != theOther.Circle.Axis().Direction().Y()
171 || Circle.Axis().Direction().Z() != theOther.Circle.Axis().Direction().Z()
172 || Circle.XAxis().Direction().X() != theOther.Circle.XAxis().Direction().X()
173 || Circle.XAxis().Direction().Y() != theOther.Circle.XAxis().Direction().Y()
174 || Circle.XAxis().Direction().Z() != theOther.Circle.XAxis().Direction().Z()
175 || Circle.Radius() != theOther.Circle.Radius() )
180 if ( Plane.Location().X() != theOther.Plane.Location().X()
181 || Plane.Location().Y() != theOther.Plane.Location().Y()
182 || Plane.Location().Z() != theOther.Plane.Location().Z()
183 || Plane.Axis().Direction().X() != theOther.Plane.Axis().Direction().X()
184 || Plane.Axis().Direction().Y() != theOther.Plane.Axis().Direction().Y()
185 || Plane.Axis().Direction().Z() != theOther.Plane.Axis().Direction().Z() )
190 if ( Flyout != theOther.Flyout
191 || TextHPos != theOther.TextHPos
192 || TextVPos != theOther.TextVPos )
200 //=================================================================================
201 // function : Angle::Init
203 //=================================================================================
204 void GEOMGUI_DimensionProperty::Angle::Init( const Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS )
207 aFromLCS.SetTransformation( gp_Ax3(), theLCS );
209 FirstPoint = theIO->FirstPoint().Transformed( aFromLCS );
210 SecondPoint = theIO->SecondPoint().Transformed( aFromLCS );
211 CenterPoint = theIO->CenterPoint().Transformed( aFromLCS );
212 Flyout = theIO->GetFlyout();
213 TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
214 TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
217 //=================================================================================
218 // function : Angle::Update
220 //=================================================================================
221 void GEOMGUI_DimensionProperty::Angle::Update( Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS )
224 aToLCS.SetTransformation( theLCS, gp_Ax3() );
226 gp_Pnt aPoint1 = FirstPoint.Transformed( aToLCS );
227 gp_Pnt aPoint2 = CenterPoint.Transformed( aToLCS );
228 gp_Pnt aPoint3 = SecondPoint.Transformed( aToLCS );
230 theIO->SetMeasuredGeometry( aPoint1, aPoint2, aPoint3 );
231 theIO->SetFlyout( Flyout );
233 Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
234 aStyle->SetTextHorizontalPosition( TextHPos );
235 aStyle->SetTextVerticalPosition( TextVPos );
236 theIO->SetDimensionAspect( aStyle );
239 //=================================================================================
240 // function : Angle::operator ==
242 //=================================================================================
243 bool GEOMGUI_DimensionProperty::Angle::operator == (const Angle& theOther) const
245 if ( FirstPoint.X() != theOther.FirstPoint.X()
246 || FirstPoint.Y() != theOther.FirstPoint.Y()
247 || FirstPoint.Z() != theOther.FirstPoint.Z()
248 || SecondPoint.X() != theOther.SecondPoint.X()
249 || SecondPoint.Y() != theOther.SecondPoint.Y()
250 || SecondPoint.Z() != theOther.SecondPoint.Z()
251 || CenterPoint.X() != theOther.CenterPoint.X()
252 || CenterPoint.Y() != theOther.CenterPoint.Y()
253 || CenterPoint.Z() != theOther.CenterPoint.Z() )
258 if ( Flyout != theOther.Flyout
259 || TextHPos != theOther.TextHPos
260 || TextVPos != theOther.TextVPos )
268 //=================================================================================
269 // function : Constructor
271 //=================================================================================
272 GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty()
276 //=================================================================================
277 // function : Copy constructor
279 //=================================================================================
280 GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( const GEOMGUI_DimensionProperty& theOther )
282 const VectorOfVisibility& aOtherVis = theOther.myVisibility;
283 const VectorOfNames& aOtherNames = theOther.myNames;
284 const VectorOfRecords& aOtherRecords = theOther.myRecords;
286 VectorOfVisibility::const_iterator aVisIt = aOtherVis.constBegin();
287 VectorOfNames::const_iterator aNamesIt = aOtherNames.constBegin();
288 VectorOfRecords::const_iterator aRecordIt = aOtherRecords.constBegin();
289 for ( ; aRecordIt != aOtherRecords.constEnd(); ++aVisIt, ++aNamesIt, ++aRecordIt )
291 RecordPtr aNewRecord;
292 const RecordPtr& aRecord = *aRecordIt;
293 switch( aRecord->Type() )
295 case DimensionType_Length :
296 aNewRecord = RecordPtr( new Length( *aRecord->AsLength() ) );
299 case DimensionType_Diameter :
300 aNewRecord = RecordPtr( new Diameter( *aRecord->AsDiameter() ) );
303 case DimensionType_Angle :
304 aNewRecord = RecordPtr( new Angle( *aRecord->AsAngle() ) );
308 myVisibility.append( *aVisIt );
309 myNames.append( *aNamesIt );
310 myRecords.append( aNewRecord );
314 //=================================================================================
315 // function : Destructor
317 //=================================================================================
318 GEOMGUI_DimensionProperty::~GEOMGUI_DimensionProperty()
322 //=================================================================================
323 // function : operator QVariant()
325 //=================================================================================
326 GEOMGUI_DimensionProperty::operator QVariant()
329 aQVariant.setValue( *this );
333 //=================================================================================
334 // function : operator ==
336 //=================================================================================
337 bool GEOMGUI_DimensionProperty::operator == (const GEOMGUI_DimensionProperty& theOther) const
339 if ( myVisibility.size() != theOther.myVisibility.size()
340 || myNames.size() != theOther.myNames.size()
341 || myRecords.size() != theOther.myRecords.size() )
346 for ( int it = 0; it < myRecords.size(); ++it )
348 if ( myVisibility[it] != theOther.myVisibility[it] )
353 if ( myNames[it] != theOther.myNames[it] )
358 const RecordPtr& aRecord = myRecords[it];
359 const RecordPtr& aOtherRecord = theOther.myRecords[it];
360 if ( aRecord->Type() != aOtherRecord->Type() )
365 switch ( aRecord->Type() )
367 case DimensionType_Length:
368 if ( (*aRecord->AsLength()) != (*aOtherRecord->AsLength()) )
374 case DimensionType_Diameter:
375 if ( (*aRecord->AsDiameter()) != (*aOtherRecord->AsDiameter()) )
381 case DimensionType_Angle:
382 if ( (*aRecord->AsAngle()) != (*aOtherRecord->AsAngle()) )
393 //=================================================================================
394 // function : GetNumber
396 //=================================================================================
397 int GEOMGUI_DimensionProperty::GetNumber() const
399 return myRecords.size();
402 //=================================================================================
403 // function : AddRecord
405 //=================================================================================
406 void GEOMGUI_DimensionProperty::AddRecord( const Handle(AIS_Dimension)& theIO, const gp_Ax3& theLCS )
408 RecordPtr aNewRecord;
410 int aType = TypeFromIO( theIO );
414 case DimensionType_Length :
416 Handle(AIS_LengthDimension) aLength =
417 Handle(AIS_LengthDimension)::DownCast( theIO );
419 aNewRecord = RecordPtr( new Length() );
420 aNewRecord->AsLength()->Init( aLength, theLCS );
424 case DimensionType_Diameter :
426 Handle(AIS_DiameterDimension) aDiam =
427 Handle(AIS_DiameterDimension)::DownCast( theIO );
429 aNewRecord = RecordPtr( new Diameter() );
430 aNewRecord->AsDiameter()->Init( aDiam, theLCS );
434 case DimensionType_Angle :
436 Handle(AIS_AngleDimension) anAngle =
437 Handle(AIS_AngleDimension)::DownCast( theIO );
439 aNewRecord = RecordPtr( new Angle() );
440 aNewRecord->AsAngle()->Init( anAngle, theLCS );
444 myVisibility.append( true );
445 myNames.append( QString() );
446 myRecords.append( aNewRecord );
449 //=================================================================================
450 // function : AddRecord
452 //=================================================================================
453 void GEOMGUI_DimensionProperty::AddRecord( const RecordPtr& theRecord )
455 myVisibility.append( true );
456 myNames.append( QString() );
457 myRecords.append( theRecord );
460 //=================================================================================
461 // function : RemoveRecord
463 //=================================================================================
464 void GEOMGUI_DimensionProperty::RemoveRecord( const int theIndex )
466 myRecords.remove( theIndex );
469 //=================================================================================
472 //=================================================================================
473 void GEOMGUI_DimensionProperty::Clear()
478 //=================================================================================
479 // function : SetRecord
481 //=================================================================================
482 void GEOMGUI_DimensionProperty::SetRecord( const int theIndex,
483 const Handle(AIS_Dimension)& theIO,
484 const gp_Ax3& theLCS )
486 int aType = TypeFromIO( theIO );
488 RecordPtr& aChangeRecord = myRecords[theIndex];
492 case DimensionType_Length :
494 Handle(AIS_LengthDimension) aLength =
495 Handle(AIS_LengthDimension)::DownCast( theIO );
497 aChangeRecord = RecordPtr( new Length() );
498 aChangeRecord->AsLength()->Init( aLength, theLCS );
502 case DimensionType_Diameter :
504 Handle(AIS_DiameterDimension) aDiam =
505 Handle(AIS_DiameterDimension)::DownCast( theIO );
507 aChangeRecord = RecordPtr( new Diameter() );
508 aChangeRecord->AsDiameter()->Init( aDiam, theLCS );
512 case DimensionType_Angle :
514 Handle(AIS_AngleDimension) anAngle =
515 Handle(AIS_AngleDimension)::DownCast( theIO );
517 aChangeRecord = RecordPtr( new Angle() );
518 aChangeRecord->AsAngle()->Init( anAngle, theLCS );
523 //=================================================================================
524 // function : SetRecord
526 //=================================================================================
527 void GEOMGUI_DimensionProperty::SetRecord( const int theIndex, const RecordPtr& theRecord )
529 myRecords[theIndex] = theRecord;
532 //=================================================================================
533 // function : GetRecord
535 //=================================================================================
536 const GEOMGUI_DimensionProperty::RecordPtr& GEOMGUI_DimensionProperty::GetRecord( const int theIndex ) const
538 return myRecords[theIndex];
541 //=================================================================================
542 // function : IsVisible
544 //=================================================================================
545 bool GEOMGUI_DimensionProperty::IsVisible( const int theIndex ) const
547 return myVisibility[theIndex];
550 //=================================================================================
551 // function : SetVisible
553 //=================================================================================
554 void GEOMGUI_DimensionProperty::SetVisible( const int theIndex, const bool theIsVisible )
556 myVisibility[theIndex] = theIsVisible;
559 //=================================================================================
560 // function : GetName
562 //=================================================================================
563 QString GEOMGUI_DimensionProperty::GetName( const int theIndex ) const
565 return myNames[theIndex];
568 //=================================================================================
569 // function : SetName
571 //=================================================================================
572 void GEOMGUI_DimensionProperty::SetName( const int theIndex, const QString &theName )
574 myNames[theIndex] = theName;
577 //=================================================================================
578 // function : GetType
580 //=================================================================================
581 int GEOMGUI_DimensionProperty::GetType( const int theIndex ) const
583 return myRecords[theIndex]->Type();
586 //=================================================================================
587 // function : LoadFromAttribute
589 //=================================================================================
590 void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
591 const std::string& theEntry )
595 _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
601 _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
603 _PTR(GenericAttribute) aSeekAtt;
604 _PTR(AttributeTableOfReal) aRecordsAtt;
606 if ( !aSObj->FindAttribute( aSeekAtt, "AttributeTableOfReal" ) )
611 aRecordsAtt = aSeekAtt;
613 for ( int aRecordIt = 1; aRecordIt <= aRecordsAtt->GetNbColumns(); ++aRecordIt )
615 std::vector<double> aPacked = aRecordsAtt->GetColumn( aRecordIt );
619 QString aName( aRecordsAtt->GetColumnTitle( aRecordIt ).c_str() );
625 bool isVisible = (bool) aPacked[it++];
628 int aType = (int) aPacked[it++];
632 case DimensionType_Length :
634 Length* aLength = new Length;
636 // custom plane [2,3,4,5]
637 Standard_Real A = (Standard_Real) aPacked[it++];
638 Standard_Real B = (Standard_Real) aPacked[it++];
639 Standard_Real C = (Standard_Real) aPacked[it++];
640 Standard_Real D = (Standard_Real) aPacked[it++];
641 aLength->Plane = gp_Pln( A, B, C, D );
644 aLength->Flyout = (Standard_Real) aPacked[it++];
647 aLength->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
648 aLength->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
651 Standard_Real aFirstX = aPacked[it++];
652 Standard_Real aFirstY = aPacked[it++];
653 Standard_Real aFirstZ = aPacked[it++];
654 aLength->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
656 // point 2 [12,13,14]
657 Standard_Real aSecondX = aPacked[it++];
658 Standard_Real aSecondY = aPacked[it++];
659 Standard_Real aSecondZ = aPacked[it++];
660 aLength->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
662 aRecord = RecordPtr( aLength );
666 case DimensionType_Diameter :
668 Diameter* aDiam = new Diameter;
670 // custom plane [2,3,4,5]
671 Standard_Real A = (Standard_Real) aPacked[it++];
672 Standard_Real B = (Standard_Real) aPacked[it++];
673 Standard_Real C = (Standard_Real) aPacked[it++];
674 Standard_Real D = (Standard_Real) aPacked[it++];
675 aDiam->Plane = gp_Pln( A, B, C, D );
678 aDiam->Flyout = (Standard_Real) aPacked[it++];
681 aDiam->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
682 aDiam->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
684 // circle location [9,10,11]
685 Standard_Real aLocX = (Standard_Real) aPacked[it++];
686 Standard_Real aLocY = (Standard_Real) aPacked[it++];
687 Standard_Real aLocZ = (Standard_Real) aPacked[it++];
689 // circle normal [12,13,14]
690 Standard_Real aNormX = (Standard_Real) aPacked[it++];
691 Standard_Real aNormY = (Standard_Real) aPacked[it++];
692 Standard_Real aNormZ = (Standard_Real) aPacked[it++];
694 // x-direction [15,16,17]
695 Standard_Real aXDirX = (Standard_Real) aPacked[it++];
696 Standard_Real aXDirY = (Standard_Real) aPacked[it++];
697 Standard_Real aXDirZ = (Standard_Real) aPacked[it++];
700 Standard_Real aRadius = (Standard_Real) aPacked[it++];
702 gp_Ax2 anAx( gp_Pnt( aLocX, aLocY, aLocZ ),
703 gp_Dir( aNormX, aNormY, aNormZ ),
704 gp_Dir( aXDirX, aXDirY, aXDirZ ) );
706 aDiam->Circle = gp_Circ( anAx, aRadius );
708 aRecord = RecordPtr( aDiam );
712 case DimensionType_Angle :
714 Angle* anAngle = new Angle;
717 anAngle->Flyout = (Standard_Real) aPacked[it++];
720 anAngle->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
721 anAngle->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
724 Standard_Real aFirstX = (Standard_Real) aPacked[it++];
725 Standard_Real aFirstY = (Standard_Real) aPacked[it++];
726 Standard_Real aFirstZ = (Standard_Real) aPacked[it++];
729 Standard_Real aSecondX = (Standard_Real) aPacked[it++];
730 Standard_Real aSecondY = (Standard_Real) aPacked[it++];
731 Standard_Real aSecondZ = (Standard_Real) aPacked[it++];
734 Standard_Real aCenterX = (Standard_Real) aPacked[it++];
735 Standard_Real aCenterY = (Standard_Real) aPacked[it++];
736 Standard_Real aCenterZ = (Standard_Real) aPacked[it++];
738 // points point 1 [4-6], point 2 [7-9], center [10-12]
739 anAngle->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
740 anAngle->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
741 anAngle->CenterPoint = gp_Pnt( aCenterX, aCenterY, aCenterZ );
743 aRecord = RecordPtr( anAngle );
748 myVisibility.append( isVisible );
749 myNames.append( aName );
750 myRecords.append( aRecord );
754 //=================================================================================
755 // function : SaveToAttribute
757 //=================================================================================
758 void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
759 const std::string &theEntry )
761 _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
767 _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
769 _PTR(AttributeTableOfReal) aRecordsAtt;
771 aRecordsAtt = aBuilder->FindOrCreateAttribute( aSObj, "AttributeTableOfReal" );
772 aRecordsAtt->SetNbColumns( 0 );
774 for ( int it = 0; it < myRecords.size(); ++it )
776 bool aVisibility = myVisibility[it];
777 QString& aName = myNames[it];
778 RecordPtr& aRecord = myRecords[it];
780 std::vector<double> aPacked;
783 aPacked.push_back( (double) aVisibility );
786 aPacked.push_back( (double) aRecord->Type() );
788 switch ( aRecord->Type() )
790 case DimensionType_Length:
792 Length* aProps = aRecord->AsLength();
794 // custom plane [2,3,4,5]
795 Standard_Real A, B, C, D;
796 aProps->Plane.Coefficients( A, B, C, D );
797 aPacked.push_back( (double) A );
798 aPacked.push_back( (double) B );
799 aPacked.push_back( (double) C );
800 aPacked.push_back( (double) D );
803 aPacked.push_back( (double) aProps->Flyout );
806 aPacked.push_back( (double) aProps->TextHPos );
807 aPacked.push_back( (double) aProps->TextVPos );
810 aPacked.push_back( (double) aProps->FirstPoint.X() );
811 aPacked.push_back( (double) aProps->FirstPoint.Y() );
812 aPacked.push_back( (double) aProps->FirstPoint.Z() );
814 // point 2 [12,13,14]
815 aPacked.push_back( (double) aProps->SecondPoint.X() );
816 aPacked.push_back( (double) aProps->SecondPoint.Y() );
817 aPacked.push_back( (double) aProps->SecondPoint.Z() );
821 case DimensionType_Diameter:
823 Diameter* aProps = aRecord->AsDiameter();
825 // custom plane [2,3,4,5]
826 Standard_Real A, B, C, D;
827 aProps->Plane.Coefficients( A, B, C, D );
828 aPacked.push_back( (double) A );
829 aPacked.push_back( (double) B );
830 aPacked.push_back( (double) C );
831 aPacked.push_back( (double) D );
834 aPacked.push_back( (double) aProps->Flyout );
837 aPacked.push_back( (double) aProps->TextHPos );
838 aPacked.push_back( (double) aProps->TextVPos );
840 // circle location [9,10,11]
841 aPacked.push_back( (double) aProps->Circle.Location().X() );
842 aPacked.push_back( (double) aProps->Circle.Location().Y() );
843 aPacked.push_back( (double) aProps->Circle.Location().Z() );
845 // circle normal [12,13,14]
846 aPacked.push_back( (double) aProps->Circle.Axis().Direction().X() );
847 aPacked.push_back( (double) aProps->Circle.Axis().Direction().Y() );
848 aPacked.push_back( (double) aProps->Circle.Axis().Direction().Z() );
850 // x-direction [15,16,17]
851 aPacked.push_back( (double) aProps->Circle.XAxis().Direction().X() );
852 aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Y() );
853 aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Z() );
856 aPacked.push_back( (double) aProps->Circle.Radius() );
860 case DimensionType_Angle:
862 Angle* aProps = aRecord->AsAngle();
865 aPacked.push_back( (double) aProps->Flyout );
868 aPacked.push_back( (double) aProps->TextHPos );
869 aPacked.push_back( (double) aProps->TextVPos );
872 aPacked.push_back( (double) aProps->FirstPoint.X() );
873 aPacked.push_back( (double) aProps->FirstPoint.Y() );
874 aPacked.push_back( (double) aProps->FirstPoint.Z() );
877 aPacked.push_back( (double) aProps->SecondPoint.X() );
878 aPacked.push_back( (double) aProps->SecondPoint.Y() );
879 aPacked.push_back( (double) aProps->SecondPoint.Z() );
882 aPacked.push_back( (double) aProps->CenterPoint.X() );
883 aPacked.push_back( (double) aProps->CenterPoint.Y() );
884 aPacked.push_back( (double) aProps->CenterPoint.Z() );
889 aRecordsAtt->AddColumn( aPacked );
890 aRecordsAtt->SetColumnTitle( it + 1, aName.toStdString() );
894 //=================================================================================
895 // function : TypeFromIO
897 //=================================================================================
898 int GEOMGUI_DimensionProperty::TypeFromIO( const Handle(AIS_Dimension)& theIO ) const
900 if ( theIO->IsKind( STANDARD_TYPE( AIS_LengthDimension ) ) )
902 return DimensionType_Length;
905 if ( theIO->IsKind( STANDARD_TYPE( AIS_DiameterDimension ) ) )
907 return DimensionType_Diameter;
910 if ( theIO->IsKind( STANDARD_TYPE( AIS_AngleDimension ) ) )
912 return DimensionType_Angle;
915 Standard_ProgramError::Raise( "unsupported dimension type" );