7 #include "glwidget_OnDisp.h"
12 GLWidget_OnDisp::GLWidget_OnDisp(QWidget *parent)
13 : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
15 qtGreen = QColor::fromCmykF(0.40, 0.0, 1.0, 0.0);
16 qtPurple = QColor::fromCmykF(0.0, 0.0, 0.0, 0.0);
29 GLWidget_OnDisp::~GLWidget_OnDisp()
33 QSize GLWidget_OnDisp::minimumSizeHint()
const
38 QSize GLWidget_OnDisp::sizeHint()
const
41 qDebug()<<
"GL:Width="<<this->width();
42 qDebug()<<
"GL:Height="<<this->height();
43 return QSize(this->width(), this->height());
47 void GLWidget_OnDisp::initializeGL()
50 glClearColor(1.0f, 1.0f,1.0f, 0.0);
54 void GLWidget_OnDisp::paintGL()
56 glClear(GL_COLOR_BUFFER_BIT);
59 glScalef(1.0, 1.0, 1.0);
71 glColor3f(0.0f,0.0f,0.0f);
72 drawAx(m_x, m_x+m_w, m_y, m_y-m_h);
76 glColor3f(0.0f,0.0f,1.0f);
78 drawLines(m_samples, m_row, m_col, m_wise_type, m_x, m_y, m_w, m_h);
83 void GLWidget_OnDisp::resizeGL(
int width,
int height)
85 glViewport( 0, 0, (GLint)width, (GLint)height );
86 glMatrixMode( GL_PROJECTION );
88 glOrtho( xl, xr, yd, yt, -1.0, 1.0 );
89 glMatrixMode( GL_MODELVIEW );
92 void GLWidget_OnDisp::SetGLView(
float xleft,
float xright,
float ydown,
float ytop)
100 glMatrixMode( GL_PROJECTION );
102 glOrtho( xl, xr, yd, yt, -1.0, 1.0 );
103 glMatrixMode( GL_MODELVIEW );
105 void GLWidget_OnDisp::SetdrawLines(MatrixXf tmp,
int wise_type,
int chnind,
float x,
float y,
float w,
float h)
113 m_row = m_tmp.rows();
114 m_col = m_tmp.cols();
124 SetGLView(xleft, xright, ydown, ytop);
126 m_wise_type = wise_type;
132 for(
int i = 0; i<m_col;i++)
133 m_tmp(chnind,i) -= m_tmp(chnind,0);
135 m_samples = m_tmp.data();
142 void GLWidget_OnDisp::SetChnInd(
int chnind)
145 qDebug()<<
"GLWidget_OnDisp:chnind : "<<chnind;
154 void GLWidget_OnDisp::drawAx(
float xleft,
float xright,
float ytop,
float ydown)
158 glBegin(GL_LINE_STRIP);
159 glVertex2f(xleft, ytop);
160 glVertex2f(xright, ytop);
161 glVertex2f(xright, ydown);
162 glVertex2f(xleft, ydown);
163 glVertex2f(xleft, ytop);
169 glVertex2f(xleft, ytop-(ytop-ydown)/3);
170 glVertex2f(xleft+(xright-xleft)/20, ytop-(ytop-ydown)/3);
172 glVertex2f(xleft, ytop-2*(ytop-ydown)/3);
173 glVertex2f(xleft+(xright-xleft)/20, ytop-2*(ytop-ydown)/3);
175 glVertex2f(xleft+(xright-xleft)/3, ydown);
176 glVertex2f(xleft+(xright-xleft)/3, ydown+(ytop-ydown)/20);
178 glVertex2f(xleft+2*(xright-xleft)/3, ydown);
179 glVertex2f(xleft+2*(xright-xleft)/3, ydown+(ytop-ydown)/20);
185 void GLWidget_OnDisp::drawLines(
float * samples,
int row,
int col,
int wise_type,
186 float x,
float y,
float w,
float h)
191 int chanIndx = m_chnind;
195 drawOneLine(samples, row, col, wise_type, chanIndx, xCoordScale*x, yCoordScale*y, w, h);
199 void GLWidget_OnDisp::drawOneLine(
float * samples,
int row,
int col,
int wise_type,
int chanIndx,
200 float x,
float y,
float w,
float h)
203 float wscale = w/col;
206 glBegin(GL_LINE_STRIP);
208 for(
int i=0;i<col;i++){
209 glVertex2f(i*wscale+x,hscale*(y-h/2+samples[i*row+chanIndx]));
214 for(
int i=0;i<col;i++){
215 glVertex2f(i*wscale+x,hscale*(y-h/2+samples[i+chanIndx*col]));