1 //----------------------------------------------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------------------------------------------
6 #include "wxContourGUIExample.h"
7 #include "wxContourMainFrame.h"
8 //#include "OutlineModelManager.h"
9 //#include "wxContourEventHandler.h"
12 #include <creaImageIOWxGimmickDialog.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>
23 //#include "OutlineModelBuilder.h"
24 //#include "ContourThing.h"
25 //#include "AxeThing.h"
26 //#include "ImageSourceThing.h"
27 //#include "ImageSectionThing.h"
28 //#include "SomeEnvironment.h"
29 //#include "ReaderEnvironment.h"
34 //#include "interfMainPanel.h"
37 wxContourMainFrame* wxTheApplication::frame = 0;
38 //----------------------------------------------------------------------------------------------------------------
39 // This macro implements the entry point (main function) for the application
40 //----------------------------------------------------------------------------------------------------------------
42 IMPLEMENT_APP( wxTheApplication );
45 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
46 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
53 void wxAppConsole::OnAssert(char const *,int,char const *,char const *)
57 void wxAppConsole::OnAssertFailure(char const *,int,char const *,char const *,char const *)
62 bool wxTheApplication :: OnInit()
65 //-------------------------------------------------------------
66 // Doing what is done by the bbtk boxes
67 //vtkMetaImageReader *reader = vtkMetaImageReader::New();
68 // reader->SetFileName( "data\\hola.mhd" );
69 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/img02.maracas.mhd" );
70 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/test01.maracas.mhd" );
71 // reader->SetFileName( "C:/download/Elise/Elise_IRM_Helium/A/test01b.maracas.mhd" );
73 //wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.mhd"), wxOPEN );
74 //if (dialog.ShowModal() == wxID_OK)
76 // std::string filename = (const char *)(dialog.GetPath().mb_str());
77 // reader->SetFileName( filename.c_str() );
79 // reader->SetFileName( "data\\hola.mhd" );
85 wxInitAllImageHandlers();
87 int image_type = GIMMICK_3D_IMAGE_SELECTION;
90 creaImageIO::WxGimmickDialog w(0,
92 _T("WxGimmickDialog test"),
99 vtkImageData* selectedimage=NULL;
100 if(w.GetReturnCode() == wxID_OK){
102 std::vector<std::string> s;
103 w.GetSelectedFiles(s);
104 std::vector<std::string>::iterator i;
105 for (i=s.begin();i!=s.end();++i){
106 std::cout << *i << std::endl;
109 std::cout << "$$$$ "<<std::endl;
110 std::vector<vtkImageData*> images;
111 w.GetSelectedImages(images);
112 selectedimage = images[0];
113 //crea::VtkBasicSlicer(images.front());
114 //images.front()->Delete();
116 }else if (w.GetReturnCode() == wxID_CANCEL){
117 vtkMetaImageReader *reader = vtkMetaImageReader::New();
118 reader->SetFileName( "data/hola.mhd" );
120 selectedimage = reader->GetOutput();
125 std::string conceptsFN = "data/holaConceptsFile.cf";
126 std::string imageSourcesFN = "data/holaImagesInstantsFile.of";
127 std::string imageSectionsFN = "";
128 std::string axeThingsFN = "";
130 std::map<std::string, ImageSourceThing *> * sourcesMap = new std::map<std::string, ImageSourceThing *>();
131 std::map<std::string, ImageSectionThing *>* sectionsMap = new std::map<std::string, ImageSectionThing *>();
132 std::map<std::string, AxeThing *>* axesMap = new std::map<std::string, AxeThing *>();
133 std::map<std::string, ContourThing *>* outlinesMap = new std::map<std::string, ContourThing *>();
135 ImageSourceThing * thing = new ImageSourceThing(selectedimage);
136 sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( "Source Image 1", thing));
138 OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN );
139 _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
140 _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
141 _builder->buildAxe_Envornment(axeThingsFN, axesMap );
142 _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
144 //-------------------------------------------------------------
146 //frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
149 //Creating the evtHandler of the panels
150 wxContourEventHandler * eventHandler = new wxContourEventHandler();
152 //Creating the window that will show the panels
154 //wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 - Use limited to the research team (Creatis-LRMN)"), wxPoint(50,50), wxSize(800, 600) );
155 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(50,50), wxSize(800, 600) );
156 frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600) );
158 //frame = new wxContourMainFrame( NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 17 Oct 2008 - Use limited to the research team (Creatis-LRMN)"), wxPoint(50,50), wxSize(800, 600) );
159 frame1->CreateStatusBar();
161 //Getting the parent for the panels ( using aui )
162 wxAuiNotebook * parent = frame->createNotebook();
164 //Creating the objects to manage
165 OutlineModelManager * modelManager = new OutlineModelManager( _builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv() );
167 wxInstantChooserPanel * instantPanel = new wxInstantChooserPanel( parent, "Instant Chooser", true );
168 ImageSourceThing * imageSource = modelManager->getImageSourceThingByKeyName( "Source Image 1" );
169 wxContourViewPanel * theViewPanel = new wxContourViewPanel( imageSource->getSourceImage(), parent );
170 //wxContour_ButtonsBar * buttons = new wxContour_ButtonsBar(frame, -1, wxDefaultPosition, wxDefaultSize);
172 eventHandler->setModelManager( modelManager );
173 eventHandler->setViewPanel( theViewPanel );
174 eventHandler->setInstantChooserPanel( instantPanel );
175 //eventHandler->setButtonsBar( buttons );
177 //buttons->Show(false);
179 bool successConfiuration = eventHandler->configureEventsHandling();
181 frame->setViewPanel( theViewPanel );
182 frame->setInstantChooserPanel( instantPanel );
184 // frame->setButtonsBar( buttons );
186 successConfiuration &= frame->configurePanels( parent );
189 //buttons->Show(false);
196 //if ( successConfiuration )
198 // frame->Show(TRUE);
201 // SetTopWindow(frame);
203 //JCP -- new Interface
204 interfMainPanel* pannew = interfMainPanel::getInstance(frame1, eventHandler);
206 //pannew->addContourCheckBox("contour1");
207 //pannew->addContourCheckBox("contour3");
208 //pannew->addContourCheckBox("contour2");
209 //pannew->addContourCheckBox("contour4");
210 //JCP -- new Interface
215 wxInitAllImageHandlers();
217 int image_type = GIMMICK_3D_IMAGE_SELECTION;
220 creaImageIO::WxGimmickDialog w(0,
222 _T("WxGimmickDialog test"),
229 //vtkImageData* selectedimage=NULL;
230 std::vector<vtkImageData*> images;
231 if(w.GetReturnCode() == wxID_OK){
233 std::vector<std::string> s;
234 w.GetSelectedFiles(s);
235 std::vector<std::string>::iterator i;
236 for (i=s.begin();i!=s.end();++i){
237 std::cout << *i << std::endl;
240 std::cout << "$$$$ "<<std::endl;
241 w.GetSelectedImages(images);
242 //selectedimage = images[0];
243 //crea::VtkBasicSlicer(images.front());
244 //images.front()->Delete();
246 }else if (w.GetReturnCode() == wxID_CANCEL){
247 vtkMetaImageReader *reader = vtkMetaImageReader::New();
248 reader->SetFileName( "data/hola.mhd" );
250 images.push_back(reader->GetOutput());
256 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 28 Jan 2009 "), wxPoint(400,50), wxSize(800, 600) );
257 //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
258 frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images );
259 frame1->CreateStatusBar();
267 int main(int argc, char* argv[])
269 return WinMain(::GetModuleHandle(NULL), NULL,
270 ::GetCommandLine(), SW_SHOWNORMAL);