]> Creatis software - creaContours.git/blob - appli/wxContourGUIExample/wxContourGUIExample.cxx
#3206 creaContours Feature New Normal branch vtk7itk4wx3-mingw
[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 "OutlineModelManager.h"
33 //#include "wxContourEventHandler.h"
34 //#include <creaImageIOWxGimmickDialog.h>
35 //#include <creaImageIOWxGimmickReaderDialog.h>
36 #include <creaImageIOWxSimpleDlg.h>
37 #include <creaImageIOSystem.h>
38 #include <creaVtkBasicSlicer.h>
39 //#include "wxContourMainPanel.h"
40 #include "vtkMetaImageReader.h"
41 #include <map>
42 #include "vtkImageData.h"
43 #include "wx/artprov.h"
44 #include <wx/filedlg.h>
45
46 #ifndef PATH_MAX // If not defined yet : do it
47 #  define PATH_MAX 2048
48 #endif
49 #if defined(WIN32)
50   #include <direct.h>
51 #else
52    #include <dirent.h>
53 #endif
54 #include <stdlib.h>
55
56 wxContourMainFrame* wxTheApplication::frame = 0;
57
58 //----------------------------------------------------------------------------------------------------------------
59 // This macro implements the entry point (main function) for the application
60 //----------------------------------------------------------------------------------------------------------------
61
62 //=========================================================================
63 //=========================================================================
64 IMPLEMENT_APP( wxTheApplication );
65 /*
66 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
67 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
68 {
69 }
70 */
71
72 #ifdef _DEBUG
73 void wxAppConsole::OnAssert(char const *,int,char const *,char const *)
74 {
75 }
76
77 void wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)
78 {
79 }
80 #endif
81
82 bool wxTheApplication::OnInit()
83 {
84         vtkOutputWindowCreaContour *outputWindowCreaContour= vtkOutputWindowCreaContour::New();
85         vtkOutputWindow::SetInstance( outputWindowCreaContour );
86         outputWindowCreaContour->Delete();
87         wxString infoImage;
88         wxInitAllImageHandlers();
89
90 //EED01Juin2010 int min_image_type = GIMMICK_2D_IMAGE_SELECTION;
91 //EED01Juin2010 int max_image_type = GIMMICK_3D_IMAGE_SELECTION;
92 //EED01Juin2010 int output_dim = NATIVE;
93 //EED01Juin2010 int threads = 1;
94
95 //EED 1Juin2010
96       creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
97       w.ShowModal();
98
99         std::vector<vtkImageData*> images;
100 //EED 1Juin2010
101 //      creaImageIO::WxGimmickReaderDialog w(0,
102 //                                                                              -1,
103 //                                                                              "creaContours_Descriptor.dscp",
104 //                                                                              "creatisContours DB",
105 //                                                                              _T("WxGimmickDialog test"),
106 //                                                                              wxDefaultPosition,wxSize(1200,800)
107 //                                                                              ,min_image_type,
108 //                                                                              max_image_type,
109 //                                                                              output_dim,
110 //                                                                              threads);
111 //      w.ShowModal();
112
113 //JCP
114         //std::string datadir(  crea::wx2std(GetExecutablePath()) );
115         std::string datadir(  crea::System::GetExecutablePath() );
116 //JCP
117             #ifdef LINUX /* assume this is OSX */
118                    datadir=datadir+"/../share/creaContours";
119             #endif // MACOSX
120                 #ifdef MACOSX /* assume this is OSX */
121                         datadir=datadir+"/../../../../share/creaContours";
122                 #endif // MACOSX
123                 if(w.GetReturnCode() == wxID_OK)
124                 {
125                         std::vector<std::string> s;
126                         images    = w.getImagesSelected();
127                         infoImage = w.getInfoImage();
128                 } else if (w.GetReturnCode() == wxID_CANCEL)
129                 {
130                         vtkMetaImageReader *reader = vtkMetaImageReader::New();
131                         std::string filename= datadir + "/data/hola.mhd";
132                         infoImage=_T("DEFAULT-Image:")+crea::std2wx(filename);
133                         reader->SetFileName( filename.c_str() );
134                         reader->Update();
135                         images.push_back(reader->GetOutput());
136                 } else {
137                         return -1;
138                 }
139         wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("Creatis- ROI Application- Evaluation version,01 Agost 2010 ")+infoImage, wxPoint(400,50), wxSize(800, 600) );
140         //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
141         frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images,  wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,datadir );
142         frame1->CreateStatusBar();
143         frame1->Show(TRUE);
144     frame->RefreshInterface();
145         return TRUE;
146 }
147
148 #if(WIN32)
149 int main(int argc, char* argv[])
150   {  
151         char buffer[500];
152         wcstombs(buffer, ::GetCommandLine(), 500);
153     return WinMain(::GetModuleHandle(NULL), NULL, buffer, SW_SHOWNORMAL);
154 //    return WinMain(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), SW_SHOWNORMAL);
155   }
156 #else
157 #endif
158