1 | #ifndef _FROG_ELEMENT_EVENT_SIM_HIT_H__
|
---|
2 | #define _FROG_ELEMENT_EVENT_SIM_HIT_H__
|
---|
3 |
|
---|
4 | #include "FROG_Element_Base.h"
|
---|
5 | #include "FROG_Objects_Extended.h"
|
---|
6 | #ifdef FROG_OPENGL
|
---|
7 | #include "../GL/glext.h"
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | class FROG_Element_Event_Sim_Hit : public FROG_Element_Base {
|
---|
11 | public :
|
---|
12 | float x; float y; float z; float Charge; unsigned char ProcessType;
|
---|
13 | FROG_Objects_Extended* frogObjects_;
|
---|
14 | unsigned int nameId_;
|
---|
15 |
|
---|
16 |
|
---|
17 | virtual bool isCompactible(){ return true; }
|
---|
18 |
|
---|
19 | static unsigned int sizeOf(){ return FROG_Element_Base::sizeOf() + 4*sizeof(float) + 1*sizeof(unsigned char); }
|
---|
20 |
|
---|
21 | FROG_Element_Event_Sim_Hit(float x_, float y_, float z_, float Charge_, unsigned char ProcessType_):
|
---|
22 | FROG_Element_Base(C_SIM_HIT),
|
---|
23 | x(x_),y(y_),z(z_),Charge(Charge_), ProcessType(ProcessType_)
|
---|
24 | {
|
---|
25 | size_ = sizeOf();
|
---|
26 | }
|
---|
27 |
|
---|
28 | FROG_Element_Event_Sim_Hit(FILE* pFile) : FROG_Element_Base(C_RECO_HIT)
|
---|
29 | {
|
---|
30 | size_ = sizeOf();
|
---|
31 | fread(&x ,sizeof(x) ,1,pFile);
|
---|
32 | fread(&y ,sizeof(y) ,1,pFile);
|
---|
33 | fread(&z ,sizeof(z) ,1,pFile);
|
---|
34 | fread(&Charge ,sizeof(Charge) ,1,pFile);
|
---|
35 | fread(&ProcessType ,sizeof(ProcessType) ,1,pFile);
|
---|
36 | }
|
---|
37 |
|
---|
38 | virtual void write () {
|
---|
39 | size_ = sizeOf();
|
---|
40 | data_ = new unsigned char[size_-6];
|
---|
41 | data_ = FillBuffer( data_, &x, sizeof(x));
|
---|
42 | data_ = FillBuffer( data_, &y, sizeof(y));
|
---|
43 | data_ = FillBuffer( data_, &z, sizeof(z));
|
---|
44 | data_ = FillBuffer( data_, &Charge, sizeof(Charge));
|
---|
45 | data_ = FillBuffer( data_, &ProcessType, sizeof(ProcessType));
|
---|
46 | data_ = (unsigned char*)((unsigned long)data_ - (size_-6) );
|
---|
47 | }
|
---|
48 |
|
---|
49 | virtual void printInfos(char* buffer){
|
---|
50 | sprintf(buffer,"SimHit : x=%7.2f y=%7.2f z=%7.2f Charge=%E ProcessType=%i",x,y,z,Charge,ProcessType);
|
---|
51 | }
|
---|
52 |
|
---|
53 | #ifdef FROG_OPENGL
|
---|
54 | virtual void display(bool UseDisplayList=true, float* color=NULL){
|
---|
55 | // first Init Colors & Style!
|
---|
56 | init(NULL);
|
---|
57 | glColor4fv (style_->color_);
|
---|
58 |
|
---|
59 | if(Start_Display(UseDisplayList)){
|
---|
60 | FROG_Light::SwitchLight_NoNormal();
|
---|
61 |
|
---|
62 | glLoadName( nameId_ );
|
---|
63 |
|
---|
64 | if(style_->marker_>0){
|
---|
65 | glBindTexture(GL_TEXTURE_2D,frogObjects_->getMarker(style_->marker_));
|
---|
66 | glEnable(GL_TEXTURE_2D);
|
---|
67 | glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
|
---|
68 | glEnable( GL_POINT_SPRITE_ARB );
|
---|
69 | }
|
---|
70 |
|
---|
71 | glPointSize (style_->markerSize_);
|
---|
72 | glBegin (GL_POINTS);
|
---|
73 | glVertex3f(x, y, z);
|
---|
74 | glEnd();
|
---|
75 |
|
---|
76 | if(style_->marker_>0){
|
---|
77 | glDisable( GL_POINT_SPRITE_ARB );
|
---|
78 | glDisable(GL_TEXTURE_2D);
|
---|
79 | glBindTexture(GL_TEXTURE_2D,0);
|
---|
80 | }
|
---|
81 |
|
---|
82 | FROG_Light::SwitchLight_Normal();
|
---|
83 | End_Display(UseDisplayList);
|
---|
84 | }
|
---|
85 | }
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | virtual void init(void* frogObjects){
|
---|
89 | if(frogObjects!=NULL){
|
---|
90 | frogObjects_ = (FROG_Objects_Extended*) frogObjects;
|
---|
91 | nameId_ = frogObjects_->frogEvent_->name_map.size();
|
---|
92 | frogObjects_->frogEvent_->name_map.push_back(this);
|
---|
93 | //for(unsigned int i=0;i<daughters_.size();i++) daughters_[i]->init(frogObjects);
|
---|
94 | }else if(frogObjects==NULL && frogObjects_ != NULL){
|
---|
95 | if(mother_ != NULL && mother_->style_ !=NULL){ style_ = mother_->style_;
|
---|
96 | }else{ style_ = new FROG_Objects_Style(); }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | };
|
---|
100 |
|
---|
101 | #endif
|
---|