Changeset 96 in svn for trunk/Utilities/FROG/Includes/FROG
- Timestamp:
- Dec 12, 2008, 6:23:24 PM (16 years ago)
- 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 87 87 PosX-WidthX -LengthX-ThickX,PosY-WidthY -LengthY-ThickY,PosZ-WidthZ -LengthZ-ThickZ, 88 88 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 */122 89 } 123 90 #endif -
trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_CustomCube.h
r95 r96 122 122 P7X, P7Y, P7Z, 123 123 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 */157 124 } 158 125 #endif -
trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_CustomSurface.h
r95 r96 77 77 glLoadName( detId_ ); 78 78 79 glBegin (GL_QUADS); 79 glBegin (GL_QUADS); 80 SetNormal (P1X, P1Y, P1Z, 81 P2X, P2Y, P2Z, 82 P3X, P3Y, P3Z); 83 80 84 glVertex3f (P1X, P1Y, P1Z); // FIRST FACE 81 85 glVertex3f (P2X, P2Y, P2Z); 82 86 glVertex3f (P3X, P3Y, P3Z); 83 87 glVertex3f (P4X, P4Y, P4Z); 88 89 90 91 SetNormal (P1X, P1Y, P1Z, 92 P4X, P4Y, P4Z, 93 P3X, P3Y, P3Z); 84 94 85 95 glVertex3f (P1X, P1Y, P1Z); // SECOND FACE -
trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Disc.h
r95 r96 70 70 double dphi = 6.283185307179586476925286766559 /NPhi; 71 71 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); 78 80 glBegin (GL_TRIANGLES); 79 81 for(double phi=0; phi<=6.2831;phi+=dphi){ 82 glNormal3f (0 ,0 ,1); 80 83 glVertex3f (Radius*cos(phi) ,Radius*sin(phi) ,0); // FIRST FACE 81 84 glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi) ,0); 82 85 glVertex3f (0 ,0 ,0); 83 86 87 glNormal3f (0 ,0 ,-1); 84 88 glVertex3f (Radius*cos(phi+dphi) ,Radius*sin(phi+dphi) ,0); // SECOND FACE 85 89 glVertex3f (Radius*cos(phi) ,Radius*sin(phi) ,0); -
trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_PartialSphere.h
r95 r96 87 87 for(double the=Theta1; the<=Theta2-dthe;the+=dthe){ 88 88 for(double phi=Phi1; phi<=Phi2 -dphi;phi+=dphi){ 89 glNormal3f ( cos(the)*cos(phi) , cos(the)*sin(phi) , sin(the)); 89 90 glVertex3f (Radius*cos(the)*cos(phi) ,Radius*cos(the)*sin(phi) ,Radius*sin(the)); // OUTER FACE 90 91 glVertex3f (Radius*cos(the)*cos(phi+dphi) ,Radius*cos(the)*sin(phi+dphi) ,Radius*sin(the)); … … 92 93 glVertex3f (Radius*cos(the+dthe)*cos(phi) ,Radius*cos(the+dthe)*sin(phi) ,Radius*sin(the+dthe)); 93 94 95 glNormal3f ( -cos(the)*cos(phi) , -cos(the)*sin(phi) , -sin(the)); 94 96 glVertex3f (Radius*cos(the)*cos(phi) ,Radius*cos(the)*sin(phi) ,Radius*sin(the)); // INNER FACE 95 97 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 3 3 4 4 #include "FROG_Element_Base.h" 5 #include "FROG_Primitives.h" 5 6 6 7 class FROG_Element_Primitive_Rectangle : public FROG_Element_Base_With_DetId { … … 67 68 if(color){glColor4fv(color);}else{glColor4fv(style_->color_);} 68 69 glLoadName( detId_ ); 70 69 71 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); //+++ 72 79 glVertex3f (PosX-WidthX +LengthX,PosY-WidthY +LengthY,PosZ-WidthZ +LengthZ); //-++ 73 80 glVertex3f (PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ); //--+ 74 81 glVertex3f (PosX+WidthX -LengthX,PosY+WidthY -LengthY,PosZ+WidthZ -LengthZ); //+-+ 75 82 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); //+++ 77 90 glVertex3f (PosX+WidthX -LengthX,PosY+WidthY -LengthY,PosZ+WidthZ -LengthZ); //+-+ 78 91 glVertex3f (PosX-WidthX -LengthX,PosY-WidthY -LengthY,PosZ-WidthZ -LengthZ); //--+ -
trunk/Utilities/FROG/Includes/FROG/FROG_Element_Primitive_Sphere.h
r95 r96 63 63 double dphi = 6.283185307179586476925286766559 /NPhi; 64 64 double dthe = 3.1415926535897932384626433832795/NTheta; 65 66 glPushMatrix(); 67 glTranslatef(PosX,PosY,PosZ); 65 68 glBegin (GL_QUADS); 66 69 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)); }} 72 76 glEnd(); 77 glPopMatrix(); 73 78 } 74 79 #endif -
trunk/Utilities/FROG/Includes/FROG/FROG_Events.cpp
r95 r96 9 9 } 10 10 11 void FROG_Events::Load (const char* path) 12 { 13 if(frogObjects_ && frogObjects_->frogEvent_){ 11 void FROG_Events::Load(){ 12 FilesPath_.clear(); 13 FilesPath_ = frogObjects_->frogCard_->GetStringVector("InputVisFile"); 14 int FileToLoad = 0; 15 16 Load(FileToLoad); 17 } 18 19 void 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 45 void FROG_Events::Load(const char* path){ 46 FilesPath_.clear(); 47 FilesPath_.push_back(path); 48 int FileToLoad = 0; 49 50 Load(FileToLoad); 51 } 52 53 void 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_){ 14 59 frogObjects_->frogEvent_->uninit(); 15 60 frogObjects_->frogEvent_->deleteDaughters(); … … 17 62 } 18 63 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" ); 23 69 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); 25 71 if(prim){ delete prim; prim=NULL;} 26 72 return; … … 39 85 //evt->FillMap(); 40 86 } 41 } 87 } 42 88 } 43 89 … … 56 102 57 103 #ifdef FROG_ZLIB 58 59 60 61 62 63 104 if(CompressFiles){ 105 char* path2 = new char[strlen(path)]; 106 strcpy(path2,path); 107 FROG_ZLIB_Deflate(path2); 108 delete path2; 109 } 64 110 #endif 65 111 } … … 72 118 FILE* pFile; 73 119 if(CurrentSize_==0){ 74 //pFile = fopen("InLive.vis","wb");75 120 pFile = fopen(path,"wb"); 76 121 unsigned short prim_type = prim->type(); … … 94 139 prim->deleteDaughters(); 95 140 }else{ 96 //pFile = fopen("InLive.vis","ab+" );97 141 pFile = fopen(path,"ab+" ); 98 142 fseek(pFile,CurrentSize_,SEEK_SET); … … 107 151 if(CurrentSize_ + dau->size()>=MaxSize){ 108 152 MaxFileHasBeenReached=true; 109 // for(unsigned j=0;j<i;j++){prim->deleteDaughter(i);}110 153 } 111 154 if(MaxFileHasBeenReached)continue; … … 124 167 fclose(pFile); 125 168 126 //pFile = fopen("InLive.vis","rb+" );127 169 pFile = fopen(path,"rb+" ); 128 170 fseek(pFile,2,SEEK_SET); … … 154 196 FROG_Element_Event* FROG_Events::GoToEvent(int i) 155 197 { 198 if(CurrentFile_< 0)return NULL; 199 if(CurrentFile_>=(int)FilesPath_.size())return NULL; 200 156 201 if(frogObjects_->frogEvent_){ 157 202 frogObjects_->frogEvent_->uninit(); 158 203 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); 163 209 if(prim)Current_Event = prim->getDaughterSize()-1; 164 }else{ 210 }else{ 165 211 Current_Event=i; 166 } 212 } 167 213 168 214 if(!prim)return NULL; 169 215 frogObjects_->setEvent(dynamic_cast<FROG_Element_Event*>(prim->getDaughter(Current_Event))); 170 216 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()); 178 225 fclose(pFile); 179 226 … … 185 232 return frogObjects_->frogEvent_; 186 233 } 234 187 235 FROG_Element_Event* FROG_Events::NextEvent() 188 236 { … … 190 238 if(Current_Event+1<prim->getDaughterSize()){ Current_Event++; 191 239 }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 197 246 FROG_Element_Event* FROG_Events::PreviousEvent() 198 247 { … … 200 249 if(Current_Event!=0){ Current_Event--; 201 250 }else{ 202 Load(FilePath_);251 PreviousFile(); 203 252 Current_Event = prim->getDaughterSize()-1; 204 253 } … … 206 255 } 207 256 208 void FROG_Events::Init(FROG_Objects_Extended* frogObjects) 209 { 210 if(!prim)return; 211 frogObjects_ = frogObjects; 257 void 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 268 void 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 279 const 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(); 212 286 } 213 287 -
trunk/Utilities/FROG/Includes/FROG/FROG_Events.h
r95 r96 17 17 #include "FROG_Element_Event.h" 18 18 #include "FROG_Objects_Extended.h" 19 #include "FROG_Net_Tools.h" 19 20 20 21 #ifdef FROG_ZLIB … … 32 33 std::vector<unsigned int> OpenedMenu; 33 34 private : 34 const char* FilePath_; 35 std::vector<string> FilesPath_; 36 int CurrentFile_; 35 37 unsigned int CurrentSize_; 36 38 public: 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){ 38 40 prim = new FROG_Element_Base(C_PRIMARY); 39 41 … … 43 45 void AddEvent(FROG_Element_Event* event); 44 46 47 void Load (); 48 void Load (std::vector<string>& FilesFromCard); 45 49 void Load (const char* path); 50 void Load (int CurrentFile); 51 46 52 void Save (const char* path); 47 53 bool SaveInLive (const char* path, bool CloseFile=false, bool CompressFiles=true, unsigned int MaxSize=(unsigned int)-1); … … 52 58 FROG_Element_Event* PreviousEvent(); 53 59 60 void NextFile(); 61 void PreviousFile(); 62 const char* CurrentFile(); 63 54 64 FROG_Element_Event* getCurrentEvent() const { 55 65 if( Current_Event<prim->getDaughterSize() ) … … 59 69 60 70 int NumberOfEvents() const { return prim->getDaughterSize(); } 61 void Init(FROG_Objects_Extended* frogObjects);62 71 63 72 void keepEventToDisplay(FROG_Element_Base* mother); … … 68 77 void keepOpenedMenu(FROG_Element_Base* mother); 69 78 void updateOpenedMenu(); 70 71 72 79 }; 73 80 -
trunk/Utilities/FROG/Includes/FROG/FROG_Net.h
r95 r96 3 3 #define _FROG_NET_H__ 4 4 5 #include "../CURL/curl.h"6 5 #include <stdio.h> 7 6 #include <iostream> 8 7 8 #include "../CURL/curl.h" 9 9 class FROG_Net { 10 10 -
trunk/Utilities/FROG/Includes/FROG/FROG_Net_Tools.h
r95 r96 6 6 #include <iostream> 7 7 8 #include "FROG_ZLib.h" 9 #include "FROG_Path.h" 10 11 #ifdef FROG_CURL 8 12 #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 90 14 91 15 92 return localPath;93 }94 16 17 bool GetPathFromURL(char* dest, char* inputFile, unsigned int sizeMax, const char* AbsolutePath); 18 bool IsExpectedFileSize(char* fileName); 19 void* DownLoadFile(void* inputFile,const char* AbsolutePath); 95 20 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 106 24 107 25 #endif -
trunk/Utilities/FROG/Includes/FROG/FROG_Objects_Extended.h
r95 r96 6 6 #define _FROG_OBJECTS_EXTENDED_H__ 7 7 8 #include "FROG_Path.h" 8 9 #include "FROG_Objects.h" 9 10 #include "FROG_Element_Event.h" … … 71 72 #ifdef FROG_OPENGL 72 73 void loadMarkers(){ 73 char Path[255]; 74 char LocalPath[2048]; 75 char AbsolPath[2048]; 74 76 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); 80 81 Marker[i] = tmp; 81 82 }else{ -
trunk/Utilities/FROG/Includes/FROG/FROG_ReadCards.cpp
r95 r96 14 14 #include "FROG_ReadCards.h" 15 15 16 // repalce the std getline method, 17 // in order to be LINUX/MACOS/WINDOWS compatible 18 // Because those systems have different end line convention 19 istream& 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 16 49 // remove comments and whitespace 17 50 void FROG_ReadCards::clean() { … … 22 55 while ( !mFile.eof() ) { 23 56 24 getline(mFile,line,'\n'); 57 getLine(mFile,line); 58 //getline(mFile,line,'\n'); 25 59 //printf("%s\n",line.c_str()); 26 60 … … 88 122 // check that the file is not already in the list 89 123 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) 92 128 alreadyIn=true; 93 129 } 94 130 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); 98 132 } 133 99 134 } 100 135 }else{ … … 116 151 void FROG_ReadCards::Construct(const char* filename) { 117 152 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); 119 156 120 157 for(unsigned int i = 0;i<mFilesToRead.size();i++){ … … 405 442 } 406 443 444 407 445 std::string FROG_ReadCards::GetString(const char* format, ...){ 408 446 char tag[255]; -
trunk/Utilities/FROG/Includes/FROG/FROG_ReadCards.h
r95 r96 12 12 using namespace std; 13 13 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 15 22 #include <ext/hash_map> 16 23 using namespace __gnu_cxx; … … 24 31 typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> > Values; 25 32 typedef hash_map<std::string, std::vector< std::string >, hash<std::string>, equal_to<std::string> >::iterator Values_Iterator; 26 #elif macos27 #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 #else39 #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;43 33 #endif 44 34 … … 58 48 public: 59 49 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); } 63 55 64 56 ~FROG_ReadCards() { } 65 57 58 istream& getLine(istream& is, string& str); 66 59 67 60 int GetNValues() const { return mValues.size(); } … … 91 84 bool GetBool(bool Default, const char* format, ...); 92 85 86 public: 87 std::string mAbsolutePath; 93 88 94 89 private: -
trunk/Utilities/FROG/Includes/FROG/FROG_Texture.cpp
r95 r96 33 33 } 34 34 35 void LoadTexture(unsigned int* id, c har* strFileName, bool VerticalFlip)35 void LoadTexture(unsigned int* id, const char* strFileName, bool VerticalFlip) 36 36 { 37 37 if(!strFileName) return; … … 68 68 } 69 69 70 void SaveScreenshot(c har* strFileName,unsigned int Width, unsigned int Height, void (*func)(void))70 void SaveScreenshot(const char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void)) 71 71 { 72 72 if(!strFileName) return; … … 134 134 135 135 136 void LoadPNG(stTexture* Texture, c har* strFileName)136 void LoadPNG(stTexture* Texture, const char* strFileName) 137 137 { 138 138 png_structp png_ptr; … … 229 229 230 230 231 void SavePNG(stTexture* Texture, c har* strFileName)231 void SavePNG(stTexture* Texture, const char* strFileName) 232 232 { 233 233 if(Texture->texels==NULL || Texture->width==0 || Texture->height==0) return; -
trunk/Utilities/FROG/Includes/FROG/FROG_Texture.h
r95 r96 10 10 #endif 11 11 12 #ifdef linux 13 #elif macos 14 #else 12 #ifdef windows 15 13 #pragma comment (lib,"Includes/ZLIB/Lib/zdll.lib") 16 14 #pragma comment (lib,"Includes/PNGLIB/Lib/libpng13.lib") … … 54 52 stTexture* VerticalFlipTexture(stTexture* Source); 55 53 56 void LoadTexture(unsigned int* id, c har* strFileName, bool VerticalFlip=false);57 void SaveScreenshot(c har* strFileName,unsigned int Width, unsigned int Height, void (*func)(void));54 void LoadTexture(unsigned int* id, const char* strFileName, bool VerticalFlip=false); 55 void SaveScreenshot(const char* strFileName,unsigned int Width, unsigned int Height, void (*func)(void)); 58 56 59 void LoadPNG(stTexture* Texture, c har* strFileName);60 void SavePNG(stTexture* Texture, c har* strFileName);57 void LoadPNG(stTexture* Texture, const char* strFileName); 58 void SavePNG(stTexture* Texture, const char* strFileName); 61 59 62 60 -
trunk/Utilities/FROG/Includes/FROG/FROG_View.h
r95 r96 57 57 58 58 bool screen_flag; 59 bool isSwappable; 59 60 60 61 float BackGround_Color_[4]; … … 84 85 85 86 screen_flag = false; 87 isSwappable = true; 86 88 87 89 BackGround_Color_[0] = 0; … … 106 108 frogObjects_->frogCard_->GetFloat(&(cam_->target_y) ,"%s_Cam_Target_Y" ,Name_); 107 109 frogObjects_->frogCard_->GetFloat(&(cam_->target_z) ,"%s_Cam_Target_Z" ,Name_); 110 111 isSwappable = frogObjects_->frogCard_->GetBool(isSwappable,"%s_IsSwappable", Name_); 108 112 109 113 if(geomToDisplay_.size()>0)geomToDisplay_.clear(); -
trunk/Utilities/FROG/Includes/FROG/FROG_View_Menu.h
r95 r96 14 14 class Order { 15 15 public: 16 bool operator () (MenuEntry* a, MenuEntry* b){16 // bool operator () (MenuEntry* a, MenuEntry* b){ 17 17 // return (a->type() < b->type()); 18 18 … … 21 21 // FROG_Element_Base_With_DetId* FEBD = dynamic_cast<FROG_Element_Base_With_DetId*>(mother); 22 22 // 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 // } 25 25 }; 26 26 … … 57 57 Imax = 0; 58 58 59 Menu_CleanUp(); 59 Menu_CleanUp(); 60 60 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)); 62 62 } 63 63 -
trunk/Utilities/FROG/Includes/FROG/FROG_View_Tools.h
r95 r96 65 65 // printf("Swap : %s <--> %s\n",v1->Name_, v2->Name_); 66 66 67 if( !(v1->isSwappable && v2->isSwappable) )return; 68 67 69 float temp_card_vx_ = v1->card_vx_; 68 70 float temp_card_vy_ = v1->card_vy_; -
trunk/Utilities/FROG/Includes/FROG/FROG_ZLib.cpp
r95 r96 57 57 58 58 59 bool FROG_ZLIB_Deflate(char* source_path ){59 bool FROG_ZLIB_Deflate(char* source_path, bool keepIntermediateFile){ 60 60 unsigned int N = strlen(source_path); 61 61 … … 79 79 printf("%s has been deflate corretly\n",source_path); 80 80 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" ); 82 82 return true; 83 83 }else if(returnedValue==Z_MEM_ERROR){ … … 155 155 156 156 157 bool FROG_ZLIB_Inflate(char* source_path ){157 bool FROG_ZLIB_Inflate(char* source_path, bool keepIntermediateFile){ 158 158 unsigned int N = strlen(source_path); 159 159 … … 187 187 if(returnedValue==Z_OK){ 188 188 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" ); 191 191 strcpy(source_path,dest_path); 192 192 return true; -
trunk/Utilities/FROG/Includes/FROG/FROG_ZLib.h
r95 r96 8 8 #include "../ZLIB/zlib.h" 9 9 10 //#ifdef linux 11 //#else 10 #ifdef windows 12 11 // #pragma comment (lib,"Includes/ZLIB/Lib/zdll.lib") 13 //#endif12 #endif 14 13 15 14 #define CHUNK 16384 … … 20 19 bool FROG_ZLIB_IsUnZippedFileExist(char* source_path); 21 20 22 bool FROG_ZLIB_Inflate(char* source_path);23 21 int FROG_ZLIB_Inflate(FILE *source, FILE *dest); 22 bool FROG_ZLIB_Inflate(char* source_path, bool keepIntermediateFile=false); 24 23 25 24 int FROG_ZLIB_Deflate(FILE *source, FILE *dest, int level); 26 bool FROG_ZLIB_Deflate(char* source_path );25 bool FROG_ZLIB_Deflate(char* source_path, bool keepIntermediateFile=false); 27 26 28 27 #endif
Note:
See TracChangeset
for help on using the changeset viewer.