File indexing completed on 2025-02-23 04:08:59

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
0003    SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net>
0004    SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0005 
0006    SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KOGUIDESDATA_H
0010 #define KOGUIDESDATA_H
0011 
0012 #include "kritaui_export.h"
0013 #include <QScopedPointer>
0014 #include <QList>
0015 #include <boost/operators.hpp>
0016 #include <KoUnit.h>
0017 
0018 class QDomElement;
0019 class QDomDocument;
0020 class QColor;
0021 class QPen;
0022 
0023 
0024 class KRITAUI_EXPORT KisGuidesConfig : boost::equality_comparable<KisGuidesConfig>
0025 {
0026 public:
0027     enum LineTypeInternal {
0028         LINE_SOLID = 0,
0029         LINE_DASHED,
0030         LINE_DOTTED
0031     };
0032 
0033 public:
0034     KisGuidesConfig();
0035     ~KisGuidesConfig();
0036 
0037     KisGuidesConfig(const KisGuidesConfig &rhs);
0038     KisGuidesConfig& operator=(const KisGuidesConfig &rhs);
0039     bool operator==(const KisGuidesConfig &rhs) const;
0040     bool hasSamePositionAs(const KisGuidesConfig &rhs) const;
0041 
0042     /**
0043      * @brief Set the positions of the horizontal guide lines
0044      *
0045      * @param lines a list of positions of the horizontal guide lines
0046      */
0047     void setHorizontalGuideLines(const QList<qreal> &lines);
0048 
0049     /**
0050      * @brief Set the positions of the vertical guide lines
0051      *
0052      * @param lines a list of positions of the vertical guide lines
0053      */
0054     void setVerticalGuideLines(const QList<qreal> &lines);
0055 
0056     /**
0057      * @brief Add a guide line to the canvas.
0058      *
0059      * @param orientation the orientation of the guide line
0060      * @param position the position in document coordinates of the guide line
0061      */
0062     void addGuideLine(Qt::Orientation orientation, qreal position);
0063 
0064     bool showGuides() const;
0065     void setShowGuides(bool value);
0066     bool lockGuides() const;
0067     void setLockGuides(bool value);
0068     bool snapToGuides() const;
0069     void setSnapToGuides(bool value);
0070 
0071     bool rulersMultiple2() const;
0072     void setRulersMultiple2(bool value);
0073 
0074     KoUnit::Type unitType() const;
0075     void setUnitType(KoUnit::Type type);
0076 
0077     LineTypeInternal guidesLineType() const;
0078     void setGuidesLineType(LineTypeInternal value);
0079 
0080     QColor guidesColor() const;
0081     void setGuidesColor(const QColor &value);
0082 
0083     QPen guidesPen() const;
0084 
0085     /// Returns the list of horizontal guide lines.
0086     const QList<qreal>& horizontalGuideLines() const;
0087 
0088     /// Returns the list of vertical guide lines.
0089     const QList<qreal>& verticalGuideLines() const;
0090 
0091     bool hasGuides() const;
0092 
0093     void loadStaticData();
0094     void saveStaticData() const;
0095 
0096     QDomElement saveToXml(QDomDocument& doc, const QString &tag) const;
0097     bool loadFromXml(const QDomElement &parent);
0098 
0099     bool isDefault() const;
0100 
0101     /// Transform the guides using the given \p transform. Please note that \p transform
0102     /// should be in 'document' coordinate system.
0103     /// Used with image-wide transformations.
0104     void transform(const QTransform &transform);
0105 
0106 private:
0107     class Private;
0108     const QScopedPointer<Private> d;
0109 };
0110 
0111 
0112 #endif
0113