25 out << QString(
"NINJAV1.1");
28 for (
auto &layer : doc.
layers()) {
36 qInfo() <<
"Doc Version" << doc_version;
46 for (
int i = 0; i < layers_size; i++) {
58 out << layer->use_diode_;
59 out << layer->is_visible_;
60 out << layer->target_height_;
61 out << layer->step_height_;
62 out << layer->repeat_;
65 out << layer->children().size();
66 for (
auto &shape: layer->children()) {
74 LayerPtr layer = make_shared<Layer>();
79 in >> layer->use_diode_;
80 in >> layer->is_visible_;
81 in >> layer->target_height_;
82 in >> layer->step_height_;
88 qInfo() <<
"Parsing layer" << layer->name_ <<
"children" << shape_size;
89 for (
int i = 0; i < shape_size; i++) {
92 layer->addShape(shape);
100 switch (shape->type()) {
121 qInfo() <<
"Parsing shape" << (int) type;
134 Q_ASSERT_X(
false,
"Deserialize",
"Failed to parse shape type");
138 out << shape->rotation_;
144 in >> shape->rotation_;
151 out << *shape->bitmap_.get();
159 shape->bitmap_ = make_unique<QPixmap>(pixmap);
166 out << shape->filled_;
173 in >> shape->filled_;
181 out << shape->children_.size();
182 for (
auto &shape: shape->children_) {
192 for (
int i = 0; i < children_size; i++) {
194 shape->setParent(group);
196 group->children_ << shape;
203 out << shape->filled_;
205 out << shape->line_height_;
206 out << shape->lines_;
213 in >> shape->filled_;
215 in >> shape->line_height_;
Definition: bitmap-shape.h:7
Document state store for layers, shapes, document specfic settings and current view state.
Definition: document.h:19
const QList< LayerPtr > & layers() const
Definition: document.cpp:182
void addLayer(LayerPtr &layer)
Definition: document.cpp:106
void setWidth(qreal width)
Definition: document.cpp:130
qreal height() const
Definition: document.cpp:128
qreal width() const
Definition: document.cpp:126
void setHeight(qreal height)
Definition: document.cpp:132
Save and load documents as binary format.
Definition: document-serializer.h:18
void serializeLayer(const LayerPtr &layer)
Definition: document-serializer.h:53
void deserializeShapeProp(Shape *shape)
Definition: document-serializer.h:143
void serializeShape(const ShapePtr &shape)
Definition: document-serializer.h:97
QDataStream & out
Definition: document-serializer.h:221
TextShape * deserializeTextShape()
Definition: document-serializer.h:210
void serializePathShape(PathShape *shape)
Definition: document-serializer.h:164
void serializeGroupShape(GroupShape *shape)
Definition: document-serializer.h:179
DocumentSerializer(QDataStream &stream)
Definition: document-serializer.h:20
QDataStream & in
Definition: document-serializer.h:222
Document * deserializeDocument()
Definition: document-serializer.h:33
BitmapShape * deserializeBitmapShape()
Definition: document-serializer.h:154
ShapePtr deserializeShape()
Definition: document-serializer.h:118
void serializeShapeProp(Shape *shape)
Definition: document-serializer.h:137
void serializeDocument(Document &doc)
Definition: document-serializer.h:24
void serializeBitmapShape(BitmapShape *shape)
Definition: document-serializer.h:149
LayerPtr deserializeLayer()
Definition: document-serializer.h:73
void serializeTextShape(TextShape *shape)
Definition: document-serializer.h:201
GroupShape * deserializeGroupShape()
Definition: document-serializer.h:187
PathShape * deserializePathShape()
Definition: document-serializer.h:170
Definition: group-shape.h:8
Definition: path-shape.h:7
QPainterPath path_
Definition: path-shape.h:52
A base class for shape objects that contains transform and parent information.
Definition: shape.h:17
Type
Definition: shape.h:19
bool selected_
Definition: shape.h:134
QTransform transform_
Definition: shape.h:128
Definition: text-shape.h:6
shared_ptr< Layer > LayerPtr
Definition: layer.h:127
shared_ptr< Shape > ShapePtr
Definition: shape.h:137