]> Creatis software - creaContours.git/blob - appli/wxContourGUIExample/wxContourGUIExample.cxx
420a8941a80ee2620a13aca2d6a72550befbabfb
[creaContours.git] / appli / wxContourGUIExample / wxContourGUIExample.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 //----------------------------------------------------------------------------------------------------------------
27 // Class definition include
28 //----------------------------------------------------------------------------------------------------------------
29
30 #include "wxContourGUIExample.h"
31 #include "wxContourMainFrame.h"
32 #include <creaImageIOWxSimpleDlg.h>
33 #include <creaImageIOSystem.h>
34 #include <creaVtkBasicSlicer.h>
35 #include "vtkMetaImageReader.h"
36 #include <map>
37 #include "vtkImageData.h"
38 #include "wx/artprov.h"
39 #include <wx/filedlg.h>
40
41 #ifndef PATH_MAX // If not defined yet : do it
42 #  define PATH_MAX 2048
43 #endif
44 #if defined(WIN32)
45   #include <direct.h>
46 #else
47    #include <dirent.h>
48 #endif
49 #include <stdlib.h>
50
51 wxContourMainFrame* wxTheApplication::frame = 0;
52
53 //----------------------------------------------------------------------------------------------------------------
54 // This macro implements the entry point (main function) for the application
55 //----------------------------------------------------------------------------------------------------------------
56
57 //=========================================================================
58 //=========================================================================
59 IMPLEMENT_APP( wxTheApplication );
60 /*
61 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
62 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
63 {
64 }
65 */
66
67 #ifdef _DEBUG
68 //void wxAppConsole::OnAssert(char const *,int,char const *,char const *)
69 //{
70 //}
71
72 //void wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)
73 //{
74 //}
75 #endif
76
77 bool wxTheApplication::OnInit()
78 {
79         vtkOutputWindowCreaContour *outputWindowCreaContour= vtkOutputWindowCreaContour::New();
80         vtkOutputWindow::SetInstance( outputWindowCreaContour );
81         outputWindowCreaContour->Delete();
82         wxString infoImage;
83         wxInitAllImageHandlers();
84
85 //EED01Juin2010 int min_image_type = GIMMICK_2D_IMAGE_SELECTION;
86 //EED01Juin2010 int max_image_type = GIMMICK_3D_IMAGE_SELECTION;
87 //EED01Juin2010 int output_dim = NATIVE;
88 //EED01Juin2010 int threads = 1;
89
90 //EED 1Juin2010
91       creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
92       w.ShowModal();
93
94         std::vector<vtkImageData*> images;
95 //EED 1Juin2010
96 //      creaImageIO::WxGimmickReaderDialog w(0,
97 //                                                                              -1,
98 //                                                                              "creaContours_Descriptor.dscp",
99 //                                                                              "creatisContours DB",
100 //                                                                              _T("WxGimmickDialog test"),
101 //                                                                              wxDefaultPosition,wxSize(1200,800)
102 //                                                                              ,min_image_type,
103 //                                                                              max_image_type,
104 //                                                                              output_dim,
105 //                                                                              threads);
106 //      w.ShowModal();
107
108 //JCP
109         //std::string datadir(  crea::wx2std(GetExecutablePath()) );
110         std::string datadir(  crea::System::GetExecutablePath() );
111         
112 //JCP
113             #ifdef LINUX /* assume this is OSX */
114                    datadir=datadir+"/../share/creaContours";
115             #endif // MACOSX
116                 #ifdef MACOSX /* assume this is OSX */
117                         datadir=datadir+"/../../../../share/creaContours";
118                 #endif // MACOSX
119                 if(w.GetReturnCode() == wxID_OK)
120                 {
121                         std::vector<std::string> s;
122                         images    = w.getImagesSelected();
123                         infoImage = w.getInfoImage();
124                 } else if (w.GetReturnCode() == wxID_CANCEL)
125                 {
126                         vtkMetaImageReader *reader = vtkMetaImageReader::New();
127                         std::string filename= datadir + "/data/hola.mhd";
128                         infoImage=_T("DEFAULT-Image:")+crea::std2wx(filename);
129                         reader->SetFileName( filename.c_str() );
130                         reader->Update();
131                         images.push_back(reader->GetOutput());
132                 } else {
133                         return -1;
134                 }
135         wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("Creatis- ROI Application- Evaluation version,01 Agost 2010 ")+infoImage, wxPoint(400,50), wxSize(800, 600) );
136         //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
137         frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images,  wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
138         frame1->CreateStatusBar();
139         frame1->Show(TRUE);
140     frame->RefreshInterface();
141         return TRUE;
142 }
143
144 #if(WIN32)
145 int main(int argc, char* argv[])
146   {  
147         char buffer[500];
148         wcstombs(buffer, ::GetCommandLine(), 500);
149     return WinMain(::GetModuleHandle(NULL), NULL, buffer, SW_SHOWNORMAL);
150 //    return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
151   }
152 #else
153 #endif
154