1 //----------------------------------------------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------------------------------------------
6 #include "wxContourGUIExample.h"
7 #include "wxContourMainFrame.h"
8 #include "OutlineModelManager.h"
9 #include "wxContourEventHandler.h"
11 #include "wxContourMainPanel.h"
13 #include "vtkMetaImageReader.h"
15 #include "vtkImageData.h"
16 #include "OutlineModelBuilder.h"
17 #include "ContourThing.h"
19 #include "ImageSourceThing.h"
20 #include "ImageSectionThing.h"
21 #include "SomeEnvironment.h"
22 #include "ReaderEnvironment.h"
24 #include "wx/artprov.h"
25 #include <wx/filedlg.h>
28 #include "interfMainPanel.h"
30 #include <creaImageIOWxGimmickDialog.h>
32 #include <creaVtkBasicSlicer.h>
34 wxContourMainFrame* wxTheApplication::frame = 0;
35 //----------------------------------------------------------------------------------------------------------------
36 // This macro implements the entry point (main function) for the application
37 //----------------------------------------------------------------------------------------------------------------
39 IMPLEMENT_APP( wxTheApplication );
41 wxContourGUIExample :: wxContourGUIExample(const wxString& title, const wxPoint& pos, const wxSize& size)
42 : wxFrame((wxFrame *) NULL, -1, title, pos, size)
47 bool wxTheApplication :: OnInit()
50 //-------------------------------------------------------------
51 // Doing what is done by the bbtk boxes
52 /*vtkMetaImageReader *reader = vtkMetaImageReader::New();
53 // reader->SetFileName( "data\\hola.mhd" );
54 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/img02.maracas.mhd" );
55 // reader->SetFileName( "C:/Program Files/bbtk-1.0/data/vtk/test01.maracas.mhd" );
56 // reader->SetFileName( "C:/download/Elise/Elise_IRM_Helium/A/test01b.maracas.mhd" );
58 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.mhd"), wxOPEN );
59 if (dialog.ShowModal() == wxID_OK)
61 std::string filename = (const char *)(dialog.GetPath().mb_str());
62 reader->SetFileName( filename.c_str() );
64 reader->SetFileName( "data\\hola.mhd" );
70 wxInitAllImageHandlers();
72 int image_type = GIMMICK_3D_IMAGE_SELECTION;
75 creaImageIO::WxGimmickDialog w(0,
77 _T("WxGimmickDialog test"),
84 vtkImageData* selectedimage=NULL;
85 if(w.GetReturnCode() == wxID_OK){
87 std::vector<std::string> s;
88 w.GetSelectedFiles(s);
89 std::vector<std::string>::iterator i;
90 for (i=s.begin();i!=s.end();++i){
91 std::cout << *i << std::endl;
94 std::cout << "$$$$ "<<std::endl;
95 std::vector<vtkImageData*> images;
96 w.GetSelectedImages(images);
97 selectedimage = images[0];
98 //crea::VtkBasicSlicer(images.front());
99 //images.front()->Delete();
101 }else if (w.GetReturnCode() == wxID_CANCEL){
102 vtkMetaImageReader *reader = vtkMetaImageReader::New();
103 reader->SetFileName( "data/hola.mhd" );
105 selectedimage = reader->GetOutput();
110 std::string conceptsFN = "data/holaConceptsFile.cf";
111 std::string imageSourcesFN = "data/holaImagesInstantsFile.of";
112 std::string imageSectionsFN = "";
113 std::string axeThingsFN = "";
115 std::map<std::string, ImageSourceThing *> * sourcesMap = new std::map<std::string, ImageSourceThing *>();
116 std::map<std::string, ImageSectionThing *>* sectionsMap = new std::map<std::string, ImageSectionThing *>();
117 std::map<std::string, AxeThing *>* axesMap = new std::map<std::string, AxeThing *>();
118 std::map<std::string, ContourThing *>* outlinesMap = new std::map<std::string, ContourThing *>();
120 ImageSourceThing * thing = new ImageSourceThing(selectedimage);
121 sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( "Source Image 1", thing));
123 OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN );
124 _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
125 _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
126 _builder->buildAxe_Envornment(axeThingsFN, axesMap );
127 _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
129 //-------------------------------------------------------------
131 /*frame = new wxContourMainFrame(_builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv(),NULL, wxID_ANY, wxT("ROI Application Sample"), wxPoint(50,50), wxSize(800, 600));
134 //Creating the evtHandler of the panels
135 wxContourEventHandler * eventHandler = new wxContourEventHandler();
137 //Creating the window that will show the panels
139 //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) );
140 wxFrame* frame1 = new wxFrame(NULL, wxID_ANY, wxT("ROI Application - Evaluation version, 23 Oct 2008 "), wxPoint(50,50), wxSize(800, 600) );
141 frame = new wxContourMainFrame( frame1, wxID_ANY, wxString(""), wxPoint(50,50), wxSize(800, 600) );
143 //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) );
144 frame1->CreateStatusBar();
146 //Getting the parent for the panels ( using aui )
147 wxAuiNotebook * parent = frame->createNotebook();
149 //Creating the objects to manage
150 OutlineModelManager * modelManager = new OutlineModelManager( _builder->getImSourceEnv(), _builder->getImSectionEnv(), _builder->getAxesEnv(), _builder->getContourEnv() );
152 wxInstantChooserPanel * instantPanel = new wxInstantChooserPanel( parent, "Instant Chooser", true );
153 ImageSourceThing * imageSource = modelManager->getImageSourceThingByKeyName( "Source Image 1" );
154 wxContourViewPanel * theViewPanel = new wxContourViewPanel( imageSource->getSourceImage(), parent );
155 //wxContour_ButtonsBar * buttons = new wxContour_ButtonsBar(frame, -1, wxDefaultPosition, wxDefaultSize);
157 eventHandler->setModelManager( modelManager );
158 eventHandler->setViewPanel( theViewPanel );
159 eventHandler->setInstantChooserPanel( instantPanel );
160 //eventHandler->setButtonsBar( buttons );
162 //buttons->Show(false);
164 bool successConfiuration = eventHandler->configureEventsHandling();
166 frame->setViewPanel( theViewPanel );
167 frame->setInstantChooserPanel( instantPanel );
169 // frame->setButtonsBar( buttons );
171 successConfiuration &= frame->configurePanels( parent );
174 //buttons->Show(false);
181 if ( successConfiuration )
186 // SetTopWindow(frame);
188 //JCP -- new Interface
189 interfMainPanel* pannew = interfMainPanel::getInstance(frame1, eventHandler);
191 //pannew->addContourCheckBox("contour1");
192 //pannew->addContourCheckBox("contour3");
193 //pannew->addContourCheckBox("contour2");
194 //pannew->addContourCheckBox("contour4");
195 //JCP -- new Interface
201 int main(int argc, char* argv[])
203 return WinMain(::GetModuleHandle(NULL), NULL,
204 ::GetCommandLine(), SW_SHOWNORMAL);