Commit 7b40574a authored by shibakaneki's avatar shibakaneki

Backup of the strokes as object

parent a909eafd
......@@ -50,6 +50,7 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "document/UBDocumentProxy.h"
......@@ -563,7 +564,8 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
|| item->type() == UBGraphicsPixmapItem::Type
|| item->type() == UBGraphicsVideoItem::Type
|| item->type() == UBGraphicsAudioItem::Type
|| item->type() == UBGraphicsSvgItem::Type) {
|| item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type) {
if (!mJustSelectedItems.contains(item)) {
item->setSelected(true);
......
......@@ -45,7 +45,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
, mActiveRuler(NULL)
, mStylusTool((UBStylusTool::Enum)-1)
, mLatestDrawingTool((UBStylusTool::Enum)-1)
//, mDrawingMode(eDrawingMode_Vector)
, mDrawingMode(DRAWING_MODE)
{
connect(UBSettings::settings(), SIGNAL(colorContextChanged()), this, SIGNAL(colorPaletteChanged()));
......@@ -106,10 +106,16 @@ void UBDrawingController::setStylusTool(int tool)
mStylusTool = (UBStylusTool::Enum)tool;
if(eDrawingMode_Vector == DRAWING_MODE){
mDrawingMode = eDrawingMode_Vector;
}
if (mStylusTool == UBStylusTool::Pen)
UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser)
else if (mStylusTool == UBStylusTool::Eraser){
UBApplication::mainWindow->actionEraser->setChecked(true);
mDrawingMode = eDrawingMode_Artistic;
}
else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector)
......
......@@ -27,6 +27,8 @@ typedef enum{
eDrawingMode_Vector
}eDrawingMode;
#define DRAWING_MODE eDrawingMode_Artistic
class UBDrawingController : public QObject
{
Q_OBJECT;
......
......@@ -39,6 +39,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QPolygonF & polygon, QGraphi
, mOriginalWidth(-1)
, mIsNominalLine(false)
, mStroke(0)
, mpGroup(NULL)
{
// NOOP
initialize();
......@@ -77,6 +78,10 @@ UBGraphicsPolygonItem::~UBGraphicsPolygonItem()
clearStroke();
}
void UBGraphicsPolygonItem::setStrokesGroup(UBGraphicsStrokesGroup *group)
{
mpGroup = group;
}
void UBGraphicsPolygonItem::setStroke(UBGraphicsStroke* stroke)
{
......@@ -156,7 +161,7 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
copy->mIsNominalLine = false;
copy->setStroke(this->stroke());
copy->setGroup(this->group());
copy->setStrokesGroup(this->strokesGroup());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha;
......
......@@ -19,6 +19,7 @@
#include "core/UB.h"
#include "UBItem.h"
#include "UBGraphicsStrokesGroup.h"
class UBItem;
class UBGraphicsScene;
......@@ -37,6 +38,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
void initialize();
void setStrokesGroup(UBGraphicsStrokesGroup* group);
UBGraphicsStrokesGroup* strokesGroup() const{return mpGroup;}
void setColor(const QColor& color);
QColor color() const;
......@@ -132,6 +135,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
QColor mColorOnLightBackground;
UBGraphicsStroke* mStroke;
UBGraphicsStrokesGroup* mpGroup;
};
......
This diff is collapsed.
......@@ -16,6 +16,11 @@ public:
virtual UBItem* deepCopy() const;
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType };
virtual int type() const
{
return Type;
}
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
......
......@@ -198,8 +198,9 @@ QRectF UBGeometryUtils::lineToInnerRect(const QLineF& pLine, const qreal& pWidth
qreal centerX = (pLine.x1() + pLine.x2()) / 2;
qreal centerY = (pLine.y1() + pLine.y2()) / 2;
// Please put a fucking comment here
qreal side = sqrt((pWidth * pWidth) / 2);
qreal halfSide = side / 2;
qreal halfSide = side / 2;
return QRectF(centerX - halfSide, centerY - halfSide, side, side);
}
......
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