How do draw a line for the data? Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
manggae
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Jul 14, 2015 10:06 am

How do draw a line for the data?

Post by manggae » Wed Jul 22, 2015 1:20 pm

i painted the line using a and b by mfc.
for example,

Code: Select all

        CStatic* stc = (CStatic *)GetDlgItem(IDC_STATIC_ENERGY); // i want to draw in ID_PANEL1, instead of IDC_STATIC_ENERGY
	CRect rect;

	CClientDC dc(stc);
	stc->GetClientRect(&rect);
	CBrush brush;
	brush.CreateSolidBrush(RGB(255, 255, 255));
	FillRect(dc, &rect, brush);

	dc.MoveTo(0, rect.bottom/2);
		for (int n=0; n<frameN; n++)
		{
			//dc.LineTo(n/amp_scale2,2*feature2d[n][0]);
			dc.LineTo(n,2*feature2d[n][0]);
		}
		brush.DeleteObject();
As I tried to draw the data in the wxWidgets.
While reading the Reference, one by one, is not easy to learn.
please teach me about draw data(line) by wxwidgets.
Last edited by doublemax on Wed Jul 22, 2015 1:50 pm, edited 1 time in total.
Reason: Added code tags

User avatar
doublemax
Moderator
Moderator
Posts: 14196
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How do draw a line for the data?

Post by doublemax » Wed Jul 22, 2015 1:52 pm

This shows you how a create a wxPanel for custom drawings:
https://wiki.wxwidgets.org/Drawing_on_a_panel_with_a_DC

And this is the reference for wxDC:
http://docs.wxwidgets.org/trunk/classwx_d_c.html

Most method names are similar to MFC.
Use the source, Luke!

manggae
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Jul 14, 2015 10:06 am

Re: How do draw a line for the data?

Post by manggae » Wed Jul 22, 2015 2:22 pm

i make source in mfc about connect CRect with CClientDC.
CStatic* stc = (CStatic *)GetDlgItem(IDC_STATIC_ENERGY);
CRect rect;
CClientDC dc(stc);
stc->GetClientRect(&rect);

hm....Perhaps, if i connect wxRect and wxclient, i can draw data..

wxRect rect;
wxClientDC dc(Panel1);

but I failed to find about connect wxRect and wxclient in Reference.
How should the connection?

User avatar
doublemax
Moderator
Moderator
Posts: 14196
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How do draw a line for the data?

Post by doublemax » Wed Jul 22, 2015 2:42 pm

Code: Select all

wxRect rect = Panel1->GetRect();
Use the source, Luke!

Post Reply