// Handler for the modeless polygon counter dialog. static INT_PTR CALLBACK PolyCountDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TSTR buf; int val; switch (msg) { case WM_INITDIALOG: thePolyCounter.hDlg = hDlg; CenterWindow(hDlg, GetParent(hDlg)); thePolyCounter.maxPolys = GetISpinner(GetDlgItem(hDlg, IDC_MAX_POLY_SPIN)); thePolyCounter.maxPolys->SetScale(10.0f); thePolyCounter.maxPolys->SetLimits(0, 1000000); thePolyCounter.maxPolys->LinkToEdit(GetDlgItem(hDlg, IDC_MAX_POLY_EDIT), EDITTYPE_INT); thePolyCounter.maxPolys->SetResetValue(10000); GetAppData(thePolyCounter.ip, MAX_POLYS_ID, _T("10000"), buf); if (atoi(buf, val)) thePolyCounter.maxPolys->SetValue(val, FALSE); thePolyCounter.maxSelected = GetISpinner(GetDlgItem(hDlg, IDC_MAX_SELECTED_SPIN)); thePolyCounter.maxSelected->SetScale(10.0f); thePolyCounter.maxSelected->SetLimits(0, 1000000); thePolyCounter.maxSelected->LinkToEdit(GetDlgItem(hDlg, IDC_MAX_SELECTED_EDIT), EDITTYPE_INT); thePolyCounter.maxSelected->SetResetValue(1000); GetAppData(thePolyCounter.ip, MAX_SELECTED_ID, _T("1000"), buf); if (atoi(buf, val)) thePolyCounter.maxSelected->SetValue(val, FALSE); CheckRadioButton(hDlg, IDC_TRIANGLE, IDC_POLY, IDC_TRIANGLE); countTriangles = IsDlgButtonChecked(hDlg, IDC_TRIANGLE); InitFaceCount(); CountFaces(thePolyCounter.ip); break; case CC_SPINNER_CHANGE: case WM_CUSTEDIT_ENTER: val = thePolyCounter.maxPolys->GetIVal(); buf.printf(_T("%d"), val); WriteAppData(thePolyCounter.ip, MAX_POLYS_ID, buf); val = thePolyCounter.maxSelected->GetIVal(); buf.printf(_T("%d"), val); WriteAppData(thePolyCounter.ip, MAX_SELECTED_ID, buf); // fall through case WM_PAINT: thePolyCounter.DrawBars(); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_TRIANGLE: countTriangles = IsDlgButtonChecked(hDlg, IDC_TRIANGLE); InitFaceCount(); CountFaces(thePolyCounter.ip); thePolyCounter.DrawBars(); break; case IDC_POLY: countTriangles = !(IsDlgButtonChecked(hDlg, IDC_POLY)); InitFaceCount(); CountFaces(thePolyCounter.ip); thePolyCounter.DrawBars(); break; case IDCANCEL: EndDialog(hDlg, FALSE); ReleaseISpinner(thePolyCounter.maxPolys); ReleaseISpinner(thePolyCounter.maxSelected); if (thePolyCounter.iu) thePolyCounter.iu->CloseUtility(); thePolyCounter.hDlg = NULL; thePolyCounter.End(); break; } } return FALSE; }
CCamera* CViacamController::SetUpCamera() { CCamera* cam; int numDevices; int camId= -1; // Load app local data ReadAppData(wxConfigBase::Get()); numDevices= CCameraEnum::GetNumDevices (); if (numDevices== 0) { wxMessageDialog errorMsg (NULL, _("Not detected any camera. Aborting"), _T("Enable Viacam"), wxOK | wxICON_ERROR); errorMsg.ShowModal(); return NULL; } // Try to find previously used camera if (m_cameraName.Length()> 0) { for (camId= 0; camId< numDevices; camId++) if (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc)== m_cameraName) break; if (camId== numDevices) camId= -1; // Not found } // Show selection dialog when needed if (camId== -1) { if(numDevices > 1) { wxArrayString strArray; for (camId= 0; camId< numDevices; camId++) strArray.Add (wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc)); wxSingleChoiceDialog choiceDlg(NULL, _("Choose the camera to use"), _T("Enable Viacam"), strArray, NULL, wxDEFAULT_DIALOG_STYLE | wxOK | wxCANCEL | wxCENTRE); if (choiceDlg.ShowModal ()!= wxID_OK) return NULL; camId= choiceDlg.GetSelection(); m_cameraName= choiceDlg.GetStringSelection (); } else { camId= 0; m_cameraName= wxString(CCameraEnum::GetDeviceName (camId), wxConvLibc); } } cam= CCameraEnum::GetCamera(camId); if (!cam) return NULL; cam->SetHorizontalFlip (true); // Try to open the camera to ensure it works if (!cam->Open ()) { wxMessageDialog errorMsg (NULL, _("Can not initialize the camera.\nPerhaps is being used by other application."), _T("Enable Viacam"), wxOK | wxICON_ERROR); errorMsg.ShowModal(); delete cam; cam= NULL; ChangeCamera(); } else cam->Close(); WriteAppData(wxConfigBase::Get()); wxConfigBase::Get()->Flush(); return cam; }