Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
4b0a4ab3
Commit
4b0a4ab3
authored
Apr 29, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restored old graphics delegate behavior and added new stroke smoothing behavior
parent
10a22d7c
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
148 additions
and
140 deletions
+148
-140
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-1
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+2
-3
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+45
-95
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+1
-2
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+14
-9
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+1
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+13
-1
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+6
-4
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+8
-10
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+10
-13
UBGeometryUtils.cpp
src/frameworks/UBGeometryUtils.cpp
+43
-0
UBGeometryUtils.h
src/frameworks/UBGeometryUtils.h
+1
-0
UBGraphicsCurtainItemDelegate.cpp
src/tools/UBGraphicsCurtainItemDelegate.cpp
+1
-2
No files found.
src/board/UBBoardController.cpp
View file @
4b0a4ab3
...
@@ -2068,7 +2068,9 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
...
@@ -2068,7 +2068,9 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
mActiveScene
->
render
(
&
painter
,
targetRect
,
pSceneRect
);
mActiveScene
->
render
(
&
painter
,
targetRect
,
pSceneRect
);
mActiveScene
->
setRenderingContext
(
UBGraphicsScene
::
Screen
);
mActiveScene
->
setRenderingContext
(
UBGraphicsScene
::
Screen
);
mActiveScene
->
setRenderingQuality
(
UBItem
::
RenderingQualityNormal
);
// mActiveScene->setRenderingQuality(UBItem::RenderingQualityNormal);
mActiveScene
->
setRenderingQuality
(
UBItem
::
RenderingQualityHigh
);
mPaletteManager
->
addItem
(
QPixmap
::
fromImage
(
image
));
mPaletteManager
->
addItem
(
QPixmap
::
fromImage
(
image
));
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
4b0a4ab3
...
@@ -39,8 +39,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
...
@@ -39,8 +39,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
=
true
);
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
=
true
);
virtual
~
UBGraphicsDelegateFrame
();
virtual
~
UBGraphicsDelegateFrame
();
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QWidget
*
widget
);
QPainterPath
shape
()
const
;
QPainterPath
shape
()
const
;
...
@@ -54,7 +53,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
...
@@ -54,7 +53,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
void
positionHandles
();
void
positionHandles
();
void
setVisible
(
bool
visible
);
void
setVisible
(
bool
visible
);
virtual
void
setAntiScale
(
qreal
pAntiScale
);
virtual
void
setAntiScale
(
qreal
pAntiScale
);
enum
OperationMode
{
Scaling
,
Resizing
,
ResizingHorizontally
};
enum
OperationMode
{
Scaling
,
Resizing
,
ResizingHorizontally
};
void
setOperationMode
(
OperationMode
pMode
)
{
mOperationMode
=
pMode
;}
void
setOperationMode
(
OperationMode
pMode
)
{
mOperationMode
=
pMode
;}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
4b0a4ab3
...
@@ -179,51 +179,51 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
...
@@ -179,51 +179,51 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
void
UBGraphicsItemDelegate
::
init
()
{
{
//
if (mToolBarUsed)
if
(
mToolBarUsed
)
//
mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
//
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
//
mFrame->hide();
mFrame
->
hide
();
//
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
//
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
//
mButtons << mDeleteButton;
mButtons
<<
mDeleteButton
;
//
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
//
if (canDuplicate()){
if
(
canDuplicate
()){
//
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
//
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
//
mButtons << mDuplicateButton;
mButtons
<<
mDuplicateButton
;
//
}
}
//
mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
//
connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
//
mButtons << mMenuButton;
mButtons
<<
mMenuButton
;
//
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, Qt::BottomLeftSection);
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
//
mZOrderUpButton->setShowProgressIndicator(true);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
//
connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
//
connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
//
mButtons << mZOrderUpButton;
mButtons
<<
mZOrderUpButton
;
//
mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", mDelegated, mFrame, Qt::BottomLeftSection);
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
//
mZOrderDownButton->setShowProgressIndicator(true);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
//
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
//
connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
//
mButtons << mZOrderDownButton;
mButtons
<<
mZOrderDownButton
;
//
buildButtons();
buildButtons
();
//
foreach(DelegateButton* button, mButtons)
foreach
(
DelegateButton
*
button
,
mButtons
)
//
{
{
//
if (button->getSection() != Qt::TitleBarArea)
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
//
{
{
//
button->hide();
button
->
hide
();
//
button->setFlag(QGraphicsItem::ItemIsSelectable, true);
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
//
}
}
//
}
}
//
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
//
setFlippable(false);
setFlippable
(
false
);
//
setRotatable(false);
setRotatable
(
false
);
}
}
...
@@ -236,53 +236,6 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
...
@@ -236,53 +236,6 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
}
}
void
UBGraphicsItemDelegate
::
decorate
()
{
if
(
mToolBarUsed
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
if
(
!
mFrame
){
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
mButtons
<<
mZOrderUpButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
}
QVariant
UBGraphicsItemDelegate
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
QVariant
UBGraphicsItemDelegate
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
{
...
@@ -736,11 +689,8 @@ bool UBGraphicsItemDelegate::isFlippable()
...
@@ -736,11 +689,8 @@ bool UBGraphicsItemDelegate::isFlippable()
void
UBGraphicsItemDelegate
::
updateFrame
()
void
UBGraphicsItemDelegate
::
updateFrame
()
{
{
decorate
();
if
(
mFrame
&&
!
mFrame
->
scene
()
&&
mDelegated
->
scene
())
if
(
mFrame
&&
!
mFrame
->
scene
()
&&
mDelegated
->
scene
())
{
mDelegated
->
scene
()
->
addItem
(
mFrame
);
mDelegated
->
scene
()
->
addItem
(
mFrame
);
}
mFrame
->
setAntiScale
(
mAntiScaleRatio
);
mFrame
->
setAntiScale
(
mAntiScaleRatio
);
mFrame
->
positionHandles
();
mFrame
->
positionHandles
();
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
4b0a4ab3
...
@@ -220,7 +220,6 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -220,7 +220,6 @@ class UBGraphicsItemDelegate : public QObject
virtual
~
UBGraphicsItemDelegate
();
virtual
~
UBGraphicsItemDelegate
();
void
init
();
void
init
();
void
decorate
();
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
@@ -246,7 +245,7 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -246,7 +245,7 @@ class UBGraphicsItemDelegate : public QObject
void
startUndoStep
();
void
startUndoStep
();
void
commitUndoStep
();
void
commitUndoStep
();
UBGraphicsDelegateFrame
*
frame
()
{
if
(
!
mFrame
)
decorate
();
return
mFrame
;
}
UBGraphicsDelegateFrame
*
frame
()
{
return
mFrame
;
}
bool
canRotate
()
const
{
return
mCanRotate
;
}
bool
canRotate
()
const
{
return
mCanRotate
;
}
bool
isLocked
()
const
;
bool
isLocked
()
const
;
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
4b0a4ab3
...
@@ -65,6 +65,18 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
...
@@ -65,6 +65,18 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
initialize
();
initialize
();
}
}
UBGraphicsPolygonItem
::
UBGraphicsPolygonItem
(
const
QLineF
&
pLine
,
qreal
pStartWidth
,
qreal
pEndWidth
)
:
QGraphicsPolygonItem
(
UBGeometryUtils
::
lineToPolygon
(
pLine
,
pStartWidth
,
pEndWidth
))
,
mOriginalLine
(
pLine
)
,
mOriginalWidth
(
pEndWidth
)
,
mIsNominalLine
(
true
)
,
mStroke
(
0
)
{
// NOOP
initialize
();
}
void
UBGraphicsPolygonItem
::
initialize
()
void
UBGraphicsPolygonItem
::
initialize
()
{
{
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
DrawingItem
));
//Necessary to set if we want z value to be assigned correctly
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
DrawingItem
));
//Necessary to set if we want z value to be assigned correctly
...
@@ -157,11 +169,11 @@ QColor UBGraphicsPolygonItem::color() const
...
@@ -157,11 +169,11 @@ QColor UBGraphicsPolygonItem::color() const
UBItem
*
UBGraphicsPolygonItem
::
deepCopy
()
const
UBItem
*
UBGraphicsPolygonItem
::
deepCopy
()
const
{
{
UBGraphicsPolygonItem
*
copy
=
new
UBGraphicsPolygonItem
(
polygon
(),
0
);
UBGraphicsPolygonItem
*
copy
=
new
UBGraphicsPolygonItem
(
polygon
(),
0
);
UBGraphicsStroke
*
stroke
=
new
UBGraphicsStroke
();
UBGraphicsStroke
*
stroke
=
new
UBGraphicsStroke
();
copyItemParameters
(
copy
);
copyItemParameters
(
copy
);
copy
->
setStroke
(
stroke
);
copy
->
setStroke
(
stroke
);
...
@@ -186,7 +198,6 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
...
@@ -186,7 +198,6 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp
->
setColorOnDarkBackground
(
this
->
colorOnDarkBackground
());
cp
->
setColorOnDarkBackground
(
this
->
colorOnDarkBackground
());
cp
->
setColorOnLightBackground
(
this
->
colorOnLightBackground
());
cp
->
setColorOnLightBackground
(
this
->
colorOnLightBackground
());
//cp->setTransform(transform());
cp
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
cp
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
}
}
...
@@ -195,9 +206,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
...
@@ -195,9 +206,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
void
UBGraphicsPolygonItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
UBGraphicsPolygonItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
{
if
(
mHasAlpha
&&
scene
()
&&
scene
()
->
isLightBackground
())
if
(
mHasAlpha
&&
scene
()
&&
scene
()
->
isLightBackground
())
{
painter
->
setCompositionMode
(
QPainter
::
CompositionMode_Darken
);
painter
->
setCompositionMode
(
QPainter
::
CompositionMode_Darken
);
}
QGraphicsPolygonItem
::
paint
(
painter
,
option
,
widget
);
QGraphicsPolygonItem
::
paint
(
painter
,
option
,
widget
);
}
}
...
@@ -209,10 +218,6 @@ QPainterPath UBGraphicsPolygonItem::shape() const
...
@@ -209,10 +218,6 @@ QPainterPath UBGraphicsPolygonItem::shape() const
path
.
addRect
(
boundingRect
());
path
.
addRect
(
boundingRect
());
return
path
;
return
path
;
// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// return shapePath;
}
}
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
4b0a4ab3
...
@@ -42,6 +42,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
...
@@ -42,6 +42,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
UBGraphicsPolygonItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsPolygonItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsPolygonItem
(
const
QLineF
&
line
,
qreal
pWidth
);
UBGraphicsPolygonItem
(
const
QLineF
&
line
,
qreal
pWidth
);
UBGraphicsPolygonItem
(
const
QLineF
&
pLine
,
qreal
pStartWidth
,
qreal
pEndWidth
);
UBGraphicsPolygonItem
(
const
QPolygonF
&
polygon
,
QGraphicsItem
*
parent
=
0
);
UBGraphicsPolygonItem
(
const
QPolygonF
&
polygon
,
QGraphicsItem
*
parent
=
0
);
~
UBGraphicsPolygonItem
();
~
UBGraphicsPolygonItem
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
4b0a4ab3
...
@@ -707,7 +707,9 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
...
@@ -707,7 +707,9 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
if
(
mPreviousWidth
==
-
1.0
)
if
(
mPreviousWidth
==
-
1.0
)
mPreviousWidth
=
pWidth
;
mPreviousWidth
=
pWidth
;
UBGraphicsPolygonItem
*
polygonItem
=
lineToPolygonItem
(
QLineF
(
mPreviousPoint
,
pEndPoint
),
pWidth
);
// UBGraphicsPolygonItem *polygonItem = lineToPolygonItem(QLineF(mPreviousPoint, pEndPoint), pWidth);
UBGraphicsPolygonItem
*
polygonItem
=
lineToPolygonItem
(
QLineF
(
mPreviousPoint
,
pEndPoint
),
mPreviousWidth
,
pWidth
);
if
(
!
polygonItem
->
brush
().
isOpaque
())
if
(
!
polygonItem
->
brush
().
isOpaque
())
{
{
...
@@ -949,6 +951,16 @@ UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, c
...
@@ -949,6 +951,16 @@ UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, c
return
polygonItem
;
return
polygonItem
;
}
}
UBGraphicsPolygonItem
*
UBGraphicsScene
::
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
UBGraphicsPolygonItem
*
polygonItem
=
new
UBGraphicsPolygonItem
(
pLine
,
pStartWidth
,
pEndWidth
);
initPolygonItem
(
polygonItem
);
return
polygonItem
;
}
void
UBGraphicsScene
::
initPolygonItem
(
UBGraphicsPolygonItem
*
polygonItem
)
void
UBGraphicsScene
::
initPolygonItem
(
UBGraphicsPolygonItem
*
polygonItem
)
{
{
QColor
colorOnDarkBG
;
QColor
colorOnDarkBG
;
...
...
src/domain/UBGraphicsScene.h
View file @
4b0a4ab3
...
@@ -149,7 +149,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -149,7 +149,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsW3CWidgetItem
*
addW3CWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsW3CWidgetItem
*
addW3CWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
void
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
void
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
...
@@ -320,10 +320,10 @@ public slots:
...
@@ -320,10 +320,10 @@ public slots:
void
setDrawingMode
(
bool
bModeDesktop
);
void
setDrawingMode
(
bool
bModeDesktop
);
void
deselectAllItems
();
void
deselectAllItems
();
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
QGraphicsItem
*
replaceFor
,
QGraphicsItem
*
replaceFor
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
qreal
scaleFactor
=
1
.
0
,
qreal
scaleFactor
=
1
.
0
,
bool
pUseAnimation
=
false
);
bool
pUseAnimation
=
false
);
void
textUndoCommandAdded
(
UBGraphicsTextItem
*
textItem
);
void
textUndoCommandAdded
(
UBGraphicsTextItem
*
textItem
);
...
@@ -346,6 +346,8 @@ public slots:
...
@@ -346,6 +346,8 @@ public slots:
protected
:
protected
:
UBGraphicsPolygonItem
*
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
UBGraphicsPolygonItem
*
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
UBGraphicsPolygonItem
*
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
);
UBGraphicsPolygonItem
*
arcToPolygonItem
(
const
QLineF
&
pStartRadius
,
qreal
pSpanAngle
,
qreal
pWidth
);
UBGraphicsPolygonItem
*
arcToPolygonItem
(
const
QLineF
&
pStartRadius
,
qreal
pSpanAngle
,
qreal
pWidth
);
void
initPolygonItem
(
UBGraphicsPolygonItem
*
);
void
initPolygonItem
(
UBGraphicsPolygonItem
*
);
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
4b0a4ab3
...
@@ -55,12 +55,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
...
@@ -55,12 +55,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
...
@@ -91,8 +89,8 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
...
@@ -91,8 +89,8 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
// It is a cludge...
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
{
{
event
->
accept
();
event
->
accept
();
...
@@ -110,13 +108,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -110,13 +108,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
{
QGraphicsItem
*
curItem
=
group
->
getCurrentItem
();
QGraphicsItem
*
curItem
=
group
->
getCurrentItem
();
if
(
curItem
&&
this
!=
curItem
)
if
(
curItem
&&
this
!=
curItem
)
{
{
group
->
deselectCurrentItem
();
group
->
deselectCurrentItem
();
}
}
group
->
setCurrentItem
(
this
);
group
->
setCurrentItem
(
this
);
this
->
setSelected
(
true
);
this
->
setSelected
(
true
);
Delegate
()
->
positionHandles
();
Delegate
()
->
positionHandles
();
}
}
}
}
else
else
...
@@ -178,8 +176,8 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -178,8 +176,8 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
// It is a cludge...
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
{
{
event
->
accept
();
event
->
accept
();
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
4b0a4ab3
...
@@ -87,14 +87,8 @@ QFont UBGraphicsTextItemDelegate::createDefaultFont()
...
@@ -87,14 +87,8 @@ QFont UBGraphicsTextItemDelegate::createDefaultFont()
textFormat
.
setFontItalic
(
true
);
textFormat
.
setFontItalic
(
true
);
QFont
font
(
fFamily
,
-
1
,
bold
?
QFont
::
Bold
:
-
1
,
italic
);
QFont
font
(
fFamily
,
-
1
,
bold
?
QFont
::
Bold
:
-
1
,
italic
);
// int pixSize = UBSettings::settings()->fontPixelSize();
// if (pixSize > 0) {
// mLastFontPixelSize = pixSize;
// font.setPixelSize(pixSize);
// }
int
pointSize
=
UBSettings
::
settings
()
->
fontPointSize
();
int
pointSize
=
UBSettings
::
settings
()
->
fontPointSize
();
if
(
pointSize
>
0
)
{
if
(
pointSize
>
0
)
{
// mLastFontPixelSize = pointSize;
font
.
setPointSize
(
pointSize
);
font
.
setPointSize
(
pointSize
);
}
}
...
@@ -227,8 +221,6 @@ void UBGraphicsTextItemDelegate::pickColor()
...
@@ -227,8 +221,6 @@ void UBGraphicsTextItemDelegate::pickColor()
{
{
QColor
selectedColor
=
colorDialog
.
selectedColor
();
QColor
selectedColor
=
colorDialog
.
selectedColor
();
delegated
()
->
setDefaultTextColor
(
selectedColor
);
delegated
()
->
setDefaultTextColor
(
selectedColor
);
// delegated()->setColorOnDarkBackground(selectedColor);
// delegated()->setColorOnLightBackground(selectedColor);
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCharFormat
format
;
QTextCharFormat
format
;
format
.
setForeground
(
QBrush
(
selectedColor
));
format
.
setForeground
(
QBrush
(
selectedColor
));
...
@@ -257,6 +249,7 @@ UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
...
@@ -257,6 +249,7 @@ UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
{
{
return
static_cast
<
UBGraphicsTextItem
*>
(
mDelegated
);
return
static_cast
<
UBGraphicsTextItem
*>
(
mDelegated
);
}
}
void
UBGraphicsTextItemDelegate
::
setEditable
(
bool
editable
)
void
UBGraphicsTextItemDelegate
::
setEditable
(
bool
editable
)
{
{
if
(
editable
)
{
if
(
editable
)
{
...
@@ -271,6 +264,7 @@ void UBGraphicsTextItemDelegate::setEditable(bool editable)
...
@@ -271,6 +264,7 @@ void UBGraphicsTextItemDelegate::setEditable(bool editable)
mDelegated
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
false
));
mDelegated
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
false
));
}
}
}
}
void
UBGraphicsTextItemDelegate
::
remove
(
bool
canUndo
)
void
UBGraphicsTextItemDelegate
::
remove
(
bool
canUndo
)
{
{
UBGraphicsItemDelegate
::
remove
(
canUndo
);
UBGraphicsItemDelegate
::
remove
(
canUndo
);
...
@@ -280,6 +274,7 @@ bool UBGraphicsTextItemDelegate::isEditable()
...
@@ -280,6 +274,7 @@ bool UBGraphicsTextItemDelegate::isEditable()
{
{
return
mDelegated
->
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
();
return
mDelegated
->
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
();
}
}
void
UBGraphicsTextItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
void
UBGraphicsTextItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
{
UBGraphicsItemDelegate
::
decorateMenu
(
menu
);
UBGraphicsItemDelegate
::
decorateMenu
(
menu
);
...
@@ -289,23 +284,25 @@ void UBGraphicsTextItemDelegate::decorateMenu(QMenu *menu)
...
@@ -289,23 +284,25 @@ void UBGraphicsTextItemDelegate::decorateMenu(QMenu *menu)
mEditableAction
->
setChecked
(
isEditable
());
mEditableAction
->
setChecked
(
isEditable
());
}
}
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
{
{
UBGraphicsItemDelegate
::
updateMenuActionState
();
UBGraphicsItemDelegate
::
updateMenuActionState
();
}
}
void
UBGraphicsTextItemDelegate
::
positionHandles
()
void
UBGraphicsTextItemDelegate
::
positionHandles
()
{
{
UBGraphicsItemDelegate
::
positionHandles
();
UBGraphicsItemDelegate
::
positionHandles
();
if
(
mDelegated
->
isSelected
()
||
(
mDelegated
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
mDelegated
->
parentItem
()
->
type
()))
if
(
mDelegated
->
isSelected
()
||
(
mDelegated
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
mDelegated
->
parentItem
()
->
type
()))
{
{
if
(
mToolBarItem
->
isVisibleOnBoard
())
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
{
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
mToolBarItem
->
setScale
(
AntiScaleRatio
);
mToolBarItem
->
setScale
(
AntiScaleRatio
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
/
AntiScaleRatio
);
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
/
AntiScaleRatio
);
mToolBarItem
->
setRect
(
toolBarRect
);
mToolBarItem
->
setRect
(
toolBarRect
);
mToolBarItem
->
positionHandles
();
mToolBarItem
->
positionHandles
();
mToolBarItem
->
update
();
mToolBarItem
->
update
();
if
(
mToolBarItem
->
isShifting
())
if
(
mToolBarItem
->
isShifting
())
...
@@ -374,9 +371,9 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
...
@@ -374,9 +371,9 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
// we search continuous blocks of the text with the same PointSize and allpy new settings for them.
// we search continuous blocks of the text with the same PointSize and allpy new settings for them.
cursor
.
setPosition
(
startPos
,
QTextCursor
::
MoveAnchor
);
cursor
.
setPosition
(
startPos
,
QTextCursor
::
MoveAnchor
);
while
(
iCursorPos
<
endPos
)
while
(
iCursorPos
<
endPos
)
{
{
bEndofTheSameBlock
=
false
;
bEndofTheSameBlock
=
false
;
iBlockLen
=
0
;
iBlockLen
=
0
;
cursor
.
setPosition
(
iCursorPos
+
1
,
QTextCursor
::
KeepAnchor
);
cursor
.
setPosition
(
iCursorPos
+
1
,
QTextCursor
::
KeepAnchor
);
iPointSize
=
cursor
.
charFormat
().
font
().
pointSize
();
iPointSize
=
cursor
.
charFormat
().
font
().
pointSize
();
...
...
src/frameworks/UBGeometryUtils.cpp
View file @
4b0a4ab3
...
@@ -81,6 +81,49 @@ QPolygonF UBGeometryUtils::lineToPolygon(const QLineF& pLine, const qreal& pWidt
...
@@ -81,6 +81,49 @@ QPolygonF UBGeometryUtils::lineToPolygon(const QLineF& pLine, const qreal& pWidt
return
painterPath
.
toFillPolygon
();
return
painterPath
.
toFillPolygon
();
}
}
QPolygonF
UBGeometryUtils
::
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
qreal
x1
=
pLine
.
x1
();
qreal
y1
=
pLine
.
y1
();
qreal
x2
=
pLine
.
x2
();
qreal
y2
=
pLine
.
y2
();
qreal
alpha
=
(
90.0
-
pLine
.
angle
())
*
PI
/
180.0
;
qreal
startHypothenuse
=
pStartWidth
/
2
;
qreal
endHypothenuse
=
pEndWidth
/
2
;
// TODO UB 4.x PERF cache sin/cos table
qreal
startOpposite
=
sin
(
alpha
)
*
startHypothenuse
;
qreal
startAdjacent
=
cos
(
alpha
)
*
startHypothenuse
;
qreal
endOpposite
=
sin
(
alpha
)
*
endHypothenuse
;
qreal
endAdjacent
=
cos
(
alpha
)
*
endHypothenuse
;
QPointF
p1a
(
x1
-
startAdjacent
,
y1
-
startOpposite
);
QPointF
p1b
(
x1
+
startAdjacent
,
y1
+
startOpposite
);
QPointF
p2a
(
x2
-
endAdjacent
,
y2
-
endOpposite
);
QPointF
p2b
(
x2
+
endAdjacent
,
y2
+
endOpposite
);
QPainterPath
painterPath
;
painterPath
.
moveTo
(
p1a
);
painterPath
.
lineTo
(
p2a
);
painterPath
.
arcTo
(
x2
-
endHypothenuse
,
y2
-
endHypothenuse
,
pEndWidth
,
pEndWidth
,
(
90.0
+
pLine
.
angle
()),
-
180.0
);
//painterPath.lineTo(p2b);
painterPath
.
lineTo
(
p1b
);
painterPath
.
arcTo
(
x1
-
startHypothenuse
,
y1
-
startHypothenuse
,
pStartWidth
,
pStartWidth
,
-
1
*
(
90.0
-
pLine
.
angle
()),
-
180.0
);
painterPath
.
closeSubpath
();
return
painterPath
.
toFillPolygon
();
}
QPolygonF
UBGeometryUtils
::
lineToPolygon
(
const
QPointF
&
pStart
,
const
QPointF
&
pEnd
,
QPolygonF
UBGeometryUtils
::
lineToPolygon
(
const
QPointF
&
pStart
,
const
QPointF
&
pEnd
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
{
...
...
src/frameworks/UBGeometryUtils.h
View file @
4b0a4ab3
...
@@ -34,6 +34,7 @@ class UBGeometryUtils
...
@@ -34,6 +34,7 @@ class UBGeometryUtils
public
:
public
:
static
QPolygonF
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QPolygonF
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QPolygonF
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
);
static
QRectF
lineToInnerRect
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QRectF
lineToInnerRect
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QPolygonF
arcToPolygon
(
const
QLineF
&
startRadius
,
qreal
spanAngle
,
qreal
width
);
static
QPolygonF
arcToPolygon
(
const
QLineF
&
startRadius
,
qreal
spanAngle
,
qreal
width
);
...
...
src/tools/UBGraphicsCurtainItemDelegate.cpp
View file @
4b0a4ab3
...
@@ -45,8 +45,7 @@ UBGraphicsCurtainItemDelegate::~UBGraphicsCurtainItemDelegate()
...
@@ -45,8 +45,7 @@ UBGraphicsCurtainItemDelegate::~UBGraphicsCurtainItemDelegate()
void
UBGraphicsCurtainItemDelegate
::
init
()
void
UBGraphicsCurtainItemDelegate
::
init
()
{
{
//UBGraphicsItemDelegate::init();
UBGraphicsItemDelegate
::
init
();
decorate
();
mFrame
->
hide
();
mFrame
->
hide
();
mZOrderUpButton
->
hide
();
mZOrderUpButton
->
hide
();
mZOrderDownButton
->
hide
();
mZOrderDownButton
->
hide
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment