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
e26322e5
Commit
e26322e5
authored
May 26, 2017
by
Victor Yacovlev
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:victor-yacovlev/kumir2
parents
7b6e32c2
fca8a1a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
16 deletions
+61
-16
src/actors/turtle/turtlemodule.cpp
src/actors/turtle/turtlemodule.cpp
+41
-15
src/actors/turtle/turtlemodule.h
src/actors/turtle/turtlemodule.h
+20
-1
No files found.
src/actors/turtle/turtlemodule.cpp
View file @
e26322e5
...
...
@@ -18,7 +18,7 @@ You should change it corresponding to functionality.
#include <QtGui>
namespace
ActorTurtle
{
const
int
maxBuff
=
1000
;
...
...
@@ -171,8 +171,9 @@ static const qreal MAX_ZOOM = 1000000;
fontMetric
=
QFontMetricsF
(
font
);
qDebug
()
<<
"Char Size:"
<<
fontMetric
.
boundingRect
(
"OOOXX"
).
width
()
/
5000
;
texts
.
append
(
addSimpleText
(
Text
,
font
));
QGraphicsSimpleTextItem
*
tItem
=
new
QGraphicsSimpleTextItem
(
Text
);
tItem
->
setFont
(
font
);
texts
.
append
(
tItem
);
// texts.last()->scale(0.001,0.001);
texts
.
last
()
->
setScale
(
psizeF
);
texts
.
last
()
->
setPos
(
from
.
x
(),
from
.
y
()
-
(
fontMetric
.
boundingRect
(
Text
).
height
()
*
psizeF
));
...
...
@@ -183,7 +184,8 @@ static const qreal MAX_ZOOM = 1000000;
void
TurtleScene
::
addDrawLine
(
QLineF
lineF
,
QColor
color
,
qreal
width
)
{
if
(
lineF
.
length
()
==
0
)
return
;
QGraphicsLineItem
*
line
=
addLine
(
lineF
);
QGraphicsLineItem
*
line
=
new
QGraphicsLineItem
(
lineF
);
//addLine(lineF);
QPen
mp
=
QPen
(
QColor
(
color
));
mp
.
setWidthF
(
width
);
mp
.
setCapStyle
(
Qt
::
RoundCap
);
...
...
@@ -191,8 +193,9 @@ static const qreal MAX_ZOOM = 1000000;
line
->
setPen
(
mp
);
line
->
setZValue
(
90
);
lines
.
append
(
line
);
itemsBuffer
.
append
(
line
);
//getfromB
}
void
TurtleScene
::
DestroyNet
()
...
...
@@ -627,11 +630,11 @@ static const qreal MAX_ZOOM = 1000000;
};
void
TurtleView
::
paintEvent
(
QPaintEvent
*
event
)
{
dr_mutex
->
lock
();
//
dr_mutex->lock();
QGraphicsView
::
paintEvent
(
event
);
event
->
accept
();
dr_mutex
->
unlock
();
//
dr_mutex->unlock();
}
void
TurtleView
::
resizeEvent
(
QResizeEvent
*
event
)
...
...
@@ -880,7 +883,7 @@ void TurtleModule::createGui()
penColor
.
a
=
255
;
CurView
->
setDraw
(
this
,
&
mutex
);
CurView
->
centerOn
(
5
,
-
5
);
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
Full
ViewportUpdate
);
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
No
ViewportUpdate
);
drawNet
();
CreatePen
();
CurView
->
setZoom
(
50
);
...
...
@@ -909,7 +912,7 @@ QString TurtleModule::initialize(const QStringList &configurationParameters, con
currentState
=
Shared
::
PluginInterface
::
GS_Unlocked
;
redrawTimer
=
new
QTimer
(
this
);
connect
(
redrawTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
redraw
()));
redrawTimer
->
start
(
50
0
);
redrawTimer
->
start
(
1
0
);
}
return
""
;
}
...
...
@@ -939,12 +942,14 @@ QString TurtleModule::initialize(const QStringList &configurationParameters, con
Q_UNUSED
(
old
);
// Remove this line on implementation
Q_UNUSED
(
current
);
// Remove this line on implementation
usleep
(
10
);
CurScene
->
fromBufferToScene
();
currentState
=
current
;
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
FullViewportUpdate
);
CurView
->
forceRedraw
();
CurScene
->
update
(
CurScene
->
sceneRect
());
CurView
->
repaint
();
CurView
->
viewport
()
->
update
();
drawNet
();
...
...
@@ -993,6 +998,7 @@ QString TurtleModule::initialize(const QStringList &configurationParameters, con
/* public slot */
void
TurtleModule
::
reset
()
{
CurScene
->
clearBuffer
();
mPen
->
tailUp
();
penIsDrawing
=
false
;
mPen
->
setPos
(
0
,
0
);
...
...
@@ -1011,6 +1017,7 @@ QString TurtleModule::initialize(const QStringList &configurationParameters, con
CurView
->
forceRedraw
();
CurView
->
setZoom
(
CurView
->
zoom
()
*
2
);
CurView
->
setZoom
(
CurView
->
zoom
()
*
0.5
);
}
/* public slot */
void
TurtleModule
::
setAnimationEnabled
(
bool
enabled
)
...
...
@@ -1061,6 +1068,13 @@ mutex.unlock();
if
(
!
mPen
->
isTailUp
())
CurScene
->
addDrawLine
(
QLineF
(
QPointF
(
oldX
,
oldY
),
mPen
->
pos
()),
QColor
(
penColor
.
r
,
penColor
.
g
,
penColor
.
b
,
penColor
.
a
),
mySettings
()
->
value
(
"LineWidth"
,
4
).
toFloat
());
// CurScene->update();
mutex
.
unlock
();
int
bsize
=
maxBuff
;
while
(
bsize
>
maxBuff
-
1
)
{
mutex
.
lock
();
bsize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
}
}
...
...
@@ -1083,8 +1097,15 @@ mutex.unlock();
if
(
!
mPen
->
isTailUp
())
CurScene
->
addDrawLine
(
QLineF
(
QPointF
(
oldX
,
oldY
),
mPen
->
pos
()),
QColor
(
penColor
.
r
,
penColor
.
g
,
penColor
.
b
,
penColor
.
a
),
mySettings
()
->
value
(
"LineWidth"
,
4
).
toFloat
());
mutex
.
unlock
();
CurScene
->
update
();
// CurScene->update();
int
bsize
=
maxBuff
;
while
(
bsize
>
maxBuff
-
1
)
{
mutex
.
lock
();
bsize
=
CurScene
->
buffSize
();
mutex
.
unlock
();
}
}
/* public slot */
void
TurtleModule
::
runLeft
(
const
qreal
angle
)
...
...
@@ -1317,11 +1338,16 @@ mutex.unlock();
{
if
(
currentState
!=
Shared
::
PluginInterface
::
GS_Running
)
return
;
// mutex.lock();
// CurScene->update();
mutex
.
lock
();
CurScene
->
fromBufferToScene
();
CurScene
->
update
();
CurView
->
update
();
// mutex.unlock();
drawNet
();
mutex
.
unlock
();
// drawNet();
// usleep(10);
}
}
// namespace ActorTurtle
src/actors/turtle/turtlemodule.h
View file @
e26322e5
...
...
@@ -112,6 +112,7 @@ namespace ActorTurtle {
{
return
c_scale
;};
void
setZoom
(
double
zoom
);
void
setNet
();
//RESIZE NET
bool
isNet
()
const
{
return
net
;
...
...
@@ -148,6 +149,9 @@ namespace ActorTurtle {
QLabel
*
smallNetLabel
;
};
class
TurtleScene
:
public
QGraphicsScene
{
...
...
@@ -168,6 +172,20 @@ namespace ActorTurtle {
texts
.
clear
();
}
void
fromBufferToScene
()
{
QGraphicsItemGroup
*
buff
=
createItemGroup
(
itemsBuffer
);
buff
->
setZValue
(
90
);
addItem
(
buff
);
clearBuffer
();
}
void
clearBuffer
()
{
itemsBuffer
.
clear
();
}
int
buffSize
()
{
return
itemsBuffer
.
count
();
}
void
DestroyNet
();
void
drawOnlyAxis
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
qreal
aw
);
...
...
@@ -185,7 +203,8 @@ namespace ActorTurtle {
QList
<
QGraphicsLineItem
*>
linesDubl
;
//Базовый чертеж
QList
<
QGraphicsSimpleTextItem
*>
texts
;
TurtleModule
*
DRAW
;
QMutex
*
dr_mutex
;
QMutex
*
dr_mutex
;
QList
<
QGraphicsItem
*>
itemsBuffer
;
...
...
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