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
f16c06f9
Commit
f16c06f9
authored
Apr 05, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backup
parent
0dd72f68
Changes
43
Hide whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
1034 additions
and
821 deletions
+1034
-821
UBExportCFF.cpp
src/adaptors/UBExportCFF.cpp
+60
-0
UBExportCFF.h
src/adaptors/UBExportCFF.h
+39
-0
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+66
-41
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+2
-0
adaptors.pri
src/adaptors/adaptors.pri
+2
-0
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-4
UBBoardView.cpp
src/board/UBBoardView.cpp
+3
-1
UB.h
src/core/UB.h
+23
-2
UBApplication.cpp
src/core/UBApplication.cpp
+1
-2
UBApplicationController.cpp
src/core/UBApplicationController.cpp
+11
-10
UBApplicationController.h
src/core/UBApplicationController.h
+1
-1
UBDisplayManager.cpp
src/core/UBDisplayManager.cpp
+5
-17
UBDisplayManager.h
src/core/UBDisplayManager.h
+5
-5
UBDocumentManager.cpp
src/core/UBDocumentManager.cpp
+3
-0
UBPreferencesController.cpp
src/core/UBPreferencesController.cpp
+1
-1
UBDesktopAnnotationController.cpp
src/desktop/UBDesktopAnnotationController.cpp
+1
-0
UBGraphicsAudioItem.cpp
src/domain/UBGraphicsAudioItem.cpp
+2
-2
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+40
-27
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+17
-1
UBGraphicsPDFItem.cpp
src/domain/UBGraphicsPDFItem.cpp
+2
-5
UBGraphicsPixmapItem.cpp
src/domain/UBGraphicsPixmapItem.cpp
+1
-2
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+8
-3
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+2
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+166
-136
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+43
-24
UBGraphicsSvgItem.cpp
src/domain/UBGraphicsSvgItem.cpp
+2
-5
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+2
-16
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+4
-4
UBGraphicsVideoItem.cpp
src/domain/UBGraphicsVideoItem.cpp
+2
-2
UBGraphicsVideoItemDelegate.cpp
src/domain/UBGraphicsVideoItemDelegate.cpp
+2
-2
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+3
-1
UBItem.h
src/domain/UBItem.h
+1
-0
UBMagnifer.cpp
src/gui/UBMagnifer.cpp
+402
-388
UBMagnifer.h
src/gui/UBMagnifer.h
+97
-96
UBAbstractDrawRuler.cpp
src/tools/UBAbstractDrawRuler.cpp
+1
-0
UBGraphicsCache.cpp
src/tools/UBGraphicsCache.cpp
+1
-7
UBGraphicsCache.h
src/tools/UBGraphicsCache.h
+0
-2
UBGraphicsCompass.cpp
src/tools/UBGraphicsCompass.cpp
+2
-2
UBGraphicsCurtainItem.cpp
src/tools/UBGraphicsCurtainItem.cpp
+2
-4
UBGraphicsCurtainItemDelegate.cpp
src/tools/UBGraphicsCurtainItemDelegate.cpp
+0
-1
UBGraphicsProtractor.cpp
src/tools/UBGraphicsProtractor.cpp
+1
-2
UBGraphicsRuler.cpp
src/tools/UBGraphicsRuler.cpp
+2
-2
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+3
-3
No files found.
src/adaptors/UBExportCFF.cpp
0 → 100644
View file @
f16c06f9
#include "UBExportCFF.h"
#include "UBCFFAdaptor.h"
#include "document/UBDocumentProxy.h"
#include "core/UBDocumentManager.h"
#include "core/UBApplication.h"
UBExportCFF
::
UBExportCFF
(
QObject
*
parent
)
:
UBExportAdaptor
(
parent
)
{
}
UBExportCFF
::~
UBExportCFF
()
{
}
QString
UBExportCFF
::
exportName
()
{
return
tr
(
"Export to IWB"
);
}
QString
UBExportCFF
::
exportExtention
()
{
return
QString
(
".iwb"
);
}
void
UBExportCFF
::
persist
(
UBDocumentProxy
*
pDocument
)
{
QString
src
=
pDocument
->
persistencePath
();
if
(
!
pDocument
)
return
;
QString
filename
=
askForFileName
(
pDocument
,
tr
(
"Export as IWB File"
));
if
(
filename
.
length
()
>
0
)
{
QApplication
::
setOverrideCursor
(
QCursor
(
Qt
::
WaitCursor
));
if
(
mIsVerbose
)
UBApplication
::
showMessage
(
tr
(
"Exporting document..."
));
UBCFFAdaptor
toIWBExporter
;
if
(
toIWBExporter
.
convertUBZToIWB
(
src
,
filename
))
{
if
(
mIsVerbose
)
UBApplication
::
showMessage
(
tr
(
"Export successful."
));
}
else
if
(
mIsVerbose
)
UBApplication
::
showMessage
(
tr
(
"Export failed."
));
QApplication
::
restoreOverrideCursor
();
}
}
\ No newline at end of file
src/adaptors/UBExportCFF.h
0 → 100644
View file @
f16c06f9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBExportCFF_H_
#define UBExportCFF_H_
#include <QtCore>
#include "UBExportAdaptor.h"
#include "frameworks/UBFileSystemUtils.h"
class
UBDocumentProxy
;
class
UBExportCFF
:
public
UBExportAdaptor
{
Q_OBJECT
;
public
:
UBExportCFF
(
QObject
*
parent
=
0
);
virtual
~
UBExportCFF
();
virtual
QString
exportName
();
virtual
QString
exportExtention
();
virtual
void
persist
(
UBDocumentProxy
*
pDocument
);
};
#endif
/* UBExportCFF_H_ */
\ No newline at end of file
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
f16c06f9
...
...
@@ -306,9 +306,6 @@ UBSvgSubsetAdaptor::UBSvgSubsetReader::UBSvgSubsetReader(UBDocumentProxy* pProxy
UBGraphicsScene
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
loadScene
()
{
UBGraphicsScene
*
scene
=
0
;
qreal
maxDrawingZIndex
=
0
;
qreal
maxObjectZIndex
=
0
;
UBGraphicsWidgetItem
*
currentWidget
=
0
;
mFileVersion
=
40100
;
// default to 4.1.0
...
...
@@ -320,6 +317,8 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mXmlReader
.
readNext
();
if
(
mXmlReader
.
isStartElement
())
{
qreal
zFromSvg
=
getZValueFromSvg
();
if
(
mXmlReader
.
name
()
==
"svg"
)
{
if
(
!
scene
)
...
...
@@ -479,7 +478,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
polygonItem
);
polygonItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Graphic
));
maxDrawingZIndex
=
qMax
(
polygonItem
->
zValue
(),
maxDrawingZIndex
);
polygonItem
->
show
();
}
...
...
@@ -499,8 +497,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
addItem
(
polygonItem
);
polygonItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Graphic
));
maxDrawingZIndex
=
qMax
(
polygonItem
->
zValue
(),
maxDrawingZIndex
);
polygonItem
->
show
();
}
}
...
...
@@ -525,10 +521,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
pixmapItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
pixmapItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
pixmapItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
pixmapItem
);
...
...
@@ -544,10 +541,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
svgItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
svgItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
svgItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
svgItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
svgItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
svgItem
);
...
...
@@ -569,10 +567,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
audioItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
audioItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
audioItem
,
zFromSvg
);
audioItem
->
show
();
//force start to load the video and display the first frame
...
...
@@ -589,10 +588,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
videoItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
videoItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
videoItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
videoItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
videoItem
,
zFromSvg
);
videoItem
->
show
();
//force start to load the video and display the first frame
...
...
@@ -609,10 +609,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
textItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
textItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
textItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
textItem
,
zFromSvg
);
textItem
->
show
();
}
}
...
...
@@ -624,17 +625,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 +655,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 +668,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 +681,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 +694,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"
)
...
...
@@ -694,10 +717,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
pdfItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
pdfItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
pdfItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
pdfItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
pdfItem
,
zFromSvg
);
if
(
isBackground
)
scene
->
setAsBackgroundObject
(
pdfItem
);
...
...
@@ -716,10 +740,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
appleWidgetItem
->
resize
(
foreignObjectWidth
,
foreignObjectHeight
);
maxObjectZIndex
=
qMax
(
appleWidgetItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
appleWidgetItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
appleWidgetItem
,
zFromSvg
);
appleWidgetItem
->
show
();
currentWidget
=
appleWidgetItem
;
...
...
@@ -736,10 +761,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
w3cWidgetItem
->
resize
(
foreignObjectWidth
,
foreignObjectHeight
);
maxObjectZIndex
=
qMax
(
w3cWidgetItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
w3cWidgetItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
w3cWidgetItem
,
zFromSvg
);
w3cWidgetItem
->
show
();
currentWidget
=
w3cWidgetItem
;
...
...
@@ -754,8 +780,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
textItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
textItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
maxObjectZIndex
=
qMax
(
textItem
->
zValue
(),
maxObjectZIndex
);
scene
->
addItem
(
textItem
);
if
(
zFromSvg
!=
UBZLayerController
::
errorNum
())
UBGraphicsItem
::
assignZValue
(
textItem
,
zFromSvg
);
textItem
->
show
();
}
}
...
...
@@ -804,17 +833,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
qWarning
()
<<
"error parsing Sankore file "
<<
mXmlReader
.
errorString
();
}
if
(
scene
)
{
scene
->
setObjectZIndex
(
maxObjectZIndex
);
scene
->
setDrawingZIndex
(
maxDrawingZIndex
);
if
(
scene
)
{
scene
->
setModified
(
false
);
}
if
(
annotationGroup
)
{
if
(
annotationGroup
->
polygons
().
empty
())
delete
annotationGroup
;
if
(
annotationGroup
->
polygons
().
empty
())
delete
annotationGroup
;
}
return
scene
;
...
...
@@ -1348,12 +1374,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if
(
!
ubZValue
.
isNull
())
{
// polygonItem->setZValue (ubZValue.toString().toFloat());
UBGraphicsItem
::
assignZValue
(
polygonItem
,
ubZValue
.
toString
().
toFloat
());
}
else
{
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem
::
assignZValue
(
polygonItem
,
mGroupZIndex
);
}
...
...
@@ -1457,12 +1481,10 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
if
(
!
ubZValue
.
isNull
())
{
// polygonItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem
::
assignZValue
(
polygonItem
,
ubZValue
.
toString
().
toFloat
());
}
else
{
// polygonItem->setZValue(mGroupZIndex);
UBGraphicsItem
::
assignZValue
(
polygonItem
,
mGroupZIndex
);
}
...
...
@@ -1611,7 +1633,6 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
{
UBGraphicsPolygonItem
*
polygonItem
=
new
UBGraphicsPolygonItem
(
QLineF
(
points
.
at
(
i
),
points
.
at
(
i
+
1
)),
lineWidth
);
polygonItem
->
setColor
(
brushColor
);
// polygonItem->setZValue(zValue);
UBGraphicsItem
::
assignZValue
(
polygonItem
,
zValue
);
polygonItem
->
setColorOnDarkBackground
(
colorOnDarkBackground
);
polygonItem
->
setColorOnLightBackground
(
colorOnLightBackground
);
...
...
@@ -1956,7 +1977,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
if
(
!
ubZValue
.
isNull
())
{
// gItem->setZValue(ubZValue.toString().toFloat());
UBGraphicsItem
::
assignZValue
(
gItem
,
ubZValue
.
toString
().
toFloat
());
}
...
...
@@ -2009,6 +2029,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
)
{
...
...
@@ -2528,7 +2559,6 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
graphicsItemFromSvg
(
ruler
);
// ruler->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
UBGraphicsItem
::
assignZValue
(
ruler
,
UBGraphicsScene
::
toolLayerStart
+
UBGraphicsScene
::
toolOffsetRuler
);
ruler
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
...
...
@@ -2587,7 +2617,6 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg()
graphicsItemFromSvg
(
compass
);
//compass->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
UBGraphicsItem
::
assignZValue
(
compass
,
UBGraphicsScene
::
toolLayerStart
+
UBGraphicsScene
::
toolOffsetCompass
);
compass
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
...
...
@@ -2652,7 +2681,6 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
{
UBGraphicsProtractor
*
protractor
=
new
UBGraphicsProtractor
();
// protractor->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
UBGraphicsItem
::
assignZValue
(
protractor
,
UBGraphicsScene
::
toolLayerStart
+
UBGraphicsScene
::
toolOffsetProtractor
);
protractor
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
...
...
@@ -2723,7 +2751,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
{
UBGraphicsTriangle
*
triangle
=
new
UBGraphicsTriangle
();
// triangle->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
UBGraphicsItem
::
assignZValue
(
triangle
,
UBGraphicsScene
::
toolLayerStart
+
UBGraphicsScene
::
toolOffsetTriangle
);
triangle
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
...
...
@@ -2750,8 +2777,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsCache
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
cacheFromSvg
()
{
UBGraphicsCache
*
pCache
=
new
UBGraphicsCache
();
pCache
->
setZValue
(
UBGraphicsScene
::
toolLayerStart
+
UBGraphicsScene
::
toolOffsetCache
);
// UBGraphicsItem::assignZValue(pCache, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
pCache
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
graphicsItemFromSvg
(
pCache
);
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
f16c06f9
...
...
@@ -134,6 +134,8 @@ class UBSvgSubsetAdaptor
void
graphicsItemFromSvg
(
QGraphicsItem
*
gItem
);
qreal
getZValueFromSvg
();
QXmlStreamReader
mXmlReader
;
int
mFileVersion
;
UBDocumentProxy
*
mProxy
;
...
...
src/adaptors/adaptors.pri
View file @
f16c06f9
...
...
@@ -14,6 +14,7 @@ HEADERS += src/adaptors/UBExportAdaptor.h\
src/adaptors/UBExportWeb.h \
src/adaptors/UBWebPublisher.h \
src/adaptors/UBImportCFF.h \
src/adaptors/UBExportCFF.h \
src/adaptors/UBCFFSubsetAdaptor.h
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \
...
...
@@ -36,6 +37,7 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\
src/adaptors/UBExportWeb.cpp \
src/adaptors/UBWebPublisher.cpp \
src/adaptors/UBImportCFF.cpp \
src/adaptors/UBExportCFF.cpp \
src/adaptors/UBCFFSubsetAdaptor.cpp \
src/adaptors/publishing/UBDocumentPublisher.cpp
...
...
src/board/UBBoardController.cpp
View file @
f16c06f9
...
...
@@ -664,6 +664,7 @@ void UBBoardController::zoom(const qreal ratio, QPointF scenePoint)
UBApplication
::
applicationController
->
adjustDisplayView
();
emit
controlViewportChanged
();
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
}
...
...
@@ -1163,7 +1164,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mControlView
->
setScene
(
mActiveScene
);
mDisplayView
->
setScene
(
mActiveScene
);
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
pDocumentProxy
->
setDefaultDocumentSize
(
mActiveScene
->
nominalSize
());
updatePageSizeState
();
...
...
@@ -1564,7 +1565,7 @@ void UBBoardController::updateSystemScaleFactor()
mControlView
->
setTransform
(
scalingTransform
);
mControlView
->
horizontalScrollBar
()
->
setValue
(
viewState
.
horizontalPosition
);
mControlView
->
verticalScrollBar
()
->
setValue
(
viewState
.
verticalPostition
);
}
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
}
void
UBBoardController
::
setWidePageSize
(
bool
checked
)
...
...
@@ -1943,8 +1944,6 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if
(
gi
)
{
// gi->setZValue(mActiveScene->getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
gi
,
mActiveScene
->
getNextObjectZIndex
());
mActiveScene
->
addItem
(
gi
);
gi
->
setPos
(
gi
->
pos
()
+
QPointF
(
50
,
50
));
}
...
...
src/board/UBBoardView.cpp
View file @
f16c06f9
...
...
@@ -54,6 +54,7 @@
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
#include "core/memcheck.h"
...
...
@@ -425,7 +426,8 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
||
movingItem
->
type
()
==
UBGraphicsCompass
::
Type
||
movingItem
->
type
()
==
UBGraphicsPDFItem
::
Type
||
movingItem
->
type
()
==
UBGraphicsPolygonItem
::
Type
||
movingItem
->
type
()
==
UBGraphicsCache
::
Type
)
||
movingItem
->
type
()
==
UBGraphicsCache
::
Type
||
movingItem
->
type
()
==
UBGraphicsTriangle
::
Type
)
{
movingItem
=
NULL
;
QGraphicsView
::
mousePressEvent
(
event
);
...
...
src/core/UB.h
View file @
f16c06f9
...
...
@@ -62,7 +62,7 @@ struct UBSize
};
};
// Deprecated. Keep it for backward campability with old versions
struct
UBItemLayerType
{
enum
Enum
...
...
@@ -71,17 +71,38 @@ struct UBItemLayerType
};
};
struct
itemLayerType
{
enum
Enum
{
NoLayer
=
0
,
BackgroundItem
,
ObjectItem
,
DrawingItem
,
ToolItem
,
CppTool
,
Eraiser
,
Curtain
,
Pointer
,
Cache
,
SelectedItem
};
};
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/core/UBApplication.cpp
View file @
f16c06f9
...
...
@@ -289,7 +289,6 @@ int UBApplication::exec(const QString& pFileToImport)
bool
bUseMultiScreen
=
UBSettings
::
settings
()
->
appUseMultiscreen
->
get
().
toBool
();
mainWindow
->
actionMultiScreen
->
setChecked
(
bUseMultiScreen
);
applicationController
->
useMultiScreen
(
bUseMultiScreen
);
connect
(
mainWindow
->
actionMultiScreen
,
SIGNAL
(
triggered
(
bool
)),
applicationController
,
SLOT
(
useMultiScreen
(
bool
)));
connect
(
mainWindow
->
actionWidePageSize
,
SIGNAL
(
triggered
(
bool
)),
boardController
,
SLOT
(
setWidePageSize
(
bool
)));
connect
(
mainWindow
->
actionRegularPageSize
,
SIGNAL
(
triggered
(
bool
)),
boardController
,
SLOT
(
setRegularPageSize
(
bool
)));
...
...
@@ -299,7 +298,7 @@ int UBApplication::exec(const QString& pFileToImport)
connect
(
mainWindow
->
actionCopy
,
SIGNAL
(
triggered
()),
applicationController
,
SLOT
(
actionCopy
()));
connect
(
mainWindow
->
actionPaste
,
SIGNAL
(
triggered
()),
applicationController
,
SLOT
(
actionPaste
()));
applicationController
->
initScreenLayout
();
applicationController
->
initScreenLayout
(
bUseMultiScreen
);
boardController
->
setupLayout
();
if
(
pFileToImport
.
length
()
>
0
)
...
...
src/core/UBApplicationController.cpp
View file @
f16c06f9
...
...
@@ -135,14 +135,15 @@ void UBApplicationController::initViewState(int horizontalPosition, int vertical
}
void
UBApplicationController
::
initScreenLayout
()
void
UBApplicationController
::
initScreenLayout
(
bool
useMultiscreen
)
{
mDisplayManager
->
set
AsControl
(
mMainWindow
,
true
);
mDisplayManager
->
set
AsDisplay
(
mDisplayView
);
mDisplayManager
->
set
ControlWidget
(
mMainWindow
);
mDisplayManager
->
set
DisplayWidget
(
mDisplayView
);
mDisplayManager
->
set
AsPreviousDisplay
s
(
mPreviousViews
);
mDisplayManager
->
set
AsDesktop
(
mUninoteController
->
drawingView
());
mDisplayManager
->
set
PreviousDisplaysWidget
s
(
mPreviousViews
);
mDisplayManager
->
set
DesktopWidget
(
mUninoteController
->
drawingView
());
mDisplayManager
->
setUseMultiScreen
(
useMultiscreen
);
mDisplayManager
->
adjustScreens
(
-
1
);
}
...
...
@@ -343,7 +344,6 @@ void UBApplicationController::showBoard()
mirroringEnabled
(
false
);
mMainWindow
->
switchToBoardWidget
();
mDisplayManager
->
setAsDisplay
(
mDisplayView
);
if
(
UBApplication
::
boardController
)
UBApplication
::
boardController
->
show
();
...
...
@@ -353,7 +353,7 @@ void UBApplicationController::showBoard()
mUninoteController
->
hideWindow
();
m
DisplayManager
->
adjustScreens
(
0
);
m
MainWindow
->
show
(
);
emit
mainModeChanged
(
Board
);
...
...
@@ -637,12 +637,12 @@ void UBApplicationController::mirroringEnabled(bool enabled)
if
(
enabled
)
{
mMirror
->
start
();
mDisplayManager
->
set
AsDisplay
(
mMirror
);
mDisplayManager
->
set
DisplayWidget
(
mMirror
);
}
else
{
mDisplayManager
->
set
AsDisplay
(
mDisplayView
);
mDisplayManager
->
set
DisplayWidget
(
mDisplayView
);
mMirror
->
stop
();
}
...
...
@@ -652,7 +652,7 @@ void UBApplicationController::mirroringEnabled(bool enabled)
}
else
{
mDisplayManager
->
set
AsDisplay
(
mDisplayView
);
mDisplayManager
->
set
DisplayWidget
(
mDisplayView
);
}
}
...
...
@@ -727,6 +727,7 @@ void UBApplicationController::importFile(const QString& pFilePath)
void
UBApplicationController
::
useMultiScreen
(
bool
use
)
{
mDisplayManager
->
setUseMultiScreen
(
use
);
mDisplayManager
->
adjustScreens
(
0
);
UBSettings
::
settings
()
->
appUseMultiscreen
->
set
(
use
);
}
...
...
src/core/UBApplicationController.h
View file @
f16c06f9
...
...
@@ -51,7 +51,7 @@ class UBApplicationController : public QObject
void
blackout
();
void
initScreenLayout
();
void
initScreenLayout
(
bool
useMultiscreen
);
void
closing
();
...
...
src/core/UBDisplayManager.cpp
View file @
f16c06f9
...
...
@@ -118,16 +118,11 @@ int UBDisplayManager::numPreviousViews()
}
void
UBDisplayManager
::
set
AsControl
(
QWidget
*
pControlWidget
,
bool
ini
t
)
void
UBDisplayManager
::
set
ControlWidget
(
QWidget
*
pControlWidge
t
)
{
if
(
hasControl
()
&&
pControlWidget
&&
(
pControlWidget
!=
mControlWidget
))
{
mControlWidget
=
pControlWidget
;
mControlWidget
->
hide
();
mControlWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mControlScreenIndex
));
if
(
!
init
)
mControlWidget
->
showFullScreen
();
// !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC
// mControlWidget->setAttribute(Qt::WA_MacNoShadow);
...
...
@@ -135,14 +130,11 @@ void UBDisplayManager::setAsControl(QWidget* pControlWidget, bool init)
}
}
void
UBDisplayManager
::
set
AsDesktop
(
QWidget
*
pControlWidget
)
void
UBDisplayManager
::
set
DesktopWidget
(
QWidget
*
pControlWidget
)
{
if
(
pControlWidget
&&
(
pControlWidget
!=
mControlWidget
))
{
mDesktopWidget
=
pControlWidget
;
mDesktopWidget
->
hide
();
mDesktopWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mControlScreenIndex
));
// mDisplayWidget->showFullScreen();
// !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC
// mControlWidget->setAttribute(Qt::WA_MacNoShadow);
...
...
@@ -150,14 +142,11 @@ void UBDisplayManager::setAsDesktop(QWidget* pControlWidget )
}
}
void
UBDisplayManager
::
set
AsDisplay
(
QWidget
*
pDisplayWidget
)
void
UBDisplayManager
::
set
DisplayWidget
(
QWidget
*
pDisplayWidget
)
{
if
(
pDisplayWidget
&&
(
pDisplayWidget
!=
mDisplayWidget
))
{
mDisplayWidget
=
pDisplayWidget
;
mDisplayWidget
->
hide
();
mDisplayWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mDisplayScreenIndex
));
mDisplayWidget
->
showFullScreen
();
// !!!! Should be included into Windows after QT recompilation
#ifdef Q_WS_MAC
// mDisplayWidget->setAttribute(Qt::WA_MacNoShadow);
...
...
@@ -166,7 +155,7 @@ void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget)
}
void
UBDisplayManager
::
set
AsPreviousDisplay
s
(
QList
<
UBBoardView
*>
pPreviousViews
)
void
UBDisplayManager
::
set
PreviousDisplaysWidget
s
(
QList
<
UBBoardView
*>
pPreviousViews
)
{
mPreviousDisplayWidgets
=
pPreviousViews
;
}
...
...
@@ -182,7 +171,7 @@ QRect UBDisplayManager::displayGeometry()
return
mDesktop
->
screenGeometry
(
mDisplayScreenIndex
);
}
void
UBDisplayManager
::
swap
Screens
(
bool
swap
)
void
UBDisplayManager
::
reinit
Screens
(
bool
swap
)
{
Q_UNUSED
(
swap
);
adjustScreens
(
-
1
);
...
...
@@ -310,6 +299,5 @@ void UBDisplayManager::setRoleToScreen(DisplayRole role, int screenIndex)
void
UBDisplayManager
::
setUseMultiScreen
(
bool
pUse
)
{
mUseMultiScreen
=
pUse
;
adjustScreens
(
0
);
}
src/core/UBDisplayManager.h
View file @
f16c06f9
...
...
@@ -33,13 +33,13 @@ class UBDisplayManager : public QObject
int
numPreviousViews
();
void
set
AsControl
(
QWidget
*
pControlWidget
,
bool
init
=
false
);
void
set
ControlWidget
(
QWidget
*
pControlWidget
);
void
set
AsDisplay
(
QWidget
*
pDisplayWidget
);
void
set
DisplayWidget
(
QWidget
*
pDisplayWidget
);
void
set
AsDesktop
(
QWidget
*
pControlWidget
);
void
set
DesktopWidget
(
QWidget
*
pControlWidget
);
void
set
AsPreviousDisplay
s
(
QList
<
UBBoardView
*>
pPreviousViews
);
void
set
PreviousDisplaysWidget
s
(
QList
<
UBBoardView
*>
pPreviousViews
);
bool
hasControl
()
{
...
...
@@ -77,7 +77,7 @@ class UBDisplayManager : public QObject
public
slots
:
void
swap
Screens
(
bool
bswap
);
void
reinit
Screens
(
bool
bswap
);
void
adjustScreens
(
int
screen
);
...
...
src/core/UBDocumentManager.cpp
View file @
f16c06f9
...
...
@@ -21,6 +21,7 @@
#include "adaptors/UBExportFullPDF.h"
#include "adaptors/UBExportDocument.h"
#include "adaptors/UBExportWeb.h"
#include "adaptors/UBExportCFF.h"
#include "adaptors/UBWebPublisher.h"
#include "adaptors/UBImportDocument.h"
#include "adaptors/UBImportPDF.h"
...
...
@@ -62,6 +63,8 @@ UBDocumentManager::UBDocumentManager(QObject *parent)
QString
dummyObjects
=
tr
(
"objects"
);
QString
dummyWidgets
=
tr
(
"widgets"
);
UBExportCFF
*
cffExporter
=
new
UBExportCFF
(
this
);
mExportAdaptors
.
append
(
cffExporter
);
UBExportFullPDF
*
exportFullPdf
=
new
UBExportFullPDF
(
this
);
mExportAdaptors
.
append
(
exportFullPdf
);
UBExportDocument
*
exportDocument
=
new
UBExportDocument
(
this
);
...
...
src/core/UBPreferencesController.cpp
View file @
f16c06f9
...
...
@@ -118,7 +118,7 @@ void UBPreferencesController::wire()
connect
(
mPreferencesUI
->
useExternalBrowserCheckBox
,
SIGNAL
(
clicked
(
bool
)),
settings
->
webUseExternalBrowser
,
SLOT
(
setBool
(
bool
)));
connect
(
mPreferencesUI
->
displayBrowserPageCheckBox
,
SIGNAL
(
clicked
(
bool
)),
settings
->
webShowPageImmediatelyOnMirroredScreen
,
SLOT
(
setBool
(
bool
)));
connect
(
mPreferencesUI
->
swapControlAndDisplayScreensCheckBox
,
SIGNAL
(
clicked
(
bool
)),
settings
->
swapControlAndDisplayScreens
,
SLOT
(
setBool
(
bool
)));
connect
(
mPreferencesUI
->
swapControlAndDisplayScreensCheckBox
,
SIGNAL
(
clicked
(
bool
)),
UBApplication
::
applicationController
->
displayManager
(),
SLOT
(
swap
Screens
(
bool
)));
connect
(
mPreferencesUI
->
swapControlAndDisplayScreensCheckBox
,
SIGNAL
(
clicked
(
bool
)),
UBApplication
::
applicationController
->
displayManager
(),
SLOT
(
reinit
Screens
(
bool
)));
connect
(
mPreferencesUI
->
toolbarAtTopRadioButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toolbarPositionChanged
(
bool
)));
connect
(
mPreferencesUI
->
toolbarAtBottomRadioButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
toolbarPositionChanged
(
bool
)));
...
...
src/desktop/UBDesktopAnnotationController.cpp
View file @
f16c06f9
...
...
@@ -88,6 +88,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene
=
new
UBGraphicsScene
(
0
);
mTransparentDrawingView
->
setScene
(
mTransparentDrawingScene
);
mTransparentDrawingScene
->
setDrawingMode
(
true
);
// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView);
//mRightPalette = new UBRightPalette(mTransparentDrawingView);
...
...
src/domain/UBGraphicsAudioItem.cpp
View file @
f16c06f9
...
...
@@ -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
)
...
...
@@ -95,8 +97,6 @@ UBItem* UBGraphicsAudioItem::deepCopy() const
UBGraphicsAudioItem
*
copy
=
new
UBGraphicsAudioItem
(
audioUrl
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
f16c06f9
...
...
@@ -73,29 +73,33 @@ void UBGraphicsItemDelegate::init()
{
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
// mFrame->setZValue(UBGraphicsScene::toolLayerStart + 1);
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
)
{
button
->
hide
();
// button->setZValue(UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem
::
assignZValue
(
button
,
UBGraphicsScene
::
toolLayerStart
+
2
);
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
...
...
@@ -160,18 +164,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
if
(
!
mDelegated
->
isSelected
())
{
mDelegated
->
setSelected
(
true
);
UBGraphicsScene
*
scene
=
static_cast
<
UBGraphicsScene
*>
(
mDelegated
->
scene
());
qDebug
()
<<
mDelegated
->
zValue
();
qDebug
()
<<
scene
->
currentObjectZIndex
();
// To investigate. Z value behavior
// if (mDelegated->zValue() < scene->currentObjectZIndex() && !isLocked())
// mDelegated->setZValue(scene->getNextObjectZIndex());
positionHandles
();
return
true
;
}
else
...
...
@@ -239,12 +234,13 @@ void UBGraphicsItemDelegate::positionHandles()
mDeleteButton
->
setTransform
(
tr
);
qreal
topX
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
topY
=
mFrame
->
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
// This is where the position of the buttons is calculated. It starts always on the topleft of mFrame!
qreal
x
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
y
=
mFrame
->
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
qreal
bottomX
=
mFrame
->
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiScaleRatio
/
2
;
qreal
bottomY
=
mFrame
->
rect
().
bottom
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiScaleRatio
/
2
;
mDeleteButton
->
setPos
(
x
,
y
);
mDeleteButton
->
setPos
(
topX
,
topY
);
if
(
!
mDeleteButton
->
scene
())
{
...
...
@@ -262,13 +258,19 @@ 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
())
{
...
...
@@ -278,11 +280,10 @@ void UBGraphicsItemDelegate::positionHandles()
}
if
(
!
mFrame
->
isResizing
()){
button
->
show
();
button
->
setZValue
(
delegated
()
->
zValue
());
}
}
}
else
{
}
else
{
foreach
(
DelegateButton
*
button
,
mButtons
)
button
->
hide
();
...
...
@@ -325,7 +326,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 @
f16c06f9
...
...
@@ -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
::
TopLeftSection
)
:
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
);
...
...
@@ -147,6 +153,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
);
...
...
@@ -154,10 +163,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
;
...
...
@@ -176,6 +190,8 @@ protected slots:
private
:
virtual
void
increaseZLevel
(
int
delta
);
QPointF
mOffset
;
QTransform
mPreviousTransform
;
QPointF
mPreviousPosition
;
...
...
src/domain/UBGraphicsPDFItem.cpp
View file @
f16c06f9
...
...
@@ -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
();
}
...
...
@@ -84,8 +85,6 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
UBGraphicsPDFItem
*
copy
=
new
UBGraphicsPDFItem
(
mRenderer
,
mPageNumber
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
@@ -135,8 +134,6 @@ UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
pixmapItem
->
setPixmap
(
pixmap
);
pixmapItem
->
setPos
(
this
->
pos
());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
pixmapItem
,
this
->
zValue
());
pixmapItem
->
setTransform
(
this
->
transform
());
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsPixmapItem.cpp
View file @
f16c06f9
...
...
@@ -37,6 +37,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
);
}
...
...
@@ -102,8 +103,6 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
copy
->
setPixmap
(
this
->
pixmap
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
f16c06f9
...
...
@@ -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
()
...
...
@@ -153,9 +161,6 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
copy
->
setPen
(
this
->
pen
());
copy
->
mHasAlpha
=
this
->
mHasAlpha
;
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setColorOnDarkBackground
(
this
->
colorOnDarkBackground
());
copy
->
setColorOnLightBackground
(
this
->
colorOnLightBackground
());
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
f16c06f9
...
...
@@ -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 @
f16c06f9
...
...
@@ -61,8 +61,6 @@
#include "core/memcheck.h"
qreal
UBGraphicsScene
::
backgroundLayerStart
=
-
20000000.0
;
qreal
UBGraphicsScene
::
objectLayerStart
=
-
10000000.0
;
qreal
UBGraphicsScene
::
drawingLayerStart
=
0.0
;
qreal
UBGraphicsScene
::
toolLayerStart
=
10000000.0
;
...
...
@@ -77,6 +75,47 @@ qreal UBGraphicsScene::toolOffsetPointer = 1100;
qreal
UBGraphicsScene
::
toolOffsetCache
=
1000
;
//Didier please define offset you want
qreal
UBZLayerController
::
errorNumber
=
-
20000001.0
;
UBZLayerController
::
UBZLayerController
()
{
scopeMap
.
insert
(
itemLayerType
::
NoLayer
,
ItemLayerTypeData
(
errorNumber
,
errorNumber
));
scopeMap
.
insert
(
itemLayerType
::
BackgroundItem
,
ItemLayerTypeData
(
-
10000000.0
,
-
10000000.0
));
scopeMap
.
insert
(
itemLayerType
::
ObjectItem
,
ItemLayerTypeData
(
-
10000000.0
,
0.0
));
scopeMap
.
insert
(
itemLayerType
::
DrawingItem
,
ItemLayerTypeData
(
0.0
,
10000000.0
));
scopeMap
.
insert
(
itemLayerType
::
ToolItem
,
ItemLayerTypeData
(
10000000.0
,
10000100.0
));
scopeMap
.
insert
(
itemLayerType
::
CppTool
,
ItemLayerTypeData
(
10000100.0
,
10000200.0
));
scopeMap
.
insert
(
itemLayerType
::
Curtain
,
ItemLayerTypeData
(
10000200.0
,
10001000.0
));
scopeMap
.
insert
(
itemLayerType
::
Eraiser
,
ItemLayerTypeData
(
10001000.0
,
10001100.0
));
scopeMap
.
insert
(
itemLayerType
::
Pointer
,
ItemLayerTypeData
(
10001100.0
,
10001200.0
));
scopeMap
.
insert
(
itemLayerType
::
Cache
,
ItemLayerTypeData
(
10001300.0
,
10001400.0
));
scopeMap
.
insert
(
itemLayerType
::
SelectedItem
,
ItemLayerTypeData
(
10001000.0
,
10001000.0
));
}
qreal
UBZLayerController
::
generateZLevel
(
itemLayerType
::
Enum
key
)
{
if
(
!
scopeMap
.
contains
(
key
))
{
qDebug
()
<<
"Number is out of layer scope"
;
return
errorNumber
;
}
qreal
result
=
scopeMap
.
value
(
key
).
curValue
;
qreal
top
=
scopeMap
.
value
(
key
).
topLimit
;
result
++
;
if
(
result
>=
top
)
{
qDebug
()
<<
"new values are over for the scope"
<<
key
;
result
=
top
-
1
;
}
scopeMap
[
key
].
curValue
=
result
;
return
result
;
}
UBGraphicsScene
::
UBGraphicsScene
(
UBDocumentProxy
*
parent
)
:
UBCoreGraphicsScene
(
parent
)
,
mEraser
(
0
)
...
...
@@ -96,6 +135,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
,
enableUndoRedoStack
(
true
)
,
magniferControlViewWidget
(
0
)
,
magniferDisplayViewWidget
(
0
)
,
mIsDesktopMode
(
false
)
{
...
...
@@ -106,32 +146,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
#endif
setDocument
(
parent
);
mDrawingZIndex
=
drawingLayerStart
;
mObjectZIndex
=
objectLayerStart
;
mEraser
=
new
QGraphicsEllipseItem
();
// mem : owned and destroyed by the scene
mEraser
->
setRect
(
QRect
(
0
,
0
,
0
,
0
));
mEraser
->
setVisible
(
false
);
mEraser
->
setZValue
(
/*toolLayerStart + toolOffsetEraser*/
2
);
mEraser
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
mTools
<<
mEraser
;
addItem
(
mEraser
);
mPointer
=
new
QGraphicsEllipseItem
();
// mem : owned and destroyed by the scene
mPointer
->
setRect
(
QRect
(
0
,
0
,
20
,
20
));
mPointer
->
setVisible
(
false
);
mPointer
->
setPen
(
Qt
::
NoPen
);
mPointer
->
setBrush
(
QBrush
(
QColor
(
255
,
0
,
0
,
186
)));
mPointer
->
setZValue
(
/*toolLayerStart + toolOffsetPointer*/
2
);
mPointer
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
mTools
<<
mPointer
;
addItem
(
mPointer
);
createEraiser
();
createPointer
();
if
(
UBApplication
::
applicationController
)
{
...
...
@@ -145,8 +161,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene
::~
UBGraphicsScene
()
{
DisposeMagnifierQWidgets
();
if
(
mCurrentStroke
)
if
(
mCurrentStroke
->
polygons
().
empty
())
delete
mCurrentStroke
;
...
...
@@ -155,27 +169,18 @@ UBGraphicsScene::~UBGraphicsScene()
void
UBGraphicsScene
::
selectionChangedProcessing
()
{
if
(
selectedItems
().
count
())
UBApplication
::
showMessage
(
"ZValue is "
+
QString
::
number
(
selectedItems
().
first
()
->
zValue
(),
'f'
)
);
UBApplication
::
showMessage
(
"ZValue is "
+
QString
::
number
(
selectedItems
().
first
()
->
zValue
(),
'f'
)
+
"own z value is "
+
QString
::
number
(
selectedItems
().
first
()
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
(),
'f'
));
QList
<
QGraphicsItem
*>
allItemsList
=
items
();
qreal
maxZ
=
0.
;
for
(
int
i
=
0
;
i
<
allItemsList
.
size
();
i
++
)
{
QGraphicsItem
*
nextItem
=
allItemsList
.
at
(
i
);
//Temporary stub. Due to ugly z-order implementation I need to do this (sankore 360)
//z-order behavior should be reimplemented and this stub should be deleted
if
(
nextItem
==
mBackgroundObject
)
continue
;
//Temporary stub end (sankore 360)
if
(
nextItem
->
zValue
()
>
maxZ
)
maxZ
=
nextItem
->
zValue
();
nextItem
->
setZValue
(
nextItem
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
// nextItem->setZValue(qreal(1));
}
QList
<
QGraphicsItem
*>
selItemsList
=
selectedItems
();
for
(
int
i
=
0
;
i
<
selItemsList
.
size
();
i
++
)
{
QGraphicsItem
*
nextItem
=
selItemsList
.
at
(
i
);
nextItem
->
setZValue
(
maxZ
+
0.0001
);
if
(
nextItem
->
isSelected
())
{
nextItem
->
setZValue
(
mZLayerController
.
generateZLevel
(
itemLayerType
::
SelectedItem
));
}
else
{
nextItem
->
setZValue
(
nextItem
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
}
}
}
...
...
@@ -404,25 +409,11 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool isFirstDraw)
qreal
eraserRadius
=
eraserWidth
/
2
;
// TODO UB 4.x optimize - no need to do that every time we move it
if
(
mEraser
)
{
if
(
mEraser
)
{
mEraser
->
setRect
(
QRectF
(
pPoint
.
x
()
-
eraserRadius
,
pPoint
.
y
()
-
eraserRadius
,
eraserWidth
,
eraserWidth
));
if
(
isFirstDraw
)
{
qreal
maxZ
=
0.
;
QList
<
QGraphicsItem
*>
allItemsList
=
items
();
for
(
int
i
=
0
;
i
<
allItemsList
.
size
();
i
++
)
{
QGraphicsItem
*
nextItem
=
allItemsList
.
at
(
i
);
qreal
zValue
=
nextItem
->
zValue
();
if
(
zValue
>
maxZ
)
maxZ
=
zValue
;
nextItem
->
setZValue
(
nextItem
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
}
mEraser
->
setZValue
(
maxZ
+
0.0001
);
mEraser
->
show
();
if
(
isFirstDraw
)
{
mEraser
->
show
();
}
}
}
...
...
@@ -433,27 +424,12 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw)
qreal
pointerRadius
=
pointerDiameter
/
2
;
// TODO UB 4.x optimize - no need to do that every time we move it
if
(
mPointer
)
{
if
(
mPointer
)
{
mPointer
->
setRect
(
QRectF
(
pPoint
.
x
()
-
pointerRadius
,
pPoint
.
y
()
-
pointerRadius
,
pointerDiameter
,
pointerDiameter
));
if
(
isFirstDraw
)
{
qreal
maxZ
=
0.
;
QList
<
QGraphicsItem
*>
allItemsList
=
items
();
for
(
int
i
=
0
;
i
<
allItemsList
.
size
();
i
++
)
{
QGraphicsItem
*
nextItem
=
allItemsList
.
at
(
i
);
qreal
zValue
=
nextItem
->
zValue
();
if
(
zValue
>
maxZ
)
maxZ
=
zValue
;
nextItem
->
setZValue
(
nextItem
->
data
(
UBGraphicsItemData
::
ItemOwnZValue
).
toReal
());
}
mPointer
->
setZValue
(
maxZ
+
0.0001
);
pPoint
.
y
()
-
pointerRadius
,
pointerDiameter
,
pointerDiameter
));
if
(
isFirstDraw
)
{
mPointer
->
show
();
}
}
...
...
@@ -690,21 +666,6 @@ void UBGraphicsScene::drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle)
setDocumentUpdated
();
}
qreal
UBGraphicsScene
::
getNextDrawingZIndex
()
{
mDrawingZIndex
=
mDrawingZIndex
+
1.0
;
return
mDrawingZIndex
;
}
qreal
UBGraphicsScene
::
getNextObjectZIndex
()
{
mObjectZIndex
=
mObjectZIndex
+
1.0
;
return
mObjectZIndex
;
}
void
UBGraphicsScene
::
setBackground
(
bool
pIsDark
,
bool
pIsCrossed
)
{
bool
needRepaint
=
false
;
...
...
@@ -749,6 +710,15 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
}
}
void
UBGraphicsScene
::
setBackgroundZoomFactor
(
qreal
zoom
)
{
mZoomFactor
=
zoom
;
}
void
UBGraphicsScene
::
setDrawingMode
(
bool
bModeDesktop
)
{
mIsDesktopMode
=
bModeDesktop
;
}
void
UBGraphicsScene
::
recolorAllItems
()
{
...
...
@@ -827,9 +797,6 @@ void UBGraphicsScene::initPolygonItem(UBGraphicsPolygonItem* polygonItem)
polygonItem
->
setColorOnLightBackground
(
colorOnLightBG
);
polygonItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Graphic
));
// polygonItem->setZValue(getNextDrawingZIndex());
UBGraphicsItem
::
assignZValue
(
polygonItem
,
getNextDrawingZIndex
());
}
...
...
@@ -870,9 +837,6 @@ UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
UBGraphicsScene
*
copy
=
new
UBGraphicsScene
(
this
->
document
());
copy
->
setBackground
(
this
->
isDarkBackground
(),
this
->
isCrossedBackground
());
copy
->
mDrawingZIndex
=
this
->
mDrawingZIndex
;
copy
->
mObjectZIndex
=
this
->
mObjectZIndex
;
copy
->
setSceneRect
(
this
->
sceneRect
());
if
(
this
->
mNominalSize
.
isValid
())
...
...
@@ -1050,8 +1014,6 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, const Q
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// pixmapItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
pixmapItem
,
getNextObjectZIndex
());
pixmapItem
->
setPixmap
(
pPixmap
);
...
...
@@ -1103,8 +1065,6 @@ UBGraphicsVideoItem* UBGraphicsScene::addVideo(const QUrl& pVideoFileUrl, bool s
videoItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
videoItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// videoItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
videoItem
,
getNextObjectZIndex
());
addItem
(
videoItem
);
...
...
@@ -1136,8 +1096,6 @@ UBGraphicsAudioItem* UBGraphicsScene::addAudio(const QUrl& pAudioFileUrl, bool s
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
audioItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// audioItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
audioItem
,
getNextObjectZIndex
());
addItem
(
audioItem
);
...
...
@@ -1204,8 +1162,6 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addW3CWidget(const QUrl& pWidgetUrl, c
void
UBGraphicsScene
::
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
)
{
graphicsWidget
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// graphicsWidget->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
graphicsWidget
,
getNextObjectZIndex
());
addItem
(
graphicsWidget
);
...
...
@@ -1267,8 +1223,6 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
svgItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
svgItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// svgItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
svgItem
,
getNextObjectZIndex
());
qreal
sscale
=
1
/
UBApplication
::
boardController
->
systemScaleFactor
();
svgItem
->
scale
(
sscale
,
sscale
);
...
...
@@ -1303,8 +1257,6 @@ UBGraphicsTextItem* UBGraphicsScene::addTextWithFont(const QString& pString, con
{
UBGraphicsTextItem
*
textItem
=
new
UBGraphicsTextItem
();
textItem
->
setPlainText
(
pString
);
// textItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
textItem
,
getNextObjectZIndex
());
QFont
font
=
textItem
->
font
();
...
...
@@ -1361,8 +1313,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
UBGraphicsTextItem
*
textItem
=
new
UBGraphicsTextItem
();
textItem
->
setPlainText
(
""
);
textItem
->
setHtml
(
pString
);
// textItem->setZValue(getNextObjectZIndex());
UBGraphicsItem
::
assignZValue
(
textItem
,
getNextObjectZIndex
());
addItem
(
textItem
);
textItem
->
show
();
...
...
@@ -1388,6 +1338,8 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
setModified
(
true
);
UBCoreGraphicsScene
::
addItem
(
item
);
UBGraphicsItem
::
assignZValue
(
item
,
generateZLevel
(
item
));
if
(
!
mTools
.
contains
(
item
))
++
mItemCount
;
...
...
@@ -1398,8 +1350,10 @@ void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
{
setModified
(
true
);
foreach
(
QGraphicsItem
*
item
,
items
)
foreach
(
QGraphicsItem
*
item
,
items
)
{
UBCoreGraphicsScene
::
addItem
(
item
);
UBGraphicsItem
::
assignZValue
(
item
,
generateZLevel
(
item
));
}
mItemCount
+=
items
.
size
();
...
...
@@ -1460,8 +1414,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool
item
->
setAcceptedMouseButtons
(
Qt
::
NoButton
);
item
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
FixedBackground
);
// item->setZValue(backgroundLayerStart);
UBGraphicsItem
::
assignZValue
(
item
,
backgroundLayerStart
);
UBGraphicsItem
::
assignZValue
(
item
,
mZLayerController
.
generateZLevel
(
itemLayerType
::
BackgroundItem
));
if
(
pAdaptTransformation
)
{
...
...
@@ -1565,9 +1518,6 @@ void UBGraphicsScene::addRuler(QPointF center)
QRectF
rect
=
ruler
->
rect
();
ruler
->
setRect
(
center
.
x
()
-
rect
.
width
()
/
2
,
center
.
y
()
-
rect
.
height
()
/
2
,
rect
.
width
(),
rect
.
height
());
// ruler->setZValue(toolLayerStart + toolOffsetRuler);
UBGraphicsItem
::
assignZValue
(
ruler
,
toolLayerStart
+
toolOffsetRuler
);
ruler
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
addItem
(
ruler
);
...
...
@@ -1584,9 +1534,6 @@ void UBGraphicsScene::addProtractor(QPointF center)
UBGraphicsProtractor
*
protractor
=
new
UBGraphicsProtractor
();
// mem : owned and destroyed by the scene
mTools
<<
protractor
;
// protractor->setZValue(toolLayerStart + toolOffsetProtractor);
UBGraphicsItem
::
assignZValue
(
protractor
,
toolLayerStart
+
toolOffsetProtractor
);
protractor
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
addItem
(
protractor
);
...
...
@@ -1605,9 +1552,6 @@ void UBGraphicsScene::addTriangle(QPointF center)
UBGraphicsTriangle
*
triangle
=
new
UBGraphicsTriangle
();
// mem : owned and destroyed by the scene
mTools
<<
triangle
;
// triangle->setZValue(toolLayerStart + toolOffsetProtractor);
UBGraphicsItem
::
assignZValue
(
triangle
,
toolLayerStart
+
toolOffsetTriangle
);
triangle
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
addItem
(
triangle
);
...
...
@@ -1738,9 +1682,6 @@ void UBGraphicsScene::addCompass(QPointF center)
QRectF
rect
=
compass
->
rect
();
compass
->
setRect
(
center
.
x
()
-
rect
.
width
()
/
2
,
center
.
y
()
-
rect
.
height
()
/
2
,
rect
.
width
(),
rect
.
height
());
// compass->setZValue(toolLayerStart + toolOffsetCompass);
UBGraphicsItem
::
assignZValue
(
compass
,
toolLayerStart
+
toolOffsetCompass
);
compass
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
compass
->
setVisible
(
true
);
...
...
@@ -1772,8 +1713,6 @@ void UBGraphicsScene::addMask(const QPointF ¢er)
QRectF
rect
=
UBApplication
::
boardController
->
activeScene
()
->
normalizedSceneRect
();
rect
.
setRect
(
center
.
x
()
-
rect
.
width
()
/
4
,
center
.
y
()
-
rect
.
height
()
/
4
,
rect
.
width
()
/
2
,
rect
.
height
()
/
2
);
curtain
->
setRect
(
rect
);
UBGraphicsItem
::
assignZValue
(
curtain
,
toolLayerStart
+
toolOffsetCurtain
);
curtain
->
setVisible
(
true
);
curtain
->
setSelected
(
true
);
setModified
(
true
);
...
...
@@ -1923,6 +1862,58 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
}
}
void
UBGraphicsScene
::
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
)
{
if
(
mIsDesktopMode
)
{
QGraphicsScene
::
drawBackground
(
painter
,
rect
);
return
;
}
bool
darkBackground
=
isDarkBackground
();
if
(
darkBackground
)
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
black
)));
}
else
{
painter
->
fillRect
(
rect
,
QBrush
(
QColor
(
Qt
::
white
)));
}
if
(
mZoomFactor
>
0.5
)
{
QColor
bgCrossColor
;
if
(
darkBackground
)
bgCrossColor
=
UBSettings
::
crossDarkBackground
;
else
bgCrossColor
=
UBSettings
::
crossLightBackground
;
if
(
mZoomFactor
<
1.0
)
{
int
alpha
=
255
*
mZoomFactor
/
2
;
bgCrossColor
.
setAlpha
(
alpha
);
// fade the crossing on small zooms
}
painter
->
setPen
(
bgCrossColor
);
if
(
isCrossedBackground
())
{
qreal
firstY
=
((
int
)
(
rect
.
y
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
yPos
=
firstY
;
yPos
<
rect
.
y
()
+
rect
.
height
();
yPos
+=
UBSettings
::
crossSize
)
{
painter
->
drawLine
(
rect
.
x
(),
yPos
,
rect
.
x
()
+
rect
.
width
(),
yPos
);
}
qreal
firstX
=
((
int
)
(
rect
.
x
()
/
UBSettings
::
crossSize
))
*
UBSettings
::
crossSize
;
for
(
qreal
xPos
=
firstX
;
xPos
<
rect
.
x
()
+
rect
.
width
();
xPos
+=
UBSettings
::
crossSize
)
{
painter
->
drawLine
(
xPos
,
rect
.
y
(),
xPos
,
rect
.
y
()
+
rect
.
height
());
}
}
}
}
void
UBGraphicsScene
::
keyReleaseEvent
(
QKeyEvent
*
keyEvent
)
{
...
...
@@ -1991,7 +1982,46 @@ void UBGraphicsScene::setDocumentUpdated()
document
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
}
void
UBGraphicsScene
::
createEraiser
()
{
mEraser
=
new
QGraphicsEllipseItem
();
// mem : owned and destroyed by the scene
mEraser
->
setRect
(
QRect
(
0
,
0
,
0
,
0
));
mEraser
->
setVisible
(
false
);
mEraser
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
mEraser
->
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
Eraiser
));
//Necessary to set if we want z value to be assigned correctly
mTools
<<
mEraser
;
addItem
(
mEraser
);
}
void
UBGraphicsScene
::
createPointer
()
{
mPointer
=
new
QGraphicsEllipseItem
();
// mem : owned and destroyed by the scene
mPointer
->
setRect
(
QRect
(
0
,
0
,
20
,
20
));
mPointer
->
setVisible
(
false
);
mPointer
->
setPen
(
Qt
::
NoPen
);
mPointer
->
setBrush
(
QBrush
(
QColor
(
255
,
0
,
0
,
186
)));
mPointer
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Tool
));
mPointer
->
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
Pointer
));
//Necessary to set if we want z value to be assigned correctly
mTools
<<
mPointer
;
addItem
(
mPointer
);
}
qreal
UBGraphicsScene
::
generateZLevel
(
QGraphicsItem
*
item
)
{
qreal
result
=
UBZLayerController
::
errorNum
();
itemLayerType
::
Enum
type
=
static_cast
<
itemLayerType
::
Enum
>
(
item
->
data
(
UBGraphicsItemData
::
itemLayerType
).
toInt
());
if
(
mZLayerController
.
validLayerType
(
type
))
{
result
=
mZLayerController
.
generateZLevel
(
type
);
}
return
result
;
}
void
UBGraphicsScene
::
setToolCursor
(
int
tool
)
{
...
...
src/domain/UBGraphicsScene.h
View file @
f16c06f9
...
...
@@ -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
;}
...
...
@@ -152,23 +181,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return
mCrossedBackground
;
}
void
setDrawingZIndex
(
qreal
pDrawingZIndex
)
{
mDrawingZIndex
=
pDrawingZIndex
;
}
void
setObjectZIndex
(
qreal
pObjectZIndex
)
{
mObjectZIndex
=
pObjectZIndex
;
}
bool
hasBackground
()
{
return
(
mBackgroundObject
!=
0
);
}
qreal
getNextObjectZIndex
();
void
addRuler
(
QPointF
center
);
void
addProtractor
(
QPointF
center
);
void
addCompass
(
QPointF
center
);
...
...
@@ -225,11 +242,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
setNominalSize
(
int
pWidth
,
int
pHeight
);
qreal
currentObjectZIndex
()
{
return
mObjectZIndex
;
}
enum
RenderingContext
{
Screen
=
0
,
NonScreen
,
PdfExport
,
Podcast
...
...
@@ -276,7 +288,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
hideEraser
();
void
setBackground
(
bool
pIsDark
,
bool
pIsCrossed
);
void
setBackgroundZoomFactor
(
qreal
zoom
);
void
setDrawingMode
(
bool
bModeDesktop
);
void
deselectAllItems
();
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
qreal
scaleFactor
=
1
.
0
,
bool
pUseAnimation
=
false
);
...
...
@@ -314,18 +327,19 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void
recolorAllItems
();
qreal
getNextDrawingZIndex
();
virtual
void
drawItems
(
QPainter
*
painter
,
int
numItems
,
virtual
void
drawItems
(
QPainter
*
painter
,
int
numItems
,
QGraphicsItem
*
items
[],
const
QStyleOptionGraphicsItem
options
[],
QWidget
*
widget
=
0
);
QGraphicsItem
*
rootItem
(
QGraphicsItem
*
item
)
const
;
virtual
void
drawBackground
(
QPainter
*
painter
,
const
QRectF
&
rect
);
private
:
void
setDocumentUpdated
();
void
createEraiser
();
void
createPointer
();
qreal
mDrawingZIndex
;
qreal
mObjectZIndex
;
qreal
generateZLevel
(
QGraphicsItem
*
item
);
QGraphicsEllipseItem
*
mEraser
;
QGraphicsEllipseItem
*
mPointer
;
...
...
@@ -337,6 +351,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool
mDarkBackground
;
bool
mCrossedBackground
;
bool
mIsDesktopMode
;
qreal
mZoomFactor
;
bool
mIsModified
;
...
...
@@ -376,7 +392,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBMagnifier
*
magniferControlViewWidget
;
UBMagnifier
*
magniferDisplayViewWidget
;
UBZLayerController
mZLayerController
;
};
#endif
/* UBGRAPHICSSCENE_H_ */
src/domain/UBGraphicsSvgItem.cpp
View file @
f16c06f9
...
...
@@ -37,7 +37,6 @@ UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* pa
}
}
UBGraphicsSvgItem
::
UBGraphicsSvgItem
(
const
QByteArray
&
pFileData
,
QGraphicsItem
*
parent
)
:
QGraphicsSvgItem
(
parent
)
{
...
...
@@ -61,6 +60,8 @@ void UBGraphicsSvgItem::init()
setCacheMode
(
QGraphicsItem
::
DeviceCoordinateCache
);
setMaximumCacheSize
(
boundingRect
().
size
().
toSize
()
*
UB_MAX_ZOOM
);
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
}
...
...
@@ -132,8 +133,6 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
UBGraphicsSvgItem
*
copy
=
new
UBGraphicsSvgItem
(
this
->
fileData
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
@@ -187,8 +186,6 @@ UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
pixmapItem
->
setPixmap
(
QPixmap
::
fromImage
(
image
));
pixmapItem
->
setPos
(
this
->
pos
());
// pixmapItem->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
pixmapItem
,
this
->
zValue
());
pixmapItem
->
setTransform
(
this
->
transform
());
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
pixmapItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
f16c06f9
...
...
@@ -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);
...
...
@@ -205,8 +193,6 @@ UBItem* UBGraphicsTextItem::deepCopy() const
copy
->
setHtml
(
toHtml
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
f16c06f9
...
...
@@ -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 @
f16c06f9
...
...
@@ -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
)));
}
...
...
@@ -68,8 +70,6 @@ UBItem* UBGraphicsVideoItem::deepCopy() const
UBGraphicsVideoItem
*
copy
=
new
UBGraphicsVideoItem
(
videoUrl
,
parentItem
());
copy
->
setPos
(
this
->
pos
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBGraphicsVideoItemDelegate.cpp
View file @
f16c06f9
...
...
@@ -52,8 +52,7 @@ void UBGraphicsVideoItemDelegate::buildButtons()
mMuteButton
->
hide
();
mVideoControl
=
new
DelegateVideoControl
(
delegated
(),
mFrame
);
// mVideoControl->setZValue(UBGraphicsScene::toolLayerStart + 2);
UBGraphicsItem
::
assignZValue
(
mVideoControl
,
UBGraphicsScene
::
toolLayerStart
+
2
);
UBGraphicsItem
::
assignZValue
(
mVideoControl
,
delegated
()
->
zValue
());
mVideoControl
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
connect
(
mPlayPauseButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
togglePlayPause
()));
...
...
@@ -106,6 +105,7 @@ void UBGraphicsVideoItemDelegate::positionHandles()
}
mVideoControl
->
setAntiScale
(
mAntiScaleRatio
);
mVideoControl
->
setZValue
(
delegated
()
->
zValue
());
mVideoControl
->
show
();
}
else
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
f16c06f9
...
...
@@ -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
}
...
...
@@ -408,7 +411,6 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
UBGraphicsW3CWidgetItem
*
copy
=
new
UBGraphicsW3CWidgetItem
(
mWebKitWidget
->
widgetUrl
(),
parentItem
());
copy
->
setPos
(
this
->
pos
());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/domain/UBItem.h
View file @
f16c06f9
...
...
@@ -17,6 +17,7 @@
#include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
#include "core/UB.h"
class
UBGraphicsScene
;
...
...
src/gui/UBMagnifer.cpp
View file @
f16c06f9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include "UBMagnifer.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
#include "core/memcheck.h"
UBMagnifier
::
UBMagnifier
(
QWidget
*
parent
,
bool
isInteractive
)
:
QWidget
(
parent
,
parent
?
Qt
::
Widget
:
Qt
::
Tool
|
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
|
Qt
::
X11BypassWindowManagerHint
))
,
mShouldMoveWidget
(
false
)
,
mShouldResizeWidget
(
false
)
,
inTimer
(
false
)
,
borderPen
(
Qt
::
darkGray
)
,
gView
(
0
)
,
mView
(
0
)
{
isCusrsorAlreadyStored
=
false
;
setMouseTracking
(
true
);
//--------------------------------------------------//
QPixmap
pix
(
":/images/cursors/resize.png"
);
QTransform
tr
;
tr
.
rotate
(
45
);
mResizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
//--------------------------------------------------//
params
.
sizePercentFromScene
=
20
;
m_isInteractive
=
isInteractive
;
sClosePixmap
=
new
QPixmap
(
":/images/close.svg"
);
sIncreasePixmap
=
new
QPixmap
(
":/images/increase.svg"
);
sDecreasePixmap
=
new
QPixmap
(
":/images/decrease.svg"
);
mResizeItem
=
new
QPixmap
(
":/images/resize.svg"
);
if
(
parent
)
{
setAttribute
(
Qt
::
WA_NoMousePropagation
);
}
else
{
// standalone window
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
// setAttribute(Qt::WA_TranslucentBackground);
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
#endif
#ifdef Q_WS_MAC
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
setAttribute
(
Qt
::
WA_MacNonActivatingToolWindow
);
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
}
UBMagnifier
::~
UBMagnifier
()
{
if
(
timerUpdate
!=
0
)
{
killTimer
(
timerUpdate
);
timerUpdate
=
0
;
}
if
(
sClosePixmap
)
{
delete
sClosePixmap
;
sClosePixmap
=
NULL
;
}
if
(
sIncreasePixmap
)
{
delete
sIncreasePixmap
;
sIncreasePixmap
=
NULL
;
}
if
(
sDecreasePixmap
)
{
delete
sDecreasePixmap
;
sDecreasePixmap
=
NULL
;
}
}
void
UBMagnifier
::
setSize
(
qreal
percentFromScene
)
{
if
(
gView
==
NULL
||
mView
==
NULL
)
return
;
// calculate object size
params
.
sizePercentFromScene
=
percentFromScene
;
QSize
sceneSize
=
mView
->
size
();
qreal
size
=
params
.
sizePercentFromScene
*
sceneSize
.
width
()
/
100
;
QRect
currGeom
=
geometry
();
if
(
currGeom
.
width
()
==
currGeom
.
height
())
{
QPoint
newPos
=
mView
->
mapFromGlobal
(
updPointMove
);
setGeometry
(
newPos
.
x
()
-
size
/
2
,
newPos
.
y
()
-
size
/
2
,
size
,
size
);
}
else
setGeometry
(
0
,
0
,
size
,
size
);
// prepare transparent bit mask
QImage
mask_img
(
width
(),
height
(),
QImage
::
Format_Mono
);
mask_img
.
fill
(
0xff
);
QPainter
mask_ptr
(
&
mask_img
);
mask_ptr
.
setBrush
(
QBrush
(
QColor
(
0
,
0
,
0
)
)
);
mask_ptr
.
drawEllipse
(
QPointF
(
size
/
2
,
size
/
2
),
size
/
2
-
sClosePixmap
->
width
(),
size
/
2
-
sClosePixmap
->
width
());
bmpMask
=
QBitmap
::
fromImage
(
mask_img
);
// prepare general image
pMap
=
QPixmap
(
width
(),
height
());
pMap
.
fill
(
Qt
::
transparent
);
pMap
.
setMask
(
bmpMask
);
}
void
UBMagnifier
::
setZoom
(
qreal
zoom
)
{
params
.
zoom
=
zoom
;
}
void
UBMagnifier
::
paintEvent
(
QPaintEvent
*
event
)
{
Q_UNUSED
(
event
);
QPainter
painter
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
);
painter
.
setPen
(
Qt
::
NoPen
);
if
(
m_isInteractive
)
{
painter
.
setBrush
(
QColor
(
127
,
127
,
127
,
127
));
painter
.
drawRoundedRect
(
QRectF
(
size
().
width
()
/
2
,
size
().
height
()
/
2
,
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
width
()
)
/
2
),
15
,
15
);
painter
.
setBrush
(
QColor
(
190
,
190
,
190
,
255
));
painter
.
drawEllipse
(
QPoint
(
size
().
width
()
/
2
,
size
().
height
()
/
2
),
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
height
()
)
/
2
);
painter
.
drawPixmap
(
size
().
width
()
-
sClosePixmap
->
width
(),
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
1
,
*
sClosePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
sIncreasePixmap
->
width
(),
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
2.5
,
*
sIncreasePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
sDecreasePixmap
->
width
(),
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
3.6
,
*
sDecreasePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
mResizeItem
->
width
()
-
20
,
size
().
height
()
-
mResizeItem
->
height
()
-
20
,
*
mResizeItem
);
}
else
{
painter
.
setBrush
(
QColor
(
127
,
127
,
127
,
127
));
painter
.
drawEllipse
(
QPoint
(
size
().
width
()
/
2
,
size
().
height
()
/
2
),
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
height
()
)
/
2
);
}
painter
.
drawPixmap
(
0
,
0
,
pMap
);
}
void
UBMagnifier
::
mousePressEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
QWidget
::
mousePressEvent
(
event
);
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
mResizeItem
->
width
()
-
20
&&
event
->
pos
().
x
()
<
size
().
width
()
-
20
&&
event
->
pos
().
y
()
>=
size
().
height
()
-
mResizeItem
->
height
()
-
20
&&
event
->
pos
().
y
()
<
size
().
height
()
-
-
20
)
{
mShouldResizeWidget
=
true
;
}
else
{
mShouldMoveWidget
=
!
event
->
isAccepted
()
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
);
}
mMousePressPos
=
event
->
pos
();
mMousePressDelta
=
(
qreal
)
updPointGrab
.
x
()
+
(
qreal
)
size
().
width
()
/
2
-
(
qreal
)
event
->
globalPos
().
x
();
event
->
accept
();
update
();
}
else
event
->
ignore
();
}
void
UBMagnifier
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
if
(
mShouldMoveWidget
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
move
(
pos
()
-
mMousePressPos
+
event
->
pos
());
event
->
accept
();
QWidget
::
mouseMoveEvent
(
event
);
emit
magnifierMoved_Signal
(
QPoint
(
this
->
pos
().
x
()
+
size
().
width
()
/
2
,
this
->
pos
().
y
()
+
size
().
height
()
/
2
));
return
;
}
if
(
mShouldResizeWidget
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
QPoint
currGlobalPos
=
event
->
globalPos
();
qreal
cvW
=
mView
->
width
();
qreal
newXSize
=
(
currGlobalPos
.
x
()
+
mMousePressDelta
-
updPointGrab
.
x
()
)
*
2
;
qreal
newPercentSize
=
newXSize
*
100
/
cvW
;
emit
magnifierResized_Signal
(
newPercentSize
);
event
->
ignore
();
return
;
}
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
mResizeItem
->
width
()
-
20
&&
event
->
pos
().
x
()
<
size
().
width
()
-
20
&&
event
->
pos
().
y
()
>=
size
().
height
()
-
mResizeItem
->
height
()
-
20
&&
event
->
pos
().
y
()
<
size
().
height
()
-
-
20
&&
isCusrsorAlreadyStored
==
false
)
{
mOldCursor
=
cursor
();
isCusrsorAlreadyStored
=
true
;
setCursor
(
mResizeCursor
);
}
}
else
event
->
ignore
();
}
void
UBMagnifier
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
mShouldMoveWidget
=
false
;
mShouldResizeWidget
=
false
;
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sClosePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
1
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
2
)
{
event
->
accept
();
emit
magnifierClose_Signal
();
}
else
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sIncreasePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
2.5
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
3.5
)
{
event
->
accept
();
emit
magnifierZoomIn_Signal
();
}
else
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sDecreasePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
3.6
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
4.6
)
{
event
->
accept
();
emit
magnifierZoomOut_Signal
();
}
else
QWidget
::
mouseReleaseEvent
(
event
);
// don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
}
else
event
->
ignore
();
}
void
UBMagnifier
::
timerEvent
(
QTimerEvent
*
e
)
{
if
(
inTimer
)
return
;
if
(
e
->
timerId
()
==
timerUpdate
)
{
inTimer
=
true
;
if
(
!
(
updPointGrab
.
isNull
()))
grabPoint
(
updPointGrab
);
if
(
isCusrsorAlreadyStored
)
{
QPoint
globalCursorPos
=
QCursor
::
pos
();
QPoint
cursorPos
=
mapFromGlobal
(
globalCursorPos
);
if
(
cursorPos
.
x
()
<
size
().
width
()
-
mResizeItem
->
width
()
-
20
||
cursorPos
.
x
()
>
size
().
width
()
-
20
||
cursorPos
.
y
()
<
size
().
height
()
-
mResizeItem
->
height
()
-
20
||
cursorPos
.
y
()
>
size
().
height
()
-
-
20
)
{
isCusrsorAlreadyStored
=
false
;
setCursor
(
mOldCursor
);
}
}
inTimer
=
false
;
}
}
void
UBMagnifier
::
grabPoint
()
{
QPointF
itemPos
=
gView
->
mapFromGlobal
(
updPointGrab
);
qreal
zWidth
=
size
().
width
()
/
params
.
zoom
;
qreal
zWidthHalf
=
zWidth
/
2
;
qreal
zHeight
=
size
().
height
()
/
params
.
zoom
;
qreal
zHeightHalf
=
zHeight
/
2
;
int
x
=
itemPos
.
x
()
-
zWidthHalf
;
int
y
=
itemPos
.
y
()
-
zHeightHalf
;
QPixmap
newPixMap
(
QSize
(
zWidth
,
zHeight
));
((
QWidget
*
)
gView
)
->
render
(
&
newPixMap
,
QPoint
(
0
,
0
),
QRegion
(
x
,
y
,
zWidth
,
zHeight
));
UBApplication
::
boardController
->
activeScene
()
->
update
();
pMap
.
fill
(
Qt
::
transparent
);
pMap
=
newPixMap
.
scaled
(
QSize
(
width
(),
height
()));
pMap
.
setMask
(
bmpMask
);
update
();
}
void
UBMagnifier
::
grabPoint
(
const
QPoint
&
pGrab
)
{
updPointGrab
=
pGrab
;
QPointF
itemPos
=
gView
->
mapFromGlobal
(
pGrab
);
qreal
zWidth
=
size
().
width
()
/
params
.
zoom
;
qreal
zWidthHalf
=
zWidth
/
2
;
qreal
zHeight
=
size
().
height
()
/
params
.
zoom
;
qreal
zHeightHalf
=
zHeight
/
2
;
int
x
=
itemPos
.
x
()
-
zWidthHalf
;
int
y
=
itemPos
.
y
()
-
zHeightHalf
;
QPixmap
newPixMap
(
QSize
(
zWidth
,
zHeight
));
((
QWidget
*
)
gView
)
->
render
(
&
newPixMap
,
QPoint
(
0
,
0
),
QRegion
(
x
,
y
,
zWidth
,
zHeight
));
UBApplication
::
boardController
->
activeScene
()
->
update
();
pMap
.
fill
(
Qt
::
transparent
);
pMap
=
newPixMap
.
scaled
(
QSize
(
width
(),
height
()));
pMap
.
setMask
(
bmpMask
);
update
();
}
// from global
void
UBMagnifier
::
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
,
bool
needMove
)
{
updPointGrab
=
pGrab
;
updPointMove
=
pMove
;
if
(
needGrab
)
grabPoint
(
pGrab
);
if
(
needMove
)
{
QPoint
movePos
=
mView
->
mapFromGlobal
(
pMove
);
move
(
movePos
.
x
()
-
width
()
/
2
,
movePos
.
y
()
-
height
()
/
2
);
// move(itemPos.x(), itemPos.y());
}
}
void
UBMagnifier
::
setGrabView
(
QWidget
*
view
)
{
if
(
timerUpdate
!=
0
)
killTimer
(
timerUpdate
);
gView
=
view
;
timerUpdate
=
startTimer
(
200
);
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include "UBMagnifer.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
#include "board/UBBoardView.h"
#include "core/memcheck.h"
UBMagnifier
::
UBMagnifier
(
QWidget
*
parent
,
bool
isInteractive
)
:
QWidget
(
parent
,
parent
?
Qt
::
Widget
:
Qt
::
Tool
|
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
|
Qt
::
X11BypassWindowManagerHint
))
,
mShouldMoveWidget
(
false
)
,
mShouldResizeWidget
(
false
)
,
borderPen
(
Qt
::
darkGray
)
,
gView
(
0
)
,
mView
(
0
)
{
isCusrsorAlreadyStored
=
false
;
setMouseTracking
(
true
);
//--------------------------------------------------//
QPixmap
pix
(
":/images/cursors/resize.png"
);
QTransform
tr
;
tr
.
rotate
(
45
);
mResizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
//--------------------------------------------------//
params
.
sizePercentFromScene
=
20
;
m_isInteractive
=
isInteractive
;
sClosePixmap
=
new
QPixmap
(
":/images/close.svg"
);
sIncreasePixmap
=
new
QPixmap
(
":/images/increase.svg"
);
sDecreasePixmap
=
new
QPixmap
(
":/images/decrease.svg"
);
mResizeItem
=
new
QPixmap
(
":/images/resize.svg"
);
if
(
parent
)
{
setAttribute
(
Qt
::
WA_NoMousePropagation
);
}
else
{
// standalone window
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
// setAttribute(Qt::WA_TranslucentBackground);
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
#endif
#ifdef Q_WS_MAC
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
setAttribute
(
Qt
::
WA_MacNonActivatingToolWindow
);
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
connect
(
&
mRefreshTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
slot_refresh
()));
}
UBMagnifier
::~
UBMagnifier
()
{
if
(
sClosePixmap
)
{
delete
sClosePixmap
;
sClosePixmap
=
NULL
;
}
if
(
sIncreasePixmap
)
{
delete
sIncreasePixmap
;
sIncreasePixmap
=
NULL
;
}
if
(
sDecreasePixmap
)
{
delete
sDecreasePixmap
;
sDecreasePixmap
=
NULL
;
}
}
void
UBMagnifier
::
setSize
(
qreal
percentFromScene
)
{
if
(
gView
==
NULL
||
mView
==
NULL
)
return
;
// calculate object size
params
.
sizePercentFromScene
=
percentFromScene
;
QSize
sceneSize
=
mView
->
size
();
qreal
size
=
params
.
sizePercentFromScene
*
sceneSize
.
width
()
/
100
;
QRect
currGeom
=
geometry
();
if
(
currGeom
.
width
()
==
currGeom
.
height
())
{
QPoint
newPos
=
mView
->
mapFromGlobal
(
updPointMove
);
setGeometry
(
newPos
.
x
()
-
size
/
2
,
newPos
.
y
()
-
size
/
2
,
size
,
size
);
}
else
setGeometry
(
0
,
0
,
size
,
size
);
// prepare transparent bit mask
QImage
mask_img
(
width
(),
height
(),
QImage
::
Format_Mono
);
mask_img
.
fill
(
0xff
);
QPainter
mask_ptr
(
&
mask_img
);
mask_ptr
.
setBrush
(
QBrush
(
QColor
(
0
,
0
,
0
)
)
);
mask_ptr
.
drawEllipse
(
QPointF
(
size
/
2
,
size
/
2
),
size
/
2
-
sClosePixmap
->
width
(),
size
/
2
-
sClosePixmap
->
width
());
bmpMask
=
QBitmap
::
fromImage
(
mask_img
);
// prepare general image
pMap
=
QPixmap
(
width
(),
height
());
pMap
.
fill
(
Qt
::
transparent
);
pMap
.
setMask
(
bmpMask
);
}
void
UBMagnifier
::
setZoom
(
qreal
zoom
)
{
params
.
zoom
=
zoom
;
}
void
UBMagnifier
::
paintEvent
(
QPaintEvent
*
event
)
{
Q_UNUSED
(
event
);
QPainter
painter
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
);
painter
.
setPen
(
Qt
::
NoPen
);
if
(
m_isInteractive
)
{
painter
.
setBrush
(
QColor
(
127
,
127
,
127
,
127
));
painter
.
drawRoundedRect
(
QRectF
(
size
().
width
()
/
2
,
size
().
height
()
/
2
,
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
width
()
)
/
2
),
15
,
15
);
painter
.
setBrush
(
QColor
(
190
,
190
,
190
,
255
));
painter
.
drawEllipse
(
QPoint
(
size
().
width
()
/
2
,
size
().
height
()
/
2
),
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
height
()
)
/
2
);
painter
.
drawPixmap
(
size
().
width
()
-
sClosePixmap
->
width
(),
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
1
,
*
sClosePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
sIncreasePixmap
->
width
(),
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
2.5
,
*
sIncreasePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
sDecreasePixmap
->
width
(),
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
3.6
,
*
sDecreasePixmap
);
painter
.
drawPixmap
(
size
().
width
()
-
mResizeItem
->
width
()
-
20
,
size
().
height
()
-
mResizeItem
->
height
()
-
20
,
*
mResizeItem
);
}
else
{
painter
.
setBrush
(
QColor
(
127
,
127
,
127
,
127
));
painter
.
drawEllipse
(
QPoint
(
size
().
width
()
/
2
,
size
().
height
()
/
2
),
(
size
().
width
()
-
sClosePixmap
->
width
()
)
/
2
,
(
size
().
height
()
-
sClosePixmap
->
height
()
)
/
2
);
}
painter
.
drawPixmap
(
0
,
0
,
pMap
);
}
void
UBMagnifier
::
mousePressEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
QWidget
::
mousePressEvent
(
event
);
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
mResizeItem
->
width
()
-
20
&&
event
->
pos
().
x
()
<
size
().
width
()
-
20
&&
event
->
pos
().
y
()
>=
size
().
height
()
-
mResizeItem
->
height
()
-
20
&&
event
->
pos
().
y
()
<
size
().
height
()
-
-
20
)
{
mShouldResizeWidget
=
true
;
}
else
{
mShouldMoveWidget
=
!
event
->
isAccepted
()
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
);
}
mMousePressPos
=
event
->
pos
();
mMousePressDelta
=
(
qreal
)
updPointGrab
.
x
()
+
(
qreal
)
size
().
width
()
/
2
-
(
qreal
)
event
->
globalPos
().
x
();
event
->
accept
();
update
();
}
else
event
->
ignore
();
}
void
UBMagnifier
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
if
(
mShouldMoveWidget
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
move
(
pos
()
-
mMousePressPos
+
event
->
pos
());
event
->
accept
();
QWidget
::
mouseMoveEvent
(
event
);
emit
magnifierMoved_Signal
(
QPoint
(
this
->
pos
().
x
()
+
size
().
width
()
/
2
,
this
->
pos
().
y
()
+
size
().
height
()
/
2
));
return
;
}
if
(
mShouldResizeWidget
&&
(
event
->
buttons
()
&
Qt
::
LeftButton
))
{
QPoint
currGlobalPos
=
event
->
globalPos
();
qreal
cvW
=
mView
->
width
();
qreal
newXSize
=
(
currGlobalPos
.
x
()
+
mMousePressDelta
-
updPointGrab
.
x
()
)
*
2
;
qreal
newPercentSize
=
newXSize
*
100
/
cvW
;
emit
magnifierResized_Signal
(
newPercentSize
);
event
->
ignore
();
return
;
}
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
mResizeItem
->
width
()
-
20
&&
event
->
pos
().
x
()
<
size
().
width
()
-
20
&&
event
->
pos
().
y
()
>=
size
().
height
()
-
mResizeItem
->
height
()
-
20
&&
event
->
pos
().
y
()
<
size
().
height
()
-
-
20
&&
isCusrsorAlreadyStored
==
false
)
{
mOldCursor
=
cursor
();
isCusrsorAlreadyStored
=
true
;
setCursor
(
mResizeCursor
);
}
}
else
event
->
ignore
();
}
void
UBMagnifier
::
mouseReleaseEvent
(
QMouseEvent
*
event
)
{
if
(
m_isInteractive
)
{
mShouldMoveWidget
=
false
;
mShouldResizeWidget
=
false
;
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sClosePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
1
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sClosePixmap
->
height
()
*
2
)
{
event
->
accept
();
emit
magnifierClose_Signal
();
}
else
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sIncreasePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
2.5
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sIncreasePixmap
->
height
()
*
3.5
)
{
event
->
accept
();
emit
magnifierZoomIn_Signal
();
}
else
if
(
event
->
pos
().
x
()
>=
size
().
width
()
-
sDecreasePixmap
->
width
()
&&
event
->
pos
().
x
()
<
size
().
width
()
&&
event
->
pos
().
y
()
>=
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
3.6
&&
event
->
pos
().
y
()
<
size
().
height
()
/
2
+
sDecreasePixmap
->
height
()
*
4.6
)
{
event
->
accept
();
emit
magnifierZoomOut_Signal
();
}
else
QWidget
::
mouseReleaseEvent
(
event
);
// don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
}
else
event
->
ignore
();
}
void
UBMagnifier
::
slot_refresh
()
{
if
(
!
(
updPointGrab
.
isNull
()))
grabPoint
(
updPointGrab
);
if
(
isCusrsorAlreadyStored
)
{
QPoint
globalCursorPos
=
QCursor
::
pos
();
QPoint
cursorPos
=
mapFromGlobal
(
globalCursorPos
);
if
(
cursorPos
.
x
()
<
size
().
width
()
-
mResizeItem
->
width
()
-
20
||
cursorPos
.
x
()
>
size
().
width
()
-
20
||
cursorPos
.
y
()
<
size
().
height
()
-
mResizeItem
->
height
()
-
20
||
cursorPos
.
y
()
>
size
().
height
()
-
-
20
)
{
isCusrsorAlreadyStored
=
false
;
setCursor
(
mOldCursor
);
}
}
}
void
UBMagnifier
::
grabPoint
()
{
QMatrix
transM
=
UBApplication
::
boardController
->
controlView
()
->
matrix
();
QPointF
itemPos
=
gView
->
mapFromGlobal
(
updPointGrab
);
qreal
zWidth
=
width
()
/
(
params
.
zoom
*
transM
.
m11
());
qreal
zWidthHalf
=
zWidth
/
2
;
qreal
zHeight
=
height
()
/
(
params
.
zoom
*
transM
.
m22
());
qreal
zHeightHalf
=
zHeight
/
2
;
QPointF
pfScLtF
(
UBApplication
::
boardController
->
controlView
()
->
mapToScene
(
QPoint
(
itemPos
.
x
(),
itemPos
.
y
())));
QRect
magnifierRect
=
rect
();
float
x
=
pfScLtF
.
x
()
-
zWidthHalf
;
float
y
=
pfScLtF
.
y
()
-
zHeightHalf
;
QPointF
leftTop
(
x
,
y
);
QPointF
rightBottom
(
x
+
zWidth
,
y
+
zHeight
);
QRectF
srcRect
(
leftTop
,
rightBottom
);
QPixmap
newPixMap
(
QSize
(
width
(),
height
()));
QPainter
painter
(
&
newPixMap
);
UBApplication
::
boardController
->
activeScene
()
->
render
(
&
painter
,
QRectF
(
0
,
0
,
width
(),
height
()),
srcRect
);
painter
.
end
();
pMap
.
fill
(
Qt
::
transparent
);
pMap
=
newPixMap
.
scaled
(
QSize
(
width
(),
height
()));
pMap
.
setMask
(
bmpMask
);
update
();
}
void
UBMagnifier
::
grabPoint
(
const
QPoint
&
pGrab
)
{
QMatrix
transM
=
UBApplication
::
boardController
->
controlView
()
->
matrix
();
updPointGrab
=
pGrab
;
QPointF
itemPos
=
gView
->
mapFromGlobal
(
pGrab
);
qreal
zWidth
=
width
()
/
(
params
.
zoom
*
transM
.
m11
());
qreal
zWidthHalf
=
zWidth
/
2
;
qreal
zHeight
=
height
()
/
(
params
.
zoom
*
transM
.
m22
());
qreal
zHeightHalf
=
zHeight
/
2
;
QPointF
pfScLtF
(
UBApplication
::
boardController
->
controlView
()
->
mapToScene
(
QPoint
(
itemPos
.
x
(),
itemPos
.
y
())));
QRect
magnifierRect
=
rect
();
float
x
=
pfScLtF
.
x
()
-
zWidthHalf
;
float
y
=
pfScLtF
.
y
()
-
zHeightHalf
;
QPointF
leftTop
(
x
,
y
);
QPointF
rightBottom
(
x
+
zWidth
,
y
+
zHeight
);
QRectF
srcRect
(
leftTop
,
rightBottom
);
QPixmap
newPixMap
(
QSize
(
width
(),
height
()));
QPainter
painter
(
&
newPixMap
);
UBApplication
::
boardController
->
activeScene
()
->
render
(
&
painter
,
QRectF
(
0
,
0
,
width
(),
height
()),
srcRect
);
painter
.
end
();
// pMap.fill(Qt::transparent);
pMap
=
newPixMap
;
pMap
.
setMask
(
bmpMask
);
update
();
}
// from global
void
UBMagnifier
::
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
,
bool
needMove
)
{
updPointGrab
=
pGrab
;
updPointMove
=
pMove
;
if
(
needGrab
)
grabPoint
(
pGrab
);
if
(
needMove
)
{
QPoint
movePos
=
mView
->
mapFromGlobal
(
pMove
);
move
(
movePos
.
x
()
-
width
()
/
2
,
movePos
.
y
()
-
height
()
/
2
);
// move(itemPos.x(), itemPos.y());
}
}
void
UBMagnifier
::
setGrabView
(
QWidget
*
view
)
{
gView
=
view
;
mRefreshTimer
.
setInterval
(
40
);
mRefreshTimer
.
start
();
}
src/gui/UBMagnifer.h
View file @
f16c06f9
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
#include <QtGui>
class
UBMagnifierParams
{
public
:
int
x
;
int
y
;
qreal
zoom
;
qreal
sizePercentFromScene
;
};
class
UBMagnifier
:
public
QWidget
{
Q_OBJECT
public
:
UBMagnifier
(
QWidget
*
parent
=
0
,
bool
isInteractive
=
false
);
~
UBMagnifier
();
void
setSize
(
qreal
percentFromScene
);
void
setZoom
(
qreal
zoom
);
void
setGrabView
(
QWidget
*
view
);
void
setMoveView
(
QWidget
*
view
)
{
mView
=
view
;}
void
grabPoint
();
void
grabPoint
(
const
QPoint
&
point
);
void
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
=
true
,
bool
needMove
=
true
);
UBMagnifierParams
params
;
signals
:
void
magnifierMoved_Signal
(
QPoint
newPos
);
void
magnifierClose_Signal
();
void
magnifierZoomIn_Signal
();
void
magnifierZoomOut_Signal
();
void
magnifierResized_Signal
(
qreal
newPercentSize
);
protected
:
void
paintEvent
(
QPaintEvent
*
);
void
timerEvent
(
QTimerEvent
*
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
QPoint
mMousePressPos
;
qreal
mMousePressDelta
;
bool
mShouldMoveWidget
;
bool
mShouldResizeWidget
;
QPixmap
*
sClosePixmap
;
QPixmap
*
sIncreasePixmap
;
QPixmap
*
sDecreasePixmap
;
QPixmap
*
mResizeItem
;
bool
isCusrsorAlreadyStored
;
QCursor
mOldCursor
;
QCursor
mResizeCursor
;
private
:
bool
inTimer
;
bool
m_isInteractive
;
int
timerUpdate
;
QPoint
updPointGrab
;
QPoint
updPointMove
;
QPixmap
pMap
;
QBitmap
bmpMask
;
QPen
borderPen
;
QWidget
*
gView
;
QWidget
*
mView
;
};
#endif // UBMAGNIFIER_H
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
#include <QtGui>
class
UBMagnifierParams
{
public
:
int
x
;
int
y
;
qreal
zoom
;
qreal
sizePercentFromScene
;
};
class
UBMagnifier
:
public
QWidget
{
Q_OBJECT
public
:
UBMagnifier
(
QWidget
*
parent
=
0
,
bool
isInteractive
=
false
);
~
UBMagnifier
();
void
setSize
(
qreal
percentFromScene
);
void
setZoom
(
qreal
zoom
);
void
setGrabView
(
QWidget
*
view
);
void
setMoveView
(
QWidget
*
view
)
{
mView
=
view
;}
void
grabPoint
();
void
grabPoint
(
const
QPoint
&
point
);
void
grabNMove
(
const
QPoint
&
pGrab
,
const
QPoint
&
pMove
,
bool
needGrab
=
true
,
bool
needMove
=
true
);
UBMagnifierParams
params
;
signals
:
void
magnifierMoved_Signal
(
QPoint
newPos
);
void
magnifierClose_Signal
();
void
magnifierZoomIn_Signal
();
void
magnifierZoomOut_Signal
();
void
magnifierResized_Signal
(
qreal
newPercentSize
);
public
slots
:
void
slot_refresh
();
protected
:
void
paintEvent
(
QPaintEvent
*
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
QPoint
mMousePressPos
;
qreal
mMousePressDelta
;
bool
mShouldMoveWidget
;
bool
mShouldResizeWidget
;
QPixmap
*
sClosePixmap
;
QPixmap
*
sIncreasePixmap
;
QPixmap
*
sDecreasePixmap
;
QPixmap
*
mResizeItem
;
bool
isCusrsorAlreadyStored
;
QCursor
mOldCursor
;
QCursor
mResizeCursor
;
private
:
QTimer
mRefreshTimer
;
bool
m_isInteractive
;
QPoint
updPointGrab
;
QPoint
updPointMove
;
QPixmap
pMap
;
QBitmap
bmpMask
;
QPen
borderPen
;
QWidget
*
gView
;
QWidget
*
mView
;
};
#endif // UBMAGNIFIER_H
src/tools/UBAbstractDrawRuler.cpp
View file @
f16c06f9
...
...
@@ -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 @
f16c06f9
...
...
@@ -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
...
...
@@ -49,8 +47,6 @@ UBItem* UBGraphicsCache::deepCopy() const
copy
->
setPos
(
this
->
pos
());
copy
->
setRect
(
this
->
rect
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
// TODO UB 4.7 ... complete all members ?
...
...
@@ -92,8 +88,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 @
f16c06f9
...
...
@@ -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 @
f16c06f9
...
...
@@ -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
()));
}
...
...
@@ -85,8 +87,6 @@ UBItem* UBGraphicsCompass::deepCopy() const
copy
->
setPos
(
this
->
pos
());
copy
->
setRect
(
this
->
rect
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
// TODO UB 4.7 ... complete all members ?
...
...
src/tools/UBGraphicsCurtainItem.cpp
View file @
f16c06f9
...
...
@@ -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
()
...
...
@@ -58,8 +60,6 @@ UBGraphicsCurtainItem::~UBGraphicsCurtainItem()
QVariant
UBGraphicsCurtainItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
// if (change == QGraphicsItem::ItemSelectedHasChanged && QGraphicsRectItem::scene() && isSelected())
// setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain);
QVariant
newValue
=
value
;
...
...
@@ -131,8 +131,6 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const
copy
->
setPos
(
this
->
pos
());
copy
->
setBrush
(
this
->
brush
());
copy
->
setPen
(
this
->
pen
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
true
);
copy
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
...
...
src/tools/UBGraphicsCurtainItemDelegate.cpp
View file @
f16c06f9
...
...
@@ -52,7 +52,6 @@ bool UBGraphicsCurtainItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *ev
if
(
!
mDelegated
->
isSelected
())
{
mDelegated
->
setSelected
(
true
);
// mDelegated->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCurtain);
positionHandles
();
return
true
;
...
...
src/tools/UBGraphicsProtractor.cpp
View file @
f16c06f9
...
...
@@ -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
);
}
...
...
@@ -580,8 +581,6 @@ UBItem* UBGraphicsProtractor::deepCopy() const
copy
->
setPos
(
this
->
pos
());
copy
->
setRect
(
this
->
rect
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
copy
->
mCurrentAngle
=
this
->
mCurrentAngle
;
...
...
src/tools/UBGraphicsRuler.cpp
View file @
f16c06f9
...
...
@@ -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
();
}
...
...
@@ -74,8 +76,6 @@ UBItem* UBGraphicsRuler::deepCopy() const
copy
->
setPos
(
this
->
pos
());
copy
->
setRect
(
this
->
rect
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
// TODO UB 4.7 ... complete all members ?
...
...
src/tools/UBGraphicsTriangle.cpp
View file @
f16c06f9
...
...
@@ -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
();
}
...
...
@@ -93,8 +95,6 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
copy
->
setPos
(
this
->
pos
());
copy
->
setPolygon
(
this
->
polygon
());
// copy->setZValue(this->zValue());
UBGraphicsItem
::
assignZValue
(
copy
,
this
->
zValue
());
copy
->
setTransform
(
this
->
transform
());
// TODO UB 4.7 ... complete all members ?
...
...
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