summaryrefslogtreecommitdiffstats
path: root/Project/Element.cpp
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2016-08-17 17:19:58 -0300
committerThales1330 <thaleslima.ufu@gmail.com>2016-08-17 17:19:58 -0300
commite58cec073cbd982246898c733ae21b9f2b92b2b7 (patch)
tree1f2201686465ef0e41292d31ee3285e90ed2e7f3 /Project/Element.cpp
parent0a85e05fa7aa0e2b950c2c3bcec5d45f25b1c0e2 (diff)
downloadPSP.git-e58cec073cbd982246898c733ae21b9f2b92b2b7.tar.gz
PSP.git-e58cec073cbd982246898c733ae21b9f2b92b2b7.tar.xz
PSP.git-e58cec073cbd982246898c733ae21b9f2b92b2b7.zip
Line under implementation
Diffstat (limited to 'Project/Element.cpp')
-rw-r--r--Project/Element.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/Project/Element.cpp b/Project/Element.cpp
index a485c82..55cb87d 100644
--- a/Project/Element.cpp
+++ b/Project/Element.cpp
@@ -46,8 +46,18 @@ void Element::DrawRectangle(wxPoint2DDouble* points, GLenum mode) const
glEnd();
}
+void Element::DrawLine(std::vector<wxPoint2DDouble> points, GLenum mode) const
+{
+ glBegin(mode);
+ for(auto it = points.begin(); it != points.end(); ++it) {
+ glVertex2d((*it).m_x, (*it).m_y);
+ }
+ glEnd();
+}
+
void Element::DrawPickbox(wxPoint2DDouble position) const
{
+ glLineWidth(1.0);
glColor4d(1.0, 1.0, 1.0, 0.8);
DrawRectangle(position, 8.0, 8.0);
glColor4d(0.0, 0.0, 0.0, 1.0);
@@ -66,11 +76,29 @@ wxPoint2DDouble Element::RotateAtPosition(wxPoint2DDouble pointToRotate, double
void Element::StartMove(wxPoint2DDouble position)
{
- this->m_moveStartPt = position;
- this->m_movePos = m_position;
+ this->m_moveStartPt = position;
+ this->m_movePos = m_position;
}
-void Element::Move(wxPoint2DDouble position)
+void Element::Move(wxPoint2DDouble position) { SetPosition(m_movePos + position - m_moveStartPt); }
+wxPoint2DDouble Element::GetSwitchPoint(Element* parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
{
- SetPosition(m_movePos + position - m_moveStartPt);
-} \ No newline at end of file
+ double swLineSize = 25.0;
+ wxPoint2DDouble swPoint = wxPoint2DDouble(parentPoint.m_x, parentPoint.m_y - swLineSize);
+
+ // Rotate the second point (to compare).
+ double angle = parent->GetAngle();
+
+ secondPoint =
+ wxPoint2DDouble(std::cos(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) -
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(-angle)) * (secondPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(-angle)) * (secondPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+
+ // Rotate
+ if(secondPoint.m_y > parentPoint.m_y) angle -= 180.0;
+ return wxPoint2DDouble(std::cos(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) -
+ std::sin(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_x,
+ std::sin(wxDegToRad(angle)) * (swPoint.m_x - parentPoint.m_x) +
+ std::cos(wxDegToRad(angle)) * (swPoint.m_y - parentPoint.m_y) + parentPoint.m_y);
+}