Scope
FrameScanBasePage.cpp
1 #include "stdafx.h"
2 #include "FrameScanBasePage.h"
3 #include "PresetNameDlg.h"
4 
5 namespace scope {
6 namespace gui {
7 
9  : CNoScanBasePage(_area, _scanvecparams)
10  , zoom_edit(&_scanvecparams.zoom, true, true)
11  , zoom_scroll(&_scanvecparams.zoom, 0.1, 1, true, true)
12  , xres_edit(&_scanvecparams.xres, true, true)
13  , yres_edit(&_scanvecparams.yres, true, true)
14  , xaspectratio_edit(&_scanvecparams.xaspectratio, true, true)
15  , yaspectratio_edit(&_scanvecparams.yaspectratio, true, true)
16  , averages_edit(&scope_controller.GuiParameters.areas[area]->daq.averages, true, true)
17  , scannerdelay_edit(&scope_controller.GuiParameters.areas[area]->daq.scannerdelay, true, true)
18  , xoffset_edit(&_scanvecparams.xoffset, true, true)
19  , yoffset_edit(&_scanvecparams.yoffset, true, true)
20  , framerate_edit(&scope_controller.GuiParameters.areas[area]->framerate, true, true)
21  , frametime_edit(&scope_controller.GuiParameters.areas[area]->frametime, true, true)
22  , linerate_edit(&scope_controller.GuiParameters.areas[area]->linerate, true, true)
23  , diagram(area, &scope_controller.GuiParameters) {
24 
25  // For disabling save preset button and presets combo during scanning
27 }
28 
30  // Disconnect
31  rwstateconnection.disconnect();
32 }
33 
34 BOOL CFrameScanBasePage::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
35  // Call base class dialog initialization
36  CNoScanBasePage::OnInitDialog(wndFocus, lInitParam);
37 
38  // attach the dialog controls to the edit objects
39  presets_combo.Attach(GetDlgItem(IDC_PRESETS_COMBO));
40  savepreset_button.Attach(GetDlgItem(IDC_SAVEPRESET_BUTTON));
41  deletepreset_button.Attach(GetDlgItem(IDC_DELETEPRESET_BUTTON));
42  zoom_edit.AttachToDlgItem(GetDlgItem(IDC_ZOOM_EDIT));
43  zoom_scroll.AttachToDlgItem(GetDlgItem(IDC_ZOOM_SCROLL));
44  xres_edit.AttachToDlgItem(GetDlgItem(IDC_PIXELX_EDIT));
45  yres_edit.AttachToDlgItem(GetDlgItem(IDC_PIXELY_EDIT));
46  xaspectratio_edit.AttachToDlgItem(GetDlgItem(IDC_ASPECTRATIOX_EDIT));
47  yaspectratio_edit.AttachToDlgItem(GetDlgItem(IDC_ASPECTRATIOY_EDIT));
48  averages_edit.AttachToDlgItem(GetDlgItem(IDC_AVERAGES_EDIT));
49  scannerdelay_edit.AttachToDlgItem(GetDlgItem(IDC_SCANNERDELAY_EDIT));
50  xoffset_edit.AttachToDlgItem(GetDlgItem(IDC_XOFFSET_EDIT));
51  yoffset_edit.AttachToDlgItem(GetDlgItem(IDC_YOFFSET_EDIT));
52  framerate_edit.AttachToDlgItem(GetDlgItem(IDC_FRAMERATE));
53  frametime_edit.AttachToDlgItem(GetDlgItem(IDC_FRAMETIME));
54  linerate_edit.AttachToDlgItem(GetDlgItem(IDC_LINERATE));
55 
56  diagram.AttachToDlgItem(GetDlgItem(IDC_FPUDIAGRAM));
57 
58  // Set before by CNoScanBasePage::OnInitDialog
59  initialized = initialized && true;
60 
61  SetMsgHandled(true);
62 
63  return 0;
64 }
65 
66 LRESULT CFrameScanBasePage::OnPresetSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
67  std::shared_ptr<std::wstring> strname = std::make_shared<std::wstring>(L"PresetName");
68  CPresetNameDlg dlg(strname);
69  if ( dlg.DoModal(::GetActiveWindow()) == 0 ) {
70  scope_controller.GuiParameters.areas[area]->SaveToPreset(*strname);
71  FillPresetCombo();
72  presets_combo.SelectString(0, strname->c_str());
73  }
74  return 0;
75 }
76 
77 LRESULT CFrameScanBasePage::OnPresetDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
78  int32_t sel = presets_combo.GetCurSel();
79  if ( sel > 0 ) {
80  std::vector<wchar_t> buff(presets_combo.GetLBTextLen(sel)+1, L' '); // +1 since GetLBTextLen does not count terminating \0 ... sigh...
81  presets_combo.GetLBText(sel, buff.data());
82  scope_controller.GuiParameters.areas[area]->DeletePreset(std::wstring(buff.begin(), buff.end()-1));
83  FillPresetCombo();
84  }
85  return 0;
86 }
87 
88 LRESULT CFrameScanBasePage::OnPresetSelection(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
89  int32_t sel = presets_combo.GetCurSel();
90  if ( sel > 0 ) {
91  std::vector<wchar_t> buff(presets_combo.GetLBTextLen(sel)+1, L' '); // +1 since GetLBTextLen does not count terminating \0 ... sigh...
92  presets_combo.GetLBText(sel, buff.data());
93  scope_controller.GuiParameters.areas[area]->LoadFromPreset(std::wstring(buff.begin(), buff.end()-1));
94  }
95  return 0;
96 }
97 
99  // Do not call window procedures on non-initialized dialog
100  if ( initialized ) {
101  // Check if to disable or to enable now
102  // Since the other controls are connected to GuiParameters they are taken care of automatically
103  BOOL enabler = (scope_controller.ReadOnlyWhileScanning()==true)?FALSE:TRUE;
104  presets_combo.EnableWindow(enabler);
105  savepreset_button.EnableWindow(enabler);
106  deletepreset_button.EnableWindow(enabler);
107  }
108 }
109 
110 void CFrameScanBasePage::FillPresetCombo() {
111  // Clear the box
112  presets_combo.ResetContent();
113 
114  // custom preset allows defining new presets etc
115  presets_combo.AddString(L"Custom...");
116 
117  // load the presets' names into the combo box
118  for ( const auto& p : scope_controller.GuiParameters.areas[area]->Currentframe().presets )
119  presets_combo.AddString(p->name().c_str());
120 
121  // select the first preset (the custom one)
122  presets_combo.SetCurSel(0);
123 }
124 
125 
126 
127 }
128 
129 }
boost::signals2::connection ConnectGUI(signalchange_t::slot_type slot)
Connect signal to slot to GUI.
CScopeEditCtrl< uint32_t > yres_edit
y resolution edit control
CScopeEditCtrl< double > frametime_edit
frametime edit control (edit disabled)
CScopeEditCtrl< double > framerate_edit
framerate edit control (edit disabled)
*bool AttachToDlgItem(HWND hWnd)
()
CScopeEditCtrl< double > yoffset_edit
offset of the y scanner center position (-1..1, relative to maximum FOV)
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.
Definition: ScopeEditCtrl.h:68
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
boost::signals2::connection rwstateconnection
Connection object to the ScopeController::ReadOnlyWhileScanning for setting controls RW state...
const uint32_t area
for which area are the image settings
bool initialized
true after dialog is initialized
ScopeController scope_controller
our ScopeController here
CScopeEditCtrl< double > xoffset_edit
offset of the x scanner center position (-1..1, relative to maximum FOV)
virtual ~CFrameScanBasePage()
Disconnect from ScopeController::ReadOnlyWhileScanning.
This is the include file for standard system include files, or project specific include files that ar...
CScopeFOVDiagram diagram
diagram displaying FOV positions
CScopeEditCtrl< double > yaspectratio_edit
y aspect ratio edit control
CButton deletepreset_button
delete preset button, only here for easy disabling during scanning
Parameters for a ScannerVectorFrameBasic.
Definition: Framescan.h:45
BOOL AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item and set range and tick frequency.
CFrameScanBasePage(const uint32_t &_area, parameters::ScannerVectorFrameBasic &_scanvecparams)
We need a pointer to a basic ScannerVector (could be e.g.
CScopeEditCtrl< double > xaspectratio_edit
x aspect ratio edit control
CScopeEditCtrl< uint32_t > averages_edit
number of averages edit control
void SetReadOnlyWhileScanning() override
Connected to ScopeController::ReadOnlyWhileScanning.
CButton savepreset_button
save preset button, only here for easy disabling during scanning
CScopeEditCtrl< uint32_t > xres_edit
x resolution edit control
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
CScopeScrollbarCtrl zoom_scroll
zoom scrollbar control
CScopeEditCtrl< double > scannerdelay_edit
scannerdelay in us
static ScopeNumber< bool > ReadOnlyWhileScanning
Set to true while scanning, GUI elements can connect to this to disable buttons and controls (that ar...
CComboBox presets_combo
Connection object to the ScopeController::ReadOnlyWhileScanning for setting controls RW state...
Base class for all scanning and non-scanning scan property pages, i.e.
CScopeEditCtrl< double > zoom_edit
zoom edit control
CScopeEditCtrl< double > linerate_edit
linerate edit control (edit disabled)