You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ControlTarget.cpp 97 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087
  1. // ************************************************************************** //
  2. // ControlTarget.cpp : implementation of the CControlTarget class
  3. // Copyright(c)2012 Naiky Company. All rights reserved.
  4. //
  5. // Abstract:
  6. // ļʵCControlTargetࡣ
  7. // ********************************************* ---- ¬ΰ 2012-01-07 ***** //
  8. #include "StdAfx.h"
  9. #include "ControlTarget.h"
  10. #include "CycMachiningTarget.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. CS_T s_csBreakPointResume = _DEFCS(_CSV(18028),
  17. _CHINESE("ϵ")
  18. _ENGLISH("BreakPointResume"));
  19. CS_T s_csGoForward = _DEFCS(_CSV(18029),
  20. _CHINESE("ǰ")
  21. _ENGLISH("GoForward"));
  22. CS_T s_csGoBackward = _DEFCS(_CSV(18030),
  23. _CHINESE("")
  24. _ENGLISH("GoBackward"));
  25. CS_T s_csBACKREFPROMPT = _DEFCS(_CSV(18031),
  26. _CHINESE("лػеԭ\nǷȷϣ")
  27. _ENGLISH("It's going to go back to Reference Point\nConform or Not?"));
  28. CS_T s_csFORBIDORIGINBACK = _DEFCS(_CSV(18032),
  29. _CHINESE("ǰ㲻ִԶ")
  30. _ENGLISH("It's forbid to AutoBack at the current point"));
  31. CS_T s_csFORBIDORIGINFORWARD = _DEFCS(_CSV(18033),
  32. _CHINESE("ǰ㲻ִԶ")
  33. _ENGLISH("It's forbid to AutoForward at the current point"));
  34. CS_T s_csNoObjInFileForAction = _DEFCS(_CSV(18034),
  35. _CHINESE("|E|ļͼΣ%s!")
  36. _ENGLISH("|E|No figure in the file, unable to %s!"));
  37. CS_T s_csFORBIDRESUME = _DEFCS(_CSV(18035),
  38. _CHINESE("|E|ǰ㲻ִжϵ")
  39. _ENGLISH("|E|It's forbid to Resume at the current point"));
  40. CS_T s_csCANNOTSIMUCUT_NOOBJ = _DEFCS(_CSV(18036),
  41. _CHINESE("ļͼΣ޷߱߿")
  42. _ENGLISH("No figure in the file,can not SimuCut!"));
  43. CS_T s_csCANNOTSIMUCUT_JUST1DOT = _DEFCS(_CSV(18037),
  44. _CHINESE("ļֻһ㣬޷߱߿")
  45. _ENGLISH("Just 1 Dot in the file,can not SimuCut!"));
  46. CS_T s_csFileChanged = _DEFCS(_CSV(18038),
  47. _CHINESE("ļ޸ģ󷽿ִлӹ\nǷ񱣴棿")
  48. _ENGLISH("File changed, can not mach untill saved!\nSave or not?"));
  49. CS_T s_cs2YDetectConfigError = _DEFCS(_CSV(18039),
  50. _CHINESE("|F|˫Yԭ!")
  51. _ENGLISH("|F|Config for 2YErrorDetecting is wrong, please check!"));
  52. CS_T s_csOperateDangerous = _DEFCS(_CSV(18040),
  53. _CHINESE("ǰΣ: ̧иͷ\nǷ...")
  54. _ENGLISH("Operation dangerous: It's better to raise cutter first.\nContinue or not..."));
  55. CS_T s_csNHOURSLEFTFORCECLOSE = _DEFCS(_CSV(18041),
  56. _CHINESE("|F|עڣϵͳ%dСʱԶر!")
  57. _ENGLISH("|F|The system is expired.\nNcEditor Will Be Closed In %d Hours Without Registered Again!"));
  58. CS_T s_csNoNearPoint = _DEFCS(_CSV(18042),
  59. _CHINESE("|E|ûҵڽ㣡")
  60. _ENGLISH("|E|No near point be found!"));
  61. CS_T s_csFORBIDNEARSTART = _DEFCS(_CSV(18043),
  62. _CHINESE("|E|ǰ㲻ִڽӹ")
  63. _ENGLISH("|E|It's forbid to near start at the current point!"));
  64. CS_T s_csEXCEEDWORKTABLE = _DEFCS(_CSV(18526),
  65. _CHINESE("|E|ӹļ̨Χ")
  66. _ENGLISH("|E|Exceed the worktable travel limit!"));
  67. CS_T s_szNOAVALIBLEOBJECTTOMACH = _DEFCS(_CSV(18619),
  68. _CHINESE("ǰ˶ִУȷǷڼӹͼΣѡӹģʽδѡκͼΡ")
  69. _ENGLISH("Current motion cannot be executed. Please make sure graphic to be machined exists or it has been selected."));
  70. CS_T s_szCONFIG_TUBE_NOK = _DEFCS(_CSV(18619),
  71. _CHINESE("ϵͳòּ֧ӹܲļ")
  72. _ENGLISH("Tube file is not supported under current System Config."));
  73. CS_T s_szFORSEHOMEBEFORBEGIN = _DEFCS(_CSV(18619),
  74. _CHINESE("ӹǰȻػеԭ㣡")
  75. _ENGLISH("Before machining, all axes must go home!"));
  76. static bool _FindObjectByID(IN nce::CCadObject* pCadObj_, IN int nID_, OUT nce::CCadObject** ppResult_);
  77. typedef std::vector<UINT> vectorUINT;
  78. void _GetCadIDList(IN nce::CadObjectList* pListCads_, OUT vectorUINT& setIDs_);
  79. void _GetCamGroupByCadID(IN nce::CCamGroup* pCCamGroup_, IN vectorUINT setIDs_, OUT nce::CCamGroup* pOutCCamGroup_);
  80. const CHAR c_szScanType[] = "ScanType";
  81. //׷ʽ
  82. const char c_szPerforateType[] = "PerforateType";
  83. //
  84. const char c_szPerBlowType[] = "PerBlowType";
  85. //и
  86. const char c_szCutBlowType[] = "CutBlowType";
  87. //ȴ
  88. const char c_szCoolBlowType[] = "CoolBlowType";
  89. //ͼ㲻ӹ
  90. const char c_szOutput[] = "Output";
  91. //һ
  92. const char c_szFirstSegBlowType[] = "FirstSegBlowType";
  93. //
  94. const char c_szSecondSegBlowType[] = "SecondSegBlowType";
  95. //
  96. const char c_szThirdSegBlowType[] = "ThirdSegBlowType";
  97. //һflag
  98. const char c_szFirstSegPunch[] = "FirstSegPunch";
  99. //flag
  100. const char c_szSecondSegPunch[] = "SecondSegPunch";
  101. //flag
  102. const char c_szThirdSegPunch[] = "ThirdSegPunch";
  103. using namespace mach;
  104. using namespace ncmath;
  105. using namespace nce;
  106. CControlTarget* CControlTarget::ms_pControlTarget = NULL;
  107. CControlTarget* GetControlTarget()
  108. {
  109. return CControlTarget::ms_pControlTarget;
  110. }
  111. ///////////////////////////////////////////////////////////////////////////////
  112. // CControlTarget
  113. //
  114. IMPLEMENT_DYNAMIC(CControlTarget, CNceTarget)
  115. BEGIN_MESSAGE_MAP(CControlTarget, CNceTarget)
  116. ON_COMMAND(IDCMD_CONTROLTARGET_SHOWCONTROLDLG, OnShowControlDlg)
  117. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_SHOWCONTROLDLG, OnUpdateShowControlDlg)
  118. // ɫӦӦдOnCommandǰ ----  2012-05-25
  119. ON_COMMAND(IDCMD_CONTROLTARGET_DETECT2YERROR, OnDetect2YError)
  120. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_DETECT2YERROR, OnUpdateDetect2YError)
  121. ON_COMMAND(IDCMD_CONTROLTARGET_CLEARW, OnClearW)
  122. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_CLEARW, OnUpdateClearW)
  123. ON_COMMAND(IDCMD_CONTROLTARGET_CLEARWZ, OnClearWZ)
  124. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_CLEARWZ, OnUpdateClearWZ)
  125. ON_COMMAND(IDCMD_CONTROLTARGET_STOP, OnStop)
  126. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_STOP, OnUpdateStop)
  127. ON_COMMAND(IDCMD_CONTROLTARGET_DIRECTSET, OnDirectSet)
  128. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_DIRECTSET, OnUpdateDirectSet)
  129. ON_COMMAND(IDCMD_CONTROLTARGET_BACKRDLG, OnBackRDlg)
  130. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_BACKRDLG, OnUpdateBackRDlg)
  131. ON_COMMAND(IDCMD_CONTROLTARGET_MACHSELECTED, OnIsMachSelected)
  132. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_MACHSELECTED, OnUpdateIsMachSelected)
  133. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_STARTSELECTION, OnUpdateStartSelectNotMove)
  134. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_ZBACKR, OnUpdateZBackOrg)
  135. ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_FOLLOWCONTROL, OnUpdateFollowCtrl)
  136. ON_TARGET_NOTIFY(TN_NAMEDCOMMAND, OnNamedCommand)
  137. ON_COMMAND_RANGE(IDCMD_CONTROLTARGET_BACKR, IDCMD_CONTROLTARGET_BACKWARDEND, OnCommand)
  138. ON_UPDATE_COMMAND_UI_RANGE(IDCMD_CONTROLTARGET_BACKR, IDCMD_CONTROLTARGET_BACKWARDEND, OnUpdateCommandUI)
  139. ON_TARGET_NOTIFY(TN_TIMER_EVERY40MILLISECOND, OnEvery40Millisecond)
  140. ON_TARGET_NOTIFY(TN_POST_INITINSTANCE, OnPostInitInstance)
  141. END_MESSAGE_MAP()
  142. CControlTarget::CControlTarget()
  143. : c_nMinGFOBDistance(0.01)
  144. , m_bShowControlDlg(true)
  145. , m_nGFOBDistance(10.0)
  146. , m_nGFOBMode(0x00)
  147. , m_bShowBkrefDlgWhenStart(TRUE)
  148. , m_nGFOBKeyState(0)
  149. , m_bEnableKeyMsg(true)
  150. {
  151. ASSERT(ms_pControlTarget == NULL);
  152. ms_pControlTarget = this;
  153. // ----  2012-04-13
  154. typedef CControlTarget ThisClass;
  155. static const CommandItem _s_CommandItems[] =
  156. {
  157. // nID strName strCommand strCEParameter pGetEParameter
  158. // MFC C# CanExecute Execute
  159. { IDCMD_CONTROLTARGET_BACKR, "BackR", "BackR", NULL, NULL, },
  160. { IDCMD_CONTROLTARGET_XBACKR, "BackR", "BackR", NULL, &ThisClass::_GetParamForXBackR, },
  161. { IDCMD_CONTROLTARGET_YBACKR, "BackR", "BackR", NULL, &ThisClass::_GetParamForYBackR, },
  162. { IDCMD_CONTROLTARGET_ZBACKR, "BackRZ", "BackRZ", NULL, &ThisClass::_GetParamForZBackR, },
  163. { IDCMD_CONTROLTARGET_DIRECTSET, "DirectSet", "DirectSet", NULL, NULL, },
  164. { IDCMD_CONTROLTARGET_MOVETOFIXPOS, "BackFP", "BackFixPos", NULL, NULL, },
  165. { IDCMD_CONTROLTARGET_BACKW, "BackW", "BackW", NULL, NULL, },
  166. { IDCMD_CONTROLTARGET_CLEARW, "ClearW", "ClearW", NULL, NULL, },
  167. { IDCMD_CONTROLTARGET_BACKWZ, "BackWZ", "BackWZ", NULL, NULL, },
  168. { IDCMD_CONTROLTARGET_CLEARWZ, "ClearWZ", "ClearWZ", NULL, NULL, },
  169. { IDCMD_CONTROLTARGET_SIMUCUT, "WalkBoundRect", "RunGCode", "G00 X0 Y0", &ThisClass::_GetParamForCommand_SimuCut, },
  170. { IDCMD_CONTROLTARGET_START, "Start", "Start", "0,1", NULL, },
  171. { IDCMD_CONTROLTARGET_PAUSE, "Pause", "Pause", NULL, NULL, },
  172. { IDCMD_CONTROLTARGET_STOP, "Stop", "Stop", NULL, NULL, },
  173. { IDCMD_CONTROLTARGET_STARTSELECTION, "StartSelection", "StartSelection", "0,1", &ThisClass::_GetParamForCommand_MachSelect, },
  174. { IDCMD_CONTROLTARGET_BREAKPOINTRESUME, "BPResume", "BPResume", "0,1", &ThisClass::_GetParamForCommand_BreakPointResume, },
  175. { IDCMD_CONTROLTARGET_STARTNEARPOINT, "NearStart", "NearStart", "0,1", &ThisClass::_GetParamForCommand_StartNearPoint, },
  176. { IDCMD_CONTROLTARGET_SIMULATE, "Simulate", "Simulate", "0,1", NULL, },
  177. { IDCMD_CONTROLTARGET_DIRRUN, "DirRun", "DirRun", "0,1", NULL, },
  178. { IDCMD_CONTROLTARGET_FOLLOWCONTROL, "FollowCtrl", "FollowCtrl", NULL, NULL, },
  179. { IDCMD_CONTROLTARGET_JOGFORWARD, "JogForward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_GoForward, },
  180. { IDCMD_CONTROLTARGET_INCFORWARD, "IncForward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_IncForward, },
  181. { IDCMD_CONTROLTARGET_JOGBACKWARD, "JogBackward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_GoBackward, },
  182. { IDCMD_CONTROLTARGET_INCBACKWARD, "IncBackward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_IncBackward, },
  183. { IDCMD_CONTROLTARGET_FORWARDBEGIN, "ForwardBegin", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_ForwardBegin, },
  184. { IDCMD_CONTROLTARGET_BACKWARDBEGIN, "BackwardBegin", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_BackwardBegin, },
  185. { IDCMD_CONTROLTARGET_FORWARDEND, "ForwardEnd", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_ForwardEnd, },
  186. { IDCMD_CONTROLTARGET_BACKWARDEND, "BackwardEnd", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_BackwardEnd, },
  187. // { IDCMD_CONTROLTARGET_STARTEDGEFIND, "StartAutoEdgeFind", "StartAutoEdgeFind", NULL, NULL },
  188. };
  189. m_vectorCommandItems.clear();
  190. m_vectorCommandItems = CommandItemVector(_s_CommandItems + 0, _s_CommandItems + _countof(_s_CommandItems));
  191. memset(m_KeyStates, 0, sizeof(KeyState) * _countof(m_KeyStates));
  192. static WSItem _s_WSItems[] =
  193. {
  194. { "DirRun", "DirRunSelection2", },
  195. { "Simulate", "SimulateSelection", },
  196. { "Start", "StartSelection", },
  197. };
  198. m_vectorWSItems.clear();
  199. m_vectorWSItems = WSItemsVector(_s_WSItems + 0, _s_WSItems + _countof(_s_WSItems));
  200. // ӳʼõ֧ ----  2015-06-12
  201. CString _strCT = NceGetPrivateProfileString(_T("ControlTarget"), NULL);
  202. CString _strSBD = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowBkrefDlg"));
  203. if (_strCT == "" || _strSBD == "0" || _strSBD == "false" || _strSBD == "False" || _strSBD == "FALSE")
  204. {
  205. m_bShowBkrefDlgWhenStart = FALSE;
  206. }
  207. m_bAutoZBkrefWhenStart = FALSE;
  208. CString _strEnableMotionAccel = NceGetPrivateProfileString(_T("ControlTarget"), _T("EnableMotionAccel"), _T("1"));
  209. if (_strEnableMotionAccel == _T("0"))
  210. {
  211. m_bEnableKeyMsg = false;
  212. }
  213. m_pwndControlDlg = NULL;
  214. m_bIsMinSize = false;
  215. LOAD_PARAM(this, CControlTarget);
  216. }
  217. CControlTarget::~CControlTarget()
  218. {
  219. ASSERT(ms_pControlTarget == this);
  220. ms_pControlTarget = NULL;
  221. SAVE_PARAM(this, CControlTarget);
  222. }
  223. void CControlTarget::Initialize()
  224. {
  225. // ûCommandManagerĬϲʾ ----  2012-06-22
  226. ASSERT(m_bShowControlDlg == true);
  227. if (!mach::GetCommandManager())
  228. {
  229. m_bShowControlDlg = true;
  230. }
  231. }
  232. bool CControlTarget::CanExecuteCommand(LPCSTR pszCommand_, LPCSTR pszParameter_)
  233. {
  234. ASSERT(pszCommand_ && pszCommand_[0]);
  235. bool _bCanExecute = false;
  236. CCommandManager* _pCommandManager = mach::GetCommandManager();
  237. if (!_pCommandManager
  238. || pszParameter_ && pszParameter_[0] && !_pCommandManager->CanExecute(pszCommand_, pszParameter_, "LPCSTR", &_bCanExecute)
  239. || (!pszParameter_ || !pszParameter_[0]) && !_pCommandManager->CanExecute(pszCommand_, &_bCanExecute))
  240. {
  241. return false;
  242. }
  243. return _bCanExecute;
  244. }
  245. bool CControlTarget::ExecuteCommand(LPCSTR pszCommand_, LPCSTR pszParameter_)
  246. {
  247. ASSERT(pszCommand_ && pszCommand_[0]);
  248. CCommandManager* _pCommandManager = mach::GetCommandManager();
  249. if (!_pCommandManager)
  250. {
  251. return false;
  252. }
  253. if (pszParameter_ && pszParameter_[0] && !_pCommandManager->Execute(pszCommand_, pszParameter_, "LPCSTR")
  254. || (!pszParameter_ || !pszParameter_[0]) && !_pCommandManager->Execute(pszCommand_))
  255. {
  256. return false;
  257. }
  258. return true;
  259. }
  260. void CControlTarget::OnNamedCommand(WPARAM wParam_, LPARAM lParam_)
  261. {
  262. const CStringA _c_strTargetName = "CControlTarget";
  263. if (_c_strTargetName != (PCSTR)wParam_)
  264. {
  265. return;
  266. }
  267. // ----  2012-04-13
  268. for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
  269. {
  270. const CommandItem& _item = m_vectorCommandItems[_i];
  271. if (_item.strName != (PCSTR)lParam_)
  272. {
  273. ASSERT(_i != m_vectorCommandItems.size() - 1);
  274. continue;
  275. }
  276. // ֮Բֱӵõӳһ飬ּھȷĶ
  277. // 壺ǸID͵һString͵ַ֣ʽ
  278. // ID͵ ----  2012-04-14
  279. OnCmdMsg(_item.nID, 0, NULL, NULL);
  280. break;
  281. }
  282. }
  283. void CControlTarget::OnShowControlDlg()
  284. {
  285. m_bShowControlDlg = !m_bShowControlDlg;
  286. UpdateAllVisions();
  287. }
  288. void CControlTarget::OnMinControlDlg()
  289. {
  290. ((CMachineControlDlg_Left*)m_pwndControlDlg)->OnMinSize();
  291. }
  292. void CControlTarget::OnMaxControlDlg()
  293. {
  294. ((CMachineControlDlg_Left*)m_pwndControlDlg)->OnMaxSize();
  295. }
  296. void CControlTarget::OnUpdateShowControlDlg(CCmdUI* pCmdUI_)
  297. {
  298. ASSERT(pCmdUI_);
  299. // ǰʾʱEnalbe˵ʹԲʾǰʾʱҪCommandManagerʱ
  300. // Enable˵Աʾ ----  2012-06-22
  301. bool _bEnable = m_bShowControlDlg || mach::GetCommandManager() != NULL;
  302. pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
  303. bool _bCheck = m_bShowControlDlg;
  304. pCmdUI_->SetCheck(_bCheck ? 1 : 0);
  305. }
  306. void CControlTarget::OnCommand(UINT nID_)
  307. {
  308. //ӹʱжϵǰӹͼѹǷ
  309. if (nID_ == IDCMD_CONTROLTARGET_START)
  310. {
  311. _SendGasPressureInfo();
  312. }
  313. //ϰLT汾,λʱ,޷ģ⹦ ---20170623
  314. if ((nID_ == IDCMD_CONTROLTARGET_SIMULATE) || (nID_ == IDCMD_CONTROLTARGET_BACKR))
  315. {
  316. CString _flag = NceGetPrivateProfileString(_T("ZPLimit"), _T("ZPLimitCheck"), _T("0"));
  317. CString _Portflag = NceGetPrivateProfileString(_T("ZPLimit"), _T("StopperPort"), _T("0"));
  318. if ("1" == _flag)
  319. {
  320. mach::CPortsManager* _pPortsManager = mach::GetPortsManager();
  321. BitPort _Port;
  322. ASSERT(_pPortsManager);
  323. if (_pPortsManager)
  324. {
  325. _pPortsManager->GetBitPort((LPCSTR)_Portflag, &_Port);
  326. if(_Port.bValue)
  327. {
  328. return;
  329. }
  330. }
  331. }
  332. }
  333. if ((nID_ == IDCMD_CONTROLTARGET_START
  334. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  335. || nID_ == IDCMD_CONTROLTARGET_SIMULATE))
  336. {
  337. CTubeTarget* _pTubeTarget = GetTubeTarget();
  338. ASSERT(_pTubeTarget);
  339. // ܲļ֧ڷǹܲ·/ӹ ---- yangxiaobin 2017-01-09
  340. if (_pTubeTarget->IsTubeFile() && !_pTubeTarget->IsEnable())
  341. {
  342. NceShowMessage(_GETCS(s_szCONFIG_TUBE_NOK));
  343. return;
  344. }
  345. }
  346. //ڵʱʱڣʼͿаťȡѭķֹͣѭӹ ----liangyan 2013-9-22
  347. if (nID_ == IDCMD_CONTROLTARGET_START || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
  348. {
  349. int m_nTimeRemain = 0;
  350. CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
  351. if (_pCycMachiningTarget->GetCountDownRemain(&m_nTimeRemain) && m_nTimeRemain > 0)
  352. {
  353. _pCycMachiningTarget->SetEnable(FALSE);
  354. return;
  355. }
  356. }
  357. if (nID_ == IDCMD_CONTROLTARGET_START
  358. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  359. || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  360. {
  361. mach::CParamManager* _pParamManager = mach::GetParamManager();
  362. ASSERT(_pParamManager);
  363. mach::ParameterValue _PV;
  364. memset(&_PV, 0, sizeof(mach::ParameterValue));
  365. _pParamManager->GetParameterValue("ForceHome", &_PV);
  366. ASSERT(_PV.nType = mach::ParameterValue::VT_BOOL);
  367. bool _bForceHome = _PV.bValue;
  368. memset(&_PV, 0, sizeof(mach::ParameterValue));
  369. _pParamManager->GetParameterValue("ChannelIsRefered", &_PV);
  370. ASSERT(_PV.nType = mach::ParameterValue::VT_BOOL);
  371. if (!_PV.bValue && _bForceHome)
  372. {
  373. AfxMessageBox(_GETCS(s_szFORSEHOMEBEFORBEGIN));
  374. return;
  375. }
  376. }
  377. // ----  2012-04-13
  378. size_t _nCmdIndex = m_vectorCommandItems.size();
  379. for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
  380. {
  381. const CommandItem& _item = m_vectorCommandItems[_i];
  382. if (nID_ != _item.nID)
  383. {
  384. continue;
  385. }
  386. _nCmdIndex = _i;
  387. break;
  388. }
  389. if (_nCmdIndex < 0 || m_vectorCommandItems.size() <= _nCmdIndex)
  390. {
  391. ASSERT(FALSE);
  392. return;
  393. }
  394. // ԤϢ ----  2016-09-07
  395. if (!m_vectorCommandItems[_nCmdIndex].strCommand.IsEmpty())
  396. {
  397. CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
  398. CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
  399. if (SendTargetMessage(ID_TARGET_BROADCAST, TM_COMMAND_PREEXECUTE, (WPARAM)(PCSTR)_strCommand, (LPARAM)(PCSTR)_strParameter) != 0L)
  400. {
  401. return;
  402. }
  403. }
  404. // ΪؼƣػеԭǰҪʾ ----  2012-04-14
  405. if (nID_ == IDCMD_CONTROLTARGET_BACKR
  406. || nID_ == IDCMD_CONTROLTARGET_XBACKR
  407. || nID_ == IDCMD_CONTROLTARGET_YBACKR
  408. || nID_ == IDCMD_CONTROLTARGET_ZBACKR)
  409. {
  410. if (AfxMessageBox(_GETCS(s_csBACKREFPROMPT), MB_OKCANCEL) != IDOK)
  411. return;
  412. }
  413. // ²߱߿ ---- η 2017-01-11
  414. if (nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  415. {
  416. CTubeTarget* _pTubeTarget = GetTubeTarget();
  417. if (_pTubeTarget && _pTubeTarget->IsEnable())
  418. {
  419. return;
  420. }
  421. }
  422. // жͼΣͼΪһ㣬߱߿ ---- ׿ 2012-02-23
  423. if (nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  424. {
  425. CFileTarget* _pFileTarget = GetFileTarget();
  426. ASSERT(_pFileTarget);
  427. nce::CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
  428. ASSERT(_pCurrentCadGroup);
  429. CStateManager* _pStateManager = GetStateManager();
  430. ASSERT(_pStateManager);
  431. DRECT _rcBound;
  432. if (_pStateManager->IsSelectedMach())
  433. {
  434. CSelectTarget* _pSelectTarget = GetSelectTarget();
  435. ASSERT(_pSelectTarget);
  436. const CadObjectList* _plistSelectObjs = _pSelectTarget->GetSelectedCadObjects();
  437. _rcBound = _plistSelectObjs && _plistSelectObjs->size() > 0 ? _pSelectTarget->GetSelObjsBoundRect() : DRECT(0.0, 0.0, 0.0, 0.0);
  438. }
  439. else
  440. {
  441. _rcBound = _pCurrentCadGroup->GetBoundRect();
  442. }
  443. if (_rcBound.width <= 0.0 && _rcBound.height <= 0.0)
  444. {
  445. NceShowMessage(_GETCS(s_szNOAVALIBLEOBJECTTOMACH));
  446. return;
  447. }
  448. }
  449. // ѭӹֹͣٿʼʾǷѭӹѭӹ굱ǰ
  450. // ӹˡ ---- ƺ 2016-03-16
  451. if (nID_ == IDCMD_CONTROLTARGET_START
  452. || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
  453. {
  454. CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
  455. if (_pCycMachiningTarget
  456. && _pCycMachiningTarget->GetEnable()
  457. && _pCycMachiningTarget->GetCycTimes() - 1 > _pCycMachiningTarget->GetCycDones()
  458. && (_pCycMachiningTarget->IsInterrupt()
  459. || _pCycMachiningTarget->GetCycDones() == 0)
  460. && NceGetPrivateProfileString(_T("ControlTarget"), _T("CycStartPrompt")) == _T("1"))
  461. {
  462. CContineCyclicalMachDlg* _pwndDlg = GetContineCyclicalMachDlg();
  463. ASSERT(_pwndDlg);
  464. if (_pwndDlg->DoModal() == IDCANCEL)
  465. return;
  466. }
  467. }
  468. // ʼӹʱԶԵǰΪͣ ----  2014-04-28
  469. // ʼӹʱԶִ
  470. // ʼӹ߱߿򡢿նж ---- DingQiang 2015-06-09
  471. static DWORD _s_nLastTime = ::GetTickCount();
  472. mach::CStateManager::State _nState = mach::CStateManager::Invalid;
  473. if ((nID_ == IDCMD_CONTROLTARGET_START
  474. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  475. || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  476. && mach::GetStateManager()->GetState(&_nState)
  477. && _nState == mach::CStateManager::Idle
  478. && NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoClearW")) == _T("1"))
  479. {
  480. // νʱ300msĻͲˣΪ˽ֱָԻ⡣
  481. // ͨʽǺܺãʱʵPLCдֱϢٵPLCд
  482. // ---- ƺ 2015-10-10
  483. CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
  484. CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
  485. DWORD _nCurTime = ::GetTickCount();
  486. DWORD _nSpaceTime = _nCurTime - _s_nLastTime;
  487. bool _bSmallInterval = false;
  488. if (_nSpaceTime < 300 && _s_nLastTime != _nCurTime)
  489. {
  490. _bSmallInterval = true;
  491. }
  492. _s_nLastTime = _nCurTime;
  493. if (CanExecuteCommand(_strCommand, _strParameter) && !_bSmallInterval)
  494. OnCmdMsg(IDCMD_CONTROLTARGET_CLEARW, 0, NULL, NULL);
  495. }
  496. // ʼӹ桢Сѡӹ֮ǰʾļ ----  2012-04-14
  497. if (nID_ == IDCMD_CONTROLTARGET_START
  498. || nID_ == IDCMD_CONTROLTARGET_SIMULATE
  499. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  500. || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
  501. || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME
  502. || nID_ == IDCMD_CONTROLTARGET_JOGFORWARD
  503. || nID_ == IDCMD_CONTROLTARGET_INCFORWARD
  504. || nID_ == IDCMD_CONTROLTARGET_JOGBACKWARD
  505. || nID_ == IDCMD_CONTROLTARGET_INCBACKWARD
  506. || nID_ == IDCMD_CONTROLTARGET_FORWARDBEGIN
  507. || nID_ == IDCMD_CONTROLTARGET_BACKWARDBEGIN
  508. || nID_ == IDCMD_CONTROLTARGET_FORWARDEND
  509. || nID_ == IDCMD_CONTROLTARGET_BACKWARDEND
  510. || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT
  511. || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  512. {
  513. if (!_CheckFileSaved())
  514. return;
  515. }
  516. // ûмӹļʱ򣬶ϵǰ˲ ---- ž 2012-05-25
  517. ASSERT(GetFileTarget());
  518. if (GetFileTarget()->GetCurrentCadGroup()->GetNumOfChild() <= 0)
  519. {
  520. #define _PromptEmpty(Id, Action) \
  521. if (nID_ == Id) \
  522. { \
  523. CString _strPrompt; \
  524. _strPrompt.Format(_GETCS(s_csNoObjInFileForAction), Action); \
  525. NceShowMessage(_strPrompt); \
  526. return; \
  527. }
  528. _PromptEmpty(IDCMD_CONTROLTARGET_BREAKPOINTRESUME, _GETCS(s_csBreakPointResume));
  529. _PromptEmpty(IDCMD_CONTROLTARGET_JOGFORWARD, _GETCS(s_csGoForward));
  530. _PromptEmpty(IDCMD_CONTROLTARGET_INCFORWARD, _GETCS(s_csGoForward));
  531. _PromptEmpty(IDCMD_CONTROLTARGET_FORWARDBEGIN, _GETCS(s_csGoForward));
  532. _PromptEmpty(IDCMD_CONTROLTARGET_FORWARDEND, _GETCS(s_csGoForward));
  533. _PromptEmpty(IDCMD_CONTROLTARGET_JOGBACKWARD, _GETCS(s_csGoBackward));
  534. _PromptEmpty(IDCMD_CONTROLTARGET_INCBACKWARD, _GETCS(s_csGoBackward));
  535. _PromptEmpty(IDCMD_CONTROLTARGET_BACKWARDBEGIN, _GETCS(s_csGoBackward));
  536. _PromptEmpty(IDCMD_CONTROLTARGET_BACKWARDEND, _GETCS(s_csGoBackward));
  537. #undef _PromptEmpty
  538. }
  539. // ӹǷ񳬹λ ---- ƺ 2015-09-29
  540. ASSERT(m_vectorCommandItems[_nCmdIndex].nID == nID_);
  541. CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
  542. CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
  543. if (nID_ == IDCMD_CONTROLTARGET_START
  544. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  545. || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
  546. || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME
  547. || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT
  548. || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  549. {
  550. if (_IsOutsideTheSotfLimit(_strParameter))
  551. {
  552. NceShowMessage(_GETCS(s_csEXCEEDWORKTABLE));
  553. return;
  554. }
  555. }
  556. //зʱֻдʾǻӹ-----20170714
  557. if (nID_ == IDCMD_CONTROLTARGET_SIMULATE)
  558. {
  559. bool _bSimOutRange = false;
  560. if (_IsOutsideTheSotfLimit(_strParameter))
  561. {
  562. _bSimOutRange = true;
  563. }
  564. CString _strSimOutRange("SimOutRange");
  565. SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strSimOutRange.GetBuffer()), (LPARAM)&_bSimOutRange);
  566. }
  567. // ߱߿ܾε֧ͼιԼӹѡйܣӹλжѾһʱעͣжϺͳһ ----˼ 2017-06-14
  568. // ߱߿ڲǼӹȫͼΣҲǼӹѡͼΣҪλ
  569. //if(nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
  570. //{
  571. // if (_IsRectOutsideTheSotfLimit(_strParameter))
  572. // {
  573. // NceShowMessage(_GETCS(s_csEXCEEDWORKTABLE));
  574. // return;
  575. // }
  576. //}
  577. // ʼӹǰ֪ͨģ׼еǰͼȡ ----ƺ 2015-05-27
  578. CString _strAutoAdjust = NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoAdjustView"));
  579. if ((nID_ == IDCMD_CONTROLTARGET_START
  580. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  581. || nID_ == IDCMD_CONTROLTARGET_SIMUCUT
  582. || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME)
  583. && _strAutoAdjust == _T("1"))
  584. {
  585. SendTargetMessage(ID_TARGET_VIEWPORTADJUST, TN_TASKSTART);
  586. SendTargetMessage(ID_TARGET_TUBE, TN_TASKSTART);
  587. }
  588. // ڹܲãʼӹͼֲͬ ---- η 2016-12-30
  589. if (nID_ == IDCMD_CONTROLTARGET_SIMULATE && _strAutoAdjust == _T("1"))
  590. {
  591. SendTargetMessage(ID_TARGET_VIEWPORTADJUST, TN_TASKSTART);
  592. SendTargetMessage(ID_TARGET_TUBE, TN_TASKSTART_SIMULATE);
  593. }
  594. // 統ǰΪѡӹӦѡӹָ ---- ƺ 2016-09-27
  595. if (nID_ == IDCMD_CONTROLTARGET_START
  596. || nID_ == IDCMD_CONTROLTARGET_SIMULATE
  597. || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
  598. {
  599. // ͣʱÿʼָѡӹ ---- ƺ 2016-09-06
  600. CStateManager* _pStateManager = GetStateManager();
  601. ASSERT(_pStateManager);
  602. mach::CStateManager::State _nState = CStateManager::Idle;
  603. if(_pStateManager->GetState(&_nState)
  604. && _nState != CStateManager::Pausing
  605. && _pStateManager->IsSelectedMach())
  606. {
  607. ASSERT(_strParameter.IsEmpty());
  608. _strParameter = _GetParamForCommand_MachSelect();
  609. if (_strParameter.IsEmpty())
  610. {
  611. NceShowMessage(_GETCS(s_szNOAVALIBLEOBJECTTOMACH));
  612. return;
  613. }
  614. for (int _i = 0; _i < (int)m_vectorWSItems.size(); _i++)
  615. {
  616. if (_strCommand != m_vectorWSItems[_i].strWholeMachCommand)
  617. continue;
  618. _strCommand = m_vectorWSItems[_i].strSelectMachCommand;
  619. break;
  620. }
  621. }
  622. }
  623. if (nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME)
  624. {
  625. for (int _i = 0; _i < (int)m_vectorWSItems.size(); _i++)
  626. {
  627. // һξѡӹֱӵһָ ---- ƺ 2016-09-03
  628. if (m_vectorWSItems[_i].strSelectMachCommand == m_strLastTaskCommand)
  629. {
  630. _strCommand = m_strLastTaskCommand;
  631. break;
  632. }
  633. // һӹѡӹָʵ֡ ---- ƺ 2016-09-03
  634. if (m_vectorWSItems[_i].strWholeMachCommand == m_strLastTaskCommand)
  635. {
  636. _strCommand = m_vectorWSItems[_i].strSelectMachCommand;
  637. break;
  638. }
  639. }
  640. }
  641. // ʵӹͿвֶ֧ϵ ---- ƺ 2016-09-03
  642. if (nID_ == IDCMD_CONTROLTARGET_START
  643. || nID_ == IDCMD_CONTROLTARGET_DIRRUN
  644. || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
  645. || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT)
  646. {
  647. m_strLastTaskCommand = _strCommand;
  648. m_strLastTaskCommandParam = _strParameter;
  649. }
  650. // ǰȼʾԤʱ ----  2016-10-11
  651. if (nID_ == IDCMD_CONTROLTARGET_START
  652. || nID_ == IDCMD_CONTROLTARGET_SIMULATE)
  653. {
  654. CalculateOneHoleTime();
  655. CTubeTarget* _pTubeTarget = GetTubeTarget();
  656. ASSERT(_pTubeTarget);
  657. if (!_pTubeTarget->IsEnable())
  658. {
  659. // ܲòʾ
  660. AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_RUNREPORTTARGET_SHOWESTIMATION);
  661. // Fix TFS work item #2739 to enable shortcut keys
  662. AfxGetMainWnd()->SetFocus();
  663. }
  664. }
  665. // ¼һ¶ϵλá
  666. if ((nID_ != IDCMD_CONTROLTARGET_BREAKPOINTRESUME && _strCommand == _T("StartSelection")) ||
  667. (nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT && _strCommand == _T("NearStart")))
  668. {
  669. NceFilePos _nPos = _SelectionFirst(_strParameter);
  670. CStateManager* _pStateManager = GetStateManager();
  671. _pStateManager->SetSelectedMachFilePos(_nPos);
  672. }
  673. // ----  2012-04-14
  674. ExecuteCommand(_strCommand, _strParameter);
  675. }
  676. void CControlTarget::OnUpdateCommandUI(CCmdUI* pCmdUI_)
  677. {
  678. // ----  2012-04-13
  679. size_t _nCmdIndex = m_vectorCommandItems.size();
  680. for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
  681. {
  682. const CommandItem& _item = m_vectorCommandItems[_i];
  683. if (pCmdUI_->m_nID != _item.nID)
  684. {
  685. continue;
  686. }
  687. _nCmdIndex = _i;
  688. break;
  689. }
  690. if (_nCmdIndex < 0 || m_vectorCommandItems.size() <= _nCmdIndex)
  691. {
  692. // ˭ֽ ----  2012-08-06
  693. ASSERT(FALSE);
  694. return;
  695. }
  696. // ----  2012-04-14
  697. bool _bEnable = false;
  698. ASSERT(m_vectorCommandItems[_nCmdIndex].nID == pCmdUI_->m_nID);
  699. CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
  700. CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].strCEParameter;
  701. _bEnable = CanExecuteCommand(_strCommand, _strParameter);
  702. static const struct RunningStateItem
  703. {
  704. UINT nID;
  705. DWORD nMask;
  706. } _s_cItem[] =
  707. {
  708. {IDCMD_CONTROLTARGET_START, 0x00000001},
  709. {IDCMD_CONTROLTARGET_SIMULATE, 0x00000002},
  710. {IDCMD_CONTROLTARGET_DIRRUN, 0x00000004},
  711. {IDCMD_CONTROLTARGET_SIMUCUT, 0x00000008},
  712. {IDCMD_CONTROLTARGET_BACKR, 0x00000010},
  713. {IDCMD_CONTROLTARGET_BACKW, 0x00000020},
  714. {IDCMD_CONTROLTARGET_MOVETOFIXPOS, 0x00000040},
  715. {IDCMD_CONTROLTARGET_PAUSE, 0},
  716. };
  717. for (int _i = 0; _i < _countof(_s_cItem); _i++)
  718. {
  719. if (pCmdUI_->m_nID == _s_cItem[_i].nID)
  720. {
  721. CStateManager* _pStateManager = GetStateManager();
  722. if (!_pStateManager)
  723. {
  724. break;
  725. }
  726. BOOL _bCheck = FALSE;
  727. if (pCmdUI_->m_nID == IDCMD_CONTROLTARGET_PAUSE)
  728. {
  729. // ͣ
  730. mach::CStateManager::State _nState = CStateManager::Idle;
  731. if(_pStateManager->GetState(&_nState) && _nState == CStateManager::Pausing)
  732. {
  733. _bCheck = TRUE;
  734. }
  735. }
  736. else
  737. {
  738. DWORD _nRunningState = 0;
  739. _pStateManager->GetRunningState(&_nRunningState);
  740. _bCheck = _nRunningState & _s_cItem[_i].nMask;
  741. }
  742. // ߱߿򲻿 ---- η 2017-01-11
  743. if (pCmdUI_->m_nID == IDCMD_CONTROLTARGET_SIMUCUT)
  744. {
  745. CTubeTarget* _pTubeTarget = GetTubeTarget();
  746. if (_pTubeTarget && _pTubeTarget->IsEnable())
  747. {
  748. _bEnable = FALSE;
  749. }
  750. }
  751. if (_bEnable)
  752. {
  753. pCmdUI_->SetCheck(FALSE);
  754. pCmdUI_->Enable();
  755. return;
  756. }
  757. if (_bCheck)
  758. {
  759. pCmdUI_->SetCheck();
  760. }
  761. else
  762. {
  763. pCmdUI_->SetCheck(FALSE);
  764. pCmdUI_->Enable(_bEnable);
  765. }
  766. return;
  767. }
  768. }
  769. pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
  770. }
  771. // ð취
  772. // [Detect2YError]
  773. // Enable="1"
  774. // Subprogram="BKREF-2YERROR-DETECT"
  775. // УEnableڱʾǷ ˫Yƫ⣬SubprogramΪ˫Yƫӳ
  776. // ----  2012-06-21
  777. void CControlTarget::OnDetect2YError()
  778. {
  779. CString _strEnable = NceGetPrivateProfileString(_T("Detect2YError"), _T("Enable"), _T("0"));
  780. _strEnable.Trim();
  781. if (_strEnable == _T("0"))
  782. {
  783. ASSERT(FALSE);
  784. return;
  785. }
  786. // ȡӳRunGCode ----  2012-06-21
  787. CStringA _strSubprogram = NceGetPrivateProfileString(_T("Detect2YError"), _T("Subprogram"));
  788. if (_strSubprogram.IsEmpty())
  789. {
  790. ASSERT(FALSE);
  791. return;
  792. }
  793. // ʾȷ ----  2012-06-21
  794. if (AfxMessageBox(_GETCS(s_csOperateDangerous), MB_YESNO) != IDYES)
  795. {
  796. return;
  797. }
  798. // ִм ----  2012-06-21
  799. CStringA _strGCode;
  800. _strGCode.Format("G65 P\"%s\" L1\n", _strSubprogram);
  801. ExecuteCommand("RunGCode", _strGCode);
  802. }
  803. // ð취
  804. // [Detect2YError]
  805. // Enable="1"
  806. // Subprogram="BKREF-2YERROR-DETECT"
  807. // УEnableڱʾǷ ˫Yƫ⣬ʾ˵ĬΪá
  808. // ----  2012-06-21
  809. void CControlTarget::OnUpdateDetect2YError(CCmdUI* pCmdUI_)
  810. {
  811. ASSERT(pCmdUI_);
  812. if (pCmdUI_->m_pMenu)
  813. {
  814. CString _strEnable = NceGetPrivateProfileString(_T("Detect2YError"), _T("Enable"), _T("0"));
  815. _strEnable.Trim();
  816. if (_strEnable == _T("0"))
  817. {
  818. pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
  819. return;
  820. }
  821. }
  822. // ȡӳжǷRunGCode ----  2012-06-21
  823. CStringA _strSubprogram = NceGetPrivateProfileString(_T("Detect2YError"), _T("Subprogram"));
  824. if (_strSubprogram.IsEmpty())
  825. {
  826. pCmdUI_->Enable(FALSE);
  827. return;
  828. }
  829. CStringA _strGCode;
  830. _strGCode.Format("G65 P\"%s\" L1\n", _strSubprogram);
  831. if (!CanExecuteCommand("RunGCode", _strGCode))
  832. {
  833. pCmdUI_->Enable(FALSE);
  834. return;
  835. }
  836. pCmdUI_->Enable(TRUE);
  837. }
  838. void CControlTarget::OnClearW()
  839. {
  840. // ͨActionɣԱɳ ----  2012-03-30
  841. SendTargetMessage(ID_TARGET_SETORIGIN, TN_SETORIGIN, 0, 0);
  842. CClearWorkcoorAction::Do(TRUE); // ɳ
  843. }
  844. void CControlTarget::OnUpdateClearW(CCmdUI* pCmdUI_)
  845. {
  846. bool _bCanExecute = CanExecuteCommand("ClearW", NULL);
  847. pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
  848. }
  849. void CControlTarget::OnClearWZ()
  850. {
  851. CClearWorkcoorActionZ::Do(TRUE);
  852. }
  853. void CControlTarget::OnUpdateClearWZ(CCmdUI* pCmdUI_)
  854. {
  855. // ӹʱҲֶZĹԭ㡣 ---- ƺ 2014-12-23
  856. CStateManager* _pStateManager = GetStateManager();
  857. CStateManager::State _nState = CStateManager::Idle;
  858. bool _bCanExecute = _pStateManager
  859. && _pStateManager->GetState(&_nState)
  860. && (_nState == CStateManager::Idle
  861. || _nState == CStateManager::Estop
  862. || _nState == CStateManager::Invalid)
  863. && CanExecuteCommand("ClearWZ", NULL);
  864. pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
  865. }
  866. void CControlTarget::OnStop()
  867. {
  868. ASSERT(!CanExecuteCommand("Stop", NULL) || !CanExecuteCommand("StopSimulate", NULL));
  869. if (CanExecuteCommand("Stop", NULL))
  870. {
  871. ExecuteCommand("Stop", NULL);
  872. }
  873. if (CanExecuteCommand("StopSimulate", NULL))
  874. {
  875. ExecuteCommand("StopSimulate", NULL);
  876. }
  877. }
  878. void CControlTarget::OnUpdateStop(CCmdUI* pCmdUI_)
  879. {
  880. ASSERT(!CanExecuteCommand("Stop", NULL) || !CanExecuteCommand("StopSimulate", NULL));
  881. bool _bCanExecute = CanExecuteCommand("Stop", NULL) || CanExecuteCommand("StopSimulate", NULL);
  882. bool _bBoardSupport = NceGetPrivateProfileString(_T("ControlTarget"), _T("BoardSupport")) == _T("1");
  883. // ϶˿ڴʱͷһ״̬ԻʹstopstopsimulateͬʱΪtrue
  884. // Ϊ˶϶˿ڴ򿪵ʱֹֹͣʱһжϽ⣬ӦĽ----2017.06.27 ˼
  885. if (_bBoardSupport)
  886. {
  887. mach::CPortsManager* _pPortsManager = mach::GetPortsManager();
  888. mach::BitPort _BitPort;
  889. _pPortsManager->GetBitPort("10038", &_BitPort);
  890. if (_BitPort.bValue)
  891. {
  892. _bCanExecute = false;
  893. }
  894. }
  895. pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
  896. }
  897. void CControlTarget::OnBackRDlg()
  898. {
  899. CBkrefDlg _dlg;
  900. _dlg.m_bShowBkrefDlgWhenStart = m_bShowBkrefDlgWhenStart;
  901. _dlg.m_bAutoZBkrefWhenStart = m_bAutoZBkrefWhenStart;
  902. _dlg.DoModal();
  903. m_bShowBkrefDlgWhenStart = _dlg.m_bShowBkrefDlgWhenStart;
  904. m_bAutoZBkrefWhenStart = _dlg.m_bAutoZBkrefWhenStart;
  905. }
  906. void CControlTarget::OnUpdateBackRDlg(CCmdUI* pCmdUI_)
  907. {
  908. }
  909. void CControlTarget::OnUpdateZBackOrg(CCmdUI* pCmdUI_)
  910. {
  911. bool _bShow = NceGetPrivateProfileString(_T("ControlTarget"), _T("EnableZ"), " ") == "1";
  912. if (pCmdUI_->m_pMenu && !_bShow)
  913. {
  914. pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
  915. }
  916. pCmdUI_->Enable(CanExecuteCommand("BackRZ", "Z"));
  917. }
  918. void CControlTarget::OnUpdateFollowCtrl(CCmdUI* pCmdUI_)
  919. {
  920. bool _bEnable = CanExecuteCommand("FollowCtrl", NULL);
  921. pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
  922. if (pCmdUI_->m_pMenu && !_bEnable)
  923. {
  924. pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
  925. }
  926. }
  927. void CControlTarget::OnIsMachSelected()
  928. {
  929. CStateManager* _pStateManager = GetStateManager();
  930. ASSERT(_pStateManager);
  931. BOOL _bMachSelected = _pStateManager->IsSelectedMach();
  932. _bMachSelected = !_bMachSelected;
  933. _pStateManager->SetSelectedMach(_bMachSelected);
  934. //üӹѡͼǷѡflagCMachineControlDlgͬ----20170712
  935. ((CMachineControlDlg*)m_pwndControlDlg)->SetSelectMach(_bMachSelected);
  936. }
  937. void CControlTarget::OnUpdateIsMachSelected(CCmdUI* pCmd_)
  938. {
  939. CStateManager* _pStateManager = GetStateManager();
  940. CStateManager::State _nState = CStateManager::Idle;
  941. bool _bEnable = _pStateManager
  942. && _pStateManager->GetState(&_nState)
  943. && _nState == CStateManager::Idle;
  944. pCmd_->SetCheck(_pStateManager && _pStateManager->IsSelectedMach());
  945. pCmd_->Enable(_bEnable);
  946. }
  947. void CControlTarget::OnUpdateStartSelectNotMove(CCmdUI* pCmd_)
  948. {
  949. CStateManager* _pStateManager = GetStateManager();
  950. CStateManager::State _nState = CStateManager::Idle;
  951. bool _bEnable = _pStateManager
  952. && _pStateManager->GetState(&_nState)
  953. && _nState == CStateManager::Idle
  954. && CanExecuteCommand("StartSelection", "0,1");
  955. pCmd_->Enable(_bEnable);
  956. }
  957. // ʱVision ----  2012-04-17
  958. void CControlTarget::OnEvery40Millisecond(WPARAM wParam_, LPARAM lParam_)
  959. {
  960. _DoTraceKeyState();
  961. // Every 160 Millisecond ----  2012-04-17
  962. static int _s_nTimerCount = rand();
  963. _s_nTimerCount = (_s_nTimerCount + 1) % 4;
  964. if (_s_nTimerCount == 0)
  965. {
  966. UpdateVisions();
  967. }
  968. }
  969. void CControlTarget::OnPostInitInstance(WPARAM wParam_, LPARAM lParam_)
  970. {
  971. if (m_bShowBkrefDlgWhenStart)
  972. {
  973. CWnd* _pMainWnd = AfxGetMainWnd();
  974. ASSERT(_pMainWnd);
  975. _pMainWnd->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_BACKRDLG, 0L);
  976. }
  977. if (m_bAutoZBkrefWhenStart)
  978. {
  979. // ֱӵִУCMDϢִлᵯһȷ϶Ի ---- DingQiang 2016-09-18
  980. ExecuteCommand("BackRZ", NULL);
  981. }
  982. bool _bCheckWPosition = (NceGetPrivateProfileString(_T("ExchangeWorkbench"), _T("Enable"), _T("0")) == "1");
  983. if (_bCheckWPosition)
  984. {
  985. CWnd* _pMainWnd = AfxGetMainWnd();
  986. ASSERT(_pMainWnd);
  987. _pMainWnd->SendMessage(WM_COMMAND, IDCMD_EXCHANGEWORKBENCHTARGET_CHECKWPOSITION, 0L);
  988. }
  989. }
  990. void CControlTarget::OnDirectSet()
  991. {
  992. // XYͨеԭ־ ---- ƺ 2015-01-04
  993. if (CanExecuteCommand("DirectSet", NULL))
  994. {
  995. ExecuteCommand("DirectSet", NULL);
  996. }
  997. // Zͨеԭ־ ---- ƺ 2015-01-04
  998. if (CanExecuteCommand("DirectSetZ", NULL))
  999. {
  1000. ExecuteCommand("DirectSetZ", NULL);
  1001. }
  1002. }
  1003. void CControlTarget::OnUpdateDirectSet(CCmdUI* pCmdUI_)
  1004. {
  1005. bool _bCanExecute = CanExecuteCommand("DirectSet", NULL) || CanExecuteCommand("DirectSetZ", NULL);
  1006. pCmdUI_->Enable(_bCanExecute);
  1007. }
  1008. bool CControlTarget::_CheckFileSaved()
  1009. {
  1010. CFileTarget* _pFileTarget = GetFileTarget();
  1011. ASSERT(_pFileTarget);
  1012. if (!_pFileTarget->IsModified()) // ѱ
  1013. {
  1014. return true;
  1015. }
  1016. bool _bNeedPrompt;
  1017. // ȡiniļIJ---- DingQiang 2012-05-07
  1018. CString _strTranslateType = NceGetPrivateProfileString(_T("ControlTarget"), _T("NeedPromptSave"));
  1019. int _nTranslateType = atoi(_strTranslateType);
  1020. switch (_nTranslateType)
  1021. {
  1022. case 0: _bNeedPrompt = false; break;
  1023. case 1: _bNeedPrompt = true; break;
  1024. default: ASSERT(FALSE); _bNeedPrompt = true;
  1025. }
  1026. if (!_bNeedPrompt)
  1027. {
  1028. AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_FILETARGET_SAVE_WITHOUTDIALOG);
  1029. if (!_pFileTarget->IsModified())
  1030. {
  1031. return true;
  1032. }
  1033. else
  1034. return false;
  1035. }
  1036. else
  1037. {
  1038. if (AfxMessageBox(_GETCS(s_csFileChanged), MB_YESNO) == IDYES) // ʾ
  1039. {
  1040. AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_FILETARGET_SAVE);
  1041. if (!_pFileTarget->IsModified())
  1042. {
  1043. return true;
  1044. }
  1045. else
  1046. {
  1047. return false;
  1048. }
  1049. }
  1050. else // ʾˣ
  1051. {
  1052. ASSERT(_pFileTarget->IsModified());
  1053. return false;
  1054. }
  1055. }
  1056. }
  1057. bool CControlTarget::_CheckWorktable()
  1058. {
  1059. // ǰcamӾ ---- DingQiang 2015-09-30
  1060. CFileTarget* _pFileTarget = GetFileTarget();
  1061. ASSERT(_pFileTarget);
  1062. static CSimuCutHelper _s_SimuCutHelper;
  1063. DRECT _rcBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
  1064. // ̨ ---- DingQiang 2015-09-30
  1065. double _pWorktable[4];
  1066. DRECT _rcWorktable;
  1067. SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
  1068. _rcWorktable.x = _pWorktable[0];
  1069. _rcWorktable.y = _pWorktable[1];
  1070. _rcWorktable.width = _pWorktable[2];
  1071. _rcWorktable.height = _pWorktable[3];
  1072. return _rcWorktable.Contains(_rcBound);
  1073. }
  1074. // ߱߿Gָ ----  2012-04-14
  1075. CStringA CControlTarget::_GetParamForCommand_SimuCut()
  1076. {
  1077. // ǰͼεӾ ----  2012-04-14
  1078. CStateManager* _pStateManager = GetStateManager();
  1079. ASSERT(_pStateManager);
  1080. DRECT _rcBound;
  1081. DRECT _rcBoundLast;
  1082. if (_pStateManager->IsSelectedMach())
  1083. {
  1084. CFileTarget* _pFileTarget = GetFileTarget();
  1085. ASSERT(_pFileTarget);
  1086. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1087. CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
  1088. if (NULL == _pCamGroup || NULL == _pCadGroup)
  1089. {
  1090. return "";
  1091. }
  1092. if (_pCamGroup->GetNumOfChild() <= 0 || _pCadGroup->GetNumOfChild() <= 0)
  1093. {
  1094. return "";
  1095. }
  1096. // ѡмӹֱѡCAM ---- η 2017-06-08
  1097. bool _bFirstRect = true;
  1098. CamObjectList* _plistCamObjs = _pCamGroup->GetObjectsList();
  1099. for (CamObjectList::const_iterator _it = _plistCamObjs->begin(); _it != _plistCamObjs->end(); _it++)
  1100. {
  1101. // ҪغϵCAM
  1102. CCamObject* _pCam = *_it;
  1103. CCadObject* _pCad = NULL;
  1104. // CamеCadIDҵӦCad
  1105. bool _bFound = _FindObjectByID(_pCadGroup, (int)_pCam->GetKey_DBL("CadID"), &_pCad);
  1106. ASSERT(_bFound);
  1107. // TFS#4040 - ѡмӹͼ߱߿ɾijͼΣ߱߿򽫷false ---- yangxiaobin
  1108. if (!_bFound)
  1109. continue;
  1110. if (_pCad!=NULL && _pCad->IsSelected())
  1111. {
  1112. static CSimuCutHelper _s_SimuCutHelper;
  1113. _rcBoundLast = _s_SimuCutHelper._GetBoundRect_Object(_pCam);
  1114. if (_bFirstRect)
  1115. {
  1116. _rcBound = _rcBoundLast;
  1117. _bFirstRect = false;
  1118. }
  1119. else
  1120. {
  1121. DRECT::Union(_rcBound, _rcBound, _rcBoundLast);
  1122. }
  1123. }
  1124. }
  1125. }
  1126. else
  1127. {
  1128. CFileTarget* _pFileTarget = GetFileTarget();
  1129. ASSERT(_pFileTarget);
  1130. static CSimuCutHelper _s_SimuCutHelper;
  1131. _rcBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
  1132. }
  1133. if (_rcBound.width < 0.0 || _rcBound.height < 0.0)
  1134. {
  1135. return "";
  1136. }
  1137. // ʱ߱߿
  1138. DPOINT2 _ptCor[] = // Corner
  1139. {
  1140. DPOINT2(_rcBound.GetLeft(), _rcBound.GetBottom()),
  1141. DPOINT2(_rcBound.GetRight(), _rcBound.GetBottom()),
  1142. DPOINT2(_rcBound.GetRight(), _rcBound.GetTop()),
  1143. DPOINT2(_rcBound.GetLeft(), _rcBound.GetTop()),
  1144. };
  1145. // Ѳ߶λӾο ---- ׿ 2012.11.14
  1146. CWCSAdjustTarget* _pWCSAdjustTarget = GetWCSAdjustTarget();
  1147. if (_pWCSAdjustTarget)
  1148. {
  1149. for (int _i = 0; _i < _countof(_ptCor); _i++)
  1150. {
  1151. _ptCor[_i] = _pWCSAdjustTarget->DoWCSAdjust(_ptCor[_i]);
  1152. }
  1153. }
  1154. // ᵱǰλʼ ----  2012-04-14
  1155. size_t _nBSI = 0; // BestStartIndex
  1156. if (CParamManager* _pParamManager = GetParamManager())
  1157. {
  1158. DPOINT2 _ptCurrentPos;
  1159. ParameterValue _ParameterValueAxis0;
  1160. ParameterValue _ParameterValueAxis1;
  1161. _pParamManager->GetParameterValue("State_Axis0_WorkcoorPos", &_ParameterValueAxis0);
  1162. _pParamManager->GetParameterValue("State_Axis1_WorkcoorPos", &_ParameterValueAxis1);
  1163. if ((_ParameterValueAxis0.nType == ParameterValue::VT_DOUBLE)
  1164. &&(_ParameterValueAxis1.nType == ParameterValue::VT_DOUBLE))
  1165. {
  1166. _ptCurrentPos.x = _ParameterValueAxis0.dValue;
  1167. _ptCurrentPos.y = _ParameterValueAxis1.dValue;
  1168. double _nBestDistance = DBL_MAX;
  1169. for (size_t _i = 0; _i < _countof(_ptCor); _i++)
  1170. {
  1171. double _nDistance = (_ptCor[_i] - _ptCurrentPos).GetLength();
  1172. if (_nDistance < _nBestDistance)
  1173. {
  1174. _nBSI = _i;
  1175. _nBestDistance = _nDistance;
  1176. }
  1177. }
  1178. }
  1179. }
  1180. // ñڱҪ߱߿ͼεӾɵG ---- ׿ 2012-02-24
  1181. CStringA _strGCode = "";
  1182. // ԱRunCodeʱ֪ʲô
  1183. _strGCode.Append("'Command=SimuCut\n");
  1184. // дʱʹÿɵCodeDzһ
  1185. SYSTEMTIME _t;
  1186. GetLocalTime(&_t);
  1187. _strGCode.AppendFormat("'Time=%d-%02d-%02d %02d:%02d:%02d\n", _t.wYear, _t.wMonth, _t.wDay, _t.wHour, _t.wMinute, _t.wSecond);
  1188. // ִ߱߿ǰһЩ涯򿪹ر涯ȡ ---- ƺ 2015-10-11
  1189. CStringA _strPreSubPro = NceGetPrivateProfileString(_T("ControlTarget"), _T("PreSimuCutActions"));
  1190. if (!_strPreSubPro.IsEmpty())
  1191. {
  1192. CStringA _strPreActions;
  1193. _strPreActions.Format("G65 P\"%s\" L1\n", _strPreSubPro);
  1194. _strGCode.AppendFormat(_strPreActions);
  1195. }
  1196. // ߱߿ٶ
  1197. CStringA _strG = "G00";
  1198. CStringA _strF = "";
  1199. CString _strSimuCutSpeed = NceGetPrivateProfileString(_T("ControlTarget"), _T("SimuCutSpeed"));
  1200. if (!_strSimuCutSpeed.IsEmpty())
  1201. {
  1202. _strG = "G905 G00";
  1203. _strF.Format("F=%s", CStringA(_strSimuCutSpeed));
  1204. }
  1205. C_ASSERT(_countof(_ptCor) == 4);
  1206. _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 0) % 4].x, _ptCor[(_nBSI + 0) % 4].y, _strF);
  1207. _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 1) % 4].x, _ptCor[(_nBSI + 1) % 4].y, _strF);
  1208. _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 2) % 4].x, _ptCor[(_nBSI + 2) % 4].y, _strF);
  1209. _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 3) % 4].x, _ptCor[(_nBSI + 3) % 4].y, _strF);
  1210. _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 4) % 4].x, _ptCor[(_nBSI + 4) % 4].y, _strF);
  1211. if(NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoClearW")) == _T("1"))
  1212. {
  1213. // ʼǰ˵ǰΪԭ㣬Ҫԭ ---- DingQiang 2015-06-09
  1214. _strGCode.AppendFormat("G65 P\"TOORG\" L1\n");
  1215. }
  1216. return _strGCode;
  1217. }
  1218. // ϵ ---- DingQiang 2015-06-30
  1219. CStringA CControlTarget::_GetParamForCommand_BreakPointResume()
  1220. {
  1221. //ִжϵǰжµǰѹǷ
  1222. _SendGasPressureInfo();
  1223. // ȡǰõĶϵλһ:
  1224. // 0ûʾĬϵļλãֹͣ󲻶ʱļλá
  1225. // 1ʾֹͣϢʱλãʱһںִֹͣǰع⣬ļλ
  1226. // õĿľΪܽϹعλ ---- DingQiang 2015-06-30
  1227. CString _strBPPT = NceGetPrivateProfileString(_T("ControlTarget"), _T("BreakPointPosType"));
  1228. int _nBPPT = _strBPPT.IsEmpty() ? 0 : atoi(_strBPPT);
  1229. CStateManager* _pStateManager = GetStateManager();
  1230. ASSERT(_pStateManager);
  1231. ASSERT(_nBPPT == 0 || _nBPPT == 1);
  1232. NceFilePos _StartPos;
  1233. if (_nBPPT == 0)
  1234. {
  1235. _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
  1236. }
  1237. else
  1238. {
  1239. ParameterValue _ParameterValue;
  1240. memset(&_ParameterValue, 0, sizeof(ParameterValue));
  1241. CParamManager* _pParamManager = GetParamManager();
  1242. ASSERT(_pParamManager);
  1243. _pParamManager->GetParameterValue("PreStopFilePos", &_ParameterValue);
  1244. ASSERT(_ParameterValue.nType == ParameterValue::VT_INT64);
  1245. // 1. Get start position
  1246. _StartPos = _ParameterValue.i64Value;
  1247. }
  1248. CString _strBackDistance = NceGetPrivateProfileString(_T("BreakPointFallback"), _T("BreakPointFallbackDistance"));
  1249. double _nBackDistance = atof(_strBackDistance);
  1250. ASSERT(_nBackDistance >= 0.0);
  1251. CFileTarget* _pFileTarget = GetFileTarget();
  1252. ASSERT(_pFileTarget);
  1253. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1254. ASSERT(_pCamGroup);
  1255. const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
  1256. // ˺λΪϵʼλ ---- ߿ϼ 2016-10-10
  1257. if (_pStartCamObject && DOUBLE_GREAT(_nBackDistance, 0.0))
  1258. {
  1259. // ǰӹļյ㲻л ---- ߿ϼ 2016-11-02
  1260. NceFilePos _CurrentCamEndPos;
  1261. _CurrentCamEndPos = CFilePositionHelper::ScanEndPos(_pStartCamObject);
  1262. bool _bStartPos = DOUBLE_EQU(_StartPos.nOffset, 0.0) && DOUBLE_EQU(_StartPos.nRate, 0.0);
  1263. bool _bEndPos = _StartPos == _CurrentCamEndPos;
  1264. if (!_bStartPos && !_bEndPos)
  1265. {
  1266. int _nBackOffset = _StartPos.nOffset;
  1267. double _nBackRate = _StartPos.nRate;
  1268. double _nActualTravelLength = 0.0;
  1269. bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1270. _StartPos.nOffset, _StartPos.nRate, _nBackDistance, &_nBackOffset, &_nBackRate, &_nActualTravelLength);
  1271. ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= _nBackDistance);
  1272. _StartPos.nOffset = _nBackOffset;
  1273. _StartPos.nRate = _nBackRate;
  1274. }
  1275. }
  1276. if (_StartPos <= EOF)
  1277. {
  1278. _StartPos = 0;
  1279. }
  1280. _pStateManager->SetSelectedMachFilePos(_StartPos);
  1281. if (!_pStateManager->IsSelectedMach())
  1282. {
  1283. NceFilePos _nEndPos;
  1284. _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
  1285. if (_pStartCamObject && _pStartCamObject->GetType() == campath)
  1286. {
  1287. int _nEndOffset = _StartPos.nOffset;
  1288. double _nEndRate = _StartPos.nRate;
  1289. double _nActualTravelLength = 0.0;
  1290. bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1291. _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
  1292. &_nEndOffset, &_nEndRate, &_nActualTravelLength);
  1293. ASSERT(_bSucceed);
  1294. if (_nActualTravelLength <= 1.0e-2)
  1295. {
  1296. // ϵ·ʣº٣޶·ĩʼ ----  2012-04-14
  1297. _StartPos.nOffset = _nEndOffset;
  1298. _StartPos.nRate = _nEndRate;
  1299. }
  1300. }
  1301. if (!_pStartCamObject
  1302. || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
  1303. || (__int64)_StartPos == (__int64)_nEndPos)
  1304. {
  1305. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1306. return "";
  1307. }
  1308. CStringA _strParameter;
  1309. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1310. return _strParameter;
  1311. }
  1312. ASSERT(m_strLastTaskCommand == _T("StartSelection")
  1313. || m_strLastTaskCommand == _T("NearStart")
  1314. || m_strLastTaskCommand == _T("DirRunSelection2"));
  1315. ASSERT(!m_strLastTaskCommandParam.IsEmpty());
  1316. CStringA _strParameter = _Mid(m_strLastTaskCommandParam, _StartPos);
  1317. if (_strParameter.IsEmpty())
  1318. {
  1319. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1320. }
  1321. return _strParameter;
  1322. }
  1323. CStringA CControlTarget::_GetParamForCommand_GoForward()
  1324. {
  1325. // 1. Get start position
  1326. NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
  1327. if (_StartPos <= EOF)
  1328. {
  1329. _StartPos = 0;
  1330. }
  1331. // 2. Get end position
  1332. CFileTarget* _pFileTarget = GetFileTarget();
  1333. ASSERT(_pFileTarget);
  1334. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1335. ASSERT(_pCamGroup);
  1336. NceFilePos _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
  1337. // 3. Working
  1338. const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
  1339. if (_pStartCamObject && _pStartCamObject->GetType() == campath)
  1340. {
  1341. int _nEndOffset = _StartPos.nOffset;
  1342. double _nEndRate = _StartPos.nRate;
  1343. double _nActualTravelLength = 0.0;
  1344. bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1345. _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
  1346. &_nEndOffset, &_nEndRate, &_nActualTravelLength);
  1347. ASSERT(_bSucceed);
  1348. if (_nActualTravelLength <= 1.0e-2)
  1349. {
  1350. // ϵ·ʣº٣޶·ĩʼ ----  2012-04-14
  1351. _StartPos.nOffset = _nEndOffset;
  1352. _StartPos.nRate = _nEndRate;
  1353. }
  1354. }
  1355. if (!_pStartCamObject
  1356. || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
  1357. || (__int64)_StartPos == (__int64)_nEndPos)
  1358. {
  1359. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1360. return "";
  1361. }
  1362. CStringA _strParameter;
  1363. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1364. return _strParameter;
  1365. }
  1366. CStringA CControlTarget::_GetParamForCommand_StartNearPoint()
  1367. {
  1368. //ִٽӹǰжµǰѹǷ
  1369. _SendGasPressureInfo();
  1370. //ҵǰλ ---- DingQiang 2013-06-28
  1371. DPOINT2 _ptCur;
  1372. CParamManager* _pParamManager = GetParamManager();
  1373. ASSERT(_pParamManager);
  1374. ParameterValue _ParameterValue;
  1375. memset(&_ParameterValue, 0, sizeof(ParameterValue));
  1376. _pParamManager->GetParameterValue("State_Axis0_WorkcoorPos", &_ParameterValue);
  1377. ASSERT(_ParameterValue.nType == ParameterValue::VT_DOUBLE);
  1378. _ptCur.x = _ParameterValue.dValue;
  1379. _pParamManager->GetParameterValue("State_Axis1_WorkcoorPos", &_ParameterValue);
  1380. ASSERT(_ParameterValue.nType == ParameterValue::VT_DOUBLE);
  1381. _ptCur.y = _ParameterValue.dValue;
  1382. // ڽ뾶 ---- DingQiang 2013-06-26
  1383. CString _strNearRadius = NceGetPrivateProfileString(_T("ControlTarget"), _T("NearPointRadius"));
  1384. double _nNearRadius = _tstof(_strNearRadius);
  1385. // ҵҪ󼯺ϵCadͼεID ---- DingQiang 2013-06-26
  1386. CFileTarget* _pFileTarget = GetFileTarget();
  1387. const CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
  1388. setUINT _setIDs;
  1389. CStateManager* _pStateManager = GetStateManager();
  1390. ASSERT(_pStateManager);
  1391. if (_pStateManager->IsSelectedMach())
  1392. {
  1393. // ǹѡ<ӹѡͼ>Ǵѡͼȡڽͼ ----  2016-09-13
  1394. CSelectTarget* _pSelectTarget = GetSelectTarget();
  1395. ASSERT(_pSelectTarget);
  1396. const CadObjectList* _plistSelectedCads = _pSelectTarget->GetSelectedCadObjects();
  1397. ASSERT(_plistSelectedCads);
  1398. CCadGroup _group;
  1399. *(_group.GetObjectsList()) = *_plistSelectedCads;
  1400. GetCadIDByCircle(&_group, _ptCur, _nNearRadius, _setIDs);
  1401. _group.PickOffAll();
  1402. }
  1403. else
  1404. {
  1405. GetCadIDByCircle(_pCurrentCadGroup, _ptCur, _nNearRadius, _setIDs);
  1406. }
  1407. if (_setIDs.size() == 0)
  1408. {
  1409. NceShowMessage(_GETCS(s_csNoNearPoint));
  1410. return "";
  1411. }
  1412. // camҵЩIDϵcamݣĿ㵽ÿcamľ룬
  1413. // cam ---- DingQiang 2013-06-26
  1414. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1415. CamObjectList _listCam;
  1416. GetCamListByCadID(_pCamGroup, _setIDs, &_listCam);
  1417. if (_listCam.size() == 0)
  1418. {
  1419. NceShowMessage(_GETCS(s_csNoNearPoint));
  1420. return "";
  1421. }
  1422. // ĵļλ ---- DingQiang 2013-06-27
  1423. __int64 _StartPos = 0;
  1424. double _nMinDis = GetCamMinDistance(&_listCam, _ptCur, &_StartPos);
  1425. ASSERT(_nMinDis < DBL_MAX);
  1426. CStringA _strParameter;
  1427. if (_pStateManager->IsSelectedMach())
  1428. {
  1429. // ǹѡ<ӹѡͼ>ǴѡͼεļӹΧѡȡ ----  2016-09-13
  1430. _strParameter = _Mid(_GetParamForCommand_MachSelect(), _StartPos);
  1431. }
  1432. else
  1433. {
  1434. NceFilePos _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
  1435. if((__int64)_StartPos != (__int64)_nEndPos)
  1436. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1437. }
  1438. // ʼͽٵͬһλʱӹ ---- DingQiang 2013-06-28
  1439. if (_strParameter.IsEmpty())
  1440. {
  1441. NceShowMessage(_GETCS(s_csFORBIDNEARSTART));
  1442. }
  1443. return _strParameter;
  1444. }
  1445. CStringA CControlTarget::_GetParamForCommand_MachSelect()
  1446. {
  1447. // MAKE_NCEPOS()
  1448. CFileTarget* _pFileTarget = GetFileTarget();
  1449. ASSERT(_pFileTarget);
  1450. CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
  1451. ASSERT(_pCadGroup);
  1452. setUINT _selectCadId;
  1453. GetCadSelectID(_pCadGroup, _selectCadId);
  1454. if (_selectCadId.size() == 0)
  1455. {
  1456. return "";
  1457. }
  1458. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1459. ASSERT(_pCamGroup);
  1460. listCamInfo _selectCamInfo;
  1461. GetCamSelectID(_pCamGroup, _selectCadId, _selectCamInfo);
  1462. if (_selectCamInfo.size() == 0)
  1463. {
  1464. return "";
  1465. }
  1466. CStringA _str;
  1467. for (listCamInfo::const_iterator _it = _selectCamInfo.begin(); _it != _selectCamInfo.end(); ++_it)
  1468. {
  1469. _str.AppendFormat("%lld,%lld;", _it->nStartPos, _it->nEndPos);
  1470. }
  1471. if (!_str.IsEmpty())
  1472. {
  1473. _str = _str.Left(_str.GetLength() - 1);
  1474. }
  1475. return _str;
  1476. }
  1477. CStringA CControlTarget::_GetParamForCommand_GoBackward()
  1478. {
  1479. // 1. Get start position
  1480. NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
  1481. if (_StartPos <= EOF)
  1482. {
  1483. _StartPos = 0;
  1484. }
  1485. // 2. Get end position
  1486. CFileTarget* _pFileTarget = GetFileTarget();
  1487. ASSERT(_pFileTarget);
  1488. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1489. ASSERT(_pCamGroup);
  1490. NceFilePos _nEndPos = CFilePositionHelper::ScanStartPos(_pCamGroup);
  1491. // 3. Working
  1492. const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
  1493. if (_pStartCamObject && _pStartCamObject->GetType() == campath)
  1494. {
  1495. int _nEndOffset = _StartPos.nOffset;
  1496. double _nEndRate = _StartPos.nRate;
  1497. double _nActualTravelLength = 0.0;
  1498. bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1499. _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
  1500. &_nEndOffset, &_nEndRate, &_nActualTravelLength);
  1501. ASSERT(_bSucceed);
  1502. if (_nActualTravelLength <= 1.0e-2)
  1503. {
  1504. // ϵ·ʣº٣޶·ͷʼ ----  2012-04-14
  1505. _StartPos.nOffset = _nEndOffset;
  1506. _StartPos.nRate = _nEndRate;
  1507. }
  1508. }
  1509. if (!_pStartCamObject
  1510. || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
  1511. || (__int64)_StartPos == (__int64)_nEndPos)
  1512. {
  1513. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1514. return "";
  1515. }
  1516. CStringA _strParameter;
  1517. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1518. return _strParameter;
  1519. }
  1520. CStringA CControlTarget::_GetParamForCommand_IncForward()
  1521. {
  1522. // 1. Get start position
  1523. NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
  1524. if (_StartPos <= EOF)
  1525. {
  1526. _StartPos = 0;
  1527. }
  1528. // 2. Get end position
  1529. CFileTarget* _pFileTarget = GetFileTarget();
  1530. ASSERT(_pFileTarget);
  1531. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1532. ASSERT(_pCamGroup);
  1533. ASSERT(m_nGFOBDistance > 0.0);
  1534. NceFilePos _nEndPos = _StartPos;
  1535. double _nActualTravelLength = 0.0;
  1536. bool _bSucceed = CFilePositionHelper::TravelForward(_pCamGroup,
  1537. _StartPos, m_nGFOBDistance, &_nEndPos, &_nActualTravelLength);
  1538. ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= m_nGFOBDistance);
  1539. // 3. Working
  1540. const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
  1541. if (_pStartCamObject && _pStartCamObject->GetType() == campath)
  1542. {
  1543. int _nEndOffset = _StartPos.nOffset;
  1544. double _nEndRate = _StartPos.nRate;
  1545. double _nActualTravelLength = 0.0;
  1546. bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1547. _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
  1548. &_nEndOffset, &_nEndRate, &_nActualTravelLength);
  1549. ASSERT(_bSucceed);
  1550. if (_nActualTravelLength <= 1.0e-2)
  1551. {
  1552. // ϵ·ʣº٣޶·ͷʼ ----  2012-04-14
  1553. _StartPos.nOffset = _nEndOffset;
  1554. _StartPos.nRate = _nEndRate;
  1555. }
  1556. }
  1557. if (!_pStartCamObject
  1558. || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
  1559. || (__int64)_StartPos == (__int64)_nEndPos)
  1560. {
  1561. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1562. return "";
  1563. }
  1564. CStringA _strParameter;
  1565. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1566. return _strParameter;
  1567. }
  1568. CStringA CControlTarget::_GetParamForCommand_IncBackward()
  1569. {
  1570. // 1. Get start position
  1571. NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
  1572. if (_StartPos <= EOF)
  1573. {
  1574. _StartPos = 0;
  1575. }
  1576. // 2. Get end position
  1577. CFileTarget* _pFileTarget = GetFileTarget();
  1578. ASSERT(_pFileTarget);
  1579. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  1580. ASSERT(_pCamGroup);
  1581. ASSERT(m_nGFOBDistance > 0.0);
  1582. NceFilePos _nEndPos = _StartPos;
  1583. double _nActualTravelLength = 0.0;
  1584. bool _bSucceed = CFilePositionHelper::TravelBackward(_pCamGroup,
  1585. _StartPos, m_nGFOBDistance, &_nEndPos, &_nActualTravelLength);
  1586. ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= m_nGFOBDistance);
  1587. // 3. Working
  1588. const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
  1589. if (_pStartCamObject && _pStartCamObject->GetType() == campath)
  1590. {
  1591. int _nEndOffset = _StartPos.nOffset;
  1592. double _nEndRate = _StartPos.nRate;
  1593. double _nActualTravelLength = 0.0;
  1594. bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
  1595. _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
  1596. &_nEndOffset, &_nEndRate, &_nActualTravelLength);
  1597. ASSERT(_bSucceed);
  1598. if (_nActualTravelLength <= 1.0e-2)
  1599. {
  1600. // ϵ·ʣº٣޶·ͷʼ ----  2012-04-14
  1601. _StartPos.nOffset = _nEndOffset;
  1602. _StartPos.nRate = _nEndRate;
  1603. }
  1604. }
  1605. if (!_pStartCamObject
  1606. || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
  1607. || (__int64)_StartPos == (__int64)_nEndPos)
  1608. {
  1609. NceShowMessage(_GETCS(s_csFORBIDRESUME));
  1610. return "";
  1611. }
  1612. CStringA _strParameter;
  1613. _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
  1614. return _strParameter;
  1615. }
  1616. CStringA CControlTarget::_GetParamForCommand_ForwardBegin()
  1617. {
  1618. CStringA _strRet;
  1619. if (GetGFOBMode() == 0x00)
  1620. {
  1621. _strRet = _GetParamForCommand_GoForward();
  1622. }
  1623. return _strRet;
  1624. }
  1625. CStringA CControlTarget::_GetParamForCommand_BackwardBegin()
  1626. {
  1627. CStringA _strRet;
  1628. if (GetGFOBMode() == 0x00)
  1629. {
  1630. _strRet = _GetParamForCommand_GoBackward();
  1631. }
  1632. return _strRet;
  1633. }
  1634. CStringA CControlTarget::_GetParamForCommand_ForwardEnd()
  1635. {
  1636. CStringA _strRet;
  1637. if (GetGFOBMode() == 0x00)
  1638. {
  1639. AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_STOP, 0);
  1640. return _strRet;
  1641. }
  1642. ASSERT(GetGFOBMode() == 0x01);
  1643. _strRet = _GetParamForCommand_IncForward();
  1644. return _strRet;
  1645. }
  1646. CStringA CControlTarget::_GetParamForCommand_BackwardEnd()
  1647. {
  1648. CStringA _strRet;
  1649. if (GetGFOBMode() == 0x00)
  1650. {
  1651. AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_STOP, 0);
  1652. return _strRet;
  1653. }
  1654. ASSERT(GetGFOBMode() == 0x01);
  1655. _strRet = _GetParamForCommand_IncBackward();
  1656. return _strRet;
  1657. }
  1658. CStringA CControlTarget::_GetParamForXBackR()
  1659. {
  1660. return "X";
  1661. }
  1662. CStringA CControlTarget::_GetParamForYBackR()
  1663. {
  1664. return "Y";
  1665. }
  1666. CStringA CControlTarget::_GetParamForZBackR()
  1667. {
  1668. return "Z";
  1669. }
  1670. CStringA CControlTarget::_GetParamForCommand_BackWZ()
  1671. {
  1672. return "G65 P\"TOZORG\" L1\n";
  1673. }
  1674. void CControlTarget::_ToTraceKeyState(UINT nChar_, bool bEnable_)
  1675. {
  1676. // ٸ٣ ----  2013-09-06
  1677. if (!bEnable_)
  1678. {
  1679. for(int _i = 0; _i < _countof(m_KeyStates); _i++)
  1680. {
  1681. KeyState& _ks = m_KeyStates[_i];
  1682. if (_ks.nChar == nChar_)
  1683. {
  1684. _ks.nChar = 0;
  1685. _ks.nState = 0;
  1686. }
  1687. }
  1688. return;
  1689. }
  1690. // ʼ٣¼ֵ ----  2013-09-06
  1691. BOOL _nInitState = ::GetKeyState(nChar_) < 0 ? 1 : 0;
  1692. for(int _i = 0; _i < _countof(m_KeyStates); _i++)
  1693. {
  1694. KeyState& _ks = m_KeyStates[_i];
  1695. if (_ks.nChar == nChar_)
  1696. {
  1697. _ks.nState = _nInitState;
  1698. return;
  1699. }
  1700. }
  1701. for(int _i = 0; _i < _countof(m_KeyStates); _i++)
  1702. {
  1703. KeyState& _ks = m_KeyStates[_i];
  1704. if (_ks.nChar == 0)
  1705. {
  1706. _ks.nChar = nChar_;
  1707. _ks.nState = _nInitState;
  1708. return;
  1709. }
  1710. }
  1711. // No slot to trace any more ----  2013-09-06
  1712. ASSERT(FALSE);
  1713. }
  1714. void CControlTarget::_DoTraceKeyState()
  1715. {
  1716. for(int _i = 0; _i < _countof(m_KeyStates); _i++)
  1717. {
  1718. KeyState& _ks = m_KeyStates[_i];
  1719. if (_ks.nChar == 0)
  1720. {
  1721. continue;
  1722. }
  1723. BOOL _nState = ::GetKeyState(_ks.nChar) < 0 ? 1 : 0;
  1724. if (_nState != _ks.nState)
  1725. {
  1726. _ks.nState = _nState;
  1727. // ٵİ״̬ģΪϢ ----  2013-09-06
  1728. MSG _msg = { NULL, _nState == 0 ? WM_KEYUP : WM_KEYDOWN, WPARAM(_ks.nChar), LPARAM(1) };
  1729. OnKeyMessage(&_msg);
  1730. }
  1731. }
  1732. }
  1733. void CControlTarget::GetCadSelectID(IN const CCadGroup* pCadGroup_, OUT setUINT& setIDs_)
  1734. {
  1735. ASSERT(pCadGroup_);
  1736. int _nNumOfChild = pCadGroup_->GetNumOfChild();
  1737. const CCadObject* _pCadObject = NULL;
  1738. typedef std::pair<setUINT::iterator, bool> pairRet;
  1739. for (int _i = 0; _i != _nNumOfChild; ++_i)
  1740. {
  1741. _pCadObject = pCadGroup_->GetAt(_i);
  1742. if (_pCadObject->IsSelected())
  1743. {
  1744. pairRet _Ret = setIDs_.insert(_pCadObject->GetID());
  1745. ASSERT(_Ret.second);
  1746. }
  1747. if (_pCadObject->GetType() == cadgroup)
  1748. {
  1749. GetCadSelectID((CCadGroup*)_pCadObject, setIDs_);
  1750. }
  1751. // ѡͼΪʱҲҪݹID ---- DingQiang 2012-11-30
  1752. if (_pCadObject->GetType() == cadtext)
  1753. {
  1754. CCadText* _pCadText = (CCadText*)_pCadObject;
  1755. GetCadSelectID(_pCadText->GetTextGroup(), setIDs_);
  1756. }
  1757. }
  1758. }
  1759. void CControlTarget::GetCamSelectID(IN const nce::CCamGroup* pCamGroup_, IN const setUINT& setIDs_, OUT listCamInfo& setCamInfo_)
  1760. {
  1761. ASSERT(pCamGroup_);
  1762. ASSERT(setIDs_.size());
  1763. int _nNumOfChild = pCamGroup_->GetNumOfChild();
  1764. for (int _i = 0; _i != _nNumOfChild; ++_i)
  1765. {
  1766. const CCamObject* _pCamObject = pCamGroup_->GetAt(_i);
  1767. cam_t _elet = _pCamObject->GetType();
  1768. if (_elet == camgroup)
  1769. {
  1770. GetCamSelectID((CCamGroup*)_pCamObject, setIDs_, setCamInfo_);
  1771. }
  1772. else
  1773. {
  1774. ASSERT(_elet == camhole || _elet == campath);
  1775. UINT _nID = (UINT)_pCamObject->GetKey_DBL("CadID");
  1776. if (setIDs_.find(_nID) != setIDs_.end())
  1777. {
  1778. // ʹCFilePositionHelperļλõؼ ----  2015-08-30
  1779. CamInfo _caminfo = {
  1780. _pCamObject->GetID(),
  1781. CFilePositionHelper::ScanStartPos(_pCamObject),
  1782. CFilePositionHelper::ScanEndPos(_pCamObject)};
  1783. setCamInfo_.push_back(_caminfo);
  1784. }
  1785. }
  1786. }
  1787. }
  1788. void CControlTarget::GetCadIDByCircle(IN const nce::CCadGroup* pCCadGroup_, DPOINT2 ptCenter_, double nRadius_, OUT setUINT& setIDs_)
  1789. {
  1790. ASSERT(pCCadGroup_);
  1791. int _nNumOfChild = pCCadGroup_->GetNumOfChild();
  1792. const CCadObject* _pCadObject = NULL;
  1793. for (int _it = 0; _it < _nNumOfChild; _it++)
  1794. {
  1795. _pCadObject = pCCadGroup_->GetAt(_it);
  1796. if (_pCadObject->GetType() == cadgroup)
  1797. {
  1798. GetCadIDByCircle((CCadGroup*)_pCadObject, ptCenter_, nRadius_, setIDs_);
  1799. continue;
  1800. }
  1801. if (_pCadObject->GetType() == cadtext)
  1802. {
  1803. GetCadIDByCircle(((CCadText*)_pCadObject)->GetTextGroup(), ptCenter_, nRadius_, setIDs_);
  1804. continue;
  1805. }
  1806. double _nMinDis = GetMinDistance(_pCadObject, ptCenter_);
  1807. if (_nMinDis <= nRadius_)
  1808. {
  1809. setIDs_.insert(_pCadObject->GetID());
  1810. }
  1811. }
  1812. }
  1813. void CControlTarget::GetCamListByCadID(IN nce::CCamGroup* pCCamGroup_, IN setUINT setIDs_, OUT CamObjectList* plistCamObject)
  1814. {
  1815. ASSERT(pCCamGroup_);
  1816. ASSERT(plistCamObject->size() == 0);
  1817. CCamObject* _pCamObject = NULL;
  1818. for (int _it = 0; _it < pCCamGroup_->GetNumOfChild(); _it++)
  1819. {
  1820. _pCamObject = pCCamGroup_->GetAt(_it);
  1821. if (_pCamObject->GetType() == camgroup)
  1822. {
  1823. GetCamListByCadID((CCamGroup*)_pCamObject, setIDs_, plistCamObject);
  1824. continue;
  1825. }
  1826. UINT _CadID = (UINT)_pCamObject->GetKey_DBL("CadID");
  1827. if (setIDs_.find(_CadID) != setIDs_.end())
  1828. {
  1829. plistCamObject->push_back(_pCamObject);
  1830. }
  1831. }
  1832. }
  1833. // ҵһCadIDӦCam ---- ƺ 2017-05-21
  1834. void CControlTarget::GetFirstCamObjByCadID(IN nce::CCamGroup* pCCamGroup_, IN UINT nCadID_, OUT CCamObject** ppCamObject_)
  1835. {
  1836. ASSERT(pCCamGroup_ && ppCamObject_);
  1837. CamObjectList* _plistCamObjs = pCCamGroup_->GetObjectsList();
  1838. for (CamObjectList::iterator _it = _plistCamObjs->begin();
  1839. _it != _plistCamObjs->end(); _it++)
  1840. {
  1841. // ųԤײĵ㡣 ---- ƺ 2017-05-21
  1842. if ((*_it)->GetKey_DBL("CadID") == nCadID_
  1843. && (*_it)->GetType() == campath)
  1844. {
  1845. *ppCamObject_ = *_it;
  1846. return;
  1847. }
  1848. }
  1849. }
  1850. double CControlTarget::GetCamMinDistance(IN const nce::CCamObject* pCamObject_, IN DPOINT2 pt_, OUT __int64* pnPos_ /* = NULL */)
  1851. {
  1852. ASSERT(pCamObject_);
  1853. double _nMinDis = DBL_MAX;
  1854. cam_t _type = pCamObject_->GetType();
  1855. switch (_type)
  1856. {
  1857. case camhole:
  1858. {
  1859. CCamHole* _pCamHole = (CCamHole*)pCamObject_;
  1860. _nMinDis = GetCamMinDistance(_pCamHole, pt_, pnPos_);
  1861. }
  1862. break;
  1863. case campath:
  1864. {
  1865. CCamPath* _pCamPath = (CCamPath*)pCamObject_;
  1866. _nMinDis = GetCamMinDistance(_pCamPath, pt_, pnPos_);
  1867. }
  1868. break;
  1869. case camgroup:
  1870. {
  1871. CCamGroup* _pCamGroup = (CCamGroup*)pCamObject_;
  1872. _nMinDis = GetCamMinDistance(_pCamGroup->GetObjectsList(), pt_, pnPos_);
  1873. }
  1874. break;
  1875. default:
  1876. ASSERT(FALSE);
  1877. break;
  1878. }
  1879. return _nMinDis;
  1880. }
  1881. double CControlTarget::GetCamMinDistance(IN const nce::CCamHole* pCamHole_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
  1882. {
  1883. ASSERT(pCamHole_);
  1884. DPOINT2 _ptTemp(pCamHole_->GetStart().x, pCamHole_->GetStart().y);
  1885. if (pnPos_)
  1886. {
  1887. NceFilePos _pos;
  1888. _pos.SetID(pCamHole_->GetID());
  1889. _pos.SetOffset(0);
  1890. _pos.SetRate(0);
  1891. *pnPos_ = (__int64)_pos;
  1892. }
  1893. return (pt_ - _ptTemp).GetLength();
  1894. }
  1895. double CControlTarget::GetCamMinDistance(IN const nce::CCamPath* pCamPath_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
  1896. {
  1897. ASSERT(pCamPath_ != NULL);
  1898. double _nMinDis = DBL_MAX;
  1899. __int64 _nPos = 0;
  1900. // PathNURBS·NURBSģ̾뼰Ӧļλ ---- duquan 2016-07-28
  1901. CCamSplineWrapper _CamSplineWrapper(pCamPath_);
  1902. if (_CamSplineWrapper.IsSpline())
  1903. {
  1904. NceFilePos _pos;
  1905. _pos.SetID(pCamPath_->GetID());
  1906. _pos.SetOffset(0);
  1907. _pos.SetRate(0.);
  1908. _nMinDis = _CamSplineWrapper.GetMinDistFromAimPos(pt_, &_pos);
  1909. _nPos = (__int64)_pos;
  1910. if (pnPos_ != NULL)
  1911. *pnPos_ = _nPos;
  1912. return _nMinDis;
  1913. }
  1914. UINT _nNodeCount = pCamPath_->GetNodeCount();
  1915. for (UINT _it = 0; _it < _nNodeCount; _it++)
  1916. {
  1917. double _nDistance = DBL_MAX;
  1918. double _nRate = 0;
  1919. CCamPath::NODE _nNode = pCamPath_->GetNode(_it);
  1920. CCamPath::NODE_T _typeNode = _nNode.nType;
  1921. if (_typeNode == CCamPath::nt_line_xy
  1922. || _typeNode == CCamPath::nt_line_x
  1923. || _typeNode == CCamPath::nt_line_y)
  1924. {
  1925. DPOINT2 _ptStart(_nNode.ptStart.x, _nNode.ptStart.y);
  1926. DPOINT2 _ptEnd(_nNode.ptEnd.x, _nNode.ptEnd.y);
  1927. DPOINT2 _vecTemp = pt_ - _ptStart;
  1928. DPOINT2 _vecLine = _ptEnd - _ptStart;
  1929. double _nTemp = _vecTemp * _vecLine;
  1930. double _nValue = _vecLine * _vecLine;
  1931. ASSERT(_nValue >= 0.0);
  1932. DPOINT2 _point;
  1933. if (_nTemp < 0.0)
  1934. {
  1935. _point = _ptStart;
  1936. _nRate = 0;
  1937. }
  1938. else if (_nTemp > _nValue)
  1939. {
  1940. _point = _ptEnd;
  1941. _nRate = 1;
  1942. }
  1943. else
  1944. {
  1945. LineD2D _line(_ptStart, _ptEnd);
  1946. D2GetProjectionPoint(pt_, _line, &_point);
  1947. _nRate = (_point - _ptStart).GetLength() / (_ptEnd - _ptStart).GetLength();
  1948. }
  1949. _nDistance = (pt_ - _point).GetLength();
  1950. }
  1951. else if (_typeNode == CCamPath::nt_arc_xy)
  1952. {
  1953. DPOINT2 _ptStart(_nNode.ptStart.x, _nNode.ptStart.y);
  1954. DPOINT2 _ptEnd(_nNode.ptEnd.x, _nNode.ptEnd.y);
  1955. DPOINT2 _ptCenter;
  1956. double _nStartAngle;
  1957. double _nRadius;
  1958. double _nSweptAngle;
  1959. SEGMENT::SolveArc(_ptStart, _ptEnd, _nNode.nBulge, &_ptCenter, &_nRadius, &_nStartAngle, &_nSweptAngle);
  1960. DPOINT2 _vector = pt_ - _ptCenter;
  1961. double _nAngle = D2GetNormalAngle(_vector);
  1962. double _nMin = _nSweptAngle > 0 ? _nStartAngle : _nStartAngle + _nSweptAngle;
  1963. double _nMax = _nSweptAngle > 0 ? _nStartAngle + _nSweptAngle : _nStartAngle;
  1964. bool _bInRange = IsInRange(_nAngle, _nMin, _nMax);
  1965. if (_bInRange)
  1966. {
  1967. _nDistance = abs((pt_ - _ptCenter).GetLength() - _nRadius);
  1968. _nRate = (_nAngle - _nStartAngle) / _nSweptAngle;
  1969. }
  1970. else
  1971. {
  1972. double _nDis1 = (pt_ - _ptStart).GetLength();
  1973. double _nDis2 = (pt_ - _ptEnd).GetLength();
  1974. if (_nDis1 < _nDis2)
  1975. {
  1976. _nDistance = _nDis1;
  1977. _nRate = 0;
  1978. }
  1979. else
  1980. {
  1981. _nDistance = _nDis2;
  1982. _nRate = 1;
  1983. }
  1984. }
  1985. }
  1986. else if (_typeNode == CCamPath::nt_circle_xy_cw
  1987. || _typeNode == CCamPath::nt_circle_xy_ccw)
  1988. {
  1989. DPOINT2 _ptCenter(_nNode.ptCenter.x, _nNode.ptCenter.y);
  1990. DPOINT2 _vector = pt_ - _ptCenter;
  1991. double _nRadius = _nNode.nRadius;
  1992. double _nAngle = D2GetNormalAngle(_vector);
  1993. double _nLength = (pt_ - _ptCenter).GetLength();
  1994. if (_typeNode == CCamPath::nt_circle_xy_cw)
  1995. {
  1996. _nRate = (2 * c_nPIE - _nAngle) / (2 * c_nPIE);
  1997. }
  1998. else
  1999. {
  2000. _nRate = _nAngle / (2 * c_nPIE);
  2001. }
  2002. _nDistance = abs(_nLength - _nRadius);
  2003. }
  2004. else
  2005. {
  2006. ASSERT(FALSE);
  2007. continue;
  2008. }
  2009. if (_nDistance < _nMinDis)
  2010. {
  2011. _nMinDis = _nDistance;
  2012. NceFilePos _pos;
  2013. _pos.SetID(pCamPath_->GetID());
  2014. // յ㣬ҵĵСʱ޶ͼ ---- DingQiang 2013-07-08
  2015. if (pCamPath_->GetStartPoint() == pCamPath_->GetEndPoint()
  2016. && _it == _nNodeCount -1
  2017. && abs(_nRate - 1) < 1.0e-2)
  2018. {
  2019. _pos.SetOffset(0);
  2020. _pos.SetRate(0);
  2021. }
  2022. else
  2023. {
  2024. _pos.SetOffset(_it);
  2025. _pos.SetRate(_nRate);
  2026. }
  2027. _nPos = (__int64)_pos;
  2028. }
  2029. }
  2030. if (pnPos_)
  2031. {
  2032. *pnPos_ = _nPos;
  2033. }
  2034. return _nMinDis;
  2035. }
  2036. double CControlTarget::GetCamMinDistance(IN const nce::CamObjectList* plistCamObject_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
  2037. {
  2038. ASSERT(plistCamObject_ && plistCamObject_->size() > 0);
  2039. double _nMinDis = DBL_MAX;
  2040. __int64 _nPos = 0;
  2041. const CCamObject* _pCamObject = NULL;
  2042. for (CamObjectList::const_iterator _it = plistCamObject_->begin(); _it != plistCamObject_->end(); _it++)
  2043. {
  2044. const CCamObject* _pCam = *_it;
  2045. __int64 _nPosTemp =0;
  2046. double _nDistance = GetCamMinDistance(_pCam, pt_, &_nPosTemp);
  2047. if (_nDistance < _nMinDis)
  2048. {
  2049. _nMinDis = _nDistance;
  2050. _nPos = _nPosTemp;
  2051. _pCamObject = _pCam;
  2052. }
  2053. }
  2054. if (pnPos_ && _pCamObject)
  2055. {
  2056. *pnPos_ = _nPos;
  2057. }
  2058. return _nMinDis;
  2059. }
  2060. bool operator<(const CamInfo& caminfo1_, const CamInfo& caminfo2_)
  2061. {
  2062. return caminfo1_.nID < caminfo2_.nID;
  2063. };
  2064. BOOL CControlTarget::OnKeyMessage(const MSG* pMsg_)
  2065. {
  2066. ASSERT(pMsg_);
  2067. CCommandManager* _pCommandManager = GetCommandManager();
  2068. if (!_pCommandManager)
  2069. {
  2070. return FALSE;
  2071. }
  2072. //㴰DZ༭򲻽ֶ ----  2012-04-13
  2073. HWND _hwndFocus = ::GetFocus();
  2074. if (::IsWindow(_hwndFocus))
  2075. {
  2076. TCHAR _szWndClassName[64];
  2077. memset(_szWndClassName, 0, _countof(_szWndClassName) * sizeof(TCHAR));
  2078. ::GetClassName(_hwndFocus, _szWndClassName, _countof(_szWndClassName));
  2079. if (!_tcsicmp(_szWndClassName, _T("Edit")))
  2080. {
  2081. return FALSE;
  2082. }
  2083. }
  2084. BOOL _bSucceed = FALSE;
  2085. static const struct GFOBMsgItem
  2086. {
  2087. UINT nGFOBMessage; // WM_KEYDOWN or WM_KEYUP
  2088. UINT nGFOBChar;
  2089. UINT nGFOBRepCnt;
  2090. DWORD nGFOBMode; // 0x00-㶯, 0x01-ǰ/ָľ
  2091. UINT nGFOBCmdID;
  2092. DWORD nMask;
  2093. } _s_GFOBMsgItems[] =
  2094. {
  2095. { WM_KEYDOWN, VK_F3, 1, 0x00, IDCMD_CONTROLTARGET_JOGBACKWARD, 0x00000001},
  2096. { WM_KEYDOWN, VK_F4, 1, 0x00, IDCMD_CONTROLTARGET_JOGFORWARD, 0x00000002},
  2097. { WM_KEYUP, VK_F3, 1, 0x00, IDCMD_CONTROLTARGET_STOP, 0x00000001},
  2098. { WM_KEYUP, VK_F4, 1, 0x00, IDCMD_CONTROLTARGET_STOP, 0x00000002},
  2099. { WM_KEYUP, VK_F3, 1, 0x01, IDCMD_CONTROLTARGET_INCBACKWARD, 0x00000001},
  2100. { WM_KEYUP, VK_F4, 1, 0x01, IDCMD_CONTROLTARGET_INCFORWARD, 0x00000002},
  2101. };
  2102. for (size_t _i = 0; _i < _countof(_s_GFOBMsgItems); _i++)
  2103. {
  2104. const GFOBMsgItem& _item = _s_GFOBMsgItems[_i];
  2105. if (pMsg_->message != _item.nGFOBMessage
  2106. || static_cast<UINT>(pMsg_->wParam) != _item.nGFOBChar
  2107. || LOWORD(pMsg_->lParam) != _item.nGFOBRepCnt
  2108. || GetGFOBMode() != _item.nGFOBMode)
  2109. {
  2110. continue;
  2111. }
  2112. // /رհ״̬ ----  2013-09-04
  2113. _ToTraceKeyState(UINT(pMsg_->wParam), pMsg_->message == WM_KEYDOWN ? true : false);
  2114. _bSucceed = OnCmdMsg(_item.nGFOBCmdID, 0, NULL, NULL);
  2115. if (_item.nGFOBMessage == WM_KEYDOWN)
  2116. {
  2117. m_nGFOBKeyState |= _item.nMask;
  2118. }
  2119. else
  2120. {
  2121. m_nGFOBKeyState &= !_item.nMask;
  2122. }
  2123. }
  2124. return _bSucceed ? TRUE : FALSE;
  2125. }
  2126. void CControlTarget::SetGFOBMode(DWORD nGFOBMode_)
  2127. {
  2128. m_nGFOBMode = nGFOBMode_;
  2129. CParamManager* _pParamManager = GetParamManager();
  2130. if (_pParamManager)
  2131. {
  2132. mach::ParameterValue _Parameter;
  2133. memset(&_Parameter, 0, sizeof(mach::ParameterValue));
  2134. _Parameter.nType = mach::ParameterValue::VT_INT;
  2135. _Parameter.iValue = m_nGFOBMode == 1 ? 1 : 0;
  2136. _pParamManager->SetParameterValue("GoBackMode", &_Parameter);
  2137. }
  2138. }
  2139. DWORD CControlTarget::GetGFOBMode()
  2140. {
  2141. CParamManager* _pParamManager = GetParamManager();
  2142. if (_pParamManager)
  2143. {
  2144. mach::ParameterValue _Parameter;
  2145. memset(&_Parameter, 0, sizeof(mach::ParameterValue));
  2146. if (_pParamManager->GetParameterValue("GoBackMode", &_Parameter))
  2147. {
  2148. ASSERT(_Parameter.nType == mach::ParameterValue::VT_INT);
  2149. m_nGFOBMode = _Parameter.iValue;
  2150. }
  2151. }
  2152. return m_nGFOBMode;
  2153. }
  2154. bool CControlTarget::_IsOutsideTheSotfLimit(const CStringA strFilePosition_)
  2155. {
  2156. CParamManager* _pParamManager = GetParamManager();
  2157. if (!_pParamManager)
  2158. {
  2159. ASSERT(FALSE);
  2160. return false;
  2161. }
  2162. mach::ParameterValue _IsCheckLimitX;
  2163. mach::ParameterValue _IsCheckLimitY;
  2164. bool _bSuccess = _pParamManager->GetParameterValue("IsCheckLimitX", &_IsCheckLimitX);
  2165. _bSuccess &= _pParamManager->GetParameterValue("IsCheckLimitY", &_IsCheckLimitY);
  2166. ASSERT(_IsCheckLimitX.nType == ParameterValue::VT_BOOL && _IsCheckLimitY.nType == ParameterValue::VT_BOOL);
  2167. if (!_IsCheckLimitX.bValue && !_IsCheckLimitY.bValue)
  2168. return false;
  2169. mach::ParameterValue _IsReferedX;
  2170. mach::ParameterValue _IsReferedY;
  2171. _bSuccess &= _pParamManager->GetParameterValue("IsReferedX", &_IsReferedX);
  2172. _bSuccess &= _pParamManager->GetParameterValue("IsReferedY", &_IsReferedY);
  2173. ASSERT(_IsReferedX.nType == ParameterValue::VT_BOOL && _IsReferedY.nType == ParameterValue::VT_BOOL);
  2174. if (!_bSuccess)
  2175. {
  2176. ASSERT(FALSE);
  2177. return false;
  2178. }
  2179. // ûлػеԭ㲻λ
  2180. if (!_IsReferedX.bValue && !_IsReferedY.bValue)
  2181. {
  2182. return false;
  2183. }
  2184. CFileTarget* _pFileTarget = GetFileTarget();
  2185. if (!_pFileTarget)
  2186. {
  2187. ASSERT(FALSE);
  2188. return false;
  2189. }
  2190. // ûõͼξͲжˡ ---- ƺ 2015-12-12
  2191. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  2192. if (_pFileTarget->GetFilePath().IsEmpty()
  2193. || !_pCamGroup->GetObjectsList()
  2194. || _pCamGroup->GetObjectsList()->size() == 0)
  2195. {
  2196. return false;
  2197. }
  2198. double _pWorktable[4];
  2199. DRECT _rcWorktable;
  2200. SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
  2201. _rcWorktable.x = _pWorktable[0];
  2202. _rcWorktable.y = _pWorktable[1];
  2203. _rcWorktable.width = _pWorktable[2];
  2204. _rcWorktable.height = _pWorktable[3];
  2205. DRECT _rectBound;
  2206. static CSimuCutHelper _s_SimuCutHelper;
  2207. CStateManager* _pStateManager = GetStateManager();
  2208. // ӹͼΡ
  2209. if (!_pStateManager->IsSelectedMach())
  2210. {
  2211. _rectBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
  2212. }
  2213. // ѡӹ
  2214. else
  2215. {
  2216. DRECT _rectBoundLast;
  2217. CFileTarget* _pFileTarget = GetFileTarget();
  2218. ASSERT(_pFileTarget);
  2219. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  2220. CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
  2221. CSelectTarget* _pSelectTarget = GetSelectTarget();
  2222. ASSERT(_pSelectTarget);
  2223. const CadObjectList* _plistSelectObjs = _pSelectTarget->GetSelectedCadObjects();
  2224. vectorUINT _setCadID;
  2225. CCamGroup* _pSelcetCamGroup = new CCamGroup;
  2226. _GetCadIDList((CadObjectList*)_plistSelectObjs,_setCadID);
  2227. if (_setCadID.size() > 0)
  2228. {
  2229. _GetCamGroupByCadID(_pCamGroup, _setCadID, _pSelcetCamGroup);
  2230. _rectBound = _s_SimuCutHelper.GetBoundRect(_pSelcetCamGroup);
  2231. }
  2232. _pSelcetCamGroup->GetObjectsList()->clear();
  2233. delete _pSelcetCamGroup;
  2234. }
  2235. _DoWCSAdjust(_rectBound);
  2236. if (_IsCheckLimitX.bValue && _IsReferedX.bValue
  2237. && (_rectBound.GetLeft() < _rcWorktable.GetLeft() || _rectBound.GetRight() > _rcWorktable.GetRight()))
  2238. return true;
  2239. if (_IsCheckLimitY.bValue && _IsReferedY.bValue
  2240. && (_rectBound.GetBottom() < _rcWorktable.GetBottom() || _rectBound.GetTop() > _rcWorktable.GetTop()))
  2241. return true;
  2242. return false;
  2243. }
  2244. bool CControlTarget::_IsRectOutsideTheSotfLimit(const CStringA strFilePosition_)
  2245. {
  2246. CParamManager* _pParamManager = GetParamManager();
  2247. if (!_pParamManager)
  2248. {
  2249. ASSERT(FALSE);
  2250. return false;
  2251. }
  2252. mach::ParameterValue _IsCheckLimitX;
  2253. mach::ParameterValue _IsCheckLimitY;
  2254. bool _bSuccess = _pParamManager->GetParameterValue("IsCheckLimitX", &_IsCheckLimitX);
  2255. _bSuccess &= _pParamManager->GetParameterValue("IsCheckLimitY", &_IsCheckLimitY);
  2256. ASSERT(_IsCheckLimitX.nType == ParameterValue::VT_BOOL && _IsCheckLimitY.nType == ParameterValue::VT_BOOL);
  2257. if (!_IsCheckLimitX.bValue && !_IsCheckLimitY.bValue)
  2258. return false;
  2259. mach::ParameterValue _IsReferedX;
  2260. mach::ParameterValue _IsReferedY;
  2261. _bSuccess &= _pParamManager->GetParameterValue("IsReferedX", &_IsReferedX);
  2262. _bSuccess &= _pParamManager->GetParameterValue("IsReferedY", &_IsReferedY);
  2263. ASSERT(_IsReferedX.nType == ParameterValue::VT_BOOL && _IsReferedY.nType == ParameterValue::VT_BOOL);
  2264. if (!_bSuccess)
  2265. {
  2266. ASSERT(FALSE);
  2267. return false;
  2268. }
  2269. // ûлػеԭ㲻λ
  2270. if (!_IsReferedX.bValue && !_IsReferedY.bValue)
  2271. {
  2272. return false;
  2273. }
  2274. CFileTarget* _pFileTarget = GetFileTarget();
  2275. if (!_pFileTarget)
  2276. {
  2277. ASSERT(FALSE);
  2278. return false;
  2279. }
  2280. // ûõͼξͲжˡ ---- ƺ 2015-12-12
  2281. CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
  2282. if (_pFileTarget->GetFilePath().IsEmpty()
  2283. || !_pCamGroup->GetObjectsList()
  2284. || _pCamGroup->GetObjectsList()->size() == 0)
  2285. {
  2286. return false;
  2287. }
  2288. double _pWorktable[4];
  2289. DRECT _rcWorktable;
  2290. SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
  2291. _rcWorktable.x = _pWorktable[0];
  2292. _rcWorktable.y = _pWorktable[1];
  2293. _rcWorktable.width = _pWorktable[2];
  2294. _rcWorktable.height = _pWorktable[3];
  2295. DRECT _rectBound;
  2296. // ߿Ƿ񳬹λ
  2297. static CSimuCutHelper _s_SimuCutHelper;
  2298. ASSERT(!strFilePosition_.IsEmpty());
  2299. _rectBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
  2300. _DoWCSAdjust(_rectBound);
  2301. if (_IsCheckLimitX.bValue && _IsReferedX.bValue
  2302. && (_rectBound.GetLeft() < _rcWorktable.GetLeft() || _rectBound.GetRight() > _rcWorktable.GetRight()))
  2303. return true;
  2304. if (_IsCheckLimitY.bValue && _IsReferedY.bValue
  2305. && (_rectBound.GetBottom() < _rcWorktable.GetBottom() || _rectBound.GetTop() > _rcWorktable.GetTop()))
  2306. return true;
  2307. return false;
  2308. }
  2309. // ָӹΧڴضλÿʼĺ󲿣ڴ˷Χڷؿַ ---- ƺ 2016-09-14
  2310. CStringA CControlTarget::_Mid(const CStringA& strSelection_, __int64 nStartPos_)
  2311. {
  2312. if (strSelection_.IsEmpty())
  2313. {
  2314. ASSERT(FALSE);
  2315. return "";
  2316. }
  2317. int _nIndex = strSelection_.Find(_T(';'));
  2318. CString _strSection = _nIndex == -1 ? strSelection_ : strSelection_.Mid(0, _nIndex);
  2319. __int64 _nLastEndPos = -1;
  2320. CString _strRet;
  2321. while(!_strSection.IsEmpty())
  2322. {
  2323. __int64 _nStart = 0;
  2324. __int64 _nEnd = 0;
  2325. int _nCount = sscanf_s(_strSection, _T("%lld,%lld"), &_nStart, &_nEnd);
  2326. ASSERT(_nCount == 2);
  2327. // Ĭϴļǵģ"a,b;c,d"a < b < c < d ---- ƺ 2016-09-14
  2328. ASSERT(_nLastEndPos <= _nStart && _nStart <= _nEnd);
  2329. // ǰλòڴڡ ---- ƺ 2016-09-14
  2330. if (nStartPos_ < _nStart
  2331. && _nLastEndPos == -1)
  2332. {
  2333. return "";
  2334. }
  2335. // ǰλĿ϶ڣ"a,b;c,d", ǰλ > b && ǰλ < c ---- ƺ 2016-09-14
  2336. if (nStartPos_ < _nStart
  2337. && _nLastEndPos > 0
  2338. && nStartPos_ > _nLastEndPos)
  2339. {
  2340. _strRet.Format(_T("%lld,%lld;"), _nStart, _nEnd);
  2341. if (_nIndex != -1)
  2342. _strRet += strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
  2343. break;
  2344. }
  2345. // ǰλijڡ ---- ƺ 2016-09-14
  2346. if (nStartPos_ >= _nStart && nStartPos_ < _nEnd)
  2347. {
  2348. _strRet.Format(_T("%lld,%lld;"), nStartPos_, _nEnd);
  2349. if (_nIndex != -1)
  2350. _strRet += strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
  2351. break;
  2352. }
  2353. // ǰλøպijյ㡣 ---- ƺ 2016-09-14
  2354. if (nStartPos_ == _nEnd && _nIndex != -1)
  2355. {
  2356. _strRet = strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
  2357. break;
  2358. }
  2359. if (_nIndex == -1)
  2360. break;
  2361. _nLastEndPos = _nEnd;
  2362. int _nNextIndex = strSelection_.Find(_T(';'), _nIndex + 1);
  2363. _strSection = _nNextIndex == -1
  2364. ? strSelection_.Right(strSelection_.GetLength() - _nIndex - 1)
  2365. : strSelection_.Mid(_nIndex + 1, _nNextIndex - _nIndex);
  2366. _nIndex = _nNextIndex;
  2367. }
  2368. // һǷֺţɾ ---- ƺ 2016-09-14
  2369. int _nLen = _strRet.GetLength();
  2370. if (_nLen > 0 && _strRet[_nLen - 1] == _T(';'))
  2371. {
  2372. _strRet.Delete(_nLen - 1);
  2373. }
  2374. return _strRet;
  2375. }
  2376. void CControlTarget::_DoWCSAdjust(DRECT& rcRect_)
  2377. {
  2378. CWCSAdjustTarget* _pWCSAdjustTarget = GetWCSAdjustTarget();
  2379. if (!_pWCSAdjustTarget)
  2380. return;
  2381. DRECT _rcOrg = rcRect_;
  2382. DPOINT2 _ptTopLeft (_rcOrg.GetLeft(), _rcOrg.GetTop());
  2383. DPOINT2 _ptRightBottom(_rcOrg.GetRight(), _rcOrg.GetBottom());
  2384. DPOINT2 _ptBottomLeft(_rcOrg.GetLeft(), _rcOrg.GetBottom());
  2385. DPOINT2 _ptTopRight(_rcOrg.GetRight(), _rcOrg.GetTop());
  2386. _ptTopLeft = _pWCSAdjustTarget->DoWCSAdjust(_ptTopLeft);
  2387. _ptRightBottom = _pWCSAdjustTarget->DoWCSAdjust(_ptRightBottom);
  2388. _ptBottomLeft = _pWCSAdjustTarget->DoWCSAdjust(_ptBottomLeft);
  2389. _ptTopRight = _pWCSAdjustTarget->DoWCSAdjust(_ptTopRight);
  2390. double _nLeft = min(min(min(_ptTopLeft.x, _ptTopRight.x), _ptBottomLeft.x), _ptRightBottom.x);
  2391. double _nRight = max(max(max(_ptTopLeft.x, _ptTopRight.x), _ptBottomLeft.x), _ptRightBottom.x);
  2392. double _nBottom = min(min(min(_ptTopLeft.y, _ptTopRight.y), _ptBottomLeft.y), _ptRightBottom.y);
  2393. double _nTop = max(max(max(_ptTopLeft.y, _ptTopRight.y), _ptBottomLeft.y), _ptRightBottom.y);
  2394. DRECT _rcNew;
  2395. _rcNew.x = _nLeft;
  2396. _rcNew.y = _nBottom;
  2397. _rcNew.width = _nRight - _nLeft;
  2398. _rcNew.height = _nTop - _nBottom;
  2399. rcRect_ = _rcNew;
  2400. }
  2401. // CadIDҵӦCad
  2402. static bool _FindObjectByID(IN CCadObject* pCadObject_, IN int nID_, OUT CCadObject** ppResult_)
  2403. {
  2404. if (pCadObject_->GetID() == nID_)
  2405. {
  2406. *ppResult_ = pCadObject_;
  2407. return true;
  2408. }
  2409. if (pCadObject_->GetType() == cadtext)
  2410. {
  2411. CCadText* _pCadText = dynamic_cast<CCadText*>(pCadObject_);
  2412. ASSERT(_pCadText);
  2413. if (_FindObjectByID(_pCadText->GetTextGroup(), nID_, ppResult_))
  2414. return true;
  2415. }
  2416. if (pCadObject_->GetType() == cadgroup)
  2417. {
  2418. CCadGroup* _pCadGroup = dynamic_cast<CCadGroup*>(pCadObject_);
  2419. ASSERT(_pCadGroup);
  2420. for (int _i = 0; _i < _pCadGroup->GetNumOfChild(); _i++)
  2421. {
  2422. CCadObject* _pCad = _pCadGroup->GetAt(_i);
  2423. ASSERT(_pCad);
  2424. if (_FindObjectByID(_pCad, nID_, ppResult_))
  2425. return true;
  2426. }
  2427. }
  2428. return false;
  2429. }
  2430. __int64 CControlTarget::_SelectionFirst(const CStringA& strSelection_)
  2431. {
  2432. if (strSelection_.IsEmpty())
  2433. {
  2434. ASSERT(FALSE);
  2435. return 0;
  2436. }
  2437. int _nIndex = strSelection_.Find(_T(';'));
  2438. CString _strSection = _nIndex == -1 ? strSelection_ : strSelection_.Mid(0, _nIndex);
  2439. __int64 _nLastEndPos = -1;
  2440. CString _strRet;
  2441. if(!_strSection.IsEmpty())
  2442. {
  2443. __int64 _nStart = 0;
  2444. __int64 _nEnd = 0;
  2445. int _nCount = sscanf_s(_strSection, _T("%lld,%lld"), &_nStart, &_nEnd);
  2446. ASSERT(_nCount == 2);
  2447. return _nStart;
  2448. }
  2449. return 0;
  2450. }
  2451. void _GetCadIDObj(IN CCadObject* pCadObject_, OUT vectorUINT& setIDs_)
  2452. {
  2453. setIDs_.push_back(pCadObject_->GetID());
  2454. if (pCadObject_->GetType() == cadtext)
  2455. {
  2456. CCadText* _pCadText = dynamic_cast<CCadText*>(pCadObject_);
  2457. ASSERT(_pCadText);
  2458. _GetCadIDObj(_pCadText->GetTextGroup(), setIDs_);
  2459. }
  2460. if (pCadObject_->GetType() == cadgroup)
  2461. {
  2462. CCadGroup* _pCadGroup = dynamic_cast<CCadGroup*>(pCadObject_);
  2463. ASSERT(_pCadGroup);
  2464. for (int _i = 0; _i < _pCadGroup->GetNumOfChild(); _i++)
  2465. {
  2466. CCadObject* _pCad = _pCadGroup->GetAt(_i);
  2467. ASSERT(_pCad);
  2468. _GetCadIDObj(_pCad, setIDs_);
  2469. }
  2470. }
  2471. }
  2472. void _GetCadIDList(IN CadObjectList* pListCads_, OUT vectorUINT& setIDs_)
  2473. {
  2474. for (CadObjectList::iterator _it = pListCads_->begin(); _it != pListCads_->end(); _it++)
  2475. {
  2476. _GetCadIDObj(*_it, setIDs_);
  2477. }
  2478. }
  2479. void _GetCamGroupByCadID(IN nce::CCamGroup* pCCamGroup_, IN vectorUINT setIDs_, OUT nce::CCamGroup* pOutCCamGroup_)
  2480. {
  2481. ASSERT(pCCamGroup_);
  2482. CamObjectList* _plistCamObjs = pCCamGroup_->GetObjectsList();
  2483. for (CamObjectList::const_iterator _it = _plistCamObjs->begin(); _it != _plistCamObjs->end(); _it++)
  2484. {
  2485. // ҪغϵCAM
  2486. CCamObject* _pCam = *_it;
  2487. CCadObject* _pCad = NULL;
  2488. // CamеCadIDҵӦCad
  2489. int _nID = (int)_pCam->GetKey_DBL("CadID");
  2490. if (std::find(setIDs_.begin(), setIDs_.end(), _nID) != setIDs_.end())
  2491. {
  2492. pOutCCamGroup_->GetObjectsList()->push_back(_pCam);
  2493. }
  2494. }
  2495. return;
  2496. for (int _i = 0; _i < setIDs_.size(); _i++)
  2497. {
  2498. CCamObject* _pCamObject = NULL;
  2499. SendTargetMessage(ID_TARGET_CADTOCAM, TN_GETCAM_BYCADID, setIDs_[_i], (LPARAM)&_pCamObject);
  2500. if (_pCamObject != NULL)
  2501. {
  2502. pOutCCamGroup_->GetObjectsList()->push_back(_pCamObject);
  2503. }
  2504. }
  2505. }
  2506. void CControlTarget::_SendGasPressureInfo()
  2507. {
  2508. CString _flag = NceGetPrivateProfileString(_T("GasCheck"), _T("GNGasCheck"), _T("0"));
  2509. if ("1" != _flag)
  2510. {
  2511. return;
  2512. }
  2513. CStateManager* _pStateManager = GetStateManager();
  2514. ASSERT(_pStateManager);
  2515. bool _bAirCheck = false;
  2516. bool _bOxygenCheck = false;
  2517. bool _bNitrogenCheck = false;
  2518. CFileTarget* _pFileTarget = GetFileTarget();
  2519. ASSERT(_pFileTarget);
  2520. nce::ParamVector* _pParamVector = _pFileTarget->GetCurrentCadParams();
  2521. nce::CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
  2522. for (size_t _i = 0; _i < _pParamVector->size(); _i++)
  2523. {
  2524. if (_bAirCheck && _bOxygenCheck && _bNitrogenCheck)
  2525. {
  2526. continue;
  2527. }
  2528. if (_pStateManager->IsSelectedMach())
  2529. {
  2530. bool _isSelect = false;
  2531. //жѡͼѡǷҪѹ;
  2532. for (int _j = 0; _j < _pCurrentCadGroup->GetNumOfChild(); _j++)
  2533. {
  2534. if (_pCurrentCadGroup->GetAt(_j)->IsSelected())
  2535. {
  2536. if (_i == _pCurrentCadGroup->GetAt(_j)->GetParamIndex())
  2537. {
  2538. _isSelect = true;
  2539. }
  2540. }
  2541. }
  2542. if(!_isSelect)
  2543. {
  2544. continue;
  2545. }
  2546. }
  2547. else
  2548. {
  2549. //жϵǰͼѡǷҪѹ;
  2550. for (int _j = 0; _j < _pCurrentCadGroup->GetNumOfChild(); _j++)
  2551. {
  2552. if (_i == _pCurrentCadGroup->GetAt(_j)->GetParamIndex())
  2553. {
  2554. CParam* _pParam = _pParamVector->at(_i);
  2555. if(_pParam->GetKey(c_szOutput) == _T("0"))
  2556. {
  2557. continue;
  2558. }
  2559. //ȴж
  2560. if (_pParam->GetKey(c_szCoolBlowType) == _T("0"))
  2561. {
  2562. _bAirCheck = true;
  2563. }
  2564. if (_pParam->GetKey(c_szCoolBlowType) == _T("1"))
  2565. {
  2566. _bNitrogenCheck = true;
  2567. }
  2568. if (_pParam->GetKey(c_szCoolBlowType) == _T("2"))
  2569. {
  2570. _bOxygenCheck = true;
  2571. }
  2572. if (_pParam->GetKey(c_szCoolBlowType) == _T("3"))
  2573. {
  2574. _bNitrogenCheck = true;
  2575. }
  2576. if (_pParam->GetKey(c_szCoolBlowType) == _T("4"))
  2577. {
  2578. _bOxygenCheck = true;
  2579. }
  2580. //׷ʽ
  2581. //ֱӴ
  2582. if (_pParam->GetKey(c_szPerforateType) == _T("0"))
  2583. {
  2584. //иж
  2585. if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
  2586. {
  2587. _bAirCheck = true;
  2588. }
  2589. if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
  2590. {
  2591. _bNitrogenCheck = true;
  2592. }
  2593. if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
  2594. {
  2595. _bOxygenCheck = true;
  2596. }
  2597. if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
  2598. {
  2599. _bNitrogenCheck = true;
  2600. }
  2601. if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
  2602. {
  2603. _bOxygenCheck = true;
  2604. }
  2605. }
  2606. //׻ֶδ
  2607. if (_pParam->GetKey(c_szPerforateType) == _T("1") || _pParam->GetKey(c_szPerforateType) == _T("2"))
  2608. {
  2609. //иж
  2610. if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
  2611. {
  2612. _bAirCheck = true;
  2613. }
  2614. if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
  2615. {
  2616. _bNitrogenCheck = true;
  2617. }
  2618. if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
  2619. {
  2620. _bOxygenCheck = true;
  2621. }
  2622. if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
  2623. {
  2624. _bNitrogenCheck = true;
  2625. }
  2626. if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
  2627. {
  2628. _bOxygenCheck = true;
  2629. }
  2630. //ж
  2631. if (_pParam->GetKey(c_szPerBlowType) == _T("0"))
  2632. {
  2633. _bAirCheck = true;
  2634. }
  2635. if (_pParam->GetKey(c_szPerBlowType) == _T("1"))
  2636. {
  2637. _bNitrogenCheck = true;
  2638. }
  2639. if (_pParam->GetKey(c_szPerBlowType) == _T("2"))
  2640. {
  2641. _bOxygenCheck = true;
  2642. }
  2643. if (_pParam->GetKey(c_szPerBlowType) == _T("3"))
  2644. {
  2645. _bNitrogenCheck = true;
  2646. }
  2647. if (_pParam->GetKey(c_szPerBlowType) == _T("4"))
  2648. {
  2649. _bOxygenCheck = true;
  2650. }
  2651. }
  2652. //
  2653. if (_pParam->GetKey(c_szPerforateType) == _T("3"))
  2654. {
  2655. //иж
  2656. if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
  2657. {
  2658. _bAirCheck = true;
  2659. }
  2660. if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
  2661. {
  2662. _bNitrogenCheck = true;
  2663. }
  2664. if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
  2665. {
  2666. _bOxygenCheck = true;
  2667. }
  2668. if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
  2669. {
  2670. _bNitrogenCheck = true;
  2671. }
  2672. if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
  2673. {
  2674. _bOxygenCheck = true;
  2675. }
  2676. //һ
  2677. if (_pParam->GetKey(c_szFirstSegPunch) == _T("1"))
  2678. {
  2679. if (_pParam->GetKey(c_szFirstSegBlowType) == _T("0"))
  2680. {
  2681. _bAirCheck = true;
  2682. }
  2683. if (_pParam->GetKey(c_szFirstSegBlowType) == _T("1"))
  2684. {
  2685. _bNitrogenCheck = true;
  2686. }
  2687. if (_pParam->GetKey(c_szFirstSegBlowType) == _T("2"))
  2688. {
  2689. _bOxygenCheck = true;
  2690. }
  2691. if (_pParam->GetKey(c_szFirstSegBlowType) == _T("3"))
  2692. {
  2693. _bNitrogenCheck = true;
  2694. }
  2695. if (_pParam->GetKey(c_szFirstSegBlowType) == _T("4"))
  2696. {
  2697. _bOxygenCheck = true;
  2698. }
  2699. }
  2700. //
  2701. if (_pParam->GetKey(c_szSecondSegPunch) == _T("1"))
  2702. {
  2703. if (_pParam->GetKey(c_szSecondSegBlowType) == _T("0"))
  2704. {
  2705. _bAirCheck = true;
  2706. }
  2707. if (_pParam->GetKey(c_szSecondSegBlowType) == _T("1"))
  2708. {
  2709. _bNitrogenCheck = true;
  2710. }
  2711. if (_pParam->GetKey(c_szSecondSegBlowType) == _T("2"))
  2712. {
  2713. _bOxygenCheck = true;
  2714. }
  2715. if (_pParam->GetKey(c_szSecondSegBlowType) == _T("3"))
  2716. {
  2717. _bNitrogenCheck = true;
  2718. }
  2719. if (_pParam->GetKey(c_szSecondSegBlowType) == _T("4"))
  2720. {
  2721. _bOxygenCheck = true;
  2722. }
  2723. }
  2724. //
  2725. if (_pParam->GetKey(c_szThirdSegPunch) == _T("1"))
  2726. {
  2727. if (_pParam->GetKey(c_szThirdSegBlowType) == _T("0"))
  2728. {
  2729. _bAirCheck = true;
  2730. }
  2731. if (_pParam->GetKey(c_szThirdSegBlowType) == _T("1"))
  2732. {
  2733. _bNitrogenCheck = true;
  2734. }
  2735. if (_pParam->GetKey(c_szThirdSegBlowType) == _T("2"))
  2736. {
  2737. _bOxygenCheck = true;
  2738. }
  2739. if (_pParam->GetKey(c_szThirdSegBlowType) == _T("3"))
  2740. {
  2741. _bNitrogenCheck = true;
  2742. }
  2743. if (_pParam->GetKey(c_szThirdSegBlowType) == _T("4"))
  2744. {
  2745. _bOxygenCheck = true;
  2746. }
  2747. }
  2748. }
  2749. }
  2750. //ӹͬʱҪжһͨͼе
  2751. CParamManager* _pParamManager = GetParamManager();
  2752. ParameterValue _DefaultBlowType;
  2753. _pParamManager->GetParameterValue("GP_DefaultBlowType", &_DefaultBlowType);
  2754. if(0 == _DefaultBlowType.iValue)
  2755. {
  2756. _bAirCheck = true;
  2757. }
  2758. else if ((1 == _DefaultBlowType.iValue) || (3 == _DefaultBlowType.iValue))
  2759. {
  2760. _bNitrogenCheck = true;
  2761. }
  2762. else if ((2 == _DefaultBlowType.iValue) || (4 == _DefaultBlowType.iValue))
  2763. {
  2764. _bOxygenCheck = true;
  2765. }
  2766. CString _strCheckAir("EnableCheckAir");
  2767. SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckAir.GetBuffer()), (LPARAM)&_bAirCheck);
  2768. CString _strCheckOxygen("EnableCheckOxygen");
  2769. SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckOxygen.GetBuffer()), (LPARAM)&_bOxygenCheck);
  2770. CString _strCheckNitrogen("EnableCheckNitrogen");
  2771. SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckNitrogen.GetBuffer()), (LPARAM)&_bNitrogenCheck);
  2772. }
  2773. }
  2774. }
  2775. }
  2776. void CControlTarget::SetSelectMach(bool _bSelectMach)
  2777. {
  2778. m_bSelectMach = _bSelectMach;
  2779. }
  2780. bool CControlTarget::GetSelectMach()
  2781. {
  2782. return m_bSelectMach;
  2783. }

No Description

Contributors (2)