本文整理汇总了C++中PageItem::DrawObj方法的典型用法代码示例。如果您正苦于以下问题:C++ PageItem::DrawObj方法的具体用法?C++ PageItem::DrawObj怎么用?C++ PageItem::DrawObj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageItem
的用法示例。
在下文中一共展示了PageItem::DrawObj方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReOrderText
void ReOrderText(ScribusDoc *currentDoc, ScribusView *view)
{
double savScale = view->scale();
view->setScale(1.0);
currentDoc->RePos = true;
QImage pgPix(10, 10, QImage::Format_ARGB32_Premultiplied);
QRect rd; // = QRect(0,0,9,9);
ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height());
for (int azz=0; azz<currentDoc->MasterItems.count(); ++azz)
{
PageItem *currItem = currentDoc->MasterItems.at(azz);
if (currItem->itemType() == PageItem::PathText)
currItem->DrawObj(painter, rd);
}
for (int azz=0; azz<currentDoc->Items->count(); ++azz)
{
PageItem *currItem = currentDoc->Items->at(azz);
currItem->layout();
if (currItem->itemType() == PageItem::PathText)
currItem->DrawObj(painter, rd); //FIXME: this should be replaced by code in layout()
}
currentDoc->RePos = false;
view->setScale(savScale);
delete painter;
}
示例2: createPreview
void ScPattern::createPreview()
{
double sc = 500.0 / qMax(width, height);
bool savedFlag = doc->guidesPrefs().framesShown;
bool savedDoDrawing = doc->DoDrawing;
doc->guidesPrefs().framesShown = false;
doc->DoDrawing = true;
pattern = QImage(qRound(width * sc), qRound(height * sc), QImage::Format_ARGB32_Premultiplied);
pattern.fill( qRgba(0, 0, 0, 0) );
ScPainter *painter = new ScPainter(&pattern, pattern.width(), pattern.height(), 1, 0);
painter->setZoomFactor(sc);
for (int i = 0; i < items.count(); ++i)
{
PageItem* embedded = items.at(i);
painter->save();
painter->translate(embedded->gXpos, embedded->gYpos);
embedded->isEmbedded = true;
embedded->invalid = true;
embedded->DrawObj(painter, QRectF());
embedded->isEmbedded = false;
painter->restore();
}
painter->end();
delete painter;
doc->DoDrawing = savedDoDrawing;
doc->guidesPrefs().framesShown = savedFlag;
}
示例3: DrawObj_Item
void PageItem_Group::DrawObj_Item(ScPainter *p, QRectF /*e*/)
{
if (m_Doc->RePos)
return;
if (groupItemList.isEmpty())
{
if (m_Doc->guidesPrefs().framesShown)
{
p->save();
p->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
p->drawLine(FPoint(0, 0), FPoint(m_width, m_height));
p->drawLine(FPoint(0, m_height), FPoint(m_width, 0));
p->setFont(QApplication::font());
p->drawLine(FPoint(0, 0), FPoint(m_width, 0));
p->drawLine(FPoint(m_width, 0), FPoint(m_width, m_height));
p->drawLine(FPoint(m_width, m_height), FPoint(0, m_height));
p->drawLine(FPoint(0, m_height), FPoint(0, 0));
p->setBrush(QColor(255, 255, 255));
p->setBrushOpacity(0.0);
p->drawText(QRectF(0.0, 0.0, m_width, m_height), "Empty Group");
p->restore();
}
return;
}
p->save();
if (imageFlippedH())
{
p->translate(m_width, 0);
p->scale(-1, 1);
}
if (imageFlippedV())
{
p->translate(0, m_height);
p->scale(1, -1);
}
if ((maskType() == 1) || (maskType() == 2) || (maskType() == 4) || (maskType() == 5))
{
if ((maskType() == 1) || (maskType() == 2))
p->setMaskMode(1);
else
p->setMaskMode(3);
if ((!gradientMask().isEmpty()) && (!m_Doc->docGradients.contains(gradientMask())))
gradientMaskVal = "";
if (!(gradientMask().isEmpty()) && (m_Doc->docGradients.contains(gradientMask())))
mask_gradient = m_Doc->docGradients[gradientMask()];
p->mask_gradient = mask_gradient;
if ((maskType() == 1) || (maskType() == 4))
p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew);
else
p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew);
}
else if ((maskType() == 3) || (maskType() == 6) || (maskType() == 7) || (maskType() == 8))
{
if ((patternMask().isEmpty()) || (!m_Doc->docPatterns.contains(patternMask())))
p->setMaskMode(0);
else
{
double scw = m_width / groupWidth;
double sch = m_height / groupHeight;
p->setPatternMask(&m_Doc->docPatterns[patternMask()], patternMaskScaleX * scw, patternMaskScaleY * sch, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
if (maskType() == 3)
p->setMaskMode(2);
else if (maskType() == 6)
p->setMaskMode(4);
else if (maskType() == 7)
p->setMaskMode(5);
else
p->setMaskMode(6);
}
}
else
p->setMaskMode(0);
p->setFillRule(fillRule);
if (m_groupClips)
p->beginLayer(1.0 - fillTransparency(), fillBlendmode(), &PoLine);
else
p->beginLayer(1.0 - fillTransparency(), fillBlendmode());
p->setMaskMode(0);
p->scale(m_width / groupWidth, m_height / groupHeight);
for (int em = 0; em < groupItemList.count(); ++em)
{
PageItem* embedded = groupItemList.at(em);
p->save();
p->translate(embedded->gXpos, embedded->gYpos);
embedded->isEmbedded = true;
embedded->invalidateLayout();
embedded->DrawObj(p, QRectF());
embedded->isEmbedded = false;
p->restore();
if (m_Doc->guidesPrefs().framesShown)
{
p->save();
double x = embedded->xPos();
double y = embedded->yPos();
embedded->setXYPos(embedded->gXpos, embedded->gYpos, true);
embedded->DrawObj_Decoration(p);
embedded->setXYPos(x, y, true);
p->restore();
//.........这里部分代码省略.........
示例4: paintTable
//.........这里部分代码省略.........
* 3) Horizontal borders
* 4) Decorative grid lines.
* 5) Cell content.
*/
// Pass 1: Paint cell fills.
for (int row = 0; row < table()->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < table()->columns(); col += colSpan)
{
TableCell cell = table()->cellAt(row, col);
if (row == cell.row())
paintCellFill(cell, p);
colSpan = cell.columnSpan();
}
}
// Pass 2: Paint vertical borders.
for (int row = 0; row < table()->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < table()->columns(); col += colSpan)
{
TableCell cell = table()->cellAt(row, col);
if (row == cell.row())
{
paintCellRightBorders(cell, p);
if (col == 0)
paintCellLeftBorders(cell, p);
}
colSpan = cell.columnSpan();
}
}
// Pass 3: Paint horizontal borders.
for (int row = 0; row < table()->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < table()->columns(); col += colSpan)
{
TableCell cell = table()->cellAt(row, col);
if (row == cell.row())
{
paintCellBottomBorders(cell, p);
if (row == 0)
paintCellTopBorders(cell, p);
}
colSpan = cell.columnSpan();
}
}
// Pass 4: Paint grid lines.
if (table()->m_Doc->guidesPrefs().framesShown)
{
for (int row = 0; row < table()->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < table()->columns(); col += colSpan)
{
TableCell cell = table()->cellAt(row, col);
if (row == cell.row())
{
int endCol = col + cell.columnSpan() - 1;
int endRow = row + cell.rowSpan() - 1;
qreal left = table()->columnPosition(col);
qreal right = table()->columnPosition(endCol) + table()->columnWidth(endCol);
qreal top = table()->rowPosition(row);
qreal bottom = table()->rowPosition(endRow) + table()->rowHeight(endRow);
// Paint right and bottom grid line.
paintGridLine(QPointF(right, top), QPointF(right, bottom), p);
paintGridLine(QPointF(left, bottom), QPointF(right, bottom), p);
// Paint left and top grid line.
if (col == 0)
paintGridLine(QPointF(left, top), QPointF(left, bottom), p);
if (row == 0)
paintGridLine(QPointF(left, top), QPointF(right, top), p);
}
colSpan = cell.columnSpan();
}
}
}
// Pass 5: Paint cell content.
for (int row = 0; row < table()->rows(); ++row)
{
for (int col = 0; col < table()->columns(); col ++)
{
TableCell cell = table()->cellAt(row, col);
if (cell.row() == row && cell.column() == col)
{
PageItem* textFrame = cell.textFrame();
textFrame->DrawObj(p, QRectF());
textFrame->DrawObj_Decoration(p);
}
}
}
p->restore();
}
示例5: WriteElem
QString ScriXmlDoc::WriteElem(ScribusDoc *doc, Selection* selection)
{
if (selection->count()==0)
return "";
double xp, yp, wp, hp;
PageItem *item;
QString documentStr = "";
item = selection->itemAt(0);
QList<PageItem*> emG;
QMap<int, PageItem*> emMap;
emG.clear();
for (int cor = 0; cor < selection->count(); ++cor)
{
emMap.insert(doc->Items->indexOf(selection->itemAt(cor)), selection->itemAt(cor));
}
emG = emMap.values();
double selectionWidth = 0;
double selectionHeight = 0;
if (selection->isMultipleSelection())
{
double gx, gy, gw, gh;
selection->getGroupRect(&gx, &gy, &gw, &gh);
xp = gx;
yp = gy;
wp = gw;
hp = gh;
selection->getVisualGroupRect(&gx, &gy, &selectionWidth, &selectionHeight);
}
else
{
double minx = std::numeric_limits<double>::max();
double miny = std::numeric_limits<double>::max();
double maxx = -std::numeric_limits<double>::max();
double maxy = -std::numeric_limits<double>::max();
double x1, x2, y1, y2;
item->getVisualBoundingRect(&x1, &y1, &x2, &y2);
xp = qMin(minx, x1);
yp = qMin(miny, y1);
selectionWidth = wp = qMax(maxx, x2) - xp;
selectionHeight = hp = qMax(maxy, y2) - yp;
}
double scaleI = 50.0 / qMax(selectionWidth, selectionHeight);
QImage retImg = QImage(50, 50, QImage::Format_ARGB32_Premultiplied);
retImg.fill( qRgba(0, 0, 0, 0) );
ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
painter->setZoomFactor(scaleI);
for (int em = 0; em < emG.count(); ++em)
{
PageItem* embedded = emG.at(em);
painter->save();
painter->translate(-xp, -yp);
embedded->invalid = true;
embedded->DrawObj(painter, QRectF());
painter->restore();
}
int pg = doc->OnPage(xp + wp / 2.0, yp + hp / 2.0);
if (pg > -1)
{
xp = xp - doc->getXOffsetForPage(pg);
yp = yp - doc->getYOffsetForPage(pg);
}
delete painter;
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
retImg.save(&buffer, "PNG");
QByteArray ba = buffer.buffer().toBase64();
buffer.close();
const FileFormat *fmt = LoadSavePlugin::getFormatById(FORMATID_SLA150EXPORT);
if (fmt)
{
fmt->setupTargets(doc, 0, doc->scMW(), 0, &(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts));
documentStr = fmt->saveElements(xp, yp, wp, hp, selection, ba);
}
return documentStr;
}