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
741298c0
Commit
741298c0
authored
May 17, 2013
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Common and private frame
parent
07a270bf
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
276 additions
and
62 deletions
+276
-62
Sankore_3.1.pro
Sankore_3.1.pro
+1
-0
UBBoardView.cpp
src/board/UBBoardView.cpp
+31
-3
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+64
-54
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+9
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+20
-1
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+3
-2
UBSelectionFrame.cpp
src/domain/UBSelectionFrame.cpp
+105
-0
UBSelectionFrame.h
src/domain/UBSelectionFrame.h
+39
-0
domain.pri
src/domain/domain.pri
+4
-2
No files found.
Sankore_3.1.pro
View file @
741298c0
...
@@ -374,6 +374,7 @@ macx {
...
@@ -374,6 +374,7 @@ macx {
linux-g++
* {
linux-g++
* {
CONFIG += link_prl
CONFIG += link_prl
LIBS += -lcrypto
LIBS += -lcrypto
LIBS += -lprofiler
LIBS += -lX11
LIBS += -lX11
QMAKE_CFLAGS += -fopenmp
QMAKE_CFLAGS += -fopenmp
QMAKE_CXXFLAGS += -fopenmp
QMAKE_CXXFLAGS += -fopenmp
...
...
src/board/UBBoardView.cpp
View file @
741298c0
...
@@ -1028,10 +1028,11 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -1028,10 +1028,11 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
}
}
else
else
{
{
if
(
mUBRubberBand
)
if
(
mUBRubberBand
)
{
mUBRubberBand
->
hide
();
mUBRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
setMultipleSelectionProcess
(
false
);
}
}
}
handleItemMousePress
(
event
);
handleItemMousePress
(
event
);
event
->
accept
();
event
->
accept
();
...
@@ -1107,6 +1108,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -1107,6 +1108,12 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
void
void
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
UBBoardView
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
{
static
QTime
lastCallTime
;
if
(
!
lastCallTime
.
isNull
())
{
qDebug
()
<<
"time interval is "
<<
lastCallTime
.
msecsTo
(
QTime
::
currentTime
());
}
QTime
mouseMoveTime
=
QTime
::
currentTime
();
if
(
!
mIsDragInProgress
&&
((
mapToScene
(
event
->
pos
())
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
()))
if
(
!
mIsDragInProgress
&&
((
mapToScene
(
event
->
pos
())
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
()))
{
{
return
;
return
;
...
@@ -1153,15 +1160,23 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1153,15 +1160,23 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
mUBRubberBand
->
setGeometry
(
bandRect
);
mUBRubberBand
->
setGeometry
(
bandRect
);
QTime
startTime
=
QTime
::
currentTime
();
QTime
testTime
=
QTime
::
currentTime
();
QList
<
QGraphicsItem
*>
rubberItems
=
items
(
bandRect
);
QList
<
QGraphicsItem
*>
rubberItems
=
items
(
bandRect
);
qDebug
()
<<
"=================="
;
qDebug
()
<<
"| ====rubber items"
<<
testTime
.
msecsTo
(
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
());
testTime
=
QTime
::
currentTime
();
if
(
currentTool
==
UBStylusTool
::
Selector
)
int
counter
=
0
;
if
(
currentTool
==
UBStylusTool
::
Selector
)
{
foreach
(
QGraphicsItem
*
item
,
items
(
bandRect
))
{
foreach
(
QGraphicsItem
*
item
,
items
(
bandRect
))
{
if
(
item
->
type
()
==
UBGraphicsW3CWidgetItem
::
Type
if
(
item
->
type
()
==
UBGraphicsW3CWidgetItem
::
Type
...
@@ -1172,12 +1187,21 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1172,12 +1187,21 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
||
item
->
type
()
==
UBGraphicsStrokesGroup
::
Type
||
item
->
type
()
==
UBGraphicsStrokesGroup
::
Type
||
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
||
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
if
(
!
mJustSelectedItems
.
contains
(
item
))
{
if
(
!
mJustSelectedItems
.
contains
(
item
))
{
counter
++
;
item
->
setSelected
(
true
);
item
->
setSelected
(
true
);
mJustSelectedItems
.
insert
(
item
);
mJustSelectedItems
.
insert
(
item
);
}
}
item
->
setSelected
(
true
);
}
}
}
}
}
qDebug
()
<<
"| ==selected items count"
<<
counter
<<
endl
<<
"| ==selection time"
<<
testTime
.
msecsTo
(
QTime
::
currentTime
())
<<
endl
<<
"| =elapsed time "
<<
startTime
.
msecsTo
(
QTime
::
currentTime
())
<<
endl
<<
"=================="
;
}
}
}
}
...
@@ -1211,6 +1235,8 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
...
@@ -1211,6 +1235,8 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
if
((
event
->
pos
()
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
())
if
((
event
->
pos
()
-
mLastPressedMousePos
).
manhattanLength
()
<
QApplication
::
startDragDistance
())
mWidgetMoved
=
true
;
mWidgetMoved
=
true
;
qDebug
()
<<
"mouse move time"
<<
mouseMoveTime
.
msecsTo
(
QTime
::
currentTime
());
lastCallTime
=
QTime
::
currentTime
();
}
}
void
void
...
@@ -1289,6 +1315,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1289,6 +1315,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if
(
mUBRubberBand
&&
mUBRubberBand
->
isVisible
())
{
if
(
mUBRubberBand
&&
mUBRubberBand
->
isVisible
())
{
mUBRubberBand
->
hide
();
mUBRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
updateMultipleSelectionFrame
();
}
}
if
(
bReleaseIsNeed
)
if
(
bReleaseIsNeed
)
...
@@ -1325,6 +1352,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
...
@@ -1325,6 +1352,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
if
(
mRubberBand
)
{
if
(
mRubberBand
)
{
mRubberBand
->
hide
();
mRubberBand
->
hide
();
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
setMultipleSelectionProcess
(
false
);
scene
()
->
updateMultipleSelectionFrame
();
}
}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
741298c0
...
@@ -179,61 +179,67 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
...
@@ -179,61 +179,67 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
void
UBGraphicsItemDelegate
::
init
()
{
{
// if (mToolBarUsed)
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
// mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
setFlippable
(
false
);
setRotatable
(
false
);
// mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
// mFrame->hide();
// mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
// mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
// mButtons << mDeleteButton;
// connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
// if (canDuplicate()){
// mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
// connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
// mButtons << mDuplicateButton;
// }
// mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
// connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
// mButtons << mMenuButton;
// mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, Qt::BottomLeftSection);
// mZOrderUpButton->setShowProgressIndicator(true);
// connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
// connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
// mButtons << mZOrderUpButton;
// mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", mDelegated, mFrame, Qt::BottomLeftSection);
// mZOrderDownButton->setShowProgressIndicator(true);
// connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
// mButtons << mZOrderDownButton;
// buildButtons();
// foreach(DelegateButton* button, mButtons)
// {
// if (button->getSection() != Qt::TitleBarArea)
// {
// button->hide();
// button->setFlag(QGraphicsItem::ItemIsSelectable, true);
// }
// }
// //Wrapper function. Use it to set correct data() to QGraphicsItem as well
// setFlippable(false);
// setRotatable(false);
}
}
void
UBGraphicsItemDelegate
::
createControls
()
void
UBGraphicsItemDelegate
::
createControls
()
{
{
if
(
mToolBarUsed
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderUpButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderUpButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelUp
()));
connect
(
mZOrderUpButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelTop
()));
mButtons
<<
mZOrderUpButton
;
mZOrderDownButton
=
new
DelegateButton
(
":/images/z_layer_down.svg"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
}
void
UBGraphicsItemDelegate
::
freeControls
()
void
UBGraphicsItemDelegate
::
freeControls
()
{
{
QGraphicsScene
*
controlsScene
=
delegated
()
->
scene
();
UB_FREE_CONTROL
(
mFrame
,
controlsScene
);
UB_FREE_CONTROL
(
mDeleteButton
,
controlsScene
);
UB_FREE_CONTROL
(
mMenuButton
,
controlsScene
);
UB_FREE_CONTROL
(
mZOrderUpButton
,
controlsScene
);
UB_FREE_CONTROL
(
mZOrderDownButton
,
controlsScene
);
freeButtons
();
}
}
...
@@ -266,15 +272,16 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
...
@@ -266,15 +272,16 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
}
}
// if ((change == QGraphicsItem::ItemSelectedHasChanged
if
((
change
==
QGraphicsItem
::
ItemSelectedHasChanged
// || change == QGraphicsItem::ItemPositionHasChanged
||
change
==
QGraphicsItem
::
ItemPositionHasChanged
// || change == QGraphicsItem::ItemTransformHasChanged)
||
change
==
QGraphicsItem
::
ItemTransformHasChanged
)
// && mDelegated->scene()
&&
mDelegated
->
scene
()
// && UBApplication::boardController)
&&
UBApplication
::
boardController
)
// {
{
// mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
createControls
();
// positionHandles();
mAntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
// }
positionHandles
();
}
if
(
change
==
QGraphicsItem
::
ItemPositionHasChanged
if
(
change
==
QGraphicsItem
::
ItemPositionHasChanged
||
change
==
QGraphicsItem
::
ItemTransformHasChanged
||
change
==
QGraphicsItem
::
ItemTransformHasChanged
...
@@ -611,6 +618,9 @@ void UBGraphicsItemDelegate::onZoomChanged()
...
@@ -611,6 +618,9 @@ void UBGraphicsItemDelegate::onZoomChanged()
void
UBGraphicsItemDelegate
::
buildButtons
()
void
UBGraphicsItemDelegate
::
buildButtons
()
{
{
}
}
void
UBGraphicsItemDelegate
::
freeButtons
()
{
}
void
UBGraphicsItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
void
UBGraphicsItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
{
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
741298c0
...
@@ -24,6 +24,14 @@
...
@@ -24,6 +24,14 @@
#ifndef UBGRAPHICSITEMDELEGATE_H_
#ifndef UBGRAPHICSITEMDELEGATE_H_
#define UBGRAPHICSITEMDELEGATE_H_
#define UBGRAPHICSITEMDELEGATE_H_
#define UB_FREE_CONTROL(Object, Scene) \
if (Object) { \
if (Scene) { \
Scene->removeItem(Object); \
} \
delete Object; \
} \
#include <QtGui>
#include <QtGui>
#include <QtSvg>
#include <QtSvg>
#include <QMimeData>
#include <QMimeData>
...
@@ -289,6 +297,7 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -289,6 +297,7 @@ class UBGraphicsItemDelegate : public QObject
protected
:
protected
:
virtual
void
buildButtons
();
virtual
void
buildButtons
();
virtual
void
freeButtons
();
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
decorateMenu
(
QMenu
*
menu
);
virtual
void
updateMenuActionState
();
virtual
void
updateMenuActionState
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
741298c0
...
@@ -66,6 +66,7 @@
...
@@ -66,6 +66,7 @@
#include "UBGraphicsPDFItem.h"
#include "UBGraphicsPDFItem.h"
#include "UBGraphicsTextItem.h"
#include "UBGraphicsTextItem.h"
#include "UBGraphicsStrokesGroup.h"
#include "UBGraphicsStrokesGroup.h"
#include "UBSelectionFrame.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsGroupContainerItem.h"
...
@@ -288,6 +289,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
...
@@ -288,6 +289,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
,
mpLastPolygon
(
NULL
)
,
mpLastPolygon
(
NULL
)
,
mCurrentPolygon
(
0
)
,
mCurrentPolygon
(
0
)
,
mMultipleSelectionProcess
(
false
)
,
mMultipleSelectionProcess
(
false
)
,
mSelectionFrame
(
0
)
{
{
UBCoreGraphicsScene
::
setObjectName
(
"BoardScene"
);
UBCoreGraphicsScene
::
setObjectName
(
"BoardScene"
);
#ifdef __ppc__
#ifdef __ppc__
...
@@ -296,7 +298,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
...
@@ -296,7 +298,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
mShouldUseOMP
=
QSysInfo
::
MacintoshVersion
>=
QSysInfo
::
MV_10_5
;
mShouldUseOMP
=
QSysInfo
::
MacintoshVersion
>=
QSysInfo
::
MV_10_5
;
#endif
#endif
setItemIndexMethod
(
QGraphicsScene
::
BspTreeIndex
);
//
setItemIndexMethod(QGraphicsScene::BspTreeIndex);
setUuid
(
QUuid
::
createUuid
());
setUuid
(
QUuid
::
createUuid
());
setDocument
(
parent
);
setDocument
(
parent
);
...
@@ -1032,6 +1034,23 @@ UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRad
...
@@ -1032,6 +1034,23 @@ UBGraphicsPolygonItem* UBGraphicsScene::arcToPolygonItem(const QLineF& pStartRad
return
polygonToPolygonItem
(
polygon
);
return
polygonToPolygonItem
(
polygon
);
}
}
void
UBGraphicsScene
::
updateMultipleSelectionFrame
()
{
qDebug
()
<<
"selected item count"
<<
selectedItems
().
count
();
QList
<
QGraphicsItem
*>
selItems
=
selectedItems
();
if
(
!
mSelectionFrame
)
{
mSelectionFrame
=
new
UBSelectionFrame
();
addItem
(
mSelectionFrame
);
}
mSelectionFrame
->
setEnclosedItems
(
selItems
);
if
(
!
mSelectionFrame
->
isEmpty
())
{
mSelectionFrame
->
setVisible
(
true
);
}
else
{
mSelectionFrame
->
setVisible
(
false
);
}
}
UBGraphicsPolygonItem
*
UBGraphicsScene
::
polygonToPolygonItem
(
const
QPolygonF
pPolygon
)
UBGraphicsPolygonItem
*
UBGraphicsScene
::
polygonToPolygonItem
(
const
QPolygonF
pPolygon
)
{
{
UBGraphicsPolygonItem
*
polygonItem
=
new
UBGraphicsPolygonItem
(
pPolygon
);
UBGraphicsPolygonItem
*
polygonItem
=
new
UBGraphicsPolygonItem
(
pPolygon
);
...
...
src/domain/UBGraphicsScene.h
View file @
741298c0
...
@@ -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 UBGRAPHICSSCENE_H_
#ifndef UBGRAPHICSSCENE_H_
#define UBGRAPHICSSCENE_H_
#define UBGRAPHICSSCENE_H_
...
@@ -56,6 +54,7 @@ class UBMagnifierParams;
...
@@ -56,6 +54,7 @@ class UBMagnifierParams;
class
UBMagnifier
;
class
UBMagnifier
;
class
UBGraphicsCache
;
class
UBGraphicsCache
;
class
UBGraphicsGroupContainerItem
;
class
UBGraphicsGroupContainerItem
;
class
UBSelectionFrame
;
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
const
double
PI
=
4
.
0
*
atan
(
1
.
0
);
...
@@ -312,6 +311,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...
@@ -312,6 +311,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsPolygonItem
*
polygonToPolygonItem
(
const
QPolygonF
pPolygon
);
UBGraphicsPolygonItem
*
polygonToPolygonItem
(
const
QPolygonF
pPolygon
);
void
setMultipleSelectionProcess
(
bool
pEnabled
)
{
mMultipleSelectionProcess
=
pEnabled
;}
void
setMultipleSelectionProcess
(
bool
pEnabled
)
{
mMultipleSelectionProcess
=
pEnabled
;}
bool
multipleSelectionProcess
()
const
{
return
mMultipleSelectionProcess
;}
bool
multipleSelectionProcess
()
const
{
return
mMultipleSelectionProcess
;}
void
updateMultipleSelectionFrame
();
public
slots
:
public
slots
:
void
initStroke
();
void
initStroke
();
...
@@ -430,6 +430,7 @@ public slots:
...
@@ -430,6 +430,7 @@ public slots:
bool
mDrawWithCompass
;
bool
mDrawWithCompass
;
UBGraphicsPolygonItem
*
mCurrentPolygon
;
UBGraphicsPolygonItem
*
mCurrentPolygon
;
bool
mMultipleSelectionProcess
;
bool
mMultipleSelectionProcess
;
UBSelectionFrame
*
mSelectionFrame
;
};
};
...
...
src/domain/UBSelectionFrame.cpp
0 → 100644
View file @
741298c0
#include "UBSelectionFrame.h"
#include <QtGui>
#include "core/UB.h"
#include "domain/UBItem.h"
#include "board/UBBoardController.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
UBSelectionFrame
::
UBSelectionFrame
()
:
mThickness
(
UBSettings
::
settings
()
->
objectFrameWidth
)
,
mAntiscaleRatio
(
1.0
)
{
setLocalBrush
(
QBrush
(
UBSettings
::
paletteColor
));
setPen
(
Qt
::
NoPen
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Control
));
setFlags
(
QGraphicsItem
::
ItemIsMovable
);
connect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
(
qreal
)));
}
void
UBSelectionFrame
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
Q_UNUSED
(
widget
);
QPainterPath
path
;
QRectF
shRect
=
option
->
rect
;
path
.
addRoundedRect
(
shRect
,
mThickness
/
2
,
mThickness
/
2
);
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
{
QPainterPath
extruded
;
extruded
.
addRect
(
shRect
.
adjusted
(
mThickness
,
mThickness
,
(
mThickness
*
-
1
),
(
mThickness
*
-
1
)));
path
=
path
.
subtracted
(
extruded
);
}
painter
->
fillPath
(
path
,
mLocalBrush
);
}
QRectF
UBSelectionFrame
::
boundingRect
()
const
{
return
rect
().
adjusted
(
-
mThickness
,
-
mThickness
,
mThickness
,
mThickness
);
}
QPainterPath
UBSelectionFrame
::
shape
()
const
{
QPainterPath
resShape
;
QRectF
ownRect
=
rect
();
QRectF
shRect
=
ownRect
.
adjusted
(
-
mThickness
,
-
mThickness
,
mThickness
,
mThickness
);
resShape
.
addRoundedRect
(
shRect
,
mThickness
/
2
,
mThickness
/
2
);
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
{
QPainterPath
extruded
;
extruded
.
addRect
(
ownRect
);
resShape
=
resShape
.
subtracted
(
extruded
);
}
return
resShape
;
}
void
UBSelectionFrame
::
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
)
{
QRectF
resultRect
;
mEnclosedtems
.
clear
();
foreach
(
QGraphicsItem
*
nextItem
,
pGraphicsItems
)
{
UBGraphicsItemDelegate
*
nextDelegate
=
UBGraphicsItem
::
Delegate
(
nextItem
);
if
(
nextDelegate
)
{
mEnclosedtems
.
append
(
nextDelegate
);
resultRect
|=
nextItem
->
boundingRect
();
}
}
setRect
(
resultRect
);
if
(
resultRect
.
isEmpty
())
{
hide
();
}
}
void
UBSelectionFrame
::
updateRect
()
{
QRectF
result
;
foreach
(
UBGraphicsItemDelegate
*
curDelegateItem
,
mEnclosedtems
)
{
result
|=
curDelegateItem
->
delegated
()
->
boundingRect
();
}
setRect
(
result
);
if
(
result
.
isEmpty
())
{
setVisible
(
false
);
}
}
void
UBSelectionFrame
::
updateScale
()
{
setScale
(
-
UBApplication
::
boardController
->
currentZoom
());
}
void
UBSelectionFrame
::
onZoomChanged
(
qreal
pZoom
)
{
mAntiscaleRatio
=
pZoom
;
updateScale
();
}
src/domain/UBSelectionFrame.h
0 → 100644
View file @
741298c0
#ifndef UBSELECTIONFRAME_H
#define UBSELECTIONFRAME_H
#include <QGraphicsRectItem>
#include <QtGui>
class
UBGraphicsItemDelegate
;
class
UBSelectionFrame
:
public
QObject
,
public
QGraphicsRectItem
{
Q_OBJECT
public
:
UBSelectionFrame
();
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QRectF
boundingRect
()
const
;
QPainterPath
shape
()
const
;
void
setLocalBrush
(
const
QBrush
&
pBrush
)
{
mLocalBrush
=
pBrush
;}
QBrush
localBrush
()
const
{
return
mLocalBrush
;}
void
setEnclosedItems
(
const
QList
<
UBGraphicsItemDelegate
*>
pEncItems
)
{
mEnclosedtems
=
pEncItems
;
updateRect
();}
void
setEnclosedItems
(
const
QList
<
QGraphicsItem
*>
pGraphicsItems
);
void
updateRect
();
void
updateScale
();
bool
isEmpty
()
const
{
return
this
->
rect
().
isEmpty
();}
private
slots
:
void
setAntiScaleRatio
(
qreal
pAntiscaleRatio
)
{
mAntiscaleRatio
=
pAntiscaleRatio
;}
void
onZoomChanged
(
qreal
pZoom
);
private
:
int
mThickness
;
qreal
mAntiscaleRatio
;
QList
<
UBGraphicsItemDelegate
*>
mEnclosedtems
;
QBrush
mLocalBrush
;
};
#endif // UBSELECTIONFRAME_H
src/domain/domain.pri
View file @
741298c0
...
@@ -24,7 +24,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
...
@@ -24,7 +24,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsTextItemDelegate.h \
src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h
src/domain/UBGraphicsMediaItemDelegate.h \
src/domain/UBSelectionFrame.h
SOURCES += src/domain/UBGraphicsScene.cpp \
SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \
...
@@ -53,4 +54,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
...
@@ -53,4 +54,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \
src/domain/UBGraphicsTextItemDelegate.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp
src/domain/UBGraphicsWidgetItemDelegate.cpp \
src/domain/UBSelectionFrame.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