33 #include <Base/Common/W32Compat.hh>
37 #include <Gui/ImageCanvasRectangularSelection.hh>
38 #include <Base/Image/ImageIO.hh>
39 #include <Gui/StringConv.hh>
45 class MyApp:
public wxApp
47 virtual bool OnInit();
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);
61 void OnRect(wxCommandEvent& event);
63 virtual void RectangleSelected(
int tl[2],
int br[2]);
73 MyFrame *frame =
new MyFrame(
AsciiToWx(
"ImageCanvasRectangularSelection"), wxPoint(50,50),
80 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
81 EVT_MENU(
ID_Quit, MyFrame::OnQuit)
83 EVT_MENU(ID_Load, MyFrame::OnLoad)
84 EVT_MENU(ID_Rect, MyFrame::OnRect)
88 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
89 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
91 wxMenu *menuFile =
new wxMenu;
93 menuFile->Append( ID_About,
AsciiToWx(
"&About...") );
94 menuFile->Append( ID_Load,
AsciiToWx(
"&Load...") );
95 menuFile->Append( ID_Rect,
AsciiToWx(
"&Rect...") );
96 menuFile->AppendSeparator();
97 menuFile->Append( ID_Quit,
AsciiToWx(
"E&xit") );
99 wxMenuBar *menuBar =
new wxMenuBar;
100 menuBar->Append(menuFile,
AsciiToWx(
"&File") );
104 SetStatusText(
AsciiToWx(
"ImageName"), 0);
106 wxBoxSizer *box=
new wxBoxSizer(wxVERTICAL);
108 box->Add(_ic, 1, wxALL| wxGROW |wxALIGN_CENTER, 5);
109 box->SetSizeHints(
this);
113 const string fn(BIAS_TESTS_DATA
"r4.jpg" );
117 cout<<
"could not load "<<fn<<endl;
118 wxMessageBox(_T(
"could not load image. aborting. ") );
121 SetStatusText(_T(
"image"), 0);
122 _ic->Show(im,
"image" );
126 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
129 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
131 wxMessageBox(
AsciiToWx(
"This is a wxWidgtets Hello world sample"),
133 , wxOK | wxICON_INFORMATION,
this);
136 void MyFrame::OnLoad(wxCommandEvent& WXUNUSED(event))
140 if (fileDialog.ShowModal() == wxID_OK){
141 string fname=WxToAscii(fileDialog.GetPath());
144 BIASERR(
"error loading "<<fname);
146 SetStatusText(fileDialog.GetFilename(), 0);
147 _ic->Show(im, WxToAscii(fileDialog.GetFilename()));
150 cerr <<
"canceled loadin image" << endl;
154 void MyFrame::OnRect(wxCommandEvent& WXUNUSED(event))
156 _ic->SelectRectangle(*
this);
159 void MyFrame::RectangleSelected(
int tl[2],
int br[2])
161 cerr <<
"finished select rectangle: ("<<tl[0]<<
", "<<tl[1]<<
") <-> ("
162 <<br[0]<<
", "<<br[1]<<
")\n";
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
provides functionality for selection of rectangle, point, ...
callback interface for ImageCanvasExtended
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...