1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Overlay/IRectangularOverlay.h
//! @brief Defines class IRectangularOverlay.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEW_OVERLAY_IRECTANGULAROVERLAY_H
#define BORNAGAIN_GUI_VIEW_OVERLAY_IRECTANGULAROVERLAY_H
#include "GUI/View/Overlay/IMaskOverlay.h"
#include "GUI/View/Overlay/SizeHandle.h"
#include <array>
#include <memory>
//! Base view for all rectangular-like masks.
class IRectangularOverlay : public IMaskOverlay {
Q_OBJECT
public:
explicit IRectangularOverlay(ColorMap* plot);
public slots:
virtual void resizeX(double xl, double yl) = 0;
virtual void resizeY(double yl, double yh) = 0;
protected:
void update_view() override;
virtual void updatePosition() = 0;
virtual QRectF maskRectangle() = 0;
//... Item properties to scene coordinates
virtual qreal width() const = 0;
virtual qreal height() const = 0;
QRectF m_mask_rect; //!< mask rectangle in scene coordinates
//!< coordinates of corner opposite to the grip corner at the moment it first clicked
//!< in scene coordinates
SizeHandle* m_active_handle;
virtual bool is_true_mask() const { return true; } // overridden in ROIOverlay
private slots:
void setToBeResized(bool on);
private:
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
void update_bounding_rect();
void enactResize(int i, QPointF pos);
std::array<std::unique_ptr<SizeHandle>, 8> m_resize_handles;
};
#endif // BORNAGAIN_GUI_VIEW_OVERLAY_IRECTANGULAROVERLAY_H
|