|
- // ************************************************************************** //
- // MachineControlDlg.cpp : implementation of the CMachineControlDlg_Left class
- // Copyright(c)2011 Naiky Company. All rights reserved.
- //
- // Abstract:
- // 本文件实现CMachineControlDlg_Left类。
- // ********************************************* ---- 杨开锦 2011-10-31 ***** //
- #include "stdafx.h"
- #include "MachineControlDlg_Left.h"
- #include "EditItem.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #define new DEBUG_NEW
- #endif
-
- CS_T s_csRapidJog = _DEFCS(_CSV(18552),
- _CHINESE("高速")
- _ENGLISH("Rapid\nJog"));
- CS_T s_csSlowJog = _DEFCS(_CSV(18553),
- _CHINESE("连续")
- _ENGLISH("Jog"));
- CS_T s_csJOG = _DEFCS(_CSV(18554),
- _CHINESE("点动")
- _ENGLISH("Jog"));
- CS_T s_csLANGUAGE = _DEFCS(_CSV(18555),
- _CHINESE("CHN")
- _ENGLISH("ENG"));
- CS_T s_csNotInputPrompt = _DEFCS(_CSV(18556),
- _CHINESE("系统忙,当前加工状态无法修改该参数!")
- _ENGLISH("System is busy, can not change the parameters!"));
- CS_T s_csIntDataError = _DEFCS(_CSV(18557),
- _CHINESE("输入的参数无效,只能输入正整数,请重新输入!")
- _ENGLISH("Data error, it should be a positive integer, Please enter again!"));
- CS_T s_csFloatDataError = _DEFCS(_CSV(18558),
- _CHINESE("输入的参数无效,请重新输入!")
- _ENGLISH("Data error, it should be a number, Please enter again!"));
- CS_T s_csFloatDataBoundError = _DEFCS(_CSV(18559),
- _CHINESE("参数范围错误,请输入一个“%.1f~%.1f”之间的数!")
- _ENGLISH("Please enter a number between %f~%f"));
-
- CS_T s_csAXES = _DEFCS(_CSV(18560),
- _CHINESE("轴")
- _ENGLISH("Axes"));
- CS_T s_csMACHINECOORDINATE = _DEFCS(_CSV(18561),
- _CHINESE("机械坐标")
- _ENGLISH("MachCoor"));
- CS_T s_csWORKPIECECOORDINATE = _DEFCS(_CSV(18562),
- _CHINESE("工件坐标")
- _ENGLISH("WorkCoor"));
-
- CS_T s_csRESUME = _DEFCS(_CSV(18563),
- _CHINESE("断点\n继续")
- _ENGLISH("Resume"));
- CS_T s_csSIMU = _DEFCS(_CSV(18564),
- _CHINESE("仿真")
- _ENGLISH("Simu"));
- CS_T s_csDIRRUN = _DEFCS(_CSV(18565),
- _CHINESE("空运行")
- _ENGLISH("DryRun"));
- CS_T s_csSIMUCUTBOUNDRECT = _DEFCS(_CSV(18566),
- _CHINESE("走边框")
- _ENGLISH("Frame"));
- CS_T s_csTipSETWORKORG = _DEFCS(_CSV(18567),
- _CHINESE("设置工件原点")
- _ENGLISH("Set WorkOrg"));
- CS_T s_csTipMOVETOWORKORIGIN = _DEFCS(_CSV(18568),
- _CHINESE("回工件原点")
- _ENGLISH("Work Origin"));
- CS_T s_csTipSIMUCUTBOUNDRECT = _DEFCS(_CSV(18569),
- _CHINESE("走边框")
- _ENGLISH("Frame"));
- CS_T s_csTipSTART = _DEFCS(_CSV(18570),
- _CHINESE("开始")
- _ENGLISH("Start"));
- CS_T s_csTipPAUSE = _DEFCS(_CSV(18571),
- _CHINESE("暂停")
- _ENGLISH("Pause"));
- CS_T s_csTipSTOP = _DEFCS(_CSV(18572),
- _CHINESE("停止")
- _ENGLISH("Stop"));
- CS_T s_csTipGoBackward = _DEFCS(_CSV(18573),
- _CHINESE("后退")
- _ENGLISH("GoBackward"));
- CS_T s_csTipGoForward = _DEFCS(_CSV(18574),
- _CHINESE("前进")
- _ENGLISH("GoForward"));
- CS_T s_csTipFollowSample = _DEFCS(_CSV(18575),
- _CHINESE("标定")
- _ENGLISH("Sample"));
- CS_T s_csTipBackAll = _DEFCS(_CSV(18576),
- _CHINESE("全部回机械原点")
- _ENGLISH("BackAll"));
- CS_T s_csDistanceSet = _DEFCS(_CSV(18577),
- _CHINESE("前进后退距离设定")
- _ENGLISH("Distance Set"));
- CS_T s_szPortNameKey = _DEFCS(_CSV(18578),
- _CHINESE("Port%d_ChnName")
- _ENGLISH("Port%d_EngName"));
- CS_T s_szLaserOnWhenJog = _DEFCS(_CSV(18067),
- _CHINESE("点动时出激光:")
- _ENGLISH("Laser ON at Jog:"));
- CS_T s_csSELECTMACH = _DEFCS(_CSV(18620),
- _CHINESE("加工选中图形:")
- _ENGLISH("Machine Selected:"));
-
- CS_T s_szMUNU_MARKPOINT1 = _DEFCS(_CSV(18640),
- _CHINESE("标记点1")
- _ENGLISH("Mark point1"));
- CS_T s_szMUNU_MARKPOINT2 = _DEFCS(_CSV(18641),
- _CHINESE("标记点2")
- _ENGLISH("Mark point2"));
- CS_T s_szMUNU_MARKPOINT3 = _DEFCS(_CSV(18642),
- _CHINESE("标记点3")
- _ENGLISH("Mark point3"));
- CS_T s_szMUNU_MARKPOINT4 = _DEFCS(_CSV(18643),
- _CHINESE("标记点4")
- _ENGLISH("Mark point4"));
- CS_T s_szMUNU_MARKPOINT5 = _DEFCS(_CSV(18644),
- _CHINESE("标记点5")
- _ENGLISH("Mark point5"));
- CS_T s_szMUNU_MARKPOINT6 = _DEFCS(_CSV(18645),
- _CHINESE("标记点6")
- _ENGLISH("Mark point6"));
- CS_T s_szMUNU_MARKPOINT7 = _DEFCS(_CSV(18646),
- _CHINESE("标记点7")
- _ENGLISH("Mark point7"));
- CS_T s_szMUNU_MARKPOINT8 = _DEFCS(_CSV(18647),
- _CHINESE("标记点8")
- _ENGLISH("Mark point8"));
-
- using namespace mach;
- using namespace ncmath;
-
- struct CRunReportTarget::CCache
- {
- mach::CStateManager::State State;
- mach::CStateManager::Speed Speed;
- mach::CStateManager::FileInformation FileInfo;
- mach::CStateManager::CLInformation CLInfo;
- };
- ////////////////////////////////////////////////////////////////////////////////
- // CtrlID
- enum
- {
- CTRLID_BTN_F = psh1,
- CTRLID_BTN_CENTER,
- CTRLID_BTN_XP,
- CTRLID_BTN_XN,
- CTRLID_BTN_YP,
- CTRLID_BTN_YN,
- CTRLID_BTN_ZP,
- CTRLID_BTN_ZN,
- CTRLID_BTN_GOFORWARD,
- CTRLID_BTN_GOBACKWARD,
- CTRLID_BTN_GODISTANCE,
- CTRLID_BTN_CHANGECOOR,
- CTRLID_BTN_MACHSELECTEDON,
- CTRLID_BTN_MACHSELECTEDOFF,
- CTRLID_BTN_JOGLASERON,
- CTRLID_BTN_JOGLASEROFF,
- CTRLID_BTN_AUTOCYC,
- CTRLID_BTN_SELMARKPOINT,
- CTRLID_BTN_CYCMACH,
- CTRLID_BTN_MAX,
- CTRLID_BTN_MARKPOINT1,
- CTRLID_BTN_MARKPOINT2,
- CTRLID_BTN_MARKPOINT3,
- CTRLID_BTN_MARKPOINT4,
- CTRLID_BTN_MARKPOINT5,
- CTRLID_BTN_MARKPOINT6,
- CTRLID_BTN_MARKPOINT7,
- CTRLID_BTN_MARKPOINT8,
-
- CTRLID_STC_AXES = stc1,
- CTRLID_STC_COOR,
- CTRLID_STC_PORT0,
- CTRLID_STC_PORT1,
- CTRLID_STC_PORT2,
- CTRLID_STC_PORT3,
- CTRLID_STC_PORT4,
- CTRLID_STC_PORT5,
- CTRLID_STC_PORT6,
- CTRLID_STC_PORT7,
- CTRLID_STC_PORT8,
- CTRLID_STC_PORT9,
- CTRLID_STC_PORT10,
- CTRLID_STC_PORT11,
- CTRLID_STC_PORT12,
- CTRLID_STC_PORT13,
- CTRLID_STC_PORT14,
- CTRLID_STC_PORT15,
- CTRLID_STC_XVALUE,
- CTRLID_STC_YVALUE,
- CTRLID_STC_ZVALUE,
- CTRLID_STC_MACHCOOR,
- CTRLID_STC_WORKCOOR,
- CTRLID_STC_SELECTMACH,
- CTRLID_STC_JOGLASER,
-
- CTRLID_EDIT_GODISTANCE = edt1,
-
- CTRLID_SLD_SETF = ctl1,
- CTRLID_SLD_SETP,
- CTRLID_SLD_SETFH,
- };
- ////////////////////////////////////////////////////////////////////////////////
- // Local function declarations ---- DingQiang 2012-06-25
- static double _FormatInputData(double nInputData_);
-
- ////////////////////////////////////////////////////////////////////////////////
- // CMachineControlDlg_Left
- //
- // 只需要按类名创建类对象,不需要序列化与版本控制。 ---- 杨开锦 2011-10-31
- IMPLEMENT_SERIAL(CMachineControlDlg_Left, CAgileDialog, 0xFFFF)
-
- BEGIN_MESSAGE_MAP(CMachineControlDlg_Left, CAgileDialog)
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- ON_WM_CTLCOLOR()
- ON_WM_HSCROLL()
- ON_WM_LBUTTONDOWN()
- ON_MESSAGE(WM_MYDLGMESSAGE, OnEndSpeedDlg)
- ON_CONTROL_RANGE(BN_PUSHED, CTRLID_BTN_XP, CTRLID_BTN_ZN, OnDirectionBtnPushed)
- ON_CONTROL_RANGE(BN_UNPUSHED, CTRLID_BTN_XP, CTRLID_BTN_ZN, OnDirectionBtnUnpushed)
- ON_CONTROL_RANGE(BN_PUSHED, CTRLID_BTN_GOFORWARD, CTRLID_BTN_GOBACKWARD, OnGFOBBtnPushed)
- ON_CONTROL_RANGE(BN_UNPUSHED, CTRLID_BTN_GOFORWARD, CTRLID_BTN_GOBACKWARD, OnGFOBBtnUnpushed)
- ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
- ON_CONTROL(STN_DBLCLK, CTRLID_STC_COOR, OnChangeCoorMode)
- ON_MESSAGE(WM_MYEIDTMESSAGE, OnEndEditDistance)
- ON_COMMAND(CTRLID_BTN_CHANGECOOR, OnChangeCoorMode)
- ON_COMMAND(CTRLID_BTN_MAX, OnMaxSize)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_CENTER, OnSetManuMode)
- ON_CONTROL(BN_DOUBLECLICKED, CTRLID_BTN_CENTER, OnDblClickCenter)
- ON_MESSAGE(WM_BITMAPSLIDER_MOVING, OnSliderMoving)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_MACHSELECTEDON, OnCloseMachSelected)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_MACHSELECTEDOFF, OnOpenMachSelected)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_JOGLASERON, OnCloseJogLaser)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_JOGLASEROFF, OnOpenJogLaser)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_AUTOCYC, OnClickAutoCyc)
- ON_CONTROL(BN_CLICKED, CTRLID_BTN_CYCMACH, OnClickCycMach)
- ON_COMMAND(CTRLID_BTN_SELMARKPOINT, OnSelMarkPoint)
- ON_COMMAND_RANGE(CTRLID_BTN_MARKPOINT1, CTRLID_BTN_MARKPOINT8, OnMarkPointChange)
-
- END_MESSAGE_MAP()
-
- CMachineControlDlg_Left::CMachineControlDlg_Left(CWnd* pParentWnd_/* = NULL*/)
- : CMachineControlDlg_Imp(pParentWnd_)
- {
- //m_pwndSliderF = NULL;
- m_pwndBtnXP = NULL;
- m_pwndBtnXN = NULL;
- m_pwndBtnYP = NULL;
- m_pwndBtnYN = NULL;
- m_pwndBtnZP = NULL;
- m_pwndBtnZN = NULL;
- m_pwndBtnCenter = NULL;
- m_pwndStcValueWorkX = NULL;
- m_pwndStcValueWorkY = NULL;
- m_pwndStcValueWorkZ = NULL;
- m_pwndStcValueMachX = NULL;
- m_pwndStcValueMachY= NULL;
- m_pwndStcValueMachZ = NULL;
- m_pwndStcSpeed = NULL;
- m_pwndStcPower = NULL;
- m_pwndStcFollowHeight = NULL;
- m_pSetSpeedDlg = NULL;
- m_pwndSliderSetF = NULL;
- m_pwndSliderSetP = NULL;
- m_pwndSliderSetFH = NULL;
- m_pDistanceEdit = NULL;
- m_pwndRunBtn = NULL;
- m_pwndDirRunBtn = NULL;
- m_pwndBtnSelMachOn = NULL;
- m_pwndBtnSelMachOff = NULL;
- m_pwndBtnJogLaserOn = NULL;
- m_pwndBtnJogLaserOff = NULL;
- m_pwndBtnMoveIn = NULL; // 交换工作台
- m_pwndBtnMoveOut = NULL; // 释放工作台
- m_pwndBtnMax = NULL;
-
- m_pMenu = new CMenu;
-
- memset(m_pwndPortButtons, 0, sizeof(CPortButton*) * _countof(m_pwndPortButtons));
-
- m_nCoorMode = 0x00;
- m_bSelectMach = FALSE;
-
- for (int _i = 0; _i < _countof(m_nFValues); _i++)
- {
- m_nFValues[_i] = _i;
- }
-
- m_strShowAllBKMark = "0";
- m_strBKMarkAttachAxis = "0,1";
-
- m_nArcSliderFHMax = 15;
-
- m_bSliderCtrlG00 = NceGetPrivateProfileString(_T("ControlTarget"), _T("SliderCtrlG00"), _T("0")) == _T("1");
- // 同步GXX和G00的倍率。 ---- 黄海燕 2016-04-19
- if (m_bSliderCtrlG00)
- {
- if (CParamManager* _pParamManager = GetParamManager())
- {
- int _nFrp = 100;
- ParameterValue _FrpParamValue;
- if (_pParamManager->GetParameterValue("SpeedGxx_Frp", &_FrpParamValue)
- && _FrpParamValue.nType == ParameterValue::VT_INT)
- {
- _nFrp = _FrpParamValue.iValue;
- }
-
- if (_pParamManager->GetParameterValue("SpeedG00_Frp", &_FrpParamValue)
- && _FrpParamValue.nType == ParameterValue::VT_INT)
- {
- _FrpParamValue.iValue = _nFrp;
- bool _bRet = _pParamManager->SetParameterValue("SpeedG00_Frp", &_FrpParamValue);
- ASSERT(_bRet);
- }
- }
- }
-
- m_bShowSelectMach = FALSE;
- m_bShowJogLaser = FALSE;
- m_bShowAutoCyc = FALSE;
- m_bSelectMach = FALSE;
- m_nCurIndex = 1;
-
- LOAD_PARAM(this, CMachineControlDlg_Left);
- }
-
- CMachineControlDlg_Left::~CMachineControlDlg_Left()
- {
- if (m_pSetSpeedDlg)
- {
- delete m_pSetSpeedDlg;
- m_pSetSpeedDlg = NULL;
- }
-
- if (m_pMenu)
- {
- delete m_pMenu;
- m_pMenu = NULL;
- }
-
- SAVE_PARAM(this, CMachineControlDlg_Left);
- }
-
- BOOL CMachineControlDlg_Left::Create(CWnd* pParentWnd_ /* = NULL */)
- {
- // 更改窗口风格为子窗口,以便用于贴到NcEditor的右侧栏上。 ---- 杨开锦 2011-10-31
- static struct { DLGTEMPLATE dt; SHORT n1; SHORT n2; SHORT n3; }
- _s_EmptyDialogTemplate = { WS_CHILD };
- return CreateIndirect(&_s_EmptyDialogTemplate.dt, pParentWnd_);
- }
-
- void CMachineControlDlg_Left::Update()
- {
- UpdateBRFlag();
- UpdateMachCoor();
- UpdateF();
- UpdateP();
- UpdateFH();
- UpdateSpeed();
- UpdateManuCenter();
- UpdateGFOBInfo();
- UpdateEnableJogLaser();
- UpdateEnableAutoCyc();
- UpdateCycMach();
-
- for (int _i = 0; _i < _countof(m_pwndPortButtons); _i++)
- {
- if (m_pwndPortButtons[_i])
- {
- // 定时器更新 ---- 杨开锦 2013-03-11
- m_pwndPortButtons[_i]->Update();
- }
- }
- m_pwndDirRunBtn->Update();
- m_pwndRunBtn->Update();
- }
-
- BOOL CMachineControlDlg_Left::OnInitDialog()
- {
- __super::OnInitDialog();
-
- // 注册取得各控件指针。 ---- 杨开锦 2011-10-31
- Register("stcCoor", m_pwndStcCoor);
- RegisterID("stcCoor", CTRLID_STC_COOR);
- RegisterID("btnChangCoor", CTRLID_BTN_CHANGECOOR);
- Register("stcXValue", m_pwndStcValueX);
- Register("stcYValue", m_pwndStcValueY);
- Register("stcZValue", m_pwndStcValueZ);
- Register("stcTitleZ", m_pwndStcTitleZ);
- Register("stcBR", m_pwndStcBR);
- Register("stcBRX", m_pwndStcBRX);
- Register("stcBRY", m_pwndStcBRY);
- Register("stcBRZ", m_pwndStcBRZ);
- Register("stcSpeedValue", m_pwndStcSpeed);
- Register("stcPowerValue", m_pwndStcPower);
- Register("stcFollowHeightValue", m_pwndStcFollowHeight);
- Register("sliderSetF", m_pwndSliderSetF);
- Register("sliderSetP", m_pwndSliderSetP);
- Register("sliderSetFH", m_pwndSliderSetFH);
- RegisterID("sliderSetF", CTRLID_SLD_SETF);
- RegisterID("sliderSetP", CTRLID_SLD_SETP);
- RegisterID("sliderSetFH", CTRLID_SLD_SETFH);
- RegisterID("btnF", CTRLID_BTN_F);
- RegisterID("stcXValue", CTRLID_STC_XVALUE);
- RegisterID("stcYValue", CTRLID_STC_YVALUE);
- RegisterID("stcZValue", CTRLID_STC_ZVALUE);
- Register("btnXP", m_pwndBtnXP);
- Register("btnXN", m_pwndBtnXN);
- Register("btnYP", m_pwndBtnYP);
- Register("btnYN", m_pwndBtnYN);
- Register("btnZP", m_pwndBtnZP);
- Register("btnZN", m_pwndBtnZN);
- Register("stcGoDistance", m_pwndStcGoDistance);
- RegisterID("stcGoDistance", CTRLID_BTN_GODISTANCE);
- Register("btnCenter", m_pwndBtnCenter);
- RegisterID("btnCenter", CTRLID_BTN_CENTER);
- RegisterID("btnXP", CTRLID_BTN_XP);
- RegisterID("btnXN", CTRLID_BTN_XN);
- RegisterID("btnYP", CTRLID_BTN_YP);
- RegisterID("btnYN", CTRLID_BTN_YN);
- RegisterID("btnZP", CTRLID_BTN_ZP);
- RegisterID("btnZN", CTRLID_BTN_ZN);
- RegisterID("btnGoForward", CTRLID_BTN_GOFORWARD);
- RegisterID("btnGoBackward", CTRLID_BTN_GOBACKWARD);
- RegisterID("stcPort0", CTRLID_STC_PORT0);
- RegisterID("stcPort1", CTRLID_STC_PORT1);
- RegisterID("stcPort2", CTRLID_STC_PORT2);
- RegisterID("stcPort3", CTRLID_STC_PORT3);
- RegisterID("stcPort4", CTRLID_STC_PORT4);
- RegisterID("stcPort5", CTRLID_STC_PORT5);
- RegisterID("stcPort6", CTRLID_STC_PORT6);
- RegisterID("stcPort7", CTRLID_STC_PORT7);
- RegisterID("stcPort8", CTRLID_STC_PORT8);
- RegisterID("stcPort9", CTRLID_STC_PORT9);
- RegisterID("stcPort10", CTRLID_STC_PORT10);
- RegisterID("stcPort11", CTRLID_STC_PORT11);
- /*RegisterID("stcPort12", CTRLID_STC_PORT12);*/
- RegisterID("stcPort13", CTRLID_STC_PORT13);
- RegisterID("stcPort14", CTRLID_STC_PORT14);
- RegisterID("stcPort15", CTRLID_STC_PORT15);
- RegisterID("btnSelMarkPoint", CTRLID_BTN_SELMARKPOINT);
- Register("btnRun", m_pwndRunBtn);
- Register("btnDirrun", m_pwndDirRunBtn);
-
- // 将标记点选择按钮初始化 ---- 边俊霞 2017-03-15
- CString _strCurIndex;
- _strCurIndex.Format("%u", m_nCurIndex);
-
- // 标记点选项菜单
- m_pMenu->CreatePopupMenu();
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT1, _GETCS(s_szMUNU_MARKPOINT1));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT2, _GETCS(s_szMUNU_MARKPOINT2));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT3, _GETCS(s_szMUNU_MARKPOINT3));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT4, _GETCS(s_szMUNU_MARKPOINT4));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT5, _GETCS(s_szMUNU_MARKPOINT5));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT6, _GETCS(s_szMUNU_MARKPOINT6));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT7, _GETCS(s_szMUNU_MARKPOINT7));
- m_pMenu->AppendMenu(MF_STRING, CTRLID_BTN_MARKPOINT8, _GETCS(s_szMUNU_MARKPOINT8));
-
-
- // 界面显示需求,使数字在button上不居中显示 ---- 边俊霞 2017-03-15
- CString _strShowIndex = _strCurIndex + '\n';
- SetDlgItemText(CTRLID_BTN_SELMARKPOINT, _strShowIndex);
-
- RegisterID("btnCycMach", CTRLID_BTN_CYCMACH);
- Register("btnCycMach", m_pwndBtnCycMach);
- Register("btnPort6", m_pwndBtnMoveIn);
- Register("btnPort7", m_pwndBtnMoveOut);
-
- RegisterID("btnMax", CTRLID_BTN_MAX);
- Register("btnMax", m_pwndBtnMax);
- m_pwndBtnMax->ShowWindow(SW_HIDE);
-
- CString _strUserStyle = NceGetPrivateProfileString(_T("PortSet"), _T("MoveInOut"), _T("TRUE"));
- if(_strUserStyle == _T("FALSE"))
- {
- m_pwndBtnMoveIn->EnableWindow(FALSE);
- m_pwndBtnMoveOut->EnableWindow(FALSE);
- }
-
- m_bShowSelectMach = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowSelectMach")) == _T("1");
- RegisterID("btnSelMachOn", CTRLID_BTN_MACHSELECTEDON);
- Register("btnSelMachOn", m_pwndBtnSelMachOn);
- RegisterID("btnSelMachOff", CTRLID_BTN_MACHSELECTEDOFF);
- Register("btnSelMachOff", m_pwndBtnSelMachOff);
-
- RegisterID("stcMachSelText", CTRLID_STC_SELECTMACH);
- CWnd* _pwndSelectMach_Static = GetDlgItem(CTRLID_STC_SELECTMACH);
- if (_pwndSelectMach_Static)
- {
- _pwndSelectMach_Static->SetWindowText(_GETCS(s_csSELECTMACH));
- }
-
- m_pwndBtnSelMachOn->ShowWindow(m_bSelectMach ? SW_SHOW : SW_HIDE);
- m_pwndBtnSelMachOff->ShowWindow(m_bSelectMach ? SW_HIDE : SW_SHOW);
-
- // 点动出光 ---- 边俊霞 2016-12-26
- m_bShowJogLaser = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowJogLaser")) == _T("1");
- RegisterID("btnJogLaserOn", CTRLID_BTN_JOGLASERON);
- Register("btnJogLaserOn", m_pwndBtnJogLaserOn);
- RegisterID("btnJogLaserOff", CTRLID_BTN_JOGLASEROFF);
- Register("btnJogLaserOff", m_pwndBtnJogLaserOff);
- RegisterID("stcJogWithLaser", CTRLID_STC_JOGLASER);
- CWnd* _pwndStatic2 = GetDlgItem(CTRLID_STC_JOGLASER);
- if(_pwndStatic2)
- {
- _pwndStatic2->SetWindowText(_GETCS(s_szLaserOnWhenJog));
- }
-
- m_pwndBtnJogLaserOn->ShowWindow(SW_HIDE);
- m_pwndBtnJogLaserOff->ShowWindow(SW_SHOW);
-
-
- UpdateCycMach();
-
- // 自动循环 ---- 陈思 2017-1-10
- m_bShowAutoCyc = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowAutoCyc")) == _T("1");
- RegisterID("btnAutoCycle", CTRLID_BTN_AUTOCYC);
- CButton* _pBtnAutoCyc = (CButton*)GetDlgItem(CTRLID_BTN_AUTOCYC);
- if (_pBtnAutoCyc)
- {
- _pBtnAutoCyc->SetCheck(m_bShowAutoCyc ? BST_CHECKED : BST_UNCHECKED);
- }
-
- m_pwndRunBtn->SetMotionEndType(CCycMachiningTarget::TaskEndNormal);
- m_pwndDirRunBtn->SetMotionEndType(CCycMachiningTarget::DryRunEndNormal);
-
- // PortButton ---- DingQiang 2013-07-23
- for (size_t _i = 0; _i < _countof(m_pwndPortButtons); _i++)
- {
- // 注册:xaml中如果没配则注册失败,相应指针为NULL ---- DingQiang 2013-07-24
- CString _strPortButtonName;
- _strPortButtonName.Format(_T("btnPort%d"), _i);
- Register(_strPortButtonName, m_pwndPortButtons[_i]);
-
- // 初始化控件 ---- DingQiang 2016-07-14
- CString _strPortIndex;
- _strPortIndex.Format(_T("Port%d"), _i);
- if (!m_pwndPortButtons[_i] || !m_pwndPortButtons[_i]->Initialize(_T("ControlTarget"), _strPortIndex))
- {
- continue;
- }
-
- // 设置相应的端口名 ---- 杨开锦 2012-07-05
- CString _strDescriptionNameKey;
- _strDescriptionNameKey.Format(_GETCS(s_szPortNameKey), _i);
- CString _strDescriptionName = NceGetPrivateProfileString(_T("ControlTarget"), _strDescriptionNameKey);
- SetDlgItemText(CTRLID_STC_PORT0 + (int)_i, _strDescriptionName);
- }
-
- // 隐藏所有的回机械原点标志----梁艳-2015-02-08
- m_pwndStcBR->ShowWindow(SW_HIDE);
- m_pwndStcBRX->ShowWindow(SW_HIDE);
- m_pwndStcBRY->ShowWindow(SW_HIDE);
- m_pwndStcBRZ->ShowWindow(SW_HIDE);
-
- //读配置,是否显示所有轴回机械原点标志以及回机械原点关联轴的索引
- //如果可以读到,则使用读到的,否则使用默认的----梁艳-2015-02-08
- CString _strShowAllBKMark = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowAllBKMark"));
- CString _strBKMarkAttachAxis = NceGetPrivateProfileString(_T("ControlTarget"), _T("BKMarkAttachAxis"));
- if (!_strShowAllBKMark.IsEmpty())
- {
- m_strShowAllBKMark = _strShowAllBKMark;
- }
- if (!_strBKMarkAttachAxis.IsEmpty())
- {
- m_strBKMarkAttachAxis = _strBKMarkAttachAxis;
- }
-
- //只显示一个回原点标志时,求出关联轴的索引---梁艳-2015-02-08
- if (m_strShowAllBKMark == "0")
- {
- CString _strBKMarkAttachAxis = m_strBKMarkAttachAxis;
- //关联轴索引 空值或含有非法字符或只有一个非数字字符
- if (_strBKMarkAttachAxis.IsEmpty()
- ||_strBKMarkAttachAxis.SpanIncluding(_T(",012")).GetLength() != _strBKMarkAttachAxis.GetLength()
- || _strBKMarkAttachAxis.GetLength() == 1 && _strBKMarkAttachAxis.FindOneOf(_T("012")) == -1)
- {
- _strBKMarkAttachAxis.Empty();
- }
- m_strVecAxis.clear();
- while(!_strBKMarkAttachAxis.IsEmpty())
- {
- _strBKMarkAttachAxis.TrimLeft(",");
- _strBKMarkAttachAxis.TrimRight(",");
- int _Index = _strBKMarkAttachAxis.Find(",");
- if(_Index == -1)
- {
- m_strVecAxis.push_back(_strBKMarkAttachAxis);
- break;
- }
- m_strVecAxis.push_back( _strBKMarkAttachAxis.Left(_Index));
- _strBKMarkAttachAxis = _strBKMarkAttachAxis.Right(_strBKMarkAttachAxis.GetLength() - _Index);
- }
- }
-
- #define RegisterBtnID(szName_, nID_) { \
- CAgileImageButton* _pwndBtn = NULL; \
- Register(szName_, _pwndBtn); \
- ASSERT(_pwndBtn); \
- ASSERT(IsCmdID(nID_)); \
- _pwndBtn->SetCmdID(nID_); \
- }
- RegisterBtnID("btnSetW", IDCMD_CONTROLTARGET_CLEARW);
- RegisterBtnID("btnBW", IDCMD_CONTROLTARGET_BACKW);
- RegisterBtnID("btnSimuCut", IDCMD_CONTROLTARGET_SIMUCUT);
- RegisterBtnID("btnRun", IDCMD_CONTROLTARGET_START);
- RegisterBtnID("btnPause", IDCMD_CONTROLTARGET_PAUSE);
- RegisterBtnID("btnStop", IDCMD_CONTROLTARGET_STOP);
- RegisterBtnID("btnBreakpointResume", IDCMD_CONTROLTARGET_BREAKPOINTRESUME);
- RegisterBtnID("btnSimulate", IDCMD_CONTROLTARGET_SIMULATE);
- RegisterBtnID("btnDirrun", IDCMD_CONTROLTARGET_DIRRUN);
- RegisterBtnID("btnBackFixed", IDCMD_CONTROLTARGET_BACKWZ);
- RegisterBtnID("btnMarkPoint", IDCMD_MARKPOINTTARGET_MARKTHISPOINT);
- RegisterBtnID("btnBackMarkPoint", IDCMD_MARKPOINTTARGET_MOVETOMARKPOINT);
- RegisterBtnID("btnCleanJet", IDCMD_AUTOCLEANTARGET_STARTAUTOCLEAN);
- CString _strCutBoundText;
- if (NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowSampleBtn")) == _T("1"))
- {
- RegisterBtnID("btnSample", IDCMD_FOLLOWCTRLTARGET_SAMPLE);
- // 走边框放到下一排,按钮上显示字。 ---- 黄海燕 2015-09-10
- _strCutBoundText = _GETCS(s_csSIMUCUTBOUNDRECT);
- }
- if (NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowBackOrgBtn")) == _T("1"))
- RegisterBtnID("btnBackOrg", IDCMD_CONTROLTARGET_BACKR);
- #undef RegisterBtnID
-
- SetDlgItemText(CTRLID_STC_MACHCOOR, _GETCS(s_csMACHINECOORDINATE)); // 机械坐标 ---- 吴畏 2016-10-27
- SetDlgItemText(CTRLID_STC_WORKCOOR, _GETCS(s_csWORKPIECECOORDINATE)); // 工件坐标 ---- 吴畏 2016-10-27
- SetDlgItemText(CTRLID_STC_COOR, m_nCoorMode == 0x00 ? _GETCS(s_csWORKPIECECOORDINATE) : _GETCS(s_csMACHINECOORDINATE));
-
- // 设置功率滑动条范围---- DingQiang 2012-04-28
- CString _strIsGrayBottom = NceGetPrivateProfileString(_T("ControlTarget"), _T("IsGrayBottom"), _T(0));
- BOOL _bIsGrayBottom = atoi(_strIsGrayBottom);
- m_pwndSliderSetF->SetCustomerSetSize();
- if (_bIsGrayBottom)
- {
- // 加载灰色背景竖屏滑动条配色 ---- 边俊霞 2017-01-11
- m_pwndSliderSetF->SetBitmapChannel( IDB_BMP_GRAY_CHANNELBACK, IDB_BMP_GRAY_CHANNELFORE);
- m_pwndSliderSetF->SetBitmapThumb( IDB_BMP_GRAY_THUMBNORMAL, IDB_BMP_GRAY_THUMBPRESS, IDB_BMP_GRAY_THUMBHOVER);
- }
- else
- {
- m_pwndSliderSetF->SetBitmapChannel( IDB_BMP_CHANNELBACK, IBP_BMP_CHANNELFORE);
- m_pwndSliderSetF->SetBitmapThumb( IDB_BMP_THUMBNORMAL, IDB_BMP_THUMBPRESS, IDB_BMP_THUMBHOVER);
- }
- m_pwndSliderSetF->SetRange( 0, 100);
- m_pwndSliderSetF->SetPos( 0 );
-
- m_pwndSliderSetP->SetCustomerSetSize();
- if (_bIsGrayBottom)
- {
- // 加载灰色背景竖屏滑动条配色 ---- 边俊霞 2017-01-11
- m_pwndSliderSetP->SetBitmapChannel( IDB_BMP_GRAY_CHANNELBACK, IDB_BMP_GRAY_CHANNELFORE);
- m_pwndSliderSetP->SetBitmapThumb( IDB_BMP_GRAY_THUMBNORMAL, IDB_BMP_GRAY_THUMBPRESS, IDB_BMP_GRAY_THUMBHOVER);
- }
- else
- {
- m_pwndSliderSetP->SetBitmapChannel( IDB_BMP_CHANNELBACK, IBP_BMP_CHANNELFORE);
- m_pwndSliderSetP->SetBitmapThumb( IDB_BMP_THUMBNORMAL, IDB_BMP_THUMBPRESS, IDB_BMP_THUMBHOVER);
- }
- m_pwndSliderSetP->SetRange( 0, 100);
- m_pwndSliderSetP->SetPos( 0 );
-
- m_pwndSliderSetFH->SetCustomerSetSize();
- if (_bIsGrayBottom)
- {
- // 加载灰色背景竖屏滑动条配色 ---- 边俊霞 2017-01-11
- m_pwndSliderSetFH->SetBitmapChannel( IDB_BMP_GRAY_CHANNELBACK, IDB_BMP_GRAY_CHANNELFORE);
- m_pwndSliderSetFH->SetBitmapThumb( IDB_BMP_GRAY_THUMBNORMAL, IDB_BMP_GRAY_THUMBPRESS, IDB_BMP_GRAY_THUMBHOVER);
- }
- else
- {
- m_pwndSliderSetFH->SetBitmapChannel( IDB_BMP_CHANNELBACK, IBP_BMP_CHANNELFORE);
- m_pwndSliderSetFH->SetBitmapThumb( IDB_BMP_THUMBNORMAL, IDB_BMP_THUMBPRESS, IDB_BMP_THUMBHOVER);
- }
- m_pwndSliderSetFH->SetRange( 0, 80);
- m_pwndSliderSetFH->SetPos( 0 );
-
- _BuildFHIVMap();
-
- // 手动中心键为圆形按钮,手动方向键为圆环切割而成,其中X-为左月牙、X+为右月
- // 牙、Y-为下月牙、Y+为上月牙。
- // 中心键半径为34px;方向键所在圆环外径为80px,内径为40px,各键间间隔缝为
- // 宽8px。
- // 此处各区域值为略扩大一点的区域,以便确保能完全包含所画贴图而不产生边界
- // 切割据齿。 ---- 杨开锦 2011-11-02
- ASSERT(m_pwndBtnCenter && m_pwndBtnXP && m_pwndBtnXN && m_pwndBtnYP && m_pwndBtnYN);
- m_pwndBtnCenter->SetShape(::CreateEllipticRgn(-1, -1, 77, 77));
- CDC _dc;
- CDC* _pDC = GetDC();
- _dc.CreateCompatibleDC(_pDC);
- ReleaseDC(_pDC);
- _pDC = NULL;
- _dc.BeginPath();
- _dc.MoveTo(147, 28);
- _dc.SetArcDirection(AD_CLOCKWISE);
- _dc.ArcTo(-1, -1, 170, 170, 147, 28, 147, 143);
- _dc.SetArcDirection(AD_COUNTERCLOCKWISE);
- _dc.ArcTo(40, 40, 130, 130, 118, 113, 118, 57);
- _dc.LineTo(147, 28);
- _dc.EndPath();
- CRgn _rgn;
- _rgn.CreateFromPath(&_dc);
- _rgn.OffsetRgn(-120, -27);
- m_pwndBtnXP->SetShape((HRGN)_rgn.Detach());
-
- _dc.BeginPath();
- _dc.MoveTo(52, 114);
- _dc.SetArcDirection(AD_CLOCKWISE);
- _dc.ArcTo(40, 40, 130, 130, 52, 114, 52, 58);
- _dc.SetArcDirection(AD_COUNTERCLOCKWISE);
- _dc.ArcTo(-1, -1, 170, 170, 22, 30, 22, 142);
- _dc.LineTo(52, 114);
- _dc.EndPath();
- _rgn.CreateFromPath(&_dc);
- _rgn.OffsetRgn(18, -27);
- m_pwndBtnXN->SetShape((HRGN)_rgn.Detach());
-
- _dc.BeginPath();
- _dc.MoveTo(28, 23);
- _dc.SetArcDirection(AD_CLOCKWISE);
- _dc.ArcTo(0, 0, 170, 170, 28, 23, 141, 23);
- _dc.SetArcDirection(AD_COUNTERCLOCKWISE);
- _dc.ArcTo(40, 40, 130, 130, 112, 53, 57, 53);
- _dc.LineTo(28, 23);
- _dc.EndPath();
- _rgn.CreateFromPath(&_dc);
- _rgn.OffsetRgn(-1, 16);
- m_pwndBtnYP->SetShape((HRGN)_rgn.Detach());
-
- _dc.BeginPath();
- _dc.MoveTo(140, 148);
- _dc.SetArcDirection(AD_CLOCKWISE);
- _dc.ArcTo(-1, -1, 170, 170, 140, 148, 28, 148);
- _dc.SetArcDirection(AD_COUNTERCLOCKWISE);
- _dc.ArcTo(39, 39, 129, 129, 57, 116, 112, 116);
- _dc.LineTo(140, 148);
- _dc.EndPath();
- _rgn.CreateFromPath(&_dc);
- _rgn.OffsetRgn(0, -117);
- m_pwndBtnYN->SetShape((HRGN)_rgn.Detach());
-
- m_pSetSpeedDlg = new CSetSpeedDlg(this);
- ((CSetSpeedDlg*)m_pSetSpeedDlg)->Create(this);
-
- m_pwndStcCoor->ModifyStyle(0, SS_NOTIFY);
- m_pwndStcValueX->ModifyStyle(0, SS_NOTIFY);
- m_pwndStcValueY->ModifyStyle(0, SS_NOTIFY);
- m_pwndStcValueZ->ModifyStyle(0, SS_NOTIFY);
-
- // 这里加一次Update是因为:出现过一个问题,软件启动时横向的进给倍率条显示不
- // 出来,最小化最大化一下才出来。带NcStudio启动才有问题,单NcEditor没问题。
- // 没有查出原因,只是经试验发现这里Update一次就好了,于是就这么干。如果以后
- // 发现这样不是正解请修改。 ---- 杨开锦 2012-05-02
- Update();
-
- bool _bEnableZ = IsEnableZUpDown();
- m_pwndBtnZP->EnableWindow(_bEnableZ ? TRUE : FALSE);
- m_pwndBtnZN->EnableWindow(_bEnableZ ? TRUE : FALSE);
- m_pwndBtnZP->ShowWindow(_bEnableZ ? TRUE : FALSE);
- m_pwndBtnZN->ShowWindow(_bEnableZ ? TRUE : FALSE);
- SetMachineCtrlTips();
- return TRUE;
- }
-
- void CMachineControlDlg_Left::SetMachineCtrlTips()
- {
- m_MachineCtrlTips.Create(this);
- m_MachineCtrlTips.Activate(TRUE);
- m_MachineCtrlTips.SetTipTextColor(RGB(0, 0, 0));
- m_MachineCtrlTips.SetDelayTime(1000);
-
- m_MachineCtrlTips.AddTool(GetDlgItem(IDCMD_CONTROLTARGET_CLEARW), _GETCS(s_csTipSETWORKORG));
- m_MachineCtrlTips.AddTool(GetDlgItem(IDCMD_CONTROLTARGET_BACKW), _GETCS(s_csTipMOVETOWORKORIGIN));
- m_MachineCtrlTips.AddTool(GetDlgItem(IDCMD_CONTROLTARGET_START), _GETCS(s_csTipSTART));
- m_MachineCtrlTips.AddTool(GetDlgItem(IDCMD_CONTROLTARGET_PAUSE), _GETCS(s_csTipPAUSE));
- m_MachineCtrlTips.AddTool(GetDlgItem(IDCMD_CONTROLTARGET_STOP), _GETCS(s_csTipSTOP));
- m_MachineCtrlTips.AddTool(GetDlgItem(CTRLID_BTN_GOBACKWARD), _GETCS(s_csTipGoBackward));
- m_MachineCtrlTips.AddTool(GetDlgItem(CTRLID_BTN_GOFORWARD), _GETCS(s_csTipGoForward));
- CWnd* _pwndBtn = GetDlgItem(IDCMD_FOLLOWCTRLTARGET_SAMPLE);
- if (_pwndBtn)
- m_MachineCtrlTips.AddTool(_pwndBtn, _GETCS(s_csTipFollowSample));
- _pwndBtn = GetDlgItem(IDCMD_CONTROLTARGET_BACKR);
- if (_pwndBtn)
- m_MachineCtrlTips.AddTool(_pwndBtn, _GETCS(s_csTipBackAll));
- }
-
- bool CMachineControlDlg_Left::IsEnableZUpDown()
- {
- return true;
- CString _strEnableZ = NceGetPrivateProfileString(_T("ControlTarget"), _T("EnableZ"));
-
- if ("1" == _strEnableZ)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- BOOL CMachineControlDlg_Left::PreTranslateMessage(MSG* pMsg_)
- {
- // 添加此句用于机床控制栏显示提示语 ---- 嘎松卓玛 2012.05.17
- m_MachineCtrlTips.RelayEvent(pMsg_);
-
- // Let go of Keyboard Message => 此处这么做有几个目的:一个是屏蔽Enter、Esc
- // 键引发的OnOK、OnCancel关闭窗口;二是防止焦点在窗口上时,框架上的快捷键被
- // 屏蔽。 ---- 杨开锦 2012-04-08
- if (WM_KEYFIRST <= pMsg_->message && pMsg_->message <= WM_KEYLAST)
- {
- return FALSE;
- }
-
- if (pMsg_->message == WM_LBUTTONDOWN)
- {
- UINT _nCtrlID = ::GetDlgCtrlID(pMsg_->hwnd);
- if (_nCtrlID == CTRLID_BTN_GODISTANCE)
- {
- if (OnDistanceLButtonDown(pMsg_->pt))
- {
- // 如果不return的话Dialog会响应此消息,此时new出来的编辑框会又马上
- // 响应OnKillFocus导致编辑框一出来就消失 ---- DingQiang 2012-07-19
- return TRUE;
- }
- }
- }
-
- return __super::PreTranslateMessage(pMsg_);
- }
-
- // 设置手动模式 ---- 郭小航 2013-11-07
- void CMachineControlDlg_Left::OnSetManuMode()
- {
- DWORD _nBegin = GetTickCount();
- while(true)
- {
- MSG _msg;
- if (::PeekMessage(&_msg, NULL, NULL, NULL, PM_REMOVE))
- {
- ::TranslateMessage(&_msg);
- ::DispatchMessage(&_msg);
-
- if (_msg.message == WM_LBUTTONDBLCLK)
- {
- return;
- }
- }
-
- if (GetTickCount() - _nBegin > 200)
- {
- break;
- }
- }
-
- static int _s_nManuMode;
- int _nManuMode = _s_nManuMode % 3;
-
- CManualTarget* _pManualTarget = GetManualTarget();
- ASSERT(_pManualTarget);
- if (_nManuMode == 0)
- {
- _pManualTarget->SetManuMode(0);
- _pManualTarget->SetJogState(false);
- }
- else if (_nManuMode == 1)
- {
- _pManualTarget->SetManuMode(0);
- _pManualTarget->SetJogState(true);
- }
- else if (_nManuMode == 2)
- {
- _pManualTarget->SetManuMode(1);
- }
-
- _s_nManuMode ++;
- }
-
- void CMachineControlDlg_Left::UpdateMachCoor()
- {
- // 先更新标题 ---- 杨开锦 2012-07-05
- CString _strNewTitle = m_nCoorMode == 0x00 ? _GETCS(s_csWORKPIECECOORDINATE) : _GETCS(s_csMACHINECOORDINATE);
- CString _strTitle;
- m_pwndStcCoor->GetWindowText(_strTitle);
- if (_strNewTitle != _strTitle)
- {
- m_pwndStcCoor->SetWindowText(_strNewTitle);
- }
-
- CParamManager* _pParamManager = GetParamManager();
- if (!_pParamManager)
- {
- return;
- }
-
- // 将控件与相应控件的参数标识符关联创建一个结构体---- DingQiang 2012-01-12
- const struct MachItem
- {
- DWORD nCoorMode;
- CAgileLabel* pwndStcValue;
- CString strIdentifier;
- } _s_MachItems[] =
- {
- { 0x00, m_pwndStcValueX, "State_Axis0_WorkcoorPos" },
- { 0x00, m_pwndStcValueY, "State_Axis1_WorkcoorPos" },
- { 0x00, m_pwndStcValueZ, "State_Axis2_WorkcoorPos" },
- { 0x01, m_pwndStcValueX, "Dyn_Axis0_Pos"},
- { 0x01, m_pwndStcValueY, "Dyn_Axis1_Pos"},
- { 0x01, m_pwndStcValueZ, "Dyn_Axis2_Pos"}
- };
-
- for(int _i = 0; _i < _countof(_s_MachItems); _i++)
- {
- const MachItem& _item = _s_MachItems[_i];
- if (_item.nCoorMode != m_nCoorMode
- || !_item.pwndStcValue
- || !_item.pwndStcValue->IsWindowVisible())
- {
- continue;
- }
-
- ParameterValue _PV;
- if (!_pParamManager->GetParameterValue(_item.strIdentifier, &_PV) || _PV.nType != ParameterValue::VT_DOUBLE)
- {
- ASSERT(FALSE);
- continue;
- }
-
- CString _strMachCoor;
- _strMachCoor.Format("%.3f", _PV.dValue);
- if (_strMachCoor == "-0.000")
- {
- _strMachCoor = "0.000";
- }
-
- // 若更新前坐标与更新后坐标相等则不更新 ---- DingQiang 2012-01-12
- CString _strBeforeUpdate;
- _item.pwndStcValue->GetWindowText(_strBeforeUpdate);
- if (_strMachCoor != _strBeforeUpdate)
- {
- _s_MachItems[_i].pwndStcValue->SetWindowText(_strMachCoor);
- }
- }
- }
- // 回机械原点标志,配置方式如下:
- // [ControlTarget]
- // ShowAllBKMark=1
- // BKMarkAttachAxis=0,1,2
- void CMachineControlDlg_Left::UpdateBRFlag()
- {
- // 将轴原点标志控件与相应控件的参数以及轴的索引,关联创建一个结构体,方便以后扩展----梁艳-2015-02-08
- const struct AxisItems
- {
- CAgileImageLabel* pwndStcBR;
- CString strIdentifier;
- CString strIndex;
- } _s_AxisItems[] =
- {
- { m_pwndStcBRX, "State_Axis0_IsReferenced", "0" },
- { m_pwndStcBRY, "State_Axis1_IsReferenced", "1" },
- { m_pwndStcBRZ, "State_Axis2_IsReferenced", "2" }
- };
-
- CParamManager* _pParamManager = GetParamManager();
- if(!_pParamManager)
- return;
-
- //如果显示所有轴的回机械原点标志,则分别显示各轴的回机械原点标志---梁艳-2015-02-08
- if (m_strShowAllBKMark == _T("1"))
- {
- for(int _i = 0; _i < _countof(_s_AxisItems); _i++)
- {
- const AxisItems& _item = _s_AxisItems[_i];
- ParameterValue _PV;
- memset(&_PV, 0, sizeof(ParameterValue));
- if (!_pParamManager->GetParameterValue(_item.strIdentifier, &_PV) || _PV.nType != ParameterValue::VT_BOOL)
- {
- ASSERT(FALSE);
- continue;
- }
- _item.pwndStcBR->ShowWindow(_PV.bValue ? SW_SHOW : SW_HIDE);
- }
- }
- // 如果不显示所有轴的回机械原点标志,则根据关联轴的索引,只显示一个回机械原点标志---梁艳-2015-02-08
- else if(m_strShowAllBKMark == _T("0"))
- {
- bool _bIsRef = m_strVecAxis.empty()? false : true;
- for (std::vector<CString>::iterator _it = m_strVecAxis.begin(); _it != m_strVecAxis.end();_it++)
- {
- int _nCount = 0;
- CString _strAxis = *_it;
- for(int _j = 0; _j < _countof(_s_AxisItems); _j++)
- {
- const AxisItems& _item = _s_AxisItems[_j];
- ParameterValue _PV;
- memset(&_PV, 0, sizeof(ParameterValue));
- if (!_pParamManager->GetParameterValue(_item.strIdentifier, &_PV) || _PV.nType != ParameterValue::VT_BOOL)
- {
- ASSERT(FALSE);
- continue;
- }
- if (_item.strIndex == _strAxis)
- {
- _bIsRef &= _PV.bValue;
- break;
- }
- else
- {
- _nCount++;
- continue;
- }
- }
- //没有匹配项
- if (_nCount == _countof(_s_AxisItems))
- {
- _bIsRef = false;
- }
- }
- m_pwndStcBR->ShowWindow(_bIsRef ? SW_SHOW : SW_HIDE);
- }
- }
-
-
- void CMachineControlDlg_Left::OnDirectionBtnPushed(UINT nID_)
- {
- ASSERT(nID_ >= CTRLID_BTN_XP && nID_ <= CTRLID_BTN_ZN);
-
- // 将手动按钮模拟成快捷键导到CManualTarget中
- C_ASSERT(CTRLID_BTN_XP == CTRLID_BTN_XP + 0
- && CTRLID_BTN_XN == CTRLID_BTN_XP + 1
- && CTRLID_BTN_YP == CTRLID_BTN_XP + 2
- && CTRLID_BTN_YN == CTRLID_BTN_XP + 3
- && CTRLID_BTN_ZP == CTRLID_BTN_XP + 4
- && CTRLID_BTN_ZN == CTRLID_BTN_XP + 5);
- static const UINT _s_nKeys[] =
- {
- VK_NUMPAD6,
- VK_NUMPAD4,
- VK_NUMPAD8,
- VK_NUMPAD2,
- VK_NUMPAD9,
- VK_NUMPAD3,
- };
- MSG _msg = { NULL, WM_KEYDOWN, WPARAM(_s_nKeys[nID_ - CTRLID_BTN_XP]), LPARAM(1) };
- CManualTarget* _pManualTarget = GetManualTarget();
- ASSERT(_pManualTarget);
- _pManualTarget->OnKeyMessage(&_msg);
- }
-
- void CMachineControlDlg_Left::OnDirectionBtnUnpushed(UINT nID_)
- {
- ASSERT(nID_ >= CTRLID_BTN_XP && nID_ <= CTRLID_BTN_ZN);
-
- // 将手动按钮模拟成快捷键导到CManualTarget中
- C_ASSERT(CTRLID_BTN_XP == CTRLID_BTN_XP + 0
- && CTRLID_BTN_XN == CTRLID_BTN_XP + 1
- && CTRLID_BTN_YP == CTRLID_BTN_XP + 2
- && CTRLID_BTN_YN == CTRLID_BTN_XP + 3
- && CTRLID_BTN_ZP == CTRLID_BTN_XP + 4
- && CTRLID_BTN_ZN == CTRLID_BTN_XP + 5);
- static const UINT _s_nKeys[] =
- {
- VK_NUMPAD6,
- VK_NUMPAD4,
- VK_NUMPAD8,
- VK_NUMPAD2,
- VK_NUMPAD9,
- VK_NUMPAD3,
- };
- MSG _msg = { NULL, WM_KEYUP, WPARAM(_s_nKeys[nID_ - CTRLID_BTN_XP]), LPARAM(1) };
- CManualTarget* _pManualTarget = GetManualTarget();
- ASSERT(_pManualTarget);
- _pManualTarget->OnKeyMessage(&_msg);
- }
-
- void CMachineControlDlg_Left::OnGFOBBtnPushed(UINT nID_)
- {
- ASSERT(nID_ >= CTRLID_BTN_GOFORWARD && nID_ <= CTRLID_BTN_GOBACKWARD);
-
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
- if (_pControlTarget->GetGFOBMode() != 0x00)
- {
- return;
- }
-
- C_ASSERT(CTRLID_BTN_GOFORWARD == CTRLID_BTN_GOFORWARD + 0
- && CTRLID_BTN_GOBACKWARD == CTRLID_BTN_GOFORWARD + 1);
- static const UINT _s_nCmdIDs[] =
- {
- IDCMD_CONTROLTARGET_JOGFORWARD,
- IDCMD_CONTROLTARGET_JOGBACKWARD,
- };
- AfxGetMainWnd()->SendMessage(WM_COMMAND, _s_nCmdIDs[nID_ - CTRLID_BTN_GOFORWARD], 0);
- }
-
- void CMachineControlDlg_Left::OnGFOBBtnUnpushed(UINT nID_)
- {
- ASSERT(nID_ >= CTRLID_BTN_GOFORWARD && nID_ <= CTRLID_BTN_GOBACKWARD);
-
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
- if (_pControlTarget->GetGFOBMode() == 0x00)
- {
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_STOP, 0);
- return;
- }
-
- C_ASSERT(CTRLID_BTN_GOFORWARD == CTRLID_BTN_GOFORWARD + 0
- && CTRLID_BTN_GOBACKWARD == CTRLID_BTN_GOFORWARD + 1);
- static const UINT _s_nCmdIDs[] =
- {
- IDCMD_CONTROLTARGET_INCFORWARD,
- IDCMD_CONTROLTARGET_INCBACKWARD,
- };
- AfxGetMainWnd()->SendMessage(WM_COMMAND, _s_nCmdIDs[nID_ - CTRLID_BTN_GOFORWARD], 0);
- }
-
- LRESULT CMachineControlDlg_Left::OnIdleUpdateCmdUI(WPARAM wParam_, LPARAM lParam_)
- {
- static const struct ManualBtnItem
- {
- CButton* pBtnManual;
- DWORD nMask;
- } _s_cManualBtnItems[] =
- {
- {m_pwndBtnYN, 0x00000001},
- {m_pwndBtnXN, 0x00000002},
- {m_pwndBtnXP, 0x00000004},
- {m_pwndBtnYP, 0x00000008},
- {m_pwndBtnZP, 0x00000010},
- {m_pwndBtnZN, 0x00000020},
- {m_pwndBtnCenter, 0x00000040},
- };
-
- CManualTarget* _pManualTarget = GetManualTarget();
- if (!_pManualTarget)
- {
- return 0;
- }
- DWORD _ManualKeyState = _pManualTarget->GetManuKeyState();
-
- for (int _i = 0; _i < _countof(_s_cManualBtnItems); _i++)
- {
- if (_ManualKeyState & _s_cManualBtnItems[_i].nMask)
- {
- _s_cManualBtnItems[_i].pBtnManual->SetCheck(TRUE);
- }
- else
- _s_cManualBtnItems[_i].pBtnManual->SetCheck(FALSE);
- }
-
-
- // 真实前进后退状态和按钮F3、F4按下,只要一个状态为真即将按钮置亮 ---- DingQiang 2014-10-11
- static const struct GOBBtnItem
- {
- UINT nID;
- DWORD nKeyboardMask;
- DWORD nRunningStateMask;
- } _s_cGOBBtnItems[] =
- {
- {CTRLID_BTN_GOBACKWARD, 0x00000001, 0x00000100},
- {CTRLID_BTN_GOFORWARD, 0x00000002, 0x00000080},
- };
-
- CControlTarget* _pControlTarget = GetControlTarget();
- CStateManager* _pStateManager = GetStateManager();
- if (!_pControlTarget || !_pStateManager)
- {
- return 0;
- }
-
- DWORD _GOBKeyState = _pControlTarget->GetGOBKeyState();
- DWORD _nRunningState = 0;
- _pStateManager->GetRunningState(&_nRunningState);
-
- for (int _i = 0; _i < _countof(_s_cGOBBtnItems); _i++)
- {
- BOOL _bCheck = _nRunningState & _s_cGOBBtnItems[_i].nRunningStateMask;
- _bCheck |= _GOBKeyState & _s_cGOBBtnItems[_i].nKeyboardMask;
-
- ((CButton*)GetDlgItem(_s_cGOBBtnItems[_i].nID))->SetCheck(_bCheck);
- }
-
- return 1;
- }
-
- void CMachineControlDlg_Left::OnHScroll(UINT nSBCode_, UINT nPos_, CScrollBar* pScrollBar_)
- {
-
- }
-
- // 更新进给倍率的显示值 ---- DingQiang 2012-02-07
- void CMachineControlDlg_Left::UpdateF()
- {
- _BuildFIVMap();
-
- // 从ParamManager中读出进给倍率的当前值,如果读不到,则以设定倍率滑动条上的
- // 值为准。 ---- 杨开锦 2012-02-18
- ASSERT(m_pwndSliderSetF);
- int _nIndex = m_pwndSliderSetF->GetPos();
- int _nFrp = 100;
- _UpdateFValue(_nIndex, &_nFrp);
- if (CParamManager* _pParamManager = GetParamManager())
- {
- const CStringA _c_strFrpIdentifier = "SpeedGxx_Frp";
- ParameterValue _FrpParamValue;
- if (_pParamManager->GetParameterValue(_c_strFrpIdentifier, &_FrpParamValue)
- && _FrpParamValue.nType == ParameterValue::VT_INT)
- {
- _nFrp = _FrpParamValue.iValue;
- _UpdateFIndex(&_nIndex, _nFrp);
- }
- }
-
- // 更新横向滑动条
- ASSERT(m_pwndSliderSetF);
- int _nCurPos_SliderSetF = m_pwndSliderSetF->GetPos();
- int _nNewPos_SliderSetF = min(_nFrp, m_pwndSliderSetF->GetRangeMax());
- if (_nNewPos_SliderSetF != _nCurPos_SliderSetF)
- {
- m_pwndSliderSetF->SetPos(_nNewPos_SliderSetF);
- m_pwndSliderSetF->Invalidate();
- }
- }
-
- void CMachineControlDlg_Left::UpdateP()
- {
- CParamManager* _pParamManager = mach::GetParamManager();
- if (!_pParamManager)
- {
- return;
- }
- Parameter _DutyCycle;
- if (!_pParamManager->GetParameter("PWM_DutyCycle", &_DutyCycle))
- {
- return;
- }
- ASSERT(_DutyCycle.Value.nType == ParameterValue::VT_INT);
- Parameter _RatedPower;
- if (!_pParamManager->GetParameter("GP_LaserRatedPower", &_RatedPower))
- {
- return;
- }
- ASSERT(_RatedPower.Value.nType == ParameterValue::VT_INT);
-
- CString _strOldInfo;
- m_pwndStcPower->GetWindowText(_strOldInfo);
-
- CString _strValue;
- _strValue.Format("%d", _DutyCycle.Value.iValue * _RatedPower.Value.iValue / 100);
- if (_strValue != _strOldInfo)
- {
- m_pwndStcPower->SetWindowText(_strValue);
- }
-
- // 更新横向滑动条
- ASSERT(m_pwndSliderSetP);
- int _nCurPos_SliderSetP = m_pwndSliderSetP->GetPos();
- int _nNewPos_SliderSetP = _DutyCycle.Value.iValue;
- if (_nNewPos_SliderSetP != _nCurPos_SliderSetP)
- {
- m_pwndSliderSetP->SetPos(_nNewPos_SliderSetP);
- m_pwndSliderSetP->Invalidate();
- }
- }
-
- void CMachineControlDlg_Left::_BuildFHIVMap()
- {
- for (int _i = 0; _i <= 10; _i++)
- {
- m_nFHValues[_i] = _i * 0.02;
- }
-
- for (int _i = 11; _i <= 20; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[10] + (_i - 10) * 0.03;
- }
-
- for (int _i = 21; _i <= 30; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[20] + (_i - 20) * 0.03;
- }
-
- for (int _i = 31; _i <= 40; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[30] + (_i - 30) * 0.02;
- }
-
- for (int _i = 41; _i <= 50; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[40] + (_i - 40) * 0.1;
- }
-
- for (int _i = 51; _i <= 60; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[50] + (_i - 50) * 0.3;
- }
-
- for (int _i = 61; _i <= 70; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[60] + (_i - 60) * 0.5;
- }
-
- for (int _i = 71; _i <= 80; _i++)
- {
- m_nFHValues[_i] = m_nFHValues[70] + (_i - 70) * 0.5;
- }
- }
-
- void CMachineControlDlg_Left::_UpdateFHValue(int nIndex_, double* pnVaue_)
- {
- ASSERT(nIndex_ >= 0 && nIndex_ <= 80);
- *pnVaue_ = m_nFHValues[nIndex_];
- return;
- }
-
- void CMachineControlDlg_Left::_UpdateFHindex(int* pnIndex_, double nValue_)
- {
- ASSERT(nValue_ >= 0);
- for (int i = 0; i < _countof(m_nFHValues); i++)
- {
- if (DOUBLE_EQU(nValue_, m_nFHValues[i]))
- {
- *pnIndex_ = i;
- return;
- }
-
- if (nValue_ < m_nFHValues[i])
- {
- ASSERT(i > 0);
- *pnIndex_ = i - 1;
- return;
- }
- }
- }
-
- void CMachineControlDlg_Left::UpdateFH()
- {
- CParamManager* _pParamManager = mach::GetParamManager();
- if (!_pParamManager)
- {
- return;
- }
- Parameter _FollowHeight;
- if (!_pParamManager->GetParameter("GP_FollowHeight", &_FollowHeight))
- {
- return;
- }
-
- CString _strOldInfo;
- m_pwndStcFollowHeight->GetWindowText(_strOldInfo);
-
- CString _strValue;
- _strValue.Format("%.2f", _FollowHeight.Value.dValue);
- if (_strValue != _strOldInfo)
- {
- m_pwndStcFollowHeight->SetWindowText(_strValue);
- }
-
- double _nFollowHeigth = (min(_FollowHeight.Value.dValue, m_nArcSliderFHMax));
-
- int _nIndex;
- _UpdateFHindex(&_nIndex, _nFollowHeigth);
-
- // 更新横向滑动条
- ASSERT(m_pwndSliderSetFH);
- int _nCurPos_SliderSetFH = m_pwndSliderSetFH->GetPos();
- int _nNewPos_SliderSetFH = _nIndex;
- if (_nNewPos_SliderSetFH != _nCurPos_SliderSetFH)
- {
- m_pwndSliderSetFH->SetPos(_nNewPos_SliderSetFH);
- m_pwndSliderSetFH->Invalidate();
- }
-
- //// 更新弧形旋钮显示
- //ASSERT(m_pwndSliderFH);
- //int _nCurPos_SliderFH = m_pwndSliderFH->GetPos();
- //int _nNewPos_SliderFH = _nIndex;
- //if (_nNewPos_SliderFH != _nCurPos_SliderFH)
- //{
- // m_pwndSliderFH->SetPos(_nNewPos_SliderFH);
- // m_pwndSliderFH->SetSelection(m_pwndSliderF->GetRangeMin(), _nNewPos_SliderFH);
- //}
- }
-
- void CMachineControlDlg_Left::UpdateManuCenter()
- {
- ASSERT(m_pwndBtnCenter);
-
- // 当前显示的串 ---- 杨开锦 2012-02-21
- CString _strOldText;
- m_pwndBtnCenter->GetWindowText(_strOldText);
-
- // 需要显示的串 ---- 杨开锦 2012-02-21
- CString _strNewText;
- CManualTarget* _pManualTarget = GetManualTarget();
- ASSERT(_pManualTarget);
- if (_pManualTarget->IsJogMode() && _pManualTarget->GetJogState())
- {
- _strNewText = _GETCS(s_csRapidJog);
- }
- else if (_pManualTarget->IsJogMode() && !_pManualTarget->GetJogState())
- {
- _strNewText = _GETCS(s_csSlowJog);
- }
- else
- {
- double _nIncDistance = _pManualTarget->GetIncDistance();
-
- if (_nIncDistance >= 1000)
- {
- _strNewText.Format(_T("%.2f"), _nIncDistance);
- }
- else if (_nIncDistance >= 100)
- {
- _strNewText.Format(_T("%.3f"), _nIncDistance);
- }
- else if (_nIncDistance >= 10)
- {
- _strNewText.Format(_T("%.4f"), _nIncDistance);
- }
- else if (_nIncDistance >= 0)
- {
- _strNewText.Format(_T("%.5f"), _nIncDistance);
- }
- _strNewText.TrimRight(_T('0'));
- _strNewText.TrimRight(_T('.'));
- _strNewText += "\nmm";
- }
-
- // 更新 ---- 杨开锦 2012-02-21
- if (_strNewText != _strOldText)
- {
- m_pwndBtnCenter->SetWindowText(_strNewText);
- }
- }
-
- void CMachineControlDlg_Left::UpdateGFOBInfo()
- {
- // 点动时显示“点动”,否则显示指定的距离 ---- 杨开锦 2012-03-10
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
- CString _strGFOBDistance;
- if (_pControlTarget->GetGFOBMode() == 0x01)
- {
- double _nGFOBDistance = _pControlTarget->GetGFOBDistance();
- ASSERT(_nGFOBDistance >= 0);
- _strGFOBDistance.Format(_T("%f"), _nGFOBDistance);
- _strGFOBDistance.TrimRight(_T('0'));
- _strGFOBDistance.TrimRight(_T('.'));
- _strGFOBDistance.AppendFormat("mm");
- }
- else
- {
- ASSERT(_pControlTarget->GetGFOBMode() == 0x00);
- _strGFOBDistance.Format("%s", _GETCS(s_csJOG));
- }
-
- // 惰性更新 ---- 杨开锦 2012-03-10
- CString _strOldInfo;
- m_pwndStcGoDistance->GetWindowText(_strOldInfo);
- if (_strGFOBDistance != _strOldInfo)
- {
- m_pwndStcGoDistance->SetWindowText(_strGFOBDistance);
- }
- }
-
- void CMachineControlDlg_Left::UpdateSpeed()
- {
- double _nSpeed = 0.0;
- if (const CSpeedometerTarget* _pST = GetSpeedometerTarget())
- {
- // 直接拉计数器的XY速度来显示 ---- 杨开锦 2015-11-25
- _nSpeed = _pST->GetRealSpeedXY() * 60;
- }
-
- CString _strValue;
- _strValue.Format("%d", (int)_nSpeed);
- CString _strOldInfo;
- m_pwndStcSpeed->GetWindowText(_strOldInfo);
- if (_strValue != _strOldInfo)
- {
- m_pwndStcSpeed->SetWindowText(_strValue);
- }
- }
-
- void CMachineControlDlg_Left::UpdateEnableJogLaser()
- {
- bool _bEnable = false;
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("EnableJogLaser", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_BOOL)
- {
- _bEnable = _ParamValue.bValue;
- }
- else
- {
- return;
- }
-
- m_pwndBtnJogLaserOn->ShowWindow(_bEnable ? SW_SHOW : SW_HIDE);
- m_pwndBtnJogLaserOff->ShowWindow(_bEnable ? SW_HIDE : SW_SHOW);
- }
-
- void CMachineControlDlg_Left::UpdateEnableAutoCyc()
- {
- CButton* _pwndCheckAutoCyc = (CButton*)GetDlgItem(CTRLID_BTN_AUTOCYC);
- if (!_pwndCheckAutoCyc)
- {
- return;
- }
-
- bool _bEnable1 = false;
- bool _bEnable2 = false;
-
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("AutoExchangeTaskEnd", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_INT)
- {
- if(_ParamValue.iValue == 1)
- {
- _bEnable1 = true;
- }
- else
- {
- ASSERT(_ParamValue.iValue == 0);
- _bEnable1 = false;
- }
- }
- else
- {
- return;
- }
-
- CCycMachiningTarget* _pCycMachingTarget = GetCycMachiningTarget();
- int _nCycTimes = _pCycMachingTarget->GetCycTimes();
- BOOL _bCycEnable= _pCycMachingTarget->GetEnable();
- if(_bCycEnable == TRUE)
- {
- _bEnable2 = true;
- }
- else
- {
- _bEnable2 = false;
- }
- bool _bEnable = _bEnable1 && _bEnable2;
-
- bool _bBtnChecked = _pwndCheckAutoCyc->GetCheck() == BST_CHECKED ? true : false;
- if (_bEnable != _bBtnChecked)
- {
- _pwndCheckAutoCyc->SetCheck(_bEnable ? BST_CHECKED : BST_UNCHECKED);
- }
- }
-
- // 倍率条为120格,映射到0-最大进给倍率,其中100以下为直接对应,100以下可以非线性
- // [0,100] => [0,100]
- // [100,120] => [100,MaxFrp]
- // 这里假设了 MaxFrp >= 100
- // 对于100以下的部分没什么好说的,此处主要说明100以上的部分如何映射:
- // 1) 如果MaxFrp=120,则这部分跟100以下一样,也是线性
- // Value = Index
- // 2) 如果MaxFrp<120,则这部分仍以线性方式增长到最大值MaxFrp,到最大值后不增长
- // Value = Index (when Index <= MaxFrp)
- // = MaxFrp (when Index >= MaxFrp)
- // 3) 如果MaxFrp>120,则这部分以线性叠加指数增长来映射
- // Value = Index * a^(Index - 100)
- // 其中 a可由MaxFrp算出,例如
- // MaxFrp = 150 => 150 = 120 * a^(120-100) => a = (1.25)^(0.05)
- // ---- 杨开锦 2013-03-26
- void CMachineControlDlg_Left::_BuildFIVMap()
- {
- int _nMaxFrp = m_nFValues[120];
- if (CParamManager* _pParamManager = GetParamManager())
- {
- const CStringA _c_strMaxFrpIdentifier = "MaxFrp";
- ParameterValue _MaxFrpParamValue;
- if (!_pParamManager->GetParameterValue(_c_strMaxFrpIdentifier, &_MaxFrpParamValue)
- || _MaxFrpParamValue.nType != ParameterValue::VT_INT
- || _MaxFrpParamValue.iValue == _nMaxFrp)
- {
- // 变化才更新
- return;
- }
- _nMaxFrp = _MaxFrpParamValue.iValue;
- }
-
- C_ASSERT(_countof(m_nFValues) == 121);
- if (_nMaxFrp <= 120)
- {
- for (int _i = 0; _i < _countof(m_nFValues); _i++)
- {
- m_nFValues[_i] = min(_i, _nMaxFrp);
- }
- return;
- }
-
- C_ASSERT(_countof(m_nFValues) == 121);
- for (int _i = 0; _i <= 100; _i++)
- {
- m_nFValues[_i] = _i;
- }
- double _nA = pow(_nMaxFrp / 120.0, 0.05);
- for (int _i = 101; _i < _countof(m_nFValues); _i++)
- {
- int _nV = (int)(_i * pow(_nA, _i - 100.0) + 0.5);
- m_nFValues[_i] = min(_nV, _nMaxFrp);
- }
- }
-
- void CMachineControlDlg_Left::_UpdateFValue(int nIndex_, int* pnValue_)
- {
- ASSERT(nIndex_ >= 0 && nIndex_ < _countof(m_nFValues) && pnValue_);
- *pnValue_ = m_nFValues[nIndex_];
- }
-
- void CMachineControlDlg_Left::_UpdateFIndex(int* pnIndex_, int nValue_)
- {
- ASSERT(pnIndex_ && *pnIndex_ >= 0 && *pnIndex_ < _countof(m_nFValues));
- if (nValue_ == m_nFValues[*pnIndex_])
- {
- return;
- }
-
- int _i = 0;
- while (_i < _countof(m_nFValues) && m_nFValues[_i] < nValue_)
- {
- _i++;
- }
- *pnIndex_ = _i;
- }
-
- LRESULT CMachineControlDlg_Left::OnEndSpeedDlg(WPARAM wParam_, LPARAM lParam_)
- {
- m_pSetSpeedDlg->ShowWindow(SW_HIDE);
- DWORD _nManuMode = (DWORD)wParam_;
- union
- {
- LPARAM lValue;
- float fValue;
- } Value;
- Value.lValue = lParam_;
- double _nValue = (float)Value.fValue;
-
- CManualTarget* _pManualTarget = GetManualTarget();
- ASSERT(_pManualTarget);
-
- // 设置手动低速 ---- 郭小航 2013-11-07
- if (_nManuMode == 0)
- {
- _pManualTarget->SetManuMode(0);
- _pManualTarget->SetJogState(false);
-
- CParamManager* _pParamManager = GetParamManager();
- if (_pParamManager)
- {
- ParameterValue _ParamValue;
- _pParamManager->GetParameterValue("1_0_JVelocityQuick", &_ParamValue);
- if (_nValue > _ParamValue.dValue)
- {
- _ParamValue.dValue = _nValue;
- _pParamManager->SetParameterValue("1_0_JVelocityQuick", &_ParamValue);
- _pParamManager->SetParameterValue("1_0_JVelocity", &_ParamValue);
- }
- else
- {
- _ParamValue.dValue = _nValue;
- _pParamManager->SetParameterValue("1_0_JVelocity", &_ParamValue);
- }
- }
- }
- // 设置手动高速 ---- 郭小航 2013-11-07
- else if (_nManuMode == 1)
- {
- _pManualTarget->SetManuMode(0);
- _pManualTarget->SetJogState(true);
-
- CParamManager* _pParamManager = GetParamManager();
- if (_pParamManager)
- {
- ParameterValue _ParamValue;
- _pParamManager->GetParameterValue("1_0_JVelocity", &_ParamValue);
- if (_nValue < _ParamValue.dValue)
- {
- _ParamValue.dValue = _nValue;
- _pParamManager->SetParameterValue("1_0_JVelocity", &_ParamValue);
- _pParamManager->SetParameterValue("1_0_JVelocityQuick", &_ParamValue);
- }
- else
- {
- _ParamValue.dValue = _nValue;
- _pParamManager->SetParameterValue("1_0_JVelocityQuick", &_ParamValue);
- }
- }
- }
- // 设置步长 ---- 郭小航 2013-11-07
- else if (_nManuMode == 2)
- {
- _pManualTarget->SetManuMode(1);
- _pManualTarget->SetIncDistance(_nValue);
- }
-
- return TRUE;
- }
-
- LRESULT CMachineControlDlg_Left::OnEndEditDistance(WPARAM wParam_, LPARAM lParam_)
- {
- ASSERT(lParam_);
- CString* _strText = reinterpret_cast<CString*>(lParam_);
- CString _strGetValue = *_strText;
- m_pwndStcGoDistance->ShowWindow(SW_SHOW);
- if (IsValidDate(_strGetValue, "double", 100000, 0., "mm"))
- {
- double _nGetValue = _tstof(_strGetValue);
- _nGetValue = _FormatInputData(_nGetValue);
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
- _pControlTarget->SetGFOBDistance(_nGetValue);
- }
-
- return TRUE;
- }
-
- void CMachineControlDlg_Left::OnLButtonDown(UINT nFlags_, CPoint point_)
- {
- if (::IsWindow(m_pDistanceEdit->GetSafeHwnd()))
- {
- delete m_pDistanceEdit;
- m_pDistanceEdit = NULL;
- }
- else
- m_pDistanceEdit = NULL;
- }
-
- // 响应鼠标单击前进后退显示按钮消息。以100/1200处为界,点击前部份:如果是步进模
- // 式则弹出编辑框可编辑前进后退距离,如果是点动模式则不响应。点击后部份:切换前
- // 进后退模式。返回True则表示不再进行消息循环 ---- DingQiang 2012-07-19
- BOOL CMachineControlDlg_Left::OnDistanceLButtonDown(CPoint point_)
- {
- CControlTarget* _pControlTarget = GetControlTarget();
- if (!_pControlTarget)
- {
- return FALSE;
- }
-
- CRect _rcGoDistance;
- m_pwndStcGoDistance->GetWindowRect(_rcGoDistance);
- double _nWide = _rcGoDistance.Width() * 0.83;
- double _nDivide = _rcGoDistance.left + _nWide;
-
- if (point_.x < _nDivide)
- {
- if (_pControlTarget->GetGFOBMode() == 0x00)
- {
- return TRUE;
- }
-
- if (::IsWindow(m_pDistanceEdit->GetSafeHwnd()))
- {
- // 这样做的目的是防止编辑框已经Create出的时候,又点击到按钮又Create一次 ---- DingQiang 2012-07-20
- return FALSE;
- }
-
- CString _strItemText;
- m_pwndStcGoDistance->GetWindowText(_strItemText);
- CRect _rect(0, 0, 0, 0);
- m_pwndStcGoDistance->GetWindowRect(_rect);
-
- // new一个编辑框出来,其父窗口为前进后退距离显示框 ---- DingQiang 2012-07-19
- m_pwndStcGoDistance->ScreenToClient(&_rect);
- _rect.top += 7;
- _rect.bottom -= 6;
- _rect.left += 2;
- _rect.right -= 2;
- DWORD _dwStyle;
- _dwStyle = WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER | ES_CENTER | ES_AUTOVSCROLL | ES_NOHIDESEL;
- m_pDistanceEdit = new CEditItem(this, _strItemText);
- m_pDistanceEdit->Create(_dwStyle, _rect, m_pwndStcGoDistance, CTRLID_EDIT_GODISTANCE);
- return TRUE;
- }
- else
- {
- DWORD _nSetMode;
- if (_pControlTarget->GetGFOBMode() == 0x00)
- {
- _nSetMode = 0x01;
- }
- else
- _nSetMode = 0x00;
-
- _pControlTarget->SetGFOBMode(_nSetMode);
- return FALSE;
- }
-
- return FALSE;
- }
-
- // 检查数据是否是合法的输入,允许输入正数、小数、单位。不允许负数和字母---- DingQiang 2012-03-07
- bool CMachineControlDlg_Left::IsValidDate(LPCSTR szInPut_, // 输入字符串
- LPCSTR szType_, // 数据类型
- double nMax_, // 允许的最大值
- double nMin_, // 允许的最小值
- LPCSTR szUnit_) // 允许输入单位
- {
- int _nNumDots = 0; // 小数点个数,只允许一个
- CString _strInPut = szInPut_;
- CString _strUint = szUnit_;
- int _nLength = (int)strlen(_strInPut); // 输入入字符串长度
- int _nUnitLength = (int)strlen(_strUint); // 允许使用的单位字符串长度
- bool b_ContainUnit = false; // 是否包含单位
-
- if (0 == _nLength)
- {
- return false;
- }
-
- // 多于两个小数点则返回false---- DingQiang 2012-03-07
- int _nDotCount = 0;
- for (int _i = 0; _i < _nLength; _i++)
- {
- char _szDot = _strInPut[_i];
- if (_szDot == '.')
- {
- _nDotCount++;
- }
- }
-
- if (_nDotCount > 1)
- {
- AfxMessageBox(_GETCS(s_csFloatDataError));
- return false;
- }
-
- // 先检查字符串后面的_nUnitLength长度是否是数字,如果有一个不是数字则立马判
- // 断后面_nUnitLength个字符是否是单位字符,如果即不是数字也不是单位字符则直
- // 接返回错误信息,不再做其它检查。 ---- DingQiang 2012-03-07
- int _nCheckUint = (_nLength - _nUnitLength) > 0 ? _nLength - _nUnitLength : _nLength;
- for (int _j = _nCheckUint; _j < _nLength; _j++)
- {
- char _szChar = _strInPut[_j];
- if(_szChar < 0 || _szChar > 255)
- {
- AfxMessageBox(_GETCS(s_csFloatDataError));
- return false;
- }
- if (!isdigit(_szChar))
- {
- if (_szChar != '.')
- {
- if (_strUint.Compare(_strInPut.Right(_nUnitLength)) != 0)
- {
- AfxMessageBox(_GETCS(s_csFloatDataError));
- return false;
- }
- else
- {
- b_ContainUnit = true;
- }
- }
- }
- }
-
- // 如果有符号则检查除符号外的字符,如没有符号则全部检查---- DingQiang 2012-03-08
- int _nCheckNum = b_ContainUnit ? _nCheckUint : _nLength;
- int _i = 0;
- for (; _i < _nCheckNum; _i++)
- {
- char _c = _strInPut[_i];
- if (!isdigit(_c))
- {
- if (0 == strcmp(szType_, "int"))
- {
- break;
- }
- else if (0 == strcmp(szType_, "double") || 0 == strcmp(szType_, "float"))
- {
- if (_c == '.' && _nNumDots == 0)
- {
- _nNumDots++;
- }
- else
- {
- break;
- }
- }
- else
- ASSERT(false);
- }
- }
-
- if (_i != _nCheckNum && (strcmp(szType_, "int") == 0))
- {
- AfxMessageBox(_GETCS(s_csIntDataError));
- return false;
- }
-
- if (_i != _nCheckNum && (strcmp(szType_, "float") == 0 || strcmp(szType_, "double") == 0))
- {
- AfxMessageBox(_GETCS(s_csFloatDataError));
- return false;
- }
-
- double _nInPut = (double)_tstof(szInPut_);
- if ( _nInPut > nMin_ && _nInPut < nMax_)
- {
- return true;
- }
- else
- {
- CString _strErrorShow;
- _strErrorShow.Format(_GETCS(s_csFloatDataBoundError), nMin_, nMax_);
- AfxMessageBox(_strErrorShow);
- return false;
- }
- }
-
- void CMachineControlDlg_Left::OnChangeCoorMode()
- {
- m_nCoorMode = (m_nCoorMode == 0x00) ? 0x01 : 0x00;
- UpdateMachCoor();
- }
-
- // 格式化输入 ---- DingQiang 2012-06-25
- static double _FormatInputData(double nInputData_)
- {
- ASSERT(nInputData_ >= 0);
- CString _strTemp;
- _strTemp.Format(_T("%f"), nInputData_);
-
- CString _strOut = _strTemp.Left(6);
-
- return _tstof(_strOut);
- }
-
- // 设置手动速度 ---- 郭小航 2013-11-07
- void CMachineControlDlg_Left::OnDblClickCenter()
- {
- CStateManager* _pStateManager = GetStateManager();
- if (!_pStateManager)
- return;
-
- CStateManager::State _State = mach::CStateManager::Invalid;
- if (!_pStateManager->GetState(&_State))
- {
- return;
- }
-
- if (_State != mach::CStateManager::Invalid
- && _State != mach::CStateManager::Idle
- //&& _State != mach::CStateManager::Lock // 仿真时也不能修改速度。
- && _State != mach::CStateManager::Estop)
- {
- AfxMessageBox(_GETCS(s_csNotInputPrompt));
- return;
- }
-
- ASSERT(m_pwndBtnCenter && ::IsWindow(m_pwndBtnCenter->m_hWnd));
- CRect _rcBtnCenter;
- m_pwndBtnCenter->GetWindowRect(&_rcBtnCenter);
- ((CSetSpeedDlg*)m_pSetSpeedDlg)->SetBasePosition(_rcBtnCenter.TopLeft());
- m_pSetSpeedDlg->ShowWindow(SW_SHOW);
- }
-
- LRESULT CMachineControlDlg_Left::OnSliderMoving(WPARAM wParam_, LPARAM lParam_)
- {
- CParamManager* _pParamManager = mach::GetParamManager();
- if (!_pParamManager)
- {
- ASSERT(FALSE);
- return 0;
- }
-
- UINT _nCtrlID = (UINT)wParam_;
- int _nIndex = (int)lParam_;
- if (wParam_ == CTRLID_SLD_SETF)
- {
- int _nFrp = 100;
- _UpdateFValue(_nIndex, &_nFrp);
-
- // 为安全计,通过CParamManager修改参数都会全部检查所有参数,在此处可能并
- // 非必须的,且全部检查会让进给倍率条显得卡起来,有拖尾。 因此,此处我们
- // 通过造一个Command来绕过全部检查。 ---- 杨开锦 2012-08-17
- if (CCommandManager* _pCommandManager = GetCommandManager())
- {
- const CStringA _c_strSetFrpCommand = "SetFrp";
- CStringA _strFrp;
- _strFrp.Format("%d", _nFrp);
- _pCommandManager->Execute(_c_strSetFrpCommand, _strFrp, "LPCSTR");
- }
- if (m_bSliderCtrlG00)
- {
- if (CCommandManager* _pCommandManager = GetCommandManager())
- {
- const CStringA _c_strSetG00FrpCommand = "SetG00Frp";
- CStringA _strFrp;
- _strFrp.Format("%d", _nFrp);
- _pCommandManager->Execute(_c_strSetG00FrpCommand, _strFrp, "LPCSTR");
- }
- }
-
- UpdateF();
- }
-
- if (wParam_ == CTRLID_SLD_SETFH)
- {
- double _nValue;
- _UpdateFHValue(_nIndex, &_nValue);
- ParameterValue _Value;
- memset(&_Value, 0, sizeof(ParameterValue));
- _pParamManager->GetParameterValue("ActualSampleLength", &_Value);
- if (_Value.nType != ParameterValue::VT_DOUBLE)
- {
- return 0;
- }
- _nValue = min(_nValue, _Value.dValue);
-
- if (CCommandManager* _pCommandManager = GetCommandManager())
- {
- const CStringA _c_strSetFHCommand = "SetFollowHeight";
- CStringA _strFH;
- _strFH.Format("%.3f", _nValue);
- _pCommandManager->Execute(_c_strSetFHCommand, _strFH, "LPCSTR");
- }
- UpdateFH();
- }
-
- if (wParam_ == CTRLID_SLD_SETP)
- {
- if (CCommandManager* _pCommandManager = GetCommandManager())
- {
- const CStringA _c_strSetPowerCommand = "SetDutyCycles";
- CStringA _strPower;
- _strPower.Format("%d", _nIndex);
- _pCommandManager->Execute(_c_strSetPowerCommand, _strPower, "LPCSTR");
- }
- UpdateP();
- }
- return 1;
- }
-
- void CMachineControlDlg_Left::OnClickMachSelected()
- {
- //CStateManager* _pStateManager = GetStateManager();
- //ASSERT(_pStateManager);
- //CStateManager::State _nState = CStateManager::Idle;
- //BOOL _bEnable = _pStateManager->GetState(&_nState) && _nState == CStateManager::Idle;
- //if (!_bEnable)
- // return;
-
- //CButton* _pBtn = (CButton*)GetDlgItem(CTRLID_BTN_MACHSELECTED);
- //BOOL _bMachSelected = _pBtn->GetCheck() == BST_CHECKED;
- //_bMachSelected = !_bMachSelected;
- //m_bSelectMach = _bMachSelected;
- //_pStateManager->SetSelectedMach(m_bSelectMach);
- //_pBtn->SetCheck(_bMachSelected ? BST_CHECKED : BST_UNCHECKED);
- }
-
- void CMachineControlDlg_Left::OnCloseMachSelected()
- {
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- CStateManager::State _nState = CStateManager::Idle;
- BOOL _bEnable = _pStateManager->GetState(&_nState) && _nState == CStateManager::Idle;
- if (!_bEnable)
- return;
-
- ASSERT(m_bSelectMach == TRUE);
- m_bSelectMach = FALSE;
- _pStateManager->SetSelectedMach(m_bSelectMach);
- m_pwndBtnSelMachOn->ShowWindow(m_bSelectMach ? SW_SHOW : SW_HIDE);
- m_pwndBtnSelMachOff->ShowWindow(m_bSelectMach ? SW_HIDE : SW_SHOW);
- }
-
- void CMachineControlDlg_Left::OnOpenMachSelected()
- {
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- CStateManager::State _nState = CStateManager::Idle;
- BOOL _bEnable = _pStateManager->GetState(&_nState) && _nState == CStateManager::Idle;
- if (!_bEnable)
- return;
-
- ASSERT(m_bSelectMach == FALSE);
- m_bSelectMach = TRUE;
- _pStateManager->SetSelectedMach(m_bSelectMach);
- m_pwndBtnSelMachOn->ShowWindow(m_bSelectMach ? SW_SHOW : SW_HIDE);
- m_pwndBtnSelMachOff->ShowWindow(m_bSelectMach ? SW_HIDE : SW_SHOW);
- }
-
- void CMachineControlDlg_Left::OnClickJogLaser()
- {
- bool _bValue = false;
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("EnableJogLaser", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_BOOL)
- {
- _bValue = _ParamValue.bValue;
- }
- else
- {
- ASSERT(FALSE);
- return;
- }
-
- _ParamValue.bValue = !_bValue;
- _pParamManager->SetParameterValue("EnableJogLaser", &_ParamValue);
- UpdateEnableJogLaser();
- }
-
- void CMachineControlDlg_Left::OnCloseJogLaser()
- {
- bool _bValue = false;
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("EnableJogLaser", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_BOOL)
- {
- _bValue = _ParamValue.bValue;
- // ASSERT(_bValue = TRUE);
- }
- else
- {
- ASSERT(FALSE);
- return;
- }
-
- _ParamValue.bValue = FALSE;
- _pParamManager->SetParameterValue("EnableJogLaser", &_ParamValue);
-
- m_pwndBtnJogLaserOn->ShowWindow(SW_HIDE);
- m_pwndBtnJogLaserOff->ShowWindow(SW_SHOW);
-
- UpdateEnableJogLaser();
- }
-
- void CMachineControlDlg_Left::OnOpenJogLaser()
- {
- bool _bValue = false;
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("EnableJogLaser", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_BOOL)
- {
- _bValue = _ParamValue.bValue;
- //ASSERT(_bValue = FALSE);
- }
- else
- {
- ASSERT(FALSE);
- return;
- }
-
- _ParamValue.bValue = TRUE;
- _pParamManager->SetParameterValue("EnableJogLaser", &_ParamValue);
-
- m_pwndBtnJogLaserOn->ShowWindow(SW_SHOW);
- m_pwndBtnJogLaserOff->ShowWindow(SW_HIDE);
-
- UpdateEnableJogLaser();
- }
-
- void CMachineControlDlg_Left::OnClickAutoCyc()
- {
- bool _bEnable1 = false;
- bool _bEnable2 = false;
-
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParamValue;
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- if(_pParamManager->GetParameterValue("AutoExchangeTaskEnd", &_ParamValue)
- && _ParamValue.nType == mach::ParameterValue::VT_INT)
- {
- if(_ParamValue.iValue == 1)
- {
- _bEnable1 = true;
- }
- else
- {
- ASSERT(_ParamValue.iValue == 0);
- _bEnable1 = false;
- }
- }
- else
- {
- return;
- }
-
- CCycMachiningTarget* _pCycMachingTarget = GetCycMachiningTarget();
- int _nCycTimes = _pCycMachingTarget->GetCycTimes();
- BOOL _bCycEnable= _pCycMachingTarget->GetEnable();
- if(_bCycEnable == TRUE)
- {
- _bEnable2 = true;
- }
- else
- {
- _bEnable2 = false;
- }
-
- bool _bEnable = _bEnable1 && _bEnable2;
-
-
- if(_bEnable)
- {
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- _ParamValue.nType = ParameterValue::VT_INT;
- _ParamValue.iValue = 0;
- _pParamManager->SetParameterValue("AutoExchangeTaskEnd", &_ParamValue);
-
- _pCycMachingTarget->SetEnable(FALSE);
- }
- else
- {
- memset(&_ParamValue, 0, sizeof(ParameterValue));
- _ParamValue.nType = ParameterValue::VT_INT;
- _ParamValue.iValue = 1;
- _pParamManager->SetParameterValue("AutoExchangeTaskEnd", &_ParamValue);
-
- _pCycMachingTarget->SetEnable(TRUE);
- }
- UpdateEnableAutoCyc();
- SendTargetMessage(ID_TARGET_EXCHANGEWORKBENCH, TM_AUTOCYC_CHECK, 0, 0);
- }
-
- void CMachineControlDlg_Left::OnClickCycMach()
- {
- CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
- ASSERT(_pCycMachiningTarget);
-
- bool _bCycMach = _pCycMachiningTarget->GetEnable();
- _bCycMach = !_bCycMach;
-
- _pCycMachiningTarget->SetEnable(_bCycMach);
- m_pwndBtnCycMach->SetCheck(_bCycMach);
- }
-
- void CMachineControlDlg_Left::UpdateCycMach()
- {
- // 循环加工
- CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
- ASSERT(_pCycMachiningTarget);
-
- bool _bCycMach = _pCycMachiningTarget->GetEnable();
- m_pwndBtnCycMach->SetCheck(_bCycMach);
- }
-
- HBRUSH CMachineControlDlg_Left::OnCtlColor(CDC* pDC_, CWnd* pWnd_, UINT nCtlColor_)
- {
- HBRUSH _hBrush = __super::OnCtlColor(pDC_, pWnd_, nCtlColor_);
-
- //COLORREF _clrTextColor;
- //if (CNceTheme::GetElement("ToolbarTextColor", &_clrTextColor))
- //{
- // pDC_->SetTextColor(_clrTextColor);
- //}
-
- //if (m_brush)
- //{
- // pDC_->SetBkMode(TRANSPARENT);
- // return m_brush;
- //}
-
- //return _hBrush;
-
- //pDC_->SetBkMode(TRANSPARENT);
- return m_brush;
- }
-
- BOOL CMachineControlDlg_Left::OnEraseBkgnd(CDC* pDC)
- {
- // 绘制黑色背景 ---- 吴畏 2017-03-29
- CPaintDC dc(this);
- CRect _rect;
- GetClientRect(_rect);
- CBrush _brush;
- _brush.CreateSolidBrush(COLORREF(RGB(0, 0, 0)));
- dc.FillRect(&_rect,&_brush);
- _brush.DeleteObject();
-
- return TRUE;
- }
-
- void CMachineControlDlg_Left::BufferDraw(CDC* pDC)
- {
- BITMAP bmp;//储存位图信息的结构体
- CRect rect;
- GetClientRect(rect);//获取客户区域的矩形
- bufferdc.CreateCompatibleDC(NULL);//创建兼容DC
- bufferbmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());//创建兼容位图
- bufferdc.SelectObject(&bufferbmp);//将位图选入内存区域
- CBitmap *pOldBit = bufferdc.SelectObject(&bufferbmp);
- bufferbmp.GetBitmap(&bmp);//获取内存位图的信息
- //在此处添加绘制代码
-
-
- SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);
- pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &bufferdc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);//将内存中的内容复制到设备
- bufferdc.DeleteDC(); //删除DC
- bufferbmp.DeleteObject(); //删除位图
- }
-
- void CMachineControlDlg_Left::OnDraw(CDC* pDC)
- {
- /*CDocument* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (!pDoc)
- return;*/
- BufferDraw(pDC);
- }
-
- void CMachineControlDlg_Left::OnPaint()
- {
- CRect PaintRect;
- CPaintDC dc(this);
- CDC MemDC;
- CBitmap MemBitmap;
-
- // 双缓冲绘图
- GetClientRect(PaintRect);
- if (MemDC.CreateCompatibleDC(&dc))
- {
- if (MemBitmap.CreateCompatibleBitmap(&dc, PaintRect.Width(), PaintRect.Height()))
- {
- if (HGDIOBJ OldObject = MemDC.SelectObject(MemBitmap))
- {
- // 拷贝背景图, 以处理透明色
- if (MemDC.BitBlt(0, 0, PaintRect.Width(), PaintRect.Height(), &dc, 0, 0, SRCCOPY))
- {
- Gdiplus::Graphics g(MemDC);
-
- // Paint here ...
-
- dc.BitBlt(0, 0, PaintRect.Width(), PaintRect.Height(), &MemDC, 0, 0, SRCCOPY);
- }
- MemDC.SelectObject(OldObject);
- }
- MemBitmap.DeleteObject();
- }
- MemDC.DeleteDC();
- }
- }
-
- void CMachineControlDlg_Left::OnMinSize()
- {
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
-
- if (_pControlTarget->GetMinSize())
- {
- return;
- }
-
- CRect _rect;
- GetClientRect(&_rect);
- int _width = _rect.Width();
- int _nHeight = _rect.Height();
-
- HWND _hwnd = GetSafeHwnd();
- ASSERT(_hwnd);
- ::MoveWindow(_hwnd, 0, 0, 20, _nHeight, true);
-
- _pControlTarget->SetMinSize(true);
- m_pwndBtnMax->ShowWindow(SW_SHOW);
- }
-
- void CMachineControlDlg_Left::OnMaxSize()
- {
- CControlTarget* _pControlTarget = GetControlTarget();
- ASSERT(_pControlTarget);
-
- if (!_pControlTarget->GetMinSize())
- {
- return;
- }
-
- HWND _hwnd = GetSafeHwnd();
- ASSERT(_hwnd);
- CRect _rect;
- GetClientRect(&_rect);
- int _width = _rect.Width();
- int _nHeight = _rect.Height();
-
- ::MoveWindow(_hwnd, 0, 0, 536, _nHeight, true);
-
- _pControlTarget->SetMinSize(false);
-
- m_pwndBtnMax->ShowWindow(SW_HIDE);
- }
-
- void CMachineControlDlg_Left::OnSelMarkPoint()
- {
- // 加载标记点选项菜单 ---- 边俊霞 2017-05-11
- CRect _rcRect;
- GetDlgItem(CTRLID_BTN_SELMARKPOINT)->GetWindowRect(&_rcRect);
- m_pMenu->TrackPopupMenu(TPM_CENTERALIGN | TPM_LEFTBUTTON, _rcRect.right, _rcRect.bottom, this);
- }
-
- void CMachineControlDlg_Left::OnMarkPointChange(UINT ID_)
- {
- // 在标记点按钮上显示当前选择的标记点index ---- 边俊霞 2017-03-14
- UINT _nCurIndex = ID_ - CTRLID_BTN_MARKPOINT1 + 1;
- m_nCurIndex = _nCurIndex;
- CString _strCurIndex;
- _strCurIndex.Format("%u", _nCurIndex);
-
- // 使数字在button上不居中显示 ---- 边俊霞 2017-03-15
- CString _strShowIndex = _strCurIndex + '\n';
- SetDlgItemText(CTRLID_BTN_SELMARKPOINT, _strShowIndex);
-
- // 将当前选择的标记点index传到MarkPointTarget ---- 边俊霞 2017-03-14
- CMarkPointTarget* _pMarkPointTarget = GetMarkPointTarget();
- ASSERT(_pMarkPointTarget);
- _pMarkPointTarget->SetCurMarkIndex(_nCurIndex - 1);
- }
|