Пример #1
0
/*--------------------------------------------------------------
 Routine : draw_symbol
 Purpose : Draws the symbol.
---------------------------------------------------------------*/
void
draw_symbol(Canvas canvas, CanvasCoord symbol_centre, SYMBOL *symbol)
{
    SEGMENT     *seg_list;
    ARC         *arc;
    RECTANGLE   *rect;
    POLYLINE    *poly;
    LINE        *line;

    ASSERT( symbol != NULL );

    seg_list = symbol->segment_list;
    while (seg_list != NULL) {
        /* Identify and draw the segment type */
        switch (seg_list->type) {
        case CLEAR_ARC_SEG :
            arc =  (ARC *)(seg_list->seg);
            clear_arc(canvas, arc, symbol_centre);
            break;
        case FILL_ARC_SEG :
            arc =  (ARC *)(seg_list->seg);
            fill_arc(canvas, arc, symbol_centre, symbol->type);
            break;
        case ARC_SEG :
            arc =  (ARC *)(seg_list->seg);
            draw_arc(canvas, arc, symbol_centre);
            break;
        case RECTANGLE_SEG :
            rect =  (RECTANGLE *)(seg_list->seg);
            draw_rectangle(canvas, rect, symbol_centre);
            break;
        case FILL_RECTANGLE_SEG :
            rect =  (RECTANGLE *)(seg_list->seg);
            fill_rectangle(canvas, rect, symbol_centre, symbol->type);
            break;
		case FILL_POLYLINE_SEG :
            poly = (POLYLINE *)(seg_list->seg);
            fill_polyline(canvas, poly, symbol_centre, symbol->type);
            break;
		case POLYLINE_SEG :
            poly =  (POLYLINE *)(seg_list->seg);
            draw_polyline(canvas, poly, symbol_centre);
            break;
        case LINE_SEG :
            line =  (LINE *)(seg_list->seg);
            draw_line(canvas, line, symbol_centre);
            break;
        default:
            printf("\n*** draw_symbol : Invalid segment type ***\n\n");
            exit(1);
        }
        seg_list = seg_list->next;
    }
}
Пример #2
0
void ArcballHelper::fill_half_arc(
    Arcball const & arcball,
    std::vector<glm::vec3> & positions,
    glm::vec3 axis)
{
    // create a perpendicular vector that is a "mirror" over another axis
    glm::vec3 mirror_point;
    if (axis.z != 1.0f) {
        mirror_point.x = axis.y;
        mirror_point.y = -axis.x;
        mirror_point = glm::normalize(mirror_point);
    } else {
        mirror_point.x = 0.0f;
        mirror_point.y = 1.0f;
    }

    auto mid_point = glm::cross(mirror_point, axis);

    // "combine" the two half arcs into one arc
    fill_arc(arcball, positions, mirror_point, mid_point);
    fill_arc(arcball, positions, mid_point, -mirror_point);
}
Пример #3
0
void ArcballHelper::update_drag(Arcball const & arcball)
{
    std::vector<glm::vec3> positions;

    if (arcball.dragging) {
        auto color = glm::vec3(1.0f, 1.0f, 0.0f);
        // set appropiate drag arc color depending on the constraint axis
        if (arcball.constraint.current != AxisSet::NONE) {
            color = axis_index_color(arcball.constraint.nearest);
        }
        auto & material = drag_node->get_material();
        material.get_uniform("diffuse") = color;

        fill_arc(arcball, positions, arcball.drag.from, arcball.drag.to);
    }

    auto & mesh = drag_node->get_mesh();
    mesh.set_positions(positions);
}
Пример #4
0
static void 
fill_ellipse (DiaRenderer *object, Point *center,
              real width, real height, Color *color)
{
  fill_arc(object, center, width, height, 0.0, 360.0, color); 
}