File indexing completed on 2024-05-19 04:36:34
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_ANCHOR_HANDLE_H 0021 #define TIKZ_UI_ANCHOR_HANDLE_H 0022 0023 #include "Handle.h" 0024 #include <tikz/core/MetaPos.h> 0025 0026 namespace tikz { 0027 namespace ui { 0028 0029 class NodeItem; 0030 0031 class AnchorHandle : public Handle 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 /** 0037 * Constructor. 0038 */ 0039 AnchorHandle(NodeItem * node, const QString & anchor); 0040 0041 /** 0042 * Destructor 0043 */ 0044 virtual ~AnchorHandle(); 0045 0046 /** 0047 * Reimplment to return a proper UserType + 2. 0048 */ 0049 int type() const override; 0050 0051 // 0052 // node/anchor accessors 0053 // 0054 public: 0055 /** 0056 * Get the node this anchor handle. 0057 */ 0058 NodeItem * node() const; 0059 0060 /** 0061 * Get the anchor of this anchor handle. 0062 */ 0063 QString anchor() const; 0064 0065 /** 0066 * Get the tikz::core::Node and anchor as MetaPos. 0067 */ 0068 const tikz::core::MetaPos & metaPos() const; 0069 0070 // 0071 // reimplemented from QGraphicsItem 0072 // 0073 public: 0074 /** 0075 * Paint this item. 0076 */ 0077 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; 0078 0079 /** 0080 * Reimplemented, depending on QString anchor type. 0081 */ 0082 QRectF boundingRect() const override; 0083 0084 /** 0085 * Reimplemented, depending on QString anchor type. 0086 */ 0087 bool contains(const QPointF &point) const override; 0088 0089 // 0090 // internal 0091 // 0092 private: 0093 /** 0094 * The position with anchor of the node. 0095 */ 0096 tikz::core::MetaPos m_metaPos; 0097 0098 /** 0099 * The associated NodeItem. 0100 */ 0101 NodeItem * m_node; 0102 }; 0103 0104 } 0105 } 0106 0107 #endif // TIKZ_UI_ANCHOR_HANDLE_H 0108 0109 // kate: indent-width 4; replace-tabs on;