- else {
-#endif
- double edge = 1.;
- unsigned int nx = GetDocument()->nx();
- unsigned int ny = GetDocument()->ny();
- const ImageFileArrayConst v = GetDocument()->getArray();
- if (nx == 0 || ny == 0 || ! v)
- return;
-
- glRotatef( m_dXRotate, 1.0, 0.0, 0.0 );
- glRotatef( m_dZRotate, 0.0, 1.0, 0.0 );
- glRotatef( m_dYRotate, 0.0, 0.0, 1.0 );
- glTranslatef (-static_cast<double>(nx) / 2., 0, -static_cast<double>(ny) / 2.);
-
- InitMaterials();
-
- if (m_bSmooth) {
- glShadeModel (GL_SMOOTH);
- } else {
- glShadeModel (GL_FLAT);
+
+ if (m_bLighting) {
+ glEnable (GL_LIGHTING);
+ } else {
+ glDisable (GL_LIGHTING);
+ }
+
+ unsigned int nx = GetDocument()->nx();
+ unsigned int ny = GetDocument()->ny();
+
+ glRotated (m_dZRotate, 0.0, 1.0, 0.0);
+ glRotated (m_dXRotate, 0.0, 0.0, 1.0);
+ glRotated (m_dYRotate, 1.0, 0.0, 0.0);
+ glTranslated (-static_cast<double>(nx - 1) / 2, 0.0, -static_cast<double>(ny - 1) / 2);
+
+ InitMaterials();
+ if (m_bWireframe) {
+ if (! m_bColor)
+ glColor3f (1.0f, 1.0f, 1.0f);
+ glPolygonOffset (1.0f, 1.0f);
+ glEnable (GL_POLYGON_OFFSET_FILL);
+ glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+ glCallList (DISPLAYLIST_COLOR);
+
+ glColor3f (0.0f, 0.0f, 0.0f);
+ glPolygonOffset (0.0f, 0.0f);
+ glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+ glCallList (DISPLAYLIST_NO_COLOR);
+ } else {
+ glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+ if (! m_bColor) {
+ glColor3f (1.0f, 1.0f, 1.0f);
+ glCallList (DISPLAYLIST_NO_COLOR);
+ } else
+ glCallList (DISPLAYLIST_COLOR);
+ }
+
+}
+
+void
+Graph3dFileView::CreateDisplayList()
+{
+ if (! GetDocument())
+ return;
+
+ unsigned int nx = GetDocument()->nx();
+ unsigned int ny = GetDocument()->ny();
+ const ImageFileArrayConst v = GetDocument()->getArray();
+ if (nx == 0 || ny == 0 || ! v)
+ return;
+
+ glNewList (DISPLAYLIST_COLOR, GL_COMPILE);
+
+ double dMin = m_dColorScaleMin;
+ double dIntensityScale = m_dColorScaleMax - m_dColorScaleMin;
+ double actOffset = m_dGraphMin;
+ double actScale = 0.4 * sqrt(nx*nx+ny*ny) / (m_dGraphMax - m_dGraphMin);
+ double dXOffset = -(static_cast<double>(nx) - 1) / 2.;
+ double dYOffset = -(static_cast<double>(ny) - 1) / 2.;
+ dXOffset = 0;
+ dYOffset = 0;
+
+ double dXPos = -dXOffset;
+ for (unsigned ix = 0; ix < nx - 1; ix++, dXPos++) {
+ double dYPos = -dYOffset;
+ glBegin(GL_QUAD_STRIP);
+ double p1[3], p2[3], p3[3], n1[3];
+ p1[0] = dXPos; p1[1] = actScale * (v[ix][0] + actOffset); p1[2] = dYPos;
+ p2[0] = dXPos+1; p2[1] = actScale * (v[ix+1][0] + actOffset); p2[2] = dYPos;
+ p3[0] = dXPos; p3[1] = actScale * (v[ix][1] + actOffset); p3[2] = dYPos + 1;
+ CalculateVectorNormal<double> (p1, p2, p3, &n1[0], &n1[1], &n1[2]);
+
+ double dIntensity1, dIntensity2;
+ if (m_bColor) {
+ dIntensity1 = (v[ix][0] - dMin) / dIntensityScale;
+ dIntensity2 = (v[ix+1][0] - dMin) / dIntensityScale;