Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsWidgets/LtsImageCropper/lts_image_cropper.h
T
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document

C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+

Build status: BUILD_RTI=OFF successful (0 errors, warnings only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-23 20:49:23 +02:00

109 lines
2.5 KiB
C++

/*
* @RDE_HEADER@
* graphicsview widget to resize qpixmaps/qimages with mouse drag and mwheel
* $Id$
* $HeadURL$
* $Author$
* Created by Jens Heilmann, SLTE, 2020-10-14
*/
#pragma once
#include "lts_widgets_export.h"
#include <QtWidgets/QGraphicsView>
namespace LtsWidgets
{
/**
* @brief The ImageCropper class provides a graphicsview widget to crop images with mouse drag and mwheel scroll.
* avatar() returns a pixmap of the current view (the cropped image).
*/
class LTSWIDGETS_EXPORT LtsImageCropper : public QGraphicsView
{
Q_OBJECT
Q_PROPERTY(QPixmap pixMap READ pixmap WRITE setPixmap)
Q_PROPERTY(double multiplier READ multiplier WRITE setMultiplier)
Q_PROPERTY(double maxZoom READ maxZoom WRITE setMaxZoom)
public:
/**
* @brief ImageCropper
* @param parent
* @param size specifies the size of the graphicsview widget, aswell as the size of the cropped image.
* @param image to crop
*/
LtsImageCropper(QWidget *parent = nullptr, const QSize &size = {} , const QPixmap &pixmap = {});
~LtsImageCropper();
/**
* @brief setter for image
* @param image
*/
void setPixmap(const QPixmap &pixmap);
/**
* @brief setter for image
* @param image
*/
void setImage(const QImage &image);
/**
* @brief set the zoom mutliplier for mwheel scaling e.g. 1.03.
* @param multiplier
*/
void setMultiplier(double multiplier);
/**
* @brief set the maximum zoom in scale e.g. 2.0 = 200% zoom in.
* @param maxZoom
*/
void setMaxZoom(double maxZoom) { m_maxScale = maxZoom; }
/**
* @brief returns the current graphicsview view as a pixmap.
* @return qpixmap
*/
QPixmap pixmap() { return grab(); }
/**
* @brief returns the current graphicsview view as qimage.
* @return qimage
*/
QImage image();
/**
* @brief returns the current multiplier
* @return double
*/
double multiplier() const { return m_multiplier; }
/**
* @brief returns the current max zoom value
* @return double
*/
double maxZoom() const { return m_maxScale; }
private:
QGraphicsScene *m_scene = nullptr;
QGraphicsPixmapItem *m_pixmapItem = nullptr;
double m_currentZoom;
double m_minScale;
double m_maxScale;
double m_stepScale;
double m_multiplier;
void calculateScaleStep();
protected:
void wheelEvent(QWheelEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
};
} // namespace LtsWidgets