File indexing completed on 2024-05-19 04:36:37
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2013 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 #include "AbstractShape.h" 0021 #include "RectShape.h" 0022 #include "CircleShape.h" 0023 #include "DiamondShape.h" 0024 #include "EllipseShape.h" 0025 0026 #include <cmath> 0027 0028 namespace tikz { 0029 namespace ui { 0030 0031 class AbstractShapePrivate 0032 { 0033 public: 0034 NodeItem* node; 0035 }; 0036 0037 AbstractShape::AbstractShape(NodeItem * node) 0038 : d(new AbstractShapePrivate()) 0039 { 0040 d->node = node; 0041 } 0042 0043 AbstractShape::~AbstractShape() 0044 { 0045 delete d; 0046 } 0047 0048 NodeItem* AbstractShape::node() const 0049 { 0050 return d->node; 0051 } 0052 0053 tikz::Shape AbstractShape::type() const 0054 { 0055 return tikz::Shape::NoShape; 0056 } 0057 0058 void AbstractShape::adjustShapeRect(const QRectF & textRect, QRectF & shapeRect) const 0059 { 0060 Q_UNUSED(textRect); 0061 Q_UNUSED(shapeRect); 0062 } 0063 0064 QPainterPath AbstractShape::shape() const 0065 { 0066 return QPainterPath(); 0067 } 0068 0069 QPainterPath AbstractShape::outline() const 0070 { 0071 return shape(); 0072 } 0073 0074 QStringList AbstractShape::supportedAnchors() const 0075 { 0076 // there are no anchors by default 0077 return QStringList(); 0078 } 0079 0080 QPointF AbstractShape::anchorPos(const QString & anchor) const 0081 { 0082 return QPointF(0, 0); 0083 } 0084 0085 QPointF AbstractShape::contactPoint(const QString & anchor, qreal rad) const 0086 { 0087 return QPointF(0, 0); 0088 } 0089 0090 0091 AbstractShape *createShape(tikz::Shape shape, NodeItem* node) 0092 { 0093 switch (shape) { 0094 case tikz::Shape::NoShape: return new AbstractShape(node); 0095 case tikz::Shape::ShapeRectangle: return new RectShape(node); 0096 case tikz::Shape::ShapeCircle: return new CircleShape(node); 0097 case tikz::Shape::ShapeDiamond: return new DiamondShape(node); 0098 case tikz::Shape::ShapeEllipse: return new EllipseShape(node); 0099 default: break; 0100 } 0101 return new AbstractShape(node); 0102 } 0103 0104 } 0105 } 0106 0107 // kate: indent-width 4; replace-tabs on;