void CatmulRom::draw() { double scale = 1; double scale2 = 1; // double scale2 = 1 * cos(90) + 2; if (size() < 2) return; int i, n; QVector3D p0, p1, prev; QMatrix3x3 cur_frame, prev_frame; // Draw curve if (size() >= 4 && m_draw_curve) { p0 = points[1]; prev = p0; prev_frame = calculate_frame(p0, prev); for (n = 1; n < size() -2 ; n++) { for (i = 0; i < SAMPLES; i++) { scale2 = cos(((double)360 / size() -2 ) * n + i) + 2; glColor3f(m_curve_color.x(), m_curve_color.y(), m_curve_color.z()); p1 = point_on_curve(points[n - 1], points[n], points[n + 1], points[n + 2], (1.0f/SAMPLES) * i); cur_frame = calculate_frame(p0, p1); if (m_shape.size() > 2 && m_draw_solid) draw_cross_section(p0, cur_frame, prev, prev_frame, scale, scale2); else DrawLib::drawLine(p0, p1); m_cube.draw(); prev = p0; p0 = p1; prev_frame = cur_frame; scale = scale2; } } } }
//============================================================================= void slit_info::process_broam(const char *temp, int f) { if (f & BBP_BROAM_HANDLED) { if (f & BBP_BROAM_METRICS) calculate_frame(); show_menu(false); return; } if (BBP_broam_int(this, temp, "baseWidth", &baseWidth)) { calculate_frame(); show_menu(false); return; } if (BBP_broam_int(this, temp, "alignment", &alignment)) { calculate_frame(); show_menu(false); return; } if (BBP_broam_int(this, temp, "order", &order)) { calculate_frame(); show_menu(false); return; } if (BBP_broam_bool(this, temp, "setMargin", &setMargin)) { pos_changed(); show_menu(false); return; } }
void Frame::draw( cairo_t *cairo ) { #ifdef DEBUG_FRAME std::cout << "\nFRAME::DRAW()\n\n"; std::cout << "width = " << _width << "\n"; std::cout << "height = " << _height << "\n"; #endif // Build colormap legend build_colormap_legend(); // Draw background cairo_rectangle( cairo, _offx, _offy, _width, _height ); cairo_set_source_rgb( cairo, _bg[0], _bg[1], _bg[2] ); cairo_fill( cairo ); // Get drawable bounding boxes and set ruler ranges calculate_autoranging(); // Calculate frame location and size calculate_frame( cairo ); // Draw contents with clipping on set_frame_clipping( cairo ); for( size_t a = 0; a < _dobj.size(); a++ ) { cairo_save( cairo ); PlotAxis xaxis = _dobj[a]._xaxis; PlotAxis yaxis = _dobj[a]._yaxis; double range[4]; _ruler[xaxis].get_ranges( range[0], range[2] ); _ruler[yaxis].get_ranges( range[1], range[3] ); Coordmapper cm( _cm[xaxis], _cm[yaxis] ); _dobj[a]._graph->plot( cairo, &cm, range ); cairo_restore( cairo ); } unset_frame_clipping( cairo ); draw_legend( cairo ); draw_colormap_legend( cairo ); // Draw frame (on top of user drawn image) draw_frame( cairo ); }
void CatmulRom::timestep() { QVector3D p0, p1; if (size() < 4) return; if (m_animation_step == 0 && m_animation_vertex == 1) { p0 = points[m_animation_vertex]; } else p0 = m_anim_p0; if (m_animation_vertex >= size() - 2) { m_animation_vertex = 1; m_animation_step = 0; p0 = points[m_animation_vertex]; } else { if (m_animation_step >= SAMPLES) { m_animation_step = 0; m_animation_vertex++; } else { m_animation_step++; } } p1 = point_on_curve(points[m_animation_vertex - 1], points[m_animation_vertex ], points[m_animation_vertex + 1], points[m_animation_vertex + 2], (1.0f/SAMPLES) * m_animation_step); m_cube.set_orientation(calculate_frame(p0, p1)); m_cube.set_position(p1); p0 = p1; m_anim_p0 = p0; }