Move the sources to trunk
[opencv] / apps / HMMDemo / HMMParams.cpp
1 // HMMParams.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "hmmdemo.h"
6 #include "HMMParams.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CHMMParams property page
16
17 IMPLEMENT_DYNCREATE(CHMMParams, CPropertyPage)
18
19 CHMMParams::CHMMParams() : CPropertyPage(CHMMParams::IDD)
20 {
21     m_States[0] = 5;//superstate
22
23     m_States[1] = 3;
24     m_States[2] = 6;
25     m_States[3] = 6;
26     m_States[4] = 6;
27     m_States[5] = 3;
28     m_States[6] = 0;
29     m_States[7] = 0;
30
31         //{{AFX_DATA_INIT(CHMMParams)
32         m_NumMix = 3;
33         //}}AFX_DATA_INIT
34 }
35
36 CHMMParams::~CHMMParams()
37 {
38 }
39
40 void CHMMParams::DoDataExchange(CDataExchange* pDX)
41 {
42         CPropertyPage::DoDataExchange(pDX);
43         //{{AFX_DATA_MAP(CHMMParams)
44     DDX_Text(pDX, IDC_NUMIX, m_NumMix);
45     DDX_Text(pDX, IDC_EDIT1, m_States[1]);
46     DDX_Text(pDX, IDC_EDIT2, m_States[2]);
47     DDX_Text(pDX, IDC_EDIT3, m_States[3]);
48     DDX_Text(pDX, IDC_EDIT4, m_States[4]);
49     DDX_Text(pDX, IDC_EDIT5, m_States[5]);
50     DDX_Text(pDX, IDC_EDIT6, m_States[6]);
51     DDX_Text(pDX, IDC_EDIT7, m_States[7]);
52         DDV_MinMaxInt(pDX, m_NumMix, 0, 255);
53         //}}AFX_DATA_MAP
54 }
55
56
57 BEGIN_MESSAGE_MAP(CHMMParams, CPropertyPage)
58         //{{AFX_MSG_MAP(CHMMParams)
59         //}}AFX_MSG_MAP
60 END_MESSAGE_MAP()
61
62 /////////////////////////////////////////////////////////////////////////////
63 // CHMMParams message handlers
64
65 BOOL CHMMParams::OnInitDialog() 
66 {       
67         CPropertyPage::OnInitDialog();
68         
69     //init check boxes
70     for( int i = 0; i < 7; i++ )
71     {
72         BOOL enable  = i < m_States[0];
73          ((CButton*)GetDlgItem( IDC_CHECK1 + i ))->SetCheck( enable );
74          GetDlgItem( IDC_EDIT1 + i )->EnableWindow( enable );
75     }     
76
77         // TODO: Add extra initialization here
78         
79         return TRUE;  // return TRUE unless you set the focus to a control
80                       // EXCEPTION: OCX Property Pages should return FALSE
81 }
82
83 BOOL CHMMParams::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
84 {
85         // TODO: Add your specialized code here and/or call the base class
86     if ( (nID >= IDC_CHECK1) && (nID <= IDC_CHECK7) )
87     {
88         int offset =  nID - IDC_CHECK1;
89
90         BOOL enable;
91         enable = ((CButton*)GetDlgItem( nID ))->GetCheck();
92
93         //enable all previous
94         if (enable)
95         {
96             for( int i = 0 ; i <= offset; i++ )  
97             {
98                 ((CButton*)GetDlgItem( IDC_CHECK1 + i ))->SetCheck( enable );
99                 GetDlgItem( IDC_EDIT1 + i )->EnableWindow( enable );
100             }
101             m_States[0] = offset+1;
102
103         }
104         else   //disable all consequtive
105         {
106             for( int i = offset ; i < 7; i++ )  
107             {
108                 ((CButton*)GetDlgItem( IDC_CHECK1 + i ))->SetCheck( enable );
109                 GetDlgItem( IDC_EDIT1 + i )->EnableWindow( enable );
110             }
111             m_States[0] = offset;
112         }
113         
114
115     }
116         
117         return CPropertyPage::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
118 }