///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CONSTR/DESTR CVisText::CVisText() { // Default Color/Draw Values Color[0]=Color[1]=Color[2]=1; #if INDEX_MODE ColorIndex=VisWindow->ColorRGB2I(Color); #endif Alpha=1; // Clipped Clipped = VISWIN_IS_CLIPPED(X,Y); // Transform ScaleX=ScaleY= 1; Angle = 0; // FONT & STRING SETUP Fill=TRUE; fontUnderline=FALSE; fontItalic=FALSE; fontWeight=500; strcpy(fontName,VISTEXT_DEFAULT_FONT); listBase=-1; BuildFont(); textString[0]=NULL; calcTextBox(); }
void CVisComplexObj::updateScrVertices(void) { if(exact){ // Do the transformations by hand for each point // and then use the exact calibration double co,si,x,y, *p = getVertices(), *d = scrVertices; int m, dim0 = GetLength(p, 0); co = cos(angle*(3.1415926535/180.0)); si = sin(angle*(3.1415926535/180.0)); Clipped = 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 *= scale; y *= scale; // 3: Translate x += X; y += Y; // 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; } } }
CVisComplexObj::CVisComplexObj() { int i; for (i = 0; i < aiTopIndex; ++i) arrays[i] = NULL; scrVertices = NULL; lineStipple = 0; lineStippleFactor = 1; lineWidth = 1.0f; pointSize = 1.0f; drawMode = odmPoints; color[0] = color[1] = color[2] = 1.0; #if INDEX_MODE ColorIndex=VisWindow->ColorRGB2I(color); #endif alpha=1; exact=0; // Clipped Clipped = VISWIN_IS_CLIPPED(X,Y); // Transform scale = 1; angle = 0; // Data Structures // ROT is used if not computing Exact vertex locations for(i=0; i<15; i++) ROT[i]=0.; ROT[10]=1.; // [3 3] of the rotation component ROT[15]=1.; // Last element -- multiplies translation }
void CVisText::draw() { if(Show){ // Only get exact calibration location of center // and approximate the rest of the points float x = XPosToScreen(X,Y); float y = YPosToScreen(X,Y); // Only ask if center is clipped?! Clipped = VISWIN_IS_CLIPPED(x,y); // Setup Transformation glMatrixMode (GL_MODELVIEW); glLoadIdentity(); glTranslatef(x,y,Z); // 4: Translate to POS glRotatef(Angle,0,0,1); // 3: Rotate About Z axis glScalef(ScaleX,ScaleY,1); // 2: Scale glTranslatef(-Length/2,-Height/2,0); // 1: Translate to Center the Text // Set Color and Lighting Properties #if INDEX_MODE glIndexi(ColorIndex); #else glColor4f(Color[0],Color[1],Color[2],Alpha); #endif // glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits // Indicate start of glyph display lists glListBase (listBase); // Now draw the characters in a string glCallLists (strlen(textString), GL_UNSIGNED_BYTE, textString); // glPopAttrib(); // Pops The Display List Bits } }
void CVisComplexObj::draw() { logToFile((f, "VisComplexObj Draw\n")); if(!Show) return; double *vertices = exact ? scrVertices : 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, Z); } 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); Clipped = VISWIN_IS_CLIPPED(x,y); DPosToDScreen(JAC,x,y); // Rot 4x4, allocated by column, as in matlab // Jac, though, is only the 2x2 Jacobian ROT[0]=(float)scale*JAC[0][0]; ROT[1]=(float)scale*JAC[1][0]; ROT[4]=(float)scale*JAC[0][1]; ROT[5]=(float)scale*JAC[1][1]; ROT[12]=x; ROT[13]=y; ROT[14]=Z; glMatrixMode (GL_MODELVIEW); // glLoadIdentity(); // glTranslatef((float)x,(float)y,Z); // 3: Translate // glScalef((float)scx,(float)scy,1); // 2: Scale glLoadMatrixf(ROT); // 2: Translate and Scale glRotatef((float)angle,0,0,1); // 1: Rotate About Z axis } #if INDEX_MODE glIndexi(ColorIndex); #else glColor4d(color[0],color[1],color[2],alpha); #endif 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[aiNormals ] != 0) glEnableClientState(GL_NORMAL_ARRAY); if (arrays[aiColors ] != 0) glEnableClientState(GL_COLOR_ARRAY); if (arrays[aiEdgeFlags] != 0) glEnableClientState(GL_EDGE_FLAG_ARRAY); if (vertices != 0) glVertexPointer(GetLength(vertices, 0), GL_DOUBLE, 0, vertices); if (arrays[aiNormals] != 0) glNormalPointer(GL_DOUBLE, 0, arrays[aiNormals]); if (arrays[aiColors] != 0) glColorPointer (GetLength(arrays[aiColors], 0), GL_DOUBLE, 0, arrays[aiColors]); if (arrays[aiEdgeFlags] != 0) glEdgeFlagPointer(0, arrays[aiEdgeFlags]); if (arrays[aiIndices] != 0) glDrawElements(glDrawModeMap[drawMode], GetLength(arrays[aiIndices]), GL_UNSIGNED_INT, arrays[aiIndices]); else glDrawArrays(glDrawModeMap[drawMode], 0, GetLength(vertices, 1)); if (vertices != 0) glDisableClientState(GL_VERTEX_ARRAY); if (arrays[aiNormals ] != 0) glDisableClientState(GL_NORMAL_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(); }