|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087 |
- // ************************************************************************** //
- // ControlTarget.cpp : implementation of the CControlTarget class
- // Copyright(c)2012 Naiky Company. All rights reserved.
- //
- // Abstract:
- // ļʵCControlTargetࡣ
- // ********************************************* ---- ¬ΰ 2012-01-07 ***** //
- #include "StdAfx.h"
- #include "ControlTarget.h"
- #include "CycMachiningTarget.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- CS_T s_csBreakPointResume = _DEFCS(_CSV(18028),
- _CHINESE("ϵ")
- _ENGLISH("BreakPointResume"));
- CS_T s_csGoForward = _DEFCS(_CSV(18029),
- _CHINESE("ǰ")
- _ENGLISH("GoForward"));
- CS_T s_csGoBackward = _DEFCS(_CSV(18030),
- _CHINESE("")
- _ENGLISH("GoBackward"));
- CS_T s_csBACKREFPROMPT = _DEFCS(_CSV(18031),
- _CHINESE("лػеԭ\nǷȷϣ")
- _ENGLISH("It's going to go back to Reference Point\nConform or Not?"));
- CS_T s_csFORBIDORIGINBACK = _DEFCS(_CSV(18032),
- _CHINESE("ǰ㲻ִԶ")
- _ENGLISH("It's forbid to AutoBack at the current point"));
- CS_T s_csFORBIDORIGINFORWARD = _DEFCS(_CSV(18033),
- _CHINESE("ǰ㲻ִԶ")
- _ENGLISH("It's forbid to AutoForward at the current point"));
- CS_T s_csNoObjInFileForAction = _DEFCS(_CSV(18034),
- _CHINESE("|E|ļͼΣ%s!")
- _ENGLISH("|E|No figure in the file, unable to %s!"));
- CS_T s_csFORBIDRESUME = _DEFCS(_CSV(18035),
- _CHINESE("|E|ǰ㲻ִжϵ")
- _ENGLISH("|E|It's forbid to Resume at the current point"));
- CS_T s_csCANNOTSIMUCUT_NOOBJ = _DEFCS(_CSV(18036),
- _CHINESE("ļͼΣ߱߿")
- _ENGLISH("No figure in the file,can not SimuCut!"));
- CS_T s_csCANNOTSIMUCUT_JUST1DOT = _DEFCS(_CSV(18037),
- _CHINESE("ļֻһ㣬߱߿")
- _ENGLISH("Just 1 Dot in the file,can not SimuCut!"));
- CS_T s_csFileChanged = _DEFCS(_CSV(18038),
- _CHINESE("ļģִлӹ\nǷ棿")
- _ENGLISH("File changed, can not mach untill saved!\nSave or not?"));
- CS_T s_cs2YDetectConfigError = _DEFCS(_CSV(18039),
- _CHINESE("|F|˫Yԭ!")
- _ENGLISH("|F|Config for 2YErrorDetecting is wrong, please check!"));
- CS_T s_csOperateDangerous = _DEFCS(_CSV(18040),
- _CHINESE("ǰΣ: ̧иͷ\nǷ...")
- _ENGLISH("Operation dangerous: It's better to raise cutter first.\nContinue or not..."));
- CS_T s_csNHOURSLEFTFORCECLOSE = _DEFCS(_CSV(18041),
- _CHINESE("|F|עڣϵͳ%dСʱԶر!")
- _ENGLISH("|F|The system is expired.\nNcEditor Will Be Closed In %d Hours Without Registered Again!"));
- CS_T s_csNoNearPoint = _DEFCS(_CSV(18042),
- _CHINESE("|E|ûҵڽ㣡")
- _ENGLISH("|E|No near point be found!"));
- CS_T s_csFORBIDNEARSTART = _DEFCS(_CSV(18043),
- _CHINESE("|E|ǰ㲻ִڽӹ")
- _ENGLISH("|E|It's forbid to near start at the current point!"));
- CS_T s_csEXCEEDWORKTABLE = _DEFCS(_CSV(18526),
- _CHINESE("|E|ӹļ̨Χ")
- _ENGLISH("|E|Exceed the worktable travel limit!"));
- CS_T s_szNOAVALIBLEOBJECTTOMACH = _DEFCS(_CSV(18619),
- _CHINESE("ǰ˶ִУȷǷڼӹͼΣѡӹģʽδѡκͼΡ")
- _ENGLISH("Current motion cannot be executed. Please make sure graphic to be machined exists or it has been selected."));
- CS_T s_szCONFIG_TUBE_NOK = _DEFCS(_CSV(18619),
- _CHINESE("ϵͳòּ֧ӹܲļ")
- _ENGLISH("Tube file is not supported under current System Config."));
- CS_T s_szFORSEHOMEBEFORBEGIN = _DEFCS(_CSV(18619),
- _CHINESE("ӹǰȻػеԭ㣡")
- _ENGLISH("Before machining, all axes must go home!"));
-
- static bool _FindObjectByID(IN nce::CCadObject* pCadObj_, IN int nID_, OUT nce::CCadObject** ppResult_);
- typedef std::vector<UINT> vectorUINT;
- void _GetCadIDList(IN nce::CadObjectList* pListCads_, OUT vectorUINT& setIDs_);
- void _GetCamGroupByCadID(IN nce::CCamGroup* pCCamGroup_, IN vectorUINT setIDs_, OUT nce::CCamGroup* pOutCCamGroup_);
-
- const CHAR c_szScanType[] = "ScanType";
- //ʽ
- const char c_szPerforateType[] = "PerforateType";
- //
- const char c_szPerBlowType[] = "PerBlowType";
- //и
- const char c_szCutBlowType[] = "CutBlowType";
- //ȴ
- const char c_szCoolBlowType[] = "CoolBlowType";
- //ͼ㲻ӹ
- const char c_szOutput[] = "Output";
- //һ
- const char c_szFirstSegBlowType[] = "FirstSegBlowType";
- //
- const char c_szSecondSegBlowType[] = "SecondSegBlowType";
- //
- const char c_szThirdSegBlowType[] = "ThirdSegBlowType";
- //һflag
- const char c_szFirstSegPunch[] = "FirstSegPunch";
- //flag
- const char c_szSecondSegPunch[] = "SecondSegPunch";
- //flag
- const char c_szThirdSegPunch[] = "ThirdSegPunch";
-
- using namespace mach;
- using namespace ncmath;
- using namespace nce;
-
- CControlTarget* CControlTarget::ms_pControlTarget = NULL;
- CControlTarget* GetControlTarget()
- {
- return CControlTarget::ms_pControlTarget;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // CControlTarget
- //
- IMPLEMENT_DYNAMIC(CControlTarget, CNceTarget)
- BEGIN_MESSAGE_MAP(CControlTarget, CNceTarget)
- ON_COMMAND(IDCMD_CONTROLTARGET_SHOWCONTROLDLG, OnShowControlDlg)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_SHOWCONTROLDLG, OnUpdateShowControlDlg)
-
- // ɫӦӦдOnCommandǰ ---- 2012-05-25
- ON_COMMAND(IDCMD_CONTROLTARGET_DETECT2YERROR, OnDetect2YError)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_DETECT2YERROR, OnUpdateDetect2YError)
- ON_COMMAND(IDCMD_CONTROLTARGET_CLEARW, OnClearW)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_CLEARW, OnUpdateClearW)
- ON_COMMAND(IDCMD_CONTROLTARGET_CLEARWZ, OnClearWZ)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_CLEARWZ, OnUpdateClearWZ)
- ON_COMMAND(IDCMD_CONTROLTARGET_STOP, OnStop)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_STOP, OnUpdateStop)
- ON_COMMAND(IDCMD_CONTROLTARGET_DIRECTSET, OnDirectSet)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_DIRECTSET, OnUpdateDirectSet)
- ON_COMMAND(IDCMD_CONTROLTARGET_BACKRDLG, OnBackRDlg)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_BACKRDLG, OnUpdateBackRDlg)
- ON_COMMAND(IDCMD_CONTROLTARGET_MACHSELECTED, OnIsMachSelected)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_MACHSELECTED, OnUpdateIsMachSelected)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_STARTSELECTION, OnUpdateStartSelectNotMove)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_ZBACKR, OnUpdateZBackOrg)
- ON_UPDATE_COMMAND_UI(IDCMD_CONTROLTARGET_FOLLOWCONTROL, OnUpdateFollowCtrl)
- ON_TARGET_NOTIFY(TN_NAMEDCOMMAND, OnNamedCommand)
- ON_COMMAND_RANGE(IDCMD_CONTROLTARGET_BACKR, IDCMD_CONTROLTARGET_BACKWARDEND, OnCommand)
- ON_UPDATE_COMMAND_UI_RANGE(IDCMD_CONTROLTARGET_BACKR, IDCMD_CONTROLTARGET_BACKWARDEND, OnUpdateCommandUI)
- ON_TARGET_NOTIFY(TN_TIMER_EVERY40MILLISECOND, OnEvery40Millisecond)
- ON_TARGET_NOTIFY(TN_POST_INITINSTANCE, OnPostInitInstance)
- END_MESSAGE_MAP()
-
- CControlTarget::CControlTarget()
- : c_nMinGFOBDistance(0.01)
- , m_bShowControlDlg(true)
- , m_nGFOBDistance(10.0)
- , m_nGFOBMode(0x00)
- , m_bShowBkrefDlgWhenStart(TRUE)
- , m_nGFOBKeyState(0)
- , m_bEnableKeyMsg(true)
- {
- ASSERT(ms_pControlTarget == NULL);
- ms_pControlTarget = this;
-
- // ---- 2012-04-13
- typedef CControlTarget ThisClass;
- static const CommandItem _s_CommandItems[] =
- {
- // nID strName strCommand strCEParameter pGetEParameter
- // MFC C# CanExecute Execute
- { IDCMD_CONTROLTARGET_BACKR, "BackR", "BackR", NULL, NULL, },
- { IDCMD_CONTROLTARGET_XBACKR, "BackR", "BackR", NULL, &ThisClass::_GetParamForXBackR, },
- { IDCMD_CONTROLTARGET_YBACKR, "BackR", "BackR", NULL, &ThisClass::_GetParamForYBackR, },
- { IDCMD_CONTROLTARGET_ZBACKR, "BackRZ", "BackRZ", NULL, &ThisClass::_GetParamForZBackR, },
- { IDCMD_CONTROLTARGET_DIRECTSET, "DirectSet", "DirectSet", NULL, NULL, },
- { IDCMD_CONTROLTARGET_MOVETOFIXPOS, "BackFP", "BackFixPos", NULL, NULL, },
- { IDCMD_CONTROLTARGET_BACKW, "BackW", "BackW", NULL, NULL, },
- { IDCMD_CONTROLTARGET_CLEARW, "ClearW", "ClearW", NULL, NULL, },
- { IDCMD_CONTROLTARGET_BACKWZ, "BackWZ", "BackWZ", NULL, NULL, },
- { IDCMD_CONTROLTARGET_CLEARWZ, "ClearWZ", "ClearWZ", NULL, NULL, },
- { IDCMD_CONTROLTARGET_SIMUCUT, "WalkBoundRect", "RunGCode", "G00 X0 Y0", &ThisClass::_GetParamForCommand_SimuCut, },
- { IDCMD_CONTROLTARGET_START, "Start", "Start", "0,1", NULL, },
- { IDCMD_CONTROLTARGET_PAUSE, "Pause", "Pause", NULL, NULL, },
- { IDCMD_CONTROLTARGET_STOP, "Stop", "Stop", NULL, NULL, },
- { IDCMD_CONTROLTARGET_STARTSELECTION, "StartSelection", "StartSelection", "0,1", &ThisClass::_GetParamForCommand_MachSelect, },
- { IDCMD_CONTROLTARGET_BREAKPOINTRESUME, "BPResume", "BPResume", "0,1", &ThisClass::_GetParamForCommand_BreakPointResume, },
- { IDCMD_CONTROLTARGET_STARTNEARPOINT, "NearStart", "NearStart", "0,1", &ThisClass::_GetParamForCommand_StartNearPoint, },
- { IDCMD_CONTROLTARGET_SIMULATE, "Simulate", "Simulate", "0,1", NULL, },
- { IDCMD_CONTROLTARGET_DIRRUN, "DirRun", "DirRun", "0,1", NULL, },
- { IDCMD_CONTROLTARGET_FOLLOWCONTROL, "FollowCtrl", "FollowCtrl", NULL, NULL, },
-
- { IDCMD_CONTROLTARGET_JOGFORWARD, "JogForward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_GoForward, },
- { IDCMD_CONTROLTARGET_INCFORWARD, "IncForward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_IncForward, },
- { IDCMD_CONTROLTARGET_JOGBACKWARD, "JogBackward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_GoBackward, },
- { IDCMD_CONTROLTARGET_INCBACKWARD, "IncBackward", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_IncBackward, },
- { IDCMD_CONTROLTARGET_FORWARDBEGIN, "ForwardBegin", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_ForwardBegin, },
- { IDCMD_CONTROLTARGET_BACKWARDBEGIN, "BackwardBegin", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_BackwardBegin, },
- { IDCMD_CONTROLTARGET_FORWARDEND, "ForwardEnd", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_ForwardEnd, },
- { IDCMD_CONTROLTARGET_BACKWARDEND, "BackwardEnd", "DirRunSelection", "0,1", &ThisClass::_GetParamForCommand_BackwardEnd, },
-
- // { IDCMD_CONTROLTARGET_STARTEDGEFIND, "StartAutoEdgeFind", "StartAutoEdgeFind", NULL, NULL },
- };
- m_vectorCommandItems.clear();
- m_vectorCommandItems = CommandItemVector(_s_CommandItems + 0, _s_CommandItems + _countof(_s_CommandItems));
-
- memset(m_KeyStates, 0, sizeof(KeyState) * _countof(m_KeyStates));
-
- static WSItem _s_WSItems[] =
- {
- { "DirRun", "DirRunSelection2", },
- { "Simulate", "SimulateSelection", },
- { "Start", "StartSelection", },
- };
- m_vectorWSItems.clear();
- m_vectorWSItems = WSItemsVector(_s_WSItems + 0, _s_WSItems + _countof(_s_WSItems));
-
- // ӳʼõ֧ ---- 2015-06-12
- CString _strCT = NceGetPrivateProfileString(_T("ControlTarget"), NULL);
- CString _strSBD = NceGetPrivateProfileString(_T("ControlTarget"), _T("ShowBkrefDlg"));
- if (_strCT == "" || _strSBD == "0" || _strSBD == "false" || _strSBD == "False" || _strSBD == "FALSE")
- {
- m_bShowBkrefDlgWhenStart = FALSE;
- }
- m_bAutoZBkrefWhenStart = FALSE;
-
- CString _strEnableMotionAccel = NceGetPrivateProfileString(_T("ControlTarget"), _T("EnableMotionAccel"), _T("1"));
- if (_strEnableMotionAccel == _T("0"))
- {
- m_bEnableKeyMsg = false;
- }
-
- m_pwndControlDlg = NULL;
- m_bIsMinSize = false;
-
- LOAD_PARAM(this, CControlTarget);
- }
-
- CControlTarget::~CControlTarget()
- {
- ASSERT(ms_pControlTarget == this);
- ms_pControlTarget = NULL;
-
- SAVE_PARAM(this, CControlTarget);
- }
-
- void CControlTarget::Initialize()
- {
- // ûCommandManagerĬϲʾ ---- 2012-06-22
- ASSERT(m_bShowControlDlg == true);
- if (!mach::GetCommandManager())
- {
- m_bShowControlDlg = true;
- }
- }
-
- bool CControlTarget::CanExecuteCommand(LPCSTR pszCommand_, LPCSTR pszParameter_)
- {
- ASSERT(pszCommand_ && pszCommand_[0]);
-
- bool _bCanExecute = false;
- CCommandManager* _pCommandManager = mach::GetCommandManager();
- if (!_pCommandManager
- || pszParameter_ && pszParameter_[0] && !_pCommandManager->CanExecute(pszCommand_, pszParameter_, "LPCSTR", &_bCanExecute)
- || (!pszParameter_ || !pszParameter_[0]) && !_pCommandManager->CanExecute(pszCommand_, &_bCanExecute))
- {
- return false;
- }
-
- return _bCanExecute;
- }
-
- bool CControlTarget::ExecuteCommand(LPCSTR pszCommand_, LPCSTR pszParameter_)
- {
- ASSERT(pszCommand_ && pszCommand_[0]);
-
- CCommandManager* _pCommandManager = mach::GetCommandManager();
- if (!_pCommandManager)
- {
- return false;
- }
-
- if (pszParameter_ && pszParameter_[0] && !_pCommandManager->Execute(pszCommand_, pszParameter_, "LPCSTR")
- || (!pszParameter_ || !pszParameter_[0]) && !_pCommandManager->Execute(pszCommand_))
- {
- return false;
- }
-
- return true;
- }
-
- void CControlTarget::OnNamedCommand(WPARAM wParam_, LPARAM lParam_)
- {
- const CStringA _c_strTargetName = "CControlTarget";
- if (_c_strTargetName != (PCSTR)wParam_)
- {
- return;
- }
-
- // ---- 2012-04-13
- for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
- {
- const CommandItem& _item = m_vectorCommandItems[_i];
- if (_item.strName != (PCSTR)lParam_)
- {
- ASSERT(_i != m_vectorCommandItems.size() - 1);
- continue;
- }
-
- // ֮Բֱӵõӳһ飬ּھȷĶ
- // 壺ǸID͵һString͵ַ֣ʽ
- // ID͵ ---- 2012-04-14
- OnCmdMsg(_item.nID, 0, NULL, NULL);
- break;
- }
- }
-
- void CControlTarget::OnShowControlDlg()
- {
- m_bShowControlDlg = !m_bShowControlDlg;
- UpdateAllVisions();
- }
-
- void CControlTarget::OnMinControlDlg()
- {
- ((CMachineControlDlg_Left*)m_pwndControlDlg)->OnMinSize();
- }
-
- void CControlTarget::OnMaxControlDlg()
- {
- ((CMachineControlDlg_Left*)m_pwndControlDlg)->OnMaxSize();
- }
-
- void CControlTarget::OnUpdateShowControlDlg(CCmdUI* pCmdUI_)
- {
- ASSERT(pCmdUI_);
-
- // ǰʾʱEnalbe˵ʹԲʾǰʾʱҪCommandManagerʱ
- // Enable˵Աʾ ---- 2012-06-22
- bool _bEnable = m_bShowControlDlg || mach::GetCommandManager() != NULL;
- pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
-
- bool _bCheck = m_bShowControlDlg;
- pCmdUI_->SetCheck(_bCheck ? 1 : 0);
- }
-
- void CControlTarget::OnCommand(UINT nID_)
- {
- //ӹʱжϵǰӹͼѹǷ
- if (nID_ == IDCMD_CONTROLTARGET_START)
- {
- _SendGasPressureInfo();
- }
- //ϰLT汾,λʱ,ģ ---20170623
- if ((nID_ == IDCMD_CONTROLTARGET_SIMULATE) || (nID_ == IDCMD_CONTROLTARGET_BACKR))
- {
- CString _flag = NceGetPrivateProfileString(_T("ZPLimit"), _T("ZPLimitCheck"), _T("0"));
- CString _Portflag = NceGetPrivateProfileString(_T("ZPLimit"), _T("StopperPort"), _T("0"));
- if ("1" == _flag)
- {
- mach::CPortsManager* _pPortsManager = mach::GetPortsManager();
- BitPort _Port;
- ASSERT(_pPortsManager);
- if (_pPortsManager)
- {
- _pPortsManager->GetBitPort((LPCSTR)_Portflag, &_Port);
- if(_Port.bValue)
- {
- return;
- }
- }
- }
- }
- if ((nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_SIMULATE))
- {
- CTubeTarget* _pTubeTarget = GetTubeTarget();
- ASSERT(_pTubeTarget);
- // ܲļ֧ڷǹܲ·/ӹ ---- yangxiaobin 2017-01-09
- if (_pTubeTarget->IsTubeFile() && !_pTubeTarget->IsEnable())
- {
- NceShowMessage(_GETCS(s_szCONFIG_TUBE_NOK));
- return;
- }
- }
-
- //ڵʱʱڣʼͿаťȡѭķֹͣѭӹ ----liangyan 2013-9-22
- if (nID_ == IDCMD_CONTROLTARGET_START || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
- {
- int m_nTimeRemain = 0;
- CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
- if (_pCycMachiningTarget->GetCountDownRemain(&m_nTimeRemain) && m_nTimeRemain > 0)
- {
- _pCycMachiningTarget->SetEnable(FALSE);
- return;
- }
- }
-
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- mach::CParamManager* _pParamManager = mach::GetParamManager();
- ASSERT(_pParamManager);
- mach::ParameterValue _PV;
- memset(&_PV, 0, sizeof(mach::ParameterValue));
- _pParamManager->GetParameterValue("ForceHome", &_PV);
- ASSERT(_PV.nType = mach::ParameterValue::VT_BOOL);
- bool _bForceHome = _PV.bValue;
-
- memset(&_PV, 0, sizeof(mach::ParameterValue));
- _pParamManager->GetParameterValue("ChannelIsRefered", &_PV);
- ASSERT(_PV.nType = mach::ParameterValue::VT_BOOL);
- if (!_PV.bValue && _bForceHome)
- {
- AfxMessageBox(_GETCS(s_szFORSEHOMEBEFORBEGIN));
- return;
- }
- }
-
- // ---- 2012-04-13
- size_t _nCmdIndex = m_vectorCommandItems.size();
- for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
- {
- const CommandItem& _item = m_vectorCommandItems[_i];
- if (nID_ != _item.nID)
- {
- continue;
- }
-
- _nCmdIndex = _i;
- break;
- }
- if (_nCmdIndex < 0 || m_vectorCommandItems.size() <= _nCmdIndex)
- {
- ASSERT(FALSE);
- return;
- }
-
- // ԤϢ ---- 2016-09-07
- if (!m_vectorCommandItems[_nCmdIndex].strCommand.IsEmpty())
- {
- CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
- CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
- if (SendTargetMessage(ID_TARGET_BROADCAST, TM_COMMAND_PREEXECUTE, (WPARAM)(PCSTR)_strCommand, (LPARAM)(PCSTR)_strParameter) != 0L)
- {
- return;
- }
- }
-
- // ΪؼƣػеԭǰҪʾ ---- 2012-04-14
- if (nID_ == IDCMD_CONTROLTARGET_BACKR
- || nID_ == IDCMD_CONTROLTARGET_XBACKR
- || nID_ == IDCMD_CONTROLTARGET_YBACKR
- || nID_ == IDCMD_CONTROLTARGET_ZBACKR)
- {
- if (AfxMessageBox(_GETCS(s_csBACKREFPROMPT), MB_OKCANCEL) != IDOK)
- return;
- }
-
- // ²߱߿ ---- η 2017-01-11
- if (nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- CTubeTarget* _pTubeTarget = GetTubeTarget();
- if (_pTubeTarget && _pTubeTarget->IsEnable())
- {
- return;
- }
- }
-
-
-
- // жͼΣͼΪһ㣬߱߿ ---- 2012-02-23
- if (nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- nce::CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
- ASSERT(_pCurrentCadGroup);
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- DRECT _rcBound;
- if (_pStateManager->IsSelectedMach())
- {
- CSelectTarget* _pSelectTarget = GetSelectTarget();
- ASSERT(_pSelectTarget);
- const CadObjectList* _plistSelectObjs = _pSelectTarget->GetSelectedCadObjects();
- _rcBound = _plistSelectObjs && _plistSelectObjs->size() > 0 ? _pSelectTarget->GetSelObjsBoundRect() : DRECT(0.0, 0.0, 0.0, 0.0);
- }
- else
- {
- _rcBound = _pCurrentCadGroup->GetBoundRect();
- }
-
- if (_rcBound.width <= 0.0 && _rcBound.height <= 0.0)
- {
- NceShowMessage(_GETCS(s_szNOAVALIBLEOBJECTTOMACH));
- return;
- }
- }
-
- // ѭӹֹͣٿʼʾǷѭӹѭӹ굱ǰ
- // ӹˡ ---- ƺ 2016-03-16
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
- {
- CCycMachiningTarget* _pCycMachiningTarget = GetCycMachiningTarget();
- if (_pCycMachiningTarget
- && _pCycMachiningTarget->GetEnable()
- && _pCycMachiningTarget->GetCycTimes() - 1 > _pCycMachiningTarget->GetCycDones()
- && (_pCycMachiningTarget->IsInterrupt()
- || _pCycMachiningTarget->GetCycDones() == 0)
- && NceGetPrivateProfileString(_T("ControlTarget"), _T("CycStartPrompt")) == _T("1"))
- {
- CContineCyclicalMachDlg* _pwndDlg = GetContineCyclicalMachDlg();
- ASSERT(_pwndDlg);
- if (_pwndDlg->DoModal() == IDCANCEL)
- return;
- }
- }
-
- // ʼӹʱԶԵǰΪͣ ---- 2014-04-28
- // ʼӹʱԶִ
- // ʼӹ߱߿նж ---- DingQiang 2015-06-09
- static DWORD _s_nLastTime = ::GetTickCount();
- mach::CStateManager::State _nState = mach::CStateManager::Invalid;
- if ((nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- && mach::GetStateManager()->GetState(&_nState)
- && _nState == mach::CStateManager::Idle
- && NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoClearW")) == _T("1"))
- {
- // νʱ300msĻͲˣΪ˽ֱָԻ⡣
- // ͨʽǺܺãʱʵPLCдֱϢٵPLCд
- // ---- ƺ 2015-10-10
- CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
- CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
- DWORD _nCurTime = ::GetTickCount();
- DWORD _nSpaceTime = _nCurTime - _s_nLastTime;
- bool _bSmallInterval = false;
- if (_nSpaceTime < 300 && _s_nLastTime != _nCurTime)
- {
- _bSmallInterval = true;
- }
- _s_nLastTime = _nCurTime;
- if (CanExecuteCommand(_strCommand, _strParameter) && !_bSmallInterval)
- OnCmdMsg(IDCMD_CONTROLTARGET_CLEARW, 0, NULL, NULL);
- }
-
- // ʼӹ桢Сѡӹ֮ǰʾļ ---- 2012-04-14
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_SIMULATE
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
- || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME
- || nID_ == IDCMD_CONTROLTARGET_JOGFORWARD
- || nID_ == IDCMD_CONTROLTARGET_INCFORWARD
- || nID_ == IDCMD_CONTROLTARGET_JOGBACKWARD
- || nID_ == IDCMD_CONTROLTARGET_INCBACKWARD
- || nID_ == IDCMD_CONTROLTARGET_FORWARDBEGIN
- || nID_ == IDCMD_CONTROLTARGET_BACKWARDBEGIN
- || nID_ == IDCMD_CONTROLTARGET_FORWARDEND
- || nID_ == IDCMD_CONTROLTARGET_BACKWARDEND
- || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT
- || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- if (!_CheckFileSaved())
- return;
- }
-
- // ûмӹļʱϵǰ˲ ---- ž 2012-05-25
- ASSERT(GetFileTarget());
- if (GetFileTarget()->GetCurrentCadGroup()->GetNumOfChild() <= 0)
- {
- #define _PromptEmpty(Id, Action) \
- if (nID_ == Id) \
- { \
- CString _strPrompt; \
- _strPrompt.Format(_GETCS(s_csNoObjInFileForAction), Action); \
- NceShowMessage(_strPrompt); \
- return; \
- }
- _PromptEmpty(IDCMD_CONTROLTARGET_BREAKPOINTRESUME, _GETCS(s_csBreakPointResume));
- _PromptEmpty(IDCMD_CONTROLTARGET_JOGFORWARD, _GETCS(s_csGoForward));
- _PromptEmpty(IDCMD_CONTROLTARGET_INCFORWARD, _GETCS(s_csGoForward));
- _PromptEmpty(IDCMD_CONTROLTARGET_FORWARDBEGIN, _GETCS(s_csGoForward));
- _PromptEmpty(IDCMD_CONTROLTARGET_FORWARDEND, _GETCS(s_csGoForward));
- _PromptEmpty(IDCMD_CONTROLTARGET_JOGBACKWARD, _GETCS(s_csGoBackward));
- _PromptEmpty(IDCMD_CONTROLTARGET_INCBACKWARD, _GETCS(s_csGoBackward));
- _PromptEmpty(IDCMD_CONTROLTARGET_BACKWARDBEGIN, _GETCS(s_csGoBackward));
- _PromptEmpty(IDCMD_CONTROLTARGET_BACKWARDEND, _GETCS(s_csGoBackward));
- #undef _PromptEmpty
- }
-
- // ӹǷλ ---- ƺ 2015-09-29
- ASSERT(m_vectorCommandItems[_nCmdIndex].nID == nID_);
- CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
- CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].pGetEParameter ? (this->*m_vectorCommandItems[_nCmdIndex].pGetEParameter)() : "";
-
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
- || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME
- || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT
- || nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- if (_IsOutsideTheSotfLimit(_strParameter))
- {
- NceShowMessage(_GETCS(s_csEXCEEDWORKTABLE));
- return;
- }
- }
- //зʱֻдʾǻӹ-----20170714
- if (nID_ == IDCMD_CONTROLTARGET_SIMULATE)
- {
- bool _bSimOutRange = false;
- if (_IsOutsideTheSotfLimit(_strParameter))
- {
- _bSimOutRange = true;
- }
- CString _strSimOutRange("SimOutRange");
- SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strSimOutRange.GetBuffer()), (LPARAM)&_bSimOutRange);
- }
- // ߱߿ܾε֧ͼιԼӹѡйܣӹλжѾһʱעͣжϺͳһ ----˼ 2017-06-14
- // ߱߿ڲǼӹȫͼΣҲǼӹѡͼΣҪλ
- //if(nID_ == IDCMD_CONTROLTARGET_SIMUCUT)
- //{
- // if (_IsRectOutsideTheSotfLimit(_strParameter))
- // {
- // NceShowMessage(_GETCS(s_csEXCEEDWORKTABLE));
- // return;
- // }
- //}
-
- // ʼӹǰ֪ͨģеǰͼȡ ----ƺ 2015-05-27
- CString _strAutoAdjust = NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoAdjustView"));
- if ((nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_SIMUCUT
- || nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME)
- && _strAutoAdjust == _T("1"))
- {
- SendTargetMessage(ID_TARGET_VIEWPORTADJUST, TN_TASKSTART);
- SendTargetMessage(ID_TARGET_TUBE, TN_TASKSTART);
- }
-
- // ڹܲãʼӹͼֲͬ ---- η 2016-12-30
- if (nID_ == IDCMD_CONTROLTARGET_SIMULATE && _strAutoAdjust == _T("1"))
- {
- SendTargetMessage(ID_TARGET_VIEWPORTADJUST, TN_TASKSTART);
- SendTargetMessage(ID_TARGET_TUBE, TN_TASKSTART_SIMULATE);
- }
-
- // 統ǰΪѡӹӦѡӹָ ---- ƺ 2016-09-27
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_SIMULATE
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN)
- {
- // ͣʱÿʼָѡӹ ---- ƺ 2016-09-06
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- mach::CStateManager::State _nState = CStateManager::Idle;
- if(_pStateManager->GetState(&_nState)
- && _nState != CStateManager::Pausing
- && _pStateManager->IsSelectedMach())
- {
- ASSERT(_strParameter.IsEmpty());
- _strParameter = _GetParamForCommand_MachSelect();
- if (_strParameter.IsEmpty())
- {
- NceShowMessage(_GETCS(s_szNOAVALIBLEOBJECTTOMACH));
- return;
- }
-
- for (int _i = 0; _i < (int)m_vectorWSItems.size(); _i++)
- {
- if (_strCommand != m_vectorWSItems[_i].strWholeMachCommand)
- continue;
- _strCommand = m_vectorWSItems[_i].strSelectMachCommand;
- break;
- }
- }
- }
-
- if (nID_ == IDCMD_CONTROLTARGET_BREAKPOINTRESUME)
- {
- for (int _i = 0; _i < (int)m_vectorWSItems.size(); _i++)
- {
- // һξѡӹֱӵһָ ---- ƺ 2016-09-03
- if (m_vectorWSItems[_i].strSelectMachCommand == m_strLastTaskCommand)
- {
- _strCommand = m_strLastTaskCommand;
- break;
- }
-
- // һӹѡӹָʵ֡ ---- ƺ 2016-09-03
- if (m_vectorWSItems[_i].strWholeMachCommand == m_strLastTaskCommand)
- {
- _strCommand = m_vectorWSItems[_i].strSelectMachCommand;
- break;
- }
- }
- }
-
- // ʵӹͿвֶ֧ϵ ---- ƺ 2016-09-03
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_DIRRUN
- || nID_ == IDCMD_CONTROLTARGET_STARTSELECTION
- || nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT)
- {
- m_strLastTaskCommand = _strCommand;
- m_strLastTaskCommandParam = _strParameter;
- }
-
- // ǰȼʾԤʱ ---- 2016-10-11
- if (nID_ == IDCMD_CONTROLTARGET_START
- || nID_ == IDCMD_CONTROLTARGET_SIMULATE)
- {
- CalculateOneHoleTime();
- CTubeTarget* _pTubeTarget = GetTubeTarget();
- ASSERT(_pTubeTarget);
- if (!_pTubeTarget->IsEnable())
- {
- // ܲòʾ
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_RUNREPORTTARGET_SHOWESTIMATION);
- // Fix TFS work item #2739 to enable shortcut keys
- AfxGetMainWnd()->SetFocus();
- }
- }
-
- // ¼һ¶ϵλá
- if ((nID_ != IDCMD_CONTROLTARGET_BREAKPOINTRESUME && _strCommand == _T("StartSelection")) ||
- (nID_ == IDCMD_CONTROLTARGET_STARTNEARPOINT && _strCommand == _T("NearStart")))
-
- {
- NceFilePos _nPos = _SelectionFirst(_strParameter);
- CStateManager* _pStateManager = GetStateManager();
- _pStateManager->SetSelectedMachFilePos(_nPos);
- }
-
- // ---- 2012-04-14
- ExecuteCommand(_strCommand, _strParameter);
- }
-
- void CControlTarget::OnUpdateCommandUI(CCmdUI* pCmdUI_)
- {
- // ---- 2012-04-13
- size_t _nCmdIndex = m_vectorCommandItems.size();
- for (size_t _i = 0; _i < m_vectorCommandItems.size(); _i++)
- {
- const CommandItem& _item = m_vectorCommandItems[_i];
- if (pCmdUI_->m_nID != _item.nID)
- {
- continue;
- }
-
- _nCmdIndex = _i;
- break;
- }
- if (_nCmdIndex < 0 || m_vectorCommandItems.size() <= _nCmdIndex)
- {
- // ˭ֽ ---- 2012-08-06
- ASSERT(FALSE);
- return;
- }
-
- // ---- 2012-04-14
- bool _bEnable = false;
- ASSERT(m_vectorCommandItems[_nCmdIndex].nID == pCmdUI_->m_nID);
- CStringA _strCommand = m_vectorCommandItems[_nCmdIndex].strCommand;
- CStringA _strParameter = m_vectorCommandItems[_nCmdIndex].strCEParameter;
- _bEnable = CanExecuteCommand(_strCommand, _strParameter);
- static const struct RunningStateItem
- {
- UINT nID;
- DWORD nMask;
- } _s_cItem[] =
- {
- {IDCMD_CONTROLTARGET_START, 0x00000001},
- {IDCMD_CONTROLTARGET_SIMULATE, 0x00000002},
- {IDCMD_CONTROLTARGET_DIRRUN, 0x00000004},
- {IDCMD_CONTROLTARGET_SIMUCUT, 0x00000008},
- {IDCMD_CONTROLTARGET_BACKR, 0x00000010},
- {IDCMD_CONTROLTARGET_BACKW, 0x00000020},
- {IDCMD_CONTROLTARGET_MOVETOFIXPOS, 0x00000040},
- {IDCMD_CONTROLTARGET_PAUSE, 0},
- };
-
- for (int _i = 0; _i < _countof(_s_cItem); _i++)
- {
- if (pCmdUI_->m_nID == _s_cItem[_i].nID)
- {
- CStateManager* _pStateManager = GetStateManager();
- if (!_pStateManager)
- {
- break;
- }
-
- BOOL _bCheck = FALSE;
- if (pCmdUI_->m_nID == IDCMD_CONTROLTARGET_PAUSE)
- {
- // ͣ
- mach::CStateManager::State _nState = CStateManager::Idle;
- if(_pStateManager->GetState(&_nState) && _nState == CStateManager::Pausing)
- {
- _bCheck = TRUE;
- }
- }
- else
- {
- DWORD _nRunningState = 0;
- _pStateManager->GetRunningState(&_nRunningState);
- _bCheck = _nRunningState & _s_cItem[_i].nMask;
- }
-
- // ߱߿ ---- η 2017-01-11
- if (pCmdUI_->m_nID == IDCMD_CONTROLTARGET_SIMUCUT)
- {
- CTubeTarget* _pTubeTarget = GetTubeTarget();
- if (_pTubeTarget && _pTubeTarget->IsEnable())
- {
- _bEnable = FALSE;
- }
- }
-
- if (_bEnable)
- {
- pCmdUI_->SetCheck(FALSE);
- pCmdUI_->Enable();
- return;
- }
-
- if (_bCheck)
- {
- pCmdUI_->SetCheck();
- }
- else
- {
- pCmdUI_->SetCheck(FALSE);
- pCmdUI_->Enable(_bEnable);
- }
-
- return;
- }
- }
-
- pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
- }
-
- // ð취
- // [Detect2YError]
- // Enable="1"
- // Subprogram="BKREF-2YERROR-DETECT"
- // УEnableڱʾǷ ˫Yƫ⣬SubprogramΪ˫Yƫӳ
- // ---- 2012-06-21
- void CControlTarget::OnDetect2YError()
- {
- CString _strEnable = NceGetPrivateProfileString(_T("Detect2YError"), _T("Enable"), _T("0"));
- _strEnable.Trim();
- if (_strEnable == _T("0"))
- {
- ASSERT(FALSE);
- return;
- }
-
- // ȡӳRunGCode ---- 2012-06-21
- CStringA _strSubprogram = NceGetPrivateProfileString(_T("Detect2YError"), _T("Subprogram"));
- if (_strSubprogram.IsEmpty())
- {
- ASSERT(FALSE);
- return;
- }
-
- // ʾȷ ---- 2012-06-21
- if (AfxMessageBox(_GETCS(s_csOperateDangerous), MB_YESNO) != IDYES)
- {
- return;
- }
-
- // ִм ---- 2012-06-21
- CStringA _strGCode;
- _strGCode.Format("G65 P\"%s\" L1\n", _strSubprogram);
- ExecuteCommand("RunGCode", _strGCode);
- }
-
- // ð취
- // [Detect2YError]
- // Enable="1"
- // Subprogram="BKREF-2YERROR-DETECT"
- // УEnableڱʾǷ ˫Yƫ⣬ʾ˵ĬΪá
- // ---- 2012-06-21
- void CControlTarget::OnUpdateDetect2YError(CCmdUI* pCmdUI_)
- {
- ASSERT(pCmdUI_);
-
- if (pCmdUI_->m_pMenu)
- {
- CString _strEnable = NceGetPrivateProfileString(_T("Detect2YError"), _T("Enable"), _T("0"));
- _strEnable.Trim();
- if (_strEnable == _T("0"))
- {
- pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
- return;
- }
- }
-
- // ȡӳжǷRunGCode ---- 2012-06-21
- CStringA _strSubprogram = NceGetPrivateProfileString(_T("Detect2YError"), _T("Subprogram"));
- if (_strSubprogram.IsEmpty())
- {
- pCmdUI_->Enable(FALSE);
- return;
- }
-
- CStringA _strGCode;
- _strGCode.Format("G65 P\"%s\" L1\n", _strSubprogram);
- if (!CanExecuteCommand("RunGCode", _strGCode))
- {
- pCmdUI_->Enable(FALSE);
- return;
- }
-
- pCmdUI_->Enable(TRUE);
- }
-
- void CControlTarget::OnClearW()
- {
- // ͨActionɣԱɳ ---- 2012-03-30
- SendTargetMessage(ID_TARGET_SETORIGIN, TN_SETORIGIN, 0, 0);
- CClearWorkcoorAction::Do(TRUE); // ɳ
- }
-
- void CControlTarget::OnUpdateClearW(CCmdUI* pCmdUI_)
- {
- bool _bCanExecute = CanExecuteCommand("ClearW", NULL);
- pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
- }
-
- void CControlTarget::OnClearWZ()
- {
- CClearWorkcoorActionZ::Do(TRUE);
- }
-
- void CControlTarget::OnUpdateClearWZ(CCmdUI* pCmdUI_)
- {
- // ӹʱҲֶZĹԭ㡣 ---- ƺ 2014-12-23
- CStateManager* _pStateManager = GetStateManager();
- CStateManager::State _nState = CStateManager::Idle;
- bool _bCanExecute = _pStateManager
- && _pStateManager->GetState(&_nState)
- && (_nState == CStateManager::Idle
- || _nState == CStateManager::Estop
- || _nState == CStateManager::Invalid)
- && CanExecuteCommand("ClearWZ", NULL);
- pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
- }
-
- void CControlTarget::OnStop()
- {
- ASSERT(!CanExecuteCommand("Stop", NULL) || !CanExecuteCommand("StopSimulate", NULL));
-
- if (CanExecuteCommand("Stop", NULL))
- {
- ExecuteCommand("Stop", NULL);
- }
-
- if (CanExecuteCommand("StopSimulate", NULL))
- {
- ExecuteCommand("StopSimulate", NULL);
- }
- }
-
- void CControlTarget::OnUpdateStop(CCmdUI* pCmdUI_)
- {
- ASSERT(!CanExecuteCommand("Stop", NULL) || !CanExecuteCommand("StopSimulate", NULL));
- bool _bCanExecute = CanExecuteCommand("Stop", NULL) || CanExecuteCommand("StopSimulate", NULL);
- bool _bBoardSupport = NceGetPrivateProfileString(_T("ControlTarget"), _T("BoardSupport")) == _T("1");
- // ϶˿ڴʱͷһ״̬ԻʹstopstopsimulateͬʱΪtrue
- // Ϊ˶϶˿ڴʱֹֹͣʱһжϽ⣬ӦĽ----2017.06.27 ˼
- if (_bBoardSupport)
- {
- mach::CPortsManager* _pPortsManager = mach::GetPortsManager();
- mach::BitPort _BitPort;
- _pPortsManager->GetBitPort("10038", &_BitPort);
- if (_BitPort.bValue)
- {
- _bCanExecute = false;
- }
- }
- pCmdUI_->Enable(_bCanExecute ? TRUE : FALSE);
- }
-
- void CControlTarget::OnBackRDlg()
- {
- CBkrefDlg _dlg;
- _dlg.m_bShowBkrefDlgWhenStart = m_bShowBkrefDlgWhenStart;
- _dlg.m_bAutoZBkrefWhenStart = m_bAutoZBkrefWhenStart;
- _dlg.DoModal();
- m_bShowBkrefDlgWhenStart = _dlg.m_bShowBkrefDlgWhenStart;
- m_bAutoZBkrefWhenStart = _dlg.m_bAutoZBkrefWhenStart;
- }
-
- void CControlTarget::OnUpdateBackRDlg(CCmdUI* pCmdUI_)
- {
- }
-
- void CControlTarget::OnUpdateZBackOrg(CCmdUI* pCmdUI_)
- {
- bool _bShow = NceGetPrivateProfileString(_T("ControlTarget"), _T("EnableZ"), " ") == "1";
- if (pCmdUI_->m_pMenu && !_bShow)
- {
- pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
- }
- pCmdUI_->Enable(CanExecuteCommand("BackRZ", "Z"));
- }
-
- void CControlTarget::OnUpdateFollowCtrl(CCmdUI* pCmdUI_)
- {
- bool _bEnable = CanExecuteCommand("FollowCtrl", NULL);
- pCmdUI_->Enable(_bEnable ? TRUE : FALSE);
- if (pCmdUI_->m_pMenu && !_bEnable)
- {
- pCmdUI_->m_pMenu->DeleteMenu(pCmdUI_->m_nID, MF_BYCOMMAND);
- }
- }
-
- void CControlTarget::OnIsMachSelected()
- {
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- BOOL _bMachSelected = _pStateManager->IsSelectedMach();
- _bMachSelected = !_bMachSelected;
- _pStateManager->SetSelectedMach(_bMachSelected);
- //üӹѡͼǷѡflagCMachineControlDlgͬ----20170712
- ((CMachineControlDlg*)m_pwndControlDlg)->SetSelectMach(_bMachSelected);
- }
-
- void CControlTarget::OnUpdateIsMachSelected(CCmdUI* pCmd_)
- {
- CStateManager* _pStateManager = GetStateManager();
- CStateManager::State _nState = CStateManager::Idle;
- bool _bEnable = _pStateManager
- && _pStateManager->GetState(&_nState)
- && _nState == CStateManager::Idle;
- pCmd_->SetCheck(_pStateManager && _pStateManager->IsSelectedMach());
- pCmd_->Enable(_bEnable);
- }
-
- void CControlTarget::OnUpdateStartSelectNotMove(CCmdUI* pCmd_)
- {
- CStateManager* _pStateManager = GetStateManager();
- CStateManager::State _nState = CStateManager::Idle;
- bool _bEnable = _pStateManager
- && _pStateManager->GetState(&_nState)
- && _nState == CStateManager::Idle
- && CanExecuteCommand("StartSelection", "0,1");
- pCmd_->Enable(_bEnable);
- }
-
- // ʱVision ---- 2012-04-17
- void CControlTarget::OnEvery40Millisecond(WPARAM wParam_, LPARAM lParam_)
- {
- _DoTraceKeyState();
-
- // Every 160 Millisecond ---- 2012-04-17
- static int _s_nTimerCount = rand();
- _s_nTimerCount = (_s_nTimerCount + 1) % 4;
- if (_s_nTimerCount == 0)
- {
- UpdateVisions();
- }
- }
-
- void CControlTarget::OnPostInitInstance(WPARAM wParam_, LPARAM lParam_)
- {
- if (m_bShowBkrefDlgWhenStart)
- {
- CWnd* _pMainWnd = AfxGetMainWnd();
- ASSERT(_pMainWnd);
- _pMainWnd->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_BACKRDLG, 0L);
- }
-
- if (m_bAutoZBkrefWhenStart)
- {
- // ֱӵִУCMDϢִлᵯһȷ϶Ի ---- DingQiang 2016-09-18
- ExecuteCommand("BackRZ", NULL);
- }
-
- bool _bCheckWPosition = (NceGetPrivateProfileString(_T("ExchangeWorkbench"), _T("Enable"), _T("0")) == "1");
- if (_bCheckWPosition)
- {
- CWnd* _pMainWnd = AfxGetMainWnd();
- ASSERT(_pMainWnd);
- _pMainWnd->SendMessage(WM_COMMAND, IDCMD_EXCHANGEWORKBENCHTARGET_CHECKWPOSITION, 0L);
- }
- }
-
- void CControlTarget::OnDirectSet()
- {
- // XYͨеԭ־ ---- ƺ 2015-01-04
- if (CanExecuteCommand("DirectSet", NULL))
- {
- ExecuteCommand("DirectSet", NULL);
- }
-
- // Zͨеԭ־ ---- ƺ 2015-01-04
- if (CanExecuteCommand("DirectSetZ", NULL))
- {
- ExecuteCommand("DirectSetZ", NULL);
- }
- }
-
- void CControlTarget::OnUpdateDirectSet(CCmdUI* pCmdUI_)
- {
- bool _bCanExecute = CanExecuteCommand("DirectSet", NULL) || CanExecuteCommand("DirectSetZ", NULL);
- pCmdUI_->Enable(_bCanExecute);
- }
-
- bool CControlTarget::_CheckFileSaved()
- {
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- if (!_pFileTarget->IsModified()) // ѱ
- {
- return true;
- }
-
- bool _bNeedPrompt;
- // ȡiniļIJ---- DingQiang 2012-05-07
- CString _strTranslateType = NceGetPrivateProfileString(_T("ControlTarget"), _T("NeedPromptSave"));
- int _nTranslateType = atoi(_strTranslateType);
- switch (_nTranslateType)
- {
- case 0: _bNeedPrompt = false; break;
- case 1: _bNeedPrompt = true; break;
- default: ASSERT(FALSE); _bNeedPrompt = true;
- }
-
- if (!_bNeedPrompt)
- {
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_FILETARGET_SAVE_WITHOUTDIALOG);
- if (!_pFileTarget->IsModified())
- {
- return true;
- }
- else
- return false;
- }
- else
- {
- if (AfxMessageBox(_GETCS(s_csFileChanged), MB_YESNO) == IDYES) // ʾ
- {
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_FILETARGET_SAVE);
- if (!_pFileTarget->IsModified())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else // ʾˣ
- {
- ASSERT(_pFileTarget->IsModified());
- return false;
- }
- }
- }
-
- bool CControlTarget::_CheckWorktable()
- {
- // ǰcamӾ ---- DingQiang 2015-09-30
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- static CSimuCutHelper _s_SimuCutHelper;
- DRECT _rcBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
-
- // ̨ ---- DingQiang 2015-09-30
- double _pWorktable[4];
- DRECT _rcWorktable;
- SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
- _rcWorktable.x = _pWorktable[0];
- _rcWorktable.y = _pWorktable[1];
- _rcWorktable.width = _pWorktable[2];
- _rcWorktable.height = _pWorktable[3];
-
- return _rcWorktable.Contains(_rcBound);
- }
-
- // ߱߿Gָ ---- 2012-04-14
- CStringA CControlTarget::_GetParamForCommand_SimuCut()
- {
- // ǰͼεӾ ---- 2012-04-14
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- DRECT _rcBound;
- DRECT _rcBoundLast;
- if (_pStateManager->IsSelectedMach())
- {
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
- if (NULL == _pCamGroup || NULL == _pCadGroup)
- {
- return "";
- }
-
- if (_pCamGroup->GetNumOfChild() <= 0 || _pCadGroup->GetNumOfChild() <= 0)
- {
- return "";
- }
-
- // ѡмӹֱѡCAM ---- η 2017-06-08
- bool _bFirstRect = true;
- CamObjectList* _plistCamObjs = _pCamGroup->GetObjectsList();
- for (CamObjectList::const_iterator _it = _plistCamObjs->begin(); _it != _plistCamObjs->end(); _it++)
- {
- // ҪغϵCAM
- CCamObject* _pCam = *_it;
- CCadObject* _pCad = NULL;
-
- // CamеCadIDҵӦCad
- bool _bFound = _FindObjectByID(_pCadGroup, (int)_pCam->GetKey_DBL("CadID"), &_pCad);
- ASSERT(_bFound);
-
- // TFS#4040 - ѡмӹͼ߱߿ɾijͼΣ߱߿false ---- yangxiaobin
- if (!_bFound)
- continue;
- if (_pCad!=NULL && _pCad->IsSelected())
- {
- static CSimuCutHelper _s_SimuCutHelper;
- _rcBoundLast = _s_SimuCutHelper._GetBoundRect_Object(_pCam);
- if (_bFirstRect)
- {
- _rcBound = _rcBoundLast;
- _bFirstRect = false;
- }
- else
- {
- DRECT::Union(_rcBound, _rcBound, _rcBoundLast);
- }
- }
- }
- }
- else
- {
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- static CSimuCutHelper _s_SimuCutHelper;
- _rcBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
- }
-
- if (_rcBound.width < 0.0 || _rcBound.height < 0.0)
- {
- return "";
- }
-
- // ʱ߱߿
- DPOINT2 _ptCor[] = // Corner
- {
- DPOINT2(_rcBound.GetLeft(), _rcBound.GetBottom()),
- DPOINT2(_rcBound.GetRight(), _rcBound.GetBottom()),
- DPOINT2(_rcBound.GetRight(), _rcBound.GetTop()),
- DPOINT2(_rcBound.GetLeft(), _rcBound.GetTop()),
- };
-
- // Ѳ߶λӾο ---- 2012.11.14
- CWCSAdjustTarget* _pWCSAdjustTarget = GetWCSAdjustTarget();
- if (_pWCSAdjustTarget)
- {
- for (int _i = 0; _i < _countof(_ptCor); _i++)
- {
- _ptCor[_i] = _pWCSAdjustTarget->DoWCSAdjust(_ptCor[_i]);
- }
- }
-
- // ᵱǰλʼ ---- 2012-04-14
- size_t _nBSI = 0; // BestStartIndex
- if (CParamManager* _pParamManager = GetParamManager())
- {
- DPOINT2 _ptCurrentPos;
- ParameterValue _ParameterValueAxis0;
- ParameterValue _ParameterValueAxis1;
- _pParamManager->GetParameterValue("State_Axis0_WorkcoorPos", &_ParameterValueAxis0);
- _pParamManager->GetParameterValue("State_Axis1_WorkcoorPos", &_ParameterValueAxis1);
- if ((_ParameterValueAxis0.nType == ParameterValue::VT_DOUBLE)
- &&(_ParameterValueAxis1.nType == ParameterValue::VT_DOUBLE))
- {
- _ptCurrentPos.x = _ParameterValueAxis0.dValue;
- _ptCurrentPos.y = _ParameterValueAxis1.dValue;
-
- double _nBestDistance = DBL_MAX;
- for (size_t _i = 0; _i < _countof(_ptCor); _i++)
- {
- double _nDistance = (_ptCor[_i] - _ptCurrentPos).GetLength();
- if (_nDistance < _nBestDistance)
- {
- _nBSI = _i;
- _nBestDistance = _nDistance;
- }
- }
- }
- }
-
- // ñڱҪ߱߿ͼεӾɵG ---- 2012-02-24
- CStringA _strGCode = "";
-
- // ԱRunCodeʱ֪ʲô
- _strGCode.Append("'Command=SimuCut\n");
-
- // дʱʹÿɵCodeDzһ
- SYSTEMTIME _t;
- GetLocalTime(&_t);
- _strGCode.AppendFormat("'Time=%d-%02d-%02d %02d:%02d:%02d\n", _t.wYear, _t.wMonth, _t.wDay, _t.wHour, _t.wMinute, _t.wSecond);
-
- // ִ߱߿ǰһЩ涯ر涯ȡ ---- ƺ 2015-10-11
- CStringA _strPreSubPro = NceGetPrivateProfileString(_T("ControlTarget"), _T("PreSimuCutActions"));
- if (!_strPreSubPro.IsEmpty())
- {
- CStringA _strPreActions;
- _strPreActions.Format("G65 P\"%s\" L1\n", _strPreSubPro);
- _strGCode.AppendFormat(_strPreActions);
- }
-
- // ߱߿ٶ
- CStringA _strG = "G00";
- CStringA _strF = "";
- CString _strSimuCutSpeed = NceGetPrivateProfileString(_T("ControlTarget"), _T("SimuCutSpeed"));
- if (!_strSimuCutSpeed.IsEmpty())
- {
- _strG = "G905 G00";
- _strF.Format("F=%s", CStringA(_strSimuCutSpeed));
- }
-
- C_ASSERT(_countof(_ptCor) == 4);
- _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 0) % 4].x, _ptCor[(_nBSI + 0) % 4].y, _strF);
- _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 1) % 4].x, _ptCor[(_nBSI + 1) % 4].y, _strF);
- _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 2) % 4].x, _ptCor[(_nBSI + 2) % 4].y, _strF);
- _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 3) % 4].x, _ptCor[(_nBSI + 3) % 4].y, _strF);
- _strGCode.AppendFormat("%s X%.4f Y%.4f %s\r\n", _strG, _ptCor[(_nBSI + 4) % 4].x, _ptCor[(_nBSI + 4) % 4].y, _strF);
- if(NceGetPrivateProfileString(_T("ControlTarget"), _T("AutoClearW")) == _T("1"))
- {
- // ʼǰ˵ǰΪԭ㣬Ҫԭ ---- DingQiang 2015-06-09
- _strGCode.AppendFormat("G65 P\"TOORG\" L1\n");
- }
- return _strGCode;
- }
-
- // ϵ ---- DingQiang 2015-06-30
- CStringA CControlTarget::_GetParamForCommand_BreakPointResume()
- {
- //ִжϵǰжµǰѹǷ
- _SendGasPressureInfo();
-
- // ȡǰõĶϵλһ:
- // 0ûʾĬϵļλãֹͣʱļλá
- // 1ʾֹͣϢʱλãʱһںִֹͣǰع⣬ļλ
- // õĿľΪܽϹعλ ---- DingQiang 2015-06-30
- CString _strBPPT = NceGetPrivateProfileString(_T("ControlTarget"), _T("BreakPointPosType"));
- int _nBPPT = _strBPPT.IsEmpty() ? 0 : atoi(_strBPPT);
-
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- ASSERT(_nBPPT == 0 || _nBPPT == 1);
- NceFilePos _StartPos;
- if (_nBPPT == 0)
- {
- _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
- }
- else
- {
- ParameterValue _ParameterValue;
- memset(&_ParameterValue, 0, sizeof(ParameterValue));
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- _pParamManager->GetParameterValue("PreStopFilePos", &_ParameterValue);
- ASSERT(_ParameterValue.nType == ParameterValue::VT_INT64);
- // 1. Get start position
- _StartPos = _ParameterValue.i64Value;
- }
-
- CString _strBackDistance = NceGetPrivateProfileString(_T("BreakPointFallback"), _T("BreakPointFallbackDistance"));
- double _nBackDistance = atof(_strBackDistance);
- ASSERT(_nBackDistance >= 0.0);
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
-
- // ˺λΪϵʼλ ---- ߿ϼ 2016-10-10
- if (_pStartCamObject && DOUBLE_GREAT(_nBackDistance, 0.0))
- {
- // ǰӹļյ㲻л ---- ߿ϼ 2016-11-02
- NceFilePos _CurrentCamEndPos;
- _CurrentCamEndPos = CFilePositionHelper::ScanEndPos(_pStartCamObject);
- bool _bStartPos = DOUBLE_EQU(_StartPos.nOffset, 0.0) && DOUBLE_EQU(_StartPos.nRate, 0.0);
- bool _bEndPos = _StartPos == _CurrentCamEndPos;
-
- if (!_bStartPos && !_bEndPos)
- {
- int _nBackOffset = _StartPos.nOffset;
- double _nBackRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, _nBackDistance, &_nBackOffset, &_nBackRate, &_nActualTravelLength);
- ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= _nBackDistance);
-
- _StartPos.nOffset = _nBackOffset;
- _StartPos.nRate = _nBackRate;
- }
- }
-
- if (_StartPos <= EOF)
- {
- _StartPos = 0;
- }
-
- _pStateManager->SetSelectedMachFilePos(_StartPos);
-
- if (!_pStateManager->IsSelectedMach())
- {
- NceFilePos _nEndPos;
- _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
- if (_pStartCamObject && _pStartCamObject->GetType() == campath)
- {
- int _nEndOffset = _StartPos.nOffset;
- double _nEndRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
- &_nEndOffset, &_nEndRate, &_nActualTravelLength);
- ASSERT(_bSucceed);
- if (_nActualTravelLength <= 1.0e-2)
- {
- // ϵ·ʣº٣·ĩʼ ---- 2012-04-14
- _StartPos.nOffset = _nEndOffset;
- _StartPos.nRate = _nEndRate;
- }
- }
-
- if (!_pStartCamObject
- || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
- || (__int64)_StartPos == (__int64)_nEndPos)
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- return "";
- }
-
- CStringA _strParameter;
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- return _strParameter;
- }
-
- ASSERT(m_strLastTaskCommand == _T("StartSelection")
- || m_strLastTaskCommand == _T("NearStart")
- || m_strLastTaskCommand == _T("DirRunSelection2"));
-
- ASSERT(!m_strLastTaskCommandParam.IsEmpty());
- CStringA _strParameter = _Mid(m_strLastTaskCommandParam, _StartPos);
- if (_strParameter.IsEmpty())
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- }
-
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_GoForward()
- {
- // 1. Get start position
- NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
- if (_StartPos <= EOF)
- {
- _StartPos = 0;
- }
-
- // 2. Get end position
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- NceFilePos _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
-
- // 3. Working
- const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
- if (_pStartCamObject && _pStartCamObject->GetType() == campath)
- {
- int _nEndOffset = _StartPos.nOffset;
- double _nEndRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
- &_nEndOffset, &_nEndRate, &_nActualTravelLength);
- ASSERT(_bSucceed);
- if (_nActualTravelLength <= 1.0e-2)
- {
- // ϵ·ʣº٣·ĩʼ ---- 2012-04-14
- _StartPos.nOffset = _nEndOffset;
- _StartPos.nRate = _nEndRate;
- }
- }
-
- if (!_pStartCamObject
- || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
- || (__int64)_StartPos == (__int64)_nEndPos)
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- return "";
- }
-
- CStringA _strParameter;
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_StartNearPoint()
- {
- //ִٽӹǰжµǰѹǷ
- _SendGasPressureInfo();
-
- //ҵǰλ ---- DingQiang 2013-06-28
- DPOINT2 _ptCur;
- CParamManager* _pParamManager = GetParamManager();
- ASSERT(_pParamManager);
- ParameterValue _ParameterValue;
- memset(&_ParameterValue, 0, sizeof(ParameterValue));
- _pParamManager->GetParameterValue("State_Axis0_WorkcoorPos", &_ParameterValue);
- ASSERT(_ParameterValue.nType == ParameterValue::VT_DOUBLE);
- _ptCur.x = _ParameterValue.dValue;
- _pParamManager->GetParameterValue("State_Axis1_WorkcoorPos", &_ParameterValue);
- ASSERT(_ParameterValue.nType == ParameterValue::VT_DOUBLE);
- _ptCur.y = _ParameterValue.dValue;
-
- // ڽ뾶 ---- DingQiang 2013-06-26
- CString _strNearRadius = NceGetPrivateProfileString(_T("ControlTarget"), _T("NearPointRadius"));
- double _nNearRadius = _tstof(_strNearRadius);
-
- // ҵҪϵCadͼεID ---- DingQiang 2013-06-26
- CFileTarget* _pFileTarget = GetFileTarget();
- const CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
- setUINT _setIDs;
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- if (_pStateManager->IsSelectedMach())
- {
- // ǹѡ<ӹѡͼ>Ǵѡͼȡڽͼ ---- 2016-09-13
- CSelectTarget* _pSelectTarget = GetSelectTarget();
- ASSERT(_pSelectTarget);
- const CadObjectList* _plistSelectedCads = _pSelectTarget->GetSelectedCadObjects();
- ASSERT(_plistSelectedCads);
- CCadGroup _group;
- *(_group.GetObjectsList()) = *_plistSelectedCads;
- GetCadIDByCircle(&_group, _ptCur, _nNearRadius, _setIDs);
- _group.PickOffAll();
- }
- else
- {
- GetCadIDByCircle(_pCurrentCadGroup, _ptCur, _nNearRadius, _setIDs);
- }
-
- if (_setIDs.size() == 0)
- {
- NceShowMessage(_GETCS(s_csNoNearPoint));
- return "";
- }
-
- // camҵЩIDϵcamݣĿ㵽ÿcamľ룬
- // cam ---- DingQiang 2013-06-26
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- CamObjectList _listCam;
- GetCamListByCadID(_pCamGroup, _setIDs, &_listCam);
- if (_listCam.size() == 0)
- {
- NceShowMessage(_GETCS(s_csNoNearPoint));
- return "";
- }
-
- // ĵļλ ---- DingQiang 2013-06-27
- __int64 _StartPos = 0;
- double _nMinDis = GetCamMinDistance(&_listCam, _ptCur, &_StartPos);
- ASSERT(_nMinDis < DBL_MAX);
-
- CStringA _strParameter;
- if (_pStateManager->IsSelectedMach())
- {
- // ǹѡ<ӹѡͼ>ǴѡͼεļӹΧѡȡ ---- 2016-09-13
- _strParameter = _Mid(_GetParamForCommand_MachSelect(), _StartPos);
- }
- else
- {
- NceFilePos _nEndPos = CFilePositionHelper::ScanEndPos(_pCamGroup);
- if((__int64)_StartPos != (__int64)_nEndPos)
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- }
-
- // ʼͽٵͬһλʱӹ ---- DingQiang 2013-06-28
- if (_strParameter.IsEmpty())
- {
- NceShowMessage(_GETCS(s_csFORBIDNEARSTART));
- }
-
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_MachSelect()
- {
- // MAKE_NCEPOS()
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
- ASSERT(_pCadGroup);
- setUINT _selectCadId;
- GetCadSelectID(_pCadGroup, _selectCadId);
- if (_selectCadId.size() == 0)
- {
- return "";
- }
-
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- listCamInfo _selectCamInfo;
- GetCamSelectID(_pCamGroup, _selectCadId, _selectCamInfo);
- if (_selectCamInfo.size() == 0)
- {
- return "";
- }
-
- CStringA _str;
- for (listCamInfo::const_iterator _it = _selectCamInfo.begin(); _it != _selectCamInfo.end(); ++_it)
- {
- _str.AppendFormat("%lld,%lld;", _it->nStartPos, _it->nEndPos);
- }
-
- if (!_str.IsEmpty())
- {
- _str = _str.Left(_str.GetLength() - 1);
- }
- return _str;
- }
-
- CStringA CControlTarget::_GetParamForCommand_GoBackward()
- {
- // 1. Get start position
- NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
- if (_StartPos <= EOF)
- {
- _StartPos = 0;
- }
-
- // 2. Get end position
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- NceFilePos _nEndPos = CFilePositionHelper::ScanStartPos(_pCamGroup);
-
- // 3. Working
- const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
- if (_pStartCamObject && _pStartCamObject->GetType() == campath)
- {
- int _nEndOffset = _StartPos.nOffset;
- double _nEndRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
- &_nEndOffset, &_nEndRate, &_nActualTravelLength);
- ASSERT(_bSucceed);
- if (_nActualTravelLength <= 1.0e-2)
- {
- // ϵ·ʣº٣·ͷʼ ---- 2012-04-14
- _StartPos.nOffset = _nEndOffset;
- _StartPos.nRate = _nEndRate;
- }
- }
-
- if (!_pStartCamObject
- || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
- || (__int64)_StartPos == (__int64)_nEndPos)
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- return "";
- }
-
- CStringA _strParameter;
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_IncForward()
- {
- // 1. Get start position
- NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
- if (_StartPos <= EOF)
- {
- _StartPos = 0;
- }
-
- // 2. Get end position
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- ASSERT(m_nGFOBDistance > 0.0);
- NceFilePos _nEndPos = _StartPos;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelForward(_pCamGroup,
- _StartPos, m_nGFOBDistance, &_nEndPos, &_nActualTravelLength);
- ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= m_nGFOBDistance);
-
- // 3. Working
- const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
- if (_pStartCamObject && _pStartCamObject->GetType() == campath)
- {
- int _nEndOffset = _StartPos.nOffset;
- double _nEndRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelForward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
- &_nEndOffset, &_nEndRate, &_nActualTravelLength);
- ASSERT(_bSucceed);
- if (_nActualTravelLength <= 1.0e-2)
- {
- // ϵ·ʣº٣·ͷʼ ---- 2012-04-14
- _StartPos.nOffset = _nEndOffset;
- _StartPos.nRate = _nEndRate;
- }
- }
-
- if (!_pStartCamObject
- || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
- || (__int64)_StartPos == (__int64)_nEndPos)
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- return "";
- }
-
- CStringA _strParameter;
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_IncBackward()
- {
- // 1. Get start position
- NceFilePos _StartPos = CFilePositionHelper::GetCurrentMachFilePosition();
- if (_StartPos <= EOF)
- {
- _StartPos = 0;
- }
-
- // 2. Get end position
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- ASSERT(_pCamGroup);
- ASSERT(m_nGFOBDistance > 0.0);
- NceFilePos _nEndPos = _StartPos;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelBackward(_pCamGroup,
- _StartPos, m_nGFOBDistance, &_nEndPos, &_nActualTravelLength);
- ASSERT(0.0 <= _nActualTravelLength && _nActualTravelLength <= m_nGFOBDistance);
-
- // 3. Working
- const CCamObject* _pStartCamObject = CFilePositionHelper::FindCamObjectByID(_pCamGroup, _StartPos.nID);
- if (_pStartCamObject && _pStartCamObject->GetType() == campath)
- {
- int _nEndOffset = _StartPos.nOffset;
- double _nEndRate = _StartPos.nRate;
- double _nActualTravelLength = 0.0;
- bool _bSucceed = CFilePositionHelper::TravelBackward(dynamic_cast<const CCamPath*>(_pStartCamObject),
- _StartPos.nOffset, _StartPos.nRate, 1.0e-1,
- &_nEndOffset, &_nEndRate, &_nActualTravelLength);
- ASSERT(_bSucceed);
- if (_nActualTravelLength <= 1.0e-2)
- {
- // ϵ·ʣº٣·ͷʼ ---- 2012-04-14
- _StartPos.nOffset = _nEndOffset;
- _StartPos.nRate = _nEndRate;
- }
- }
-
- if (!_pStartCamObject
- || _pStartCamObject->GetType() != camhole && _pStartCamObject->GetType() != campath
- || (__int64)_StartPos == (__int64)_nEndPos)
- {
- NceShowMessage(_GETCS(s_csFORBIDRESUME));
- return "";
- }
-
- CStringA _strParameter;
- _strParameter.Format("%lld,%lld", (__int64)_StartPos, (__int64)_nEndPos);
- return _strParameter;
- }
-
- CStringA CControlTarget::_GetParamForCommand_ForwardBegin()
- {
- CStringA _strRet;
- if (GetGFOBMode() == 0x00)
- {
- _strRet = _GetParamForCommand_GoForward();
- }
-
- return _strRet;
- }
-
- CStringA CControlTarget::_GetParamForCommand_BackwardBegin()
- {
- CStringA _strRet;
- if (GetGFOBMode() == 0x00)
- {
- _strRet = _GetParamForCommand_GoBackward();
- }
-
- return _strRet;
- }
-
- CStringA CControlTarget::_GetParamForCommand_ForwardEnd()
- {
- CStringA _strRet;
- if (GetGFOBMode() == 0x00)
- {
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_STOP, 0);
- return _strRet;
- }
-
- ASSERT(GetGFOBMode() == 0x01);
- _strRet = _GetParamForCommand_IncForward();
- return _strRet;
- }
-
- CStringA CControlTarget::_GetParamForCommand_BackwardEnd()
- {
- CStringA _strRet;
- if (GetGFOBMode() == 0x00)
- {
- AfxGetMainWnd()->SendMessage(WM_COMMAND, IDCMD_CONTROLTARGET_STOP, 0);
- return _strRet;
- }
-
- ASSERT(GetGFOBMode() == 0x01);
- _strRet = _GetParamForCommand_IncBackward();
- return _strRet;
- }
-
- CStringA CControlTarget::_GetParamForXBackR()
- {
- return "X";
- }
-
- CStringA CControlTarget::_GetParamForYBackR()
- {
- return "Y";
- }
-
- CStringA CControlTarget::_GetParamForZBackR()
- {
- return "Z";
- }
-
- CStringA CControlTarget::_GetParamForCommand_BackWZ()
- {
- return "G65 P\"TOZORG\" L1\n";
- }
-
- void CControlTarget::_ToTraceKeyState(UINT nChar_, bool bEnable_)
- {
- // ٸ٣ ---- 2013-09-06
- if (!bEnable_)
- {
- for(int _i = 0; _i < _countof(m_KeyStates); _i++)
- {
- KeyState& _ks = m_KeyStates[_i];
- if (_ks.nChar == nChar_)
- {
- _ks.nChar = 0;
- _ks.nState = 0;
- }
- }
- return;
- }
-
- // ʼ٣¼ֵ ---- 2013-09-06
- BOOL _nInitState = ::GetKeyState(nChar_) < 0 ? 1 : 0;
-
- for(int _i = 0; _i < _countof(m_KeyStates); _i++)
- {
- KeyState& _ks = m_KeyStates[_i];
- if (_ks.nChar == nChar_)
- {
- _ks.nState = _nInitState;
- return;
- }
- }
-
- for(int _i = 0; _i < _countof(m_KeyStates); _i++)
- {
- KeyState& _ks = m_KeyStates[_i];
- if (_ks.nChar == 0)
- {
- _ks.nChar = nChar_;
- _ks.nState = _nInitState;
- return;
- }
- }
-
- // No slot to trace any more ---- 2013-09-06
- ASSERT(FALSE);
- }
-
- void CControlTarget::_DoTraceKeyState()
- {
- for(int _i = 0; _i < _countof(m_KeyStates); _i++)
- {
- KeyState& _ks = m_KeyStates[_i];
- if (_ks.nChar == 0)
- {
- continue;
- }
-
- BOOL _nState = ::GetKeyState(_ks.nChar) < 0 ? 1 : 0;
- if (_nState != _ks.nState)
- {
- _ks.nState = _nState;
-
- // ٵİ״̬ģΪϢ ---- 2013-09-06
- MSG _msg = { NULL, _nState == 0 ? WM_KEYUP : WM_KEYDOWN, WPARAM(_ks.nChar), LPARAM(1) };
- OnKeyMessage(&_msg);
- }
- }
- }
-
- void CControlTarget::GetCadSelectID(IN const CCadGroup* pCadGroup_, OUT setUINT& setIDs_)
- {
- ASSERT(pCadGroup_);
- int _nNumOfChild = pCadGroup_->GetNumOfChild();
- const CCadObject* _pCadObject = NULL;
- typedef std::pair<setUINT::iterator, bool> pairRet;
- for (int _i = 0; _i != _nNumOfChild; ++_i)
- {
- _pCadObject = pCadGroup_->GetAt(_i);
- if (_pCadObject->IsSelected())
- {
- pairRet _Ret = setIDs_.insert(_pCadObject->GetID());
- ASSERT(_Ret.second);
- }
- if (_pCadObject->GetType() == cadgroup)
- {
- GetCadSelectID((CCadGroup*)_pCadObject, setIDs_);
- }
-
- // ѡͼΪʱҲҪݹID ---- DingQiang 2012-11-30
- if (_pCadObject->GetType() == cadtext)
- {
- CCadText* _pCadText = (CCadText*)_pCadObject;
- GetCadSelectID(_pCadText->GetTextGroup(), setIDs_);
- }
- }
- }
-
- void CControlTarget::GetCamSelectID(IN const nce::CCamGroup* pCamGroup_, IN const setUINT& setIDs_, OUT listCamInfo& setCamInfo_)
- {
- ASSERT(pCamGroup_);
- ASSERT(setIDs_.size());
- int _nNumOfChild = pCamGroup_->GetNumOfChild();
- for (int _i = 0; _i != _nNumOfChild; ++_i)
- {
- const CCamObject* _pCamObject = pCamGroup_->GetAt(_i);
- cam_t _elet = _pCamObject->GetType();
- if (_elet == camgroup)
- {
- GetCamSelectID((CCamGroup*)_pCamObject, setIDs_, setCamInfo_);
- }
- else
- {
- ASSERT(_elet == camhole || _elet == campath);
- UINT _nID = (UINT)_pCamObject->GetKey_DBL("CadID");
- if (setIDs_.find(_nID) != setIDs_.end())
- {
- // ʹCFilePositionHelperļλõؼ ---- 2015-08-30
- CamInfo _caminfo = {
- _pCamObject->GetID(),
- CFilePositionHelper::ScanStartPos(_pCamObject),
- CFilePositionHelper::ScanEndPos(_pCamObject)};
- setCamInfo_.push_back(_caminfo);
- }
- }
- }
- }
-
- void CControlTarget::GetCadIDByCircle(IN const nce::CCadGroup* pCCadGroup_, DPOINT2 ptCenter_, double nRadius_, OUT setUINT& setIDs_)
- {
- ASSERT(pCCadGroup_);
- int _nNumOfChild = pCCadGroup_->GetNumOfChild();
- const CCadObject* _pCadObject = NULL;
- for (int _it = 0; _it < _nNumOfChild; _it++)
- {
- _pCadObject = pCCadGroup_->GetAt(_it);
- if (_pCadObject->GetType() == cadgroup)
- {
- GetCadIDByCircle((CCadGroup*)_pCadObject, ptCenter_, nRadius_, setIDs_);
- continue;
- }
-
- if (_pCadObject->GetType() == cadtext)
- {
- GetCadIDByCircle(((CCadText*)_pCadObject)->GetTextGroup(), ptCenter_, nRadius_, setIDs_);
- continue;
- }
-
- double _nMinDis = GetMinDistance(_pCadObject, ptCenter_);
- if (_nMinDis <= nRadius_)
- {
- setIDs_.insert(_pCadObject->GetID());
- }
- }
- }
-
- void CControlTarget::GetCamListByCadID(IN nce::CCamGroup* pCCamGroup_, IN setUINT setIDs_, OUT CamObjectList* plistCamObject)
- {
- ASSERT(pCCamGroup_);
- ASSERT(plistCamObject->size() == 0);
- CCamObject* _pCamObject = NULL;
- for (int _it = 0; _it < pCCamGroup_->GetNumOfChild(); _it++)
- {
- _pCamObject = pCCamGroup_->GetAt(_it);
- if (_pCamObject->GetType() == camgroup)
- {
- GetCamListByCadID((CCamGroup*)_pCamObject, setIDs_, plistCamObject);
- continue;
- }
-
- UINT _CadID = (UINT)_pCamObject->GetKey_DBL("CadID");
- if (setIDs_.find(_CadID) != setIDs_.end())
- {
- plistCamObject->push_back(_pCamObject);
- }
- }
- }
-
- // ҵһCadIDӦCam ---- ƺ 2017-05-21
- void CControlTarget::GetFirstCamObjByCadID(IN nce::CCamGroup* pCCamGroup_, IN UINT nCadID_, OUT CCamObject** ppCamObject_)
- {
- ASSERT(pCCamGroup_ && ppCamObject_);
- CamObjectList* _plistCamObjs = pCCamGroup_->GetObjectsList();
- for (CamObjectList::iterator _it = _plistCamObjs->begin();
- _it != _plistCamObjs->end(); _it++)
- {
- // ųԤײĵ㡣 ---- ƺ 2017-05-21
- if ((*_it)->GetKey_DBL("CadID") == nCadID_
- && (*_it)->GetType() == campath)
- {
- *ppCamObject_ = *_it;
- return;
- }
- }
- }
-
- double CControlTarget::GetCamMinDistance(IN const nce::CCamObject* pCamObject_, IN DPOINT2 pt_, OUT __int64* pnPos_ /* = NULL */)
- {
- ASSERT(pCamObject_);
-
- double _nMinDis = DBL_MAX;
- cam_t _type = pCamObject_->GetType();
- switch (_type)
- {
- case camhole:
- {
- CCamHole* _pCamHole = (CCamHole*)pCamObject_;
- _nMinDis = GetCamMinDistance(_pCamHole, pt_, pnPos_);
- }
- break;
- case campath:
- {
- CCamPath* _pCamPath = (CCamPath*)pCamObject_;
- _nMinDis = GetCamMinDistance(_pCamPath, pt_, pnPos_);
- }
- break;
- case camgroup:
- {
- CCamGroup* _pCamGroup = (CCamGroup*)pCamObject_;
- _nMinDis = GetCamMinDistance(_pCamGroup->GetObjectsList(), pt_, pnPos_);
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return _nMinDis;
- }
-
- double CControlTarget::GetCamMinDistance(IN const nce::CCamHole* pCamHole_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
- {
- ASSERT(pCamHole_);
- DPOINT2 _ptTemp(pCamHole_->GetStart().x, pCamHole_->GetStart().y);
-
- if (pnPos_)
- {
- NceFilePos _pos;
- _pos.SetID(pCamHole_->GetID());
- _pos.SetOffset(0);
- _pos.SetRate(0);
-
- *pnPos_ = (__int64)_pos;
- }
-
- return (pt_ - _ptTemp).GetLength();
- }
-
- double CControlTarget::GetCamMinDistance(IN const nce::CCamPath* pCamPath_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
- {
- ASSERT(pCamPath_ != NULL);
- double _nMinDis = DBL_MAX;
- __int64 _nPos = 0;
-
- // PathNURBS·NURBSģ̾뼰Ӧļλ ---- duquan 2016-07-28
- CCamSplineWrapper _CamSplineWrapper(pCamPath_);
- if (_CamSplineWrapper.IsSpline())
- {
- NceFilePos _pos;
- _pos.SetID(pCamPath_->GetID());
- _pos.SetOffset(0);
- _pos.SetRate(0.);
-
- _nMinDis = _CamSplineWrapper.GetMinDistFromAimPos(pt_, &_pos);
- _nPos = (__int64)_pos;
- if (pnPos_ != NULL)
- *pnPos_ = _nPos;
-
- return _nMinDis;
- }
-
- UINT _nNodeCount = pCamPath_->GetNodeCount();
- for (UINT _it = 0; _it < _nNodeCount; _it++)
- {
- double _nDistance = DBL_MAX;
- double _nRate = 0;
-
- CCamPath::NODE _nNode = pCamPath_->GetNode(_it);
- CCamPath::NODE_T _typeNode = _nNode.nType;
- if (_typeNode == CCamPath::nt_line_xy
- || _typeNode == CCamPath::nt_line_x
- || _typeNode == CCamPath::nt_line_y)
- {
- DPOINT2 _ptStart(_nNode.ptStart.x, _nNode.ptStart.y);
- DPOINT2 _ptEnd(_nNode.ptEnd.x, _nNode.ptEnd.y);
- DPOINT2 _vecTemp = pt_ - _ptStart;
- DPOINT2 _vecLine = _ptEnd - _ptStart;
- double _nTemp = _vecTemp * _vecLine;
- double _nValue = _vecLine * _vecLine;
- ASSERT(_nValue >= 0.0);
-
- DPOINT2 _point;
- if (_nTemp < 0.0)
- {
- _point = _ptStart;
- _nRate = 0;
- }
- else if (_nTemp > _nValue)
- {
- _point = _ptEnd;
- _nRate = 1;
- }
- else
- {
- LineD2D _line(_ptStart, _ptEnd);
- D2GetProjectionPoint(pt_, _line, &_point);
- _nRate = (_point - _ptStart).GetLength() / (_ptEnd - _ptStart).GetLength();
- }
-
- _nDistance = (pt_ - _point).GetLength();
- }
- else if (_typeNode == CCamPath::nt_arc_xy)
- {
- DPOINT2 _ptStart(_nNode.ptStart.x, _nNode.ptStart.y);
- DPOINT2 _ptEnd(_nNode.ptEnd.x, _nNode.ptEnd.y);
- DPOINT2 _ptCenter;
- double _nStartAngle;
- double _nRadius;
- double _nSweptAngle;
- SEGMENT::SolveArc(_ptStart, _ptEnd, _nNode.nBulge, &_ptCenter, &_nRadius, &_nStartAngle, &_nSweptAngle);
-
- DPOINT2 _vector = pt_ - _ptCenter;
- double _nAngle = D2GetNormalAngle(_vector);
- double _nMin = _nSweptAngle > 0 ? _nStartAngle : _nStartAngle + _nSweptAngle;
- double _nMax = _nSweptAngle > 0 ? _nStartAngle + _nSweptAngle : _nStartAngle;
- bool _bInRange = IsInRange(_nAngle, _nMin, _nMax);
- if (_bInRange)
- {
- _nDistance = abs((pt_ - _ptCenter).GetLength() - _nRadius);
- _nRate = (_nAngle - _nStartAngle) / _nSweptAngle;
- }
- else
- {
- double _nDis1 = (pt_ - _ptStart).GetLength();
- double _nDis2 = (pt_ - _ptEnd).GetLength();
- if (_nDis1 < _nDis2)
- {
- _nDistance = _nDis1;
- _nRate = 0;
- }
- else
- {
- _nDistance = _nDis2;
- _nRate = 1;
- }
- }
- }
- else if (_typeNode == CCamPath::nt_circle_xy_cw
- || _typeNode == CCamPath::nt_circle_xy_ccw)
- {
- DPOINT2 _ptCenter(_nNode.ptCenter.x, _nNode.ptCenter.y);
- DPOINT2 _vector = pt_ - _ptCenter;
- double _nRadius = _nNode.nRadius;
- double _nAngle = D2GetNormalAngle(_vector);
- double _nLength = (pt_ - _ptCenter).GetLength();
- if (_typeNode == CCamPath::nt_circle_xy_cw)
- {
- _nRate = (2 * c_nPIE - _nAngle) / (2 * c_nPIE);
- }
- else
- {
- _nRate = _nAngle / (2 * c_nPIE);
- }
-
- _nDistance = abs(_nLength - _nRadius);
- }
- else
- {
- ASSERT(FALSE);
- continue;
- }
-
- if (_nDistance < _nMinDis)
- {
- _nMinDis = _nDistance;
- NceFilePos _pos;
- _pos.SetID(pCamPath_->GetID());
-
- // յ㣬ҵĵСʱͼ ---- DingQiang 2013-07-08
- if (pCamPath_->GetStartPoint() == pCamPath_->GetEndPoint()
- && _it == _nNodeCount -1
- && abs(_nRate - 1) < 1.0e-2)
- {
- _pos.SetOffset(0);
- _pos.SetRate(0);
- }
- else
- {
- _pos.SetOffset(_it);
- _pos.SetRate(_nRate);
- }
-
- _nPos = (__int64)_pos;
- }
- }
-
- if (pnPos_)
- {
- *pnPos_ = _nPos;
- }
-
- return _nMinDis;
- }
-
- double CControlTarget::GetCamMinDistance(IN const nce::CamObjectList* plistCamObject_, IN DPOINT2 pt_, OUT __int64* pnPos_ /*= NULL*/)
- {
- ASSERT(plistCamObject_ && plistCamObject_->size() > 0);
- double _nMinDis = DBL_MAX;
- __int64 _nPos = 0;
- const CCamObject* _pCamObject = NULL;
- for (CamObjectList::const_iterator _it = plistCamObject_->begin(); _it != plistCamObject_->end(); _it++)
- {
- const CCamObject* _pCam = *_it;
- __int64 _nPosTemp =0;
- double _nDistance = GetCamMinDistance(_pCam, pt_, &_nPosTemp);
- if (_nDistance < _nMinDis)
- {
- _nMinDis = _nDistance;
- _nPos = _nPosTemp;
- _pCamObject = _pCam;
- }
- }
-
- if (pnPos_ && _pCamObject)
- {
- *pnPos_ = _nPos;
- }
-
- return _nMinDis;
- }
-
- bool operator<(const CamInfo& caminfo1_, const CamInfo& caminfo2_)
- {
- return caminfo1_.nID < caminfo2_.nID;
- };
-
- BOOL CControlTarget::OnKeyMessage(const MSG* pMsg_)
- {
- ASSERT(pMsg_);
-
- CCommandManager* _pCommandManager = GetCommandManager();
- if (!_pCommandManager)
- {
- return FALSE;
- }
-
- //㴰DZ༭ֶ ---- 2012-04-13
- HWND _hwndFocus = ::GetFocus();
- if (::IsWindow(_hwndFocus))
- {
- TCHAR _szWndClassName[64];
- memset(_szWndClassName, 0, _countof(_szWndClassName) * sizeof(TCHAR));
- ::GetClassName(_hwndFocus, _szWndClassName, _countof(_szWndClassName));
- if (!_tcsicmp(_szWndClassName, _T("Edit")))
- {
- return FALSE;
- }
- }
-
- BOOL _bSucceed = FALSE;
- static const struct GFOBMsgItem
- {
- UINT nGFOBMessage; // WM_KEYDOWN or WM_KEYUP
- UINT nGFOBChar;
- UINT nGFOBRepCnt;
- DWORD nGFOBMode; // 0x00-㶯, 0x01-ǰ/ָľ
- UINT nGFOBCmdID;
- DWORD nMask;
- } _s_GFOBMsgItems[] =
- {
- { WM_KEYDOWN, VK_F3, 1, 0x00, IDCMD_CONTROLTARGET_JOGBACKWARD, 0x00000001},
- { WM_KEYDOWN, VK_F4, 1, 0x00, IDCMD_CONTROLTARGET_JOGFORWARD, 0x00000002},
- { WM_KEYUP, VK_F3, 1, 0x00, IDCMD_CONTROLTARGET_STOP, 0x00000001},
- { WM_KEYUP, VK_F4, 1, 0x00, IDCMD_CONTROLTARGET_STOP, 0x00000002},
-
- { WM_KEYUP, VK_F3, 1, 0x01, IDCMD_CONTROLTARGET_INCBACKWARD, 0x00000001},
- { WM_KEYUP, VK_F4, 1, 0x01, IDCMD_CONTROLTARGET_INCFORWARD, 0x00000002},
- };
- for (size_t _i = 0; _i < _countof(_s_GFOBMsgItems); _i++)
- {
- const GFOBMsgItem& _item = _s_GFOBMsgItems[_i];
- if (pMsg_->message != _item.nGFOBMessage
- || static_cast<UINT>(pMsg_->wParam) != _item.nGFOBChar
- || LOWORD(pMsg_->lParam) != _item.nGFOBRepCnt
- || GetGFOBMode() != _item.nGFOBMode)
- {
- continue;
- }
-
- // /رհ״̬ ---- 2013-09-04
- _ToTraceKeyState(UINT(pMsg_->wParam), pMsg_->message == WM_KEYDOWN ? true : false);
-
- _bSucceed = OnCmdMsg(_item.nGFOBCmdID, 0, NULL, NULL);
-
- if (_item.nGFOBMessage == WM_KEYDOWN)
- {
- m_nGFOBKeyState |= _item.nMask;
- }
- else
- {
- m_nGFOBKeyState &= !_item.nMask;
- }
- }
-
- return _bSucceed ? TRUE : FALSE;
- }
-
- void CControlTarget::SetGFOBMode(DWORD nGFOBMode_)
- {
- m_nGFOBMode = nGFOBMode_;
- CParamManager* _pParamManager = GetParamManager();
- if (_pParamManager)
- {
- mach::ParameterValue _Parameter;
- memset(&_Parameter, 0, sizeof(mach::ParameterValue));
- _Parameter.nType = mach::ParameterValue::VT_INT;
- _Parameter.iValue = m_nGFOBMode == 1 ? 1 : 0;
- _pParamManager->SetParameterValue("GoBackMode", &_Parameter);
- }
- }
-
- DWORD CControlTarget::GetGFOBMode()
- {
- CParamManager* _pParamManager = GetParamManager();
- if (_pParamManager)
- {
- mach::ParameterValue _Parameter;
- memset(&_Parameter, 0, sizeof(mach::ParameterValue));
- if (_pParamManager->GetParameterValue("GoBackMode", &_Parameter))
- {
- ASSERT(_Parameter.nType == mach::ParameterValue::VT_INT);
- m_nGFOBMode = _Parameter.iValue;
- }
- }
-
- return m_nGFOBMode;
- }
-
- bool CControlTarget::_IsOutsideTheSotfLimit(const CStringA strFilePosition_)
- {
- CParamManager* _pParamManager = GetParamManager();
- if (!_pParamManager)
- {
- ASSERT(FALSE);
- return false;
- }
- mach::ParameterValue _IsCheckLimitX;
- mach::ParameterValue _IsCheckLimitY;
- bool _bSuccess = _pParamManager->GetParameterValue("IsCheckLimitX", &_IsCheckLimitX);
- _bSuccess &= _pParamManager->GetParameterValue("IsCheckLimitY", &_IsCheckLimitY);
- ASSERT(_IsCheckLimitX.nType == ParameterValue::VT_BOOL && _IsCheckLimitY.nType == ParameterValue::VT_BOOL);
- if (!_IsCheckLimitX.bValue && !_IsCheckLimitY.bValue)
- return false;
-
- mach::ParameterValue _IsReferedX;
- mach::ParameterValue _IsReferedY;
- _bSuccess &= _pParamManager->GetParameterValue("IsReferedX", &_IsReferedX);
- _bSuccess &= _pParamManager->GetParameterValue("IsReferedY", &_IsReferedY);
- ASSERT(_IsReferedX.nType == ParameterValue::VT_BOOL && _IsReferedY.nType == ParameterValue::VT_BOOL);
- if (!_bSuccess)
- {
- ASSERT(FALSE);
- return false;
- }
- // ûлػеԭ㲻λ
- if (!_IsReferedX.bValue && !_IsReferedY.bValue)
- {
- return false;
- }
-
- CFileTarget* _pFileTarget = GetFileTarget();
- if (!_pFileTarget)
- {
- ASSERT(FALSE);
- return false;
- }
-
- // ûõͼξͲжˡ ---- ƺ 2015-12-12
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- if (_pFileTarget->GetFilePath().IsEmpty()
- || !_pCamGroup->GetObjectsList()
- || _pCamGroup->GetObjectsList()->size() == 0)
- {
- return false;
- }
-
- double _pWorktable[4];
- DRECT _rcWorktable;
- SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
- _rcWorktable.x = _pWorktable[0];
- _rcWorktable.y = _pWorktable[1];
- _rcWorktable.width = _pWorktable[2];
- _rcWorktable.height = _pWorktable[3];
- DRECT _rectBound;
- static CSimuCutHelper _s_SimuCutHelper;
- CStateManager* _pStateManager = GetStateManager();
-
- // ӹͼΡ
- if (!_pStateManager->IsSelectedMach())
- {
- _rectBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
- }
-
- // ѡӹ
- else
- {
- DRECT _rectBoundLast;
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- CCadGroup* _pCadGroup = _pFileTarget->GetCurrentCadGroup();
-
- CSelectTarget* _pSelectTarget = GetSelectTarget();
- ASSERT(_pSelectTarget);
- const CadObjectList* _plistSelectObjs = _pSelectTarget->GetSelectedCadObjects();
-
- vectorUINT _setCadID;
- CCamGroup* _pSelcetCamGroup = new CCamGroup;
- _GetCadIDList((CadObjectList*)_plistSelectObjs,_setCadID);
- if (_setCadID.size() > 0)
- {
- _GetCamGroupByCadID(_pCamGroup, _setCadID, _pSelcetCamGroup);
- _rectBound = _s_SimuCutHelper.GetBoundRect(_pSelcetCamGroup);
- }
- _pSelcetCamGroup->GetObjectsList()->clear();
- delete _pSelcetCamGroup;
- }
-
- _DoWCSAdjust(_rectBound);
- if (_IsCheckLimitX.bValue && _IsReferedX.bValue
- && (_rectBound.GetLeft() < _rcWorktable.GetLeft() || _rectBound.GetRight() > _rcWorktable.GetRight()))
- return true;
-
- if (_IsCheckLimitY.bValue && _IsReferedY.bValue
- && (_rectBound.GetBottom() < _rcWorktable.GetBottom() || _rectBound.GetTop() > _rcWorktable.GetTop()))
- return true;
-
- return false;
- }
-
- bool CControlTarget::_IsRectOutsideTheSotfLimit(const CStringA strFilePosition_)
- {
- CParamManager* _pParamManager = GetParamManager();
- if (!_pParamManager)
- {
- ASSERT(FALSE);
- return false;
- }
- mach::ParameterValue _IsCheckLimitX;
- mach::ParameterValue _IsCheckLimitY;
- bool _bSuccess = _pParamManager->GetParameterValue("IsCheckLimitX", &_IsCheckLimitX);
- _bSuccess &= _pParamManager->GetParameterValue("IsCheckLimitY", &_IsCheckLimitY);
- ASSERT(_IsCheckLimitX.nType == ParameterValue::VT_BOOL && _IsCheckLimitY.nType == ParameterValue::VT_BOOL);
- if (!_IsCheckLimitX.bValue && !_IsCheckLimitY.bValue)
- return false;
-
- mach::ParameterValue _IsReferedX;
- mach::ParameterValue _IsReferedY;
- _bSuccess &= _pParamManager->GetParameterValue("IsReferedX", &_IsReferedX);
- _bSuccess &= _pParamManager->GetParameterValue("IsReferedY", &_IsReferedY);
- ASSERT(_IsReferedX.nType == ParameterValue::VT_BOOL && _IsReferedY.nType == ParameterValue::VT_BOOL);
- if (!_bSuccess)
- {
- ASSERT(FALSE);
- return false;
- }
- // ûлػеԭ㲻λ
- if (!_IsReferedX.bValue && !_IsReferedY.bValue)
- {
- return false;
- }
-
- CFileTarget* _pFileTarget = GetFileTarget();
- if (!_pFileTarget)
- {
- ASSERT(FALSE);
- return false;
- }
-
- // ûõͼξͲжˡ ---- ƺ 2015-12-12
- CCamGroup* _pCamGroup = _pFileTarget->GetCurrentCamGroup();
- if (_pFileTarget->GetFilePath().IsEmpty()
- || !_pCamGroup->GetObjectsList()
- || _pCamGroup->GetObjectsList()->size() == 0)
- {
- return false;
- }
-
- double _pWorktable[4];
- DRECT _rcWorktable;
- SendTargetMessage(ID_TARGET_WORKTABLE, TM_GET_WORKTABLE,(WPARAM)_pWorktable);
- _rcWorktable.x = _pWorktable[0];
- _rcWorktable.y = _pWorktable[1];
- _rcWorktable.width = _pWorktable[2];
- _rcWorktable.height = _pWorktable[3];
- DRECT _rectBound;
-
- // ߿Ƿλ
- static CSimuCutHelper _s_SimuCutHelper;
- ASSERT(!strFilePosition_.IsEmpty());
- _rectBound = _s_SimuCutHelper.GetBoundRect(_pFileTarget->GetCurrentCamGroup());
- _DoWCSAdjust(_rectBound);
- if (_IsCheckLimitX.bValue && _IsReferedX.bValue
- && (_rectBound.GetLeft() < _rcWorktable.GetLeft() || _rectBound.GetRight() > _rcWorktable.GetRight()))
- return true;
-
- if (_IsCheckLimitY.bValue && _IsReferedY.bValue
- && (_rectBound.GetBottom() < _rcWorktable.GetBottom() || _rectBound.GetTop() > _rcWorktable.GetTop()))
- return true;
-
- return false;
- }
-
- // ָӹΧڴضλÿʼĺڴ˷Χڷؿַ ---- ƺ 2016-09-14
- CStringA CControlTarget::_Mid(const CStringA& strSelection_, __int64 nStartPos_)
- {
- if (strSelection_.IsEmpty())
- {
- ASSERT(FALSE);
- return "";
- }
-
- int _nIndex = strSelection_.Find(_T(';'));
- CString _strSection = _nIndex == -1 ? strSelection_ : strSelection_.Mid(0, _nIndex);
- __int64 _nLastEndPos = -1;
- CString _strRet;
- while(!_strSection.IsEmpty())
- {
- __int64 _nStart = 0;
- __int64 _nEnd = 0;
- int _nCount = sscanf_s(_strSection, _T("%lld,%lld"), &_nStart, &_nEnd);
- ASSERT(_nCount == 2);
-
- // Ĭϴļǵģ"a,b;c,d"a < b < c < d ---- ƺ 2016-09-14
- ASSERT(_nLastEndPos <= _nStart && _nStart <= _nEnd);
-
- // ǰλòڴڡ ---- ƺ 2016-09-14
- if (nStartPos_ < _nStart
- && _nLastEndPos == -1)
- {
- return "";
- }
-
- // ǰλĿ϶ڣ"a,b;c,d", ǰλ > b && ǰλ < c ---- ƺ 2016-09-14
- if (nStartPos_ < _nStart
- && _nLastEndPos > 0
- && nStartPos_ > _nLastEndPos)
- {
- _strRet.Format(_T("%lld,%lld;"), _nStart, _nEnd);
- if (_nIndex != -1)
- _strRet += strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
- break;
- }
-
- // ǰλijڡ ---- ƺ 2016-09-14
- if (nStartPos_ >= _nStart && nStartPos_ < _nEnd)
- {
- _strRet.Format(_T("%lld,%lld;"), nStartPos_, _nEnd);
- if (_nIndex != -1)
- _strRet += strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
- break;
- }
-
- // ǰλøպijյ㡣 ---- ƺ 2016-09-14
- if (nStartPos_ == _nEnd && _nIndex != -1)
- {
- _strRet = strSelection_.Right(strSelection_.GetLength() - _nIndex - 1);
- break;
- }
-
- if (_nIndex == -1)
- break;
-
- _nLastEndPos = _nEnd;
- int _nNextIndex = strSelection_.Find(_T(';'), _nIndex + 1);
- _strSection = _nNextIndex == -1
- ? strSelection_.Right(strSelection_.GetLength() - _nIndex - 1)
- : strSelection_.Mid(_nIndex + 1, _nNextIndex - _nIndex);
- _nIndex = _nNextIndex;
- }
-
- // һǷֺţɾ ---- ƺ 2016-09-14
- int _nLen = _strRet.GetLength();
- if (_nLen > 0 && _strRet[_nLen - 1] == _T(';'))
- {
- _strRet.Delete(_nLen - 1);
- }
-
- return _strRet;
- }
-
- void CControlTarget::_DoWCSAdjust(DRECT& rcRect_)
- {
- CWCSAdjustTarget* _pWCSAdjustTarget = GetWCSAdjustTarget();
- if (!_pWCSAdjustTarget)
- return;
-
- DRECT _rcOrg = rcRect_;
- DPOINT2 _ptTopLeft (_rcOrg.GetLeft(), _rcOrg.GetTop());
- DPOINT2 _ptRightBottom(_rcOrg.GetRight(), _rcOrg.GetBottom());
- DPOINT2 _ptBottomLeft(_rcOrg.GetLeft(), _rcOrg.GetBottom());
- DPOINT2 _ptTopRight(_rcOrg.GetRight(), _rcOrg.GetTop());
- _ptTopLeft = _pWCSAdjustTarget->DoWCSAdjust(_ptTopLeft);
- _ptRightBottom = _pWCSAdjustTarget->DoWCSAdjust(_ptRightBottom);
- _ptBottomLeft = _pWCSAdjustTarget->DoWCSAdjust(_ptBottomLeft);
- _ptTopRight = _pWCSAdjustTarget->DoWCSAdjust(_ptTopRight);
- double _nLeft = min(min(min(_ptTopLeft.x, _ptTopRight.x), _ptBottomLeft.x), _ptRightBottom.x);
- double _nRight = max(max(max(_ptTopLeft.x, _ptTopRight.x), _ptBottomLeft.x), _ptRightBottom.x);
- double _nBottom = min(min(min(_ptTopLeft.y, _ptTopRight.y), _ptBottomLeft.y), _ptRightBottom.y);
- double _nTop = max(max(max(_ptTopLeft.y, _ptTopRight.y), _ptBottomLeft.y), _ptRightBottom.y);
- DRECT _rcNew;
- _rcNew.x = _nLeft;
- _rcNew.y = _nBottom;
- _rcNew.width = _nRight - _nLeft;
- _rcNew.height = _nTop - _nBottom;
- rcRect_ = _rcNew;
- }
-
- // CadIDҵӦCad
- static bool _FindObjectByID(IN CCadObject* pCadObject_, IN int nID_, OUT CCadObject** ppResult_)
- {
- if (pCadObject_->GetID() == nID_)
- {
- *ppResult_ = pCadObject_;
- return true;
- }
-
- if (pCadObject_->GetType() == cadtext)
- {
- CCadText* _pCadText = dynamic_cast<CCadText*>(pCadObject_);
- ASSERT(_pCadText);
- if (_FindObjectByID(_pCadText->GetTextGroup(), nID_, ppResult_))
- return true;
- }
- if (pCadObject_->GetType() == cadgroup)
- {
- CCadGroup* _pCadGroup = dynamic_cast<CCadGroup*>(pCadObject_);
- ASSERT(_pCadGroup);
- for (int _i = 0; _i < _pCadGroup->GetNumOfChild(); _i++)
- {
- CCadObject* _pCad = _pCadGroup->GetAt(_i);
- ASSERT(_pCad);
- if (_FindObjectByID(_pCad, nID_, ppResult_))
- return true;
- }
- }
-
- return false;
- }
-
- __int64 CControlTarget::_SelectionFirst(const CStringA& strSelection_)
- {
- if (strSelection_.IsEmpty())
- {
- ASSERT(FALSE);
- return 0;
- }
-
- int _nIndex = strSelection_.Find(_T(';'));
- CString _strSection = _nIndex == -1 ? strSelection_ : strSelection_.Mid(0, _nIndex);
- __int64 _nLastEndPos = -1;
- CString _strRet;
- if(!_strSection.IsEmpty())
- {
- __int64 _nStart = 0;
- __int64 _nEnd = 0;
- int _nCount = sscanf_s(_strSection, _T("%lld,%lld"), &_nStart, &_nEnd);
- ASSERT(_nCount == 2);
- return _nStart;
- }
- return 0;
- }
-
-
- void _GetCadIDObj(IN CCadObject* pCadObject_, OUT vectorUINT& setIDs_)
- {
- setIDs_.push_back(pCadObject_->GetID());
- if (pCadObject_->GetType() == cadtext)
- {
- CCadText* _pCadText = dynamic_cast<CCadText*>(pCadObject_);
- ASSERT(_pCadText);
- _GetCadIDObj(_pCadText->GetTextGroup(), setIDs_);
-
- }
- if (pCadObject_->GetType() == cadgroup)
- {
- CCadGroup* _pCadGroup = dynamic_cast<CCadGroup*>(pCadObject_);
- ASSERT(_pCadGroup);
- for (int _i = 0; _i < _pCadGroup->GetNumOfChild(); _i++)
- {
- CCadObject* _pCad = _pCadGroup->GetAt(_i);
- ASSERT(_pCad);
- _GetCadIDObj(_pCad, setIDs_);
- }
- }
- }
-
- void _GetCadIDList(IN CadObjectList* pListCads_, OUT vectorUINT& setIDs_)
- {
- for (CadObjectList::iterator _it = pListCads_->begin(); _it != pListCads_->end(); _it++)
- {
- _GetCadIDObj(*_it, setIDs_);
- }
- }
-
- void _GetCamGroupByCadID(IN nce::CCamGroup* pCCamGroup_, IN vectorUINT setIDs_, OUT nce::CCamGroup* pOutCCamGroup_)
- {
- ASSERT(pCCamGroup_);
- CamObjectList* _plistCamObjs = pCCamGroup_->GetObjectsList();
- for (CamObjectList::const_iterator _it = _plistCamObjs->begin(); _it != _plistCamObjs->end(); _it++)
- {
- // ҪغϵCAM
- CCamObject* _pCam = *_it;
- CCadObject* _pCad = NULL;
-
- // CamеCadIDҵӦCad
- int _nID = (int)_pCam->GetKey_DBL("CadID");
- if (std::find(setIDs_.begin(), setIDs_.end(), _nID) != setIDs_.end())
- {
- pOutCCamGroup_->GetObjectsList()->push_back(_pCam);
- }
- }
- return;
- for (int _i = 0; _i < setIDs_.size(); _i++)
- {
- CCamObject* _pCamObject = NULL;
- SendTargetMessage(ID_TARGET_CADTOCAM, TN_GETCAM_BYCADID, setIDs_[_i], (LPARAM)&_pCamObject);
- if (_pCamObject != NULL)
- {
- pOutCCamGroup_->GetObjectsList()->push_back(_pCamObject);
- }
- }
-
- }
-
- void CControlTarget::_SendGasPressureInfo()
- {
- CString _flag = NceGetPrivateProfileString(_T("GasCheck"), _T("GNGasCheck"), _T("0"));
- if ("1" != _flag)
- {
- return;
- }
- CStateManager* _pStateManager = GetStateManager();
- ASSERT(_pStateManager);
- bool _bAirCheck = false;
- bool _bOxygenCheck = false;
- bool _bNitrogenCheck = false;
- CFileTarget* _pFileTarget = GetFileTarget();
- ASSERT(_pFileTarget);
- nce::ParamVector* _pParamVector = _pFileTarget->GetCurrentCadParams();
- nce::CCadGroup* _pCurrentCadGroup = _pFileTarget->GetCurrentCadGroup();
-
- for (size_t _i = 0; _i < _pParamVector->size(); _i++)
- {
-
- if (_bAirCheck && _bOxygenCheck && _bNitrogenCheck)
- {
- continue;
- }
- if (_pStateManager->IsSelectedMach())
- {
- bool _isSelect = false;
- //жѡͼѡǷҪѹ;
- for (int _j = 0; _j < _pCurrentCadGroup->GetNumOfChild(); _j++)
- {
- if (_pCurrentCadGroup->GetAt(_j)->IsSelected())
- {
- if (_i == _pCurrentCadGroup->GetAt(_j)->GetParamIndex())
- {
- _isSelect = true;
- }
- }
- }
-
- if(!_isSelect)
- {
- continue;
- }
- }
- else
- {
- //жϵǰͼѡǷҪѹ;
- for (int _j = 0; _j < _pCurrentCadGroup->GetNumOfChild(); _j++)
- {
- if (_i == _pCurrentCadGroup->GetAt(_j)->GetParamIndex())
- {
- CParam* _pParam = _pParamVector->at(_i);
- if(_pParam->GetKey(c_szOutput) == _T("0"))
- {
- continue;
- }
- //ȴж
- if (_pParam->GetKey(c_szCoolBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szCoolBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCoolBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szCoolBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCoolBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
-
- //ʽ
- //ֱӴ
- if (_pParam->GetKey(c_szPerforateType) == _T("0"))
- {
- //иж
- if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
- }
- //ֶδ
- if (_pParam->GetKey(c_szPerforateType) == _T("1") || _pParam->GetKey(c_szPerforateType) == _T("2"))
- {
- //иж
- if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
-
- //ж
- if (_pParam->GetKey(c_szPerBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szPerBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szPerBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szPerBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szPerBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
-
- }
- //
- if (_pParam->GetKey(c_szPerforateType) == _T("3"))
- {
- //иж
- if (_pParam->GetKey(c_szCutBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szCutBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
- //һ
- if (_pParam->GetKey(c_szFirstSegPunch) == _T("1"))
- {
- if (_pParam->GetKey(c_szFirstSegBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szFirstSegBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szFirstSegBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szFirstSegBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szFirstSegBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
- }
- //
- if (_pParam->GetKey(c_szSecondSegPunch) == _T("1"))
- {
- if (_pParam->GetKey(c_szSecondSegBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szSecondSegBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szSecondSegBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szSecondSegBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szSecondSegBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
- }
- //
- if (_pParam->GetKey(c_szThirdSegPunch) == _T("1"))
- {
- if (_pParam->GetKey(c_szThirdSegBlowType) == _T("0"))
- {
- _bAirCheck = true;
- }
- if (_pParam->GetKey(c_szThirdSegBlowType) == _T("1"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szThirdSegBlowType) == _T("2"))
- {
- _bOxygenCheck = true;
- }
- if (_pParam->GetKey(c_szThirdSegBlowType) == _T("3"))
- {
- _bNitrogenCheck = true;
- }
- if (_pParam->GetKey(c_szThirdSegBlowType) == _T("4"))
- {
- _bOxygenCheck = true;
- }
- }
-
- }
- }
- //ӹͬʱҪжһͨͼе
- CParamManager* _pParamManager = GetParamManager();
-
- ParameterValue _DefaultBlowType;
- _pParamManager->GetParameterValue("GP_DefaultBlowType", &_DefaultBlowType);
- if(0 == _DefaultBlowType.iValue)
- {
- _bAirCheck = true;
- }
- else if ((1 == _DefaultBlowType.iValue) || (3 == _DefaultBlowType.iValue))
- {
- _bNitrogenCheck = true;
- }
- else if ((2 == _DefaultBlowType.iValue) || (4 == _DefaultBlowType.iValue))
- {
- _bOxygenCheck = true;
- }
- CString _strCheckAir("EnableCheckAir");
- SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckAir.GetBuffer()), (LPARAM)&_bAirCheck);
-
- CString _strCheckOxygen("EnableCheckOxygen");
- SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckOxygen.GetBuffer()), (LPARAM)&_bOxygenCheck);
-
- CString _strCheckNitrogen("EnableCheckNitrogen");
- SendTargetMessage(ID_TARGET_PARAMMANAGER, TM_SET_PARAMVALUE, WPARAM(_strCheckNitrogen.GetBuffer()), (LPARAM)&_bNitrogenCheck);
- }
- }
- }
-
- }
- void CControlTarget::SetSelectMach(bool _bSelectMach)
- {
- m_bSelectMach = _bSelectMach;
- }
- bool CControlTarget::GetSelectMach()
- {
- return m_bSelectMach;
- }
|