Scope
ScanModesSettingsPage.cpp
1 #include "StdAfx.h"
2 #include "ScanModesSettingsPage.h"
3 #include "scanmodes/ScannerVectorFrameBasic.h"
4 
5 namespace scope {
6  namespace gui {
7 
8 CScanModesSettingsPage::CScanModesSettingsPage()
9  : framesaw_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::Sawtooth))
10  , framebidi_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::Bidirectional))
11  , framehopper_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::Planehopper))
12  , frameresonancebidi_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::ResonanceBiDi))
13  , frameresonancehopper_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::ResonanceHopper))
14  , linestraight_radio(&scope_controller.ScanMode[0].map.at(ScannerVectorTypeHelper::LineStraight)) {
15  // start with buttons connected to area 0
16 }
17 
18 BOOL CScanModesSettingsPage::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) {
19  areas_list.Attach(GetDlgItem(IDC_AREAS_LIST));
20  framesaw_radio.AttachToDlgItem(GetDlgItem(IDC_FRAME_SAWTOOTH_RADIO));
21  framebidi_radio.AttachToDlgItem(GetDlgItem(IDC_FRAME_BIDI_RADIO));
22  framehopper_radio.AttachToDlgItem(GetDlgItem(IDC_FRAME_PLANEHOPPER_RADIO));
23  frameresonancebidi_radio.AttachToDlgItem(GetDlgItem(IDC_FRAME_RESONANT_BIDI_RADIO));
24  frameresonancehopper_radio.AttachToDlgItem(GetDlgItem(IDC_FRAME_RESONANT_PLANEHOPPER_RADIO));
25  linestraight_radio.AttachToDlgItem(GetDlgItem(IDC_LINE_STRAIGHT_RADIO));
26 
27  // Disable scan modes that are not supported by builtin scanner
28  framesaw_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::Sawtooth));
29  framebidi_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::Bidirectional));
30  framehopper_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::Planehopper));
31  frameresonancebidi_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::ResonanceBiDi));
32  frameresonancehopper_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::ResonanceHopper));
33  linestraight_radio.Enable(ScannerSupportedVectors::IsBuiltinSupported(ScannerVectorTypeHelper::LineStraight));
34 
35  // Add areas to list box and select area 0
36  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
37  std::wostringstream stream;
38  stream << L"Area " << a+1;
39  areas_list.AddString(stream.str().c_str());
40  }
41  areas_list.SetCurSel(0);
42 
43  SetChecks(0);
44 
45  SetMsgHandled(false);
46  return 0;
47 }
48 
49 LRESULT CScanModesSettingsPage::OnAreaChange(WORD, WORD, HWND, BOOL&) {
50  int32_t sel = areas_list.GetCurSel();
51 
52  if ( sel == LB_ERR )
53  return 0;
54  assert( (sel >= 0) && (sel < SCOPE_NAREAS) );
55 
56  // Disconnect from old areas ScanMode buttons
57  framesaw_radio.Disconnect();
58  framebidi_radio.Disconnect();
59  framehopper_radio.Disconnect();
60  frameresonancebidi_radio.Disconnect();
61  frameresonancehopper_radio.Disconnect();
62  linestraight_radio.Disconnect();
63 
64  // Connect to selected area's ScanMode buttons and uncheck all
65  framesaw_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::Sawtooth));
66  framesaw_radio.SetCheck(BST_UNCHECKED);
67  framebidi_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::Bidirectional));
68  framebidi_radio.SetCheck(BST_UNCHECKED);
69  framehopper_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::Planehopper));
70  framehopper_radio.SetCheck(BST_UNCHECKED);
71  frameresonancebidi_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::ResonanceBiDi));
72  frameresonancebidi_radio.SetCheck(BST_UNCHECKED);
73  frameresonancehopper_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::ResonanceHopper));
74  frameresonancehopper_radio.SetCheck(BST_UNCHECKED);
75  linestraight_radio.Connect(&scope_controller.ScanMode[sel].map.at(ScannerVectorTypeHelper::LineStraight));
76  linestraight_radio.SetCheck(BST_UNCHECKED);
77 
78  SetChecks(sel);
79 
80  return 0;
81 }
82 
83 void CScanModesSettingsPage::SetChecks(const uint32_t& _a) {
84  // Copy the settings of the current area from the master area
86 
87  // Check the one that corresponds to the scan mode of this area (if the scan mode is supported by the built-in scanners is checked inside Scope_Controller::SetScanMode()
88  switch ( scope_controller.GuiParameters.areas[_a]->scanmode().t ) {
89  case ScannerVectorTypeHelper::Sawtooth:
90  framesaw_radio.SetCheck(BST_CHECKED);
91  break;
92  case ScannerVectorTypeHelper::Bidirectional:
93  framebidi_radio.SetCheck(BST_CHECKED);
94  break;
95  case ScannerVectorTypeHelper::Planehopper:
96  framehopper_radio.SetCheck(BST_CHECKED);
97  break;
98  case ScannerVectorTypeHelper::ResonanceBiDi:
99  frameresonancebidi_radio.SetCheck(BST_CHECKED);
100  break;
101  case ScannerVectorTypeHelper::ResonanceHopper:
102  frameresonancehopper_radio.SetCheck(BST_CHECKED);
103  break;
104  case ScannerVectorTypeHelper::LineStraight:
105  linestraight_radio.SetCheck(BST_CHECKED);
106  break;
107  }
108 }
109 
110 
111 }
112 
113 }
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
CListBox areas_list
List of all areas, selection updates radio buttons.
static bool IsBuiltinSupported(const ScannerVectorTypeHelper::Mode &_scanmode)
Returns true if a given scannervector/scanmode is supported by the builtin/hardcoded (see ScopeDefine...
void SetChecks(const uint32_t &_a)
Checks radio buttons according to the scan mode of the selected area.
void Enable(const bool &state)
Sets the enabled/disabled state of the control.
BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
Handles dialog initialization.
This is the include file for standard system include files, or project specific include files that ar...
static std::array< ScanModeButtons, SCOPE_NAREAS > ScanMode
Buttons for switching the scan mode.
scope::ScopeController scope_controller
A ScopeController kept handy.
LRESULT OnAreaChange(WORD, WORD, HWND, BOOL &)
handles selection changes in area list box
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.