Commit 351aaa52 authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Add KisVectorShapeObject Class

parent 2ed1c1d5
......@@ -21,6 +21,7 @@ set(kritalibbrush_LIB_SRCS
kis_svg_brush.cpp
kis_vectoranimated_brush.cpp
kis_vectorbrush_parasite.cpp
KisVectorShapeObject.cpp
kis_qimage_pyramid.cpp
KisSharedQImagePyramid.cpp
kis_text_brush.cpp
......
......@@ -76,14 +76,29 @@ bool KisVectorAnimatedBrush::load()
}
KisVectorBrushParasite KisVectorAnimatedBrush::m_parasite;
QList<KisVectorShapeObject> KisVectorAnimatedBrush::m_vectorObjects;
bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
{
m_svg = dev->readAll();
qDebug() << "load";
m_parasite.parseSvg(m_svg);
// parse SVG to list of Shapes;
m_shapes = m_parasite.parseSvg(m_svg);
// set Index to 0
m_parasite.setIndex(0);
setBrushTipImage(m_parasite.nextBrushTip());
// convert the shapes to KisVectorShapeObjects
for(int i = 0; i<m_shapes.count(); i++)
{
m_vectorObjects.append(KisVectorShapeObject(m_shapes.at(i)));
}
KisVectorShapeObject currentVectorObject = m_vectorObjects.at(m_parasite.index());
QImage tip = currentVectorObject.image();
setBrushTipImage(tip);
setValid(true);
......@@ -168,9 +183,10 @@ void KisVectorAnimatedBrush::notifyStrokeStarted()
void KisVectorAnimatedBrush::newbrushTip()
{
QImage image = m_parasite.nextBrushTip();
KisVectorShapeObject currentVectorObject = m_vectorObjects.at(m_parasite.index());
QImage tip = currentVectorObject.image();
setBrushTipImage(tip);
setBrushTipImage(image);
setValid(true);
setBrushType(MASK);
......
......@@ -26,6 +26,8 @@
#include <SvgParser.h>
#include <KoXmlReader.h>
#include <kis_vectorbrush_parasite.h>
#include <KisVectorShapeObject.h>
//
......@@ -70,7 +72,10 @@ public:
private:
QByteArray m_svg;
QList<KoShape*> m_shapes;
static QList<KisVectorShapeObject> m_vectorObjects;
static KisVectorBrushParasite m_parasite;
};
#endif
......@@ -32,13 +32,14 @@ KisVectorBrushParasite::KisVectorBrushParasite()
m_strokes = 0;
}
void KisVectorBrushParasite::parseSvg(QByteArray svg)
QList<KoShape*> KisVectorBrushParasite::parseSvg(QByteArray svg)
{
m_shapes= KisVectorBrushParasite::svgToKoShapes(svg);
m_images = KisVectorBrushParasite::shapesToImages(m_shapes);
m_maxIndex = m_images.size();
m_maxIndex--; //minus one because count starts from zero
return m_shapes;
}
......@@ -133,6 +134,10 @@ QImage KisVectorBrushParasite::nextBrushTip()
// return shapeToQImage(m_shapes, m_index);
}
int KisVectorBrushParasite::index()
{
return m_index;
}
int KisVectorBrushParasite::maxIndex()
{
......@@ -142,7 +147,7 @@ int KisVectorBrushParasite::maxIndex()
void KisVectorBrushParasite::nextIndex()
{
// qDebug() << "index" << m_index;
qDebug() << "index" << m_index;
if (m_index == m_maxIndex){
m_index = 0;
} else {
......
......@@ -22,6 +22,7 @@
#include <SvgParser.h>
#include <KoXmlReader.h>
class KisVectorBrushParasite
{
public:
......@@ -31,8 +32,8 @@ public:
* This function gets the SVG and
* sets m_listOfImages
* */
void parseSvg(QByteArray svg);
QList<KoShape*> svgToKoShapes(QByteArray svg);
QList<KoShape*> parseSvg(QByteArray svg);
QImage shapeToQImage(QList<KoShape*> shapes, int index);
QList<QImage> shapesToImages(QList<KoShape*> shapes);
......@@ -45,11 +46,15 @@ public:
void setIndex(int index);
void nextIndex();
int index();
int maxIndex();
int numberStrokes();
bool canPaint();
private:
QList<KoShape*> svgToKoShapes(QByteArray svg);
private:
QList<KoShape*> m_shapes;
QList<QImage> m_images;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment