drawline produces broken lines Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 29, 2008 11:47 am

Thanks, I don`t know it before

anandvincent78
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Oct 05, 2007 8:46 am

Post by anandvincent78 » Sat Mar 29, 2008 11:58 am

Thanks to all of you helping me out. Lester in particular thanks very much. I used the functions you provided in my code and the version1 pretty much solves the problem I had. My problem was that of selecting the line with a mouse click. Using version1 of your code I can select the lines with good accuracy. Though the lines seem dotted rather than continous. Please find attached snapshots of my drawing using version1 and version2.
Attachments
v1.PNG
v2.PNG
Wxwidgets 2.8.9
OS WindowsXP
IDE VS 2005

anandvincent78
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Oct 05, 2007 8:46 am

Post by anandvincent78 » Sat Mar 29, 2008 12:02 pm

doublemax wrote:like tan already mentioned, wxWidgets supports antialiased drawing operations on all major platforms using wxGCGC.

Usually you only have to change/add 2 lines of code in your drawing routine.

Check the "drawing" sample.

http://forums.wxwidgets.org/viewtopic.php?p=66885#66885
I checked this forum topic. There is some mention of rebuilding the core and linking gdiplus.lib. Where I can find step by step instruction to do this? My knowledge of VS is very minimal.
Wxwidgets 2.8.9
OS WindowsXP
IDE VS 2005

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 29, 2008 12:11 pm

I cannot understand why it draw so ugly for You, that's my screen with this function:
Attachments
1.PNG

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 29, 2008 12:17 pm

What dc You use - wxMemoryDC, wxPaintDC, wxClientDC, wxBufferedDC ?

lester
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Sep 02, 2006 7:24 pm
Location: Ukraine

Post by lester » Sat Mar 29, 2008 12:19 pm

Some code with sample can be very useful for me

anandvincent78
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Oct 05, 2007 8:46 am

Post by anandvincent78 » Sun Mar 30, 2008 7:38 am

lester wrote:What dc You use - wxMemoryDC, wxPaintDC, wxClientDC, wxBufferedDC ?
I am using the wxDC device context. I do all my drawing in the DoPaint function using wxDC context. See some sample code below.

Code: Select all

void MyCanvas::DoPaint(wxDC& dc) {
// Loop to draw the lines
	for( int i=0; i<(int)arc_id_vector.size(); i++ ) {
		loc_x1 = g.return_arc_x1( arc_id_vector[i] ); // Store the x1 location of arc
		loc_y1 = g.return_arc_y1( arc_id_vector[i] ); // Store the y1 location of arc
		loc_x2 = g.return_arc_x2( arc_id_vector[i] ); // Store the x2 location of arc
		loc_y2 = g.return_arc_y2( arc_id_vector[i] ); // Store the y2 location of arc

		dc.SetPen( *wxBLACK_PEN );
		wxBrush *brush = new wxBrush();
		brush->SetColour(*wxBLACK);
		brush->SetStyle(wxTRANSPARENT );
		dc.SetBrush( *brush );
		//wxBLACK_BRUSH->SetStyle( wxSOLID );

		// Draw line with the (x1, y1) and (x2, y2) locations multiplied by a scale
		//dc.DrawLine( loc_x1 * scale , loc_y1 * scale , loc_x2 * scale , loc_y2 * scale );
		DrawWuLine( &dc, loc_x1 * scale , loc_y1 * scale , loc_x2 * scale , loc_y2 * scale );

		str3.clear();
		//str3.Printf( _T("%3.1f" ), g.return_arc_length( arc_id_vector[i] ) );
		str3.Printf( _T("%d" ), arc_id_vector[i]  );
		//str3.Printf( _T("%d" ), g.return_arc_navigability( arc_id_vector[i] ) );
		
		dc.DrawText( str3, ((loc_x1+loc_x2)/2.0)*scale, ((loc_y1+loc_y2)/2.0)*scale ) ; 
	}
Wxwidgets 2.8.9
OS WindowsXP
IDE VS 2005

Post Reply