centerview.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #include "centerview.h"
  2. std::string gCompClass[] = {"Driver","Detection","Fusion","Control","Tool","test"};
  3. CenterView::CenterView(QTabWidget * pTab,ProgMon * pPM)
  4. {
  5. mTabMain = pTab;
  6. mpPM = pPM;
  7. int i;
  8. for(i=0;i<5;i++)
  9. {
  10. GroupUnit * gu = new GroupUnit();
  11. QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
  12. gu->mpGroup = p;
  13. gu->mstrgroupname = gCompClass[i];
  14. gu->mpPM = mpPM;
  15. gu->CreateView();
  16. connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
  17. connect(gu,SIGNAL(ProgLogClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgLogClick(ProgUnit*,ProgramViewUnit *,bool)));
  18. mvectorGropup.push_back(gu);
  19. }
  20. QGroupBox * p = CreateInfoGroup(mTabMain,"Info");
  21. QTimer * timer = new QTimer();
  22. connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
  23. timer->start(1000);
  24. }
  25. CenterView::~CenterView()
  26. {
  27. while(mTabMain->count()>0)mTabMain->removeTab(mTabMain->count()-1);
  28. }
  29. void CenterView::ResetView()
  30. {
  31. static bool bFirstReset = true;
  32. while(mTabMain->count()>1)
  33. {
  34. qDebug("count is %d",mTabMain->count());
  35. mTabMain->removeTab(mTabMain->count()-1);
  36. }
  37. if(bFirstReset)
  38. {
  39. mvectorGropup[0]->mpGroup->setVisible(false);
  40. bFirstReset = false;
  41. }
  42. mvectorGropup.clear();
  43. // mTabMain->clear();
  44. int i;
  45. for(i=0;i<5;i++)
  46. {
  47. GroupUnit * gu = new GroupUnit();
  48. QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
  49. gu->mpGroup = p;
  50. gu->mstrgroupname = gCompClass[i];
  51. gu->mpPM = mpPM;
  52. connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
  53. mvectorGropup.push_back(gu);
  54. }
  55. QGroupBox * p = CreateInfoGroup(mTabMain,"Info");
  56. for(i=0;i<5;i++)
  57. {
  58. mvectorGropup[i]->CreateView();
  59. }
  60. mTabMain->removeTab(0);
  61. // int i;
  62. // for(i=0;i<5;i++)
  63. // {
  64. // GroupUnit * gu = new GroupUnit();
  65. // QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
  66. // gu->mpGroup = p;
  67. // gu->mstrgroupname = gCompClass[i];
  68. // gu->mpPM = mpPM;
  69. // gu->CreateView();
  70. // connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
  71. // mvectorGropup.push_back(gu);
  72. // }
  73. // int i;
  74. // for(i=0;i<5;i++)
  75. // {
  76. // mvectorGropup[i]->DeleteView();
  77. // mvectorGropup[i]->ReCreateView();
  78. // }
  79. }
  80. QGroupBox * CenterView::CreateInfoGroup(QTabWidget * p,std::string strtab)
  81. {
  82. QGroupBox * pGroup = new QGroupBox();
  83. pGroup->setGeometry(0,0,1800,1000);
  84. QScrollArea * pScroll = new QScrollArea();
  85. pScroll->setWidget(pGroup);
  86. p->addTab(pScroll,strtab.data());
  87. mpPTE = new QPlainTextEdit(pGroup);
  88. mpPTE->setGeometry(30,30,800,600);
  89. return pGroup;
  90. }
  91. QGroupBox * CenterView::CreateGroup(QTabWidget * p,std::string strtab)
  92. {
  93. QGroupBox * pGroup = new QGroupBox();
  94. pGroup->setGeometry(0,0,1800,5000);
  95. QScrollArea * pScroll = new QScrollArea();
  96. pScroll->setWidget(pGroup);
  97. p->addTab(pScroll,strtab.data());
  98. return pGroup;
  99. }
  100. void CenterView::onProgClick(ProgUnit * pu,ProgramViewUnit * pvu,bool bClick)
  101. {
  102. emit ProgClick(pu,pvu,bClick);
  103. }
  104. void CenterView::onProgLogClick(ProgUnit * pu,ProgramViewUnit * pvu,bool bClick)
  105. {
  106. emit ProgLogClick(pu,pvu,bClick);
  107. }
  108. void CenterView::ProcStarted(ProgUnit *pu)
  109. {
  110. int i;
  111. int nsize = mvectorGropup.size();
  112. for(i=0;i<nsize;i++)
  113. {
  114. mvectorGropup.at(i)->ProcStarted(pu);
  115. }
  116. }
  117. void CenterView::ProcStopted(ProgUnit *pu)
  118. {
  119. int i;
  120. int nsize = mvectorGropup.size();
  121. for(i=0;i<nsize;i++)
  122. {
  123. mvectorGropup.at(i)->ProcStopted(pu);
  124. }
  125. }
  126. void CenterView::UpdateState()
  127. {
  128. int i;
  129. int nsize = mvectorGropup.size();
  130. for(i=0;i<nsize;i++)
  131. {
  132. mvectorGropup.at(i)->UpdateState();
  133. }
  134. }
  135. void CenterView::onTimer()
  136. {
  137. QString strsysinfo = mpPM->GetSysInfo();
  138. // qDebug(strsysinfo.toLatin1().data());
  139. mpPTE->setPlainText(strsysinfo);
  140. }