[go: up one dir, main page]

Menu

[r769]: / mia2 / gui / myocard.cc  Maximize  Restore  History

Download this file

179 lines (140 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Copyright (c) 2008 Gert Wollny
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <wx/wx.h>
#include <sstream>
#include <mia/2d/2dimageio.hh>
#include <mia/core.hh>
#include <gui/serieswindow.hh>
NS_MIA_USE;
using namespace std;
class CMyoCardApp: public wxApp {
public:
virtual bool OnInit();
};
class CMyoMainframe : public wxFrame {
public:
CMyoMainframe(const wxString& title);
// event handlers
void OnQuit(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
private:
DECLARE_EVENT_TABLE();
CSeriesPanel *panel;
};
DECLARE_APP(CMyoCardApp);
IMPLEMENT_APP_NO_MAIN(CMyoCardApp);
bool CMyoCardApp::OnInit()
{
CMyoMainframe *frame = new CMyoMainframe(wxT("Myocardial Perfusion Analysis"));
frame->Show(true);
return true;
}
BEGIN_EVENT_TABLE(CMyoMainframe, wxFrame)
EVT_MENU(wxID_ABOUT, CMyoMainframe::OnAbout)
EVT_MENU(wxID_OPEN, CMyoMainframe::OnOpen)
EVT_MENU(wxID_EXIT, CMyoMainframe::OnQuit)
END_EVENT_TABLE();
void CMyoMainframe::OnQuit(wxCommandEvent& event)
{
Close();
}
void CMyoMainframe::OnOpen(wxCommandEvent& event)
{
wxString caption = wxT("Choos a set of files");
const C2DImageIOPluginHandler::Instance& imageio = C2DImageIOPluginHandler::instance();
set<string> supported_types = imageio.get_set();
if (supported_types.empty()) {
wxString msg;
msg.Printf(wxT("No image types supported!"));
wxMessageBox(msg, wxT("Error"), wxOK | wxICON_ERROR, this);
return;
}
set<string>::const_iterator i = supported_types.begin();
wxString wildcard;
wxString s(i->c_str(), wxConvUTF8);
wildcard.append(s);
wildcard.append(wxT(" files (*."));
wildcard.append(s);
wildcard.append(wxT(")|*."));
wildcard.append(s);
++i;
for ( ; i != supported_types.end(); ++i) {
wxString s(i->c_str(), wxConvUTF8);
wildcard.append(wxT("|"));
wildcard.append(s);
wildcard.append(wxT(" files (*."));
wildcard.append(s);
wildcard.append(wxT(")|*."));
wildcard.append(s);
}
wxString defaultDir = wxT(".");
wxString defaultFilename = wxEmptyString;
wxFileDialog zelga(this, caption, defaultDir, defaultFilename, wildcard, wxMULTIPLE);
if (zelga.ShowModal() == wxID_OK) {
wxArrayString filenames;
zelga.GetPaths(filenames);
filenames.Sort();
C2DImageIOPluginHandler::Instance::PData all_images(new C2DImageIOPluginHandler::Instance::Data);
// open the files using the MIA interface
for (size_t i = 0; i < filenames.GetCount(); ++i) {
SetStatusText(filenames[i]);
string name(filenames[i].char_str());
cvmsg() << name << "\n";
C2DImageIOPluginHandler::Instance::PData in_image_list = imageio.load(name);
all_images->insert(all_images->end(), in_image_list->begin(), in_image_list->end());
}
panel->set_series(all_images);
stringstream msg;
msg << "Loaded " << all_images->size() << " frames";
SetStatusText(wxString(msg.str().c_str(), wxConvUTF8));
// redraw the viewer ...
}
}
void CMyoMainframe::OnAbout(wxCommandEvent& event)
{
wxString msg;
msg.Printf(wxT("This is a tool to analyse myocardial perfusion MRI series"));
wxMessageBox(msg, wxT("About"), wxOK | wxICON_INFORMATION, this);
}
CMyoMainframe::CMyoMainframe(const wxString& title):
wxFrame(NULL, wxID_ANY, title)
{
wxMenu *fileMenu = new wxMenu;
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"), wxT("Show abput dialog"));
fileMenu->Append(wxID_OPEN, wxT("&Open\tCtrl-O"), wxT("Open a set of images"));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, wxT("&Quit\tCtrl-Q"), wxT("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(fileMenu, wxT("&File"));
menuBar->Append(helpMenu, wxT("&Help"));
SetMenuBar(menuBar);
panel = new CSeriesPanel(this, wxID_ANY, wxT("the display"));
panel->Show();
CreateStatusBar(2);
SetStatusText(wxT("Welcome ..."));
}
int main(int argc, char **argv)
{
CCmdOptionList options;
options.parse(argc, argv);
// normally the next call should use the remaining arguments
wxEntry(argc, argv);
}