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