franchouze
16th January 2013, 16:01
Hi everybody,
I am using Qwtplot3D 0.2.7 to plot 3D surface and it works fine.
On my own inherited class of SurfacePlot, I also need to plot a 3D polyline.
The only way I found to draw something is to overload the createData() function like this :
void PlotSurface::createData()
{
Qwt3D::SurfacePlot::createData();
if(!ptrIsNul(_myData))
{
Qwt3D::setDeviceLineWidth( 2 );
glColor3d(0., 1., 1.);
glPushMatrix();
glScaled(_scaleX,_scaleY,_scaleZ);
glTranslated(_offsetX,_offsetY, _offsetZ);
glRotated(_angleZ,0.0,0.0,1.0);
glBegin( GL_LINES );
for(unsigned int i = 0; i < _myData->getNbLines(); i ++)
{
for(unsigned int j =0; j < _myData->getLine(i)->getNbPoints()-1; j++ )
{
Point<float,3> p1 = _myData->getLine(i)->getPoint(j);
Point<float,3> p2 = _myData->getLine(i)->getPoint(j+1);
glVertex3d(p1[0], p1[1], p1[2]);
glVertex3d(p2[0], p2[1], p2[2]);
}
}
glEnd();
glPopMatrix();
}
}
1) Is it the good way to do it ?
2) The lines are drawn. However, when I look the surface plot from above (I then see a X,Y plane), the lines are not at the correct coordinates. Moreover these coordinates depends on the Z values of my surface data. The _offsetX etc... parameters are set to 0 ans _scaleX etc... are set to 1.0. _angleZ is also equal to 0.0.
I would like to draw those lines like the grid of the surface is drawn but I can't find a way.
Any Idea ?
Thanks in advance.
I am using Qwtplot3D 0.2.7 to plot 3D surface and it works fine.
On my own inherited class of SurfacePlot, I also need to plot a 3D polyline.
The only way I found to draw something is to overload the createData() function like this :
void PlotSurface::createData()
{
Qwt3D::SurfacePlot::createData();
if(!ptrIsNul(_myData))
{
Qwt3D::setDeviceLineWidth( 2 );
glColor3d(0., 1., 1.);
glPushMatrix();
glScaled(_scaleX,_scaleY,_scaleZ);
glTranslated(_offsetX,_offsetY, _offsetZ);
glRotated(_angleZ,0.0,0.0,1.0);
glBegin( GL_LINES );
for(unsigned int i = 0; i < _myData->getNbLines(); i ++)
{
for(unsigned int j =0; j < _myData->getLine(i)->getNbPoints()-1; j++ )
{
Point<float,3> p1 = _myData->getLine(i)->getPoint(j);
Point<float,3> p2 = _myData->getLine(i)->getPoint(j+1);
glVertex3d(p1[0], p1[1], p1[2]);
glVertex3d(p2[0], p2[1], p2[2]);
}
}
glEnd();
glPopMatrix();
}
}
1) Is it the good way to do it ?
2) The lines are drawn. However, when I look the surface plot from above (I then see a X,Y plane), the lines are not at the correct coordinates. Moreover these coordinates depends on the Z values of my surface data. The _offsetX etc... parameters are set to 0 ans _scaleX etc... are set to 1.0. _angleZ is also equal to 0.0.
I would like to draw those lines like the grid of the surface is drawn but I can't find a way.
Any Idea ?
Thanks in advance.