1 //----------------------------------------------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------------------------------------------
5 #include "wxContourGUIExample.h"
6 #include "wxContourMainFrame.h"
7 //#include "OutlineModelManager.h"
8 //#include "wxContourEventHandler.h"
10 //#include <creaImageIOWxGimmickDialog.h>
11 #include <creaImageIOWxGimmickReaderDialog.h>
12 #include <creaImageIOSystem.h>
14 #include <creaVtkBasicSlicer.h>
15 //#include "wxContourMainPanel.h"
17 #include "vtkMetaImageReader.h"
19 #include "vtkImageData.h"
21 #include "wx/artprov.h"
22 #include <wx/filedlg.h>
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"
34 //#include "interfMainPanel.h"
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
41 # define PATH_MAX MAXPATHLEN
46 #ifndef PATH_MAX // If not defined yet : do it
47 # define PATH_MAX 2048
58 wxContourMainFrame* wxTheApplication::frame = 0;
60 //----------------------------------------------------------------------------------------------------------------
61 // This macro implements the entry point (main function) for the application
62 //----------------------------------------------------------------------------------------------------------------
68 #define CREACONTOUR_VALID_FILE_SEPARATOR_CHAR '\\'
70 #define CREACONTOUR_VALID_FILE_SEPARATOR_CHAR '/'
73 //=========================================================================
74 std::string GetExecutablePath()
77 //EED int err = get_app_path(name, PATH_MAX);
78 int err = crea::System::GetAppPath(name,PATH_MAX);
81 printf("Could not determine current executable path ? ");
83 // remove the exe name
85 slash = strrchr(name, CREACONTOUR_VALID_FILE_SEPARATOR_CHAR);
93 //=========================================================================
94 //=========================================================================
95 IMPLEMENT_APP( wxTheApplication );
97 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
98 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
104 void wxAppConsole::OnAssert(char const *,int,char const *,char const *)
108 void wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)
113 bool wxTheApplication :: OnInit()
115 wxInitAllImageHandlers();
117 int min_image_type = GIMMICK_2D_IMAGE_SELECTION;
118 int max_image_type = GIMMICK_3D_IMAGE_SELECTION;
119 int output_dim = NATIVE;
122 std::vector<vtkImageData*> images;
123 printf("EED wxContourGUIExample:OnInit 1\n");
124 creaImageIO::WxGimmickReaderDialog w(0,
126 "creaContours_Descriptor.dscp",
127 "creatisContours DB",
128 _T("WxGimmickDialog test"),
129 wxDefaultPosition,wxSize(1200,800)
136 printf("EED wxContourGUIExample:OnInit 2\n");
140 //std::string datadir( crea::wx2std(GetExecutablePath()) );
141 std::string datadir( GetExecutablePath() );
144 #ifdef MACOSX /* assume this is OSX */
145 datadir=datadir+"/../../..";
149 if(w.GetReturnCode() == wxID_OK)
151 std::vector<std::string> s;
152 w.GetSelectedFiles(s);
153 std::vector<std::string>::iterator i;
154 for (i=s.begin();i!=s.end();++i)
156 std::cout << *i << std::endl;
158 std::cout << "$$$$ "<<std::endl;
159 //w.GetSelectedImages(images);
160 w.GetSelectedImages(images,output_dim);
162 else if (w.GetReturnCode() == wxID_CANCEL)
164 vtkMetaImageReader *reader = vtkMetaImageReader::New();
165 std::string filename= datadir + "/data/hola.mhd";
166 reader->SetFileName( filename.c_str() );
168 images.push_back(reader->GetOutput());
176 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 09 Feb 2009 "), wxPoint(400,50), wxSize(800, 600) );
178 //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
179 frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images, wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
180 frame1->CreateStatusBar();
182 frame->RefreshInterface();
187 int main(int argc, char* argv[])
189 return WinMain(::GetModuleHandle(NULL), NULL,
190 ::GetCommandLine(), SW_SHOWNORMAL);