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)
80 static bool isMadeByRc(
const wxDataViewListCtrl &device_list,
unsigned int row)
87 static bool isRcVisard(
const wxVector<wxVariant> &device)
92 static bool isRcVisard(
const wxDataViewListCtrl &device_list,
unsigned int row)
99 wxFrame(NULL, wxID_ANY, title, pos, wxSize(1080,350)),
100 device_list_(nullptr),
101 discover_button_(nullptr),
102 filter_input_(nullptr),
103 reset_button_(nullptr),
104 force_ip_button_(nullptr),
105 reset_dialog_(nullptr),
106 force_ip_dialog_(nullptr),
107 about_dialog_(nullptr),
108 menu_event_item_(nullptr),
109 only_rc_sensors_(true),
113 wxIcon icon_128(logo_128_xpm);
118 spinner_.Load(gif_stream, wxANIMATION_TYPE_GIF);
121 wxMenu *menuFile =
new wxMenu();
122 menuFile->Append(wxID_EXIT);
124 wxMenu *menuHelp =
new wxMenu();
125 menuHelp->Append(wxID_HELP);
126 menuHelp->Append(wxID_ABOUT);
128 wxMenuBar *menuBar =
new wxMenuBar();
129 menuBar->Append(menuFile,
"&File");
130 menuBar->Append(menuHelp,
"&Help");
136 auto *panel =
new wxPanel(
this, wxID_ANY);
137 auto *vbox =
new wxBoxSizer(wxVERTICAL);
141 auto *button_box =
new wxBoxSizer(wxHORIZONTAL);
145 button_box->AddSpacer(10);
146 button_box->Add(
new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
147 wxSize(-1,30), wxLI_VERTICAL));
148 button_box->AddSpacer(10);
153 "Only Roboception devices",
154 wxDefaultPosition, wxSize(-1, h));
156 button_box->Add(only_rc_cbox, 1);
158 button_box->AddSpacer(10);
159 button_box->Add(
new wxStaticLine(panel, wxID_ANY, wxDefaultPosition,
160 wxSize(-1,30), wxLI_VERTICAL));
161 button_box->AddSpacer(10);
163 auto *filter_text =
new wxStaticText(panel, wxID_ANY,
"Filter");
164 button_box->Add(filter_text, 1, wxTOP, 6);
166 button_box->AddSpacer(10);
168 wxDefaultPosition, wxSize(150, -1));
172 button_box->Add(-1, 0, wxEXPAND);
175 wxPoint(-1,-1), wxSize(32,32));
178 vbox->Add(button_box, 0, wxALL, 10);
183 auto *data_box =
new wxBoxSizer(wxHORIZONTAL);
190 wxDATAVIEW_CELL_INERT,
192 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
194 wxDATAVIEW_CELL_INERT,
196 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
198 wxDATAVIEW_CELL_INERT,
200 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
202 wxDATAVIEW_CELL_INERT,
204 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
206 wxDATAVIEW_CELL_INERT,
208 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
210 wxDATAVIEW_CELL_INERT,
212 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
214 wxDATAVIEW_CELL_INERT,
216 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
218 wxDATAVIEW_CELL_INERT,
220 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE);
222 device_list_->SetToolTip(
"Double-click row to open WebGUI in browser.");
226 vbox->Add(data_box, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
230 auto *button_box =
new wxBoxSizer(wxHORIZONTAL);
237 "Set temporary IP address");
244 button_box->Add(-1, 0, wxEXPAND);
247 wxDefaultPosition, wxSize(h,h));
248 button_box->Add(help_button, 0);
250 vbox->Add(button_box, 0, wxTOP | wxLEFT | wxRIGHT, 10);
253 panel->SetSizer(vbox);
256 help_ctrl_ =
new wxHtmlHelpController(wxHF_DEFAULT_STYLE, panel);
260 wxEVT_COMMAND_BUTTON_CLICKED,
263 wxEVT_COMMAND_DISCOVERY_COMPLETED,
266 wxEVT_COMMAND_DISCOVERY_ERROR,
269 wxEVT_COMMAND_BUTTON_CLICKED,
272 wxEVT_COMMAND_BUTTON_CLICKED,
275 wxEVT_COMMAND_BUTTON_CLICKED,
278 wxEVT_COMMAND_BUTTON_CLICKED,
281 wxEVT_DATAVIEW_ITEM_ACTIVATED,
284 wxEVT_DATAVIEW_SELECTION_CHANGED,
287 wxEVT_DATAVIEW_ITEM_CONTEXT_MENU,
340 wxPersistentRegisterAndRestore(
this,
"discover_frame");
376 if (thread->Run() != wxTHREAD_NO_ERROR)
378 std::cerr <<
"Could not spawn thread" << std::endl;
397 std::vector<bool> show_in_reset_dialog;
402 const bool matches_filter = [&] {
406 const bool none = std::none_of(d.begin(), d.end(), [&filter_text](
const wxVariant& v) {
407 const auto s = v.GetString().ToStdString();
408 return wildcardMatch(s.begin(), s.end(), filter_text.begin(), filter_text.end());
421 show_in_reset_dialog.push_back(
isRcVisard(d));
432 std::ostringstream oss;
433 oss <<
"An error occurred during discovery: " <<
event.GetString();
434 wxMessageBox(oss.str(),
"Error", wxOK | wxICON_ERROR);
461 const auto item =
event.GetItem();
464 if (row == wxNOT_FOUND)
474 const auto item =
event.GetItem();
477 if (row == wxNOT_FOUND)
501 menu.Append(
ID_CopyIP,
"Copy IP address");
506 menu.AppendSeparator();
508 menu.AppendSeparator();
555 const auto cell =
device_list_->GetTextValue(row, column);
557 if (wxTheClipboard->Open())
559 wxTheClipboard->SetData(
new wxTextDataObject(cell));
560 wxTheClipboard->Close();
645 if (row != wxNOT_FOUND)
655 if (row != wxNOT_FOUND)
665 if (row != wxNOT_FOUND)
678 static_cast<unsigned int>(row),
IP);
679 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.
static const std::string RC_CUBE
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.