Example #1
0
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 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);

}
Example #4
0
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);
}
Example #5
0
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 {
Example #6
0
void THISCLASS::DrawTrigger(wxPaintDC &dc, const SwisTrackCoreEventRecorder::Timeline *timeline) {
	// Prepare
	wxSize dcsize = dc.GetSize();
	int dw = dcsize.GetWidth();
	int dh = dcsize.GetHeight();
	dc.SetBrush(wxBrush(wxColour(0xee, 0xee, 0xee)));
	dc.SetPen(wxPen(wxColour(0xee, 0xee, 0xee)));

	// Draw
	double starttime = -1;
	bool active = timeline->mBeginState.mTriggerActive;
	SwisTrackCoreEventRecorder::Timeline::tEventList::const_iterator it = timeline->mEvents.begin();
	while (it != timeline->mEvents.end()) {
		if (it->mType == SwisTrackCoreEventRecorder::sType_BeforeTriggerStart) {
			starttime = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(*it));;
			active = true;
		} else if (it->mType == SwisTrackCoreEventRecorder::sType_AfterTriggerStop) {
			double time = mSwisTrack->mSwisTrackCore->mEventRecorder->CalculateDuration(&(timeline->mBegin), &(*it));
			DrawTrigger(dc, dw, dh, starttime, time);
			starttime = time;
			active = false;
		}

		it++;
	}

	// Draw last event
	if (active) {
		DrawTrigger(dc, dw, dh, starttime, -1);
	}
}
void LaserPanelLayer::render(wxPaintDC &dc, const CoordScale &drawscale) const {
	static wxPen pens[] = {
		wxPen(*wxBLUE),
		wxPen(*wxGREEN),
		wxPen(*wxRED)
	};

	static wxBrush brushes[] = {
		wxBrush(*wxBLUE),
		wxBrush(*wxGREEN),
		wxBrush(*wxRED)
	};

	for (int laser=0; laser < readings.size(); laser++) {
		const LaserSensor::DistAngleVec &distangles = readings[laser];
		for (LaserSensor::DistAngleVec::const_iterator i = distangles.begin(); i != distangles.end(); ++i) {
			Coord coord = i->toCoord(M_PI/2);

			Pos pos = drawscale.coordToPos(coord.x + 50, 100 - coord.y);

			int num = min(laser, 3);
			dc.SetPen(pens[num]);
			dc.SetBrush(brushes[num]);
			dc.DrawCircle(pos.x, pos.y, 1);
		}
	}
}
void TimeLogChart::DrawCharts(wxPaintDC &dc)
{
    if (m_chartCollection == NULL && m_chartCollection->GetCount() == 0)
        return;

    for (int i = 0; i < m_chartCollection->GetCount(); i++)
    {
        ChartValueList *list =  m_chartCollection->Item(i)->GetData();
        int nValues = list->GetCount();
        if (nValues > 1)
        {
            ChartValueList::reverse_iterator iter;
            dc.SetPen(wxPen(list->GetColour()));

            int dx = m_axisBounds.GetRight();
            wxPoint points[nValues];
            int n = 0;

            for (iter = list->rbegin(); iter != list->rend(); ++iter)
            {
                dx = m_axisBounds.GetRight() - (int)floor(n*m_axisBounds.GetWidth() / (double)(m_logDuration-1));
                double *v = *iter;
                int yValue = ValueToPixel(*v);
                points[n] = wxPoint(dx, m_axisBounds.GetBottom()-yValue);
                n++;
            }

            dc.DrawSpline(list->GetCount(), points);
        }
    }
}
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;
    }
}
Example #10
0
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);
}
Example #11
0
void gcProgressBar::doHandPaint(wxPaintDC& dc)
{
	wxSize size = GetSize();
	uint32 w = size.GetWidth();
	uint32 h = size.GetHeight()-2;

	uint32 wp = w*m_uiProg/100;

	wxColour green(0, 255, 0);
	wxColour white(255, 255, 255);
	wxColour black(0, 0, 0);

	dc.SetPen(wxPen(green,1)); 
	dc.SetBrush(wxBrush(green));
	dc.DrawRectangle(0,0, wp, h);

	dc.SetPen(wxPen(white,1)); 
	dc.SetBrush(wxBrush(white));
	dc.DrawRectangle(wp,0, w, h);
}
Example #12
0
//-----------------------------------------------------------------------------
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 SudokuSolverFrame::DrawBoardNumbers(wxPaintDC &dc)
{
	unsigned int spSq = 0;
    unsigned int smallSide;
    unsigned int i,j,k, pVal;
    wxString debugString;
    wxString pString;
    wxColour redC, greenC, blackC;

    redC.Set(200,0,0);
    greenC.Set(0,200,0);
    blackC.Set(0,0,0);

    wxSize sz = GameBoardPanel->GetClientSize();
    if (sz.x < sz.y)
        smallSide = sz.x;
    else
        smallSide = sz.y;

    spSq = smallSide / 9;
    smallSide -= 10;

        // Create a 16 point, serif font, that is not bold,
    //   not italic, and not underlined.
    dc.SetPen(*wxBLACK_PEN );
    wxFont BigFont(spSq/2,wxFONTFAMILY_ROMAN,wxNORMAL,wxNORMAL,false);
    wxFont SmallFont(spSq/8,wxFONTFAMILY_ROMAN,wxNORMAL,wxNORMAL,false);

    // Tell dc to use this font
    dc.SetFont(BigFont);

    for(i=0;i < 9;i++)
    {
        for(j=0;j<9;j++)
        {
            if (mGuessGB->GetVal(i, j) != 0) // Show if there's a value
            {
                dc.SetFont(BigFont);
                debugString.clear();
                debugString << _("i = ") << i << _(" j = ") << j;
                debugString << _("\nVal = ") << mGuessGB->GetVal(i, j);
                //wxMessageBox(debugString);

                pVal = 0;
                pVal = mGuessGB->GetVal(i, j);
                if(mGuessGB->GetShown(i, j))
                    dc.SetTextForeground(blackC);
                else if(mGuessGB->GetVal(i, j) == mMainGB->GetVal(i, j))
                    dc.SetTextForeground(greenC);
                else
                    dc.SetTextForeground(redC);


                pString.clear();
                pString << pVal;
                dc.DrawText(pString, 6 * spSq / 20 + ((j) * spSq), spSq / 6 + ((i) * spSq));
            }
            else // Draw all possibles
            {
                for(k=1;k<=9;k++)
                {
                    dc.SetFont(SmallFont);
                    pString.clear();
                    pString << k;
                    if(mGuessGB->GetPossibles(i, j, k))
                    switch (k)
                    {
                        case 1:
                            dc.DrawText(pString, spSq*j + spSq/12, spSq*i + spSq/12);
                            break;
                        case 2:
                            dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq/12);
                            break;
                        case 3:
                            dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq/12);
                            break;
                        case 4:
                            dc.DrawText(pString, spSq*j + spSq/12, spSq*i + spSq*9/24);
                            break;
                        case 5:
                            dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq*9/24);
                            break;
                        case 6:
                            dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq*9/24);
                            break;
                        case 7:
                            dc.DrawText(pString, spSq*j + spSq*1/12, spSq*i + spSq*8/12);
                            break;
                        case 8:
                            dc.DrawText(pString, spSq*j + spSq*5/12, spSq*i + spSq*8/12);
                            break;
                        case 9:
                            dc.DrawText(pString, spSq*j + spSq*9/12, spSq*i + spSq*8/12);
                            break;
                        default:
                            break;
                    }

                }
            }
        }
    }

}
void TimeLogChart::DrawBackground(wxPaintDC &dc)
{
    dc.SetPen(*wxGREY_PEN);
    dc.SetBackground(wxBrush(wxColour(0xffffff)));
    dc.DrawRectangle(m_backgroundBounds);
}