Hi Sina,

please see the tutorials on how to open a render window and my mail from the 
13.10.2015 (23:05) for a code snippet that demonstrates how to display an 
mitk::Image in a Qt widget.

Best,
Stefan

From: Sina Gerlach [mailto:sina.gerlac...@gmx.de]
Sent: Montag, 9. November 2015 15:47
To: mitk-users@lists.sourceforge.net
Subject: [mitk-users] Qmitk Renderwindow

Hello,
I'm trying to open a Renderwindow and display a Dicom image using QFileDialog, 
which doesn't work.
Theres also another Part where I try displaying a dicom image in a 
QGraphcsview/QLabel.
Heres my Code for clarification:

void MainWindow::on_openButton_pressed()
{
    QString imagePath = QFileDialog::getOpenFileName(
        this, tr("Open File"),
        "",
        tr("DICOM(*.dcm);;JPEG(*.jpg)")
        );
    imageObject = new QImage();
    imageObject->load(imagePath)
        image = QPixmap::fromImage(*imageObject);

        //..using GraphicsView
        // This only works with JPG not Dicom! (mit Slider/unverzerrt)
        scene = new QGraphicsScene(this);
        scene->addPixmap(image);
        scene->setSceneRect(image.rect());
        ui->ViewCoronal->setScene(scene);

//..using QLabel
    // This only works with JPG not Dicom! (verzerrt)
    if (image.load(imagePath))
    {
        QPainter painter(&image);
        painter.setPen(Qt::red);
        QRectF rect(100, 100, 100, 100);
        painter.drawRect(rect);
        QSize bigsize = ui->label->size();
        ui->label->setPixmap(image.scaled(bigsize, Qt::IgnoreAspectRatio, 
Qt::FastTransformation));
        ui->label->show();

    //MITK approach
    // Register Qmitk-dependent global instances
    QmitkRegisterClasses();
    //Create a DataStorage
    mitk::StandaloneDataStorage::Pointer ds = 
mitk::StandaloneDataStorage::New();

    //Load datanode (eg. many image formats, surface formats, etc.)
    std::string current_locale_text = imagePath.toLocal8Bit().constData();
    mitk::IOUtil::Load(current_locale_text, *ds);

    // Tell the RenderWindow which (part of) the datastorage to render
    QmitkRenderWindow renderWindow;
    renderWindow.GetRenderer()->SetDataStorage(ds);

    // Initialize the RenderWindow
    mitk::TimeGeometry::Pointer geo = 
ds->ComputeBoundingGeometry3D(ds->GetAll());
    mitk::RenderingManager::GetInstance()->InitializeViews(geo);
    //mitk::RenderingManager::GetInstance()->InitializeViews();

    // Select a slice
    mitk::SliceNavigationController::Pointer sliceNaviController = 
renderWindow.GetSliceNavigationController();
    if (sliceNaviController)
        sliceNaviController->GetSlice()->SetPos(0);
    renderWindow.show();
    renderWindow.resize(256, 256);
}
Is there a way to initialize the Renderwindow that it works (I think it doesn't 
work because its not in main())?
Regarding the QGraphicsview/QLabel: I've seen here that its possible: 
http://stackoverflow.com/questions/18488050/interactively-editing-an-existing-rectangle-on-a-qpixmap?lq=1
Do I need a Plugin or anything else to make this work?

Thank you!
Best Regards
Sina

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to