Scope
HistogramFrame.h
1 #pragma once
2 #include "ScopeDefines.h"
3 #include "HistogramView.h"
4 #include "controllers/ScopeController.h"
5 #include "ScopeDatatypes.h"
6 #include "helpers/Active.h"
7 #include "ThirdParty/ToolbarHelper.h"
8 #include "resource.h"
9 
10 namespace scope {
11  namespace gui {
12 
14 typedef CWinTraits<WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> CHistogramFrameTraits;
15 
18  : public CFrameWindowImpl<CHistogramFrame, CWindow, CHistogramFrameTraits>
19  , public CUpdateUI<CHistogramFrame>
20  , public CToolBarHelper<CHistogramFrame>
21  , public CIdleHandler
22  , public Active<bool> {
23 
24 protected:
26  typedef CFrameWindowImpl<CHistogramFrame, CWindow, CHistogramFrameTraits> CHistogramFrameType;
27 
30 
32  const uint32_t area;
33 
35  const uint32_t channels;
36 
38  bool attached;
39 
41  bool loghist;
42 
44  CToolBarCtrl toolbar;
45 
48  std::wstring statusstr;
49 
52  std::wstring limitsstr;
53 
55  CMultiPaneStatusBarCtrl m_wndStatusBar;
56 
59 
61  uint32_t framecount;
62 
63 protected:
69  bool RunUpdateStatusbar(StopCondition* const ac);
70 
71 public:
73  CCommandBarCtrl m_CmdBar;
74 
75  DECLARE_FRAME_WND_CLASS(NULL, IDR_HISTOGRAM)
76 
77 
78  CHistogramFrame(const uint32_t& _area, const uint32_t& _channels);
79 
81  ~CHistogramFrame();
82 
83  BEGIN_UPDATE_UI_MAP(CHistogramFrame)
84  UPDATE_ELEMENT(IDC_OPTIMIZE, UPDUI_TOOLBAR)
85  UPDATE_ELEMENT(IDC_FULLRANGE, UPDUI_TOOLBAR)
86  UPDATE_ELEMENT(IDC_LOGHISTOGRAM, UPDUI_TOOLBAR)
87  UPDATE_ELEMENT(0, UPDUI_STATUSBAR) // status
88  UPDATE_ELEMENT(1, UPDUI_STATUSBAR) // area
89  UPDATE_ELEMENT(2, UPDUI_STATUSBAR) // framecount
90  END_UPDATE_UI_MAP()
91 
92  BEGIN_MSG_MAP(CHistogramFrame)
93  MSG_WM_CREATE(OnCreate)
94  MSG_WM_DESTROY(OnDestroy)
95  COMMAND_ID_HANDLER_EX(IDC_OPTIMIZE, OnOptimize)
96  COMMAND_ID_HANDLER_EX(IDC_FULLRANGE, OnFullRange)
97  COMMAND_ID_HANDLER_EX(IDC_LOGHISTOGRAM, OnLogHistogram)
98  MESSAGE_HANDLER(WM_UPDATEHISTOLIMITS, OnUpdateHistogramLimits)
99  CHAIN_MSG_MAP(CToolBarHelper<CHistogramFrame>)
100  CHAIN_MSG_MAP(CUpdateUI<CHistogramFrame>)
101  CHAIN_MSG_MAP(CHistogramFrameType)
102  CHAIN_CLIENT_COMMANDS()
103  END_MSG_MAP()
104 
106  void OnToolBarCombo(HWND hWndCombo, UINT nID, int nSel, LPCTSTR lpszText, DWORD_PTR dwItemData) {}
107 
111  virtual void OnFinalMessage(HWND /*hWnd*/);
112 
114  virtual BOOL OnIdle();
115 
117  int OnCreate(LPCREATESTRUCT lpCreateStruct);
118 
120  void OnDestroy();
121 
123  void OnSizing(UINT fwSide, LPRECT pRect);
124 
126  void OnOptimize(UINT uNotifyCode, int nID, CWindow wndCtl);
127 
129  void OnFullRange(UINT uNotifyCode, int nID, CWindow wndCtl);
130 
132  void OnLogHistogram(UINT uNotifyCode, int nID, CWindow wndCtl);
138  LRESULT OnUpdateHistogramLimits(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
145  void HistoGramAndRender(scope::SCOPE_MULTIIMAGECPTR_T const _multi);
146 
148  void UpdateStatus(const RunState& _rs);
152  uint32_t Area() const { return area; }
153 
154 };
155 
156 }}
157 
Main controller of microscope hardware and acquisition, also interface to the GUI.
const uint32_t channels
number of channels for this area
Thread-safe lock-free bool to signal a requested stop to the worker function currently executed in th...
Definition: helpers.h:87
void OnFullRange(UINT uNotifyCode, int nID, CWindow wndCtl)
Calls CHistogramView::FullRange on view.
An active object implementation.
Definition: Active.h:11
const uint32_t area
which area is the histogram for
CCommandBarCtrl m_CmdBar
the command bar.
void UpdateStatus(const RunState &_rs)
Updates the statusstr and send RunUpdateStatusbar to the Active object.
void HistoGramAndRender(scope::SCOPE_MULTIIMAGECPTR_T const _multi)
Sends the worker function 'RunHistoGramAndRender' to the ActiveObject.
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
std::wstring limitsstr
holds the current limits as string (we need a member since the lifetime of a local variable is too sh...
CWinTraits< WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE > CHistogramFrameTraits
Traits for this window are standard CFramwWinTraits but without WS_THICKFRAME => no resize possible...
LRESULT OnUpdateHistogramLimits(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Limit bar movements are handled in the client window (CHistogramView) but we want also an update of C...
uint32_t framecount
number of the currently displayed histogram
bool attached
are we attached to ScopeController?
In here all declarations for all kinds of datatypes Scope needs.
bool RunUpdateStatusbar(StopCondition *const ac)
Worker function for all statusbar updates which will run in the Active's thread.
Manages the display of histograms.
CHistogramView view
The view inside the client window.
CFrameWindowImpl< CHistogramFrame, CWindow, CHistogramFrameTraits > CHistogramFrameType
Need to typedef this, otherwise problems with CHAIN_MSG_MAP macro...
bool loghist
do we want a logarithmic count histogram
CToolBarCtrl toolbar
the toolbar
CHistogramView is a holder for the renderer, calculates histograms, and takes care of window resizes ...
Definition: HistogramView.h:21
void OnLogHistogram(UINT uNotifyCode, int nID, CWindow wndCtl)
Switches between normal and logarithmic histogram.
scope::ScopeController scope_controller
our ScopeController here
CMultiPaneStatusBarCtrl m_wndStatusBar
the statusbar (multipane)
void OnOptimize(UINT uNotifyCode, int nID, CWindow wndCtl)
Calls CHistogramView::Optimize on view.
std::wstring statusstr
holds the current run status as string (we need a member since the lifetime of a local variable is to...
void OnDestroy()
Detaches frame from ScopeController, because after OnDestroy the HWND is not valid anymore...
int OnCreate(LPCREATESTRUCT lpCreateStruct)
Creates view, toolbar, statusbar etc., resizes window correctly.
void OnSizing(UINT fwSide, LPRECT pRect)
Keeps an aspect ratio of 1 by adapting pRect.