void GLWidget::paintGL() { int i; draw_axes(); draw_disk(); int nticks = 10; renderText(0.0, 0.0, 0.0, "0"); qglColor( Qt::lightGray ); for (i=0; i<nticks; i++) { if (i*10.0 < maxb){ renderText(-i*10.0*xs, 0.0, 0.0, QString("%1").arg(i*10.0)); renderText(i*10.0*xs, 0.0, 0.0, QString("%1").arg(i*10.0)); renderText(0.0, -i*10.0*ys, 0.0, QString("%1").arg(i*10.0)); renderText(0.0, i*10.0*ys, 0.0, QString("%1").arg(i*10.0)); renderText(0.0, 0.0, -i*10.0*zs, QString("%1").arg(i*10.0)); renderText(0.0, 0.0, i*10.0*zs, QString("%1").arg(i*10.0)); } } if (ex.size()>0 && ey.size()>0 && ez.size()>0 && ei.size()>0){ glBegin(GL_POINTS); qglColor( blue->toRgb() ); for (i=0; i<ei.size(); i++){ if (ei[i]*15+50 < 300) { qglColor( blue->darker(50+ei[i]*15)); if (ei[i] == ci || ci == 0) glVertex3f(ex[i]*xs, ey[i]*ys, ez[i]*zs); } } glEnd(); } }
void SimpleBody::render_selection() { #ifdef WANT_GLUT flo x, y; glScalef(radius, radius, radius); if (parent->parent->volume->dimensions()==3) { glPushMatrix(); glRotatef(90.0, 1.0, 0.0, 0.0); draw_disk(1); glPopMatrix(); glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); draw_disk(1); glPopMatrix(); } draw_disk(1); #endif // WANT_GLUT }
static void draw (GeometryTester *super) { PointLineClosestPointTester *self = (PointLineClosestPointTester*) super; glColor3f (1, 1, 0); glBegin (GL_LINES); glVertex2f (self->seg1.x, self->seg1.y); glVertex2f (self->seg2.x, self->seg2.y); glEnd (); // glPushMatrix (); // glTranslatef (self->seg1.x, self->seg1.y, 0); // gluDisk (self->quadric, 0, 5, 50, 1); // glPopMatrix (); // glPushMatrix (); // glTranslatef (self->seg2.x, self->seg2.y, 0); // gluDisk (self->quadric, 0, 5, 50, 1); // glPopMatrix (); glColor3f (0, 0.5, 1); draw_disk (self, self->pt.x, self->pt.y, 5); glColor3f (1, 0, 1); point2d_t seg_closest_point; double u = 0; geom_point_line_seg_closest_point_2d (&self->pt, &self->seg1, &self->seg2, &seg_closest_point, &u); draw_disk (self, seg_closest_point.x, seg_closest_point.y, 5); vec3d_t a = { self->seg1.x, self->seg1.y, 1 }; vec3d_t b = { self->seg2.x, self->seg2.y, 1 }; vec3d_t c; geom_vec_cross_3d (&a, &b, &c); geom_vec_normalize_3d (&c); vec3d_t p = { self->pt.x, self->pt.y, 1 }; double d = geom_vec_vec_dot_3d (&c, &p); printf ("%f %f %f\n", d, d*d, geom_point_point_distance_2d (&self->pt, &seg_closest_point)); glColor3f (0, 1, 0); point2d_t line_closest_point; if (0 != geom_point_line_closest_point_2d (&self->pt, &self->seg1, &self->seg2, &line_closest_point, NULL)) return; draw_disk (self, line_closest_point.x, line_closest_point.y, 3); }
static void draw (GeometryTester *super) { PointPolylineClosestPointTester *self = (PointPolylineClosestPointTester*) super; glColor3f (1, 1, 0); pointlist2d_t *poly1 = pointlist2d_new_from_gqueue (self->poly1); if (!poly1) return; glColor3f (0, 1, 0); draw_disk (self, self->last_mouse_pt.x, self->last_mouse_pt.y, 5); #if 1 if (poly1->npoints > 1) { int vals[4]; glGetIntegerv (GL_VIEWPORT, vals); glBegin (GL_POINTS); glColor3f (1, 1, 1); for (int i = 0; i < vals[2]; i++) { int j; for (j = 0; j < vals[3]; j++) { point2d_t pt = { .x = i, .y = j }; int line_ind; double line_alpha = 0; geom_point_polyline_closest_point_2d (&pt, poly1, &line_ind, &line_alpha, NULL); color_t c = COLORS[line_ind % NUM_COLORS]; // if (line_ind == 0 && line_alpha <= 0) { // c.r = c.g = c.b = 0; // } else if (line_ind == poly1->npoints - 2 && line_alpha >= 1) { // c.r = c.g = c.b = 0; // } glColor3f (0.3 * c.r, 0.3 * c.g, 0.3 * c.b); glVertex2d (pt.x, pt.y); } } glEnd (); }