From 81f3cece14f68570e22440baf4674f7e4ed04d96 Mon Sep 17 00:00:00 2001 From: schroedtert <t.schroedter@fz-juelich.de> Date: Fri, 4 Mar 2022 15:29:13 +0100 Subject: [PATCH 1/5] Merge trackingRoiItem and recognitionRoiItem in one class RoiItem Only differences between both classes were the color and the on which control checkbox to act and what function of PeTrack to trigger. This is now resolved via Qt's signal slot mechanism. Signed-off-by: schroedtert <t.schroedter@fz-juelich.de> --- CMakeLists.txt | 6 +- include/petrack.h | 10 +- include/{recognitionRoiItem.h => roiItem.h} | 22 +- include/trackingRoiItem.h | 63 ---- src/control.cpp | 3 +- src/personStorage.cpp | 2 +- src/petrack.cpp | 12 +- src/recognition.cpp | 2 +- src/{recognitionRoiItem.cpp => roiItem.cpp} | 27 +- src/tracker.cpp | 2 +- src/trackerItem.cpp | 3 +- src/trackingRoiItem.cpp | 350 -------------------- 12 files changed, 50 insertions(+), 452 deletions(-) rename include/{recognitionRoiItem.h => roiItem.h} (83%) delete mode 100644 include/trackingRoiItem.h rename src/{recognitionRoiItem.cpp => roiItem.cpp} (94%) delete mode 100644 src/trackingRoiItem.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1491e11f2..fe245a84a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,7 +328,6 @@ target_sources(petrack_core PRIVATE include/colorMarkerWidget.h include/codeMarkerWidget.h include/multiColorMarkerWidget.h - include/recognitionRoiItem.h include/imageItem.h include/logoItem.h include/gridItem.h @@ -364,7 +363,7 @@ target_sources(petrack_core PRIVATE include/qtColorTriangle.h include/swapFilter.h include/extrCalibration.h - include/trackingRoiItem.h + include/roiItem.h include/analysePlot.h include/IO.h include/skeletonTree.h @@ -389,7 +388,6 @@ target_sources(petrack_core PRIVATE src/colorMarkerWidget.cpp src/codeMarkerWidget.cpp src/multiColorMarkerWidget.cpp - src/recognitionRoiItem.cpp src/imageItem.cpp src/logoItem.cpp src/gridItem.cpp @@ -425,7 +423,7 @@ target_sources(petrack_core PRIVATE src/qtColorTriangle.cpp src/swapFilter.cpp src/extrCalibration.cpp - src/trackingRoiItem.cpp + src/roiItem.cpp src/IO.cpp src/skeletonTree.cpp src/skeletonTreeFactory.cpp diff --git a/include/petrack.h b/include/petrack.h index 187b268fb..1596a093e 100644 --- a/include/petrack.h +++ b/include/petrack.h @@ -46,7 +46,7 @@ class CalibFilter; class Animation; -class TrackingRoiItem; +class RoiItem; class RecognitionRoiItem; class GridItem; @@ -240,8 +240,8 @@ public: inline MultiColorMarkerItem *getMultiColorMarkerItem() { return mMultiColorMarkerItem; } inline BackgroundItem *getBackgroundItem() { return mBackgroundItem; } inline MoCapItem *getMoCapItem() { return mMoCapItem; } - inline RecognitionRoiItem *getRecoRoiItem() { return mRecognitionRoiItem; } - inline TrackingRoiItem *getTrackRoiItem() { return mTrackingRoiItem; } + inline RoiItem *getRecoRoiItem() { return mRecognitionRoiItem; } + inline RoiItem *getTrackRoiItem() { return mTrackingRoiItem; } inline TrackerItem *getTrackerItem() { return mTrackerItem; } inline Animation *getAnimation() { return mAnimation; } @@ -429,8 +429,8 @@ private: LogoItem *mLogoItem; CoordItem *mCoordItem; GridItem *mGridItem; - RecognitionRoiItem *mRecognitionRoiItem; - TrackingRoiItem *mTrackingRoiItem; + RoiItem *mRecognitionRoiItem; + RoiItem *mTrackingRoiItem; TrackerItem *mTrackerItem; StereoItem *mStereoItem; ColorMarkerItem *mColorMarkerItem; diff --git a/include/recognitionRoiItem.h b/include/roiItem.h similarity index 83% rename from include/recognitionRoiItem.h rename to include/roiItem.h index d942d6d90..06306b482 100644 --- a/include/recognitionRoiItem.h +++ b/include/roiItem.h @@ -18,19 +18,22 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#ifndef RECOGNITIONROIITEM_H -#define RECOGNITIONROIITEM_H +#ifndef ROIITEM_H +#define ROIITEM_H #include <QGraphicsRectItem> +#include <QObject> class Petrack; class Control; - -class RecognitionRoiItem : public QGraphicsRectItem +class RoiItem : public QObject, public QGraphicsRectItem { + Q_OBJECT + inline static constexpr int DISTANCE_TO_BORDER = 5; inline static constexpr int MIN_SIZE = 10; + enum pressLocation { inside, @@ -50,14 +53,21 @@ private: QRect mPressRect; QPointF mPressPos; enum pressLocation mPressLocation; + bool mIsFixed; public: - RecognitionRoiItem(QWidget *wParent, QGraphicsItem *parent = nullptr); + RoiItem(QWidget *wParent, QColor color, QGraphicsItem *parent = nullptr); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void checkRect(); + +public slots: + void setFixed(bool fixed) { mIsFixed = fixed; } + +signals: + void changed(); // NOLINT }; -#endif +#endif // ROIITEM_H diff --git a/include/trackingRoiItem.h b/include/trackingRoiItem.h deleted file mode 100644 index 36512d1e2..000000000 --- a/include/trackingRoiItem.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * PeTrack - Software for tracking pedestrians movement in videos - * Copyright (C) 2010-2022 Forschungszentrum Jßlich GmbH, - * Maik Boltes, Juliane Adrian, Ricardo Martin Brualla, Arne Graf, Paul Häger, Daniel Hillebrand, - * Deniz Kilic, Paul Lieberenz, Daniel Salden, Tobias SchrÜdter, Ann Katrin Seemann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -#ifndef TRACKINGROIITEM_H -#define TRACKINGROIITEM_H - -#include <QGraphicsRectItem> - -class Petrack; -class Control; - -class TrackingRoiItem : public QGraphicsRectItem -{ - inline static constexpr int DISTANCE_TO_BORDER = 5; - inline static constexpr int MIN_SIZE = 10; - - enum pressLocation - { - inside, - top, - bottom, - left, - right, - topLeft, - topRight, - bottomLeft, - bottomRight - }; - -private: - Petrack *mMainWindow; - Control *mControlWidget; - QRect mPressRect; - QPointF mPressPos; - enum pressLocation mPressLocation; - -public: - TrackingRoiItem(QWidget *wParent, QGraphicsItem *parent = nullptr); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - void checkRect(); -}; - -#endif // TRACKINGROIITEM_H diff --git a/src/control.cpp b/src/control.cpp index e2fac3713..786632c2a 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -34,11 +34,10 @@ #include "pMessageBox.h" #include "petrack.h" #include "player.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "stereoWidget.h" #include "tracker.h" #include "trackerItem.h" -#include "trackingRoiItem.h" #include "view.h" #include <QDomElement> diff --git a/src/personStorage.cpp b/src/personStorage.cpp index 11ab1c3ca..a3a4b465a 100644 --- a/src/personStorage.cpp +++ b/src/personStorage.cpp @@ -25,7 +25,7 @@ #include "multiColorMarkerWidget.h" #include "pMessageBox.h" #include "petrack.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" /** * @brief split trajectorie pers before frame frame diff --git a/src/petrack.cpp b/src/petrack.cpp index ceb25c1cf..0959c5599 100644 --- a/src/petrack.cpp +++ b/src/petrack.cpp @@ -43,13 +43,12 @@ #include "pMessageBox.h" #include "petrack.h" #include "player.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "stereoItem.h" #include "stereoWidget.h" #include "tracker.h" #include "trackerItem.h" #include "trackerReal.h" -#include "trackingRoiItem.h" #include "view.h" #include <QtPrintSupport/QPrintDialog> @@ -154,10 +153,15 @@ Petrack::Petrack() : mCoordItem->setZValue(3); // groesser heisst weiter oben mImageItem->setCoordItem(mCoordItem); - mTrackingRoiItem = new TrackingRoiItem(this); + mTrackingRoiItem = new RoiItem(this, Qt::blue); + connect(mControlWidget->trackRoiFix, &QCheckBox::stateChanged, mTrackingRoiItem, &RoiItem::setFixed); + connect(mTrackingRoiItem, &RoiItem::changed, this, [=]() { this->setTrackChanged(true); }); mTrackingRoiItem->setZValue(4); // groesser heisst weiter oben - mRecognitionRoiItem = new RecognitionRoiItem(this); + mRecognitionRoiItem = new RoiItem(this, Qt::green); + connect(mControlWidget->roiFix, &QCheckBox::stateChanged, mRecognitionRoiItem, &RoiItem::setFixed); + connect(mRecognitionRoiItem, &RoiItem::changed, this, [=]() { this->setRecognitionChanged(true); }); + mRecognitionRoiItem->setZValue(5); // groesser heisst weiter oben diff --git a/src/recognition.cpp b/src/recognition.cpp index e8eb6186c..ef5125f56 100644 --- a/src/recognition.cpp +++ b/src/recognition.cpp @@ -32,7 +32,7 @@ #include "multiColorMarkerItem.h" #include "multiColorMarkerWidget.h" #include "pMessageBox.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "tracker.h" #include <QPointF> diff --git a/src/recognitionRoiItem.cpp b/src/roiItem.cpp similarity index 94% rename from src/recognitionRoiItem.cpp rename to src/roiItem.cpp index a97823122..9bef483e9 100644 --- a/src/recognitionRoiItem.cpp +++ b/src/roiItem.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "control.h" #include "petrack.h" @@ -26,21 +26,21 @@ #include <QtWidgets> -RecognitionRoiItem::RecognitionRoiItem(QWidget *wParent, QGraphicsItem *parent) : QGraphicsRectItem(parent) +RoiItem::RoiItem(QWidget *wParent, QColor color, QGraphicsItem *parent) : QObject(wParent), QGraphicsRectItem(parent) { mMainWindow = (class Petrack *) wParent; mControlWidget = mMainWindow->getControlWidget(); setRect(0, 0, 0, 0); // qreal x, qreal y, qreal width, qreal height - QPen pen(Qt::green); + QPen pen(color); setPen(pen); setAcceptHoverEvents(true); setFlags(ItemIsMovable); // default in control hide(); // default in control } -void RecognitionRoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) +void RoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if(!mControlWidget->getRecoRoiFix()) + if(!mIsFixed) { mPressRect = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); @@ -101,9 +101,10 @@ void RecognitionRoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) QGraphicsRectItem::mousePressEvent(event); } -void RecognitionRoiItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void RoiItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - mMainWindow->setRecognitionChanged(true); + emit changed(); + if(!mMainWindow->isLoading()) { mMainWindow->updateImage(); @@ -113,9 +114,9 @@ void RecognitionRoiItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } // event, of moving mouse while mouse button is pressed -void RecognitionRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void RoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if(!mControlWidget->getRecoRoiFix()) + if(!mIsFixed) { QImage *img = mMainWindow->getImage(); QPoint diff = QPoint(myRound((event->pos() - mPressPos).x()), myRound((event->pos() - mPressPos).y())); @@ -229,7 +230,7 @@ void RecognitionRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } // event, of moving mouse -void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +void RoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { QPointF pos = event->scenePos(); pos.setX(pos.x() + mMainWindow->getImageBorderSize()); @@ -241,7 +242,7 @@ void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { mMainWindow->setMousePosOnImage(pos); - if(!mControlWidget->getRecoRoiFix()) + if(!mIsFixed) { QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); @@ -298,12 +299,12 @@ void RecognitionRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } // check rect because bordersize changes and without mouse event nothing changes the rect -void RecognitionRoiItem::checkRect() +void RoiItem::checkRect() { cv::Mat img = mMainWindow->getImageFiltered(); + if(!img.empty()) { - // not QImage *img = mMainWindow->getImage(); as size is not adapted yet QRect r = QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); if(r.x() > img.cols - mMainWindow->getImageBorderSize() - MIN_SIZE || diff --git a/src/tracker.cpp b/src/tracker.cpp index 4eb1ff784..062373e7f 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -26,7 +26,7 @@ #include "multiColorMarkerWidget.h" #include "pMessageBox.h" #include "petrack.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "stereoWidget.h" #include <ctime> diff --git a/src/trackerItem.cpp b/src/trackerItem.cpp index 85cbb6337..8dca56c62 100644 --- a/src/trackerItem.cpp +++ b/src/trackerItem.cpp @@ -24,9 +24,8 @@ #include "control.h" #include "personStorage.h" #include "petrack.h" -#include "recognitionRoiItem.h" +#include "roiItem.h" #include "tracker.h" -#include "trackingRoiItem.h" #include "view.h" #include <QInputDialog> diff --git a/src/trackingRoiItem.cpp b/src/trackingRoiItem.cpp deleted file mode 100644 index 6b961c0b5..000000000 --- a/src/trackingRoiItem.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* - * PeTrack - Software for tracking pedestrians movement in videos - * Copyright (C) 2010-2022 Forschungszentrum Jßlich GmbH, - * Maik Boltes, Juliane Adrian, Ricardo Martin Brualla, Arne Graf, Paul Häger, Daniel Hillebrand, - * Deniz Kilic, Paul Lieberenz, Daniel Salden, Tobias SchrÜdter, Ann Katrin Seemann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -#include "trackingRoiItem.h" - -#include "control.h" -#include "petrack.h" -#include "view.h" - -#include <QtWidgets> - -TrackingRoiItem::TrackingRoiItem(QWidget *wParent, QGraphicsItem *parent) : QGraphicsRectItem(parent) -{ - mMainWindow = (class Petrack *) wParent; - mControlWidget = mMainWindow->getControlWidget(); - setRect(0, 0, 0, 0); // qreal x, qreal y, qreal width, qreal height - QPen pen(Qt::blue); - setPen(pen); - setAcceptHoverEvents(true); - setFlags(ItemIsMovable); // default in control - hide(); // default in control -} - -void TrackingRoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if(!mControlWidget->getTrackRoiFix()) - { - mPressRect = - QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); - mPressPos = event->pos(); - if((event->pos()).x() < DISTANCE_TO_BORDER + mPressRect.x()) - { - if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) - { - mPressLocation = topLeft; - setCursor(Qt::SizeFDiagCursor); - } - else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) - { - mPressLocation = bottomLeft; - setCursor(Qt::SizeBDiagCursor); - } - else - { - mPressLocation = left; - setCursor(Qt::SizeHorCursor); - } - } - else if((event->pos()).x() > mPressRect.width() + mPressRect.x() - DISTANCE_TO_BORDER) - { - if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) - { - mPressLocation = topRight; - setCursor(Qt::SizeBDiagCursor); - } - else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) - { - mPressLocation = bottomRight; - setCursor(Qt::SizeFDiagCursor); - } - else - { - mPressLocation = right; - setCursor(Qt::SizeHorCursor); - } - } - else if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) - { - mPressLocation = top; - setCursor(Qt::SizeVerCursor); - } - else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) - { - mPressLocation = bottom; - setCursor(Qt::SizeVerCursor); - } - else - { - mPressLocation = inside; - setCursor(Qt::ClosedHandCursor); - } - } - - QGraphicsRectItem::mousePressEvent(event); -} - -void TrackingRoiItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - mMainWindow->setTrackChanged(true); - // mMainWindow->setRecognitionChanged(true); - if(!mMainWindow->isLoading()) - { - mMainWindow->updateImage(); - } - - QGraphicsRectItem::mouseReleaseEvent(event); -} - -// event, of moving mouse while mouse button is pressed -void TrackingRoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if(!mControlWidget->getTrackRoiFix()) - { - QImage *img = mMainWindow->getImage(); - QPoint diff = QPoint(myRound((event->pos() - mPressPos).x()), myRound((event->pos() - mPressPos).y())); - // raender des bildes nicht ueberscheiten - // swappen des rechtecks vermeiden, damit keine negativen width... - if(img != nullptr) - { - if(mPressLocation == inside || mPressLocation == topLeft || mPressLocation == left || - mPressLocation == bottomLeft) - { - if(mPressRect.x() + diff.x() < -mMainWindow->getImageBorderSize()) - { - diff.setX(-mPressRect.x() - mMainWindow->getImageBorderSize()); - } - if(mPressLocation != inside && mPressRect.width() - diff.x() < MIN_SIZE) - { - diff.setX(mPressRect.width() - MIN_SIZE); - } - } - if(mPressLocation == inside || mPressLocation == topLeft || mPressLocation == top || - mPressLocation == topRight) - { - if(mPressRect.y() + diff.y() < -mMainWindow->getImageBorderSize()) - { - diff.setY(-mPressRect.y() - mMainWindow->getImageBorderSize()); - } - if(mPressLocation != inside && mPressRect.height() - diff.y() < MIN_SIZE) - { - diff.setY(mPressRect.height() - MIN_SIZE); - } - } - if(mPressLocation == inside || mPressLocation == topRight || mPressLocation == right || - mPressLocation == bottomRight) - { - if(mPressRect.x() + diff.x() + mPressRect.width() > img->width() - mMainWindow->getImageBorderSize()) - { - diff.setX(img->width() - mPressRect.x() - mPressRect.width() - mMainWindow->getImageBorderSize()); - } - if(mPressLocation != inside && mPressRect.width() + diff.x() < MIN_SIZE) - { - diff.setX(-mPressRect.width() + MIN_SIZE); - } - } - if(mPressLocation == inside || mPressLocation == bottomLeft || mPressLocation == bottom || - mPressLocation == bottomRight) - { - if(mPressRect.y() + diff.y() + mPressRect.height() > img->height() - mMainWindow->getImageBorderSize()) - { - diff.setY(img->height() - mPressRect.y() - mPressRect.height() - mMainWindow->getImageBorderSize()); - } - if(mPressLocation != inside && mPressRect.height() + diff.y() < MIN_SIZE) - { - diff.setY(-mPressRect.height() + MIN_SIZE); - } - } - } - if(mPressLocation == topLeft) - { - setRect( - mPressRect.x() + diff.x(), - mPressRect.y() + diff.y(), - mPressRect.width() - diff.x(), - mPressRect.height() - diff.y()); - } - else if(mPressLocation == topRight) - { - setRect( - mPressRect.x(), - mPressRect.y() + diff.y(), - mPressRect.width() + diff.x(), - mPressRect.height() - diff.y()); - } - else if(mPressLocation == bottomLeft) - { - setRect( - mPressRect.x() + diff.x(), - mPressRect.y(), - mPressRect.width() - diff.x(), - mPressRect.height() + diff.y()); - } - else if(mPressLocation == bottomRight) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height() + diff.y()); - } - else if(mPressLocation == left) - { - setRect(mPressRect.x() + diff.x(), mPressRect.y(), mPressRect.width() - diff.x(), mPressRect.height()); - } - else if(mPressLocation == right) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height()); - } - else if(mPressLocation == top) - { - setRect(mPressRect.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height() - diff.y()); - } - else if(mPressLocation == bottom) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width(), mPressRect.height() + diff.y()); - } - else // entspricht: if (mPressLocation == inside) - { - setRect(mPressRect.x() + diff.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height()); - } - // nicht, da sonst koordinatensystem verschoben wird: QGraphicsRectItem::mouseMoveEvent(event); // drag - } - else // drag mach ich selber - { - QGraphicsRectItem::mouseMoveEvent(event); - } -} - -// event, of moving mouse -void TrackingRoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - QPointF pos = event->scenePos(); - pos.setX(pos.x() + mMainWindow->getImageBorderSize()); - pos.setY(pos.y() + mMainWindow->getImageBorderSize()); - // abfrage auf width() ..., da durch rectLinie die recoBox etwas groesser ist als das Bild und - // es bei mMainWindow->setMousePosOnImage(pos); zum fehler beim bildzugriff kommen kann!!! - if(mMainWindow->getImage() && //(pos.x() > 0) && (pos.y() > 0) && - (pos.x() < mMainWindow->getImage()->width()) && (pos.y() < mMainWindow->getImage()->height())) - { - mMainWindow->setMousePosOnImage(pos); - - if(!mControlWidget->getTrackRoiFix()) - { - QRect r = - QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); - if((event->pos()).x() < DISTANCE_TO_BORDER + r.x()) - { - if((event->pos()).y() < DISTANCE_TO_BORDER + r.y()) - { - setCursor(Qt::SizeFDiagCursor); - } - else if((event->pos()).y() > r.height() + r.y() - DISTANCE_TO_BORDER) - { - setCursor(Qt::SizeBDiagCursor); - } - else - { - setCursor(Qt::SizeHorCursor); - } - } - else if((event->pos()).x() > r.width() + r.x() - DISTANCE_TO_BORDER) - { - if((event->pos()).y() < DISTANCE_TO_BORDER + r.y()) - { - setCursor(Qt::SizeBDiagCursor); - } - else if((event->pos()).y() > r.height() + r.y() - DISTANCE_TO_BORDER) - { - setCursor(Qt::SizeFDiagCursor); - } - else - { - setCursor(Qt::SizeHorCursor); - } - } - else if( - ((event->pos()).y() < DISTANCE_TO_BORDER + r.y()) || - ((event->pos()).y() > r.height() + r.y() - DISTANCE_TO_BORDER)) - { - setCursor(Qt::SizeVerCursor); - } - else - { - setCursor(Qt::OpenHandCursor); - } - } - else // wird nur einmal durchaufen - ruecksetzen in control.cpp - { - setAcceptHoverEvents(false); // verhoindert nicht, dass wenn objekt darunter liegt, was andereen cursor - // haette - cursor wird weiterhin beim drueberfahren auf cross gesetzt - setCursor(Qt::CrossCursor); - } - } - - QGraphicsRectItem::hoverMoveEvent(event); -} - -// check rect because bordersize changes and without mouse event nothing changes the rect -void TrackingRoiItem::checkRect() -{ - // not QImage *img = mMainWindow->getImage(); as size is not adapted yet - cv::Mat img = mMainWindow->getImageFiltered(); - - if(!img.empty()) - { - QRect r = - QRect(myRound(rect().left()), myRound(rect().top()), myRound(rect().width()), myRound(rect().height())); - if(r.x() > img.cols - mMainWindow->getImageBorderSize() - MIN_SIZE || - r.y() > img.rows - mMainWindow->getImageBorderSize() - MIN_SIZE || - r.x() + r.width() < -mMainWindow->getImageBorderSize() + MIN_SIZE || - r.y() + r.height() < -mMainWindow->getImageBorderSize() + MIN_SIZE) - { - setRect(-mMainWindow->getImageBorderSize(), -mMainWindow->getImageBorderSize(), img.cols, img.rows); - } - else - { - if(r.x() < -mMainWindow->getImageBorderSize()) - { - setRect( - -mMainWindow->getImageBorderSize(), - r.y(), - r.width() + (mMainWindow->getImageBorderSize() + r.x()), - r.height()); - } - if(r.y() < -mMainWindow->getImageBorderSize()) - { - setRect( - r.x(), - -mMainWindow->getImageBorderSize(), - r.width(), - r.height() + (mMainWindow->getImageBorderSize() + r.y())); - } - if(r.x() + mMainWindow->getImageBorderSize() + r.width() > img.cols) - { - setRect(r.x(), r.y(), img.cols - r.x() - mMainWindow->getImageBorderSize(), r.height()); - } - if(r.y() + mMainWindow->getImageBorderSize() + r.height() > img.rows) - { - setRect(r.x(), r.y(), r.width(), img.rows - r.y() - mMainWindow->getImageBorderSize()); - } - } - } - else - { - setRect(0, 0, 0, 0); - } -} -- GitLab From dd2de43853afe429be33e6fbb0d18399df3f5adf Mon Sep 17 00:00:00 2001 From: schroedtert <t.schroedter@fz-juelich.de> Date: Fri, 4 Mar 2022 16:08:15 +0100 Subject: [PATCH 2/5] Some refactoring - renaming function to better reflect purpose - resolve clang-tidy warnings - cleaning up, remove no longer needed includes Signed-off-by: schroedtert <t.schroedter@fz-juelich.de> --- include/roiItem.h | 30 ++++---- src/petrack.cpp | 4 +- src/roiItem.cpp | 171 ++++++++++++++++++++++------------------------ 3 files changed, 97 insertions(+), 108 deletions(-) diff --git a/include/roiItem.h b/include/roiItem.h index 06306b482..5ad084710 100644 --- a/include/roiItem.h +++ b/include/roiItem.h @@ -25,7 +25,6 @@ #include <QObject> class Petrack; -class Control; class RoiItem : public QObject, public QGraphicsRectItem { @@ -34,7 +33,7 @@ class RoiItem : public QObject, public QGraphicsRectItem inline static constexpr int DISTANCE_TO_BORDER = 5; inline static constexpr int MIN_SIZE = 10; - enum pressLocation + enum class PressLocation { inside, top, @@ -48,26 +47,23 @@ class RoiItem : public QObject, public QGraphicsRectItem }; private: - Petrack *mMainWindow; - Control *mControlWidget; - QRect mPressRect; - QPointF mPressPos; - enum pressLocation mPressLocation; - bool mIsFixed; + Petrack *mMainWindow; + QRect mPressRect; + QPointF mPressPos; + PressLocation mPressLocation{PressLocation::inside}; + bool mIsFixed{false}; public: - RoiItem(QWidget *wParent, QColor color, QGraphicsItem *parent = nullptr); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - void checkRect(); - -public slots: + RoiItem(QWidget *wParent, const QColor &color); + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override; + void restoreSize(); void setFixed(bool fixed) { mIsFixed = fixed; } signals: - void changed(); // NOLINT + void changed(); }; #endif // ROIITEM_H diff --git a/src/petrack.cpp b/src/petrack.cpp index 0959c5599..fdd5a873d 100644 --- a/src/petrack.cpp +++ b/src/petrack.cpp @@ -3675,7 +3675,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n size.height = mImgFiltered.rows; mTracker->resize(size); - mTrackingRoiItem->checkRect(); + mTrackingRoiItem->restoreSize(); } #ifndef STEREO_DISABLED // buildt disparity picture if it should be used for height detection @@ -3731,7 +3731,7 @@ void Petrack::updateImage(bool imageChanged) // default = false (only true for n #endif if(borderChanged) { - mRecognitionRoiItem->checkRect(); + mRecognitionRoiItem->restoreSize(); } if(mControlWidget->performRecognition->checkState() == Qt::Checked) diff --git a/src/roiItem.cpp b/src/roiItem.cpp index 9bef483e9..49ddc6545 100644 --- a/src/roiItem.cpp +++ b/src/roiItem.cpp @@ -20,17 +20,13 @@ #include "roiItem.h" -#include "control.h" #include "petrack.h" -#include "view.h" -#include <QtWidgets> -RoiItem::RoiItem(QWidget *wParent, QColor color, QGraphicsItem *parent) : QObject(wParent), QGraphicsRectItem(parent) +RoiItem::RoiItem(QWidget *wParent, const QColor &color) : QObject(wParent) { - mMainWindow = (class Petrack *) wParent; - mControlWidget = mMainWindow->getControlWidget(); - setRect(0, 0, 0, 0); // qreal x, qreal y, qreal width, qreal height + mMainWindow = dynamic_cast<class Petrack *>(wParent); + setRect(0, 0, 0, 0); QPen pen(color); setPen(pen); setAcceptHoverEvents(true); @@ -49,17 +45,17 @@ void RoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) { - mPressLocation = topLeft; + mPressLocation = PressLocation::topLeft; setCursor(Qt::SizeFDiagCursor); } else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) { - mPressLocation = bottomLeft; + mPressLocation = PressLocation::bottomLeft; setCursor(Qt::SizeBDiagCursor); } else { - mPressLocation = left; + mPressLocation = PressLocation::left; setCursor(Qt::SizeHorCursor); } } @@ -67,33 +63,33 @@ void RoiItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) { - mPressLocation = topRight; + mPressLocation = PressLocation::topRight; setCursor(Qt::SizeBDiagCursor); } else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) { - mPressLocation = bottomRight; + mPressLocation = PressLocation::bottomRight; setCursor(Qt::SizeFDiagCursor); } else { - mPressLocation = right; + mPressLocation = PressLocation::right; setCursor(Qt::SizeHorCursor); } } else if((event->pos()).y() < DISTANCE_TO_BORDER + mPressRect.y()) { - mPressLocation = top; + mPressLocation = PressLocation::top; setCursor(Qt::SizeVerCursor); } else if((event->pos()).y() > mPressRect.height() + mPressRect.y() - DISTANCE_TO_BORDER) { - mPressLocation = bottom; + mPressLocation = PressLocation::bottom; setCursor(Qt::SizeVerCursor); } else { - mPressLocation = inside; + mPressLocation = PressLocation::inside; setCursor(Qt::ClosedHandCursor); } } @@ -113,132 +109,127 @@ void RoiItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QGraphicsRectItem::mouseReleaseEvent(event); } -// event, of moving mouse while mouse button is pressed void RoiItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + // event, of moving mouse while mouse button is pressed if(!mIsFixed) { QImage *img = mMainWindow->getImage(); QPoint diff = QPoint(myRound((event->pos() - mPressPos).x()), myRound((event->pos() - mPressPos).y())); - // raender des bildes nicht ueberscheiten - // swappen des rechtecks vermeiden, damit keine negativen width... + // do not extend over the border of the image + // do not swap the rectangle, to avoid negative width if(img != nullptr) { - if(mPressLocation == inside || mPressLocation == topLeft || mPressLocation == left || - mPressLocation == bottomLeft) + if(mPressLocation == PressLocation::inside || mPressLocation == PressLocation::topLeft || + mPressLocation == PressLocation::left || mPressLocation == PressLocation::bottomLeft) { if(mPressRect.x() + diff.x() < -mMainWindow->getImageBorderSize()) { diff.setX(-mPressRect.x() - mMainWindow->getImageBorderSize()); } - if(mPressLocation != inside && mPressRect.width() - diff.x() < MIN_SIZE) + if(mPressLocation != PressLocation::inside && mPressRect.width() - diff.x() < MIN_SIZE) { diff.setX(mPressRect.width() - MIN_SIZE); } } - if(mPressLocation == inside || mPressLocation == topLeft || mPressLocation == top || - mPressLocation == topRight) + if(mPressLocation == PressLocation::inside || mPressLocation == PressLocation::topLeft || + mPressLocation == PressLocation::top || mPressLocation == PressLocation::topRight) { if(mPressRect.y() + diff.y() < -mMainWindow->getImageBorderSize()) { diff.setY(-mPressRect.y() - mMainWindow->getImageBorderSize()); } - if(mPressLocation != inside && mPressRect.height() - diff.y() < MIN_SIZE) + if(mPressLocation != PressLocation::inside && mPressRect.height() - diff.y() < MIN_SIZE) { diff.setY(mPressRect.height() - MIN_SIZE); } } - if(mPressLocation == inside || mPressLocation == topRight || mPressLocation == right || - mPressLocation == bottomRight) + if(mPressLocation == PressLocation::inside || mPressLocation == PressLocation::topRight || + mPressLocation == PressLocation::right || mPressLocation == PressLocation::bottomRight) { if(mPressRect.x() + diff.x() + mPressRect.width() > img->width() - mMainWindow->getImageBorderSize()) { diff.setX(img->width() - mPressRect.x() - mPressRect.width() - mMainWindow->getImageBorderSize()); } - if(mPressLocation != inside && mPressRect.width() + diff.x() < MIN_SIZE) + if(mPressLocation != PressLocation::inside && mPressRect.width() + diff.x() < MIN_SIZE) { diff.setX(-mPressRect.width() + MIN_SIZE); } } - if(mPressLocation == inside || mPressLocation == bottomLeft || mPressLocation == bottom || - mPressLocation == bottomRight) + if(mPressLocation == PressLocation::inside || mPressLocation == PressLocation::bottomLeft || + mPressLocation == PressLocation::bottom || mPressLocation == PressLocation::bottomRight) { if(mPressRect.y() + diff.y() + mPressRect.height() > img->height() - mMainWindow->getImageBorderSize()) { diff.setY(img->height() - mPressRect.y() - mPressRect.height() - mMainWindow->getImageBorderSize()); } - if(mPressLocation != inside && mPressRect.height() + diff.y() < MIN_SIZE) + if(mPressLocation != PressLocation::inside && mPressRect.height() + diff.y() < MIN_SIZE) { diff.setY(-mPressRect.height() + MIN_SIZE); } } } - if(mPressLocation == topLeft) - { - setRect( - mPressRect.x() + diff.x(), - mPressRect.y() + diff.y(), - mPressRect.width() - diff.x(), - mPressRect.height() - diff.y()); - } - else if(mPressLocation == topRight) - { - setRect( - mPressRect.x(), - mPressRect.y() + diff.y(), - mPressRect.width() + diff.x(), - mPressRect.height() - diff.y()); - } - else if(mPressLocation == bottomLeft) - { - setRect( - mPressRect.x() + diff.x(), - mPressRect.y(), - mPressRect.width() - diff.x(), - mPressRect.height() + diff.y()); - } - else if(mPressLocation == bottomRight) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height() + diff.y()); - } - else if(mPressLocation == left) - { - setRect(mPressRect.x() + diff.x(), mPressRect.y(), mPressRect.width() - diff.x(), mPressRect.height()); - } - else if(mPressLocation == right) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height()); - } - else if(mPressLocation == top) - { - setRect(mPressRect.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height() - diff.y()); - } - else if(mPressLocation == bottom) - { - setRect(mPressRect.x(), mPressRect.y(), mPressRect.width(), mPressRect.height() + diff.y()); - } - else // entspricht: if (mPressLocation == inside) + + switch(mPressLocation) { - setRect(mPressRect.x() + diff.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height()); + case PressLocation::topLeft: + setRect( + mPressRect.x() + diff.x(), + mPressRect.y() + diff.y(), + mPressRect.width() - diff.x(), + mPressRect.height() - diff.y()); + break; + case PressLocation::topRight: + setRect( + mPressRect.x(), + mPressRect.y() + diff.y(), + mPressRect.width() + diff.x(), + mPressRect.height() - diff.y()); + break; + case PressLocation::bottomLeft: + setRect( + mPressRect.x() + diff.x(), + mPressRect.y(), + mPressRect.width() - diff.x(), + mPressRect.height() + diff.y()); + break; + case PressLocation::bottomRight: + setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height() + diff.y()); + break; + case PressLocation::left: + setRect(mPressRect.x() + diff.x(), mPressRect.y(), mPressRect.width() - diff.x(), mPressRect.height()); + break; + case PressLocation::right: + setRect(mPressRect.x(), mPressRect.y(), mPressRect.width() + diff.x(), mPressRect.height()); + break; + case PressLocation::top: + setRect(mPressRect.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height() - diff.y()); + break; + case PressLocation::bottom: + setRect(mPressRect.x(), mPressRect.y(), mPressRect.width(), mPressRect.height() + diff.y()); + break; + case PressLocation::inside: + setRect(mPressRect.x() + diff.x(), mPressRect.y() + diff.y(), mPressRect.width(), mPressRect.height()); + break; + // do not use QGraphicsRectItem::mouseMoveEvent(event) as it also moves the coordinate system } - // nicht, da sonst koordinatensystem verschoben wird: QGraphicsRectItem::mouseMoveEvent(event); // drag } - else // drag mach ich selber + else { QGraphicsRectItem::mouseMoveEvent(event); } } -// event, of moving mouse void RoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { QPointF pos = event->scenePos(); pos.setX(pos.x() + mMainWindow->getImageBorderSize()); pos.setY(pos.y() + mMainWindow->getImageBorderSize()); - // abfrage auf width() ..., da durch rectLinie die recoBox etwas groesser ist als das Bild und - // es bei mMainWindow->setMousePosOnImage(pos); zum fehler beim bildzugriff kommen kann!!! - if(mMainWindow->getImage() && //(pos.x() > 0) && (pos.y() > 0) && - (pos.x() < mMainWindow->getImage()->width()) && (pos.y() < mMainWindow->getImage()->height())) + + // due to the line width of the QRect, the QRect might get slightly larger than the image. To avoid errors then + // accessing the image mMainWindow->setMousePosOnImage(pos) also width() is checked here + if((mMainWindow->getImage() != nullptr) && (pos.x() < mMainWindow->getImage()->width()) && + (pos.y() < mMainWindow->getImage()->height())) { mMainWindow->setMousePosOnImage(pos); @@ -287,10 +278,10 @@ void RoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) setCursor(Qt::OpenHandCursor); } } - else // wird nur einmal durchaufen - ruecksetzen in control.cpp + else // will only be executed once - reset in control.cpp { - setAcceptHoverEvents(false); // verhoindert nicht, dass wenn objekt darunter liegt, was andereen cursor - // haette - cursor wird weiterhin beim drueberfahren auf cross gesetzt + // if an object underneath would have a different cursor, the cursor will still be set to cross + setAcceptHoverEvents(false); setCursor(Qt::CrossCursor); } } @@ -298,8 +289,10 @@ void RoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) QGraphicsRectItem::hoverMoveEvent(event); } -// check rect because bordersize changes and without mouse event nothing changes the rect -void RoiItem::checkRect() +/** + * @brief Restores the size of the ROI if the image sized changed + */ +void RoiItem::restoreSize() { cv::Mat img = mMainWindow->getImageFiltered(); -- GitLab From dbd53abb2eb3451157ee2f568202587789fea186 Mon Sep 17 00:00:00 2001 From: schroedtert <t.schroedter@fz-juelich.de> Date: Mon, 7 Mar 2022 16:21:48 +0100 Subject: [PATCH 3/5] Fix indentation of CMakeLists Signed-off-by: schroedtert <t.schroedter@fz-juelich.de> --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe245a84a..96dae5129 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,7 +363,7 @@ target_sources(petrack_core PRIVATE include/qtColorTriangle.h include/swapFilter.h include/extrCalibration.h - include/roiItem.h + include/roiItem.h include/analysePlot.h include/IO.h include/skeletonTree.h @@ -423,7 +423,7 @@ target_sources(petrack_core PRIVATE src/qtColorTriangle.cpp src/swapFilter.cpp src/extrCalibration.cpp - src/roiItem.cpp + src/roiItem.cpp src/IO.cpp src/skeletonTree.cpp src/skeletonTreeFactory.cpp -- GitLab From f6f253e8dcb424d5b8eaba21e2309f789c56a3ad Mon Sep 17 00:00:00 2001 From: schroedtert <t.schroedter@fz-juelich.de> Date: Mon, 7 Mar 2022 16:22:23 +0100 Subject: [PATCH 4/5] Fix typo Signed-off-by: schroedtert <t.schroedter@fz-juelich.de> --- src/roiItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/roiItem.cpp b/src/roiItem.cpp index 49ddc6545..362db0dbe 100644 --- a/src/roiItem.cpp +++ b/src/roiItem.cpp @@ -290,7 +290,7 @@ void RoiItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } /** - * @brief Restores the size of the ROI if the image sized changed + * @brief Restores the size of the ROI if the image size changed */ void RoiItem::restoreSize() { -- GitLab From 5d2e22b5023db23373c70f7f16a6ffe62f1d62e3 Mon Sep 17 00:00:00 2001 From: schroedtert <t.schroedter@fz-juelich.de> Date: Mon, 7 Mar 2022 16:32:31 +0100 Subject: [PATCH 5/5] Move connection to control as it belongs there. Signed-off-by: schroedtert <t.schroedter@fz-juelich.de> --- include/control.h | 7 ++++++- src/control.cpp | 11 ++++++++++- src/petrack.cpp | 22 +++++++++------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/control.h b/include/control.h index f7623b9d6..781960607 100644 --- a/include/control.h +++ b/include/control.h @@ -36,7 +36,12 @@ class Control : public QWidget, public Ui::Control Q_OBJECT public: - Control(QWidget &parent, QGraphicsScene &scene, reco::Recognizer &recognizer); + Control( + QWidget &parent, + QGraphicsScene &scene, + reco::Recognizer &recognizer, + RoiItem &trackRoiItem, + RoiItem &recoRoiItem); void setScene(QGraphicsScene *sc); diff --git a/src/control.cpp b/src/control.cpp index 786632c2a..a7abaa840 100644 --- a/src/control.cpp +++ b/src/control.cpp @@ -45,7 +45,13 @@ #define DEFAULT_HEIGHT 180.0 -Control::Control(QWidget &parent, QGraphicsScene &scene, reco::Recognizer &recognizer) : QWidget(&parent) +Control::Control( + QWidget &parent, + QGraphicsScene &scene, + reco::Recognizer &recognizer, + RoiItem &trackRoiItem, + RoiItem &recoRoiItem) : + QWidget(&parent) { setAccessibleName("Control"); mMainWindow = (class Petrack *) &parent; @@ -214,6 +220,9 @@ Control::Control(QWidget &parent, QGraphicsScene &scene, reco::Recognizer &recog scrollAreaWidgetContents_4->sizeHint().width() + 2 * scrollArea_4->frameWidth() + scrollArea_4->verticalScrollBar()->sizeHint().width() + scrollAreaWidgetContents_4->layout()->margin() * 2 + scrollAreaWidgetContents_4->layout()->spacing() * 2); + + connect(trackRoiFix, &QCheckBox::stateChanged, &trackRoiItem, &RoiItem::setFixed); + connect(roiFix, &QCheckBox::stateChanged, &recoRoiItem, &RoiItem::setFixed); } void Control::setScene(QGraphicsScene *sc) diff --git a/src/petrack.cpp b/src/petrack.cpp index fdd5a873d..ab7c718a2 100644 --- a/src/petrack.cpp +++ b/src/petrack.cpp @@ -112,7 +112,15 @@ Petrack::Petrack() : mScene = new QGraphicsScene(this); - mControlWidget = new Control(*this, *mScene, mReco); + mTrackingRoiItem = new RoiItem(this, Qt::blue); + connect(mTrackingRoiItem, &RoiItem::changed, this, [=]() { this->setTrackChanged(true); }); + mTrackingRoiItem->setZValue(4); // groesser heisst weiter oben + + mRecognitionRoiItem = new RoiItem(this, Qt::green); + connect(mRecognitionRoiItem, &RoiItem::changed, this, [=]() { this->setRecognitionChanged(true); }); + mRecognitionRoiItem->setZValue(5); // groesser heisst weiter oben + + mControlWidget = new Control(*this, *mScene, mReco, *mTrackingRoiItem, *mRecognitionRoiItem); cw = mControlWidget; // muss spaeter geloescht werden mStereoWidget = new StereoWidget(this); @@ -153,18 +161,6 @@ Petrack::Petrack() : mCoordItem->setZValue(3); // groesser heisst weiter oben mImageItem->setCoordItem(mCoordItem); - mTrackingRoiItem = new RoiItem(this, Qt::blue); - connect(mControlWidget->trackRoiFix, &QCheckBox::stateChanged, mTrackingRoiItem, &RoiItem::setFixed); - connect(mTrackingRoiItem, &RoiItem::changed, this, [=]() { this->setTrackChanged(true); }); - mTrackingRoiItem->setZValue(4); // groesser heisst weiter oben - - mRecognitionRoiItem = new RoiItem(this, Qt::green); - connect(mControlWidget->roiFix, &QCheckBox::stateChanged, mRecognitionRoiItem, &RoiItem::setFixed); - connect(mRecognitionRoiItem, &RoiItem::changed, this, [=]() { this->setRecognitionChanged(true); }); - - mRecognitionRoiItem->setZValue(5); // groesser heisst weiter oben - - mViewWidget = new ViewWidget(this); mView = mViewWidget->view(); mView->setScene(mScene); -- GitLab