Scope
StackSettingsPage.cpp
1 #include "stdafx.h"
2 #include "StackSettingsPage.h"
3 
4 namespace scope {
5  namespace gui {
6 
7 CStackSettingsPage::CStackSettingsPage(void)
8  : initialized(false)
9  , start_stack_button(&scope_controller.StartStackButton)
10  , startat_edit(&scope_controller.GuiParameters.stack.startat[0].position, true, true)
11  , stopat_edit(&scope_controller.GuiParameters.stack.stopat[0].position, true, true)
12  , spacing_edit(&scope_controller.GuiParameters.stack.spacing, true, true)
13  , starthere_button(&scope_controller.StackStartHereButton)
14  , stophere_button(&scope_controller.StackStopHereButton)
15  , stack_progress(&scope_controller.PlaneCounter)
16  , zdevicetype(ZDeviceHelper::ZStage) {
18 }
19 
20 BOOL CStackSettingsPage::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
21  start_stack_button.AttachToDlgItem(GetDlgItem(IDC_STARTSTACK_BUTTON));
22  startat_edit.AttachToDlgItem(GetDlgItem(IDC_STARTAT_EDIT));
23  stopat_edit.AttachToDlgItem(GetDlgItem(IDC_STOPAT_EDIT));
24  spacing_edit.AttachToDlgItem(GetDlgItem(IDC_SPACING_EDIT));
25  starthere_button.AttachToDlgItem(GetDlgItem(IDC_STARTHERE_BUTTON));
26  stophere_button.AttachToDlgItem(GetDlgItem(IDC_STOPHERE_BUTTON));
27  stack_progress.AttachToDlgItem(GetDlgItem(IDC_STACK_PROGRESS));
28  zstage_button.Attach(GetDlgItem(IDC_ZSTAGE_RADIO));
29  fastz_button.Attach(GetDlgItem(IDC_ETL_RADIO));
30  recalc_button.Attach(GetDlgItem(IDC_RECALC_BUTTON));
31  lambda_static.Attach(GetDlgItem(IDC_LAMBDA_STATIC));
32 
33  zstage_button.SetCheck(BM_SETCHECK);
34  zdevicetype = ZDeviceHelper::ZStage;
36 
37  planes_list.Attach(GetDlgItem(IDC_SLICES_LIST));
38  planes_list.InsertColumn(0, L"Slice", 0, 35);
39  planes_list.InsertColumn(1, L"Z Stage", 0, 50);
40  CString label(L"");
41  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
42  label.Format(L"Pockels %d", a+1);
43  planes_list.InsertColumn(2+2*a, label, 0, 60);
44  label.Format(L"FastZ %d", a+1);
45  planes_list.InsertColumn(3+2*a, label, 0, 50);
46  }
47  SetMsgHandled(false);
48  initialized = true;
49  return 0;
50 }
51 
52 LRESULT CStackSettingsPage::OnZControlRadio(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
53  // Could have used DDX, but this seems easier...
54  // Get the checked one and set local and GuiParameters
55  if ( zstage_button.GetCheck() == BST_CHECKED )
56  zdevicetype = ZDeviceHelper::ZStage;
57  if ( fastz_button.GetCheck() == BST_CHECKED )
58  zdevicetype = ZDeviceHelper::FastZ;
61  return 0;
62 }
63 
64 LRESULT CStackSettingsPage::OnRecalcButton(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
66  return 0;
67 }
68 
70  planes_list.DeleteAllItems();
71  std::wostringstream stream;
72 
73  for ( uint32_t p = 0 ; p < scope_controller.GuiParameters.stack.planes___.size() ; p++ ) {
74  planes_list.InsertItem(p, L"Plane", NULL);
75 
76  // Plane no
77  stream << p;
78  planes_list.SetItemText(p, 0, stream.str().c_str());
79  stream.str(L"");
80 
81  // Stage z Position. Always the same for all areas, either variable or fixed to current position (if etl zstacking)
82  if ( zdevicetype == ZDeviceHelper::ZStage )
83  stream << std::setprecision(0) << scope_controller.GuiParameters.stack.planes___[p][0].position();
84  else
85  stream << std::setprecision(0) << scope_controller.GuiParameters.stage.zpos();
86  planes_list.SetItemText(p, 1, stream.str().c_str());
87  stream.str(L"");
88 
89  // Fast z position and pockels for each area
90  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
91  stream << std::setprecision(2) << scope_controller.GuiParameters.stack.planes___[p][a].pockels();
92  planes_list.SetItemText(p, 2+2*a, stream.str().c_str());
93  stream.str(L"");
94  // Etl z position. Either variable or fixed to current positions (if stage z stacking)
95  if ( zdevicetype == ZDeviceHelper::FastZ )
96  stream << std::setprecision(0) << scope_controller.GuiParameters.stack.planes___[p][a].position();
97  else
98  stream << std::setprecision(0) << scope_controller.GuiParameters.areas[a]->Currentframe().fastz();
99  planes_list.SetItemText(p, 3+2*a, stream.str().c_str());
100  stream.str(L"");
101  }
102  }
104  stream << L"Lambda " << std::setprecision(1) << l << L" µm";
105  lambda_static.SetWindowText(stream.str().c_str());
106 }
107 
109  // This is called from ScopeControllerImpl, even if window is not yet initialized (because user did not click on that page yet)
110  if ( initialized ) {
111  // ReadOnlyWhileScanning is true while scanning -> enabled = false
112  BOOL state = !scope_controller.ReadOnlyWhileScanning();
113  recalc_button.EnableWindow(state);
114  fastz_button.EnableWindow(state);
115  zstage_button.EnableWindow(state);
116  // If we disable, the user cannot scroll through the list (and see what planes left to scan etc.) while scanning
117  //planes_list.EnableWindow(state);
118  }
119 }
120 
121 }}
boost::signals2::connection ConnectGUI(signalchange_t::slot_type slot)
Connect signal to slot to GUI.
CScopeButtonCtrl starthere_button
to set startat to current position
ScopeController scope_controller
Our ScopeController here.
ScopeValue< ZDevice > zdevicetype
type of z device to use
Definition: Runstates.h:38
CScopeProgressCtrl stack_progress
for stack progress
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.
Definition: ScopeEditCtrl.h:68
Stack stack
the StackParameters
Definition: Scope.h:237
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
void OnChangedRunState()
changes button states etc when acquisition is running.
CListViewCtrl planes_list
to edit properties of each plane
BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
initializes the dialog
SCOPE_XYZCONTROL_T stage
the parameters for the xyz stage (set type in ScopeDefines.h)
Definition: Scope.h:246
CScopeButtonCtrl stophere_button
to set stopat to current position
CStatic lambda_static
for displaying space constant of exponential pockels interpolation (see parameters::stack) ...
std::vector< std::array< PlaneProperties, SCOPE_NAREAS > > planes___
Vector with properties for every plane.
Definition: Runstates.h:35
scope::ScopeController scope_controller
keep a ScopeController to connect GUI controls
This is the include file for standard system include files, or project specific include files that ar...
CButton recalc_button
trigger recalculation of the slices list
CButton zstage_button
use zstage radio button
void UpdatePlanesList()
updates the list view ctrl on start/stop/spacing changes
CScopeEditCtrl< double > spacing_edit
spacing (in um) between slices
ZDevice zdevicetype
keeps track locally which zdevice type to use for stack
CScopeButtonCtrl start_stack_button
to start stack scan
bool initialized
true if window is initialized
BOOL AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item and set range.
LRESULT OnRecalcButton(WORD, WORD, HWND, BOOL &)
handles clicks on the recalculate button
CScopeEditCtrl< double > startat_edit
stack start zcontrol position
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
LRESULT OnZControlRadio(WORD, WORD, HWND, BOOL &)
handles clicks on the z control buttons
virtual double Lambda(const uint32_t &_area)
space constant for exponential pockels interpolation
Definition: Runstates.cpp:81
CScopeEditCtrl< double > stopat_edit
stack end zcontrol position
static ScopeNumber< bool > ReadOnlyWhileScanning
Set to true while scanning, GUI elements can connect to this to disable buttons and controls (that ar...
CButton fastz_button
use fastz radio button
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.