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_INSTANT_CELL_H
18 #define VAC_INSTANT_CELL_H
19 
20 #include "Cell.h"
21 
22 namespace VectorAnimationComplex
23 {
24 
25 class KeyCell: virtual public Cell
26 {
27 public:
28     // -------------- Public standard interface -------------
29 
30     // Constructor and destructor
31     KeyCell(VAC * vac, Time time);
32 
33     // drawing
34     virtual void drawRaw3D(View3DSettings & viewSettings);
35 
36     // Time info
frame()37     int frame() const { return time_.frame(); }
floatTime()38     double floatTime() const { return time_.floatTime(); }
time()39     Time time() const { return time_; }
40 
41     Time temporalDragMinTime() const;
42     Time temporalDragMaxTime() const;
43     void setTime(Time time);
44 
45     // Reimplement
46     bool exists(Time time) const;
47     bool isBefore(Time time) const;
48     bool isAfter(Time time) const;
49     bool isAt(Time time) const;
50 
51     // Topological Navigation Information
52     KeyCellSet beforeCells() const;
53     KeyCellSet afterCells() const;
54 
55     // Bounding box
56     using Cell::boundingBox;
57     using Cell::outlineBoundingBox;
58     BoundingBox boundingBox() const;
59     BoundingBox outlineBoundingBox() const;
60 
61 private:
62     Time time_;
63 
64     // Trusting operators
65     friend class VAC;
66     friend class Operator;
67     bool checkKey_() const;
68 
69 protected:
70     virtual ~KeyCell()=0;
71 
72 // --------- Cloning, Assigning, Copying, Serializing ----------
73 
74 
75 protected:
76     KeyCell(VAC * vac, QTextStream & in);
stringType()77     virtual QString stringType() const {return "KeyCell";}
78     virtual void read2ndPass();
79     virtual void remapPointers(VAC * newVAC);
80     virtual void save_(QTextStream & out);
81     KeyCell(KeyCell * other);
82     KeyCell(VAC * vac, XmlStreamReader & xml);
83     virtual void write_(XmlStreamWriter & xml) const;
84 };
85 
86 }
87 
88 #endif
89