I'm new to MITK and I would like to:

Display a text string (vtkCornerAnnotation) overlapping an Image, using
QmitkStdMultiWidget render Window

Problems I encounter:
1)The text appears in corner 1, but immediately disappears
2)A white box appears, covering the whole window1, covering the image, which
is not displayed
3)If I resize the window, the white box disappears, and the image is
rendered
4)As I use a QmitkStdMultiWidget, If I change the window where I like to
display the text (let's say to window2),  the text appears and the white box
doesn't appears, and then the text immediately disappears


In order to do display the text, I create a vtkCornerAnnotation, a vtk
renderer, add the vtkActor2D (vtkCornerAnnotation inherits from vtkActor2D)
to the renderer and display it in window1.

When I run the application, the text is displayed for about 0.5 seconds,
then it disappears. Another strange behaviour is that a white box appears,
covering the whole window1. Then, if I resize the main window, the box also
disappears, and the image is display. That means that the image and the text
(in my case the white box!) are never displayed together, maybe because the
white box is as big as the whole window. I also tried to set the text as
foreground, but the behaviour is the same.

I also tried not to load an image, and the text is correctly display in any
window (window1 as well as window2), without the white box! It seems like
the text remains in the background (?). I tied to change it to the
foreground but I also achieved negative results

Here is the most relevant part of my code:

//basic mitk initialization and image loading
mitk::DataTree::Pointer tree=mitk::DataTree::New();
mitk::DataTreePreOrderIterator it(tree);

mitk::DataTreeNodeFactory::Pointer nodeReader;
nodeReader = mitk::DataTreeNodeFactory::New();
nodeReader->SetFileName( filename ); //filename is an Image
nodeReader->Update();

mitk::DataTreeNode::Pointer node;
node = nodeReader->GetOutput();
it.Add(node);



QHBox toplevelWidget;
toplevelWidget.setSpacing(1);

QmitkStdMultiWidget renderWindow(&toplevelWidget);
renderWindow.SetData(&it); //if I comment this line, the text is correctly
displayed,
renderWindow.InitializeStandardViews(&it);
renderWindow.Fit();
renderWindow.EnableNavigationControllerEventListening();


//create a cornerText Actor
vtkCornerAnnotation *cornerText = vtkCornerAnnotation::New();
cornerText->SetText(1,"Hello");


vtkRenderer *ren = vtkRenderer::New();

// Add the actors
ren->AddActor(cornerText);
//ren->SetErase(0);  //I tried both with and without this line but didn't
work

renderWindow.GetRenderWindow1()->GetVtkLayerController()->InsertBackgroundRenderer(ren,
true);

//renderWindow.GetRenderWindow1()->GetVtkRenderWindow()->SetErase(0); //I
tried both with and without this line but didn't work

dynamic_cast<mitk::OpenGLRenderer*>(renderWindow.GetRenderWindow1
()->GetRenderer())->UpdateIncludingVtkActors();

//renderWindow.GetRenderWindow1()->RequestUpdate(); //I tried both with and
without this line but nothing changed

mitk::RenderingManager::GetInstance()->RequestUpdateAll();

qtapplication.setMainWidget(&toplevelWidget);
toplevelWidget.show();

qtapplication.exec();



Any help is deeply appreciated.

Thanks in advance,

-- 
Martín
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to