本文整理汇总了C++中WPainterPath类的典型用法代码示例。如果您正苦于以下问题:C++ WPainterPath类的具体用法?C++ WPainterPath怎么用?C++ WPainterPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WPainterPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPath
void WMeasurePaintDevice::drawPath(const WPainterPath& path)
{
if (path.isEmpty())
return;
expandBounds(path.controlPointRect());
}
示例2: connectPath
void WPainterPath::connectPath(const WPainterPath& path)
{
if (currentPosition() != path.beginPosition())
lineTo(path.beginPosition());
addPath(path);
}
示例3: jsRef
WPainterPath WTransform::map(const WPainterPath& path) const
{
if (isIdentity()) return path;
WPainterPath result;
if (isJavaScriptBound() || path.isJavaScriptBound()) {
const WJavaScriptExposableObject *o = this;
if (!isJavaScriptBound()) o = &path;
result.assignBinding(*o,
WT_CLASS ".gfxUtils.transform_apply(" + jsRef() + ',' + path.jsRef() + ')');
}
const std::vector<WPainterPath::Segment> &sourceSegments = path.segments();
for (std::size_t i = 0; i < sourceSegments.size(); ++i) {
double tx, ty;
if (sourceSegments[i].type() == WPainterPath::Segment::ArcR ||
sourceSegments[i].type() == WPainterPath::Segment::ArcAngleSweep) {
result.segments_.push_back(sourceSegments[i]);
} else {
map(sourceSegments[i].x(), sourceSegments[i].y(), &tx, &ty);
result.segments_.push_back(WPainterPath::Segment(tx, ty, sourceSegments[i].type()));
}
}
return result;
}
示例4: addPath
void WPainterPath::addPath(const WPainterPath& path)
{
if (currentPosition() != path.beginPosition())
moveTo(path.beginPosition());
Utils::insert(segments_, path.segments_);
}
示例5: drawArc
void WMeasurePaintDevice::drawArc(const WRectF& rect, double startAngle,
double spanAngle)
{
WPainterPath p;
double r = std::max(rect.width(), rect.height()) / 2;
double cx = rect.center().x();
double cy = rect.center().y();
p.arcMoveTo(cx, cy, r, startAngle);
p.arcTo(cx, cy, r, startAngle, spanAngle);
expandBounds(p.controlPointRect());
}
示例6: drawPolyline
void WPainter::drawPolyline(const WT_ARRAY WPointF *points, int pointCount)
{
if (pointCount < 2)
return;
WPainterPath path;
path.moveTo(points[0]);
for (int i = 1; i < pointCount; ++i)
path.lineTo(points[i]);
WBrush oldBrush = WBrush(brush());
setBrush(WBrush());
drawPath(path);
setBrush(oldBrush);
}
示例7: drawPolygon
void WPainter::drawPolygon(const WT_ARRAY WPointF *points, int pointCount
/*, FillRule fillRule */)
{
if (pointCount < 2)
return;
WPainterPath path;
path.moveTo(points[0]);
for (int i = 1; i < pointCount; ++i)
path.lineTo(points[i]);
path.closeSubPath();
drawPath(path);
}
示例8: drawPath
void WPdfImage::drawPath(const WPainterPath& path)
{
if (path.isEmpty())
return;
drawPlainPath(path);
paintPath();
}
示例9: WTransform
void WPainter::drawChord(const WRectF& rectangle, int startAngle, int spanAngle)
{
WTransform oldTransform = WTransform(worldTransform());
translate(rectangle.center().x(), rectangle.center().y());
scale(1., rectangle.height() / rectangle.width());
double start = startAngle / 16.;
double span = spanAngle / 16.;
WPainterPath path;
path.arcMoveTo(0, 0, rectangle.width()/2., start);
path.arcTo(0, 0, rectangle.width()/2., start, span);
path.closeSubPath();
drawPath(path);
setWorldTransform(oldTransform);
}
示例10: drawPath
void WRasterImage::drawPath(const WPainterPath& path)
{
if (!path.isEmpty()) {
SkPath p;
impl_->drawPlainPath(p, path);
if (painter()->brush().style() != NoBrush) {
impl_->canvas_->drawPath(p, impl_->fillPaint_);
}
if (painter()->pen().style() != NoPen) {
impl_->canvas_->drawPath(p, impl_->strokePaint_);
}
}
}
示例11: switch
void WCartesianChart::renderLegendIcon(WPainter& painter,
const WPointF& pos,
const WDataSeries& series) const
{
switch (series.type()) {
case BarSeries: {
WPainterPath path;
path.moveTo(-6, 8);
path.lineTo(-6, -8);
path.lineTo(6, -8);
path.lineTo(6, 8);
painter.setPen(series.pen());
painter.setBrush(series.brush());
painter.translate(pos.x() + 7.5, pos.y());
painter.drawPath(path);
painter.translate(-(pos.x() + 7.5), -pos.y());
break;
}
case LineSeries:
case CurveSeries: {
painter.setPen(series.pen());
double offset = (series.pen().width() == 0 ? 0.5 : 0);
painter.drawLine(pos.x(), pos.y() + offset, pos.x() + 16, pos.y() + offset);
}
// no break;
case PointSeries: {
WPainterPath path;
drawMarker(series, path);
if (!path.isEmpty()) {
painter.translate(pos.x() + 8, pos.y());
painter.setPen(series.markerPen());
painter.setBrush(series.markerBrush());
painter.drawPath(path);
painter.translate(- (pos.x() + 8), -pos.y());
}
break;
}
}
}
示例12: drawText
void WPainter::drawText(const WRectF& rectangle,
WFlags<AlignmentFlag> alignmentFlags,
TextFlag textFlag,
const WString& text)
{
if (textFlag == TextSingleLine)
drawText(rectangle, alignmentFlags, text);
else {
if (!(alignmentFlags & AlignVerticalMask))
alignmentFlags |= AlignTop;
if (!(alignmentFlags & AlignHorizontalMask))
alignmentFlags |= AlignLeft;
if (device_->features() & WPaintDevice::CanWordWrap)
device_->drawText(rectangle.normalized(), alignmentFlags, textFlag, text);
else if (device_->features() & WPaintDevice::HasFontMetrics) {
#ifndef WT_TARGET_JAVA
MultiLineTextRenderer renderer(*this, rectangle);
AlignmentFlag horizontalAlign = alignmentFlags & AlignHorizontalMask;
AlignmentFlag verticalAlign = alignmentFlags & AlignVerticalMask;
/*
* Oh irony: after all these years of hating CSS, we now
* implemented an XHTML renderer for which we need to use the
* same silly workarounds to render the text with all possible
* alignment options
*/
WStringStream s;
s << "<table style=\"width:" << (int)rectangle.width() << "px;\""
"cellspacing=\"0\"><tr>"
"<td style=\"padding:0px;height:" << (int)rectangle.height() <<
"px;color:" << pen().color().cssText()
<< ";text-align:";
switch (horizontalAlign) {
case AlignLeft:
s << "left";
break;
case AlignRight:
s << "right";
break;
case AlignCenter:
s << "center";
break;
default:
break;
}
s << ";vertical-align:";
switch (verticalAlign) {
case AlignTop:
s << "top";
break;
case AlignBottom:
s << "bottom";
break;
case AlignMiddle:
s << "middle";
break;
default:
break;
}
s << ";" << font().cssText(false);
s << "\">"
<< WWebWidget::escapeText(text, true).toUTF8()
<< "</td></tr></table>";
save();
/*
* FIXME: what if there was already a clip path? We need to combine
* them ...
*/
WPainterPath p;
p.addRect(rectangle.x() + 1, rectangle.y() + 1, rectangle.width() - 2, rectangle.height() - 2);
setClipPath(p);
setClipping(true);
renderer.render(WString::fromUTF8(s.str()));
restore();
#endif // WT_TARGET_JAVA
} else
throw WException("WPainter::drawText(): device does not support "
"TextWordWrap or FontMetrics");
}
}
示例13: drawPath
void WMeasurePaintDevice::drawPath(const WPainterPath& path)
{
expandBounds(path.controlPointRect());
}
示例14: painter
//.........这里部分代码省略.........
brush.setStyle(SolidPattern);
brush.setColor(backcolor);
painter.setBrush(brush);
painter.drawRect(xMin +(-x_pos_shift+increase_width/2)/100*gWidth* widthFactor, yMax+(y_pos_shift-increase_height/2)/100*gHeight * widthFactor, gWidth* widthFactor*(100-increase_width)/100, gHeight * widthFactor*(-1+increase_height/100));
}
else{
painter.setWindow(xMin +x_pos_shift, yMax-y_pos_shift, 0, 0);
}
// for normal picture
//painter.setWindow(xMin , yMax, gWidth* widthFactor, -gHeight * widthFactor);
pwidth/=480;
pwidth*=4;
//if(iwidth<0.06)
// iwidth=0.06;
if(iwidth == 0.0015){
pen.setWidth(pwidth);
}
else
{
pen.setWidth(iwidth);
}
//std::cerr<<pwidth<<" "<<iwidth<<"\n";
pen.setColor(bordercolor);
brush.setStyle(SolidPattern);
brush.setColor(fillcolor);
font= new WFont();
font->setSize(WLength(labelpercentage*gWidth*widthFactor));
painter.setFont(*font);
painter.setPen(pen);
painter.setBrush(brush);
WPainterPath path;
poLayer->ResetReading();
OGRPoint *centroid = new OGRPoint();
char label[100];
while( (poFeature = poLayer->GetNextFeature()) != NULL )
{
centroid->empty();
label[0]=0;
if(labelindex>0)
{
OGRFeatureDefn *PointFDefn = poLayer->GetLayerDefn();
OGRFieldDefn *PointFieldDefn = PointFDefn->GetFieldDefn(labelindex-1);
if( PointFieldDefn->GetType() == OFTInteger )
sprintf(label, "%d", poFeature->GetFieldAsInteger(labelindex-1) );
else if( PointFieldDefn->GetType() == OFTReal )
sprintf(label, "%.3f", poFeature->GetFieldAsDouble(labelindex-1) );
else if( PointFieldDefn->GetType() == OFTString )
sprintf(label, "%s", poFeature->GetFieldAsString(labelindex-1) );
else
sprintf(label, "%s", poFeature->GetFieldAsString(labelindex-1) );
}
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
if( poGeometry != NULL && wkbFlatten(poGeometry->getGeometryType()) == wkbPoint )
{
OGRPoint *poPoint = (OGRPoint *) poGeometry;
double x = poPoint->getX();
double y = poPoint->getY();
//painter.drawPoint(x/scaleFactor,y/scaleFactor);
示例15: drawEmwebE
void ShapesWidget::drawEmwebE(WPainter& painter)
{
WPainterPath p;
/* Path copied from our SVG for half of the E */
p.moveTo(46.835084,58.783624);
p.cubicTo(45.700172,58.783624,35.350098,58.911502,24.656354,63.283309);
p.cubicTo(8.7595992,69.78907,0,82.38499,0,98.809238);
p.cubicTo(0,115.20152,08.7595992,127.82141,24.656354,134.31119);
p.cubicTo(35.350098,138.69099,45.700172,138.81088,46.835084,138.81088);
p.lineTo(94.509362,138.81088);
p.lineTo(94.509362,117.58323);
p.lineTo(46.835084,117.58323);
p.cubicTo(46.811106,117.58323,39.466151,117.47134,32.608727,114.53815);
p.cubicTo(25.095932,111.34122,21.747144,106.47389,21.747144,98.809238);
p.cubicTo(21.747144,91.120612,25.095932,86.269265,32.608727,83.064338);
p.cubicTo(39.466151,80.123159,46.811106,80.027251,46.89103,80.027251);
p.lineTo(94.509362,80.027251);
p.lineTo(94.509362,58.783624);
p.lineTo(46.835084,58.783624);
painter.drawPath(p);
painter.save();
painter.translate(0,-58.783624);
painter.drawPath(p);
painter.restore();
}