mirror of
https://github.com/rene-dev/stmbl.git
synced 2026-09-22 14:54:12 +08:00
term aufgeteilt
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
#include "basicdrawpane.hpp"
|
||||
|
||||
BasicDrawPane::BasicDrawPane(wxFrame* parent) : wxPanel(parent){
|
||||
Bind(wxEVT_PAINT, &BasicDrawPane::paintEvent, this);
|
||||
xpos = 0;
|
||||
for (int i = 0; i<1024/2; i++) {
|
||||
data.push_back(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by the system of by wxWidgets when the panel needs
|
||||
* to be redrawn. You can also trigger this call by
|
||||
* calling Refresh()/Update().
|
||||
*/
|
||||
|
||||
void BasicDrawPane::paintEvent(wxPaintEvent & evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alternatively, you can use a clientDC to paint on the panel
|
||||
* at any time. Using this generally does not free you from
|
||||
* catching paint events, since it is possible that e.g. the window
|
||||
* manager throws away your drawing when the window comes to the
|
||||
* background, and expects you will redraw it when the window comes
|
||||
* back (by sending a paint event).
|
||||
*
|
||||
* In most cases, this will not be needed at all; simply handling
|
||||
* paint events and calling Refresh() when a refresh is needed
|
||||
* will do the job.
|
||||
*/
|
||||
void BasicDrawPane::paintNow()
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void BasicDrawPane::plotvalue(int value)
|
||||
{
|
||||
std::cout << "data:" << value << std::endl;
|
||||
//data.at(xpos) += 0.1;
|
||||
|
||||
data.at(xpos) = (float)value/64;
|
||||
xpos = (xpos+1)%data.size();
|
||||
Refresh();
|
||||
//oder
|
||||
//Update();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
wxCoord w,h;
|
||||
dc.GetSize(&w, &h);
|
||||
|
||||
// ursprung oben links
|
||||
// draw some text
|
||||
//dc.DrawText(wxT("Testing"), 40, 60);
|
||||
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.DrawLine( 0, h/2, w, h/2 );
|
||||
|
||||
dc.SetPen(*wxBLACK_PEN);
|
||||
|
||||
x = 0;
|
||||
y = h/2;
|
||||
xstep = w/(data.size()-1);
|
||||
for(auto point : data){
|
||||
xold = x;
|
||||
yold = y;
|
||||
y = h/2-point*h/2;
|
||||
dc.DrawLine( xold-xstep, yold, x, y );
|
||||
x += xstep;
|
||||
}
|
||||
|
||||
// Look at the wxDC docs to learn how to draw other stuff
|
||||
}
|
||||
Reference in New Issue
Block a user