diff options
author | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-06-02 21:47:06 -0300 |
---|---|---|
committer | Thales Lima Oliveira <thaleslima.ufu@gmail.com> | 2020-06-02 21:47:06 -0300 |
commit | 113a35d0fe8938973fa1c100b77f456ed250e61b (patch) | |
tree | 586d1c3113082cbb2b92cd46c3c96a25a0e75e67 /Project/Load.cpp | |
parent | 6ce2bdcf85dffee6b6ef7b95b888b8b96372a3d6 (diff) | |
download | PSP.git-113a35d0fe8938973fa1c100b77f456ed250e61b.tar.gz PSP.git-113a35d0fe8938973fa1c100b77f456ed250e61b.tar.xz PSP.git-113a35d0fe8938973fa1c100b77f456ed250e61b.zip |
OpenGL bugfixes and wxGC port alternative init
OpenGL major bugfixes;
Device context port alternative to OpenGL code init (WorkspaceDC). Some machines don't support OpenGL 3+;
Fixed some issues with MSVC.
Diffstat (limited to 'Project/Load.cpp')
-rw-r--r-- | Project/Load.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Project/Load.cpp b/Project/Load.cpp index d9f1b2a..22c9cd9 100644 --- a/Project/Load.cpp +++ b/Project/Load.cpp @@ -116,6 +116,75 @@ void Load::Draw(wxPoint2DDouble translation, double scale) const } } +void Load::DrawDC(wxPoint2DDouble translation, double scale, wxGraphicsContext* gc) const +{ + OpenGLColour elementColour; + if (m_online) { + if (m_dynEvent) + elementColour = m_dynamicEventColour; + else + elementColour = m_onlineElementColour; + } + else + elementColour = m_offlineElementColour; + + if (m_inserted) { + // Draw Selection (layer 1). + if (m_selected) { + gc->SetPen(wxPen(wxColour(m_selectionColour.GetDcRGBA()), 2 + m_borderSize * 2.0)); + gc->SetBrush(*wxTRANSPARENT_BRUSH); + + gc->DrawLines(m_pointList.size(), &m_pointList[0]); + + gc->SetPen(*wxTRANSPARENT_PEN); + gc->SetBrush(wxBrush(wxColour(m_selectionColour.GetDcRGBA()))); + + std::vector<wxPoint2DDouble> selTriangPts; + selTriangPts.push_back(m_triangPts[0] + m_position + + wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale)); + selTriangPts.push_back(m_triangPts[1] + m_position + + wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale)); + selTriangPts.push_back(m_triangPts[2] + m_position + wxPoint2DDouble(0.0, m_borderSize / scale)); + + // Push the current matrix on stack. + gc->PushState(); + // Rotate the matrix around the object position. + gc->Translate(m_position.m_x, m_position.m_y); + gc->Rotate(wxDegToRad(m_angle)); + gc->Translate(-m_position.m_x, -m_position.m_y); + DrawDCTriangle(selTriangPts, gc); + gc->PopState(); + + // Draw node selection. + DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, gc); + } + + // Draw Load (layer 2). + gc->SetPen(wxPen(wxColour(elementColour.GetDcRGBA()), 2)); + gc->SetBrush(*wxTRANSPARENT_BRUSH); + gc->DrawLines(m_pointList.size(), &m_pointList[0]); + + // Draw node. + gc->SetPen(*wxTRANSPARENT_PEN); + gc->SetBrush(wxBrush(wxColour(elementColour.GetDcRGBA()))); + DrawDCCircle(m_pointList[0], 5.0, 10, gc); + + DrawDCSwitches(gc); + DrawDCPowerFlowPts(gc); + + std::vector<wxPoint2DDouble> triangPts; + for (int i = 0; i < 3; i++) { triangPts.push_back(m_triangPts[i] + m_position); } + gc->PushState(); + gc->Translate(m_position.m_x, m_position.m_y); + gc->Rotate(wxDegToRad(m_angle)); + gc->Translate(-m_position.m_x, -m_position.m_y); + gc->SetPen(*wxTRANSPARENT_PEN); + gc->SetBrush(wxBrush(wxColour(elementColour.GetDcRGBA()))); + DrawDCTriangle(triangPts, gc); + gc->PopState(); + } +} + void Load::Rotate(bool clockwise) { double rotAngle = m_rotationAngle; |