Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Added size check on uiInitialize to avoid unneccesarry actions when size
Browse files Browse the repository at this point in the history
stays the same
  • Loading branch information
MPIBR-kretschmerf committed Feb 2, 2017
1 parent 969c51f commit 637fba8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 22 additions & 20 deletions TrackerPlugin_EyeTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,28 @@ QObject *TrackerPlugin_EyeTracker::worker()

void TrackerPlugin_EyeTracker::initializeUI(QLayout *layout, QGraphicsScene *cameraScene, QSize cameraResolution)
{
this->cameraResolution = cameraResolution;
layout->addWidget(this);
this->cameraScene = cameraScene;

for(int i=0;i<rectItems.size();i++){
this->cameraScene->addItem(rectItems.at(i));
}

/*Resize rectangles according to the correct size*/
if(cameraResolution.width()>cameraResolution.height()){
this->maxRectWidth = cameraResolution.height()/2;
}else{
this->maxRectWidth = cameraResolution.width()/2;
}
qDebug()<<maxRectWidth;
for(int i=0;i<rectItems.size();i++){
rectItems.at(i)->setRect(QRect(0,0,maxRectWidth,maxRectWidth));
emit(thresholdChanged(i, uiSliders.at(i)->value()));
emit(sizeChanged(i, QSize(rectItems.at(i)->rect().width(), rectItems.at(i)->rect().height())));
emit(posChanged(i, QPoint(rectItems.at(i)->pos().rx(),rectItems.at(i)->pos().ry())));
/*Keep rectangles unchanged if the resolution didn't change*/
if(this->cameraResolution!=cameraResolution){
this->cameraResolution = cameraResolution;
layout->addWidget(this);
this->cameraScene = cameraScene;

for(int i=0;i<rectItems.size();i++){
this->cameraScene->addItem(rectItems.at(i));
}

/*Resize rectangles according to the correct size*/
if(cameraResolution.width()>cameraResolution.height()){
this->maxRectWidth = cameraResolution.height()/2;
}else{
this->maxRectWidth = cameraResolution.width()/2;
}
for(int i=0;i<rectItems.size();i++){
rectItems.at(i)->setRect(QRect(0,0,maxRectWidth,maxRectWidth));
emit(thresholdChanged(i, uiSliders.at(i)->value()));
emit(sizeChanged(i, QSize(rectItems.at(i)->rect().width(), rectItems.at(i)->rect().height())));
emit(posChanged(i, QPoint(rectItems.at(i)->pos().rx(),rectItems.at(i)->pos().ry())));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion TrackerPlugin_EyeTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TrackerPlugin_EyeTracker : public QWidget, public TrackerInterface
QObject *worker();
void initializeUI(QLayout* guiTargetLayout, QGraphicsScene* cameraScene, QSize cameraResolution);
TrackerWorker* trackerWorker;
QSize cameraResolution;
QSize cameraResolution = QSize(0,0);

private:
Ui::TrackerPlugin_EyeTracker *ui;
Expand Down

0 comments on commit 637fba8

Please sign in to comment.