Модифицирование программы для определения класса, реализующего понятие геометрической фигуры в графической системе (Лабораторная работа № 2), страница 2

  case 2: ret=y[0]; break;

  case 3: ret=lx; break;

  case 4: ret=ly; break;

  case 5: ret=alf; break;

  case 6: ret=x[9]; break;

  case 7: ret=y[9]; break;

  case 8: ret=llx; break;

  case 9: ret=lly; break;

  case 10: ret=bet; break;

  case 11: ret=fatline; break;

  case 12: ret=typeline; break;

  case 13: ret=colorline; break;

  case 14: ret=typefill; break;

  case 15: ret=colorfill; break;

 }

 return ret;

}

int Romb::Getxy(int z)

{int ret;

 switch (z)

 {case 1: ret=x[1];break;

  case 2: ret=x[2];break;

  case 3: ret=x[3];break;

  case 4: ret=x[4];break;

  case 5: ret=x[5];break;

  case 6: ret=x[6];break;

  case 7: ret=x[7];break;

  case 8: ret=x[8];break;

  case 9:  ret=y[1];break;

  case 10: ret=y[2];break;

  case 11: ret=y[3];break;

  case 12: ret=y[4];break;

  case 13: ret=y[5];break;

  case 14: ret=y[6];break;

  case 15: ret=y[7];break;

  case 16: ret=y[8];break;

 }

 return ret;

}

//------------------LOAD from file--------------------------

void Romb::load()

{float cx, sx, cy, sy;

 FILE *load;

 load=fopen ("load.txt","r");

//---------------------------------------------------------1

 fscanf (load,"%d%d%d%d%d",&x[0],&y[0],&lx,&ly,&alf);

//---------------------------------------------------------2

 fscanf (load,"%d%d%d%d%d",&x[9],&y[9],&llx,&lly,&bet);

//-----------------------------------------------------Graph

 fscanf (load,"%d%d%d%d%d",&fatline,&typeline,&colorline,&typefill,&colorfill);

 n=4;

 calculation();

}

//----------------------Calculation---------------------------

void Romb::calculation()

{float cx, sx, cy, sy;

 cx=lx*cos(alf*0.0175);

 sx=lx*sin(alf*0.0175);

 sy=ly*sin(alf*0.0175);

 cy=ly*cos(alf*0.0175);

 x[1]=x[0]-cx;

 y[1]=y[0]-sx;

 x[2]=x[0]+sy;

 y[2]=y[0]-cy;

 x[3]=x[0]+cx;

 y[3]=y[0]+sx;

 x[4]=x[0]-sy;

 y[4]=y[0]+cy;

 cx=llx*cos(bet*0.0175);

 sx=llx*sin(bet*0.0175);

 sy=lly*sin(bet*0.0175);

 cy=lly*cos(bet*0.0175);

 x[5]=x[9]-cx;

 y[5]=y[9]-sx;

 x[6]=x[9]+sy;

 y[6]=y[9]-cy;

 x[7]=x[9]+cx;

 y[7]=y[9]+sx;

 x[8]=x[9]-sy;

 y[8]=y[9]+cy;

}

//------------------------SAVE to File------------------------

void Romb::save()

{FILE *save;

 int i;

 save=fopen("save.txt","w");

 fprintf (save,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",x[0],y[0],lx,ly,alf,x[9],y[9],llx,lly,bet,fatline,typeline,colorline,typefill,colorfill);

}

//--------------Destruct--------------------------------------

Romb::~Romb()

{

}

//-----------------------Just four Lines

void Romb::drawromb()

{line (x[1+n],y[1+n],x[2+n],y[2+n]);

 line (x[2+n],y[2+n],x[3+n],y[3+n]);

 line (x[3+n],y[3+n],x[4+n],y[4+n]);

 line (x[4+n],y[4+n],x[1+n],y[1+n]);

}

//----------------Contour of romb-------------------------------

void Romb::contromb()

{ setlinestyle (typeline,0,fatline);

  setcolor(colorline);

  drawromb();

}

//----------------Color romb------------------------------------

void Romb::coloromb()

{ setcolor(colorline);

  setlinestyle(0,0,fatline);

  drawromb();

  setfillstyle(typefill,colorfill);

  floodfill(x[0],y[0],colorline);

  setcolor(0);

  drawromb();

  setcolor(colorline);

  setlinestyle(typeline,0,fatline);

  drawromb();

}

//------------------Double romb---------------------------------

void Romb::dupromb()

{int col;

   coloromb();

   n=0;

   col=colorfill;

   colorfill=0;

   coloromb();

   colorfill=col;

   n=4;

}

//-----------------Graphic options------------------------------

void Romb::options(int fl,int tl,int cl,int tf,int cf)