15 #ifndef BORNAGAIN_GUI2_SLDEDITOR_ELEMENTVIEW_H
16 #define BORNAGAIN_GUI2_SLDEDITOR_ELEMENTVIEW_H
18 #include "darefl_export.h"
21 #include <QGraphicsObject>
26 class DAREFLCORE_EXPORT
ElementView :
public QGraphicsObject {
33 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
override;
34 void advance(
int phase)
override;
38 void setCenterBased(
bool choice);
39 void adaptX(
bool choice);
40 void adaptY(
bool choice);
41 void adaptW(
bool choice);
42 void adaptH(
bool choice);
43 void stretchLeft(
bool choice);
44 void stretchRight(
bool choice);
47 QRectF displayRect(
const QRectF& real_rect)
const;
48 QPainterPath displayPath(QPainterPath real_path)
const;
49 QPointF scenePos(QPointF pixel_pos)
const;
51 void hoverEnterEvent(QGraphicsSceneHoverEvent* event)
override;
52 void hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
override;
53 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override;
54 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override;
57 QRectF displayRectCenterBased(
const QRectF& real_rect)
const;
58 QRectF displayRectEdgeBased(
const QRectF& real_rect)
const;
59 QRectF stretchRectLeft(
const QRectF& real_rect)
const;
60 QRectF stretchRectRight(
const QRectF& real_rect)
const;
63 bool m_center_based =
true;
64 bool m_adapt_x =
true;
65 bool m_adapt_y =
true;
66 bool m_adapt_width =
true;
67 bool m_adapt_height =
true;
68 bool m_stretch_left =
false;
69 bool m_stretch_right =
false;
Interface to convert coordinates of "scene" to coordinates of "widget".
The interface of any QGraphicsViewItem on GraphicsScene to the Sceneadapter.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.