Martín,
 
which version of MITK are you using?
 
For current SVN  (MITK > 0.8) the mitk::vtkPropRenderer allows for simple text 
displaying (see 
http://www.mitk.org/documentation/doxygen/classmitk_1_1VtkPropRenderer.html).
A similar function is also included in the mitk::openGLRenderer for MITK <= 0.8 
(see 
http://www.mitk.org/documentation/mitk-0.8/classmitk_1_1OpenGLRenderer.html).
 
Having a quick look at your code is suggest that the 
InsertBackgroundRenderer(ren, true); call results in rendering the text behind 
all other MITK related stuff (in particular, rendering all datatree nodes). 
Since your text shall be displayed in front of the DataTreeNodes, I suppose you 
should call InsertForegroundRenderer() of the mitkVtkLayerController in order 
to add your new vtkRenderer to the vtkRenderWindow of the widget.
 
SetErase(0) will be necessary in order to avoid the new vtkRenderer from 
clearing the OpenGL scene.
 
Regards
 
Matthias Baumhauer                      Phone:  (+49) 6221/42-2328
Deutsches Krebsforschungszentrum        Fax:    (+49) 6221/42-2345
Div. Medical and Biological Informatics (E130)
Im Neuenheimer Feld 280                 email:  [EMAIL PROTECTED]
D-69120 Heidelberg, Germany             http://www.dkfz-heidelberg.de/de/mbi 
<http://www.dkfz-heidelberg.de/de/mbi> 
  
 
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Martín Bianculli
Gesendet: Montag, 25. Februar 2008 12:39
An: [email protected]
Betreff: [mitk-users] Text Display
 
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