]> Creatis software - creaMaracasVisu.git/blob - appli/ManualPaint/ManualPaint.cxx
77c3b16f705df67271a765253a707cc8bd497be2
[creaMaracasVisu.git] / appli / ManualPaint / ManualPaint.cxx
1 /*=========================================================================
2
3 Program:   ManualPaint
4 Module:    creaMaracasVisu
5 Language:  C++
6
7 =========================================================================*/
8
9 #include <vtkMetaImageReader.h>
10 #include "ManualPaintModel.h"
11 #include "wxManualPaintPanel.h"
12
13 #include "wx/wx.h"
14
15 class MyApp;
16 class MyFrame;
17
18 // Define a new application type, each program should derive a class from wxApp
19 class MyApp : public wxApp
20 {
21 public:
22     // this one is called on application startup and is a good place for the app
23     // initialization (doing it here and not in the ctor allows to have an error
24     // return: if OnInit() returns false, the application terminates)
25     virtual bool OnInit();
26 };
27
28 // Define a new frame type: this is going to be our main frame
29 class MyFrame : public wxFrame
30 {
31 public:
32     // ctor(s)
33     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
34     ~MyFrame();
35
36     // event handlers (these functions should _not_ be virtual)
37     void OnQuit(wxCommandEvent& event);
38
39 private:
40
41 //      wxRenderWindow *MyRenderWindow;
42
43
44 private:
45     // any class wishing to process wxWindows events must use this macro
46     DECLARE_EVENT_TABLE()
47 };
48
49 // IDs for the controls and the menu commands
50 enum
51 {
52     // menu items
53     Minimal_Quit = 1,
54     Minimal_About
55 };
56
57 #define MY_FRAME      101
58 #define MY_VTK_WINDOW 102
59
60 // the event tables connect the wxWindows events with the functions (event
61 // handlers) which process them. It can be also done at run-time, but for the
62 // simple menu events like this the static method is much simpler.
63 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
64     EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
65 END_EVENT_TABLE()
66
67 // Create a new application object: this macro will allow wxWindows to create
68 // the application object during program execution (it's better than using a
69 // static object for many reasons) and also declares the accessor function
70 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
71 // not wxApp)
72 IMPLEMENT_APP(MyApp)
73
74 // 'Main program' equivalent: the program execution "starts" here
75 bool MyApp::OnInit()
76 {
77     // create the main application window
78     MyFrame *frame = new MyFrame(_T("wxWindows-VTK App"),
79                                  wxPoint(50, 50), wxSize(450, 340));
80
81     // and show it (the frames, unlike simple controls, are not shown when
82     // created initially)
83     frame->Show(TRUE);
84     
85
86         
87     // success: wxApp::OnRun() will be called which will enter the main message
88     // loop and the application will run. If we returned FALSE here, the
89     // application would exit immediately.
90     return TRUE;
91 }
92
93 // frame constructor
94 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
95        : wxFrame((wxFrame *)NULL, -1, title, pos, size)
96 {
97
98         vtkMetaImageReader *Reader=vtkMetaImageReader::New();
99 //      Reader->SetFileName(argv[1]);
100         Reader->SetFileName("/home/valette/sphere.mhd");
101         Reader->Update();
102         
103
104         ManualPaintModel *mpModel = new ManualPaintModel;
105         mpModel->SetImage(Reader->GetOutput());
106
107         wxManualPaintPanel *mpPanel = new wxManualPaintPanel(this);
108         mpPanel->SetManualPaintModel(mpModel);
109 /*
110         MyRenderWindow=wxRenderWindow::New(this, MY_VTK_WINDOW);
111
112   vtkConeSource     *pConeSource;
113   pConeSource   = vtkConeSource::New();
114   pConeSource->SetResolution(800);
115
116         MyRenderWindow->SetInput(pConeSource->GetOutput());
117         pConeSource->Delete();
118                 RenderWindowWidgets *RWidgets= new RenderWindowWidgets(this, 1000,wxPanelNameStr,
119         wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE);
120         RWidgets->Show(TRUE);*/
121
122 }
123
124 MyFrame::~MyFrame()
125 {
126 }
127
128 // event handlers
129
130 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
131 {
132     // TRUE is to force the frame to close
133     Close(TRUE);
134 }
135 /*
136 int main( int argc, char *argv[] )
137 {
138
139         vtkMetaImageReader *Reader=vtkMetaImageReader::New();
140         Reader->SetFileName(argv[1]);
141         Reader->Update();
142         
143
144         ManualPaintModel *mpModel = new ManualPaintModel;
145         mpModel->SetImage(Reader->GetOutput());
146
147         wxManualPaintPanel *mpPanel = new wxManualPaintPanel;
148         mpPanel->SetManualPaintModel(mpModel);
149
150
151         return (0);
152 }
153 */