From a54f50d0bf86c7c4d400e8b4d30cbc6091cfd9df Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Fri, 24 Feb 2017 12:25:41 -0300 Subject: Connection line implementation start --- Project/ConnectionLine.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Project/ConnectionLine.cpp (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp new file mode 100644 index 0000000..68d893a --- /dev/null +++ b/Project/ConnectionLine.cpp @@ -0,0 +1,29 @@ +#include "ConnectionLine.h" + +ConnectionLine::ConnectionLine() + : ControlElement() +{ +} + +ConnectionLine::~ConnectionLine() {} + +void ConnectionLine::Draw(wxPoint2DDouble translation, double scale) const +{ + +} + +bool ConnectionLine::Contains(wxPoint2DDouble position) const +{ + if(PointToLineDistance(position) < 5.0) { + return true; + } + return false; +} + +bool ConnectionLine::Intersects(wxRect2DDouble rect) const +{ + for(auto it = m_pointList.begin(); it != m_pointList.end(); ++it) { + if(rect.Contains(*it)) return true; + } + return false; +} -- cgit From 4ddc7be64451db873e49169e951532ce8893e359 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Fri, 3 Mar 2017 18:50:40 -0300 Subject: More connection line methods implemented --- Project/ConnectionLine.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 2 deletions(-) (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index 68d893a..3cd6547 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -1,15 +1,31 @@ #include "ConnectionLine.h" -ConnectionLine::ConnectionLine() +ConnectionLine::ConnectionLine(Node* firstNode) : ControlElement() { + wxPoint2DDouble pt = firstNode->GetPosition(); + m_tmpSndPt = pt; + for(int i = 0; i < 6; i++) { + m_pointList.push_back(pt); + } + m_nodeList.push_back(firstNode); } ConnectionLine::~ConnectionLine() {} void ConnectionLine::Draw(wxPoint2DDouble translation, double scale) const { - + // Line selected (Layer 1). + if(m_selected) { + glLineWidth(1.5 + m_borderSize * 2.0); + glColor4dv(m_selectionColour.GetRGBA()); + DrawLine(m_pointList); + } + + // Draw line (Layer 2) + glLineWidth(1.5); + glColor4d(0.0, 0.0, 0.0, 1.0); + DrawLine(m_pointList); } bool ConnectionLine::Contains(wxPoint2DDouble position) const @@ -27,3 +43,72 @@ bool ConnectionLine::Intersects(wxRect2DDouble rect) const } return false; } + +void ConnectionLine::UpdatePoints() +{ + bool hasOneNode = true; + wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); + wxPoint2DDouble pt2; + if(m_nodeList.size() == 1) + pt2 = m_tmpSndPt; + else { + pt2 = m_nodeList[1]->GetPosition(); + hasOneNode = false; + } + wxPoint2DDouble midPt = (pt1 + pt2) / 2.0 + wxPoint2DDouble(0.0, m_lineOffset); + + m_pointList[0] = pt1; + if(m_nodeList[0]->GetAngle() == 0.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(-10, 0); + else if(m_nodeList[0]->GetAngle() == 90.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, -10); + else if(m_nodeList[0]->GetAngle() == 180.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(10, 0); + else if(m_nodeList[0]->GetAngle() == 270.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, 10); + + m_pointList[2] = m_pointList[1] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[1].m_y); + + m_pointList[5] = pt2; + if(hasOneNode) + m_pointList[4] = pt2; + else { + if(m_nodeList[1]->GetAngle() == 0.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(-10, 0); + else if(m_nodeList[1]->GetAngle() == 90.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, -10); + else if(m_nodeList[1]->GetAngle() == 180.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(10, 0); + else if(m_nodeList[1]->GetAngle() == 270.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, 10); + } + + m_pointList[3] = m_pointList[4] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[4].m_y); +} + +bool ConnectionLine::AppendNode(Node* node, ControlElement* parent) +{ + if(m_nodeList.size() != 1) return false; + if(m_nodeList[0] == node) return false; + if(m_nodeList[0]->GetNodeType() == node->GetNodeType()) return false; + auto nodeList = parent->GetNodeList(); + for(auto it = nodeList.begin(), itEnd = nodeList.end(); it != itEnd; ++it) { + Node* parentNode = *it; + if(parentNode == m_nodeList[0]) return false; + } + + m_nodeList.push_back(node); + return true; +} + +void ConnectionLine::Move(wxPoint2DDouble position) +{ + m_lineOffset = m_moveStartOffset + position.m_y - m_moveStartPtY; + UpdatePoints(); +} + +void ConnectionLine::StartMove(wxPoint2DDouble position) +{ + m_moveStartPtY = position.m_y; + m_moveStartOffset = m_lineOffset; +} -- cgit From d11da00a993f1eeae6a1be50839ac72740e4e27b Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Sat, 4 Mar 2017 17:14:52 -0300 Subject: Delete element implemented --- Project/ConnectionLine.cpp | 92 +++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 37 deletions(-) (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index 3cd6547..fefe144 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -9,6 +9,7 @@ ConnectionLine::ConnectionLine(Node* firstNode) m_pointList.push_back(pt); } m_nodeList.push_back(firstNode); + firstNode->SetConnected(); } ConnectionLine::~ConnectionLine() {} @@ -46,44 +47,50 @@ bool ConnectionLine::Intersects(wxRect2DDouble rect) const void ConnectionLine::UpdatePoints() { - bool hasOneNode = true; - wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); - wxPoint2DDouble pt2; - if(m_nodeList.size() == 1) - pt2 = m_tmpSndPt; - else { - pt2 = m_nodeList[1]->GetPosition(); - hasOneNode = false; - } - wxPoint2DDouble midPt = (pt1 + pt2) / 2.0 + wxPoint2DDouble(0.0, m_lineOffset); - - m_pointList[0] = pt1; - if(m_nodeList[0]->GetAngle() == 0.0) - m_pointList[1] = m_pointList[0] + wxPoint2DDouble(-10, 0); - else if(m_nodeList[0]->GetAngle() == 90.0) - m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, -10); - else if(m_nodeList[0]->GetAngle() == 180.0) - m_pointList[1] = m_pointList[0] + wxPoint2DDouble(10, 0); - else if(m_nodeList[0]->GetAngle() == 270.0) - m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, 10); - - m_pointList[2] = m_pointList[1] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[1].m_y); - - m_pointList[5] = pt2; - if(hasOneNode) - m_pointList[4] = pt2; - else { - if(m_nodeList[1]->GetAngle() == 0.0) - m_pointList[4] = m_pointList[5] + wxPoint2DDouble(-10, 0); - else if(m_nodeList[1]->GetAngle() == 90.0) - m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, -10); - else if(m_nodeList[1]->GetAngle() == 180.0) - m_pointList[4] = m_pointList[5] + wxPoint2DDouble(10, 0); - else if(m_nodeList[1]->GetAngle() == 270.0) - m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, 10); - } + if(m_type == ELEMENT_ELEMENT) { + bool hasOneNode = true; + wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); + wxPoint2DDouble pt2; + if(m_nodeList.size() == 1) + pt2 = m_tmpSndPt; + else { + pt2 = m_nodeList[1]->GetPosition(); + hasOneNode = false; + } + wxPoint2DDouble midPt = (pt1 + pt2) / 2.0 + wxPoint2DDouble(0.0, m_lineOffset); + + m_pointList[0] = pt1; + if(m_nodeList[0]->GetAngle() == 0.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(-10, 0); + else if(m_nodeList[0]->GetAngle() == 90.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, -10); + else if(m_nodeList[0]->GetAngle() == 180.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(10, 0); + else if(m_nodeList[0]->GetAngle() == 270.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, 10); - m_pointList[3] = m_pointList[4] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[4].m_y); + m_pointList[2] = m_pointList[1] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[1].m_y); + + m_pointList[5] = pt2; + if(hasOneNode) + m_pointList[4] = pt2; + else { + if(m_nodeList[1]->GetAngle() == 0.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(-10, 0); + else if(m_nodeList[1]->GetAngle() == 90.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, -10); + else if(m_nodeList[1]->GetAngle() == 180.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(10, 0); + else if(m_nodeList[1]->GetAngle() == 270.0) + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, 10); + } + + m_pointList[3] = m_pointList[4] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[4].m_y); + } else if(m_type == ELEMENT_LINE) { + wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); + wxPoint2DDouble pt2 = m_parentLine->GetMidPoint(); + //CONTINUE... + } } bool ConnectionLine::AppendNode(Node* node, ControlElement* parent) @@ -98,6 +105,7 @@ bool ConnectionLine::AppendNode(Node* node, ControlElement* parent) } m_nodeList.push_back(node); + node->SetConnected(); return true; } @@ -112,3 +120,13 @@ void ConnectionLine::StartMove(wxPoint2DDouble position) m_moveStartPtY = position.m_y; m_moveStartOffset = m_lineOffset; } + +wxPoint2DDouble ConnectionLine::GetMidPoint() const { return ((m_pointList[2] + m_pointList[3]) / 2.0); } + +void ConnectionLine::SetParentLine(ConnectionLine* parent) +{ + if(parent) { + m_type = ELEMENT_LINE; + m_parentLine = parent; + } +} -- cgit From b3be8e8ef6338bce2106d9c161bf3c7f7f7f9244 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Mon, 6 Mar 2017 18:59:37 -0300 Subject: Connection line fully implemented Bug on delete a chid line and update points --- Project/ConnectionLine.cpp | 52 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index fefe144..ecbec1d 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -27,6 +27,11 @@ void ConnectionLine::Draw(wxPoint2DDouble translation, double scale) const glLineWidth(1.5); glColor4d(0.0, 0.0, 0.0, 1.0); DrawLine(m_pointList); + + if(m_type == ELEMENT_LINE) { + glColor4d(0.0, 0.0, 0.0, 1.0); + DrawCircle(m_pointList[5], 3, 10, GL_POLYGON); + } } bool ConnectionLine::Contains(wxPoint2DDouble position) const @@ -89,7 +94,32 @@ void ConnectionLine::UpdatePoints() } else if(m_type == ELEMENT_LINE) { wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); wxPoint2DDouble pt2 = m_parentLine->GetMidPoint(); - //CONTINUE... + wxPoint2DDouble midPt = (pt1 + pt2) / 2.0 + wxPoint2DDouble(0.0, m_lineOffset); + + m_pointList[0] = pt1; + if(m_nodeList[0]->GetAngle() == 0.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(-10, 0); + else if(m_nodeList[0]->GetAngle() == 90.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, -10); + else if(m_nodeList[0]->GetAngle() == 180.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(10, 0); + else if(m_nodeList[0]->GetAngle() == 270.0) + m_pointList[1] = m_pointList[0] + wxPoint2DDouble(0, 10); + + m_pointList[2] = m_pointList[1] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[1].m_y); + + m_pointList[5] = pt2; + if(m_pointList[2].m_y > pt2.m_y) { + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, 10); + } else { + m_pointList[4] = m_pointList[5] + wxPoint2DDouble(0, -10); + } + + m_pointList[3] = m_pointList[4] + wxPoint2DDouble(0.0, midPt.m_y - m_pointList[4].m_y); + } + for(auto it = m_childList.begin(), itEnd = m_childList.end(); it != itEnd; ++it) { + ConnectionLine* child = static_cast(*it); + child->UpdatePoints(); } } @@ -123,10 +153,22 @@ void ConnectionLine::StartMove(wxPoint2DDouble position) wxPoint2DDouble ConnectionLine::GetMidPoint() const { return ((m_pointList[2] + m_pointList[3]) / 2.0); } -void ConnectionLine::SetParentLine(ConnectionLine* parent) +bool ConnectionLine::SetParentLine(ConnectionLine* parent) +{ + if(m_nodeList[0]->GetNodeType() != Node::NODE_IN) return false; + if(!parent) return false; + + m_type = ELEMENT_LINE; + m_parentLine = parent; + return true; +} + +std::vector ConnectionLine::GetLineChildList() const { - if(parent) { - m_type = ELEMENT_LINE; - m_parentLine = parent; + std::vector childList; + for(auto it = m_childList.begin(), itEnd = m_childList.end(); it != itEnd; ++it) { + ConnectionLine* child = static_cast(*it); + childList.push_back(child); } + return childList; } -- cgit From 21ebf63bb59357000f9bb44acde176d4ff169c01 Mon Sep 17 00:00:00 2001 From: Thales1330 Date: Thu, 9 Mar 2017 15:09:43 -0300 Subject: Sum implemented --- Project/ConnectionLine.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index ecbec1d..8a232fe 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -27,7 +27,7 @@ void ConnectionLine::Draw(wxPoint2DDouble translation, double scale) const glLineWidth(1.5); glColor4d(0.0, 0.0, 0.0, 1.0); DrawLine(m_pointList); - + if(m_type == ELEMENT_LINE) { glColor4d(0.0, 0.0, 0.0, 1.0); DrawCircle(m_pointList[5], 3, 10, GL_POLYGON); @@ -95,7 +95,7 @@ void ConnectionLine::UpdatePoints() wxPoint2DDouble pt1 = m_nodeList[0]->GetPosition(); wxPoint2DDouble pt2 = m_parentLine->GetMidPoint(); wxPoint2DDouble midPt = (pt1 + pt2) / 2.0 + wxPoint2DDouble(0.0, m_lineOffset); - + m_pointList[0] = pt1; if(m_nodeList[0]->GetAngle() == 0.0) m_pointList[1] = m_pointList[0] + wxPoint2DDouble(-10, 0); @@ -157,7 +157,7 @@ bool ConnectionLine::SetParentLine(ConnectionLine* parent) { if(m_nodeList[0]->GetNodeType() != Node::NODE_IN) return false; if(!parent) return false; - + m_type = ELEMENT_LINE; m_parentLine = parent; return true; @@ -172,3 +172,11 @@ std::vector ConnectionLine::GetLineChildList() const } return childList; } + +void ConnectionLine::RemoveParent(Element* parent) +{ + for(auto it = m_parentList.begin(); it != m_parentList.end(); ++it) { + Element* element = *it; + if(element == parent) m_parentList.erase(it--); + } +} -- cgit From f19803bc64885bcfaef15cfd7a8139c28d3dd506 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sat, 8 Apr 2017 16:31:25 -0300 Subject: Control editor export under implementation File handling --- Project/ConnectionLine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Project/ConnectionLine.cpp') 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; -- cgit From 0ec05e0cb396a9ef153d29f605d4a0bbeb0dc7c1 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Mon, 17 Apr 2017 20:25:10 -0300 Subject: Connection line import under implementation Parent line not implemented yet --- Project/ConnectionLine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Project/ConnectionLine.cpp') diff --git a/Project/ConnectionLine.cpp b/Project/ConnectionLine.cpp index 9b7ce40..ea04e5e 100644 --- a/Project/ConnectionLine.cpp +++ b/Project/ConnectionLine.cpp @@ -1,5 +1,9 @@ #include "ConnectionLine.h" +ConnectionLine::ConnectionLine() : ControlElement(-1) +{ +} + ConnectionLine::ConnectionLine(Node* firstNode, int id) : ControlElement(id) { -- cgit