123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- #include "centerview.h"
- std::string gCompClass[] = {"Driver","Detection","Fusion","Control","Tool","test"};
- CenterView::CenterView(QTabWidget * pTab,ProgMon * pPM)
- {
- mTabMain = pTab;
- mpPM = pPM;
- int i;
- for(i=0;i<5;i++)
- {
- GroupUnit * gu = new GroupUnit();
- QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
- gu->mpGroup = p;
- gu->mstrgroupname = gCompClass[i];
- gu->mpPM = mpPM;
- gu->CreateView();
- connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
- connect(gu,SIGNAL(ProgLogClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgLogClick(ProgUnit*,ProgramViewUnit *,bool)));
- mvectorGropup.push_back(gu);
- }
- QGroupBox * p = CreateInfoGroup(mTabMain,"Info");
- QTimer * timer = new QTimer();
- connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
- timer->start(1000);
- }
- CenterView::~CenterView()
- {
- while(mTabMain->count()>0)mTabMain->removeTab(mTabMain->count()-1);
- }
- void CenterView::ResetView()
- {
- static bool bFirstReset = true;
- while(mTabMain->count()>1)
- {
- qDebug("count is %d",mTabMain->count());
- mTabMain->removeTab(mTabMain->count()-1);
- }
- if(bFirstReset)
- {
- mvectorGropup[0]->mpGroup->setVisible(false);
- bFirstReset = false;
- }
- mvectorGropup.clear();
- // mTabMain->clear();
- int i;
- for(i=0;i<5;i++)
- {
- GroupUnit * gu = new GroupUnit();
- QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
- gu->mpGroup = p;
- gu->mstrgroupname = gCompClass[i];
- gu->mpPM = mpPM;
- connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
- mvectorGropup.push_back(gu);
- }
- QGroupBox * p = CreateInfoGroup(mTabMain,"Info");
- for(i=0;i<5;i++)
- {
- mvectorGropup[i]->CreateView();
- }
- mTabMain->removeTab(0);
- // int i;
- // for(i=0;i<5;i++)
- // {
- // GroupUnit * gu = new GroupUnit();
- // QGroupBox * p = CreateGroup(mTabMain,gCompClass[i]);
- // gu->mpGroup = p;
- // gu->mstrgroupname = gCompClass[i];
- // gu->mpPM = mpPM;
- // gu->CreateView();
- // connect(gu,SIGNAL(ProgClick(ProgUnit*,ProgramViewUnit *,bool)),this,SLOT(onProgClick(ProgUnit*,ProgramViewUnit *,bool)));
- // mvectorGropup.push_back(gu);
- // }
- // int i;
- // for(i=0;i<5;i++)
- // {
- // mvectorGropup[i]->DeleteView();
- // mvectorGropup[i]->ReCreateView();
- // }
- }
- QGroupBox * CenterView::CreateInfoGroup(QTabWidget * p,std::string strtab)
- {
- QGroupBox * pGroup = new QGroupBox();
- pGroup->setGeometry(0,0,1800,1000);
- QScrollArea * pScroll = new QScrollArea();
- pScroll->setWidget(pGroup);
- p->addTab(pScroll,strtab.data());
- mpPTE = new QPlainTextEdit(pGroup);
- mpPTE->setGeometry(30,30,800,600);
- return pGroup;
- }
- QGroupBox * CenterView::CreateGroup(QTabWidget * p,std::string strtab)
- {
- QGroupBox * pGroup = new QGroupBox();
- pGroup->setGeometry(0,0,1800,5000);
- QScrollArea * pScroll = new QScrollArea();
- pScroll->setWidget(pGroup);
- p->addTab(pScroll,strtab.data());
- return pGroup;
- }
- void CenterView::onProgClick(ProgUnit * pu,ProgramViewUnit * pvu,bool bClick)
- {
- emit ProgClick(pu,pvu,bClick);
- }
- void CenterView::onProgLogClick(ProgUnit * pu,ProgramViewUnit * pvu,bool bClick)
- {
- emit ProgLogClick(pu,pvu,bClick);
- }
- void CenterView::ProcStarted(ProgUnit *pu)
- {
- int i;
- int nsize = mvectorGropup.size();
- for(i=0;i<nsize;i++)
- {
- mvectorGropup.at(i)->ProcStarted(pu);
- }
- }
- void CenterView::ProcStopted(ProgUnit *pu)
- {
- int i;
- int nsize = mvectorGropup.size();
- for(i=0;i<nsize;i++)
- {
- mvectorGropup.at(i)->ProcStopted(pu);
- }
- }
- void CenterView::UpdateState()
- {
- int i;
- int nsize = mvectorGropup.size();
- for(i=0;i<nsize;i++)
- {
- mvectorGropup.at(i)->UpdateState();
- }
- }
- void CenterView::onTimer()
- {
- QString strsysinfo = mpPM->GetSysInfo();
- // qDebug(strsysinfo.toLatin1().data());
- mpPTE->setPlainText(strsysinfo);
- }
|