Scope
ScanSettingsSheet.cpp
1 #include "StdAfx.h"
2 #include "ScanSettingsSheet.h"
3 #include "NoScanBasePage.h"
4 #include "FrameScanSawPage.h"
5 #include "FrameScanBidiPage.h"
6 #include "FrameScanHopperPage.h"
7 #include "FrameScanResonancePage.h"
8 #include "ScopeDatatypes.h"
9 
10 namespace scope {
11  namespace gui {
12 
14  : inputsinfospage(dynamic_cast<parameters::SCOPE_INPUTS_PARAMETERS_T*>(scope_controller.GuiParameters.areas[0]->daq.inputs.get())){
15 
16  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
17  if ( scope_controller.GuiParameters.areas[a]->isslave() )
18  scanpages[a] = std::unique_ptr<CNoScanBasePage>(new CNoScanBasePage(a, scope_controller.GuiParameters.areas[a]->Currentframe()));
19  else
20  scanpages[a] = std::unique_ptr<CFrameScanSawPage>(new CFrameScanSawPage(a));
21  }
22 }
23 
24 HWND CScanSettingsSheet::Create(const HWND hWndParent, const int nStartPage, const CRect & rc) {
25  ATLASSERT(m_hWnd == NULL);
26 
27  for ( auto& fsp : scanpages )
28  AddPage(*fsp);
29  AddPage(storagesettingspage);
30  AddPage(stimulationsettingspage);
31  AddPage(movementpage);
32  AddPage(inputsinfospage);
33 
34  m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_MODELESS | PSH_USECALLBACK;
35  m_psh.hwndParent = hWndParent;
36  m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
37  m_psh.nPages = m_arrPages.GetSize();
38  m_psh.pfnCallback = CScanSettingsSheet::PropSheetCallback;
39 
40  _Module.AddCreateWndData(&m_thunk.cd, this);
41 
42  HWND hWnd = (HWND)::PropertySheet(&m_psh);
43  _CleanUpPages(); // ensure clean-up, required if call failed
44 
45  ATLASSERT(m_hWnd == hWnd);
46 
47  if ( hWnd ) {
48  int nAdjX = GetSystemMetrics(SM_CXDLGFRAME) * 2;
49  int nAdjY = GetSystemMetrics(SM_CYDLGFRAME) * 2;
50  SetWindowPos(NULL, rc.left - nAdjX, rc.top - nAdjY, rc.Width(), rc.Height(),
51  SWP_NOZORDER|SWP_NOACTIVATE);
52  }
53 
54  SetActivePage(nStartPage);
55 
56  // Register the callback that is called by ScopeController upon scan mode changes
58  std::function<void(const uint32_t&, const ScannerVectorType&)> cb(std::bind(&CScanSettingsSheet::ChangeScanmode, this, std::placeholders::_1, std::placeholders::_2));
59  scope_controller.RegisterScanmodeCallback(cb);
60 
61  return hWnd;
62 }
63 
64 int CALLBACK CScanSettingsSheet::PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) {
65  int nRetVal = 0;
66 
67  if (uMsg == PSCB_INITIALIZED) {
68  ATLASSERT(hWnd != NULL);
69  CScanSettingsSheet* pT = (CScanSettingsSheet*)_Module.ExtractCreateWndData();
70  pT->SubclassWindow(hWnd); // subclass the sheet window
71  pT->_CleanUpPages(); // remove page handles array
72  }
73  else if (uMsg == PSCB_PRECREATE) {
74  LPDLGTEMPLATE pTemplate = (LPDLGTEMPLATE)lParam;
75  ATLASSERT(pTemplate);
76 
77  DWORD dwRemove = WS_POPUP|WS_SYSMENU|WS_CAPTION|DS_MODALFRAME;
78  DWORD dwAdd = WS_CHILD|WS_VISIBLE|WS_TABSTOP|DS_CONTEXTHELP|DS_3DLOOK|DS_CONTROL;
79 
80  pTemplate->style = (pTemplate->style & ~dwRemove) | dwAdd;
81  pTemplate->dwExtendedStyle |= WS_EX_CONTROLPARENT;
82  nRetVal = 1;
83  }
84 
85  return nRetVal;
86 }
87 
88 LRESULT CScanSettingsSheet::OnSelChange(WPARAM wParam, LPNMHDR pnmHdr, BOOL & bHandled) {
89  return DefWindowProc(WM_NOTIFY, wParam, (LPARAM)pnmHdr);
90 }
91 
92 void CScanSettingsSheet::ChangeScanmode(const uint32_t& _area, const ScannerVectorType& _type) {
93  // First SCOPE_NAREA pages are scan proppages
94  RemovePage(_area);
95 
96  switch( _type.t ) {
97  case ScannerVectorTypeHelper::Sawtooth:
98  scanpages[_area].reset(new CFrameScanSawPage(_area));
99  break;
100  case ScannerVectorTypeHelper::Bidirectional:
101  scanpages[_area].reset(new CFrameScanBidiPage(_area));
102  break;
103  case ScannerVectorTypeHelper::Planehopper:
104  scanpages[_area].reset(new CFrameScanHopperPage(_area));
105  break;
106  case ScannerVectorTypeHelper::ResonanceBiDi:
107  scanpages[_area].reset(new CFrameScanResonancePage(_area));
108  break;
109  }
110 
111  // Insert the new one at the same position
112  InsertPage(_area, *scanpages[_area]);
113  SetActivePage(_area);
114 }
115 
116 }}
Main controller of microscope hardware and acquisition, also interface to the GUI.
HWND Create(const HWND hWndParent, const int nStartPage, const CRect &rc)
Adds all the settingspages.
ScopeController scope_controller
Our ScopeController here.
Property page for frame scan with resonance scanner.
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
Settings sheet that has settings pages for different parameter sets.
std::array< std::unique_ptr< CNoScanBasePage >, SCOPE_NAREAS > scanpages
one imaging settings page for each area
Property page for bidirectional frame scan.
This is the include file for standard system include files, or project specific include files that ar...
void RegisterScanmodeCallback(std::function< void(const uint32_t &, const ScannerVectorType &)> _callback)
Registers a function to call when scanmode is changed.
T::Mode t
the enum from the template class
CMovementPage movementpage
the settings page for all stages
CStorageSettingsPage storagesettingspage
the storage settings page
In here all declarations for all kinds of datatypes Scope needs.
CScanSettingsSheet()
Generates CImageSettingsPages for every area.
Property page for sawtooth frame scan.
Property page for bidirectional frame scan.
CStimulationSettingsPage stimulationsettingspage
the stimulation settings page
void ChangeScanmode(const uint32_t &_area, const ScannerVectorType &_type)
Change the imaging settings page according to the choosen scan mode.
CAppModule _Module
The ATL application module.
Definition: scope.cpp:10
static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam)
We need this for whatever (see some WTL dialog tutorial)...
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
Base class for all scanning and non-scanning scan property pages, i.e.
SCOPE_INPUTSINFOPAGE_T inputsinfospage
a settings page for DAQmx/FPGA information