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
a0a0d208
Commit
a0a0d208
authored
Mar 29, 2012
by
Ivan Ilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UBZLayerController created. Z level implementation restructured
parent
a95472cd
Changes
26
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
283 additions
and
77 deletions
+283
-77
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+63
-0
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+2
-0
UB.h
src/core/UB.h
+22
-2
UBGraphicsAudioItem.cpp
src/domain/UBGraphicsAudioItem.cpp
+2
-0
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+40
-13
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+17
-1
UBGraphicsPDFItem.cpp
src/domain/UBGraphicsPDFItem.cpp
+2
-1
UBGraphicsPixmapItem.cpp
src/domain/UBGraphicsPixmapItem.cpp
+1
-0
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+8
-0
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+2
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+64
-32
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+34
-1
UBGraphicsSvgItem.cpp
src/domain/UBGraphicsSvgItem.cpp
+2
-1
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+2
-14
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+4
-4
UBGraphicsVideoItem.cpp
src/domain/UBGraphicsVideoItem.cpp
+2
-0
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+3
-0
UBItem.h
src/domain/UBItem.h
+1
-0
UBAbstractDrawRuler.cpp
src/tools/UBAbstractDrawRuler.cpp
+1
-0
UBGraphicsCache.cpp
src/tools/UBGraphicsCache.cpp
+1
-5
UBGraphicsCache.h
src/tools/UBGraphicsCache.h
+0
-2
UBGraphicsCompass.cpp
src/tools/UBGraphicsCompass.cpp
+2
-0
UBGraphicsCurtainItem.cpp
src/tools/UBGraphicsCurtainItem.cpp
+2
-0
UBGraphicsProtractor.cpp
src/tools/UBGraphicsProtractor.cpp
+1
-0
UBGraphicsRuler.cpp
src/tools/UBGraphicsRuler.cpp
+2
-0
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+3
-1
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
a0a0d208
...
...
@@ -320,6 +320,8 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mXmlReader
.
readNext
();
if
(
mXmlReader
.
isStartElement
())
{
qreal
zFromSvg
=
getZValueFromSvg
();
if
(
mXmlReader
.
name
()
==
"svg"
)
{
if
(
!
scene
)
...
...
@@ -529,6 +531,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
pixmapItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
pixmapItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
pixmapItem
);
...
...
@@ -548,6 +553,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
svgItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
svgItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
svgItem
);
...
...
@@ -573,6 +581,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
audioItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
audioItem
,
zFromSvg
);
audioItem
->
show
();
//force start to load the video and display the first frame
...
...
@@ -593,6 +604,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
videoItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
videoItem
,
zFromSvg
);
videoItem
->
show
();
//force start to load the video and display the first frame
...
...
@@ -613,6 +627,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
textItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
textItem
,
zFromSvg
);
textItem
->
show
();
}
}
...
...
@@ -624,17 +641,27 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
scene
->
addItem
(
mask
);
scene
->
registerTool
(
mask
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
mask
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"ruler"
)
{
QString
ubZValue
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"z-value"
).
toString
();
UBGraphicsRuler
*
ruler
=
rulerFromSvg
();
ubZValue
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"z-value"
).
toString
();
if
(
ruler
)
{
scene
->
addItem
(
ruler
);
scene
->
registerTool
(
ruler
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
ruler
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"compass"
)
{
...
...
@@ -644,6 +671,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
scene
->
addItem
(
compass
);
scene
->
registerTool
(
compass
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
compass
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"protractor"
)
...
...
@@ -654,6 +684,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
scene
->
addItem
(
protractor
);
scene
->
registerTool
(
protractor
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
protractor
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"triangle"
)
...
...
@@ -664,6 +697,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
scene
->
addItem
(
triangle
);
scene
->
registerTool
(
triangle
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
triangle
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"cache"
)
...
...
@@ -674,6 +710,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
cache
);
scene
->
registerTool
(
cache
);
UBApplication
::
boardController
->
notifyCache
(
true
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
cache
,
zFromSvg
);
}
}
else
if
(
mXmlReader
.
name
()
==
"foreignObject"
)
...
...
@@ -698,6 +737,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
pdfItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
pdfItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
pdfItem
);
...
...
@@ -720,6 +762,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
appleWidgetItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
appleWidgetItem
,
zFromSvg
);
appleWidgetItem
->
show
();
currentWidget
=
appleWidgetItem
;
...
...
@@ -740,6 +785,9 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
w3cWidgetItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
w3cWidgetItem
,
zFromSvg
);
w3cWidgetItem
->
show
();
currentWidget
=
w3cWidgetItem
;
...
...
@@ -756,6 +804,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
maxObjectZIndex
=
qMax
(
textItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
textItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
textItem
,
zFromSvg
);
textItem
->
show
();
}
}
...
...
@@ -2009,6 +2061,17 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
}
}
qreal
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
getZValueFromSvg
()
{
qreal
result
=
UBZLayerController
::
errorNum
();
QStringRef
ubZValue
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"z-value"
);
if
(
!
ubZValue
.
isNull
())
{
result
=
ubZValue
.
toString
().
toFloat
();
}
return
result
;
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
graphicsItemToSvg
(
QGraphicsItem
*
item
)
{
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
a0a0d208
...
...
@@ -134,6 +134,8 @@ class UBSvgSubsetAdaptor
void
graphicsItemFromSvg
(
QGraphicsItem
*
gItem
);
qreal
getZValueFromSvg
();
QXmlStreamReader
mXmlReader
;
int
mFileVersion
;
UBDocumentProxy
*
mProxy
;
...
...
src/core/UB.h
View file @
a0a0d208
...
...
@@ -62,7 +62,7 @@ struct UBSize
};
};
// Deprecated. Keep it for backward campability with old versions
struct
UBItemLayerType
{
enum
Enum
...
...
@@ -71,17 +71,37 @@ struct UBItemLayerType
};
};
struct
itemLayerType
{
enum
Enum
{
NoLayer
=
0
,
BackgroundItem
,
ObjectItem
,
DrawingItem
,
ToolItem
,
CppTool
,
Eraiser
,
Curtain
,
Pointer
,
Cache
};
};
struct
UBGraphicsItemData
{
enum
Enum
{
ItemLayerType
ItemLayerType
//Deprecated. Keep it for backward campability with old versions. Use itemLayerType instead
,
ItemLocked
,
ItemEditable
//for text only
,
ItemOwnZValue
,
itemLayerType
//use instead of deprecated ItemLayerType
};
};
struct
UBGraphicsItemType
{
enum
Enum
...
...
src/domain/UBGraphicsAudioItem.cpp
View file @
a0a0d208
...
...
@@ -64,6 +64,8 @@ UBGraphicsAudioItem::UBGraphicsAudioItem(const QUrl& pAudioFileUrl, QGraphicsIte
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
void
UBGraphicsAudioItem
::
onStateChanged
(
Phonon
::
State
newState
,
Phonon
::
State
oldState
)
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
a0a0d208
...
...
@@ -76,18 +76,26 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItem
::
assignZValue
(
mFrame
,
UBGraphicsScene
::
toolLayerStart
+
1
);
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
);
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
);
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
);
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevel
()));
mButtons
<<
mZOrderUpButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
decreaseZLevel
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
...
...
@@ -238,10 +246,13 @@ void UBGraphicsItemDelegate::positionHandles()
mDeleteButton
->
setTransform
(
tr
);
qreal
x
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
y
=
mFrame
->
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
qreal
topX
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
topY
=
mFrame
->
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
mDeleteButton
->
setPos
(
x
,
y
);
qreal
bottomX
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
bottomY
=
mFrame
->
rect
().
bottom
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
mDeleteButton
->
setPos
(
topX
,
topY
);
if
(
!
mDeleteButton
->
scene
())
{
...
...
@@ -257,12 +268,18 @@ void UBGraphicsItemDelegate::positionHandles()
lock
(
isLocked
());
for
(
int
i
=
1
;
i
<
mButtons
.
length
();
i
++
)
{
DelegateButton
*
button
=
mButtons
[
i
];
int
i
=
1
,
j
=
0
,
k
=
0
;
while
((
i
+
j
)
<
mButtons
.
size
())
{
DelegateButton
*
button
=
mButtons
[
i
+
j
];
button
->
setTransform
(
tr
);
button
->
setPos
(
x
+
(
i
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
y
);
if
(
button
->
getSection
()
==
Qt
::
TopLeftSection
)
{
button
->
setPos
(
topX
+
(
i
++
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
topY
);
}
else
if
(
button
->
getSection
()
==
Qt
::
BottomLeftSection
)
{
button
->
setPos
(
bottomX
+
(
++
j
*
1.6
*
mFrameWidth
*
mAntiScaleRatio
),
bottomY
);
}
else
if
(
button
->
getSection
()
==
Qt
::
NoSection
)
{
++
k
;
}
if
(
!
button
->
scene
())
{
button
->
setParentItem
(
mFrame
);
//update parent for the case the item has been previously removed from scene
...
...
@@ -271,9 +288,7 @@ void UBGraphicsItemDelegate::positionHandles()
}
button
->
show
();
}
}
else
{
}
else
{
foreach
(
DelegateButton
*
button
,
mButtons
)
button
->
hide
();
...
...
@@ -316,7 +331,19 @@ void UBGraphicsItemDelegate::duplicate()
UBApplication
::
boardController
->
copy
();
UBApplication
::
boardController
->
paste
();
}
void
UBGraphicsItemDelegate
::
increaseZLevel
(
int
delta
)
{
qDebug
()
<<
delegated
()
->
scene
()
->
items
().
count
();
// UBGraphicsItem::assignZValue(delegated(), )
// int valueCandidate = delegated()->data(UBGraphicsItemData::ItemOwnZValue).toInt();
// if (delta < 0) {
// } else if (delta > 0) {
// }
}
void
UBGraphicsItemDelegate
::
lock
(
bool
locked
)
{
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
a0a0d208
...
...
@@ -33,10 +33,11 @@ class DelegateButton: public QGraphicsSvgItem
Q_OBJECT
public
:
DelegateButton
(
const
QString
&
fileName
,
QGraphicsItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
)
DelegateButton
(
const
QString
&
fileName
,
QGraphicsItem
*
pDelegated
,
QGraphicsItem
*
parent
=
0
,
Qt
::
WindowFrameSection
section
=
Qt
::
NoSection
)
:
QGraphicsSvgItem
(
fileName
,
parent
)
,
mDelegated
(
pDelegated
)
,
mIsTransparentToMouseEvent
(
false
)
,
mButtonAlignmentSection
(
section
)
{
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
...
...
@@ -57,6 +58,9 @@ class DelegateButton: public QGraphicsSvgItem
QGraphicsSvgItem
::
setSharedRenderer
(
new
QSvgRenderer
(
fileName
,
this
));
}
void
setSection
(
Qt
::
WindowFrameSection
section
)
{
mButtonAlignmentSection
=
section
;}
Qt
::
WindowFrameSection
getSection
()
const
{
return
mButtonAlignmentSection
;}
protected
:
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -80,7 +84,9 @@ class DelegateButton: public QGraphicsSvgItem
QGraphicsItem
*
mDelegated
;
bool
mIsTransparentToMouseEvent
;
Qt
::
WindowFrameSection
mButtonAlignmentSection
;
signals
:
void
clicked
(
bool
checked
=
false
);
...
...
@@ -142,6 +148,9 @@ class UBGraphicsItemDelegate : public QObject
virtual
void
lock
(
bool
lock
);
virtual
void
duplicate
();
virtual
void
increaseZLevel
()
{
increaseZLevel
(
1
);}
virtual
void
decreaseZLevel
()
{
increaseZLevel
(
-
1
);}
protected
:
virtual
void
buildButtons
()
{;}
virtual
void
decorateMenu
(
QMenu
*
menu
);
...
...
@@ -149,10 +158,15 @@ class UBGraphicsItemDelegate : public QObject
QGraphicsItem
*
mDelegated
;
//buttons from the top left section of delegate frame
DelegateButton
*
mDeleteButton
;
DelegateButton
*
mDuplicateButton
;
DelegateButton
*
mMenuButton
;
//buttons from the bottom left section of delegate frame
DelegateButton
*
mZOrderUpButton
;
DelegateButton
*
mZOrderDownButton
;
QMenu
*
mMenu
;
QAction
*
mLockAction
;
...
...
@@ -171,6 +185,8 @@ protected slots:
private
:
virtual
void
increaseZLevel
(
int
delta
);
QPointF
mOffset
;
QTransform
mPreviousTransform
;
QPointF
mPreviousPosition
;
...
...
src/domain/UBGraphicsPDFItem.cpp
View file @
a0a0d208
...
...
@@ -26,7 +26,8 @@
UBGraphicsPDFItem
::
UBGraphicsPDFItem
(
PDFRenderer
*
renderer
,
int
pageNumber
,
QGraphicsItem
*
parent
)
:
GraphicsPDFItem
(
renderer
,
pageNumber
,
parent
)
{
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
//deprecated
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
BackgroundItem
));
//Necessary to set if we want z value to be assigned correctly
mDelegate
=
new
UBGraphicsItemDelegate
(
this
,
0
);
mDelegate
->
init
();
}
...
...
src/domain/UBGraphicsPixmapItem.cpp
View file @
a0a0d208
...
...
@@ -33,6 +33,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setTransformationMode
(
Qt
::
SmoothTransformation
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
}
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
a0a0d208
...
...
@@ -30,6 +30,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (QGraphicsItem * parent)
,
mStroke
(
0
)
{
// NOOP
initialize
();
}
...
...
@@ -40,6 +41,7 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QPolygonF & polygon, QGraphi
,
mStroke
(
0
)
{
// NOOP
initialize
();
}
...
...
@@ -51,6 +53,12 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
,
mStroke
(
0
)
{
// NOOP
initialize
();
}
void
UBGraphicsPolygonItem
::
initialize
()
{
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
DrawingItem
));
//Necessary to set if we want z value to be assigned correctly
}
void
UBGraphicsPolygonItem
::
clearStroke
()
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
a0a0d208
...
...
@@ -35,6 +35,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
~
UBGraphicsPolygonItem
();
void
initialize
();
void
setColor
(
const
QColor
&
color
);
QColor
color
()
const
;
...
...
src/domain/UBGraphicsScene.cpp
View file @
a0a0d208
This diff is collapsed.
Click to expand it.
src/domain/UBGraphicsScene.h
View file @
a0a0d208
...
...
@@ -25,7 +25,6 @@
#include "UBItem.h"
#include "tools/UBGraphicsCurtainItem.h"
class
UBGraphicsPixmapItem
;
class
UBGraphicsProxyWidget
;
class
UBGraphicsSvgItem
;
...
...
@@ -50,11 +49,41 @@ class UBGraphicsCache;
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
class
UBZLayerController
{
public
:
struct
ItemLayerTypeData
{
ItemLayerTypeData
()
:
bottomLimit
(
0
),
topLimit
(
0
),
curValue
(
0
)
{;}
ItemLayerTypeData
(
qreal
bot
,
qreal
top
)
:
bottomLimit
(
bot
),
topLimit
(
top
),
curValue
(
bot
)
{;}
qreal
bottomLimit
;
qreal
topLimit
;
qreal
curValue
;
};
typedef
QMap
<
itemLayerType
::
Enum
,
ItemLayerTypeData
>
ScopeMap
;
UBZLayerController
();
qreal
getBottomLimit
(
itemLayerType
::
Enum
key
)
const
{
return
scopeMap
.
value
(
key
).
bottomLimit
;}
qreal
getTopLimit
(
itemLayerType
::
Enum
key
)
const
{
return
scopeMap
.
value
(
key
).
topLimit
;}
bool
validLayerType
(
itemLayerType
::
Enum
key
)
const
{
return
scopeMap
.
contains
(
key
);}
static
qreal
errorNum
()
{
return
errorNumber
;}
qreal
generateZLevel
(
itemLayerType
::
Enum
key
);
private
:
ScopeMap
scopeMap
;
static
qreal
errorNumber
;
};
class
UBGraphicsScene
:
public
UBCoreGraphicsScene
,
public
UBItem
{
Q_OBJECT
public
:
// tmp stub for divide addings scene objects from undo mechanism implementation
void
setURStackEnable
(
bool
set
=
true
)
{
enableUndoRedoStack
=
set
;}
...
...
@@ -323,6 +352,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
private
:
void
setDocumentUpdated
();
qreal
generateZLevel
(
QGraphicsItem
*
item
);
qreal
mDrawingZIndex
;
qreal
mObjectZIndex
;
...
...
@@ -376,7 +406,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBMagnifier
*
magniferControlViewWidget
;
UBMagnifier
*
magniferDisplayViewWidget
;
UBZLayerController
mZLayerController
;
};
#endif
/* UBGRAPHICSSCENE_H_ */
src/domain/UBGraphicsSvgItem.cpp
View file @
a0a0d208
...
...
@@ -37,7 +37,6 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* pa
}
}
UBGraphicsSvgItem
::
UBGraphicsSvgItem
(
const
QByteArray
&
pFileData
,
QGraphicsItem
*
parent
)
:
QGraphicsSvgItem
(
parent
)
{
...
...
@@ -47,6 +46,8 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QByteArray& pFileData, QGraphicsItem*
setSharedRenderer
(
renderer
);
mFileData
=
pFileData
;
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
a0a0d208
...
...
@@ -40,23 +40,11 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
mTypeTextHereLabel
=
tr
(
"<Type Text Here>"
);
// if (lastUsedTextColor.isValid())
// {
// setDefaultTextColor(lastUsedTextColor);
// setColorOnDarkBackground(lastUsedTextColor);
// setColorOnLightBackground(lastUsedTextColor);
// }
// else
// {
// QColor colorOnDarkBG = UBApplication::boardController->penColorOnDarkBackground();
// QColor colorOnLightBG = UBApplication::boardController->penColorOnLightBackground();
// setColorOnDarkBackground(colorOnDarkBG);
// setColorOnLightBackground(colorOnLightBG);
// }
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
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// setFlag(QGraphicsItem::ItemIsMovable, true);
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
a0a0d208
...
...
@@ -96,10 +96,10 @@ void UBGraphicsTextItemDelegate::buildButtons()
{
UBGraphicsItemDelegate
::
buildButtons
();
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
mFrame
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
mFrame
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
mFrame
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
mFrame
);
mFontButton
=
new
DelegateButton
(
":/images/font.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mColorButton
=
new
DelegateButton
(
":/images/color.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mDecreaseSizeButton
=
new
DelegateButton
(
":/images/minus.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mIncreaseSizeButton
=
new
DelegateButton
(
":/images/plus.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mFontButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickFont
()));
connect
(
mColorButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
pickColor
()));
...
...
src/domain/UBGraphicsVideoItem.cpp
View file @
a0a0d208
...
...
@@ -51,6 +51,8 @@ UBGraphicsVideoItem::UBGraphicsVideoItem(const QUrl& pVideoFileUrl, QGraphicsIte
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
connect
(
mDelegate
,
SIGNAL
(
showOnDisplayChanged
(
bool
)),
this
,
SLOT
(
showOnDisplayChanged
(
bool
)));
connect
(
mMediaObject
,
SIGNAL
(
hasVideoChanged
(
bool
)),
this
,
SLOT
(
hasVideoChanged
(
bool
)));
}
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
a0a0d208
...
...
@@ -39,6 +39,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(QGraphicsItem *parent, int widgetType
UBGraphicsWidgetItemDelegate
*
delegate
=
new
UBGraphicsWidgetItemDelegate
(
this
,
widgetType
);
delegate
->
init
();
setDelegate
(
delegate
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
...
...
@@ -154,6 +155,8 @@ void UBGraphicsWidgetItem::initialize()
if
(
mDelegate
&&
mDelegate
->
frame
()
&&
mWebKitWidget
->
resizable
())
mDelegate
->
frame
()
->
setOperationMode
(
UBGraphicsDelegateFrame
::
Resizing
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
...
...
src/domain/UBItem.h
View file @
a0a0d208
...
...
@@ -17,6 +17,7 @@
#include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
#include "core/UB.h"
class
UBGraphicsScene
;
...
...
src/tools/UBAbstractDrawRuler.cpp
View file @
a0a0d208
...
...
@@ -48,6 +48,7 @@ UBAbstractDrawRuler::UBAbstractDrawRuler()
QDesktopWidget
*
desktop
=
UBApplication
::
desktop
();
int
dpiCommon
=
(
desktop
->
physicalDpiX
()
+
desktop
->
physicalDpiY
())
/
2
;
sPixelsPerMillimeter
=
qRound
(
dpiCommon
/
25.4
f
);
//because 1inch = 25.4 mm
}
void
UBAbstractDrawRuler
::
create
(
QGraphicsItem
&
item
)
...
...
src/tools/UBGraphicsCache.cpp
View file @
a0a0d208
...
...
@@ -33,14 +33,12 @@ UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
// Get the board size and pass it to the shape
QRect
boardRect
=
UBApplication
::
boardController
->
displayView
()
->
rect
();
setRect
(
-
15
*
boardRect
.
width
(),
-
15
*
boardRect
.
height
(),
30
*
boardRect
.
width
(),
30
*
boardRect
.
height
());
// setZValue(CACHE_ZVALUE);
UBGraphicsItem
::
assignZValue
(
this
,
CACHE_ZVALUE
);
setData
(
Qt
::
UserRole
,
QVariant
(
"Cache"
));
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
Cache
));
//Necessary to set if we want z value to be assigned correctly
}
UBGraphicsCache
::~
UBGraphicsCache
()
{
}
UBItem
*
UBGraphicsCache
::
deepCopy
()
const
...
...
@@ -92,8 +90,6 @@ void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
UBGraphicsItem
::
assignZValue
(
this
,
CACHE_ZVALUE
);
painter
->
setBrush
(
mMaskColor
);
painter
->
setPen
(
mMaskColor
);
...
...
src/tools/UBGraphicsCache.h
View file @
a0a0d208
...
...
@@ -21,8 +21,6 @@
#include "domain/UBItem.h"
#include "core/UB.h"
#define CACHE_ZVALUE 100000
typedef
enum
{
eMaskShape_Circle
,
...
...
src/tools/UBGraphicsCompass.cpp
View file @
a0a0d208
...
...
@@ -70,6 +70,8 @@ UBGraphicsCompass::UBGraphicsCompass()
unsetCursor
();
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
CppTool
));
//Necessary to set if we want z value to be assigned correctly
connect
(
UBApplication
::
boardController
,
SIGNAL
(
penColorChanged
()),
this
,
SLOT
(
penColorChanged
()));
connect
(
UBDrawingController
::
drawingController
(),
SIGNAL
(
lineWidthIndexChanged
(
int
)),
this
,
SLOT
(
lineWidthChanged
()));
}
...
...
src/tools/UBGraphicsCurtainItem.cpp
View file @
a0a0d208
...
...
@@ -49,6 +49,8 @@ UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Tool
);
setPen
(
Qt
::
NoPen
);
this
->
setAcceptHoverEvents
(
true
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
Curtain
));
//Necessary to set if we want z value to be assigned correctly
}
UBGraphicsCurtainItem
::~
UBGraphicsCurtainItem
()
...
...
src/tools/UBGraphicsProtractor.cpp
View file @
a0a0d208
...
...
@@ -63,6 +63,7 @@ UBGraphicsProtractor::UBGraphicsProtractor()
mRotateSvgItem
->
setVisible
(
false
);
mRotateSvgItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
CppTool
));
//Necessary to set if we want z value to be assigned correctly
scale
(
1.5
,
1.5
);
}
...
...
src/tools/UBGraphicsRuler.cpp
View file @
a0a0d208
...
...
@@ -44,6 +44,8 @@ UBGraphicsRuler::UBGraphicsRuler()
create
(
*
this
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
CppTool
));
//Necessary to set if we want z value to be assigned correctly
updateResizeCursor
();
}
...
...
src/tools/UBGraphicsTriangle.cpp
View file @
a0a0d208
...
...
@@ -43,8 +43,8 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mHFlipSvgItem
=
new
QGraphicsSvgItem
(
":/images/hflipTool.svg"
,
this
);
mHFlipSvgItem
->
setVisible
(
false
);
mHFlipSvgItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
mHFlipSvgItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
mVFlipSvgItem
=
new
QGraphicsSvgItem
(
":/images/vflipTool.svg"
,
this
);
mVFlipSvgItem
->
setVisible
(
false
);
...
...
@@ -54,6 +54,8 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mRotateSvgItem
->
setVisible
(
false
);
mRotateSvgItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
CppTool
));
//Necessary to set if we want z value to be assigned correctly
updateResizeCursor
();
}
...
...
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