📄 fmdocvr.cpp
字号:
#include "StdAfx.h"#include "FMDocVR.h"#include "FusionDefine.h"#include "FusionGlobal.h"#include <math.h>RxFMDocVR::RxFMDocVR(){ m_iVRZoomFactor = 100;}//////////////////// Get the one and only global object// RxFMDocVR& RxFMDocVR::GetFMDocVR(){ // By creating theMap here, C++ doesn't instantiate it until/unless // it's ever used! This is a good trick to use in C++, to // instantiate/initialize a static object the first time it's used. // static RxFMDocVR theDocVR; return theDocVR;}/////////////////////////////////////////////////////////////////////////////// BEGIN : VR I/O/Operation functions// END : VR functions//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BEGIN : MPR I/O/Operation functionsvoid RxFMDocVR::MPR_Set_Struct(_3DMPR_INFO_PTR stPtrMPR){ m_stMPR.ptCenter.x = stPtrMPR->ptCenter.x; m_stMPR.ptCenter.y = stPtrMPR->ptCenter.y; m_stMPR.ptCenterSlant.x = stPtrMPR->ptCenterSlant.x; m_stMPR.ptCenterSlant.y = stPtrMPR->ptCenterSlant.y; m_stMPR.iCircleAngle = stPtrMPR->iCircleAngle; m_stMPR.iSelected = stPtrMPR->iSelected;}void RxFMDocVR::MPR_Set_Center(LPPOINT ptCenter){ m_stMPR.ptCenter.x = ptCenter->x; m_stMPR.ptCenter.y = ptCenter->y;}void RxFMDocVR::MPR_Set_Center_Slant(LPPOINT ptCenterSlant){ m_stMPR.ptCenterSlant.x = ptCenterSlant->x; m_stMPR.ptCenterSlant.y = ptCenterSlant->y;}void RxFMDocVR::MPR_Set_Circle_Angle(int iCircleAngle){ m_stMPR.iCircleAngle = iCircleAngle;}void RxFMDocVR::MPR_Set_Selected(int iSelected){ m_stMPR.iSelected = iSelected;}_3DMPR_INFO_PTR RxFMDocVR::MPR_Get_Struct(){ return &m_stMPR;}LPPOINT RxFMDocVR::MPR_Get_Center(){ return &(m_stMPR.ptCenter);}LPPOINT RxFMDocVR::MPR_Get_Center_Slant(){ return &(m_stMPR.ptCenterSlant);}int RxFMDocVR::MPR_Get_Circle_Angle(){ return m_stMPR.iCircleAngle;}int RxFMDocVR::MPR_Get_Selected(){ return m_stMPR.iSelected;}void RxFMDocVR::MPR_Initialize(CSize szWindow){ m_stMPR.ptCenter.x = szWindow.cx / 2; m_stMPR.ptCenter.y = szWindow.cy / 2; m_stMPR.ptCenterSlant = m_stMPR.ptCenter; m_stMPR.iCircleAngle = 45; m_stMPR.iSelected = HT_3DMPR_HORIZONTAL;}void RxFMDocVR::MPR_GetSlantPoint(LPPOINT ptStart, LPPOINT ptEnd, CSize szWindow){ int iTempAngle = 180 - m_stMPR.iCircleAngle; if(iTempAngle < 0) iTempAngle += 360; iTempAngle %= 180; double a, b; if(iTempAngle <= 45 || iTempAngle >= 135) { a = tan((double)iTempAngle * M_PI/180); b = m_stMPR.ptCenterSlant.y - a * m_stMPR.ptCenterSlant.x; ptStart->x = 0; ptStart->y = ROUNDOFF(b); ptEnd->x = szWindow.cx; ptEnd->y = ROUNDOFF(a * szWindow.cx + b); } else { a = tan((double)(90 - iTempAngle) * M_PI/180); b = m_stMPR.ptCenterSlant.x - a * m_stMPR.ptCenterSlant.y; ptStart->x = ROUNDOFF(b); ptStart->y = 0; ptEnd->x = ROUNDOFF(a * szWindow.cy + b); ptEnd->y = szWindow.cy; }}int RxFMDocVR::MPR_HitTest(LPPOINT point){ double dSlope; // Slant center double dDistance = (m_stMPR.ptCenterSlant.x - point->x) * (m_stMPR.ptCenterSlant.x - point->x) + (m_stMPR.ptCenterSlant.y - point->y) * (m_stMPR.ptCenterSlant.y - point->y); dDistance = sqrt(dDistance); if((int)dDistance <= MPR_CIRCLE_RADIUS) return HT_3DMPR_CIRCLE; // Slant line int nTempAngle = 180 - (int)m_stMPR.iCircleAngle; nTempAngle %= 180; dSlope = tan((double)nTempAngle); if(nTempAngle <= 45 || nTempAngle >= 135) { dSlope = tan((double)nTempAngle * M_PI/180); dDistance = fabs(dSlope * (point->x - m_stMPR.ptCenterSlant.x) + m_stMPR.ptCenterSlant.y - point->y) / sqrt(dSlope * dSlope + 1); } else { dSlope = tan((double)(90 - nTempAngle) * M_PI/180); dDistance = fabs(dSlope * (point->y - m_stMPR.ptCenterSlant.y) + m_stMPR.ptCenterSlant.x - point->x) / sqrt(dSlope * dSlope + 1); } int nHitDistance = 10; if(dDistance < nHitDistance) return HT_3DMPR_SLANT; // for x-line (horizontal) nHitDistance = 6; dDistance = (double)(point->y - m_stMPR.ptCenter.y); dDistance = (dDistance > 0) ? dDistance : -dDistance; if(dDistance < nHitDistance) return HT_3DMPR_HORIZONTAL; // for y-line (vertical) dDistance = (double)(point->x - m_stMPR.ptCenter.x); dDistance = (dDistance > 0) ? dDistance : -dDistance; if(dDistance < nHitDistance) return HT_3DMPR_VERTICAL; return HT_3DMPR_NONE;}// END : MPR functions/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -