1 #include <test_HYDROOperations_Factory.h>
3 #include <HYDROData_Document.h>
4 #include <HYDROData_Image.h>
5 #include <HYDROOperations_Factory.h>
8 #include <ImageComposer_CropOperator.h>
10 void test_HYDROOperations_Factory::testCreate()
12 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
14 HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
15 CPPUNIT_ASSERT(aFactory);
16 Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
17 CPPUNIT_ASSERT(!anImage.IsNull());
18 CPPUNIT_ASSERT(anImage->Image().isNull());
23 static QImage TestImage() {
24 QImage aPic(50, 40, QImage::Format_RGB32);
26 QPainter aPainter(&aPic);
27 aPainter.drawEllipse(6, 7, 38, 30);
28 aPainter.drawLine(0, 40, 10, 0);
29 aPainter.drawLine(10, 0, 25, 35);
30 aPainter.drawLine(25, 35, 40, 0);
31 aPainter.drawLine(40, 0, 50, 40);
35 void test_HYDROOperations_Factory::testCrop()
37 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
38 HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
39 Handle(HYDROData_Image) anImage = aFactory->CreateImage(aDoc, NULL);
40 // prepare the original image and crop-path
41 QImage aPic = TestImage();
42 anImage->SetImage(aPic);
43 QPainterPath aPath(QPointF(25, 0));
48 // prepare Composer Operation
49 ImageComposer_CropOperator aCropOp;
50 aCropOp.setArgs(Qt::red, aPath);
51 // create crop - image
52 Handle(HYDROData_Image) aCrop = aFactory->CreateImage(aDoc, &aCropOp);
53 CPPUNIT_ASSERT(!aCrop.IsNull());
54 aCrop->AppendReference(anImage);
55 aFactory->UpdateImage(aDoc, aCrop);
56 // check crop operation was performed
57 CPPUNIT_ASSERT(!aCrop->Image().isNull());
58 CPPUNIT_ASSERT(aCrop->Image() != aPic);