1 // -*- C++ -*- 2 // -------------------------------------------------------------------- 3 // The reference object 4 // -------------------------------------------------------------------- 5 /* 6 7 This file is part of the extensible drawing editor Ipe. 8 Copyright (c) 1993-2020 Otfried Cheong 9 10 Ipe is free software; you can redistribute it and/or modify it 11 under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3 of the License, or 13 (at your option) any later version. 14 15 As a special exception, you have permission to link Ipe with the 16 CGAL library and distribute executables, as long as you follow the 17 requirements of the Gnu General Public License in regard to all of 18 the software in the executable aside from CGAL. 19 20 Ipe is distributed in the hope that it will be useful, but WITHOUT 21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 23 License for more details. 24 25 You should have received a copy of the GNU General Public License 26 along with Ipe; if not, you can find it at 27 "http://www.gnu.org/copyleft/gpl.html", or write to the Free 28 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 30 */ 31 32 #ifndef IPEREF_H 33 #define IPEREF_H 34 35 #include "ipeobject.h" 36 37 // -------------------------------------------------------------------- 38 39 namespace ipe { 40 41 class Cascade; 42 43 class Reference : public Object { 44 public: 45 enum { EHasStroke = 0x001, EHasFill = 0x002, 46 EHasPen = 0x004, EHasSize = 0x008, 47 EIsMark = 0x010, EIsArrow = 0x020 }; 48 49 explicit Reference(const AllAttributes &attr, Attribute name, Vector pos); 50 51 explicit Reference(const XmlAttributes &attr, String data); 52 53 virtual Object *clone() const; 54 55 virtual Reference *asReference(); 56 57 virtual Type type() const; 58 59 virtual void accept(Visitor &visitor) const; 60 61 virtual void saveAsXml(Stream &stream, String layer) const; 62 virtual void draw(Painter &painter) const; 63 virtual void drawSimple(Painter &painter) const; 64 virtual void addToBBox(Rect &box, const Matrix &m, bool cp) const; 65 virtual double distance(const Vector &v, const Matrix &m, 66 double bound) const; 67 virtual void snapVtx(const Vector &mouse, const Matrix &m, 68 Vector &pos, double &bound) const; 69 virtual void snapBnd(const Vector &mouse, const Matrix &m, 70 Vector &pos, double &bound) const; 71 72 virtual void checkStyle(const Cascade *sheet, AttributeSeq &seq) const; 73 74 void setName(Attribute name); 75 //! Return symbolic name. name()76 inline Attribute name() const { return iName; } 77 78 void setStroke(Attribute color); 79 //! Return stroke color. stroke()80 inline Attribute stroke() const { return iStroke; } 81 void setFill(Attribute color); 82 //! Return fill color. fill()83 inline Attribute fill() const { return iFill; } 84 //! Return pen. pen()85 inline Attribute pen() const { return iPen; } 86 void setPen(Attribute pen); 87 void setSize(Attribute size); 88 //! Return symbol size. size()89 inline Attribute size() const { return iSize; } 90 //! Return position of symbol on page. position()91 inline Vector position() const { return iPos; } 92 93 virtual bool setAttribute(Property prop, Attribute value); 94 virtual Attribute getAttribute(Property prop) const noexcept; 95 flags()96 inline uint32_t flags() const { return iFlags; } 97 static uint32_t flagsFromName(String name); 98 99 private: 100 Attribute iName; 101 Vector iPos; 102 Attribute iSize; 103 Attribute iStroke; 104 Attribute iFill; 105 Attribute iPen; 106 uint32_t iFlags; 107 mutable std::vector<Vector> iSnap; // caching info from the symbol itself 108 }; 109 110 } // namespace 111 112 // -------------------------------------------------------------------- 113 #endif 114