Example #1
0
// Draw the stone type of colour in cell (x, y) using the provided device context
void SimpleGoPanel::DrawStone(wxDC& dc, int x, int y, int colour)
{	if(colour==EMPTY)
	{	dc.SetBrush(*wxWHITE_BRUSH);
		dc.SetPen(*wxWHITE_PEN);
		dc.DrawRectangle(16*x-8, 16*y-8, 8, 8);
		dc.DrawRectangle(16*x-8, 16*y+1, 8, 7);
		dc.DrawRectangle(16*x+1, 16*y-8, 7, 8);
		dc.DrawRectangle(16*x+1, 16*y+1, 7, 7);
		if(x==1)
			dc.DrawLine(16*x-8, 16*y, 16*x, 16*y);
		else if(x==boardsize)
			dc.DrawLine(16*x+1, 16*y, 16*x+8, 16*y);
		if(y==1)
			dc.DrawLine(16*x, 16*y-8, 16*x, 16*y);
		else if(y==boardsize)
			dc.DrawLine(16*x, 16*y+1, 16*x, 16*y+8);
		dc.SetPen(*wxBLACK_PEN);
		dc.DrawLine(16*x-(x>1?8:0),16*y,16*x+(x<boardsize?8:1),16*y);
		dc.DrawLine(16*x,16*y-(y>1?8:0),16*x,16*y+(y<boardsize?8:1));
		dc.SetBrush(*wxBLACK_BRUSH);
		if((boardsize==7&&(x==3||x==boardsize-2)&&(y==3||y==boardsize-2))
			||(boardsize>7&&boardsize<13&&(x==3||x==boardsize-2||2*x==boardsize+1)&&(y==3||y==boardsize-2||2*y==boardsize+1))
			||(boardsize>=13&&(x==4||x==boardsize-3||2*x==boardsize+1)&&(y==4||y==boardsize-3||2*y==boardsize+1)))
			dc.DrawRectangle(16*x-1, 16*y-1, 3, 3);
	}
	else if(colour==BLACK)
	{	dc.SetPen(*wxBLACK_PEN);
		dc.DrawLine(16*x-(x>1?8:0),16*y,16*x+(x<boardsize?8:0),16*y);
		dc.DrawLine(16*x,16*y-(y>1?8:1),16*x,16*y+(y<boardsize?8:1));
		dc.SetBrush(*wxBLACK_BRUSH);
		dc.DrawCircle(wxPoint(16*x,16*y), 7);
	}
	else if(colour==WHITE)
	{	dc.SetBrush(*wxWHITE_BRUSH);
		dc.SetPen(*wxBLACK_PEN);
		dc.DrawLine(16*x-(x>1?8:0),16*y,16*x-(x>1?7:0),16*y);
		dc.DrawLine(16*x,16*y-(y>1?8:0),16*x,16*y-(y>1?7:0));
		dc.DrawCircle(wxPoint(16*x,16*y), 7);
	}
	else if(colour==AREA(BLACK))
	{	dc.SetPen(*wxBLACK_PEN);
		dc.SetBrush(*wxBLACK_BRUSH);
		dc.DrawCircle(wxPoint(16*x,16*y), 3);
	}
	else if(colour==AREA(WHITE))
	{	dc.SetBrush(*wxWHITE_BRUSH);
		dc.SetPen(*wxBLACK_PEN);
		dc.DrawCircle(wxPoint(16*x,16*y), 3);
	}
}
Example #2
0
    void BenchmarkCircles(const wxString& msg, wxDC& dc)
    {
        if ( !opts.testCircles )
            return;

        if ( opts.mapMode != 0 )
            dc.SetMapMode((wxMappingMode)opts.mapMode);
        if ( opts.penWidth != 0 )
            dc.SetPen(wxPen(*wxWHITE, opts.penWidth));

        dc.SetBrush( *wxGREEN_BRUSH );

        wxPrintf("Benchmarking %s: ", msg);
        fflush(stdout);

        wxStopWatch sw;
        for ( long n = 0; n < opts.numIters; n++ )
        {
            int x = rand() % opts.width,
                y = rand() % opts.height;

            dc.DrawCircle(x, y, 32);
        }

        const long t = sw.Time();

        wxPrintf("%ld circles done in %ldms = %gus/circle\n",
                 opts.numIters, t, (1000. * t)/opts.numIters);
    }
void CWKSP_Shapes::_Edit_Shape_Draw_Point(wxDC &dc, int x, int y, bool bSelected)
{
	dc.SetPen  (wxPen(m_Edit_Color));
	dc.SetBrush(*wxTRANSPARENT_BRUSH);

	dc.DrawCircle(x, y, 2);

	Draw_Edge(dc, EDGE_STYLE_SIMPLE,
		x - EDIT_TICKMARK_SIZE - 1,
		y - EDIT_TICKMARK_SIZE - 1,
		x + EDIT_TICKMARK_SIZE,
		y + EDIT_TICKMARK_SIZE
	);

	if( bSelected )
	{
		dc.SetPen(*wxRED_PEN);

		Draw_Edge(dc, EDGE_STYLE_SIMPLE,
			x - EDIT_TICKMARK_SIZE - 2,
			y - EDIT_TICKMARK_SIZE - 2,
			x + EDIT_TICKMARK_SIZE + 1,
			y + EDIT_TICKMARK_SIZE + 1
		);
	}
}
void Plotter::draw_plot(wxDC& dc){
	int x_cur;
	std::vector<double>* V;
	for(int i=0;i< (int)values.size(); i++){
		V = values.at(i);
		dc.SetBrush(*this->colors.at( i % (int)this->colors.size() ));
		wxPen pen(*this->colors.at( i % (int)this->colors.size() ));
		pen.SetWidth(this->pen_width);
		if(i>=(int)this->colors.size())
			pen.SetStyle(wxLONG_DASH);
		dc.SetPen(pen);
		x_cur = this->margin_x;
		if( (int)V->size()==1){
			// special case of only one sample; next block assumes at least two samples.
			wxCoord y = this->y_orig - (V->at(0) * this->scale_v);
			if(this->min_y < 0 ){
				int offset = (int)floor(this->min_y) - 1;
				y += (offset * this->scale_v );
			}
			if( V->at(0)!=NA_VALUE )
				dc.DrawCircle(x_cur, y, 2);
		}
		else{
			for(int j=0; j<(int)V->size()-1; j++){
				wxCoord y1 = this->y_orig - (V->at(j) * this->scale_v);
				wxCoord y2 = this->y_orig - (V->at(j+1) * this->scale_v);
				if(this->min_y < 0 ){
					int offset = (int)this->min_y - 1;
					y1 += (offset * this->scale_v );
					y2 += (offset * this->scale_v );
				}
				wxCoord x1 = x_cur;
				wxCoord x2 = x1 + this->scale_h;
				if( this->draw_lines_on_plot ){
					if( V->at(j)!=NA_VALUE && V->at(j+1)!= NA_VALUE)
						dc.DrawLine(x1, y1, x2, y2);
				}
				if( V->at(j)!=NA_VALUE )
					dc.DrawCircle(x1, y1, 2);
				if( V->at(j+1)!=NA_VALUE )
					dc.DrawCircle(x2, y2, 2);
				x_cur += this->scale_h;
			}
		}
	}
}
void BasicDrawPane::renderTrue(wxDC& dc)
{
	dc.Clear();
	// draw a circle
	if (menu->number != 0)
	{
	dc.SetBrush(*wxGREEN_BRUSH); // green filling
    dc.SetPen( wxPen( wxColor(255,0,0), 3 ) ); // 5-pixels-thick red outline
    dc.DrawCircle( wxPoint(menu->pArray[0].x, menu->pArray[0].y), 10 /* radius */ );

	dc.SetBrush(*wxBLUE_BRUSH);
	dc.SetPen( wxPen( wxColor(255,255,0), 3 ) );
	for (int i = 1; i < menu->number; i++)
	{
		dc.DrawCircle( wxPoint(menu->pArray[i].x,menu->pArray[i].y), 5 /* radius */ );
	}
	}
}
Example #6
0
void CurvePane::render(wxDC&  dc)
{
	double px = 0.0;
	double py = 0.0;
	double x=0, y=0;
	dc.Clear();
	int w, h;
	dc.GetSize(&w, &h);
	int m=10;
	int radius;
	wxConfigBase::Get()->Read("tool.curve.controlpointradius",&radius,5);
	
	//x axis:
	dc.DrawLine(m,h-m,m,h-m-255);
	//y axis:
	dc.DrawLine(m,h-m,m+255,h-m);

	//center lines:
	dc.SetPen(*wxLIGHT_GREY_PEN);
	dc.DrawLine(m+128,h-m,m+128,h-m-255);
	dc.DrawLine(m,h-m-128,m+255,h-m-128);
	//null curve:
	dc.DrawLine(m,h-m,m+255,h-m-255);
	//quarter lines:
	dc.SetPen(wxPen(wxColour(192,192,192), 1, wxPENSTYLE_DOT_DASH ));
	dc.DrawLine(m+64,h-m,m+64,h-m-255);
	dc.DrawLine(m,h-m-64,m+255,h-m-64);
	dc.DrawLine(m+192,h-m,m+192,h-m-255);
	dc.DrawLine(m,h-m-192,m+255,h-m-192);
	dc.SetPen(*wxBLACK_PEN);

	//double ax = ((double) w/x);
	//double ay = ((double) h/y)*z;


	for (double x=0.0; x<256.0; x++) {
		y=c.getpoint(x);
		if (y>255.0) y = 255.0; if (y<0.0) y=0.0;
		dc.DrawLine(m+px,h-m-py,m+x,h-m-y);
		px = x;
		py = y;
	}

	//if (mousemotion)dc.DrawCircle(pos,5);
	std::vector<cp> controlpts = c.getControlPoints();
	for (unsigned int i=0; i<controlpts.size(); i++) {
		if ((controlpts[i].x == selectedCP.x) & (controlpts[i].y == selectedCP.y)) {
			//dc.DrawText(wxString::Format("%d,%d",selectedCP.x,selectedCP.y),selectedCP.x-20,selectedCP.y-20);
			dc.SetPen(*wxRED_PEN);
		}
		dc.DrawCircle(m+controlpts[i].x,h-m-controlpts[i].y,radius);
		dc.SetPen(*wxBLACK_PEN);
	}
}
Example #7
0
void wxSFCircleShape::DrawHover(wxDC& dc)
{
	// HINT: overload it for custom actions...

	wxRealPoint pos = GetAbsolutePosition();

	dc.SetPen(wxPen(m_nHoverColor, 1));
	dc.SetBrush(m_Fill);
	dc.DrawCircle(int(pos.x + m_nRectSize.x/2), int(pos.y + m_nRectSize.y/2), int(m_nRectSize.x/2));
	dc.SetBrush(wxNullBrush);
	dc.SetPen(wxNullPen);
}
Example #8
0
void wxSFConnectionPoint::DrawHover(wxDC& dc)
{
    // HINT: overload it for custom actions...

    dc.SetPen( *wxBLACK_PEN );
    dc.SetBrush( *wxRED_BRUSH );

    dc.DrawCircle( Conv2Point( GetConnectionPoint() ), RADIUS );

    dc.SetBrush( wxNullBrush );
    dc.SetPen( wxNullPen );
}
void kwxAngularRegulator::DrawKnob(wxDC &temp_dc)
{
	double x, y ;

	x = (m_nClientHeight / 2) - m_dxi ;
	y = (m_nClientHeight / 2) - m_dyi ;


	temp_dc.SetPen(*wxThePenList->FindOrCreatePen(m_cKnobBorderColour, 1, wxSOLID));
	temp_dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cKnobColour,wxSOLID));

	temp_dc.DrawCircle(x, y, 5) ;
}
//---------------------------------------------------------
void CVIEW_ScatterPlot::_Draw_Points(wxDC &dc, wxRect r)
{
	double	dx	= (r.GetWidth () - 1.) / m_Trend.Get_Data_XStats().Get_Range();
	double	dy	= (r.GetHeight() - 1.) / m_Trend.Get_Data_YStats().Get_Range();

	for(int i=0; i<m_Trend.Get_Data_Count(); i++)
	{
		dc.DrawCircle(
			GET_DC_X(m_Trend.Get_Data_X(i)),
			GET_DC_Y(m_Trend.Get_Data_Y(i)), 2
		);
	}
}
Example #11
0
void wxSFCircleShape::DrawShadow(wxDC& dc)
{
	// HINT: overload it for custom actions...

    if( m_Fill.GetStyle() != wxTRANSPARENT )
    {
        wxRealPoint pos = GetAbsolutePosition();

        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.SetBrush(GetParentCanvas()->GetShadowFill());
        dc.DrawCircle(int(pos.x + m_nRectSize.x/2 + GetParentCanvas()->GetShadowOffset().x), int(pos.y + m_nRectSize.y/2 + GetParentCanvas()->GetShadowOffset().y), int(m_nRectSize.x/2));
        dc.SetBrush(wxNullBrush);
        dc.SetPen(wxNullPen);
    }
}
Example #12
0
void BasicDrawPanel::Paint(wxDC &dc)
{
	dc.SetPen( wxPen( wxColor(255,0,0), 3 ) );
	switch(mMeassure)
	{
		case M_DIFF:
			dc.SetPen( wxPen( wxColor(255,0,0), 3 ) );
			dc.DrawLine( mapx(mMStartX), mapy(mMStartY), mapx(mMEndX), mapy(mMEndY));
			break;
		case M_POINT:
			dc.DrawCircle(mapx(mMStartX), mapy(mMStartY),3);
			break;
		default:
			break;
	}
}
Example #13
0
void PCPNewCanvas::PaintControls(wxDC& dc)
{
	if (!show_pcp_control) return;
	// draw control line
	wxPen pen(*wxBLUE_PEN);
	pen.SetWidth(2);
	dc.SetPen(pen);
	dc.SetBrush(*wxWHITE_BRUSH);
	wxPoint cpt = control_circs[control_line_sel]->center;
	cpt.x += control_circs[control_line_sel]->getXNudge();
	cpt.y = sel2.y;
	int x_end = control_lines[control_line_sel]->points[1].x;
	
	dc.DrawLine(cpt.x, cpt.y, x_end, cpt.y);
	dc.DrawCircle(cpt, control_circs[control_line_sel]->radius);
}
void PreviewWindow::DrawTrajectory(wxDC& dc)
{
	Point previous;
	dc.SetPen(wxPen(trajectoryColour, lineWidth*2, wxSOLID));
	for_each(trajectory.begin(), trajectory.end(), [&](Point& p)
	{
		Point start = TransformPoint(previous);
		Point end = TransformPoint(p);
		if(drawTrajectory)
			dc.DrawLine(start.x, start.y, end.x, end.y);
		previous = p;
	});
	dc.SetPen(wxPen(trajectoryColour, lineWidth, wxSOLID));
	dc.SetBrush(*wxRED_BRUSH);
	previous = TransformPoint(previous);
	dc.DrawCircle(previous.x, previous.y, 4);
}
Example #15
0
//---------------------------------------------------------
inline void CWKSP_Layer_Legend::_Draw_Box(wxDC &dc, int y, int dy, wxColour Color)
{
	wxPen	Pen;
	wxBrush	Brush;

	//-----------------------------------------------------
	_Set_Size(0, dy);

	dy	-= BOX_SPACE;

	//-----------------------------------------------------
	if( m_Box_bOutline == false )
	{
		Pen		= dc.GetPen();
		Pen.SetColour(Color);
		dc.SetPen(Pen);
	}

	if( m_Box_bFill )
	{
		Brush	= dc.GetBrush();
		Brush.SetColour(Color);
		dc.SetBrush(Brush);
	}

	//-----------------------------------------------------
	switch( m_BoxStyle )
	{
	case BOXSTYLE_LINE:
		dc.DrawLine(m_xBox                  , y + dy / 2, m_xBox +     m_dxBox / 4, y);
		dc.DrawLine(m_xBox +     m_dxBox / 4, y         , m_xBox + 3 * m_dxBox / 4, y + dy);
		dc.DrawLine(m_xBox + 3 * m_dxBox / 4, y + dy    , m_xBox +     m_dxBox    , y + dy / 2);
		break;

	case BOXSTYLE_CIRCLE:
		dc.DrawCircle(m_xBox + m_dxBox / 2, y + dy / 2, dy / 2);
		break;

	case BOXSTYLE_RECT:	default:
		dc.DrawRectangle(m_xBox, y, m_dxBox, dy);
		break;
	}
}
//---------------------------------------------------------
void CVIEW_ScatterPlot::_Draw_Regression(wxDC &dc, wxRect r)
{
	wxPen	oldPen	= dc.GetPen();

	dc.SetPen(wxPen(
		m_Options("REG_COLOR")->asColor(),
		m_Options("REG_SIZE" )->asInt()
	));

	//-----------------------------------------------------
	double	dx	= (r.GetWidth () - 1.) / m_Trend.Get_Data_XStats().Get_Range();
	double	dy	= (r.GetHeight() - 1.) / m_Trend.Get_Data_YStats().Get_Range();

	//-----------------------------------------------------
	dc.DrawCircle(
		GET_DC_X(m_Trend.Get_Data_XStats().Get_Mean()),
		GET_DC_Y(m_Trend.Get_Data_YStats().Get_Mean()), 2
	);

	double	ex	= m_Trend.Get_Data_XStats().Get_Range() / (double)r.GetWidth();
	double	x	= m_Trend.Get_Data_XMin();

	for(int ix=0, ay, by=0; ix<r.GetWidth(); ix++, x+=ex)
	{
		double	y	= m_Trend.Get_Value(x);

		ay	= by; by = r.GetBottom() - (int)(dy * (y - m_Trend.Get_Data_YMin()));

		if( ix > 0 && r.GetTop() < ay && ay < r.GetBottom() && r.GetTop() < by && by < r.GetBottom() )
		{
			dc.DrawLine(r.GetLeft() + ix - 1, ay, r.GetLeft() + ix, by);
		}
	}

	dc.SetPen(oldPen);

	//-----------------------------------------------------
	Draw_Text(dc, TEXTALIGN_BOTTOMCENTER, r.GetLeft() + r.GetWidth() / 2, r.GetTop(),
		m_Trend.Get_Formula(SG_TREND_STRING_Compact).c_str()
	);
}
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void BasicDrawPane::render(wxDC&  dc)
{
	cout << "heythere\n" << endl;
    // draw some text
    dc.DrawText(wxT("Testing"), 40, 60); 
    
    // draw a circle
    dc.SetBrush(*wxGREEN_BRUSH); // green filling
    dc.SetPen( wxPen( wxColor(255,0,0), 5 ) ); // 5-pixels-thick red outline
    dc.DrawCircle( wxPoint(200,100), 25 /* radius */ );
    
    // draw a rectangle
    dc.SetBrush(*wxBLUE_BRUSH); // blue filling
    dc.SetPen( wxPen( wxColor(255,175,175), 10 ) ); // 10-pixels-thick pink outline
    dc.DrawRectangle( 300, 100, 400, 200 );
    
    // draw a line
    dc.SetPen( wxPen( wxColor(0,0,0), 3 ) ); // black line, 3 pixels thick
    dc.DrawLine( 300, 100, 700, 300 ); // draw line across the rectangle
    
    // Look at the wxDC docs to learn how to draw other stuff
}
//---------------------------------------------------------
void CVariogram_Diagram::On_Draw(wxDC &dc, wxRect rDraw)
{
	if( m_pVariogram->Get_Count() > 0 )
	{
		int		i, ix, iy, jx, jy;
		double	x, dx;

		//-------------------------------------------------
		if( m_pModel->Get_Data_Count() > 0 )
		{
			ix	= Get_xToScreen(m_pModel->Get_Data_XMax());
			dc.SetPen  (wxPen(wxColour(  0, 127,   0), 2));
			dc.DrawLine(ix, Get_yToScreen(m_yMin), ix, Get_yToScreen(m_yMax));
		}

		//-------------------------------------------------
		if( m_bPairs && m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT) > 0 )
		{
			double	dScale	= m_yMax / m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT);

			dc.SetPen  (wxColour(191, 191, 191));
			dc.SetBrush(wxColour(191, 191, 191));

			for(i=0; i<m_pVariogram->Get_Count(); i++)
			{
				CSG_Table_Record	*pRecord	= m_pVariogram->Get_Record(i);

				ix	= Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE));
				iy	= Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_COUNT   ) * dScale);

				dc.DrawCircle(ix, iy, 3);
			}
		}

		//-------------------------------------------------
		dc.SetPen  (wxColour(127, 127, 127));
		dc.SetBrush(wxColour(  0,   0,   0));

		for(i=0; i<m_pVariogram->Get_Count(); i++)
		{
			CSG_Table_Record	*pRecord	= m_pVariogram->Get_Record(i);

			ix	= Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE));
			iy	= Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP ));

			dc.DrawCircle(ix, iy, 3);
		}

		//-------------------------------------------------
		if( m_pModel->is_Okay() )
		{
			dc.SetPen(wxPen(*wxRED, 2));

			dx	= (m_xMax - m_xMin) / (double)rDraw.GetWidth();

			ix	= Get_xToScreen(m_xMin);
			iy	= Get_yToScreen(m_pModel->Get_Value(m_xMin));

			for(x=m_xMin+dx; x<=m_xMax; x+=dx)
			{
				jx	= ix;
				jy	= iy;
				ix	= Get_xToScreen(x);
				iy	= Get_yToScreen(m_pModel->Get_Value(x));

				dc.DrawLine(jx, jy, ix, iy);
			}
		}
	}
}
void kwxAngularMeter::DrawNeedle(wxDC &dc) 
{
	//indicatore triangolare
	double dxi,dyi, val;
	wxPoint ppoint[6];
	int w, h ;

	GetClientSize(&w,&h);

	dc.SetPen(*wxThePenList->FindOrCreatePen(m_cNeedleColour, 1,wxSOLID));

	val = (m_nScaledVal + m_nAngleStart) * m_dPI / 180; //radianti parametro angolo

	dyi = sin(val - 90) * 2; //coordinate base sinistra
	dxi = cos(val - 90) * 2;

	ppoint[0].x = static_cast<int>((w / 2) - dxi);	//base sinistra
	ppoint[0].y = static_cast<int>((h / 2) - dyi);

	dxi = cos(val) * ((h / 2) - 4); //coordinate punta indicatore
	dyi = sin(val) * ((h / 2) - 4);

	ppoint[2].x = static_cast<int>((w / 2) - dxi);	//punta
	ppoint[2].y = static_cast<int>((h / 2) - dyi);

	dxi = cos(val + 90) * 2; //coordinate base destra
	dyi = sin(val + 90) * 2;

	ppoint[4].x = static_cast<int>((w / 2) - dxi);	//base destra
	ppoint[4].y = static_cast<int>((h / 2) - dyi);

	ppoint[5].x = ppoint[0].x;	//ritorno base sinistra
	ppoint[5].y = ppoint[0].y;

//////////////////////////
	val = (m_nScaledVal + m_nAngleStart + 1) * m_dPI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinate medio destra
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[3].x = static_cast<int>((w / 2) - dxi);	//base media destra
	ppoint[3].y = static_cast<int>((h / 2) - dyi);

	val = (m_nScaledVal + m_nAngleStart - 1) * m_dPI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinate medio sinistra
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[1].x = static_cast<int>((w / 2) - dxi);	//base media sinistra
	ppoint[1].y = static_cast<int>((h / 2) - dyi);

/////////////////////////


	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cNeedleColour,wxSOLID));

	dc.DrawPolygon(6, ppoint, 0, 0, wxODDEVEN_RULE);

	//cerchio indicatore
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxWHITE,wxSOLID));
	dc.DrawCircle(w / 2, h / 2, 4);
}
Example #20
0
void CParameter::DrawFore(wxDC& dc, wxRect& rc)
{
	m_iSamplesPerPixel = m_pTracks->GetSamplesPerPixel();

	if(m_fMax == 0.f)
		return;

	m_fScale	= (float)rc.GetHeight() / (float)(m_fMax - m_fMin);
	int start	= m_pRegion->GetStartPos();
	int end		= m_pRegion->GetEndPos();
	int offset	= m_pRegion->GetStartOffset();
	int top		= rc.GetTop();
	int bottom	= rc.GetTop() + rc.GetHeight();
	int left	= rc.GetX() + 1;
	int right	= left + rc.GetWidth() - 1;
	float value = 0.f;
	int prevX	= left;
	int prevY	= bottom;
	int pos	= m_bAfterTrack ? 0 : start;
	bool bLoaded = false;

	bool bDrawCircle = true;

	if(!m_pInput->GetParamAt(pos, m_index, &value))
	{
		pos = m_pInput->GetPrevOffset(pos);
		bDrawCircle = false;
	}
	else
		bLoaded = true;

	wxPen oldpen = dc.GetPen();
	wxColor color = m_color;
	if( IsSelected() )
		color.Set(255-color.Red(), 255-color.Green(), 255-color.Blue());
	dc.SetPen( wxPen(color) );

	do {
		if(m_pInput->GetParamAt(pos, m_index, &value))
		{
			bLoaded = true;

			int x = pos;
			int y = (int)((float)bottom - (value * m_fScale));

			if(y>top && y<bottom)
			{
				if(m_bAfterTrack && offset>=0)
					x += start - offset;

				x /= m_iSamplesPerPixel;

				if(x <= left)
					prevX = left;
				else if(x >= right)
					y = prevY;
				else
				{
					dc.DrawLine(prevX, prevY, x, prevY);	// Horizontal line
					dc.DrawLine(x, prevY, x, y);			// Vertical line

					if( bDrawCircle )
					{
						if(m_pSelectedPoint &&
							m_pSelectedPoint->m_offset==pos &&
							m_pSelectedPoint->m_value==value)
						{
							dc.DrawRectangle(x-3, y-3, 6, 6);	// Selected parameter
						}
						else
							dc.DrawCircle(x, y, 3);				// Parameter
					}

					prevX = x;
				}

				bDrawCircle = true;

				prevY = y;
			}
		}
		pos = m_pInput->GetNextOffset(pos);
	} while ( pos>0 && pos<end && prevX<right );

	if(bLoaded && prevX<right) // there have been parameters!
		dc.DrawLine(prevX, prevY, right, prevY);

	dc.SetPen(oldpen);
}
Example #21
0
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
{
    switch (g->control_group->type)
    {
    case GROUP_TYPE_TILT :
    case GROUP_TYPE_STICK :
    case GROUP_TYPE_CURSOR :
    {
        // this is starting to be a mess combining all these in one case

        double x = 0, y = 0, z = 0;

        switch (g->control_group->type)
        {
        case GROUP_TYPE_STICK :
            ((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
            break;
        case GROUP_TYPE_TILT :
            ((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
            break;
        case GROUP_TYPE_CURSOR :
            ((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
            break;
        }

        // ir cursor forward movement
        if (GROUP_TYPE_CURSOR == g->control_group->type)
        {
            if (z)
            {
                dc.SetPen(*wxRED_PEN);
                dc.SetBrush(*wxRED_BRUSH);
            }
            else
            {
                dc.SetPen(*wxGREY_PEN);
                dc.SetBrush(*wxGREY_BRUSH);
            }
            dc.DrawRectangle(0, 31 - z*31, 64, 2);
        }

        // octagon for visual aid for diagonal adjustment
        dc.SetPen(*wxLIGHT_GREY_PEN);
        dc.SetBrush(*wxWHITE_BRUSH);
        if (GROUP_TYPE_STICK == g->control_group->type)
        {
            // outline and fill colors
            wxBrush LightGrayBrush("#dddddd");
            wxPen LightGrayPen("#bfbfbf");
            dc.SetBrush(LightGrayBrush);
            dc.SetPen(LightGrayPen);

            // polygon offset
            float max
            , diagonal
            , box = 64
                    , d_of = box / 256.0
                             , x_of = box / 2.0;

            if (g->control_group->name == "Main Stick")
            {
                max = (87.0f / 127.0f) * 100;
                diagonal = (55.0f / 127.0f) * 100.0;
            }
            else if (g->control_group->name == "C-Stick")
            {
                max = (74.0f / 127.0f) * 100;
                diagonal = (46.0f / 127.0f) * 100;
            }
            else
            {
                max = (82.0f / 127.0f) * 100;
                diagonal = (58.0f / 127.0f) * 100;
            }

            // polygon corners
            wxPoint Points[8];
            Points[0].x = (int)(0.0 * d_of + x_of);
            Points[0].y = (int)(max * d_of + x_of);
            Points[1].x = (int)(diagonal * d_of + x_of);
            Points[1].y = (int)(diagonal * d_of + x_of);
            Points[2].x = (int)(max * d_of + x_of);
            Points[2].y = (int)(0.0 * d_of + x_of);
            Points[3].x = (int)(diagonal * d_of + x_of);
            Points[3].y = (int)(-diagonal * d_of + x_of);
            Points[4].x = (int)(0.0 * d_of + x_of);
            Points[4].y = (int)(-max * d_of + x_of);
            Points[5].x = (int)(-diagonal * d_of + x_of);
            Points[5].y = (int)(-diagonal * d_of + x_of);
            Points[6].x = (int)(-max * d_of + x_of);
            Points[6].y = (int)(0.0 * d_of + x_of);
            Points[7].x = (int)(-diagonal * d_of + x_of);
            Points[7].y = (int)(diagonal * d_of + x_of);

            // draw polygon
            dc.DrawPolygon(8, Points);
        }
        else
        {
            dc.DrawRectangle(16, 16, 32, 32);
        }

        if (GROUP_TYPE_CURSOR != g->control_group->type)
        {
            // deadzone circle
            dc.SetBrush(*wxLIGHT_GREY_BRUSH);
            dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
        }

        // raw dot
        {
            float xx, yy;
            xx = g->control_group->controls[3]->control_ref->State();
            xx -= g->control_group->controls[2]->control_ref->State();
            yy = g->control_group->controls[1]->control_ref->State();
            yy -= g->control_group->controls[0]->control_ref->State();

            dc.SetPen(*wxGREY_PEN);
            dc.SetBrush(*wxGREY_BRUSH);
            DrawCoordinate(dc, xx, yy);
        }

        // adjusted dot
        if (x != 0 && y != 0)
        {
            dc.SetPen(*wxRED_PEN);
            dc.SetBrush(*wxRED_BRUSH);
            // XXX: The adjusted values flip the Y axis to be in the format
            // the Wii expects. Should this be in WiimoteEmu.cpp instead?
            DrawCoordinate(dc, x, -y);
        }
    }
    break;
    case GROUP_TYPE_FORCE :
    {
        double raw_dot[3];
        double adj_dot[3];
        const float deadzone = g->control_group->settings[0]->value;

        // adjusted
        ((ControllerEmu::Force*)g->control_group)->GetState(adj_dot);

        // raw
        for (unsigned int i=0; i<3; ++i)
        {
            raw_dot[i] = (g->control_group->controls[i*2 + 1]->control_ref->State() -
                          g->control_group->controls[i*2]->control_ref->State());
        }

        // deadzone rect for forward/backward visual
        dc.SetBrush(*wxLIGHT_GREY_BRUSH);
        dc.SetPen(*wxLIGHT_GREY_PEN);
        int deadzone_height = deadzone * VIS_BITMAP_SIZE;
        DrawCenteredRectangle(dc, 0, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE, deadzone_height);

#define LINE_HEIGHT 2
        int line_y;

        // raw forward/background line
        dc.SetPen(*wxGREY_PEN);
        dc.SetBrush(*wxGREY_BRUSH);
        line_y = VIS_COORD(raw_dot[2]);
        DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);

        // adjusted forward/background line
        if (adj_dot[2] != 0.0)
        {
            dc.SetPen(*wxRED_PEN);
            dc.SetBrush(*wxRED_BRUSH);
            line_y = VIS_COORD(adj_dot[2]);
            DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);
        }

#define DEADZONE_RECT_SIZE 32

        // empty deadzone square
        dc.SetBrush(*wxWHITE_BRUSH);
        dc.SetPen(*wxLIGHT_GREY_PEN);
        DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, DEADZONE_RECT_SIZE, DEADZONE_RECT_SIZE);

        // deadzone square
        dc.SetBrush(*wxLIGHT_GREY_BRUSH);
        int dz_size = (deadzone * DEADZONE_RECT_SIZE);
        DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, dz_size, dz_size);

        // raw dot
        dc.SetPen(*wxGREY_PEN);
        dc.SetBrush(*wxGREY_BRUSH);
        DrawCoordinate(dc, raw_dot[1], raw_dot[0]);

        // adjusted dot
        if (adj_dot[1] != 0 && adj_dot[0] != 0)
        {
            dc.SetPen(*wxRED_PEN);
            dc.SetBrush(*wxRED_BRUSH);
            DrawCoordinate(dc, adj_dot[1], adj_dot[0]);
        }

    }
    break;
    case GROUP_TYPE_BUTTONS :
    {
        const unsigned int button_count = ((unsigned int)g->control_group->controls.size());

        // draw the shit
        dc.SetPen(*wxGREY_PEN);

        unsigned int * const bitmasks = new unsigned int[ button_count ];
        for (unsigned int n = 0; n<button_count; ++n)
            bitmasks[n] = (1 << n);

        unsigned int buttons = 0;
        ((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);

        for (unsigned int n = 0; n<button_count; ++n)
        {
            if (buttons & bitmasks[n])
            {
                dc.SetBrush(*wxRED_BRUSH);
            }
            else
            {
                unsigned char amt = 255 - g->control_group->controls[n]->control_ref->State() * 128;
                dc.SetBrush(wxBrush(wxColour(amt, amt, amt)));
            }
            dc.DrawRectangle(n * 12, 0, 14, 12);

            // text
            const std::string name = g->control_group->controls[n]->name;
            // bit of hax so ZL, ZR show up as L, R
            dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
        }

        delete[] bitmasks;

    }
    break;
    case GROUP_TYPE_TRIGGERS :
    {
        const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));

        // draw the shit
        dc.SetPen(*wxGREY_PEN);
        ControlState deadzone =  g->control_group->settings[0]->value;

        double* const trigs = new double[trigger_count];
        ((ControllerEmu::Triggers*)g->control_group)->GetState(trigs);

        for (unsigned int n = 0; n < trigger_count; ++n)
        {
            ControlState trig_r = g->control_group->controls[n]->control_ref->State();

            // outline
            dc.SetPen(*wxGREY_PEN);
            dc.SetBrush(*wxWHITE_BRUSH);
            dc.DrawRectangle(0, n*12, 64, 14);

            // raw
            dc.SetBrush(*wxGREY_BRUSH);
            dc.DrawRectangle(0, n*12, trig_r*64, 14);

            // deadzone affected
            dc.SetBrush(*wxRED_BRUSH);
            dc.DrawRectangle(0, n*12, trigs[n]*64, 14);

            // text
            dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
        }

        delete[] trigs;

        // deadzone box
        dc.SetPen(*wxLIGHT_GREY_PEN);
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);

    }
    break;
    case GROUP_TYPE_MIXED_TRIGGERS :
    {
        const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));

        // draw the shit
        dc.SetPen(*wxGREY_PEN);
        ControlState thresh = g->control_group->settings[0]->value;

        for (unsigned int n = 0; n < trigger_count; ++n)
        {
            dc.SetBrush(*wxRED_BRUSH);
            ControlState trig_d = g->control_group->controls[n]->control_ref->State();

            ControlState trig_a = trig_d > thresh ? 1
                                  : g->control_group->controls[n+trigger_count]->control_ref->State();

            dc.DrawRectangle(0, n*12, 64+20, 14);
            if (trig_d <= thresh)
                dc.SetBrush(*wxWHITE_BRUSH);
            dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
            dc.DrawRectangle(64, n*12, 32, 14);

            // text
            dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
            dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
        }

        // threshold box
        dc.SetPen(*wxLIGHT_GREY_PEN);
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);

    }
    break;
    case GROUP_TYPE_SLIDER:
    {
        const ControlState deadzone = g->control_group->settings[0]->value;

        ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
        dc.SetPen(*wxGREY_PEN);
        dc.SetBrush(*wxGREY_BRUSH);
        dc.DrawRectangle(31 + state * 30, 0, 2, 14);

        double adj_state;
        ((ControllerEmu::Slider*)g->control_group)->GetState(&adj_state);
        if (state)
        {
            dc.SetPen(*wxRED_PEN);
            dc.SetBrush(*wxRED_BRUSH);
            dc.DrawRectangle(31 + adj_state * 30, 0, 2, 14);
        }

        // deadzone box
        dc.SetPen(*wxLIGHT_GREY_PEN);
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
    }
    break;
    default:
        break;
    }
}
Example #22
0
void wxlCanObjCircle::DoDraw( wxDC& dc, double absx, double absy )
{
    dc.DrawCircle( m_canvas->WorldToDeviceX( absx ), m_canvas->WorldToDeviceX( absy ), m_canvas->WorldToDeviceXRel( m_r ) );
}
Example #23
0
void ChipPackage::Draw(wxDC& dc, const wxSize& sz, const wxString& chipModel)
{
    // set some GUI objects common to all packages-drawing code
    dc.SetPen(*wxBLACK_PEN);

    switch (Type)
    {
    case PDIP:
    case SOIC:
    case SSOP:
        {
            // some drawing constants:

            // in these package types, pins are organized in two columns:
            const unsigned int PinPerSide = GetPinCount()/2;
            if ((GetPinCount()%2) != 0)
            {
                wxLogWarning(_("Invalid odd pin count: %d"), GetPinCount());
                return;
            }

            // choose reasonable package width&height to
            // - make best use of the available space
            // - avoid drawing package excessively big
            const unsigned int BoxW = sz.GetWidth()/3;
            const unsigned int BoxH = (unsigned int)((double)sz.GetHeight()*0.8);
            const unsigned int BoxX = (sz.GetWidth()-BoxW)/2;
            const unsigned int BoxY = (sz.GetHeight()-BoxH)/2;
            const unsigned int R = BoxW/6;
            
            if (int(BoxW/8) == 0)
                return;     // this happens for very small package sizes;
                            // the check avoids an assertion failure from wxFont ctor later

            // draw the PIC package box
            dc.DrawRectangle(BoxX, BoxY, BoxW, BoxH);
            dc.DrawArc(sz.GetWidth()/2-R, BoxY + 1,
                       sz.GetWidth()/2+R, BoxY + 1,
                       sz.GetWidth()/2, BoxY + 1);


            dc.SetFont(wxFont(wxSize(0, BoxW/8), wxFONTFAMILY_DEFAULT,
                              wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
            const wxSize& nameSz = dc.GetTextExtent(chipModel);
            dc.DrawRotatedText(chipModel,
                               (sz.GetWidth() + nameSz.GetHeight())/2,
                               (sz.GetHeight() - nameSz.GetWidth())/2,
                               -90);

            // draw the pins
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxH, 0, PinPerSide, 
                     0, wxLEFT);
            DrawPins(dc, wxPoint(BoxX+BoxW, BoxY), BoxH, PinPerSide, GetPinCount(), 
                     DRAWPIN_INVERTED_ORDER, wxRIGHT);
        }
        break;

    case MQFP:
    case TQFP:
    case PLCC:
	case QFN:
        {
            // some drawing constants:

            // in these package types, pins are organized in two columns:
            const unsigned int PinPerSide = GetPinCount()/4;
            if ((GetPinCount()%4) != 0)
            {
                wxLogWarning(_("Invalid pin count: %d"), GetPinCount());
                return;
            }

            // choose reasonable package width&height to
            // - make best use of the available space
            // - avoid drawing package excessively big
            const unsigned int BoxL = max(sz.GetWidth()/2,80);
            const unsigned int BoxX = (sz.GetWidth()-BoxL)/2;
            const unsigned int BoxY = (sz.GetHeight()-BoxL)/2;
            const unsigned int R = BoxL/10;
            
            if (int(BoxL/10) == 0)
                return;     // this happens for very small package sizes;
                            // the check avoids an assertion failure from wxFont ctor later

            // draw the PIC package box
            dc.DrawRectangle(BoxX, BoxY, BoxL, BoxL);
            dc.DrawCircle(BoxX+int(R*1.3), BoxY+int(R*1.3), R/2);

            // draw the name of the PIC model in the centre of the box
            dc.SetFont(wxFont(wxSize(0, BoxL/10), wxFONTFAMILY_DEFAULT,
                              wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
			const wxSize& nameSz = dc.GetTextExtent(chipModel);
            dc.DrawText(chipModel,
                        (sz.GetWidth() - nameSz.GetWidth())/2,
                        (sz.GetHeight() - nameSz.GetHeight())/2);

            // draw the pins
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, 0, PinPerSide, 
                     DRAWPIN_NUMBERS_INSIDE_PINS, wxLEFT);
            DrawPins(dc, wxPoint(BoxX, BoxY+BoxL), BoxL, PinPerSide, PinPerSide*2, 
                     DRAWPIN_NUMBERS_INSIDE_PINS, wxBOTTOM);
            DrawPins(dc, wxPoint(BoxX+BoxL, BoxY), BoxL, PinPerSide*2, PinPerSide*3, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxRIGHT);
            DrawPins(dc, wxPoint(BoxX, BoxY), BoxL, PinPerSide*3, PinPerSide*4, 
                     DRAWPIN_INVERTED_ORDER|DRAWPIN_NUMBERS_INSIDE_PINS, wxTOP);
        }
        break;

    default:
        break;
    }
}
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
{
	switch (g->control_group->type)
	{
	case GROUP_TYPE_TILT :
	case GROUP_TYPE_STICK :
	case GROUP_TYPE_CURSOR :
	{
		// this is starting to be a mess combining all these in one case

		ControlState x = 0, y = 0, z = 0;

		switch (g->control_group->type)
		{
		case GROUP_TYPE_STICK :
			((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
			break;
		case GROUP_TYPE_TILT :
			((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
			break;
		case GROUP_TYPE_CURSOR :
			((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
			break;
		}

		// ir cursor forward movement
		if (GROUP_TYPE_CURSOR == g->control_group->type)
		{
			if (z)
			{
				dc.SetPen(*wxRED_PEN);
				dc.SetBrush(*wxRED_BRUSH);
			}
			else
			{
				dc.SetPen(*wxGREY_PEN);
				dc.SetBrush(*wxGREY_BRUSH);
			}
			dc.DrawRectangle(0, 31 - z*31, 64, 2);
		}

		// input zone
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxWHITE_BRUSH);
		if (GROUP_TYPE_STICK == g->control_group->type)
		{
			// outline and fill colors
			wxBrush LightGrayBrush("#dddddd");
			wxPen LightGrayPen("#bfbfbf");
			dc.SetBrush(LightGrayBrush);
			dc.SetPen(LightGrayPen);

			ShapePosition p;
			p.box = 64;
			p.offset = p.box / 2;
			p.range = 256;
			p.scale = p.box / p.range;
			p.dz = 15 * p.scale;
			bool octagon = false;

			if (g->control_group->name == "Main Stick")
			{
				p.max = 87 * p.scale;
				p.diag = 55 * p.scale;
			}
			else if (g->control_group->name == "C-Stick")
			{
				p.max = 74 * p.scale;
				p.diag = 46 * p.scale;
			}
			else
			{
				p.scale = 1;
				p.max = 32;
				octagon = true;
			}

			if (octagon)
				DrawOctagon(&dc, p);
			else
				DrawDodecagon(&dc, p);
		}
		else
		{
			dc.DrawRectangle(16, 16, 32, 32);
		}

		if (GROUP_TYPE_CURSOR != g->control_group->type)
		{
			// deadzone circle
			dc.SetBrush(*wxLIGHT_GREY_BRUSH);
			dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
		}

		// raw dot
		{
		ControlState xx, yy;
		xx = g->control_group->controls[3]->control_ref->State();
		xx -= g->control_group->controls[2]->control_ref->State();
		yy = g->control_group->controls[1]->control_ref->State();
		yy -= g->control_group->controls[0]->control_ref->State();

		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		DrawCoordinate(dc, xx, yy);
		}

		// adjusted dot
		if (x != 0 || y != 0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			// XXX: The adjusted values flip the Y axis to be in the format
			// the Wii expects. Should this be in WiimoteEmu.cpp instead?
			DrawCoordinate(dc, x, -y);
		}
	}
	break;
	case GROUP_TYPE_FORCE :
	{
		ControlState raw_dot[3];
		ControlState adj_dot[3];
		const ControlState deadzone = g->control_group->settings[0]->value;

		// adjusted
		((ControllerEmu::Force*)g->control_group)->GetState(adj_dot);

		// raw
		for (unsigned int i=0; i<3; ++i)
		{
			raw_dot[i] = (g->control_group->controls[i*2 + 1]->control_ref->State() -
				      g->control_group->controls[i*2]->control_ref->State());
		}

		// deadzone rect for forward/backward visual
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		dc.SetPen(*wxLIGHT_GREY_PEN);
		int deadzone_height = deadzone * VIS_BITMAP_SIZE;
		DrawCenteredRectangle(dc, 0, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE, deadzone_height);

#define LINE_HEIGHT 2
		int line_y;

		// raw forward/background line
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		line_y = VIS_COORD(raw_dot[2]);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);

		// adjusted forward/background line
		if (adj_dot[2] != 0.0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			line_y = VIS_COORD(adj_dot[2]);
			DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);
		}

#define DEADZONE_RECT_SIZE 32

		// empty deadzone square
		dc.SetBrush(*wxWHITE_BRUSH);
		dc.SetPen(*wxLIGHT_GREY_PEN);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, DEADZONE_RECT_SIZE, DEADZONE_RECT_SIZE);

		// deadzone square
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		int dz_size = (deadzone * DEADZONE_RECT_SIZE);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, dz_size, dz_size);

		// raw dot
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		DrawCoordinate(dc, raw_dot[1], raw_dot[0]);

		// adjusted dot
		if (adj_dot[1] != 0 && adj_dot[0] != 0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			DrawCoordinate(dc, adj_dot[1], adj_dot[0]);
		}

	}
	break;
	case GROUP_TYPE_BUTTONS :
	{
		unsigned int button_count = ((unsigned int)g->control_group->controls.size());

		// draw the shit
		dc.SetPen(*wxGREY_PEN);

		unsigned int* const bitmasks = new unsigned int[button_count];
		for (unsigned int n = 0; n<button_count; ++n)
			bitmasks[n] = (1 << n);

		unsigned int buttons = 0;
		((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);

		// Draw buttons in rows of 8
		for (unsigned int row = 0; row < ceil((float)button_count / 8.0f); row++)
		{
			unsigned int buttons_to_draw = 8;
			if ((button_count - row * 8) <= 8)
				buttons_to_draw = button_count - row * 8;

			for (unsigned int n = 0; n < buttons_to_draw; ++n)
			{
				DrawButton(bitmasks, buttons, n, dc, g, row);
			}
		}

		delete[] bitmasks;

	}
	break;
	case GROUP_TYPE_TRIGGERS :
	{
		const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));

		// draw the shit
		dc.SetPen(*wxGREY_PEN);
		ControlState deadzone =  g->control_group->settings[0]->value;

		ControlState* const trigs = new ControlState[trigger_count];
		((ControllerEmu::Triggers*)g->control_group)->GetState(trigs);

		for (unsigned int n = 0; n < trigger_count; ++n)
		{
			ControlState trig_r = g->control_group->controls[n]->control_ref->State();

			// outline
			dc.SetPen(*wxGREY_PEN);
			dc.SetBrush(*wxWHITE_BRUSH);
			dc.DrawRectangle(0, n*12, 64, 14);

			// raw
			dc.SetBrush(*wxGREY_BRUSH);
			dc.DrawRectangle(0, n*12, trig_r*64, 14);

			// deadzone affected
			dc.SetBrush(*wxRED_BRUSH);
			dc.DrawRectangle(0, n*12, trigs[n]*64, 14);

			// text
			dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
		}

		delete[] trigs;

		// deadzone box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);

	}
	break;
	case GROUP_TYPE_MIXED_TRIGGERS :
	{
		const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));

		// draw the shit
		dc.SetPen(*wxGREY_PEN);
		ControlState thresh = g->control_group->settings[0]->value;

		for (unsigned int n = 0; n < trigger_count; ++n)
		{
			dc.SetBrush(*wxRED_BRUSH);
			ControlState trig_d = g->control_group->controls[n]->control_ref->State();

			ControlState trig_a = trig_d > thresh ? 1
				: g->control_group->controls[n+trigger_count]->control_ref->State();

			dc.DrawRectangle(0, n*12, 64+20, 14);
			if (trig_d <= thresh)
				dc.SetBrush(*wxWHITE_BRUSH);
			dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
			dc.DrawRectangle(64, n*12, 32, 14);

			// text
			dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
			dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
		}

		// threshold box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);

	}
	break;
	case GROUP_TYPE_SLIDER:
	{
		const ControlState deadzone = g->control_group->settings[0]->value;

		ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		dc.DrawRectangle(31 + state * 30, 0, 2, 14);

		ControlState adj_state;
		((ControllerEmu::Slider*)g->control_group)->GetState(&adj_state);
		if (state)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			dc.DrawRectangle(31 + adj_state * 30, 0, 2, 14);
		}

		// deadzone box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
	}
	break;
	default:
	break;
	}
}
Example #25
0
void BasicDrawPane::render(wxDC&  dc)
{
  if(!drawMatrix)
  {
    dc.DrawBitmap(bmp, 0, 0, false);

    double scale = (double)windowSize / (double)maxXY;
    int r = 6;
    int cx = scale*boatX-r/2;
    int cy = windowSize-(scale*boatY);

    // draw a circle
    dc.SetBrush(*wxYELLOW_BRUSH); // green filling
    dc.SetPen( wxPen( wxColor(255,255,0), 6 ) ); // 5-pixels-thick red outline
    dc.DrawCircle( wxPoint(cx,cy), 5 /* radius */ );

    dc.DrawLine(cx+(6*sin(boatHeading)),cy+(6*cos(boatHeading)),cx+(10*cos(boatHeading)),cy-(10*sin(boatHeading)));
    dc.DrawLine(cx-(6*sin(boatHeading)),cy-(6*cos(boatHeading)),cx+(10*cos(boatHeading)),cy-(10*sin(boatHeading)));
  }
  if(drawMatrix)
  {
    double dx = windowSize/nx;
    double dy = windowSize/ny;

    double maxDepth = 1;
    //find maximum depth
    for(int i=0;i<nx;i++)
      for(int j=0;j<ny;j++)
        maxDepth = std::max(maxDepth,matrix[i][j]->getDepth());

    for(int j=0;j<ny;j++) {
      for(int i=0;i<nx;i++) {
        // draw a rectangle
        if(matrix[i][j]->getStatus() == 0)
          dc.SetBrush(*wxWHITE_BRUSH); // not scanned

        if(matrix[i][j]->getStatus() == 1)
        {
            //dc.SetBrush(*wxGREEN_BRUSH); // scanned
            //set color for scanned area
            double d = std::min(maxDepth,matrix[i][j]->getDepth()) / maxDepth;

            int red   = (1-d) * 255;
            int green = (1-d) * 150;
            int blue  = d * 200;

            red = std::max(0,std::min(255,red));
            green = std::max(0,std::min(255,green));
            blue = std::max(0,std::min(255,blue));

            wxBrush brush(wxColor(red,green,blue),1);
            dc.SetBrush(brush);
        }
        if(matrix[i][j]->getStatus() == 2)
            dc.SetBrush(*wxRED_BRUSH); // land

        if(matrix[i][j]->getStatus() == 3)
            dc.SetBrush(*wxYELLOW_BRUSH); // probably land

        if(matrix[i][j]->getStatus() == 5)
          dc.SetBrush(*wxGREY_BRUSH); // outside

        double x1 = scale*matrix[i][j]->getX();
        double y1 = scale*matrix[i][j]->getY();
        double d = std::min(dx,dy);
        dc.SetPen( wxPen( wxColor(255,255,255), 1 ) );
        dc.DrawRectangle( x1-(d/2), windowSize-y1-(d/2), d, d );
      }
    }

    //draw regions
    if(regions == NULL)
      return;

    for(int i=0;i<regions->size();i++)
    {
      PolygonSegment* ps = regions->at(i);

      int s = ps->xPoints->size();
      for(int j=0;j<s;j++)
      {
        double x1 = scale*ps->xPoints->at(j);
        double y1 = scale*ps->yPoints->at(j);
        double x2 = scale*ps->xPoints->at((j+1) % s);
        double y2 = scale*ps->yPoints->at((j+1) % s);

        // draw a line
        dc.SetPen( wxPen( wxColor(0,0,0), 3 ) ); // black line, 3 pixels thick
        //dc.DrawLine( 300, 100, 700, 300 ); // draw line across the rectangle
        dc.DrawLine(x1,windowSize - y1, x2, windowSize-y2);
      }
    }
  }
}
void kwxAngularMeter::DrawNeedle(wxDC &dc)
{
	//Triangular
	double dxi,dyi, val;
	wxPoint ppoint[6];
	int w, h ;

	GetClientSize(&w,&h);

	dc.SetPen(*wxThePenList->FindOrCreatePen(m_cNeedleColour, 1,wxSOLID));

	val = (m_nScaledVal + m_nAngleStart) * m_dPI / 180; //radians angle parameter

	dyi = sin(val - 90) * 2; //coordinates of the left base
	dxi = cos(val - 90) * 2;

	ppoint[0].x = (w / 2) - dxi;	//left base
	ppoint[0].y = (h / 2) - dyi;

	dxi = cos(val) * ((h / 2) - 4); //coordinates of the tip marker
	dyi = sin(val) * ((h / 2) - 4);

	ppoint[2].x = (w / 2) - dxi;	//points
	ppoint[2].y = (h / 2) - dyi;

	dxi = cos(val + 90) * 2; //coordinates basic right
	dyi = sin(val + 90) * 2;

	ppoint[4].x = (w / 2) - dxi;	//right based
	ppoint[4].y = (h / 2) - dyi;

	ppoint[5].x = ppoint[0].x;	//return the left base
	ppoint[5].y = ppoint[0].y;

//////////////////////////
	val = (m_nScaledVal + m_nAngleStart + 1) * m_dPI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinates of the right middle
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[3].x = (w / 2) - dxi;	//average basis right
	ppoint[3].y = (h / 2) - dyi;

	val = (m_nScaledVal + m_nAngleStart - 1) * m_dPI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinates of the left middle
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[1].x = (w / 2) - dxi;	//average basis the left
	ppoint[1].y = (h / 2) - dyi;

/////////////////////////


	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cNeedleColour,wxSOLID));

	dc.DrawPolygon(6, ppoint, 0, 0, wxODDEVEN_RULE);

	//Circle indicator
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*wxWHITE,wxSOLID));
	dc.DrawCircle(w / 2, h / 2, 4);
}
Example #27
0
void AngularMeter::DrawNeedle(wxDC &dc)
{
	//indicatore triangolare
	double dxi,dyi, val;
	wxPoint ppoint[6];
	int w, h ;

	GetClientSize(&w,&h);

	int hOffset = 0;
	int wOffset = 0;
	if (w > h) wOffset = (w - h) / 2;
	if (h > w) hOffset = (h - w) / 2;
	//square out the size
	if (w > h) w=h;
	if (h > w) h=w;

	dc.SetPen(*wxThePenList->FindOrCreatePen(_needleColor, 1,wxSOLID));

	val = (_scaledValue + _angleStart) * _PI / 180; //radianti parametro angolo

	dyi = sin(val - 90) * 2; //coordinate base sinistra
	dxi = cos(val - 90) * 2;

	ppoint[0].x = (int)((w / 2) - dxi);	//base sinistra
	ppoint[0].y = (int)((h / 2) - dyi);

	dxi = cos(val) * ((h / 2) - 4); //coordinate punta indicatore
	dyi = sin(val) * ((h / 2) - 4);

	ppoint[2].x = (int)((w / 2) - dxi);	//punta
	ppoint[2].y = (int)((h / 2) - dyi);

	dxi = cos(val + 90) * 2; //coordinate base destra
	dyi = sin(val + 90) * 2;

	ppoint[4].x = (int)((w / 2) - dxi);	//base destra
	ppoint[4].y = (int)((h / 2) - dyi);

	ppoint[5].x = ppoint[0].x;	//ritorno base sinistra
	ppoint[5].y = ppoint[0].y;

//////////////////////////
	val = (_scaledValue + _angleStart + 1) * _PI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinate medio destra
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[3].x = (int)((w / 2) - dxi);	//base media destra
	ppoint[3].y = (int)((h / 2) - dyi);

	val = (_scaledValue + _angleStart - 1) * _PI / 180;

	dxi = cos(val) * ((h / 2) - 10); //coordinate medio sinistra
	dyi = sin(val) * ((h / 2) - 10);

	ppoint[1].x = (int)((w / 2) - dxi);	//base media sinistra
	ppoint[1].y = (int)((h / 2) - dyi);

/////////////////////////


	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_needleColor,wxSOLID));

	dc.DrawPolygon(6, ppoint, wOffset, hOffset, wxODDEVEN_RULE);

	//cerchio indicatore
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_needleColor,wxSOLID));
	dc.DrawCircle((w / 2) + wOffset, (h / 2) + hOffset, 10);
}
Example #28
0
//void simple_vector_layer::Draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent, double zoomFactor, double translationX, double translationY, double resolution) const
void simple_vector_layer::draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent) const
{
    wxPen pen;
    wxBrush brush;

    // 2D
    pen.SetWidth(m_polygon_border_width);
    pen.SetColour(m_polygon_border_color);
    pen.SetStyle(m_polygon_border_style);
    brush.SetColour(m_polygon_inner_color);
    brush.SetStyle(m_polygon_inner_style);
    dc.SetPen(pen);
    dc.SetBrush(brush);
    for (unsigned int i = 0; i < m_circles.size(); i++)
    {
        wxPoint p = transform().from_local_int(m_circles[i]);
        wxCoord r = static_cast<wxCoord>(m_circles[i].radius / transform().zoom_factor());
        dc.DrawCircle(p, r);
    }
    // Ellipses alignees
    for (unsigned int i=0;i<m_ellipses.size();++i)
    {
        wxPoint p = transform().from_local_int(m_ellipses[i]);
        wxSize  s(
                static_cast<wxCoord>(2*m_ellipses[i].a/transform().zoom_factor()),
                static_cast<wxCoord>(2*m_ellipses[i].b/transform().zoom_factor())
                );
        dc.DrawEllipse(p,s);
        //dc.DrawEllipticArc(p,s,0.,90.);
        //dc.DrawEllipticArcRot(p,s,0.,90.);
    }
    // Ellipses non alignees
    for (unsigned int i=0;i<m_rotatedellipses.size();++i)
    {
        std::vector<wxPoint> points;
        points.reserve( m_rotatedellipses[i].controlPoints.size() );
        for (unsigned int j=0;j<m_rotatedellipses[i].controlPoints.size();++j)
            points.push_back(transform().from_local_int(m_rotatedellipses[i].controlPoints[j]));
        dc.DrawSpline(static_cast<int>(points.size()),&points.front());
    }
    for (unsigned int i=0;i<m_polygons.size();++i)
    {
        std::vector<wxPoint> points;
        points.reserve( m_polygons[i].size() );
        for (unsigned int j=0;j<m_polygons[i].size();++j)
            points.push_back(transform().from_local_int(m_polygons[i][j]));
        dc.DrawPolygon( static_cast<int>(points.size()) , &(points.front()) );
    }

    // 1D
    pen.SetColour(m_line_color);
    pen.SetWidth(m_line_width);
    pen.SetStyle(m_line_style);
    dc.SetPen(pen);
    for (unsigned int i = 0; i < m_arcs.size(); i++)
    {
        const arc_type &local_tab = m_arcs[i];
        for (unsigned int j = 0; j < local_tab.arc_points.size() - 1; ++j)
        {
            wxPoint p = transform().from_local_int(local_tab.arc_points[j  ]);
            wxPoint q = transform().from_local_int(local_tab.arc_points[j+1]);
            dc.DrawLine(p,q);
        }
    }
    // Splines
    for (unsigned int i=0;i<m_splines.size();++i)
    {
        const spline_type& spline = m_splines[i];
        std::vector<wxPoint> points;
        unsigned int n = static_cast<int>(spline.size());
        for (unsigned int j=0;j<n;++j)
        {
            wxPoint p = transform().from_local_int(spline[j]);
            points.push_back(p);
        }
        dc.DrawSpline(n,&points.front());
    }

    // 0D
    pen.SetColour(m_point_color);
    pen.SetWidth(m_point_width);
    dc.SetPen(pen);
    for (unsigned int i = 0; i < m_points.size(); i++)
    {
        wxPoint p = transform().from_local_int(m_points[i]);
        //dc.DrawLine(p);
        dc.DrawPoint(p);
    }

    // Text
    if(text_visibility())
    {
        pen.SetColour(m_text_color);
        dc.SetPen(pen);
        for (unsigned int i = 0; i < m_texts.size(); i++)
        {
            wxPoint p = transform().from_local_int(m_texts[i].first);
            //dc.DrawLine(p);
            dc.DrawText(wxString(m_texts[i].second.c_str(),*wxConvCurrent),p);
        }
    }
}
Example #29
0
void GLCanvas::drawUserInterface(wxDC &dc) const
{
    wxSize size = GetSize();
    wxPoint pos(0, 0);
    pos.x = size.x - _buttonSize;

    wxSize buttonSize(_buttonSize, _buttonSize);

    wxPen whitePen(wxColour(255, 255, 255));
    whitePen.SetWidth(1);
    wxPen blackPen(wxColour(0, 0, 0));
    blackPen.SetWidth(1);
    wxPen greenPen(wxColour(0, 255, 0));
    wxBrush brush;

	dc.SetPen(blackPen);

    brush.SetColour(wxColour(0, 0, 0));
	dc.SetBrush(brush);

	// draw black background behind all buttons
	dc.DrawRectangle(pos.x - 1, pos.y, _buttonSize + 1, _numButtons * _buttonSize + 1);

	// draw grit
	if (_style & DRAW_GRID)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRectangle(pos.x + 1, pos.y + 1, _buttonSize - 2, _buttonSize - 2);

	dc.DrawLine(pos.x + _buttonSizeHalf, pos.y + 1, pos.x + _buttonSizeHalf, pos.y + _buttonSize - 1);
	dc.DrawLine(pos.x + 1, pos.y + _buttonSizeHalf, size.x - 1, pos.y + _buttonSizeHalf);

	pos.y += _buttonSize;

	// draw a cube for showing AABB
	if (_style & DRAW_AABB)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRectangle(pos.x + _buttonSizeHalf - 3, pos.y + 3, _buttonSizeHalf, _buttonSizeHalf);
	dc.DrawRectangle(pos.x + 2, pos.y + _buttonSizeHalf - 2, _buttonSizeHalf, _buttonSizeHalf);

	dc.DrawLine(pos.x + 2, pos.y + _buttonSizeHalf - 2, pos.x + _buttonSizeHalf - 3, pos.y + 3);
	dc.DrawLine(pos.x + 2 + _buttonSizeHalf, pos.y + _buttonSizeHalf - 2, pos.x + _buttonSize - 3, pos.y + 3);
	dc.DrawLine(pos.x + 2 + _buttonSizeHalf, pos.y + _buttonSize - 3, pos.x + _buttonSize - 3, pos.y + _buttonSizeHalf + 2);

	pos.y += _buttonSize;

	// draw coordinate system
	if (_style & DRAW_LOCAL_COORDINATE_SYSTEM)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawLine(pos.x + 2, pos.y + 3, pos.x + 2, pos.y + _buttonSize - 2);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, size.x - 3, pos.y + _buttonSize - 2);

	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 6, pos.y + _buttonSizeHalf + 2);

	pos.y += _buttonSize;

	// draw joint constraints
	if (_style & DRAW_JOINT_CONSTRAINTS)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }
	//dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 3);
    //dc.DrawArc(pos.x + 4, pos.y + 5, pos.x + 4, pos.y + _buttonSize - 5, pos.x + _buttonSizeHalf + 2, pos.y + _buttonSizeHalf);
	//dc.DrawCircle(pos.x + 6, pos.y + _buttonSizeHalf, 3);
	dc.DrawEllipse(pos.x + 4, pos.y + 3, _buttonSizeHalf - 5, _buttonSizeHalf + 4);
	dc.DrawLine(pos.x + 8, pos.y + 3, pos.x + _buttonSizeHalf + 5, pos.y + _buttonSizeHalf);
	dc.DrawLine(pos.x + 8, pos.y + _buttonSizeHalf + 7, pos.x + _buttonSizeHalf + 5, pos.y + _buttonSizeHalf);

	pos.y += _buttonSize;

	// draw rotation axis
	if (_style & DRAW_ROTATION_AXIS)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

    dc.DrawArc(pos.x + _buttonSizeHalf + 2, pos.y + _buttonSize - 2, pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf + 1, pos.x + 2, pos.y + _buttonSize - 2);
    //dc.DrawEllipse(pos.x + 6, pos.y + 5, _buttonSize - 12, _buttonSize - 10);
    //dc.DrawCircle(pos.x + _buttonSizeHalf + 2, pos.y + _buttonSizeHalf - 2, 3);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 2, pos.y + 2);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 2, pos.y + _buttonSize - 2);

	pos.y += _buttonSize;

	// draw label
	if (_style & DRAW_LABEL)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRoundedRectangle(pos.x + 4, pos.y + 3, _buttonSize - 5, _buttonSizeHalf, 3.0);
	dc.DrawSpline(pos.x + 4, pos.y + _buttonSizeHalf - 3, pos.x + 1, pos.y + _buttonSizeHalf + 4, pos.x + _buttonSizeHalf + 4, pos.y + _buttonSizeHalf + 6);

	pos.y += _buttonSize;

	// draw locate skeleton button
    dc.SetPen(whitePen);

	dc.DrawLine(pos.x + _buttonSizeHalf, pos.y + 2, pos.x + _buttonSizeHalf, pos.y + _buttonSize - 1);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSizeHalf, size.x - 1, pos.y + _buttonSizeHalf);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 4);
	brush.SetColour(wxColour(255, 255, 255));
	dc.SetBrush(brush);
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 8);


	pos.y += _buttonSize;

	// draw settings button
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 3);

	dc.SetPen(blackPen);

	brush.SetColour(wxColour(0, 0, 0));
	dc.SetBrush(brush);

	dc.DrawCircle(pos.x + _buttonSizeHalf + 6, pos.y + _buttonSizeHalf, 2);
	dc.DrawCircle(pos.x + _buttonSizeHalf - 6, pos.y + _buttonSizeHalf, 2);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf + 6, 2);
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf - 6, 2);

	dc.SetPen(whitePen);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 7);
}
void LineShape::drawHead(wxDC& dc)
{
	int arrowHeadSize = 10;

	// First we draw a triangle at (0.0)
	// Second we rotate the triangle with the angle the line makes with the
	// Y-axis around it's centre
	// Than we move the centre of the triangle to the end of the line, but
	// outside the node

	top = Point(0, -arrowHeadSize);
	right = Point(arrowHeadSize * std::sin(PI / 3), arrowHeadSize * std::cos(PI / 3));
	left = Point(-arrowHeadSize * std::sin(PI / 3), arrowHeadSize * std::cos(PI / 3));

	// double angle = getAngle();
	double angle = Shape2DUtils::getAngle(node1->getCentre(), node2->getCentre()) + 0.5 * PI;

	top = Shape2DUtils::rotate(top, angle);
	right = Shape2DUtils::rotate(right, angle);
	left = Shape2DUtils::rotate(left, angle);

	double shortenLine = 0.0;

	double dxRect = node2->getSize().x / 2;
	double dyRect = node2->getSize().y / 2;
	double boundaryAngle = std::atan(dxRect / dyRect);

	if (0.0 < angle && angle <= PI / 2) {
		if (angle < boundaryAngle) {
			shortenLine = dyRect / std::cos(angle);
		} else {
			shortenLine = dxRect / std::cos(PI / 2 - angle);
		}
	} else if (PI / 2 < angle && angle <= 2 * PI / 2) {
		if (angle < PI - boundaryAngle) {
			shortenLine = dxRect / std::cos(angle - PI / 2);
		} else {
			shortenLine = dyRect / std::cos(PI - angle);
		}
	} else if (2 * PI / 2 < angle && angle <= 3 * PI / 2) {
		if (angle < boundaryAngle + PI) {
			shortenLine = dyRect / std::cos(angle - PI);
		} else {
			shortenLine = dxRect / std::cos(3 * PI / 2 - angle);
		}
	} else if (3 * PI / 2 < angle && angle <= 4 * PI / 2) {
		if (angle < 2 * PI - boundaryAngle) {
			shortenLine = dxRect / std::cos(angle - PI / 2);
		} else {
			shortenLine = dyRect / std::cos(PI / 2 - angle);
		}
	} else {
		if (angle < 2 * PI - boundaryAngle) {
			shortenLine = dxRect / std::cos(angle - 3 * PI / 2);
		} else {
			shortenLine = dyRect / std::cos(2 * PI - angle);
		}
	}

	shortenLine += arrowHeadSize;

	double dX = (getLength() - shortenLine) * sin(angle);
	double dY = (getLength() - shortenLine) * cos(angle);

	Point triangleCentre(getBegin().x + dX, getBegin().y - dY);

	top += triangleCentre;
	right += triangleCentre;
	left += triangleCentre;

	Point triangle[] = {top, right, left};

	if (isSelected()) {
		dc.SetPen(wxPen(WXSTRING("RED"), lineWidth, wxSOLID));
		dc.SetBrush(wxBrush(wxColour(WXSTRING("RED"))));
	} else {
		dc.SetPen(wxPen(WXSTRING("BLACK"), lineWidth, wxSOLID));
		dc.SetBrush(wxBrush(wxColour(WXSTRING("BLACK"))));
	}
	dc.DrawPolygon(3, triangle);

	// For debugging purposes
	dc.SetPen(wxPen(WXSTRING("ORANGE"), 2, wxSOLID));
	dc.SetBrush(wxBrush(wxColour(WXSTRING("ORANGE"))));
	dc.DrawCircle(top, 2);
	dc.SetPen(wxPen(WXSTRING("GREEN"), 2, wxSOLID)); // stuuRRRRRRboord RRRRRRechts gRRRRRRoen
	dc.SetBrush(wxBrush(wxColour(WXSTRING("GREEN"))));
	dc.DrawCircle(right, 2);
	dc.SetPen(wxPen(WXSTRING("RED"), 2, wxSOLID));
	dc.SetBrush(wxBrush(wxColour(WXSTRING("RED"))));
	dc.DrawCircle(left, 2);
}