本文整理汇总了C++中GiGraphics类的典型用法代码示例。如果您正苦于以下问题:C++ GiGraphics类的具体用法?C++ GiGraphics怎么用?C++ GiGraphics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GiGraphics类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
void GiGraphics::copy(const GiGraphics& src)
{
if (this != &src) {
m_impl->bkcolor = src.m_impl->bkcolor;
m_impl->maxPenWidth = src.m_impl->maxPenWidth;
m_impl->drawColors = src.m_impl->drawColors;
m_impl->xform->copy(src.xf());
}
}
示例2: draw
bool MgShape::draw(int mode, GiGraphics& gs, const GiContext *ctx, int segment) const
{
GiContext tmpctx(*contextc());
if (shapec()->isKindOf(6)) { // MgComposite
tmpctx = ctx ? *ctx : GiContext(0, GiColor(), kGiLineNull);
}
else {
if (ctx) {
float addw = ctx->getLineWidth();
float width = tmpctx.getLineWidth();
width = -gs.calcPenWidth(width, tmpctx.isAutoScale()); // 像素宽度,负数
if (addw <= 0)
tmpctx.setLineWidth(width + addw, false); // 像素宽度加宽
else // 传入正数表示像素宽度
tmpctx.setLineWidth(-addw, ctx->isAutoScale()); // 换成新的像素宽度
}
if (ctx && ctx->getLineColor().a > 0) {
tmpctx.setLineColor(ctx->getLineColor());
}
if (ctx && !ctx->isNullLine()) {
tmpctx.setLineStyle(ctx->getLineStyle());
}
if (ctx && ctx->hasFillColor()) {
tmpctx.setFillColor(ctx->getFillColor());
}
}
bool ret = false;
Box2d rect(shapec()->getExtent() * gs.xf().modelToDisplay());
rect.inflate(1 + gs.calcPenWidth(tmpctx.getLineWidth(), tmpctx.isAutoScale()) / 2);
if (gs.beginShape(shapec()->getType(), getID(), rect.xmin,
rect.ymin, rect.width(), rect.height())) {
ret = shapec()->draw(mode, gs, tmpctx, segment);
gs.endShape(shapec()->getType(), getID(), rect.xmin, rect.ymin);
}
return ret;
}
示例3: draw
bool MgShape::draw(int mode, GiGraphics& gs, const GiContext *ctx, int segment) const
{
GiContext tmpctx(context());
if (shapec()->isKindOf(6)) { // MgComposite
tmpctx = ctx ? *ctx : GiContext(0, GiColor(), GiContext::kNullLine);
}
else if (ctx) {
float addw = ctx->getLineWidth();
if (addw < -0.1f) {
tmpctx.setExtraWidth(-addw);
} else if (addw > 0.1f) { // 传入正数表示像素宽度
tmpctx.setLineWidth(-addw, ctx->isAutoScale()); // 换成新的像素宽度
}
if (ctx->getLineColor().a > 0) {
tmpctx.setLineColor(ctx->getLineColor());
}
if (!ctx->isNullLine()) {
tmpctx.setLineStyle(ctx->getLineStyle());
}
if (ctx->hasFillColor()) {
tmpctx.setFillColor(ctx->getFillColor());
}
}
bool ret = false;
Box2d rect(shapec()->getExtent() * gs.xf().modelToDisplay());
rect.inflate(1 + gs.calcPenWidth(tmpctx.getLineWidth(), tmpctx.isAutoScale()) / 2);
if (gs.beginShape(shapec()->getType(), getID(),
(int)shapec()->getChangeCount(),
rect.xmin, rect.ymin, rect.width(), rect.height())) {
ret = drawShape(getParent(), *shapec(), mode, gs, tmpctx, segment);
gs.endShape(shapec()->getType(), getID(), rect.xmin, rect.ymin);
}
return ret;
}
示例4: _draw
bool MgGrid::_draw(int mode, GiGraphics& gs, const GiContext& ctx) const
{
Vector2d cell(m_cell / 2);
if (cell.x < _MGZERO || cell.y < _MGZERO) {
GiContext ctxedge(ctx);
ctxedge.setNoFillColor();
gs.drawRect(&ctxedge, getRect());
return __super::_draw(mode, gs, ctx);
}
int nx = (int)(getWidth() / cell.x + _MGZERO);
int ny = (int)(getHeight() / cell.y + _MGZERO);
Box2d rect(getPoint(3), getPoint(3)
+ Vector2d((float)(cell.x * nx), (float)(cell.y * ny)));
float w = gs.calcPenWidth(ctx.getLineWidth(), ctx.isAutoScale()) / -2.f;
GiContext ctxgrid(w, ctx.getLineColor());
bool antiAlias = gs.setAntiAliasMode(false);
int ret = gs.drawRect(&ctxgrid, rect) ? 1 : 0;
bool switchx = (nx >= 10 && cell.x < gs.xf().displayToModel(20, true));
bool switchy = (ny >= 10 && cell.y < gs.xf().displayToModel(20, true));
Point2d pts[2] = { rect.leftTop(), rect.leftBottom() };
for (int i = 1; i < nx; i++) {
pts[0].x += cell.x;
pts[1].x += cell.x;
ctxgrid.setLineWidth(!switchx || i%5 > 0 ? w/2 : w, false);
ctxgrid.setLineAlpha(-w < 0.9f && (!switchx || i%5 > 0) ?
ctx.getLineAlpha() / 2 : ctx.getLineAlpha());
ret += gs.drawLine(&ctxgrid, pts[0], pts[1]) ? 1 : 0;
}
pts[0] = rect.leftBottom();
pts[1] = rect.rightBottom();
for (int j = 1; j < ny; j++) {
pts[0].y += cell.y;
pts[1].y += cell.y;
ctxgrid.setLineWidth(!switchy || j%5 > 0 ? w/2 : w, false);
ctxgrid.setLineAlpha(-w < 0.9f && (!switchy || j%5 > 0) ?
ctx.getLineAlpha() / 2 : ctx.getLineAlpha());
ret += gs.drawLine(&ctxgrid, pts[0], pts[1]) ? 1 : 0;
}
gs.setAntiAliasMode(antiAlias);
return __super::_draw(mode, gs, ctx) || ret > 0;
}
示例5: draw
bool GiPath::draw(GiGraphics& gs, const GiContext* ctx, bool fill)
{
Matrix2d matD(gs.xf().modelToDisplay());
Point2d a, b, c;
if (m_data->points.empty() || m_data->points.size() != m_data->types.size())
return false;
gs.rawBeginPath();
for (size_t i = 0; i < m_data->points.size(); i++)
{
switch (m_data->types[i] & ~kGiCloseFigure)
{
case kGiMoveTo:
a = m_data->points[i] * matD;
gs.rawMoveTo(a.x, a.y);
break;
case kGiLineTo:
a = m_data->points[i] * matD;
gs.rawLineTo(a.x, a.y);
break;
case kGiBeziersTo:
if (i + 2 >= m_data->points.size())
return false;
a = m_data->points[i] * matD;
b = m_data->points[i+1] * matD;
c = m_data->points[i+2] * matD;
gs.rawBezierTo(a.x, a.y, b.x, b.y, c.x, c.y);
i += 2;
break;
default:
return false;
}
if (m_data->types[i] & kGiCloseFigure)
gs.rawClosePath();
}
gs.rawEndPath(ctx, fill);
return true;
}
示例6: draw
virtual void draw(GiGraphics& gs, const Matrix2d&) const {
gs.getCanvas()->drawPath(stroke, fill);
}
示例7: _draw
bool MgParallel::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const
{
bool ret = gs.drawPolygon(&ctx, 4, _points);
return __super::_draw(mode, gs, ctx, segment) || ret;
}
示例8: _draw
bool MgLine::_draw(GiGraphics& gs, const GiContext& ctx) const
{
bool ret = gs.drawLine(&ctx, _points[0], _points[1]);
return __super::_draw(gs, ctx) || ret;
}
示例9: _draw
bool MgRect::_draw(GiGraphics& gs, const GiContext& ctx) const
{
bool ret = gs.drawPolygon(&ctx, 4, _points);
return __super::_draw(gs, ctx) || ret;
}
示例10: draw
bool draw(const Point2d* pxs, int n) const
{
return pxs && n > 1 && m_gs->rawLines(m_pContext, pxs, n);
}