firewatch/0002755000177200017720000000000010402063546012372 5ustar koflerkoflerfirewatch/icons/0002755000177200017720000000000010402065061013477 5ustar koflerkoflerfirewatch/icons/select.xpm0000644000177200017720000000256410402057615015517 0ustar koflerkofler/* XPM */ static char*select_xpm[]={ "32 32 13 1", "c c #c6c6c6", "e c #ff00ff", "k c #00ff00", "b c #000000", ". c #848484", "f c #ffff00", "d c #840000", "i c #0000ff", " c None", "j c #008400", "h c #000084", "a c #ffffff", "g c #ff0000", ".................... ", ".aaaaaaaaaaaaaaaaaa.b ", ".aaaaaaaaaaaaaaaaaa..b ", ".aaaaaaaacddddcaaaa.c.b ", ".aaaaaaacddddddcaaa.ac.b ", ".aaaaaaaddddddddaaa.aac.b ", ".aaaaaaad.dddd.daaabbbbbbb ", ".aaaaaaadefcc.gdaaaaaaaacb hh ", ".aaaaaaadcgggggdaaaaaaaacb hfhb", ".aaaaaaadcgggggd.......acb haihb", ".aaaaaaadcggggg.aaaaa..acbhaihb ", ".aaaaaaa.caggg.aaaaa.a.achfiib ", ".aaaaaaa.cagg.......aa.ahaiib ", ".aaaaaaa.caag.aaaaa.aa.haiib ", ".aaaaaaa.caaa.aaaaa.aahfiib ", ".aaa.jjjj.aaa.aaaaa.ahaiib ", ".aajjcfkkjjaa.aaaaa.haiihb ", ".a.jcfkkkkj...aaaaahfiihbb ", ".ajcfkkkkkjba.aaaahaiihbcb ", ".ajcfkkkkkjba....haiihbacb ", ".ajcfkkkkkjbaaaahfiihbaacb ", ".ajcfkkkkjjbaaa..iihbaaacb ", ".a.jcfkkjjb.aa.fcbbbaaaacb ", ".aajjjjjjbbaaa.fc.baaaaacb ", ".aaa.bbbb.aaa.cc..baaaaacb ", ".aaaaaaaaaaadcegdbaaaaaacb ", ".aaaaaaggggdgggdbaaaaaaacb ", ".aaaadgggdddbbbbaaaaaaaacb ", ".aaaaadddaaaaaaaaaaaaaaacb ", ".aaaaaaaaaaaaaaaaaaaaaaacb ", ".ccccccccccccccccccccccccb ", "bbbbbbbbbbbbbbbbbbbbbbbbbb "}; firewatch/icons/random.xpm0000644000177200017720000000150410402057615015511 0ustar koflerkofler/* XPM */ static char *random_xpm[] = { /* columns rows colors chars-per-pixel */ "22 22 9 1", " c black", ". c #000000006363", "X c navy", "o c #00000000C0C0", "O c blue", "+ c #808080808080", "@ c #A0A0A0A0A0A0", "# c #C0C0C0C0FFFF", "$ c None", /* pixels */ "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$@+oOO@$$$$$$$$", "$$$$$$$+ooooOOO@$$$$$$", "$$$$$$+XX+$$$$@O$$$$$$", "$$$$$$XX+$$$$$$$$$$$$$", "$$$$$XXX$$$$$$$.$$$$$$", "$$$.......$$$$...$$$$$", "$$$$.....$$$$.....$$$$", "$$$$$...$$$$.......$$$", "$$$$$$.$$$$$$$XXX$$$$$", "$$$$$$$$$$$$$+XX$$$$$$", "$$$$$$O@$$$$+XX+$$$$$$", "$$$$$$#OOOoooo+$$$$$$$", "$$$$$$$$@OOo+@$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$", "$$$$$$$$$$$$$$$$$$$$$$" }; firewatch/icons/stock_new-labels-24.xpm0000644000177200017720000000326110402057615017712 0ustar koflerkofler/* XPM */ static char * stock_new_labels_24_xpm[] = { "24 24 65 1", " c None", ". c #000000", "+ c #FFFFFF", "@ c #E9E9E9", "# c #CFCFCF", "$ c #858585", "% c #B5B5B5", "& c #8C8C8C", "* c #939393", "= c #B9B9B9", "- c #D8D8D8", "; c #DBDBDB", "> c #DFDFDF", ", c #E2E2E2", "' c #E6E6E6", ") c #EDEDED", "! c #D3D3D3", "~ c #D6D6D6", "{ c #DADADA", "] c #DDDDDD", "^ c #D7D7D7", "/ c #D0D0D0", "( c #E8E8E8", "_ c #EBEBEB", ": c #EFEFEF", "< c #929292", "[ c #9A9A9A", "} c #B1B1B1", "| c #ACACAC", "1 c #8F8F8F", "2 c #BABABA", "3 c #919191", "4 c #898989", "5 c #C3C3C3", "6 c #F1F1F1", "7 c #DEDEDE", "8 c #C6C6C6", "9 c #C7C7C7", "0 c #C1C1C1", "a c #E1E1E1", "b c #E5E5E5", "c c #ECECEC", "d c #F3F3F3", "e c #E0E0E0", "f c #979797", "g c #8E8E8E", "h c #B2B2B2", "i c #B8B8B8", "j c #E4E4E4", "k c #E7E7E7", "l c #EAEAEA", "m c #EEEEEE", "n c #F5F5F5", "o c #D1D1D1", "p c #D4D4D4", "q c #F0F0F0", "r c #F7F7F7", "s c #BDBDBD", "t c #C0C0C0", "u c #C9C9C9", "v c #CDCDCD", "w c #E3E3E3", "x c #D2D2D2", "y c #A0A0A0", "z c #969696", " ", " ............... ", " .++++++++++++++@. ", " .+#$%&*=-;>,'@);. ", " .+####!~{]^/(_:]... ", " .+#<&[}|12345)67.+@. ", " .+#890^;7ab(c:de.);. ", " .+#fgh%iejklm6n,.:]. ", " .+#op-;>,'@)qdrj.67.. ", " .@st59uv/!~{]ewx.de.. ", " ...............yn,.. ", " .+#op-;>,'@)qdrj.. ", " .@st59uv/!~{]ewx.. ", " ...............z. ", " .+#op-;>,'@)qdrj. ", " .@st59uv/!~{]ewx. ", " ................. ", " .@st59uv/!~{]ewx. ", " ................. ", " .@st59uv/!~{]ewx. ", " ................. ", " .@st59uv/!~{]ewx. ", " ............... ", " "}; firewatch/icons/browse.xpm0000644000177200017720000000300410402057615015527 0ustar koflerkofler/* XPM */ static char *browse_xpm[] = { /* width height num_colors chars_per_pixel */ " 32 32 16 1", /* colors */ ". c #ffffff", "# c #fffbf0", "a c #c0c0c0", "b c #ffff99", "c c #ffcc99", "d c #868686", "e c #00ffff", "f c #008080", " c None", "h c #0000ff", "i c #000080", "j c #cccc66", "k c #999900", "l c #808000", "m c #333300", "n c #040404", /* pixels */ " ", " kkkkkkkkk ", " k.bbbbbbbbk ", " k.bbbbbbbbbbk ", " k#bbbbbbbbbbbbk ", "kjjjjjjjjjjjjjjjkkkkkkkkkkkkkk ", "k.............................n ", "k.bbbbbccddddnllbbbbbcbbcbbbcbjm", "k.bbbbcddaeaednndcbcbbbcbbbcbcjm", "k.bbbcda.e.e.eafndbbbbcbbccbbbjm", "k.bbcda.e.e.eaeafnlbcbbbcbbbbcjm", "k.bbcd.e...eaeaeanlcbbbbbcbcbcjm", "k.bbdae...eaeaeaefndcbcbcbbbcbjm", "k.bbde.e..aeaeaeafnlbbbcbbccbcjm", "k.bbdae..aeaeaeaefndbcbbcbbbcbjm", "k.bbde.e.eaeaeaeafnlcbcbbccbbcjm", "k.bbdae.eaeaeaeaefndbbbbcbbccbjm", "k.bbcdae.eaeaeaefndccbccbcccbcjm", "k.bbcdfaeaeaeaeffnlbbcbbcbbcccjm", "k.bbbcdfaeaeaeffndnccbccbccbcbjm", "k.bcbbcnnfffffnnaddncccccbccccjm", "k.bbbbbccnnnnnda.adhncbbccccbcjm", "k.bbcbcbbccccccda.ehhnccbcbbccjm", "k.cbbbbbcbbccbbcdheehhncccccccjm", "k.bbbcbcbbcbbccbciheehhncbccccjm", "k.cbcbcbbcbcbbbcbciheehhncccbcjm", "kjjjjjjjjjjjjjjjjjkiheehhmjjjjjm", " mmmmmmmmmmmmmmmmmnniheehhmmmmm ", " iheehhn ", " iheehn ", " ihehn ", " nnn "}; firewatch/icons/retrieveSimilar.bmp0000644000177200017720000000443610402057615017360 0ustar koflerkoflerBM j(4!´  ÿÿÿúù÷ø÷ôóóóñìéñïçìììïìäëäàäääíéßäàÜèä×åÜÖá×ÐãÝÌàÙÇÛÛÛÓÓÓßÕÍÝ×ÃÕÑÇÛÏÇ×ÊÁËËËÃÃÃÛÔ¿ÓźÕ̳Ñ·ÆÁ¾ÒɯÐÇ«Îħͽ±Ê¿ŸÎ¹–Ź—Á´Â¬ƒ»»»³³³¬¬¬¤¤¤¿«œ»¥•»­„£Ÿœ¡ž–µŒ±˜†²“…®•‚œœœ›—””””˜•“Œ…‹‹‹Š†ƒƒƒƒ¿©~¼¦y¹£u· p¶Ÿp«}ªŠy©ˆw¦Šu¨‡v¦„s´œk°™f«šg®–b£n‡…}Ÿj«“]¦”_ž…H›‚C¡l}{~gšva˜t^–q[”oX“nVlQiNŒeK‰bF‡`D‡_D˜?•~=“x5‘v2Žv2s.…j ‚Z<€W9„jg{{{|txtqtttuskkkkkiadddda^b_W[[[ZVTSSSXUMKKKNJEDDD}a{_y] w[ vZrUC?<B?7<<<33353++++%%%ƒƒƒƒƒƒƒƒƒƒ4jjjjjjjjjiDŠŒŒŒŒŒŒŒŒŒ‡ƒƒƒƒƒƒƒƒƒƒƒƒ4jjjjjjjjjjjiŠŠŠŠŠŠŠŠŠŠŠ ƒƒƒƒƒƒƒƒƒƒƒƒOjjjjjjjjjjjj*‰‰‰‰‰‰‰‰‰‰‰ #ƒƒƒƒƒƒƒƒƒƒƒƒOjjjjjjjjjjjj)‡‡‡‡‡‡‡‡‡‡‡ #ƒƒƒƒƒƒƒƒƒƒƒƒOjjjjjjjjjjjj)†††‡†‡††††† #@@eA@@bI@@ƒQ?OYHHijHHHHHHi,,"((m{w(({(m5+*#g$$P$$$I$$$ƒƒƒOM33_j333333^jjj1(5ymy+yyyt#~??e@??S@@?ƒƒƒROYGHijGGHHGHijijj((mwr((w((=wtwt#ƒƒƒƒƒƒƒƒƒƒƒƒbOjjjjjjjjijij]irttrttrtrrr)t#€@@eB@@bI@@ƒcOYHHijGGMHHHi1j*)=rp)*r*); r#g$$P$$$I$$$ƒbOM33_j333333^,j5p;p+p#e$#P$$$I$$$ƒcOH33_j333333^,j((5p;((m((+m#ƒƒƒƒƒƒƒƒƒƒƒƒcOjjjjjjjjjjjj,j============#ƒƒƒƒƒƒƒƒƒƒƒƒbOjjjjjjjjjjjj,j=========;;=#€@@eB@@bI@@ƒcOYHHijHHMHHHi,j++7;;++;++7;#g$$P$$$I$$$ƒbOH33_j333333^,j++5;7++7++5;#ƒƒƒƒƒƒƒƒƒƒƒƒcOjjjjjjjjjjjj,j555555555555#ƒƒƒƒƒƒƒƒƒƒƒƒbOijjjjjjjjjjj,j5+++55++5+++!€@AeI@IcJ@IƒcOZHTijHHTHHMa,j775++77+775+#e$$P$$$I$$$ƒbOH33_j333333^,j ==5*+==*==7)#~>>c?>>S@>>ƒcOYDGijDDGDDHi,j =;+)*;;);=+)#ƒƒƒƒƒƒƒƒƒƒƒƒcVjjjjjjjjjjjj-j (()())(((()(#ƒƒƒƒƒƒƒƒƒƒƒƒSOijjjjjjjjjijOj ((((((((((( (#g$$P$$$I$$$ƒ€€cOM33_j333333^]jjjrr7*rrrr;#~>>c?>>S@>>ƒƒƒOXDGijDDGDDHijijVpr*(rrpr+#ƒƒƒƒƒƒƒƒƒƒƒƒ~kOjjjjjjjjjjji\\H#g$$P$$$I$$$ƒOH33_j333333^}};)}}}{=#g$$P$$$I$$$ƒOH33_j333333^†}; )}} }†= ~''c>''R?''ƒOXDDijDDDDDDiy{* {y {y+ƒƒƒƒƒƒƒƒƒƒƒƒCjjjjjjjjjjjj  ƒƒƒƒƒƒƒƒƒƒDjjjjjjjjjiMfirewatch/SelectDialog.cc0000644000177200017720000003055410402057615015245 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ // Generated by DialogBlocks (Personal Edition), Di 31 Jan 2006 14:34:02 CET #if defined(__GNUG__) && !defined(__APPLE__) #pragma implementation "SelectDialog.h" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif ////@begin includes ////@end includes #include "SelectDialog.h" #include "RootFrame.h" #include ////@begin XPM images ////@end XPM images /*! * SelectDialog type definition */ IMPLEMENT_DYNAMIC_CLASS( SelectDialog, wxDialog ) /*! * SelectDialog event table definition */ BEGIN_EVENT_TABLE( SelectDialog, wxDialog ) ////@begin SelectDialog event table entries EVT_CLOSE( SelectDialog::OnCloseWindow ) EVT_IDLE( SelectDialog::OnIdle ) EVT_MOUSE_EVENTS( SelectDialog::OnMouse ) EVT_SLIDER( ID_SLIDER_SELECTION, SelectDialog::OnZoom ) EVT_BUTTON( ID_CLEAR_SELECTION, SelectDialog::OnClearSelection ) EVT_BUTTON( ID_SEND_SELECTION, SelectDialog::OnSendSelection ) EVT_BUTTON( ID_BUTTON3, SelectDialog::OnExit ) ////@end SelectDialog event table entries END_EVENT_TABLE() /*! * SelectDialog constructors */ SelectDialog::SelectDialog( ) { } SelectDialog::SelectDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { Create(parent, id, caption, pos, size, style); } /*! * SelectDialog creator */ bool SelectDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin SelectDialog member initialisation selectCanvas = NULL; zoomSlider = NULL; ////@end SelectDialog member initialisation ////@begin SelectDialog creation SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); ////@end SelectDialog creation rootFrame = (RootFrame*) parent; return TRUE; } /*! * Control creation for SelectDialog */ void SelectDialog::CreateControls() { ////@begin SelectDialog content construction // Generated by DialogBlocks, Do 09 Feb 2006 17:10:53 CET (Personal Edition) SelectDialog* itemDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); selectCanvas = new SelectCanvas( itemDialog1, ID_SELECTCANVAS, wxDefaultPosition, wxSize(500, 400), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); itemBoxSizer2->Add(selectCanvas, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); selectCanvas->SetScrollbars(1, 1, 0, 0); wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_RIGHT|wxALL, 0); wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("-"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); zoomSlider = new wxSlider( itemDialog1, ID_SLIDER_SELECTION, 100, 5, 200, wxDefaultPosition, wxSize(150, 15), wxNO_BORDER ); itemBoxSizer4->Add(zoomSlider, 0, wxALIGN_CENTER_VERTICAL, 0); wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("+"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2); wxButton* itemButton9 = new wxButton( itemDialog1, ID_CLEAR_SELECTION, _("Clear Selection"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer8->Add(itemButton9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2); wxButton* itemButton10 = new wxButton( itemDialog1, ID_SEND_SELECTION, _("Send Selection"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer8->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2); itemBoxSizer8->Add(40, 5, 0, wxGROW|wxALL, 5); wxButton* itemButton12 = new wxButton( itemDialog1, ID_BUTTON3, _("exit"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer8->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2); ////@end SelectDialog content construction } /*! * Should we show tooltips? */ bool SelectDialog::ShowToolTips() { return TRUE; } /*! * Get bitmap resources */ wxBitmap SelectDialog::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin SelectDialog bitmap retrieval return wxNullBitmap; ////@end SelectDialog bitmap retrieval } /*! * Get icon resources */ wxIcon SelectDialog::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin SelectDialog icon retrieval return wxNullIcon; ////@end SelectDialog icon retrieval } /*! * All mouse events event handler for ID_SCROLLEDWINDOW */ void SelectDialog::OnMouse( wxMouseEvent& event ) { // this method is left intentionally blank ;) // moved to SelectCanvas::OnMouse ; } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON */ void SelectDialog::OnClearSelection( wxCommandEvent& event ) { selectCanvas->clearSelection(); Refresh(); } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 */ void SelectDialog::OnSendSelection( wxCommandEvent& event ) { wxString newFile = selectCanvas->getSelectedImageName(); if (newFile.IsEmpty()) { wxMessageBox(_("Selection could not be sent!\nDo you have enough access rights in the Fire image folder?")); } else { rootFrame->sendNewImage(newFile); } } /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 */ void SelectDialog::OnExit( wxCommandEvent& event ) { Show(false); } /*! * wxEVT_CLOSE_WINDOW event handler for ID_DIALOG */ void SelectDialog::OnCloseWindow( wxCloseEvent& event ) { ////@begin wxEVT_CLOSE_WINDOW event handler for ID_DIALOG in SelectDialog. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_CLOSE_WINDOW event handler for ID_DIALOG in SelectDialog. } /*! * wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER */ void SelectDialog::OnZoom( wxCommandEvent& event ) { selectCanvas->updateZoom((float) zoomSlider->GetValue()/100.f); } /*! * wxEVT_IDLE event handler for ID_DIALOG */ void SelectDialog::OnIdle( wxIdleEvent& event ) { if(selectCanvas->hasSelection()) { FindWindow(ID_CLEAR_SELECTION)->Enable(); FindWindow(ID_SEND_SELECTION)->Enable(); } else { FindWindow(ID_CLEAR_SELECTION)->Enable(false); FindWindow(ID_SEND_SELECTION)->Enable(false); } } BEGIN_EVENT_TABLE( SelectCanvas, wxScrolledWindow ) EVT_MOUSE_EVENTS( SelectCanvas::OnMouse ) EVT_PAINT( SelectCanvas::OnPaint ) END_EVENT_TABLE() SelectCanvas::SelectCanvas(wxWindow* _parent, wxWindowID id,const wxPoint& pos, const wxSize& size, const long style) : wxScrolledWindow(_parent, id, pos, size, style) { parent = 0; parent = (SelectDialog*)_parent; selecting = false; selected = false; startPoint.x = 0; startPoint.y = 0; currentPoint.x = 0; currentPoint.y = 0; endPoint.x = 0; endPoint.y = 0; } void SelectCanvas::setFireItem(const FireItem& item) { clearSelection(); fireItem = item; fireItem.setScale(1.f); SetVirtualSize(fireItem.getThumbnail().GetWidth(), fireItem.getThumbnail().GetHeight()); Refresh(); } void SelectCanvas::updateZoom(float scale) { //selected = false; fireItem.setScale(scale); SetVirtualSize(fireItem.getThumbnail().GetWidth(), fireItem.getThumbnail().GetHeight()); Refresh(); } void SelectCanvas::clearSelection() { selected = false; startPoint.x = 0; startPoint.y = 0; endPoint.x = 0; endPoint.y = 0; } wxString SelectCanvas::getSelectedImageName() { if (!selected) return wxString(wxT("")); wxRect selection(startPoint, endPoint); wxImage subimage = fireItem.getImage().GetSubImage(selection); wxString pathname = fireItem.getName().BeforeLast(wxFILE_SEP_PATH); wxString filename = fireItem.getName().AfterLast(wxFILE_SEP_PATH); wxString suffix = filename.AfterLast(wxFILE_SEP_EXT); wxString base = filename.BeforeLast(wxFILE_SEP_EXT); // save in Fire folder, it goes there anyway wxString newFilename = pathname + wxFILE_SEP_PATH + base + wxT("part") + wxFILE_SEP_EXT + suffix; // if the file cannot be saved, return empty string if(!subimage.SaveFile(newFilename)) return wxString(wxT("")); return newFilename; } void SelectCanvas::OnMouse( wxMouseEvent& event ) { wxClientDC dc(this); DoPrepareDC(dc); // Take into account scrolling currentPoint = event.GetLogicalPosition(dc); // restrict selection to actual image! if (currentPoint.x < 0) currentPoint.x = 0; else if (currentPoint.x > fireItem.getThumbnail().GetWidth()) currentPoint.x = fireItem.getThumbnail().GetWidth(); if (currentPoint.y < 0) currentPoint.y = 0; else if (currentPoint.y > fireItem.getThumbnail().GetHeight()) currentPoint.y = fireItem.getThumbnail().GetHeight(); currentPoint.x = (int) (((float)currentPoint.x) / fireItem.getScale()); currentPoint.y = (int) (((float)currentPoint.y) / fireItem.getScale()); int viewStartX, viewStartY ; GetViewStart(&viewStartX, &viewStartY); if (event.GetWheelRotation()<0){ Scroll(-1,viewStartY+50); } if (event.GetWheelRotation()>0){ Scroll(-1,viewStartY-50); } if (event.Dragging() && event.LeftIsDown()) { if (selected) selected = false; if (!selecting) { selecting = true; startPoint = currentPoint; } else { if ((event.GetX() > GetClientSize().GetWidth()) && (currentPoint.x < fireItem.getThumbnail().GetWidth())){ Scroll(viewStartX+10,-1); } if ((event.GetY() > GetClientSize().GetHeight()) && (currentPoint.y < fireItem.getThumbnail().GetHeight())){ Scroll(-1,viewStartY+10); } if ((event.GetX() < 0) && (currentPoint.x >= 0)){ if(viewStartX>=10) Scroll(viewStartX-10,-1); else Scroll(0,-1); } if ((event.GetY() < 0 ) && (currentPoint.y >= 0)){ if(viewStartY>=10) Scroll(-1,viewStartY-10); else Scroll(-1,0); } Refresh(); } } else if (event.LeftUp()) { if (selecting) { selecting = false; endPoint = currentPoint; selected = true; Refresh(); } } } void SelectCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); PrepareDC(dc); dc.DrawBitmap(fireItem.getThumbnail(), 1, 1); dc.SetBrush(*wxTRANSPARENT_BRUSH); if (selecting) { wxPen* tmpLine = new wxPen (*wxRED, 1, wxSHORT_DASH); dc.SetPen(*tmpLine); // dc.DrawRectangle(startPoint.x, startPoint.y, currentPoint.x - startPoint.x, currentPoint.y - startPoint.y); dc.DrawRectangle((int) (((float)startPoint.x) * fireItem.getScale()), (int) (((float)startPoint.y) * fireItem.getScale()), (int) (((float)(currentPoint.x - startPoint.x)) * fireItem.getScale()), (int) (((float)(currentPoint.y - startPoint.y)) * fireItem.getScale())); delete tmpLine; } if (selected) { dc.SetPen(*wxRED_PEN); dc.DrawRectangle((int) (((float)startPoint.x) * fireItem.getScale()), (int) (((float)startPoint.y) * fireItem.getScale()), (int) (((float)(endPoint.x - startPoint.x)) * fireItem.getScale()), (int) (((float)(endPoint.y - startPoint.y)) * fireItem.getScale())); } } firewatch/.cdtproject0000644000177200017720000000660210402057615014536 0ustar koflerkofler make all true true make run false true make clean false true firewatch/firewatch.rc0000644000177200017720000000007010402057615014667 0ustar koflerkofler#ifndef APSTUDIO_INVOKED #include "wx/msw/wx.rc" #endif firewatch/RootFrame.cc0000644000177200017720000004471510402057615014610 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ // Generated by DialogBlocks (Personal Edition), Do 26 Jan 2006 14:22:16 CET #if defined(__GNUG__) && !defined(__APPLE__) #pragma implementation "RootFrame.h" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif ////@begin includes ////@end includes #include #include using namespace std; #include "RootFrame.h" #include "thumbnailctrl.h" #include "thumbnaildlg.h" #include "FireWatch.h" #include "FireItem.h" ////@begin XPM images #include "icons/random.xpm" #include "icons/stock_new-labels-24.xpm" #include "icons/browse.xpm" #include "icons/select.xpm" ////@end XPM images /*! * RootFrame type definition */ IMPLEMENT_CLASS( RootFrame, wxFrame ) /*! * RootFrame event table definition */ BEGIN_EVENT_TABLE( RootFrame, wxFrame ) ////@begin RootFrame event table entries EVT_IDLE( RootFrame::OnIdle ) EVT_MENU( MENU_FILE_LOAD, RootFrame::OnMenuFileLoad ) EVT_MENU( MENU_FILE_EXIT, RootFrame::OnMenuFileExitClick ) EVT_MENU( ID_MENUSETTINGS_SERVER, RootFrame::OnMenuSettingsServer ) EVT_MENU( ID_MENU, RootFrame::OnMenuClick ) EVT_MENU( ToolBarRandom, RootFrame::OnRandom ) EVT_MENU( ToolBarRetrieve, RootFrame::OnToolbarRetrieveSimilar ) EVT_MENU( ToolBarBrowse, RootFrame::OnToolbarBrowseClick ) EVT_MENU( ToolBarSelect, RootFrame::OnToolbarSelect ) EVT_SPINCTRL( ID_SPINCTRL, RootFrame::OnFireResultsUpdated ) EVT_SLIDER( ID_SLIDER, RootFrame::OnZoom ) ////@end RootFrame event table entries EVT_THUMBNAIL_ITEM_SELECTED(wxID_ANY, RootFrame::OnItemSelect) EVT_THUMBNAIL_ITEM_DESELECTED(wxID_ANY, RootFrame::OnItemDeSelect) EVT_THUMBNAIL_LEFT_CLICK(wxID_ANY, RootFrame::OnItemClick) EVT_THUMBNAIL_LEFT_DCLICK(wxID_ANY, RootFrame::OnItemDoubleClick) EVT_THUMBNAIL_RIGHT_CLICK(wxID_ANY, RootFrame::OnItemRightClick) EVT_CONTEXT_MENU(RootFrame::OnItemContextClick) END_EVENT_TABLE() /*! * RootFrame constructors */ RootFrame::RootFrame( ) { } RootFrame::RootFrame( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { Create( parent, id, caption, pos, size, style ); } /*! * RootFrame creator */ bool RootFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin RootFrame member initialisation fireResultCount = NULL; scrolledWindow = NULL; zoomSlider = NULL; ////@end RootFrame member initialisation ////@begin RootFrame creation wxFrame::Create( parent, id, caption, pos, size, style ); CreateControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); ////@end RootFrame creation browseDialog = 0; selectDialog = 0; selectedItem = 0; scaleFactor = (float) zoomSlider->GetValue()/100.f; return TRUE; } /*! * Control creation for RootFrame */ void RootFrame::CreateControls() { ////@begin RootFrame content construction // Generated by DialogBlocks, Do 16 Feb 2006 16:25:18 CET (Personal Edition) RootFrame* itemFrame1 = this; wxMenuBar* menuBar = new wxMenuBar; wxMenu* itemMenu3 = new wxMenu; itemMenu3->Append(MENU_FILE_LOAD, _("Load ..."), _T(""), wxITEM_NORMAL); itemMenu3->Append(ID_MENU_CONNECT, _("Connect Fire servers ..."), _T(""), wxITEM_NORMAL); itemMenu3->AppendSeparator(); itemMenu3->Append(MENU_FILE_EXIT, _("Exit"), _T(""), wxITEM_NORMAL); menuBar->Append(itemMenu3, _("File")); wxMenu* itemMenu8 = new wxMenu; itemMenu8->Append(ID_MENUSETTINGS_SERVER, _("Server settings"), _T(""), wxITEM_NORMAL); menuBar->Append(itemMenu8, _("Settings")); wxMenu* itemMenu10 = new wxMenu; itemMenu10->Append(ID_MENU, _("About FireWatch"), _T(""), wxITEM_NORMAL); menuBar->Append(itemMenu10, _("Help")); itemFrame1->SetMenuBar(menuBar); wxToolBar* itemToolBar12 = CreateToolBar( wxTB_FLAT|wxTB_HORIZONTAL, ID_TOOLBAR1 ); wxBitmap itemtool13Bitmap(itemFrame1->GetBitmapResource(wxT("icons/random.xpm"))); itemToolBar12->AddTool(ToolBarRandom, _("random"), itemtool13Bitmap, wxNullBitmap, wxITEM_NORMAL, _("get random images"), _("get random images")); itemToolBar12->AddSeparator(); wxBitmap itemtool15Bitmap(itemFrame1->GetBitmapResource(wxT("icons/stock_new-labels-24.xpm"))); itemToolBar12->AddTool(ToolBarRetrieve, _("retrieveSimilar"), itemtool15Bitmap, _("retrieve similar"), wxITEM_NORMAL); itemToolBar12->AddSeparator(); wxBitmap itemtool17Bitmap(itemFrame1->GetBitmapResource(wxT("icons/browse.xpm"))); itemToolBar12->AddTool(ToolBarBrowse, _("browse"), itemtool17Bitmap, wxNullBitmap, wxITEM_NORMAL, _("browse local file system"), _("browse local file system")); itemToolBar12->AddSeparator(); wxBitmap itemtool19Bitmap(itemFrame1->GetBitmapResource(wxT("icons/select.xpm"))); itemToolBar12->AddTool(ToolBarSelect, _("select"), itemtool19Bitmap, wxNullBitmap, wxITEM_NORMAL, _("select an image region"), _("select an image region")); itemToolBar12->AddSeparator(); wxStaticText* itemStaticText21 = new wxStaticText( itemToolBar12, wxID_STATIC, _("results: "), wxDefaultPosition, wxDefaultSize, 0 ); itemToolBar12->AddControl(itemStaticText21); fireResultCount = new wxSpinCtrl( itemToolBar12, ID_SPINCTRL, _T("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 1 ); fireResultCount->SetHelpText(_("number of Fire results")); if (ShowToolTips()) fireResultCount->SetToolTip(_("number of Fire results")); itemToolBar12->AddControl(fireResultCount); itemToolBar12->Realize(); itemFrame1->SetToolBar(itemToolBar12); wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL); itemFrame1->SetSizer(itemBoxSizer23); scrolledWindow = new wxThumbnailCtrl( itemFrame1, ID_SCROLLEDWINDOW1, wxDefaultPosition, wxSize(750, 550), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); itemBoxSizer23->Add(scrolledWindow, 1, wxGROW|wxALL, 5); scrolledWindow->SetScrollbars(1, 1, 1000, 1000); wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer23->Add(itemBoxSizer25, 0, wxALIGN_RIGHT|wxALL, 5); wxStaticText* itemStaticText26 = new wxStaticText( itemFrame1, wxID_STATIC, _("-"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer25->Add(itemStaticText26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); zoomSlider = new wxSlider( itemFrame1, ID_SLIDER, 40, 10, 100, wxDefaultPosition, wxSize(150, 15), wxNO_BORDER ); itemBoxSizer25->Add(zoomSlider, 0, wxALIGN_CENTER_VERTICAL, 0); wxStaticText* itemStaticText28 = new wxStaticText( itemFrame1, wxID_STATIC, _("+"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer25->Add(itemStaticText28, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); ////@end RootFrame content construction // Create custom windows not generated automatically here. ////@begin RootFrame content initialisation ////@end RootFrame content initialisation } void RootFrame::initFireWatch(wxString host, unsigned short port) { firewatch.setServer(host, port); firewatch.initialize(); fireResultCount->SetValue(firewatch.getResultCount()); } void RootFrame::sendNewImage(wxString imageName) { std::vector& results = firewatch.retrieve(imageName, true, true); if (results.empty()) { wxMessageBox(_("something went wrong...\nMaybe you don't have enough access rights in the Fire image folder?")); } else { selectedItem = 0; displayFireResults(results); } } void RootFrame::displayFireResults(std::vector& results) { scrolledWindow->Freeze(); scrolledWindow->Clear(); wxString path = firewatch.getPath(); int maxX = 0; int maxY = 0; for (unsigned int i = 0; i < results.size(); ++i) { // compose full path to image results[i].setName(path + wxFILE_SEP_PATH + results[i].getName()); FireItem* tmpItem = new FireItem(results[i].getName(), scaleFactor); wxSize tmpSize = tmpItem->DoGetBestSize(); if (maxX < tmpSize.x) maxX = tmpSize.x; if (maxY < tmpSize.y) maxY = tmpSize.y; scrolledWindow->Append(tmpItem); } scrolledWindow->SetThumbnailImageSize(wxSize(maxX, maxY)); scrolledWindow->Thaw(); } /*! * Should we show tooltips? */ bool RootFrame::ShowToolTips() { return TRUE; } /*! * Get bitmap resources */ wxBitmap RootFrame::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin RootFrame bitmap retrieval wxUnusedVar(name); if (name == _T("icons/random.xpm")) { wxBitmap bitmap(random_xpm); return bitmap; } else if (name == _T("icons/stock_new-labels-24.xpm")) { wxBitmap bitmap( stock_new_labels_24_xpm); return bitmap; } else if (name == _T("icons/browse.xpm")) { wxBitmap bitmap(browse_xpm); return bitmap; } else if (name == _T("icons/select.xpm")) { wxBitmap bitmap(select_xpm); return bitmap; } return wxNullBitmap; ////@end RootFrame bitmap retrieval } /*! * Get icon resources */ wxIcon RootFrame::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin RootFrame icon retrieval wxUnusedVar(name); return wxNullIcon; ////@end RootFrame icon retrieval } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for Random */ void RootFrame::OnRandom( wxCommandEvent& event ) { std::vector& results = firewatch.getRandomImages(); selectedItem = 0; displayFireResults(results); } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for MENU_FILE_LOAD */ void RootFrame::OnMenuFileLoad(wxCommandEvent & event) { // show browse dialog if (browseDialog == 0) { browseDialog = new wxThumbnailBrowserDialog(this, wxID_ANY); wxString initialPath = wxGetCwd(); if (wxDirExists(initialPath)) browseDialog->SetSelection(initialPath); } if (wxID_OK == browseDialog->ShowModal()) { wxString sel = browseDialog->GetSelection(); if (sel.IsEmpty()) return; // copy image to fire folder -> check access rights wxString filename = sel.AfterLast(wxFILE_SEP_PATH); wxString newFilename = firewatch.getPath() + wxFILE_SEP_PATH + filename; // check if file already exists /*if (wxFileExists(newFilename)) { wxMessageBox(_("a file with this name already exists!")); return; }*/ // copy image into Fire location and check if it worked if (!wxCopyFile(sel, newFilename, false)) { wxMessageBox(_("could not upload image!\nDo you have enough access rights in the Fire image folder?")); return; } std::vector& results = firewatch.retrieve(newFilename, true, true); if (results.empty()) { wxMessageBox(_("something went wrong...\nMaybe you don't have enough access rights in the Fire image folder?")); } else { selectedItem = 0; displayFireResults(results); } } } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for MENU_FILE_EXIT */ void RootFrame::OnMenuFileExitClick(wxCommandEvent & event) { Close(TRUE); } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU */ void RootFrame::OnMenuClick( wxCommandEvent& event ) { ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU in RootFrame. // Before editing this code, remove the block markers. wxMessageBox(_("FireWatch: GUI for the Flexible Image Retrieval Engine")); ////@end wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU in RootFrame. } /*! * wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER */ void RootFrame::OnZoom( wxCommandEvent& event ) { scaleFactor = (float) zoomSlider->GetValue()/100.f; scrolledWindow->Freeze(); int maxX = 0; int maxY = 0; for(int i=0; i < scrolledWindow->GetCount(); ++i) { FireItem* tmpItem = (FireItem*) scrolledWindow->GetItem(i); tmpItem->setScale(scaleFactor); wxSize tmpSize = tmpItem->DoGetBestSize(); if (maxX < tmpSize.x) maxX = tmpSize.x; if (maxY < tmpSize.y) maxY = tmpSize.y; } scrolledWindow->SetThumbnailImageSize(wxSize(maxX, maxY)); scrolledWindow->Thaw(); } void RootFrame::OnItemSelect(wxThumbnailEvent& event) { selectedItem = (FireItem*) scrolledWindow->GetItem(event.GetIndex()); GetToolBar()->EnableTool(ToolBarSelect, true); GetToolBar()->EnableTool(ToolBarRetrieve, true); } void RootFrame::OnItemDeSelect(wxThumbnailEvent& event) { selectedItem = 0; } void RootFrame::OnItemClick(wxThumbnailEvent& event) { // int itemID = event.GetIndex(); } void RootFrame::OnItemDoubleClick(wxThumbnailEvent& event) { int itemID = event.GetIndex(); wxString fullPath = ((FireItem*)scrolledWindow->GetItem(itemID))->getName(); wxString path = firewatch.getPath(); // strip path and additionally introduced file separator (+1) wxString file = fullPath.Mid(path.Length()+1); std::vector& results = firewatch.retrieve(file); if (results.empty()) { wxMessageBox(_("something went wrong...\nMaybe you don't have enough access rights in the Fire image folder?")); } else { selectedItem = 0; displayFireResults(results); } } void RootFrame::OnItemRightClick(wxThumbnailEvent& event) { selectedItem = (FireItem*) scrolledWindow->GetItem(event.GetIndex()); GetToolBar()->EnableTool(ToolBarSelect, true); GetToolBar()->EnableTool(ToolBarRetrieve, true); ContextMenu(); } void RootFrame::OnItemContextClick(wxContextMenuEvent& event){ if (selectedItem != 0) { //if the context menu doesn't appear close to the selected image -> calculate position and give it as parameter ContextMenu(); } } void RootFrame::ContextMenu(const wxPoint& pos){ wxMenu* contextMenu = new wxMenu; contextMenu->Append(ToolBarSelect, _("Select region..."), _T(""), wxITEM_NORMAL); contextMenu->Append(ToolBarRetrieve, _("Retrieve similar..."), _T(""), wxITEM_NORMAL); wxWindow* popupContextMenu = new wxWindow(this, wxID_ANY); popupContextMenu->PopupMenu(contextMenu, pos); popupContextMenu->Show(false); delete popupContextMenu; delete contextMenu; } /*! * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL */ void RootFrame::OnFireResultsUpdated( wxSpinEvent& event ) { fireResultCount->SetValue(firewatch.setResultCount(fireResultCount->GetValue())); } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarBrowse */ void RootFrame::OnToolbarBrowseClick( wxCommandEvent& event ) { // show browse dialog if (browseDialog == 0) { browseDialog = new wxThumbnailBrowserDialog(this, wxID_ANY); wxString initialPath = wxGetCwd(); if (wxDirExists(initialPath)) browseDialog->SetSelection(initialPath); } if (wxID_OK == browseDialog->ShowModal()) { wxString sel = browseDialog->GetSelection(); if (sel.IsEmpty()) return; // copy image to fire folder -> check access rights wxString filename = sel.AfterLast(wxFILE_SEP_PATH); wxString newFilename = firewatch.getPath() + wxFILE_SEP_PATH + filename; // check if file already exists /*if (wxFileExists(newFilename)) { wxMessageBox(_("a file with this name already exists!")); return; }*/ // copy image into Fire location and check if it worked if (!wxCopyFile(sel, newFilename, false)) { wxMessageBox(_("could not upload image!\nDo you have enough access rights in the Fire image folder?")); return; } std::vector& results = firewatch.retrieve(newFilename, true, true); if (results.empty()) { wxMessageBox(_("something went wrong...\nMaybe you don't have enough access rights in the Fire image folder?")); } else { selectedItem = 0; displayFireResults(results); } } } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarSelect */ void RootFrame::OnToolbarSelect( wxCommandEvent& event ) { if (selectDialog == 0) { selectDialog = new SelectDialog(this, wxID_ANY); } if (selectedItem != 0) { selectDialog->setFireItem(*selectedItem); selectDialog->Show(); } } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarRetrieve */ void RootFrame::OnToolbarRetrieveSimilar (wxCommandEvent& event ){ if (selectedItem != 0) { wxString fullPath = selectedItem->getName(); wxString path = firewatch.getPath(); // strip path and additionally introduced file separator (+1) wxString file = fullPath.Mid(path.Length()+1); std::vector& results = firewatch.retrieve(file); if (results.empty()) { wxMessageBox(_("something went wrong...\nMaybe you don't have enough access rights in the Fire image folder?")); } else { selectedItem = 0; displayFireResults(results); } } } /*! * wxEVT_IDLE event handler for ID_FRAME */ void RootFrame::OnIdle( wxIdleEvent& event ) { if(selectedItem == 0){ GetToolBar()->EnableTool(ToolBarSelect, false); GetToolBar()->EnableTool(ToolBarRetrieve, false); } } /*! * wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENUSETTINGS_SERVER */ void RootFrame::OnMenuSettingsServer( wxCommandEvent& event ) { ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENUSETTINGS_SERVER in RootFrame. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENUSETTINGS_SERVER in RootFrame. } firewatch/SelectDialog.h0000644000177200017720000001203410402057615015100 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ // Generated by DialogBlocks (Personal Edition), Di 31 Jan 2006 14:34:02 CET #ifndef _SELECTDIALOG_H_ #define _SELECTDIALOG_H_ #if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "SelectDialog.cc" #endif /*! * Includes */ ////@begin includes ////@end includes #include "FireItem.h" /*! * Forward declarations */ ////@begin forward declarations class SelectCanvas; ////@end forward declarations class SelectDialog; class RootFrame; /*! * Control identifiers */ ////@begin control identifiers #define ID_DIALOG 10007 #define SYMBOL_SELECTDIALOG_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX #define SYMBOL_SELECTDIALOG_TITLE _("Select Region") #define SYMBOL_SELECTDIALOG_IDNAME ID_DIALOG #define SYMBOL_SELECTDIALOG_SIZE wxDefaultSize #define SYMBOL_SELECTDIALOG_POSITION wxDefaultPosition #define ID_SELECTCANVAS 10008 #define ID_SLIDER_SELECTION 10004 #define ID_CLEAR_SELECTION 10010 #define ID_SEND_SELECTION 10013 #define ID_BUTTON3 10015 ////@end control identifiers /*! * Compatibility */ #ifndef wxCLOSE_BOX #define wxCLOSE_BOX 0x1000 #endif #ifndef wxFIXED_MINSIZE #define wxFIXED_MINSIZE 0 #endif class SelectCanvas: public wxScrolledWindow { DECLARE_EVENT_TABLE() public: SelectCanvas(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const long style); virtual void OnPaint(wxPaintEvent&); /// Processes mouse events void OnMouse(wxMouseEvent& event); void updateZoom(float scale); void setFireItem(const FireItem& item); void clearSelection(); inline bool hasSelection() { return selected; } wxString getSelectedImageName(); private: SelectDialog* parent; bool selecting; bool selected; wxPoint startPoint; wxPoint currentPoint; wxPoint endPoint; FireItem fireItem; }; /*! * SelectDialog class declaration */ class SelectDialog: public wxDialog { DECLARE_DYNAMIC_CLASS( SelectDialog ) DECLARE_EVENT_TABLE() public: /// Constructors SelectDialog( ); SelectDialog( wxWindow* parent, wxWindowID id = SYMBOL_SELECTDIALOG_IDNAME, const wxString& caption = SYMBOL_SELECTDIALOG_TITLE, const wxPoint& pos = SYMBOL_SELECTDIALOG_POSITION, const wxSize& size = SYMBOL_SELECTDIALOG_SIZE, long style = SYMBOL_SELECTDIALOG_STYLE ); /// Creation bool Create( wxWindow* parent, wxWindowID id = SYMBOL_SELECTDIALOG_IDNAME, const wxString& caption = SYMBOL_SELECTDIALOG_TITLE, const wxPoint& pos = SYMBOL_SELECTDIALOG_POSITION, const wxSize& size = SYMBOL_SELECTDIALOG_SIZE, long style = SYMBOL_SELECTDIALOG_STYLE ); /// Creates the controls and sizers void CreateControls(); ////@begin SelectDialog event handler declarations /// wxEVT_CLOSE_WINDOW event handler for ID_DIALOG void OnCloseWindow( wxCloseEvent& event ); /// wxEVT_IDLE event handler for ID_DIALOG void OnIdle( wxIdleEvent& event ); /// All mouse events event handler for ID_SELECTCANVAS void OnMouse( wxMouseEvent& event ); /// wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER_SELECTION void OnZoom( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_SELECTION void OnClearSelection( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SEND_SELECTION void OnSendSelection( wxCommandEvent& event ); /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON3 void OnExit( wxCommandEvent& event ); ////@end SelectDialog event handler declarations ////@begin SelectDialog member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end SelectDialog member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin SelectDialog member variables SelectCanvas* selectCanvas; wxSlider* zoomSlider; ////@end SelectDialog member variables void setFireItem(const FireItem& item) { if (selectCanvas != 0) selectCanvas->setFireItem(item); zoomSlider->SetValue(100); } RootFrame* rootFrame; }; #endif // _SELECTDIALOG_H_ firewatch/RootFrame.h0000644000177200017720000001334210402057615014442 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ // Generated by DialogBlocks (Personal Edition), Do 26 Jan 2006 14:22:16 CET #ifndef _ROOTFRAME_H_ #define _ROOTFRAME_H_ #if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "RootFrame.cc" #endif /*! * Includes */ ////@begin includes #include "wx/frame.h" #include "wx/toolbar.h" #include "wx/spinctrl.h" ////@end includes #include "thumbnaildlg.h" #include "FireWatch.h" #include "FireItem.h" #include "SelectDialog.h" /*! * Forward declarations */ ////@begin forward declarations class wxSpinCtrl; class wxThumbnailCtrl; ////@end forward declarations class wxThumbnailEvent; /*! * Control identifiers */ ////@begin control identifiers #define ID_FRAME 10009 #define SYMBOL_ROOTFRAME_STYLE wxDEFAULT_FRAME_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE|wxMAXIMIZE|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX #define SYMBOL_ROOTFRAME_TITLE _("FireWatch") #define SYMBOL_ROOTFRAME_IDNAME ID_FRAME #define SYMBOL_ROOTFRAME_SIZE wxDefaultSize #define SYMBOL_ROOTFRAME_POSITION wxDefaultPosition #define MENU_FILE_LOAD 10000 #define ID_MENU_CONNECT 10021 #define MENU_FILE_EXIT 10001 #define ID_MENUSETTINGS_SERVER 10017 #define ID_MENU 10003 #define ID_TOOLBAR1 10011 #define ToolBarRandom 10012 #define ToolBarRetrieve 10016 #define ToolBarBrowse 10006 #define ToolBarSelect 10014 #define ID_SPINCTRL 10004 #define ID_SCROLLEDWINDOW1 10005 #define ID_SLIDER 10002 ////@end control identifiers /*! * Compatibility */ #ifndef wxCLOSE_BOX #define wxCLOSE_BOX 0x1000 #endif #ifndef wxFIXED_MINSIZE #define wxFIXED_MINSIZE 0 #endif /*! * RootFrame class declaration */ class RootFrame: public wxFrame { DECLARE_CLASS( RootFrame ) DECLARE_EVENT_TABLE() public: /// Constructors RootFrame( ); RootFrame( wxWindow* parent, wxWindowID id = SYMBOL_ROOTFRAME_IDNAME, const wxString& caption = SYMBOL_ROOTFRAME_TITLE, const wxPoint& pos = SYMBOL_ROOTFRAME_POSITION, const wxSize& size = SYMBOL_ROOTFRAME_SIZE, long style = SYMBOL_ROOTFRAME_STYLE ); bool Create( wxWindow* parent, wxWindowID id = SYMBOL_ROOTFRAME_IDNAME, const wxString& caption = SYMBOL_ROOTFRAME_TITLE, const wxPoint& pos = SYMBOL_ROOTFRAME_POSITION, const wxSize& size = SYMBOL_ROOTFRAME_SIZE, long style = SYMBOL_ROOTFRAME_STYLE ); /// Creates the controls and sizers void CreateControls(); ////@begin RootFrame event handler declarations /// wxEVT_IDLE event handler for ID_FRAME void OnIdle( wxIdleEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for MENU_FILE_LOAD void OnMenuFileLoad( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for MENU_FILE_EXIT void OnMenuFileExitClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENUSETTINGS_SERVER void OnMenuSettingsServer( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU void OnMenuClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarRandom void OnRandom( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarRetrieve void OnToolbarRetrieveSimilar( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarBrowse void OnToolbarBrowseClick( wxCommandEvent& event ); /// wxEVT_COMMAND_MENU_SELECTED event handler for ToolBarSelect void OnToolbarSelect( wxCommandEvent& event ); /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_SPINCTRL void OnFireResultsUpdated( wxSpinEvent& event ); /// wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER void OnZoom( wxCommandEvent& event ); ////@end RootFrame event handler declarations ////@begin RootFrame member function declarations /// Retrieves bitmap resources wxBitmap GetBitmapResource( const wxString& name ); /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); ////@end RootFrame member function declarations /// Should we show tooltips? static bool ShowToolTips(); void initFireWatch(wxString host, unsigned short port); void displayFireResults(std::vector& results); void sendNewImage(wxString); void OnItemSelect(wxThumbnailEvent& event); void OnItemDeSelect(wxThumbnailEvent& event); void OnItemClick(wxThumbnailEvent& event); void OnItemDoubleClick(wxThumbnailEvent& event); void OnItemRightClick(wxThumbnailEvent& event); void OnItemContextClick(wxContextMenuEvent& event); void ContextMenu(const wxPoint& pos = wxDefaultPosition); private: ////@begin RootFrame member variables wxSpinCtrl* fireResultCount; wxThumbnailCtrl* scrolledWindow; wxSlider* zoomSlider; ////@end RootFrame member variables wxThumbnailBrowserDialog* browseDialog; SelectDialog* selectDialog; FireWatch firewatch; float scaleFactor; FireItem* selectedItem; }; #endif // _ROOTFRAME_H_ firewatch/.project0000644000177200017720000000525710402057615014050 0ustar koflerkofler firewatch org.eclipse.cdt.make.core.makeBuilder org.eclipse.cdt.make.core.build.arguments org.eclipse.cdt.core.errorOutputParser org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; org.eclipse.cdt.make.core.enableAutoBuild true org.eclipse.cdt.make.core.environment org.eclipse.cdt.make.core.enableFullBuild true org.eclipse.cdt.make.core.build.target.inc all org.eclipse.cdt.make.core.enabledIncrementalBuild true org.eclipse.cdt.make.core.build.location org.eclipse.cdt.make.core.build.target.clean clean org.eclipse.cdt.make.core.build.command make org.eclipse.cdt.make.core.enableCleanBuild true org.eclipse.cdt.make.core.append_environment true org.eclipse.cdt.make.core.build.target.full clean all org.eclipse.cdt.make.core.useDefaultBuildCmd true org.eclipse.cdt.make.core.build.target.auto all org.eclipse.cdt.make.core.stopOnError false org.eclipse.cdt.make.core.ScannerConfigBuilder org.eclipse.cdt.core.cnature org.eclipse.cdt.make.core.makeNature org.eclipse.cdt.make.core.ScannerConfigNature org.eclipse.cdt.core.ccnature firewatch/Application.cc0000644000177200017720000000322210402057615015141 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 #include "Application.h" #include "RootFrame.h" using namespace std; IMPLEMENT_APP(wxApplication) bool wxApplication::OnInit() { if (argc < 2) { cerr << "usage: firewatch host [port]" << endl << endl; exit(-1); } else { port = 12960; if (argc == 3) { wxString tmpPort = argv[2]; tmpPort.ToULong((unsigned long*)&port); } host = argv[1]; } wxImage::AddHandler(new wxJPEGHandler); wxImage::AddHandler(new wxPNGHandler); //--- set up GUI RootFrame* frame = new RootFrame(0); //frame->Centre(); frame->initFireWatch(host, port); frame->Show(true); SetTopWindow(frame); frame->Refresh(); return true; } wxApplication::~wxApplication() { } firewatch/FireItem.cc0000644000177200017720000000656010402057615014412 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 "FireItem.h" //BEGIN_EVENT_TABLE(FireItem, wxThumbnailItem) // EVT_PAINT(FireItem::OnPaint) //END_EVENT_TABLE() IMPLEMENT_CLASS(FireItem, wxThumbnailItem) FireItem::FireItem(const FireResult& fireResult, float _scale) { Init(); Create(fireResult, _scale); } FireItem::FireItem(const FireItem& item) { Init(); Create(item.result, item.scale); } void FireItem::operator=(const FireItem& item) { Init(); Create(item.result, item.scale); } FireItem::FireItem() { Init(); } FireItem::~FireItem() { if (image != 0) delete image; if (thumbnail != 0) delete thumbnail; } void FireItem::Init() { image = 0; thumbnail = 0; scale = 1.f; result.setName(wxT("")); result.setScore(0.f); } bool FireItem::Create(const FireResult& fireResult, float _scale) { result = fireResult; scale = _scale; if (!wxFileExists(getName())) { result.setScore(-1.f); return false; } // load image -> image if(image != 0) delete image; image = new wxImage(getName()); // scale image -> thumbnail if (thumbnail != 0) delete thumbnail; thumbnail = new wxBitmap(image->Scale((int)(image->GetWidth()*scale), (int)(image->GetHeight()*scale))); wxThumbnailItem::SetFilename(getName()); return true; } wxSize FireItem::DoGetBestSize() const { wxSize size; size.x = thumbnail->GetWidth(); size.y = thumbnail->GetHeight(); return size; } bool FireItem::Draw(wxDC& dc, wxThumbnailCtrl* WXUNUSED(ctrl), const wxRect& rect, int WXUNUSED(style)) { if (thumbnail->Ok()) { int x = rect.x + (rect.width - thumbnail->GetWidth())/2; int y = rect.y + (rect.height - thumbnail->GetHeight())/2; dc.DrawBitmap(*thumbnail, x, y); } return true; } bool FireItem::Load(wxThumbnailCtrl* ctrl, bool forceLoad) { if (thumbnail->Ok() && !forceLoad) return true; if (!wxFileExists(getName())) return false; // load image -> image if(image != 0) delete image; image = new wxImage(getName()); // scale image -> thumbnail if (thumbnail != 0) delete thumbnail; thumbnail = new wxBitmap(image->Scale((int)(image->GetWidth()*scale), (int)(image->GetHeight()*scale))); return true; } void FireItem::setScale(float value) { if (image == 0) return; scale = value; if (thumbnail != 0) delete thumbnail; thumbnail = new wxBitmap(image->Scale((int)(image->GetWidth()*scale), (int)(image->GetHeight()*scale))); } firewatch/firewatch.pjd0000644000177200017720000033511410402057615015052 0ustar koflerkofler
0 "" "" "" "" 61 "" 1 0 0 1 1 0 "Christian Kofler" "(c) 2006 DFKI IUPR" "" 0 "<All platforms>" "<Any>" "///////////////////////////////////////////////////////////////////////////// // Name: %HEADER-FILENAME% // Author: %AUTHOR% // Created: %DATE% // Copyright: %COPYRIGHT% ///////////////////////////////////////////////////////////////////////////// " "///////////////////////////////////////////////////////////////////////////// // Name: %SOURCE-FILENAME% // Purpose: // Author: %AUTHOR% // Modified by: // Created: %DATE% // RCS-ID: // Copyright: %COPYRIGHT% // Licence: ///////////////////////////////////////////////////////////////////////////// " "/*! * %BODY% */ " "///////////////////////////////////////////////////////////////////////////// // Name: %SYMBOLS-FILENAME% // Purpose: Symbols file // Author: %AUTHOR% // Modified by: // Created: %DATE% // RCS-ID: // Copyright: %COPYRIGHT% // Licence: ///////////////////////////////////////////////////////////////////////////// " "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "%HEADER-FILENAME%" #endif " "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "%HEADER-FILENAME%" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif " "" "" "" "app.h" "app.cpp" "Application" 0 "" "GCC Debug" "<System>" "<System>" "" 0 1 1
"" "data-document" "" "" 0 1 0 0 "Configurations" "config-data-document" "" "" 0 1 0 0 "" 1 "" "Debug" "ANSI" "Static" "Modular" "GUI" "wxGTK+2" "Dynamic" "Yes" "No" "No" "%WXVERSION%" "%EXECUTABLE%" "" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "GCC Debug" "gcc-config-data-document" "" "" 0 1 0 0 "GCC" 1 "GCC" "Debug" "ANSI" "Static" "Modular" "GUI" "wxGTK+2" "Dynamic" "Yes" "No" "No" "Yes" "Yes" "%WXVERSION%" "%EXECUTABLE%" "" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "%AUTO%" "Projects" "root-document" "" "project" 1 1 0 0 "Windows" "html-document" "" "dialogsfolder" 1 1 0 1 "FireWatch" "dialog-document" "" "frame" 0 1 0 0 "26/1/2006" "wbFrameProxy" 10000 0 "" 0 "wxEVT_IDLE|OnIdle" "ID_FRAME" 10009 "RootFrame" "wxFrame" "RootFrame.cc" "RootFrame.h" "" "FireWatch" 0 "" 0 "" "" "" "" "" 0 1 "<Any platform>" 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "" 0 1 -1 -1 -1 -1 "" "wxMenuBar: ID_MENUBAR" "dialog-control-document" "" "menubar" 0 1 0 0 "26/1/2006" "wbMenuBarProxy" "ID_MENUBAR" "<Any platform>" "File" "dialog-control-document" "" "menu" 0 1 0 0 "27/1/2006" "wbMenuProxy" "File" 1 "<Any platform>" "Load ...: MENU_FILE_LOAD" "dialog-control-document" "" "menuitem" 0 1 0 0 "16/2/2006" "wbMenuItemProxy" "wxEVT_COMMAND_MENU_SELECTED|OnMenuFileLoad" "MENU_FILE_LOAD" 10000 "Load ..." "Normal" 0 1 "" "" "<Any platform>" "Connect Fire servers ...: ID_MENU_CONNECT" "dialog-control-document" "" "menuitem" 0 1 0 0 "16/2/2006" "wbMenuItemProxy" "ID_MENU_CONNECT" 10021 "Connect Fire servers ..." "Normal" 0 1 "" "" "<Any platform>" "------------" "dialog-control-document" "" "menuitem" 0 1 0 0 "27/1/2006" "wbMenuSeparatorProxy" "<Any platform>" "Exit: MENU_FILE_EXIT" "dialog-control-document" "" "menuitem" 0 1 0 0 "27/1/2006" "wbMenuItemProxy" "wxEVT_COMMAND_MENU_SELECTED|OnMenuFileExitClick" "MENU_FILE_EXIT" 10001 "Exit" "Normal" 0 1 "" "" "<Any platform>" "Settings" "dialog-control-document" "" "menu" 0 1 0 0 "16/2/2006" "wbMenuProxy" "Settings" 1 "<Any platform>" "Server settings: ID_MENUSETTINGS_SERVER" "dialog-control-document" "" "menuitem" 0 1 0 0 "16/2/2006" "wbMenuItemProxy" "wxEVT_COMMAND_MENU_SELECTED|OnMenuSettingsServer" "ID_MENUSETTINGS_SERVER" 10017 "Server settings" "Normal" 0 1 "" "" "<Any platform>" "Help" "dialog-control-document" "" "menu" 0 1 0 0 "27/1/2006" "wbMenuProxy" "Help" 1 "<Any platform>" "About FireWatch: ID_MENU" "dialog-control-document" "" "menuitem" 0 1 0 0 "27/1/2006" "wbMenuItemProxy" "wxEVT_COMMAND_MENU_SELECTED|OnMenuClick|SHOWMESSAGE|FireWatch: GUI for the Flexible Image Retrieval Engine" "ID_MENU" 10003 "About FireWatch" "Normal" 0 1 "" "" "<Any platform>" "wxToolBar: ID_TOOLBAR1" "dialog-control-document" "" "toolbar" 0 1 0 0 "26/1/2006" "wbToolBarProxy" "ID_TOOLBAR1" 10011 "wxToolBar" "" "" "" "" "" "" 0 1 "<Any platform>" "" "" 16 15 0 0 1 5 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 20 "Centre" "Centre" 0 5 1 1 1 1 0 0 1 "" "" "random: ToolBarRandom" "dialog-control-document" "" "menuitem" 0 1 0 0 "30/1/2006" "wbToolBarButtonProxy" "wxEVT_COMMAND_MENU_SELECTED|OnRandom" "ToolBarRandom" 10012 "icons/random.xpm" "random" "Normal" 1 "get random images" "get random images" "<Any platform>" "----------" "dialog-control-document" "" "menuitem" 0 1 0 0 "16/2/2006" "wbToolBarSeparatorProxy" "<Any platform>" "retrieveSimilar: ToolBarRetrieve" "dialog-control-document" "" "menuitem" 0 1 0 0 "16/2/2006" "wbToolBarButtonProxy" "wxEVT_COMMAND_MENU_SELECTED|OnToolbarRetrieveSimilar" "ToolBarRetrieve" 10016 "icons/stock_new-labels-24.xpm" "retrieveSimilar" "Normal" 1 "retrieve similar" "" "<Any platform>" "----------" "dialog-control-document" "" "menuitem" 0 1 0 0 "30/1/2006" "wbToolBarSeparatorProxy" "<Any platform>" "browse: ToolBarBrowse" "dialog-control-document" "" "menuitem" 0 1 0 0 "30/1/2006" "wbToolBarButtonProxy" "wxEVT_COMMAND_MENU_SELECTED|OnToolbarBrowseClick" "ToolBarBrowse" 10006 "icons/browse.xpm" "browse" "Normal" 1 "browse local file system" "browse local file system" "<Any platform>" "----------" "dialog-control-document" "" "menuitem" 0 1 0 0 "30/1/2006" "wbToolBarSeparatorProxy" "<Any platform>" "select: ToolBarSelect" "dialog-control-document" "" "menuitem" 0 1 0 0 "1/2/2006" "wbToolBarButtonProxy" "wxEVT_COMMAND_MENU_SELECTED|OnToolbarSelect" "ToolBarSelect" 10014 "icons/select.xpm" "select" "Normal" 1 "select an image region" "select an image region" "<Any platform>" "----------" "dialog-control-document" "" "menuitem" 0 1 0 0 "1/2/2006" "wbToolBarSeparatorProxy" "<Any platform>" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "30/1/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "results: " "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 1 0 "" "" "wxSpinCtrl: ID_SPINCTRL" "dialog-control-document" "" "spinctrl" 0 1 0 0 "30/1/2006" "wbSpinCtrlProxy" "wxEVT_COMMAND_SPINCTRL_UPDATED|OnFireResultsUpdated" "ID_SPINCTRL" 10004 "wxSpinCtrl" "fireResultCount" 1 100 1 "number of Fire results" "number of Fire results" "" "" "" 0 1 "<Any platform>" "" "" 1 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxBoxSizer V" "dialog-control-document" "" "sizer" 0 1 0 0 "26/1/2006" "wbBoxSizerProxy" "Vertical" "" 0 1 0 "<Any platform>" ": ID_SCROLLEDWINDOW1" "dialog-control-document" "" "scrolledwindow" 0 1 0 0 "26/1/2006" "wbScrolledWindowProxy" "ID_SCROLLEDWINDOW1" 10005 "wxThumbnailCtrl" "" "scrolledWindow" 1 1 1 1000 1000 "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 1 0 0 0 0 1 1 0 0 "" -1 -1 750 550 "Expand" "Centre" 1 5 1 1 1 1 0 0 0 "" "" "wxBoxSizer H" "dialog-control-document" "" "sizer" 0 1 0 0 "26/1/2006" "wbBoxSizerProxy" "Horizontal" "" "Right" "Centre" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "26/1/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "-" "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxSlider: ID_SLIDER" "dialog-control-document" "" "slider" 0 1 0 0 "26/1/2006" "wbSliderProxy" "wxEVT_COMMAND_SLIDER_UPDATED|OnZoom" "ID_SLIDER" 10002 "wxSlider" "zoomSlider" 10 100 40 "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 "" -1 -1 150 15 "Centre" "Centre" 0 0 0 0 0 0 0 0 0 "" "" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "26/1/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "+" "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "Select Region" "dialog-document" "" "dialog" 0 1 0 0 "31/1/2006" "wbDialogProxy" 10000 0 "" 0 "wxEVT_CLOSE_WINDOW|OnCloseWindow" "wxEVT_IDLE|OnIdle" "ID_DIALOG" 10007 "SelectDialog" "wxDialog" "wxDialog" "SelectDialog.cc" "SelectDialog.h" "" "Select Region" 0 "" 0 "" "" "" "" "" 0 1 "<Any platform>" 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 "" 0 1 -1 -1 -1 -1 "" "wxBoxSizer V" "dialog-control-document" "" "sizer" 0 1 0 0 "wbBoxSizerProxy" "Vertical" "" "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxScrolledWindow: ID_SELECTCANVAS" "dialog-control-document" "" "scrolledwindow" 0 1 0 0 "31/1/2006" "wbScrolledWindowProxy" "All mouse events|OnMouse" "ID_SELECTCANVAS" 10008 "SelectCanvas" "wxScrolledWindow" "selectCanvas" 1 1 1 0 0 "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 1 0 0 0 0 1 1 0 0 "" -1 -1 500 400 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxBoxSizer H" "dialog-control-document" "" "sizer" 0 1 0 0 "1/2/2006" "wbBoxSizerProxy" "Horizontal" "" "Right" "Centre" 0 0 1 1 1 1 0 0 0 "<Any platform>" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "1/2/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "-" "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxSlider: ID_SLIDER_SELECTION" "dialog-control-document" "" "slider" 0 1 0 0 "1/2/2006" "wbSliderProxy" "wxEVT_COMMAND_SLIDER_UPDATED|OnZoom" "ID_SLIDER_SELECTION" 10004 "wxSlider" "zoomSlider" 5 200 100 "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 "" -1 -1 150 15 "Centre" "Centre" 0 0 0 0 0 0 0 0 0 "" "" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "1/2/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "+" "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxBoxSizer H" "dialog-control-document" "" "sizer" 0 1 0 0 "31/1/2006" "wbBoxSizerProxy" "Horizontal" "" "Centre" "Centre" 0 2 1 1 1 1 0 0 0 "<Any platform>" "wxButton: ID_CLEAR_SELECTION" "dialog-control-document" "" "dialogcontrol" 0 1 0 0 "31/1/2006" "wbButtonProxy" "wxEVT_COMMAND_BUTTON_CLICKED|OnClearSelection" "ID_CLEAR_SELECTION" 10010 "wxButton" "" "Clear Selection" 0 "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 2 1 1 1 1 0 0 0 "" "" "wxButton: ID_SEND_SELECTION" "dialog-control-document" "" "dialogcontrol" 0 1 0 0 "31/1/2006" "wbButtonProxy" "wxEVT_COMMAND_BUTTON_CLICKED|OnSendSelection" "ID_SEND_SELECTION" 10013 "wxButton" "" "Send Selection" 0 "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 2 1 1 1 1 0 0 0 "" "" "Spacer" "dialog-control-document" "" "spacer" 0 1 0 0 "31/1/2006" "wbSpacerProxy" 40 5 "Centre" "Expand" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxButton: ID_BUTTON3" "dialog-control-document" "" "dialogcontrol" 0 1 0 0 "31/1/2006" "wbButtonProxy" "wxEVT_COMMAND_BUTTON_CLICKED|OnExit" "ID_BUTTON3" 10015 "wxButton" "" "exit" 0 "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 2 1 1 1 1 0 0 0 "" "" "ItemPanel" "dialog-document" "" "dialog" 0 1 0 0 "1/2/2006" "wbDialogProxy" 10000 0 "" 0 "ID_DIALOG" 10018 "MyDialog" "wxPanel" "wxPanel" "" "" "" "Dialog" 1 "" 0 "" "" "" "" "" 0 1 "<Any platform>" 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 "" 0 1 -1 -1 400 300 "" "wxBoxSizer V" "dialog-control-document" "" "sizer" 0 1 0 0 "1/2/2006" "wbBoxSizerProxy" "Vertical" "" "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxStaticBitmap: wxID_STATIC" "dialog-control-document" "" "staticbitmap" 0 1 0 0 "1/2/2006" "wbStaticBitmapProxy" "wxID_STATIC" 5105 "wxStaticBitmap" "" "" "" "" "" "" "" 0 1 "<Any platform>" 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxBoxSizer H" "dialog-control-document" "" "sizer" 0 1 0 0 "1/2/2006" "wbBoxSizerProxy" "Horizontal" "" "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxStaticText: wxID_STATIC" "dialog-control-document" "" "statictext" 0 1 0 0 "1/2/2006" "wbStaticTextProxy" "wxID_STATIC" 5105 "wxStaticText" "" "score: 1.36" "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 0 0 0 0 0 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 1 0 "" "" "wxBoxSizer H" "dialog-control-document" "" "sizer" 0 1 0 0 "1/2/2006" "wbBoxSizerProxy" "Horizontal" "" "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "<Any platform>" "wxRadioButton: ID_RADIOBUTTON" "dialog-control-document" "" "radiobutton" 0 1 0 0 "1/2/2006" "wbRadioButtonProxy" "ID_RADIOBUTTON" 10019 "wxRadioButton" "" "Radiobutton" 0 "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "wxRadioButton: ID_RADIOBUTTON1" "dialog-control-document" "" "radiobutton" 0 1 0 0 "1/2/2006" "wbRadioButtonProxy" "ID_RADIOBUTTON1" 10020 "wxRadioButton" "" "Radiobutton" 0 "" "" "" "" "" 0 1 "<Any platform>" "" "" 0 0 0 "" -1 -1 -1 -1 "Centre" "Centre" 0 5 1 1 1 1 0 0 0 "" "" "Sources" "html-document" "" "sourcesfolder" 1 1 0 1 "firewatch.rc" "source-editor-document" "firewatch.rc" "source-editor" 0 0 1 0 "26/1/2006" "" "Images" "html-document" "" "bitmapsfolder" 1 1 0 1 "random.xpm" "image-document" "icons/random.xpm" "image" 0 0 0 0 "27/1/2006" 100 "browse.xpm" "image-document" "icons/browse.xpm" "image" 0 0 0 0 "30/1/2006" 100 "select.xpm" "image-document" "icons/select.xpm" "image" 0 0 0 0 "1/2/2006" 100 "retrieveSimilar.xpm" "image-document" "icons/retrieveSimilar.xpm" "image" 0 0 0 0 "16/2/2006" 100 "stock_new-labels-24.xpm" "image-document" "icons/stock_new-labels-24.xpm" "image" 0 0 0 0 "16/2/2006" 100
firewatch/Application.h0000644000177200017720000000225510402057615015010 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ #ifndef _WXAPPLICATION_H_ #define _WXAPPLICATION_H_ #include #include #include "FireWatch.h" class wxApplication : public wxApp { private: wxString host; unsigned int port; public: virtual ~wxApplication(); virtual bool OnInit(); }; #endif //_WXAPPLICATION_H_ firewatch/FireItem.h0000644000177200017720000000550410402057615014251 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ #ifndef FIREITEM_H_ #define FIREITEM_H_ #include #include "thumbnailctrl.h" #include "FireResult.h" /** * FireItem represents a thumbnail of an image in FireWatch. * It contains the image itself as well as the score it got (if any). * The visual representation lets the user set (+/0/-) for requeries. */ class FireItem : public wxThumbnailItem { DECLARE_CLASS(FireItem) public: /** * create a FireItem with * @param _filename where to load the image * @param _scale the current scale factor * @param _score the score of the image in a Fire query */ FireItem(const FireResult& fireResult, float _scale=1.f); FireItem(const FireItem& item); FireItem(); virtual ~FireItem(); void operator=(const FireItem&); wxSize DoGetBestSize() const; virtual bool Draw(wxDC& dc, wxThumbnailCtrl* ctrl, const wxRect& rect, int style) ; virtual bool Load(wxThumbnailCtrl* ctrl, bool forceLoad) ; void Init(); bool Create(const FireResult& fireResult, float _scale); /** * where the file is located in the file system */ inline wxString getName() { return result.getName(); } /** * the current score in a Fire query */ inline float getScore() { return result.getScore(); } /** * to scale thumbnails on-the fly */ void setScale(float value); inline float getScale() { return scale; } const wxBitmap& getThumbnail() { return *thumbnail; } const wxImage& getImage() { return *image; } private: FireResult result; //< contains Fire information wxImage* image; //< the original image (scale=1.f) wxBitmap* thumbnail; //< the scaled version of the image float scale; }; #endif /*FIREITEM_H_*/ firewatch/thumbnailctrl.cc0000644000177200017720000013076710402057615015565 0ustar koflerkofler///////////////////////////////////////////////////////////////////////////// // Name: thumbnailctrl.cpp // Purpose: Displays a scrolling window of thumbnails // Author: Julian Smart // Modified by: // Created: 03/08/04 17:22:46 // RCS-ID: // Copyright: (c) Julian Smart // Licence: wxWidgets Licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) #pragma implementation "thumbnailctrl.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "thumbnailctrl.h" #if wxCHECK_VERSION(2,5,5) #define USE_BUFFERED_PAINT 1 #else #define USE_BUFFERED_PAINT 0 #endif // #include "utils.h" #include "wx/settings.h" #include "wx/arrimpl.cpp" #include "wx/image.h" #include "wx/filename.h" #include "wx/dcbuffer.h" #include "tick.xpm" WX_DEFINE_OBJARRAY(wxThumbnailItemArray); DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_ITEM_SELECTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_ITEM_DESELECTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_LEFT_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_MIDDLE_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_RIGHT_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_LEFT_DCLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_RETURN) IMPLEMENT_CLASS( wxThumbnailCtrl, wxScrolledWindow ) IMPLEMENT_CLASS( wxThumbnailItem, wxObject ) IMPLEMENT_CLASS( wxThumbnailEvent, wxNotifyEvent ) BEGIN_EVENT_TABLE( wxThumbnailCtrl, wxScrolledWindow ) EVT_PAINT(wxThumbnailCtrl::OnPaint) EVT_ERASE_BACKGROUND(wxThumbnailCtrl::OnEraseBackground) EVT_LEFT_DOWN(wxThumbnailCtrl::OnLeftClick) EVT_RIGHT_DOWN(wxThumbnailCtrl::OnRightClick) EVT_MIDDLE_DOWN(wxThumbnailCtrl::OnMiddleClick) EVT_LEFT_DCLICK(wxThumbnailCtrl::OnLeftDClick) EVT_CHAR(wxThumbnailCtrl::OnChar) EVT_SIZE(wxThumbnailCtrl::OnSize) EVT_SET_FOCUS(wxThumbnailCtrl::OnSetFocus) EVT_KILL_FOCUS(wxThumbnailCtrl::OnKillFocus) EVT_MENU(wxID_SELECTALL, wxThumbnailCtrl::OnSelectAll) EVT_UPDATE_UI(wxID_SELECTALL, wxThumbnailCtrl::OnUpdateSelectAll) END_EVENT_TABLE() wxThumbnailCtrl* wxThumbnailCtrl::sm_currentThumbnailCtrl = NULL; /*! * wxThumbnailCtrl */ wxThumbnailCtrl::wxThumbnailCtrl( ) { Init(); } wxThumbnailCtrl::wxThumbnailCtrl( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) { Init(); Create(parent, id, pos, size, style); } /// Creation bool wxThumbnailCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) { if (!wxScrolledWindow::Create(parent, id, pos, size, style #if wxCHECK_VERSION(2,5,1) |wxFULL_REPAINT_ON_RESIZE #endif )) return false; if (!GetFont().Ok()) { SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } CalculateOverallThumbnailSize(); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); m_tagBitmap = wxBitmap(tick_xpm); #if wxCHECK_VERSION(2,5,1) SetBackgroundStyle(wxBG_STYLE_CUSTOM); #endif // Tell the sizers to use the given or best size SetBestFittingSize(size); #if USE_BUFFERED_PAINT // Create a buffer RecreateBuffer(size); #endif return true; } /// Member initialisation void wxThumbnailCtrl::Init() { m_thumbnailOverallSize = wxTHUMBNAIL_DEFAULT_OVERALL_SIZE; m_thumbnailImageSize = wxTHUMBNAIL_DEFAULT_IMAGE_SIZE; m_freezeCount = 0; m_spacing = wxTHUMBNAIL_DEFAULT_SPACING; m_thumbnailMargin = wxTHUMBNAIL_DEFAULT_MARGIN; m_firstSelection = -1; m_lastSelection = -1; m_sortMode = wxTHUMBNAIL_SORT_NAME_UP; m_focussedThumbnailBackgroundColour = wxTHUMBNAIL_DEFAULT_FOCUSSED_BACKGROUND; m_unfocussedThumbnailBackgroundColour = wxTHUMBNAIL_DEFAULT_UNFOCUSSED_BACKGROUND; m_unselectedThumbnailBackgroundColour = wxTHUMBNAIL_DEFAULT_UNSELECTED_BACKGROUND; m_typeColour = wxTHUMBNAIL_DEFAULT_TYPE_COLOUR; m_tagColour = wxTHUMBNAIL_DEFAULT_TAG_COLOUR; m_focusRectColour = wxTHUMBNAIL_DEFAULT_FOCUS_RECT_COLOUR; m_focusItem = -1; } /// Call Freeze to prevent refresh void wxThumbnailCtrl::Freeze() { m_freezeCount ++; } /// Call Thaw to refresh void wxThumbnailCtrl::Thaw() { m_freezeCount --; if (m_freezeCount == 0) { SetupScrollbars(); Refresh(); } } /// Append a single item int wxThumbnailCtrl::Append(wxThumbnailItem* item) { int sz = (int) GetCount(); m_items.Add(item); m_firstSelection = -1; m_lastSelection = -1; m_focusItem = -1; item->Load(this, false); if (m_freezeCount == 0) { SetupScrollbars(); Refresh(); } return sz; } /// Insert a single item int wxThumbnailCtrl::Insert(wxThumbnailItem* item, int pos) { m_items.Insert(item, pos); m_firstSelection = -1; m_lastSelection = -1; m_focusItem = -1; // Must now change selection indices because // items above it have moved up size_t i; for (i = 0; i < m_selections.GetCount(); i++) { if (m_selections[i] >= pos) m_selections[i] = m_selections[i] + 1; } // Ditto for tags for (i = 0; i < m_tags.GetCount(); i++) { if (m_tags[i] >= pos) m_tags[i] = m_tags[i] + 1; } item->Load(this, false); if (m_freezeCount == 0) { SetupScrollbars(); Refresh(); } return pos; } /// Clear all items void wxThumbnailCtrl::Clear() { m_firstSelection = -1; m_lastSelection = -1; m_focusItem = -1; m_items.Clear(); m_selections.Clear(); m_tags.Clear(); if (m_freezeCount == 0) { SetupScrollbars(); Refresh(); } } static bool wxGetIntegerFromFilename(const wxString& fname, int& n) { wxString filename = fname; wxStripExtension(filename); wxString strNum; size_t len = filename.Len(); size_t i; for (i = len; i == 0; i--) { if (wxIsdigit(filename[i]) != 0) { strNum = filename[i] + strNum; } else break; } if (strNum.IsEmpty()) return false; else { n = wxAtoi(strNum); return true; } } int wxThumbnailCtrlCmpFunc(wxThumbnailItem** item1, wxThumbnailItem** item2) { int sortMode = wxTHUMBNAIL_SORT_NAME_UP; if (wxThumbnailCtrl::GetThumbnailCtrl()) sortMode = wxThumbnailCtrl::GetThumbnailCtrl()->GetSortMode(); if (sortMode == wxTHUMBNAIL_SORT_NAME_UP || sortMode == wxTHUMBNAIL_SORT_NAME_DOWN) { wxString filename1, filename2; if (sortMode == wxTHUMBNAIL_SORT_NAME_UP) { filename1 = wxFileNameFromPath((*item1)->GetFilename()); filename2 = wxFileNameFromPath((*item2)->GetFilename()); } else { filename2 = wxFileNameFromPath((*item1)->GetFilename()); filename1 = wxFileNameFromPath((*item2)->GetFilename()); } return filename1.CmpNoCase(filename2); } else if (sortMode == wxTHUMBNAIL_SORT_TIMESTAMP_UP || sortMode == wxTHUMBNAIL_SORT_TIMESTAMP_DOWN) { wxFileName fname1, fname2; if (sortMode == wxTHUMBNAIL_SORT_TIMESTAMP_UP) { fname1 = ((*item1)->GetFilename()); fname2 = ((*item2)->GetFilename()); } else { fname2 = ((*item1)->GetFilename()); fname1 = ((*item2)->GetFilename()); } wxDateTime lastMod1, lastMod2; if (fname1.GetTimes(NULL, & lastMod1, NULL) && fname2.GetTimes(NULL, & lastMod2, NULL)) { if (lastMod1 < lastMod2) return -1; else if (lastMod1 > lastMod2) return 1; else return 0; } else return 0; } else if (sortMode == wxTHUMBNAIL_SORT_NUMERICALLY_UP || sortMode == wxTHUMBNAIL_SORT_NUMERICALLY_DOWN) { int n1, n2; bool success1, success2; if (sortMode == wxTHUMBNAIL_SORT_NUMERICALLY_UP) { success1 = wxGetIntegerFromFilename((*item1)->GetFilename(), n1); success2 = wxGetIntegerFromFilename((*item2)->GetFilename(), n2); } else { success1 = wxGetIntegerFromFilename((*item2)->GetFilename(), n1); success2 = wxGetIntegerFromFilename((*item1)->GetFilename(), n2); } if (success1 && !success2) return -1; else if (!success1 && success2) return 1; else if (!success1 && !success2) return 0; if (n1 < n2) return -1; else if (n2 > n1) return 1; else return 0; } else if (sortMode == wxTHUMBNAIL_SORT_TYPE_UP || sortMode == wxTHUMBNAIL_SORT_TYPE_DOWN) { wxString filename1, path1, ext1; wxString filename2, path2, ext2; if (sortMode == wxTHUMBNAIL_SORT_TYPE_UP) { wxSplitPath((*item1)->GetFilename(), & filename1, & path1, & ext1); wxSplitPath((*item2)->GetFilename(), & filename2, & path2, & ext2); } else { wxSplitPath((*item2)->GetFilename(), & filename1, & path1, & ext1); wxSplitPath((*item1)->GetFilename(), & filename2, & path2, & ext2); } return ext1.CmpNoCase(ext2); } return 0; } /// Sorts items in the specified way void wxThumbnailCtrl::Sort(int sortMode) { m_sortMode = sortMode; // preserve and restore selections & tags size_t i; size_t len = m_items.GetCount(); for (i = 0; i < len; i++) { wxThumbnailItem& item = m_items[i]; int state = 0; if (IsSelected(i)) state |= wxTHUMBNAIL_SELECTED; if (IsTagged(i)) state |= wxTHUMBNAIL_TAGGED; item.SetState(state); } m_selections.Clear(); m_tags.Clear(); m_firstSelection = -1; m_lastSelection = -1; m_focusItem = -1; sm_currentThumbnailCtrl = this; m_items.Sort(wxThumbnailCtrlCmpFunc); sm_currentThumbnailCtrl = NULL; Freeze(); for (i = 0; i < len; i++) { wxThumbnailItem& item = m_items[i]; if (item.GetState() & wxTHUMBNAIL_SELECTED) Select(i); if (item.GetState() & wxTHUMBNAIL_TAGGED) Tag(i); } Thaw(); } /// Delete this item void wxThumbnailCtrl::Delete(int n) { if (m_firstSelection == n) m_firstSelection = -1; if (m_lastSelection == n) m_lastSelection = -1; if (m_focusItem == n) m_focusItem = -1; if (m_selections.Index(n) != wxNOT_FOUND) m_selections.Remove(n); if (m_tags.Index(n) != wxNOT_FOUND) m_tags.Remove(n); m_items.RemoveAt(n); // Must now change selection indices because // items have moved down size_t i; for (i = 0; i < m_selections.GetCount(); i++) { if (m_selections[i] > n) m_selections[i] = m_selections[i] - 1; } if (m_freezeCount == 0) { SetupScrollbars(); Refresh(); } } /// Get the nth item wxThumbnailItem* wxThumbnailCtrl::GetItem(int n) { wxASSERT(n < GetCount()); if (n < GetCount()) { return & m_items[(size_t) n]; } else return NULL; } /// Get the overall rect of the given item bool wxThumbnailCtrl::GetItemRect(int n, wxRect& rect, bool transform) { wxASSERT(n < GetCount()); if (n < GetCount()) { int row, col; if (!GetRowCol(n, GetClientSize(), row, col)) return false; int x = col * (m_thumbnailOverallSize.x + m_spacing) + m_spacing; int y = row * (m_thumbnailOverallSize.y + m_spacing) + m_spacing; if (transform) { int startX, startY; int xppu, yppu; GetScrollPixelsPerUnit(& xppu, & yppu); GetViewStart(& startX, & startY); x = x - startX*xppu; y = y - startY*yppu; } rect.x = x; rect.y = y; rect.width = m_thumbnailOverallSize.x; rect.height = m_thumbnailOverallSize.y; return true; } return false; } /// Get the image rect of the given item bool wxThumbnailCtrl::GetItemRectImage(int n, wxRect& rect, bool transform) { wxASSERT(n < GetCount()); wxRect outerRect; if (!GetItemRect(n, outerRect, transform)) return false; rect.width = m_thumbnailImageSize.x; rect.height = m_thumbnailImageSize.y; rect.x = outerRect.x + (outerRect.width - rect.width)/2; rect.y = outerRect.y + (outerRect.height - rect.height)/2; if ((GetWindowStyle() & wxTH_EXTENSION_LABEL) == 0) rect.y -= m_thumbnailTextHeight / 2; return true; } /// The size of the image part void wxThumbnailCtrl::SetThumbnailImageSize(const wxSize& sz) { m_thumbnailImageSize = sz; CalculateOverallThumbnailSize(); if (GetCount() > 0 && m_freezeCount == 0) { SetupScrollbars(); Refresh(); } } /// Calculate the outer thumbnail size based /// on font used for text and inner size void wxThumbnailCtrl::CalculateOverallThumbnailSize() { wxCoord w; wxClientDC dc(this); dc.SetFont(GetFont()); dc.GetTextExtent(wxT("X"), & w, & m_thumbnailTextHeight); // From left to right: margin, image, margin m_thumbnailOverallSize.x = m_thumbnailMargin * 2 + m_thumbnailImageSize.x; // From top to bottom: margin, text + margin (if wxTH_EXTENSION_LABEL set), image, margin, text, margin if (GetWindowStyle() & wxTH_EXTENSION_LABEL) { m_thumbnailOverallSize.y = m_thumbnailMargin * 4 + m_thumbnailTextHeight * 2 + m_thumbnailImageSize.y; } else { m_thumbnailOverallSize.y = m_thumbnailMargin * 3 + m_thumbnailTextHeight + m_thumbnailImageSize.y; } } /// Return the row and column given the client /// size and a left-to-right, top-to-bottom layout /// assumption bool wxThumbnailCtrl::GetRowCol(int item, const wxSize& clientSize, int& row, int& col) { wxASSERT(item < GetCount()); if (item >= GetCount()) return false; // How many can we fit in a row? int perRow = clientSize.x/(m_thumbnailOverallSize.x + m_spacing); if (perRow < 1) perRow = 1; row = item/perRow; col = item % perRow; return true; } /// Select or deselect an item void wxThumbnailCtrl::Select(int n, bool select) { wxASSERT (n < GetCount()); if (select) { if (m_selections.Index(n) == wxNOT_FOUND) m_selections.Add(n); } else { if (m_selections.Index(n) != wxNOT_FOUND) m_selections.Remove(n); } m_firstSelection = n; m_lastSelection = n; int oldFocusItem = m_focusItem; m_focusItem = n; if (m_freezeCount == 0) { wxRect rect; GetItemRect(n, rect); RefreshRect(rect); if (oldFocusItem != -1 && oldFocusItem != n) { GetItemRect(oldFocusItem, rect); RefreshRect(rect); } } } /// Select or deselect a range void wxThumbnailCtrl::SelectRange(int from, int to, bool select) { int first = from; int last = to; if (first < last) { first = to; last = from; } wxASSERT (first >= 0 && first < GetCount()); wxASSERT (last >= 0 && last < GetCount()); Freeze(); int i; for (i = first; i < last; i++) { Select(i, select); } m_focusItem = to; Thaw(); } /// Select all void wxThumbnailCtrl::SelectAll() { Freeze(); int i; for (i = 0; i < GetCount(); i++) { Select(i, true); } if (GetCount() > 0) { m_focusItem = GetCount()-1; } else { m_focusItem = -1; } Thaw(); } /// Select none void wxThumbnailCtrl::SelectNone() { Freeze(); int i; for (i = 0; i < GetCount(); i++) { Select(i, false); } Thaw(); } /// Get the index of the single selection, if not multi-select. /// Returns -1 if there is no selection. int wxThumbnailCtrl::GetSelection() const { if (m_selections.GetCount() > 0) return m_selections[0u]; else return -1; } /// Returns true if the item is selected bool wxThumbnailCtrl::IsSelected(int n) const { return (m_selections.Index(n) != wxNOT_FOUND) ; } /// Clears all selections void wxThumbnailCtrl::ClearSelections() { int count = GetCount(); m_selections.Clear(); m_firstSelection = -1; m_lastSelection = -1; m_focusItem = -1; if (count > 0 && m_freezeCount == 0) { Refresh(); } } /// Set the focus item void wxThumbnailCtrl::SetFocusItem(int item) { wxASSERT( item < GetCount() ); if (item < GetCount()) { int oldFocusItem = m_focusItem; m_focusItem = item; if (m_freezeCount == 0) { wxRect rect; if (oldFocusItem != -1) { GetItemRect(oldFocusItem, rect); RefreshRect(rect); } if (m_focusItem != -1) { GetItemRect(m_focusItem, rect); RefreshRect(rect); } } } } /// Tag or untag an item void wxThumbnailCtrl::Tag(int n, bool tag) { wxASSERT (n < GetCount()); if (tag) { if (m_tags.Index(n) == wxNOT_FOUND) m_tags.Add(n); } else { if (m_tags.Index(n) != wxNOT_FOUND) m_tags.Remove(n); } if (m_freezeCount == 0) { wxRect rect; GetItemRect(n, rect); RefreshRect(rect); } } /// Returns true if the item is tagged bool wxThumbnailCtrl::IsTagged(int n) const { return (m_tags.Index(n) != wxNOT_FOUND) ; } /// Clears all tags void wxThumbnailCtrl::ClearTags() { int count = GetCount(); m_tags.Clear(); if (count > 0 && m_freezeCount == 0) { Refresh(); } } /// Painting void wxThumbnailCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { // Set this to 0 to compare it with the // unbuffered implementation #if USE_BUFFERED_PAINT wxBufferedPaintDC dc(this, m_bufferBitmap); #else wxPaintDC dc(this); #endif PrepareDC(dc); if (m_freezeCount > 0) return; // Paint the background PaintBackground(dc); if (GetCount() == 0) return; wxRegion dirtyRegion = GetUpdateRegion(); bool isFocussed = (FindFocus() == this); int i; int count = GetCount(); int style = 0; wxRect rect, untransformedRect, imageRect, untransformedImageRect; for (i = 0; i < count; i++) { GetItemRect(i, rect); wxRegionContain c = dirtyRegion.Contains(rect); if (c != wxOutRegion) { GetItemRectImage(i, imageRect); style = 0; if (IsSelected(i)) style |= wxTHUMBNAIL_SELECTED; if (IsTagged(i)) style |= wxTHUMBNAIL_TAGGED; if (isFocussed) style |= wxTHUMBNAIL_FOCUSSED; if (isFocussed && i == m_focusItem) style |= wxTHUMBNAIL_IS_FOCUS; GetItemRect(i, untransformedRect, false); GetItemRectImage(i, untransformedImageRect, false); DrawItemBackground(i, dc, untransformedRect, untransformedImageRect, style); DrawItem(i, dc, untransformedImageRect, style); } } } // Empty implementation, to prevent flicker void wxThumbnailCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) { } void wxThumbnailCtrl::OnSetFocus(wxFocusEvent& WXUNUSED(event)) { if (GetCount() > 0) Refresh(); } void wxThumbnailCtrl::OnKillFocus(wxFocusEvent& WXUNUSED(event)) { if (GetCount() > 0) Refresh(); } /// Left-click void wxThumbnailCtrl::OnLeftClick(wxMouseEvent& event) { SetFocus(); int n; if (HitTest(event.GetPosition(), n)) { int flags = 0; if (event.ControlDown()) flags |= wxTHUMBNAIL_CTRL_DOWN; if (event.ShiftDown()) flags |= wxTHUMBNAIL_SHIFT_DOWN; if (event.AltDown()) flags |= wxTHUMBNAIL_ALT_DOWN; EnsureVisible(n); DoSelection(n, flags); wxThumbnailEvent cmdEvent( wxEVT_COMMAND_THUMBNAIL_LEFT_CLICK, GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetIndex(n); cmdEvent.SetFlags(flags); GetEventHandler()->ProcessEvent(cmdEvent); } } /// Right-click void wxThumbnailCtrl::OnRightClick(wxMouseEvent& event) { SetFocus(); int n; if (HitTest(event.GetPosition(), n)) { int flags = 0; if (event.ControlDown()) flags |= wxTHUMBNAIL_CTRL_DOWN; if (event.ShiftDown()) flags |= wxTHUMBNAIL_SHIFT_DOWN; if (event.AltDown()) flags |= wxTHUMBNAIL_ALT_DOWN; // These two lines are replaced by two lines copied from the left mouse click: //if (m_focusItem != n) //SetFocusItem(n); EnsureVisible(n); //copied from left mouse click DoSelection(n, flags); //copied from left mouse click wxThumbnailEvent cmdEvent( wxEVT_COMMAND_THUMBNAIL_RIGHT_CLICK, GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetIndex(n); cmdEvent.SetFlags(flags); GetEventHandler()->ProcessEvent(cmdEvent); } } /// Left-double-click void wxThumbnailCtrl::OnLeftDClick(wxMouseEvent& event) { int n; if (HitTest(event.GetPosition(), n)) { int flags = 0; if (event.ControlDown()) flags |= wxTHUMBNAIL_CTRL_DOWN; if (event.ShiftDown()) flags |= wxTHUMBNAIL_SHIFT_DOWN; if (event.AltDown()) flags |= wxTHUMBNAIL_ALT_DOWN; wxThumbnailEvent cmdEvent( wxEVT_COMMAND_THUMBNAIL_LEFT_DCLICK, GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetIndex(n); cmdEvent.SetFlags(flags); GetEventHandler()->ProcessEvent(cmdEvent); } } /// Middle-click void wxThumbnailCtrl::OnMiddleClick(wxMouseEvent& event) { int n; if (HitTest(event.GetPosition(), n)) { int flags = 0; if (event.ControlDown()) flags |= wxTHUMBNAIL_CTRL_DOWN; if (event.ShiftDown()) flags |= wxTHUMBNAIL_SHIFT_DOWN; if (event.AltDown()) flags |= wxTHUMBNAIL_ALT_DOWN; wxThumbnailEvent cmdEvent( wxEVT_COMMAND_THUMBNAIL_MIDDLE_CLICK, GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetIndex(n); cmdEvent.SetFlags(flags); GetEventHandler()->ProcessEvent(cmdEvent); } } /// Key press void wxThumbnailCtrl::OnChar(wxKeyEvent& event) { int flags = 0; if (event.ControlDown()) flags |= wxTHUMBNAIL_CTRL_DOWN; if (event.ShiftDown()) flags |= wxTHUMBNAIL_SHIFT_DOWN; if (event.AltDown()) flags |= wxTHUMBNAIL_ALT_DOWN; if (event.GetKeyCode() == WXK_LEFT || event.GetKeyCode() == WXK_RIGHT || event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_HOME || event.GetKeyCode() == WXK_PAGEUP || event.GetKeyCode() == WXK_PAGEDOWN || event.GetKeyCode() == WXK_PRIOR || event.GetKeyCode() == WXK_NEXT || event.GetKeyCode() == WXK_END) { Navigate(event.GetKeyCode(), flags); } else if (event.GetKeyCode() == WXK_RETURN) { wxThumbnailEvent cmdEvent( wxEVT_COMMAND_THUMBNAIL_RETURN, GetId()); cmdEvent.SetEventObject(this); cmdEvent.SetFlags(flags); GetEventHandler()->ProcessEvent(cmdEvent); } else event.Skip(); } /// Keyboard navigation bool wxThumbnailCtrl::Navigate(int keyCode, int flags) { if (GetCount() == 0) return false; wxSize clientSize = GetClientSize(); int perRow = clientSize.x/(m_thumbnailOverallSize.x + m_spacing); if (perRow < 1) perRow = 1; int rowsInView = clientSize.y/(m_thumbnailOverallSize.y + m_spacing); if (rowsInView < 1) rowsInView = 1; int focus = m_focusItem; if (focus == -1) focus = m_lastSelection; if (focus == -1 || focus >= GetCount()) { m_lastSelection = 0; DoSelection(m_lastSelection, flags); ScrollIntoView(m_lastSelection, keyCode); return true; } if (keyCode == WXK_RIGHT) { int next = focus + 1; if (next < GetCount()) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_LEFT) { int next = focus - 1; if (next >= 0) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_UP) { int next = focus - perRow; if (next >= 0) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_DOWN) { int next = focus + perRow; if (next < GetCount()) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_PAGEUP || keyCode == WXK_PRIOR) { int next = focus - (perRow * rowsInView); if (next < 0) next = 0; if (next >= 0) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_PAGEDOWN || keyCode == WXK_NEXT) { int next = focus + (perRow * rowsInView); if (next >= GetCount()) next = GetCount() - 1; if (next < GetCount()) { DoSelection(next, flags); ScrollIntoView(next, keyCode); } } else if (keyCode == WXK_HOME) { DoSelection(0, flags); ScrollIntoView(0, keyCode); } else if (keyCode == WXK_END) { DoSelection(GetCount()-1, flags); ScrollIntoView(GetCount()-1, keyCode); } return true; } /// Scroll to see the image void wxThumbnailCtrl::ScrollIntoView(int n, int keyCode) { wxRect rect; GetItemRect(n, rect, false); // _Not_ relative to scroll start int ppuX, ppuY; GetScrollPixelsPerUnit(& ppuX, & ppuY); int startX, startY; GetViewStart(& startX, & startY); startX = 0; startY = startY * ppuY; int sx, sy; GetVirtualSize(& sx, & sy); sx = 0; if (ppuY != 0) sy = sy/ppuY; wxSize clientSize = GetClientSize(); // Going down if (keyCode == WXK_DOWN || keyCode == WXK_RIGHT || keyCode == WXK_END || keyCode == WXK_NEXT || keyCode == WXK_PAGEDOWN) { if ((rect.y + rect.height) > (clientSize.y + startY)) { // Make it scroll so this item is at the bottom // of the window int y = rect.y - (clientSize.y - m_thumbnailOverallSize.y - m_spacing) ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } else if (rect.y < startY) { // Make it scroll so this item is at the top // of the window int y = rect.y ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } } // Going up else if (keyCode == WXK_UP || keyCode == WXK_LEFT || keyCode == WXK_HOME || keyCode == WXK_PRIOR || keyCode == WXK_PAGEUP) { if (rect.y < startY) { // Make it scroll so this item is at the top // of the window int y = rect.y ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } else if ((rect.y + rect.height) > (clientSize.y + startY)) { // Make it scroll so this item is at the bottom // of the window int y = rect.y - (clientSize.y - m_thumbnailOverallSize.y - m_spacing) ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } } } /// Scrolls the item into view if necessary void wxThumbnailCtrl::EnsureVisible(int n) { wxRect rect; GetItemRect(n, rect, false); // _Not_ relative to scroll start int ppuX, ppuY; GetScrollPixelsPerUnit(& ppuX, & ppuY); int startX, startY; GetViewStart(& startX, & startY); startX = 0; startY = startY * ppuY; int sx, sy; GetVirtualSize(& sx, & sy); sx = 0; if (ppuY != 0) sy = sy/ppuY; wxSize clientSize = GetClientSize(); if ((rect.y + rect.height) > (clientSize.y + startY)) { // Make it scroll so this item is at the bottom // of the window int y = rect.y - (clientSize.y - m_thumbnailOverallSize.y - m_spacing) ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } else if (rect.y < startY) { // Make it scroll so this item is at the top // of the window int y = rect.y ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int) (0.5 + y/ppuY)); } } /// Forces a reload of this item's thumbnail image void wxThumbnailCtrl::Reload(int n) { wxThumbnailItem* item = GetItem(n); if (item) { item->Load(this, true); } } /// Finds an item that matches a given filename int wxThumbnailCtrl::FindItemForFilename(const wxString& filename) { wxString searchName = filename; #ifdef __WXMSW__ searchName.Replace(wxT("\\"), wxT("/")); #endif size_t i; for (i = 0; i < m_items.GetCount(); i++) { wxThumbnailItem& item = m_items[i]; wxString itemName = item.GetFilename(); #ifdef __WXMSW__ itemName.Replace(wxT("\\"), wxT("/")); #endif if (itemName == searchName) return i; } return -1; } /// Sizing void wxThumbnailCtrl::OnSize(wxSizeEvent& event) { SetupScrollbars(); RecreateBuffer(); event.Skip(); } /// Set up scrollbars, e.g. after a resize void wxThumbnailCtrl::SetupScrollbars() { if (m_freezeCount) return; if (GetCount() == 0) { SetScrollbars(0, 0, 0, 0, 0, 0); return; } int lastItem = wxMax(0, GetCount() - 1); int pixelsPerUnit = 10; wxSize clientSize = GetClientSize(); int row, col; GetRowCol(lastItem, clientSize, row, col); int maxHeight = (row+1) * (m_thumbnailOverallSize.y + m_spacing) + m_spacing; int unitsY = maxHeight/pixelsPerUnit; int startX, startY; GetViewStart(& startX, & startY); int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0); int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit; // Move to previous scroll position if // possible SetScrollbars(0, pixelsPerUnit, 0, unitsY, wxMin(maxPositionX, startX), wxMin(maxPositionY, startY)); } /// Draws the item. Normally you override function in wxThumbnailItem. bool wxThumbnailCtrl::DrawItem(int n, wxDC& dc, const wxRect& rect, int style) { wxThumbnailItem* item = GetItem(n); if (item) { return item->Draw(dc, this, rect, style); } else return false; } /// Draws the background for the item, including bevel bool wxThumbnailCtrl::DrawItemBackground(int n, wxDC& dc, const wxRect& rect, const wxRect& imageRect, int style) { wxThumbnailItem* item = GetItem(n); if (item) { return item->DrawBackground(dc, this, rect, imageRect, style, n); } else { return false; } } /// Do (de)selection void wxThumbnailCtrl::DoSelection(int n, int flags) { bool isSelected = IsSelected(n); wxArrayInt stateChanged; bool multiSelect = (GetWindowStyle() & wxTH_MULTIPLE_SELECT) != 0; if (multiSelect && (flags & wxTHUMBNAIL_CTRL_DOWN) == wxTHUMBNAIL_CTRL_DOWN) { Select(n, !isSelected); stateChanged.Add(n); } else if (multiSelect && (flags & wxTHUMBNAIL_SHIFT_DOWN) == wxTHUMBNAIL_SHIFT_DOWN) { // We need to find the last item selected, // and select all in between. int first = m_firstSelection ; // Want to keep the 'first' selection // if we're extending the selection bool keepFirstSelection = false; wxArrayInt oldSelections = m_selections; m_selections.Clear(); // TODO: need to refresh those that become unselected. Store old selections, compare with new if (m_firstSelection != -1 && m_firstSelection < GetCount() && m_firstSelection != n) { int step = (n < m_firstSelection) ? -1 : 1; int i; for (i = m_firstSelection; i != n; i += step) { if (!IsSelected(i)) { m_selections.Add(i); stateChanged.Add(i); wxRect rect; GetItemRect(i, rect); RefreshRect(rect); } } keepFirstSelection = true; } // Refresh all the previously selected items that became unselected size_t i; for (i = 0; i < oldSelections.GetCount(); i++) { if (!IsSelected(oldSelections[i])) { wxRect rect; GetItemRect(oldSelections[i], rect); RefreshRect(rect); } } Select(n, true); if (stateChanged.Index(n) == wxNOT_FOUND) stateChanged.Add(n); if (keepFirstSelection) m_firstSelection = first; } else { size_t i = 0; for (i = 0; i < m_selections.GetCount(); i++) { wxRect rect; GetItemRect(m_selections[i], rect); RefreshRect(rect); stateChanged.Add(i); } m_selections.Clear(); Select(n, true); if (stateChanged.Index(n) == wxNOT_FOUND) stateChanged.Add(n); } // Now notify the app of any selection changes size_t i = 0; for (i = 0; i < stateChanged.GetCount(); i++) { wxThumbnailEvent event( m_selections.Index(stateChanged[i]) != wxNOT_FOUND ? wxEVT_COMMAND_THUMBNAIL_ITEM_SELECTED : wxEVT_COMMAND_THUMBNAIL_ITEM_DESELECTED, GetId()); event.SetEventObject(this); event.SetIndex(stateChanged[i]); GetEventHandler()->ProcessEvent(event); } } /// Find the item under the given point bool wxThumbnailCtrl::HitTest(const wxPoint& pt, int& n) { wxSize clientSize = GetClientSize(); int startX, startY; int ppuX, ppuY; GetViewStart(& startX, & startY); GetScrollPixelsPerUnit(& ppuX, & ppuY); int perRow = clientSize.x/(m_thumbnailOverallSize.x + m_spacing); if (perRow < 1) perRow = 1; int colPos = (int) (pt.x / (m_thumbnailOverallSize.x + m_spacing)); int rowPos = (int) ((pt.y + startY * ppuY) / (m_thumbnailOverallSize.y + m_spacing)); int itemN = (rowPos * perRow + colPos); if (itemN >= GetCount()) return false; wxRect rect; GetItemRect(itemN, rect); if (rect.Inside(pt)) { n = itemN; return true; } return false; } void wxThumbnailCtrl::OnSelectAll(wxCommandEvent& WXUNUSED(event)) { SelectAll(); } void wxThumbnailCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event) { event.Enable( GetCount() > 0 ); } /// Paint the background void wxThumbnailCtrl::PaintBackground(wxDC& dc) { wxColour backgroundColour = GetBackgroundColour(); if (!backgroundColour.Ok()) backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); // Clear the background dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); wxRect windowRect(wxPoint(0, 0), GetClientSize()); windowRect.x -= 2; windowRect.y -= 2; windowRect.width += 4; windowRect.height += 4; // We need to shift the rectangle to take into account // scrolling. Converting device to logical coordinates. CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y); dc.DrawRectangle(windowRect); } /// Recreate buffer bitmap if necessary bool wxThumbnailCtrl::RecreateBuffer(const wxSize& size) { wxSize sz = size; if (sz == wxDefaultSize) sz = GetClientSize(); if (sz.x < 1 || sz.y < 1) return false; if (!m_bufferBitmap.Ok() || m_bufferBitmap.GetWidth() < sz.x || m_bufferBitmap.GetHeight() < sz.y) m_bufferBitmap = wxBitmap(sz.x, sz.y); return m_bufferBitmap.Ok(); } /*! * wxThumbnailItem */ /// Draw the item bool wxThumbnailItem::Draw(wxDC& WXUNUSED(dc), wxThumbnailCtrl* WXUNUSED(ctrl), const wxRect& WXUNUSED(rect), int WXUNUSED(style)) { return false; } /// Draw the item background bool wxThumbnailItem::DrawBackground(wxDC& dc, wxThumbnailCtrl* ctrl, const wxRect& rect, const wxRect& imageRect, int style, int WXUNUSED(index)) { wxColour mediumGrey = ctrl->GetUnselectedThumbnailBackgroundColour(); wxColour unfocussedDarkGrey = ctrl->GetSelectedThumbnailUnfocussedBackgroundColour(); wxColour focussedDarkGrey = ctrl->GetSelectedThumbnailFocussedBackgroundColour(); wxColour darkGrey ; if (style & wxTHUMBNAIL_FOCUSSED) darkGrey = focussedDarkGrey; else darkGrey = unfocussedDarkGrey; if (style & wxTHUMBNAIL_SELECTED) { wxBrush brush(darkGrey); wxPen pen(darkGrey); dc.SetBrush(brush); dc.SetPen(pen); } else { wxBrush brush(mediumGrey); wxPen pen(mediumGrey); dc.SetBrush(brush); dc.SetPen(pen); } dc.DrawRectangle(rect); if (style & wxTHUMBNAIL_TAGGED) { wxPen bluePen = ctrl->GetTagColour(); dc.SetPen(bluePen); dc.DrawLine(rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); dc.DrawLine(rect.GetLeft(), rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop()); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom()); } else if (style & wxTHUMBNAIL_SELECTED) { dc.SetPen(*wxWHITE_PEN); dc.DrawLine(rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); dc.DrawLine(rect.GetLeft(), rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); dc.SetPen(*wxBLACK_PEN); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop()); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom()); } else { dc.SetPen(*wxBLACK_PEN); dc.DrawLine(rect.GetRight(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); dc.DrawLine(rect.GetLeft(), rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetTop()); dc.DrawLine(rect.GetLeft(), rect.GetTop(), rect.GetLeft(), rect.GetBottom()); } wxString filename = wxFileNameFromPath(m_filename); if (!filename.IsEmpty() && (ctrl->GetWindowStyle() & wxTH_TEXT_LABEL)) { dc.SetFont(ctrl->GetFont()); if (style & wxTHUMBNAIL_SELECTED) dc.SetTextForeground(*wxWHITE); else dc.SetTextForeground(*wxBLACK); dc.SetBackgroundMode(wxTRANSPARENT); int margin = ctrl->GetThumbnailMargin(); wxRect fRect; fRect.x = rect.x + margin; fRect.y = rect.y + rect.height - (rect.height - imageRect.height)/2 + margin; fRect.width = rect.width - 2*margin; fRect.height = (rect.height - imageRect.height)/2 - 2*margin; wxCoord textW, textH; dc.GetTextExtent(filename, & textW, & textH); dc.SetClippingRegion(fRect); int x = fRect.x + wxMax(0, (fRect.width - textW)/2); int y = fRect.y ; dc.DrawText(filename, x, y); dc.DestroyClippingRegion(); } if (!filename.IsEmpty()) { wxString file, name, ext; wxSplitPath(filename, & file, & name, & ext); if (!ext.IsEmpty() && (ctrl->GetWindowStyle() & wxTH_EXTENSION_LABEL)) { ext.MakeUpper(); dc.SetFont(ctrl->GetFont()); if (style & wxTHUMBNAIL_SELECTED) dc.SetTextForeground(*wxWHITE); else dc.SetTextForeground(ctrl->GetTypeColour()); dc.SetBackgroundMode(wxTRANSPARENT); int margin = ctrl->GetThumbnailMargin(); wxRect fRect; fRect.x = rect.x + margin; fRect.y = rect.y + margin; fRect.width = rect.width - 2*margin; fRect.height = (rect.height - imageRect.height)/2 - 2*margin; wxCoord textW, textH; dc.GetTextExtent(ext, & textW, & textH); dc.SetClippingRegion(fRect); int x = fRect.x ; int y = fRect.y ; dc.DrawText(ext, x, y); dc.DestroyClippingRegion(); } } // Draw tag bitmap if (style & wxTHUMBNAIL_TAGGED) { const wxBitmap& tagBitmap = ctrl->GetTagBitmap(); if (tagBitmap.Ok()) { int x = rect.x + rect.width - tagBitmap.GetWidth() - ctrl->GetThumbnailMargin(); int y = rect.y + ctrl->GetThumbnailMargin(); dc.DrawBitmap(tagBitmap, x, y, true); } } // If the item itself is the focus, draw a dotted // rectangle around it if (style & wxTHUMBNAIL_IS_FOCUS) { wxPen dottedPen(ctrl->GetFocusRectColour(), 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); wxRect focusRect = imageRect; focusRect.x --; focusRect.y --; focusRect.width += 2; focusRect.height += 2; dc.DrawRectangle(focusRect); } return true; } wxSize wxThumbnailCtrl::DoGetBestSize() const { wxSize sz = wxWindow::DoGetBestSize(); return sz; } /*! * wxImageThumbnailItem */ IMPLEMENT_CLASS(wxImageThumbnailItem, wxThumbnailItem) /// Draw the item bool wxImageThumbnailItem::Draw(wxDC& dc, wxThumbnailCtrl* WXUNUSED(ctrl), const wxRect& rect, int WXUNUSED(style)) { if (m_cachedBitmap.Ok()) { int x = rect.x + (rect.width - m_cachedBitmap.GetWidth())/2; int y = rect.y + (rect.height - m_cachedBitmap.GetHeight())/2; // Work around apparent eVC++ bug (image not drawing properly) #ifdef __WXWINCE__ wxBitmap tmpBitmap = m_cachedBitmap; dc.DrawBitmap(tmpBitmap, x, y); #else dc.DrawBitmap(m_cachedBitmap, x, y); #endif } return true; } /// Load the thumbnail bool wxImageThumbnailItem::Load(wxThumbnailCtrl* ctrl, bool forceLoad) { if (m_cachedBitmap.Ok() && !forceLoad) return true; if (wxFileExists(m_filename)) { wxImage image; if (image.LoadFile(m_filename, wxBITMAP_TYPE_ANY)) { wxSize thumbnailSize = ctrl->GetThumbnailImageSize(); double scaleX = ((double) thumbnailSize.x)/((double) image.GetWidth()); double scaleY = ((double) thumbnailSize.y)/((double) image.GetHeight()); if (scaleX < 1.0 || scaleY < 1.0) { double scale = wxMin(scaleX, scaleY); int newWidth = (int) (scale * image.GetWidth()); int newHeight = (int) (scale * image.GetHeight()); image.Rescale(newWidth, newHeight); } m_cachedBitmap = wxBitmap(image); return true; } } return false; } firewatch/README0000644000177200017720000001010010402057615013240 0ustar koflerkofler--- FireWatch --- a client for FIRE ----------------------------------------------------------------------------- Copyright ----------------------------------------------------------------------------- Copyright (C) 2006 DFKI GmbH (www.dfki.de) Image Understanding and Pattern Recognition Lab (www.iupr.org) Author: Christian Kofler FireWatch is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License >= version 2 ----------------------------------------------------------------------------- Introduction ----------------------------------------------------------------------------- FireWatch is a client application for the Flexible Image Retrieval Engine FIRE, which is mainly developed at RWTH Aachen by Thomas Deselaers More infos about FIRE and downloads can be found at: (http://www-i6.informatik.rwth-aachen.de/~deselaers/fire.html) FireWatch is written in C++ using wxWidgets (www.wxwidgets.org) With FireWatch you can: - obtain a random set of images - select an image and retrieve similar images - select a part of an image and retrieve similar images - upload a new image to FIRE and retrieve similar images FireWatch offers some advantages in usability compared to the web-based FIRE client. First, the display of the images can be modified flexibly with a zoom slider and scrollbars and, second, the amount of results can be adjusted at any time. ----------------------------------------------------------------------------- Installation ----------------------------------------------------------------------------- FireWatch requires wxWidgets >= version 2.6 To compile FireWatch simply run make. There is no install target defined. ----------------------------------------------------------------------------- Execution ----------------------------------------------------------------------------- You simply connect to a FIRE server with the command: ./firewatch [port] the default port is 12960 You MUST be able to access the files of the FIRE database! Otherwise you cannot see anything. ----------------------------------------------------------------------------- Usage ----------------------------------------------------------------------------- The entire Application should be quite intuitive. However, here are some basics: - to get random images just click on the 1st toolbar button (arrows) - to retrieve similar images double-click on an image or select it and push the 2nd toolbar button or open the context-menu either with right-click or an according key and select "Retrieve similar..." - to select a region of an image just select it and push the 4th toolbar button or open the context-menu and select "Select region..." in the "Select Region" dialog jut draw a region and press "send selection" to query similar images by this selection - to upload a new image select the File->Load menu or push the 3rd toolbar button. Then select the image to upload and press OK. - to change the amount of results simply type in the desired value or adjust it with the arrows ----------------------------------------------------------------------------- a rough Changelog ----------------------------------------------------------------------------- 2005-09-21 - Christian Kofler FireWatch - watching how FIRE works FireWatch will be a GUI application to work with FIRE, the Flexible Image Retrieval System. Connection is established via telnet. Data is exchanged using the FIRE command set. --- 2005-11-15 - Christian Kofler FireWatch itself will not be developped anymore. It may be seen as a "rapid prototype". The gained functionality will be integrated in a different application. --- 2006-02-08 - Christian Kofler Completely reworked FireWatch. It can now be seen as something like a real application. --- 2006-03-03 - Christian Kofler Several improvements have been made in the past weeks. They are available now in the first release of FireWatch: FireWatch-0.1firewatch/tick.xpm0000755000177200017720000000034310402057615014053 0ustar koflerkofler/* XPM */ static char *tick_xpm[] = { "11 9 2 1", " c None", ". c #0000FF", " ", " .. ", " ... ", " ... ", " .. ... ", " ...... ", " .... ", " .. ", " "}; firewatch/thumbnailctrl.h0000644000177200017720000004204210402057615015413 0ustar koflerkofler///////////////////////////////////////////////////////////////////////////// // Name: thumbnailctrl.h // Purpose: Displays a scrolling window of thumbnails // Author: Julian Smart // Modified by: // Created: 03/08/04 17:22:46 // RCS-ID: // Copyright: (c) Julian Smart // Licence: wxWidgets Licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_THUMBNAILCTRL_H_ #define _WX_THUMBNAILCTRL_H_ #if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "thumbnailctrl.cpp" #endif #include "wx/dynarray.h" /*! * Includes */ /*! * Styles and flags */ /* Styles */ #define wxTH_MULTIPLE_SELECT 0x0010 #define wxTH_SINGLE_SELECT 0x0000 #define wxTH_TEXT_LABEL 0x0020 #define wxTH_IMAGE_LABEL 0x0040 #define wxTH_EXTENSION_LABEL 0x0080 /* Flags */ #define wxTHUMBNAIL_SHIFT_DOWN 0x01 #define wxTHUMBNAIL_CTRL_DOWN 0x02 #define wxTHUMBNAIL_ALT_DOWN 0x04 #define wxTHUMBNAIL_SORT_NAME_UP 1 #define wxTHUMBNAIL_SORT_NAME_DOWN 2 #define wxTHUMBNAIL_SORT_TIMESTAMP_UP 3 #define wxTHUMBNAIL_SORT_TIMESTAMP_DOWN 4 #define wxTHUMBNAIL_SORT_NUMERICALLY_UP 5 #define wxTHUMBNAIL_SORT_NUMERICALLY_DOWN 6 #define wxTHUMBNAIL_SORT_TYPE_UP 7 #define wxTHUMBNAIL_SORT_TYPE_DOWN 8 /* Defaults */ #define wxTHUMBNAIL_DEFAULT_OVERALL_SIZE wxSize(-1, -1) #define wxTHUMBNAIL_DEFAULT_IMAGE_SIZE wxSize(200, 200) #define wxTHUMBNAIL_DEFAULT_SPACING 3 #define wxTHUMBNAIL_DEFAULT_MARGIN 3 #define wxTHUMBNAIL_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175) #define wxTHUMBNAIL_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140) // #define wxTHUMBNAIL_DEFAULT_UNSELECTED_BACKGROUND wxColour(205, 205, 205) #define wxTHUMBNAIL_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) #define wxTHUMBNAIL_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200) #define wxTHUMBNAIL_DEFAULT_TAG_COLOUR wxColour(0, 0, 255) #define wxTHUMBNAIL_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80) /*! * Forward declarations */ class wxThumbnailCtrl; /*! * wxThumbnailItem class declaration */ // Drawing styles/states #define wxTHUMBNAIL_SELECTED 0x01 #define wxTHUMBNAIL_TAGGED 0x02 // The control is focussed #define wxTHUMBNAIL_FOCUSSED 0x04 // The item itself has the focus #define wxTHUMBNAIL_IS_FOCUS 0x08 class wxThumbnailItem: public wxObject { DECLARE_CLASS(wxThumbnailItem) public: // Constructors wxThumbnailItem(const wxString& filename = wxEmptyString) { m_filename = filename; m_state = 0; } // Accessors /// Filename void SetFilename(const wxString& filename) { m_filename = filename; } const wxString& GetFilename() const { return m_filename; } /// State storage while sorting void SetState(int state) { m_state = state; } int GetState() const { return m_state; } // Overrideables /// Draw the item virtual bool Draw(wxDC& dc, wxThumbnailCtrl* ctrl, const wxRect& rect, int style) ; /// Draw the background virtual bool DrawBackground(wxDC& dc, wxThumbnailCtrl* ctrl, const wxRect& rect, const wxRect& imageRect, int style, int index) ; /// Load the thumbnail virtual bool Load(wxThumbnailCtrl* WXUNUSED(ctrl), bool WXUNUSED(forceLoad)) { return false; } protected: wxString m_filename; int m_state; // state storage while sorting }; /*! * wxImageThumbnailItem class declaration */ class wxImageThumbnailItem: public wxThumbnailItem { DECLARE_CLASS(wxImageThumbnailItem) public: // Constructors wxImageThumbnailItem(const wxString& filename = wxEmptyString): wxThumbnailItem(filename) {} // Overrideables /// Draw the item virtual bool Draw(wxDC& dc, wxThumbnailCtrl* ctrl, const wxRect& rect, int style) ; /// Load the thumbnail virtual bool Load(wxThumbnailCtrl* ctrl, bool forceLoad) ; protected: wxBitmap m_cachedBitmap; }; WX_DECLARE_OBJARRAY(wxThumbnailItem, wxThumbnailItemArray); /*! * wxThumbnailCtrl class declaration */ class wxThumbnailCtrl: public wxScrolledWindow { DECLARE_CLASS( wxThumbnailCtrl ) DECLARE_EVENT_TABLE() public: // Constructors wxThumbnailCtrl( ); wxThumbnailCtrl( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTH_TEXT_LABEL|wxTH_IMAGE_LABEL|wxTH_EXTENSION_LABEL ); // Operations /// Creation bool Create( wxWindow* parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTH_TEXT_LABEL|wxTH_IMAGE_LABEL|wxTH_EXTENSION_LABEL ); /// Member initialisation void Init(); /// Call Freeze to prevent refresh void Freeze(); /// Call Thaw to refresh void Thaw(); /// Scrolls the item into view if necessary void EnsureVisible(int n); /// Forces a reload of this item's thumbnail image void Reload(int n); /// Finds an item that matches a given filename int FindItemForFilename(const wxString& filename); /// Sorts items in the specified way void Sort(int sortMode); /// Draws the item. Normally you override function in wxThumbnailItem. virtual bool DrawItem(int n, wxDC& dc, const wxRect& rect, int style) ; /// Draws the background for the item, including bevel virtual bool DrawItemBackground(int n, wxDC& dc, const wxRect& rect, const wxRect& imageRect, int style) ; // Adding items /// Append a single item virtual int Append(wxThumbnailItem* item); /// Insert a single item virtual int Insert(wxThumbnailItem* item, int pos = 0); // Deleting items /// Clear all items virtual void Clear() ; /// Delete this item virtual void Delete(int n) ; // Accessing items /// Get the number of items in the control virtual int GetCount() const { return m_items.GetCount(); } /// Is the control empty? bool IsEmpty() const { return GetCount() == 0; } /// Get the nth item wxThumbnailItem* GetItem(int n); /// Get the overall rect of the given item /// If transform is true, rect is relative to the scroll viewport /// (i.e. may be negative) bool GetItemRect(int item, wxRect& rect, bool transform = true); /// Get the image rect of the given item bool GetItemRectImage(int item, wxRect& rect, bool transform = true); /// Return the row and column given the client /// size and a left-to-right, top-to-bottom layout /// assumption bool GetRowCol(int item, const wxSize& clientSize, int& row, int& col); /// Get the focus item, or -1 if there is none int GetFocusItem() const { return m_focusItem; } /// Set the focus item void SetFocusItem(int item) ; // Selection /// Select or deselect an item void Select(int n, bool select = true) ; /// Select or deselect a range void SelectRange(int from, int to, bool select = true) ; /// Tag or untag an item void Tag(int n, bool tag = true) ; /// Select all void SelectAll() ; /// Select none void SelectNone() ; /// Get the index of the single selection, if not multi-select. /// Returns -1 if there is no selection. int GetSelection() const ; /// Get indexes of all selections, if multi-select const wxArrayInt& GetSelections() const { return m_selections; } /// Get indexes of all tags const wxArrayInt& GetTags() const { return m_tags; } /// Returns true if the item is selected bool IsSelected(int n) const ; /// Returns true if the item is tagged bool IsTagged(int n) const ; /// Clears all selections void ClearSelections(); /// Clears all tags void ClearTags(); // Visual properties /// The overall size of the thumbnail, including decorations. /// DON'T USE THIS from the application, since it will /// normally be calculated by SetThumbnailImageSize. void SetThumbnailOverallSize(const wxSize& sz) { m_thumbnailOverallSize = sz; } const wxSize& GetThumbnailOverallSize() const { return m_thumbnailOverallSize; } /// The size of the image part void SetThumbnailImageSize(const wxSize& sz); const wxSize& GetThumbnailImageSize() const { return m_thumbnailImageSize; } /// The inter-item spacing void SetSpacing(int spacing) { m_spacing = spacing; } int GetSpacing() const { return m_spacing; } /// The margin between elements within the thumbnail void SetThumbnailMargin(int margin) { m_thumbnailMargin = margin; } int GetThumbnailMargin() const { return m_thumbnailMargin; } /// The height required for text in the thumbnail void SetThumbnailTextHeight(int h) { m_thumbnailTextHeight = h; } int GetThumbnailTextHeight() const { return m_thumbnailTextHeight; } /// The focussed and unfocussed background colour for a /// selected thumbnail void SetSelectedThumbnailBackgroundColour(const wxColour& focussedColour, const wxColour& unfocussedColour) { m_focussedThumbnailBackgroundColour = focussedColour; m_unfocussedThumbnailBackgroundColour = unfocussedColour; } const wxColour& GetSelectedThumbnailFocussedBackgroundColour() const { return m_focussedThumbnailBackgroundColour; } const wxColour& GetSelectedThumbnailUnfocussedBackgroundColour() const { return m_unfocussedThumbnailBackgroundColour; } /// The unselected background colour for a thumbnail void SetUnselectedThumbnailBackgroundColour(const wxColour& colour) { m_unselectedThumbnailBackgroundColour = colour; } const wxColour& GetUnselectedThumbnailBackgroundColour() const { return m_unselectedThumbnailBackgroundColour; } /// The colour for the type text (top left of thumbnail) void SetTypeColour(const wxColour& colour) { m_typeColour = colour; } const wxColour& GetTypeColour() const { return m_typeColour; } /// The colour for the tag outline void SetTagColour(const wxColour& colour) { m_tagColour = colour; } const wxColour& GetTagColour() const { return m_tagColour; } /// The focus rectangle pen colour void SetFocusRectColour(const wxColour& colour) { m_focusRectColour = colour; } const wxColour& GetFocusRectColour() const { return m_focusRectColour; } // Command handlers void OnSelectAll(wxCommandEvent& event); void OnUpdateSelectAll(wxUpdateUIEvent& event); // Event handlers /// Painting void OnPaint(wxPaintEvent& event); void OnEraseBackground(wxEraseEvent& event); /// Left-click void OnLeftClick(wxMouseEvent& event); /// Left-double-click void OnLeftDClick(wxMouseEvent& event); /// Middle-click void OnMiddleClick(wxMouseEvent& event); /// Right-click void OnRightClick(wxMouseEvent& event); /// Key press void OnChar(wxKeyEvent& event); /// Sizing void OnSize(wxSizeEvent& event); /// Setting/losing focus void OnSetFocus(wxFocusEvent& event); void OnKillFocus(wxFocusEvent& event); // Implementation /// Set up scrollbars, e.g. after a resize void SetupScrollbars(); /// Calculate the outer thumbnail size based /// on font used for text and inner size void CalculateOverallThumbnailSize(); /// Do (de)selection void DoSelection(int n, int flags); /// Find the item under the given point bool HitTest(const wxPoint& pt, int& n); /// Keyboard navigation virtual bool Navigate(int keyCode, int flags); /// Scroll to see the image void ScrollIntoView(int n, int keyCode); /// Paint the background void PaintBackground(wxDC& dc); /// Recreate buffer bitmap if necessary bool RecreateBuffer(const wxSize& size = wxDefaultSize); /// Get tag bitmap const wxBitmap& GetTagBitmap() const { return m_tagBitmap; } /// Get/set sort mode void SetSortMode(int sortMode) { m_sortMode = sortMode; } int GetSortMode() const { return m_sortMode ; } static wxThumbnailCtrl* GetThumbnailCtrl() { return sm_currentThumbnailCtrl; } // Overrides wxSize DoGetBestSize() const ; // Data members private: /// The items wxThumbnailItemArray m_items; /// The selections wxArrayInt m_selections; /// The tags wxArrayInt m_tags; /// Outer size of the thumbnail item wxSize m_thumbnailOverallSize; /// Image size of the thumbnail item wxSize m_thumbnailImageSize; /// The inter-item spacing int m_spacing; /// The margin between the image/text and the edge of the thumbnail int m_thumbnailMargin; /// The height of thumbnail text in the current font int m_thumbnailTextHeight; /// Allows nested Freeze/Thaw int m_freezeCount; /// First selection in a range int m_firstSelection; /// Last selection int m_lastSelection; /// Focus item int m_focusItem; /// Tag marker bitmap wxBitmap m_tagBitmap; /// Sort mode int m_sortMode; /// Current control, used in sorting static wxThumbnailCtrl* sm_currentThumbnailCtrl; /// Focussed/unfocussed selected thumbnail background colours wxColour m_focussedThumbnailBackgroundColour; wxColour m_unfocussedThumbnailBackgroundColour; wxColour m_unselectedThumbnailBackgroundColour; wxColour m_focusRectColour; /// Type text colour wxColour m_typeColour; /// Tag colour wxColour m_tagColour; /// Buffer bitmap wxBitmap m_bufferBitmap; }; /*! * wxThumbnailEvent - the event class for wxThumbnailCtrl notifications */ class wxThumbnailEvent : public wxNotifyEvent { public: wxThumbnailEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) : wxNotifyEvent(commandType, winid), m_itemIndex(-1), m_flags(0) { } wxThumbnailEvent(const wxThumbnailEvent& event) : wxNotifyEvent(event), m_itemIndex(event.m_itemIndex), m_flags(event.m_flags) { } int GetIndex() const { return m_itemIndex; } void SetIndex(int n) { m_itemIndex = n; } int GetFlags() const { return m_flags; } void SetFlags(int flags) { m_flags = flags; } virtual wxEvent *Clone() const { return new wxThumbnailEvent(*this); } protected: int m_itemIndex; int m_flags; private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxThumbnailEvent) }; /*! * wxThumbnailCtrl event macros */ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_ITEM_SELECTED, 2600) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_ITEM_DESELECTED, 2601) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_LEFT_CLICK, 2602) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_RIGHT_CLICK, 2603) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_MIDDLE_CLICK, 2604) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_LEFT_DCLICK, 2605) DECLARE_EVENT_TYPE(wxEVT_COMMAND_THUMBNAIL_RETURN, 2606) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxThumbnailEventFunction)(wxThumbnailEvent&); #define EVT_THUMBNAIL_ITEM_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_ITEM_DESELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #define EVT_THUMBNAIL_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_THUMBNAIL_RETURN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxThumbnailEventFunction, & fn ), NULL ), #endif // _WX_THUMBNAILCTRL_H_ firewatch/thumbnaildlg.cc0000644000177200017720000002203010402057615015346 0ustar koflerkofler///////////////////////////////////////////////////////////////////////////// // Name: thumbnaildlg.cpp // Purpose: // Author: Julian Smart // Modified by: // Created: 03/16/04 16:08:52 // RCS-ID: // Copyright: (c) Julian Smart // Licence: ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "thumbnaildlg.h" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wx.h" #ifdef __BORLANDC__ #pragma hdrstop #endif ////@begin includes ////@end includes #include "wx/dir.h" #include "thumbnaildlg.h" // #include "thumbnailitem.h" // #include "utils.h" ////@begin XPM images ////@end XPM images /// Returns the image type, or -1, determined from the extension. static int DetermineImageType(const wxString& filename); /*! * wxThumbnailBrowserDialog type definition */ IMPLEMENT_CLASS( wxThumbnailBrowserDialog, wxDialog ) /*! * wxThumbnailBrowserDialog event table definition */ BEGIN_EVENT_TABLE( wxThumbnailBrowserDialog, wxDialog ) // The correct control is actually the tree control, not the dir control. EVT_TREE_SEL_CHANGED( wxID_TREECTRL, wxThumbnailBrowserDialog::OnImageBrowserDirctrlSelChanged ) EVT_THUMBNAIL_LEFT_CLICK(ID_IMAGE_BROWSER_BROWSER, wxThumbnailBrowserDialog::OnLeftClick) EVT_THUMBNAIL_LEFT_DCLICK(ID_IMAGE_BROWSER_BROWSER, wxThumbnailBrowserDialog::OnLeftDClick) ////@begin wxThumbnailBrowserDialog event table entries EVT_TREE_SEL_CHANGED( ID_IMAGE_BROWSER_DIRCTRL, wxThumbnailBrowserDialog::OnImageBrowserDirctrlSelChanged ) ////@end wxThumbnailBrowserDialog event table entries END_EVENT_TABLE() /*! * wxThumbnailBrowserDialog constructors */ wxThumbnailBrowserDialog::wxThumbnailBrowserDialog( ) { m_selectionCount = -1; } wxThumbnailBrowserDialog::wxThumbnailBrowserDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_selectionCount = -1; Create(parent, id, caption, pos, size, style); } /*! * wxThumbnailBrowserDialog creator */ bool wxThumbnailBrowserDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin wxThumbnailBrowserDialog member initialisation m_dirCtrl = NULL; m_imageBrowser = NULL; ////@end wxThumbnailBrowserDialog member initialisation ////@begin wxThumbnailBrowserDialog creation SetExtraStyle(wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); Centre(); ////@end wxThumbnailBrowserDialog creation if (!m_initialSelection.IsEmpty()) SetSelection(m_initialSelection); wxSplitterWindow* splitter = (wxSplitterWindow*) FindWindow(ID_IMAGE_BROWSER_SPLITTER); // Make the splitter update its sizes now instead of in idle time // to reduce on-screen changes splitter->UpdateSize(); return TRUE; } /*! * Control creation for wxThumbnailBrowserDialog */ void wxThumbnailBrowserDialog::CreateControls() { #define EXTRA_STYLES wxTH_TEXT_LABEL|wxTH_IMAGE_LABEL|wxTH_EXTENSION_LABEL|wxTH_MULTIPLE_SELECT ////@begin wxThumbnailBrowserDialog content construction wxThumbnailBrowserDialog* item1 = this; wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); item1->SetSizer(item2); item1->SetAutoLayout(TRUE); wxBoxSizer* item3 = new wxBoxSizer(wxVERTICAL); item2->Add(item3, 1, wxGROW|wxALL, 5); wxSplitterWindow* item4 = new wxSplitterWindow( item1, ID_IMAGE_BROWSER_SPLITTER, wxDefaultPosition, wxSize(500, 400), wxSP_3DBORDER|wxSP_3DSASH|wxNO_BORDER|wxCLIP_CHILDREN|wxSP_LIVE_UPDATE ); wxGenericDirCtrl* item5 = new wxGenericDirCtrl( item4, ID_IMAGE_BROWSER_DIRCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxDIRCTRL_DIR_ONLY, _T("All files (*.*)|*.*"), 0 ); m_dirCtrl = item5; wxThumbnailCtrl* item6 = new wxThumbnailCtrl( item4, ID_IMAGE_BROWSER_BROWSER, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL|wxTH_TEXT_LABEL|wxTH_IMAGE_LABEL|wxTH_EXTENSION_LABEL|wxTH_MULTIPLE_SELECT ); m_imageBrowser = item6; item4->SplitVertically(item5, item6, 180); item3->Add(item4, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5); wxBoxSizer* item7 = new wxBoxSizer(wxHORIZONTAL); item3->Add(item7, 0, wxGROW, 5); item7->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* item9 = new wxButton( item1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); item9->SetDefault(); item7->Add(item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* item11 = new wxButton( item1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); item7->Add(item11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* item10 = new wxButton( item1, wxID_CANCEL, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); item7->Add(item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); ////@end wxThumbnailBrowserDialog content construction } /*! * Should we show tooltips? */ bool wxThumbnailBrowserDialog::ShowToolTips() { return TRUE; } /*! * wxEVT_COMMAND_TREE_SEL_CHANGED event handler for ID_IMAGE_BROWSER_DIRCTRL */ void wxThumbnailBrowserDialog::OnImageBrowserDirctrlSelChanged( wxTreeEvent& event ) { if (!m_dirCtrl || !m_imageBrowser) return; m_selectionCount ++; if (m_selectionCount > 1) { m_selectionCount --; return; } wxTreeItemId id = event.GetItem(); if (id) { wxDirItemData* data = (wxDirItemData*) m_dirCtrl->GetTreeCtrl()->GetItemData(id); if (data && data->m_isDir) { ShowFolder(data->m_path); } } m_selectionCount --; } /// Shows the images in the given dir void wxThumbnailBrowserDialog::ShowFolder(const wxString& path) { wxBusyCursor busy; m_imageBrowser->Clear(); m_imageBrowser->Freeze(); wxDir dir; if (dir.Open(path)) { wxString filename; bool cont = dir.GetFirst(&filename, wxT("*.*"), wxDIR_FILES); while ( cont ) { wxString file = path + wxFILE_SEP_PATH + filename; if (wxFileExists(file) && DetermineImageType(file) != -1) { m_imageBrowser->Append(new wxImageThumbnailItem(file)); } cont = dir.GetNext(&filename); } } m_imageBrowser->Thaw(); } /// Custom event handlers void wxThumbnailBrowserDialog::OnLeftClick(wxThumbnailEvent& event) { if (event.GetFlags() & wxTHUMBNAIL_ALT_DOWN) { int index = event.GetIndex(); m_imageBrowser->Tag(index, !m_imageBrowser->IsTagged(index)); } } void wxThumbnailBrowserDialog::OnLeftDClick(wxThumbnailEvent& WXUNUSED(event)) { EndModal(wxID_OK); } void wxThumbnailBrowserDialog::SetSelection(const wxString& filename) { if (!m_imageBrowser) { m_initialSelection = filename; return; } m_selectionCount = 0; if (wxDirExists(filename)) { m_dirCtrl->SetPath(filename); return; } wxString path = wxPathOnly(filename); wxString file = wxFileNameFromPath(filename); m_dirCtrl->SetPath(path); m_selectionCount = -1; int index = m_imageBrowser->FindItemForFilename(filename); if (index > -1) { m_imageBrowser->Select(index); m_imageBrowser->EnsureVisible(index); } } wxString wxThumbnailBrowserDialog::GetSelection() const { int sel = m_imageBrowser->GetSelection(); if (sel > -1) { wxThumbnailItem* item = m_imageBrowser->GetItem(sel); if (item) { return item->GetFilename(); } } return wxEmptyString; } wxArrayString wxThumbnailBrowserDialog::GetSelections() const { wxArrayString arr; wxArrayInt selections = m_imageBrowser->GetSelections(); size_t i; for (i = 0; i < selections.GetCount(); i++) { wxThumbnailItem* item = m_imageBrowser->GetItem(selections[i]); if (item) arr.Add(item->GetFilename()); } return arr; } // Returns the image type, or -1, determined from the extension. static int DetermineImageType(const wxString& filename) { wxString path, name, ext; wxSplitPath(filename, & path, & name, & ext); ext.MakeLower(); if (ext == wxT("jpg") || ext == wxT("jpeg")) return wxBITMAP_TYPE_JPEG; else if (ext == wxT("gif")) return wxBITMAP_TYPE_GIF; else if (ext == wxT("bmp")) return wxBITMAP_TYPE_BMP; else if (ext == wxT("png")) return wxBITMAP_TYPE_PNG; else if (ext == wxT("pcx")) return wxBITMAP_TYPE_PCX; else if (ext == wxT("tif") || ext == wxT("tiff")) return wxBITMAP_TYPE_TIF; else return -1; } firewatch/FireWatch.cc0000644000177200017720000001255310402057615014561 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 "FireWatch.h" #include #include #include #include using namespace std; FireWatch::FireWatch() { // default to localhost hostname = wxT("localhost"); defaultPort = 12960; fileCount = 0; resultCount = 0; fireResults.clear(); setlocale(LC_NUMERIC, "C"); } FireWatch::~FireWatch() { if (!fireResults.empty()) fireResults.clear(); } void FireWatch::setServer(wxString host, unsigned short port) { if(host.IsEmpty()) return; hostname = host; defaultPort = port; } bool FireWatch::initialize() { bool status = false; cout << "[FireWatch] " << "connecting to " << hostname.mb_str(); cout << " and initializing..." << endl; status = client.connect(hostname, defaultPort); if (status == false) { wxMessageBox(wxT("could not connect to ") + hostname ); return false; } getServerConfig(); if (path.IsEmpty()) return false; cout << "[FireWatch] " << "fileCount: " << fileCount << endl; cout << "[FireWatch] " << "resultCount: " << resultCount << endl; cout << "[FireWatch] " << "path: " << path.mb_str() << endl; return status; } bool FireWatch::release() { bool status = false; status = client.release(); if (status) cout << "[FireWatch] " << "connection closed" << endl; else cout << "[FireWatch] " << "failed to close connection!" << endl; return status; } vector& FireWatch::getRandomImages() { wxString imageName; wxString result = client.request(wxT("random")); wxStringTokenizer tokenizer(result); // clear fireResults if not empty and we have new results if (tokenizer.HasMoreTokens() && !fireResults.empty()) fireResults.clear(); // get all result images while (tokenizer.HasMoreTokens()) { imageName = tokenizer.GetNextToken(); fireResults.push_back(FireResult(imageName)); } printFireResults(); return fireResults; } vector& FireWatch::retrieve(wxString queryImage, bool newfile, bool save) { wxString token; wxString imageName; double score = 0.f; wxString query; if (newfile) { query = wxT("newfile"); if (save) query += wxT("save"); query += wxT(" "); } else { query = wxT("retrieve +"); } query += queryImage; wxString result = client.request(query); wxStringTokenizer tokenizer(result); // clear fireResults if not empty and we have new results if (tokenizer.HasMoreTokens() && !fireResults.empty()) fireResults.clear(); // get all result images while (tokenizer.HasMoreTokens()) { imageName = tokenizer.GetNextToken(); token = tokenizer.GetNextToken(); if (!token.IsEmpty()) token.ToDouble((double*)&score); fireResults.push_back(FireResult(imageName, score)); } printFireResults(); return fireResults; } void FireWatch::getServerConfig() { wxString token; // request server info with "info" wxString result = client.request(wxString(wxT("info"))); wxStringTokenizer tokenizer(result); // example "info" string from Fire server //filelist 1250 results 10 path /data/datasets/otto/OTTO2/fire-data //extensions 0 scoring linear size 2 weight 0 1 weight 1 1 //suffix 0 tamura.histo.gz jsd suffix 1 color.histo.gz jsd // cut "filelist" tokenizer.GetNextToken(); token = tokenizer.GetNextToken(); if (!token.IsEmpty()) token.ToULong((unsigned long*)&fileCount); // cut "results" tokenizer.GetNextToken(); token = tokenizer.GetNextToken(); if (!token.IsEmpty()) token.ToULong((unsigned long*)&resultCount); // cut "path" tokenizer.GetNextToken(); path = tokenizer.GetNextToken(); } unsigned int FireWatch::setResultCount(unsigned int value) { wxString query = wxT("setresults ") + wxString::Format(wxT("%d"), value); wxString result = client.request(query); // cut "results =" result = result.After('='); if (!result.IsEmpty()) result.ToULong((unsigned long*)&resultCount); cout << "[FireWatch] result count = " << resultCount << endl; return resultCount; } void FireWatch::printFireResults() { cout << endl << "[FireWatch] " << "result images: " << endl; for (unsigned int i = 0; i < fireResults.size(); ++i) { cout << " name: " << fireResults[i].getName().mb_str(); cout << " score: " << fireResults[i].getScore() << endl; } } firewatch/thumbnaildlg.h0000644000177200017720000000735210402057615015222 0ustar koflerkofler///////////////////////////////////////////////////////////////////////////// // Name: thumbnaildlg.h // Purpose: // Author: Julian Smart // Modified by: // Created: 03/16/04 16:08:52 // RCS-ID: // Copyright: (c) Julian Smart // Licence: ///////////////////////////////////////////////////////////////////////////// #ifndef _THUMBNAILDLG_H_ #define _THUMBNAILDLG_H_ #if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "thumbnaildlg.cpp" #endif /*! * Includes */ ////@begin includes #include "wx/wx.h" #include "wx/splitter.h" #include "wx/dirctrl.h" ////@end includes #include "thumbnailctrl.h" /*! * Forward declarations */ ////@begin forward declarations class wxGenericDirCtrl; class wxThumbnailCtrl; ////@end forward declarations /*! * Control identifiers */ ////@begin control identifiers #define ID_IMAGE_BROWSER_DIALOG 21500 #define SYMBOL_WXTHUMBNAILBROWSERDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX #define SYMBOL_WXTHUMBNAILBROWSERDIALOG_TITLE _("Image Browser Dialog") #define SYMBOL_WXTHUMBNAILBROWSERDIALOG_IDNAME ID_IMAGE_BROWSER_DIALOG #define SYMBOL_WXTHUMBNAILBROWSERDIALOG_SIZE wxSize(400, 300) #define SYMBOL_WXTHUMBNAILBROWSERDIALOG_POSITION wxPoint(0, 0) #define ID_IMAGE_BROWSER_SPLITTER 21501 #define ID_IMAGE_BROWSER_DIRCTRL 21502 #define ID_IMAGE_BROWSER_BROWSER 21503 ////@end control identifiers /*! * Compatibility */ #ifndef wxCLOSE_BOX #define wxCLOSE_BOX 0x1000 #endif /*! * wxThumbnailBrowserDialog class declaration */ class wxThumbnailBrowserDialog: public wxDialog { DECLARE_CLASS( wxThumbnailBrowserDialog ) DECLARE_EVENT_TABLE() public: /// Constructors wxThumbnailBrowserDialog( ); wxThumbnailBrowserDialog( wxWindow* parent, wxWindowID id = SYMBOL_WXTHUMBNAILBROWSERDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTHUMBNAILBROWSERDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTHUMBNAILBROWSERDIALOG_POSITION, const wxSize& size = SYMBOL_WXTHUMBNAILBROWSERDIALOG_SIZE, long style = SYMBOL_WXTHUMBNAILBROWSERDIALOG_STYLE ); /// Creation bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXTHUMBNAILBROWSERDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTHUMBNAILBROWSERDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTHUMBNAILBROWSERDIALOG_POSITION, const wxSize& size = SYMBOL_WXTHUMBNAILBROWSERDIALOG_SIZE, long style = SYMBOL_WXTHUMBNAILBROWSERDIALOG_STYLE ); /// Creates the controls and sizers void CreateControls(); /// Shows the images in the given dir void ShowFolder(const wxString& path); /// Accessors void SetSelection(const wxString& filename); wxString GetSelection() const ; wxArrayString GetSelections() const ; /// Custom event handlers void OnLeftClick(wxThumbnailEvent& event); void OnLeftDClick(wxThumbnailEvent& event); ////@begin wxThumbnailBrowserDialog event handler declarations /// wxEVT_COMMAND_TREE_SEL_CHANGED event handler for ID_IMAGE_BROWSER_DIRCTRL void OnImageBrowserDirctrlSelChanged( wxTreeEvent& event ); ////@end wxThumbnailBrowserDialog event handler declarations ////@begin wxThumbnailBrowserDialog member function declarations ////@end wxThumbnailBrowserDialog member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin wxThumbnailBrowserDialog member variables wxGenericDirCtrl* m_dirCtrl; wxThumbnailCtrl* m_imageBrowser; ////@end wxThumbnailBrowserDialog member variables // Work around calling selection callback twice int m_selectionCount; // Initial path or filename, if set wxString m_initialSelection; }; #endif // _THUMBNAILDLG_H_ firewatch/FireWatch.h0000644000177200017720000000566110402057615014425 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ #ifndef FIREWATCH_H_ #define FIREWATCH_H_ #include #include #include #include "FireResult.h" #include "FireClient.h" class FireWatch { public: FireWatch(); virtual ~FireWatch(); void setServer(wxString host, unsigned short port); bool initialize(); bool release(); wxString inline getPath() { return path; } std::vector& getRandomImages(); std::vector& retrieve(wxString queryImage, bool newfile=false, bool save=false); /** * set the number of results to display * * @return the current number of Fire results */ unsigned int setResultCount(unsigned int); /** * @return the current number of Fire results */ inline unsigned int getResultCount() { return resultCount; } private: unsigned short defaultPort; wxString hostname; unsigned int fileCount; unsigned int resultCount; wxString path; FireClient client; std::vector fireResults; void getServerConfig(); void printFireResults(); }; /* * the current Fire commands * map_["info"]=CMD_INFO; map_["retrieve"]=CMD_RETRIEVE; map_["setdist"]=CMD_SETDIST; map_["filelist"]=CMD_FILELIST; map_["setweight"]=CMD_SETWEIGHT; map_["setresults"]=CMD_SETRESULTS; map_["random"]=CMD_RANDOM; map_["listfiles"]=CMD_LISTFILES; map_["savedistances"]=CMD_SAVEDISTANCES; map_["help"]=CMD_HELP; map_["quit"]=CMD_QUIT; map_["bye"]=CMD_BYE; map_["class"]=CMD_CLASS; map_["expand"]=CMD_EXPAND; map_["metaexpand"]=CMD_METAEXPAND; map_["metafeatureinfo"]=CMD_METAFEATUREINFO; map_["textexpand"]=CMD_TEXTEXPAND; map_["saverelevances"]=CMD_SAVERELEVANCES; map_["retrieveandsaveranks"]=CMD_RETRIEVEANDSAVERANKS; map_["setextensions"]=CMD_SETEXTENSION; map_["metaretrieve"]=CMD_METARETRIEVE; map_["textretrieve"]=CMD_TEXTRETRIEVE; map_["setscoring"]=CMD_SETSCORING; map_["password"]=CMD_PASSWORD; map_["interactor"]=CMD_INTERACTOR; map_["newfile"]=CMD_NEWFILE; map_["newfilesave"]=CMD_NEWFILESAVE; * */ #endif /*FIREWATCH_H_*/ firewatch/FireClient.cc0000644000177200017720000001130610402057615014724 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 using namespace std; #include "FireClient.h" BEGIN_EVENT_TABLE(FireClient, wxEvtHandler) EVT_SOCKET(SOCKET_ID, FireClient::OnSocketEvent) END_EVENT_TABLE() FireClient::FireClient() { socket = 0; connected = false; socketInputStream = 0; textInputStream = 0; input = wxT(""); } FireClient::~FireClient() { if (socket != 0) socket->Destroy(); } bool FireClient::connect(wxString host, unsigned short port) { if (host.IsEmpty() || port == 0) return false; wxIPV4address addr; addr.Hostname(host); addr.Service(port); // Create the socket socket = new wxSocketClient(); // Set up the event handler and subscribe to most events socket->SetEventHandler(*this, SOCKET_ID); socket->SetNotify(wxSOCKET_CONNECTION_FLAG | wxSOCKET_LOST_FLAG); // socket->SetFlags(wxSOCKET_WAITALL); socket->Notify(true); // connect socket->Connect(addr, false); // Wait until the request completes or until we decide to give up bool waitmore = true; unsigned short waitCount = 0; while ( !socket->WaitOnConnect(0, 300) && waitmore ) { // possibly give some feedback to the user, // and update waitmore as needed. if(++waitCount > 20) waitmore = false; } connected = socket->IsConnected(); if (connected) { // connect SocketInputStream with TextInputStream for reading input socketInputStream = new wxSocketInputStream(*socket); textInputStream = new wxTextInputStream(*socketInputStream); } cout << "[FireClient] " << "connection " << (connected?"established":"failed") << endl; return connected; } wxString FireClient::request(wxString query) { if (!connected || query.IsEmpty()) return wxString(wxT("")); query += wxT("\r\n"); // clear input string before awaiting new input if (!input.IsEmpty()) input.Clear(); // send query to server socket->Write(query.mb_str(), query.Length()); if (textInputStream != 0) { input = textInputStream->ReadLine(); } // wait until new input comes in // Wait until the request completes or until we decide to give up /* bool waitmore = true; unsigned short waitCount = 0; while ( !socket->WaitForRead(0, 300) && waitmore ) { // possibly give some feedback to the user, // and update waitmore as needed. if(++waitCount > 20) waitmore = false; } */ /* Wait for read does not return if there IS sth to read! * I don't understand this and I can't believe we must use * an extra thread for this! * It is also not acceptable to wait one second for every * transaction! * !!! solve !!! */ //socket->WaitForRead(3); cout << "[FireClient] " << "query: " << query.mb_str() << endl; cout << "[FireClient] " << "result: " << input.mb_str() << endl; return input; } bool FireClient::release() { // be kind and say goodbye to the fire server socket->Write(wxT("bye\r\n"), 5); socket->Destroy(); connected = false; return true; } void FireClient::OnSocketEvent(wxSocketEvent& event) { // The socket that had the event //wxSocketBase* socket = event.GetSocket(); switch(event.GetSocketEvent()) { case wxSOCKET_CONNECTION: { connected = true; break; } case wxSOCKET_OUTPUT: { // not handled break; } case wxSOCKET_INPUT: { // Reads a line from the input stream and returns it // (without the end of line character). cout << "[FireClient] " << "socket input event" << endl; //cout << "socket input: " << input << endl; break; } case wxSOCKET_LOST: { socket->Destroy(); connected = false; break; } } } firewatch/FireResult.h0000644000177200017720000000272110402057615014627 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ #ifndef FIRERESULT_H_ #define FIRERESULT_H_ #include class FireResult { public: FireResult() { FireResult(wxT("")); } FireResult(wxString n, float sc = 0.f) { name = n; score = sc; } virtual ~FireResult() {} void operator=(const FireResult& rhs) { this->name = rhs.name; this->score=rhs.score; } void inline setName(wxString n) { name = n; } wxString inline getName() { return name; } void inline setScore(float sc) { score = sc; } float inline getScore() { return score; } private: wxString name; float score; }; #endif /*FIRERESULT_H_*/ firewatch/FireClient.h0000644000177200017720000000344510402057615014573 0ustar koflerkofler/* * Copyright (C) 2006 DFKI GmbH * Image Understanding and Pattern Recognition Lab * Author: Christian Kofler * * 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 */ #ifndef NETWORKER_H_ #define NETWORKER_H_ #include #include #include #include #define SOCKET_ID 12345 class FireClient : public wxEvtHandler { public: FireClient(); virtual ~FireClient(); bool connect(wxString host, unsigned short port); wxString request(wxString query); bool release(); void OnSocketEvent(wxSocketEvent& event); inline bool isConnected() { return connected; } private: /** the socket for the connection */ wxSocketClient* socket; /** * socketInputStream is redirected to a textInputStream * that can be read with Readline() */ wxSocketInputStream* socketInputStream; wxTextInputStream* textInputStream; /** the received input */ wxString input; /** indicates whether or not a connection to the fire server exists */ bool connected; DECLARE_EVENT_TABLE() }; #endif /*NETWORKER_H_*/ firewatch/makefile0000644000177200017720000000344610402057615014077 0ustar koflerkofler############################################################ # 2005-07-27 - Christian Kofler ############################################################ # usage: # - define name of binary in TARGET # - put all src files to compile in SRC # it is assumed that they are .cc ! # - put paths to additional includes in INCLUDE # - put paths to additional libs in LDFLAGS # - put all used libs in LDLIBS # # all: builds standard app # clean: removes app objects etc # run: runs application ############################################################ SHELL=/bin/bash # the resulting binary TARGET = firewatch # the src files to compile SRC = Application.cc RootFrame.cc thumbnailctrl.cc SelectDialog.cc \ thumbnaildlg.cc FireItem.cc FireWatch.cc FireClient.cc # paths to includes (-Ipath) INCLUDE = # paths to libs (-Lpath) LDFLAGS = `wx-config --libs` # not unicode #LDFLAGS = `/usr/local/bin/wx-config --libs` # unicode #LDFLAGS = `/usr/bin/wx-config --libs` # on iupr3, gwinner's account #LDFLAGS = `/home2/gwinner/wx-config --libs` # libs (-llib) LDLIBS= # flags CFLAGS= `wx-config --cxxflags` # not unicode #CFLAGS= `/usr/local/bin/wx-config --cxxflags` # unicode #CFLAGS= `/usr/bin/wx-config --cxxflags` # on iupr3, gwinner's account #CFLAGS= `/home2/gwinner/wx-config --cxxflags` ############################################################ # standard CC=g++ CXX=$(CC) OBJ=$(SRC:.cc=.o) #debug symbols #CFLAGS+=-g -O4 -Wall -DDEBUG CFLAGS+= -O4 ############################################################ # rules .PHONY: all clean run all: $(TARGET) clean: -rm $(TARGET) -rm $(OBJ) -rm *~ run: all ./$(TARGET) localhost 12960 $(TARGET): $(OBJ) $(CC) $(OBJ) $(INCLUDE) $(CFLAGS) $(LDFLAGS) \ $(LDLIBS) -o $(TARGET) %.o: %.cc $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@