//************************************************************************//* ANIMATEUR2D.H                                                        *//************************************************************************//*                                                                      *//*                                                                      *//*                                                                      *//*                                                 (C)GCOMPA 1997-2002  *//************************************************************************#ifndef  __ANIMATEUR2D#define  __ANIMATEUR2D#include <list>#include <vector>#include <string>#ifndef _TRIPLET#define _TRIPLETtypedef struct{int ind1, ind2; double k;} triplet;#endifclass CSerie;#define lineaire  0#define accelere  1	//inactif#define ralenti   2	//bug#define soft      3#define libre           0#define solidaire       2#define tete_a_tete     1#define tete_a_queue    3#define queue_a_tete    5#define queue_a_queue   7#define pilote(x)   CAnimateur2d::CPilote *x  = new CAnimateur2d::CPiloteusing namespace std;inline string first( const string& s ) {return s.substr(0, s.find('.'));}inline string last ( const string& s ) {return s.substr(s.find('.')+1);}typedef vector<int>    VECTOR_INT;typedef vector<double> VECTOR_DOUBLE;class CShooting;//========================================================================class CAnimateur2d {	//===============================     CAnimateur2d    friend class CTriplet;    friend class CCompute;    friend class CSupport;    friend class CPilote;  public:    class CSupport;    class CTriplet;    //--------------------------------------------------------------------    class CPilote {	//------------------------------------------   CPilote        class CCrochet {	//----------------------------------  CCrochet            struct couple {                int time;                int cle;             };          public:            list<couple> liste_couples;            int  mode;            void  addcouple ( int t, int cle ) {couple c={t,cle};liste_couples.push_back(c);}            int   getcount  ()                 {return liste_couples.size();}            void  set_mode  ( int m )          {mode = m;}            int   get_mode  ()                 {return mode;}            void  dump      ();        };  // fin classe CCrochet        class CCompute {	//----------------------------------  CCompute            struct polynome {                public:                double  a;      // q[0]                double  b;      // q[1]                double  c;      // q[2]                double  d;      // q[3]                double  val( double x ){return (a+ x*(b+ x*(c+x*d)));}            };            VECTOR_INT forme;            VECTOR_INT l1;            VECTOR_INT l2;            VECTOR_INT kind;            VECTOR_DOUBLE r;            VECTOR_DOUBLE lr;            VECTOR_DOUBLE pr;            int ncle, nima;            double dlr;          public:            void  int1( VECTOR_DOUBLE& x, VECTOR_DOUBLE& y, short l1, short l, short i                      , polynome& q );            void  init( CPilote *P, int nima );            void  compute_pos   ( CSupport *sup );            void  compute_forme ( CTriplet *trip );            void  compute_rythme();        };	// fin classe CCompute        //....class CPilote        CCompute* pcalc;        CTriplet* ptriplet;        CCrochet* pcroc;      public:        list<CCrochet*> liste_pcrochets;        CPilote                     ()                 {pcalc=new CCompute; pcroc=NULL;}        void  addcouple             ( int t, int cle );        void  addcrochet            ( int mode=soft );        void  addcrochet            ( CCrochet* p )    {liste_pcrochets.push_back(p);}        void  compute_triplet       ( int nimages );    CSupport* compute_support       ( CSerie* pserie, int id );    CTriplet* get_ptriplet          ()                 {return ptriplet;}        int   getcount              ()                 {return liste_pcrochets.size();}        void  dump_pilote           ();        void  dump_triplet          ();    };	// fin classe CPilote    class CSupport {	//--------------------------------------  CSupport        vector<posxyal> posxyals;      public:        VECTOR_DOUBLE x;        VECTOR_DOUBLE y;        VECTOR_DOUBLE a;        VECTOR_DOUBLE l;        string    ident;        CTriplet* ptriplet;        void     get_solidaire    ( int ima, posxyal& posit );        void     continuite_angle ();        void     set_ident        ( const string& s ) {ident = s;}        void     add_posxyal      ( posxyal& pos )    {posxyals.push_back(pos);}        posxyal& get_posxyal      ( int image )       {return posxyals[image];}        void     dump_poscles     ();        void     dump_posresults  ();    };  // fin classe CSupport    class CTriplet {	//--------------------------------------  CTriplet        vector<triplet> triplets;      public:        int     get_ind1   ( int ima )       {return triplets[ima].ind1;}        int     get_ind2   ( int ima )       {return triplets[ima].ind2;}        double  get_coef   ( int ima )       {return triplets[ima].k;}        void    addtriplet ( triplet& trip ) {triplets.push_back(trip);}        triplet get_triplet( int ima )       {return triplets[ima];}        void    dump_triplets();    };  // fin classe CTriplet    class CDicSerie {	//------------------------------------ CDicSerie        struct data_serie {            string  nom;            CSerie *pserie;        };        vector<data_serie> table;      public:        CSerie *get  ( const string& nom );       void    dump ();    };  // fin classe CDicSerie    class CDicPilote {	//------------------------------- CDicPilote        struct data_pilote {             string   nom;            CPilote *ppilote;        };        vector<data_pilote>  table;        int ndata;      public:        CDicPilote           ()                         {ndata=-1;}        int      add         ();        void     set_nom     ( int i, const string& nom ) {table[i].nom = nom;}        void     set_ppilote ( int i, CPilote *ppilote )  {table[i].ppilote = ppilote;}        string   get_nom     ( int i)                     {return table[i].nom;}        int      get_ppilote ( const string& nom );        CPilote *get_ppilote ( int i)                     {return table[i].ppilote;}    };  // fin classe CDicPilote    class CTablePosition {	//----------------------------- CTablePosition        struct data_position {            void      actualise ( vector<data_position>& table, int image );            void      load      ( int image ) {posit = psupport->get_posxyal(image);}            //---- fixe au cours du plan            string    nom;            int       indexpilote;            CSupport *psupport;            //---- la structure modifiable            int       indexpere;            int       accroche;            int       indexaqui;            //---- valeurs actuelles            posxyal   posit;            bool      okworld;        };        vector<data_position> table;        int ndata;      public:        int posactive;      public:        CTablePosition        ();        void  actualise       ( int image );        int   add             ( const string& nom );        void  set_indexpere   ( int i, int indexpere ) {table[i].indexpere   = indexpere;}        void  set_indexpilote ( int i, int index )     {table[i].indexpilote = index;}        void  set_indexaqui   ( int i, int indexaqui ) {table[i].indexaqui   = indexaqui;}        void  set_psupport    ( int i, CSupport *p )   {table[i].psupport    = p;}        void  set_accroche    ( int i, int accroche )  {table[i].accroche    = accroche;}        int   get_accroche    ( int i )                {return table[i].accroche;}    CSupport* get_support     ( int i )                {return table[i].psupport;}     posxyal& get_poscur      ( int index )            {return table[index].posit;}     string   get_name        ( int index )            {return table[index].nom;}        int   get_index       ( const string& nom );        int   get_indexpere   ( int index )            {return table[index].indexpere;}        int   get_indexpilote ( int index )            {return table[index].indexpilote;}        int   get_nearest     ( int x, int y );        void  dump            ();        void  dump_supports   ();    };  // fin classe CTablePosition    class CTableAffichage {	//---------------------------- CTableAffichage        struct data_affiche {            //---- fixe au cours du plan            string    nom;            CSerie   *pserie;            int       id;            int       indexpilote;            CTriplet *ptriplet;            //---- la structure modifiable            int       indexpere;            void shot ( int image, CTablePosition *ptpos );            bool isin ( int image, CTablePosition *ptpos, int x, int y );        };        vector<data_affiche>  table;        vector<data_affiche>::iterator ptable;        VECTOR_INT ordre;        int ndata;      public:        CSerie* get_pserie(int index);        int   formactive;        CTableAffichage       ()                       {ndata=-1;}        void  shot            ( int image, CTablePosition* );        int   add             ( const string& nom );        void  set_pserie      ( int i, CSerie*p )      {table[i].pserie      = p;}        void  set_id          ( int i, int id )        {table[i].id          = id;}        void  set_indexpere   ( int i, int index )     {table[i].indexpere   = index;}        void  set_indexpilote ( int i, int index )     {table[i].indexpilote = index;}        void  set_ptriplet    ( int i, CTriplet*p )    {table[i].ptriplet    = p;}     string   get_name        ( int index )            {return table[index].nom;}        int   get_indexpere   ( int index )            {return table[index].indexpere;}        int   get_index       ( const string& nom );        int   get_indexpilote ( int index )            {return table[index].indexpilote;}        int   get_nearest     ( int image, CTablePosition*, int x, int y );        void  dump            ();    };  // fin classe CTableAffichage    //... class CAnimateur2d    CDicSerie       dicserie;    CDicPilote      dicpilote;    CTablePosition  tpos;    CTableAffichage taff;    int             nimages;    string          path;  public:    int     image_en_cours;              CAnimateur2d  ()        {nimages=0;}              CAnimateur2d  ( int n ) {nimages=n;}      void    add_position( const string& nom, const string& pere, const string& pil                          , int accroche=libre, const string& aqui="" );      string  get_name_position       ( int i ){return tpos.get_name(i);}      string  get_perename_position   ( int i ){return tpos.get_name(tpos.get_indexpere(i));}      string  get_pilotename_position ( int i ){return dicpilote.get_nom(tpos.get_indexpilote(i));}      int     detect_position         ( int x, int y );      int     get_accro_position      ( int index );      void    set_accro_position      ( int index, int accro );      void    add_forme               ( const string& nom, const string& pere, const string& pil );      string  get_name_forme          ( int i ){return taff.get_name(i);}      string  get_perename_forme      ( int i ){return tpos.get_name(taff.get_indexpere(i));}      string  get_pilotename_forme    ( int i ){return dicpilote.get_nom(taff.get_indexpilote(i));}      int     detect_forme            ( int x, int y );      CSerie* get_pserie_forme        ( int index );      string  get_seriename_forme     ( int index );        void  set_path      ( const string& p )        {path = p;}        void  set_nimages   ( int n )                  {nimages = n;}        int   get_nimages   ()                         {return nimages;}        void  add_pilote    ( const string& nom, CPilote* ppil );        void  shot          ( int image );        void  shot          ()                         {shot(image_en_cours);}        void  tourne        ();        void  dump_serie    ()                         {dicserie.dump();}        void  dump_pos      ()                         {tpos.dump();}        void  dump_aff      ()                         {taff.dump();}        void  dump_supports ()                         {tpos.dump_supports();}};  // fin classe CAnimateur2d//========================================================================#endif                                                                                                                                                                                                                           