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;
124 creaImageIO::WxGimmickReaderDialog w(0,
126 "creaContours_Descriptor.dscp",
127 "creatisContours DB",
128 _T("WxGimmickDialog test"),
129 wxDefaultPosition,wxSize(1200,800)
139 //std::string datadir( crea::wx2std(GetExecutablePath()) );
140 std::string datadir( GetExecutablePath() );
143 #ifdef MACOSX /* assume this is OSX */
144 datadir=datadir+"/../../..";
148 if(w.GetReturnCode() == wxID_OK)
150 std::vector<std::string> s;
151 w.GetSelectedFiles(s);
152 std::vector<std::string>::iterator i;
153 for (i=s.begin();i!=s.end();++i)
155 std::cout << *i << std::endl;
157 std::cout << "$$$$ "<<std::endl;
158 //w.GetSelectedImages(images);
159 w.GetSelectedImages(images,output_dim);
161 else if (w.GetReturnCode() == wxID_CANCEL)
163 vtkMetaImageReader *reader = vtkMetaImageReader::New();
164 std::string filename= datadir + "/data/hola.mhd";
165 reader->SetFileName( filename.c_str() );
167 images.push_back(reader->GetOutput());
175 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 09 Feb 2009 "), wxPoint(400,50), wxSize(800, 600) );
177 //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
178 frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images, wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
179 frame1->CreateStatusBar();
181 frame->RefreshInterface();
186 int main(int argc, char* argv[])
188 return WinMain(::GetModuleHandle(NULL), NULL,
189 ::GetCommandLine(), SW_SHOWNORMAL);