31 #include <Base/Common/W32Compat.hh>
35 #include <Gui/ScaledImageCanvas.hh>
36 #include <Gui/StringConv.hh>
37 #include <Base/Image/ImageIO.hh>
45 class MyApp:
public wxApp
47 virtual bool OnInit();
52 class MyFrame: public wxFrame
56 MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size);
58 void OnQuit(wxCommandEvent& event);
59 void OnAbout(wxCommandEvent& event);
60 void OnLoad(wxCommandEvent& event);
69 MyFrame *frame =
new MyFrame( wxT(
"ImageCanvas"), wxPoint(50,50),
73 BIASASSERT(frame!=NULL);
74 string filename(WxToAscii(argv[1]));
78 BIASERR(
"error loading "<<filename<<endl);
82 BIASASSERT(frame->_ic != NULL);
83 frame->_ic->Show(img, filename.c_str() );
84 cout<<
"loaded image file "<<filename<<
" successfully."<<endl;
93 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
94 EVT_MENU(
ID_Quit, MyFrame::OnQuit)
96 EVT_MENU(ID_Load, MyFrame::OnLoad)
100 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
101 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
103 wxMenu *menuFile =
new wxMenu;
105 menuFile->Append( ID_About, wxT(
"&About...") );
106 menuFile->Append( ID_Load, wxT(
"&Load...") );
107 menuFile->AppendSeparator();
108 menuFile->Append( ID_Quit, wxT(
"E&xit") );
110 wxMenuBar *menuBar =
new wxMenuBar;
111 menuBar->Append(menuFile, wxT(
"&File"));
116 SetStatusText(wxT(
"ImageName"), 0);
118 wxBoxSizer *box=
new wxBoxSizer(wxVERTICAL);
121 box->Add(_ic, 1, wxALL| wxGROW, 5);
122 box->SetSizeHints(
this);
126 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
129 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
131 wxMessageBox(wxT(
"This is a wxWidgets Hello world sample"),
132 wxT(
"About Hello World"), wxOK | wxICON_INFORMATION,
this);
135 void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event))
137 wxFileDialog fileDialog(
this, wxT(
"Choose a file"), wxT(
"."), wxT(
""));
138 if (fileDialog.ShowModal() == wxID_OK){
139 string fname=WxToAscii(fileDialog.GetPath());
142 BIASERR(
"error loading "<<fname<<
"\nshould a be float image");
144 SetStatusText(fileDialog.GetFilename().c_str(), 0);
145 _ic->Show(im, WxToAscii(fileDialog.GetFilename()));
148 cerr <<
"canceled loading image" << endl;
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
display float images in wx application, provides zoom, scale, shift and investigation functionality ...
This is the base class for images in BIAS.