//============================================================================== void CVDisk::Draw() { int iVtx; m_nClipped = 0; if(!m_IsVisible) return; m_CalcScrnVertices(); glColor4f( m_fRGB[0], m_fRGB[1], m_fRGB[2], m_fAlpha); if(m_iIsFilled) glPolygonMode(GL_FRONT, GL_FILL); else { glPolygonMode(GL_FRONT, GL_LINE); // GL_LINE_WIDTH?? } glBegin(GL_POLYGON); for( iVtx = 0; iVtx < m_nVertices; iVtx++) { m_nClipped += IS_OFF_WINDOW(m_afScrnVtxX[iVtx],m_afScrnVtxY[iVtx]); glVertex3f( m_afScrnVtxX[iVtx], m_afScrnVtxY[iVtx], (float) m_dZ); } glEnd(); }
void CVComplexShape::updateScrVertices(void) { if(exact){ // Do the transformations by hand for each point // and then use the exact calibration double co,si,x,y, *p = m_getVertices(), *d = scrVertices; int m, dim0 = GetLength(p, 0); co = cos(m_dAngle*(3.1415926535/180.0)); si = sin(m_dAngle*(3.1415926535/180.0)); m_nClipped = 0; for(m=GetLength(p, 1)-1; m >= 0; --m, p+=dim0, d+=dim0){ // 1: Rotate x = co*p[0] - si*p[1]; y = si*p[0] + co*p[1]; // 2: Scale x *= m_dScale; y *= m_dScale; // 3: Translate x += m_dX; y += m_dY; /* Old VisWin // Remap Through Calibration d[0] = XPosToScreen((float)x,(float)y); d[1] = YPosToScreen((float)x,(float)y); if (dim0 > 2) d[2] = p[2]; // Clipped if any vtx is off screen if( VISWIN_IS_CLIPPED(d[0],d[1]) ) Clipped = 1; */ g_TransformCoordinatesD( x, y, d, d+1 ); m_nClipped += IS_OFF_WINDOW(d[0],d[1]); if (dim0 > 2) d[2] = p[2]; } } }
void CVComplexShape::Draw() { // logToFile((f, "CVComplexShape Draw\n")); if(!m_IsVisible) return; double *vertices = exact ? scrVertices : m_getVertices(); if (arrays[aiIndices] != 0 && GetLength(arrays[aiIndices], 1) == 0 || vertices == 0 || GetLength(vertices, 1) == 0) return; glPushMatrix(); if(exact){ glMatrixMode (GL_MODELVIEW); glLoadIdentity(); glTranslated(0.0, 0.0, m_dZ); } else { // Only get exact calibration location of center // and approximate the rest of the points /* float x = XPosToScreen((float)X,(float)Y); float y = YPosToScreen((float)X,(float)Y); m_nClipped = VISWIN_IS_CLIPPED(x,y); */ float pix[2]; g_TransformCoordinatesF( m_dX, m_dY, pix, pix+1 ); m_nClipped = IS_OFF_WINDOW(pix[0],pix[1]); g_TransformGradientD(JAC,m_dX,m_dY); /* DPosToDScreen(JAC,x,y); */ // Rot 4x4, allocated by column, as in matlab // Jac, though, is only the 2x2 Jacobian ROT[0]=m_dScale*JAC[0][0]; ROT[1]=m_dScale*JAC[1][0]; ROT[4]=m_dScale*JAC[0][1]; ROT[5]=m_dScale*JAC[1][1]; ROT[12]=pix[0]; ROT[13]=pix[1]; ROT[14]=m_dZ; glMatrixMode (GL_MODELVIEW); // glLoadIdentity(); // glTranslatef((float)x,(float)y,Z); // 3: Translate // glScalef((float)scx,(float)scy,1); // 2: Scale glLoadMatrixd(ROT); // 2: Translate and Scale glRotatef((float)m_dAngle,0,0,1); // 1: Rotate About Z axis } glColor4d(m_fRGB[0],m_fRGB[1],m_fRGB[2],m_fAlpha); if (drawMode >= odmLines && drawMode <= odmLineLoop) { if (lineStipple != 0) { glLineStipple(lineStippleFactor, lineStipple); glEnable(GL_LINE_STIPPLE); } if (lineWidth != 1.0) glLineWidth((float)lineWidth); } if (drawMode == odmPoints && pointSize != 1.0) glPointSize((float)pointSize); if (drawMode >= odmTriangles && drawMode <= odmPolygon) { if (arrays[aiPolygonStipple] != 0) { glEnable(GL_POLYGON_STIPPLE); glPolygonStipple((unsigned char *)arrays[aiPolygonStipple]); } } if (vertices != 0) glEnableClientState(GL_VERTEX_ARRAY); if (arrays[aiColors ] != 0) glEnableClientState(GL_COLOR_ARRAY); if (arrays[aiEdgeFlags] != 0) glEnableClientState(GL_EDGE_FLAG_ARRAY); if (arrays[aiIndices] != 0) { if (vertices != 0) glVertexPointer(GetLength(vertices, 0), GL_DOUBLE, 0, vertices); if (arrays[aiColors] != 0) glColorPointer (GetLength(arrays[aiColors], 0), GL_DOUBLE, 0, arrays[aiColors]); // if (arrays[aiEdgeFlags] != 0) // glEdgeFlagPointer(0, arrays[aiEdgeFlags]); if (GetDim(arrays[aiIndices]) == 1 || GetLength(arrays[aiIndices], 0) == 1) glDrawElements(glDrawModeMap[drawMode], GetLength(arrays[aiIndices]), GL_UNSIGNED_INT, arrays[aiIndices]); else { int len0 = GetLength(arrays[aiIndices], 0); int len1 = GetLength(arrays[aiIndices], 1); for (int i=0; i < len1; ++i) glDrawElements(glDrawModeMap[drawMode], len0, GL_UNSIGNED_INT, ((unsigned int *)arrays[aiIndices]) + len0 * i); } } else if (vertices != 0) { int len2 = GetDim(vertices) <= 2 ? 1 : GetLength(vertices, 2); for (int i=0; i < len2; ++i) { if (vertices != 0) glVertexPointer(GetLength(vertices, 0), GL_DOUBLE, 0, vertices + GetLength(vertices, 0) * GetLength(vertices, 1) * i); if (arrays[aiColors] != 0) glColorPointer (GetLength(arrays[aiColors], 0), GL_DOUBLE, 0, arrays[aiColors] + GetLength(arrays[aiColors], 0) * GetLength(arrays[aiColors], 1) * i); // if (arrays[aiEdgeFlags] != 0) // glEdgeFlagPointer(0, arrays[aiEdgeFlags]); glDrawArrays(glDrawModeMap[drawMode], 0, GetLength(vertices, 1)); } } if (vertices != 0) glDisableClientState(GL_VERTEX_ARRAY); if (arrays[aiColors ] != 0) glDisableClientState(GL_COLOR_ARRAY); if (arrays[aiEdgeFlags] != 0) glDisableClientState(GL_EDGE_FLAG_ARRAY); if (drawMode >= odmTriangles && drawMode <= odmPolygon) { if (arrays[aiPolygonStipple] != 0) glDisable(GL_POLYGON_STIPPLE); } if (drawMode >= odmLines && drawMode <= odmLineLoop) { if (lineStipple != 0) glDisable(GL_LINE_STIPPLE); if (lineWidth != 1.0) glLineWidth(1.0); } if (drawMode == odmPoints && pointSize != 1.0) glPointSize(1.0); glPopMatrix(); }