MCPcopy Create free account
hub / github.com/andybarry/makerscanner / OnButCaptureClick

Method OnButCaptureClick

ActiveStereoMain.cpp:290–352  ·  view source on GitHub ↗

Scan button clicked -- start a new scan!

Source from the content-addressed store, hash-verified

288
289// Scan button clicked -- start a new scan!
290void ActiveStereoFrame::OnButCaptureClick(wxCommandEvent& event)
291{
292 wxString directory = wxT("");
293
294 // read the last directory used
295 wxConfig *config = (wxConfig*)wxConfigBase::Get();
296 if (config->Read(wxT("ScanDir"), &directory))
297 {
298 // check for a not valid directory
299 if (wxDir::Exists(directory) == false)
300 {
301 directory = wxT("");
302 }
303 } else {
304 // failed to read config
305 directory = wxT("");
306 }
307 // ask where to save the point cloud file
308 wxFileDialog dialog(this, wxT("Save pointcloud file"), directory, wxT("pointcloud.ply"), wxT("*.ply"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
309 if (dialog.ShowModal() != wxID_OK)
310 {
311 // user clicked cancel
312 return;
313 }
314
315 // get the filename and path as a string
316 pointcloudFilename = dialog.GetPath();
317
318 wxFileName dir(pointcloudFilename);
319 if (dir.IsOk() == true)
320 {
321 // save the new selected directory
322 config->Write(wxT("ScanDir"), dir.GetPath());
323
324 }
325
326 // clear the point cloud file
327 wxFFile file(pointcloudFilename, wxT("w"));
328 if (file.IsOpened())
329 {
330 txtLog->AppendText(wxT("\nWriting point cloud file:\n\t"));
331 txtLog->AppendText(pointcloudFilename);
332 file.Close();
333 } else {
334 txtLog->AppendText(wxT("\nPoint cloud file did not open!"));
335 return;
336 }
337
338 // Disable buttons/sliders during scanning
339 SetGUIStateDuringScan(true);
340
341 if (!cam)
342 {
343 cam = new Cameras(txtLog, this, scanStatus, cameraNum); // create the camera object if it doesn't already exist
344 }
345
346 cam->SetThresholdPixelValue(sliderImageThreshold->GetValue());
347 cam->SetBrightnessFilterValue(float(sliderBrightnessFilter->GetValue()) / 100.0);

Callers

nothing calls this directly

Calls 3

StartScanMethod · 0.80

Tested by

no test coverage detected