2#include <qcustomplot.h>
15 void SetPen(
const QPen &pen);
17 virtual double selectTest(
const QPointF &pos,
bool onlySelectable,
18 QVariant *details =
nullptr)
const override;
23 QCPItemAnchor *
const top;
52 virtual void draw(QCPPainter *painter)
override;
71 : QCPAbstractItem(parentPlot),
72 topLeft(createPosition(QLatin1String(
"topLeft"))),
73 bottomRight(createPosition(QLatin1String(
"bottomRight"))),
74 topLeftRim(createAnchor(QLatin1String(
"topLeftRim"), aiTopLeftRim)),
75 top(createAnchor(QLatin1String(
"top"), aiTop)),
76 topRightRim(createAnchor(QLatin1String(
"topRightRim"), aiTopRightRim)),
77 right(createAnchor(QLatin1String(
"right"), aiRight)),
79 createAnchor(QLatin1String(
"bottomRightRim"), aiBottomRightRim)),
80 bottom(createAnchor(QLatin1String(
"bottom"), aiBottom)),
82 createAnchor(QLatin1String(
"bottomLeftRim"), aiBottomLeftRim)),
83 left(createAnchor(QLatin1String(
"left"), aiLeft)),
84 center(createAnchor(QLatin1String(
"center"), aiCenter)) {
102 QVariant *details)
const {
106 Q_UNUSED(onlySelectable);
113 QPointF p1 =
topLeft->pixelPosition();
116 if (p1.toPoint() == p2.toPoint())
return;
118 QRectF arcRect = QRectF(p1, p2).normalized();
120 const int clipEnlarge = qCeil(
MainPen().widthF());
123 clipRect().adjusted(-clipEnlarge, -clipEnlarge, clipEnlarge, clipEnlarge);
125 if (arcRect.intersects(clip)) {
136 qDebug() << Q_FUNC_INFO <<
"Item too large for memory, setting invisible";
148 return rect.center() + (rect.topLeft() - rect.center()) * 1 / qSqrt(2);
150 return (rect.topLeft() + rect.topRight()) * 0.5;
152 return rect.center() + (rect.topRight() - rect.center()) * 1 / qSqrt(2);
154 return (rect.topRight() + rect.bottomRight()) * 0.5;
156 return rect.center() +
157 (rect.bottomRight() - rect.center()) * 1 / qSqrt(2);
159 return (rect.bottomLeft() + rect.bottomRight()) * 0.5;
161 return rect.center() + (rect.bottomLeft() - rect.center()) * 1 / qSqrt(2);
163 return (rect.topLeft() + rect.bottomLeft()) * 0.5;
165 return (rect.topLeft() + rect.bottomRight()) * 0.5;
168 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
197 double center_y,
double rad) {
198 topLeft->setCoords(center_x - rad, center_y + rad);
199 bottomRight->setCoords(center_x + rad, center_y - rad);
219 std::pair<double, double> start_and_end) {
Class of the arc shape.
Definition plot_item_arc.h:8
int arc_start_
Definition plot_item_arc.h:59
void SetPen(const QPen &pen)
Sets the pen that will be used to draw the line of the arc.
Definition plot_item_arc.h:98
int arc_length_
Definition plot_item_arc.h:60
virtual ~PlotItemArc() override
Definition plot_item_arc.h:91
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const override
Definition plot_item_arc.h:101
QCPItemAnchor *const bottomLeftRim
Definition plot_item_arc.h:28
void SetCenterAndRadiusCoords(double center_x, double center_y, double rad)
Sets center and radius of the arc by setting topLeft and bottomRight.
Definition plot_item_arc.h:196
virtual QPointF anchorPixelPosition(int anchorId) const override
Definition plot_item_arc.h:144
QCPItemPosition *const topLeft
Definition plot_item_arc.h:20
QCPItemAnchor *const bottom
Definition plot_item_arc.h:27
QCPItemAnchor *const bottomRightRim
Definition plot_item_arc.h:26
QCPItemAnchor *const top
Definition plot_item_arc.h:23
AnchorIndex
Definition plot_item_arc.h:37
@ aiBottomLeftRim
Definition plot_item_arc.h:44
@ aiCenter
Definition plot_item_arc.h:46
@ aiBottomRightRim
Definition plot_item_arc.h:42
@ aiTopLeftRim
Definition plot_item_arc.h:38
@ aiBottom
Definition plot_item_arc.h:43
@ aiTopRightRim
Definition plot_item_arc.h:40
@ aiRight
Definition plot_item_arc.h:41
@ aiTop
Definition plot_item_arc.h:39
@ aiLeft
Definition plot_item_arc.h:45
PlotItemArc(QCustomPlot *parentPlot)
Creates an arc item and sets default values.
Definition plot_item_arc.h:70
QPen mSelectedPen
Definition plot_item_arc.h:49
void SetStartAndEnd(double start_angle, double end_angle)
Sets start and end of current acr.
Definition plot_item_arc.h:207
QCPItemAnchor *const topLeftRim
Definition plot_item_arc.h:22
QBrush mBrush
Definition plot_item_arc.h:50
QPen MainPen() const
Returns the pen that should be used for drawing lines Returns mPen when the item is not selected and ...
Definition plot_item_arc.h:177
QPen Pen() const
Definition plot_item_arc.h:13
QCPItemAnchor *const topRightRim
Definition plot_item_arc.h:24
QCPItemAnchor *const right
Definition plot_item_arc.h:25
virtual void draw(QCPPainter *painter) override
Definition plot_item_arc.h:112
QCPItemAnchor *const left
Definition plot_item_arc.h:29
QCPItemAnchor *const center
Definition plot_item_arc.h:30
QBrush MainBrush() const
Returns the brush that should be used for drawing fills of the item Returns mBrush when the item is n...
Definition plot_item_arc.h:186
QCPItemPosition *const bottomRight
Definition plot_item_arc.h:21
QBrush mSelectedBrush
Definition plot_item_arc.h:50
QPen mPen
Definition plot_item_arc.h:49
static constexpr char arc_correction_value
Value for arc degree in qPainter.
Definition plot_item_arc.h:5