/*************************************************************************** * Copyright (c) 2023 Abdullah Tahiri #include #include #include #include #include "PropertyVisualLayerList.h" using namespace App; using namespace Base; using namespace std; using namespace SketcherGui; TYPESYSTEM_SOURCE(SketcherGui::PropertyVisualLayerList, App::PropertyLists) //************************************************************************** // Construction/Destruction PropertyVisualLayerList::PropertyVisualLayerList() = default; PropertyVisualLayerList::~PropertyVisualLayerList() = default; //************************************************************************** // Base class implementer PyObject* PropertyVisualLayerList::getPyObject() { THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart"); } VisualLayer PropertyVisualLayerList::getPyValue(PyObject* item) const { (void)item; THROWM(Base::NotImplementedError, "PropertyVisualLayerList has no python counterpart"); } void PropertyVisualLayerList::Save(Base::Writer& writer) const { writer.Stream() << writer.ind() << "" << endl; writer.incInd(); for (int i = 0; i < getSize(); i++) { _lValueList[i].Save(writer); } writer.decInd(); writer.Stream() << writer.ind() << "" << endl; } void PropertyVisualLayerList::Restore(Base::XMLReader& reader) { reader.readElement("VisualLayerList"); // get the value of my attribute int count = reader.getAttributeAsInteger("count"); std::vector layers; layers.reserve(count); for (int i = 0; i < count; i++) { VisualLayer visualLayer; visualLayer.Restore(reader); layers.push_back(std::move(visualLayer)); } reader.readEndElement("VisualLayerList"); setValues(std::move(layers)); } void PropertyVisualLayerList::Restore(Base::DocumentReader& reader, XERCES_CPP_NAMESPACE_QUALIFIER DOMElement* containerEl) { auto Prop_VisualLayerListDOM = reader.FindElementByField(containerEl, "Property", "name", "VisualLayerList"); if (Prop_VisualLayerListDOM) { auto VisualLayerListDOM = reader.FindElement(Prop_VisualLayerListDOM, "VisualLayerList"); const char* count_cstr = reader.GetAttribute(VisualLayerListDOM, "count"); if (count_cstr) { int count = reader.ContentToInt(count_cstr); std::vector layers; layers.reserve(count); auto prev_VisualLayerDOM = reader.FindElement(VisualLayerListDOM, "VisualLayer"); VisualLayer visualLayer; visualLayer.Restore(reader, prev_VisualLayerDOM); layers.push_back(std::move(visualLayer)); for (int i = 1; i < count; i++) { auto VisualLayerDOM_i = reader.FindNextElement(prev_VisualLayerDOM, "VisualLayer"); VisualLayer visualLayer; visualLayer.Restore(reader, VisualLayerDOM_i); layers.push_back(std::move(visualLayer)); prev_VisualLayerDOM = VisualLayerDOM_i; } setValues(std::move(layers)); } } } Property* PropertyVisualLayerList::Copy() const { PropertyVisualLayerList* p = new PropertyVisualLayerList(); p->_lValueList = _lValueList; return p; } void PropertyVisualLayerList::Paste(const Property& from) { setValues(dynamic_cast(from)._lValueList); } unsigned int PropertyVisualLayerList::getMemSize() const { return static_cast(_lValueList.size() * sizeof(VisualLayer)); }