File indexing completed on 2024-05-12 04:35:04
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_PATH_H 0021 #define TIKZ_PATH_H 0022 0023 #include <QObject> 0024 0025 #include "Entity.h" 0026 #include "tikz.h" 0027 0028 namespace tikz { 0029 namespace core { 0030 0031 class Document; 0032 class Node; 0033 class Style; 0034 class Visitor; 0035 class PathPrivate; 0036 0037 class TIKZKITCORE_EXPORT Path : public Entity 0038 { 0039 Q_OBJECT 0040 Q_PROPERTY(Uid style READ styleUid WRITE setStyle) 0041 0042 // 0043 // Path type 0044 // 0045 public: 0046 0047 /** 0048 * Returns the element type of this edge. 0049 */ 0050 virtual PathType type() const; 0051 0052 public: 0053 /** 0054 * Virtual destructor. 0055 */ 0056 virtual ~Path(); 0057 0058 /** 0059 * Returns EntityType::Edge. 0060 */ 0061 tikz::EntityType entityType() const override; 0062 0063 // 0064 // visitor pattern 0065 // 0066 public: 0067 /** 0068 * Visitor pattern. 0069 * Visits all elements of the document. 0070 */ 0071 bool accept(Visitor & visitor); 0072 0073 // 0074 // serialization 0075 // 0076 public: 0077 /** 0078 * Load the state from the @p json object. 0079 */ 0080 void loadData(const QJsonObject & json) override; 0081 0082 /** 0083 * Save the state to the json object. 0084 */ 0085 QJsonObject saveData() const override; 0086 0087 // 0088 // path properties 0089 // 0090 public: 0091 /** 0092 * Get the Style object of this path. 0093 * The returned style is always a valid pointer. 0094 */ 0095 Style * style() const; 0096 0097 /** 0098 * Get the Style object of this node. 0099 * The returned style is always a valid pointer. 0100 */ 0101 Uid styleUid() const; 0102 0103 /** 0104 * Set the internal style of this path to @p uid. 0105 */ 0106 void setStyle(const Uid & styleUid); 0107 0108 // 0109 // internal to tikz::Document 0110 // 0111 protected: 0112 friend class Document; 0113 0114 /** 0115 * Constructor that associates this path with the tikz Document 0116 * referred to by @p uid. 0117 * @param uid unique id of the path 0118 */ 0119 Path(const Uid & uid); 0120 0121 /** 0122 * This function is called by Document::deletePath() right before the 0123 * Path is deleted. Invoking the undo action will construct the path 0124 * again. Therefore, this function needs to add all undo items so that 0125 * the respective call of undo() will add properties of the Path again. 0126 * 0127 * @note: the Style of this path is taken care of. No need to put 0128 * this into the undo stack again. 0129 * 0130 * The default implementation is empty. 0131 */ 0132 virtual void deconstruct(); 0133 0134 /** 0135 * This function is called for all paths to notify that @p node is 0136 * about to be deleted. If a path is attached to this node, 0137 * detach it here such that the path is still consistent. 0138 * 0139 * The default implementation is empty. 0140 * 0141 * @p node Node that is about to be deleted 0142 */ 0143 virtual void detachFromNode(Node * node); 0144 0145 // 0146 // internal 0147 // 0148 private: 0149 /** 0150 * Private default constructor, not implemented 0151 */ 0152 Path(); 0153 private: 0154 PathPrivate * const d; 0155 }; 0156 0157 } 0158 } 0159 0160 #endif // TIKZ_PATH_H 0161 0162 // kate: indent-width 4; replace-tabs on;