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 );
44 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
45 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
50 bool wxTheApplication :: OnInit()
53 //-------------------------------------------------------------
54 // Doing what is done by the bbtk boxes
55 //vtkMetaImageReader *reader = vtkMetaImageReader::New();
56 // reader->SetFileName( "data\\hola.mhd" );
57 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/img02.maracas.mhd" );
58 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/test01.maracas.mhd" );
59 // reader->SetFileName( "C:/download/Elise/Elise_IRM_Helium/A/test01b.maracas.mhd" );
61 //wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.mhd"), wxOPEN );
62 //if (dialog.ShowModal() == wxID_OK)
64 // std::string filename = (const char *)(dialog.GetPath().mb_str());
65 // reader->SetFileName( filename.c_str() );
67 // reader->SetFileName( "data\\hola.mhd" );
73 wxInitAllImageHandlers();
75 int image_type = GIMMICK_3D_IMAGE_SELECTION;
78 creaImageIO::WxGimmickDialog w(0,
80 _T("WxGimmickDialog test"),
87 vtkImageData* selectedimage=NULL;
88 if(w.GetReturnCode() == wxID_OK){
90 std::vector<std::string> s;
91 w.GetSelectedFiles(s);
92 std::vector<std::string>::iterator i;
93 for (i=s.begin();i!=s.end();++i){
94 std::cout << *i << std::endl;
97 std::cout << "$$$$ "<<std::endl;
98 std::vector<vtkImageData*> images;
99 w.GetSelectedImages(images);
100 selectedimage = images[0];
101 //crea::VtkBasicSlicer(images.front());
102 //images.front()->Delete();
104 }else if (w.GetReturnCode() == wxID_CANCEL){
105 vtkMetaImageReader *reader = vtkMetaImageReader::New();
106 reader->SetFileName( "data/hola.mhd" );
108 selectedimage = reader->GetOutput();
113 std::string conceptsFN = "data/holaConceptsFile.cf";
114 std::string imageSourcesFN = "data/holaImagesInstantsFile.of";
115 std::string imageSectionsFN = "";
116 std::string axeThingsFN = "";
118 std::map<std::string, ImageSourceThing *> * sourcesMap = new std::map<std::string, ImageSourceThing *>();
119 std::map<std::string, ImageSectionThing *>* sectionsMap = new std::map<std::string, ImageSectionThing *>();
120 std::map<std::string, AxeThing *>* axesMap = new std::map<std::string, AxeThing *>();
121 std::map<std::string, ContourThing *>* outlinesMap = new std::map<std::string, ContourThing *>();
123 ImageSourceThing * thing = new ImageSourceThing(selectedimage);
124 sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( "Source Image 1", thing));
126 OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN );
127 _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
128 _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
129 _builder->buildAxe_Envornment(axeThingsFN, axesMap );
130 _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
132 //-------------------------------------------------------------
134 //frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
137 //Creating the evtHandler of the panels
138 wxContourEventHandler * eventHandler = new wxContourEventHandler();
140 //Creating the window that will show the panels
142 //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) );
143 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(50,50), wxSize(800, 600) );
144 frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600) );
146 //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) );
147 frame1->CreateStatusBar();
149 //Getting the parent for the panels ( using aui )
150 wxAuiNotebook * parent = frame->createNotebook();
152 //Creating the objects to manage
153 OutlineModelManager * modelManager = new OutlineModelManager( _builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv() );
155 wxInstantChooserPanel * instantPanel = new wxInstantChooserPanel( parent, "Instant Chooser", true );
156 ImageSourceThing * imageSource = modelManager->getImageSourceThingByKeyName( "Source Image 1" );
157 wxContourViewPanel * theViewPanel = new wxContourViewPanel( imageSource->getSourceImage(), parent );
158 //wxContour_ButtonsBar * buttons = new wxContour_ButtonsBar(frame, -1, wxDefaultPosition, wxDefaultSize);
160 eventHandler->setModelManager( modelManager );
161 eventHandler->setViewPanel( theViewPanel );
162 eventHandler->setInstantChooserPanel( instantPanel );
163 //eventHandler->setButtonsBar( buttons );
165 //buttons->Show(false);
167 bool successConfiuration = eventHandler->configureEventsHandling();
169 frame->setViewPanel( theViewPanel );
170 frame->setInstantChooserPanel( instantPanel );
172 // frame->setButtonsBar( buttons );
174 successConfiuration &= frame->configurePanels( parent );
177 //buttons->Show(false);
184 //if ( successConfiuration )
186 // frame->Show(TRUE);
189 // SetTopWindow(frame);
191 //JCP -- new Interface
192 interfMainPanel* pannew = interfMainPanel::getInstance(frame1, eventHandler);
194 //pannew->addContourCheckBox("contour1");
195 //pannew->addContourCheckBox("contour3");
196 //pannew->addContourCheckBox("contour2");
197 //pannew->addContourCheckBox("contour4");
198 //JCP -- new Interface
203 wxInitAllImageHandlers();
205 int image_type = GIMMICK_3D_IMAGE_SELECTION;
208 creaImageIO::WxGimmickDialog w(0,
210 _T("WxGimmickDialog test"),
217 //vtkImageData* selectedimage=NULL;
218 std::vector<vtkImageData*> images;
219 if(w.GetReturnCode() == wxID_OK){
221 std::vector<std::string> s;
222 w.GetSelectedFiles(s);
223 std::vector<std::string>::iterator i;
224 for (i=s.begin();i!=s.end();++i){
225 std::cout << *i << std::endl;
228 std::cout << "$$$$ "<<std::endl;
229 w.GetSelectedImages(images);
230 //selectedimage = images[0];
231 //crea::VtkBasicSlicer(images.front());
232 //images.front()->Delete();
234 }else if (w.GetReturnCode() == wxID_CANCEL){
235 vtkMetaImageReader *reader = vtkMetaImageReader::New();
236 reader->SetFileName( "data/hola.mhd" );
238 images.push_back(reader->GetOutput());
244 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(400,50), wxSize(800, 600) );
245 //frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(_T("")), wxPoint(50,50), wxSize(800, 600), images );
246 frame = wxContourMainFrame::getInstance(frame1, wxID_ANY, wxString(_T("")), wxPoint(200,50), wxSize(800, 600), images );
247 frame1->CreateStatusBar();
255 int main(int argc, char* argv[])
257 return WinMain(::GetModuleHandle(NULL), NULL,
258 ::GetCommandLine(), SW_SHOWNORMAL);