224 Introduction to C++ Programming and Graphics
file1<< setiosflags(ios::fixed | ios::showpoint);
for (int i=0; i<=ntcx; i++){
float xprint = xmin + i*rticx;
file1 << setprecision(3) << setw(6) << xprint << endl;}
for (int i=0; i<=ntcy; i++){
float yprint = ymin + i*rticy;
file1 << setprecision(3) << setw(6) << yprint << endl;}
file1.close();
float textszx = 0.3*xmargin; // text size
float textszy = 0.3*ymargin; // text size
textsize (textszx,textszy);
}
ifstream file2;
file2.open("xyunit");
char xunit[6];
char yunit[6];
//--- Draw the x tick marks:
for (int i=0; i<=ntcx; i++)
{
float xgo = xmin+i*rticx;
move2 (xgo, ymin);
rmove2 (0.0, tchy);
rdraw2 (0.0,-tchy);
if(Ilabelax==1)
{
move2(xgo-0.4*rticx, ymin-0.4*ymargin);
file2 >> xunit;
drawstr (xunit);
}
}
//--- Draw the y tick marks:
for (int i=0; i<=ntcy; i++)
{
float ygo = ymin+i*rticy;
move2 (xmin, ygo);
rmove2 (tchx, 0.0);
rdraw2 (-tchx, 0.0);
if(labelax==1)
{
move2 (xmin-0.9*xmargin,ygo-0.1*ymargin);
file2 >> yunit;
drawstr (yunit);