Scope
HistogramView.h
1 #pragma once
2 
3 #include "direct2d/D2HistogramRender.h"
4 #include "controllers/ScopeController.h"
5 #include "controls/ScopeButtonCtrl.h"
6 #include "ScopeDatatypes.h"
7 #include "resource.h"
8 
9 // Forward declarations
10 namespace scope {
11 class SCOPE_MULTIIMAGE_T;
12 typedef std::shared_ptr<const SCOPE_MULTIIMAGE_T> SCOPE_MULTIIMAGECPTR_T;
13 class ScopeMultiHistogram;
14 typedef std::shared_ptr<ScopeMultiHistogram> ScopeMultiHistogramPtr;
15 }
16 
17 namespace scope {
18  namespace gui {
19 
22  : public CWindowImpl<CHistogramView> {
23 
24 protected:
26  static const uint32_t width = 512;
27 
29  const uint32_t area;
30 
32  const uint32_t channels;
33 
35  uint16_t range;
36 
39 
41  SCOPE_MULTIIMAGECPTR_T current_frame;
42 
44  ScopeMultiHistogramPtr current_histogram;
45 
47  std::vector<uint16_t> lower_limits;
48 
50  std::vector<uint16_t> upper_limits;
51 
54 
56  std::vector<bool> dragginglower;
57 
59  std::vector<bool> draggingupper;
60 
62  std::vector<FLOAT> llpos;
63 
65  std::vector<FLOAT> ulpos;
66 
67 protected:
69  void SetLimits();
70 
72  void UpdateHistogramFrame();
73 
74 public:
76  CHistogramView(const uint32_t& _area, const uint32_t& _channels, uint16_t _range);
77 
79  DECLARE_WND_CLASS_EX(nullptr, CS_HREDRAW | CS_VREDRAW, -1);
80 
81  BEGIN_MSG_MAP(CChannelView)
82  MSG_WM_SHOWWINDOW(OnShowWindow)
83  MSG_WM_PAINT(OnPaint)
84  MSG_WM_LBUTTONDOWN(OnLButtonDown)
85  MSG_WM_LBUTTONUP(OnLButtonUp)
86  MSG_WM_MOUSEMOVE(OnMouseMove)
87  MSG_WM_DISPLAYCHANGE(OnDisplayChange)
88  MSG_WM_ERASEBKGND(OnEraseBkgnd)
89  MSG_WM_SIZE(OnSize)
90  END_MSG_MAP()
91 
94  BOOL PreTranslateMessage(MSG* pMsg);
95 
97  virtual void OnFinalMessage(HWND /*hWnd*/);
98 
100  void OnShowWindow(BOOL bShow, UINT nStatus);
101 
103  void OnLButtonDown(UINT nFlags, CPoint point);
104 
106  void OnLButtonUp(UINT nFlags, CPoint point);
107 
109  void OnMouseMove(UINT nFlags, CPoint point);
110 
112  LRESULT OnEraseBkgnd(HDC wParam) { return true; }
113 
115  void OnPaint(CDCHandle /*dc*/);
116 
118  void OnSize(UINT /*type*/, CSize _size);
119 
120  void OnDisplayChange(UINT /*bpp*/, CSize /*resolution*/);
127 
130 
133 
140 
Main controller of microscope hardware and acquisition, also interface to the GUI.
const uint32_t area
for which area
Definition: HistogramView.h:29
const uint32_t channels
how many channels
Definition: HistogramView.h:32
void OnLButtonDown(UINT nFlags, CPoint point)
Ask renderer for hit test and set click state.
std::vector< uint16_t > upper_limits
upper limit values of all channels/the value that corresponds to histogram array index (because of ra...
Definition: HistogramView.h:50
std::vector< bool > dragginglower
Keeps track of mouse dragging which lower limit.
Definition: HistogramView.h:56
uint16_t range
what uin16_t histogram range is used
Definition: HistogramView.h:35
void OnLButtonUp(UINT nFlags, CPoint point)
Releases click state.
void SetLimits()
Set limits in renderer and scope_controller.
ScopeMultiHistogramPtr current_histogram
currently displayed histogram
Definition: HistogramView.h:44
SCOPE_MULTIIMAGECPTR_T current_frame
image corresponding to the currently displayed histogram
Definition: HistogramView.h:41
CChannelView is just a dumb holder for the renderer and takes care of window resizes etc...
Definition: ChannelView.h:9
std::vector< bool > draggingupper
Keeps track of mouse dragging which upper limit.
Definition: HistogramView.h:59
void OnMouseMove(UINT nFlags, CPoint point)
If moving with left mouse button down, give position to Renderer and render limit bars...
void OnShowWindow(BOOL bShow, UINT nStatus)
Create the renderer only now, because now the window is shown.
Handles all Direct2D rendering in a CHistogramView.
std::vector< uint16_t > lower_limits
lower limit values of all channels/the value that corresponds to histogram array index (because of ra...
Definition: HistogramView.h:47
In here all declarations for all kinds of datatypes Scope needs.
std::vector< FLOAT > ulpos
Keeps track of the upper limit positions in screen coordinates/histogram array index.
Definition: HistogramView.h:65
void OnSize(UINT, CSize _size)
Resize the Renderer accordingly, be careful not to resize to 0.
DECLARE_WND_CLASS_EX(nullptr, CS_HREDRAW|CS_VREDRAW,-1)
Set background brush to -1, avoids erasure of background (similar effect as OnEraseBkgnd below...
LRESULT OnEraseBkgnd(HDC wParam)
avoids flickering during resize
void UpdateHistogramFrame()
Update Histogram with current parameters.
static const uint32_t width
static constant width of the histogram renderer
Definition: HistogramView.h:26
CHistogramView is a holder for the renderer, calculates histograms, and takes care of window resizes ...
Definition: HistogramView.h:21
ScopeController scope_controller
the ScopeController kept handy here
Definition: HistogramView.h:38
d2d::D2HistogramRender renderer
this one handles all of the Views rendering
Definition: HistogramView.h:53
CHistogramView(const uint32_t &_area, const uint32_t &_channels, uint16_t _range)
Initialize everything.
void OnPaint(CDCHandle)
Render the histogram and the limit bars (both via Renderer)
std::vector< FLOAT > llpos
Keeps track of the lower limit positions in screen coordinates/histogram array index.
Definition: HistogramView.h:62
virtual void OnFinalMessage(HWND)
Do not do 'delete this;' because view is a member of frame and gets destroyed when frame is destroyed...