本文整理汇总了C++中QPainterPath::toReversed方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::toReversed方法的具体用法?C++ QPainterPath::toReversed怎么用?C++ QPainterPath::toReversed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::toReversed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawFace
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
{
std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
QPainterPath facePath;
for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
QPainterPath wirePath;
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
//Save the start Position
QPainterPath edgePath = drawPainterPath(*edge);
// If the current end point matches the shape end point the new edge path needs reversing
QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) { //magic tolerance
edgePath = edgePath.toReversed();
}
wirePath.connectPath(edgePath);
}
//dumpPath("wirePath:",wirePath);
facePath.addPath(wirePath);
}
facePath.setFillRule(Qt::OddEvenFill);
QGIFace* gFace = new QGIFace(idx);
addToGroup(gFace);
gFace->setPos(0.0,0.0);
gFace->setPath(facePath);
//debug a path
//std::stringstream faceId;
//faceId << "facePath " << idx;
//dumpPath(faceId.str().c_str(),facePath);
return gFace;
}
示例2: updatePath
void PolygonObject::updatePath(const QPainterPath& p)
{
normalPath = p;
QPainterPath closedPath = normalPath;
closedPath.closeSubpath();
QPainterPath reversePath = closedPath.toReversed();
reversePath.connectPath(closedPath);
setObjectPath(reversePath);
}
示例3: checkForUpdate
void NWaveformSlider::checkForUpdate()
{
if (!m_waveBuilder)
return;
bool needsUpdate = FALSE;
if (m_oldValue != value() || m_oldSize != size())
needsUpdate = TRUE;
float pos;
int index;
m_waveBuilder->positionAndIndex(pos, index);
if (!(pos < 0 || index < 0) &&
!(m_oldBuildPos == pos &&
m_oldIndex == index &&
m_waveImage.size() == size()))
{
m_oldBuildPos = pos;
m_oldIndex = index;
if (m_waveImage.size() != size())
m_waveImage = QImage(size(), QImage::Format_ARGB32_Premultiplied);
QPainter painter(&m_waveImage);
m_waveImage.fill(0);
painter.setRenderHint(QPainter::Antialiasing);
painter.setBrush(wave_bg);
QPen wavePen;
wavePen.setWidth(0);
wavePen.setColor(wave_border);
painter.setPen(wavePen);
painter.translate(1, 1);
painter.scale((qreal)(width() - 1) / m_oldIndex * m_oldBuildPos, (height() - 2) / 2);
painter.translate(0, 1);
QPainterPath pathPos;
QPainterPath pathNeg;
NWaveformPeaks *peaks = m_waveBuilder->peaks();
for (int i = 0; i < m_oldIndex; ++i) {
pathPos.lineTo(i, peaks->positive(i));
pathNeg.lineTo(i, peaks->negative(i));
}
QPainterPath fullPath(pathNeg);
fullPath.connectPath(pathPos.toReversed());
fullPath.closeSubpath();
painter.drawPath(fullPath);
needsUpdate = TRUE;
}
if (needsUpdate)
update();
}
示例4: checkForUpdate
void NWaveformSlider::checkForUpdate()
{
if (!m_waveBuilder)
return;
float builderPos;
int builderIndex;
m_waveBuilder->positionAndIndex(builderPos, builderIndex);
if (m_oldSize != size() || m_oldBuilderIndex != builderIndex)
m_needsUpdate = true;
if ((builderPos != 0.0 && builderPos != 1.0) && m_timer->interval() != FAST_INTERVAL)
m_timer->setInterval(FAST_INTERVAL);
else
if ((builderPos == 0.0 || builderPos == 1.0) && m_timer->interval() != IDLE_INTERVAL)
m_timer->setInterval(IDLE_INTERVAL);
if (m_needsUpdate) {
QPainter painter;
QImage waveImage;
QImage backgroundImage;
waveImage = backgroundImage = m_progressPlayingImage = m_progressPausedImage = m_remainingPlayingImage = m_remainingPausedImage = QImage(size(), QImage::Format_ARGB32_Premultiplied);
m_oldBuilderPos = builderPos;
m_oldBuilderIndex = builderIndex;
m_oldSize = size();
// waveform >>
waveImage.fill(0);
painter.begin(&waveImage);
painter.setBrush(m_waveBackground);
QPen wavePen;
wavePen.setWidth(0);
wavePen.setColor(m_waveBorderColor);
painter.setPen(wavePen);
painter.translate(1, 1);
painter.scale((qreal)(width() - 1) / m_oldBuilderIndex * m_oldBuilderPos, (height() - 2) / 2);
painter.translate(0, 1);
QPainterPath pathPos;
QPainterPath pathNeg;
NWaveformPeaks *peaks = m_waveBuilder->peaks();
for (int i = 0; i < m_oldBuilderIndex; ++i) {
pathPos.lineTo(i, peaks->positive(i));
pathNeg.lineTo(i, peaks->negative(i));
}
QPainterPath fullPath(pathNeg);
fullPath.connectPath(pathPos.toReversed());
fullPath.closeSubpath();
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(fullPath);
painter.end();
// << waveform
// main background >>
painter.begin(&backgroundImage);
backgroundImage.fill(0);
painter.setPen(Qt::NoPen);
painter.setBrush(m_background);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawRoundedRect(rect(), m_radius, m_radius);
painter.end();
// << main background
QList<QImage *> images; images << &m_progressPlayingImage << &m_progressPausedImage << &m_remainingPlayingImage << &m_remainingPausedImage;
QList<QPainter::CompositionMode> modes; modes << m_playingComposition << m_pausedComposition << m_playingComposition << m_pausedComposition;
QList<QBrush> brushes; brushes << m_progressPlayingBackground << m_progressPausedBackground << m_remainingPlayingBackground << m_remainingPausedBackground;
for (int i = 0; i < images.size(); ++i) {
painter.begin(images[i]);
// background
images[i]->fill(0);
// + overlay
painter.setPen(Qt::NoPen);
painter.setBrush(brushes[i]);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawRoundedRect(rect(), m_radius, m_radius);
// + waveform
painter.setCompositionMode(modes[i]);
painter.drawImage(0, 0, waveImage);
painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
painter.drawImage(0, 0, backgroundImage);
painter.end();
}
update();
m_needsUpdate = false;
}
}