-void DrawGrid(Rect rc)
-{
- int i, j, k;
- double h,w,x,y;
- Point pt[2];
- Rect rcBox;
-
- w = (double)(rc.right-rc.left+1) - cxChar;
- h = (double)(rc.top-rc.bottom+1) - cxChar - cyChar;
-
- SFG = w/(Hur-Hll);
- SFG = min(SFG, h/(Vur-Vll));
-
- // Center drawing
- X0G = (int)(rc.left + rc.right - (int)(SFG*(Hur-Hll)))/2;
- Y0G = (int)(rc.top + rc.bottom + cyChar - (int)(SFG*(Vur-Vll)))/2;
-
- g_GLTable.m_pfn_qglLineWidth (2);
- g_GLTable.m_pfn_qglColor3f (0, 1, 0);
- g_GLTable.m_pfn_qglDisable (GL_LINE_STIPPLE);
-
- pt[0].y = Y0G;
- pt[1].y = Y0G + (int)(SFG*(Vur-Vll));
- g_GLTable.m_pfn_qglBegin (GL_LINES);
- for(i=0; i<=NH; i++)
- {
- x = Hll + i * dh;
- pt[0].x = X0G + (int)(SFG*(x-Hll));
- g_GLTable.m_pfn_qglVertex2i(pt[0].x, pt[0].y);
- g_GLTable.m_pfn_qglVertex2i(pt[0].x, pt[1].y);
- }
- g_GLTable.m_pfn_qglEnd ();
- pt[0].x = X0G;
- pt[1].x = X0G + (int)(SFG*(Hur-Hll));
- g_GLTable.m_pfn_qglBegin (GL_LINES);
- for(i=0; i<=NV; i++)
- {
- y = Vll + i * dv;
- pt[0].y = Y0G + (int)(SFG*(Vur-y));
- g_GLTable.m_pfn_qglVertex2i (pt[0].x,pt[0].y);
- g_GLTable.m_pfn_qglVertex2i (pt[1].x,pt[0].y);
- }
- g_GLTable.m_pfn_qglEnd ();
-
- g_GLTable.m_pfn_qglLineWidth (1);
-
- // Draw axes
- pt[0].x = rc.right - cyChar - cxChar - cyChar/2;
- pt[0].y = rc.bottom + cyChar/2;
- pt[1].x = pt[0].x + cyChar;
- pt[1].y = pt[0].y;
- g_GLTable.m_pfn_qglBegin (GL_LINES);
- g_GLTable.m_pfn_qglVertex2i (pt[0].x,pt[0].y);
- g_GLTable.m_pfn_qglVertex2i (pt[1].x,pt[1].y);
- g_GLTable.m_pfn_qglEnd ();
- switch(Plane)
- {
- case PLANE_YZ0:
- case PLANE_YZ1:
- texfont_write ("Y", pt[1].x, pt[1].y+cyChar/2);
- break;
- default:
- texfont_write ("X", pt[1].x, pt[1].y+cyChar/2);
- }
- pt[1].x = pt[0].x;
- pt[1].y = pt[0].y + cyChar;
- g_GLTable.m_pfn_qglBegin (GL_LINES);
- g_GLTable.m_pfn_qglVertex2i (pt[0].x,pt[0].y);
- g_GLTable.m_pfn_qglVertex2i (pt[1].x,pt[1].y);
- g_GLTable.m_pfn_qglEnd ();
- switch(Plane)
- {
- case PLANE_XY0:
- case PLANE_XY1:
- texfont_write ("Y", pt[1].x-cyChar/2, pt[1].y+cyChar);
- break;
- default:
- texfont_write ("Z", pt[1].x-cyChar/2, pt[1].y+cyChar);
- }
-
- // Denote fixed points with a 5x5 red rectangle
- for(i=0; i<=NH; i++)
- {
- for(j=0; j<=NV; j++)
- {
- if(xyz[i][j].fixed)
- {
- x = Hll + i*dh;
- y = Vll + j*dv;
- rcBox.left = X0G + (int)(SFG*(x-Hll)) - 2;
- rcBox.top = Y0G + (int)(SFG*(Vur-y)) + 2;
- rcBox.right = rcBox.left + 5;
- rcBox.bottom = rcBox.top - 5;
-
- DRAW_QUAD (rcBox, 1,0,0);
- }
- }
- }
-
- // Denote currently selected point with a 5x5 green rectangle
- if (NumVerticesSelected)
- {
- for(k=0; k<NumVerticesSelected; k++)
- {
- x = Hll + Vertex[k].i*dh;
- y = Vll + Vertex[k].j*dv;
- rcBox.left = X0G + (int)(SFG*(x-Hll)) - 2;
- rcBox.top = Y0G + (int)(SFG*(Vur-y)) + 2;
- rcBox.right = rcBox.left + 5;
- rcBox.bottom = rcBox.top - 5;
-
- DRAW_QUAD (rcBox, 0,1,0);
- }
- }
-
- // Unmovable vertices
- for(i=0; i<=NH; i++)
- {
- for(j=0; j<=NV; j++)
- {
- if(!CanEdit(i,j))
- {
- x = Hll + i*dh;
- y = Vll + j*dv;
- rcBox.left = X0G + (int)(SFG*(x-Hll)) - 2;
- rcBox.top = Y0G + (int)(SFG*(Vur-y)) + 2;
- rcBox.right = rcBox.left + 5;
- rcBox.bottom = rcBox.top - 5;
-
- DRAW_QUAD (rcBox, 1,1,0);
- }
- }
- }
-
- // Legend
- rcBox.left = rc.left + cxChar/2 - 2;
- rcBox.top = rc.top - cyChar/2 - 2;
- rcBox.right = rcBox.left + 5;
- rcBox.bottom = rcBox.top - 5;
- DRAW_QUAD (rcBox, 1,0,0);
- texfont_write ("Fixed points", rcBox.right+cxChar,rcBox.top-4+cyChar/2);
-
- rcBox.top -= cyChar;
- rcBox.bottom -= cyChar;
- DRAW_QUAD (rcBox, 1,1,0);
- texfont_write ("Not movable", rcBox.right+cxChar, rcBox.top-4+cyChar/2);
-
- rcBox.top -= cyChar;
- rcBox.bottom -= cyChar;
- DRAW_QUAD (rcBox, 0,1,0);
- texfont_write ("Selected", rcBox.right+cxChar, rcBox.top-4+cyChar/2);
+void DrawGrid( Rect rc ){
+ int i, j, k;
+ double h,w,x,y;
+ Point pt[2];
+ Rect rcBox;
+
+ w = (double)( rc.right - rc.left + 1 ) - cxChar;
+ h = (double)( rc.top - rc.bottom + 1 ) - cxChar - cyChar;
+
+ SFG = w / ( Hur - Hll );
+ SFG = min( SFG, h / ( Vur - Vll ) );
+
+ // Center drawing
+ X0G = (int)( rc.left + rc.right - (int)( SFG * ( Hur - Hll ) ) ) / 2;
+ Y0G = (int)( rc.top + rc.bottom + cyChar - (int)( SFG * ( Vur - Vll ) ) ) / 2;
+
+ g_GLTable.m_pfn_qglLineWidth( 2 );
+ g_GLTable.m_pfn_qglColor3f( 0, 1, 0 );
+ g_GLTable.m_pfn_qglDisable( GL_LINE_STIPPLE );
+
+ pt[0].y = Y0G;
+ pt[1].y = Y0G + (int)( SFG * ( Vur - Vll ) );
+ g_GLTable.m_pfn_qglBegin( GL_LINES );
+ for ( i = 0; i <= NH; i++ )
+ {
+ x = Hll + i * dh;
+ pt[0].x = X0G + (int)( SFG * ( x - Hll ) );
+ g_GLTable.m_pfn_qglVertex2i( pt[0].x, pt[0].y );
+ g_GLTable.m_pfn_qglVertex2i( pt[0].x, pt[1].y );
+ }
+ g_GLTable.m_pfn_qglEnd();
+ pt[0].x = X0G;
+ pt[1].x = X0G + (int)( SFG * ( Hur - Hll ) );
+ g_GLTable.m_pfn_qglBegin( GL_LINES );
+ for ( i = 0; i <= NV; i++ )
+ {
+ y = Vll + i * dv;
+ pt[0].y = Y0G + (int)( SFG * ( Vur - y ) );
+ g_GLTable.m_pfn_qglVertex2i( pt[0].x,pt[0].y );
+ g_GLTable.m_pfn_qglVertex2i( pt[1].x,pt[0].y );
+ }
+ g_GLTable.m_pfn_qglEnd();
+
+ g_GLTable.m_pfn_qglLineWidth( 1 );
+
+ // Draw axes
+ pt[0].x = rc.right - cyChar - cxChar - cyChar / 2;
+ pt[0].y = rc.bottom + cyChar / 2;
+ pt[1].x = pt[0].x + cyChar;
+ pt[1].y = pt[0].y;
+ g_GLTable.m_pfn_qglBegin( GL_LINES );
+ g_GLTable.m_pfn_qglVertex2i( pt[0].x,pt[0].y );
+ g_GLTable.m_pfn_qglVertex2i( pt[1].x,pt[1].y );
+ g_GLTable.m_pfn_qglEnd();
+ switch ( Plane )
+ {
+ case PLANE_YZ0:
+ case PLANE_YZ1:
+ texfont_write( "Y", pt[1].x, pt[1].y + cyChar / 2 );
+ break;
+ default:
+ texfont_write( "X", pt[1].x, pt[1].y + cyChar / 2 );
+ }
+ pt[1].x = pt[0].x;
+ pt[1].y = pt[0].y + cyChar;
+ g_GLTable.m_pfn_qglBegin( GL_LINES );
+ g_GLTable.m_pfn_qglVertex2i( pt[0].x,pt[0].y );
+ g_GLTable.m_pfn_qglVertex2i( pt[1].x,pt[1].y );
+ g_GLTable.m_pfn_qglEnd();
+ switch ( Plane )
+ {
+ case PLANE_XY0:
+ case PLANE_XY1:
+ texfont_write( "Y", pt[1].x - cyChar / 2, pt[1].y + cyChar );
+ break;
+ default:
+ texfont_write( "Z", pt[1].x - cyChar / 2, pt[1].y + cyChar );
+ }
+
+ // Denote fixed points with a 5x5 red rectangle
+ for ( i = 0; i <= NH; i++ )
+ {
+ for ( j = 0; j <= NV; j++ )
+ {
+ if ( xyz[i][j].fixed ) {
+ x = Hll + i * dh;
+ y = Vll + j * dv;
+ rcBox.left = X0G + (int)( SFG * ( x - Hll ) ) - 2;
+ rcBox.top = Y0G + (int)( SFG * ( Vur - y ) ) + 2;
+ rcBox.right = rcBox.left + 5;
+ rcBox.bottom = rcBox.top - 5;
+
+ DRAW_QUAD( rcBox, 1,0,0 );
+ }
+ }
+ }
+
+ // Denote currently selected point with a 5x5 green rectangle
+ if ( NumVerticesSelected ) {
+ for ( k = 0; k < NumVerticesSelected; k++ )
+ {
+ x = Hll + Vertex[k].i * dh;
+ y = Vll + Vertex[k].j * dv;
+ rcBox.left = X0G + (int)( SFG * ( x - Hll ) ) - 2;
+ rcBox.top = Y0G + (int)( SFG * ( Vur - y ) ) + 2;
+ rcBox.right = rcBox.left + 5;
+ rcBox.bottom = rcBox.top - 5;
+
+ DRAW_QUAD( rcBox, 0,1,0 );
+ }
+ }
+
+ // Unmovable vertices
+ for ( i = 0; i <= NH; i++ )
+ {
+ for ( j = 0; j <= NV; j++ )
+ {
+ if ( !CanEdit( i,j ) ) {
+ x = Hll + i * dh;
+ y = Vll + j * dv;
+ rcBox.left = X0G + (int)( SFG * ( x - Hll ) ) - 2;
+ rcBox.top = Y0G + (int)( SFG * ( Vur - y ) ) + 2;
+ rcBox.right = rcBox.left + 5;
+ rcBox.bottom = rcBox.top - 5;
+
+ DRAW_QUAD( rcBox, 1,1,0 );
+ }
+ }
+ }
+
+ // Legend
+ rcBox.left = rc.left + cxChar / 2 - 2;
+ rcBox.top = rc.top - cyChar / 2 - 2;
+ rcBox.right = rcBox.left + 5;
+ rcBox.bottom = rcBox.top - 5;
+ DRAW_QUAD( rcBox, 1,0,0 );
+ texfont_write( "Fixed points", rcBox.right + cxChar,rcBox.top - 4 + cyChar / 2 );
+
+ rcBox.top -= cyChar;
+ rcBox.bottom -= cyChar;
+ DRAW_QUAD( rcBox, 1,1,0 );
+ texfont_write( "Not movable", rcBox.right + cxChar, rcBox.top - 4 + cyChar / 2 );
+
+ rcBox.top -= cyChar;
+ rcBox.bottom -= cyChar;
+ DRAW_QUAD( rcBox, 0,1,0 );
+ texfont_write( "Selected", rcBox.right + cxChar, rcBox.top - 4 + cyChar / 2 );