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
519c39c8
Commit
519c39c8
authored
Sep 21, 2012
by
Guillaume Burel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed, improved, cleaned and commented aristo tool.
parent
a74b7ca1
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
357 additions
and
312 deletions
+357
-312
UBGraphicsAristo.cpp
src/tools/UBGraphicsAristo.cpp
+230
-173
UBGraphicsAristo.h
src/tools/UBGraphicsAristo.h
+127
-139
No files found.
src/tools/UBGraphicsAristo.cpp
View file @
519c39c8
This diff is collapsed.
Click to expand it.
src/tools/UBGraphicsAristo.h
View file @
519c39c8
...
@@ -16,150 +16,138 @@
...
@@ -16,150 +16,138 @@
#ifndef UBGRAPHICSARISTO_H_
#ifndef UBGRAPHICSARISTO_H_
#define UBGRAPHICSARISTO_H_
#define UBGRAPHICSARISTO_H_
#include <QtGui>
#include <QtSvg>
#include <QGraphicsPolygonItem>
#include "core/UB.h"
#include "core/UB.h"
#include "domain/UBItem.h"
#include "domain/UBItem.h"
#include "tools/UBAbstractDrawRuler.h"
#include "tools/UBAbstractDrawRuler.h"
#include <QBrush>
class
UBGraphicsScene
;
#include <QCursor>
class
UBItem
;
#include <QGraphicsPathItem>
#include <QGraphicsSceneHoverEvent>
class
UBGraphicsAristo
:
public
UBAbstractDrawRuler
,
public
QGraphicsPolygonItem
,
public
UBItem
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSvgItem>
#include <QPainter>
#include <QPainterPath>
#include <QPointF>
#include <QRectF>
#include <QStyleOptionGraphicsItem>
#include <QTransform>
#include <QWidget>
class
UBGraphicsAristo
:
public
UBAbstractDrawRuler
,
public
QGraphicsPathItem
,
public
UBItem
{
{
Q_OBJECT
Q_OBJECT
public
:
public
:
UBGraphicsAristo
();
UBGraphicsAristo
();
virtual
~
UBGraphicsAristo
();
virtual
~
UBGraphicsAristo
();
enum
{
Type
=
UBGraphicsItemType
::
AristoItemType
};
enum
{
enum
Tool
{
None
,
Move
,
Resize
,
Rotate
,
Close
,
MoveMarker
,
HorizontalFlip
};
Type
=
UBGraphicsItemType
::
AristoItemType
};
virtual
int
type
()
const
{
enum
Tool
{
return
Type
;
None
,
}
Move
,
Resize
,
virtual
UBItem
*
deepCopy
(
void
)
const
;
Rotate
,
virtual
void
copyItemParameters
(
UBItem
*
copy
)
const
;
Close
,
MoveMarker
,
virtual
void
StartLine
(
const
QPointF
&
scenePos
,
qreal
width
);
HorizontalFlip
virtual
void
DrawLine
(
const
QPointF
&
position
,
qreal
width
);
};
virtual
void
EndLine
();
enum
Orientation
enum
UBGraphicsAristoOrientation
{
{
Bottom
=
0
,
Bottom
=
0
,
Top
,
Top
Undefined
};
};
static
UBGraphicsAristoOrientation
orientationFromStr
(
QStringRef
&
str
)
void
setOrientation
(
Orientation
orientation
);
{
void
setBoundingRect
(
QRectF
boundingRect
);
if
(
str
==
"Bottom"
)
return
Bottom
;
if
(
str
==
"Top"
)
return
Top
;
virtual
UBItem
*
deepCopy
()
const
;
return
sDefaultOrientation
;
virtual
void
copyItemParameters
(
UBItem
*
copy
)
const
;
}
static
QString
orientationToStr
(
UBGraphicsAristoOrientation
orientation
)
virtual
void
StartLine
(
const
QPointF
&
scenePos
,
qreal
width
);
{
virtual
void
DrawLine
(
const
QPointF
&
position
,
qreal
width
);
QString
result
;
virtual
void
EndLine
();
if
(
orientation
==
0
)
result
=
"Bottom"
;
else
if
(
orientation
==
1
)
result
=
"Top"
;
virtual
int
type
()
const
{
return
result
;
return
Type
;
}
}
UBGraphicsScene
*
scene
()
const
;
void
setRect
(
const
QRectF
&
rect
,
UBGraphicsAristoOrientation
orientation
)
{
protected
:
setRect
(
rect
.
x
(),
rect
.
y
(),
rect
.
width
(),
rect
.
height
(),
orientation
);
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
styleOption
,
QWidget
*
widget
);
}
virtual
void
rotateAroundCenter
(
qreal
angle
);
void
setRect
(
qreal
x
,
qreal
y
,
qreal
w
,
qreal
h
,
UBGraphicsAristoOrientation
orientation
);
virtual
void
resize
(
qreal
factor
);
void
setOrientation
(
UBGraphicsAristoOrientation
orientation
);
virtual
QPointF
rotationCenter
()
const
;
UBGraphicsAristoOrientation
getOrientation
()
const
{
return
mOrientation
;}
virtual
QRectF
closeButtonRect
()
const
;
QRectF
hFlipRect
()
const
;
QRectF
rect
()
const
{
return
boundingRect
();}
QRectF
markerButtonRect
()
const
;
QRectF
resizeButtonRect
()
const
;
UBGraphicsScene
*
scene
()
const
;
QRectF
rotateRect
()
const
;
protected
:
QCursor
flipCursor
()
const
;
QCursor
markerCursor
()
const
;
virtual
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
styleOption
,
QWidget
*
widget
);
QCursor
resizeCursor
()
const
;
virtual
QPainterPath
shape
()
const
;
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
rotateAroundCenter
(
qreal
angle
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
resize
(
qreal
factor
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
QPointF
rotationCenter
()
const
;
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
QRectF
closeButtonRect
()
const
;
QRectF
resizeButtonRect
()
const
;
private
:
QRectF
hFlipRect
()
const
;
Tool
toolFromPos
(
QPointF
pos
);
QRectF
rotateRect
()
const
;
QRectF
markerButtonRect
()
const
;
QTransform
calculateRotationTransform
();
void
rotateAroundCenter
(
QTransform
&
transform
,
QPointF
center
);
QCursor
flipCursor
()
const
;
QCursor
resizeCursor
()
const
;
void
calculatePoints
();
QCursor
markerCursor
()
const
;
QPainterPath
determinePath
();
void
setItemsPos
();
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
makeGeometryChange
();
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
QBrush
fillBrush
()
const
;
virtual
void
hoverEnterEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
paintGraduations
(
QPainter
*
painter
);
virtual
void
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
paintMarker
(
QPainter
*
painter
);
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
void
paintProtractorGraduations
(
QPainter
*
painter
);
void
paintRulerGraduations
(
QPainter
*
painter
);
private
:
UBGraphicsAristo
::
Tool
toolFromPos
(
QPointF
pos
);
inline
qreal
radius
()
const
QTransform
calculateRotationTransform
();
{
qreal
angle
;
return
sqrt
(((
B
.
x
()
-
A
.
x
())
*
(
B
.
x
()
-
A
.
x
()))
+
((
B
.
y
()
-
A
.
y
())
*
(
B
.
y
()
-
A
.
y
())))
*
9
/
16
-
20
;
}
void
rotateAroundCenter
(
QTransform
&
transform
,
QPointF
center
);
bool
mMarking
;
bool
mResizing
;
bool
mResizing
;
bool
mRotating
;
bool
mRotating
;
bool
mMarking
;
QRect
lastRect
;
Orientation
mOrientation
;
qreal
mSpan
;
qreal
mAngle
;
// Coordinates are transformed....
qreal
mCurrentAngle
;
QPoint
lastPos
;
qreal
mStartAngle
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
QGraphicsSvgItem
*
mRotateSvgItem
;
qreal
mSpan
;
QGraphicsSvgItem
*
mResizeSvgItem
;
QGraphicsSvgItem
*
mMarkerSvgItem
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
qreal
mStartAngle
;
QGraphicsSvgItem
*
mMarkerSvgItem
;
qreal
mCurrentAngle
;
QGraphicsSvgItem
*
mResizeSvgItem
;
QGraphicsSvgItem
*
mRotateSvgItem
;
static
const
QRect
sDefaultRect
;
static
const
UBGraphicsAristoOrientation
sDefaultOrientation
;
QPointF
A
,
B
,
C
;
void
paintGraduations
(
QPainter
*
painter
);
static
const
int
sArcAngleMargin
=
5
;
void
paintRulerGraduations
(
QPainter
*
painter
);
static
const
Orientation
sDefaultOrientation
;
void
paintProtractorGraduations
(
QPainter
*
painter
);
static
const
QRectF
sDefaultRect
;
void
paintMarker
(
QPainter
*
painter
);
inline
qreal
radius
()
const
{
return
sqrt
(((
B
.
x
()
-
A
.
x
())
*
(
B
.
x
()
-
A
.
x
()))
+
((
B
.
y
()
-
A
.
y
())
*
(
B
.
y
()
-
A
.
y
())))
*
9
/
16
-
20
;
}
QBrush
fillBrush
()
const
;
UBGraphicsAristoOrientation
mOrientation
;
void
calculatePoints
(
const
QRectF
&
rect
);
QPointF
A
,
B
,
C
;
static
const
int
d
=
70
;
// width of triangle border
static
const
int
sArrowLength
=
30
;
static
const
int
sMinWidth
=
380
;
static
const
int
sMinHeight
=
200
;
static
const
int
sArcAngleMargin
=
5
;
};
};
#endif
/* UBGRAPHICSARISTO_H_ */
#endif
/* UBGRAPHICSARISTO_H_ */
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