123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "dialogbigpic.h"
- #include "ui_dialogbigpic.h"
- #include "mainwindow.h"
- extern iv::vision::rawpic grawpic[CAMERA_NUM];
- extern qint64 gTimeRawPic[CAMERA_NUM] ;
- extern QMutex gMutexPic[CAMERA_NUM];
- DialogBigPic::DialogBigPic(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogBigPic)
- {
- ui->setupUi(this);
- mpview = new MyView(this);
- mpview->setObjectName(QStringLiteral("graphicsView"));
- mpview->setGeometry(QRect(30, 30, 600, 600));
- mpview->setCacheMode(mpview->CacheBackground);
- mscene = new QGraphicsScene;
- mpPicView = new IVPicView();
- mpPicView->start();
- mnLastPicTime = 0;
- mbDraw = false;
- connect(mpPicView,SIGNAL(painterupadate()),this,SLOT(onPainterUpdate()));
- QTimer * timer = new QTimer();
- connect(timer,SIGNAL(timeout()),this,SLOT(onTimerPic()));
- timer->start(10);
- setWindowTitle("View Picture");
- }
- DialogBigPic::~DialogBigPic()
- {
- delete ui;
- }
- void DialogBigPic::onTimerPic()
- {
- if(mbRefresh == false)return;
- bool bUpdate = false;
- int ncam = mnCamera;
- if((mnLastPicTime != gTimeRawPic[ncam])&&(gTimeRawPic[ncam]!= 0))
- {
- gMutexPic[ncam].lock();
- mpPicView->SetPic(grawpic[ncam]);
- gMutexPic[ncam].unlock();
- bUpdate = true;
- mbDraw = true;
- }
- // if(bUpdate)update();
- }
- void DialogBigPic::paintEvent(QPaintEvent *)
- {
- if(mbDraw)
- {
- QImage image = mpPicView->GetImage();
- mscene->clear();
- mscene->addPixmap(QPixmap::fromImage(image));
- mpview->setScene(mscene);
- mpview->show();
- }
- }
- void DialogBigPic::resizeEvent(QResizeEvent *event)
- {
- (void)event;
- QRect rect = this->geometry();
- double fwidth = rect.width()/1;
- double fheight = rect.height()/1;
- mpview->setGeometry(0,0,fwidth,fheight);
- // rect.setX(rect.x());
- }
- void DialogBigPic::setRefresh(bool brefresh)
- {
- mbRefresh = brefresh;
- }
- void DialogBigPic::onPainterUpdate()
- {
- update();
- }
- void DialogBigPic::setCamera(int n)
- {
- mnCamera = n;
- }
|