1 // Copyright (C) 2012-2019 The VPaint Developers. 2 // See the COPYRIGHT file at the top-level directory of this distribution 3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 #ifndef VAC_VERTEX_OBJECT_H 18 #define VAC_VERTEX_OBJECT_H 19 20 #include "Eigen.h" 21 #include "Cell.h" 22 #include "Halfedge.h" 23 #include <QPair> 24 25 namespace VectorAnimationComplex 26 { 27 28 class VertexCell: virtual public Cell 29 { 30 public: 31 VertexCell(VAC * vac); 32 33 // Casting toVertexCell()34 VertexCell * toVertexCell() { return this; } 35 36 // Geometry 37 virtual Eigen::Vector2d pos(Time time) const=0; 38 double size(Time time) const; // Note: computed from incident edges 39 40 // Drawing 41 //void draw(Time time, ViewSettings & viewSettings); 42 void drawRaw(Time time, ViewSettings & viewSettings); 43 void drawRawTopology(Time time, ViewSettings & viewSettings); 44 45 // Topology 46 CellSet spatialBoundary() const; 47 CellSet spatialBoundary(Time t) const; 48 QList<Halfedge> incidentEdges(Time t) const; 49 50 51 protected: 52 virtual ~VertexCell()=0; 53 54 private: 55 56 // Trusting operators 57 friend class Operator; 58 bool checkVertex_() const; 59 60 void drawPickCustom(Time time, ViewSettings & viewSettings); 61 bool isPickableCustom(Time time) const; 62 63 // Implementation of triangulate for both KeyVertex and InbetweenVertex 64 void triangulate_(Time time, Triangles & out) const; 65 66 // Implementation of outline bounding box for both KeyVertex and InbetweenVertex 67 void computeOutlineBoundingBox_(Time t, BoundingBox & out) const; 68 69 // --------- Cloning, Assigning, Copying, Serializing ---------- 70 71 protected: 72 virtual void save_(QTextStream & out); 73 VertexCell(VertexCell * other); 74 VertexCell(VAC * vac, QTextStream & in); stringType()75 virtual QString stringType() const {return "VertexCell";} 76 virtual void read2ndPass(); 77 virtual void remapPointers(VAC * newVAC); 78 VertexCell(VAC * vac, XmlStreamReader & xml); 79 virtual void write_(XmlStreamWriter & xml) const; 80 }; 81 82 } 83 84 85 #endif 86 87