File indexing completed on 2024-05-19 04:36:37

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 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_DIAMOND_SHAPE_H
0021 #define TIKZ_UI_DIAMOND_SHAPE_H
0022 
0023 #include "AbstractShape.h"
0024 
0025 namespace tikz {
0026 namespace ui {
0027 
0028 class DiamondShapePrivate;
0029 
0030 class DiamondShape : public AbstractShape
0031 {
0032     public:
0033         /**
0034          * Default constructor
0035          */
0036         DiamondShape(NodeItem * node);
0037 
0038         /**
0039          * Default constructor
0040          */
0041         virtual ~DiamondShape();
0042 
0043     //
0044     // Shape properties
0045     //
0046     public:
0047         /**
0048          * Returns the type of this shape.
0049          */
0050         tikz::Shape type() const override;
0051 
0052         /**
0053          * Reimplemented such that the ellipse inside @p shapeRect completely
0054          * includes the @p textRect.
0055          */
0056         void adjustShapeRect(const QRectF & textRect, QRectF & shapeRect) const override;
0057 
0058         /**
0059          * Returns the painter path of this shape.
0060          * This path is also used to draw the shape.
0061          */
0062         QPainterPath shape() const override;
0063 
0064         /**
0065          * Returns the outline of this shape, i.e. the shape() extended
0066          * by the pen's width.
0067          */
0068         QPainterPath outline() const override;
0069 
0070         /**
0071          * Returns a list of anchors the shape supports.
0072          */
0073         QStringList supportedAnchors() const override;
0074 
0075         /**
0076          * Returns the position of @p anchor in local node coordinates.
0077          */
0078         QPointF anchorPos(const QString & anchor) const override;
0079 
0080         /**
0081          * Returns the contact point for @p anchor and angle @p rad.
0082          */
0083         QPointF contactPoint(const QString & anchor, qreal rad) const override;
0084 
0085     private:
0086         /**
0087          * Outline as QRectF.
0088          */
0089         QRectF outlineRect() const;
0090 
0091     private:
0092         DiamondShapePrivate * const d;
0093 };
0094 
0095 }
0096 }
0097 
0098 #endif // TIKZ_UI_DIAMOND_SHAPE_H
0099 
0100 // kate: indent-width 4; replace-tabs on;