Allink  v0.1
Animation.cpp
1 #include "DrEffect.h"
2 #ifdef __glut_h__
3 DrEffect *DrE;
4 void Animation::DrMessage(const char * s, ...)
5 {
6 #ifdef DEBUG
7  va_list args;
8  va_start(args, s);
9  vfprintf(stderr, s, args);
10  fprintf(stderr, "\n");
11  va_end(args);
12 #else
13  return;
14 #endif
15 }
16 void ParticleList(){
17  //Pol->RenderPart();
18 }
19 void ParticleRealTime(){
20  return;
21 }
22 void reshape(int w,int h){
23  DrE->Dreshape(w,h);
24 }
25 void Timer(int v){
26  DrE->DTimer(v);
27 }
28 void MouseMove(int x,int y){
29  DrE->DMouseMove(x,y);
30 }
31 void mouse(int button, int state,int x,int y){
32  DrE->Dmouse(button,state,x,y);
33 };
34 void special(int k, int x, int y){
35  DrE->Dspecial(k,x,y);
36 }
37 void Slide(){}
38 void DrawParticles(){}
39 void Particle(){}
40 void keyboard(unsigned char key,int x, int y){
41  DrE->keyboardDraw(key);
42 }
43 void Menu(){}
44 void Figure(){
45  //Dr->Draw1();
46  DrE->ShowImage();
47 }
48 void Figure1(){
49  DrE->Draw1();
50 }
51 Animation::Animation(QWidget *parent): QGLWidget(parent){
52  FileName = new char[160];
53  DrE = new DrEffect();
54  st = DrE->Hist;
55  sprintf(FileName,"RadDistrNanoR3.8H0.5.tif");
56  xRot = 0;
57  yRot = 0;
58  zRot = 0;
59  Grana = 0;
60  NVar=0;
61  NMass=0;
62  Valori = 20;
63  v1 = new VarDatFile(NMass,NVar,Valori);
64 }
65 void Animation::initializeGL(){
66  DrMessage("Animation.InitialiezeGL");
67  DrE->Window();return; //Dr->OpenImage(FileName);
68  //qglClearColor(trolltechPurple.dark());
69  //object = makeObject();
70  glClearColor(.0,.0,.0,.0);//colore sfondo
71  glShadeModel(GL_SMOOTH);// Enables Smooth Shading
72  glClearDepth(1.0f);// Depth Buffer Setup
73  glEnable(GL_DEPTH_TEST);//Controllo di profondit`a
74  // glDepthMask(GL_FALSE);
75  // glDepthRange(0,-10.);
76  glDepthFunc(GL_LEQUAL);// The Type Of Depth Test To Do
77  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
78  glEnable(GL_CULL_FACE);
79 }
80 void Animation::NomeFile(const QString &S){
81  DrMessage("Animation.NomeFile");
82  sprintf(FileName,"%s",S.ascii());
83 }
84 void Animation::NomeFile(char *ExtName){
85  DrMessage("Animation.NomeFile");
86  sprintf(FileName,"%s",ExtName);
87  Open();
88 }
89 void Animation::Open(){
90  DrMessage("Animation.Open");
91  DrE->OpenImage(FileName);
92  paintGL();
93  repaint();
94 }
95 void Animation::Filter(){
96  DrMessage("Animation.Filter");
97  //DrE->Edges();
98  DrE->EffectFilter();
99  paintGL();
100  repaint();
101 }
102 void Animation::Motion(){
103  DrMessage("Animation.Motion");
104  DrE->EffectMotion();
105  paintGL();
106  repaint();
107 }
108 void Animation::FilterContrast(){
109  DrMessage("Animation.FilterContrast");
110  DrE->Contrast();
111  paintGL();
112  repaint();
113 }
114 void Animation::FilterIncrease(){
115  DrMessage("Animation.FilterIncrease");
116  DrE->EffectIncrease();
117  paintGL();
118  repaint();
119 }
120 void Animation::FilterMC(){
121  DrMessage("Animation.FilterMC");
122  DrE->EffectMC();
123  paintGL();
124  repaint();
125 }
126 void Animation::IncrSlide(){
127  DrMessage("Animation.IncrSlide");
128  Slide++;
129  paintGL();
130  repaint();
131 }
132 void Animation::FilterCoarseGrain(){
133  DrMessage("Animation.FilterCoarseGrain");
134  DrE->EffectCoarseGrain(Grana);
135  paintGL();
136  repaint();
137 }
138 void Animation::Run(){
139  DrMessage("Animation.Run");
140  DrE->Run();
141 }
142 void Animation::ImpGrana(int ExtGrana){
143  if(Grana < 0 || Grana > 32) return;
144  Grana = ExtGrana;
145 }
146 void Animation::resizeGL(int width,int height){
147  DrMessage("Animation.resizeGL");
148  DrE->Dreshape(width,height);return;
149  int side = qMin(width, height);
150  glViewport((width - side) / 2, (height - side) / 2, side, side);
151  glMatrixMode(GL_PROJECTION);
152  glLoadIdentity();
153  gluPerspective(60,(GLfloat) width/(GLfloat) height,.1,200.);//ang,rapp,zmin,zmax
154  //glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
155  glMatrixMode(GL_MODELVIEW);
156 }
157 void Animation::paintGL(){
158  DrMessage("Animation.paintGL");
159  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
160  glLoadIdentity();
161  //glPushMatrix();
162  glTranslatef(0.,0.,-.6);
163  glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
164  glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
165  glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
166  glColor4f(.0,1.0,.0,1.);
167  DrE->ShowImage();
168  // glutWireCube((GLfloat).5);
169  // Dr->Draw1();
170  //glutSolidSphere(.1,20,20);
171  //glPopMatrix();
172 }
173 void Animation::paintEvent(QPaintEvent (event)){
174  DrMessage("Animation.paintEvent");
175  QPainter p(this);
176  //paintGL();
177 }
178 void Animation::mousePressEvent(QMouseEvent *event)
179 {
180  lastPos = event->pos();
181 }
182 void Animation::mouseMoveEvent(QMouseEvent *event){
183  // Dr->DMouseMove(event->x(),event->y());return;
184  int dx = event->x() - lastPos.x();
185  int dy = event->y() - lastPos.y();
186 
187  if (event->buttons() & Qt::LeftButton) {
188  setXRotation(xRot + 8 * dy);
189  setYRotation(yRot + 8 * dx);
190  } else if (event->buttons() & Qt::RightButton) {
191  setXRotation(xRot + 8 * dy);
192  setZRotation(zRot + 8 * dx);
193  }
194  lastPos = event->pos();
195 }
196 void Animation::setXRotation(int angle)
197 {
198  //normalizeAngle(&angle);
199  if (angle != xRot) {
200  xRot = angle;
201  emit xRotationChanged(angle);
202  updateGL();
203  }
204 }
205 void Animation::setYRotation(int angle)
206 {
207  //normalizeAngle(&angle);
208  if (angle != yRot) {
209  yRot = angle;
210  emit yRotationChanged(angle);
211  updateGL();
212  }
213 }
214 void Animation::setZRotation(int angle)
215 {
216  //normalizeAngle(&angle);
217  if (angle != zRot) {
218  zRot = angle;
219  emit zRotationChanged(angle);
220  updateGL();
221  }
222 }
223 void Animation::Histo(){
224  DrMessage("Animation.Histo");
225  DrE->Histo();
226  st = DrE->Hist;
227  NMass = DrE->NChar;
228  NVar = DrE->NLevel;
229  Valori = 20;
230  return ;
231  delete v1;
232  v1 = new VarDatFile(st,NMass,NVar,Valori);
233  v1->ScriviTutto("Histo.dat",0,1.,1.);
234  //Punta();
235 }
236 void Animation::NablaPhi(){
237  DrMessage("Animation.NablaPhi");
238  DrE->NablaPhi();
239  st = DrE->Phi;
240  NMass = DrE->BuffSize();
241  NVar = 2;
242  Valori = 100;
243  delete v1;
244  v1 = new VarDatFile(st,NMass,NVar,Valori);
245  v1->ScriviTutto("NablaPhi.dat",0,1.,1.);
246  v1->ScriviTutto("NablaPhiLogLog.dat",0,1.,1.);
247  //Punta();
248 }
249 void Animation::Punta(){
250  delete v1;
251  v1 = new VarDatFile(st,NMass,NVar,Valori);
252  DrMessage("Animation.Punta");
253  emit PuntaCoord(st,NMass,NVar,Valori);
254  //emit PuntaCoord(v1);
255 }
256 void Animation::BlackWhite(){
257  DrMessage("Animation.BlackWhite");
258  DrE->BlackWhite();
259  repaint();
260 }
261 void Animation::Binary(){
262  DrMessage("Animation.Binary");
263  DrE->Binary(0);
264  repaint();
265 }
266 
267 #endif// __glut_h__
void DMouseMove(int x, int y)
How the scene rotate (Camera view should be implemented)
Definition: DrawControl.cpp:63
void Dreshape(int w, int h)
Principal reshape function.
Definition: Draw.cpp:237
void Run()
Create an animation.
Definition: DrOpenGL.cpp:15
void EffectCoarseGrain(int Grana)
Defocus the images in blocks.
Definition: DrOpenGL.cpp:94
void Dspecial(int k, int x, int y)
Boh.
void EffectMotion()
Shifting of pixels.
Definition: DrOpenGL.cpp:197
void keyboardDraw(unsigned char key)
Combines the key with the functions.
void DTimer(int v)
Not working.
Definition: Draw.cpp:144
void EffectMC()
Applies a random disposition of blocks.
Definition: DrOpenGL.cpp:68
int OpenImage(const char *FileName)
Open a image to be store in pixel.
Definition: DrawFile.cpp:180
void EffectFilter()
Applies a filter to pixel.
Definition: DrOpenGL.cpp:168
void Draw1(void)
A scene for debugging.
Definition: DrawScene.cpp:122
Reads and stores a data file to be elaborated via Matematica.
Definition: VarDatFile.h:26
void EffectIncrease()
Increase the resolution.
Definition: DrOpenGL.cpp:54
void ShowImage()
Displays the data stored in pixel.
Definition: DrawScene.cpp:211
void Window(int argc, char **argv)
Initial definition of the window.
Definition: Draw.cpp:108
int NLevel
Levels of the images data (usually 4=RGBA)
Definition: Draw.h:256
VarDatFile * v1
Class for the file handle.
void Dmouse(int button, int state, int x, int y)
To launch the menu.
Definition: DrawControl.cpp:86
void ScriviTutto(char *file, int LogLog, int NVisMin, int NVisMax)
Writes all the content in memory.
Definition: VarDatFile.cpp:766