FreeCAD

Форк
0
/
PropertyVisualLayerList.cpp 
109 строк · 4.0 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com      *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include <Base/Console.h>
26
#include <Base/Interpreter.h>
27
#include <Base/Reader.h>
28
#include <Base/Writer.h>
29

30
#include "PropertyVisualLayerList.h"
31

32

33
using namespace App;
34
using namespace Base;
35
using namespace std;
36
using namespace SketcherGui;
37

38

39
TYPESYSTEM_SOURCE(SketcherGui::PropertyVisualLayerList, App::PropertyLists)
40

41
//**************************************************************************
42
// Construction/Destruction
43

44
PropertyVisualLayerList::PropertyVisualLayerList() = default;
45

46
PropertyVisualLayerList::~PropertyVisualLayerList() = default;
47

48
//**************************************************************************
49
// Base class implementer
50

51
PyObject* PropertyVisualLayerList::getPyObject()
52
{
53
    THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart");
54
}
55

56
VisualLayer PropertyVisualLayerList::getPyValue(PyObject* item) const
57
{
58

59
    (void)item;
60
    THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart");
61
}
62

63
void PropertyVisualLayerList::Save(Base::Writer& writer) const
64
{
65
    writer.Stream() << writer.ind() << "<VisualLayerList count=\"" << getSize() << "\">" << endl;
66
    writer.incInd();
67
    for (int i = 0; i < getSize(); i++) {
68
        _lValueList[i].Save(writer);
69
    }
70
    writer.decInd();
71
    writer.Stream() << writer.ind() << "</VisualLayerList>" << endl;
72
}
73

74
void PropertyVisualLayerList::Restore(Base::XMLReader& reader)
75
{
76
    reader.readElement("VisualLayerList");
77
    // get the value of my attribute
78
    int count = reader.getAttributeAsInteger("count");
79

80
    std::vector<VisualLayer> layers;
81
    layers.reserve(count);
82

83
    for (int i = 0; i < count; i++) {
84
        VisualLayer visualLayer;
85
        visualLayer.Restore(reader);
86
        layers.push_back(std::move(visualLayer));
87
    }
88

89
    reader.readEndElement("VisualLayerList");
90

91
    setValues(std::move(layers));
92
}
93

94
Property* PropertyVisualLayerList::Copy() const
95
{
96
    PropertyVisualLayerList* p = new PropertyVisualLayerList();
97
    p->_lValueList = _lValueList;
98
    return p;
99
}
100

101
void PropertyVisualLayerList::Paste(const Property& from)
102
{
103
    setValues(dynamic_cast<const PropertyVisualLayerList&>(from)._lValueList);
104
}
105

106
unsigned int PropertyVisualLayerList::getMemSize() const
107
{
108
    return static_cast<unsigned int>(_lValueList.size() * sizeof(VisualLayer));
109
}
110

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.