/*! Draw a subset of the samples \param painter Painter \param xMap Maps x-values into pixel coordinates. \param yMap Maps y-values into pixel coordinates. \param canvasRect Contents rect of the canvas \param from Index of the first sample to be painted \param to Index of the last sample to be painted. If to < 0 the series will be painted to its last sample. \sa drawTube(), drawSymbols() */ void QwtPlotIntervalCurve::drawSeries( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const { if ( to < 0 ) to = dataSize() - 1; if ( from < 0 ) from = 0; if ( from > to ) return; switch ( d_data->style ) { case Tube: drawTube( painter, xMap, yMap, canvasRect, from, to ); break; case NoCurve: default: break; } if ( d_data->symbol && ( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) ) { drawSymbols( painter, *d_data->symbol, xMap, yMap, canvasRect, from, to ); } }
void InstrumentRenderer::draw(const std::vector<bool> &visibleComps, bool showGuides, bool picking) { const auto &compInfo = m_actor.componentInfo(); std::vector<bool> visited(compInfo.size(), false); for (size_t i = compInfo.root(); i != std::numeric_limits<size_t>::max(); --i) { auto type = compInfo.componentType(i); if (type == ComponentType::Infinite) continue; if (type == ComponentType::Grid) { if (visibleComps[i]) { drawGridBank(i, picking); updateVisited(compInfo, i, visited); } continue; } if (type == ComponentType::Rectangular) { if (visibleComps[i]) { drawRectangularBank(i, picking); updateVisited(compInfo, i, visited); } continue; } if (type == ComponentType::OutlineComposite) { if (visibleComps[i]) { drawTube(i, picking); updateVisited(compInfo, i, visited); } continue; } if (type == ComponentType::Structured) { if (visibleComps[i]) { drawStructuredBank(i, picking); updateVisited(compInfo, i, visited); } continue; } if (!compInfo.isDetector(i) && !showGuides) { visited[i] = true; continue; } if (compInfo.hasValidShape(i) && visibleComps[i] && !visited[i]) { visited[i] = true; drawSingleDetector(i, picking); } } }
void HumanBodyModelRenderer::generateDisplayLists() { if( _m ) _dplistSize = _m->boneCount() + 1; else return; if( !_dplist ) _dplist = new GLuint[_dplistSize]; else glDeleteLists(_dplist[0], _dplistSize); _dplist[0] = glGenLists(_dplistSize); for(int i=0;i<_dplistSize;i++) { _dplist[i] = _dplist[0] + i; BoneSegment* bone = _m->_boneSegments[i]; double endX, endY, endZ; endX = bone->_length * bone->_dir.x(); endY = bone->_length * bone->_dir.y(); endZ = bone->_length * bone->_dir.z(); glNewList(_dplist[i], GL_COMPILE); glPushMatrix(); // draw the joint glColor4f(1, 0, 0, 1); GLfloat joint_diffuse[] = {1, 0.75, 0.65, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, joint_diffuse); double radius; if(bone->_length >= 1.0) radius = sqrt(bone->_length); else radius = bone->_length; glPushMatrix(); glTranslatef(endX, endY, endZ); glutSolidSphere(0.5 * radius, 20, 20); glPopMatrix(); // draw the bone glColor4f(0.65, 0.75, 1.0, 1.0); GLfloat bone_diffuse[] = {0.7, 1.0, 0.85, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, bone_diffuse); drawTube(0, 0, 0, endX, endY, endZ, 0.25 * radius, 2, 16); glPopMatrix(); glEndList(); } }
void display( ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* Fixed light Pos */ GLfloat position[] = {15*sin(0.5*seconds), 0 , 15*cos(0.5*seconds)}; glLightfv(GL_LIGHT0, GL_POSITION, position); /* Set up gluLookAt */ double eyex, eyey, eyez; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); sphereToCart(eyeTheta, eyePhi, eyeRho, &eyex, &eyey, &eyez); gluLookAt(eyex, eyey, eyez, 0,0,0, 0,0,1); drawTube(); glutSwapBuffers(); }
void HumanBodyModelRenderer::drawBone(BoneSegment *bone) { // draw the bone, then draw all its children recursively // ignore the root node glPushMatrix(); if( bone->_id > 0 ) { glMultMatrixd(bone->_rot_parent_to_self.rawData()); if( 0 ) drawAxis(); double endX, endY, endZ; endX = bone->_length * bone->_dir.x(); endY = bone->_length * bone->_dir.y(); endZ = bone->_length * bone->_dir.z(); glPushMatrix(); if( _frameIdx >= 0) { FrameParameters& pose = _m->_frames[_frameIdx]; // apply the root pose BoneSegmentParameter& boneParam = pose._boneParams[bone->_id]; if( bone->_dof != boneParam._numParams ) throw "amc file contains error! cannot display animation!"; for(int i=bone->_dof - 1;i>=0;i--) { string dofname = bone->_dofName[i]; #if 1 if(dofname == "rx") glRotatef(boneParam._params[i], 1., 0., 0.); if(dofname == "ry") glRotatef(boneParam._params[i], 0., 1, 0.); if(dofname == "rz") glRotatef(boneParam._params[i], 0., 0., 1.); #else // for testing purpose if(dofname == "rx") glMultMatrixd(makeXRotationMatrix_deg(boneParam._params[i]).transposed().rawData()); if(dofname == "ry") glMultMatrixd(makeYRotationMatrix_deg(boneParam._params[i]).transposed().rawData()); if(dofname == "rz") glMultMatrixd(makeZRotationMatrix_deg(boneParam._params[i]).transposed().rawData()); #endif } } #if 0 glPushMatrix(); // draw the joint glColor4f(1, 0, 0, 1); GLfloat joint_diffuse[] = {1, 0.75, 0.65, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, joint_diffuse); double radius = powf(bone->_length / 2.0, 0.25); glutSolidSphere(radius, 20, 20); // draw the bone glColor4f(0.65, 0.75, 1.0, 1.0); GLfloat bone_diffuse[] = {0.7, 1.0, 0.85, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, bone_diffuse); drawTube(0, 0, 0, endX, endY, endZ, 0.75 * radius, 40, 40); glPopMatrix(); #else glCallList( _dplist[bone->_id] ); #endif glTranslatef(endX, endY, endZ); } for(int i=0;i<bone->_numChildren;i++) { BoneSegment* child = _m->_boneSegments[bone->_children[i]]; drawBone( child ); } glPopMatrix(); glPopMatrix(); }