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_ANIMATED_VERTEX_H
18 #define VAC_ANIMATED_VERTEX_H
19 
20 #include "Eigen.h"
21 #include "InbetweenCell.h"
22 #include "VertexCell.h"
23 #include <QList>
24 
25 namespace VectorAnimationComplex
26 {
27 
28 class InbetweenVertex: public InbetweenCell, public VertexCell
29 {
30 public:
31     // Constructor
32     InbetweenVertex(VAC * vac,
33              KeyVertex * beforeVertex,
34              KeyVertex * afterVertex);
35 
36     // Topology
37     KeyCellSet beforeCells() const;
38     KeyCellSet afterCells() const;
39     KeyVertex * beforeVertex() const;
40     KeyVertex * afterVertex() const;
41 
42     //Drawing
43     void glColor3D_();
44     void drawRaw3D(View3DSettings & viewSettings);
45 
46     // Geometry
47     Eigen::Vector2d pos(Time time) const;
48     //double size(Time time) const;
49 
50 
51 
52     // Operators
53     /*
54     void addEdgeNeighbour(Edge * edge, EdgeBoundary b);
55     void removeEdgeNeighbour(Edge * edge, EdgeBoundary b);
56     */
57     //KeyCell *insertKeyFrame(Time time);
58 
59 
60 private:
61     // Trusting operators
62     friend class VAC;
63     friend class Operator;
64     bool check_() const;
65 
66     ~InbetweenVertex();
67 
68     // Update Boundary
69     void updateBoundary_impl(KeyVertex * oldVertex, KeyVertex * newVertex);
70 
71     KeyVertex * beforeVertex_;
72     KeyVertex * afterVertex_;
73 
74     // Cubic spline interpolation
75     //KeyVertexList beforeBeforenodes() const;
76     //KeyVertexList afterAfternodes() const;
77     Eigen::Vector2d posCubic(Time time) const;
78 
79     // Linear interpolation
80     Eigen::Vector2d posLinear(Time time) const;
81 
82 // --------- Cloning, Assigning, Copying, Serializing ----------
83 
84 protected:
85     // Cloning
86     InbetweenVertex(InbetweenVertex * other);
87     virtual InbetweenVertex * clone();
88     virtual void remapPointers(VAC * newVAC);
89 
90     // Serializing / Unserializing
91     virtual QString xmlType_() const;
92     virtual void write_(XmlStreamWriter & xml) const;
93     InbetweenVertex(VAC * vac, XmlStreamReader &xml);
94     virtual void read2ndPass();
95 
96     // Serializing / Unserializing DEPRECATED
97     virtual void save_(QTextStream & out);
stringType()98     virtual QString stringType() const {return "InbetweenVertex";}
99     InbetweenVertex(VAC * vac, QTextStream & in);
100       public: class Read1stPass {
101     friend Cell * Cell::read1stPass(VAC * vac, QTextStream & in);
create(VAC * g,QTextStream & in)102     static InbetweenVertex * create(VAC * g, QTextStream & in)
103             {return new InbetweenVertex(g, in);}  };
104 
105 private:
106     struct TempRead { int before, after; };
107     TempRead * tmp_;
108 
109 };
110 
111 }
112 
113 #endif
114