]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Initial version
authoradmin <salome-admin@opencascade.com>
Mon, 15 Jul 2013 11:58:58 +0000 (11:58 +0000)
committeradmin <salome-admin@opencascade.com>
Mon, 15 Jul 2013 11:58:58 +0000 (11:58 +0000)
12 files changed:
src/HYDROData/HYDROData.h [new file with mode: 0644]
src/HYDROData/HYDROData_Application.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Application.h [new file with mode: 0644]
src/HYDROData/HYDROData_Image.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Iterator.h [new file with mode: 0644]
src/HYDROData/HYDROData_Object.cxx [new file with mode: 0644]
src/HYDROData/test_HYDROData_Document.h [new file with mode: 0644]
src/HYDROData/test_HYDROData_Image.h [new file with mode: 0644]
src/HYDROData/test_HYDROData_Iterator.cxx [new file with mode: 0644]
src/HYDROData/test_HYDROData_Iterator.h [new file with mode: 0644]
src/HYDROData/test_HYDROData_Object.cxx [new file with mode: 0644]
src/HYDROData/test_HYDROData_Object.h [new file with mode: 0644]

diff --git a/src/HYDROData/HYDROData.h b/src/HYDROData/HYDROData.h
new file mode 100644 (file)
index 0000000..220feb9
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef HYDRODATA_H
+#define HYDRODATA_H
+
+#if defined HYDRODATA_EXPORTS
+#if defined WIN32
+#define HYDRODATA_EXPORT              __declspec( dllexport )
+#else
+#define HYDRODATA_EXPORT
+#endif
+#else
+#if defined WIN32
+#define HYDRODATA_EXPORT              __declspec( dllimport )
+#else
+#define HYDRODATA_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/HYDROData/HYDROData_Application.cxx b/src/HYDROData/HYDROData_Application.cxx
new file mode 100644 (file)
index 0000000..3c03259
--- /dev/null
@@ -0,0 +1,82 @@
+#include <HYDROData_Application.h>
+
+#include <TColStd_SequenceOfExtendedString.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Application,TDocStd_Application)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Application,TDocStd_Application)
+
+static HYDROData_Application* TheApplication = new HYDROData_Application;
+
+//=======================================================================
+//function : getApplication
+//purpose  : 
+//=======================================================================
+HYDROData_Application* HYDROData_Application::GetApplication() 
+{
+  return TheApplication;
+}
+
+//=======================================================================
+//function : getDocument
+//purpose  : 
+//=======================================================================
+Handle(HYDROData_Document) HYDROData_Application::GetDocument(int theStudyID)
+{
+  if (myDocuments.IsBound(theStudyID)) {
+    return myDocuments.Find(theStudyID);
+  }
+  // document not found => create the new one
+  return Handle(HYDROData_Document)();
+}
+
+//=======================================================================
+//function : OCAFApp_Application
+//purpose  : 
+//=======================================================================
+HYDROData_Application::HYDROData_Application ()
+{
+  // store handle to the application to avoid nullification
+  static Handle(HYDROData_Application) TheKeepHandle;
+  TheKeepHandle = this;
+}
+
+//=======================================================================
+//function : addDocument
+//purpose  : 
+//=======================================================================
+void HYDROData_Application::AddDocument(int theStudyID, Handle(HYDROData_Document) theDocument)
+{
+  myDocuments.Bind(theStudyID, theDocument);
+}
+
+//=======================================================================
+//function : removeDocument
+//purpose  : 
+//=======================================================================
+void HYDROData_Application::RemoveDocument(Handle(HYDROData_Document) theDocument)
+{
+  DataMapOfStudyIDDocument::Iterator anIter(myDocuments);
+  for(; anIter.More(); anIter.Next())
+    if (anIter.Value() == theDocument) {
+      myDocuments.UnBind(anIter.Key());
+      break;
+    }
+}
+
+//=======================================================================
+//function : Formats
+//purpose  : 
+//=======================================================================
+void HYDROData_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) 
+{
+  theFormats.Append(TCollection_ExtendedString ("BinOcaf")); // standard binary schema
+}
+
+//=======================================================================
+//function : ResourcesName
+//purpose  : 
+//=======================================================================
+Standard_CString HYDROData_Application::ResourcesName()
+{
+  return Standard_CString("Standard");
+}
diff --git a/src/HYDROData/HYDROData_Application.h b/src/HYDROData/HYDROData_Application.h
new file mode 100644 (file)
index 0000000..b0fa53d
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef HYDROData_Application_HeaderFile
+#define HYDROData_Application_HeaderFile
+
+#include <HYDROData_Document.h> 
+#include <TDocStd_Application.hxx>
+#include <NCollection_DataMap.hxx>
+
+typedef NCollection_DataMap<int, Handle(HYDROData_Document)> DataMapOfStudyIDDocument;
+
+/**\class HYDROData_Application
+ *
+ * \brief Realization of Open CASCADE application abstraction. Class for 
+ *        internal use inside of a package only.
+ * 
+ * Application supports the formats and document management. It is uses OCAF-lke
+ * architecture and just implements specific features of the module.
+ */
+class HYDROData_Application : public TDocStd_Application
+{
+public: // useful methods inside of the package
+
+  //! Retuns the application: one per process    
+  HYDRODATA_EXPORT static HYDROData_Application* GetApplication();   
+
+public: // Redefined OCAF methods
+  //! Return name of resource (i.e. "Standard")
+  Standard_CString ResourcesName();
+  //! Return format (i.e "MDTV-Standard")
+  //! \param theFormats sequence of allowed formats for input/output
+  virtual void Formats(TColStd_SequenceOfExtendedString& theFormats);    
+  //! Constructor
+  //! Use method GetInstance() method to obtain 
+  //! the static instance of the object (or derive your own application)
+  HYDROData_Application();
+
+  // CASCADE RTTI
+  DEFINE_STANDARD_RTTI(HYDROData_Application)
+
+private:
+  //! Returns document by its study ID, if document doesn't exists return null
+  Handle(HYDROData_Document) GetDocument(int theStudyID);
+
+  //! Appends document to the application
+  void AddDocument(int theStudyID, Handle(HYDROData_Document) theDocument);
+
+  //! Removes document from the application
+  void RemoveDocument(Handle(HYDROData_Document) theDocument);
+
+  //! map from SALOME study ID to the document
+  DataMapOfStudyIDDocument myDocuments;
+
+  friend class HYDROData_Document; // to manipulate documents of application
+};
+
+// Define handle class 
+DEFINE_STANDARD_HANDLE(HYDROData_Application,TDocStd_Application)
+
+#endif
diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx
new file mode 100644 (file)
index 0000000..62e1ba5
--- /dev/null
@@ -0,0 +1,186 @@
+#include <HYDROData_Image.h>
+#include <HYDROData_Iterator.h>
+
+#include <TDataStd_RealArray.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_ReferenceList.hxx>
+#include <TDF_ListIteratorOfLabelList.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Object)
+
+HYDROData_Image::HYDROData_Image()
+{
+}
+
+HYDROData_Image::~HYDROData_Image()
+{
+}
+
+void HYDROData_Image::SetImage(const QImage& theImage)
+{
+  if (theImage.isNull()) {
+    // for empty image remove all previously stored attributes
+    myLab.ForgetAttribute(TDataStd_IntegerArray::GetID());
+    myLab.ForgetAttribute(TDataStd_ByteArray::GetID());
+    return;
+  }
+  // store width, height, bytes per line and format in integer array 
+  Handle(TDataStd_IntegerArray) aParams;
+  if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams)) {
+    aParams = TDataStd_IntegerArray::Set(myLab, 1, 4);
+  }
+  aParams->SetValue(1, theImage.width());
+  aParams->SetValue(2, theImage.height());
+  aParams->SetValue(3, theImage.bytesPerLine());
+  aParams->SetValue(4, (int)(theImage.format()));
+  // store data of image in byte array
+  Handle(TDataStd_ByteArray) aData;
+  int aLen = theImage.byteCount();
+  if (!myLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
+    aData = TDataStd_ByteArray::Set(myLab, 1, aLen);
+  }
+  // copy bytes one by one
+  const uchar* aBits = theImage.bits();
+  if (aData->Length() != aLen) {
+    Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, aLen);
+    for(int a = 0; a < aLen; a++)
+      aNewData->SetValue(a + 1, aBits[a]);
+    aData->ChangeArray(aNewData);
+  } else {
+    for(int a = 0; a < aLen; a++)
+      aData->SetValue(a + 1, aBits[a]);
+  }
+
+}
+
+QImage HYDROData_Image::Image()
+{
+  Handle(TDataStd_IntegerArray) aParams;
+  Handle(TDataStd_ByteArray) aData;
+  if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams) ||
+      !myLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
+    return QImage(); // return empty image if there is no array
+  /*
+  // make uchar array one by one
+  int aLen = aData->Upper();
+  uchar* anArray = new uchar[aLen];
+  for(int a = 0; a < aLen; a++)
+    anArray[a] = aData->Value(a + 1);
+  // recreate image from integer parameters and array of bytes
+  QImage aResult(anArray, aParams->Value(1), aParams->Value(2),
+                 aParams->Value(3), QImage::Format(aParams->Value(4)));
+  delete [] anArray; <- this is wrong, because QImage references to this array
+  */
+  uchar* anArray = (uchar*)(void*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
+  QImage aResult(anArray, aParams->Value(1), aParams->Value(2),
+                 aParams->Value(3), QImage::Format(aParams->Value(4)));
+
+  return aResult;
+}
+
+void HYDROData_Image::SetTrsf(const QTransform& theTrsf)
+{
+  // locate 9 coeffs of matrix into the real array
+  Handle(TDataStd_RealArray) anArray;
+  if (!myLab.FindAttribute(TDataStd_RealArray::GetID(), anArray)) {
+    if (theTrsf.isIdentity()) return; // no need to store identity transformation
+    anArray = TDataStd_RealArray::Set(myLab, 1, 9);
+  }
+  anArray->SetValue(1, theTrsf.m11());
+  anArray->SetValue(2, theTrsf.m12());
+  anArray->SetValue(3, theTrsf.m13());
+  anArray->SetValue(4, theTrsf.m21());
+  anArray->SetValue(5, theTrsf.m22());
+  anArray->SetValue(6, theTrsf.m23());
+  anArray->SetValue(7, theTrsf.m31());
+  anArray->SetValue(8, theTrsf.m32());
+  anArray->SetValue(9, theTrsf.m33());
+}
+
+QTransform HYDROData_Image::Trsf()
+{
+  // get 9 coeffs of matrix from the real array
+  Handle(TDataStd_RealArray) anArray;
+  if (!myLab.FindAttribute(TDataStd_RealArray::GetID(), anArray))
+    return QTransform(); // return identity if there is no array
+  QTransform aTrsf(
+    anArray->Value(1), anArray->Value(2), anArray->Value(3), 
+    anArray->Value(4), anArray->Value(5), anArray->Value(6), 
+    anArray->Value(7), anArray->Value(8), anArray->Value(9));
+  return aTrsf;
+}
+
+void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced)
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
+    aRefs = TDataStd_ReferenceList::Set(myLab);
+  aRefs->Append(theReferenced->Label());
+}
+
+int HYDROData_Image::NbReferences()
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
+    return 0;
+  return aRefs->Extent();
+}
+
+Handle(HYDROData_Image) HYDROData_Image::Reference(const int theIndex) const
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
+    return Handle(HYDROData_Image)();
+  if (theIndex < 0 || theIndex >= aRefs->Extent())
+    return Handle(HYDROData_Image)();
+
+  TDF_ListIteratorOfLabelList anIter(aRefs->List());
+  for(int anIndex = 0; anIndex != theIndex; anIter.Next(), anIndex++);
+  const TDF_Label& aRefLab = anIter.Value();
+  return Handle(HYDROData_Image)::DownCast(HYDROData_Iterator::Object(aRefLab));
+}
+
+void HYDROData_Image::ChangeReference(
+    const int theIndex, Handle(HYDROData_Image) theReferenced)
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
+    aRefs = TDataStd_ReferenceList::Set(myLab);
+  if (theIndex >= aRefs->Extent()) { // for too big index append it just to the end
+    AppendReference(theReferenced);
+  } else { // remove and insert new
+    TDF_ListIteratorOfLabelList anIter(aRefs->List());
+    int anIndex = 0;
+    for(; anIndex != theIndex; anIter.Next(), anIndex++);
+    const TDF_Label& aRemovedLab = anIter.Value();
+    anIter.Next();
+    aRefs->Remove(aRemovedLab);
+    if (anIter.More()) 
+      aRefs->InsertBefore(theReferenced->Label(), anIter.Value());
+    else 
+      aRefs->Append(theReferenced->Label());
+  }
+}
+
+void HYDROData_Image::RemoveReference(const int theIndex)
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
+    return; // no references, nothing to remove
+  if (aRefs->Extent() == 1 && theIndex == 0) { // remove all if only one
+    ClearReferences();
+    return;
+  }
+  TDF_ListIteratorOfLabelList anIter(aRefs->List());
+  int anIndex = 0;
+  for(; anIndex != theIndex && anIter.More(); anIter.Next(), anIndex++);
+  if (anIter.More())
+    aRefs->Remove(anIter.Value());
+}
+
+void HYDROData_Image::ClearReferences()
+{
+  myLab.ForgetAttribute(TDataStd_ReferenceList::GetID());
+}
diff --git a/src/HYDROData/HYDROData_Iterator.h b/src/HYDROData/HYDROData_Iterator.h
new file mode 100644 (file)
index 0000000..b24ee4b
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef HYDROData_Iterator_HeaderFile
+#define HYDROData_Iterator_HeaderFile
+
+#include <HYDROData_Object.h>
+#include <HYDROData_Document.h>
+
+#include <TDF_ChildIDIterator.hxx>
+
+/**\class HYDROData_Iterator
+ * \brief Allows to iterate all objects by the document and kind of object.
+ *
+ * Using the document data structures, iterates through objects, filtered by 
+ * kind of this object. This class must have information about all kinds of 
+ * objects of the document: for correct iteration and creation of them.
+ */
+class HYDROData_Iterator
+{
+public:
+  /**
+   * Initializes iterator by objects of the document.
+   * \param theDoc document to iterate
+   * \param theKind kind of the iterated object, can be UNKNOWN: to iterate all objects
+   */
+  HYDRODATA_EXPORT HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind);
+
+  /**
+   * Iterates to the next object
+   */
+  HYDRODATA_EXPORT void Next();
+
+  /**
+   * Returns true if current object exists
+   */
+  HYDRODATA_EXPORT bool More() const;
+
+  /**
+   * Returns the current object of the iterator.
+   */
+  HYDRODATA_EXPORT Handle(HYDROData_Object) Current();
+
+protected:
+
+  friend class HYDROData_Document;
+  friend class HYDROData_Image;
+
+  /**
+   * Creates object in the document, call HYDROData_Document method to create 
+   * objects from other packages.
+   * \param theDoc document where object will be located
+   * \param theKind kind of the new object, can not be UNKNOWN
+   */
+  static Handle_HYDROData_Object CreateObject(
+    Handle_HYDROData_Document theDoc, ObjectKind theKind);
+
+  /**
+   * Returns object associated to the given label.
+   */
+  static Handle_HYDROData_Object Object(const TDF_Label theLabel);
+
+  TDF_ChildIDIterator myIter; ///< iterator by the objects in the document
+};
+
+#endif
diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx
new file mode 100644 (file)
index 0000000..488b03e
--- /dev/null
@@ -0,0 +1,57 @@
+#include <HYDROData_Object.h>
+
+#include <TDataStd_Name.hxx>
+#include <TDF_CopyLabel.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared)
+
+// is equal function for unique object mapping
+bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2)
+{
+  return (theObj1->ID() == theObj2->ID());
+}
+
+QString HYDROData_Object::GetName() const
+{
+  Handle(TDataStd_Name) aName;
+  if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
+    TCollection_AsciiString aStr(aName->Get());
+    return QString(aStr.ToCString());
+  }
+  return QString();
+}
+
+void HYDROData_Object::SetName(const QString& theName)
+{
+  TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
+}
+
+bool HYDROData_Object::IsRemoved() const
+{
+  return !myLab.HasAttribute();
+}
+
+void HYDROData_Object::Remove()
+{
+  return myLab.ForgetAllAttributes(Standard_True);
+}
+
+HYDROData_Object::HYDROData_Object()
+{
+}
+
+HYDROData_Object::~HYDROData_Object()
+{
+}
+
+void HYDROData_Object::CopyTo(Handle_HYDROData_Object theDestination) const
+{
+  TDF_CopyLabel aCopy(myLab, theDestination->Label());
+  aCopy.Perform();
+}
+
+void HYDROData_Object::SetLabel(TDF_Label theLabel)
+{
+  myLab = theLabel;
+}
diff --git a/src/HYDROData/test_HYDROData_Document.h b/src/HYDROData/test_HYDROData_Document.h
new file mode 100644 (file)
index 0000000..8c72fef
--- /dev/null
@@ -0,0 +1,29 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Document : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_Document);
+  CPPUNIT_TEST(testSaveOpen);
+  CPPUNIT_TEST(testOperations);
+  CPPUNIT_TEST(testUndoRedo);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks the save and open document as a file
+  void testSaveOpen();
+
+  // checks the operations management: open/commit/abort, etc
+  void testOperations();
+
+  // checks the operations undo/redo
+  void testUndoRedo();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Document);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Document, "HYDROData_Document");
diff --git a/src/HYDROData/test_HYDROData_Image.h b/src/HYDROData/test_HYDROData_Image.h
new file mode 100644 (file)
index 0000000..96f9726
--- /dev/null
@@ -0,0 +1,33 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Image : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_Image);
+  CPPUNIT_TEST(testQImage);
+  CPPUNIT_TEST(testTrsf);
+  CPPUNIT_TEST(testReferences);
+  CPPUNIT_TEST(testCopy);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks save/restore QImages information
+  void testQImage();
+
+  // checks the transformations
+  void testTrsf();
+
+  // checks the references management
+  void testReferences();
+
+  // checks the image properties copy/paste
+  void testCopy();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Image);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Image, "HYDROData_Image");
diff --git a/src/HYDROData/test_HYDROData_Iterator.cxx b/src/HYDROData/test_HYDROData_Iterator.cxx
new file mode 100644 (file)
index 0000000..cb43a4b
--- /dev/null
@@ -0,0 +1,60 @@
+#include<test_HYDROData_Iterator.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Iterator.h>
+
+void test_HYDROData_Iterator::testOneKind()
+{
+  static const QString aName1("test_name1");
+  static const QString aName2("test_name2");
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Object) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
+  anObj->SetName(aName1);
+  // first HYDROData_Object must be destroyed because there is no hander pointer naymore
+  anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
+  anObj->SetName(aName2);
+
+  HYDROData_Iterator anIter(aDoc, KIND_IMAGE);
+  CPPUNIT_ASSERT(anIter.More());
+  CPPUNIT_ASSERT(!anIter.Current().IsNull());
+  CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
+
+  anIter.Next();
+  CPPUNIT_ASSERT(anIter.More());
+  CPPUNIT_ASSERT(!anIter.Current().IsNull());
+  CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
+
+  anIter.Next();
+  CPPUNIT_ASSERT(!anIter.More());
+
+  aDoc->Close();
+}
+
+void test_HYDROData_Iterator::testAllKinds()
+{
+  static const QString aName1("test_name1");
+  static const QString aName2("test_name2");
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Object) anObj = aDoc->CreateObject(KIND_IMAGE); // image object
+  anObj->SetName(aName1);
+  // first HYDROData_Object must be destroyed because there is no hander pointer naymore
+  anObj = aDoc->CreateObject(KIND_IMAGE); // second image object
+  anObj->SetName(aName2);
+
+  HYDROData_Iterator anIter(aDoc, KIND_UNKNOWN);
+  CPPUNIT_ASSERT(anIter.More());
+  CPPUNIT_ASSERT(!anIter.Current().IsNull());
+  CPPUNIT_ASSERT_EQUAL(aName1.toStdString(), anIter.Current()->GetName().toStdString());
+
+  anIter.Next();
+  CPPUNIT_ASSERT(anIter.More());
+  CPPUNIT_ASSERT(!anIter.Current().IsNull());
+  CPPUNIT_ASSERT_EQUAL(aName2.toStdString(), anIter.Current()->GetName().toStdString());
+
+  anIter.Next();
+  CPPUNIT_ASSERT(!anIter.More());
+
+  aDoc->Close();
+}
diff --git a/src/HYDROData/test_HYDROData_Iterator.h b/src/HYDROData/test_HYDROData_Iterator.h
new file mode 100644 (file)
index 0000000..d7586cc
--- /dev/null
@@ -0,0 +1,25 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Iterator : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_Iterator);
+  CPPUNIT_TEST(testOneKind);
+  CPPUNIT_TEST(testAllKinds);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks iteration by one kind
+  void testOneKind();
+
+  // checks iteration by all kinds
+  void testAllKinds();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Iterator);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Iterator, "HYDROData_Iterator");
diff --git a/src/HYDROData/test_HYDROData_Object.cxx b/src/HYDROData/test_HYDROData_Object.cxx
new file mode 100644 (file)
index 0000000..9035e35
--- /dev/null
@@ -0,0 +1,46 @@
+#include<test_HYDROData_Object.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Object.h>
+
+void test_HYDROData_Object::testName()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Object) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+  static const QString aName("test_name");
+  anObj->SetName(aName);
+  CPPUNIT_ASSERT_EQUAL(aName.toStdString(), anObj->GetName().toStdString());
+  
+  aDoc->Close();
+}
+
+void test_HYDROData_Object::testRemove()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+  
+  Handle(HYDROData_Object) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+  CPPUNIT_ASSERT(!anObj->IsRemoved());
+  anObj->Remove();
+  CPPUNIT_ASSERT(anObj->IsRemoved());
+
+  aDoc->Close();
+}
+
+void test_HYDROData_Object::testCopy()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Object) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+  static const QString aName("test_name");
+  anObj->SetName(aName);
+
+  Handle(HYDROData_Object) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
+  CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
+  anObj->CopyTo(aCopy);
+
+  // check the copied object has same name as original
+  CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
+
+  aDoc->Close();
+}
diff --git a/src/HYDROData/test_HYDROData_Object.h b/src/HYDROData/test_HYDROData_Object.h
new file mode 100644 (file)
index 0000000..12284fa
--- /dev/null
@@ -0,0 +1,29 @@
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Object : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(test_HYDROData_Object);
+  CPPUNIT_TEST(testName);
+  CPPUNIT_TEST(testRemove);
+  CPPUNIT_TEST(testCopy);
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+
+  void setUp() {}
+
+  void tearDown() {}
+
+  // checks the "name" methods
+  void testName();
+
+  // checks the remove of object
+  void testRemove();
+
+  // checks the copying of object
+  void testCopy();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Object);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROData_Object, "HYDROData_Object");