the_application(agg::pix_format_e format, bool flip_y) : agg::platform_support(format, flip_y), m_rotate(10, 3, "Rotate", !flip_y), m_even_odd(60, 3, "Even-Odd", !flip_y), m_draft(130, 3, "Draft", !flip_y), m_roundoff(175, 3, "Roundoff", !flip_y), m_angle_delta(10, 21, 250-10, 27, !flip_y), m_redraw_flag(true) { m_angle_delta.label("Step=%4.3f degree"); g_attr[g_npaths++] = path_attributes(g_path.start_new_path(), agg::rgba8(255, 255, 0), agg::rgba8(0, 0, 0), 1.0); g_path.concat_poly(g_poly_bulb, AGG_POLY_SIZE(g_poly_bulb), true); g_attr[g_npaths++] = path_attributes(g_path.start_new_path(), agg::rgba8(255, 255, 200), agg::rgba8(90, 0, 0), 0.7); g_path.concat_poly(g_poly_beam1, AGG_POLY_SIZE(g_poly_beam1), true); g_path.concat_poly(g_poly_beam2, AGG_POLY_SIZE(g_poly_beam2), true); g_path.concat_poly(g_poly_beam3, AGG_POLY_SIZE(g_poly_beam3), true); g_path.concat_poly(g_poly_beam4, AGG_POLY_SIZE(g_poly_beam4), true); g_attr[g_npaths++] = path_attributes(g_path.start_new_path(), agg::rgba8(0, 0, 0), agg::rgba8(0, 0, 0), 0.0); g_path.concat_poly(g_poly_fig1, AGG_POLY_SIZE(g_poly_fig1), true); g_path.concat_poly(g_poly_fig2, AGG_POLY_SIZE(g_poly_fig2), true); g_path.concat_poly(g_poly_fig3, AGG_POLY_SIZE(g_poly_fig3), true); g_path.concat_poly(g_poly_fig4, AGG_POLY_SIZE(g_poly_fig4), true); g_path.concat_poly(g_poly_fig5, AGG_POLY_SIZE(g_poly_fig5), true); g_path.concat_poly(g_poly_fig6, AGG_POLY_SIZE(g_poly_fig6), true); m_rotate.text_size(7); m_even_odd.text_size(7); m_draft.text_size(7); m_roundoff.text_size(7); add_ctrl(m_rotate); add_ctrl(m_even_odd); add_ctrl(m_draft); add_ctrl(m_roundoff); add_ctrl(m_angle_delta); m_angle_delta.value(0.01); }
void GraphAggRenderer::fillPolygon(Point *points, int pointCount, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.move_to(points[0].x(), points[0].y()); for (int i = 1; i < pointCount; ++i) { ps.line_to(points[i].x(), points[i].y()); } ps.end_poly(agg::path_flags_close); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void GraphAggRenderer::fillEllipse(Point *center, float width, float height, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::ellipse e1; e1.init(center->x(), center->y(), width, height, 100); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.concat_path(e1); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void GraphAggRenderer::fillRect(Point *ulCorner, Point *lrCorner, Color *color) { //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); ps.move_to(ulCorner->x(), ulCorner->y()); ps.line_to(lrCorner->x(), ulCorner->y()); ps.line_to(lrCorner->x(), lrCorner->y()); ps.line_to(ulCorner->x(), lrCorner->y()); ps.line_to(ulCorner->x(), ulCorner->y()); ps.end_poly(); // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = false; attr.fill_flag = true; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }
void begin_path() { unsigned idx = source_.start_new_path(); attributes_.add(path_attributes(cur_attr(), idx)); }
void push_attr() { attr_stack_.add(attr_stack_.size() ? attr_stack_[attr_stack_.size() - 1] : path_attributes()); }
//------------------------------------------------------------------------ void path_renderer::begin_path() { push_attr(); unsigned idx = m_storage.start_new_path(); m_attr_storage.add(path_attributes(cur_attr(), idx)); }
//------------------------------------------------------------------------ void path_renderer::push_attr() { m_attr_stack.add(m_attr_stack.size() ? m_attr_stack[m_attr_stack.size() - 1] : path_attributes()); }
void GraphAggRenderer::push_attr() { m_data->attr_stack.add(m_data->attr_stack.size() ? m_data->attr_stack[m_data->attr_stack.size() - 1] : path_attributes()); }
void GraphAggRenderer::drawString(const QString &text, Point *pos, int alignment, Color *color) { if (text.isEmpty()) return; //qDebug() << QString("%1").arg(__PRETTY_FUNCTION__); agg::path_storage &ps = m_data->ps; unsigned idx = ps.start_new_path(); // 绘制文本 font_manager_type *fman = get_fman(); double x = pos->x(); double y = pos->y(); wchar_t *buffer = new wchar_t[text.size() + 1]; text.toWCharArray(buffer); buffer[text.size()] = NULL; //qDebug() << text; const wchar_t *p = buffer;//L"this is a deom."; while (*p) { //qDebug() << QString(*p); const agg::glyph_cache* glyph = fman->glyph(*p); if (glyph) { //qDebug() << QString("good"); fman->init_embedded_adaptors(glyph, x, y); ps.concat_path(fman->path_adaptor()); /* cc_pa_type ccpath(fman->path_adaptor()); cs_cc_pa_type csccpath(ccpath); //ct_cs_cc_pa_type ctpath(csccpath, transform); //ras.add_path(ctpath); ps.concat_path(csccpath); */ x += glyph->advance_x; y += glyph->advance_y; //qDebug() << QString("%1,%2").arg(x).arg(y); } else { //qDebug() << QString("bad"); } ++p; } delete []buffer; // 保存属性 push_attr(); m_data->as.add(path_attributes(cur_attr(), idx)); //保存idx值 path_attributes attr = cur_attr(); attr.stroke_flag = true; attr.fill_flag = false; attr.fill_color = agg::rgba8(color->red(), color->green(), color->blue(), color->alpha()); attr.index = idx; m_data->as[m_data->as.size() -1] = attr; pop_attr(); updateBbox(); }