55 #include <wx/dataview.h> 56 #include <wx/button.h> 57 #include <wx/animate.h> 58 #include <wx/mstream.h> 62 #include <wx/clipbrd.h> 64 #include <wx/msgdlg.h> 65 #include <wx/html/helpctrl.h> 66 #include <wx/cshelp.h> 67 #include <wx/statline.h> 68 #include <wx/persist/toplevel.h> 70 #include "resources/logo_128.xpm" 73 static bool isMadeByRc(
const wxVector<wxVariant> &device)
79 static bool isMadeByRc(
const wxDataViewListCtrl &device_list,
unsigned int row)
85 static bool isRcVisard(
const wxVector<wxVariant> &device)
90 static bool isRcVisard(
const wxDataViewListCtrl &device_list,
unsigned int row)
97 wxFrame(NULL, wxID_ANY, title, pos, wxSize(1080,350)),
98 device_list_(nullptr),
99 discover_button_(nullptr),
100 filter_input_(nullptr),
101 reset_button_(nullptr),
102 force_ip_button_(nullptr),
103 reset_dialog_(nullptr),
104 force_ip_dialog_(nullptr),
105 about_dialog_(nullptr),
106 menu_event_item_(nullptr),
107 only_rc_sensors_(true),
111 wxIcon icon_128(logo_128_xpm);
116 spinner_.Load(gif_stream, wxANIMATION_TYPE_GIF);
119 wxMenu *menuFile =
new wxMenu();
120 menuFile->Append(wxID_EXIT);
122 wxMenu *menuHelp =
new wxMenu();
123 menuHelp->Append(wxID_HELP);
124 menuHelp->Append(wxID_ABOUT);
126 wxMenuBar *menuBar =
new wxMenuBar();
127 menuBar->Append(menuFile,
"&File");
128 menuBar->Append(menuHelp,
"&Help");
134 auto *panel =
new wxPanel(
this, wxID_ANY);
135 auto *vbox =
new wxBoxSizer(wxVERTICAL);
139 auto *button_box =
new wxBoxSizer(wxHORIZONTAL);
143 button_box->AddSpacer(10);
144 button_box->Add(
new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
145 wxSize(-1,30), wxLI_VERTICAL));
146 button_box->AddSpacer(10);
151 "Only rc_... devices",
152 wxDefaultPosition, wxSize(-1, h));
154 button_box->Add(only_rc_cbox, 1);
156 button_box->AddSpacer(10);
157 button_box->Add(
new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
158 wxSize(-1,30), wxLI_VERTICAL));
159 button_box->AddSpacer(10);
161 auto *filter_text =
new wxStaticText(panel, wxID_ANY,
"Filter");
162 button_box->Add(filter_text, 1, wxTOP, 6);
164 button_box->AddSpacer(10);
166 wxDefaultPosition, wxSize(150, -1));
170 button_box->Add(-1, 0, wxEXPAND);
173 wxPoint(-1,-1), wxSize(32,32));
176 vbox->Add(button_box, 0, wxALL, 10);
181 auto *data_box =
new wxBoxSizer(wxHORIZONTAL);
188 wxDATAVIEW_CELL_INERT,
190 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
192 wxDATAVIEW_CELL_INERT,
194 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
196 wxDATAVIEW_CELL_INERT,
198 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
200 wxDATAVIEW_CELL_INERT,
202 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
204 wxDATAVIEW_CELL_INERT,
206 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
208 wxDATAVIEW_CELL_INERT,
210 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
212 wxDATAVIEW_CELL_INERT,
214 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
216 wxDATAVIEW_CELL_INERT,
218 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
220 device_list_->SetToolTip(
"Double-click row to open WebGUI in browser.");
224 vbox->Add(data_box, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
228 auto *button_box =
new wxBoxSizer(wxHORIZONTAL);
235 "Set temporary IP address");
242 button_box->Add(-1, 0, wxEXPAND);
245 wxDefaultPosition, wxSize(h,h));
246 button_box->Add(help_button, 0);
248 vbox->Add(button_box, 0, wxTOP | wxLEFT | wxRIGHT, 10);
251 panel->SetSizer(vbox);
254 help_ctrl_ =
new wxHtmlHelpController(wxHF_DEFAULT_STYLE, panel);
258 wxEVT_COMMAND_BUTTON_CLICKED,
261 wxEVT_COMMAND_DISCOVERY_COMPLETED,
264 wxEVT_COMMAND_DISCOVERY_ERROR,
267 wxEVT_COMMAND_BUTTON_CLICKED,
270 wxEVT_COMMAND_BUTTON_CLICKED,
273 wxEVT_COMMAND_BUTTON_CLICKED,
276 wxEVT_COMMAND_BUTTON_CLICKED,
279 wxEVT_DATAVIEW_ITEM_ACTIVATED,
282 wxEVT_DATAVIEW_SELECTION_CHANGED,
285 wxEVT_DATAVIEW_ITEM_CONTEXT_MENU,
338 wxPersistentRegisterAndRestore(
this,
"discover_frame");
374 if (thread->Run() != wxTHREAD_NO_ERROR)
376 std::cerr <<
"Could not spawn thread" << std::endl;
395 std::vector<bool> show_in_reset_dialog;
400 const bool matches_filter = [&] {
404 const bool none = std::none_of(d.begin(), d.end(), [&filter_text](
const wxVariant& v) {
405 const auto s = v.GetString().ToStdString();
406 return wildcardMatch(s.begin(), s.end(), filter_text.begin(), filter_text.end());
419 show_in_reset_dialog.push_back(
isRcVisard(d));
430 std::ostringstream oss;
431 oss <<
"An error occurred during discovery: " <<
event.GetString();
432 wxMessageBox(oss.str(),
"Error", wxOK | wxICON_ERROR);
459 const auto item =
event.GetItem();
462 if (row == wxNOT_FOUND)
472 const auto item =
event.GetItem();
475 if (row == wxNOT_FOUND)
499 menu.Append(
ID_CopyIP,
"Copy IP address");
504 menu.AppendSeparator();
506 menu.AppendSeparator();
553 const auto cell =
device_list_->GetTextValue(row, column);
555 if (wxTheClipboard->Open())
557 wxTheClipboard->SetData(
new wxTextDataObject(cell));
558 wxTheClipboard->Close();
643 if (row != wxNOT_FOUND)
653 if (row != wxNOT_FOUND)
663 if (row != wxNOT_FOUND)
676 static_cast<unsigned int>(row),
IP);
677 wxLaunchDefaultBrowser(
"http://" + ip_wxstring +
"/");
static const std::string ROBOCEPTION
void openResetDialog(int row)
Open device reset dialog.
void onFilterTextChange(wxCommandEvent &evt)
Event handler for change of the filter text box.
static bool isRcVisard(const wxVector< wxVariant > &device)
void openReconnectDialog(int row)
Open Reconnect dialog.
static bool isMadeByRc(const wxVector< wxVariant > &device)
static const std::string RC_VISARD
Dialog for Magic Packets reset of rc_visard.
void onHelp(wxCommandEvent &)
Event handler for "help" item in window menu.
void onForceIpButton(wxCommandEvent &)
Event handler for ForceIP button click.
DiscoverFrame(const wxString &title, const wxPoint &pos)
Constructor.
void onReconnectButton(wxCommandEvent &)
Event handler for Reconnect button click.
bool wildcardMatch(std::string::const_iterator str_first, std::string::const_iterator str_last, std::string::const_iterator p_first, std::string::const_iterator p_last)
std::vector< wxVector< wxVariant > > last_data_
std::unique_ptr< std::pair< int, int > > menu_event_item_
ReconnectDialog * reconnect_dialog_
void onDeviceDoubleClick(wxDataViewEvent &event)
Event handler for double click on a device.
void onDiscoveryError(wxThreadEvent &event)
Event handler for erroneous device discovery.
void onOpenWebGUI(wxMenuEvent &)
Event handler for "open web gui" context menu item.
void onResetContextMenu(wxMenuEvent &)
Event handler for "reset" context menu item.
ResetDialog * reset_dialog_
Dialog for sending FORCEIP_CMD to camera.
void onOnlyRcCheckbox(wxCommandEvent &evt)
Event handler for change of the "only RC cameras" checkbox.
void onResetButton(wxCommandEvent &)
Event handler for Reset button click.
Main window in which the table of discovered devices is displayed.
void updateDeviceList(const std::vector< wxVector< wxVariant >> &d)
Updates the device table.
void openForceIpDialog(int row)
Open Force IP dialog.
wxButton * force_ip_button_
ForceIpDialog * force_ip_dialog_
AboutDialog * about_dialog_
void onCopy(wxMenuEvent &)
Event handler for "copy" context menu item.
wxAnimationCtrl * spinner_ctrl_
wxButton * discover_button_
Thread in which the discovery of devices is run.
Dialog for sending FORCEIP_CMD with IP set to 0 to camera.
unsigned char logo_32_rotate_gif[]
void onDataViewContextMenu(wxDataViewEvent &event)
Event handler for right mouse button click on device.
void openWebGUI(int row)
Open WebGUI for device in specific row.
void setDiscoveredSensors(const wxDataViewListModel *sensor_list, const std::vector< bool > &show={})
Set list of discovered devices to provide a drop down menu to the user.
void onDiscoveryCompleted(wxThreadEvent &event)
Event handler for completed device discovery.
void clearBusy()
Stop spinner rotation.
wxTextCtrl * filter_input_
void onDiscoverButton(wxCommandEvent &)
Event handler for Discovery button click.
void onExit(wxCommandEvent &)
Event handler for exit command.
wxHtmlHelpController * help_ctrl_
wxButton * reconnect_button_
void onForceIpContextMenu(wxMenuEvent &)
Event handler for "force ip" context menu item.
void onDeviceSelection(wxDataViewEvent &event)
Event handler for selection of a device.
void setActiveSensor(const unsigned int row)
Select a specific device of the list set by setDiscoveredSensors.
void onReconnectContextMenu(wxMenuEvent &)
Event handler for "reconnect" context menu item.
wxDataViewListCtrl * device_list_
void onHelpDiscovery(wxCommandEvent &)
Event handler for help button.
void onAbout(wxCommandEvent &)
Event handler for "about" item in window menu.
void setBusy()
Let spinner rotate.