diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index 0f4018055f3179a3d3e1b2cae8d53aa52bb22313..7be2e20160c19c8323c0c57aae4ba3dd26d1cf39 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -89,7 +89,7 @@ void drawContext::load(std::string filename) OpenProject(filename); // reset openGL view - this->eventHandler(10); + eventHandler(10); // run onelab clients to populate the database onelab_cb("check"); @@ -101,36 +101,36 @@ void drawContext::load(std::string filename) void drawContext::eventHandler(int event, float x, float y) { - this->_current.set(this->_scale, this->_translate, this->_right, this->_left, - this->_bottom, this->_top, this->_width, this->_height, x, y); + _current.set(_scale, _translate, _right, _left, + _bottom, _top, _width, _height, x, y); double xx[3] = {1.,0.,0.}; double yy[3] = {0.,1.,0.}; double q[4]; switch(event){ case 0: // finger(s) press the screen // in this case x and y represent the start point - this->_start.set(this->_scale, this->_translate, this->_right, this->_left, - this->_bottom, this->_top, this->_width, this->_height, x, y); - this->_previous.set(this->_scale, this->_translate, this->_right, this->_left, - this->_bottom, this->_top, this->_width, this->_height, x, y); + _start.set(_scale, _translate, _right, _left, + _bottom, _top, _width, _height, x, y); + _previous.set(_scale, _translate, _right, _left, + _bottom, _top, _width, _height, x, y); break; case 1: // finger move (translate) // in this case x and y represent the current point - _translate[0] += (this->_current.wnr[0] - this->_previous.wnr[0]); - _translate[1] += (this->_current.wnr[1] - this->_previous.wnr[1]); + _translate[0] += (_current.wnr[0] - _previous.wnr[0]); + _translate[1] += (_current.wnr[1] - _previous.wnr[1]); _translate[2] = 0.; break; case 2: // fingers move (scale) // in this case we don't care about previous and current position, x // represent the scale - this->_scale[0] = this->_scale[1] = this->_scale[2] = x; - this->_start.recenter(this->_scale, this->_translate); + _scale[0] = _scale[1] = _scale[2] = x; + _start.recenter(_scale, _translate); break; case 3: // fingers move (rotate) - this->addQuaternion((2. * this->_previous.win[0] - this->_width) / this->_width, - (this->_height - 2. * this->_previous.win[1]) / this->_height, - (2. * this->_current.win[0] - this->_width) / this->_width, - (this->_height - 2. * this->_current.win[1]) / this->_height); + addQuaternion((2. * _previous.win[0] - _width) / _width, + (_height - 2. * _previous.win[1]) / _height, + (2. * _current.win[0] - _width) / _width, + (_height - 2. * _current.win[1]) / _height); break; case 4: // release the finger(s) // Do nothing ? @@ -154,23 +154,23 @@ void drawContext::eventHandler(int event, float x, float y) } break; } - this->_previous.set(this->_scale, this->_translate, this->_right, this->_left, - this->_bottom, this->_top, this->_width, this->_height, x, y); + _previous.set(_scale, _translate, _right, _left, + _bottom, _top, _width, _height, x, y); } void drawContext::setQuaternion(double q0, double q1, double q2, double q3) { - this->_quaternion[0] = q0; - this->_quaternion[1] = q1; - this->_quaternion[2] = q2; - this->_quaternion[3] = q3; + _quaternion[0] = q0; + _quaternion[1] = q1; + _quaternion[2] = q2; + _quaternion[3] = q3; } void drawContext::addQuaternion(double p1x, double p1y, double p2x, double p2y) { double quat[4]; trackball(quat, p1x, p1y, p2x, p2y); - add_quats(quat, this->_quaternion, this->_quaternion); + add_quats(quat, _quaternion, _quaternion); } void drawContext::buildRotationMatrix() @@ -183,8 +183,8 @@ void drawContext::buildRotationMatrix() void drawContext::OrthofFromGModel() { SBoundingBox3d bb = GModel::current()->bounds(); - double ratio = (double)(this->_width ? this->_width : 1.) / - (double)(this->_height ? this->_height : 1.); + double ratio = (double)(_width ? _width : 1.) / + (double)(_height ? _height : 1.); double bbRation = (bb.max().x() - bb.min().x()) / (bb.max().y() - bb.min().y()); double xmin = -ratio, xmax = ratio, ymin = -1., ymax = 1.; if(bbRation < 1) { @@ -214,23 +214,23 @@ void drawContext::OrthofFromGModel() glGetIntegerv(GL_MATRIX_MODE, &matrixMode); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - this->_left = (xmin != 0 || xmax != 0)? xmin : -ratio; - this->_right = (xmin != 0 || xmax != 0)? xmax : ratio; - this->_top = (xmin != 0 || xmax != 0)? ymax : 1.0; - this->_bottom = (xmin != 0 || xmax != 0)? ymin : -1.0; - this->_far = -clip; - glOrthof(this->_left, this->_right, this->_bottom, this->_top, -clip, clip); + _left = (xmin != 0 || xmax != 0)? xmin : -ratio; + _right = (xmin != 0 || xmax != 0)? xmax : ratio; + _top = (xmin != 0 || xmax != 0)? ymax : 1.0; + _bottom = (xmin != 0 || xmax != 0)? ymin : -1.0; + _far = -clip; + glOrthof(_left, _right, _bottom, _top, -clip, clip); glMatrixMode(matrixMode); } void drawContext::initView(int w, int h) { - this->_height = h; - this->_width = w; + _height = h; + _width = w; glViewport(0, 0, w, h); - this->OrthofFromGModel(); + OrthofFromGModel(); glClearColor(.83,.85,.98,1.); glDepthMask(GL_TRUE); @@ -351,7 +351,7 @@ void drawContext::drawVectorArray(PViewOptions *opt, VertexArray *va) GLubyte *color = (GLubyte *)va->getColorArray(4 * i); glColor4ub(*(color), *(color+1), *(color+2), *(color+3)); if(fabs(dx) > 1. || fabs(dy) > 1. || fabs(dz) > 1.){ - double d = (this->_right - this->_left) / this->_width / _scale[0]; + double d = (_right - _left) / _width / _scale[0]; dx *= d; dy *= d; dz *= d; double x = s[0], y = s[1], z = s[2]; drawVector(x,y,z,dx,dy,dz); @@ -390,12 +390,12 @@ void drawContext::drawScale() if(!opt->visible) continue; PViewData *data = p->getData(); - double width = (this->_right -this->_left) / 2.; - double height = (this->_top - this->_bottom) / 10.; + double width = (_right -_left) / 2.; + double height = (_top - _bottom) / 10.; double dh = height / 5; double box = width / (opt->nbIso ? opt->nbIso : 1); - double xmin = this->_left + (this->_right - this->_left -width)/2.; - double ymin = this->_bottom + 0.8 * height + height * nPview; + double xmin = _left + (_right - _left -width)/2.; + double ymin = _bottom + 0.8 * height + height * nPview; std::vector<GLfloat> vertex(opt->nbIso*3*4); std::vector<GLubyte> color(opt->nbIso*4*4); @@ -575,7 +575,7 @@ void drawContext::drawAxes(float x0, float y0, float z0, float h) void drawContext::drawView() { - this->OrthofFromGModel(); + OrthofFromGModel(); glMatrixMode(GL_MODELVIEW); // fill the background @@ -584,10 +584,10 @@ void drawContext::drawView() glPushMatrix(); glLoadIdentity(); const GLfloat squareVertices[] = { - (GLfloat)this->_top, (GLfloat)this->_left, 2*this->_far, - (GLfloat)this->_top, (GLfloat)this->_right, 2*this->_far, - (GLfloat)this->_bottom, (GLfloat)this->_left, 2*this->_far, - (GLfloat)this->_bottom, (GLfloat)this->_right, 2*this->_far, + (GLfloat)_top, (GLfloat)_left, 2*_far, + (GLfloat)_top, (GLfloat)_right, 2*_far, + (GLfloat)_bottom, (GLfloat)_left, 2*_far, + (GLfloat)_bottom, (GLfloat)_right, 2*_far, }; const GLubyte squareColors[] = { 255, 255, 255, 255, @@ -609,23 +609,23 @@ void drawContext::drawView() glLoadIdentity(); glScalef(_scale[0], _scale[1], _scale[2]); glTranslatef(_translate[0], _translate[1], _translate[2]); - this->buildRotationMatrix(); + buildRotationMatrix(); glMultMatrixf(_rotatef); checkGlError("Initialize position"); // glEnable(GL_DEPTH_TEST); - this->drawMesh(); + drawMesh(); checkGlError("Draw mesh"); - this->drawGeom(); + drawGeom(); checkGlError("Draw geometry"); - this->drawPost(); + drawPost(); checkGlError("Draw post-pro"); glDisable(GL_DEPTH_TEST); - this->drawScale(); + drawScale(); checkGlError("Draw scales"); - this->drawAxes(this->_right - (this->_top - this->_bottom)/15.0, - this->_bottom + (this->_top - this->_bottom)/15.0, - 0, (this->_top - this->_bottom)/25.); + drawAxes(_right - (_top - _bottom)/15.0, + _bottom + (_top - _bottom)/15.0, + 0, (_top - _bottom)/25.); checkGlError("Draw axes"); } @@ -787,5 +787,3 @@ int animation_prev() } return ret; } - -// vim:set ts=2: diff --git a/contrib/mobile/drawContext.h b/contrib/mobile/drawContext.h index 504bf4b97149c24cfc39dcf5c1ed3e589caa435a..0f498206078cdfc0fd9266357d9b915d8ec0d30e 100644 --- a/contrib/mobile/drawContext.h +++ b/contrib/mobile/drawContext.h @@ -37,8 +37,8 @@ private: int _width, _height; // size of OpenGL context in pixel float _left, _right, _top, _bottom, _far; // value of "border" float _fontFactor; - bool _gradiant, // show the background gradiant - _fillMesh; // fill the Mesh + bool _gradiant; // show the background gradiant + bool _fillMesh; // fill the Mesh void OrthofFromGModel(void); void drawPView(PView *p); @@ -51,10 +51,10 @@ public: void setQuaternion(double q0, double q1, double q2, double q3); void addQuaternion(double p1x, double p1y, double p2x, double p2y); void buildRotationMatrix(); - void setTranslate(int i, float t) {if(i>=0 && i<3) this->_translate[i] = t;} - float getTranslate(int i) {if(i>=0 && i<3) return this->_translate[i]; return 0;} - void setScale(int i, float s) {if(i>=0 && i<3) this->_scale[i] = s;} - float getScale(int i) {if(i>=0 && i<3) return this->_scale[i]; return 0;} + void setTranslate(int i, float t) {if(i>=0 && i<3) _translate[i] = t;} + float getTranslate(int i) {if(i>=0 && i<3) return _translate[i]; return 0;} + void setScale(int i, float s) {if(i>=0 && i<3) _scale[i] = s;} + float getScale(int i) {if(i>=0 && i<3) return _scale[i]; return 0;} void initView(int w, int h); void drawView(); void drawAxes(float x0=0., float y0=0., float z0=0., float h=0.5); diff --git a/contrib/mobile/drawString.cpp b/contrib/mobile/drawString.cpp index da303974f8e4021b754a543a0b8d1a702a410adf..d9b6baad9b166eea78c9ef2a8843ab76418e5a14 100644 --- a/contrib/mobile/drawString.cpp +++ b/contrib/mobile/drawString.cpp @@ -18,17 +18,17 @@ drawString::drawString(std::string text, int size, float color[4]) { _size = size; if(color == NULL) - this->setColor(0.0f, 0.0f, 0.0f, 1.0f); + setColor(0.0f, 0.0f, 0.0f, 1.0f); else - this->setColor(color); - this->setText(text); + setColor(color); + setText(text); } void drawString::setText(std::string text) { - this->_text = text; - getBitmapFromString(this->_text.c_str(), _size, &this->_map, - &this->_height, &this->_width, &this->_realWidth); + _text = text; + getBitmapFromString(_text.c_str(), _size, &_map, + &_height, &_width, &_realWidth); } void drawString::setColor(float color[4]) diff --git a/contrib/mobile/drawString.h b/contrib/mobile/drawString.h index 7e144440113816cfdfe2072f4ccf5d9cd3cbbe08..715cd5a0ac696f472948de423ffad0ce1f5b8105 100644 --- a/contrib/mobile/drawString.h +++ b/contrib/mobile/drawString.h @@ -15,18 +15,18 @@ class drawString { private: - std::string _text; // Text to draw - float _color[4]; // Text color - int _size; // Text size in px - int _height, _width, _realWidth; // Size of the texture in px - unsigned char *_map; + std::string _text; // Text to draw + float _color[4]; // Text color + int _size; // Text size in px + int _height, _width, _realWidth; // Size of the texture in px + unsigned char *_map; public: - drawString(std::string text, int size=12, float *color=NULL); - ~drawString(){if(_map)free(_map);} + drawString(std::string text, int size=12, float *color=NULL); + ~drawString(){if(_map)free(_map);} - void setText(std::string text); - void setColor(float *color); - void setColor(float r, float g, float b, float a); - void draw(float x, float y, float z, float w, float h, bool center=true); + void setText(std::string text); + void setColor(float *color); + void setColor(float r, float g, float b, float a); + void draw(float x, float y, float z, float w, float h, bool center=true); };