Salome HOME
Small correction for writing of data to file.
[modules/hydro.git] / src / HYDROData / HYDROData_Image.cxx
index 0d1da6761f1b9e1e8fd86725d2a2ac75adf4c3a7..930d2a0e0733b9c04f8aa5c4ee5761e3cc7fc69a 100644 (file)
@@ -7,10 +7,9 @@
 #include <TDataStd_ReferenceList.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDataStd_UAttribute.hxx>
+#include <TDataStd_AsciiString.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 
-// tage of the child of my label that contains information about the operator
-static const int TAG_OPERATOR = 1; 
 static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
@@ -60,6 +59,23 @@ QImage HYDROData_Image::Image()
   return aResult;
 }
 
+void HYDROData_Image::SetFilePath(const QString& theFilePath)
+{
+  TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
+  TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr );
+}
+
+QString HYDROData_Image::GetFilePath() const
+{
+  QString aRes;
+
+  Handle(TDataStd_AsciiString) anAsciiStr;
+  if ( myLab.FindChild( DataTag_FilePath ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
+    aRes = QString( anAsciiStr->Get().ToCString() );
+
+  return aRes;
+}
+
 void HYDROData_Image::SetTrsf(const QTransform& theTrsf)
 {
   // locate 9 coeffs of matrix into the real array
@@ -92,6 +108,49 @@ QTransform HYDROData_Image::Trsf()
   return aTrsf;
 }
 
+void HYDROData_Image::SetTrsfPoints(const QPoint& thePointAIn,
+                                    const QPoint& thePointBIn,
+                                    const QPoint& thePointCIn,
+                                    const QPointF& thePointAOut,
+                                    const QPointF& thePointBOut,
+                                    const QPointF& thePointCOut)
+{
+  Handle(TDataStd_RealArray) anArray;
+  if (!myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+    anArray = TDataStd_RealArray::Set(myLab.FindChild(DataTag_TrsfPoints), 1, 12);
+  }
+  anArray->SetValue(1, thePointAIn.x());
+  anArray->SetValue(2, thePointAIn.y());
+  anArray->SetValue(3, thePointBIn.x());
+  anArray->SetValue(4, thePointBIn.y());
+  anArray->SetValue(5, thePointCIn.x());
+  anArray->SetValue(6, thePointCIn.y());
+  anArray->SetValue(7, thePointAOut.x());
+  anArray->SetValue(8, thePointAOut.y());
+  anArray->SetValue(9, thePointBOut.x());
+  anArray->SetValue(10, thePointBOut.y());
+  anArray->SetValue(11, thePointCOut.x());
+  anArray->SetValue(12, thePointCOut.y());
+}
+
+void HYDROData_Image::TrsfPoints(QPoint& thePointAIn,
+                                 QPoint& thePointBIn,
+                                 QPoint& thePointCIn,
+                                 QPointF& thePointAOut,
+                                 QPointF& thePointBOut,
+                                 QPointF& thePointCOut)
+{
+  Handle(TDataStd_RealArray) anArray;
+  if (myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+    thePointAIn = QPointF( anArray->Value(1), anArray->Value(2) ).toPoint();
+    thePointBIn = QPointF( anArray->Value(3), anArray->Value(4) ).toPoint();
+    thePointCIn = QPointF( anArray->Value(5), anArray->Value(6) ).toPoint();
+    thePointAOut = QPointF( anArray->Value(7), anArray->Value(8) );
+    thePointBOut = QPointF( anArray->Value(9), anArray->Value(10) );
+    thePointCOut = QPointF( anArray->Value(11), anArray->Value(12) );
+  }
+}
+
 void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced)
 {
   Handle(TDataStd_ReferenceList) aRefs;
@@ -167,14 +226,14 @@ void HYDROData_Image::ClearReferences()
 
 void HYDROData_Image::SetOperatorName(const QString theOpName)
 {
-  TDataStd_Name::Set(myLab.FindChild(TAG_OPERATOR),
+  TDataStd_Name::Set(myLab.FindChild(DataTag_Operator),
     TCollection_ExtendedString(theOpName.toLatin1().constData()));
 }
 
 QString HYDROData_Image::OperatorName()
 {
   Handle(TDataStd_Name) aName;
-  if (myLab.FindChild(TAG_OPERATOR).
+  if (myLab.FindChild(DataTag_Operator).
         FindAttribute(TDataStd_Name::GetID(), aName)) {
     TCollection_AsciiString aStr(aName->Get());
     return QString(aStr.ToCString());
@@ -184,13 +243,13 @@ QString HYDROData_Image::OperatorName()
 
 void HYDROData_Image::SetArgs(const QByteArray& theArgs)
 {
-  SaveByteArray(TAG_OPERATOR, theArgs.constData(), theArgs.length());
+  SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length());
 }
 
 QByteArray HYDROData_Image::Args()
 {
   int aLen = 0;
-  const char* aData = ByteArray(TAG_OPERATOR, aLen);
+  const char* aData = ByteArray(DataTag_Operator, aLen);
   if (!aLen)
     return QByteArray();
   return QByteArray(aData, aLen);