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

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 "PathItem.h"
0021 
0022 #include <tikz/core/Path.h>
0023 #include "DocumentPrivate.h"
0024 
0025 #include <QDebug>
0026 
0027 namespace tikz {
0028 namespace ui {
0029 
0030 class PathPrivate
0031 {
0032     public:
0033         // edge and nodes
0034         tikz::core::Path * path;
0035 };
0036 
0037 PathItem::PathItem(tikz::core::Path * path, QGraphicsItem * parent)
0038     : TikzItem(parent)
0039     , d(new PathPrivate())
0040 {
0041     d->path = path;
0042 
0043     // setPos needed?
0044     setPos(0, 0);
0045 
0046     setFlag(QGraphicsItem::ItemIsSelectable, true);
0047     setCacheMode(QGraphicsItem::DeviceCoordinateCache);
0048 
0049     // forward changed() signal
0050     connect(d->path, SIGNAL(changed()), this, SIGNAL(changed()));
0051 }
0052 
0053 PathItem::~PathItem()
0054 {
0055     delete d;
0056 }
0057 
0058 DocumentPrivate * PathItem::document() const
0059 {
0060     Q_ASSERT(qobject_cast<DocumentPrivate*>(d->path->document()) != nullptr);
0061     return qobject_cast<DocumentPrivate*>(d->path->document());
0062 }
0063 
0064 int PathItem::type() const
0065 {
0066     return UserType + 3;
0067 }
0068 
0069 tikz::core::Path * PathItem::path() const
0070 {
0071     return d->path;
0072 }
0073 
0074 tikz::core::Uid PathItem::uid() const
0075 {
0076     return d->path->uid();
0077 }
0078 
0079 tikz::core::Style* PathItem::style() const
0080 {
0081     return d->path->style();
0082 }
0083 
0084 }
0085 }
0086 
0087 // kate: indent-width 4; replace-tabs on;