Move the sources to trunk
[opencv] / apps / CamShiftDemo / mainfrm.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/// MainFrm.h : interface of the CMainFrame class
41 //
42 /////////////////////////////////////////////////////////////////////////////
43
44 #if !defined(AFX_MAINFRM_H__A510D781_2548_11D3_8C73_00A0C998A94B__INCLUDED_)
45 #define AFX_MAINFRM_H__A510D781_2548_11D3_8C73_00A0C998A94B__INCLUDED_
46
47 #if _MSC_VER > 1000
48 #pragma once
49 #endif // _MSC_VER > 1000
50
51 #include "cvstreams.h"
52 #include "iCamShift.h"
53 #include "CamShiftUIDs.h"
54
55 #define SafeRelease(p) { if( (p) != 0 ) { (p)->Release(); (p)= 0; } }
56 #define WM_GRAPHNOTIFY  WM_USER+13 
57
58
59 /////////////////////////////////////////////////////////////////////////////
60 // CBar dialog
61
62 class CBar : public CDialogBar
63 {
64 // Construction
65 public:
66     CBar();   // standard constructor
67
68     ReadParamsFromControls( CvCamShiftParams& params );
69     WriteParamsToControls( CvCamShiftParams& params );
70
71 // Dialog Data
72     //{{AFX_DATA(CBar)
73     enum { IDD = IDD_BAR };
74     int     m_Smin;
75     int     m_Threshold;
76     int     m_Vmax;
77     int     m_Vmin;
78     int     m_Bins;
79     BOOL    m_ShowPicture;
80     BOOL    m_ShowBackProject;
81     BOOL    m_ShowHistogram;
82     //}}AFX_DATA
83
84 // Overrides
85     // ClassWizard generated virtual function overrides
86     //{{AFX_VIRTUAL(CBar)
87     protected:
88     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
89     //}}AFX_VIRTUAL
90
91 // Implementation
92 protected:
93
94     // Generated message map functions
95     //{{AFX_MSG(CBar)
96     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
97     afx_msg void OnPicture();
98     afx_msg void OnBackProject();
99     afx_msg void OnHistogram();
100     //}}AFX_MSG
101     DECLARE_MESSAGE_MAP()
102 };
103
104 class CMainFrame : public CFrameWnd
105 {
106 protected: // create from serialization only
107     CMainFrame();
108     DECLARE_DYNCREATE(CMainFrame)
109
110 // Attributes
111 public:
112     ICamShift*      m_CamShiftProp;
113
114 // Operations
115 public:
116
117 // Overrides
118     // ClassWizard generated virtual function overrides
119     //{{AFX_VIRTUAL(CMainFrame)
120     virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
121     //}}AFX_VIRTUAL
122
123 // Implementation
124 public:
125     virtual ~CMainFrame();
126 #ifdef _DEBUG
127     virtual void AssertValid() const;
128     virtual void Dump(CDumpContext& dc) const;
129 #endif
130
131     CRect           StartTrackerInit();
132     void            EndTrackerInit( CRect r );
133     void            UpdateThreshold();
134     void            ChangeSource();
135     void            StopGraph();
136     void            StartGraph();
137     bool            CreateFilterGraph();
138     void            ClearFilterGraph();
139     void            DestroyFilterGraph();
140     bool            CreateCamShift();
141     bool            CreateCamera( int idx=0 );
142     void            CreateBouncingBall();
143     void            SetVideoWindowSize();
144     CRect           GetVideoWindowSize(); 
145     void            GetScaleFactor( int& sx, int &sy );
146
147 protected:  // control bar embedded members
148     CStatusBar      m_wndStatusBar;
149     CToolBar        m_wndToolBar;
150     CBar            m_wndBar;
151     int             m_input;
152     CRect           m_src_rect;
153     
154     // DirectShow interface pointers
155     IGraphBuilder*  m_GraphBuilder;
156     IMediaControl*  m_MediaControl;
157     IVideoWindow*   m_VideoWindow;
158     IFilterGraph*   m_FilterGraph;
159     IMediaEventEx*  m_MediaEventEx;
160     IBaseFilter*    m_SourceFilter;
161     IBaseFilter*    m_CamShift;
162
163 // Generated message map functions
164 protected:
165     //{{AFX_MSG(CMainFrame)
166     afx_msg int  OnCreate(LPCREATESTRUCT lpCreateStruct);
167     afx_msg void OnDestroy();
168     afx_msg void OnSize(UINT nType, int cx, int cy);
169     afx_msg void OnCamera();
170     afx_msg void OnBall();
171     afx_msg void OnFile();
172     afx_msg void OnPlayPause();
173     afx_msg void OnUpdateCamera(CCmdUI* pCmdUI);
174     afx_msg void OnUpdateBall(CCmdUI* pCmdUI);
175     afx_msg void OnUpdateFile(CCmdUI* pCmdUI);
176     afx_msg void OnUpdatePlayPause(CCmdUI* pCmdUI);
177     //}}AFX_MSG
178     DECLARE_MESSAGE_MAP()
179 };
180
181 /////////////////////////////////////////////////////////////////////////////
182
183 //{{AFX_INSERT_LOCATION}}
184 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
185
186 #endif // !defined(AFX_MAINFRM_H__A510D781_2548_11D3_8C73_00A0C998A94B__INCLUDED_)