]> Creatis software - creaContours.git/blob - appli/wxContourGUIExample/wxContourGUIExample.cxx
*** empty log message ***
[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         wxInitAllImageHandlers();
94
95 //EED01Juin2010 int min_image_type = GIMMICK_2D_IMAGE_SELECTION;
96 //EED01Juin2010 int max_image_type = GIMMICK_3D_IMAGE_SELECTION;
97 //EED01Juin2010 int output_dim = NATIVE;
98 //EED01Juin2010 int threads = 1;
99
100
101 //EED 1Juin2010
102       creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB"); 
103       w.ShowModal(); 
104   
105         std::vector<vtkImageData*> images;
106 //EED 1Juin2010
107 //      creaImageIO::WxGimmickReaderDialog w(0,
108 //                                                                              -1,
109 //                                                                              "creaContours_Descriptor.dscp",
110 //                                                                              "creatisContours DB", 
111 //                                                                              _T("WxGimmickDialog test"),
112 //                                                                              wxDefaultPosition,wxSize(1200,800)
113 //                                                                              ,min_image_type,
114 //                                                                              max_image_type,
115 //                                                                              output_dim,
116 //                                                                              threads);  
117 //      w.ShowModal();
118
119
120 //JCP
121         //std::string datadir(  crea::wx2std(GetExecutablePath()) );    
122         std::string datadir(  crea::System::GetExecutablePath() );
123 //JCP
124
125             #ifdef LINUX /* assume this is OSX */
126                    datadir=datadir+"/../share/creaContours";
127             #endif // MACOSX    
128         
129                 #ifdef MACOSX /* assume this is OSX */
130                         datadir=datadir+"/../../../../share/creaContours";
131                 #endif // MACOSX        
132                 
133                 
134                 if(w.GetReturnCode() == wxID_OK)
135                 {
136                                 std::vector<std::string> s;
137 //EED 01Juin2010                                w.GetSelectedFiles(s);
138
139
140 //EED                   std::vector<std::string>::iterator i;
141 //                              for (i=s.begin();i!=s.end();++i)
142 //                              {
143 //                                      std::cout << *i << std::endl;
144 //                              }
145 //                              std::cout << "$$$$ "<<std::endl;
146                                 //w.GetSelectedImages(images);
147
148 //EED31mai2010                          w.GetSelectedImages(images,output_dim);
149
150
151 //EED 1Juin2010
152 //                              std::vector<creaImageIO::OutStrGimmick> out;
153 //                              std::vector<std::string> attr;
154 ////                            attr.push_back("D0028_0010");
155 ////                            attr.push_back("D0008_0023");
156 ////                            attr.push_back("D0008_1070");
157 //                              w.getSelected(out, attr,true,"");
158 ////                            std::cout<<out.size()<<std::endl;
159 ////                            crea::VtkBasicSlicer(out.front().img);
160 //                              int size=out.size();
161 //                              int ii;
162 //                              for (ii=0;ii<size;ii++)
163 //                              {
164 //                                      images.push_back(out[ii].img);
165 //                              }
166
167 //EED 1Juin2010
168                                 printf("EED creaContours wxTheApplication :: OnInit  %d\n", w.getImagesSelected().size() );
169                                 images=w.getImagesSelected(); 
170                                 printf("EED creaContours wxTheApplication :: OnInit  %d\n", images.size() );
171
172                 }
173                 else if (w.GetReturnCode() == wxID_CANCEL)
174                 {
175                                 vtkMetaImageReader *reader = vtkMetaImageReader::New();
176                                 std::string filename= datadir + "/data/hola.mhd";          
177                                 reader->SetFileName( filename.c_str() );
178                                 reader->Update();
179                                 images.push_back(reader->GetOutput());
180                         }
181                         else
182                         {        
183                                 return -1;
184                         }   
185
186
187         wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application  -    Evaluation version, 09 Feb 2009 "), wxPoint(400,50), wxSize(800, 600) );
188
189         //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images ); 
190         frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images,  wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
191         frame1->CreateStatusBar();
192         frame1->Show(TRUE);
193     frame->RefreshInterface();
194         return TRUE;
195 }
196
197 #if(WIN32)
198 int main(int argc, char* argv[])                                        
199   {                                                                     
200     return WinMain(::GetModuleHandle(NULL), NULL,                       
201                    ::GetCommandLine(), SW_SHOWNORMAL);                  
202   }             
203 #else
204 #endif
205