]> Creatis software - creaContours.git/blob - appli/wxContourGUIExample/wxContourGUIExample.cxx
4c26c642884fd832f49c57bef62093f14bb5be4e
[creaContours.git] / appli / wxContourGUIExample / wxContourGUIExample.cxx
1 //----------------------------------------------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------------------------------------------
4
5 #include "wxContourGUIExample.h"
6 #include "wxContourMainFrame.h"
7 //#include "OutlineModelManager.h"
8 //#include "wxContourEventHandler.h"
9
10 //#include <creaImageIOWxGimmickDialog.h>
11 //#include <creaImageIOWxGimmickReaderDialog.h>
12 #include <creaImageIOWxSimpleDlg.h>
13
14 #include <creaImageIOSystem.h>
15
16 #include <creaVtkBasicSlicer.h>
17 //#include "wxContourMainPanel.h"
18
19 #include "vtkMetaImageReader.h"
20 #include <map>
21 #include "vtkImageData.h"
22
23 #include "wx/artprov.h"
24 #include <wx/filedlg.h>
25
26
27 /* EED EraseMe
28 //#include "OutlineModelBuilder.h"
29 //#include "ContourThing.h"
30 //#include "AxeThing.h"
31 //#include "ImageSourceThing.h"
32 //#include "ImageSectionThing.h"
33 //#include "SomeEnvironment.h"
34 //#include "ReaderEnvironment.h"
35
36 //#include "interfMainPanel.h"
37
38 #if defined(MACOSX) // assume this is OSX
39 # include <sys/param.h>
40 # include <mach-o/dyld.h> // _NSGetExecutablePath : must add -framework CoreFoundation to link line
41 # include <string.h>
42 # ifndef PATH_MAX
43 #  define PATH_MAX MAXPATHLEN
44 # endif
45 #endif // MACOSX
46 */
47
48 #ifndef PATH_MAX // If not defined yet : do it
49 #  define PATH_MAX 2048
50 #endif
51
52 #if defined(WIN32)
53   #include <direct.h>
54 #else
55    #include <dirent.h>
56 #endif
57
58 #include <stdlib.h>
59
60 wxContourMainFrame* wxTheApplication::frame = 0;
61
62 //----------------------------------------------------------------------------------------------------------------
63 // This macro implements the entry point (main function) for the application
64 //----------------------------------------------------------------------------------------------------------------
65
66
67
68
69
70
71 //=========================================================================
72 //=========================================================================
73 IMPLEMENT_APP( wxTheApplication );
74 /*
75 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
76 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
77 {
78 }
79 */
80
81 #ifdef _DEBUG
82 void wxAppConsole::OnAssert(char const *,int,char const *,char const *)
83 {
84 }
85
86 void wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)
87 {
88 }
89 #endif
90
91 bool wxTheApplication :: OnInit()
92 {
93         wxString infoImage;
94         wxInitAllImageHandlers();
95
96 //EED01Juin2010 int min_image_type = GIMMICK_2D_IMAGE_SELECTION;
97 //EED01Juin2010 int max_image_type = GIMMICK_3D_IMAGE_SELECTION;
98 //EED01Juin2010 int output_dim = NATIVE;
99 //EED01Juin2010 int threads = 1;
100
101
102 //EED 1Juin2010
103       creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
104       w.ShowModal();
105
106         std::vector<vtkImageData*> images;
107 //EED 1Juin2010
108 //      creaImageIO::WxGimmickReaderDialog w(0,
109 //                                                                              -1,
110 //                                                                              "creaContours_Descriptor.dscp",
111 //                                                                              "creatisContours DB",
112 //                                                                              _T("WxGimmickDialog test"),
113 //                                                                              wxDefaultPosition,wxSize(1200,800)
114 //                                                                              ,min_image_type,
115 //                                                                              max_image_type,
116 //                                                                              output_dim,
117 //                                                                              threads);
118 //      w.ShowModal();
119
120
121 //JCP
122         //std::string datadir(  crea::wx2std(GetExecutablePath()) );
123         std::string datadir(  crea::System::GetExecutablePath() );
124 //JCP
125
126             #ifdef LINUX /* assume this is OSX */
127                    datadir=datadir+"/../share/creaContours";
128             #endif // MACOSX
129
130                 #ifdef MACOSX /* assume this is OSX */
131                         datadir=datadir+"/../../../../share/creaContours";
132                 #endif // MACOSX
133
134
135                 if(w.GetReturnCode() == wxID_OK)
136                 {
137                                 std::vector<std::string> s;
138 //EED 01Juin2010                                w.GetSelectedFiles(s);
139
140
141 //EED                   std::vector<std::string>::iterator i;
142 //                              for (i=s.begin();i!=s.end();++i)
143 //                              {
144 //                                      std::cout << *i << std::endl;
145 //                              }
146 //                              std::cout << "$$$$ "<<std::endl;
147                                 //w.GetSelectedImages(images);
148
149 //EED31mai2010                          w.GetSelectedImages(images,output_dim);
150
151
152 //EED 1Juin2010
153 //                              std::vector<creaImageIO::OutStrGimmick> out;
154 //                              std::vector<std::string> attr;
155 ////                            attr.push_back("D0028_0010");
156 ////                            attr.push_back("D0008_0023");
157 ////                            attr.push_back("D0008_1070");
158 //                              w.getSelected(out, attr,true,"");
159 ////                            std::cout<<out.size()<<std::endl;
160 ////                            crea::VtkBasicSlicer(out.front().img);
161 //                              int size=out.size();
162 //                              int ii;
163 //                              for (ii=0;ii<size;ii++)
164 //                              {
165 //                                      images.push_back(out[ii].img);
166 //                              }
167
168 //EED 1Juin2010
169 //                              printf("EED creaContours wxTheApplication :: OnInit  %d\n", w.getImagesSelected().size() );
170                                 images    = w.getImagesSelected();
171                                 infoImage = w.getInfoImage();
172 //                              printf("EED creaContours wxTheApplication :: OnInit  %d\n", images.size() );
173
174                 }
175                 else if (w.GetReturnCode() == wxID_CANCEL)
176                 {
177                                 vtkMetaImageReader *reader = vtkMetaImageReader::New();
178                                 std::string filename= datadir + "/data/hola.mhd";
179                                 infoImage=_T("DEFAULT-Image:")+crea::std2wx(filename);
180                                 reader->SetFileName( filename.c_str() );
181                                 reader->Update();
182                                 images.push_back(reader->GetOutput());
183                         }
184                         else
185                         {
186                                 return -1;
187                         }
188
189
190         wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("Creatis- ROI Application- Evaluation version,01 Agost 2010 ")+infoImage, wxPoint(400,50), wxSize(800, 600) );
191
192         //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
193         frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images,  wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
194         frame1->CreateStatusBar();
195         frame1->Show(TRUE);
196     frame->RefreshInterface();
197         return TRUE;
198 }
199
200 #if(WIN32)
201 int main(int argc, char* argv[])
202   {
203     return WinMain(::GetModuleHandle(NULL), NULL,
204                    ::GetCommandLine(), SW_SHOWNORMAL);
205   }
206 #else
207 #endif
208