View Full Version : Problems rendering

10-09-2007, 05:04 PM
I have 2 QGLWidgets in a QMainWindow inside a project I am developing using Qt 4.3 and OpenGL. The top of the 2 widgets shows a 2D "profile" view of one record of data. The bottom of the widgets shows a 3D view of all the records of data. Initially when you look at the bottom widget, you see a bunch of lines that run straight from left to right. But as you move the mouse, the bottom widget rotates about the x-axis making the z-values visible.

You begin to see the shape of the profile view in the top widget as the z-data for the selected record in the bottom widget is the y-data for the top widget and they share the same x-data. The data itself displays correctly, but when I try to add some "spanAnnotations" to my plots, they work fine on the top 2D widget, but not on the bottom 3D widget. I cannot figure out why this does not work and I was hoping somebody could see an error in my drawing code of the "spanAnnotations".

for( int i = 0 ; i < spanAnnotations.size( ) ; i++ )
mpQgl->qglColor( spanAnnotations[i].color );

// Style 0 is OPEN_BOTTOM
if( spanAnnotations[i].style == 0 )
glBegin( GL_LINE_STRIP );
if( spanAnnotations[i].threeDimensional )
glVertex3f( spanAnnotations[i].left, spanAnnotations[i].yThreeDimensionalData, spanAnnotations[i].bottom );
glVertex3f( spanAnnotations[i].left, spanAnnotations[i].yThreeDimensionalData, spanAnnotations[i].top );
glVertex3f( spanAnnotations[i].right, spanAnnotations[i].yThreeDimensionalData, spanAnnotations[i].top );
glVertex3f( spanAnnotations[i].right, spanAnnotations[i].yThreeDimensionalData, spanAnnotations[i].bottom );
glVertex3f( spanAnnotations[i].left, spanAnnotations[i].bottom, 0.0 );
glVertex3f( spanAnnotations[i].left, spanAnnotations[i].top, 0.0 );
glVertex3f( spanAnnotations[i].right, spanAnnotations[i].top, 0.0 );
glVertex3f( spanAnnotations[i].right, spanAnnotations[i].bottom, 0.0 );
glEnd( );
} // end if( spanAnnotations[i].style == 0 )
} I am currently only using open bottom spans so a span looks like:

| |
| | This goes around a specific area of data. Can anybody see anything wrong with this code, mainly the part where z != 0.0 for all 4 vertices. When z == 0.0, I only have 2D data. Thanks!

10-10-2007, 08:07 AM
Another silly mistake by me. After taking a night off I came in refreshed and discovered I was adding my spanAnnotations to the wrong widget. I was adding the 3D items to the 2D plot, so obviously I wouldn't see these items in the 3D object since they weren't being added there. Thanks for your help anyways!