[Insight-users] fltk viewer
Samuel Rodríguez Bescos
srodrigu@gbt.tfo.upm.es
Wed, 18 Sep 2002 13:17:11 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0010_01C25F15.B29D4B40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I think the problem is realted with the fltk. You want the program =
finish when you close the Viewer window. Don't you?.
For that, I think you have to write the next code line:
........previous code.......
m_AnyViewer->Show();
Fl::run(); ***This line makes that the program doesn't continue until =
all the windows of your program are closed.****
(.....) more code.....
I hope this help you,
Samuel
----- Original Message -----=20
From: Zein Salah=20
To: ITK Users=20
Sent: Wednesday, September 18, 2002 12:34 PM
Subject: [Insight-users] fltk viewer
Hello friends,
I have written a very simple program that just reads a meta file and =
displays it using the fltkimage viewer.
the program reads the file correctly, displays it. BUT I can not see =
the displayed files because the fltk viewer panel ends execution very =
fast, it just flashes once and then disappears.
Do anybody have an idea, where the problem is.=20
Here is my program:
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
#include <iostream>
#include <itkImage.h>
#include <itkImageFileReader.h>
#include <fltkImageViewer.h>
#include <FL/Fl.H>
#include <FL/fl_file_chooser.H>
///////////////////////////////////////////////////////////
void LoadShowImage(char *filename)
{
typedef fltk::ImageViewer< float, unsigned char > =
ImageViewerType;
typedef float =
PixelType;
typedef itk::Image<PixelType, 3> =
ImageType;=20
typedef itk::ImageFileReader< ImageType > =
VolumeReaderType;
std::cout << "Loading File: " << filename << std::endl;
VolumeReaderType::Pointer m_Reader =3D VolumeReaderType::New();
m_Reader->SetFileName( filename );
m_Reader->Update();
ImageViewerType *m_AnyViewer=3D new ImageViewerType;
m_AnyViewer->SetImage( m_Reader->GetOutput() );
m_AnyViewer->Show();
std::cout << "Image [ " << filename << " ] Showed ..." << =
std::endl;
}
////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
char *fName;
=20
if(argc =3D=3D 1)
{
fName =3D fl_file_chooser("Pick a MetaImage file", "*.mh*", =
".");
if(fName =3D=3D NULL || strlen(fName)<1)
{
return 0;
}
} else if(argv[1][0] !=3D '-') {
fName =3D argv[argc-1];
}=20
LoadShowImage(fName);
=20
return 1;
}
=
->8<------------->8<------------->8<------------->8<------------->8<-----=
-------->8<-
Zein I. Salah=20
Universit=E4t T=FCbingen, WSI-GRIS=20
Sand 14=20
72076 T=FCbingen=20
Email: salah@gris.uni-tuebingen.de / zeinsalah@hotmail.com
Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)=20
------=_NextPart_000_0010_01C25F15.B29D4B40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2715.400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I think the problem is realted with the =
fltk. You=20
want the program finish when you close the Viewer window. Don't=20
you?.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For that, I think you have to =
write the next=20
code line:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>........previous =
code.......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000 =
size=3D2>m_AnyViewer->Show();</FONT></DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Fl::run(); ***<FONT =
face=3DArial=20
size=3D2>This line makes that the program doesn't continue until all the =
windows=20
of your program are closed.****</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>(.....) more code.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> I hope this help =
you,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Samuel</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A title=3Dsalah@gris.uni-tuebingen.de=20
href=3D"mailto:salah@gris.uni-tuebingen.de">Zein Salah</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20
title=3Dinsight-users@public.kitware.com=20
href=3D"mailto:insight-users@public.kitware.com">ITK Users</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, September 18, =
2002 12:34=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Insight-users] fltk=20
viewer</DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DArial size=3D2>Hello friends,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have written a very simple =
program that=20
just reads a meta file and displays it using the fltkimage=20
viewer.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>the program reads the file correctly, =
displays=20
it. BUT I can not see the displayed files because the fltk viewer =
panel ends=20
execution very fast, it just flashes once and then =
disappears.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Do anybody have an idea, where the =
problem is.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is my program:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000=20
=
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D*/<BR>#include=20
<iostream></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include=20
<itkImage.h><BR>#include =
<itkImageFileReader.h><BR>#include=20
<fltkImageViewer.h></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#ff0000 size=3D2>#include=20
<FL/Fl.H><BR>#include <FL/fl_file_chooser.H></FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV><FONT face=3DArial =
size=3D2>
<DIV><BR><FONT=20
=
color=3D#ff0000>/////////////////////////////////////////////////////////=
//<BR>void=20
LoadShowImage(char *filename)<BR>{</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> typedef fltk::ImageViewer< float, =
unsigned=20
char > ImageViewerType;<BR> =
typedef=20
=
float &n=
bsp; &nb=
sp; &nbs=
p; =20
=
&=
nbsp; =20
PixelType;<BR> typedef itk::Image<PixelType,=20
=
3> &n=
bsp; &nb=
sp; =20
ImageType; <BR> typedef itk::ImageFileReader< =
ImageType=20
=
> &nb=
sp; =20
VolumeReaderType;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> std::cout << "Loading =
File: "=20
<< filename << std::endl;<BR> =20
VolumeReaderType::Pointer m_Reader =3D=20
VolumeReaderType::New();<BR> m_Reader->SetFileName( =
filename=20
);<BR> m_Reader->Update();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> ImageViewerType =
*m_AnyViewer=3D new=20
ImageViewerType;<BR> m_AnyViewer->SetImage(=20
m_Reader->GetOutput() );<BR> =20
m_AnyViewer->Show();</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> std::cout << "Image [ " =
<<=20
filename << " ] Showed ..." << std::endl;</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000>}</FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT=20
=
color=3D#ff0000>/////////////////////////////////////////////////////////=
///<BR>int=20
main(int argc, char **argv)<BR>{<BR> char=20
*fName;<BR> <BR> if(argc =3D=3D 1)<BR> =20
{<BR> fName =3D fl_file_chooser("Pick a =
MetaImage=20
file", "*.mh*", ".");<BR> if(fName =
=3D=3D NULL ||=20
strlen(fName)<1)<BR> =20
{<BR> return=20
0;<BR> }<BR> } else =
if(argv[1][0] !=3D=20
'-') {<BR> fName =3D =
argv[argc-1];<BR> =20
} </FONT></DIV>
<DIV><FONT color=3D#ff0000></FONT> </DIV>
<DIV><FONT color=3D#ff0000> =
LoadShowImage(fName);<BR> =20
<BR> return 1;<BR>}<BR></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>->8<------------->8<------------->8<----------=
--->8<------------->8<------------->8<-<BR>Zein=20
I. Salah <BR>Universit=E4t T=FCbingen, WSI-GRIS <BR>Sand 14 <BR>72076 =
T=FCbingen=20
<BR>Email: <A=20
=
href=3D"mailto:salah@gris.uni-tuebingen.de">salah@gris.uni-tuebingen.de</=
A> =20
/ <A =
href=3D"mailto:zeinsalah@hotmail.com">zeinsalah@hotmail.com</A><BR>Tel.: =
(07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)=20
</FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0010_01C25F15.B29D4B40--