14#include <QApplication>
53 m_resolutionProxy(m_model->resolutionProxy())
61 m_resolutionProxy(m_model->resolutionProxy())
101 m_model->setObjectName(
"KisShapeSelectionModel");
102 m_model->moveToThread(qApp->thread());
103 m_canvas->setObjectName(
"KisShapeSelectionCanvas");
104 m_canvas->moveToThread(qApp->thread());
116 const QSizeF sizeInPx = imageRect.size();
132 if (store->
open(
"content.svg")) {
134 storeDev.
open(QIODevice::ReadOnly);
186 QTransform resolutionMatrix;
192 Q_FOREACH (
KoShape * shape, shapesList) {
215 Q_ASSERT(projection);
223 Q_ASSERT(projection);
231 const qint32 MASK_IMAGE_WIDTH = 256;
232 const qint32 MASK_IMAGE_HEIGHT = 256;
238 selectionOutline = t.
map(selectionOutline);
242 projection->
clear(requestedRect);
245 projection->
fill(requestedRect, transparentColor);
247 const QRect r = requestedRect & selectionOutline.boundingRect().toAlignedRect();
249 QImage polygonMaskImage(MASK_IMAGE_WIDTH, MASK_IMAGE_HEIGHT, QImage::Format_ARGB32);
250 QPainter maskPainter(&polygonMaskImage);
251 maskPainter.setRenderHint(QPainter::Antialiasing,
true);
254 for (qint32 x = r.x(); x < r.x() + r.width(); x += MASK_IMAGE_WIDTH) {
255 for (qint32 y = r.y(); y < r.y() + r.height(); y += MASK_IMAGE_HEIGHT) {
257 maskPainter.fillRect(polygonMaskImage.rect(), Qt::black);
258 maskPainter.translate(-x, -y);
259 maskPainter.fillPath(selectionOutline, Qt::white);
260 maskPainter.translate(x, y);
262 qint32 rectWidth = qMin(r.x() + r.width() - x, MASK_IMAGE_WIDTH);
263 qint32 rectHeight = qMin(r.y() + r.height() - y, MASK_IMAGE_HEIGHT);
267 (*it.
rawData()) = qRed(polygonMaskImage.pixel(it.
x() - x, it.
y() - y));
309 if(
shapes.isEmpty())
return 0;
321 oldTransformations.append(oldTransform);
325 newTransformations.append(oldTransform);
328 QTransform localTransform = globalTransform * realTransform * globalTransform.inverted();
329 newTransformations.append(localTransform*oldTransform);
const quint8 OPACITY_TRANSPARENT_U8
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
virtual int currentLevelOfDetail() const =0
void fill(const QRect &rc, const KoColor &color)
const KoColorSpace * colorSpace() const
KoColor defaultPixel() const
KisDefaultBoundsBaseSP defaultBounds() const
ALWAYS_INLINE quint8 * rawData()
ALWAYS_INLINE int x() const
ALWAYS_INLINE int y() const
static QList< KoShape * > createShapesFromSvg(QIODevice *device, const QString &baseXmlDir, const QRectF &rectInPixels, qreal resolutionPPI, KoDocumentResourceManager *resourceManager, bool loadingFromKra, QSizeF *fragmentSize, QStringList *warnings=0, QStringList *errors=0)
static bool saveShapesToStore(KoStore *store, QList< KoShape * > shapes, const QSizeF &sizeInPt)
KoShapeManager * shapeManager() const override
KisShapeSelectionFactory()
void setUpdatesEnabled(bool enabled)
int count() const override
void setShapeSelection(KisShapeSelection *selection)
bool updatesEnabled() const
void setResolutionProxy(KisImageResolutionProxySP newResolutionProxy)
friend class KisTakeAllShapesCommand
void setUpdatesEnabled(bool enabled)
bool updatesEnabled() const
void setResolutionProxy(KisImageResolutionProxySP resolutionProxy) override
KUndo2Command * resetToEmpty() override
void moveY(qint32 y) override
void moveX(qint32 x) override
void init(KisImageResolutionProxySP resolutionProxy, KoShapeControllerBase *shapeControllerBase)
bool saveSelection(KoStore *store, const QRect &imageRect) const
void renderSelection(KisPaintDeviceSP projection, const QRect &requestedRect)
void slotMoveShapes(const QPointF &diff)
void recalculateOutlineCache() override
KisSelectionComponent * clone(KisSelection *selection) override
bool outlineCacheValid() const override
KisImageViewConverter * m_converter
KisShapeSelectionCanvas * m_canvas
KisShapeSelectionModel * m_model
KisShapeSelection(const KisShapeSelection &rhs)
QPainterPath outlineCache() const override
KoShapeManager * shapeManager() const
KoShapeControllerBase * m_shapeControllerBase
void paintComponent(QPainter &painter) const override
Paint the component Implement this method to allow the shape to paint itself, just like the KoShape::...
bool loadSelection(KoStore *store, const QRect &imageRect)
KisImageResolutionProxySP m_resolutionProxy
void renderToProjection(KisPaintDeviceSP projection) override
~KisShapeSelection() override
void sigMoveShapes(const QPointF &diff)
bool isEmpty() const override
QPointer< KoShapeController > shapeController
static KoColor createTransparent(const KoColorSpace *cs)
QList< KoShape * > shapes() const
void addShape(KoShape *shape)
void setHidden(bool hidden)
QRectF boundingRect() const override
Get the bounding box of the shape.
QList< KoShape * > shapes
void setUpdatesBlocked(bool value)
void addShape(KoShape *shape, KoShapeManager::Repaint repaint=PaintShapeOnAdd)
virtual QPainterPath outline() const
void setSelectable(bool selectable)
KoShapeContainer * parent() const
QTransform absoluteTransformation() const
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
QTransform transformation() const
Returns the shapes local transformation matrix.
virtual void setPosition(const QPointF &position)
Set the position of the shape in pt.
void setShapeId(const QString &id)
QTransform transform() const
return the current matrix that contains the rotation/scale/position of this shape
QPointF position() const
Get the position of the shape in pt.
bool open(OpenMode m) override
bool open(const QString &name)
virtual QPointF viewToDocument(const QPointF &viewPoint) const
virtual QPointF documentToView(const QPointF &documentPoint) const
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)