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
3d8deb8c
Commit
3d8deb8c
authored
Jun 21, 2011
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graphics ruler: drawing lines
parent
4f09fe08
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
275 additions
and
84 deletions
+275
-84
drawRulerLine.png
resources/images/cursors/drawRulerLine.png
+0
-0
sankore.qrc
resources/sankore.qrc
+1
-0
UBWidgetUniboardAPI.cpp
src/api/UBWidgetUniboardAPI.cpp
+2
-1
UBBoardView.cpp
src/board/UBBoardView.cpp
+17
-9
UBDrawingController.cpp
src/board/UBDrawingController.cpp
+1
-0
UBDrawingController.h
src/board/UBDrawingController.h
+4
-0
UB.h
src/core/UB.h
+11
-1
UBDisplayManager.cpp
src/core/UBDisplayManager.cpp
+6
-0
UBDesktopAnnotationController.cpp
src/desktop/UBDesktopAnnotationController.cpp
+3
-0
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+0
-1
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+38
-22
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+7
-1
UBDockPalette.cpp
src/gui/UBDockPalette.cpp
+6
-1
UBFloatingPalette.cpp
src/gui/UBFloatingPalette.cpp
+3
-0
UBResources.cpp
src/gui/UBResources.cpp
+1
-0
UBResources.h
src/gui/UBResources.h
+1
-0
UBAbstractDrawRuler.cpp
src/tools/UBAbstractDrawRuler.cpp
+9
-0
UBAbstractDrawRuler.h
src/tools/UBAbstractDrawRuler.h
+21
-0
UBGraphicsCompass.cpp
src/tools/UBGraphicsCompass.cpp
+4
-4
UBGraphicsProtractor.cpp
src/tools/UBGraphicsProtractor.cpp
+0
-1
UBGraphicsRuler.cpp
src/tools/UBGraphicsRuler.cpp
+125
-40
UBGraphicsRuler.h
src/tools/UBGraphicsRuler.h
+11
-1
tools.pri
src/tools/tools.pri
+4
-2
No files found.
resources/images/cursors/drawRulerLine.png
0 → 100644
View file @
3d8deb8c
444 Bytes
resources/sankore.qrc
View file @
3d8deb8c
...
@@ -173,6 +173,7 @@
...
@@ -173,6 +173,7 @@
<file>images/cursors/rotate.png</file>
<file>images/cursors/rotate.png</file>
<file>images/cursors/resize.png</file>
<file>images/cursors/resize.png</file>
<file>images/cursors/drawCompass.png</file>
<file>images/cursors/drawCompass.png</file>
<file>images/cursors/drawRulerLine.png</file>
<file>images/print/onepage.png</file>
<file>images/print/onepage.png</file>
<file>images/print/thumbnails.png</file>
<file>images/print/thumbnails.png</file>
<file>images/print/twopages.png</file>
<file>images/print/twopages.png</file>
...
...
src/api/UBWidgetUniboardAPI.cpp
View file @
3d8deb8c
...
@@ -179,7 +179,8 @@ void UBWidgetUniboardAPI::drawLineTo(const qreal x, const qreal y, const qreal p
...
@@ -179,7 +179,8 @@ void UBWidgetUniboardAPI::drawLineTo(const qreal x, const qreal y, const qreal p
return
;
return
;
if
(
mScene
)
if
(
mScene
)
mScene
->
drawLineTo
(
QPointF
(
x
,
y
),
pWidth
);
mScene
->
drawLineTo
(
QPointF
(
x
,
y
),
pWidth
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
}
...
...
src/board/UBBoardView.cpp
View file @
3d8deb8c
...
@@ -450,15 +450,18 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -450,15 +450,18 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
event
->
accept
();
event
->
accept
();
}
}
else
else
{
{
viewport
()
->
setCursor
(
QCursor
(
Qt
::
BlankCursor
));
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
==
NULL
)
{
if
(
scene
()
&&
!
mTabletStylusIsPressed
)
viewport
()
->
setCursor
(
QCursor
(
Qt
::
BlankCursor
));
{
}
scene
()
->
inputDevicePress
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())));
}
if
(
scene
()
&&
!
mTabletStylusIsPressed
)
event
->
accept
();
{
scene
()
->
inputDevicePress
(
mapToScene
(
UBGeometryUtils
::
pointConstrainedInRect
(
event
->
pos
(),
rect
())));
}
event
->
accept
();
}
}
}
}
}
}
...
@@ -487,6 +490,11 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -487,6 +490,11 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
{
{
QGraphicsView
::
mouseMoveEvent
(
event
);
QGraphicsView
::
mouseMoveEvent
(
event
);
}
}
else
if
((
UBDrawingController
::
drawingController
()
->
isDrawingTool
())
&&
!
mMouseButtonIsPressed
)
{
QGraphicsView
::
mouseMoveEvent
(
event
);
}
else
if
(
currentTool
==
UBStylusTool
::
Text
||
currentTool
==
UBStylusTool
::
Capture
)
else
if
(
currentTool
==
UBStylusTool
::
Text
||
currentTool
==
UBStylusTool
::
Capture
)
{
{
if
(
mRubberBand
&&
(
mIsCreatingTextZone
||
mIsCreatingSceneGrabZone
))
if
(
mRubberBand
&&
(
mIsCreatingTextZone
||
mIsCreatingSceneGrabZone
))
...
...
src/board/UBDrawingController.cpp
View file @
3d8deb8c
...
@@ -27,6 +27,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
...
@@ -27,6 +27,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
mStylusTool
((
UBStylusTool
::
Enum
)
-
1
)
,
mStylusTool
((
UBStylusTool
::
Enum
)
-
1
)
,
mLatestDrawingTool
((
UBStylusTool
::
Enum
)
-
1
)
,
mLatestDrawingTool
((
UBStylusTool
::
Enum
)
-
1
)
,
mActiveRuler
(
NULL
)
{
{
connect
(
UBSettings
::
settings
(),
SIGNAL
(
colorContextChanged
()),
this
,
SIGNAL
(
colorPaletteChanged
()));
connect
(
UBSettings
::
settings
(),
SIGNAL
(
colorContextChanged
()),
this
,
SIGNAL
(
colorPaletteChanged
()));
...
...
src/board/UBDrawingController.h
View file @
3d8deb8c
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
#include "core/UB.h"
#include "core/UB.h"
class
UBAbstractDrawRuler
;
class
UBDrawingController
:
public
QObject
class
UBDrawingController
:
public
QObject
{
{
Q_OBJECT
;
Q_OBJECT
;
...
@@ -39,6 +41,8 @@ class UBDrawingController : public QObject
...
@@ -39,6 +41,8 @@ class UBDrawingController : public QObject
void
setMarkerColor
(
bool
onDarkBackground
,
const
QColor
&
color
,
int
pIndex
);
void
setMarkerColor
(
bool
onDarkBackground
,
const
QColor
&
color
,
int
pIndex
);
void
setMarkerAlpha
(
qreal
alpha
);
void
setMarkerAlpha
(
qreal
alpha
);
UBAbstractDrawRuler
*
mActiveRuler
;
public
slots
:
public
slots
:
void
setStylusTool
(
int
tool
);
void
setStylusTool
(
int
tool
);
...
...
src/core/UB.h
View file @
3d8deb8c
...
@@ -16,7 +16,17 @@ struct UBStylusTool
...
@@ -16,7 +16,17 @@ struct UBStylusTool
{
{
enum
Enum
enum
Enum
{
{
Pen
=
0
,
Eraser
,
Marker
,
Selector
,
Hand
,
ZoomIn
,
ZoomOut
,
Pointer
,
Line
,
Text
,
Capture
Pen
=
0
,
Eraser
,
Marker
,
Selector
,
Hand
,
ZoomIn
,
ZoomOut
,
Pointer
,
Line
,
Text
,
Capture
};
};
};
};
...
...
src/core/UBDisplayManager.cpp
View file @
3d8deb8c
...
@@ -114,7 +114,10 @@ void UBDisplayManager::setAsControl(QWidget* pControlWidget )
...
@@ -114,7 +114,10 @@ void UBDisplayManager::setAsControl(QWidget* pControlWidget )
mControlWidget
->
hide
();
mControlWidget
->
hide
();
mControlWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mControlScreenIndex
));
mControlWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mControlScreenIndex
));
mControlWidget
->
showFullScreen
();
mControlWidget
->
showFullScreen
();
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
mControlWidget
->
setAttribute
(
Qt
::
WA_MacNoShadow
);
mControlWidget
->
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
}
}
}
...
@@ -127,7 +130,10 @@ void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget)
...
@@ -127,7 +130,10 @@ void UBDisplayManager::setAsDisplay(QWidget* pDisplayWidget)
mDisplayWidget
->
hide
();
mDisplayWidget
->
hide
();
mDisplayWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mDisplayScreenIndex
));
mDisplayWidget
->
setGeometry
(
mDesktop
->
screenGeometry
(
mDisplayScreenIndex
));
mDisplayWidget
->
showFullScreen
();
mDisplayWidget
->
showFullScreen
();
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
mDisplayWidget
->
setAttribute
(
Qt
::
WA_MacNoShadow
);
mDisplayWidget
->
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
}
}
}
...
...
src/desktop/UBDesktopAnnotationController.cpp
View file @
3d8deb8c
...
@@ -60,7 +60,10 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
...
@@ -60,7 +60,10 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingView
=
new
UBBoardView
(
UBApplication
::
boardController
,
0
);
// deleted in UBDesktopAnnotationController::destructor
mTransparentDrawingView
=
new
UBBoardView
(
UBApplication
::
boardController
,
0
);
// deleted in UBDesktopAnnotationController::destructor
mTransparentDrawingView
->
setAttribute
(
Qt
::
WA_TranslucentBackground
,
true
);
mTransparentDrawingView
->
setAttribute
(
Qt
::
WA_TranslucentBackground
,
true
);
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
mTransparentDrawingView
->
setAttribute
(
Qt
::
WA_MacNoShadow
,
true
);
mTransparentDrawingView
->
setAttribute
(
Qt
::
WA_MacNoShadow
,
true
);
#endif
mTransparentDrawingView
->
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
|
Qt
::
Window
);
mTransparentDrawingView
->
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
|
Qt
::
Window
);
mTransparentDrawingView
->
setCacheMode
(
QGraphicsView
::
CacheNone
);
mTransparentDrawingView
->
setCacheMode
(
QGraphicsView
::
CacheNone
);
mTransparentDrawingView
->
resize
(
UBApplication
::
desktop
()
->
width
(),
UBApplication
::
desktop
()
->
height
());
mTransparentDrawingView
->
resize
(
UBApplication
::
desktop
()
->
width
(),
UBApplication
::
desktop
()
->
height
());
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
3d8deb8c
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "gui/UBResources.h"
#include "gui/UBResources.h"
const
double
PI
=
4.0
*
atan
(
1.0
);
qreal
const
UBGraphicsDelegateFrame
::
mAngleTolerance
=
6
;
qreal
const
UBGraphicsDelegateFrame
::
mAngleTolerance
=
6
;
UBGraphicsDelegateFrame
::
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
)
UBGraphicsDelegateFrame
::
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
)
...
...
src/domain/UBGraphicsScene.cpp
View file @
3d8deb8c
...
@@ -59,8 +59,6 @@ qreal UBGraphicsScene::toolOffsetEraser = 200;
...
@@ -59,8 +59,6 @@ qreal UBGraphicsScene::toolOffsetEraser = 200;
qreal
UBGraphicsScene
::
toolOffsetCurtain
=
1000
;
qreal
UBGraphicsScene
::
toolOffsetCurtain
=
1000
;
qreal
UBGraphicsScene
::
toolOffsetPointer
=
1100
;
qreal
UBGraphicsScene
::
toolOffsetPointer
=
1100
;
const
double
PI
=
4.0
*
atan
(
1.0
);
UBGraphicsScene
::
UBGraphicsScene
(
UBDocumentProxy
*
parent
)
UBGraphicsScene
::
UBGraphicsScene
(
UBDocumentProxy
*
parent
)
:
UBCoreGraphicsScene
(
parent
)
:
UBCoreGraphicsScene
(
parent
)
,
mEraser
(
0
)
,
mEraser
(
0
)
...
@@ -163,8 +161,18 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
...
@@ -163,8 +161,18 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mAddedItems
.
clear
();
mAddedItems
.
clear
();
mRemovedItems
.
clear
();
mRemovedItems
.
clear
();
moveTo
(
scenePos
);
drawLineTo
(
scenePos
,
width
);
if
(
UBDrawingController
::
drawingController
()
->
mActiveRuler
)
{
UBDrawingController
::
drawingController
()
->
mActiveRuler
->
StartLine
(
scenePos
,
width
);
}
else
{
moveTo
(
scenePos
);
drawLineTo
(
scenePos
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
accepted
=
true
;
accepted
=
true
;
}
}
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
...
@@ -220,21 +228,29 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
...
@@ -220,21 +228,29 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width
/=
UBApplication
::
boardController
->
systemScaleFactor
();
width
/=
UBApplication
::
boardController
->
systemScaleFactor
();
width
/=
UBApplication
::
boardController
->
currentZoom
();
width
/=
UBApplication
::
boardController
->
currentZoom
();
if
(
currentTool
==
UBStylusTool
::
Line
)
if
(
dc
->
mActiveRuler
)
{
{
QLineF
radius
(
mPreviousPoint
,
position
);
dc
->
mActiveRuler
->
DrawLine
(
position
,
width
);
qreal
angle
=
radius
.
angle
();
}
angle
=
qRound
(
angle
/
45
)
*
45
;
else
qreal
radiusLength
=
radius
.
length
();
{
QPointF
newPosition
(
if
(
currentTool
==
UBStylusTool
::
Line
)
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
{
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
QLineF
radius
(
mPreviousPoint
,
position
);
QLineF
chord
(
position
,
newPosition
);
qreal
angle
=
radius
.
angle
();
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
angle
=
qRound
(
angle
/
45
)
*
45
;
position
=
newPosition
;
qreal
radiusLength
=
radius
.
length
();
}
QPointF
newPosition
(
mPreviousPoint
.
x
()
+
radiusLength
*
cos
((
angle
*
PI
)
/
180
),
drawLineTo
(
position
,
width
);
mPreviousPoint
.
y
()
-
radiusLength
*
sin
((
angle
*
PI
)
/
180
));
QLineF
chord
(
position
,
newPosition
);
if
(
chord
.
length
()
<
qMin
((
int
)
16
,
(
int
)(
radiusLength
/
20
)))
position
=
newPosition
;
}
drawLineTo
(
position
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
}
}
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
else
if
(
currentTool
==
UBStylusTool
::
Eraser
)
{
{
...
@@ -348,7 +364,7 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint)
...
@@ -348,7 +364,7 @@ void UBGraphicsScene::moveTo(const QPointF &pPoint)
}
}
void
UBGraphicsScene
::
drawLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
)
void
UBGraphicsScene
::
drawLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
,
bool
bLineStyle
)
{
{
if
(
mPreviousWidth
==
-
1.0
)
if
(
mPreviousWidth
==
-
1.0
)
mPreviousWidth
=
pWidth
;
mPreviousWidth
=
pWidth
;
...
@@ -364,7 +380,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -364,7 +380,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
}
}
}
if
(
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Lin
e
)
if
(
bLineStyl
e
)
{
{
QSetIterator
<
QGraphicsItem
*>
itItems
(
mAddedItems
);
QSetIterator
<
QGraphicsItem
*>
itItems
(
mAddedItems
);
...
@@ -388,7 +404,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -388,7 +404,7 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth)
mPreviousPolygonItems
.
append
(
polygonItem
);
mPreviousPolygonItems
.
append
(
polygonItem
);
if
(
UBDrawingController
::
drawingController
()
->
stylusTool
()
!=
UBStylusTool
::
Lin
e
)
if
(
!
bLineStyl
e
)
{
{
mPreviousPoint
=
pEndPoint
;
mPreviousPoint
=
pEndPoint
;
mPreviousWidth
=
pWidth
;
mPreviousWidth
=
pWidth
;
...
...
src/domain/UBGraphicsScene.h
View file @
3d8deb8c
...
@@ -37,6 +37,7 @@ class UBDocumentProxy;
...
@@ -37,6 +37,7 @@ class UBDocumentProxy;
class
UBGraphicsCurtainItem
;
class
UBGraphicsCurtainItem
;
class
UBGraphicsStroke
;
class
UBGraphicsStroke
;
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
class
UBGraphicsScene
:
public
UBCoreGraphicsScene
,
public
UBItem
class
UBGraphicsScene
:
public
UBCoreGraphicsScene
,
public
UBItem
{
{
...
@@ -99,7 +100,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -99,7 +100,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QRectF
normalizedSceneRect
(
qreal
ratio
=
-
1
.
0
);
QRectF
normalizedSceneRect
(
qreal
ratio
=
-
1
.
0
);
void
moveTo
(
const
QPointF
&
pPoint
);
void
moveTo
(
const
QPointF
&
pPoint
);
void
drawLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
);
void
drawLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
,
bool
bLineStyle
);
void
eraseLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
);
void
eraseLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
);
void
drawArcTo
(
const
QPointF
&
pCenterPoint
,
qreal
pSpanAngle
);
void
drawArcTo
(
const
QPointF
&
pCenterPoint
,
qreal
pSpanAngle
);
...
@@ -240,6 +241,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -240,6 +241,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
mTools
<<
item
;
mTools
<<
item
;
}
}
const
QPointF
&
previousPoint
()
{
return
mPreviousPoint
;
}
public
slots
:
public
slots
:
void
hideEraser
();
void
hideEraser
();
...
...
src/gui/UBDockPalette.cpp
View file @
3d8deb8c
...
@@ -33,7 +33,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
...
@@ -33,7 +33,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
{
{
// standalone window
// standalone window
setAttribute
(
Qt
::
WA_TranslucentBackground
);
setAttribute
(
Qt
::
WA_TranslucentBackground
);
setAttribute
(
Qt
::
WA_MacNoShadow
);
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
}
mBackgroundBrush
=
QBrush
(
UBSettings
::
paletteColor
);
mBackgroundBrush
=
QBrush
(
UBSettings
::
paletteColor
);
...
...
src/gui/UBFloatingPalette.cpp
View file @
3d8deb8c
...
@@ -26,10 +26,13 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent)
...
@@ -26,10 +26,13 @@ UBFloatingPalette::UBFloatingPalette(Qt::Corner position, QWidget *parent)
else
else
{
{
// standalone window
// standalone window
// !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN
setAttribute
(
Qt
::
WA_TranslucentBackground
);
setAttribute
(
Qt
::
WA_TranslucentBackground
);
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
setAttribute
(
Qt
::
WA_MacAlwaysShowToolWindow
);
setAttribute
(
Qt
::
WA_MacNonActivatingToolWindow
);
setAttribute
(
Qt
::
WA_MacNonActivatingToolWindow
);
setAttribute
(
Qt
::
WA_MacNoShadow
);
setAttribute
(
Qt
::
WA_MacNoShadow
);
#endif
}
}
mBackgroundBrush
=
QBrush
(
UBSettings
::
paletteColor
);
mBackgroundBrush
=
QBrush
(
UBSettings
::
paletteColor
);
...
...
src/gui/UBResources.cpp
View file @
3d8deb8c
...
@@ -43,4 +43,5 @@ void UBResources::init()
...
@@ -43,4 +43,5 @@ void UBResources::init()
arrowCursor
=
QCursor
(
Qt
::
ArrowCursor
);
arrowCursor
=
QCursor
(
Qt
::
ArrowCursor
);
textCursor
=
QCursor
(
Qt
::
ArrowCursor
);
textCursor
=
QCursor
(
Qt
::
ArrowCursor
);
rotateCursor
=
QCursor
(
QPixmap
(
":/images/cursors/rotate.png"
),
16
,
16
);
rotateCursor
=
QCursor
(
QPixmap
(
":/images/cursors/rotate.png"
),
16
,
16
);
drawLineRulerCursor
=
QCursor
(
QPixmap
(
":/images/cursors/drawRulerLine.png"
),
3
,
12
);
}
}
src/gui/UBResources.h
View file @
3d8deb8c
...
@@ -31,6 +31,7 @@ class UBResources : public QObject
...
@@ -31,6 +31,7 @@ class UBResources : public QObject
QCursor
arrowCursor
;
QCursor
arrowCursor
;
QCursor
textCursor
;
QCursor
textCursor
;
QCursor
rotateCursor
;
QCursor
rotateCursor
;
QCursor
drawLineRulerCursor
;
};
};
#endif
/* UBRESOURCES_H_ */
#endif
/* UBRESOURCES_H_ */
src/tools/UBAbstractDrawRuler.cpp
0 → 100644
View file @
3d8deb8c
#include "UBAbstractDrawRuler.h"
UBAbstractDrawRuler
::
UBAbstractDrawRuler
()
{}
UBAbstractDrawRuler
::~
UBAbstractDrawRuler
()
{}
src/tools/UBAbstractDrawRuler.h
0 → 100644
View file @
3d8deb8c
#ifndef UB_ABSTRACTDRAWRULER_H_
#define UB_ABSTRACTDRAWRULER_H_
#include <QtGui>
class
UBGraphicsScene
;
class
UBAbstractDrawRuler
:
public
QObject
{
Q_OBJECT
;
public
:
UBAbstractDrawRuler
();
~
UBAbstractDrawRuler
();
virtual
void
StartLine
(
const
QPointF
&
position
,
qreal
width
)
=
0
;
virtual
void
DrawLine
(
const
QPointF
&
position
,
qreal
width
)
=
0
;
virtual
void
EndLine
()
=
0
;
};
#endif
\ No newline at end of file
src/tools/UBGraphicsCompass.cpp
View file @
3d8deb8c
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBDrawingController.h" // TODO UB 4.x clean that dependency
#include "board/UBDrawingController.h" // TODO UB 4.x clean that dependency
const
double
PI
=
4.0
*
atan
(
1.0
);
const
QRect
UBGraphicsCompass
::
sDefaultRect
=
QRect
(
0
,
-
20
,
300
,
48
);
const
QRect
UBGraphicsCompass
::
sDefaultRect
=
QRect
(
0
,
-
20
,
300
,
48
);
const
QColor
UBGraphicsCompass
::
sLightBackgroundMiddleFillColor
=
QColor
(
0x72
,
0x72
,
0x72
,
sFillTransparency
);
const
QColor
UBGraphicsCompass
::
sLightBackgroundMiddleFillColor
=
QColor
(
0x72
,
0x72
,
0x72
,
sFillTransparency
);
const
QColor
UBGraphicsCompass
::
sLightBackgroundEdgeFillColor
=
QColor
(
0xc3
,
0xc3
,
0xc3
,
sFillTransparency
);
const
QColor
UBGraphicsCompass
::
sLightBackgroundEdgeFillColor
=
QColor
(
0xc3
,
0xc3
,
0xc3
,
sFillTransparency
);
...
@@ -511,9 +509,11 @@ void UBGraphicsCompass::paintCenterCross()
...
@@ -511,9 +509,11 @@ void UBGraphicsCompass::paintCenterCross()
{
{
QPointF
needleCrossCenter
=
mapToScene
(
needlePosition
());
QPointF
needleCrossCenter
=
mapToScene
(
needlePosition
());
scene
()
->
moveTo
(
QPointF
(
needleCrossCenter
.
x
()
-
5
,
needleCrossCenter
.
y
()));
scene
()
->
moveTo
(
QPointF
(
needleCrossCenter
.
x
()
-
5
,
needleCrossCenter
.
y
()));
scene
()
->
drawLineTo
(
QPointF
(
needleCrossCenter
.
x
()
+
5
,
needleCrossCenter
.
y
()),
1
);
scene
()
->
drawLineTo
(
QPointF
(
needleCrossCenter
.
x
()
+
5
,
needleCrossCenter
.
y
()),
1
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
scene
()
->
moveTo
(
QPointF
(
needleCrossCenter
.
x
(),
needleCrossCenter
.
y
()
-
5
));
scene
()
->
moveTo
(
QPointF
(
needleCrossCenter
.
x
(),
needleCrossCenter
.
y
()
-
5
));
scene
()
->
drawLineTo
(
QPointF
(
needleCrossCenter
.
x
(),
needleCrossCenter
.
y
()
+
5
),
1
);
scene
()
->
drawLineTo
(
QPointF
(
needleCrossCenter
.
x
(),
needleCrossCenter
.
y
()
+
5
),
1
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
==
UBStylusTool
::
Line
);
}
}
QPointF
UBGraphicsCompass
::
needlePosition
()
const
QPointF
UBGraphicsCompass
::
needlePosition
()
const
...
...
src/tools/UBGraphicsProtractor.cpp
View file @
3d8deb8c
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
#include "board/UBBoardController.h"
#include "board/UBBoardController.h"
const
double
PI
=
4.0
*
atan
(
1.0
);
const
int
UBGraphicsProtractor
::
sFillTransparency
=
127
;
const
int
UBGraphicsProtractor
::
sFillTransparency
=
127
;
const
int
UBGraphicsProtractor
::
sDrawTransparency
=
192
;
const
int
UBGraphicsProtractor
::
sDrawTransparency
=
192
;
const
QRectF
UBGraphicsProtractor
::
sDefaultRect
=
QRectF
(
-
175
,
-
175
,
350
,
350
);
const
QRectF
UBGraphicsProtractor
::
sDefaultRect
=
QRectF
(
-
175
,
-
175
,
350
,
350
);
...
...
src/tools/UBGraphicsRuler.cpp
View file @
3d8deb8c
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include "core/UBApplication.h"
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "gui/UBResources.h"
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBBoardController.h" // TODO UB 4.x clean that dependency
#include "board/UBDrawingController.h"
const
QRect
UBGraphicsRuler
::
sDefaultRect
=
QRect
(
0
,
0
,
800
,
96
);
const
QRect
UBGraphicsRuler
::
sDefaultRect
=
QRect
(
0
,
0
,
800
,
96
);
const
QColor
UBGraphicsRuler
::
sLightBackgroundMiddleFillColor
=
QColor
(
0x72
,
0x72
,
0x72
,
sFillTransparency
);
const
QColor
UBGraphicsRuler
::
sLightBackgroundMiddleFillColor
=
QColor
(
0x72
,
0x72
,
0x72
,
sFillTransparency
);
...
@@ -200,29 +201,40 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
...
@@ -200,29 +201,40 @@ void UBGraphicsRuler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void
UBGraphicsRuler
::
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
)
void
UBGraphicsRuler
::
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
{
mCloseSvgItem
->
setParentItem
(
this
);
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
mResizeSvgItem
->
setParentItem
(
this
);
mRotateSvgItem
->
setParentItem
(
this
);
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
mShowButtons
=
true
;
mCloseSvgItem
->
setParentItem
(
this
);
mCloseSvgItem
->
setVisible
(
mShowButtons
);
mResizeSvgItem
->
setParentItem
(
this
);
mResizeSvgItem
->
setVisible
(
mShowButtons
);
mRotateSvgItem
->
setParentItem
(
this
);
mRotateSvgItem
->
setVisible
(
mShowButtons
);
if
(
event
->
pos
().
x
()
>=
resizeButtonRect
().
left
())
mShowButtons
=
true
;
{
mCloseSvgItem
->
setVisible
(
mShowButtons
);
setCursor
(
resizeCursor
());
mResizeSvgItem
->
setVisible
(
mShowButtons
);
}
mRotateSvgItem
->
setVisible
(
mShowButtons
);
else
if
(
event
->
pos
().
x
()
>=
resizeButtonRect
().
left
())
{
{
if
(
closeButtonRect
().
contains
(
event
->
pos
()))
setCursor
(
resizeCursor
());
setCursor
(
closeCursor
());
}
else
if
(
rotateButtonRect
().
contains
(
event
->
pos
()))
else
setCursor
(
rotateCursor
());
{
else
if
(
closeButtonRect
().
contains
(
event
->
pos
()))
setCursor
(
moveCursor
());
setCursor
(
closeCursor
());
}
else
if
(
rotateButtonRect
().
contains
(
event
->
pos
()))
event
->
accept
();
setCursor
(
rotateCursor
());
update
();
else
setCursor
(
moveCursor
());
}
event
->
accept
();
update
();
}
else
if
(
UBDrawingController
::
drawingController
()
->
isDrawingTool
())
{
setCursor
(
drawRulerLineCursor
());
UBDrawingController
::
drawingController
()
->
mActiveRuler
=
this
;
event
->
accept
();
}
}
}
void
UBGraphicsRuler
::
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
)
void
UBGraphicsRuler
::
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
)
...
@@ -232,29 +244,39 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
...
@@ -232,29 +244,39 @@ void UBGraphicsRuler::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
mCloseSvgItem
->
setVisible
(
mShowButtons
);
mCloseSvgItem
->
setVisible
(
mShowButtons
);
mResizeSvgItem
->
setVisible
(
mShowButtons
);
mResizeSvgItem
->
setVisible
(
mShowButtons
);
mRotateSvgItem
->
setVisible
(
mShowButtons
);
mRotateSvgItem
->
setVisible
(
mShowButtons
);
UBDrawingController
::
drawingController
()
->
mActiveRuler
=
NULL
;
event
->
accept
();
event
->
accept
();
update
();
update
();
}
}
void
UBGraphicsRuler
::
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
)
void
UBGraphicsRuler
::
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
{
mCloseSvgItem
->
setVisible
(
mShowButtons
);
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
mResizeSvgItem
->
setVisible
(
mShowButtons
);
mRotateSvgItem
->
setVisible
(
mShowButtons
);
if
(
currentTool
==
UBStylusTool
::
Selector
)
if
(
event
->
pos
().
x
()
>=
resizeButtonRect
().
left
())
{
{
mCloseSvgItem
->
setVisible
(
mShowButtons
);
setCursor
(
resizeCursor
());
mResizeSvgItem
->
setVisible
(
mShowButtons
);
}
mRotateSvgItem
->
setVisible
(
mShowButtons
);
else
if
(
event
->
pos
().
x
()
>=
resizeButtonRect
().
left
())
{
{
if
(
closeButtonRect
().
contains
(
event
->
pos
()))
setCursor
(
resizeCursor
());
setCursor
(
closeCursor
());
}
else
if
(
rotateButtonRect
().
contains
(
event
->
pos
()))
else
setCursor
(
rotateCursor
());
{
else
if
(
closeButtonRect
().
contains
(
event
->
pos
()))
setCursor
(
moveCursor
());
setCursor
(
closeCursor
());
}
else
if
(
rotateButtonRect
().
contains
(
event
->
pos
()))
event
->
accept
();
setCursor
(
rotateCursor
());
else
setCursor
(
moveCursor
());
}
event
->
accept
();
}
else
if
(
currentTool
==
UBStylusTool
::
Pen
||
currentTool
==
UBStylusTool
::
Marker
)
{
event
->
accept
();
}
}
}
void
UBGraphicsRuler
::
fillBackground
(
QPainter
*
painter
)
void
UBGraphicsRuler
::
fillBackground
(
QPainter
*
painter
)
...
@@ -456,3 +478,66 @@ void UBGraphicsRuler::updateResizeCursor()
...
@@ -456,3 +478,66 @@ void UBGraphicsRuler::updateResizeCursor()
QCursor
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
QCursor
resizeCursor
=
QCursor
(
pix
.
transformed
(
tr
,
Qt
::
SmoothTransformation
),
pix
.
width
()
/
2
,
pix
.
height
()
/
2
);
mResizeCursor
=
resizeCursor
;
mResizeCursor
=
resizeCursor
;
}
}
QCursor
UBGraphicsRuler
::
drawRulerLineCursor
()
const
{
return
UBResources
::
resources
()
->
drawLineRulerCursor
;
}
void
UBGraphicsRuler
::
StartLine
(
const
QPointF
&
scenePos
,
qreal
width
)
{
QPointF
itemPos
=
mapFromScene
(
scenePos
);
qreal
y
;
if
(
itemPos
.
y
()
>
rect
().
y
()
+
rect
().
height
()
/
2
)
{
drawLineDirection
=
0
;
y
=
rect
().
y
()
+
rect
().
height
()
+
width
/
2
;
}
else
{
drawLineDirection
=
1
;
y
=
rect
().
y
()
-
width
/
2
;
}
if
(
itemPos
.
x
()
<
rect
().
x
()
+
sLeftEdgeMargin
)
itemPos
.
setX
(
rect
().
x
()
+
sLeftEdgeMargin
);
if
(
itemPos
.
x
()
>
rect
().
x
()
+
rect
().
width
()
-
sLeftEdgeMargin
)
itemPos
.
setX
(
rect
().
x
()
+
rect
().
width
()
-
sLeftEdgeMargin
);
itemPos
.
setY
(
y
);
itemPos
=
mapToScene
(
itemPos
);
scene
()
->
moveTo
(
itemPos
);
scene
()
->
drawLineTo
(
itemPos
,
width
,
true
);
}
void
UBGraphicsRuler
::
DrawLine
(
const
QPointF
&
scenePos
,
qreal
width
)
{
QPointF
itemPos
=
mapFromScene
(
scenePos
);
qreal
y
;
if
(
drawLineDirection
==
0
)
{
y
=
rect
().
y
()
+
rect
().
height
()
+
width
/
2
;
}
else
{
y
=
rect
().
y
()
-
width
/
2
;
}
if
(
itemPos
.
x
()
<
rect
().
x
()
+
sLeftEdgeMargin
)
itemPos
.
setX
(
rect
().
x
()
+
sLeftEdgeMargin
);
if
(
itemPos
.
x
()
>
rect
().
x
()
+
rect
().
width
()
-
sLeftEdgeMargin
)
itemPos
.
setX
(
rect
().
x
()
+
rect
().
width
()
-
sLeftEdgeMargin
);
itemPos
.
setY
(
y
);
itemPos
=
mapToScene
(
itemPos
);
// We have to use "pointed" line for marker tool
scene
()
->
drawLineTo
(
itemPos
,
width
,
UBDrawingController
::
drawingController
()
->
stylusTool
()
!=
UBStylusTool
::
Marker
);
}
void
UBGraphicsRuler
::
EndLine
()
{}
src/tools/UBGraphicsRuler.h
View file @
3d8deb8c
...
@@ -14,10 +14,11 @@
...
@@ -14,10 +14,11 @@
#include "core/UB.h"
#include "core/UB.h"
#include "domain/UBItem.h"
#include "domain/UBItem.h"
#include "tools/UBAbstractDrawRuler.h"
class
UBGraphicsScene
;
class
UBGraphicsScene
;
class
UBGraphicsRuler
:
public
QObject
,
public
QGraphicsRectItem
,
public
UBItem
class
UBGraphicsRuler
:
public
UBAbstractDrawRuler
,
public
QGraphicsRectItem
,
public
UBItem
{
{
Q_OBJECT
;
Q_OBJECT
;
...
@@ -34,6 +35,10 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
...
@@ -34,6 +35,10 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBItem
*
deepCopy
()
const
;
virtual
void
StartLine
(
const
QPointF
&
position
,
qreal
width
);
virtual
void
DrawLine
(
const
QPointF
&
position
,
qreal
width
);
virtual
void
EndLine
();
signals
:
signals
:
void
hidden
();
void
hidden
();
...
@@ -63,6 +68,7 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
...
@@ -63,6 +68,7 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QCursor
resizeCursor
()
const
;
QCursor
resizeCursor
()
const
;
QCursor
rotateCursor
()
const
;
QCursor
rotateCursor
()
const
;
QCursor
closeCursor
()
const
;
QCursor
closeCursor
()
const
;
QCursor
drawRulerLineCursor
()
const
;
QRectF
resizeButtonRect
()
const
;
QRectF
resizeButtonRect
()
const
;
QRectF
closeButtonRect
()
const
;
QRectF
closeButtonRect
()
const
;
QRectF
rotateButtonRect
()
const
;
QRectF
rotateButtonRect
()
const
;
...
@@ -72,6 +78,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
...
@@ -72,6 +78,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QColor
edgeFillColor
()
const
;
QColor
edgeFillColor
()
const
;
QFont
font
()
const
;
QFont
font
()
const
;
int
drawLineDirection
;
// Members
// Members
bool
mResizing
;
bool
mResizing
;
bool
mRotating
;
bool
mRotating
;
...
@@ -82,6 +90,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
...
@@ -82,6 +90,8 @@ class UBGraphicsRuler : public QObject, public QGraphicsRectItem, public UBItem
QCursor
mResizeCursor
;
QCursor
mResizeCursor
;
qreal
mAntiScaleRatio
;
qreal
mAntiScaleRatio
;
QPointF
startDrawPosition
;
// Constants
// Constants
static
const
QRect
sDefaultRect
;
static
const
QRect
sDefaultRect
;
static
const
int
sLeftEdgeMargin
=
10
;
static
const
int
sLeftEdgeMargin
=
10
;
...
...
src/tools/tools.pri
View file @
3d8deb8c
...
@@ -4,11 +4,13 @@ HEADERS += src/tools/UBGraphicsRuler.h \
...
@@ -4,11 +4,13 @@ HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBGraphicsCompass.h \
src/tools/UBGraphicsCompass.h \
src/tools/UBToolsManager.h \
src/tools/UBToolsManager.h \
src/tools/UBGraphicsCurtainItem.h \
src/tools/UBGraphicsCurtainItem.h \
src/tools/UBGraphicsCurtainItemDelegate.h
src/tools/UBGraphicsCurtainItemDelegate.h \
src/tools/UBAbstractDrawRuler.h
SOURCES += src/tools/UBGraphicsRuler.cpp \
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsProtractor.cpp \
src/tools/UBGraphicsProtractor.cpp \
src/tools/UBGraphicsCompass.cpp \
src/tools/UBGraphicsCompass.cpp \
src/tools/UBToolsManager.cpp \
src/tools/UBToolsManager.cpp \
src/tools/UBGraphicsCurtainItem.cpp \
src/tools/UBGraphicsCurtainItem.cpp \
src/tools/UBGraphicsCurtainItemDelegate.cpp \
src/tools/UBGraphicsCurtainItemDelegate.cpp \
\ No newline at end of file
src/tools/UBAbstractDrawRuler.cpp
\ No newline at end of file
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