summaryrefslogtreecommitdiffstats
path: root/Project/Sum.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2018-01-08 20:09:35 -0200
committerGitHub <noreply@github.com>2018-01-08 20:09:35 -0200
commit29af4e28898f44df444fef5534134c6b6000418d (patch)
tree13fd8f4449f2cfeed8a6185e96a6889f9529285d /Project/Sum.cpp
parent0c0280cfcf540f943fd2dbfdf7ac0304ea96a465 (diff)
parentc11a42ee83fcf535557d4f2cc259efae2da1b7ff (diff)
downloadPSP.git-29af4e28898f44df444fef5534134c6b6000418d.tar.gz
PSP.git-29af4e28898f44df444fef5534134c6b6000418d.tar.xz
PSP.git-29af4e28898f44df444fef5534134c6b6000418d.zip
Merge pull request #44 from Thales1330/org/file-handling-and-ctrl-init
Org file handling and ctrl init
Diffstat (limited to 'Project/Sum.cpp')
-rw-r--r--Project/Sum.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/Project/Sum.cpp b/Project/Sum.cpp
index 52fe66a..9908497 100644
--- a/Project/Sum.cpp
+++ b/Project/Sum.cpp
@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+#include "ConnectionLine.h"
#include "Sum.h"
#include "SumForm.h"
-#include "ConnectionLine.h"
Sum::Sum(int id) : ControlElement(id)
{
@@ -245,3 +245,42 @@ Element* Sum::GetCopy()
*copy = *this;
return copy;
}
+
+rapidxml::xml_node<>* Sum::SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode)
+{
+ auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Sum");
+ XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
+
+ SaveCADProperties(doc, elementNode);
+ SaveControlNodes(doc, elementNode);
+
+ // Element properties
+ auto signsNode = XMLParser::AppendNode(doc, elementNode, "Signs");
+ for(unsigned int i = 0; i < m_signalList.size(); ++i) {
+ auto value = XMLParser::AppendNode(doc, signsNode, "Value");
+ XMLParser::SetNodeValue(doc, value, static_cast<int>(m_signalList[i]));
+ }
+
+ return elementNode;
+}
+
+bool Sum::OpenElement(rapidxml::xml_node<>* elementNode)
+{
+ if(!OpenCADProperties(elementNode)) return false;
+ if(!OpenControlNodes(elementNode)) return false;
+
+ m_signalList.clear();
+ auto signsNode = elementNode->first_node("Signs");
+ auto sign = signsNode->first_node("Value");
+ while(sign) {
+ long value;
+ wxString(sign->value()).ToCLong(&value);
+ m_signalList.push_back(static_cast<Sum::Signal>(value));
+ sign = sign->next_sibling("Value");
+ }
+
+ StartMove(m_position);
+ UpdatePoints();
+
+ return true;
+}