Viewers - Quick start


When using a Graphical User Interface (GUI), any GUI, the application main function is reduced to an event processing infinite loop: events are generated by user interaction on graphic widgets, and dispatched to the proper event handler.

wxWindows

Under wxWindows, an event loop is provided and the user even do not write a main function. Instead, he should inherit a class from the wxApp base class and redefine the OnInit() virtual method that gets called upon application initialization. The macro IMPLEMENT_APP is provided that contains the generic main method. The minimal wxWindows application is thus:

#include <wx/wx.h>

class MyApplication : public wxApp {
public:
  virtual bool OnInit();
};

bool MyApplication::OnInit() {
  ...
  return TRUE;
}

IMPLEMENT_APP(MyApplication);
You then need to compile with wxWindows libraries using for instance:
g++ -Wall -D_LINUX_ `wx-config --cflags` -Icrea/libs Application.cxx -c
g++ Application.o -o Application -Wl,-rpath,${HOME}/crea/lib -L${HOME}/crea/lib -lcreaViewer -lcreaImage -lcreaCore `wx-config --libs`

Visualization

For visualization of images, two classes are provided. ImageViewer is designed to display an 2D, 3D or 4D image, while VideoViewer is dedicated to 2D+T time series. The constructor only needs a BaseImage object. Thus the following application displays an image:
bool MyApplication::OnInit() {
  BaseImage *img = new BaseImage("image.jpg");
  (void) new ImageViewer(*img);
  return TRUE;
}
and the following one a video:
bool MyApplication::OnInit() {
  BaseImage *img = new BaseImage("serie.mpeg");
  (void) new VideoViewer(*img);
  return TRUE;
}
In fact, the constructor of ImageViewer accepts two additionnal parameters that are the dimensions of the visualized slice in case of 3D or 4D visualization. Given a 3D image for instance, you can decide to display the YZ plane as follow:
bool MyApplication::OnInit() {
  BaseImage *img = new BaseImage("image.inr", Plane::Y, Plane::Z);
  (void) new ImageViewer(*img);
  return TRUE;
}

Classes documentation