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
a5aa8996
Commit
a5aa8996
authored
Apr 05, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-80
Objects rotation
parent
ab1b28e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
8 deletions
+44
-8
UBSettings.cpp
src/core/UBSettings.cpp
+3
-0
UBSettings.h
src/core/UBSettings.h
+3
-2
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+28
-3
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+6
-1
domain.pri
src/domain/domain.pri
+4
-2
No files found.
src/core/UBSettings.cpp
View file @
a5aa8996
...
...
@@ -377,6 +377,8 @@ void UBSettings::init()
KeyboardLocale
=
new
UBSetting
(
this
,
"Board"
,
"StartupKeyboardLocale"
,
0
);
swapControlAndDisplayScreens
=
new
UBSetting
(
this
,
"App"
,
"SwapControlAndDisplayScreens"
,
false
);
angleTolerance
=
new
UBSetting
(
this
,
"App"
,
"AngleTolerance"
,
4
);
}
...
...
@@ -1139,3 +1141,4 @@ QString UBSettings::replaceWildcard(QString& path)
return
result
;
}
src/core/UBSettings.h
View file @
a5aa8996
...
...
@@ -97,8 +97,7 @@ class UBSettings : public QObject
void
setCommunityPassword
(
const
QString
&
password
);
void
init
();
//user directories
static
QString
userDataDirectory
();
static
QString
userDocumentDirectory
();
...
...
@@ -326,6 +325,8 @@ class UBSettings : public QObject
UBSetting
*
KeyboardLocale
;
UBSetting
*
swapControlAndDisplayScreens
;
UBSetting
*
angleTolerance
;
public
slots
:
void
setPenWidthIndex
(
int
index
);
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
a5aa8996
...
...
@@ -29,8 +29,6 @@
#include "core/memcheck.h"
qreal
const
UBGraphicsDelegateFrame
::
mAngleTolerance
=
6
;
UBGraphicsDelegateFrame
::
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
)
:
QGraphicsRectItem
(),
QObject
(
pDelegate
)
,
mCurrentTool
(
None
)
...
...
@@ -51,6 +49,8 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
,
mMirrorX
(
false
)
,
mMirrorY
(
false
)
{
mAngleTolerance
=
UBSettings
::
settings
()
->
angleTolerance
->
get
().
toReal
();
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setAcceptedMouseButtons
(
Qt
::
LeftButton
);
...
...
@@ -90,11 +90,14 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
positionHandles
();
this
->
setAcceptHoverEvents
(
true
);
angleWidget
=
new
UBAngleWidget
();
}
UBGraphicsDelegateFrame
::~
UBGraphicsDelegateFrame
()
{
delete
angleWidget
;
// NOOP
}
...
...
@@ -372,7 +375,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QLineF
startLine
(
sceneBoundingRect
().
center
(),
event
->
lastScenePos
());
QLineF
currentLine
(
sceneBoundingRect
().
center
(),
event
->
scenePos
());
mAngle
+=
startLine
.
angleTo
(
currentLine
);
if
((
int
)
mAngle
%
45
>=
45
-
mAngleTolerance
||
(
int
)
mAngle
%
45
<=
mAngleTolerance
)
if
((
int
)
mAngle
%
45
>=
45
-
mAngleTolerance
||
(
int
)
mAngle
%
45
<=
mAngleTolerance
)
{
mAngle
=
qRound
(
mAngle
/
45
)
*
45
;
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
...
...
@@ -382,6 +387,23 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
mAngleOffset
=
0
;
}
}
else
if
((
int
)
mAngle
%
30
>=
30
-
mAngleTolerance
||
(
int
)
mAngle
%
30
<=
mAngleTolerance
)
{
mAngle
=
qRound
(
mAngle
/
30
)
*
30
;
mAngleOffset
+=
startLine
.
angleTo
(
currentLine
);
if
((
int
)
mAngleOffset
%
360
>
mAngleTolerance
&&
(
int
)
mAngleOffset
%
360
<
360
-
mAngleTolerance
)
{
mAngle
+=
mAngleOffset
;
mAngleOffset
=
0
;
}
}
if
(
!
angleWidget
->
isVisible
())
angleWidget
->
show
();
angleWidget
->
setText
(
QString
::
number
((
int
)
mAngle
%
360
));
angleWidget
->
update
();
}
else
if
(
moving
())
...
...
@@ -451,6 +473,9 @@ QTransform UBGraphicsDelegateFrame::buildTransform()
void
UBGraphicsDelegateFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
angleWidget
->
isVisible
())
angleWidget
->
hide
();
updateResizeCursors
();
mDelegate
->
commitUndoStep
();
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
a5aa8996
...
...
@@ -18,6 +18,7 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBAngleWidget.h"
class
QGraphicsSceneMouseEvent
;
class
UBGraphicsItemDelegate
;
...
...
@@ -91,7 +92,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
qreal
mTranslateY
;
qreal
mTotalTranslateX
;
qreal
mTotalTranslateY
;
static
const
qreal
mAngleTolerance
;
qreal
mAngleTolerance
;
QRect
mAngleRect
;
QPointF
mStartingPoint
;
QTransform
mInitialTransform
;
...
...
@@ -117,5 +119,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool
mResizing
;
bool
mMirroredXAtStart
;
bool
mMirroredYAtStart
;
UBAngleWidget
*
angleWidget
;
};
#endif
/* UBGRAPHICSDELEGATEFRAME_H_ */
src/domain/domain.pri
View file @
a5aa8996
...
...
@@ -22,7 +22,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsMediaItem.h \
src/domain/UBGraphicsAudioItem.h \
src/domain/UBGraphicsAudioItemDelegate.h \
src/domain/UBAbstractUndoCommand.h
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsVideoItemDelegate.h \
...
...
@@ -54,7 +55,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBGraphicsAudioItem.cpp \
src/domain/UBGraphicsAudioItemDelegate.cpp \
src/domain/UBAbstractUndoCommand.cpp
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsVideoItemDelegate.cpp \
...
...
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