예제 #1
0
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);
		}
	}
}
예제 #2
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);
	}
}
예제 #3
0
void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
    wxLogNull noLog; //We take care of errors.

    wxSize size = previewPanel.GetSize();

    //Checkerboard background
    dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg);
    dc.DrawRectangle(0,0, size.GetWidth(), size.GetHeight());

    wxString fullFilename = GetAbsoluteFile(project);

    if ( !wxFile::Exists(fullFilename) )
        return;

    wxBitmap bmp( fullFilename, wxBITMAP_TYPE_ANY);
    if ( bmp.GetWidth() != 0 && bmp.GetHeight() != 0 && (bmp.GetWidth() > previewPanel.GetSize().x || bmp.GetHeight() > previewPanel.GetSize().y) )
    {
        //Rescale to fit in previewPanel
        float xFactor = static_cast<float>(previewPanel.GetSize().x)/static_cast<float>(bmp.GetWidth());
        float yFactor = static_cast<float>(previewPanel.GetSize().y)/static_cast<float>(bmp.GetHeight());
        float factor = std::min(xFactor, yFactor);

        wxImage image = bmp.ConvertToImage();
        if ( bmp.GetWidth()*factor >= 5 && bmp.GetHeight()*factor >= 5)
            bmp = wxBitmap(image.Scale(bmp.GetWidth()*factor, bmp.GetHeight()*factor));
    }

    //Display image in the center
    if ( bmp.IsOk() )
        dc.DrawBitmap(bmp,
                      (size.GetWidth() - bmp.GetWidth()) / 2,
                      (size.GetHeight() - bmp.GetHeight()) / 2,
                      true /* use mask */);
}
예제 #4
0
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);
        }
    }
}
예제 #5
0
void TimeLogChart::DrawTitle(wxPaintDC &dc)
{
    wxRect titleRect = GetClientRect();
    titleRect.SetHeight(m_axisBounds.GetTop());
    titleRect.Deflate(m_axisBounds.GetLeft(), 5);
    dc.SetFont(*m_titleFont);

    dc.DrawText(m_title, titleRect.GetTopLeft());
}
예제 #6
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);
}
예제 #7
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);
}
예제 #8
0
static int DrawText(wxPaintDC& arDC, const wxString& arString, int aStartPosition, wxFont& arFont)
{
        int Width = 0;
        int Height = 0;

        if (arString.Length() > 0)
        {
                arDC.SetFont(arFont);
                arDC.GetTextExtent(arString, &Width, &Height);
                arDC.DrawText(arString, aStartPosition, 0);
        }
        
        return aStartPosition+Width;
}
예제 #9
0
void ButtonPanel::DrawButton(wxPaintDC &dc)
{
	int totalWidth=0;
	int maxHeight = m_playButton->GetSize().GetHeight();
	totalWidth+=m_playButton->GetSize().GetWidth();
	totalWidth+=m_previousButton->GetSize().GetWidth();
	totalWidth+=m_stopButton->GetSize().GetWidth();
	totalWidth+=m_nextButton->GetSize().GetWidth();
	totalWidth+=m_browseButton->GetSize().GetWidth();
	totalWidth+=m_slider->GetSize().GetWidth();
	totalWidth+=25;
	
	wxSize size = GetSize();

	// draw background
	wxBitmap bg = wxGetBitmapFromMemory(panel_background_bmp, 
			sizeof(panel_background_bmp));
	for(int x=0; x<size.GetWidth(); x+=bg.GetWidth())
		dc.DrawBitmap(bg, x, 0, true);
	
	// previous
	int x = (size.GetWidth()-totalWidth)/2;
	wxSize buttonSize = m_previousButton->GetSize();
	int y = (maxHeight-buttonSize.GetHeight())/2;
	m_previousButton->Move(wxPoint(x,y));

	// stop
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_stopButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_stopButton->Move(wxPoint(x,y));
	
	// play
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_playButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_playButton->Move(wxPoint(x,y));
	
	// next
	x = x + buttonSize.GetWidth()+5;
	buttonSize = m_nextButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_nextButton->Move(wxPoint(x,y));
	
	// browse
	x = x + buttonSize.GetWidth()+10;
	buttonSize = m_browseButton->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_browseButton->Move(wxPoint(x,y));
	
	// volume slider
	x = x + buttonSize.GetWidth()+20;
	buttonSize = m_slider->GetSize();
	y = (maxHeight-buttonSize.GetHeight())/2;
	m_slider->Move(wxPoint(x,y));
}
예제 #10
0
void gcProgressBar::doImgPaint(wxPaintDC& dc)
{
	int h = GetSize().GetHeight();
	int w = GetSize().GetWidth();
#ifdef WIN32 // unused AFAIK
	int ih = m_imgProg->GetSize().GetHeight();
#endif
	int iw = m_imgProg->GetSize().GetWidth();

	uint32 wp = w*m_uiProg/100;

	wxImage scaled = m_imgProg->Scale(iw, h);
	wxBitmap norm = GetGCThemeManager()->getSprite(scaled, "progressbar", "Norm");
	wxBitmap nedge = GetGCThemeManager()->getSprite(scaled, "progressbar", "NormEdge");
	wxBitmap empty = GetGCThemeManager()->getSprite(scaled, "progressbar", "Empty");

	wxBitmap   tmpBmp(w, h);
	wxMemoryDC tmpDC(tmpBmp);

	tmpDC.SetBrush(wxBrush(wxColor(255,0,255)));
	tmpDC.SetPen( wxPen(wxColor(255,0,255),1) );
	tmpDC.DrawRectangle(0,0,w,h);


	uint32 neWidth = nedge.GetWidth();
	wxColor c(255,0,255);

	if (wp == 0)
	{
		//dont do any thing
	}
	else if (wp <= neWidth)
	{
		wxBitmap left = nedge.ConvertToImage().GetSubImage(wxRect(neWidth-wp,0,neWidth,h));
		tmpDC.DrawBitmap(left, 0, 0, true);
	}
	else
	{
		wxBitmap left(wp-neWidth, h);
		
		gcImage::tileImg(left, norm, &c);

		tmpDC.DrawBitmap(left, 0, 0, true);
		tmpDC.DrawBitmap(nedge, wp-neWidth, 0, true);
	}

	wxBitmap right(w-wp, h);
	gcImage::tileImg(right, empty, &c);
	tmpDC.DrawBitmap(right, wp,0,true);

	tmpDC.SelectObject(wxNullBitmap);

	doExtraImgPaint(tmpBmp, w, h);

	dc.DrawBitmap(tmpBmp, 0,0, true);
}
예제 #11
0
void MyVideoCaptureWindow::DoPaint( wxPaintDC& dc )
{
    wxVideoCaptureWindowBase::DoPaint(dc);

    if (!IsDeviceConnected())
    {
        // The window is blank when disconnected so we might as well
        // give a hint to people that they need to connect first.
        wxBitmap bmp = wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32));
        wxSize clientSize(GetClientSize());

        wxString txt(wxT("Please select a capture device"));
        wxSize txtSize = dc.GetTextExtent(txt);

        dc.DrawText(txt,   clientSize.GetWidth()/2  - txtSize.GetWidth()/2,
                           clientSize.GetHeight()/2 - txtSize.GetHeight());
        dc.DrawBitmap(bmp, clientSize.GetWidth()/2  - bmp.GetWidth()/2,
                           clientSize.GetHeight()/2 + 4);
    }
}
예제 #12
0
void SliderPanel::DrawSlider(wxPaintDC &dc)
{
	wxColour color;
	color.Set(wxT("#DDE1E6"));
	dc.SetBackground(wxBrush(color));
	dc.Clear();

	wxSize size = GetSize();
	int width = size.GetWidth();
	int height = size.GetHeight();

	wxSize size2 = m_slider->GetSize();
	int width2 = size2.GetWidth();
	int height2 = size2.GetHeight();

	int x = (width-width2)/2;
	int y = (height-height2)/2;

	m_slider->Move(wxPoint(x,y));
}
예제 #13
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 {
예제 #14
0
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;
    }
}
예제 #15
0
//-----------------------------------------------------------------------------
void LineProfileCanvas::OnPaintCustom( wxPaintDC& dc )
//-----------------------------------------------------------------------------
{
    wxCoord yOffset( 1 ), w( 0 ), h( 0 );
    dc.GetSize( &w, &h );
    const double scaleX = static_cast<double>( w - 2 * GetBorderWidth() ) / static_cast<double>( ( GetDataCount() == 0 ) ? 1 : GetDataCount() - 1 );
    const double scaleY = GetScaleY( h );
    DrawMarkerLines( dc, w, h, scaleX );
    unsigned int from, to;
    GetDrawRange( &from, &to );
    const int borderWidth = GetBorderWidth();
    const wxString YMarkerString( wxString::Format( wxT( "Draw Range(absolute): %d / %d, " ), from, to ) );
    wxCoord xOffset;
    dc.GetTextExtent( YMarkerString, &xOffset, 0 );
    xOffset += borderWidth / 2;
    dc.DrawText( YMarkerString, borderWidth / 2, yOffset );
    if( m_boUnsupportedPixelFormat )
    {
        dc.SetTextForeground( *wxRED );
        dc.DrawText( wxString( wxT( "Unsupported pixel format" ) ), xOffset, yOffset );
        dc.SetTextForeground( *wxBLACK );
    }
    else if( m_ppData )
    {
        for( int channel = 0; channel < m_ChannelCount; channel++ )
        {
            DrawProfileLine( dc, h, borderWidth + 1, scaleX, scaleY, from, to, m_ppData[channel], GetDataCount(), *m_Pens[channel].pColour_ );
            DrawInfoString( dc, wxString::Format( wxT( "%s%s: " ), ( channel != 0 ) ? wxT( ", " ) : wxT( "" ), m_Pens[channel].description_.c_str() ), xOffset, yOffset, *( m_Pens[channel].pColour_ ) );
        }
    }
}
예제 #16
0
bool THISCLASS::Paint(wxPaintDC &dc) {
	// Get timeline
	const SwisTrackCoreEventRecorder::Timeline *timeline = mSwisTrack->mSwisTrackCore->mEventRecorder->GetLastTimeline();
	if (timeline == 0) {
		return false;
	}

	// Draw background
	dc.SetBackground(wxBrush(wxColour(0xff, 0xff, 0xff)));
	dc.Clear();

	// Draw
	DrawTrigger(dc, timeline);
	DrawTicks(dc, timeline);
	DrawComponentSteps(dc, timeline);
	DrawStepLapTimes(dc, timeline);
	DrawSteps(dc, timeline);
	DrawStartStop(dc, timeline);
	DrawBeginEnd(dc, timeline);
	DrawTimelineOverflow(dc, timeline);

	return true;
}
예제 #17
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] );
        }
    }
}
예제 #18
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);
}
예제 #19
0
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);
    }
}
예제 #20
0
void CMyGLCanvas_DisplayWindow3D::OnPostRenderSwapBuffers(
	double At, wxPaintDC& dc)
{
	if (m_win3D) m_win3D->internal_setRenderingFPS(At > 0 ? 1.0 / At : 1e9);

	// If we are requested to do so, grab images to disk as they are rendered:
	string grabFile;
	if (m_win3D) grabFile = m_win3D->grabImageGetNextFile();
	if (m_win3D && (!grabFile.empty() || m_win3D->isCapturingImgs()))
	{
		int w, h;
		dc.GetSize(&w, &h);

		// Save image directly from OpenGL - It could also use 4 channels and
		// save with GL_BGRA_EXT
		CImage::Ptr frame(new CImage(w, h, 3, false));
		glReadBuffer(GL_FRONT);
		glReadPixels(0, 0, w, h, GL_BGR_EXT, GL_UNSIGNED_BYTE, (*frame)(0, 0));

		if (!grabFile.empty())
		{
			frame->saveToFile(grabFile);
			m_win3D->internal_emitGrabImageEvent(grabFile);
		}

		if (m_win3D->isCapturingImgs())
		{
			{
				std::lock_guard<std::mutex> lock(
					m_win3D->m_last_captured_img_cs);
				m_win3D->m_last_captured_img = frame;
				frame.reset();
			}
		}
	}
}
void CMyGLCanvas_DisplayWindow3D::OnPostRenderSwapBuffers(double At, wxPaintDC &dc)
{
	if (m_win3D) m_win3D->internal_setRenderingFPS(At>0 ? 1.0/At : 1e9);

	// If we are requested to do so, grab images to disk as they are rendered:
	string grabFile = m_win3D->grabImageGetNextFile();
	if (m_win3D && (!grabFile.empty() || m_win3D->isCapturingImgs()) )
	{
		int w,h;
		dc.GetSize(&w, &h);

		// create a memory DC and bitmap to capture the DC
		wxMemoryDC memDC;
		wxBitmap memBmp(w, h);
		memDC.SelectObject(memBmp);
		memDC.Blit(0,0, w,h, &dc, 0,0);

		if (!grabFile.empty())
		{
			memBmp.SaveFile( _U(grabFile.c_str()) , wxBITMAP_TYPE_PNG );
			m_win3D->internal_emitGrabImageEvent(grabFile);
		}

		if (m_win3D->isCapturingImgs())
		{
			wxImage img = memBmp.ConvertToImage();
			CImagePtr pimg = mrpt::gui::wxImage2MRPTImagePtr(img);

			{
				mrpt::synch::CCriticalSectionLocker	lock(& m_win3D->m_last_captured_img_cs );
				m_win3D->m_last_captured_img = pimg;
				pimg.clear_unique();
			}
		}
	}
}
예제 #22
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);
}
예제 #23
0
void CCodeView::LineTo(wxPaintDC &dc, int x, int y)
{
	dc.DrawLine(m_lx, m_ly, x, y);
	m_lx = x;
	m_ly = y;
}
예제 #24
0
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);
}
예제 #25
0
void THISCLASS::DrawTrigger(wxPaintDC &dc, int dw, int dh, double starttime, double stoptime) {
	int startx = ((starttime < 0) ? -5 : (int)floor(starttime * mViewScale + mViewOffset + 0.5));
	int stopx = ((stoptime < 0) ? dw + 5 : (int)floor(stoptime * mViewScale + mViewOffset + 0.5));
	dc.DrawRectangle(startx, 0, stopx - startx, dh);
}
예제 #26
0
void TimeLogChart::DrawBackground(wxPaintDC &dc)
{
    dc.SetPen(*wxGREY_PEN);
    dc.SetBackground(wxBrush(wxColour(0xffffff)));
    dc.DrawRectangle(m_backgroundBounds);
}
예제 #27
0
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;
                    }

                }
            }
        }
    }

}
예제 #28
0
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);

}
예제 #29
0
void PeakMeter::OnSized( wxPaintDC& dc )
{
	m_colorBack.Set(wxT("#DDE1E6"));
	dc.SetBackground(wxBrush(m_colorBack));
	dc.Clear();

	wxRect rc = GetClientRect();

	int rw = rc.GetWidth();
	int rh = rc.GetHeight();

	// draw meter
	wxBitmap bmp = wxGetBitmapFromMemory(meter_bmp, sizeof(meter_bmp));
	int bw = bmp.GetWidth();
	int bh = bmp.GetHeight();

	m_meterBitmapX = (rw-bw)/2;
	m_meterBitmapY = (rh-bh)/2;
	dc.DrawBitmap(bmp, m_meterBitmapX, m_meterBitmapY, true);

	// draw repeat button
	int x = m_meterBitmapX+20;

	if ( m_repeatButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(repeat_all_bmp,
											  sizeof(repeat_all_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(repeat_all_hover_bmp,
											  sizeof(repeat_all_hover_bmp));
		m_repeatButton= new GButton(this, wxID_ANY,
									wxDefaultPosition, bmp1, bmp2);
		m_repeatButton->SetToolTip(wxT("Choose Repeat mode (Repeat All)"));
		Connect(m_repeatButton->GetId(), wxEVT_COMMAND_GBUTTON,
				(wxObjectEventFunction) (wxEventFunction) &PeakMeter::OnRepeat);
	}
	m_repeatButton->Move(x, m_meterBitmapY+25);

	if ( m_playModeButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(play_mode_normal_bmp,
											  sizeof(play_mode_normal_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(play_mode_normal_hover_bmp,
											  sizeof(play_mode_normal_hover_bmp));
		m_playModeButton= new GButton(this, wxID_ANY,
									  wxDefaultPosition, bmp1, bmp2);
		m_playModeButton->SetToolTip(wxT("Choose Play mode"));
	}
	m_playModeButton->Move(x, m_meterBitmapY+45);

	// draw convert button
	bmp = wxGetBitmapFromMemory(button_bmp, sizeof(button_bmp));
	int bw2 = bmp.GetWidth();
	bh = bmp.GetHeight();

	x = m_meterBitmapX-bw2-10;
	if ( m_convertButton == NULL )
	{
		wxBitmap bmp1 = wxGetBitmapFromMemory(convert_bmp,
											  sizeof(convert_bmp));
		wxBitmap bmp2 = wxGetBitmapFromMemory(convert_hover_bmp,
											  sizeof(convert_hover_bmp));
		wxBitmap bmp3 = wxGetBitmapFromMemory(convert_clicked_bmp,
											  sizeof(convert_clicked_bmp));
		m_convertButton= new GButton(this, wxID_ANY,
									 wxDefaultPosition, bmp1, bmp2, bmp3);
	}
	m_convertButton->Move(x, m_meterBitmapY+5);

	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);

	x = m_meterBitmapX+bw+10;
	dc.DrawBitmap(bmp, x, m_meterBitmapY+5, true);
	dc.DrawBitmap(bmp, x, m_meterBitmapY+40, true);
}
예제 #30
0
void CCodeView::_LineTo(wxPaintDC &dc, int x, int y)
{
	dc.DrawLine(lx, ly, x, y);
	lx = x;
	ly = y;
}