1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
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.
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.
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.
42 // This class implements the property page for the CCondens filter
44 #include <cvstreams.h>
51 #include "Condensprop.h"
52 #include "Condensuids.h"
57 // This goes in the factory template table to create new filter instances
63 // This goes in the factory template table to create new filter instances
65 CUnknown * WINAPI CCondensProperties::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
67 CUnknown *punk = new CCondensProperties(lpunk, phr);
76 void CCondensProperties::InitSlider( int id, int lower, int upper, int tic_freq )
78 HWND slider = GetDlgItem( m_hWnd, id );
81 SendMessage( slider, TBM_SETRANGE, TRUE, MAKELONG(lower, upper) );
85 SendMessage( slider, TBM_SETTICFREQ, tic_freq, 0 );
91 void CCondensProperties::SetSliderPos( int id, int pos )
93 HWND slider = GetDlgItem( m_hWnd, id );
96 SendMessage( slider, TBM_SETPOS, TRUE, pos );
101 int CCondensProperties::GetSliderPos( int id )
103 HWND slider = GetDlgItem( m_hWnd, id );
108 pos = SendMessage( slider, TBM_GETPOS, 0, 0 );
115 void CCondensProperties::ReadParamsFromControls()
117 m_params.x = ((float)GetSliderPos( IDC_WIN_LEFT ))/SLIDER_MAX;
118 m_params.y = ((float)GetSliderPos( IDC_WIN_TOP ))/SLIDER_MAX;
119 m_params.width = ((float)GetSliderPos( IDC_WIN_WIDTH ))/SLIDER_MAX;
120 m_params.height = ((float)GetSliderPos( IDC_WIN_HEIGHT ))/SLIDER_MAX;
122 m_params.Smin = GetSliderPos( IDC_S_MIN );
123 m_params.Vmin = GetSliderPos( IDC_V_MIN );
125 //m_params.nSamples = GetSliderPos( IDC_SLIDERS_NUM );
127 m_params.view = IsDlgButtonChecked( m_hWnd, IDC_BACKPR );
131 void CCondensProperties::WriteParamsToControls()
133 SetSliderPos( IDC_WIN_LEFT, cvRound( m_params.x * SLIDER_MAX ));
134 SetSliderPos( IDC_WIN_TOP, cvRound( m_params.y * SLIDER_MAX ));
135 SetSliderPos( IDC_WIN_WIDTH, cvRound( m_params.width * SLIDER_MAX ));
136 SetSliderPos( IDC_WIN_HEIGHT, cvRound( m_params.height * SLIDER_MAX ));
138 SetSliderPos( IDC_S_MIN, m_params.Smin );
139 SetSliderPos( IDC_V_MIN, m_params.Vmin );
141 //SetSliderPos( IDC_SAMPLES_NUM, m_params.nSamples );
143 CheckRadioButton( m_hWnd, IDC_NORMAL, IDC_BACKPR, m_params.view + IDC_NORMAL );
149 CCondensProperties::CCondensProperties(LPUNKNOWN pUnk, HRESULT *phr) :
150 CBasePropertyPage(NAME("Condens Property Page"),pUnk,
162 // Sets m_bDirty and notifies the property page site of the change
164 void CCondensProperties::SetDirty()
168 m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
177 // Virtual method called by base class with Window messages
179 BOOL CCondensProperties::OnReceiveMessage( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
186 InitSlider( IDC_WIN_LEFT, 0, 1000, 0 );
187 InitSlider( IDC_WIN_TOP, 0, 1000, 0 );
188 InitSlider( IDC_WIN_WIDTH, 0, 1000, 0 );
189 InitSlider( IDC_WIN_HEIGHT, 0, 1000, 0 );
191 InitSlider( IDC_S_MIN, 0, 255, 5 );
192 InitSlider( IDC_V_MIN, 0, 255, 5 );
194 //InitSlider( IDC_SAMPLES_NUM, 16, 256, 16 );
196 WriteParamsToControls();
206 if(LOWORD(wParam) == IDC_START)
208 m_pCCondens->StartTracking();
210 else if (LOWORD(wParam) == IDC_STOP)
212 m_pCCondens->StopTracking();
216 return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
217 } // OnReceiveMessage
223 // Called when the property page connects to a filter
225 HRESULT CCondensProperties::OnConnect(IUnknown *pUnknown)
227 ASSERT(m_pCCondens == NULL);
229 HRESULT hr = pUnknown->QueryInterface(IID_ICCondens, (void **) &m_pCCondens);
231 return E_NOINTERFACE;
235 m_pCCondens->GetParams(&m_params);
245 // Called when we're disconnected from a filter
247 HRESULT CCondensProperties::OnDisconnect()
249 // Release of Interface after setting the appropriate contrast value
251 if (m_pCCondens == NULL) {
255 m_pCCondens->Release();
265 // We are being deactivated
267 HRESULT CCondensProperties::OnDeactivate(void)
277 // Changes made should be kept. Change the variable
279 HRESULT CCondensProperties::OnApplyChanges()
281 ReadParamsFromControls();
282 m_pCCondens->SetParams(&m_params);