本文整理汇总了C++中KoShape类的典型用法代码示例。如果您正苦于以下问题:C++ KoShape类的具体用法?C++ KoShape怎么用?C++ KoShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KoShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
KUndo2Command* KoCreateShapeStrategy::createCommand()
{
Q_D(KoShapeRubberSelectStrategy);
KoCreateShapesTool *parent = static_cast<KoCreateShapesTool*>(d_ptr->tool);
KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(parent->shapeId());
if (! factory) {
warnFlake << "Application requested a shape that is not registered" << parent->shapeId();
return 0;
}
const KoProperties *props = parent->shapeProperties();
KoShape *shape;
if (props)
shape = factory->createShape(props, parent->canvas()->shapeController()->resourceManager());
else
shape = factory->createDefaultShape(parent->canvas()->shapeController()->resourceManager());
if (shape->shapeId().isEmpty())
shape->setShapeId(factory->id());
QRectF rect = d->selectedRect();
shape->setPosition(rect.topLeft());
QSizeF newSize = rect.size();
// if the user has dragged when creating the shape,
// resize the shape to the dragged size
if (newSize.width() > 1.0 && newSize.height() > 1.0)
shape->setSize(newSize);
KUndo2Command * cmd = parent->canvas()->shapeController()->addShape(shape);
if (cmd) {
KoSelection *selection = parent->canvas()->shapeManager()->selection();
selection->deselectAll();
selection->select(shape);
}
return cmd;
}
示例2: run
void KisSelectionToVectorActionFactory::run(KisView2 *view)
{
KisSelectionSP selection = view->selection();
if (selection->hasShapeSelection() ||
!selection->outlineCacheValid()) {
return;
}
QPainterPath selectionOutline = selection->outlineCache();
QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(selectionOutline));
shape->setShapeId(KoPathShapeId);
/**
* Mark a shape that it belongs to a shape selection
*/
if(!shape->userData()) {
shape->setUserData(new KisShapeSelectionMarker);
}
KisProcessingApplicator *ap = beginAction(view, i18n("Convert to Vector Selection"));
ap->applyCommand(view->canvasBase()->shapeController()->addShape(shape),
KisStrokeJobData::SEQUENTIAL,
KisStrokeJobData::EXCLUSIVE);
endAction(ap, KisOperationConfiguration(id()).toXML());
}
示例3: Q_D
void KoTosContainer::setTextAlignment(Qt::Alignment alignment)
{
Q_D(KoTosContainer);
KoShape *textShape = this->textShape();
if (textShape == 0) {
warnFlake << "No text shape present in KoTosContainer";
return;
}
// vertical
KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(textShape->userData());
shapeData->setVerticalAlignment(alignment);
// horizontal
Q_ASSERT(shapeData->document());
QTextBlockFormat bf;
bf.setAlignment(alignment & Qt::AlignHorizontal_Mask);
QTextCursor cursor(shapeData->document());
cursor.setPosition(QTextCursor::End, QTextCursor::KeepAnchor);
cursor.mergeBlockFormat(bf);
d->alignment = alignment;
}
示例4: KPageDialog
KWFrameDialog::KWFrameDialog(const QList<KoShape *> &shapes, KWDocument *document, KWCanvas *canvas)
: KPageDialog(canvas)
, m_frameConnectSelector(0)
, m_canvas(canvas)
{
m_state = new FrameConfigSharedState(document);
setFaceType(Tabbed);
m_anchoringProperties = new KWAnchoringProperties(m_state);
if (m_anchoringProperties->open(shapes))
addPage(m_anchoringProperties, i18n("Smart Positioning"));
m_runAroundProperties = new KWRunAroundProperties(m_state);
if (m_runAroundProperties->open(shapes))
addPage(m_runAroundProperties, i18n("Text Run Around"));
if (shapes.count() == 1) {
m_frameConnectSelector = new KWFrameConnectSelector(m_state);
KoShape *shape = shapes.first();
m_state->setKeepAspectRatio(shape->keepAspectRatio());
if (m_frameConnectSelector->canOpen(shape)) {
m_frameConnectSelector->open(shape);
addPage(m_frameConnectSelector, i18n("Connect Text Frames"));
} else {
delete m_frameConnectSelector;
m_frameConnectSelector = 0;
}
}
connect(this, SIGNAL(accepted()), this, SLOT(okClicked()));
connect(this, SIGNAL(rejected()), this, SLOT(cancelClicked()));
}
示例5: image
KoShape *KPrPlaceholderPictureStrategy::createShape(KoDocumentResourceManager *rm)
{
KoShape * shape = 0;
KUrl url = KFileDialog::getOpenUrl();
if ( !url.isEmpty() ) {
shape = KPrPlaceholderStrategy::createShape(rm);
KoImageCollection *collection = rm->imageCollection();
Q_ASSERT(collection);
QString tmpFile;
if (KIO::NetAccess::download(url, tmpFile, 0)) {
QImage image(tmpFile);
if (!image.isNull()) {
//setSuffix(url.prettyUrl());
KoImageData *data = collection->createImageData(image);
if (data->isValid()) {
shape->setUserData( data );
// TODO the pic should be fit into the space provided
shape->setSize( data->imageSize() );
}
}
} else {
kWarning() << "open image " << url.prettyUrl() << "failed";
}
}
return shape;
}
示例6: updateCache
void KPrAttributeHeight::updateCache(KPrAnimationCache *cache, KPrShapeAnimation *shapeAnimation, qreal value)
{
qreal tx = 0.0, ty = 0.0;
KoShape * shape = shapeAnimation->shape();
KoTextBlockData * textBlockData = shapeAnimation->textBlockData();
QTransform transform;
if (textBlockData) {
if (KoTextShapeData *textShapeData = dynamic_cast<KoTextShapeData*>(shape->userData())) {
QTextDocument *textDocument = textShapeData->document();
for (int i = 0; i < textDocument->blockCount(); i++) {
QTextBlock textBlock = textDocument->findBlockByNumber(i);
if (textBlock.userData() == textBlockData) {
QTextLayout *layout = textBlock.layout();
value = value * cache->pageSize().height() / layout->boundingRect().height();
tx = layout->minimumWidth() * cache->zoom() / 2;
ty = layout->boundingRect().height() * cache->zoom() / 2;
}
}
}
}
else {
value = value * cache->pageSize().height() / shape->size().height();
tx = shape->size().width() * cache->zoom() / 2;
ty = shape->size().height() * cache->zoom() / 2;
}
transform.translate(tx, ty).scale(1, value).translate(-tx, -ty);
cache->update(shape, shapeAnimation->textBlockData(), "transform", transform);
}
示例7: KoPathShapeFactory
void TestKoShapeFactory::testOdfElement()
{
KoShapeFactoryBase * factory = new KoPathShapeFactory(QStringList());
QVERIFY(factory->odfElements().front().second.contains("path"));
QVERIFY(factory->odfElements().front().second.contains("line"));
QVERIFY(factory->odfElements().front().second.contains("polyline"));
QVERIFY(factory->odfElements().front().second.contains("polygon"));
QVERIFY(factory->odfElements().front().first == KoXmlNS::draw);
QBuffer xmldevice;
xmldevice.open(QIODevice::WriteOnly);
QTextStream xmlstream(&xmldevice);
xmlstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xmlstream << "<office:document-content xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\" xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\" xmlns:presentation=\"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\" xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\" xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\" xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\" xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\" xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\" xmlns:math=\"http://www.w3.org/1998/Math/MathML\" xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\" xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\" xmlns:koffice=\"http://www.koffice.org/2005/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
xmlstream << "<office:body>";
xmlstream << "<office:text>";
xmlstream << "<text:p text:style-name=\"P1\"><?opendocument cursor-position?></text:p>";
xmlstream << "<draw:path svg:d=\"M10,10L100,100\"></draw:path>";
xmlstream << "</office:text>";
xmlstream << "</office:body>";
xmlstream << "</office:document-content>";
xmldevice.close();
KoXmlDocument doc;
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
QCOMPARE(doc.setContent(&xmldevice, true, &errorMsg, &errorLine, &errorColumn), true);
QCOMPARE(errorMsg.isEmpty(), true);
QCOMPARE(errorLine, 0);
QCOMPARE(errorColumn, 0);
KoXmlElement contentElement = doc.documentElement();
KoXmlElement bodyElement = contentElement.firstChild().toElement();
// XXX: When loading is implemented, these no doubt have to be
// sensibly filled.
KoOdfStylesReader stylesReader;
KoOdfLoadingContext odfContext(stylesReader, 0);
KoShapeLoadingContext shapeContext(odfContext, 0);
KoXmlElement textElement = bodyElement.firstChild().firstChild().toElement();
QVERIFY(textElement.tagName() == "p");
QCOMPARE(factory->supports(textElement, shapeContext), false);
KoXmlElement pathElement = bodyElement.firstChild().lastChild().toElement();
QVERIFY(pathElement.tagName() == "path");
QCOMPARE(factory->supports(pathElement, shapeContext), true);
KoShape *shape = factory->createDefaultShape();
QVERIFY(shape);
QVERIFY(shape->loadOdf(pathElement, shapeContext));
delete shape;
delete factory;
}
示例8: setRunThrough
void KoTosContainer::setRunThrough(short int runThrough)
{
KoShape::setRunThrough(runThrough);
KoShape *textShape = this->textShape();
if (textShape) {
textShape->setRunThrough(runThrough);
}
}
示例9: initCache
void KPrAttributeY::initCache(KPrAnimationCache *animationCache, int step, KPrShapeAnimation * shapeAnimation, qreal startValue, qreal endValue)
{
KoShape * shape = shapeAnimation->shape();
qreal v1 = (startValue * animationCache->pageSize().height() - shape->position().y()) * animationCache->zoom();
qreal v2 = (endValue * animationCache->pageSize().height() - shape->position().y()) * animationCache->zoom();
animationCache->init(step, shape, shapeAnimation->textBlockUserData(), "transform", QTransform().translate(0, v1));
animationCache->init(step + 1, shape, shapeAnimation->textBlockUserData(), "transform", QTransform().translate(0, v2));
}
示例10: handlePaintRect
void ConnectionTool::paint(QPainter &painter, const KoViewConverter &converter)
{
// get the correctly sized rect for painting handles
QRectF handleRect = handlePaintRect(QPointF());
painter.setRenderHint(QPainter::Antialiasing, true);
if (m_currentStrategy) {
painter.save();
m_currentStrategy->paint(painter, converter);
painter.restore();
}
QList<KoShape*> shapes = canvas()->shapeManager()->shapes();
for (QList<KoShape*>::const_iterator end = shapes.constBegin(); end != shapes.constEnd(); ++end) {
KoShape* shape = *end;
if (!dynamic_cast<KoConnectionShape*>(shape)) {
// only paint connection points of textShapes not inside a tos container and other shapes
if (shape->shapeId() == TextShape_SHAPEID && dynamic_cast<KoTosContainer*>(shape->parent())) continue;
painter.save();
painter.setPen(Qt::black);
QTransform transform = shape->absoluteTransformation(0);
KoShape::applyConversion(painter, converter);
// Draw all the connection points of the shape
KoConnectionPoints connectionPoints = shape->connectionPoints();
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
if (shape == findNonConnectionShapeAtPosition(transform.map(cp.value().position)) ) {
handleRect.moveCenter(transform.map(cp.value().position));
painter.setBrush(cp.key() == m_activeHandle && shape == m_currentShape ?
Qt::red : Qt::white);
painter.drawRect(handleRect);
}
}
painter.restore();
}
}
// paint connection points or connection handles depending
// on the shape the mouse is currently
if (m_currentShape && m_editMode == EditConnection) {
KoConnectionShape *connectionShape = dynamic_cast<KoConnectionShape*>(m_currentShape);
if (connectionShape) {
int radius = handleRadius()+1;
int handleCount = connectionShape->handleCount();
for(int i = 0; i < handleCount; ++i) {
painter.save();
painter.setPen(Qt::blue);
painter.setBrush(i == m_activeHandle ? Qt::red : Qt::white);
painter.setTransform(connectionShape->absoluteTransformation(&converter) * painter.transform());
connectionShape->paintHandle(painter, converter, i, radius);
painter.restore();
}
}
}
}
示例11: updateCache
void KPrAttributeY::updateCache(KPrAnimationCache *cache, KPrShapeAnimation *shapeAnimation, qreal value)
{
KoShape *shape = shapeAnimation->shape();
QTransform transform;
value = value * cache->pageSize().height();
value = value - shape->position().y();
value = value * cache->zoom();
transform.translate(0, value);
cache->update(shape, shapeAnimation->textBlockUserData(), "transform", transform);
}
示例12: setPlainText
void KoTosContainer::setPlainText(const QString &text)
{
KoShape *textShape = this->textShape();
if (textShape == 0) {
warnFlake << "No text shape present in KoTosContainer";
return;
}
KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(textShape->userData());
Q_ASSERT(shapeData->document());
shapeData->document()->setPlainText(text);
}
示例13: Q_ASSERT
void KWCreateOutlineCommand::undo()
{
QUndoCommand::undo();
Q_ASSERT(m_container);
KoShape *child = m_frame->shape();
child->setTransformation(m_container->absoluteTransformation(0));
m_container->removeShape(m_frame->shape());
m_container->setApplicationData(0);
m_controller->removeShape(m_container);
m_frame->setOutlineShape(0);
m_deleteOnExit = true;
}
示例14: undo
void KoShapeTransformCommand::undo()
{
KUndo2Command::undo();
const int shapeCount = d->shapes.count();
for (int i = 0; i < shapeCount; ++i) {
KoShape * shape = d->shapes[i];
shape->update();
shape->setTransformation(d->oldState[i]);
shape->update();
}
}
示例15: orderedShapes
// static
KoShapeGroupCommand * KoShapeGroupCommand::createCommand(KoShapeGroup *container, const QList<KoShape *> &shapes, KUndo2Command *parent)
{
QList<KoShape*> orderedShapes(shapes);
qSort(orderedShapes.begin(), orderedShapes.end(), KoShape::compareShapeZIndex);
if (!orderedShapes.isEmpty()) {
KoShape * top = orderedShapes.last();
container->setParent(top->parent());
container->setZIndex(top->zIndex());
}
return new KoShapeGroupCommand(container, orderedShapes, parent);
}