Warning, file /graphics/tikzkit/src/ui/paths/EllipsePathItem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 2013-2014 Dominik Haumann <dhaumann@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Library General Public License as published
0007  * by the Free Software Foundation, either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, see
0017  * <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef TIKZ_UI_ELLIPSE_PATH_ITEM_H
0021 #define TIKZ_UI_ELLIPSE_PATH_ITEM_H
0022 
0023 #include <PathItem.h>
0024 
0025 #include <QPointer>
0026 
0027 class QPainter;
0028 
0029 namespace tikz {
0030 namespace core {
0031     class EllipsePath;
0032     class Node;
0033 }
0034 
0035 namespace ui {
0036 
0037 class DocumentPrivate;
0038 class NodeItem;
0039 class TikzEllipsePathPrivate;
0040 
0041 class EllipsePathItem : public tikz::ui::PathItem
0042 {
0043     Q_OBJECT
0044 
0045     public:
0046         /**
0047          * Constructor with assigned @p path.
0048          */
0049         EllipsePathItem(tikz::core::Path * path);
0050 
0051         /**
0052          * Destructor
0053          */
0054         virtual ~EllipsePathItem();
0055 
0056         /**
0057          * Returns the associated document, if available.
0058          */
0059         DocumentPrivate * document() const;
0060 
0061         /**
0062          * Returns the tikz::core::Path object, casted to tikz::core::EllipsePath
0063          */
0064         tikz::core::EllipsePath * ellipsePath() const;
0065 
0066         /**
0067          * Set the node to @p node.
0068          * @param node node of the ellipse. 0 is allowed.
0069          */
0070         void setNode(NodeItem* node);
0071 
0072         /**
0073          * Get the node where the ellipse is anchored at.
0074          * @return the end node or 0, if the end of the edge is not connected.
0075          */
0076         NodeItem* node() const;
0077 
0078         /**
0079          * Get the position of the start of the edge.
0080          * @return the position in item coordinates
0081          */
0082         QPointF pos() const;
0083 
0084     //
0085     // anchor methods
0086     //
0087     public:
0088         /**
0089          * Get the anchor of the ellipse.
0090          */
0091         QString anchor() const;
0092 
0093     public Q_SLOTS:
0094         /**
0095          * Set the anchor of the ellipse to @p anchor.
0096          */
0097         void setAnchor(const QString & anchor);
0098 
0099     //
0100     // reimplemented from QGraphicsItem
0101     //
0102     public:
0103         /**
0104          * Paint this item.
0105          */
0106         void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
0107 
0108         /**
0109          * Returns the bounding rect of this item.
0110          */
0111         QRectF boundingRect() const override;
0112 
0113         /**
0114          * Returns an exact shape as painter path
0115          */
0116         QPainterPath shape() const override;
0117 
0118         /**
0119          * Returns @p true, if @p point is contained in the edge.
0120          */
0121         bool contains(const QPointF & point) const override;
0122 
0123     private Q_SLOTS:
0124         void slotUpdate();
0125 
0126         /**
0127          * This function is called whenever the tikz::core::EllipsePath::setNode()
0128          * changes. This is required, since otherwise the model is updated,
0129          * without the PathItem being notified.
0130          */
0131         void updateNode(tikz::core::Node * node);
0132 
0133     private Q_SLOTS:
0134         /**
0135          * Updates the cache of the ellipse.
0136          */
0137         void updateCache();
0138 
0139     private:
0140         // the NodeItem this ellipse possibly is anchored at
0141         QPointer<NodeItem> m_node;
0142 
0143         //
0144         // cached paths
0145         //
0146         bool m_dirty;
0147 
0148         // the ellipse path
0149         QPainterPath m_ellipse;
0150 
0151         // a stroked path, used to hover the contour on mouse over
0152         QPainterPath m_hoverPath;
0153 
0154         // the shape, including all possible spacings
0155         QPainterPath m_shapePath;
0156 
0157         // the bounding rect around m_hoverPath
0158         QRectF m_boundingRect;
0159 };
0160 
0161 }
0162 }
0163 
0164 #endif // TIKZ_UI_ELLIPSE_PATH_ITEM_H
0165 
0166 // kate: indent-width 4; replace-tabs on;