Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
ElementDataObject.cpp
1/*
2 * Copyright (C) 2017 Thales Lima Oliveira <thales@ufu.br>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#include "ElementDataObject.h"
19
20ElementDataObject::ElementDataObject() : wxDataObjectSimple(wxDataFormat(wxT("PSPCopy")))
21{
22 m_elementsLists = new ElementsLists();
23}
24
25ElementDataObject::ElementDataObject(std::vector<Element*> elementList) : wxDataObjectSimple(wxDataFormat(wxT("PSPCopy")))
26{
27 m_elementsLists = new ElementsLists();
28 if(elementList.size() > 0) {
29 // Separate buses (parents) from the rest of the elements (childs).
30 for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
31 Element* copy = (*it)->GetCopy();
32 if(copy) {
33 if(Bus* bus = dynamic_cast<Bus*>(copy))
34 m_elementsLists->parentList.push_back(bus);
35 else
36 m_elementsLists->elementList.push_back(copy);
37 }
38 }
39 }
40}
41
42ElementDataObject::~ElementDataObject() {}
43size_t ElementDataObject::GetDataSize() const
44{
45 return sizeof(void*);
46 //return sizeof(*this);
47}
48
49bool ElementDataObject::GetDataHere(void* buf) const
50{
51 *(ElementsLists**)buf = m_elementsLists;
52 //buf = m_elementsLists;
53 return true;
54}
55
56bool ElementDataObject::SetData(size_t len, const void* buf)
57{
58 m_elementsLists = *(ElementsLists**)buf;
59 //m_elementsLists = const_cast<ElementsLists*>(static_cast<const ElementsLists*>(buf));
60 return true;
61}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
virtual Element * GetCopy()
Get a the element copy.
Definition Element.h:261