File indexing completed on 2024-06-23 04:25:59
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net> 0003 * SPDX-FileCopyrightText: 2010 Geoffry Song <goffrie@gmail.com> 0004 * SPDX-FileCopyrightText: 2014 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> 0005 * SPDX-FileCopyrightText: 2017 Scott Petrovic <scottpetrovic@gmail.com> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef _PARALLELRULER_ASSISTANT_H_ 0011 #define _PARALLELRULER_ASSISTANT_H_ 0012 0013 #include "kis_painting_assistant.h" 0014 #include <QObject> 0015 #include <QPolygonF> 0016 #include <QLineF> 0017 #include <QTransform> 0018 /* Design: 0019 */ 0020 class ParallelRuler; 0021 0022 class ParallelRulerAssistant : public KisPaintingAssistant 0023 { 0024 public: 0025 ParallelRulerAssistant(); 0026 KisPaintingAssistantSP clone(QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap) const override; 0027 QPointF adjustPosition(const QPointF& point, const QPointF& strokeBegin, const bool snapToAny, qreal moveThresholdPt) override; 0028 void adjustLine(QPointF &point, QPointF& strokeBegin) override; 0029 QPointF getDefaultEditorPosition() const override; 0030 int numHandles() const override { return isLocal() ? 4 : 2; } 0031 bool isAssistantComplete() const override; 0032 bool canBeLocal() const override; 0033 0034 void saveCustomXml(QXmlStreamWriter* xml) override; 0035 bool loadCustomXml(QXmlStreamReader* xml) override; 0036 0037 protected: 0038 void drawAssistant(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter* converter, bool cached = true,KisCanvas2* canvas=0, bool assistantVisible=true, bool previewVisible=true) override; 0039 void drawCache(QPainter& gc, const KisCoordinatesConverter *converter, bool assistantVisible=true) override; 0040 0041 KisPaintingAssistantHandleSP firstLocalHandle() const override; 0042 KisPaintingAssistantHandleSP secondLocalHandle() const override; 0043 0044 private: 0045 QPointF project(const QPointF& pt, const QPointF& strokeBegin, qreal moveThresholdPt); 0046 explicit ParallelRulerAssistant(const ParallelRulerAssistant &rhs, QMap<KisPaintingAssistantHandleSP, KisPaintingAssistantHandleSP> &handleMap); 0047 0048 }; 0049 0050 class ParallelRulerAssistantFactory : public KisPaintingAssistantFactory 0051 { 0052 public: 0053 ParallelRulerAssistantFactory(); 0054 ~ParallelRulerAssistantFactory() override; 0055 QString id() const override; 0056 QString name() const override; 0057 KisPaintingAssistant* createPaintingAssistant() const override; 0058 }; 0059 0060 #endif