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
8b6a9279
Commit
8b6a9279
authored
Nov 26, 2015
by
agriche
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Bypass the boundRect() method at each resizepolygon.
parent
691eb2a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
5 deletions
+56
-5
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+40
-2
UBGraphicsTriangle.h
src/tools/UBGraphicsTriangle.h
+16
-3
No files found.
src/tools/UBGraphicsTriangle.cpp
View file @
8b6a9279
...
...
@@ -25,8 +25,10 @@
#include <QGraphicsPolygonItem>
//#include <QGraphicsPolygonItem>
#include <QPolygonF>
#include <QtWidgets/QGraphicsPolygonItem>
#include "tools/UBGraphicsTriangle.h"
#include "core/UBApplication.h"
...
...
@@ -131,19 +133,38 @@ void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsT
polygon
<<
QPointF
(
x
,
y
)
<<
QPoint
(
x
,
y
+
h
)
<<
QPoint
(
x
+
w
,
y
+
h
);
setPolygon
(
polygon
);
// Save the bounds rect
bounds_rect
.
setX
(
x
);
bounds_rect
.
setY
(
y
);
bounds_rect
.
setWidth
(
w
);
bounds_rect
.
setHeight
(
h
);
setOrientation
(
orientation
);
}
void
UBGraphicsTriangle
::
setOrientation
(
UBGraphicsTriangleOrientation
orientation
)
{
mOrientation
=
orientation
;
calculatePoints
(
boundingRect
());
//calculatePoints(boundingRect());
calculatePoints
(
bounds_rect
);
QPolygonF
polygon
;
polygon
<<
A1
<<
B1
<<
C1
;
setPolygon
(
polygon
);
}
QRectF
UBGraphicsTriangle
::
bounding_Rect
()
const
{
QRectF
bounds
=
QRectF
(
0
,
0
,
0
,
0
);
bounds
.
setX
(
bounds_rect
.
x
());
bounds
.
setY
(
bounds_rect
.
y
());
bounds
.
setWidth
(
bounds_rect
.
width
());
bounds
.
setHeight
(
bounds_rect
.
height
());
return
bounds
;
}
UBGraphicsScene
*
UBGraphicsTriangle
::
scene
()
const
{
return
static_cast
<
UBGraphicsScene
*>
(
QGraphicsPolygonItem
::
scene
());
...
...
@@ -151,6 +172,8 @@ UBGraphicsScene* UBGraphicsTriangle::scene() const
void
UBGraphicsTriangle
::
calculatePoints
(
const
QRectF
&
r
)
{
//qDebug() << "UBGraphicsTriangle calculatePoints()"<<"r ="<<r<<"mOrientation ="<<mOrientation;
switch
(
mOrientation
)
{
...
...
@@ -277,6 +300,10 @@ void UBGraphicsTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem
mRotateSvgItem
->
setTransform
(
antiScaleTransform
);
mCloseSvgItem
->
setPos
(
closeButtonRect
().
topLeft
());
qDebug
()
<<
"UBGraphicsTriangle Paint"
<<
"closeButtonRect().topLeft()="
<<
closeButtonRect
().
topLeft
();
mHFlipSvgItem
->
setPos
(
hFlipRect
().
topLeft
());
mVFlipSvgItem
->
setPos
(
vFlipRect
().
topLeft
());
mRotateSvgItem
->
setPos
(
rotateRect
().
topLeft
());
...
...
@@ -289,6 +316,8 @@ void UBGraphicsTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem
if
(
mShowButtons
||
mResizing2
)
painter
->
drawPolygon
(
resize2Polygon
());
}
}
QPainterPath
UBGraphicsTriangle
::
shape
()
const
...
...
@@ -296,6 +325,8 @@ QPainterPath UBGraphicsTriangle::shape() const
QPainterPath
tShape
;
QPolygonF
tPolygon
;
qDebug
()
<<
"UBGraphicsTriangle shape()"
<<
"A1 ="
<<
A1
<<
"B1 ="
<<
B1
<<
"C1 ="
<<
C1
;
tPolygon
<<
A1
<<
B1
<<
C1
;
tShape
.
addPolygon
(
tPolygon
);
tPolygon
.
clear
();
...
...
@@ -304,6 +335,9 @@ QPainterPath UBGraphicsTriangle::shape() const
tShape
.
addPolygon
(
tPolygon
);
tPolygon
.
clear
();
qDebug
()
<<
"UBGraphicsTriangle shape()"
<<
"A1 ="
<<
A1
<<
"B1 ="
<<
B1
<<
"C1 ="
<<
C1
;
qDebug
()
<<
"UBGraphicsTriangle shape()"
<<
"A2 ="
<<
A2
<<
"B2 ="
<<
B2
<<
"C2 ="
<<
C2
;
return
tShape
;
}
...
...
@@ -800,6 +834,10 @@ void UBGraphicsTriangle::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
UBDrawingController
::
drawingController
()
->
mActiveRuler
=
this
;
event
->
accept
();
}
//
//event->accept(); //**
//update(); //**
}
void
UBGraphicsTriangle
::
hoverLeaveEvent
(
QGraphicsSceneHoverEvent
*
event
)
...
...
src/tools/UBGraphicsTriangle.h
View file @
8b6a9279
...
...
@@ -28,9 +28,14 @@
#ifndef UBGRAPHICSTRIANGLE_H_
#define UBGRAPHICSTRIANGLE_H_
#include <QtGui>
//#include <QtGui>
#include <QtWidgets>
#include <QtSvg>
#include <QGraphicsPolygonItem>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsPolygonItem>
#include "core/UB.h"
#include "domain/UBItem.h"
...
...
@@ -92,7 +97,9 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
void
setRect
(
const
QRectF
&
rect
,
UBGraphicsTriangleOrientation
orientation
)
{
setRect
(
rect
.
x
(),
rect
.
y
(),
rect
.
width
(),
rect
.
height
(),
orientation
);
qDebug
()
<<
"setRect"
<<
"rect = "
<<
rect
<<
"orientation :"
<<
orientation
;
setRect
(
rect
.
x
(),
rect
.
y
(),
rect
.
width
(),
rect
.
height
(),
orientation
);
}
void
setRect
(
qreal
x
,
qreal
y
,
qreal
w
,
qreal
h
,
UBGraphicsTriangleOrientation
orientation
);
void
setOrientation
(
UBGraphicsTriangleOrientation
orientation
);
...
...
@@ -119,6 +126,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
QRectF
vFlipRect
()
const
;
QRectF
rotateRect
()
const
;
QRectF
bounding_Rect
()
const
;
QCursor
resizeCursor1
()
const
;
QCursor
resizeCursor2
()
const
;
...
...
@@ -149,6 +158,10 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
// Coordinates are transformed....
QPoint
lastPos
;
// Save the last bounds rect
QRectF
bounds_rect
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
QGraphicsSvgItem
*
mVFlipSvgItem
;
QGraphicsSvgItem
*
mRotateSvgItem
;
...
...
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