Scope
D2HistogramRender.h
1 #pragma once
2 
3 #include "d2wrap.h"
4 
5 // Forward declarations
6 namespace scope {
7 class ScopeMultiHistogram;
8 typedef std::shared_ptr<ScopeMultiHistogram> ScopeMultiHistogramPtr;
9 }
10 
11 namespace d2d {
12 
17 
18 protected:
20  mutable std::mutex mutex;
21 
23  const uint32_t width;
24 
26  const uint32_t channels;
27 
29  std::unique_ptr<RenderTarget> render_target;
30 
32  ID2D1SolidColorBrush* brushwhite;
33 
35  ID2D1SolidColorBrush* brushred;
36 
38  ID2D1SolidColorBrush* brushyellow;
39 
41  HWND hwnd;
42 
44  std::vector<FLOAT> llpos;
45 
47  std::vector<FLOAT> ulpos;
48 
50  scope::ScopeMultiHistogramPtr hist;
51 
52 protected:
55 
58 
61 
62 public:
63 
64 public:
66  D2HistogramRender(const uint32_t& _width, const uint32_t& _channels, scope::ScopeMultiHistogramPtr _hist);
67 
70 
72  void Create(const HWND& _hwnd);
73 
75  void SetHistogram(scope::ScopeMultiHistogramPtr _hist);
76 
78  void Render();
79 
81  void Size(const CSize& size);
82 
88  bool ClickedAt(const CPoint _clickpoint, uint32_t& _channel, bool& _uplo);
89 
91  void SetLowerLimitPosition(const uint32_t& _channel, const FLOAT& _pos);
92 
94  void SetUpperLimitPosition(const uint32_t& _channel, const FLOAT& _pos);
95 };
96 
98 typedef std::shared_ptr<D2HistogramRender> D2HistogramRenderPtr;
99 
100 }
std::unique_ptr< RenderTarget > render_target
Direct2D render target.
D2HistogramRender operator=(const D2HistogramRender &)
Disable assignment.
const uint32_t width
constant width of the renderer
scope::ScopeMultiHistogramPtr hist
Pointer to the currently rendered multi histogram.
Wrappers around the Direct2D interface.
void SetHistogram(scope::ScopeMultiHistogramPtr _hist)
Sets the pointer to the current multi histogram.
void Render()
Draws the current multi histogram with the limit lines.
void DiscardDeviceResources()
Safely release all Direct2D resources.
Parts of the code are modified from Microsoft's Direct2D nbody example: Copyright (c) Microsoft Corpo...
std::shared_ptr< D2HistogramRender > D2HistogramRenderPtr
Shared pointer to a D2HistogramRenderPtr.
bool ClickedAt(const CPoint _clickpoint, uint32_t &_channel, bool &_uplo)
Checks if click hit a limit (+-5 pixel) and if yes, on which channel and upper or lower limit line...
D2HistogramRender(const D2HistogramRender &)
Disable copy.
HWND hwnd
windows handle
Handles all Direct2D rendering in a CHistogramView.
std::vector< FLOAT > ulpos
Keeps track of the upper limit positions in screen coordinates.
ID2D1SolidColorBrush * brushwhite
Direct2D white brush.
void Create(const HWND &_hwnd)
Creates the render target for a hwnd, the brushes for painting, and sets the limit position to the wi...
void SetLowerLimitPosition(const uint32_t &_channel, const FLOAT &_pos)
Set position of a lower limit line.
std::vector< FLOAT > llpos
Keeps track of the lower limit positions in screen coordinates.
ID2D1SolidColorBrush * brushyellow
Direct2D yellow brush.
const uint32_t channels
number of channels
void Size(const CSize &size)
Resizes the renderer and the limit positions.
std::mutex mutex
mutex for protection
void SetUpperLimitPosition(const uint32_t &_channel, const FLOAT &_pos)
Set position of an upper limit line.
~D2HistogramRender()
Discard device resources.
ID2D1SolidColorBrush * brushred
Direct2D red brush.