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

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_ABSTRACT_ARROW_H
0021 #define TIKZ_UI_ABSTRACT_ARROW_H
0022 
0023 #include <QPointF>
0024 #include <QPainterPath>
0025 
0026 #include <tikz/core/tikz.h>
0027 
0028 class QPainter;
0029 
0030 namespace tikz {
0031 namespace core {
0032     class Style;
0033 }
0034 }
0035 
0036 class AbstractArrowPrivate;
0037 
0038 class AbstractArrow
0039 {
0040     public:
0041         /**
0042          * Constructor with @p edge.
0043          */
0044         AbstractArrow(tikz::core::Style* style);
0045 
0046         /**
0047          * Destructor.
0048          */
0049         virtual ~AbstractArrow();
0050 
0051         /**
0052          * Returns the pointer to the style passed in the constructor.
0053          */
0054         tikz::core::Style* style() const;
0055 
0056     //
0057     // Arrow properties
0058     //
0059     public:
0060         /**
0061          * Returns the type of this arrow.
0062          */
0063         virtual tikz::Arrow type() const;
0064 
0065         /**
0066          * Gui visible name, such as "to" or "stealth".
0067          * The string should be translated.
0068          */
0069         virtual QString name() const;
0070 
0071         /**
0072          * The 'left extend' value defines the extent of the arrow to the left,
0073          * beginning at the arrow tip. This value is only only important when
0074          * when an arrow is being reversed or composed with other arrow tips.
0075          * @note: Currently, this value is not used by qtikzgui.
0076          */
0077         virtual qreal leftExtend() const;
0078 
0079         /**
0080          * The line is shortened by the amount of 'right extend' on the right.
0081          * This is often equal to half of the line width.
0082          */
0083         virtual qreal rightExtend() const;
0084 
0085         /**
0086          * Draw the arrow.
0087          */
0088         virtual void draw(QPainter* painter) const;
0089 
0090         /**
0091          * Returns the painter path of this arrow.
0092          */
0093         virtual QPainterPath path() const;
0094 
0095         /**
0096          * Returns the contour painter path of this arrow by drawing the
0097          * arrow's path with a pen of width @p width.
0098          */
0099         virtual QPainterPath contour(qreal width) const;
0100 
0101     private:
0102         AbstractArrowPrivate * const d;
0103 };
0104 
0105 /**
0106  * Factory function to get arrow instances for arrow type @p type.
0107  */
0108 extern AbstractArrow *createArrow(tikz::Arrow type, tikz::core::Style* style);
0109 
0110 #endif // TIKZ_UI_ABSTRACT_ARROW_H
0111 
0112 // kate: indent-width 4; replace-tabs on;