]> Creatis software - creaMaracasVisu.git/blob - appli/BasicViewer/main.cxx
462a57ed311ee9991906535b5e76409dd7682027
[creaMaracasVisu.git] / appli / BasicViewer / main.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 #include "wx/wx.h"
28 #include "wxMaracas_N_ViewersWidget.h"
29 #include "OpenImageDialog.h"
30 #include "vtkImageData.h"
31
32
33 class MyApp:public wxApp
34 {
35 public:
36         virtual bool OnInit();
37 };
38
39 class MyFrame:public wxFrame
40 {
41 public:
42
43         MyFrame(const wxString& title);
44
45         void OnQuit(wxCommandEvent& event);
46         void OnOpen(wxCommandEvent& event);
47         void OnAbout(wxCommandEvent& event);
48         //void SimpleSliderDialog();
49
50 private:
51
52         //bbwx::Slider::Pointer mSlider;
53 //      bbcreaMaracasVisu::bbmaracasVisuViewerNV::Pointer viewer;
54         vtkImageData* image;
55         wxWindow* viewer;
56         DECLARE_EVENT_TABLE()
57
58 };
59
60 DECLARE_APP(MyApp)
61
62 IMPLEMENT_APP(MyApp)
63
64 bool MyApp::OnInit()
65 {
66         MyFrame *frame = new MyFrame(wxT("CREATIS basic"));
67
68         const int width = 600;
69         const int height = 250;
70
71         frame->SetSize(width,height);
72         
73         frame->Show(true);
74
75         return true;
76 }
77
78 BEGIN_EVENT_TABLE(MyFrame,wxFrame)
79         EVT_MENU(wxID_ABOUT,MyFrame::OnAbout)
80         EVT_MENU(wxID_OPEN,MyFrame::OnOpen)
81         EVT_MENU(wxID_EXIT,MyFrame::OnQuit)
82 END_EVENT_TABLE()
83
84
85 void MyFrame::OnOpen(wxCommandEvent& event)
86 {
87         //wxMessageBox(wxT("You clicked the open option"));
88
89                         creaMaracasVisuKernel::OpenImageDialog *diag = new creaMaracasVisuKernel::OpenImageDialog(true);
90                          wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
91
92                         if(diag->getImageData() != NULL){
93                                 std::vector<int>* vectype;
94                                 vectype = new std::vector<int>();
95                                 vectype->push_back(5);
96                                 vectype->push_back(0);
97                                 viewer = new wxMaracas_N_ViewersWidget(this,diag->getImageData(), vectype);
98                         sizer->Add(viewer,1,wxGROW);
99                           SetSizer(sizer);
100                         }
101 }
102
103 void MyFrame::OnAbout(wxCommandEvent& event)
104 {
105         
106 }
107
108 void MyFrame::OnQuit(wxCommandEvent& event)
109 {
110         Close();
111 }
112
113 MyFrame::MyFrame(const wxString& title):wxFrame(NULL,wxID_ANY,title)
114 {
115
116         
117         // viewer = bbcreaMaracasVisu::bbmaracasVisuViewerNV::New("Viewer");
118         //mSlider = bbwx::Slider::New("slider");
119         //mSlider->bbUserCreateWidget(this);
120
121
122         //sizer->Add(mSlider->bbGetOutputWidget(),1,wxGROW);
123
124
125
126         wxMenu *fileMenu = new wxMenu;
127
128         wxMenu *helpMenu = new wxMenu;
129
130         helpMenu->Append(wxID_ABOUT,wxT("&About...\tF1"),wxT("Show about dialog"));
131
132         fileMenu->Append(wxID_OPEN,wxT("&O&pen\tAlt-O"),wxT("Open Files"));
133         fileMenu->Append(wxID_EXIT,wxT("&E&xit\tAlt-X"),wxT("Quit"));
134
135
136         wxMenuBar *menuBar = new wxMenuBar();
137         menuBar->Append(fileMenu,wxT("&File"));
138         menuBar->Append(helpMenu,wxT("&Help"));
139
140         SetMenuBar(menuBar);
141
142          // SetAutoLayout(true);
143         /*CreateStatusBar(2);
144         SetStatusText(wxT("CREATIS"));*/
145 }
146