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 path_renderer::end_path() { if(m_attr_storage.size() == 0) { throw exception("end_path : The path was not begun"); } path_attributes attr = cur_attr(); unsigned idx = m_attr_storage[m_attr_storage.size() - 1].index; attr.index = idx; m_attr_storage[m_attr_storage.size() - 1] = attr; pop_attr(); }
void end_path() { if(attributes_.size() == 0) { throw std::runtime_error("end_path : The path was not begun"); } path_attributes attr = cur_attr(); unsigned idx = attributes_[attributes_.size() - 1].index; attr.index = idx; attributes_[attributes_.size() - 1] = attr; pop_attr(); }
//------------------------------------------------------------------------ void path_renderer::end_path() { if(m_attr_storage.size() == 0) { gdx_log_error("gdx","end_path : The path was not begun"); } path_attributes& attr = cur_attr(); unsigned idx = m_attr_storage[m_attr_storage.size() - 1].index; attr.index = idx; m_attr_storage[m_attr_storage.size() - 1] = attr; if(attr.gradient) { if (m_attr_storage[m_attr_storage.size() - 1].gradient) { delete m_attr_storage[m_attr_storage.size() - 1].gradient; } m_attr_storage[m_attr_storage.size() - 1].gradient = attr.gradient->clone(); } pop_attr(); }
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(); }