// // FUNCTION: HandleCommand() // // PURPOSE: Take action in response to user action at the dialog box's controls. // void HandleCommand(_In_ HWND hwndDlg, _In_ WORD wCtrlId) { switch (wCtrlId) { case IDC_CLOSE: // Close the sample dialog box. EndDialog(hwndDlg, 0); break; case IDC_RADIO_100: case IDC_RADIO_200: case IDC_RADIO_300: case IDC_RADIO_400: // The user clicked one of the radio button to apply some fullscreen magnification. (We know the control ids are sequential here.) SetZoom(hwndDlg, (float)(wCtrlId - IDC_RADIO_100 + 1)); break; case IDC_CHECK_SETGRAYSCALE: { // The user clicked the checkbox to apply grayscale to the colors on the screen. bool fGrayscaleOn = (BST_CHECKED == SendDlgItemMessage(hwndDlg, IDC_CHECK_SETGRAYSCALE, BM_GETCHECK, 0, 0)); SetColorGrayscaleState(fGrayscaleOn); break; } case IDC_CHECK_SETINPUTTRANSFORM: { // The user clicked the checkbox to apply an input transform for touch and pen input. bool fInputTransformOn = (BST_CHECKED == SendDlgItemMessage(hwndDlg, IDC_CHECK_SETINPUTTRANSFORM, BM_GETCHECK, 0, 0)); SetInputTransform(hwndDlg, fInputTransformOn); break; } case IDC_BUTTON_GETSETTINGS: // The user wants to retrieve the current magnification settings. GetSettings(hwndDlg); break; } }
// // FUNCTION: SetZoom() // // PURPOSE: Apply fullscreen magnification. // void SetZoom(_In_ HWND hwndDlg, _In_ float magnificationFactor) { // Attempts to apply a magnification of less than 100% will fail. if (magnificationFactor >= 1.0) { // The offsets supplied to MagSetFullscreenTransform() are relative to the top left corner // of the primary monitor, in unmagnified coordinates. To position the top left corner of // some window of interest at the top left corner of the magnified view, call GetWindowRect() // to get the window rectangle, and pass the rectangle's left and top values as the offsets // supplied to MagSetFullscreenTransform(). // If the top left corner of the window of interest is to be positioned at the top left // corner of the monitor furthest to the left of the primary monitor, then the top left // corner of the virtual desktop would be adjusted by the current magnification, as follows: // int xOffset = rcTargetWindow.left - (int)(rcVirtualDesktop.left / magnificationFactor); // int yOffset = rcTargetWindow.top - (int)(rcVirtualDesktop.top / magnificationFactor); // For this sample, keep the sample's UI at the center of the magnified view on the primary monitor. // In order to do this, it is nececessary to adjust the offsets supplied to MagSetFullscreenTransform() // based on the magnification being applied. // Note that the calculations in this file which use GetSystemMetrics(SM_C*SCREEN) assume // that the values returned from that function are unaffected by the current DPI setting. // In order to ensure this, the manifest for this app declares the app to be DPI aware. int xDlg = (int)((float)GetSystemMetrics(SM_CXSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0); int yDlg = (int)((float)GetSystemMetrics(SM_CYSCREEN) * (1.0 - (1.0 / magnificationFactor)) / 2.0); BOOL fSuccess = MagSetFullscreenTransform(magnificationFactor, xDlg, yDlg); if (fSuccess) { // If an input transform for pen and touch is currently applied, update the transform // to account for the new magnification. BOOL fInputTransformEnabled; RECT rcInputTransformSource; RECT rcInputTransformDest; if (MagGetInputTransform(&fInputTransformEnabled, &rcInputTransformSource, &rcInputTransformDest)) { if (fInputTransformEnabled) { SetInputTransform(hwndDlg, fInputTransformEnabled); } } } } }
CameraObject::CameraObject() { m_videoBuffer = new TrackedVideoBuffer( DefaultImageSize[0], DefaultImageSize[1] ); SetInputTransform( m_videoBuffer->GetOutputTransform() ); m_videoInputSwitch = vtkSmartPointer<vtkPassThrough>::New(); m_videoInputSwitch->SetInputConnection( m_videoBuffer->GetVideoOutputPort() ); // by default, get input from internal buffer m_lensDisplacementTransform = vtkSmartPointer<vtkTransform>::New(); m_opticalCenterTransform = vtkSmartPointer<vtkTransform>::New(); m_opticalCenterTransform->Concatenate( this->GetWorldTransform() ); m_opticalCenterTransform->Concatenate( m_lensDisplacementTransform ); m_imageTransform = vtkSmartPointer<vtkTransform>::New(); m_imageTransform->SetInput( m_opticalCenterTransform ); m_trackingCamera = false; m_intrinsicEditable = false; m_extrinsicEditable = false; m_camera = vtkSmartPointer<vtkCamera>::New(); m_imageDistance = 100.0; m_globalOpacity = 0.7; m_saturation = 1.0; m_brightness = 1.0; m_useTransparency = false; m_useGradient = true; m_showMask = false; m_trackedTransparencyCenter = false; m_transparencyCenter[0] = 0.5; m_transparencyCenter[1] = 0.5; m_transparencyRadius[0] = 0.03; m_transparencyRadius[1] = 0.3; m_mouseMovingTransparency = false; CreateCameraRepresentation(); m_cachedImageSize[ 0 ] = DefaultImageSize[0]; m_cachedImageSize[ 1 ] = DefaultImageSize[1]; // make sure every ParamModified signal also generates a Modified signal connect( this, SIGNAL(ParamsModified()), this, SLOT(ParamsModifiedSlot()) ); }