MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / IPImageViewer

Method IPImageViewer

ImagePlay/src/IPImageViewer.cpp:22–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20#include "IPImageViewer.h"
21
22IPImageViewer::IPImageViewer(ImageViewerWindow* imageViewer, QWidget *parent) :
23 QFrame(parent)
24{
25 setLayout(new QHBoxLayout(this));
26
27 _imageViewerWindow = imageViewer;
28
29 //delete on close
30 setAttribute(Qt::WA_DeleteOnClose);
31
32 //layout()->setContentsMargins(0,0,0,0);
33
34 _processStep = NULL;
35 _image = NULL;
36 _rawData = NULL;
37 _rawImage = NULL;
38 _tabIndex = -1;
39 _resultIndex = 0;
40
41 _zoomFitMode = false;
42
43 _scale = 1.0;
44 _offsetX = 0;
45 _offsetY = 0;
46
47 // add scene
48 _pixmapItem = new IPPixmapItem(this);
49 _graphicsScene = new QGraphicsScene(this);
50 _graphicsScene->addItem(_pixmapItem);
51
52 // add view
53 _graphicsView = new IPImageViewerGraphicsView(this);
54 _graphicsView->setScene(_graphicsScene);
55 _graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
56 _graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
57 _graphicsView->setAlignment(Qt::AlignCenter);
58
59 // prevent scrollbars from catching mouse wheel events
60 horizontalScrollBar()->installEventFilter(this);
61 verticalScrollBar()->installEventFilter(this);
62
63
64 layout()->addWidget(_graphicsView);
65
66 setMouseTracking(true);
67 _graphicsView->setMouseTracking(true);
68 //_graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
69 //_graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
70
71 connect(_graphicsView->horizontalScrollBar(), &QAbstractSlider::sliderMoved, _imageViewerWindow, &ImageViewerWindow::on_horizontalScrollBarChanged);
72 connect(_graphicsView->verticalScrollBar(), &QAbstractSlider::sliderMoved, _imageViewerWindow, &ImageViewerWindow::on_verticalScrollBarChanged);
73}
74
75IPImageViewer::~IPImageViewer()
76{

Callers

nothing calls this directly

Calls 2

horizontalScrollBarMethod · 0.80
verticalScrollBarMethod · 0.80

Tested by

no test coverage detected