]> Creatis software - creaMaracasVisu.git/blob - appli/BasicViewer/main.cxx
*** empty log message ***
[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 #ifdef WIN32
64                         creaMaracasVisuKernel::OpenImageDialog *diag = new creaMaracasVisuKernel::OpenImageDialog(true);
65                          wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
66
67                         if(diag->getImageData() != NULL){
68                                 std::vector<int>* vectype;
69                                 vectype = new std::vector<int>();
70                                 vectype->push_back(5);
71                                 vectype->push_back(0);
72                                 viewer = new wxMaracas_N_ViewersWidget(this,diag->getImageData(), vectype);
73                         sizer->Add(viewer,1,wxGROW);
74                           SetSizer(sizer);
75                         }
76
77 #else 
78                         creaMaracasVisuKernel::OpenImageDialog *diag = new creaMaracasVisuKernel::OpenImageDialog(false);
79                         if(diag->getImageData() != NULL){
80                                 image = diag->getImageData();
81                                 strfilename = diag->getFilename();
82                         }
83 #endif
84 }
85
86 void MyFrame::OnAbout(wxCommandEvent& event)
87 {
88         
89 }
90
91 void MyFrame::OnQuit(wxCommandEvent& event)
92 {
93         Close();
94 }
95
96 MyFrame::MyFrame(const wxString& title):wxFrame(NULL,wxID_ANY,title)
97 {
98
99         
100         // viewer = bbcreaMaracasVisu::bbmaracasVisuViewerNV::New("Viewer");
101         //mSlider = bbwx::Slider::New("slider");
102         //mSlider->bbUserCreateWidget(this);
103
104
105         //sizer->Add(mSlider->bbGetOutputWidget(),1,wxGROW);
106
107
108
109         wxMenu *fileMenu = new wxMenu;
110
111         wxMenu *helpMenu = new wxMenu;
112
113         helpMenu->Append(wxID_ABOUT,wxT("&About...\tF1"),wxT("Show about dialog"));
114
115         fileMenu->Append(wxID_OPEN,wxT("&O&pen\tAlt-O"),wxT("Open Files"));
116         fileMenu->Append(wxID_EXIT,wxT("&E&xit\tAlt-X"),wxT("Quit"));
117
118
119         wxMenuBar *menuBar = new wxMenuBar();
120         menuBar->Append(fileMenu,wxT("&File"));
121         menuBar->Append(helpMenu,wxT("&Help"));
122
123         SetMenuBar(menuBar);
124
125          // SetAutoLayout(true);
126         /*CreateStatusBar(2);
127         SetStatusText(wxT("CREATIS"));*/
128 }
129