dialog.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include <QMessageBox>
  4. #include "Ptz.h"
  5. #include "UserDefine.h"
  6. #include <iostream>
  7. using namespace std;
  8. CPtz g_PTZ;
  9. void CALLBACK DisConnectFunc(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
  10. {
  11. Dialog * pThis = (Dialog *)dwUser;
  12. if(NULL == pThis)
  13. {
  14. return;
  15. }
  16. QEvent* eventDisconnect = new QEvent(QEvent::User);
  17. QApplication::postEvent((QObject*)pThis, eventDisconnect);
  18. return;
  19. }
  20. Dialog::Dialog(QWidget *parent) :
  21. QDialog(parent),
  22. ui(new Ui::Dialog)
  23. {
  24. ui->setupUi(this);
  25. ///³õʼ»¯
  26. InitData();
  27. }
  28. Dialog::~Dialog()
  29. {
  30. /// ·´³õʼ»¯
  31. UnInitData();
  32. delete ui;
  33. }
  34. void Dialog::ShowMessage()
  35. {
  36. if (m_bMessageTip)
  37. {
  38. m_bMessageTip = FALSE;
  39. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  40. }
  41. }
  42. bool Dialog::InitData()
  43. {
  44. CLIENT_Init(DisConnectFunc, (LDWORD)this);
  45. LOG_SET_PRINT_INFO stLogPrintInfo = {sizeof(stLogPrintInfo)};
  46. CLIENT_LogOpen(&stLogPrintInfo);
  47. installEventFilter(this);//install filter
  48. m_lLoginHandle = 0;
  49. ui->lineEdit3->setEchoMode(QLineEdit::Password);
  50. m_bMessageTip = FALSE;
  51. ui->Login->setEnabled(true);
  52. ui->Logout->setEnabled(false);
  53. m_counter = new QTimer( this );
  54. connect(m_counter, SIGNAL(timeout()), this, SLOT(ShowMessage()));
  55. m_counter->start(1000);
  56. return true;
  57. }
  58. bool Dialog::UnInitData()
  59. {
  60. CLIENT_Cleanup();
  61. if(m_counter)
  62. delete m_counter;
  63. return true;
  64. }
  65. void Dialog::on_Login_clicked()
  66. {
  67. QString strIp;
  68. QString strUserName;
  69. QString strDvrPort;
  70. QString strPassword;
  71. strIp = ui->lineEdit1->text();
  72. strUserName = ui->lineEdit4->text();
  73. strPassword = ui->lineEdit3->text();
  74. strDvrPort = ui->lineEdit2->text();
  75. int error = 0;
  76. bool numok = false;
  77. long lPort = strDvrPort.toUInt(&numok);
  78. if(numok)
  79. {
  80. NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
  81. memset(&stInparam, 0, sizeof(stInparam));
  82. stInparam.dwSize = sizeof(stInparam);
  83. strncpy(stInparam.szIP, (char *)strIp.toUtf8().data(), sizeof(stInparam.szIP) - 1);
  84. strncpy(stInparam.szPassword, (char*)strPassword.toUtf8().data(), sizeof(stInparam.szPassword) - 1);
  85. strncpy(stInparam.szUserName, (char*)strUserName.toUtf8().data(), sizeof(stInparam.szUserName) - 1);
  86. stInparam.nPort = lPort;
  87. stInparam.emSpecCap = EM_LOGIN_SPEC_CAP_TCP;
  88. NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
  89. memset(&stOutparam, 0, sizeof(stOutparam));
  90. stOutparam.dwSize = sizeof(stOutparam);
  91. m_lLoginHandle = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);
  92. if(m_lLoginHandle == 0)
  93. {
  94. if(stOutparam.nError != 255)
  95. {
  96. QMessageBox::about(this, tr("Prompt"), tr("Login failed!"));
  97. }
  98. else
  99. {
  100. error = CLIENT_GetLastError();
  101. if(error ==NET_ERROR_MAC_VALIDATE_FAILED )
  102. {
  103. QMessageBox::about(this, tr("Prompt"), tr("Login failed! bad mac address"));
  104. }
  105. else if(error ==NET_ERROR_SENIOR_VALIDATE_FAILED)
  106. {
  107. QMessageBox::about(this, tr("Prompt"), tr("Login failed! senior validate failed"));
  108. }
  109. }
  110. }
  111. else
  112. {
  113. g_PTZ.SetLoginID(m_lLoginHandle);
  114. ui->Login->setEnabled(false);
  115. ui->Logout->setEnabled(true);
  116. //initalize comboxChannel
  117. ui->comboxChannel->clear();
  118. for(int i = 1; i <= stOutparam.stuDeviceInfo.nChanNum; i++)
  119. {
  120. QString strdata = QString::number(i, 10);
  121. int nCount = ui->comboxChannel->count();
  122. ui->comboxChannel->insertItem(nCount, strdata);
  123. ui->comboxChannel->setCurrentIndex(0);
  124. m_nChannelIndex = 0;
  125. g_PTZ.SetChannel(m_nChannelIndex);
  126. m_nCtrlParam = 1;
  127. }
  128. }
  129. }
  130. else
  131. {
  132. int nRet = QMessageBox::warning(this, tr("Input Error"),
  133. "could not convert the port to numbers!\n"
  134. "please try again!\n\n ",
  135. "Retry",
  136. "Quit",0,0,1);
  137. if (nRet == QMessageBox::Retry)
  138. {
  139. }
  140. }
  141. }
  142. void Dialog::on_Logout_clicked()
  143. {
  144. if (m_lLoginHandle != 0)
  145. {
  146. BOOL bSuccess = CLIENT_Logout(m_lLoginHandle);
  147. if(bSuccess)
  148. {
  149. ui->Login->setEnabled(true);
  150. ui->Logout->setEnabled(false);
  151. }
  152. else
  153. {
  154. QMessageBox::about(this, tr("Prompt"), tr("Logout failed!"));
  155. }
  156. }
  157. }
  158. void Dialog::PTZForBasicControl(int nType, bool bStop)
  159. {
  160. bool bRet = false;
  161. bRet = g_PTZ.PtzBasicControl(nType, m_nCtrlParam, bStop);
  162. if(bRet == false)
  163. {
  164. m_bMessageTip = TRUE;
  165. }
  166. }
  167. void Dialog::on_pushButLeftUp_pressed()
  168. {
  169. PTZForBasicControl(DH_EXTPTZ_LEFTTOP, false);
  170. }
  171. void Dialog::on_pushButLeftUp_released()
  172. {
  173. PTZForBasicControl(DH_EXTPTZ_LEFTTOP, true);
  174. }
  175. void Dialog::on_pushButUp_pressed()
  176. {
  177. PTZForBasicControl(DH_PTZ_UP_CONTROL, false);
  178. }
  179. void Dialog::on_pushButUp_released()
  180. {
  181. PTZForBasicControl(DH_PTZ_UP_CONTROL, true);
  182. }
  183. void Dialog::on_comboxChannel_activated(QString )
  184. {
  185. m_nChannelIndex = ui->comboxChannel->currentIndex();
  186. g_PTZ.SetChannel(m_nChannelIndex);
  187. }
  188. void Dialog::on_comboxCtrlParam_activated(QString )
  189. {
  190. m_nCtrlParam = ui->comboxCtrlParam->currentIndex() + 1;
  191. }
  192. void Dialog::on_pushButRightUP_pressed()
  193. {
  194. PTZForBasicControl(DH_EXTPTZ_RIGHTTOP, false);
  195. }
  196. void Dialog::on_pushButRightUP_released()
  197. {
  198. PTZForBasicControl(DH_EXTPTZ_RIGHTTOP, true);
  199. }
  200. void Dialog::on_pushButLeft_pressed()
  201. {
  202. PTZForBasicControl(DH_PTZ_LEFT_CONTROL, false);
  203. }
  204. void Dialog::on_pushButLeft_released()
  205. {
  206. PTZForBasicControl(DH_PTZ_LEFT_CONTROL, true);
  207. }
  208. void Dialog::on_pushButRight_pressed()
  209. {
  210. PTZForBasicControl(DH_PTZ_RIGHT_CONTROL, false);
  211. }
  212. void Dialog::on_pushButRight_released()
  213. {
  214. PTZForBasicControl(DH_PTZ_RIGHT_CONTROL, true);
  215. }
  216. void Dialog::on_pushButLeftDown_pressed()
  217. {
  218. PTZForBasicControl(DH_EXTPTZ_LEFTDOWN, false);
  219. }
  220. void Dialog::on_pushButLeftDown_released()
  221. {
  222. PTZForBasicControl(DH_EXTPTZ_LEFTDOWN, true);
  223. }
  224. void Dialog::on_pushButDown_pressed()
  225. {
  226. PTZForBasicControl(DH_PTZ_DOWN_CONTROL, false);
  227. }
  228. void Dialog::on_pushButDown_released()
  229. {
  230. PTZForBasicControl(DH_PTZ_DOWN_CONTROL, true);
  231. }
  232. void Dialog::on_pushButRDown_pressed()
  233. {
  234. PTZForBasicControl(DH_EXTPTZ_RIGHTDOWN, false);
  235. }
  236. void Dialog::on_pushButRDown_released()
  237. {
  238. PTZForBasicControl(DH_EXTPTZ_RIGHTDOWN, true);
  239. }
  240. void Dialog::on_pushButAZoom_pressed()
  241. {
  242. PTZForBasicControl(DH_PTZ_ZOOM_ADD_CONTROL, false);
  243. }
  244. void Dialog::on_pushButAZoom_released()
  245. {
  246. PTZForBasicControl(DH_PTZ_ZOOM_ADD_CONTROL, true);
  247. }
  248. void Dialog::on_pushButDZoom_pressed()
  249. {
  250. PTZForBasicControl(DH_PTZ_ZOOM_DEC_CONTROL, false);
  251. }
  252. void Dialog::on_pushButDZoom_released()
  253. {
  254. PTZForBasicControl(DH_PTZ_ZOOM_DEC_CONTROL, true);
  255. }
  256. void Dialog::on_pushButAFocus_pressed()
  257. {
  258. PTZForBasicControl(DH_PTZ_FOCUS_ADD_CONTROL, false);
  259. }
  260. void Dialog::on_pushButAFocus_released()
  261. {
  262. PTZForBasicControl(DH_PTZ_FOCUS_ADD_CONTROL, true);
  263. }
  264. void Dialog::on_pushButDFocus_pressed()
  265. {
  266. PTZForBasicControl(DH_PTZ_FOCUS_DEC_CONTROL, false);
  267. }
  268. void Dialog::on_pushButDFocus_released()
  269. {
  270. PTZForBasicControl(DH_PTZ_FOCUS_DEC_CONTROL, true);
  271. }
  272. void Dialog::on_pushButAperture_pressed()
  273. {
  274. PTZForBasicControl(DH_PTZ_APERTURE_ADD_CONTROL, false);
  275. }
  276. void Dialog::on_pushButAperture_released()
  277. {
  278. PTZForBasicControl(DH_PTZ_APERTURE_ADD_CONTROL, true);
  279. }
  280. void Dialog::on_pushButDAperture_pressed()
  281. {
  282. PTZForBasicControl(DH_PTZ_APERTURE_DEC_CONTROL, false);
  283. }
  284. void Dialog::on_pushButDAperture_released()
  285. {
  286. PTZForBasicControl(DH_PTZ_APERTURE_DEC_CONTROL, true);
  287. }
  288. void Dialog::on_pushButSet_clicked()
  289. {
  290. bool numok = false;
  291. QString strPresetNo = ui->EditPreSetNo->text();
  292. long lPresetNo = strPresetNo.toUInt(&numok);
  293. if (lPresetNo < 1 || lPresetNo > 255)
  294. {
  295. QMessageBox::information(this, tr("Operate"), tr("Preset num must is between 1 and 255"));
  296. return;
  297. }
  298. if(numok)
  299. {
  300. PTZForPresetControl(DH_PTZ_POINT_SET_CONTROL, lPresetNo);
  301. }
  302. else
  303. {
  304. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  305. }
  306. }
  307. void Dialog::on_pushButPresetDel_clicked()
  308. {
  309. bool numok = false;
  310. QString strPresetNo = ui->EditPreSetNo->text();
  311. long lPresetNo = strPresetNo.toUInt(&numok);
  312. if (lPresetNo < 1 || lPresetNo > 255)
  313. {
  314. QMessageBox::information(this, tr("Operate"), tr("Preset num must is between 1 and 255"));
  315. return;
  316. }
  317. if(numok)
  318. {
  319. PTZForPresetControl(DH_PTZ_POINT_DEL_CONTROL, lPresetNo);
  320. }
  321. else
  322. {
  323. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  324. }
  325. }
  326. void Dialog::on_pushButGotoPreset_clicked()
  327. {
  328. bool numok = false;
  329. QString strPresetNo = ui->EditPreSetNo->text();
  330. long lPresetNo = strPresetNo.toUInt(&numok);
  331. if (lPresetNo < 1 || lPresetNo > 255)
  332. {
  333. QMessageBox::information(this, tr("Operate"), tr("Preset num must is between 1 and 255"));
  334. return;
  335. }
  336. if(numok)
  337. {
  338. PTZForPresetControl(DH_PTZ_POINT_MOVE_CONTROL, lPresetNo);
  339. }
  340. else
  341. {
  342. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  343. }
  344. }
  345. void Dialog::on_ButStartTour_clicked()
  346. {
  347. bool bPresetnumok = false;
  348. bool bTournumok = false;
  349. QString strPresetNo = ui->EditPresetNum->text();
  350. long lPresetNo = strPresetNo.toUInt(&bPresetnumok);
  351. QString strTourNo = ui->AutoTourNo->text();
  352. long lTourNo = strTourNo.toUInt(&bTournumok);
  353. if( bTournumok)
  354. {
  355. PTZForAutoTour( DH_PTZ_POINT_LOOP_CONTROL, lTourNo, lPresetNo, true );
  356. }
  357. else
  358. {
  359. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  360. }
  361. }
  362. void Dialog::on_ButStopTour_clicked()
  363. {
  364. bool bPresetnumok = false;
  365. bool bTournumok = false;
  366. QString strPresetNo = ui->EditPresetNum->text();
  367. long lPresetNo = strPresetNo.toUInt(&bPresetnumok);
  368. QString strTourNo = ui->AutoTourNo->text();
  369. long lTourNo = strTourNo.toUInt(&bTournumok);
  370. if(bTournumok)
  371. {
  372. PTZForAutoTour(DH_PTZ_POINT_LOOP_CONTROL, lTourNo, lPresetNo, false);
  373. }
  374. else
  375. {
  376. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  377. }
  378. }
  379. void Dialog::on_ButAddTour_clicked()
  380. {
  381. bool bPresetnumok = false;
  382. bool bTournumok = false;
  383. QString strPresetNo = ui->EditPresetNum->text();
  384. long lPresetNo = strPresetNo.toUInt(&bPresetnumok);
  385. if (lPresetNo < 1 || lPresetNo > 255)
  386. {
  387. QMessageBox::information(this, tr("Operate"), tr("Preset num must is between 1 and 255"));
  388. return;
  389. }
  390. QString strTourNo = ui->AutoTourNo->text();
  391. long lTourNo = strTourNo.toUInt(&bTournumok);
  392. if(bPresetnumok && bTournumok)
  393. {
  394. PTZForAutoTour( DH_EXTPTZ_ADDTOLOOP, lTourNo, lPresetNo, false );
  395. }
  396. else
  397. {
  398. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  399. }
  400. }
  401. void Dialog::on_ButDelTourPreset_clicked()
  402. {
  403. bool bPresetnumok = false;
  404. bool bTournumok = false;
  405. QString strPresetNo = ui->EditPresetNum->text();
  406. long lPresetNo = strPresetNo.toUInt(&bPresetnumok);
  407. QString strTourNo = ui->AutoTourNo->text();
  408. long lTourNo = strTourNo.toUInt(&bTournumok);
  409. if (lPresetNo < 1 || lPresetNo > 255)
  410. {
  411. QMessageBox::information(this, tr("Operate"), tr("Preset num must is between 1 and 255"));
  412. return;
  413. }
  414. if(bPresetnumok && bTournumok)
  415. {
  416. PTZForAutoTour( DH_EXTPTZ_DELFROMLOOP, lTourNo, lPresetNo, false );
  417. }
  418. else
  419. {
  420. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  421. }
  422. }
  423. void Dialog::on_ButDelTourNo_clicked()
  424. {
  425. bool bPresetnumok = false;
  426. bool bTournumok = false;
  427. QString strPresetNo = ui->EditPresetNum->text();
  428. long lPresetNo = strPresetNo.toUInt(&bPresetnumok);
  429. QString strTourNo = ui->AutoTourNo->text();
  430. long lTourNo = strTourNo.toUInt(&bTournumok);
  431. if(bTournumok)
  432. {
  433. PTZForAutoTour( DH_EXTPTZ_CLOSELOOP, lTourNo, lPresetNo, false );
  434. }
  435. else
  436. {
  437. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  438. }
  439. }
  440. void Dialog::on_ButMenuLeft_clicked()
  441. {
  442. PTZForMenu(DH_EXTPTZ_MENULEFT);
  443. }
  444. void Dialog::on_ButMenuUP_clicked()
  445. {
  446. PTZForMenu(DH_EXTPTZ_MENUUP);
  447. }
  448. void Dialog::on_ButMenuRight_clicked()
  449. {
  450. PTZForMenu(DH_EXTPTZ_MENURIGHT);
  451. }
  452. void Dialog::on_ButMenuDown_clicked()
  453. {
  454. PTZForMenu(DH_EXTPTZ_MENUDOWN);
  455. }
  456. void Dialog::on_ButOpenMenu_clicked()
  457. {
  458. PTZForMenu(DH_EXTPTZ_OPENMENU);
  459. }
  460. void Dialog::on_ButCloseMenu_clicked()
  461. {
  462. PTZForMenu(DH_EXTPTZ_CLOSEMENU);
  463. }
  464. void Dialog::on_ButMenuOK_clicked()
  465. {
  466. PTZForMenu(DH_EXTPTZ_MENUOK);
  467. }
  468. void Dialog::on_ButMenuCancel_clicked()
  469. {
  470. PTZForMenu(DH_EXTPTZ_MENUCANCEL);
  471. }
  472. void Dialog::on_ButSIT_clicked()
  473. {
  474. bool nXumok = false;
  475. bool nYumok = false;
  476. bool nZoomumok = false;
  477. QString strX = ui->lineEditX->text();
  478. long lX = strX.toLong(&nXumok);
  479. QString strY = ui->lineEditY->text();
  480. long lY = strY.toLong(&nYumok);
  481. QString strZoom = ui->lineEditZoom->text();
  482. long lZoom = strZoom.toLong(&nZoomumok);
  483. if (nXumok && nYumok && nZoomumok)
  484. {
  485. PTZForSIT( lX, lY, lZoom);
  486. }
  487. else
  488. {
  489. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  490. }
  491. }
  492. void Dialog::on_ButOpenAUX_clicked()
  493. {
  494. bool numok = false;
  495. QString strAuxNo = ui->comboxAuxNo->currentText();
  496. long lAuxNo = strAuxNo.toUInt(&numok);
  497. if(numok)
  498. {
  499. PTZForAUX( DH_EXTPTZ_AUXIOPEN, lAuxNo );
  500. }
  501. else
  502. {
  503. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  504. }
  505. }
  506. void Dialog::on_ButCloseAUX_clicked()
  507. {
  508. bool numok = false;
  509. QString strAuxNo = ui->comboxAuxNo->currentText();
  510. long lAuxNo = strAuxNo.toUInt(&numok);
  511. if(numok)
  512. {
  513. PTZForAUX( DH_EXTPTZ_AUXICLOSE, lAuxNo );
  514. }
  515. else
  516. {
  517. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  518. }
  519. }
  520. void Dialog::on_ButLimitLeft_clicked()
  521. {
  522. PTZForScan(DH_EXTPTZ_SETLEFTBORDER);
  523. }
  524. void Dialog::on_ButLimitRight_clicked()
  525. {
  526. PTZForScan(DH_EXTPTZ_SETRIGHTBORDER);
  527. }
  528. void Dialog::on_ButStartScan_clicked()
  529. {
  530. PTZForScan(DH_EXTPTZ_STARTLINESCAN);
  531. }
  532. void Dialog::on_butStopScan_clicked()
  533. {
  534. PTZForScan(DH_EXTPTZ_CLOSELINESCAN);
  535. }
  536. void Dialog::on_ButStartPan_clicked()
  537. {
  538. PTZForPan(DH_EXTPTZ_STARTPANCRUISE);
  539. }
  540. void Dialog::on_ButStopPan_clicked()
  541. {
  542. PTZForPan(DH_EXTPTZ_STOPPANCRUISE);
  543. }
  544. void Dialog::on_ButStartProgram_clicked()
  545. {
  546. bool numok = false;
  547. QString strPattemNo = ui->PattermNo->text();
  548. long lPattemNo = strPattemNo.toUInt(&numok);
  549. if(numok)
  550. {
  551. PTZForPattem( DH_EXTPTZ_SETMODESTART, lPattemNo );
  552. }
  553. else
  554. {
  555. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  556. }
  557. }
  558. void Dialog::on_ButStopProgram_clicked()
  559. {
  560. bool numok = false;
  561. QString strPattemNo = ui->PattermNo->text();
  562. long lPattemNo = strPattemNo.toUInt(&numok);
  563. if(numok)
  564. {
  565. PTZForPattem( DH_EXTPTZ_SETMODESTOP, lPattemNo );
  566. }
  567. else
  568. {
  569. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  570. }
  571. }
  572. void Dialog::on_ButStartPatterm_clicked()
  573. {
  574. bool numok = false;
  575. QString strPattemNo = ui->PattermNo->text();
  576. long lPattemNo = strPattemNo.toUInt(&numok);
  577. if(numok)
  578. {
  579. PTZForPattem( DH_EXTPTZ_RUNMODE, lPattemNo );
  580. }
  581. else
  582. {
  583. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  584. }
  585. }
  586. void Dialog::on_ButStopPatterm_clicked()
  587. {
  588. bool numok = false;
  589. QString strPattemNo = ui->PattermNo->text();
  590. long lPattemNo = strPattemNo.toUInt(&numok);
  591. if(numok)
  592. {
  593. PTZForPattem( DH_EXTPTZ_STOPMODE, lPattemNo );
  594. }
  595. else
  596. {
  597. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  598. }
  599. }
  600. void Dialog::on_ButDelPatterm_clicked()
  601. {
  602. bool numok = false;
  603. QString strPattemNo = ui->PattermNo->text();
  604. long lPattemNo = strPattemNo.toUInt(&numok);
  605. if(numok)
  606. {
  607. PTZForPattem( DH_EXTPTZ_DELETEMODE, lPattemNo );
  608. }
  609. else
  610. {
  611. QMessageBox::information(this, tr("Operate"), tr("Operate failed, Input data error"));
  612. }
  613. }
  614. void Dialog::PTZForPresetControl( int nType, int nPresetNo )
  615. {
  616. bool bRet = false;
  617. bRet = g_PTZ.PtzPreset(nType, nPresetNo);
  618. if(bRet == false)
  619. {
  620. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  621. }
  622. }
  623. void Dialog::PTZForAutoTour( int nType, int nTourNo, int nPresetNo, bool bAutoTour )
  624. {
  625. bool bRet = false;
  626. bRet = g_PTZ.PtzLoop(nType, nTourNo, nPresetNo, bAutoTour);
  627. if(bRet == false)
  628. {
  629. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  630. }
  631. }
  632. void Dialog::PTZForPattem( int nType, int nPattemNo )
  633. {
  634. bool bRet = false;
  635. bRet = g_PTZ.PtzMode(nType, nPattemNo);
  636. if(bRet == false)
  637. {
  638. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  639. }
  640. }
  641. void Dialog::PTZForScan( int nType )
  642. {
  643. bool bRet = false;
  644. bRet = g_PTZ.PtzLineScan(nType);
  645. if(bRet == false)
  646. {
  647. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  648. }
  649. }
  650. void Dialog::PTZForPan( int nType )
  651. {
  652. bool bRet = false;
  653. bRet = g_PTZ.PtzRotate(nType);
  654. if(bRet == false)
  655. {
  656. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  657. }
  658. }
  659. void Dialog::PTZForSIT( int nX, int nY, int nZoom)
  660. {
  661. bool bRet = false;
  662. bRet = g_PTZ.PtzFastGo(nX, nY, nZoom);
  663. if(bRet == false)
  664. {
  665. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  666. }
  667. }
  668. void Dialog::PTZForAUX( int nType, int nAuxNo )
  669. {
  670. bool bRet = false;
  671. bRet = g_PTZ.PtzAuxi(nType, nAuxNo);
  672. if(bRet == false)
  673. {
  674. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  675. }
  676. }
  677. void Dialog::PTZForMenu( int nType)
  678. {
  679. bool bRet = false;
  680. bRet = g_PTZ.PtzMenuControl(nType);
  681. if(bRet == false)
  682. {
  683. QMessageBox::information(this, tr("Operate"), tr("Operate fail"));
  684. }
  685. }
  686. bool Dialog::eventFilter(QObject *obj, QEvent *event)//message filter
  687. {
  688. if(event->type() == QEvent::User)
  689. {
  690. QString strDevInfo;
  691. strDevInfo.append("Disconnect!");
  692. QMessageBox::information(0, "Promt", strDevInfo);
  693. }
  694. return QWidget::eventFilter(obj, event);//don't eat event
  695. }