2 #include "MainDlgFrame.h"
3 #include "ChannelFrame.h"
4 #include "HistogramFrame.h"
6 #include "controllers/ScopeController.h"
7 #include "controllers/ScopeLogger.h"
20 pChild->CreateEx(m_hWnd, rect);
21 pChild->ShowWindow(SW_SHOWDEFAULT);
31 pChild->CreateEx(m_hWnd, rect);
32 pChild->ShowWindow(SW_SHOWDEFAULT);
41 logchild->CreateEx(m_hWnd, rect);
42 logchild->ShowWindow(SW_SHOWDEFAULT);
51 rect.bottom = w.bottom;
53 if ( w.type() == L
"CChannelFrame" )
55 if ( w.type() == L
"CHistogramFrame" )
57 if ( w.type() == L
"CLogFrame" )
62 BOOL CMainDlgFrame::PreTranslateMessage(MSG* pMsg) {
63 if (CMainDlgFrameType::PreTranslateMessage(pMsg))
73 UISetText(0, str2.c_str());
85 PostMessage(WM_CLOSE);
89 static_assert(SCOPE_NAREAS <= 4,
"No resource IDs defined for more than 4 areas, but easy to do if you need it");
91 if (nMenuID == IDR_NEWCHANNEL_MENU) {
92 CMenuHandle menu(hMenu);
93 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
94 std::wostringstream stream;
95 stream << L
"Area " << a+1;
96 menu.InsertMenu(0, MF_STRING,
viewareas_ids[a], stream.str().c_str());
99 if (nMenuID == IDR_NEWHISTOGRAM_MENU) {
100 CMenuHandle menu(hMenu);
101 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
102 std::wostringstream stream;
103 stream << L
"Area " << a+1;
107 menu.InsertMenu(0, MF_STRING | MF_GRAYED,
histogramareas_ids[a], stream.str().c_str());
116 HMENU m = GetSystemMenu(FALSE);
117 EnableMenuItem(m, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
120 HWND hWndCmdBar =
m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
126 SetMenu(HMENU(NULL));
129 HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE_EX);
132 AddToolBarDropDownMenu(hWndToolBar, IDC_NEWCHANNELDROPDOWN, IDR_NEWCHANNEL_MENU);
133 AddToolbarButtonText(hWndToolBar, IDC_NEWCHANNELDROPDOWN, L
"New View");
134 AddToolBarDropDownMenu(hWndToolBar, IDC_NEWHISTOGRAMDROPDOWN, IDR_NEWHISTOGRAM_MENU);
135 AddToolbarButtonText(hWndToolBar, IDC_NEWHISTOGRAMDROPDOWN, L
"New Histogram");
138 CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
139 AddSimpleReBarBand(hWndCmdBar);
140 AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
142 UIAddToolBar(hWndToolBar);
143 UISetCheck(ID_VIEW_TOOLBAR, 1);
144 UISetCheck(ID_VIEW_STATUS_BAR, 1);
147 m_hWndStatusBar =
m_wndStatusBar.Create(*
this, ATL_IDS_IDLEMESSAGE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
148 UIAddStatusBar (m_hWndStatusBar);
150 int32_t anPanes[] = { IDPANE_STATUS, IDPANE_MEMORY, IDPANE_CONFIG };
153 UISetText(0, L
"Stopped");
155 UISetText(1, L
"Memory");
174 CMessageLoop* pLoop =
_Module.GetMessageLoop();
175 ATLASSERT(pLoop != NULL);
176 pLoop->AddMessageFilter(
this);
177 pLoop->AddIdleHandler(
this);
181 ::GetWindowRect(hWndToolBar, &toolbarrect);
182 ScreenToClient(&toolbarrect);
184 ::GetWindowRect(hWndCmdBar, &commandbarrect);
185 ScreenToClient(&commandbarrect);
188 RECT rec = {10,10,280,350};
190 ::SetWindowPos(wnd,HWND_BOTTOM,0,53,430,939,NULL);
208 SetMsgHandled(
false);
212 return m_dlgView.PreTranslateMessage(Msg);
216 if ( nIDEvent == 1 ) {
218 PROCESS_MEMORY_COUNTERS pmc;
219 HANDLE proc = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ::GetCurrentProcessId());
220 ::GetProcessMemoryInfo(proc, &pmc,
sizeof(pmc));
223 str.Format(L
"%d Mb", pmc.WorkingSetSize/1024/1024);
234 CMessageLoop* pLoop =
_Module.GetMessageLoop();
235 ATLASSERT(pLoop != NULL);
236 pLoop->RemoveMessageFilter(
this);
237 pLoop->RemoveIdleHandler(
this);
238 DBOUT(L
"CMainDlgFrame::OnDestroy()\n");
239 SetMsgHandled(
false);
255 const RECT rect = { 330, 5, 586, 261 };
269 RECT rect = { 330, 5, 330+532, 5+350 };
276 RECT rect = { 430, 5, 786, 261 };
287 static bool bOpen =
false;
289 UISetCheck(ID_TOOLS_SHUTTEROPEN, bOpen);
301 dlg.DoModal(::GetActiveWindow());
307 COMDLG_FILTERSPEC fileTypes[] = {{ L
"XML parameter file", L
"*.xml" }};
308 CShellFileOpenDialog dlg(NULL, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST, L
"xml", fileTypes, 1);
309 dlg.GetPtr()->SetTitle(L
"Select parameter file");
310 IShellItem *psiFolder;
311 SHCreateItemFromParsingName(L
"C:\\Temp\\", NULL, IID_PPV_ARGS(&psiFolder));
312 dlg.GetPtr()->SetFolder(psiFolder);
315 if ( IDOK == dlg.DoModal(::GetDesktopWindow()) ) {
317 dlg.GetFilePath(filepath);
318 DBOUT(L
"Filepath " << filepath.GetString());
322 psiFolder->Release();
328 COMDLG_FILTERSPEC fileTypes[] = {{ L
"XML parameter file", L
"*.xml" }};
329 CShellFileSaveDialog dlg(NULL, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT, L
"xml", fileTypes, 1);
330 dlg.GetPtr()->SetTitle(L
"Select parameter file");
331 IShellItem *psiFolder;
332 SHCreateItemFromParsingName(L
"C:\\Temp\\", NULL, IID_PPV_ARGS(&psiFolder));
333 dlg.GetPtr()->SetFolder(psiFolder);
336 if ( IDOK != dlg.DoModal(::GetDesktopWindow()) )
340 dlg.GetFilePath(filepath);
341 DBOUT(L
"Filepath " << filepath.GetString());
344 psiFolder->Release();
350 COMDLG_FILTERSPEC fileTypes[] = {{ L
"XML parameter file", L
"*.xml" }};
351 CShellFileSaveDialog dlg(NULL, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT | FOS_FILEMUSTEXIST, L
"xml", fileTypes, 1);
352 dlg.GetPtr()->SetTitle(L
"Select parameter file");
353 IShellItem *psiFolder;
354 SHCreateItemFromParsingName(L
"C:\\Temp\\", NULL, IID_PPV_ARGS(&psiFolder));
355 dlg.GetPtr()->SetFolder(psiFolder);
358 if ( IDOK == dlg.DoModal(::GetDesktopWindow()) ) {
360 dlg.GetFilePath(filepath);
361 DBOUT(L
"Filepath " << filepath.GetString());
364 parameters.
Save(std::wstring(filepath.GetString()));
std::wstring CurrentConfigFile() const
The master parameters class.
void OnPaint(CDCHandle dc)
Recreates stored frames on first call.
WindowCollection frames
The parameters for windows on the screen.
bool GetShutterState(const uint32_t &_area) const
Current state of the shutter.
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
LRESULT OnSaveWindowPositions(WORD, WORD, HWND, BOOL &)
Calls ScopeController::SaveCurrentWindowPositions.
LRESULT OnSaveDefaultParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to save the default ScopeParameters.
LRESULT OnCreate(LPCREATESTRUCT lParam)
Creates the frame with all its stuff and the CMainDialogView inside.
LRESULT OnOpenLogbook(WORD, WORD, HWND, BOOL &)
Opens the LogFrame window.
LRESULT OnZeroGalvoOutputs(WORD, WORD, HWND, BOOL &)
Calls ScopeController::ZeroGalvoOutputs.
LRESULT OnLoadParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to load ScopeParameters.
Manages the display of images.
void NewLogFrame(const RECT &_rect)
Opens a CLogFrame.
LRESULT OnFileExit(WORD, WORD, HWND, BOOL &)
Calls QuitApplication.
This is the include file for standard system include files, or project specific include files that ar...
CMainDlgView m_dlgView
the view with the dialog controls
void QuitApplication()
Calls ScopeController::PrepareQuit and sends close message and subsequently quits the whole applicati...
LRESULT OnShutterOpen(WORD, WORD, HWND, BOOL &)
Calls ScopeController::OpenShutter.
scope::ScopeLogger scope_logger
our ScopeLogger here
scope::ScopeController scope_controller
our ScopeController here
Frame window class for the log.
void RecreateWindows()
Opens windows as saved.
void NewChannelFrame(const uint32_t &_area, const RECT &_rect)
Opens a new CChannelFrame.
LRESULT OnSaveParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to save ScopeParameters.
static std::array< UINT, 4 > histogramareas_ids
ids for the new histogram toolbar dropdown menu items.
CCommandBarCtrl m_CmdBar
the command bar.
#define DBOUT(s)
A debug output to the debug console.
bool LoadParameters(const std::wstring &filepath)
Load a complete ScopeParameters set from disk.
LRESULT OnAppAbout(WORD, WORD, HWND, BOOL &)
Opens the about dialog.
void Save(const std::wstring &filename) const
Save all to file.
bool firstpaint
to recreate stored windows
Manages the display of histograms.
BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
Forwards to the view.
LRESULT OnNewHistogramFrame(WORD, WORD, HWND, BOOL &)
Opens a new CHistogramFrame, determines which dropdown menu item/area was choosen.
void ZeroGalvoOutputs()
Zeros galvo outputs.
bool SaveParameters(const std::wstring &filepath)
Store the current complete ScopeParameters set to disk.
ScopeValue< RunState > run_state
current RunState
virtual void PrepareToolBarMenu(UINT nMenuID, HMENU hMenu)
Used in CToolBarHelper to fill the dropdown menus.
void NewHistogramFrame(const uint32_t &_area, const RECT &_rect)
Opens a new CHistogramFrame.
void OnTimer(UINT_PTR nIDEvent)
Update the memory consumption display.
LRESULT OnNewChannelFrame(WORD, WORD, HWND, BOOL &)
Opens a new CChannelFrame, determines which dropdown menu item/area was choosen.
std::vector< Window > collection
Vector with Window.
Shows information about Scope.
void OpenCloseShutter(const uint32_t &_area, const bool &_open)
Opens/closes the shutter.
CMultiPaneStatusBarCtrl m_wndStatusBar
the status bar
CAppModule _Module
The ATL application module.
void SaveCurrentWindowPositions()
Saves current positions of windows by adding frames to WindowCollection of ScopeController::GuiParame...
void OnDestroy()
Destroys view and removes message stuff.
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
static std::array< UINT, 4 > viewareas_ids
ids for the new view toolbar dropdown menu items.
void PrepareQuit()
Called by CMainDialogFrame::QuitApplication.