diff options
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; |