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