Page MenuHomeHEPForge

main.cpp
No OneTemporary

main.cpp

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
#include "main.h"
unsigned int EventI = 0;
void Loading()
{
switch(mLoading_I)
{
case 0:
start = time ( NULL );
// TURN Vertical Synchronisation (VSYNC) OFF
// This allow the system to have more than 60 or 75FPS.
#ifdef linux
if(GLX_SGI_swap_control){glXSwapIntervalSGI(0);printf("GLX_SGI_swap_control OK\n");}else{printf("GLX_SGI_swap_control NOT OK\n");}
#else
if(WGL_EXT_swap_control){wglSwapIntervalEXT(0);printf("WGL_EXT_swap_control OK\n");}else{printf("WGL_EXT_swap_control NOT OK\n");}
#endif
// Init the random number generator
srand (time(NULL));
Fonts = new FROG_Fonts();
ViewScreen = new FROG_View_Screen("Screen");
ViewScreen->Reshape(WINDOW_WIDTH,WINDOW_HEIGHT);
ViewScreen->LoadingInProgress(0.0f,"Reading config.txt",Fonts,LogoTexture);
LoadCard("config.txt");
if(!Card->IsTagPresent("InputGeom") && !Card->IsTagPresent("InputVisFile")){
printf("There is no .geom file neither than .vis file in the Config card\n");
printf("FROG will stop. Please update the Config card (config.txt)\n");
exit(0);
}
break;
case 1:
ViewScreen->LoadingInProgress(1.0f,"Downloading Geometry\n(if necessary)",Fonts,LogoTexture);
if(Card->IsTagPresent("InputGeom")){
inputGeom = Card->GetStringVector("InputGeom");
for(unsigned int g=0;g<inputGeom.size();g++){
inputGeom[g] = string((char*)DownLoadFile( (char*)inputGeom[g].c_str() ) );
}
}
break;
case 2:
ViewScreen->LoadingInProgress(10.0f,"Downloading Events\n(if necessary)",Fonts,LogoTexture);
if(Card->IsTagPresent("InputVisFile")) {
inputVisFileFromCard = Card->GetString("InputVisFile");
inputVisFile = string((char*)DownLoadFile( (char*)inputVisFileFromCard.c_str() ) );
}
break;
case 3:{
ViewScreen->LoadingInProgress(20.0f,"Loading Geometry",Fonts,LogoTexture);
if(geom)delete geom;
geom = new FROG_Geometry();
if(inputGeom.size()<=0){printf("Error : No Input Geometry File\n");exit(0);}
while(inputGeom.size()>0){
ViewScreen->LoadingInProgress(20.f+30.f/inputGeom.size(),(char*)inputGeom[inputGeom.size()-1].c_str(),Fonts,LogoTexture);
geom->Load((char*)inputGeom[inputGeom.size()-1].c_str());
inputGeom.pop_back();
}
frogObjects_ = new FROG_Objects_Extended(geom,NULL,Card);
/*FILE* f = fopen("geom.txt","w");
FROG_ELEMENT::PrintTree(f, geom->prim, 0);
fclose(f);*/
//FILE* f = fopen("temp2.txt","w");
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11100000), 0, 0, 4); //Transverse
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11300000), 0,-18, 3); //Transverse
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11500000), 0,-10,-8); //Transverse
//fclose(f);
//FILE* f = fopen("temp2.txt","w");
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11100000), 0, 0, 1); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11200000), 0, 0, 2); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11300000), 0, -3, 3); //Longitudinal
//FROG_ELEMENT::PrintSelection2(f, geom->FindByDetId(11300000), 0, 0.8, 1.2, 0.8); //Longitudinal //TO BE FIX
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11400000), 0, -3, 3); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11500000), 0, 0, 10); //Longitudinal //TO BE FIX
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(11600000), 0, -5, 5); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(12100000), 0, -50, 50); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(12200000), 0, -75, 75); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(12300000), 0, -10, 150); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(13100000), 0, 0, 2); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(13200000), 0, 0, 2); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(13300000), 0, 3.0, 3.3); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(14100000), 0, 0, 10); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(14200000), 0, 0, 15); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(14300000), 0, 0, 20); //Longitudinal
//FROG_ELEMENT::PrintSelection(f, geom->FindByDetId(14400000), 0, 0, 15); //Longitudinal
//fclose(f);
}break;
case 4:
ViewScreen->LoadingInProgress(80.0f,(char*)inputVisFile.c_str(),Fonts,LogoTexture);
if(events)delete events;
events = new FROG_Events();
events->Load(inputVisFile.c_str());
events->frogObjects_ = frogObjects_;
events->Init(frogObjects_);
events->readEventToDisplay(Card);
if(SCREENSAVER)eventNumber = rand()%((int)events->NumberOfEvents());
event = events->GoToEvent(eventNumber);
break;
case 5:{
ViewScreen->LoadingInProgress(95.0f,"Views Initialisation",Fonts,LogoTexture);
ViewScreen->displayFunc_ = displaytext;
std::vector<string> ViewsName = Card->GetStringVector("ActiveViews");
ViewMain = ViewScreen;
for(unsigned int i=0;i<ViewsName.size();i++){
char* tmp = new char[ViewsName[i].size()+1];
strcpy(tmp,ViewsName[i].c_str());
ActiveViews.push_back(FROG_VIEW::Create(tmp,frogObjects_));
}
if(ActiveViews.size()>0)ViewMain = ActiveViews[0];
ViewScreen->Reshape(WINDOW_WIDTH,WINDOW_HEIGHT);
for(unsigned int j=0;j<ActiveViews.size();j++){
ActiveViews[j]->Reshape(WINDOW_WIDTH,WINDOW_HEIGHT);
ActiveViews[j]->displayFunc_ = &display2;
}
ViewMain->IsActive = true;
geom->updateGeomToDisplay((void*)frogObjects_);
}break;
case 20:
ViewScreen->LoadingInProgress(99.0f,"Preparation for Display",Fonts,LogoTexture);
glEnable (GL_DEPTH_TEST);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glEnable(GL_POINT_SMOOTH);
//glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
glEnable(GL_LINE_SMOOTH);
//glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
//glEnable(GL_POLYGON_SMOOTH);
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND) ;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
mLoading = false;
end = time ( NULL );
printf("Loading Time = %isec\n",(int)(end-start));
glutDisplayFunc (display);
glutIdleFunc (display);
return;
break;
default:
break;
}
mLoading_I++;
}
void reshape (int w, int h)
{
if (h == 0) h = 1;
WINDOW_WIDTH = w;
WINDOW_HEIGHT = h;
if(ViewScreen)ViewScreen->Reshape(WINDOW_WIDTH,WINDOW_HEIGHT);
for(unsigned int j=0;j<ActiveViews.size();j++){
ActiveViews[j]->Reshape(WINDOW_WIDTH,WINDOW_HEIGHT);
}
glutPostRedisplay ();
}
void displaytext()
{
glColor4fv (Txt_Color);
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH-126,WINDOW_HEIGHT - 30,"% 10i FPS", ViewScreen->FPS);
if(mHelpScreen){
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 45 ,"F5 = SimTrack : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 60 ,"F6 = SimVertex : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 75 ,"F7 = PSimHits : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 90 ,"F8 = RecoTrack : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 105 ,"F9 = EcalHits : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 120 ,"F10 = HcalHits : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 135 ,"F11 = MuonHit/Seg: ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 150 ,"0 = Geometry to Display : NONE");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 165 ,"9 = Geometry to Display : FULL");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 200 ,"LEFT = Previous Event");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 215 ,"RIGHT = Next Event");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 230 ,"UP = Increase Rotation");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 245 ,"DOWN = Decrease Rotation");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 260 ,"p = Zoom In");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 275 ,"m = Zoom Out");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 290 ,"ENTER = Screenshot");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 305 ,"SPACE = Rotation : ON/OFF");
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH/3,WINDOW_HEIGHT - 320 ,"ESCAPE = Exit");
Fonts->Font_Fixed_9_by_15->glPrint(120,3,"This program has been created by Loic Quertenmont, loic.quertenmont@cern.ch");
}else{
Fonts->Font_Fixed_9_by_15->glPrint(WINDOW_WIDTH-153,WINDOW_HEIGHT - 14,"Press F1 for Help");
if(event) Fonts->Font_Fixed_9_by_15->glPrint(0,WINDOW_HEIGHT - 14,"#Run %i #Event %i (%02i/%02i)",event->NRun_, event->NEvent_, events->Current_Event, (int)events->NumberOfEvents()-1);
if(event) Fonts->Font_Fixed_9_by_15->glPrint(0,WINDOW_HEIGHT - 29,"%s", event->EventDate_);
char temp[255];
if(mCLicked_DetId==(unsigned int)-1){
}else if(mCLicked_DetId>1000000){
FROG_Element_Base_With_DetId* tmp = dynamic_cast<FROG_Element_Base_With_DetId*>(geom->FindByDetId(mCLicked_DetId));
if(tmp!=NULL){
sprintf(temp,"DetId = %i : Press '1' or '2' or ... to Display the parent object",tmp->DetId());
Fonts->Font_Helvetica_10->glPrint(120,3,temp);
}
}else{
if(mCLicked_DetId<event->name_map.size()){
FROG_Element_Base* tmp = event->name_map[mCLicked_DetId];
if(tmp!=NULL){
tmp->printInfos(temp);
Fonts->Font_Helvetica_10->glPrint(120,3,temp);
}
}
}
}
ViewScreen->DrawLogo(0,0,120,80,LogoTxtTexture, Fonts);
}
void display2()
{
// Display Selected Object (This should be drawn in first)
if(mCLicked_DetId==(unsigned int)-1){
}else if(mCLicked_DetId>1000000){
FROG_Element_Base_With_DetId* tmp = dynamic_cast<FROG_Element_Base_With_DetId*>(geom->FindByDetId(mCLicked_DetId));
float color[4] = {1,1,1,1};
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
if(tmp!=NULL){tmp->display(false,color);}
}else if(mCLicked_DetId<event->name_map.size()){
FROG_Element_Base* tmp = event->name_map[mCLicked_DetId];
float color[4] = {1,1,1,1};
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if(tmp!=NULL){tmp->display(false,color);}
}
// Display the FrameWork
glColor4fv (ZAxis_Color);
glLineWidth(ZAxis_Thickness);
glBegin (GL_LINES);
glVertex3d (0,0,-300);
glVertex3d (0,0,300);
glEnd();
glLineWidth(1);
/*if(print_FrameWork){
glColor4fv (Framework_Color);
glLineWidth(Framework_Thickness);
DrawCylinder(CMS_TRACKER_RADIUS, 13, 2*CMS_TRACKER_LENGTH, 0, 0, 0);
glBegin (GL_LINES);
glColor4d (1,0,0,1);
glVertex3d (0,0,0);
glVertex3d (0,0,100);
glColor4d (0,1,0,1);
glVertex3d (0,0,0);
glVertex3d (0,100,0);
glColor4d (0,0,1,1);
glVertex3d (0,0,0);
glVertex3d (100,0,0);
glEnd();
glLineWidth(1);
}*/
// Display the 3D Geometry (only if in a 3D View)
if(geom!=NULL && ViewMain->Type_==VIEW3D){
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
geom->display();
}
// Display the Event
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if(event!=NULL) event->display();
}
void display()
{
//-------- update event file if required ------------
//updateEventsFile();
glClearColor(BackGround_Color[0],BackGround_Color[1],BackGround_Color[2],1.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset le buffer de couleur et de profondeur
ViewMain->Display();
for(unsigned int j=0;j<ActiveViews.size();j++){
if(ActiveViews[j]!=ViewMain) ActiveViews[j]->Display();
}
if(ViewScreen) ViewScreen->Display();
glutSwapBuffers();
}
void updateEventsFile() {
// this function lauch a threat to download the input event file
// if required by the variable updateVisFileTime
#ifdef linux
if( updateVisFileTime>0 && !Thread_Run) {
char* argtosend = (char*)inputVisFileFromCard.c_str();
if (pthread_create (&Thread_H, NULL, DownLoadFile, (void*)argtosend) < 0) {
printf("pthread_create error for Thread_H\n");
exit (1);
}
Thread_Run=true;
}
static time_t upstart = time (NULL );
time_t upstop = time( NULL );
if(upstop - upstart > updateVisFileTime && Thread_Run) {
(void)pthread_join (Thread_H, NULL);
Thread_Run=false;
glutDisplayFunc (Loading);
glutIdleFunc (Loading);
mLoading_I = 30;
mLoading = true;
start = time ( NULL );
}
#else
if( updateVisFileTime>0 && !Thread_Run) {
char* argtosend = (char*)inputVisFileFromCard.c_str();
Thread_H = CreateThread( NULL, 0, WinDownLoadFile, (void*)argtosend, 0, &Thread_Id);
if (Thread_H == NULL){
printf("Unable to create thread\n");
exit(1);
}
Thread_Run = true;
}
static time_t upstart = time (NULL );
time_t upstop = time( NULL );
if(upstop - upstart > updateVisFileTime && Thread_Run) {
if(WaitForSingleObject(Thread_H, 0) == WAIT_OBJECT_0){
Thread_Run=false;
glutDisplayFunc (Loading);
glutIdleFunc (Loading);
mLoading_I = 30;
mLoading = true;
start = time ( NULL );
}else{
// File is not yet fully downloaded
}
upstart = time (NULL );
}
#endif
}
void processNormalKeys(unsigned char key, int x, int y)
{
int Mod = glutGetModifiers();
if(Mod==GLUT_ACTIVE_CTRL)key+=96;
switch(key){
case 27 :
exit(0);
break;
case 13 :{
char temp[255]; sprintf(temp,"screenshot%02i.%s",SCREENSHOT,SCREENSHOT_FORMAT);
SaveScreenshot(temp,WINDOW_WIDTH,WINDOW_HEIGHT, display2);
SCREENSHOT++;
}break;
case ' ':{
if(ViewMain->Type_==VIEW3D) ((FROG_View_3D*)ViewMain)->shouldRotate_ = ! ((FROG_View_3D*)ViewMain)->shouldRotate_;
}break;
case 'p' :
ViewMain->cam_->R*=0.95;
break;
case 'm' :
ViewMain->cam_->R*=1.05;
break;
case 'r' :
mDisplayMother = !mDisplayMother;
break;
case 'R' :
LoadCard("config.txt");
geom->updateGeomToDisplay(Card);
events->prim->setDisplay(0);
events->Init(frogObjects_);
events->readEventToDisplay(Card);
event = events->GoToEvent(eventNumber);
break;
case 'f' :
print_FrameWork = !print_FrameWork;
break;
case 'l':
if(Mod == GLUT_ACTIVE_CTRL){
if(FULLSCREEN){
glutReshapeWindow(SAVE_WINDOW_W, SAVE_WINDOW_H);
glutPositionWindow(SAVE_WINDOW_X,SAVE_WINDOW_Y);
}else{
SAVE_WINDOW_W = glutGet(GLUT_WINDOW_WIDTH);
SAVE_WINDOW_H = glutGet(GLUT_WINDOW_HEIGHT);
SAVE_WINDOW_X = glutGet(GLUT_WINDOW_X);
SAVE_WINDOW_Y = glutGet(GLUT_WINDOW_Y);
glutFullScreen();
}
FULLSCREEN = !FULLSCREEN;
}
break;
case '0' : geom->prim->setDisplay(0);
break;
case '9' : geom->prim->setDisplay(1);
break;
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
if(mCLicked_DetId>1000000){
FROG_Element_Base* det = geom->FindByDetId(mCLicked_DetId);
if(det!=NULL)det->setParentDisplay(1,key-48);
geom->prim->setDisplay(2);
}
break;
}
if(SCREENSAVER)exit(0);
}
void processSpecialKeys(int key, int x, int y)
{
int Mod = glutGetModifiers();
// if(Mod==GLUT_ACTIVE_CTRL)key+=96;
switch(key) {
case GLUT_KEY_F1 :
mHelpScreen = !mHelpScreen;
break;
case GLUT_KEY_F5 :
events->updateEventToDisplay(EVTID_SIMTRK);
break;
case GLUT_KEY_F6 :
events->updateEventToDisplay(EVTID_SIMVTX);
break;
case GLUT_KEY_F7 :
events->updateEventToDisplay(EVTID_SIMHIT);
break;
case GLUT_KEY_F8 :
events->updateEventToDisplay(EVTID_TRK);
break;
case GLUT_KEY_F9 :
events->updateEventToDisplay(EVTID_ECALHIT);
break;
case GLUT_KEY_F10:
events->updateEventToDisplay(EVTID_HCALHIT);
break;
case GLUT_KEY_F11 :
events->updateEventToDisplay(EVTID_MUONHIT);
events->updateEventToDisplay(EVTID_MUONSEG);
break;
case GLUT_KEY_RIGHT :
if(Mod==GLUT_ACTIVE_CTRL){
ViewMain->cam_->Move(-5,0);
}else{
mCLicked_DetId = (unsigned int) -1;
event = events->NextEvent();
}
break;
case GLUT_KEY_LEFT :
if(Mod==GLUT_ACTIVE_CTRL){
ViewMain->cam_->Move(5,0);
}else{
mCLicked_DetId = (unsigned int) -1;
event = events->PreviousEvent();
}
break;
case GLUT_KEY_UP :
if(Mod==GLUT_ACTIVE_CTRL){
ViewMain->cam_->Move(0,5);
}else{
if(ViewMain->Type_==VIEW3D) ((FROG_View_3D*)ViewMain)->dphi_ += 0.005f;
}
break;
case GLUT_KEY_DOWN :
if(Mod==GLUT_ACTIVE_CTRL){
ViewMain->cam_->Move(0,-5);
}else{
if(ViewMain->Type_==VIEW3D) ((FROG_View_3D*)ViewMain)->dphi_ -= 0.005f;
}
break;
case GLUT_KEY_HOME :
if(ViewMain->Type_==VIEW3D) ViewMain->cam_->Reset();
break;
}
if(SCREENSAVER)exit(0);
}
void processMouse(int button, int state, int x, int y)
{
int K = 0;
if(button == GLUT_LEFT_BUTTON){
K = 0;
if(state == GLUT_DOWN){
int ClickedView = -1;
for(int j=ActiveViews.size()-1;j>=0;j--){
if(ActiveViews[j]!= ViewMain && ActiveViews[j]->IsInViewPort(x,y)){
ClickedView = j;
break;
}
}
if(ClickedView>=0){
FROG_VIEW::Swap(ViewMain, ActiveViews[ClickedView]);
ViewMain->IsActive = false;
ViewMain = ActiveViews[ClickedView];
ViewMain->IsActive = true;
}else if(ViewMain->IsInViewPort(x,y)){
gl_select(x,WINDOW_HEIGHT-y);
}
}
}else if(button == GLUT_MIDDLE_BUTTON ){
K = 1;
}else if(button == GLUT_RIGHT_BUTTON){
K = 2;
}else{
}
bool old_state = MouseStates[K];
if(state == GLUT_DOWN) MouseStates[K] = true;
if(state == GLUT_UP) MouseStates[K] = false;
if( old_state != MouseStates[K]) stateChanged=true;
else stateChanged=false;
}
void processMotion(int x, int y) {
if(MouseStates[2]){
static int xold=x, yold=y;
if( stateChanged ) { xold=x; yold=y; stateChanged=false; return; }
if(ViewMain->Type_==VIEW3D){
ViewMain->cam_->phi = ViewMain->cam_->phi + 10.0*((float)(xold-x)/(float)ViewMain->cam_->R);
ViewMain->cam_->theta = ViewMain->cam_->theta + 10.0*((float)(yold-y)/(float)ViewMain->cam_->R);
}else{
ViewMain->cam_->Move((x-xold),(y-yold));
}
xold=x; yold=y;
}
}
void processPassiveMotion(int x, int y)
{
static int xold=x;
static int yold=y;
if(SCREENSAVER && (abs(x-xold)>3 || abs(y-yold)>3) )exit(0);
}
void gl_select(int x, int y)
{
ViewMain->Display_Begin();
GLuint buff[64] = {0};
GLint hits, view[4];
glSelectBuffer(64, buff);
glGetIntegerv(GL_VIEWPORT, view);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(x-2, y-2, 4.0, 4.0, view);
ViewMain->ProjectionMatrix();
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
if(geom ) { geom ->display(); }
if(event) { event->display(); }
glMatrixMode(GL_PROJECTION);
glPopMatrix();
hits = glRenderMode(GL_RENDER);
list_hits(hits, buff);
glMatrixMode(GL_MODELVIEW);
}
void list_hits(GLint hits, GLuint *names)
{
unsigned int i;
// names[i * 4 + 0] = 1 names[i * 4 + 1] = MinZ
// names[i * 4 + 3] = Name names[i * 4 + 2] = MaxZ
//get Min in Z;
// unsigned int MinZ = (unsigned int)-1;
// unsigned int NearestHit = 0;
// for (i = 0; i < hits; i++){
// if( names[i*4+1]<MinZ ){MinZ=names[i*4+1]; NearestHit = i;}
// }
if(hits==0)return;
unsigned int NearestHit = rand()%hits;
for (i = 0; (int)i < hits; i++) {
unsigned int tmp = names[i * 4 + 3];
//printf("--> %i > %i\n",i,tmp);
if(i == NearestHit){
mCLicked_DetId = tmp;
}
}
}
void LoadCard(const char* inputCard ) {
if(Card)delete Card;
Card = new FROG_ReadCards(inputCard);
Card->GetInt (&updateVisFileTime , "updateVisFileTime");
Card->GetInt (&eventNumber , "Event_Number");
Card->GetInt (&eventTime , "Event_Time");
if(eventTime>=0)glutTimerFunc(1+eventTime*1000,AutomaticEventChanging, 0);
Card->GetChar (SCREENSHOT_FORMAT,256, "Screenshot_Format");
Card->GetColor(BackGround_Color , "BackGround_Color");
Card->GetColor(Txt_Color , "Txt_Color");
Card->GetColor(Framework_Color , "Framework_Color");
Card->GetFloat(&Framework_Thickness , "Framework_Thickness");
Card->GetColor(ZAxis_Color , "ZAxis_Color");
Card->GetFloat(&ZAxis_Thickness , "ZAxis_Thickness");
}
void AutomaticEventChanging (int Extra)
{
if(!mLoading && events && event)event = events->NextEvent();
//if(!mLoading && events && event)event = events->GoToEvent(events->Current_Event);
glutTimerFunc(1+eventTime*1000,AutomaticEventChanging, 0);
EventI++;
if(event && events)printf("%8u | Run %4i Event %4i | Event %4i in File Containing %4i Events\n",EventI,event->NRun_,event->NEvent_,events->Current_Event, (int)events->NumberOfEvents()-1);
}
int main (int argc, char *argv[])
{
for(int i=1;i<argc;i++){
if(argv[i][0]=='-' && argv[i][1]=='s') SCREENSAVER = true;
}
// initialisation de GLUT
glutInit (&argc, argv);
// cr饌tion d'une fen黎re OpenGL RVBA avec en simple m駑oire tampon
// avec un tampon de profondeur
glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize (WINDOW_WIDTH, WINDOW_HEIGHT);
glutCreateWindow ("FROG Displayer");
// Charge le logo en m駑oire
LoadTexture(&LogoTexture ,"Resources/Frog_Logo.png");
LoadTexture(&LogoTxtTexture ,"Resources/Frog_LogoTxt.png");
// initialisation des fonctions callback appel馥s par glut
// pour respectivement le redimensionnement de la fen黎re
// et le rendu de la sc鈩e
glutReshapeFunc (reshape);
glutDisplayFunc (Loading);
glutIdleFunc (Loading);
// here are the new entries
glutKeyboardFunc (processNormalKeys);
glutSpecialFunc (processSpecialKeys);
glutMouseFunc(processMouse);
glutMotionFunc(processMotion);
if(SCREENSAVER){
eventTime = 20;
glutPassiveMotionFunc(processPassiveMotion);
glutFullScreen();
}
// initialisation of GLEW (OpenGL Extension Wrangler Library)
GLenum err = glewInit();
if(GLEW_OK != err){
printf("Problem: glewInit failed, something is seriously wrong\n");
printf("Error: %s\n", glewGetErrorString(err));
exit(0);
}
// entre dans la boucle d'騅鈩ements
glutMainLoop ();
return 0;
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Jan 21, 2:28 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4243667
Default Alt Text
main.cpp (22 KB)

Event Timeline