2 #include "ChannelFrame.h"
3 #include "ChannelView.h"
4 #include "helpers/ScopeMultiImage.h"
5 #include "helpers/ScopeMultiImageResonanceSW.h"
6 #include "direct2d/D2ChannelRender.h"
8 #include "controllers/ScopeController.h"
9 #include "controls/ScopeColorComboCtrl.h"
19 , channels(scope_controller.GuiParameters.areas[_area]->daq.inputs->channels())
21 , current_frame(
std::make_shared<
scope::SCOPE_MULTIIMAGE_T>(_area, channels, scope_controller.GuiParameters.areas[_area]->Currentframe().yres(), scope_controller.GuiParameters.areas[_area]->Currentframe().xres()))
22 , framecountstr(L
"Frame ")
23 , mousepos(D2D1::Point2F(0.0f, 0.0f))
24 , mouseposstr(L
"(0, 0)")
25 , statusstr(L
"Stopped")
26 , channel_colors(channels, None)
27 , overlay(scope_controller.GuiParameters.areas[_area]->Currentframe().yres(), scope_controller.GuiParameters.areas[_area]->Currentframe().xres()) {
72 if ( (_multi->Linewidth() !=
overlay.Linewidth()) || (_multi->Lines() !=
overlay.Lines()) )
73 overlay.Resize(_multi->Lines(), _multi->Linewidth());
87 const uint32_t xui =
static_cast<uint32_t
>(std::floor(
mousepos.x));
88 const uint32_t yui =
static_cast<uint32_t
>(std::floor(
mousepos.y));
89 const std::vector<uint16_t> multipix(
current_frame->GetMultiPixel(xui, yui));
90 std::wstringstream stream;
91 stream << L
"(" << xui << L
", " << yui << L
") = (";
92 for (
const auto& pix : multipix )
93 stream << pix << L
", ";
100 std::wostringstream stream;
101 stream << L
"Frame " <<
current_frame->GetImageNumber() << L
" (" << std::setprecision(1) << std::fixed <<
current_frame->PercentComplete();
111 std::wostringstream stream;
112 stream << std::setprecision(1) << std::fixed;
121 toolbar.CheckButton(IDC_SAMESIZE, FALSE);
122 toolbar.CheckButton(IDC_DOUBLESIZE, FALSE);
123 toolbar.CheckButton(IDC_HALFSIZE, FALSE);
127 m_hWndClient =
view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
129 SetMenu(HMENU(NULL));
131 toolbar = CreateSimpleToolBarCtrl(m_hWnd, IDR_CHANNELFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE_EX);
132 CreateSimpleReBar(ATL_SIMPLE_REBAR_STYLE);
137 AddToolbarButtonText(
toolbar, IDC_SAMESIZE, L
"x1");
138 AddToolbarButtonText(
toolbar, IDC_DOUBLESIZE, L
"x2");
139 AddToolbarButtonText(
toolbar, IDC_HALFSIZE, L
"x0.5");
143 for ( uint32_t ch = 0 ; ch <
channels ; ch++ ) {
158 UIAddStatusBar (m_hWndStatusBar);
160 int32_t anPanes[] = { IDPANE_STATUS , IDPANE_PIXELINFO, IDPANE_FRAMECOUNT };
172 std::wostringstream stream;
173 stream << L
"Image (Area " <<
area+1 << L
")";
174 SetWindowText(stream.str().c_str());
180 GetWindowRect(&Rect);
182 const double width = Rect.right-Rect.left;
183 const double height = Rect.bottom - Rect.top;
184 const int32_t targetHeight = round2i32(width / AspectRatio)+92;
185 const int32_t targetWidth = round2i32(height * AspectRatio)+20;
186 MoveWindow(Rect.left, Rect.top, targetWidth, targetHeight);
203 void CChannelFrame::OnToolBarCombo(HWND hWndCombo, UINT nID,
int nSel, LPCTSTR lpszText, DWORD_PTR dwItemData) {
204 uint32_t selchannel = 0;
210 DBOUT(L
"Channel " << selchannel << L
" selected color " << ColorEnum(nSel) << L
" String: " << gColorStrings[nSel].GetString());
217 const double width = pRect->right - pRect->left - 20;
218 const double height = pRect->bottom - pRect->top - 92;
221 if (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT || fwSide == WMSZ_RIGHT + WMSZ_BOTTOM || fwSide == WMSZ_LEFT + WMSZ_BOTTOM ) {
222 const int targetHeight = round2ui32(width / AspectRatio) + 92;
223 pRect->bottom = pRect->top + targetHeight;
225 else if (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || fwSide == WMSZ_LEFT + WMSZ_TOP || fwSide == WMSZ_RIGHT + WMSZ_TOP ) {
226 const int targetWidth = round2ui32(height * AspectRatio) + 20;
227 pRect->right = pRect->left + targetWidth;
243 if ( nFlags == MK_CONTROL )
246 if ( nFlags == NULL ) {
264 toolbar.CheckButton(IDC_SAMESIZE);
271 toolbar.CheckButton(IDC_DOUBLESIZE);
278 toolbar.CheckButton(IDC_HALFSIZE);
303 DBOUT(L
"CChannelFrame::LayOverAndRender dropping frame " <<
current_frame->GetImageNumber());
ID2D1Bitmap * GetBitmap()
void ResizeContent(const uint32_t &_xres, const uint32_t &_yres)
Resizes the bitmap of the renderer.
std::wstring mouseposstr
holds the current mouse position as string
Thread-safe lock-free bool to signal a requested stop to the worker function currently executed in th...
Simple class derivec from CComboBoxEx, added only method InitializeColors wich fills combo with color...
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles mouse wheel events to change zoom or pockels cell value (wheel+Ctrl)
void Quit()
Send lambda with done=true to the worker, join the worker thread, and clear the packaged task queue...
std::wstring framecountstr
Holds the current frame count etc as string.
std::wstring statusstr
holds the current run status as string
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
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)
const uint32_t channels
number of channels in this area
CChannelFrame(const uint32_t &_area)
Initialize everything.
scope::SCOPE_OVERLAY_T overlay
Overlay of channels of the currently displayed image, use shared_ptr because it is used from differen...
CToolBarCtrl toolbar
the toolbar
virtual BOOL OnIdle()
Updates toolbar and statusbar.
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
virtual void UpdateScaleText(const std::wstring &_text)
Update the scale text.
void Render()
Calls renderer.Render.
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.
const uint32_t area
area for this CChannelFrame
This is the include file for standard system include files, or project specific include files that ar...
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.
std::future< bool > Send(const Command &_cmd)
Sends a worker function/packaged task to the queue to be executed in the Active's thread...
void UncheckScaleButtons()
Unchecks all scale buttons.
#define DBOUT(s)
A debug output to the debug console.
int OnCreate(LPCREATESTRUCT lpCreateStruct)
Create view, toolbar, and statusbar etc.
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
void OnDoubleSize(UINT uCode, int nID, HWND hwncCtrl)
Sets window size to double the real frame size.
CMultiPaneStatusBarCtrl m_wndStatusBar
the statusbar
static D2D1_POINT_2F PixelsToDips(T x, T y)
Convert screen pixels to device independent points.
~CChannelFrame()
Detach if not yet happened and quit.
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.
ScopeValue< RunState > run_state
current RunState
void OnSizing(UINT fwSide, LPRECT pRect)
Keeps the aspect ratio.
bool attached
are we attached to ScopeController?
SynchronizedQueue< const std::function< void(StopCondition *const sc)> > ptq
synchronized queue of worker functions/packaged tasks that are executed in the Active' thread (see la...
D2D1_SIZE_F GetRendererSize() const
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
following http://www.mochima.com/articles/LUT/lut_h.html
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
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
CChannelView view
The view inside the client window.
void OnDestroy()
Detaches frame from ScopeController, because after OnDestroy the HWND is not valid anymore...
void InitializeColors()
fill items