1
/***************************************************************************
2
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Base/Console.h>
26
#include <Base/Interpreter.h>
27
#include <Base/Reader.h>
28
#include <Base/Writer.h>
30
#include "PropertyVisualLayerList.h"
36
using namespace SketcherGui;
39
TYPESYSTEM_SOURCE(SketcherGui::PropertyVisualLayerList, App::PropertyLists)
41
//**************************************************************************
42
// Construction/Destruction
44
PropertyVisualLayerList::PropertyVisualLayerList() = default;
46
PropertyVisualLayerList::~PropertyVisualLayerList() = default;
48
//**************************************************************************
49
// Base class implementer
51
PyObject* PropertyVisualLayerList::getPyObject()
53
THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart");
56
VisualLayer PropertyVisualLayerList::getPyValue(PyObject* item) const
60
THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart");
63
void PropertyVisualLayerList::Save(Base::Writer& writer) const
65
writer.Stream() << writer.ind() << "<VisualLayerList count=\"" << getSize() << "\">" << endl;
67
for (int i = 0; i < getSize(); i++) {
68
_lValueList[i].Save(writer);
71
writer.Stream() << writer.ind() << "</VisualLayerList>" << endl;
74
void PropertyVisualLayerList::Restore(Base::XMLReader& reader)
76
reader.readElement("VisualLayerList");
77
// get the value of my attribute
78
int count = reader.getAttributeAsInteger("count");
80
std::vector<VisualLayer> layers;
81
layers.reserve(count);
83
for (int i = 0; i < count; i++) {
84
VisualLayer visualLayer;
85
visualLayer.Restore(reader);
86
layers.push_back(std::move(visualLayer));
89
reader.readEndElement("VisualLayerList");
91
setValues(std::move(layers));
94
Property* PropertyVisualLayerList::Copy() const
96
PropertyVisualLayerList* p = new PropertyVisualLayerList();
97
p->_lValueList = _lValueList;
101
void PropertyVisualLayerList::Paste(const Property& from)
103
setValues(dynamic_cast<const PropertyVisualLayerList&>(from)._lValueList);
106
unsigned int PropertyVisualLayerList::getMemSize() const
108
return static_cast<unsigned int>(_lValueList.size() * sizeof(VisualLayer));