SlugsVideoCamControl.cpp 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "SlugsVideoCamControl.h"
#include "ui_SlugsVideoCamControl.h"

#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QTextStream>
#include <QScrollBar>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QDebug>


SlugsVideoCamControl::SlugsVideoCamControl(QWidget *parent) :
14
    QWidget(parent),
15 16
    ui(new Ui::SlugsVideoCamControl),
    dragging(0)
17 18 19 20 21 22 23 24 25 26 27 28 29
{
    ui->setupUi(this);

//    QGraphicsScene *scene = new QGraphicsScene(ui->CamControlPanel_graphicsView);
//         scene->setItemIndexMethod(QGraphicsScene::NoIndex);
//         scene->setSceneRect(-200, -200, 400, 400);
//         setScene(scene);
//         setCacheMode(CacheBackground);
//         setViewportUpdateMode(BoundingRectViewportUpdate);
//         setRenderHint(QPainter::Antialiasing);
//         setTransformationAnchor(AnchorUnderMouse);
//         setResizeAnchor(AnchorViewCenter);

30 31
//      ui->CamControlPanel_graphicsView->installEventFilter(this);
//      ui->label_x->installEventFilter(this);
32 33 34 35 36 37 38 39 40 41

}

SlugsVideoCamControl::~SlugsVideoCamControl()
{
    delete ui;
}

void SlugsVideoCamControl::mouseMoveEvent(QMouseEvent *event)
{
42 43 44 45
  QPoint tL = ui->widget->frameGeometry().topLeft();
  QPoint bR = ui->widget->frameGeometry().bottomRight();

  if (!(event->x() > bR.x() || event->x() < tL.x() ||
46
      event->y() > bR.y() || event->y() < tL.y() ) && dragging){
47 48
    ui->label_x->setText(QString::number(event->x()));
    ui->label_y->setText(QString::number(event->y()));
49 50
  }

51 52 53
}


54 55 56
void SlugsVideoCamControl::mousePressEvent(QMouseEvent *evnt)
{
  Q_UNUSED(evnt);
57

58 59
  dragging = true;
}
60

61 62 63 64
void SlugsVideoCamControl::mouseReleaseEvent(QMouseEvent *evnt)
{
dragging = false;
}
65 66 67 68 69

//void SlugsVideoCamControl::mouseDoubleClickEvent(QMouseEvent *evnt)
//{

//}