Back to index

gcompris  8.2.2
Classes | Defines | Typedefs | Enumerations | Functions | Variables
gtans.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _tanpoly
struct  _tansmalltri
struct  _tanfpnt
struct  _tanpiecedef
struct  _tanpiecepos
struct  _tanfigure
struct  _tanflpiece
struct  _tanflfig

Defines

#define AN_none   0
#define AN_move   1
#define AN_rot   2
#define ARON   0.39999
#define mPI   3.14159265356
#define TOUR   65536
#define PASTOUR   (mPI/TOUR*2)
#define CL   1.4142135624
#define CC   CL/2
#define HT   TOUR/8
#define TYPENBR   5 /* nombre de type de pieces */
#define PIECENBR   7 /* nombre de pieces par figure */
#define TRINBRMAX   4 /* nombre de triangle max par piece */
#define PNTNBRMAX   4 /* nombre de points max par piece */
#define TINYNBR   32 /* nombre de tiny triangles */
#define GRISNBR   8
#define GCPIECENOR   GRISNBR
#define GCPIECEHI   GRISNBR+1
#define GCPIECEBG   GRISNBR+2
#define GCPIECEHLP   GRISNBR+3
#define GCPETITEFG   GRISNBR+4
#define GCPETITEBG   GRISNBR+5
#define GCPETITECHK   GRISNBR+6
#define GCPETITEHLP   GRISNBR+7
#define GCPIECELAST   GCPIECEHLP
#define GCPETITEFIRST   GCPETITEFG
#define GCNBR   GCPETITEHLP+1
#define PXNBR   3
#define PXSTART   GCPIECENOR

Typedefs

typedef struct _tanpoly tanpoly
typedef struct _tansmalltri
typedef struct _tansmalltri tansmalltri
typedef struct _tanfpnt tanfpnt
typedef struct _tanpiecedef tanpiecedef
typedef struct _tanpiecepos tanpiecepos
typedef struct _tanfigure tanfigure
typedef struct _tanflpiece tanflpiece
typedef struct _tanflfig tanflfig

Enumerations

enum  tanremplis { TAN_PIECENOR = 5, TAN_PIECEHI, TAN_PETITEFG, TAN_PETITEHLP }
enum  tanpolytype { TAN_POLYNORMAL = 5, TAN_POLYBACK, TAN_POLYON }

Functions

void tanclampgrandefig (void)
void tanrecentreout (double oldzoom, double newzoom)
void tanclearreussinr (int fignr)
void tansetreussiactual (void)
void tanreleaseifrot (void)
int tanangle (double dx, double dy)
void spesavefig (void)
void tanend (void)
gboolean tanloadfigtab (char *name)
gboolean tansetpixmapmode (GtkWidget *widget, char *aname, int gcnbr)
void tansetcolormode (GdkColor *acolor, int gcnbr)
void tanredrawgrande (void)
void tanredrawpetite (void)
gboolean tansaveconfig (void)
void taninitcbgr (void)
void taninitcbpe (void)
int tanwichisselect (int x, int y)
void tansetnewfigurepart2 (void)
void tansetnewfigurepart1 (int nrfig)
void tanunselect (void)
void tandrawselect (int dx, int dy, int drot)
void taninitselect (int selected, gboolean necessaire)
void tantranstinytab (tantinytri *tinys)
void tanmaketinytabnotr (tanfigure *figure, tantinytri *tinys)
gboolean tantinytabcompare (tantinytri *tinys1, tantinytri *tinys2, int accuracy)
void tancolle (tanfigure *figure, double seuil)
void tanstatprov (gchar *msg)
void tanstatpop (void)
void tanstatpush (gchar *msg)
void change_figure (gboolean next)

Variables

GtkWidget * mainwindow
GtkWidget * widgetgrande
GtkWidget * widgetpetite
GtkStatusbar * widgetstat
GtkSpinButton * spinner
gint statconid
GdkRectangle selbackrect
GdkPixmap * pixmapgrande1
GdkPixmap * pixmapgrande2
GdkPixmap * pixmappetite
GdkPixmap * pixmappiece1
GdkPixmap * pixmappiece2
GdkPixmap * pixmapfond
GtkWidget * colselwin
GtkWidget * filselwin
tanpiecedef piecesdef []
tanfigure figuredebut
tanfigurefigtab
int figtabsize
int figactualnr
char * figfilename
tantinytri tinytabpe [TINYNBR]
tantinytri tinytabgr [TINYNBR]
tanfigure figgrande
tanfigure figpetite
int selectedgrande
int xact
int yact
int xoth
int yoth
int xold
int yold
int actiongrande
int selpossible
int rotact
int rotnew
int rotold
int rotstepnbr
int initcbgr
int initcbpe
GdkGC * invertgc
int invx2
int invy2
GdkGC * tabgc [GCNBR]
GdkColor colortab [GCNBR]
GdkPixmap ** tabpxpx
char ** tabpxnam
gboolean helpoutset
gboolean helptanset
int accuracy
gboolean editmode

Class Documentation

struct _tanpoly

Definition at line 57 of file gtans.h.

Class Members
int firstpnt
int pntnbr
tanpolytype polytype
struct _tansmalltri

Definition at line 65 of file gtans.h.

Class Members
double posx
double posy
int rot
struct _tanfpnt

Definition at line 72 of file gtans.h.

Class Members
double posx
double posy
struct _tanpiecedef

Definition at line 78 of file gtans.h.

Collaboration diagram for _tanpiecedef:
Class Members
double handlex
double handley
tanfpnt pnt
int pntnbr
tansmalltri tri
int trinbr
struct _tanpiecepos

Definition at line 88 of file gtans.h.

Class Members
int flipped
double posx
double posy
int rot
int type
struct _tanfigure

Definition at line 97 of file gtans.h.

Collaboration diagram for _tanfigure:
Class Members
double distmax
int drotmax
tanpiecepos piecepos
gboolean reussi
double zoom
struct _tanflpiece

Definition at line 106 of file gtans.h.

Collaboration diagram for _tanflpiece:
Class Members
int flpntnbr
tanfpnt * flpnts
tanpolytype polytype
struct _tanflfig

Definition at line 113 of file gtans.h.

Collaboration diagram for _tanflfig:
Class Members
tanfigure * figure
int flpiecenbr
tanflpiece flpieces

Define Documentation

#define AN_move   1

Definition at line 4 of file gtans.h.

#define AN_none   0

Definition at line 3 of file gtans.h.

#define AN_rot   2

Definition at line 5 of file gtans.h.

#define ARON   0.39999

Definition at line 7 of file gtans.h.

#define CC   CL/2

Definition at line 13 of file gtans.h.

#define CL   1.4142135624

Definition at line 12 of file gtans.h.

#define GCNBR   GCPETITEHLP+1

Definition at line 34 of file gtans.h.

#define GCPETITEBG   GRISNBR+5

Definition at line 28 of file gtans.h.

#define GCPETITECHK   GRISNBR+6

Definition at line 29 of file gtans.h.

#define GCPETITEFG   GRISNBR+4

Definition at line 27 of file gtans.h.

#define GCPETITEFIRST   GCPETITEFG

Definition at line 33 of file gtans.h.

#define GCPETITEHLP   GRISNBR+7

Definition at line 30 of file gtans.h.

#define GCPIECEBG   GRISNBR+2

Definition at line 25 of file gtans.h.

#define GCPIECEHI   GRISNBR+1

Definition at line 24 of file gtans.h.

#define GCPIECEHLP   GRISNBR+3

Definition at line 26 of file gtans.h.

#define GCPIECELAST   GCPIECEHLP

Definition at line 32 of file gtans.h.

#define GCPIECENOR   GRISNBR

Definition at line 23 of file gtans.h.

#define GRISNBR   8

Definition at line 22 of file gtans.h.

#define HT   TOUR/8

Definition at line 14 of file gtans.h.

#define mPI   3.14159265356

Definition at line 9 of file gtans.h.

#define PASTOUR   (mPI/TOUR*2)

Definition at line 11 of file gtans.h.

#define PIECENBR   7 /* nombre de pieces par figure */

Definition at line 16 of file gtans.h.

#define PNTNBRMAX   4 /* nombre de points max par piece */

Definition at line 18 of file gtans.h.

#define PXNBR   3

Definition at line 37 of file gtans.h.

#define PXSTART   GCPIECENOR

Definition at line 38 of file gtans.h.

#define TINYNBR   32 /* nombre de tiny triangles */

Definition at line 19 of file gtans.h.

#define TOUR   65536

Definition at line 10 of file gtans.h.

#define TRINBRMAX   4 /* nombre de triangle max par piece */

Definition at line 17 of file gtans.h.

#define TYPENBR   5 /* nombre de type de pieces */

Definition at line 15 of file gtans.h.


Typedef Documentation

typedef struct _tansmalltri

Definition at line 64 of file gtans.h.

typedef struct _tanfigure tanfigure
typedef struct _tanflfig tanflfig
typedef struct _tanflpiece tanflpiece
typedef struct _tanfpnt tanfpnt
typedef struct _tanpiecedef tanpiecedef
typedef struct _tanpiecepos tanpiecepos
typedef struct _tanpoly tanpoly
typedef struct _tansmalltri tansmalltri

Enumeration Type Documentation

Enumerator:
TAN_POLYNORMAL 
TAN_POLYBACK 
TAN_POLYON 

Definition at line 49 of file gtans.h.

enum tanremplis
Enumerator:
TAN_PIECENOR 
TAN_PIECEHI 
TAN_PETITEFG 
TAN_PETITEHLP 

Definition at line 41 of file gtans.h.


Function Documentation

void change_figure ( gboolean  next)

Definition at line 170 of file gtans.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void spesavefig ( void  )

Definition at line 1798 of file gtans.c.

                      {

 FILE *hand;
 int j;
 tanfigure *fig=NULL; /*juste pour eviter un warning*/

 if ( (hand=fopen("pouet.fig", "w"))!=NULL){

   fprintf(hand, "gTans v1.0 %d \n",figtabsize);

   fig=&figgrande;
   fprintf(hand,"%e %e %d \n",1.0,fig->distmax,fig->drotmax);
   for (j=0; j<PIECENBR; j++)
     fprintf(hand,"p %d %d %e %e %d \n",fig->piecepos[j].type,fig->piecepos[j].flipped,
            fig->piecepos[j].posx,fig->piecepos[j].posy,fig->piecepos[j].rot);
 }

 if (hand!=NULL){
   fclose(hand);
   figpetite=*fig;
   figpetite.zoom=1;
   tansetnewfigurepart1(-2);
   tansetnewfigurepart2();
 }

}

Here is the call graph for this function:

int tanangle ( double  dx,
double  dy 
)

Definition at line 319 of file gtans.c.

                                   {
  int ret;

  ret = (int)(atan2(dy,dx)/PASTOUR);
  ret = (ret+TOUR)%TOUR;

  return (ret);

}

Here is the caller graph for this function:

void tanclampgrandefig ( void  )

Definition at line 299 of file gtans.c.

                             {
  
  tanpiecepos *piecepos;
  int i;
  double dumzoom;
  
  dumzoom = 1.0/figgrande.zoom;
  piecepos = figgrande.piecepos;
  for (i = 0; i<PIECENBR; i++){
    piecepos->posx = CLAMP(piecepos->posx, 0.0, dumzoom);
    piecepos->posy = CLAMP(piecepos->posy, 0.0, dumzoom);
    piecepos++;
  }
  
  return;
}

Here is the caller graph for this function:

void tanclearreussinr ( int  fignr)

Definition at line 953 of file gtans.c.

                                 {

  if ( fignr>= 0 && fignr<figtabsize )
    (figtab+fignr)->reussi = FALSE;
  
}
void tancolle ( tanfigure figure,
double  seuil 
)

Definition at line 613 of file gtans.c.

                                               {

  tanpiecepos *piecepos;
  tanfpnt pnts1[PNTNBRMAX+1],pnts2[PNTNBRMAX+1];
  int pntnbr1,pntnbr2;
  int i,j,k,l;
  int nbrcommun;
  double dx,dy,dx2,dy2,dxtot,dytot;

  seuil*=seuil;
  piecepos=figure->piecepos;

  for (i=0; i<PIECENBR-1; i++){
    for (j=i+1; j<PIECENBR; j++) {
      pntnbr1=tanplacepiecefloat(&piecepos[i],pnts1,1);
      pntnbr2=tanplacepiecefloat(&piecepos[j],pnts2,1);
      nbrcommun=0;
      dxtot=dytot=0;
      for (k=0; k<pntnbr1; k++){
       for (l=0; l<pntnbr2; l++){
         dx=pnts1[k+1].posx-pnts2[l].posx;
         dy=pnts1[k+1].posy-pnts2[l].posy;
         dx2=pnts1[k].posx-pnts2[l+1].posx;
         dy2=pnts1[k].posy-pnts2[l+1].posy;
         if ( (dx*dx+dy*dy)>seuil && (dx2*dx2+dy2*dy2)>seuil ){
           if ( tandistcarsegpnt(&pnts1[k],&pnts2[l],&dx,&dy)<seuil/4 ){
             nbrcommun++;
             dxtot-=dx;
             dytot-=dy;
           }
           if ( tandistcarsegpnt(&pnts2[l],&pnts1[k],&dx,&dy)<seuil/4 ){
             nbrcommun++;
             dxtot+=dx;
             dytot+=dy;
           }
         }
       }
      }
      if (nbrcommun){
       piecepos[j].posx+=dxtot/nbrcommun;
       piecepos[j].posy+=dytot/nbrcommun;
      }
      
      pntnbr2=tanplacepiecefloat(&piecepos[j],pnts2,1);
      nbrcommun=0;
      dxtot=dytot=0;
      for (k=0; k<pntnbr1; k++){
       for (l=0; l<pntnbr2; l++){
         dx=(pnts1[k].posx-pnts2[l].posx);
         dy=(pnts1[k].posy-pnts2[l].posy);
         if ( (dx*dx+dy*dy)<seuil ){
           nbrcommun++;
           dxtot+=dx;
           dytot+=dy;
         }
/*       else{
           dx=(pnts1[(k+1)*2]-pnts2[l*2]);
           dy=(pnts1[(k+1)*2+1]-pnts2[l*2+1]);
           dx2=(pnts1[k*2]-pnts2[(l+1)*2]);
           dy2=(pnts1[k*2+1]-pnts2[(l+1)*2+1]);
           if ( (dx*dx+dy*dy)>seuil && (dx2*dx2+dy2*dy2)>seuil ){
             if ( tandistcarsegpnt(pnts1+k*2,pnts2+l*2,&dx,&dy)<seuil/100 ){
              nbrcommun++;
              dxtot-=dx;
              dytot-=dy;
             }
             if ( tandistcarsegpnt(pnts2+l*2,pnts1+k*2,&dx,&dy)<seuil/100 ){
              nbrcommun++;
              dxtot+=dx;
              dytot+=dy;
             }
           }
         }         */
       }
      }
      
      if (nbrcommun){
       piecepos[j].posx+=dxtot/nbrcommun;
       piecepos[j].posy+=dytot/nbrcommun;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tandrawselect ( int  dx,
int  dy,
int  drot 
)

Definition at line 888 of file gtans.c.

                                            {
  tanpiecepos *selpiece;
  double zoom;
  int dumrot;
  GdkRectangle selbk2;

  selpiece=&(figgrande.piecepos[PIECENBR-1]);
  zoom=widgetgrande->allocation.width*figgrande.zoom;
  
  selposxnc += dx/zoom;
  selposync += dy/zoom;

  selpiece->posx = CLAMP(selposxnc, 0, 1.0/figgrande.zoom);
  selpiece->posy = CLAMP(selposync, 0, 1.0/figgrande.zoom);
  dumrot=selpiece->rot;
  rotnew=selpiece->rot-=drot;

  gdk_draw_pixmap(pixmapgrande1,
                widgetgrande->style->fg_gc[GTK_WIDGET_STATE (widgetgrande)],
                pixmapgrande2,
                selbackrect.x,selbackrect.y,
                selbackrect.x,selbackrect.y,
                selbackrect.width,selbackrect.height);

  selbk2=tandrawpiece(widgetgrande,pixmapgrande1,
                    selpiece,
                    zoom,
                    TAN_PIECEHI);

  gtk_widget_draw (widgetgrande, &selbackrect);
  gtk_widget_draw (widgetgrande, &selbk2);

  selbackrect=selbk2;

  selpiece->rot=dumrot;

}

Here is the call graph for this function:

Here is the caller graph for this function:

void tanend ( void  )

Definition at line 1883 of file gtans.c.

                 {
  int i;
  GdkColormap *syscmap;

  syscmap = gdk_colormap_get_system();

  tansavefigstatus(figfilename, figtab, figtabsize);

  if (usergtdir!=NULL)
    g_free(usergtdir);

  if (userconf!=NULL)
    g_free(userconf);

  if (figfilename!=NULL)
    g_free(figfilename);

  if (figtab!=NULL)
    g_free(figtab);
  
  if (pixmappetite!=NULL)
    gdk_pixmap_unref(pixmappetite);
  if (pixmapgrande1!=NULL)
    gdk_pixmap_unref(pixmapgrande1);
  if (pixmapgrande2!=NULL)
    gdk_pixmap_unref(pixmapgrande2);
  if (pixmappiece1!=NULL)
    gdk_pixmap_unref(pixmappiece1);
  if (pixmappiece2!=NULL)
    gdk_pixmap_unref(pixmappiece2);
  if (pixmapfond!=NULL)
    gdk_pixmap_unref(pixmapfond);
  
  for (i=PXSTART; i<PXSTART+PXNBR; i++){
    if (tabpxpx[i]!=NULL)
      gdk_pixmap_unref(tabpxpx[i]);
    if (tabpxnam[i]!=NULL)
      g_free(tabpxnam[i]);
  }

  for (i = 0; i<GCNBR; i++){
    if (tabgc[i]!=NULL)
      gdk_gc_unref(tabgc[i]);
    if (tabcolalloc[i])
      gdk_colormap_free_colors (syscmap, &colortab[i], 1);
  }  

  gdk_gc_unref(invertgc);

  gtk_main_quit ();
}

Here is the call graph for this function:

void taninitcbgr ( void  )

Definition at line 1943 of file gtans.c.

                      {
  int i;
  GdkColor *color;

  initcbgr = TRUE; /* pour ne pas initialiser 2 fois */

  for (i=PXSTART; i<PXSTART+PXNBR; i++){
    tabgc[i] = gdk_gc_new(widgetgrande->window);
    if (tabpxpixmode[i])
      tansetpixmapmode(widgetgrande,tabpxnam[i],i);
    else
      tansetcolormode(&colortab[i],i);
  }

  for (i=0; i<GRISNBR; i++){
    color = &colortab[i];
    color->red = color->green = color->blue = (gushort)(65535.0/(GRISNBR-1)*i);
    tabgc[i] = gdk_gc_new(widgetgrande->window);
    tansetcolormode(color,i);
  }

  invertgc=gdk_gc_new(widgetgrande->window);
  gdk_gc_set_function(invertgc,GDK_INVERT);
  tabgc[GCPIECEHLP]=gdk_gc_new(widgetgrande->window);
  tansetcolormode(&colortab[GCPIECEHLP],GCPIECEHLP);
  /* les line attribute sont dans le callback */

  if (initcbpe)
    taninitcbcommun();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void taninitcbpe ( void  )

Definition at line 1977 of file gtans.c.

                      {

  initcbpe=TRUE; /* pour ne pas initialiser 2 fois (c'est pas propre, mais bon) */

  tabgc[GCPETITEFG]=gdk_gc_new(widgetpetite->window);
  tansetcolormode(&colortab[GCPETITEFG],GCPETITEFG);

  tabgc[GCPETITEBG]=gdk_gc_new(widgetpetite->window);
  tansetcolormode(&colortab[GCPETITEBG],GCPETITEBG);

  tabgc[GCPETITEHLP]=gdk_gc_new(widgetpetite->window);
  tansetcolormode(&colortab[GCPETITEHLP],GCPETITEHLP);

  tabgc[GCPETITECHK]=gdk_gc_new(widgetpetite->window);
  tansetcolormode(&colortab[GCPETITECHK],GCPETITECHK);

  if (initcbgr)
    taninitcbcommun();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void taninitselect ( int  selected,
gboolean  necessaire 
)

Definition at line 857 of file gtans.c.

                                                {

  int i;
  tanpiecepos dum;

  if ( force ||
       selected != PIECENBR-1 ||
       !selectedgrande ){

    tandrawbgndgr(pixmapgrande2);

    tandrawfigure(widgetgrande,pixmapgrande2,&figgrande,
                selected,TAN_PIECENOR);

    selbackrect.x=0;
    selbackrect.y=0;
    selbackrect.width=widgetgrande->allocation.width;
    selbackrect.height=widgetgrande->allocation.height;

    dum=figgrande.piecepos[selected];
    for (i=selected; i<PIECENBR-1; i++)
      figgrande.piecepos[i]=figgrande.piecepos[i+1];
    figgrande.piecepos[PIECENBR-1]=dum;
  }

  selposxnc = figgrande.piecepos[PIECENBR-1].posx;
  selposync = figgrande.piecepos[PIECENBR-1].posy;

}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean tanloadfigtab ( char *  name)

Definition at line 1085 of file gtans.c.

                                   {

 FILE *hand=NULL;
 int i,j;
 gboolean succes;
 int newfigtabsize;
 tanfigure *newfigtab=NULL,*figs;
 int lres;

 lres=0;

 if ( (hand = fopen(name, "r"))!=NULL &&
      fscanf(hand, "gTans v1.0 %d \n", &newfigtabsize)==1 &&
      (newfigtab = (tanfigure *)g_malloc(sizeof(tanfigure)*newfigtabsize))!=NULL ){

   lres=1;
   figs = newfigtab;
   for (i = 0; i<newfigtabsize; i++){
     *figs = figuredebut;
     figs->zoom = tanreadfloat(hand, &lres);
     figs->distmax = tanreadfloat(hand, &lres);
     SPESC(hand,"%d \n", &figs->drotmax);
     /*fscanf(hand,"%le %le %d \n",&figs->zoom,&figs->distmax,&figs->drotmax);*/
     for (j=0; j<PIECENBR; j++){
       SPESC(hand,"p %d", &figs->piecepos[j].type);
       SPESC(hand,"%d", &figs->piecepos[j].flipped);
       figs->piecepos[j].posx = tanreadfloat(hand, &lres);
       figs->piecepos[j].posy = tanreadfloat(hand, &lres);
       SPESC(hand,"%d \n", &figs->piecepos[j].rot);
       /*fscanf(hand,"%d %d %le %le %d \n",&figs->piecepos[j].type,&figs->piecepos[j].flipped,
        &figs->piecepos[j].posx,&figs->piecepos[j].posy,&figs->piecepos[j].rot);*/
     }
     figs++;
   }
 } else
      g_warning("Opening file %s fails",name);
 
 if (hand!=NULL)
   fclose(hand);

 succes=FALSE;
 if (lres==1){
   succes=TRUE;

   tansavefigstatus(figfilename, figtab, figtabsize);
   
   if(figtab!=NULL)
     g_free(figtab);
   
   tanloadfigstatus(name, newfigtab, newfigtabsize);

   figtab=newfigtab;
   figtabsize=newfigtabsize;

   actual_figure = 0;

   tansetnewfigurepart1(actual_figure);
   tansetnewfigurepart2();

   //tanspinsetvalmax(figtabsize-1);
 }

 if (succes || figfilename==NULL)
   tanallocname(&figfilename, name);
 
 return(succes);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void tanmaketinytabnotr ( tanfigure figure,
tantinytri *  tinys 
)

Definition at line 410 of file gtans.c.

                                                              {

  int i,j;
  tansmalltri dusmall,*small=&dusmall;
  tanpiecepos *piecepos;
  tanpiecedef *piecedat;
  double ly,lx2,cosrot,sinrot;
  int rot,rottri;

  piecepos=figure->piecepos;

  for (j=0; j<PIECENBR; j++){

    piecedat=&piecesdef[piecepos->type];
    rot=piecepos->rot;
    cosrot=cos(rot*PASTOUR);
    sinrot=sin(rot*PASTOUR);

    for (i=0; i<piecedat->trinbr; i++){
      lx2=piecedat->tri[i].posx-piecedat->handlex;
      ly=piecedat->tri[i].posy-piecedat->handley;
      rottri=piecedat->tri[i].rot;

      if (piecepos->flipped){
       lx2=-lx2;
       rottri=TOUR+6*HT-rottri;
      }
      
      small->posx=piecepos->posx+lx2*cosrot+ly*sinrot;
      small->posy=piecepos->posy+ly*cosrot-lx2*sinrot;
      small->rot=(rottri+rot)%TOUR;
      tansmall2tiny(small,tinys,tinys+1);
      tinys+=2;
    }
    piecepos++;
  }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void tanrecentreout ( double  oldzoom,
double  newzoom 
)

Definition at line 1755 of file gtans.c.

                                                   {

  tanpiecepos *piecepos;
  int i;
  double correction;
  
  correction = 0.5*(1/oldzoom-1/newzoom);

  dxout += correction;
  dyout += correction;

  piecepos = figgrande.piecepos;
  for (i = 0; i<PIECENBR; i++){
    piecepos->posx -= correction;
    piecepos->posy -= correction;
    piecepos++;
  }
  
  return;
}
void tanredrawgrande ( void  )

Definition at line 928 of file gtans.c.

                           {

  GdkRectangle rect={0,0,0,0};
  GtkWidget *widget=NULL;


  tanreleaseifrot();

  if (selectedgrande){
    taninitselect(PIECENBR-1, TRUE);
    tandrawselect(0,0,0);
  }
  else{
    widget=widgetgrande;
    tandrawbgndgr(pixmapgrande1);
    tandrawfigure(widget, pixmapgrande1, &figgrande, PIECENBR+1, TAN_PIECENOR);
    rect.width=widget->allocation.width;
    rect.height=widget->allocation.height;
    gtk_widget_draw (widget, &rect);
  }
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tanredrawpetite ( void  )

Definition at line 972 of file gtans.c.

                           {

  GdkRectangle rect={0,0,0,0};
  int wid,hei;

  /* in case we are called before widget configured */
  if (!widgetpetite)
    return;

  wid = widgetpetite->allocation.width;
  hei = widgetpetite->allocation.height;

  gdk_draw_rectangle (pixmappetite,
                    figpetite.reussi ? tabgc[GCPETITECHK] : tabgc[GCPETITEBG],
                    TRUE,
                    0, 0, wid, hei);

  if (!figtabsize)
    return;

  tandrawfloat (pixmappetite, FALSE);

  if (helptanset<PIECENBR)
    tandrawpiece(widgetpetite,
               pixmappetite,
               &figpetite.piecepos[helptanset],
               widgetpetite->allocation.width*figpetite.zoom,
               TAN_PETITEHLP);

  /* tandrawfigure(widget, pixmappetite, &figpetite, PIECENBR+1, TAN_PETITEFG); */

  rect.width=wid;
  rect.height=hei;
  gtk_widget_draw (widgetpetite, &rect);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void tanreleaseifrot ( void  )

Definition at line 477 of file gtans.c.

Here is the caller graph for this function:

gboolean tansaveconfig ( void  )
void tansetcolormode ( GdkColor *  acolor,
int  gcnbr 
)

Definition at line 1202 of file gtans.c.

                                                 {

  GdkPixmap *pixmap;
  GdkGC *gc;
  GdkColor *pcolor;
  GdkColormap *syscmap;
  
  gc = tabgc[gcnbr];
  pcolor = &colortab[gcnbr];
  syscmap = gdk_colormap_get_system();

  if (tabcolalloc[gcnbr])
    gdk_colormap_free_colors (syscmap, pcolor, 1);
  
  if ( gcnbr>=PXSTART && gcnbr<PXSTART+PXNBR ){
    tabpxpixmode[gcnbr] = FALSE;
    if ( (pixmap = tabpxpx[gcnbr])!=NULL ){
      tabpxpx[gcnbr] = NULL;
      gdk_pixmap_unref(pixmap);
    }  
  }
  
  pcolor->red = acolor->red;
  pcolor->green = acolor->green;
  pcolor->blue = acolor->blue;
  tabcolalloc[gcnbr] = gdk_colormap_alloc_color (syscmap, pcolor, FALSE, TRUE);
  gdk_gc_set_fill (gc, GDK_SOLID);
  gdk_gc_set_foreground (gc, pcolor);
  
}

Here is the caller graph for this function:

void tansetnewfigurepart1 ( int  nrfig)

Definition at line 1640 of file gtans.c.

                                    {

  tanfigure *figure;
  int i,j;
  double xmin=10000,xmax=-10000,ymin=10000,ymax=-10000;
  tanpiecepos *piecepos;
  tanflfig *flfig=&flfigpetite;
  int flpiecenbr,flpntnbr;
  tanfpnt *fpnts;
  tanfpnt dumfpnts[FLPNTMAX];
  tanpoly polys[PIECENBR];
  int polypntact,polypntnbr;
  int pntsuivants[FLPNTMAX];
  double seuil=0.00000000001;
  int pntnew;

  if ( nrfig>=0 && figtabsize ){
    nrfig %= figtabsize;
    actual_figure = nrfig;
    figure = figtab+nrfig;
  } else {
    if (nrfig==-1)
      figure = &figuredebut;
    else
      figure = &figpetite;
    nrfig = -1;
  }

  figactualnr = nrfig;

  helptanset=PIECENBR;
  figpetite=*figure;
  tancolle(&figpetite,0.02);
  tanmaketinytabnotr(&figpetite,tinytabpe);
  tantranstinytab(tinytabpe);

  /* la floatfig et preparation de la concatenation */
  flfig->flpiecenbr = PIECENBR;
  flfig->figure = figure;
  fpnts = dumfpnts;
  polypntact = 0;
  for (i = 0; i<PIECENBR; i++){
    polypntnbr = piecesdef[figure->piecepos[i].type].pntnbr;
    polys[i].pntnbr = polypntnbr;
    polys[i].firstpnt = polypntact;
    polys[i].polytype = TAN_POLYNORMAL;

    for (j = 0; j<polypntnbr-1; j++)
      pntsuivants[polypntact+j] = polypntact+j+1;
    pntsuivants[polypntact+j] = polypntact;
    polypntact += polypntnbr+1;

    tanplacepiecefloat(&figure->piecepos[i], fpnts,1);
    fpnts += polypntnbr+1;
  }  
  
  tanconcat(flfig, polys, pntsuivants, dumfpnts, seuil);
  tanconseq(flfig, polys, pntsuivants, dumfpnts, seuil);

  pntnew = tantasse(flfig, polys, pntsuivants, dumfpnts, fpntspetite);
  tanajoute(flfig, polys, pntsuivants, dumfpnts, seuil, pntnew);
  tanconcat(flfig, polys, pntsuivants, dumfpnts, seuil);
  tanconseq(flfig, polys, pntsuivants, dumfpnts, seuil);
  if (taninclus(flfig, polys, pntsuivants, dumfpnts, seuil))
    taninclus(flfig, polys, pntsuivants, dumfpnts, seuil);
  tanalign(flfig, polys, pntsuivants, dumfpnts);
  tanremsame(flfig, polys, pntsuivants, dumfpnts, seuil);
  
  pntnew = tantasse(flfig, polys, pntsuivants, dumfpnts, fpntspetite);
  tanajoute(flfig, polys, pntsuivants, dumfpnts, seuil, pntnew);
  tanconcat(flfig, polys, pntsuivants, dumfpnts, seuil);
  tanconseq(flfig, polys, pntsuivants, dumfpnts, seuil);
  if (taninclus(flfig, polys, pntsuivants, dumfpnts, seuil))
    taninclus(flfig, polys, pntsuivants, dumfpnts, seuil);
  tanalign(flfig, polys, pntsuivants, dumfpnts);
  tanremsame(flfig, polys, pntsuivants, dumfpnts, seuil);

  tantasse(flfig, polys, pntsuivants, dumfpnts, fpntspetite);

  /* calcul du centrage */
  flpiecenbr = flfig->flpiecenbr;
  for (i = 0; i<flpiecenbr; i++){
    fpnts = flfig->flpieces[i].flpnts;
    flpntnbr = flfig->flpieces[i].flpntnbr;
    for (j = 0; j<flpntnbr; j++){
      if (fpnts[j].posx>xmax)
       xmax=fpnts[j].posx;
      if (fpnts[j].posy>ymax)
       ymax=fpnts[j].posy;
      if (fpnts[j].posx<xmin)
       xmin=fpnts[j].posx;
      if (fpnts[j].posy<ymin)
       ymin=fpnts[j].posy;
    }
  }
  
  figpetite.zoom = 1/(( (xmax-xmin)>(ymax-ymin) ? (xmax-xmin) : (ymax-ymin) )+0.25);
  dxpetite = 0.5*(xmax+xmin)-(0.5/figpetite.zoom);
  dypetite = 0.5*(ymax+ymin)-(0.5/figpetite.zoom);
  
  dxout = 0.5*(xmax+xmin)-(0.5/figgrande.zoom);    /* cf tanrecentreout pour correction */
  dyout = 0.5*(ymax+ymin)-(0.5/figgrande.zoom);
  
  /* centrage des pieces petite */
  piecepos=figpetite.piecepos;
  for (i=0; i<PIECENBR; i++){
    piecepos->posx-=dxpetite;
    piecepos->posy-=dypetite;
    piecepos++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tansetnewfigurepart2 ( void  )

Definition at line 1779 of file gtans.c.

                               {
  
  if (selectedgrande){
    helpoutset=FALSE;
    tanunselect();
  }
  else if (helpoutset){       /* pour eviter 2 appels successif a tanredrawgrande */
    helpoutset=FALSE;
    tanredrawgrande();
  }

  tanredrawpetite();

  selpossible=TRUE;

}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean tansetpixmapmode ( GtkWidget *  widget,
char *  aname,
int  gcnbr 
)

Definition at line 1157 of file gtans.c.

                                                                    {

  GdkPixmap *pixmap;
  GdkGC *gc;
  char *pname;
  gboolean ret;
  

  pixmap=tabpxpx[gcnbr];
  pname=tabpxnam[gcnbr];
  gc=tabgc[gcnbr];

  if (tabcolalloc[gcnbr]){
    gdk_colormap_free_colors (gdk_colormap_get_system(), &colortab[gcnbr], 1);
    tabcolalloc[gcnbr] = FALSE;
  }
  
  if (pixmap!=NULL)
    gdk_pixmap_unref(pixmap);
  
  ret=FALSE;
  if ( (pixmap=gdk_pixmap_create_from_xpm (widget->window, NULL, NULL, aname))!=NULL ){
    tanallocname(&pname,aname);
    gdk_gc_set_fill (gc, GDK_TILED);
    gdk_gc_set_tile (gc, pixmap);
    ret=TRUE;
  }
  
  if (pname==NULL)
    tanallocname(&pname,"LoadPixmapFailed");
  
  tabpxpx[gcnbr] = pixmap;
  tabpxnam[gcnbr] = pname;
  tabpxpixmode[gcnbr] = ret;

  if (!ret)
    tansetcolormode(&colortab[gcnbr],gcnbr);
  
  return (ret);
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tansetreussiactual ( void  )

Definition at line 962 of file gtans.c.

                              {

  figpetite.reussi = TRUE;
  if ( figactualnr>= 0 && figactualnr<figtabsize )
    (figtab+figactualnr)->reussi = TRUE;
  
}

Here is the caller graph for this function:

void tanstatpop ( void  )
void tanstatprov ( gchar *  msg)
void tanstatpush ( gchar *  msg)
gboolean tantinytabcompare ( tantinytri *  tinys1,
tantinytri *  tinys2,
int  accuracy 
)

Definition at line 331 of file gtans.c.

                                                                                 {

  gboolean libre[TINYNBR];
  int i,j,jmin;
  double dist,mindist,mindistmax,xi,yi;
  int drot,drotmax,roti;
  double flaccur;

  switch (accuracy){
  case 0 :
    flaccur = 1.0;
    drotmax = (int)(TOUR/64)+1;
    break;
  case 2 :
    flaccur = 4.0;
    drotmax = (int)(TOUR/32)+1;
    break;
  default :
    flaccur = 2.0;
    drotmax = (int)(TOUR/64)+1;
  }
  
  /* drotmax=figpetite.drotmax; */
  mindistmax=pow(figpetite.distmax*0.10*flaccur,2);

  for (i=0; i<TINYNBR; i++)
    libre[i]=TRUE;

  for (i=0; i<TINYNBR; i++){
    jmin=0;
    mindist=100000;
    xi=tinys1[i].posx;
    yi=tinys1[i].posy;
    roti=tinys1[i].rot;

    for (j=0; j<TINYNBR; j++){
      if (libre[j]){
       dist=pow(xi-tinys2[j].posx,2)+pow(yi-tinys2[j].posy,2);
       drot=ABS(roti-tinys2[j].rot);
       if ( drot>TOUR/2 )
         drot = TOUR-drot;
       if ( dist<mindist && drot<drotmax ){
         mindist=dist;
         jmin=j;
       }
      }
    }
    libre[jmin]=FALSE;
    if ( mindist>mindistmax )
      return FALSE;
  }

  return TRUE;

}

Here is the caller graph for this function:

void tantranstinytab ( tantinytri *  tinys)

Definition at line 451 of file gtans.c.

                                        {

  int i;
  double moyx=0,moyy=0;

  for (i=0; i<TINYNBR; i++){
    moyx+=tinys->posx;
    moyy+=tinys->posy;
    tinys++;
  }

  moyx/=TINYNBR;
  moyy/=TINYNBR;

  for (i=0; i<TINYNBR; i++){
    (--tinys)->posx-=moyx;
    tinys->posy-=moyy;
  }

}

Here is the caller graph for this function:

void tanunselect ( void  )

Definition at line 1011 of file gtans.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int tanwichisselect ( int  x,
int  y 
)

Definition at line 2031 of file gtans.c.

                                 {
  
  int i;
  gboolean trouve;

  trouve=FALSE;
  for (i=PIECENBR-1; i>=0 && !trouve; i--)
    trouve=tanpntisinpiece(x,y,figgrande.piecepos+i);

  if (trouve)
    i++;

  return (i);

}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int accuracy

Definition at line 243 of file gtans.c.

Definition at line 226 of file gtans.c.

GdkColor colortab[GCNBR]

Definition at line 237 of file gtans.c.

GtkWidget* colselwin

Definition at line 194 of file gtans.c.

gboolean editmode

Definition at line 245 of file gtans.c.

Definition at line 220 of file gtans.c.

char* figfilename

Definition at line 219 of file gtans.c.

Definition at line 223 of file gtans.c.

Definition at line 223 of file gtans.c.

Definition at line 217 of file gtans.c.

Definition at line 218 of file gtans.c.

Definition at line 206 of file gtans.c.

GtkWidget * filselwin

Definition at line 194 of file gtans.c.

gboolean helpoutset

Definition at line 241 of file gtans.c.

gboolean helptanset

Definition at line 242 of file gtans.c.

int initcbgr

Definition at line 231 of file gtans.c.

int initcbpe

Definition at line 231 of file gtans.c.

GdkGC* invertgc

Definition at line 233 of file gtans.c.

int invx2

Definition at line 234 of file gtans.c.

int invy2

Definition at line 234 of file gtans.c.

GtkWidget* mainwindow

Definition at line 181 of file gtans.c.

Definition at line 198 of file gtans.c.

GdkPixmap * pixmapfond

Definition at line 192 of file gtans.c.

GdkPixmap* pixmapgrande1

Definition at line 190 of file gtans.c.

GdkPixmap * pixmapgrande2

Definition at line 190 of file gtans.c.

GdkPixmap* pixmappetite

Definition at line 191 of file gtans.c.

GdkPixmap* pixmappiece1

Definition at line 192 of file gtans.c.

GdkPixmap * pixmappiece2

Definition at line 192 of file gtans.c.

int rotact

Definition at line 228 of file gtans.c.

int rotnew

Definition at line 228 of file gtans.c.

int rotold

Definition at line 228 of file gtans.c.

Definition at line 230 of file gtans.c.

GdkRectangle selbackrect

Definition at line 188 of file gtans.c.

Definition at line 224 of file gtans.c.

Definition at line 227 of file gtans.c.

GtkSpinButton* spinner

Definition at line 185 of file gtans.c.

gint statconid

Definition at line 187 of file gtans.c.

GdkGC* tabgc[GCNBR]

Definition at line 236 of file gtans.c.

char** tabpxnam

Definition at line 239 of file gtans.c.

GdkPixmap** tabpxpx

Definition at line 238 of file gtans.c.

tantinytri tinytabgr[TINYNBR]

Definition at line 222 of file gtans.c.

tantinytri tinytabpe[TINYNBR]

Definition at line 222 of file gtans.c.

GtkWidget* widgetgrande

Definition at line 182 of file gtans.c.

GtkWidget* widgetpetite

Definition at line 183 of file gtans.c.

GtkStatusbar* widgetstat

Definition at line 184 of file gtans.c.

int xact

Definition at line 225 of file gtans.c.

int xold

Definition at line 225 of file gtans.c.

int xoth

Definition at line 225 of file gtans.c.

int yact

Definition at line 225 of file gtans.c.

int yold

Definition at line 225 of file gtans.c.

int yoth

Definition at line 225 of file gtans.c.