]> Creatis software - creaContours.git/blob - appli/wxContourGUIExample/wxContourGUIExample.cxx
fb162fe85278086ead1ec9ccc33882e1e796d77d
[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                                 std::vector<std::string>::iterator i;
132                                 for (i=s.begin();i!=s.end();++i)
133                                 {
134                                         std::cout << *i << std::endl;
135                                 }
136                                 std::cout << "$$$$ "<<std::endl;
137                                 //w.GetSelectedImages(images);
138                                 w.GetSelectedImages(images,output_dim);
139                         }
140                         else if (w.GetReturnCode() == wxID_CANCEL)
141                         {
142                                 vtkMetaImageReader *reader = vtkMetaImageReader::New();
143                                 std::string filename= datadir + "/data/hola.mhd";          
144                                 reader->SetFileName( filename.c_str() );
145                                 reader->Update();
146                                 images.push_back(reader->GetOutput());
147                         }
148                         else
149                         {        
150                                 return -1;
151                         }   
152
153
154         wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application  -    Evaluation version, 09 Feb 2009 "), wxPoint(400,50), wxSize(800, 600) );
155
156         //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images ); 
157         frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images,  wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
158         frame1->CreateStatusBar();
159         frame1->Show(TRUE);
160     frame->RefreshInterface();
161         return TRUE;
162 }
163
164 #if(WIN32)
165 int main(int argc, char* argv[])                                        
166   {                                                                     
167     return WinMain(::GetModuleHandle(NULL), NULL,                       
168                    ::GetCommandLine(), SW_SHOWNORMAL);                  
169   }             
170 #else
171 #endif
172