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
9695f6da
Commit
9695f6da
authored
Jun 14, 2017
by
denis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turtle animation
parent
21ded7e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
src/actors/turtle/turtlemodule.cpp
src/actors/turtle/turtlemodule.cpp
+18
-16
src/actors/turtle/turtlemodule.h
src/actors/turtle/turtlemodule.h
+4
-1
No files found.
src/actors/turtle/turtlemodule.cpp
View file @
9695f6da
...
...
@@ -18,8 +18,8 @@ You should change it corresponding to functionality.
#include <QtGui>
namespace
ActorTurtle
{
const
int
maxBuff
=
10
00
;
const
int
maxBuff
=
5
00
;
const
int
AnimTime
=
100
;
const
int
KumMulti
=
50
;
...
...
@@ -201,14 +201,14 @@ static const qreal MAX_ZOOM = 1000000;
void
TurtleScene
::
DestroyNet
()
{
// qDebug()<<Netlines.count();
dr_mutex
->
lock
();
//
dr_mutex->lock();
for
(
int
i
=
0
;
i
<
Netlines
.
count
();
i
++
)
{
delete
Netlines
[
i
];
}
Netlines
.
clear
();
dr_mutex
->
unlock
();
//
dr_mutex->unlock();
}
void
TurtleScene
::
drawOnlyAxis
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
qreal
aw
)
{
...
...
@@ -247,7 +247,7 @@ static const qreal MAX_ZOOM = 1000000;
// return;
dr_mutex
->
lock
()
;
if
(
!
dr_mutex
->
tryLock
(
20
))
return
;
startx
=
lines
*
step
;
double
fx1
=
startx
-
NetReserve
*
step
,
fx2
,
fy1
,
fy2
;
while
(
fx1
<
endx
+
NetReserve
*
step
)
...
...
@@ -672,8 +672,8 @@ void TurtleView::paintEvent(QPaintEvent *event)
{
if
(
pressed
)
{
dr_mutex
->
lock
();
setViewportUpdateMode
(
QGraphicsView
::
SmartViewportUpdate
);
//
dr_mutex->lock();
//
setViewportUpdateMode (QGraphicsView::SmartViewportUpdate);
QPointF
delta
=
mapToScene
(
press_pos
)
-
mapToScene
(
event
->
pos
());
...
...
@@ -690,9 +690,9 @@ void TurtleView::paintEvent(QPaintEvent *event)
qDebug
()
<<
"DELTA"
<<
delta
<<
" xd"
<<
press_pos
.
x
()
-
event
->
pos
().
x
()
<<
" yd"
<<
mapToScene
(
press_pos
).
y
()
-
mapToScene
(
event
->
pos
()).
y
();
press_pos
=
event
->
pos
();
qDebug
()
<<
"Ppos"
<<
press_pos
;
update
();
setViewportUpdateMode
(
QGraphicsView
::
NoViewportUpdate
);
dr_mutex
->
unlock
();
//
update();
//
setViewportUpdateMode (QGraphicsView::NoViewportUpdate);
//
dr_mutex->unlock();
}
};
void
TurtleView
::
setZoom
(
double
zoom
)
...
...
@@ -784,7 +784,7 @@ void TurtleView::paintEvent(QPaintEvent *event)
void
TurtleView
::
wheelEvent
(
QWheelEvent
*
event
)
{
dr_mutex
->
lock
()
;
if
(
!
dr_mutex
->
tryLock
(
20
))
return
;
float
numDegrees
=
event
->
delta
()
/
8
;
qDebug
()
<<
"whell:"
<<
numDegrees
;
// c_scale=c_scale*0.8;
...
...
@@ -912,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
(
10
);
redrawTimer
->
start
(
AnimTime
);
}
return
""
;
}
...
...
@@ -1227,14 +1227,14 @@ mutex.unlock();
void
TurtleModule
::
drawNet
()
{
// mutex.lock();
mutex
.
lock
();
//
mutex.lock();
QPointF
start_d
=
CurView
->
mapToScene
(
CurView
->
geometry
().
topLeft
());
QPointF
end_d
=
CurView
->
mapToScene
(
CurView
->
geometry
().
bottomRight
());
CurView
->
setSceneRect
(
QRectF
(
QPointF
(
start_d
.
x
()
-
(
CurView
->
geometry
().
width
())
*
(
1
/
zoom
()),
start_d
.
y
()
-
(
CurView
->
geometry
().
height
()
*
2
)
*
(
1
/
zoom
())),
QPointF
(
end_d
.
x
()
+
2000
*
(
1
/
zoom
()),
end_d
.
y
()
+
2000
*
(
1
/
zoom
()))));
mutex
.
unlock
();
//
mutex.unlock();
QPointF
start
=
CurView
->
sceneRect
().
topLeft
();
QPointF
end
=
CurView
->
sceneRect
().
bottomRight
();
CurScene
->
drawNet
(
start
.
x
(),
end
.
x
(),
start
.
y
(),
end
.
y
(),
netColor
,
netStepX
,
NetStepY
(),
CurView
->
isNet
(),
mySettings
()
->
value
(
"NetWidth"
,
1
).
toFloat
(),
mySettings
()
->
value
(
"AxisWidth"
,
2
).
toFloat
());
...
...
@@ -1356,12 +1356,14 @@ mutex.unlock();
{
if
(
currentState
!=
Shared
::
PluginInterface
::
GS_Running
)
return
;
redrawTimer
->
stop
();
mutex
.
lock
();
updateTurtle
();
qApp
->
processEvents
();
mutex
.
unlock
();
//
drawNet();
if
(
!
CurScene
->
netIsShown
())
drawNet
();
redrawTimer
->
start
(
AnimTime
);
// usleep(10);
}
...
...
src/actors/turtle/turtlemodule.h
View file @
9695f6da
...
...
@@ -212,7 +212,10 @@ namespace ActorTurtle {
}
void
DestroyNet
();
void
drawOnlyAxis
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
qreal
aw
);
bool
netIsShown
()
{
return
Netlines
.
count
()
>
0
;
}
bool
isLineAt
(
const
QPointF
&
pos
,
qreal
radius
);
qreal
drawText
(
const
QString
&
Text
,
qreal
widthChar
,
QPointF
from
,
QColor
color
);
//Returns offset of pen.
QRectF
getRect
();
...
...
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