2 #include "HYDROData_Image.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Lambert93.h"
6 #include "HYDROData_OperationsFactory.h"
8 #include <TDataStd_RealArray.hxx>
9 #include <TDataStd_ByteArray.hxx>
10 #include <TDataStd_Integer.hxx>
11 #include <TDataStd_IntegerArray.hxx>
12 #include <TDataStd_ReferenceList.hxx>
13 #include <TDataStd_UAttribute.hxx>
14 #include <TDataStd_AsciiString.hxx>
16 #include <ImageComposer_Operator.h>
17 #include <ImageComposer_MetaTypes.h>
19 #include <QStringList>
21 static const Standard_GUID GUID_SELF_SPLITTED("997995aa-5c19-40bf-9a60-ab4b70ad04d8");
22 static const Standard_GUID GUID_HAS_LOCAL_POINTS("FD8841AA-FC44-42fa-B6A7-0F682CCC6F27");
23 static const Standard_GUID GUID_HAS_GLOBAL_POINTS("330D0E81-742D-4ea3-92D4-484877CFA7C1");
25 #define PYTHON_IMAGE_ID "KIND_IMAGE"
27 IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity)
28 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Entity)
30 HYDROData_Image::HYDROData_Image()
35 HYDROData_Image::~HYDROData_Image()
39 QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
43 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
44 if ( aDocument.IsNull() )
47 QString aDocName = aDocument->GetDocPyName();
48 QString anImageName = GetName();
50 aResList << QString( "%1 = %2.CreateObject( %3 );" )
51 .arg( anImageName ).arg( aDocName ).arg( PYTHON_IMAGE_ID );
52 aResList << QString( "%1.SetName( \"%2\" );" )
53 .arg( anImageName ).arg( anImageName );
55 QString aFilePath = GetFilePath();
56 if ( !aFilePath.isEmpty() )
58 aResList << QString( "" );
59 aResList << QString( "%1.LoadImage( \"%2\" );" )
60 .arg( anImageName ).arg( aFilePath );
61 aResList << QString( "" );
63 // Dump transformation points for image
65 QString aGap = QString().fill( ' ', anImageName.size() + 16 );
67 bool anIsByTwoPoints = IsByTwoPoints();
69 QPoint aLocalPointA, aLocalPointB, aLocalPointC;
70 if ( GetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC ) )
72 aResList << QString( "%1.SetLocalPoints( QPoint( %2, %3 )," )
73 .arg( anImageName ).arg( aLocalPointA.x() ).arg( aLocalPointA.y() );
74 aResList << QString( aGap + "QPoint( %1, %2 )," )
75 .arg( aLocalPointB.x() ).arg( aLocalPointB.y() );
76 aResList << QString( aGap + "QPoint( %1, %2 ) );" )
77 .arg( aLocalPointC.x() ).arg( aLocalPointC.y() );
78 aResList << QString( "" );
81 HYDROData_Image::TransformationMode aTransformationMode;
82 QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
83 if ( GetGlobalPoints( aTransformationMode, aTrsfPointA, aTrsfPointB, aTrsfPointC ) )
85 aResList << QString( "%1.SetGlobalPoints( %2," )
86 .arg( anImageName ).arg( aTransformationMode );
87 aResList << QString( aGap + "QPointF( %1, %2 )," )
88 .arg( aTrsfPointA.x() ).arg( aTrsfPointA.y() );
89 aResList << QString( aGap + "QPointF( %1, %2 )," )
90 .arg( aTrsfPointB.x() ).arg( aTrsfPointB.y() );
91 aResList << QString( aGap + "QPointF( %1, %2 ) );" )
92 .arg( aTrsfPointC.x() ).arg( aTrsfPointC.y() );
94 if ( aTransformationMode == ReferenceImage )
96 Handle(HYDROData_Image) aRefImg = GetTrsfReferenceImage();
97 setPythonReferenceObject( theTreatedObjects, aResList, aRefImg, "SetTrsfReferenceImage" );
103 // Image is composed from other image(s)
105 QString anOperatorName = OperatorName();
106 if ( !anOperatorName.isEmpty() )
108 aResList << QString( "" );
110 aResList << QString( "%1.SetOperatorName( \"%2\" );" )
111 .arg( anImageName ).arg( anOperatorName );
113 ImageComposer_Operator* anImageOp =
114 HYDROData_OperationsFactory::Factory()->Operator( OperatorName() );
117 // Dump operation arguments
118 QString anOpArgsArrayName;
119 QStringList anOpArgs = anImageOp->dumpArgsToPython( anOpArgsArrayName );
120 if ( !anOpArgs.isEmpty() )
122 aResList << QString( "" );
123 aResList << anOpArgs;
125 aResList << QString( "" );
126 aResList << QString( "%1.SetArgs( %2 );" )
127 .arg( anImageName ).arg( anOpArgsArrayName );
132 int aNbReferences = NbReferences();
133 if ( aNbReferences > 0 )
135 aResList << QString( "" );
137 for ( int i = 0; i < aNbReferences; ++i )
139 Handle(HYDROData_Image) aRefImg = Handle(HYDROData_Image)::DownCast( Reference( i ) );
140 setPythonReferenceObject( theTreatedObjects, aResList, aRefImg, "AppendReference" );
144 // Necessary to update image in case of composed operator
145 aResList << QString( "" );
146 aResList << QString( "%1.Update();" ).arg( anImageName );
152 void HYDROData_Image::Update()
154 bool anIsToUpdate = IsMustBeUpdated();
156 HYDROData_Entity::Update();
161 HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory();
163 ImageComposer_Operator* anOp = aFactory->Operator( OperatorName() );
164 if ( anOp ) // Update image if there is an operation
166 // Fill by arguments and process the operation
167 anOp->setBinArgs( Args() );
169 QVariant anObj1, anObj2;
170 int aNbReferences = NbReferences();
172 if ( aNbReferences > 0 )
174 // First referenced object
175 Handle(HYDROData_Entity) aRefObj = Reference( 0 );
176 if ( !aRefObj.IsNull() )
178 anObj1 = aRefObj->GetDataVariant();
179 if ( !anObj1.isNull() && anObj1.canConvert<ImageComposer_Image>() )
181 ImageComposer_Image anImage = anObj1.value<ImageComposer_Image>();
182 QTransform aTransform = anImage.transform();
183 SetTrsf( aTransform );
188 if ( aNbReferences > 1 )
190 // Second referenced object
191 Handle(HYDROData_Entity) aRefObj = Reference( 1 );
192 if ( !aRefObj.IsNull() )
193 anObj2 = aRefObj->GetDataVariant();
196 ImageComposer_Image aResImg = anOp->process( anObj1, anObj2 );
198 SetTrsf( aResImg.transform() );
200 else // Update image if it positioned relatively to other image
205 SetToUpdate( false );
208 QVariant HYDROData_Image::GetDataVariant()
210 QTransform aTransform = Trsf();
212 ImageComposer_Image anImage = Image();
213 anImage.setTransform( aTransform );
216 aVarData.setValue<ImageComposer_Image>( anImage );
221 HYDROData_SequenceOfObjects HYDROData_Image::GetAllReferenceObjects() const
223 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
225 Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
226 if ( !aRefImage.IsNull() )
227 aResSeq.Append( aRefImage );
229 HYDROData_SequenceOfObjects aSeqRefObjects = GetReferenceObjects( 0 );
230 aResSeq.Append( aSeqRefObjects );
235 void HYDROData_Image::SetImage(const QImage& theImage)
237 if ( theImage.isNull() )
239 // for empty image remove all previously stored attributes
240 myLab.ForgetAttribute(TDataStd_IntegerArray::GetID());
241 myLab.ForgetAttribute(TDataStd_ByteArray::GetID());
247 // convert 8-bits images
248 if ( theImage.format() == QImage::Format_Indexed8 ) {
249 anImage = theImage.convertToFormat( QImage::Format_RGB32 );
254 // store width, height, bytes per line and format in integer array
255 Handle(TDataStd_IntegerArray) aParams;
256 if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams)) {
257 aParams = TDataStd_IntegerArray::Set(myLab, 1, 4);
259 aParams->SetValue(1, anImage.width());
260 aParams->SetValue(2, anImage.height());
261 aParams->SetValue(3, anImage.bytesPerLine());
262 aParams->SetValue(4, (int)(anImage.format()));
263 // store data of image in byte array
264 const char* aData = (const char*)(anImage.bits());
265 SaveByteArray(0, aData, anImage.byteCount());
271 bool HYDROData_Image::LoadImage( const QString& theFilePath )
273 QImage anImage( theFilePath );
275 return !anImage.isNull();
278 QImage HYDROData_Image::Image()
280 Handle(TDataStd_IntegerArray) aParams;
281 if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams))
282 return QImage(); // return empty image if there is no array
284 uchar* anArray = (uchar*)ByteArray(0, aLen);
286 return QImage(); // return empty image if there is no array
287 QImage aResult(anArray, aParams->Value(1), aParams->Value(2),
288 aParams->Value(3), QImage::Format(aParams->Value(4)));
292 void HYDROData_Image::SetFilePath( const QString& theFilePath )
294 TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
295 TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr );
300 QString HYDROData_Image::GetFilePath() const
304 TDF_Label aLabel = myLab.FindChild( DataTag_FilePath, false );
305 if ( !aLabel.IsNull() )
307 Handle(TDataStd_AsciiString) anAsciiStr;
308 if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
309 aRes = QString( anAsciiStr->Get().ToCString() );
315 void HYDROData_Image::SetTrsf(const QTransform& theTrsf)
317 // locate 9 coeffs of matrix into the real array
318 Handle(TDataStd_RealArray) anArray;
319 if (!myLab.FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
320 if (theTrsf.isIdentity()) return; // no need to store identity transformation
321 anArray = TDataStd_RealArray::Set(myLab, 1, 9);
323 anArray->SetValue(1, theTrsf.m11());
324 anArray->SetValue(2, theTrsf.m12());
325 anArray->SetValue(3, theTrsf.m13());
326 anArray->SetValue(4, theTrsf.m21());
327 anArray->SetValue(5, theTrsf.m22());
328 anArray->SetValue(6, theTrsf.m23());
329 anArray->SetValue(7, theTrsf.m31());
330 anArray->SetValue(8, theTrsf.m32());
331 anArray->SetValue(9, theTrsf.m33());
336 QTransform HYDROData_Image::Trsf() const
338 // get 9 coeffs of matrix from the real array
339 Handle(TDataStd_RealArray) anArray;
340 if (!myLab.FindAttribute(TDataStd_RealArray::GetID(), anArray))
341 return QTransform(); // return identity if there is no array
343 anArray->Value(1), anArray->Value(2), anArray->Value(3),
344 anArray->Value(4), anArray->Value(5), anArray->Value(6),
345 anArray->Value(7), anArray->Value(8), anArray->Value(9));
349 void HYDROData_Image::UpdateTrsf()
351 QPoint aPointA, aPointB, aPointC;
352 if ( !GetLocalPoints( aPointA, aPointB, aPointC ) )
355 TransformationMode aTrsfMode;
356 QPointF aTrsfPointA, aTrsfPointB, aTrsfPointC;
357 if ( !GetGlobalPoints( aTrsfMode, aTrsfPointA, aTrsfPointB, aTrsfPointC ) )
360 QTransform aRefTransform;
361 Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
363 bool anIsRefImage = aTrsfMode == ReferenceImage;
366 if ( aRefImage.IsNull() )
369 aRefTransform = aRefImage->Trsf();
372 bool anIsByTwoPoints = IsByTwoPoints();
374 // Convert lambert coordinates to cartesian
375 if ( aTrsfMode == ManualGeodesic )
377 double aXCart = 0, aYCart = 0;
379 HYDROData_Lambert93::toXY( aTrsfPointA.y(), aTrsfPointA.x(), aXCart, aYCart );
380 aTrsfPointA = QPointF( aXCart, aYCart );
382 HYDROData_Lambert93::toXY( aTrsfPointB.y(), aTrsfPointB.x(), aXCart, aYCart );
383 aTrsfPointB = QPointF( aXCart, aYCart );
385 if ( !anIsByTwoPoints )
387 HYDROData_Lambert93::toXY( aTrsfPointC.y(), aTrsfPointC.x(), aXCart, aYCart );
388 aTrsfPointC = QPointF( aXCart, aYCart );
392 // generate third points if needed
393 if ( anIsByTwoPoints )
395 aPointC = generateThirdPoint( aPointA, aPointB, true ).toPoint();
396 aTrsfPointC = generateThirdPoint( aTrsfPointA, aTrsfPointB, anIsRefImage );
399 int xa = aPointA.x();
400 int ya = aPointA.y();
401 int xb = aPointB.x();
402 int yb = aPointB.y();
403 int xc = aPointC.x();
404 int yc = aPointC.y();
406 double xta = aTrsfPointA.x();
407 double yta = aTrsfPointA.y();
408 double xtb = aTrsfPointB.x();
409 double ytb = aTrsfPointB.y();
410 double xtc = aTrsfPointC.x();
411 double ytc = aTrsfPointC.y();
413 // first, check that three input points don't belong to a single line
414 if( ( yb - ya ) * ( xc - xa ) == ( yc - ya ) * ( xb - xa ) )
417 // the same check for the reference points
418 if( anIsRefImage && ( ( ytb - yta ) * ( xtc - xta ) == ( ytc - yta ) * ( xtb - xta ) ) )
421 QTransform aTransform1( xa, ya, 1, xb, yb, 1, xc, yc, 1 );
422 QTransform aTransform2( xta, yta, 1, xtb, ytb, 1, xtc, ytc, 1 );
424 bool anIsInvertible = false;
425 QTransform aTransform1Inverted = aTransform1.inverted( &anIsInvertible );
426 if( !anIsInvertible )
429 QTransform aResTransform = aTransform1Inverted * aTransform2;
431 aResTransform *= aRefTransform;
433 SetTrsf( aResTransform );
436 bool HYDROData_Image::IsByTwoPoints() const
438 if ( !HasLocalPoints() || !HasGlobalPoints() )
441 QPoint aPointA, aPointB, aPointC;
442 GetLocalPoints( aPointA, aPointB, aPointC );
444 return aPointC.x() < 0 && aPointC.y() < 0;
447 bool HYDROData_Image::HasReferences() const
449 Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
450 int aNbReferences = NbReferences();
452 return !aRefImage.IsNull() || aNbReferences > 0;
455 void HYDROData_Image::RemoveAllReferences()
457 if ( !HasReferences() )
460 Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
461 if ( !aRefImage.IsNull() )
463 RemoveTrsfReferenceImage();
468 SetOperatorName( "" );
470 SetIsSelfSplitted( false );
473 bool anIsByTwoPoints = IsByTwoPoints();
475 QImage anImage = Image();
476 if ( anImage.isNull() )
478 SetToUpdate( false );
482 // Set local points to default position
483 QPoint aLocalPointA = QPoint( 0, 0 );
484 QPoint aLocalPointB = QPoint( anImage.width(), 0 );
485 QPoint aLocalPointC = anIsByTwoPoints ? QPoint( INT_MIN, INT_MIN ) : QPoint( 0, anImage.height() );
487 SetLocalPoints( aLocalPointA, aLocalPointB, aLocalPointC, false );
489 // Calculate global points
490 QTransform aTransform = Trsf();
492 QPointF aTrsfPointA = QPointF( aTransform.map( aLocalPointA ) );
493 QPointF aTrsfPointB = QPointF( aTransform.map( aLocalPointB ) );
494 QPointF aTrsfPointC = anIsByTwoPoints ? QPointF( INT_MIN, INT_MIN ) :
495 QPointF( aTransform.map( aLocalPointC ) );
497 SetGlobalPoints( ManualCartesian, aTrsfPointA, aTrsfPointB, aTrsfPointC );
499 SetToUpdate( false );
502 void HYDROData_Image::SetLocalPoints( const QPoint& thePointA,
503 const QPoint& thePointB,
504 const QPoint& thePointC,
505 const bool theIsUpdate )
507 Handle(TDataStd_RealArray) anArray;
508 if ( !myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
509 anArray = TDataStd_RealArray::Set( myLab.FindChild( DataTag_TrsfPoints ), 1, 12 );
511 anArray->SetValue( 1, thePointA.x() );
512 anArray->SetValue( 2, thePointA.y() );
513 anArray->SetValue( 3, thePointB.x() );
514 anArray->SetValue( 4, thePointB.y() );
515 anArray->SetValue( 5, thePointC.x() );
516 anArray->SetValue( 6, thePointC.y() );
518 TDataStd_UAttribute::Set( myLab.FindChild( DataTag_TrsfPoints ), GUID_HAS_LOCAL_POINTS );
526 bool HYDROData_Image::GetLocalPoints( QPoint& thePointA,
528 QPoint& thePointC ) const
530 if ( !HasLocalPoints() )
533 Handle(TDataStd_RealArray) anArray;
534 myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray );
536 thePointA = QPointF( anArray->Value( 1 ), anArray->Value( 2 ) ).toPoint();
537 thePointB = QPointF( anArray->Value( 3 ), anArray->Value( 4 ) ).toPoint();
538 thePointC = QPointF( anArray->Value( 5 ), anArray->Value( 6 ) ).toPoint();
543 bool HYDROData_Image::HasLocalPoints() const
545 TDF_Label aLabel = myLab.FindChild( DataTag_TrsfPoints, false );
546 if ( aLabel.IsNull() || !aLabel.IsAttribute( GUID_HAS_LOCAL_POINTS ) )
549 Handle(TDataStd_RealArray) anArray;
550 return aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray );
554 void HYDROData_Image::SetGlobalPoints( const TransformationMode& theMode,
555 const QPointF& thePointA,
556 const QPointF& thePointB,
557 const QPointF& thePointC,
558 const bool theIsUpdate )
560 Handle(TDataStd_RealArray) anArray;
561 if ( !myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray ) )
562 anArray = TDataStd_RealArray::Set( myLab.FindChild( DataTag_TrsfPoints ), 1, 12 );
564 anArray->SetValue( 7, thePointA.x() );
565 anArray->SetValue( 8, thePointA.y() );
566 anArray->SetValue( 9, thePointB.x() );
567 anArray->SetValue( 10, thePointB.y() );
568 anArray->SetValue( 11, thePointC.x() );
569 anArray->SetValue( 12, thePointC.y() );
571 SetTrsfMode( theMode );
573 TDataStd_UAttribute::Set( myLab.FindChild( DataTag_TrsfPoints ), GUID_HAS_GLOBAL_POINTS );
581 bool HYDROData_Image::GetGlobalPoints( TransformationMode& theMode,
584 QPointF& thePointC ) const
586 if ( !HasGlobalPoints() )
589 theMode = GetTrsfMode();
591 Handle(TDataStd_RealArray) anArray;
592 myLab.FindChild( DataTag_TrsfPoints ).FindAttribute( TDataStd_RealArray::GetID(), anArray );
594 thePointA = QPointF( anArray->Value( 7 ), anArray->Value( 8 ) );
595 thePointB = QPointF( anArray->Value( 9 ), anArray->Value( 10 ) );
596 thePointC = QPointF( anArray->Value( 11 ), anArray->Value( 12 ) );
601 bool HYDROData_Image::HasGlobalPoints() const
603 TDF_Label aLabel = myLab.FindChild( DataTag_TrsfPoints, false );
604 if ( aLabel.IsNull() || !aLabel.IsAttribute( GUID_HAS_GLOBAL_POINTS ) )
607 Handle(TDataStd_RealArray) anArray;
608 return aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray );
611 void HYDROData_Image::SetReferencePoints( const Handle(HYDROData_Image)& theRefImage,
612 const QPointF& thePointA,
613 const QPointF& thePointB,
614 const QPointF& thePointC,
615 const bool theIsUpdate )
617 SetTrsfReferenceImage( theRefImage );
618 SetGlobalPoints( ReferenceImage, thePointA, thePointB, thePointC, theIsUpdate );
621 bool HYDROData_Image::GetReferencePoints( Handle(HYDROData_Image)& theRefImage,
624 QPointF& thePointC ) const
626 if ( !HasReferencePoints() )
629 theRefImage = GetTrsfReferenceImage();
631 TransformationMode aMode;
632 GetGlobalPoints( aMode, thePointA, thePointB, thePointC );
637 bool HYDROData_Image::HasReferencePoints() const
639 if ( !HasGlobalPoints() )
642 Handle(HYDROData_Image) aRefImage = GetTrsfReferenceImage();
643 if ( aRefImage.IsNull() )
646 TransformationMode aTrsfMode = GetTrsfMode();
647 if ( aTrsfMode != ReferenceImage )
653 void HYDROData_Image::SetTrsfMode( const TransformationMode& theMode )
655 TDataStd_Integer::Set( myLab.FindChild( DataTag_TrsfMode ), (int)theMode );
659 HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const
661 TransformationMode aResMode = ManualGeodesic;
663 TDF_Label aLabel = myLab.FindChild( DataTag_TrsfPoints, false );
664 if ( !aLabel.IsNull() )
666 Handle(TDataStd_Integer) aMode;
667 if ( myLab.FindChild( DataTag_TrsfMode ).FindAttribute( TDataStd_Integer::GetID(), aMode ) )
668 aResMode = (TransformationMode)aMode->Get();
674 void HYDROData_Image::SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage )
676 SetReferenceObject( theRefImage, DataTag_TrsfImage );
680 Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const
682 return Handle(HYDROData_Image)::DownCast( GetReferenceObject( DataTag_TrsfImage ) );
685 void HYDROData_Image::RemoveTrsfReferenceImage()
687 RemoveReferenceObject( DataTag_TrsfImage );
691 void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced )
693 AddReferenceObject( theReferenced, 0 );
697 int HYDROData_Image::NbReferences() const
699 return NbReferenceObjects( 0 );
702 Handle(HYDROData_Entity) HYDROData_Image::Reference( const int theIndex ) const
704 return GetReferenceObject( 0, theIndex );
707 void HYDROData_Image::ChangeReference(
708 const int theIndex, Handle(HYDROData_Entity) theReferenced)
710 SetReferenceObject( theReferenced, 0, theIndex );
714 void HYDROData_Image::RemoveReference(const int theIndex)
716 RemoveReferenceObject( 0, theIndex );
720 void HYDROData_Image::ClearReferences()
722 ClearReferenceObjects( 0 );
726 void HYDROData_Image::SetOperatorName( const QString theOpName )
728 TCollection_AsciiString anAsciiStr( theOpName.toStdString().c_str() );
729 TDataStd_AsciiString::Set( myLab.FindChild( DataTag_Operator ), anAsciiStr );
733 QString HYDROData_Image::OperatorName() const
737 TDF_Label aLabel = myLab.FindChild( DataTag_Operator, false );
738 if ( !aLabel.IsNull() )
740 Handle(TDataStd_AsciiString) anAsciiStr;
741 if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
742 aRes = QString( anAsciiStr->Get().ToCString() );
748 void HYDROData_Image::SetArgs(const QByteArray& theArgs)
750 SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length());
754 QByteArray HYDROData_Image::Args() const
757 const char* aData = ByteArray(DataTag_Operator, aLen);
760 return QByteArray(aData, aLen);
763 void HYDROData_Image::SetIsSelfSplitted(bool theFlag)
766 TDataStd_UAttribute::Set(myLab, GUID_SELF_SPLITTED);
768 myLab.ForgetAttribute(GUID_SELF_SPLITTED);
773 bool HYDROData_Image::IsSelfSplitted() const
775 return myLab.IsAttribute(GUID_SELF_SPLITTED);
778 QPointF HYDROData_Image::generateThirdPoint( const QPointF& thePointA,
779 const QPointF& thePointB,
780 const bool& theIsLocal ) const
782 // Rotate vector to 90 degrees : clockwise - for local
783 // counterclockwise - for global
784 const double aTheta = theIsLocal ? -M_PI_2 : M_PI_2;
788 // Move to (0,0) for correct rotation
789 double x = thePointB.x() - thePointA.x();
790 double y = thePointB.y() - thePointA.y();
792 aResPoint.setX( x * cos( aTheta ) - y * sin( aTheta ) );
793 aResPoint.setY( x * sin( aTheta ) + y * cos( aTheta ) );
795 // Move back to origin position
796 aResPoint.setX( aResPoint.x() + thePointA.x() );
797 aResPoint.setY( aResPoint.y() + thePointA.y() );