Scope
ChannelFrame.h
1 #pragma once
2 
3 #include "ScopeDefines.h"
4 #include "controllers/ScopeController.h"
5 #include "ChannelView.h"
6 #include "helpers/ScopeOverlay.h"
7 #include "helpers/ScopeOverlayResonanceSW.h"
8 #include "helpers/Active.h"
9 #include "ThirdParty/ToolbarHelper.h"
10 #include "resource.h"
11 
12 // Forward declarations
13 class ColorProps;
14 class D2ChannelRender;
15 namespace scope {
16  class ColorProps;
17  class SCOPE_MULTIIMAGE_T;
18  typedef std::shared_ptr<const SCOPE_MULTIIMAGE_T> SCOPE_MULTIIMAGECPTR_T;
19 }
20 
21 namespace scope {
23  namespace gui {
24 
27  : public CFrameWindowImpl<CChannelFrame>
28  , public CUpdateUI<CChannelFrame>
29  , public CToolBarHelper<CChannelFrame>
30  , public CIdleHandler
31  , public Active<bool> {
32 
33 protected:
36 
38  const uint32_t area;
39 
41  const uint32_t channels;
42 
44  bool attached;
45 
48 
50  scope::SCOPE_MULTIIMAGECPTR_T current_frame;
51 
53  std::wstring framecountstr;
54 
56  D2D1_POINT_2F mousepos;
57 
59  std::wstring mouseposstr;
60 
62  std::wstring statusstr;
63 
65  CMultiPaneStatusBarCtrl m_wndStatusBar;
66 
68  CToolBarCtrl toolbar;
69 
71  std::vector<ColorProps> channel_colors;
72 
74  scope::SCOPE_OVERLAY_T overlay;
75 
77  static std::array<int32_t, 4> colorcombo_resources;
78 
79 protected:
82  bool RunLayOverAndRender(StopCondition* const sc, scope::SCOPE_MULTIIMAGECPTR_T const _multi);
83 
89  bool RunUpdateStatusbar(StopCondition* const sc, scope::SCOPE_MULTIIMAGECPTR_T const _multi);
90 
92  void UpdateScaleText();
93 
95  void UncheckScaleButtons();
96 
97 public:
99  CCommandBarCtrl m_CmdBar;
100 
101  DECLARE_FRAME_WND_CLASS(NULL, IDR_CHANNELFRAME)
102 
103 
105  CChannelFrame(const uint32_t& _area);
106 
108  ~CChannelFrame();
109 
110  BEGIN_UPDATE_UI_MAP(CChannelFrame)
111  UPDATE_ELEMENT(IDC_SAMESIZE, UPDUI_TOOLBAR)
112  UPDATE_ELEMENT(IDC_DOUBLESIZE, UPDUI_TOOLBAR)
113  UPDATE_ELEMENT(IDC_HALFSIZE, UPDUI_TOOLBAR)
114  UPDATE_ELEMENT(0, UPDUI_STATUSBAR) // status
115  UPDATE_ELEMENT(1, UPDUI_STATUSBAR) // area
116  UPDATE_ELEMENT(2, UPDUI_STATUSBAR) // framecount
117  END_UPDATE_UI_MAP()
118 
119  BEGIN_MSG_MAP(CChannelFrame)
120  MSG_WM_CREATE(OnCreate)
121  MSG_WM_DESTROY(OnDestroy)
122  MSG_WM_SIZING(OnSizing)
123  MSG_WM_MOUSEWHEEL(OnMouseWheel)
124  MESSAGE_HANDLER(WM_UPDATEMOUSEPIXEL, OnUpdateMousePixel)
125  COMMAND_ID_HANDLER_EX(IDC_SAMESIZE, OnSameSize)
126  COMMAND_ID_HANDLER_EX(IDC_DOUBLESIZE, OnDoubleSize)
127  COMMAND_ID_HANDLER_EX(IDC_HALFSIZE, OnHalfSize)
128  CHAIN_MSG_MAP(CToolBarHelper<CChannelFrame>)
129  CHAIN_MSG_MAP(CUpdateUI<CChannelFrame>)
130  CHAIN_MSG_MAP(CFrameWindowImpl<CChannelFrame>)
131  CHAIN_CLIENT_COMMANDS()
132  END_MSG_MAP()
133 
135  void OnToolBarCombo(HWND hWndCombo, UINT nID, int nSel, LPCTSTR lpszText, DWORD_PTR dwItemData);
136 
140  virtual void OnFinalMessage(HWND /*hWnd*/);
141 
143  virtual BOOL OnIdle();
144 
146  int OnCreate(LPCREATESTRUCT lpCreateStruct);
147 
149  void OnDestroy();
150 
154  void OnSizing(UINT fwSide, LPRECT pRect);
155 
157  BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
158 
160  void OnSameSize(UINT uCode, int nID, HWND hwncCtrl);
161 
163  void OnDoubleSize(UINT uCode, int nID, HWND hwncCtrl);
164 
166  void OnHalfSize(UINT uCode, int nID, HWND hwncCtrl);
173  LRESULT OnUpdateMousePixel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
180  virtual void UpdateStatus(const RunState& _rs);
181 
183  virtual void SetHistogramLimits(const uint32_t& _channel, const uint16_t& _lower, const uint16_t& _upper);
184 
187  virtual void LayOverAndRender(scope::SCOPE_MULTIIMAGECPTR_T const _multi);
188 
190  virtual void UpdateScaleText(const std::wstring& _text);
194  uint32_t Area() const { return area; }
195 };
196 
197 }}
Main controller of microscope hardware and acquisition, also interface to the GUI.
std::wstring mouseposstr
holds the current mouse position as string
Definition: ChannelFrame.h:59
Thread-safe lock-free bool to signal a requested stop to the worker function currently executed in th...
Definition: helpers.h:87
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles mouse wheel events to change zoom or pockels cell value (wheel+Ctrl)
An active object implementation.
Definition: Active.h:11
std::wstring framecountstr
Holds the current frame count etc as string.
Definition: ChannelFrame.h:53
std::wstring statusstr
holds the current run status as string
Definition: ChannelFrame.h:62
bool RunLayOverAndRender(StopCondition *const sc, scope::SCOPE_MULTIIMAGECPTR_T const _multi)
Worker function which will run in the Active's thread.
D2D1_POINT_2F mousepos
current mouse position in device independent pixels (for the renderer)
Definition: ChannelFrame.h:56
STL namespace.
const uint32_t channels
number of channels in this area
Definition: ChannelFrame.h:41
CChannelView is just a dumb holder for the renderer and takes care of window resizes etc...
Definition: ChannelView.h:9
scope::SCOPE_OVERLAY_T overlay
Overlay of channels of the currently displayed image, use shared_ptr because it is used from differen...
Definition: ChannelFrame.h:74
CToolBarCtrl toolbar
the toolbar
Definition: ChannelFrame.h:68
virtual BOOL OnIdle()
Updates toolbar and statusbar.
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
Manages the display of images.
Definition: ChannelFrame.h:26
LRESULT OnUpdateMousePixel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Mouse movements are received in the client window (CChannelView) with the correct coordinates...
static std::array< int32_t, 4 > colorcombo_resources
The resource IDs of the channel color combo boxes.
Definition: ChannelFrame.h:77
const uint32_t area
area for this CChannelFrame
Definition: ChannelFrame.h:38
void OnHalfSize(UINT uCode, int nID, HWND hwncCtrl)
Sets window size to half the real frame size.
std::vector< ColorProps > channel_colors
Ordered by channel number.
Definition: ChannelFrame.h:71
void UncheckScaleButtons()
Unchecks all scale buttons.
CCommandBarCtrl m_CmdBar
the command bar.
Definition: ChannelFrame.h:99
int OnCreate(LPCREATESTRUCT lpCreateStruct)
Create view, toolbar, and statusbar etc.
void OnDoubleSize(UINT uCode, int nID, HWND hwncCtrl)
Sets window size to double the real frame size.
CMultiPaneStatusBarCtrl m_wndStatusBar
the statusbar
Definition: ChannelFrame.h:65
virtual void OnFinalMessage(HWND)
delete this to free the memory
void UpdateScaleText()
Updates the scale text with current values from scope_controller::GuiParameters.
void OnSameSize(UINT uCode, int nID, HWND hwncCtrl)
Sets window size to match the real frame size.
virtual void LayOverAndRender(scope::SCOPE_MULTIIMAGECPTR_T const _multi)
Sends the worker function 'RunLayOverAndRender' to the ActiveObject.
void OnSizing(UINT fwSide, LPRECT pRect)
Keeps the aspect ratio.
bool attached
are we attached to ScopeController?
Definition: ChannelFrame.h:44
uint32_t Area() const
Definition: ChannelFrame.h:194
bool RunUpdateStatusbar(StopCondition *const sc, scope::SCOPE_MULTIIMAGECPTR_T const _multi)
Worker function for all statusbar updates which will run in the Active's thread.
scope::SCOPE_MULTIIMAGECPTR_T current_frame
currently displayed image
Definition: ChannelFrame.h:50
virtual void SetHistogramLimits(const uint32_t &_channel, const uint16_t &_lower, const uint16_t &_upper)
Sets upper and lower limit of displayed colors for a channel.
virtual void UpdateStatus(const RunState &_rs)
Updates the statusstr and send RunUpdateStatusbar to the Active object.
scope::ScopeController scope_controller
the ScopeController kept handy here
Definition: ChannelFrame.h:35
CChannelView view
The view inside the client window.
Definition: ChannelFrame.h:47
void OnDestroy()
Detaches frame from ScopeController, because after OnDestroy the HWND is not valid anymore...