Fork me on GitHub

Changeset 96 in svn for trunk/Utilities/FROG


Ignore:
Timestamp:
Dec 12, 2008, 6:23:24 PM (16 years ago)
Author:
severine ovyn
Message:

second commit

Location:
trunk/Utilities/FROG/Includes/FROG
Files:
3 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Cube.h

    r95 r96  
    8787                                 PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ,
    8888                                 PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ);
    89 /*
    90                 glBegin (GL_QUADS);                                     
    91                         glVertex3f (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ);       //+++                                           
    92                         glVertex3f (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ);       //-++
    93                         glVertex3f (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ);       //--+
    94                         glVertex3f (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ);       //+-+                   
    95                                                
    96                         glVertex3f (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ);       //++-
    97                         glVertex3f (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ);       //+--
    98                         glVertex3f (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ);       //---
    99                         glVertex3f (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ);       //-+-
    100                        
    101                         glVertex3f (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ);       //+++
    102                         glVertex3f (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ);       //++-;
    103                         glVertex3f (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ);       //-+-
    104                         glVertex3f (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ);       //-++
    105                        
    106                         glVertex3f (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ);       //+-+
    107                         glVertex3f (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ);       //--+
    108                         glVertex3f (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ);       //---
    109                         glVertex3f (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ);       //+--
    110 
    111                         glVertex3f (PosX+WidthX +LengthX+ThickX,PosY+WidthY +LengthY+ThickY,PosZ+WidthZ +LengthZ+ThickZ);       //+++
    112                         glVertex3f (PosX+WidthX -LengthX+ThickX,PosY+WidthY -LengthY+ThickY,PosZ+WidthZ -LengthZ+ThickZ);       //+-+
    113                         glVertex3f (PosX+WidthX -LengthX-ThickX,PosY+WidthY -LengthY-ThickY,PosZ+WidthZ -LengthZ-ThickZ);       //+--
    114                         glVertex3f (PosX+WidthX +LengthX-ThickX,PosY+WidthY +LengthY-ThickY,PosZ+WidthZ +LengthZ-ThickZ);       //++-                   
    115 
    116                         glVertex3f (PosX-WidthX +LengthX+ThickX,PosY-WidthY +LengthY+ThickY,PosZ-WidthZ +LengthZ+ThickZ);       //-++                   
    117                         glVertex3f (PosX-WidthX +LengthX-ThickX,PosY-WidthY +LengthY-ThickY,PosZ-WidthZ +LengthZ-ThickZ);       //-+-
    118                         glVertex3f (PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ);       //---
    119                         glVertex3f (PosX-WidthX -LengthX+ThickX,PosY-WidthY -LengthY+ThickY,PosZ-WidthZ -LengthZ+ThickZ);       //--+
    120                 glEnd();
    121 */
    12289        }
    12390        #endif
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_CustomCube.h

    r95 r96  
    122122                                 P7X, P7Y, P7Z,
    123123                                 P8X, P8Y, P8Z);
    124 /*
    125                 glBegin (GL_QUADS);                     
    126                         glVertex3f (P1X,P1Y,P1Z);               //+++                   
    127                         glVertex3f (P4X,P4Y,P4Z);               //+-+
    128                         glVertex3f (P3X,P3Y,P3Z);               //--+
    129                         glVertex3f (P2X,P2Y,P2Z);               //-++                   
    130                        
    131                         glVertex3f (P5X,P5Y,P5Z);               //++-
    132                         glVertex3f (P6X,P6Y,P6Z);               //-+-
    133                         glVertex3f (P7X,P7Y,P7Z);               //---
    134                         glVertex3f (P8X,P8Y,P8Z);               //+--
    135 
    136                         glVertex3f (P1X,P1Y,P1Z);               //+++
    137                         glVertex3f (P2X,P2Y,P2Z);               //-++
    138                         glVertex3f (P6X,P6Y,P6Z);               //-+-
    139                         glVertex3f (P5X,P5Y,P5Z);               //++-
    140 
    141                         glVertex3f (P4X,P4Y,P4Z);               //+-+                   
    142                         glVertex3f (P8X,P8Y,P8Z);               //+--
    143                         glVertex3f (P7X,P7Y,P7Z);               //---
    144                         glVertex3f (P3X,P3Y,P3Z);               //--+
    145 
    146                         glVertex3f (P1X,P1Y,P1Z);               //+++
    147                         glVertex3f (P5X,P5Y,P5Z);               //++-
    148                         glVertex3f (P8X,P8Y,P8Z);               //+--
    149                         glVertex3f (P4X,P4Y,P4Z);               //+-+
    150 
    151                         glVertex3f (P2X,P2Y,P2Z);               //-++
    152                         glVertex3f (P3X,P3Y,P3Z);               //--+
    153                         glVertex3f (P7X,P7Y,P7Z);               //---
    154                         glVertex3f (P6X,P6Y,P6Z);               //-+-                   
    155                 glEnd();               
    156 */
    157124        }
    158125        #endif
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_CustomSurface.h

    r95 r96  
    7777                glLoadName( detId_ );
    7878
    79                 glBegin (GL_QUADS);                     
     79                glBegin (GL_QUADS);     
     80                        SetNormal  (P1X, P1Y, P1Z,
     81                                                P2X, P2Y, P2Z,
     82                                                P3X, P3Y, P3Z);
     83
    8084                        glVertex3f (P1X, P1Y, P1Z);     // FIRST FACE
    8185                        glVertex3f (P2X, P2Y, P2Z);
    8286                        glVertex3f (P3X, P3Y, P3Z);
    8387                        glVertex3f (P4X, P4Y, P4Z);
     88
     89
     90
     91                        SetNormal  (P1X, P1Y, P1Z,
     92                                                P4X, P4Y, P4Z,
     93                                                P3X, P3Y, P3Z);
    8494
    8595                        glVertex3f (P1X, P1Y, P1Z);     // SECOND FACE
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Disc.h

    r95 r96  
    7070                double dphi  = 6.283185307179586476925286766559 /NPhi;
    7171                double D     = sqrt(DirX*DirX+DirY*DirY+DirZ*DirZ);
    72                                
    73                 glPushMatrix();
    74                 glTranslatef(PosX,PosY,PosZ);
    75                 glRotatef(57.29*acos(DirX/D),1,0,0);
    76                 glRotatef(57.29*acos(DirY/D),0,1,0);
    77                 glRotatef(57.29*acos(DirZ/D),0,0,1);
     72               
     73                double rotTheta = 57.29*asin(DirY/D);
     74                double rotPhi   = 57.29*asin(DirX/sqrt(DirX*DirX+DirZ*DirZ));
     75                       
     76                glPushMatrix();         
     77                glTranslatef(PosX,PosY,PosZ);           
     78                glRotatef(rotPhi  ,0,1,0);
     79                glRotatef(rotTheta,1,0,0);
    7880                glBegin (GL_TRIANGLES);                         
    7981                        for(double phi=0; phi<=6.2831;phi+=dphi){                       
     82                                glNormal3f (0                    ,0                     ,1);
    8083                                glVertex3f (Radius*cos(phi)              ,Radius*sin(phi)               ,0);    // FIRST FACE
    8184                                glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)  ,0);
    8285                                glVertex3f (0                                    ,0                                             ,0);
    8386
     87                                glNormal3f (0                    ,0                     ,-1);
    8488                                glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi)  ,0);    // SECOND FACE
    8589                                glVertex3f (Radius*cos(phi)              ,Radius*sin(phi)               ,0);
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_PartialSphere.h

    r95 r96  
    8787                        for(double the=Theta1; the<=Theta2-dthe;the+=dthe){
    8888                        for(double phi=Phi1;   phi<=Phi2  -dphi;phi+=dphi){                     
     89                                glNormal3f (       cos(the)*cos(phi)                    ,       cos(the)*sin(phi)                        ,       sin(the));
    8990                                glVertex3f (Radius*cos(the)*cos(phi)                    ,Radius*cos(the)*sin(phi)                        ,Radius*sin(the));             // OUTER FACE
    9091                                glVertex3f (Radius*cos(the)*cos(phi+dphi)               ,Radius*cos(the)*sin(phi+dphi)           ,Radius*sin(the));
     
    9293                                glVertex3f (Radius*cos(the+dthe)*cos(phi)               ,Radius*cos(the+dthe)*sin(phi)           ,Radius*sin(the+dthe));
    9394
     95                                glNormal3f (      -cos(the)*cos(phi)                    ,      -cos(the)*sin(phi)                        ,      -sin(the));
    9496                                glVertex3f (Radius*cos(the)*cos(phi)                    ,Radius*cos(the)*sin(phi)                        ,Radius*sin(the));             // INNER FACE
    9597                                glVertex3f (Radius*cos(the+dthe)*cos(phi)               ,Radius*cos(the+dthe)*sin(phi)           ,Radius*sin(the+dthe));
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Rectangle.h

    r95 r96  
    33
    44#include "FROG_Element_Base.h"
     5#include "FROG_Primitives.h"
    56
    67class FROG_Element_Primitive_Rectangle : public FROG_Element_Base_With_DetId {
     
    6768        if(color){glColor4fv(color);}else{glColor4fv(style_->color_);}
    6869                glLoadName( detId_ );
     70
    6971               
    70                 glBegin (GL_QUADS);             
    71                         glVertex3f (PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ);    //+++   // FIRST FACE
     72               
     73                glBegin (GL_QUADS);     
     74                        SetNormal(      PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ,                         // FIRST FACE
     75                                                PosX-WidthX +LengthX,PosY-WidthY +LengthY,PosZ-WidthZ +LengthZ,
     76                                                PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ);
     77
     78                        glVertex3f (PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ);    //+++   
    7279                        glVertex3f (PosX-WidthX +LengthX,PosY-WidthY +LengthY,PosZ-WidthZ +LengthZ);    //-++
    7380                        glVertex3f (PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ);    //--+
    7481                        glVertex3f (PosX+WidthX -LengthX,PosY+WidthY -LengthY,PosZ+WidthZ -LengthZ);    //+-+
    7582
    76                         glVertex3f (PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ);    //+++   // SECOND FACE
     83
     84
     85                        SetNormal(      PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ,                         // SECOND FACE
     86                                                PosX+WidthX -LengthX,PosY+WidthY -LengthY,PosZ+WidthZ -LengthZ,
     87                                                PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ);
     88
     89                        glVertex3f (PosX+WidthX +LengthX,PosY+WidthY +LengthY,PosZ+WidthZ +LengthZ);    //+++   
    7790                        glVertex3f (PosX+WidthX -LengthX,PosY+WidthY -LengthY,PosZ+WidthZ -LengthZ);    //+-+
    7891                        glVertex3f (PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ);    //--+
  • trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Sphere.h

    r95 r96  
    6363                double dphi =   6.283185307179586476925286766559 /NPhi;
    6464                double dthe =   3.1415926535897932384626433832795/NTheta;
     65
     66                glPushMatrix();         
     67                glTranslatef(PosX,PosY,PosZ);           
    6568                glBegin (GL_QUADS);
    6669                        for(double the=0; the<=2*3.1416-dthe;the+=dthe){
    67                         for(double phi=0; phi<=6.2831;phi+=dphi){                                                               
    68                                 glVertex3f (PosX+Radius*cos(the)*cos(phi)                       ,PosY+Radius*cos(the)*sin(phi)                   ,PosZ+Radius*sin(the));
    69                                 glVertex3f (PosX+Radius*cos(the+dthe)*cos(phi)          ,PosY+Radius*cos(the+dthe)*sin(phi)              ,PosZ+Radius*sin(the+dthe));
    70                                 glVertex3f (PosX+Radius*cos(the+dthe)*cos(phi+dphi) ,PosY+Radius*cos(the+dthe)*sin(phi+dphi) ,PosZ+Radius*sin(the+dthe));
    71                                 glVertex3f (PosX+Radius*cos(the)*cos(phi+dphi)          ,PosY+Radius*cos(the)*sin(phi+dphi)              ,PosZ+Radius*sin(the));                                                                                        }}             
     70                        for(double phi=0; phi<=6.2831;phi+=dphi){       
     71                                glNormal3f (       cos(the)*cos(phi)                    ,       cos(the)*sin(phi)                        ,       sin(the));
     72                                glVertex3f (Radius*cos(the)*cos(phi)                    ,Radius*cos(the)*sin(phi)                        ,Radius*sin(the));
     73                                glVertex3f (Radius*cos(the+dthe)*cos(phi)               ,Radius*cos(the+dthe)*sin(phi)           ,Radius*sin(the+dthe));
     74                                glVertex3f (Radius*cos(the+dthe)*cos(phi+dphi)  ,Radius*cos(the+dthe)*sin(phi+dphi)  ,Radius*sin(the+dthe));
     75                                glVertex3f (Radius*cos(the)*cos(phi+dphi)               ,Radius*cos(the)*sin(phi+dphi)           ,Radius*sin(the));                                                                                     }}             
    7276                glEnd();
     77                glPopMatrix();
    7378        }
    7479        #endif
  • trunk/Utilities/FROG/Includes/FROG/FROG_Events.cpp

    r95 r96  
    99}
    1010
    11 void FROG_Events::Load (const char* path)
    12 {
    13         if(frogObjects_ && frogObjects_->frogEvent_){   
     11void FROG_Events::Load(){       
     12        FilesPath_.clear();
     13        FilesPath_   = frogObjects_->frogCard_->GetStringVector("InputVisFile");
     14        int FileToLoad = 0;
     15
     16        Load(FileToLoad);
     17}
     18
     19void FROG_Events::Load(std::vector<string>& inputFiles){               
     20        if(!frogObjects_->frogCard_->IsTagPresent("InputVisFile") && inputFiles.size()==0){
     21                printf("No input files have been given (either from the config card or from the command line\n");
     22                return;
     23        }
     24
     25        std::vector<string> cardFiles = frogObjects_->frogCard_->GetStringVector("InputVisFile");
     26
     27        FilesPath_.clear();
     28        for(unsigned int i=0;i<inputFiles.size();i++){          FilesPath_.push_back(inputFiles[i]);}
     29        for(unsigned int i=0;i<cardFiles .size();i++){          FilesPath_.push_back(cardFiles [i]);}
     30        int FileToLoad = 0;
     31
     32        int temp;
     33        frogObjects_->frogCard_->GetInt  (&temp, "Event_Number");
     34        if(temp<0){
     35                FileToLoad = FilesPath_.size() -1;
     36        }
     37
     38        for(unsigned int i=0;i<FilesPath_.size();i++){
     39                printf("File %i  = %s\n",i,FilesPath_[i].c_str());
     40        }
     41
     42        Load(FileToLoad);
     43}
     44
     45void FROG_Events::Load(const char* path){
     46        FilesPath_.clear();
     47        FilesPath_.push_back(path);
     48        int FileToLoad = 0;
     49
     50        Load(FileToLoad);
     51}
     52
     53void FROG_Events::Load (int CurrentFile){
     54        if(CurrentFile>=(int)FilesPath_.size())return;
     55        if(CurrentFile == CurrentFile_)   return;
     56        CurrentFile_ = CurrentFile;
     57
     58        if(frogObjects_ && frogObjects_->frogEvent_){
    1459                frogObjects_->frogEvent_->uninit();
    1560                frogObjects_->frogEvent_->deleteDaughters();
     
    1762        }
    1863        if(prim){ delete prim; prim=NULL;}
    19 
    20         FilePath_ = path;
    21 
    22         FILE* pFile = fopen(FilePath_,"rb" );
     64       
     65        const char* globalpath = (char*) DownLoadFile( (char*)FilesPath_[CurrentFile].c_str(), frogObjects_->frogCard_->mAbsolutePath.c_str() );
     66        if(FROG_PATH::IsFileExist(globalpath)){FilesPath_[CurrentFile] = string(globalpath);}   
     67       
     68        FILE* pFile = fopen(globalpath,"rb" );
    2369        if(pFile==NULL){
    24                 printf("The file %s can not be opened !\n",FilePath_);
     70                printf("The file %s can not be opened !\n",globalpath);
    2571                if(prim){ delete prim; prim=NULL;}
    2672                return;
     
    3985                        //evt->FillMap();
    4086                }
    41         }
     87        }       
    4288}
    4389
     
    56102
    57103        #ifdef FROG_ZLIB
    58                 if(CompressFiles){
    59                         char* path2 = new char[strlen(path)];
    60                         strcpy(path2,path);
    61                         FROG_ZLIB_Deflate(path2);
    62                         delete path2;
    63                 }
     104        if(CompressFiles){
     105                char* path2 = new char[strlen(path)];
     106                strcpy(path2,path);
     107                FROG_ZLIB_Deflate(path2);
     108                delete path2;
     109        }
    64110        #endif
    65111}
     
    72118        FILE* pFile;
    73119        if(CurrentSize_==0){                           
    74                 //pFile = fopen("InLive.vis","wb");
    75120                pFile = fopen(path,"wb");
    76121                unsigned short prim_type = prim->type();
     
    94139                prim->deleteDaughters();               
    95140        }else{
    96                 //pFile = fopen("InLive.vis","ab+" );
    97141                pFile = fopen(path,"ab+" );
    98142                fseek(pFile,CurrentSize_,SEEK_SET);
     
    107151                                if(CurrentSize_ + dau->size()>=MaxSize){
    108152                                        MaxFileHasBeenReached=true;
    109 //                                      for(unsigned j=0;j<i;j++){prim->deleteDaughter(i);}
    110153                                }
    111154                                if(MaxFileHasBeenReached)continue;
     
    124167        fclose(pFile); 
    125168
    126         //pFile = fopen("InLive.vis","rb+" );
    127169        pFile = fopen(path,"rb+" );
    128170                fseek(pFile,2,SEEK_SET);
     
    154196FROG_Element_Event* FROG_Events::GoToEvent(int i)
    155197{
     198        if(CurrentFile_< 0)return NULL;
     199        if(CurrentFile_>=(int)FilesPath_.size())return NULL;
     200
    156201        if(frogObjects_->frogEvent_){                   
    157202                frogObjects_->frogEvent_->uninit();
    158203                frogObjects_->frogEvent_->deleteDaughters();
    159         }
    160 
    161         if(i<0 || (prim && i>=(int)prim->getDaughterSize())){           
    162                 Load(FilePath_);
     204        }       
     205
     206        if(i<0 || (prim && i>=(int)prim->getDaughterSize())){                           
     207                CurrentFile_ = -1;             
     208                Load(FilesPath_.size()-1);
    163209                if(prim)Current_Event = prim->getDaughterSize()-1;
    164         }else{
     210        }else{         
    165211                Current_Event=i;       
    166         }
     212        }       
    167213
    168214        if(!prim)return NULL;
    169215        frogObjects_->setEvent(dynamic_cast<FROG_Element_Event*>(prim->getDaughter(Current_Event)));
    170216
    171         FILE* pFile = fopen(FilePath_,"rb" );
    172                 if(pFile==NULL){
    173                         printf("The file %s can not be opened !\n",FilePath_);
    174                         return NULL;
    175                 }
    176                 fseek (pFile,((FROG_Element_Event*)frogObjects_->frogEvent_)->EventPosInFile(),SEEK_SET);
    177                 FROG_ELEMENT::Read(pFile,frogObjects_->frogEvent_,((FROG_Element_Event*)frogObjects_->frogEvent_)->EventNBytesToRead());                       
     217        FILE* pFile = fopen(FilesPath_[CurrentFile_].c_str(),"rb" );   
     218        if(pFile==NULL){
     219                printf("The file %s can not be opened !\n",FilesPath_[CurrentFile_].c_str());
     220                return NULL;
     221        }
     222       
     223        fseek (pFile,((FROG_Element_Event*)frogObjects_->frogEvent_)->EventPosInFile(),SEEK_SET);
     224        FROG_ELEMENT::Read(pFile,frogObjects_->frogEvent_,((FROG_Element_Event*)frogObjects_->frogEvent_)->EventNBytesToRead());                       
    178225        fclose(pFile);
    179226
     
    185232        return frogObjects_->frogEvent_;
    186233}
     234
    187235FROG_Element_Event* FROG_Events::NextEvent()
    188236{
     
    190238        if(Current_Event+1<prim->getDaughterSize()){    Current_Event++;
    191239        }else{
    192                 Load(FilePath_);
    193                 if(Current_Event+1<prim->getDaughterSize()){Current_Event++;}else{Current_Event=0;}
    194         }
    195         return GoToEvent(Current_Event);         
    196 }
     240                Load(CurrentFile_);
     241                if(Current_Event+1<prim->getDaughterSize()){Current_Event++;}else{NextFile();Current_Event=0;}
     242        }
     243        return GoToEvent(Current_Event);
     244}
     245
    197246FROG_Element_Event* FROG_Events::PreviousEvent()
    198247{
     
    200249        if(Current_Event!=0){   Current_Event--;       
    201250        }else{
    202                 Load(FilePath_);
     251                PreviousFile();
    203252                Current_Event = prim->getDaughterSize()-1;
    204253        }
     
    206255}
    207256
    208 void FROG_Events::Init(FROG_Objects_Extended* frogObjects)
    209 {
    210         if(!prim)return;
    211         frogObjects_ = frogObjects;
     257void FROG_Events::NextFile(){
     258        if(FilesPath_.size()<=1)return;
     259
     260        CurrentFile_++;
     261        if(CurrentFile_>=(int)FilesPath_.size()){
     262                CurrentFile_=0;
     263        }
     264
     265        Load(CurrentFile_);
     266}
     267
     268void FROG_Events::PreviousFile(){
     269        if(FilesPath_.size()<=1)return;
     270
     271        if(CurrentFile_>0){
     272                CurrentFile_--;
     273        }else{
     274                CurrentFile_ = FilesPath_.size() - 1;
     275        }
     276        Load(CurrentFile_);
     277}
     278
     279const char* FROG_Events::CurrentFile(){
     280        if(CurrentFile_>=(int)FilesPath_.size())return "NoFiles!!!";
     281
     282        if(FilesPath_[CurrentFile_].size()>60){         
     283                return FilesPath_[CurrentFile_].c_str()+(FilesPath_[CurrentFile_].size()-60);
     284        }
     285        return FilesPath_[CurrentFile_].c_str();
    212286}
    213287
  • trunk/Utilities/FROG/Includes/FROG/FROG_Events.h

    r95 r96  
    1717#include "FROG_Element_Event.h"
    1818#include "FROG_Objects_Extended.h"
     19#include "FROG_Net_Tools.h"
    1920
    2021#ifdef FROG_ZLIB
     
    3233        std::vector<unsigned int> OpenedMenu;
    3334private :
    34         const char*  FilePath_;
     35        std::vector<string>  FilesPath_;
     36                         int CurrentFile_;
    3537        unsigned int CurrentSize_;
    3638public:
    37         FROG_Events() : prim(NULL),frogObjects_(NULL), Current_Event(0),FilePath_(NULL), CurrentSize_(0){
     39        FROG_Events(FROG_Objects_Extended* frogObjects=NULL) : prim(NULL),frogObjects_(frogObjects), Current_Event(0), CurrentFile_(-1), CurrentSize_(0){
    3840                prim = new FROG_Element_Base(C_PRIMARY);
    3941
     
    4345        void AddEvent(FROG_Element_Event* event);
    4446
     47        void Load ();
     48        void Load (std::vector<string>& FilesFromCard);
    4549        void Load (const char* path);
     50        void Load (int CurrentFile);
     51
    4652        void Save (const char* path);   
    4753        bool SaveInLive (const char* path, bool CloseFile=false, bool CompressFiles=true, unsigned int MaxSize=(unsigned int)-1);
     
    5258    FROG_Element_Event* PreviousEvent();
    5359
     60    void NextFile();
     61    void PreviousFile();
     62        const char* CurrentFile();
     63
    5464    FROG_Element_Event* getCurrentEvent() const {
    5565                if( Current_Event<prim->getDaughterSize() )
     
    5969
    6070    int NumberOfEvents() const { return prim->getDaughterSize(); }
    61         void Init(FROG_Objects_Extended* frogObjects);
    6271
    6372        void keepEventToDisplay(FROG_Element_Base* mother);
     
    6877        void keepOpenedMenu(FROG_Element_Base* mother);
    6978        void updateOpenedMenu();
    70 
    71 
    7279};
    7380
  • trunk/Utilities/FROG/Includes/FROG/FROG_Net.h

    r95 r96  
    33#define _FROG_NET_H__
    44
    5 #include "../CURL/curl.h"
    65#include <stdio.h>
    76#include <iostream>
    87
     8#include "../CURL/curl.h"
    99class FROG_Net {
    1010
  • trunk/Utilities/FROG/Includes/FROG/FROG_Net_Tools.h

    r95 r96  
    66#include <iostream>
    77
     8#include "FROG_ZLib.h"
     9#include "FROG_Path.h"
     10
     11#ifdef FROG_CURL
    812#include "FROG_Net.h"
    9 #include "FROG_ZLib.h"
    10 
    11 bool GetPathFromURL(char* dest, char* inputFile, unsigned int sizeMax)
    12 {
    13         std::string result((char*)inputFile);
    14         bool toReturn = false;
    15 
    16         // check if inputVisFile contains http:// or ftp://
    17         string::size_type loc  = result.find( "http://", 0 );
    18         string::size_type loc2 = result.find( "ftp://", 0 );               
    19 
    20         if( loc != string::npos || loc2 != string::npos) {
    21                  int End = result.rfind('/');                   
    22 
    23                  string local     = result.substr(End+1,result.size());
    24                  string localPath = string("Files/") + local;           
    25                  result           = localPath;           
    26                  toReturn         = true;
    27         }
    28 
    29         if(result.size()>sizeMax){
    30                 printf("GetPathFromURL : sizeMax is smaller than the actual string size\n");
    31         }else{
    32                 strcpy(dest,result.c_str());
    33         }
    34 
    35         return toReturn;                 
    36 }
    37 
    38 bool IsExpectedFileSize(char* fileName){
    39         FILE* FileExist = fopen(fileName,"rb");
    40         if(!FileExist)return false;
    41 
    42         fseek(FileExist,0,SEEK_SET);
    43         unsigned short chunk_type     = 0;
    44         unsigned int   chunk_size     = 0;
    45         fread(&chunk_type, 1, sizeof(unsigned short), FileExist);
    46         fread(&chunk_size, 1, sizeof(unsigned int)  , FileExist);
    47         fseek(FileExist,0,SEEK_END);
    48         if( (long int)(chunk_size) > ftell(FileExist) ){
    49                 fclose(FileExist);
    50                 return false;
    51         }       
    52         fclose(FileExist);
    53         return true;
    54 }
    55 
    56 void* DownLoadFile(void* inputFile){
    57 
    58         char* localPath = new char[2048];
    59         bool IsURL = GetPathFromURL(localPath,(char*)inputFile,2048);
    60 
    61         if(IsURL) {
    62                 char local[2048];
    63                 strcpy(local,localPath+6);
    64 
    65                 //Check if unzipped file (or file, in case of not .gz extension) exist
    66 //              if(!FROG_ZLIB_IsUnZippedFileExist(localPath) || (FROG_ZLIB_IsUnZippedFileExist(localPath) && !CheckFileSize(FileExist)) ){
    67                 if(!FROG_ZLIB_IsUnZippedFileExist(localPath) || (!FROG_ZLIB_IsGZip(localPath) && !IsExpectedFileSize(localPath)) ){
    68                         printf("Loading %s from %s\n",local,(char*)inputFile);
    69                         printf("This can take few seconds\n");
    70                         FROG_Net net;
    71                         net.connect((char*)inputFile);
    72                         net.write(localPath);
    73                         net.close();
    74                 }
    75         }
    76 
    77         if(FROG_ZLIB_IsGZip(localPath)){
    78                 FROG_ZLIB_Inflate(localPath);
    79         }
    80 
    81         if(!IsExpectedFileSize(localPath) ){
    82                 printf("The downloaded File is corrupted\nAre you sure of the quality of the transfert?\n");
    83                 printf("- The .vis file doesn't exist yet\n");
    84                 printf("- Bug During the Download! : Clean up the directory File/ of all the .vis file\n");
    85                 printf("- Strong firewall : Download the file by yourself and copy it in the File/ repository\n");
    86                 printf("- NoIdea : Go on the FROG website http://projects.hepforge.org/frog/\n");
    87                 printf("  Download the latest FROG version and/or ask help on the mailing list\n");
    88                 //exit(0);
    89         }
     13#endif
    9014
    9115
    92         return localPath;                 
    93 }
    9416
     17bool  GetPathFromURL(char* dest, char* inputFile, unsigned int sizeMax, const char* AbsolutePath);
     18bool  IsExpectedFileSize(char* fileName);
     19void* DownLoadFile(void* inputFile,const char* AbsolutePath);
    9520
    96 #ifdef linux
    97 #elif macos
    98 #else
    99 DWORD WINAPI WinDownLoadFile( LPVOID lpParam ) {
    100         // interface for windows
    101     char* fileName_ = (char*)lpParam;
    102         DownLoadFile(fileName_);
    103         return 0;
    104 }
    105 #endif
     21//#ifdef windows
     22//      DWORD WINAPI WinDownLoadFile( LPVOID lpParam );
     23//#endif
    10624
    10725#endif
  • trunk/Utilities/FROG/Includes/FROG/FROG_Objects_Extended.h

    r95 r96  
    66#define _FROG_OBJECTS_EXTENDED_H__
    77
     8#include "FROG_Path.h"
    89#include "FROG_Objects.h"
    910#include "FROG_Element_Event.h"
     
    7172#ifdef FROG_OPENGL
    7273   void loadMarkers(){
    73                 char Path[255];
     74                char LocalPath[2048];
     75                char AbsolPath[2048];
    7476                for(unsigned int i=1;i<200;i++){
    75                    sprintf(Path,"Resources/Marker/%i.png",i);
    76                    FILE* file_exist = fopen(Path,"r");
    77                    if(file_exist){
    78                                 unsigned int tmp = 0;
    79                                 LoadTexture(&tmp,Path,true);
     77                   sprintf(LocalPath,"Resources/Marker/%i.png",i);
     78                   if(FROG_PATH::CheckGlobalPath(LocalPath,frogCard_->mAbsolutePath.c_str(),AbsolPath)){
     79                                unsigned int tmp = 0;                           
     80                                LoadTexture(&tmp,AbsolPath,true);
    8081                                Marker[i] = tmp;
    8182                   }else{
  • trunk/Utilities/FROG/Includes/FROG/FROG_ReadCards.cpp

    r95 r96  
    1414#include "FROG_ReadCards.h"
    1515
     16// repalce the std getline method,
     17// in order to be LINUX/MACOS/WINDOWS compatible
     18// Because those systems have different end line convention
     19istream& FROG_ReadCards::getLine(istream& is, string& buffer){
     20        char ch, peekch;
     21        char LF = '\n';
     22        char CR = '\r';
     23        is.get(ch);
     24
     25//        string buffer;
     26                buffer.clear();
     27
     28        while(!is.eof() && ch != LF && ch != CR){
     29                buffer.append(1, ch);
     30                is.get(ch);
     31        }
     32       
     33        if (is.eof()){
     34                return is;
     35        }
     36       
     37        peekch = is.peek();
     38
     39                if(ch == CR && peekch == LF){ // CR/LF is windows otherwise Mac       
     40                is.get();
     41                }else if(peekch == CR){        // allow for improbable LF/CR       
     42                is.get();
     43        }
     44
     45        return is;
     46}
     47
     48
    1649// remove comments and whitespace
    1750void FROG_ReadCards::clean() {
     
    2255  while ( !mFile.eof() ) {   
    2356
    24         getline(mFile,line,'\n');
     57          getLine(mFile,line);
     58        //getline(mFile,line,'\n');
    2559        //printf("%s\n",line.c_str());
    2660
     
    88122                        // check that the file is not already in the list
    89123                        bool alreadyIn = false;
    90                         for(unsigned int a=0;a<mFilesToRead.size();a++){
    91                                 if(strcmp(mFilesToRead[a],values[z].c_str())==0)
     124                    char* FilePath = new char[2048];
     125                        FROG_PATH::CheckGlobalPath(values[z].c_str(),mAbsolutePath.c_str(),FilePath);                   
     126                        for(unsigned int a=0;a<mFilesToRead.size()&&!alreadyIn;a++){
     127                                if(strcmp(mFilesToRead[a],FilePath)==0)
    92128                                        alreadyIn=true;
    93129                        }
    94130                        if(!alreadyIn){
    95                            char* tmp = new char[255];
    96                            sprintf(tmp,"%s",values[z].c_str());
    97                            mFilesToRead.push_back(tmp);                 
     131                           mFilesToRead.push_back(FilePath);                   
    98132                        }
     133
    99134                }
    100135        }else{
     
    116151void FROG_ReadCards::Construct(const char* filename) {
    117152
    118         mFilesToRead.push_back(filename);
     153          char* FilePath = new char[2048];
     154          FROG_PATH::CheckGlobalPath(filename,mAbsolutePath.c_str(),FilePath);                 
     155          mFilesToRead.push_back(FilePath);
    119156
    120157      for(unsigned int i = 0;i<mFilesToRead.size();i++){
     
    405442}
    406443
     444
    407445std::string FROG_ReadCards::GetString(const char* format, ...){
    408446        char tag[255];
  • trunk/Utilities/FROG/Includes/FROG/FROG_ReadCards.h

    r95 r96  
    1212using namespace std;
    1313
    14 #ifdef linux
     14#include "FROG_Path.h"
     15
     16#ifdef windows
     17  #include <hash_map>
     18 using namespace stdext;
     19 typedef hash_map<std::string, std::vector< std::string >, hash_compare<std::string, std::less<std::string> > > Values;
     20 typedef hash_map<std::string, std::vector< std::string >, hash_compare<std::string, std::less<std::string> > >::iterator Values_Iterator;
     21#else
    1522 #include <ext/hash_map>
    1623 using namespace __gnu_cxx;
     
    2431 typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> > Values;
    2532 typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> >::iterator Values_Iterator;
    26 #elif macos
    27  #include <ext/hash_map>
    28  using namespace __gnu_cxx;
    29 
    30  namespace __gnu_cxx {
    31         template<> struct hash< std::string >{
    32                 size_t operator()( const std::string& x ) const{ return hash< const char* >()( x.c_str() );  }
    33         };
    34  }
    35 
    36  typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> > Values;
    37  typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> >::iterator Values_Iterator;
    38 #else
    39  #include <hash_map>
    40  using namespace stdext;
    41  typedef hash_map<std::string, std::vector< std::string >, hash_compare<std::string, std::less<std::string> > > Values;
    42  typedef hash_map<std::string, std::vector< std::string >, hash_compare<std::string, std::less<std::string> > >::iterator Values_Iterator;
    4333#endif
    4434
     
    5848 public:
    5949
    60   FROG_ReadCards()                     {  }
    61   FROG_ReadCards(char* filename)       { Construct(filename); }
    62   FROG_ReadCards(std::string filename) { Construct(filename.c_str()); }
     50  FROG_ReadCards()                     { mAbsolutePath = string("");  }
     51  FROG_ReadCards(char* filename)       { mAbsolutePath = string(""); Construct(filename); }
     52  FROG_ReadCards(std::string filename) { mAbsolutePath = string(""); Construct(filename.c_str()); }
     53  FROG_ReadCards(const char* AbsolutePath, const char* filename){
     54                                                                                 mAbsolutePath = string(AbsolutePath);    Construct(filename); }
    6355
    6456  ~FROG_ReadCards() { }
    6557
     58  istream& getLine(istream& is, string& str);
    6659
    6760  int GetNValues() const { return mValues.size(); }
     
    9184  bool GetBool(bool Default, const char* format, ...);
    9285
     86 public:
     87  std::string  mAbsolutePath; 
    9388
    9489 private:
  • trunk/Utilities/FROG/Includes/FROG/FROG_Texture.cpp

    r95 r96  
    3333}
    3434
    35 void LoadTexture(unsigned int* id, char* strFileName, bool VerticalFlip)
     35void LoadTexture(unsigned int* id, const char* strFileName, bool VerticalFlip)
    3636{       
    3737        if(!strFileName) return;
     
    6868}
    6969
    70 void SaveScreenshot(char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void))
     70void SaveScreenshot(const char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void))
    7171{               
    7272        if(!strFileName) return;
     
    134134
    135135
    136 void LoadPNG(stTexture* Texture, char* strFileName)
     136void LoadPNG(stTexture* Texture, const char* strFileName)
    137137{
    138138        png_structp png_ptr;
     
    229229
    230230
    231 void SavePNG(stTexture* Texture, char* strFileName)
     231void SavePNG(stTexture* Texture, const char* strFileName)
    232232{
    233233        if(Texture->texels==NULL || Texture->width==0 || Texture->height==0) return;
  • trunk/Utilities/FROG/Includes/FROG/FROG_Texture.h

    r95 r96  
    1010#endif
    1111
    12 #ifdef linux
    13 #elif macos
    14 #else
     12#ifdef windows
    1513 #pragma comment (lib,"Includes/ZLIB/Lib/zdll.lib")
    1614 #pragma comment (lib,"Includes/PNGLIB/Lib/libpng13.lib") 
     
    5452stTexture* VerticalFlipTexture(stTexture* Source);
    5553
    56 void LoadTexture(unsigned int* id, char* strFileName, bool VerticalFlip=false);
    57 void SaveScreenshot(char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void));
     54void LoadTexture(unsigned int* id, const char* strFileName, bool VerticalFlip=false);
     55void SaveScreenshot(const char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void));
    5856
    59 void LoadPNG(stTexture* Texture, char* strFileName);
    60 void SavePNG(stTexture* Texture, char* strFileName);
     57void LoadPNG(stTexture* Texture, const char* strFileName);
     58void SavePNG(stTexture* Texture, const char* strFileName);
    6159
    6260
  • trunk/Utilities/FROG/Includes/FROG/FROG_View.h

    r95 r96  
    5757
    5858        bool  screen_flag;
     59        bool  isSwappable;
    5960
    6061        float BackGround_Color_[4];
     
    8485
    8586                screen_flag     = false;
     87                isSwappable     = true;
    8688
    8789                BackGround_Color_[0] = 0;
     
    106108                        frogObjects_->frogCard_->GetFloat(&(cam_->target_y)     ,"%s_Cam_Target_Y"      ,Name_);
    107109                        frogObjects_->frogCard_->GetFloat(&(cam_->target_z)     ,"%s_Cam_Target_Z"      ,Name_);
     110
     111                        isSwappable = frogObjects_->frogCard_->GetBool(isSwappable,"%s_IsSwappable", Name_);
    108112
    109113                        if(geomToDisplay_.size()>0)geomToDisplay_.clear();
  • trunk/Utilities/FROG/Includes/FROG/FROG_View_Menu.h

    r95 r96  
    1414        class Order {
    1515        public:
    16                 bool operator () (MenuEntry* a, MenuEntry* b){
     16//              bool operator () (MenuEntry* a, MenuEntry* b){
    1717                //      return (a->type() < b->type());
    1818
     
    2121//                      FROG_Element_Base_With_DetId* FEBD = dynamic_cast<FROG_Element_Base_With_DetId*>(mother);
    2222//                      if(a.Object->getMother() == b.Object->getMother() && a.Level==b.Level && FEBDN1 && FEBDN2)return (bool)strcmp(a.Name,b.Name);
    23                         return 0;
    24                 }
     23//                      return 0;
     24//              }
    2525        };
    2626       
     
    5757                Imax = 0;
    5858
    59                 Menu_CleanUp();                
     59                Menu_CleanUp();
    6060                if(frogObjects_->frogEvent_)Menu_Update(frogObjects_->frogEvent_);
    61                 if(frogObjects_->frogGeom_ )Menu_Update(frogObjects_->frogGeom_->prim->getDaughter(0));
     61                if(frogObjects_->frogGeom_ && frogObjects_->frogGeom_->prim)Menu_Update(frogObjects_->frogGeom_->prim->getDaughter(0));
    6262        }
    6363
  • trunk/Utilities/FROG/Includes/FROG/FROG_View_Tools.h

    r95 r96  
    6565//      printf("Swap : %s <--> %s\n",v1->Name_, v2->Name_);
    6666
     67        if( !(v1->isSwappable && v2->isSwappable) )return;
     68
    6769        float temp_card_vx_ = v1->card_vx_;
    6870        float temp_card_vy_ = v1->card_vy_;
  • trunk/Utilities/FROG/Includes/FROG/FROG_ZLib.cpp

    r95 r96  
    5757
    5858
    59 bool FROG_ZLIB_Deflate(char* source_path){
     59bool FROG_ZLIB_Deflate(char* source_path, bool keepIntermediateFile){
    6060        unsigned int N = strlen(source_path);
    6161
     
    7979                printf("%s has been deflate corretly\n",source_path);                           
    8080                printf("new name is %s\n",dest_path);                           
    81                 if(remove(source_path)!=0)perror( "Error deleting file" );
     81                if(!keepIntermediateFile && remove(source_path)!=0)perror( "Error deleting file" );
    8282                return true;
    8383        }else if(returnedValue==Z_MEM_ERROR){
     
    155155
    156156
    157 bool FROG_ZLIB_Inflate(char* source_path){
     157bool FROG_ZLIB_Inflate(char* source_path, bool keepIntermediateFile){
    158158        unsigned int N = strlen(source_path);
    159159
     
    187187        if(returnedValue==Z_OK){
    188188                printf("File %s has been inflate corretly\n",source_path);
    189                 printf("new name is %s\n",dest_path);
    190                 if(remove(source_path)!=0)perror( "Error deleting file" );
     189                printf("new name is %s\n",dest_path);           
     190                if(!keepIntermediateFile && remove(source_path)!=0)perror( "Error deleting file" );
    191191                strcpy(source_path,dest_path);
    192192                return true;
  • trunk/Utilities/FROG/Includes/FROG/FROG_ZLib.h

    r95 r96  
    88#include "../ZLIB/zlib.h"
    99
    10 //#ifdef linux
    11 //#else
     10#ifdef windows
    1211//      #pragma comment (lib,"Includes/ZLIB/Lib/zdll.lib")
    13 //#endif
     12#endif
    1413
    1514#define CHUNK 16384
     
    2019bool FROG_ZLIB_IsUnZippedFileExist(char* source_path);
    2120
    22 bool FROG_ZLIB_Inflate(char* source_path);
    2321int  FROG_ZLIB_Inflate(FILE *source, FILE *dest);
     22bool FROG_ZLIB_Inflate(char* source_path,  bool keepIntermediateFile=false);
    2423
    2524int  FROG_ZLIB_Deflate(FILE *source, FILE *dest, int level);
    26 bool FROG_ZLIB_Deflate(char* source_path);
     25bool FROG_ZLIB_Deflate(char* source_path,  bool keepIntermediateFile=false);
    2726
    2827#endif
Note: See TracChangeset for help on using the changeset viewer.