diff options
33 files changed, 203 insertions, 116 deletions
diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index 8a232fe..9b7ce40 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -1,7 +1,7 @@ #include "ConnectionLine.h" -ConnectionLine::ConnectionLine(Node* firstNode) - : ControlElement() +ConnectionLine::ConnectionLine(Node* firstNode, int id) + : ControlElement(id) { wxPoint2DDouble pt = firstNode->GetPosition(); m_tmpSndPt = pt; diff --git a/Project/ConnectionLine.h b/Project/ConnectionLine.h index bb2dbcd..a0df142 100644 --- a/Project/ConnectionLine.h +++ b/Project/ConnectionLine.h @@ -10,7 +10,7 @@ public: ELEMENT_ELEMENT = 0, ELEMENT_LINE }; - ConnectionLine(Node* firstNode); + ConnectionLine(Node* firstNode, int id); ~ConnectionLine(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/Constant.cpp b/Project/Constant.cpp index 77a129e..ff0ae02 100644 --- a/Project/Constant.cpp +++ b/Project/Constant.cpp @@ -1,7 +1,7 @@ #include "Constant.h" #include "ConstantForm.h" -Constant::Constant() : ControlElement() +Constant::Constant(int id) : ControlElement(id) { SetValue(m_value); m_angle = 180.0; diff --git a/Project/Constant.h b/Project/Constant.h index b193a7a..9868627 100644 --- a/Project/Constant.h +++ b/Project/Constant.h @@ -11,7 +11,7 @@ class ConstantForm; class Constant : public ControlElement { public: - Constant(); + Constant(int id); ~Constant(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp index 6dbf650..e9e95f1 100644 --- a/Project/ControlEditor.cpp +++ b/Project/ControlEditor.cpp @@ -1,5 +1,6 @@ #include "ControlEditor.h" +#include "FileHanding.h" #include "Camera.h" #include "ControlElement.h" #include "TransferFunction.h" @@ -108,9 +109,8 @@ ControlEditor::ControlEditor(wxWindow* parent, int ioflags) : ControlEditorBase( m_glContext = new wxGLContext(m_glCanvas); m_camera = new Camera(); m_selectionRect = wxRect2DDouble(0, 0, 0, 0); - //m_camera->SetScale(1.2); + // m_camera->SetScale(1.2); m_ioFlags = ioflags; - } ControlEditor::~ControlEditor() { @@ -205,50 +205,51 @@ void ControlEditor::AddElement(ControlElementButtonID id) switch(id) { case ID_IO: { m_mode = MODE_INSERT; - IOControl* io = new IOControl(m_ioFlags); + IOControl* io = new IOControl(m_ioFlags, m_lastElementID); m_elementList.push_back(io); } break; case ID_TF: { m_mode = MODE_INSERT; - TransferFunction* tf = new TransferFunction(); + TransferFunction* tf = new TransferFunction(m_lastElementID); m_elementList.push_back(tf); } break; case ID_SUM: { m_mode = MODE_INSERT; - Sum* sum = new Sum(); + Sum* sum = new Sum(m_lastElementID); m_elementList.push_back(sum); } break; case ID_CONST: { m_mode = MODE_INSERT; - Constant* constant = new Constant(); + Constant* constant = new Constant(m_lastElementID); m_elementList.push_back(constant); } break; case ID_LIMITER: { m_mode = MODE_INSERT; - Limiter* limiter = new Limiter(); + Limiter* limiter = new Limiter(m_lastElementID); m_elementList.push_back(limiter); } break; case ID_GAIN: { m_mode = MODE_INSERT; - Gain* gain = new Gain(); + Gain* gain = new Gain(m_lastElementID); m_elementList.push_back(gain); } break; case ID_MULT: { m_mode = MODE_INSERT; - Multiplier* mult = new Multiplier(); + Multiplier* mult = new Multiplier(m_lastElementID); m_elementList.push_back(mult); } break; case ID_EXP: { m_mode = MODE_INSERT; - Exponential* exp = new Exponential(); + Exponential* exp = new Exponential(m_lastElementID); m_elementList.push_back(exp); } break; case ID_RATELIM: { m_mode = MODE_INSERT; - RateLimiter* rateLim = new RateLimiter(); + RateLimiter* rateLim = new RateLimiter(m_lastElementID); m_elementList.push_back(rateLim); } break; } + m_lastElementID++; } void ControlEditor::OnPaint(wxPaintEvent& event) @@ -333,7 +334,8 @@ void ControlEditor::OnLeftClickDown(wxMouseEvent& event) Node* node = *itN; if(node->Contains(m_camera->ScreenToWorld(clickPoint))) { m_mode = MODE_INSERT_LINE; - ConnectionLine* line = new ConnectionLine(node); + ConnectionLine* line = new ConnectionLine(node, m_lastElementID); + m_lastElementID++; m_connectionList.push_back(line); element->AddChild(line); line->AddParent(element); @@ -586,7 +588,7 @@ void ControlEditor::OnIdle(wxIdleEvent& event) { // Solve wxGLString bug. if(m_firstDraw) { - TransferFunction* tf = new TransferFunction(); + TransferFunction* tf = new TransferFunction(0); m_elementList.push_back(tf); Redraw(); m_elementList.pop_back(); @@ -702,3 +704,14 @@ void ControlEditor::CheckConnections() } } } +void ControlEditor::OnExportClick(wxCommandEvent& event) +{ + FileHanding fileHandling(this); + + wxFileDialog saveFileDialog(this, _("Save CTL file"), "", "", "CTL files (*.ctl)|*.ctl", + wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + if(saveFileDialog.ShowModal() == wxID_CANCEL) return; + + fileHandling.SaveControl(saveFileDialog.GetPath()); + wxFileName fileName(saveFileDialog.GetPath()); +} diff --git a/Project/ControlEditor.h b/Project/ControlEditor.h index 0b9304c..40a2b0a 100644 --- a/Project/ControlEditor.h +++ b/Project/ControlEditor.h @@ -11,6 +11,7 @@ #include "IOControl.h" +class FileHanding; class Camera; class Element; class ControlElement; @@ -84,6 +85,7 @@ class ControlEditor : public ControlEditorBase virtual std::vector<ControlElement*> GetControlElementList() { return m_elementList; } protected: + virtual void OnExportClick(wxCommandEvent& event); virtual void OnKeyDown(wxKeyEvent& event); virtual void OnIdle(wxIdleEvent& event); virtual void OnScroll(wxMouseEvent& event); @@ -114,5 +116,7 @@ class ControlEditor : public ControlEditorBase bool m_firstDraw = true; int m_ioFlags; + + int m_lastElementID = 0; }; #endif // CONTROLEDITOR_H diff --git a/Project/ControlEditor.wxcp b/Project/ControlEditor.wxcp index ed9f512..04c0c44 100644 --- a/Project/ControlEditor.wxcp +++ b/Project/ControlEditor.wxcp @@ -313,7 +313,14 @@ "m_label": "Construct the Dropdown Menu:", "m_value": true }], - "m_events": [], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_TOOL_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnExportClick(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool", + "m_noBody": false + }], "m_children": [] }, { "m_type": 4504, diff --git a/Project/ControlEditorBase.cpp b/Project/ControlEditorBase.cpp index 8ad5899..4fe00fc 100644 --- a/Project/ControlEditorBase.cpp +++ b/Project/ControlEditorBase.cpp @@ -136,6 +136,7 @@ ControlEditorBase::ControlEditorBase(wxWindow* parent, wxWindowID id, const wxSt } #endif // Connect events + this->Connect(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(ControlEditorBase::OnExportClick), NULL, this); m_glCanvas->Connect(wxEVT_PAINT, wxPaintEventHandler(ControlEditorBase::OnPaint), NULL, this); m_glCanvas->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(ControlEditorBase::OnLeftClickDown), NULL, this); m_glCanvas->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(ControlEditorBase::OnLeftClickUp), NULL, this); @@ -151,6 +152,7 @@ ControlEditorBase::ControlEditorBase(wxWindow* parent, wxWindowID id, const wxSt ControlEditorBase::~ControlEditorBase() { + this->Disconnect(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(ControlEditorBase::OnExportClick), NULL, this); m_glCanvas->Disconnect(wxEVT_PAINT, wxPaintEventHandler(ControlEditorBase::OnPaint), NULL, this); m_glCanvas->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(ControlEditorBase::OnLeftClickDown), NULL, this); m_glCanvas->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(ControlEditorBase::OnLeftClickUp), NULL, this); diff --git a/Project/ControlEditorBase.h b/Project/ControlEditorBase.h index ecc655b..e72ca31 100644 --- a/Project/ControlEditorBase.h +++ b/Project/ControlEditorBase.h @@ -48,6 +48,7 @@ protected: wxStatusBar* m_statusBarMain; protected: + virtual void OnExportClick(wxCommandEvent& event) { event.Skip(); } virtual void OnPaint(wxPaintEvent& event) { event.Skip(); } virtual void OnLeftClickDown(wxMouseEvent& event) { event.Skip(); } virtual void OnLeftClickUp(wxMouseEvent& event) { event.Skip(); } diff --git a/Project/ControlElement.cpp b/Project/ControlElement.cpp index cc7ba20..d75c606 100644 --- a/Project/ControlElement.cpp +++ b/Project/ControlElement.cpp @@ -83,9 +83,10 @@ bool Node::Contains(wxPoint2DDouble position) const return m_rect.Contains(position); } -ControlElement::ControlElement() +ControlElement::ControlElement(int id) : Element() { + m_elementID = id; } ControlElement::~ControlElement() {} diff --git a/Project/ControlElement.h b/Project/ControlElement.h index 2a516aa..880dd98 100644 --- a/Project/ControlElement.h +++ b/Project/ControlElement.h @@ -54,7 +54,7 @@ protected: class ControlElement : public Element { public: - ControlElement(); + ControlElement(int id); ~ControlElement(); virtual void StartMove(wxPoint2DDouble position); diff --git a/Project/ControlElementContainer.cpp b/Project/ControlElementContainer.cpp index 062807a..0e0e9d4 100644 --- a/Project/ControlElementContainer.cpp +++ b/Project/ControlElementContainer.cpp @@ -1,25 +1,9 @@ #include "ControlElementContainer.h" -#include "ControlEditor.h"; -#include "ControlElement.h"; -#include "ConnectionLine.h"; -#include "Constant.h"; -#include "Exponential.h"; -#include "Gain.h"; -#include "IOControl.h"; -#include "Limiter.h"; -#include "Multiplier.h"; -#include "RateLimiter.h"; -#include "Sum.h"; -#include "TransferFunction.h"; - -ControlElementContainer::ControlElementContainer() -{ -} - -ControlElementContainer::~ControlElementContainer() -{ -} +#include "ControlEditor.h" +#include "ControlElement.h" +ControlElementContainer::ControlElementContainer() {} +ControlElementContainer::~ControlElementContainer() {} void ControlElementContainer::FillContainer(ControlEditor* editor) { ClearContainer(); @@ -33,11 +17,11 @@ void ControlElementContainer::FillContainer(ControlEditor* editor) } else if(Gain* gain = dynamic_cast<Gain*>(*it)) { m_gainList.push_back(gain); } else if(IOControl* ioControl = dynamic_cast<IOControl*>(*it)) { - m_ioControlList.push_back(IOControl); + m_ioControlList.push_back(ioControl); } else if(Limiter* limiter = dynamic_cast<Limiter*>(*it)) { m_limiterList.push_back(limiter); } else if(Multiplier* multiplier = dynamic_cast<Multiplier*>(*it)) { - m_multiplierList.push_back(limiter); + m_multiplierList.push_back(multiplier); } else if(RateLimiter* rateLimiter = dynamic_cast<RateLimiter*>(*it)) { m_rateLimiterList.push_back(rateLimiter); } else if(Sum* sum = dynamic_cast<Sum*>(*it)) { @@ -45,7 +29,7 @@ void ControlElementContainer::FillContainer(ControlEditor* editor) } else if(TransferFunction* tf = dynamic_cast<TransferFunction*>(*it)) { m_tfList.push_back(tf); } - } + } } void ControlElementContainer::ClearContainer() diff --git a/Project/ControlElementContainer.h b/Project/ControlElementContainer.h index 0e2adc0..5ff218f 100644 --- a/Project/ControlElementContainer.h +++ b/Project/ControlElementContainer.h @@ -1,19 +1,21 @@ #ifndef CONTROLELEMENTCONTAINER_H #define CONTROLELEMENTCONTAINER_H -class ControlEditor; +#include <vector> +class ControlEditor; class ControlElement; -class ConnectionLine; -class Constant; -class Exponential; -class Gain; -class IOControl; -class Limiter; -class Multiplier; -class RateLimiter; -class Sum; -class TransferFunction; + +#include "ConnectionLine.h" +#include "Constant.h" +#include "Exponential.h" +#include "Gain.h" +#include "IOControl.h" +#include "Limiter.h" +#include "Multiplier.h" +#include "RateLimiter.h" +#include "Sum.h" +#include "TransferFunction.h" class ControlElementContainer { diff --git a/Project/Exponential.cpp b/Project/Exponential.cpp index cb9dfd8..7c4f1fe 100644 --- a/Project/Exponential.cpp +++ b/Project/Exponential.cpp @@ -1,7 +1,7 @@ #include "Exponential.h" #include "ExponentialForm.h" -Exponential::Exponential() +Exponential::Exponential(int id) : ControlElement(id) { m_width = m_height = 36.0; Node* nodeIn = new Node(m_position + wxPoint2DDouble(-18, 0), Node::NODE_IN, m_borderSize); diff --git a/Project/Exponential.h b/Project/Exponential.h index ab86ebb..8260d66 100644 --- a/Project/Exponential.h +++ b/Project/Exponential.h @@ -8,7 +8,7 @@ class ExponentialForm; class Exponential : public ControlElement { public: - Exponential(); + Exponential(int id); ~Exponential(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/FileHanding.cpp b/Project/FileHanding.cpp index 1eec1ee..f049c23 100644 --- a/Project/FileHanding.cpp +++ b/Project/FileHanding.cpp @@ -1,11 +1,9 @@ #include "FileHanding.h" FileHanding::~FileHanding() {} - FileHanding::FileHanding(Workspace* workspace) { m_workspace = workspace; } - +FileHanding::FileHanding(ControlEditor* controlEditor) { m_controlEditor = controlEditor; } FileHanding::FileHanding() {} - void FileHanding::SaveProject(wxFileName path) { // Erase the file (if exists or not) and write the initial data @@ -99,7 +97,7 @@ void FileHanding::SaveProject(wxFileName path) data.number = i; bus->SetElectricalData(data); - } //} + } //} //{ Capacitor auto capacitorsNode = AppendNode(doc, elementsNode, "CapacitorList"); @@ -150,7 +148,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ IndMotor auto indMotorsNode = AppendNode(doc, elementsNode, "IndMotorList"); @@ -193,7 +191,7 @@ void FileHanding::SaveProject(wxFileName path) auto reactivePower = AppendNode(doc, electricalProp, "ReactivePower"); SetNodeValue(doc, reactivePower, data.reactivePower); SetNodeAttribute(doc, reactivePower, "UnitID", data.reactivePowerUnit); - } //} + } //} //{ Inductor auto inductorsNode = AppendNode(doc, elementsNode, "InductorList"); @@ -244,7 +242,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ Line auto linesNode = AppendNode(doc, elementsNode, "LineList"); @@ -323,7 +321,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ Load auto loadsNode = AppendNode(doc, elementsNode, "LoadList"); @@ -379,7 +377,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ SyncGenerator auto syncGeneratorsNode = AppendNode(doc, elementsNode, "SyncGeneratorList"); @@ -509,7 +507,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ SyncMotor auto syncMotorsNode = AppendNode(doc, elementsNode, "SyncMotorList"); @@ -638,7 +636,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); }*/ - } //} + } //} //{ Transfomer auto transformersNode = AppendNode(doc, elementsNode, "TransformerList"); @@ -738,7 +736,7 @@ void FileHanding::SaveProject(wxFileName path) auto swTime = AppendNode(doc, switching, "Time"); SetNodeValue(doc, swTime, swData.swTime[j]); } - } //} + } //} //{ Text auto textsNode = AppendNode(doc, elementsNode, "TextList"); @@ -829,7 +827,7 @@ bool FileHanding::OpenProject(wxFileName path) double angle = GetNodeValueDouble(cadPropNode, "Angle"); bus->SetWidth(width); bus->SetHeight(height); - bus->SetPosition(bus->GetPosition()); // Update bus rectangle. + bus->SetPosition(bus->GetPosition()); // Update bus rectangle. int numRot = angle / bus->GetRotationAngle(); bool clockwise = true; if(numRot < 0) { @@ -867,7 +865,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(bus); busList.push_back(bus); busNode = busNode->next_sibling("Bus"); - } //} + } //} //{ Capacitor auto capacitorListNode = elementsNode->first_node("CapacitorList"); @@ -939,7 +937,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(capacitor); capacitorList.push_back(capacitor); capacitorNode = capacitorNode->next_sibling("Capacitor"); - } //} + } //} //{ IndMotor auto indMotorListNode = elementsNode->first_node("IndMotorList"); @@ -1002,7 +1000,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(indMotor); indMotorList.push_back(indMotor); indMotorNode = indMotorNode->next_sibling("IndMotor"); - } //} + } //} //{ Inductor auto inductorListNode = elementsNode->first_node("InductorList"); @@ -1074,7 +1072,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(inductor); inductorList.push_back(inductor); inductorNode = inductorNode->next_sibling("Inductor"); - } //} + } //} //{ Line auto lineListNode = elementsNode->first_node("LineList"); @@ -1102,7 +1100,7 @@ bool FileHanding::OpenProject(wxFileName path) auto parentIDList = cadPropNode->first_node("ParentIDList"); if(!parentIDList) return false; auto parentNode = parentIDList->first_node("ParentID"); - long parentID[2] = { -1, -1 }; + long parentID[2] = {-1, -1}; while(parentNode) { long index = 0; wxString(parentNode->first_attribute("ID")->value()).ToLong(&index); @@ -1182,7 +1180,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(line); lineList.push_back(line); lineNode = lineNode->next_sibling("Line"); - } //} + } //} //{ Load auto loadListNode = elementsNode->first_node("LoadList"); @@ -1257,7 +1255,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(load); loadList.push_back(load); loadNode = loadNode->next_sibling("Load"); - } //} + } //} //{ SyncGenerator auto syncGeneratorListNode = elementsNode->first_node("SyncGeneratorList"); @@ -1375,7 +1373,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(syncGenerator); syncGeneratorList.push_back(syncGenerator); syncGeneratorNode = syncGeneratorNode->next_sibling("SyncGenerator"); - } //} + } //} //{ SyncMotor auto syncMotorListNode = elementsNode->first_node("SyncMotorList"); @@ -1472,7 +1470,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(syncMotor); syncMotorList.push_back(syncMotor); syncMotorNode = syncMotorNode->next_sibling("SyncMotor"); - } //} + } //} //{ Transformer auto transformerListNode = elementsNode->first_node("TransformerList"); @@ -1508,7 +1506,7 @@ bool FileHanding::OpenProject(wxFileName path) auto parentIDList = cadPropNode->first_node("ParentIDList"); if(!parentIDList) return false; auto parentNode = parentIDList->first_node("ParentID"); - long parentID[2] = { -1, -1 }; + long parentID[2] = {-1, -1}; while(parentNode) { long index = 0; wxString(parentNode->first_attribute("ID")->value()).ToLong(&index); @@ -1602,7 +1600,7 @@ bool FileHanding::OpenProject(wxFileName path) elementList.push_back(transformer); transformerList.push_back(transformer); transfomerNode = transfomerNode->next_sibling("Transfomer"); - } //} + } //} m_workspace->SetElementList(elementList); @@ -1611,7 +1609,6 @@ bool FileHanding::OpenProject(wxFileName path) if(!textListNode) return false; auto textNode = textListNode->first_node("Text"); while(textNode) { - auto cadPropNode = textNode->first_node("CADProperties"); if(!cadPropNode) return false; @@ -1630,7 +1627,7 @@ bool FileHanding::OpenProject(wxFileName path) auto textProperties = textNode->first_node("TextProperties"); if(!textProperties) return false; - + text->SetElementType((ElementType)GetNodeValueDouble(textProperties, "ElementType")); text->SetDataType((DataType)GetNodeValueDouble(textProperties, "DataType")); text->SetUnit((ElectricalUnit)GetNodeValueDouble(textProperties, "DataUnit")); @@ -1689,16 +1686,74 @@ bool FileHanding::OpenProject(wxFileName path) textList.push_back(text); textNode = textNode->next_sibling("Text"); - } //} + } //} m_workspace->SetTextList(textList); return true; } +void FileHanding::SaveControl(wxFileName path) +{ + // Same process present in SaveProject(): + std::ofstream writeProjectsFile(path.GetFullPath()); + writeProjectsFile.close(); + + rapidxml::xml_document<> doc; + rapidxml::file<> xmlFile(path.GetFullPath()); + doc.parse<0>(xmlFile.data()); + + rapidxml::xml_node<>* decl = doc.allocate_node(rapidxml::node_declaration); + rapidxml::xml_attribute<>* ver = doc.allocate_attribute("version", "1.0"); + rapidxml::xml_attribute<>* encoding = doc.allocate_attribute("encoding", "utf-8"); + decl->append_attribute(ver); + decl->append_attribute(encoding); + doc.append_node(decl); + + rapidxml::xml_node<>* rootNode = doc.allocate_node(rapidxml::node_element, "Control"); + doc.append_node(rootNode); + + rapidxml::xml_node<>* projectNameNode = AppendNode(doc, rootNode, "Name"); + SetNodeValue(doc, projectNameNode, path.GetName()); + + auto elementsNode = AppendNode(doc, rootNode, "ControlElements"); + SaveControlElements(doc, elementsNode); + std::ofstream writeXML(path.GetFullPath()); + writeXML << doc; + writeXML.close(); +} + +bool FileHanding::OpenControl(wxFileName path) {} +void FileHanding::SaveControlElements(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementsNode) +{ + ControlElementContainer ctrlContainer; + ctrlContainer.FillContainer(m_controlEditor); + + auto constsNode = AppendNode(doc, elementsNode, "ConstantList"); + auto constList = ctrlContainer.GetConstantList(); + for(auto it = constList.begin(), itEnd = constList.end(); it != itEnd; ++it) { + Constant* constant = *it; + auto constNode = AppendNode(doc, constsNode, "Constant"); + SetNodeAttribute(doc, constNode, "ID", constant->GetID()); + auto cadProp = AppendNode(doc, constNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, constant->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, constant->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, constant->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, constant->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, constant->GetAngle()); + } +} + rapidxml::xml_node<>* FileHanding::AppendNode(rapidxml::xml_document<>& doc, - rapidxml::xml_node<>* parentNode, - const char* name, - rapidxml::node_type nodeType) + rapidxml::xml_node<>* parentNode, + const char* name, + rapidxml::node_type nodeType) { rapidxml::xml_node<>* node = doc.allocate_node(nodeType, name); parentNode->append_node(node); @@ -1721,25 +1776,25 @@ void FileHanding::SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node } void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, - rapidxml::xml_node<>* node, - const char* atrName, - wxString value) + rapidxml::xml_node<>* node, + const char* atrName, + wxString value) { node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(value.mb_str()))); } void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, - rapidxml::xml_node<>* node, - const char* atrName, - int value) + rapidxml::xml_node<>* node, + const char* atrName, + int value) { node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(wxString::Format("%d", value)))); } void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, - rapidxml::xml_node<>* node, - const char* atrName, - double value) + rapidxml::xml_node<>* node, + const char* atrName, + double value) { node->append_attribute( doc.allocate_attribute(atrName, doc.allocate_string(wxString::FromCDouble(value, 13).mb_str()))); diff --git a/Project/FileHanding.h b/Project/FileHanding.h index 4546f15..1954876 100644 --- a/Project/FileHanding.h +++ b/Project/FileHanding.h @@ -6,6 +6,8 @@ #include <sstream> #include "Workspace.h" +#include "ControlEditor.h" +#include "ControlElementContainer.h" #include "ElectricCalculation.h" #include "Text.h" @@ -19,15 +21,21 @@ class FileHanding public: FileHanding(); FileHanding(Workspace* workspace); + FileHanding(ControlEditor* controlEditor); ~FileHanding(); void SetWorkspace(Workspace* workspace) { m_workspace = workspace; } + void SetControlEditor(ControlEditor* controlEditor) { m_controlEditor = controlEditor; } void SaveProject(wxFileName path); bool OpenProject(wxFileName path); + + void SaveControl(wxFileName path); + bool OpenControl(wxFileName path); protected: Workspace* m_workspace = NULL; + ControlEditor* m_controlEditor = NULL; rapidxml::xml_node<>* AppendNode(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* parentNode, @@ -42,6 +50,8 @@ protected: double GetNodeValueDouble(rapidxml::xml_node<>* parent, const char* nodeName); int GetNodeValueInt(rapidxml::xml_node<>* parent, const char* nodeName); int GetAttributeValueInt(rapidxml::xml_node<>* parent, const char* nodeName, const char* atrName); + + void SaveControlElements(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementsNode); }; #endif // FILEHANDING_H diff --git a/Project/Gain.cpp b/Project/Gain.cpp index 0e47c2c..faea89c 100644 --- a/Project/Gain.cpp +++ b/Project/Gain.cpp @@ -1,7 +1,7 @@ #include "Gain.h" #include "GainForm.h" -Gain::Gain() : ControlElement() +Gain::Gain(int id) : ControlElement(id) { m_triPts.resize(3); SetValue(m_value); diff --git a/Project/Gain.h b/Project/Gain.h index 0088e0c..8844372 100644 --- a/Project/Gain.h +++ b/Project/Gain.h @@ -11,7 +11,7 @@ class GainForm; class Gain : public ControlElement { public: - Gain(); + Gain(int id); ~Gain(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/IOControl.cpp b/Project/IOControl.cpp index e3bbb1a..d9ea52e 100644 --- a/Project/IOControl.cpp +++ b/Project/IOControl.cpp @@ -1,7 +1,7 @@ #include "IOControl.h" #include "IOControlForm.h" -IOControl::IOControl(int ioFlags) : ControlElement() +IOControl::IOControl(int ioFlags, int id) : ControlElement(id) { m_ioFlags = ioFlags; diff --git a/Project/IOControl.h b/Project/IOControl.h index e736ac1..7b3f4d0 100644 --- a/Project/IOControl.h +++ b/Project/IOControl.h @@ -20,7 +20,7 @@ class IOControl : public ControlElement OUT_MEC_POWER = 1 << 5 }; - IOControl(int ioFlags); + IOControl(int ioFlags, int id); ~IOControl(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/Limiter.cpp b/Project/Limiter.cpp index f5e037c..2a0b707 100644 --- a/Project/Limiter.cpp +++ b/Project/Limiter.cpp @@ -1,7 +1,7 @@ #include "Limiter.h" #include "LimiterForm.h" -Limiter::Limiter() : ControlElement() +Limiter::Limiter(int id) : ControlElement(id) { m_width = m_height = 36.0; Node* nodeIn = new Node(m_position + wxPoint2DDouble(-18, 0), Node::NODE_IN, m_borderSize); diff --git a/Project/Limiter.h b/Project/Limiter.h index f79cd43..5f4e55b 100644 --- a/Project/Limiter.h +++ b/Project/Limiter.h @@ -8,7 +8,7 @@ class LimiterForm; class Limiter : public ControlElement { public: - Limiter(); + Limiter(int id); ~Limiter(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/Multiplier.cpp b/Project/Multiplier.cpp index 2f91eab..ee644ed 100644 --- a/Project/Multiplier.cpp +++ b/Project/Multiplier.cpp @@ -1,6 +1,6 @@ #include "Multiplier.h" -Multiplier::Multiplier() : ControlElement() +Multiplier::Multiplier(int id) : ControlElement(id) { m_width = m_height = 36.0; Node* nodeIn1 = new Node(m_position + wxPoint2DDouble(-18, -9), Node::NODE_IN, m_borderSize); diff --git a/Project/Multiplier.h b/Project/Multiplier.h index bce2694..8a25b23 100644 --- a/Project/Multiplier.h +++ b/Project/Multiplier.h @@ -6,7 +6,7 @@ class Multiplier : public ControlElement { public: - Multiplier(); + Multiplier(int id); ~Multiplier(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/Project.mk b/Project/Project.mk index 6d159b9..977e057 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=NDSE-69 -Date :=07/04/2017 +Date :=08/04/2017 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC @@ -68,9 +68,9 @@ Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirector $(IntermediateDirectory)/Camera.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/BusFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBase.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/Bus.cpp$(ObjectSuffix) $(IntermediateDirectory)/Line.cpp$(ObjectSuffix) $(IntermediateDirectory)/Transformer.cpp$(ObjectSuffix) $(IntermediateDirectory)/Machines.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncGenerator.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Branch.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Shunt.cpp$(ObjectSuffix) $(IntermediateDirectory)/Load.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElectricCalculation.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerFlow.cpp$(ObjectSuffix) $(IntermediateDirectory)/Fault.cpp$(ObjectSuffix) $(IntermediateDirectory)/Text.cpp$(ObjectSuffix) $(IntermediateDirectory)/GraphicalElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/ConnectionLine.cpp$(ObjectSuffix) $(IntermediateDirectory)/Sum.cpp$(ObjectSuffix) $(IntermediateDirectory)/Multiplier.cpp$(ObjectSuffix) $(IntermediateDirectory)/Limiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/Exponential.cpp$(ObjectSuffix) $(IntermediateDirectory)/Constant.cpp$(ObjectSuffix) $(IntermediateDirectory)/Gain.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControl.cpp$(ObjectSuffix) $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/GeneratorStabForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SwitchingForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransformerForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LoadForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ReactiveShuntElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotorForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMachineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TextForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/SumForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ExponentialForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ConstantForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GainForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix) + $(IntermediateDirectory)/ConnectionLine.cpp$(ObjectSuffix) $(IntermediateDirectory)/Sum.cpp$(ObjectSuffix) $(IntermediateDirectory)/Multiplier.cpp$(ObjectSuffix) $(IntermediateDirectory)/Limiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/Exponential.cpp$(ObjectSuffix) $(IntermediateDirectory)/Constant.cpp$(ObjectSuffix) $(IntermediateDirectory)/Gain.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControl.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlElementContainer.cpp$(ObjectSuffix) \ + $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GeneratorStabForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SwitchingForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransformerForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LoadForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ReactiveShuntElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotorForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMachineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TextForm.cpp$(ObjectSuffix) \ + $(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SumForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ExponentialForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ConstantForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GainForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix) @@ -487,6 +487,14 @@ $(IntermediateDirectory)/IOControl.cpp$(DependSuffix): IOControl.cpp $(IntermediateDirectory)/IOControl.cpp$(PreprocessSuffix): IOControl.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IOControl.cpp$(PreprocessSuffix) IOControl.cpp +$(IntermediateDirectory)/ControlElementContainer.cpp$(ObjectSuffix): ControlElementContainer.cpp $(IntermediateDirectory)/ControlElementContainer.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/NDSE-69/Documents/GitHub/PSP/Project/ControlElementContainer.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/ControlElementContainer.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/ControlElementContainer.cpp$(DependSuffix): ControlElementContainer.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/ControlElementContainer.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/ControlElementContainer.cpp$(DependSuffix) -MM ControlElementContainer.cpp + +$(IntermediateDirectory)/ControlElementContainer.cpp$(PreprocessSuffix): ControlElementContainer.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/ControlElementContainer.cpp$(PreprocessSuffix) ControlElementContainer.cpp + $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix): BusForm.cpp $(IntermediateDirectory)/BusForm.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/NDSE-69/Documents/GitHub/PSP/Project/BusForm.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/BusForm.cpp$(DependSuffix): BusForm.cpp diff --git a/Project/Project.txt b/Project/Project.txt index 1eda1e9..e29b621 100644 --- a/Project/Project.txt +++ b/Project/Project.txt @@ -1 +1 @@ -./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/TransferFunction.cpp.o ./Release/ConnectionLine.cpp.o ./Release/Sum.cpp.o ./Release/Multiplier.cpp.o ./Release/Limiter.cpp.o ./Release/RateLimiter.cpp.o ./Release/Exponential.cpp.o ./Release/Constant.cpp.o ./Release/Gain.cpp.o ./Release/IOControl.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o ./Release/TransferFunctionForm.cpp.o ./Release/SumForm.cpp.o ./Release/LimiterForm.cpp.o ./Release/RateLimiterForm.cpp.o ./Release/ExponentialForm.cpp.o ./Release/ConstantForm.cpp.o ./Release/GainForm.cpp.o ./Release/IOControlForm.cpp.o +./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/TransferFunction.cpp.o ./Release/ConnectionLine.cpp.o ./Release/Sum.cpp.o ./Release/Multiplier.cpp.o ./Release/Limiter.cpp.o ./Release/RateLimiter.cpp.o ./Release/Exponential.cpp.o ./Release/Constant.cpp.o ./Release/Gain.cpp.o ./Release/IOControl.cpp.o ./Release/ControlElementContainer.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o ./Release/TransferFunctionForm.cpp.o ./Release/SumForm.cpp.o ./Release/LimiterForm.cpp.o ./Release/RateLimiterForm.cpp.o ./Release/ExponentialForm.cpp.o ./Release/ConstantForm.cpp.o ./Release/GainForm.cpp.o ./Release/IOControlForm.cpp.o diff --git a/Project/RateLimiter.cpp b/Project/RateLimiter.cpp index 50a303a..5da0578 100644 --- a/Project/RateLimiter.cpp +++ b/Project/RateLimiter.cpp @@ -1,7 +1,7 @@ #include "RateLimiter.h" #include "RateLimiterForm.h" -RateLimiter::RateLimiter() : ControlElement() +RateLimiter::RateLimiter(int id) : ControlElement(id) { m_width = m_height = 36.0; Node* nodeIn = new Node(m_position + wxPoint2DDouble(-18, 0), Node::NODE_IN, m_borderSize); diff --git a/Project/RateLimiter.h b/Project/RateLimiter.h index 1d6d72e..d17642b 100644 --- a/Project/RateLimiter.h +++ b/Project/RateLimiter.h @@ -8,7 +8,7 @@ class RateLimiterForm; class RateLimiter : public ControlElement { public: - RateLimiter(); + RateLimiter(int id); ~RateLimiter(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/Sum.cpp b/Project/Sum.cpp index d814bbe..606b367 100644 --- a/Project/Sum.cpp +++ b/Project/Sum.cpp @@ -1,8 +1,8 @@ #include "Sum.h" #include "SumForm.h" -Sum::Sum() - : ControlElement() +Sum::Sum(int id) + : ControlElement(id) { m_width = m_height = 36.0; Node* nodeIn1 = new Node(m_position + wxPoint2DDouble(-m_width / 2, 9 - m_height / 2), Node::NODE_IN, m_borderSize); diff --git a/Project/Sum.h b/Project/Sum.h index 30bfb4e..a99067e 100644 --- a/Project/Sum.h +++ b/Project/Sum.h @@ -9,7 +9,7 @@ class Sum : public ControlElement { public: enum Signal { SIGNAL_POSITIVE = 0, SIGNAL_NEGATIVE }; - Sum(); + Sum(int id); ~Sum(); virtual void Draw(wxPoint2DDouble translation, double scale) const; diff --git a/Project/TransferFunction.cpp b/Project/TransferFunction.cpp index 00e8fa2..9c8ffea 100644 --- a/Project/TransferFunction.cpp +++ b/Project/TransferFunction.cpp @@ -1,7 +1,7 @@ #include "TransferFunction.h" #include "TransferFunctionForm.h" -TransferFunction::TransferFunction() +TransferFunction::TransferFunction(int id) : ControlElement(id) { // Superscript unicode numbers m_supNumber[0] = L'\u2070'; diff --git a/Project/TransferFunction.h b/Project/TransferFunction.h index 34c23fc..45681ce 100644 --- a/Project/TransferFunction.h +++ b/Project/TransferFunction.h @@ -11,7 +11,7 @@ class TransferFunctionForm; class TransferFunction : public ControlElement { public: - TransferFunction(); + TransferFunction(int id); ~TransferFunction(); virtual void Draw(wxPoint2DDouble translation, double scale) const; |