]> Creatis software - creaMaracasVisu.git/blob - appli/ManualPaint/ManualPaint.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / appli / ManualPaint / ManualPaint.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la Sant�)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and
11 #  abiding by the rules of distribution of free software. You can  use,
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 #  license as circulated by CEA, CNRS and INRIA at the following URL
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability.
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
26
27 /*=========================================================================
28
29 Program:   ManualPaint
30 Module:    creaMaracasVisu
31 Language:  C++
32
33 =========================================================================*/
34
35 #include <vtkMetaImageReader.h>
36 #include "ManualPaintModel.h"
37 #include "wxManualPaintPanel.h"
38
39 #include "wx/wx.h"
40
41 class MyApp;
42 class MyFrame;
43
44 // Define a new application type, each program should derive a class from wxApp
45 class MyApp : public wxApp
46 {
47 public:
48     // this one is called on application startup and is a good place for the app
49     // initialization (doing it here and not in the ctor allows to have an error
50     // return: if OnInit() returns false, the application terminates)
51     virtual bool OnInit();
52 };
53
54 // Define a new frame type: this is going to be our main frame
55 class MyFrame : public wxFrame
56 {
57 public:
58     // ctor(s)
59     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
60     ~MyFrame();
61
62     // event handlers (these functions should _not_ be virtual)
63     void OnQuit(wxCommandEvent& event);
64
65 private:
66
67 //      wxRenderWindow *MyRenderWindow;
68
69
70 private:
71     // any class wishing to process wxWindows events must use this macro
72     DECLARE_EVENT_TABLE()
73 };
74
75 // IDs for the controls and the menu commands
76 enum
77 {
78     // menu items
79     Minimal_Quit = 1,
80     Minimal_About
81 };
82
83 #define MY_FRAME      101
84 #define MY_VTK_WINDOW 102
85
86 // the event tables connect the wxWindows events with the functions (event
87 // handlers) which process them. It can be also done at run-time, but for the
88 // simple menu events like this the static method is much simpler.
89 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
90     EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
91 END_EVENT_TABLE()
92
93 // Create a new application object: this macro will allow wxWindows to create
94 // the application object during program execution (it's better than using a
95 // static object for many reasons) and also declares the accessor function
96 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
97 // not wxApp)
98 IMPLEMENT_APP(MyApp)
99
100 // 'Main program' equivalent: the program execution "starts" here
101 bool MyApp::OnInit()
102 {
103     // create the main application window
104     MyFrame *frame = new MyFrame(_T("wxWindows-VTK App"),
105                                  wxPoint(50, 50), wxSize(450, 340));
106
107     // and show it (the frames, unlike simple controls, are not shown when
108     // created initially)
109     frame->Show(TRUE);
110     
111
112         
113     // success: wxApp::OnRun() will be called which will enter the main message
114     // loop and the application will run. If we returned FALSE here, the
115     // application would exit immediately.
116     return TRUE;
117 }
118
119 // frame constructor
120 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
121        : wxFrame((wxFrame *)NULL, -1, title, pos, size)
122 {
123
124         vtkMetaImageReader *Reader=vtkMetaImageReader::New();
125 //      Reader->SetFileName(argv[1]);
126         Reader->SetFileName("/home/valette/sphere.mhd");
127         Reader->Update();
128         
129
130         ManualPaintModel *mpModel = new ManualPaintModel;
131         mpModel->SetImage(Reader->GetOutput());
132
133         wxManualPaintPanel *mpPanel = new wxManualPaintPanel(this);
134         mpPanel->SetManualPaintModel(mpModel);
135 /*
136         MyRenderWindow=wxRenderWindow::New(this, MY_VTK_WINDOW);
137
138   vtkConeSource     *pConeSource;
139   pConeSource   = vtkConeSource::New();
140   pConeSource->SetResolution(800);
141
142         MyRenderWindow->SetInput(pConeSource->GetOutput());
143         pConeSource->Delete();
144                 RenderWindowWidgets *RWidgets= new RenderWindowWidgets(this, 1000,wxPanelNameStr,
145         wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE);
146         RWidgets->Show(TRUE);*/
147
148 }
149
150 MyFrame::~MyFrame()
151 {
152 }
153
154 // event handlers
155
156 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
157 {
158     // TRUE is to force the frame to close
159     Close(TRUE);
160 }
161 /*
162 int main( int argc, char *argv[] )
163 {
164
165         vtkMetaImageReader *Reader=vtkMetaImageReader::New();
166         Reader->SetFileName(argv[1]);
167         Reader->Update();
168         
169
170         ManualPaintModel *mpModel = new ManualPaintModel;
171         mpModel->SetImage(Reader->GetOutput());
172
173         wxManualPaintPanel *mpPanel = new wxManualPaintPanel;
174         mpPanel->SetManualPaintModel(mpModel);
175
176
177         return (0);
178 }
179 */