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
625c239e
Commit
625c239e
authored
Jun 04, 2013
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stable selection frame. Transformation fixes
parent
a672c9bf
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
166 additions
and
65 deletions
+166
-65
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-0
UBBoardView.cpp
src/board/UBBoardView.cpp
+24
-33
UBBoardView.h
src/board/UBBoardView.h
+3
-0
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+6
-5
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+11
-7
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+2
-1
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+0
-2
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+36
-7
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+4
-4
UBGraphicsStrokesGroup.cpp
src/domain/UBGraphicsStrokesGroup.cpp
+2
-1
UBSelectionFrame.cpp
src/domain/UBSelectionFrame.cpp
+63
-5
UBSelectionFrame.h
src/domain/UBSelectionFrame.h
+12
-0
No files found.
src/board/UBBoardController.cpp
View file @
625c239e
...
@@ -179,6 +179,7 @@ void UBBoardController::setupViews()
...
@@ -179,6 +179,7 @@ void UBBoardController::setupViews()
mControlLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
mControlLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
mControlView
=
new
UBBoardView
(
this
,
mControlContainer
,
true
,
false
);
mControlView
=
new
UBBoardView
(
this
,
mControlContainer
,
true
,
false
);
mControlView
->
setObjectName
(
CONTROLVIEW_OBJ_NAME
);
mControlView
->
setInteractive
(
true
);
mControlView
->
setInteractive
(
true
);
mControlView
->
setMouseTracking
(
true
);
mControlView
->
setMouseTracking
(
true
);
...
@@ -1514,6 +1515,8 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
...
@@ -1514,6 +1515,8 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
updateSystemScaleFactor
();
updateSystemScaleFactor
();
mControlView
->
setScene
(
mActiveScene
);
mControlView
->
setScene
(
mActiveScene
);
disconnect
(
mControlView
,
SIGNAL
(
mouseReleased
()),
mActiveScene
,
SLOT
(
updateSelectionFrame
()));
connect
(
mControlView
,
SIGNAL
(
mouseReleased
()),
mActiveScene
,
SLOT
(
updateSelectionFrame
()));
mDisplayView
->
setScene
(
mActiveScene
);
mDisplayView
->
setScene
(
mActiveScene
);
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
mActiveScene
->
setBackgroundZoomFactor
(
mControlView
->
transform
().
m11
());
pDocumentProxy
->
setDefaultDocumentSize
(
mActiveScene
->
nominalSize
());
pDocumentProxy
->
setDefaultDocumentSize
(
mActiveScene
->
nominalSize
());
...
...
src/board/UBBoardView.cpp
View file @
625c239e
...
@@ -1023,13 +1023,10 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -1023,13 +1023,10 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
// mUBRubberBand->show();
// mUBRubberBand->show();
// scene()->updateMultipleSelectionFrame();
// scene()->updateMultipleSelectionFrame();
scene
()
->
clearSelectionFrame
();
}
}
if
(
mUBRubberBand
)
{
if
(
mUBRubberBand
)
{
mUBRubberBand
->
hide
();
mUBRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
}
}
handleItemMousePress
(
event
);
handleItemMousePress
(
event
);
...
@@ -1077,7 +1074,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -1077,7 +1074,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
setGeometry
(
QRect
(
mMouseDownPos
,
QSize
()));
mRubberBand
->
show
();
mRubberBand
->
show
();
mIsCreatingSceneGrabZone
=
true
;
mIsCreatingSceneGrabZone
=
true
;
scene
()
->
setMultipleSelectionProcess
(
true
);
event
->
accept
();
event
->
accept
();
break
;
break
;
...
@@ -1102,12 +1098,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -1102,12 +1098,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
void
void
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
{
static
QTime
lastCallTime
;
//
static QTime lastCallTime;
if
(
!
lastCallTime
.
isNull
())
{
//
if (!lastCallTime.isNull()) {
qDebug
()
<<
"time interval is "
<<
lastCallTime
.
msecsTo
(
QTime
::
currentTime
());
//
qDebug() << "time interval is " << lastCallTime.msecsTo(QTime::currentTime());
}
//
}
QTime
mouseMoveTime
=
QTime
::
currentTime
();
//
QTime mouseMoveTime = QTime::currentTime();
if
(
!
mIsDragInProgress
if
(
!
mIsDragInProgress
&&
((
mapToScene
(
event
->
pos
())
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
()))
{
&&
((
mapToScene
(
event
->
pos
())
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
()))
{
qDebug
()
<<
"mouse move event canceled"
;
qDebug
()
<<
"mouse move event canceled"
;
...
@@ -1165,23 +1161,21 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1165,23 +1161,21 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
// mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand
->
setGeometry
(
bandRect
);
mUBRubberBand
->
setGeometry
(
bandRect
);
mUBRubberBand
->
show
();
mUBRubberBand
->
show
();
scene
()
->
setMultipleSelectionProcess
(
true
);
QTime
startTime
=
QTime
::
currentTime
();
//
QTime startTime = QTime::currentTime();
QTime
testTime
=
QTime
::
currentTime
();
//
QTime testTime = QTime::currentTime();
QList
<
QGraphicsItem
*>
rubberItems
=
items
(
bandRect
);
QList
<
QGraphicsItem
*>
rubberItems
=
items
(
bandRect
);
qDebug
()
<<
"=================="
;
//
qDebug() << "==================";
qDebug
()
<<
"| ====rubber items"
<<
testTime
.
msecsTo
(
QTime
::
currentTime
());
//
qDebug() << "| ====rubber items" << testTime.msecsTo(QTime::currentTime());
testTime
=
QTime
::
currentTime
();
//
testTime = QTime::currentTime();
foreach
(
QGraphicsItem
*
item
,
mJustSelectedItems
)
{
foreach
(
QGraphicsItem
*
item
,
mJustSelectedItems
)
{
if
(
!
rubberItems
.
contains
(
item
))
{
if
(
!
rubberItems
.
contains
(
item
))
{
item
->
setSelected
(
false
);
item
->
setSelected
(
false
);
mJustSelectedItems
.
remove
(
item
);
mJustSelectedItems
.
remove
(
item
);
}
}
}
}
qDebug
()
<<
"| ===foreach length"
<<
testTime
.
msecsTo
(
QTime
::
currentTime
());
//
qDebug() << "| ===foreach length" << testTime.msecsTo(QTime::currentTime());
testTime
=
QTime
::
currentTime
();
//
testTime = QTime::currentTime();
int
counter
=
0
;
int
counter
=
0
;
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
...
@@ -1201,15 +1195,15 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1201,15 +1195,15 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
item
->
setSelected
(
true
);
item
->
setSelected
(
true
);
mJustSelectedItems
.
insert
(
item
);
mJustSelectedItems
.
insert
(
item
);
}
}
item
->
setSelected
(
true
);
}
}
}
}
}
}
qDebug
()
<<
"| ==selected items count"
<<
counter
<<
endl
// qDebug() << "| ==selected items count" << counter << endl
<<
"| ==selection time"
<<
testTime
.
msecsTo
(
QTime
::
currentTime
())
<<
endl
// << "| ==selection time" << testTime.msecsTo(QTime::currentTime()) << endl
<<
"| =elapsed time "
<<
startTime
.
msecsTo
(
QTime
::
currentTime
())
<<
endl
// << "| =elapsed time " << startTime.msecsTo(QTime::currentTime()) << endl
<<
"=================="
;
// << "==================";
// QCoreApplication::removePostedEvents(scene(), 0);
}
}
handleItemMouseMove
(
event
);
handleItemMouseMove
(
event
);
}
break
;
}
break
;
...
@@ -1233,8 +1227,8 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1233,8 +1227,8 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
event
->
accept
();
event
->
accept
();
}
}
qDebug
()
<<
"mouse move time"
<<
mouseMoveTime
.
msecsTo
(
QTime
::
currentTime
());
//
qDebug() << "mouse move time" << mouseMoveTime.msecsTo(QTime::currentTime());
lastCallTime
=
QTime
::
currentTime
();
//
lastCallTime = QTime::currentTime();
}
}
void
void
...
@@ -1242,10 +1236,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1242,10 +1236,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{
{
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
UBStylusTool
::
Enum
currentTool
=
(
UBStylusTool
::
Enum
)
UBDrawingController
::
drawingController
()
->
stylusTool
();
setToolCursor
(
currentTool
);
setToolCursor
(
currentTool
);
// first/ propagate device release to the scene
// first/ propagate device release to the scene
if
(
scene
())
if
(
scene
())
scene
()
->
inputDeviceRelease
();
scene
()
->
inputDeviceRelease
();
if
(
currentTool
==
UBStylusTool
::
Selector
)
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
{
...
@@ -1312,8 +1306,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1312,8 +1306,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if
(
mUBRubberBand
&&
mUBRubberBand
->
isVisible
())
{
if
(
mUBRubberBand
&&
mUBRubberBand
->
isVisible
())
{
mUBRubberBand
->
hide
();
mUBRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
updateMultipleSelectionFrame
();
}
}
if
(
bReleaseIsNeed
)
if
(
bReleaseIsNeed
)
...
@@ -1349,8 +1341,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1349,8 +1341,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{
{
if
(
mRubberBand
)
{
if
(
mRubberBand
)
{
mRubberBand
->
hide
();
mRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
updateMultipleSelectionFrame
();
}
}
...
@@ -1377,7 +1367,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1377,7 +1367,6 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
{
{
if
(
mRubberBand
)
{
if
(
mRubberBand
)
{
mRubberBand
->
hide
();
mRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
}
}
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingSceneGrabZone
&&
mRubberBand
->
geometry
().
width
()
>
16
)
if
(
scene
()
&&
mRubberBand
&&
mIsCreatingSceneGrabZone
&&
mRubberBand
->
geometry
().
width
()
>
16
)
...
@@ -1412,6 +1401,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1412,6 +1401,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
movingItem
=
NULL
;
movingItem
=
NULL
;
mLongPressTimer
.
stop
();
mLongPressTimer
.
stop
();
emit
mouseReleased
();
}
}
void
void
...
...
src/board/UBBoardView.h
View file @
625c239e
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#ifndef UBBOARDVIEW_H_
#ifndef UBBOARDVIEW_H_
#define UBBOARDVIEW_H_
#define UBBOARDVIEW_H_
#define CONTROLVIEW_OBJ_NAME "ControlView"
#include <QtGui>
#include <QtGui>
#include "core/UB.h"
#include "core/UB.h"
#include "domain/UBGraphicsDelegateFrame.h"
#include "domain/UBGraphicsDelegateFrame.h"
...
@@ -64,6 +66,7 @@ class UBBoardView : public QGraphicsView
...
@@ -64,6 +66,7 @@ class UBBoardView : public QGraphicsView
void
hidden
();
void
hidden
();
void
shown
();
void
shown
();
void
clickOnBoard
();
void
clickOnBoard
();
void
mouseReleased
();
protected
:
protected
:
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
625c239e
...
@@ -238,9 +238,8 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -238,9 +238,8 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
setCursorFromAngle
(
QString
::
number
((
int
)
mAngle
%
360
));
setCursorFromAngle
(
QString
::
number
((
int
)
mAngle
%
360
));
event
->
accept
();
event
->
accept
();
if
(
moving
())
// if (moving())
prepareFramesToMove
(
getLinkedFrames
());
// prepareFramesToMove(getLinkedFrames());
}
}
void
UBGraphicsDelegateFrame
::
setCursorFromAngle
(
QString
angle
)
void
UBGraphicsDelegateFrame
::
setCursorFromAngle
(
QString
angle
)
...
@@ -395,8 +394,10 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -395,8 +394,10 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
return
;
return
;
QLineF
move
=
QLineF
(
mStartingPoint
,
event
->
scenePos
());
QLineF
move
=
QLineF
(
mStartingPoint
,
event
->
scenePos
());
qreal
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
// qreal moveX = move.length() * cos((move.angle() - mAngle) * PI / 180);
qreal
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
// qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180);
qreal
moveX
=
(
event
->
pos
()
-
mStartingPoint
).
x
();
qreal
moveY
=
(
event
->
pos
()
-
mStartingPoint
).
y
();
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
625c239e
...
@@ -252,6 +252,12 @@ void UBGraphicsItemDelegate::freeControls()
...
@@ -252,6 +252,12 @@ void UBGraphicsItemDelegate::freeControls()
freeButtons
();
freeButtons
();
}
}
void
UBGraphicsItemDelegate
::
showControls
()
{
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
positionHandles
();
}
bool
UBGraphicsItemDelegate
::
controlsExist
()
const
bool
UBGraphicsItemDelegate
::
controlsExist
()
const
{
{
return
mFrame
return
mFrame
...
@@ -278,14 +284,9 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
...
@@ -278,14 +284,9 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
switch
(
static_cast
<
int
>
(
change
))
{
switch
(
static_cast
<
int
>
(
change
))
{
case
QGraphicsItem
:
:
ItemSelectedHasChanged
:
{
case
QGraphicsItem
:
:
ItemSelectedHasChanged
:
{
if
(
ubScene
&&
!
ubScene
->
multipleSelectionProcess
()
)
{
if
(
ubScene
)
{
if
(
value
.
toBool
())
{
//selected(true)
if
(
value
.
toBool
())
{
//selected(true)
if
(
!
controlsExist
())
{
ubScene
->
setSelectedZLevel
(
delegated
());
createControls
();
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
positionHandles
();
ubScene
->
setSelectedZLevel
(
delegated
());
}
}
else
{
}
else
{
ubScene
->
setOwnZlevel
(
delegated
());
ubScene
->
setOwnZlevel
(
delegated
());
freeControls
();
freeControls
();
...
@@ -297,6 +298,9 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
...
@@ -297,6 +298,9 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
case
QGraphicsItem
:
:
ItemPositionHasChanged
:
case
QGraphicsItem
:
:
ItemPositionHasChanged
:
case
QGraphicsItem
:
:
ItemTransformHasChanged
:
case
QGraphicsItem
:
:
ItemTransformHasChanged
:
case
QGraphicsItem
:
:
ItemZValueHasChanged
:
case
QGraphicsItem
:
:
ItemZValueHasChanged
:
if
(
!
controlsExist
())
{
break
;
}
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
positionHandles
();
positionHandles
();
if
(
ubScene
)
{
if
(
ubScene
)
{
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
625c239e
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
if (Scene) { \
if (Scene) { \
Scene->removeItem(Object); \
Scene->removeItem(Object); \
} \
} \
delete Object;
\
Object->deleteLater();
\
Object = 0; \
Object = 0; \
} \
} \
...
@@ -231,6 +231,7 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -231,6 +231,7 @@ class UBGraphicsItemDelegate : public QObject
void
init
();
void
init
();
virtual
void
createControls
();
virtual
void
createControls
();
virtual
void
freeControls
();
virtual
void
freeControls
();
virtual
void
showControls
();
virtual
bool
controlsExist
()
const
;
virtual
bool
controlsExist
()
const
;
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
625c239e
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
* along with Open-Sankoré. If not, see <http://www.gnu.org/licenses/>.
* along with Open-Sankoré. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef UBGRAPHICSPOLYGONITEM_H
#ifndef UBGRAPHICSPOLYGONITEM_H
#define UBGRAPHICSPOLYGONITEM_H
#define UBGRAPHICSPOLYGONITEM_H
...
...
src/domain/UBGraphicsScene.cpp
View file @
625c239e
...
@@ -288,7 +288,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
...
@@ -288,7 +288,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
,
mZLayerController
(
new
UBZLayerController
(
this
))
,
mZLayerController
(
new
UBZLayerController
(
this
))
,
mpLastPolygon
(
NULL
)
,
mpLastPolygon
(
NULL
)
,
mCurrentPolygon
(
0
)
,
mCurrentPolygon
(
0
)
,
mMultipleSelectionProcess
(
false
)
,
mSelectionFrame
(
0
)
,
mSelectionFrame
(
0
)
{
{
UBCoreGraphicsScene
::
setObjectName
(
"BoardScene"
);
UBCoreGraphicsScene
::
setObjectName
(
"BoardScene"
);
...
@@ -1041,20 +1040,50 @@ void UBGraphicsScene::clearSelectionFrame()
...
@@ -1041,20 +1040,50 @@ void UBGraphicsScene::clearSelectionFrame()
}
}
}
}
void
UBGraphicsScene
::
updateMultipleSelectionFrame
()
UBBoardView
*
UBGraphicsScene
::
controlView
()
{
UBBoardView
*
result
=
0
;
foreach
(
QGraphicsView
*
view
,
views
())
{
if
(
view
->
objectName
()
==
CONTROLVIEW_OBJ_NAME
)
{
result
=
static_cast
<
UBBoardView
*>
(
view
);
}
}
return
result
;
}
void
UBGraphicsScene
::
updateSelectionFrame
()
{
{
qDebug
()
<<
"selected item count"
<<
selectedItems
().
count
();
qDebug
()
<<
"selected item count"
<<
selectedItems
().
count
();
QList
<
QGraphicsItem
*>
selItems
=
selectedItems
();
// if (!mMultipleSelectionProcess) {
// return;
// }
if
(
!
mSelectionFrame
)
{
if
(
!
mSelectionFrame
)
{
mSelectionFrame
=
new
UBSelectionFrame
();
mSelectionFrame
=
new
UBSelectionFrame
();
addItem
(
mSelectionFrame
);
addItem
(
mSelectionFrame
);
}
}
mSelectionFrame
->
setEnclosedItems
(
selItems
);
QList
<
QGraphicsItem
*>
selItems
=
selectedItems
();
if
(
!
mSelectionFrame
->
isEmpty
())
{
switch
(
selItems
.
count
())
{
mSelectionFrame
->
setVisible
(
true
);
case
0
:
{
}
else
{
mSelectionFrame
->
setVisible
(
false
);
mSelectionFrame
->
setEnclosedItems
(
selItems
);
}
break
;
case
1
:
{
mSelectionFrame
->
setVisible
(
false
);
mSelectionFrame
->
setVisible
(
false
);
mSelectionFrame
->
setEnclosedItems
(
QList
<
QGraphicsItem
*>
());
UBGraphicsItemDelegate
*
itemDelegate
=
UBGraphicsItem
::
Delegate
(
selItems
.
first
());
itemDelegate
->
createControls
();
selItems
.
first
()
->
setVisible
(
true
);
itemDelegate
->
showControls
();
}
break
;
default
:
{
mSelectionFrame
->
setVisible
(
true
);
mSelectionFrame
->
setEnclosedItems
(
selItems
);
}
break
;
}
}
}
}
...
...
src/domain/UBGraphicsScene.h
View file @
625c239e
...
@@ -55,6 +55,7 @@ class UBMagnifier;
...
@@ -55,6 +55,7 @@ class UBMagnifier;
class
UBGraphicsCache
;
class
UBGraphicsCache
;
class
UBGraphicsGroupContainerItem
;
class
UBGraphicsGroupContainerItem
;
class
UBSelectionFrame
;
class
UBSelectionFrame
;
class
UBBoardView
;
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
...
@@ -309,12 +310,12 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -309,12 +310,12 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
static
QUuid
getPersonalUuid
(
QGraphicsItem
*
item
);
static
QUuid
getPersonalUuid
(
QGraphicsItem
*
item
);
UBGraphicsPolygonItem
*
polygonToPolygonItem
(
const
QPolygonF
pPolygon
);
UBGraphicsPolygonItem
*
polygonToPolygonItem
(
const
QPolygonF
pPolygon
);
void
setMultipleSelectionProcess
(
bool
pEnabled
)
{
mMultipleSelectionProcess
=
pEnabled
;}
bool
multipleSelectionProcess
()
const
{
return
mMultipleSelectionProcess
;}
void
clearSelectionFrame
();
void
clearSelectionFrame
();
void
updateMultipleSelectionFrame
();
UBBoardView
*
controlView
();
public
slots
:
public
slots
:
void
updateSelectionFrame
();
void
initStroke
();
void
initStroke
();
void
hideEraser
();
void
hideEraser
();
...
@@ -430,7 +431,6 @@ public slots:
...
@@ -430,7 +431,6 @@ public slots:
bool
mDrawWithCompass
;
bool
mDrawWithCompass
;
UBGraphicsPolygonItem
*
mCurrentPolygon
;
UBGraphicsPolygonItem
*
mCurrentPolygon
;
bool
mMultipleSelectionProcess
;
UBSelectionFrame
*
mSelectionFrame
;
UBSelectionFrame
*
mSelectionFrame
;
};
};
...
...
src/domain/UBGraphicsStrokesGroup.cpp
View file @
625c239e
...
@@ -187,8 +187,9 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
...
@@ -187,8 +187,9 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
}
}
styleOption
.
state
&=
~
QStyle
::
State_Selected
;
styleOption
.
state
&=
~
QStyle
::
State_Selected
;
QGraphicsItemGroup
::
paint
(
painter
,
&
styleOption
,
widget
);
QGraphicsItemGroup
::
paint
(
painter
,
&
styleOption
,
widget
);
if
(
selectedState
)
{
if
(
selectedState
&&
!
Delegate
()
->
controlsExist
()
)
{
painter
->
save
();
painter
->
save
();
painter
->
setPen
(
Qt
::
NoPen
);
painter
->
setBrush
(
QColor
(
0x88
,
0x88
,
0x88
,
0x77
));
painter
->
setBrush
(
QColor
(
0x88
,
0x88
,
0x88
,
0x77
));
painter
->
drawRect
(
boundingRect
());
painter
->
drawRect
(
boundingRect
());
painter
->
restore
();
painter
->
restore
();
...
...
src/domain/UBSelectionFrame.cpp
View file @
625c239e
...
@@ -15,7 +15,7 @@ UBSelectionFrame::UBSelectionFrame()
...
@@ -15,7 +15,7 @@ UBSelectionFrame::UBSelectionFrame()
setLocalBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setLocalBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setFlags
(
QGraphicsItem
::
ItemIsMovable
);
setFlags
(
QGraphicsItem
::
Item
SendsGeometryChanges
/*| QGraphicsItem::ItemIsSelectable*/
|
Item
IsMovable
);
connect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
(
qreal
)));
connect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
(
qreal
)));
}
}
...
@@ -61,16 +61,17 @@ QPainterPath UBSelectionFrame::shape() const
...
@@ -61,16 +61,17 @@ QPainterPath UBSelectionFrame::shape() const
void
UBSelectionFrame
::
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
)
void
UBSelectionFrame
::
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
)
{
{
QRe
ctF
resultRect
;
QRe
gion
resultRegion
;
mEnclosedtems
.
clear
();
mEnclosedtems
.
clear
();
foreach
(
QGraphicsItem
*
nextItem
,
pGraphicsItems
)
{
foreach
(
QGraphicsItem
*
nextItem
,
pGraphicsItems
)
{
UBGraphicsItemDelegate
*
nextDelegate
=
UBGraphicsItem
::
Delegate
(
nextItem
);
UBGraphicsItemDelegate
*
nextDelegate
=
UBGraphicsItem
::
Delegate
(
nextItem
);
if
(
nextDelegate
)
{
if
(
nextDelegate
)
{
mEnclosedtems
.
append
(
nextDelegate
);
mEnclosedtems
.
append
(
nextDelegate
);
resultRe
ct
|=
nextItem
->
boundingRect
(
);
resultRe
gion
|=
nextItem
->
boundingRegion
(
nextItem
->
sceneTransform
()
);
}
}
}
}
QRectF
resultRect
=
resultRegion
.
boundingRect
();
setRect
(
resultRect
);
setRect
(
resultRect
);
if
(
resultRect
.
isEmpty
())
{
if
(
resultRect
.
isEmpty
())
{
...
@@ -80,11 +81,12 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
...
@@ -80,11 +81,12 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
void
UBSelectionFrame
::
updateRect
()
void
UBSelectionFrame
::
updateRect
()
{
{
QRe
ctF
result
;
QRe
gion
resultRegion
;
foreach
(
UBGraphicsItemDelegate
*
curDelegateItem
,
mEnclosedtems
)
{
foreach
(
UBGraphicsItemDelegate
*
curDelegateItem
,
mEnclosedtems
)
{
result
|=
curDelegateItem
->
delegated
()
->
boundingRect
(
);
result
Region
|=
curDelegateItem
->
delegated
()
->
boundingRegion
(
curDelegateItem
->
delegated
()
->
sceneTransform
()
);
}
}
QRectF
result
=
resultRegion
.
boundingRect
();
setRect
(
result
);
setRect
(
result
);
if
(
result
.
isEmpty
())
{
if
(
result
.
isEmpty
())
{
...
@@ -97,9 +99,65 @@ void UBSelectionFrame::updateScale()
...
@@ -97,9 +99,65 @@ void UBSelectionFrame::updateScale()
setScale
(
-
UBApplication
::
boardController
->
currentZoom
());
setScale
(
-
UBApplication
::
boardController
->
currentZoom
());
}
}
void
UBSelectionFrame
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mPressedPos
=
mLastMovedPos
=
event
->
pos
();
mLastTranslateOffset
=
QPointF
();
// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
// qDebug() << "TransformBefore" << curDelegate->delegated()->transform();
// }
// QGraphicsRectItem::mousePressEvent(event);
}
void
UBSelectionFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
QPointF
dp
=
event
->
pos
()
-
mPressedPos
;
foreach
(
UBGraphicsItemDelegate
*
curDelegate
,
mEnclosedtems
)
{
QGraphicsItem
*
item
=
curDelegate
->
delegated
();
QTransform
ownTransform
=
item
->
transform
();
QTransform
dTransform
(
ownTransform
.
m11
()
,
ownTransform
.
m12
()
,
ownTransform
.
m13
()
,
ownTransform
.
m21
()
,
ownTransform
.
m22
()
,
ownTransform
.
m23
()
,
ownTransform
.
m31
()
+
(
dp
-
mLastTranslateOffset
).
x
()
,
ownTransform
.
m32
()
+
(
dp
-
mLastTranslateOffset
).
y
()
,
ownTransform
.
m33
()
);
item
->
setTransform
(
dTransform
);
}
updateRect
();
mLastMovedPos
=
event
->
pos
();
mLastTranslateOffset
=
dp
;
}
void
UBSelectionFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
{
mPressedPos
=
mLastMovedPos
=
QPointF
();
// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
// qDebug() << "TransformBefore" << curDelegate->delegated()->transform();
// }
// QGraphicsRectItem::mouseReleaseEvent(event);
}
void
UBSelectionFrame
::
onZoomChanged
(
qreal
pZoom
)
void
UBSelectionFrame
::
onZoomChanged
(
qreal
pZoom
)
{
{
mAntiscaleRatio
=
pZoom
;
mAntiscaleRatio
=
pZoom
;
updateScale
();
updateScale
();
}
void
UBSelectionFrame
::
translateItem
(
QGraphicsItem
*/
*
item
*/
,
const
QPointF
&
/*translatePoint*/
)
{
}
}
src/domain/UBSelectionFrame.h
View file @
625c239e
...
@@ -25,15 +25,27 @@ public:
...
@@ -25,15 +25,27 @@ public:
void
updateScale
();
void
updateScale
();
bool
isEmpty
()
const
{
return
this
->
rect
().
isEmpty
();}
bool
isEmpty
()
const
{
return
this
->
rect
().
isEmpty
();}
protected
:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
private
slots
:
private
slots
:
void
setAntiScaleRatio
(
qreal
pAntiscaleRatio
)
{
mAntiscaleRatio
=
pAntiscaleRatio
;}
void
setAntiScaleRatio
(
qreal
pAntiscaleRatio
)
{
mAntiscaleRatio
=
pAntiscaleRatio
;}
void
onZoomChanged
(
qreal
pZoom
);
void
onZoomChanged
(
qreal
pZoom
);
private
:
void
translateItem
(
QGraphicsItem
*
item
,
const
QPointF
&
translatePoint
);
private
:
private
:
int
mThickness
;
int
mThickness
;
qreal
mAntiscaleRatio
;
qreal
mAntiscaleRatio
;
QList
<
UBGraphicsItemDelegate
*>
mEnclosedtems
;
QList
<
UBGraphicsItemDelegate
*>
mEnclosedtems
;
QBrush
mLocalBrush
;
QBrush
mLocalBrush
;
QPointF
mPressedPos
;
QPointF
mLastMovedPos
;
QPointF
mLastTranslateOffset
;
};
};
#endif // UBSELECTIONFRAME_H
#endif // UBSELECTIONFRAME_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