void Board::DrawSquare (wxPaintDC &dc, int x, int y, Tetrominoes shape) { static wxColour colors[] = { wxColour (0, 0, 0), wxColour (204, 102, 102), wxColour (102, 204, 102), wxColour (102, 102, 204), wxColour (204, 204, 102), wxColour (204, 102, 204), wxColour (102, 204, 204), wxColour (218, 170, 0) }; static wxColour light[] = { wxColour (0, 0, 0), wxColour (248, 159, 171), wxColour (121, 252, 121), wxColour (121, 121, 252), wxColour (252, 252, 121), wxColour (252, 121, 252), wxColour (121, 252, 252), wxColour (252, 198, 0) }; static wxColour dark[] = { wxColour (0, 0, 0), wxColour (128, 59, 59), wxColour (59, 128, 59), wxColour (59, 59, 128), wxColour (128, 128, 59), wxColour (128, 59, 128), wxColour (59, 128, 128), wxColour (128, 98, 0) }; wxPen pen (light[int (shape)]); pen.SetCap (wxCAP_PROJECTING); dc.SetPen (pen); dc.DrawLine (x, y + SquareHeight() - 1, x, y); dc.DrawLine (x, y, x + SquareWidth() - 1, y); wxPen darkpen (dark[int (shape)]); darkpen.SetCap (wxCAP_PROJECTING); dc.SetPen (darkpen); dc.DrawLine (x + 1, y + SquareHeight() - 1, x + SquareWidth() - 1, y + SquareHeight() - 1); dc.DrawLine (x + SquareWidth() - 1, y + SquareHeight() - 1, x + SquareWidth() - 1, y + 1); dc.SetPen (*wxTRANSPARENT_PEN); dc.SetBrush (wxBrush (colors[int (shape)])); dc.DrawRectangle (x + 1, y + 1, SquareWidth() - 2, SquareHeight() - 2); }
void TimeLogChart::DrawAxis(wxPaintDC &dc) { const int MARKER_OFFSET = 5; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(m_axisBounds); dc.SetPen(wxPen(wxColour(*wxBLACK), 1, wxPENSTYLE_DOT)); int topBound = m_axisBounds.GetTop(); int leftBound = m_axisBounds.GetLeft(); int rightBound = m_axisBounds.GetRight(); int bottomBound = m_axisBounds.GetBottom(); int dx = leftBound; wxFont savedFont = dc.GetFont(); dc.SetFont(*m_valueFont); int n = m_logDuration -1; for (int i = 0; i <= n; i++) { dx = leftBound + (int)floor(i*m_axisBounds.GetWidth() / (double)n); if (i % m_logTickFrequency == 0) { dc.DrawLine(dx, topBound, dx, bottomBound); if (i % (m_logTickFrequency*2) == 0) { // draw axis marker wxString s = wxString::Format(wxT("%d secs"), (m_logDuration-i)); wxSize ext = dc.GetTextExtent(s); dc.DrawText(s, dx - ext.GetWidth()/2, bottomBound + MARKER_OFFSET); } } } dc.DrawLine(dx, topBound, dx, bottomBound); int yValue = m_maxValue; int yValueSteps = (m_minValue-m_maxValue)/m_valueDivisions; int ySteps = ValueToPixel((m_maxValue - m_minValue)/m_valueDivisions); int dy = topBound; for (int n = 0; n < m_valueDivisions; n++) { dc.DrawLine(leftBound, dy, rightBound, dy); wxString s = wxString::Format(m_valueAxisFormat, (double)yValue/m_valueAxisScale); wxSize ext = dc.GetTextExtent(s); dc.DrawText(s, m_axisBounds.GetLeft()-ext.GetWidth() - MARKER_OFFSET, dy - ext.GetHeight()/2); dy += ySteps; yValue += yValueSteps; } dc.DrawLine(leftBound, bottomBound, rightBound, bottomBound); dc.SetFont(savedFont); }
void TimeLine::DrawRectangle(wxPaintDC& dc, int x1, int y1, int x2, int y2) { const wxPen* pen_outline = wxMEDIUM_GREY_PEN; const wxPen* pen_grey = wxLIGHT_GREY_PEN; dc.SetPen(*pen_grey); for( int y = y1; y <= y2; y++ ) { dc.DrawLine(x1, y, x2, y); } dc.SetPen(*pen_outline); dc.DrawLine(x1, y1, x2, y1); dc.DrawLine(x1, y2, x2, y2); }
void THISCLASS::DrawTicks(wxPaintDC &dc, const SwisTrackCoreEventRecorder::Timeline *timeline) { wxSize dcsize = dc.GetSize(); int dw = dcsize.GetWidth(); //int dh=dcsize.GetHeight(); // Not needed dc.SetFont(GetFont()); dc.SetPen(wxPen(wxColour(0xcc, 0xcc, 0xcc))); dc.SetTextForeground(wxColour(0xcc, 0xcc, 0xcc)); // Calculate how many ticks to display double mintickdistance = 5; double mintickdistancetime = mintickdistance / mViewScale; double tickdistancetime = pow(10, ceil(log(mintickdistancetime) / log((double)10))); // Draw ticks double endtime = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(timeline->mEnd)); int ticknumber = (int)ceil(-mViewOffset / mViewScale / tickdistancetime); while (true) { double xtime = ticknumber * tickdistancetime; if (xtime >= endtime) { break; } int x = (int)floor(xtime * mViewScale + mViewOffset); if (x > dw) { break; } if (ticknumber % 10 == 0) { dc.DrawLine(x, 0, x, 4); wxString label = wxString::Format(wxT("%d"), (int)(xtime * 1000)); int textwidth, textheight; GetTextExtent(label, &textwidth, &textheight) ; textwidth >>= 1; dc.DrawText(label, x - textwidth, 2); } else {
void TimeLogChart::DrawLegends(wxPaintDC &dc) { const int LEGEND_LENGTH = 10; if (m_chartCollection == NULL && m_chartCollection->GetCount() == 0) return; dc.SetFont(*m_valueFont); wxSize ext = dc.GetTextExtent("H"); int dy = GetClientRect().GetBottom() - ext.GetHeight(); int dx = m_axisBounds.GetLeft(); for (int i = 0; i < m_chartCollection->GetCount(); i++) { ChartValueList *list = m_chartCollection->Item(i)->GetData(); dc.SetPen(wxPen(list->GetColour(), 5)); // draw legend with latest value wxString label = list->GetTitle(); if (list->GetCount() > 0) { // get the latest value double value = *list->GetLast()->GetData()/m_valueAxisScale; label += " (" + wxString::Format(m_valueAxisFormat, value) + ")"; } ext = dc.GetTextExtent(label); dc.DrawLine(dx, dy, dx + LEGEND_LENGTH, dy); dx += LEGEND_LENGTH + 5; dc.DrawText(label, dx, dy - ext.GetHeight()/2); dx += ext.GetWidth() + 20; } }
void TimeLine::DrawTriangleMarkerFacingRight(wxPaintDC& dc, int& play_start_mark, const int& tri_size, int& height) { const wxPen* pen_black = wxBLACK_PEN; const wxPen* pen_grey = wxLIGHT_GREY_PEN; int y_top = height-tri_size; int y_bottom = y_top; int arrow_end = play_start_mark - 1; dc.SetPen(*pen_grey); for( ; y_bottom < height-1; y_bottom++, y_top--, arrow_end-- ) { dc.DrawLine(arrow_end,y_top,arrow_end,y_bottom); } dc.SetPen(*pen_black); dc.DrawLine(play_start_mark,y_top,play_start_mark,height-1); dc.DrawLine(play_start_mark-1,height-tri_size,arrow_end,y_top); dc.DrawLine(play_start_mark-1,height-tri_size,arrow_end,y_bottom); dc.DrawLine(arrow_end,y_top,arrow_end,y_bottom); }
void RobotPanelLayer::render(wxPaintDC &dc, const CoordScale &drawscale) const { const float minsize = min(drawscale.sx/gridscale.sx, drawscale.sy/gridscale.sy); Pos pos = drawscale.coordToPos(robot.getPosition()); const float thickness = minsize * .3; const float dir = robot.getDirection(); wxPoint points[3]; points[0].x = (int)(pos.x + thickness*cos(dir)); points[0].y = (int)(pos.y - thickness*sin(dir)); points[1].x = (int)(pos.x + thickness*cos(dir + 5*M_PI/4)); points[1].y = (int)(pos.y - thickness*sin(dir + 5*M_PI/4)); points[2].x = (int)(pos.x + thickness*cos(dir - 5*M_PI/4)); points[2].y = (int)(pos.y - thickness*sin(dir - 5*M_PI/4)); dc.DrawPolygon(3, points); wxBrush victimbrush(wxColour(150, 200, 130)); const RoomPlanner::Plan &plan = robot.getPlan(); if (plan.identifyvictim) dc.SetBrush(victimbrush); const float radius = max(minsize*.1f, 3.0f); for (int i = 0; i != plan.coords.size(); ++i) { Pos p = drawscale.coordToPos(plan.coords[i]); float dirrad = dirToRad(plan.facedirs[i]); dc.DrawCircle(p.x, p.y, radius); const float len = minsize*0.3; const float endx = p.x+len*cos(dirrad); const float endy = p.y-len*sin(dirrad); dc.DrawLine(p.x, p.y, endx, endy); dc.DrawCircle(endx, endy, 1); } const int crossdelta = (int)(minsize*0.15f); const PosSet &victims = robot.getIdentifiedVictims(); for (PosSet::const_iterator i = victims.begin(); i != victims.end(); ++i) { Pos pos = drawscale.coordToPos(victimscale.posToCoord(*i)); dc.DrawLine(pos.x-crossdelta, pos.y-crossdelta, pos.x+crossdelta+1, pos.y+crossdelta+1); dc.DrawLine(pos.x-crossdelta, pos.y+crossdelta, pos.x+crossdelta+1, pos.y-crossdelta-1); } }
void SudokuSolverFrame::DrawBoardBackground(wxPaintDC &dc) { unsigned int spSq = 0; unsigned int smallSide; unsigned int i,j; wxColour LGray; wxBrush LGrayBr; LGray.Set(210,210,210); LGrayBr.SetColour(LGray); wxSize sz = GameBoardPanel->GetClientSize(); if (sz.x < sz.y) smallSide = sz.x; else smallSide = sz.y; spSq = smallSide / 9; smallSide -= 10; // Set the Brush and Pen to red dc.SetBrush( LGrayBr ); dc.SetPen(*wxBLACK_PEN ); // Draw rectangle 40 pixels wide and 40 high // with upper left corner at 10 , 10. for(i=0;i<9;i++) for(j=0;j<9;j++) { if(i == col && j == row) dc.SetBrush(*wxBLUE_BRUSH); else dc.SetBrush(LGrayBr); dc.DrawRectangle( 0 + spSq*i, 0 + spSq*j, spSq - 5, spSq - 5 ); } wxColor Black(0,0,0); wxPen myBlackPen(Black,5,wxSOLID); dc.SetPen(myBlackPen); // Section Borders dc.DrawLine( 0, smallSide/3 - 2, smallSide, smallSide/3 - 2); dc.DrawLine( 0, smallSide*2/3 - 1, smallSide, smallSide*2/3 - 1); dc.DrawLine( smallSide/3 - 2, 0, smallSide/3 - 2, smallSide); dc.DrawLine( smallSide*2/3 - 1, 0, smallSide*2/3 - 1, smallSide); // Edge Borders dc.DrawLine( 0, 0, smallSide, 0); dc.DrawLine( 0, 0, 0, smallSide); dc.DrawLine( 0, smallSide, smallSide, smallSide); dc.DrawLine( smallSide, 0, smallSide, smallSide); }
//----------------------------------------------------------------------------- void PlotCanvasInfoBase::OnPaintCustom( wxPaintDC& dc ) //----------------------------------------------------------------------------- { wxCoord xOffset( 1 ), w( 0 ), h( 0 ); dc.GetSize( &w, &h ); const double scaleX = GetScaleX( w ); const double scaleY = GetScaleY( h ); DrawMarkerLines( dc, w, h, scaleX ); const plot_data_type offset = GetOffset(); for( unsigned int i = 0; i < m_PlotCount; i++ ) { const unsigned int valCount = static_cast<unsigned int>( m_ppPlotValues[i]->size() ); if( valCount > 1 ) { int lowerStart = h - GetBorderWidth(); dc.SetPen( m_pens[i % COLOUR_COUNT] ); for( unsigned int j = 0; j < valCount - 1; j++ ) { dc.DrawLine( static_cast<int>( GetBorderWidth() + ( j * scaleX ) + 1 ), static_cast<int>( lowerStart - ( ( ( *m_ppPlotValues[i] )[j] - offset ) * scaleY ) ), static_cast<int>( GetBorderWidth() + ( ( j + 1 ) * scaleX ) + 1 ), static_cast<int>( lowerStart - ( ( ( *m_ppPlotValues[i] )[j + 1] - offset ) * scaleY ) ) ); } dc.SetPen( wxNullPen ); } // info in the top left corner if( m_dataType == ctPropFloat ) { DrawInfoString( dc, wxString::Format( wxT( "Range: %.3f - %.3f, %s: %s " ), m_CurrentMinPlotValues[i], m_CurrentMaxPlotValues[i], GetPlotIdentifierPrefix().c_str(), m_PlotIdentifiers[i].c_str() ), xOffset, 1, m_pens[i] ); } else { DrawInfoString( dc, wxString::Format( wxT( "Range: %lld - %lld, %s: %s " ), static_cast<int64_type>( m_CurrentMinPlotValues[i] ), static_cast<int64_type>( m_CurrentMaxPlotValues[i] ), GetPlotIdentifierPrefix().c_str(), m_PlotIdentifiers[i].c_str() ), xOffset, 1, m_pens[i] ); } } }
void CCodeView::_LineTo(wxPaintDC &dc, int x, int y) { dc.DrawLine(lx, ly, x, y); lx = x; ly = y; }
void CCodeView::LineTo(wxPaintDC &dc, int x, int y) { dc.DrawLine(m_lx, m_ly, x, y); m_lx = x; m_ly = y; }