Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
24aea5cc
Commit
24aea5cc
authored
Jun 08, 2017
by
denis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DrawModule cashing
parent
e3a32ea8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
18 deletions
+68
-18
src/actors/draw/drawmodule.cpp
src/actors/draw/drawmodule.cpp
+48
-15
src/actors/draw/drawmodule.h
src/actors/draw/drawmodule.h
+20
-3
No files found.
src/actors/draw/drawmodule.cpp
View file @
24aea5cc
...
...
@@ -21,6 +21,7 @@ You should change it corresponding to functionality.
namespace
ActorDraw
{
const
int
maxBuff
=
1500
;
#define NET_RESERVE 15
#define KUM_MULTI 50
...
...
@@ -178,14 +179,14 @@ namespace ActorDraw {
void
DrawScene
::
addDrawLine
(
QLineF
lineF
,
QColor
color
,
qreal
width
)
{
if
(
lineF
.
length
()
==
0
)
return
;
QGraphicsLineItem
*
line
=
addLine
(
lineF
);
QGraphicsLineItem
*
line
=
new
QGraphicsLineItem
(
lineF
);
QPen
mp
=
QPen
(
QColor
(
color
));
mp
.
setWidthF
(
width
);
mp
.
setCosmetic
(
true
);
line
->
setPen
(
mp
);
line
->
setZValue
(
90
);
lines
.
append
(
line
);
itemsBuffer
.
append
(
line
);
}
...
...
@@ -820,6 +821,7 @@ DrawModule::DrawModule(ExtensionSystem::KPlugin * parent)
{
CurView
=
0
;
firstShow
=
true
;
curPos
=
QPointF
(
0
,
0
);
}
void
DrawModule
::
handleGuiReady
()
{
...
...
@@ -898,7 +900,7 @@ QString DrawModule::initialize(const QStringList &configurationParameters, const
animate
=
false
;
redrawTimer
=
new
QTimer
(
this
);
connect
(
redrawTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
redraw
()));
redrawTimer
->
start
(
50
0
);
redrawTimer
->
start
(
25
0
);
}
return
""
;
}
...
...
@@ -979,9 +981,10 @@ void DrawModule::showNavigator(bool state)
using
namespace
ExtensionSystem
;
// not to write "ExtensionSystem::" each time in this method scope
Q_UNUSED
(
old
);
// Remove this line on implementation
Q_UNUSED
(
current
);
// Remove this line on implementation
updateDraw
();
redraw
();
currentState
=
current
;
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
SmartViewportUpdate
);
// if(current==GlobalState::GS_Running)
// {
// redrawTimer->start(500);
...
...
@@ -1042,6 +1045,8 @@ void DrawModule::showNavigator(bool state)
CurView
->
forceRedraw
();
CurView
->
setZoom
(
CurView
->
zoom
()
*
2
);
CurView
->
setZoom
(
CurView
->
zoom
()
*
0.5
);
curPos
=
QPointF
(
0
,
0
);
}
/* public slot */
void
DrawModule
::
setAnimationEnabled
(
bool
enabled
)
...
...
@@ -1093,6 +1098,7 @@ void DrawModule::showNavigator(bool state)
/* public slot */
void
DrawModule
::
runMoveTo
(
const
qreal
x
,
const
qreal
y
)
{
int
curBuffSize
=
0
;
mutex
.
lock
();
QPointF
start
=
mPen
->
pos
();
mPen
->
setPos
(
x
,
-
y
);
...
...
@@ -1103,8 +1109,16 @@ void DrawModule::showNavigator(bool state)
//CurView->resetCachedContent();
//CurView->update();
// if(animate)redrawPicture();
mutex
.
unlock
();
curBuffSize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
if
(
curBuffSize
>
maxBuff
-
1
)
{
msleep
(
3
);
mutex
.
lock
();
curBuffSize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
}
// msleep(10);
}
...
...
@@ -1112,6 +1126,7 @@ void DrawModule::showNavigator(bool state)
{
/* алг сместиться на вектор(вещ dX, вещ dY) */
// TODO implement me
int
curBuffSize
=
0
;
mutex
.
lock
();
QPointF
start
=
mPen
->
pos
();
mPen
->
moveBy
(
dX
,
-
dY
);
...
...
@@ -1121,9 +1136,16 @@ void DrawModule::showNavigator(bool state)
}
//CurView->update();
//if(animate)redrawPicture();
curBuffSize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
msleep
(
1
);
if
(
curBuffSize
>
maxBuff
-
1
)
{
msleep
(
3
);
mutex
.
lock
();
curBuffSize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
}
}
...
...
@@ -1319,16 +1341,27 @@ void DrawModule::drawNet()
drawNet
();
}
}
void
DrawModule
::
red
raw
()
void
DrawModule
::
updateD
raw
()
{
if
(
currentState
!=
ExtensionSystem
::
GlobalState
::
GS_Running
)
return
;
mutex
.
lock
();
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
SmartViewportUpdate
);
mutex
.
lock
();
CurScene
->
fromBufferToScene
();
redrawPicture
();
mutex
.
unlock
();
msleep
(
5
);
// qApp->processEvents();
mutex
.
unlock
();
drawNet
();
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
NoViewportUpdate
);
}
void
DrawModule
::
redraw
()
{
if
(
currentState
!=
ExtensionSystem
::
GlobalState
::
GS_Running
)
return
;
updateDraw
();
//qApp->processEvents();
}
...
...
src/actors/draw/drawmodule.h
View file @
24aea5cc
...
...
@@ -105,7 +105,7 @@ namespace ActorDraw {
for
(
int
i
=
0
;
i
<
texts
.
count
();
i
++
)
removeItem
(
texts
.
at
(
i
));
texts
.
clear
();
clearBuffer
();
}
void
upd
()
{
...
...
@@ -118,6 +118,20 @@ namespace ActorDraw {
QRectF
getRect
();
int
saveToFile
(
const
QString
&
p_FileName
);
int
loadFromFile
(
const
QString
&
p_FileName
);
void
fromBufferToScene
()
{
QGraphicsItemGroup
*
buff
=
createItemGroup
(
itemsBuffer
);
buff
->
setZValue
(
90
);
addItem
(
buff
);
clearBuffer
();
}
void
clearBuffer
()
{
itemsBuffer
.
clear
();
}
int
buffSize
()
{
return
itemsBuffer
.
count
();
}
protected:
// void resizeEvent ( QResizeEvent * event );
// bool eventFilter(QObject *object, QEvent *event);
...
...
@@ -129,7 +143,8 @@ namespace ActorDraw {
QList
<
QGraphicsLineItem
*>
linesDubl
;
//Базовый чертеж
QList
<
QGraphicsSimpleTextItem
*>
texts
;
DrawModule
*
DRAW
;
QMutex
*
dr_mutex
;
QList
<
QGraphicsItem
*>
itemsBuffer
;
QMutex
*
dr_mutex
;
...
...
@@ -241,7 +256,7 @@ public slots:
void
openFile
();
void
saveFile
();
void
redraw
();
void
updateDraw
();
/* ========= CLASS PRIVATE ========= */
private:
...
...
@@ -265,6 +280,8 @@ private:
QTimer
*
redrawTimer
;
qreal
curAngle
;
qreal
AncX
,
AncY
;
QPointF
curPos
;
};
...
...
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