Example #1
0
TEST_F(CoordinateTransformableDataObject_test, PersistentCoordsSpec_ImageData)
{
    auto imageDataSet = vtkSmartPointer<vtkImageData>::New();
    imageDataSet->SetExtent(0, 1, 2, 4, 0, 0);
    imageDataSet->AllocateScalars(VTK_FLOAT, 1);
    
    ImageDataObject dataObject("image", *imageDataSet);

    const auto coordsSpec = ReferencedCoordinateSystemSpecification(
        CoordinateSystemType::geographic,
        "testGeoSystem",
        "testMetricSystem",
        "",
        { 100, 200 }, { 0.2, 0.3 });

    dataObject.specifyCoordinateSystem(coordsSpec);

    const auto fileName = QDir(TestEnvironment::testDirPath()).filePath("PersistentCoordsSpec.vti");

    ASSERT_TRUE(Exporter::exportData(dataObject, fileName));
    auto readDataObject = Loader::readFile<CoordinateTransformableDataObject>(fileName);
    ASSERT_TRUE(readDataObject);

    ASSERT_EQ(coordsSpec, readDataObject->coordinateSystem());
}
Example #2
0
TEST_F(DataMapping_test, ViewAndPlotViewCleanedUp)
{
    auto img = vtkSmartPointer<vtkImageData>::New();
    img->SetDimensions(4, 6, 1);
    img->AllocateScalars(VTK_FLOAT, 1);
    auto imageObject = std::make_unique<ImageDataObject>("TestImage", *img);
    auto imgPointer = imageObject.get();
    env->dataSetHander.takeData(std::move(imageObject));

    QPointer<AbstractRenderView> view, plotView;

    {
        QMainWindow mainWindow;

        view = env->mapping.openInRenderView({ imgPointer });
        ASSERT_TRUE(view);
        mainWindow.addDockWidget(Qt::LeftDockWidgetArea, view->dockWidgetParent());

        auto impl3D = dynamic_cast<RendererImplementation3D *>(&view->implementation());
        ASSERT_TRUE(impl3D);
        auto impl3Dtest = static_cast<TestRendererImplementation3D *>(impl3D); // hacked...
        auto strategy = dynamic_cast<RenderViewStrategy2D *>(impl3Dtest->strategyIfEnabled());
        ASSERT_TRUE(strategy);
        strategy->startProfilePlot();

        ASSERT_EQ(2, env->mapping.renderViews().size());
        auto first = env->mapping.renderViews()[0];
        auto second = env->mapping.renderViews()[1];
        plotView = view == first ? second : first;

        mainWindow.addDockWidget(Qt::LeftDockWidgetArea, plotView->dockWidgetParent());

        qApp->processEvents();

        env.reset();
    }
    ASSERT_FALSE(view);
    ASSERT_FALSE(plotView);
}