📄 mainframe.h
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: MainFrame.h, 5, 27.09.2002 13:00:17, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
\file MainFrame.h
\brief Interface of the CMainFrame class.
*/
#pragma once
#include "BitmapView.h"
#include <Utilities.h>
#include <queue>
#include <AtlCtrlx.h>
#include <bcam.h>
using namespace std;
using namespace Bcam;
//! Use OneShot (=true) or ContinuousShot(=false) for grabbing
const bool USE_ONESHOT = false;
//! Number of buffers used for grabbing
const unsigned int NUM_BUFFERS = 3;
//! Message fired by the GrabThread if the grab is finshed
const UINT WM_GRAB_FINISHED = WM_USER;
//! Message fired by the GrabThread if the user stops the grabbing
const UINT WM_GRAB_STOPPED = WM_USER + 1;
//! Message fired by the GrabThread if something has gone wrong
const UINT WM_ERROR = WM_USER + 2;
//! Main window of the SDI application. Handles commands.
class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
//! Default Constructor
CMainFrame() :
m_GrabFinished(false),
m_LiveGrabbing(false),
m_DisplayedBufferIndex(-1),
m_IsBayerImage(false)
{
}
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand)
MESSAGE_HANDLER(WM_GRAB_FINISHED, OnGrabFinished)
MESSAGE_HANDLER(WM_GRAB_STOPPED, OnGrabStopped)
MESSAGE_HANDLER(WM_ERROR, OnError)
COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)
COMMAND_ID_HANDLER(ID_FILE_NEW, OnFileNew)
COMMAND_ID_HANDLER(ID_FILE_OPEN, OnFileOpen)
COMMAND_ID_HANDLER(ID_FILE_SAVE, OnFileSave)
COMMAND_ID_HANDLER(ID_EDIT_COPY, OnEditCopy)
COMMAND_ID_HANDLER(ID_GRAB_LIVE, OnGrabLive)
COMMAND_ID_HANDLER(ID_GRAB_STOP, OnGrabStop)
CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
END_MSG_MAP()
BEGIN_UPDATE_UI_MAP(CMainFrame)
UPDATE_ELEMENT(ID_FILE_NEW, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_FILE_OPEN, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_FILE_SAVE, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_FILE_PRINT, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_FILE_PRINT_PREVIEW, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_FILE_PRINT_SETUP, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_EDIT_COPY, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_GRAB_LIVE, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_GRAB_STOP, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
UPDATE_ELEMENT(ID_GRAB_SNAPMONO16, UPDUI_MENUPOPUP )
END_UPDATE_UI_MAP()
// GUI objects
protected:
//! The comand bar holding the menu
CCommandBarCtrl m_CmdBar;
//! The view showing the bitmap
CBitmapView m_view;
// Command and message handlers
protected:
//! Creates the window
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Check if someonewants us to die
LRESULT OnSysCommand(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Closes the window
LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Fired if grab is to be started
LRESULT OnGrabLive(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if the GrabThread sends a messages indicating that the grab is finished
LRESULT OnGrabFinished(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Fired if grab is to be finished
LRESULT OnGrabStop(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if the GrabThread sends a messages indicating that it has terminated
LRESULT OnGrabStopped(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Fired if an error in a thread occurred
LRESULT OnError(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
//! Fired if the currently shown bitmap should be cleared
LRESULT OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if a bitmap is to be loaded
LRESULT OnFileOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if a bitmap is to be saved
LRESULT OnFileSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if the application should exit
LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
//! Fired if the imageshould be copied to the clipboard
LRESULT OnEditCopy(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
// Other implementation functions
protected:
//! called befor the message handlers
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
return TRUE;
return m_view.PreTranslateMessage(pMsg);
}
//! Idle handler
virtual BOOL OnIdle();
//! Called by the framewor if the user interface's enable status needs to be updated
void UpdateUI();
// Member Variables
protected:
//! Status Bar
CMultiPaneStatusBarCtrl m_StatusBar;
//! The camera
CBcam m_Bcam;
//! True if live grabbing is under way
bool m_LiveGrabbing;
//! Index of the buffer which is currently displayed (-1 = none)
int m_DisplayedBufferIndex;
//! Two images for double-buffering
CDibPtr m_ptrBitmaps[NUM_BUFFERS];
//! Queue holding the buffers recwived
queue<unsigned int> m_BufferQueue;
//! Thread waiting for grab commands to succeed
CThread m_GrabThread;
//! The function of the thread waiting for grab commands to succeed
static DWORD WINAPI GrabThreadProc(void* pParameter);
//! Set true by OnGrabFinished; reset by OnIdle
bool m_GrabFinished;
//! Used to measure the frame rate
CStopWatch m_StopWatch;
//! Frame rate
CMovingAvg<double> m_Fps;
//! True if the Mono8 format of the camera is in fact Bayer8
bool m_IsBayerImage;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -