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
21ded7e5
Commit
21ded7e5
authored
Jun 13, 2017
by
denis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Robot animation
parent
31161b7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
21 deletions
+53
-21
src/actors/robot/robotmodule.cpp
src/actors/robot/robotmodule.cpp
+46
-20
src/actors/robot/robotmodule.h
src/actors/robot/robotmodule.h
+6
-1
src/actors/turtle/turtlemodule.h
src/actors/turtle/turtlemodule.h
+1
-0
No files found.
src/actors/robot/robotmodule.cpp
View file @
21ded7e5
...
...
@@ -16,7 +16,7 @@ You should change it corresponding to functionality.
#include <kumir2-libs/extensionsystem/pluginmanager.h>
//#include <iostream>
const
int
AnimTime
=
10
0
;
const
int
AnimTime
=
7
0
;
namespace
ActorRobot
{
...
...
@@ -4321,8 +4321,10 @@ void RobotModule::reset()
void
RobotModule
::
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
){
using
Shared
::
PluginInterface
;
qDebug
()
<<
"RobotModuleBase::changeGlobalState"
;
view
->
setViewportUpdateMode
(
QGraphicsView
::
SmartViewportUpdate
);
if
(
current
==
PluginInterface
::
GS_Running
)
{
view
->
setViewportUpdateMode
(
QGraphicsView
::
NoViewportUpdate
);
m_actionRobotRevertEnvironment
->
setEnabled
(
false
);
m_actionRobotLoadEnvironment
->
setEnabled
(
false
);
m_actionRobotLoadRescent
->
setEnabled
(
false
);
...
...
@@ -4421,6 +4423,9 @@ QString RobotModule::initialize(const QStringList &configurationParameters, cons
DISPLAY
=
true
;
if
(
!
configurationParameters
.
contains
(
"tablesOnly"
))
{
createGui
();
redrawTimer
=
new
QTimer
();
connect
(
redrawTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
getTimer
()));
redrawTimer
->
start
(
30
);
ExtensionSystem
::
SettingsPtr
sett
;
sett
=
robotSettings
();
...
...
@@ -4460,7 +4465,7 @@ void RobotModule::runGoUp()
if
(
!
curConsoleField
->
goUp
())
setError
(
trUtf8
(
"Робот разбился: сверху стена!"
));
return
;
}
mutex
.
lock
();
qDebug
()
<<
"Robot up"
;
QString
status
=
"OK"
;
if
(
!
field
->
stepUp
())
...
...
@@ -4474,7 +4479,9 @@ void RobotModule::runGoUp()
// }
if
(
sender
()
==
m_pultWidget
)
m_pultWidget
->
Logger
->
appendText
(
trUtf8
(
"вверх"
),
QString
::
fromUtf8
(
"вверх "
),
status
);
if
(
animation
)
msleep
(
AnimTime
);
view
->
update
();
msleep
(
qrand
()
%
10
);
mutex
.
unlock
();
// view->update();
return
;
}
...
...
@@ -4487,7 +4494,7 @@ void RobotModule::runGoDown()
if
(
!
curConsoleField
->
goDown
())
setError
(
trUtf8
(
"Робот разбился: снизу стена!"
));
return
;
}
mutex
.
lock
();
qDebug
()
<<
"Robot down"
;
QString
status
=
"OK"
;
if
(
!
field
->
stepDown
())
...
...
@@ -4499,10 +4506,9 @@ void RobotModule::runGoDown()
// emit sendToPultLog(status);
// }
if
(
sender
()
==
m_pultWidget
)
m_pultWidget
->
Logger
->
appendText
(
trUtf8
(
"вниз"
),
QString
::
fromUtf8
(
"вниз "
),
status
);
// if(animation){
view
->
update
();
msleep
(
AnimTime
);
// }
if
(
animation
)
msleep
(
AnimTime
);
msleep
(
qrand
()
%
10
);
mutex
.
unlock
();
return
;
}
...
...
@@ -4517,7 +4523,7 @@ void RobotModule::runGoLeft()
if
(
!
curConsoleField
->
goLeft
())
setError
(
trUtf8
(
"Робот разбился: слева стена!"
));
return
;
}
mutex
.
lock
();
QString
status
=
"OK"
;
if
(
!
field
->
stepLeft
()){
field
->
robot
->
setCrash
(
LEFT_CRASH
);
...
...
@@ -4528,11 +4534,9 @@ void RobotModule::runGoLeft()
// emit sendToPultLog(status);
// }
if
(
sender
()
==
m_pultWidget
)
m_pultWidget
->
Logger
->
appendText
(
trUtf8
(
"влево"
),
QString
::
fromUtf8
(
"влево "
),
status
);
// if(animation)
// {
view
->
update
();
msleep
(
AnimTime
);
// }
if
(
animation
)
msleep
(
AnimTime
);
msleep
(
qrand
()
%
10
);
mutex
.
unlock
();
return
;
}
...
...
@@ -4544,7 +4548,8 @@ void RobotModule::runGoRight()
if
(
!
curConsoleField
->
goRight
())
setError
(
trUtf8
(
"Робот разбился: справа стена!"
));
return
;
}
qDebug
()
<<
"Robot right"
;
// qDebug() << "Robot right";
mutex
.
lock
();
QString
status
=
"OK"
;
if
(
!
field
->
stepRight
()){
field
->
robot
->
setCrash
(
RIGHT_CRASH
);
...
...
@@ -4553,11 +4558,10 @@ void RobotModule::runGoRight()
setError
(
trUtf8
(
"Робот разбился: справа стена!"
));}
if
(
sender
()
==
m_pultWidget
)
m_pultWidget
->
Logger
->
appendText
(
trUtf8
(
"вправо"
),
QString
::
fromUtf8
(
"вправо "
),
status
);
// if(animation)
// {
view
->
update
();
msleep
(
AnimTime
);
// }
if
(
animation
)
msleep
(
AnimTime
);
msleep
(
qrand
()
%
10
);
mutex
.
unlock
();
return
;
}
...
...
@@ -5425,6 +5429,25 @@ void RobotModule::setWindowSize()
createRescentMenu
();
}
void
RobotModule
::
updateRobot
()
{
}
void
RobotModule
::
getTimer
()
{
mutex
.
lock
();
field
->
update
();
view
->
update
();
qApp
->
processEvents
();
mutex
.
unlock
();;
}
//+++++++++++RobotView
RobotView
::
RobotView
(
RoboField
*
roboField
)
{
setScene
(
roboField
);
...
...
@@ -5664,4 +5687,7 @@ void RobotView::changeEditMode(bool state)
};
}
// $namespace
src/actors/robot/robotmodule.h
View file @
21ded7e5
...
...
@@ -580,9 +580,11 @@ namespace ActorRobot {
void
openRecent
();
void
setWindowSize
();
void
copyFromPult
(
QString
log
);
void
getTimer
();
private:
void
createGui
();
void
updateRobot
();
void
createEmptyField
(
int
rows
,
int
cols
);
int
LoadFromFile
(
QString
p_FileName
);
int
SaveToFile
(
QString
p_FileName
);
...
...
@@ -607,6 +609,9 @@ namespace ActorRobot {
bool
DISPLAY
;
ExtensionSystem
::
SettingsPtr
curSettings
;
ConsoleField
*
curConsoleField
;
QMutex
mutex
;
ExtensionSystem
::
GlobalState
currentState
;
QTimer
*
redrawTimer
;
signals:
void
sendToPultLog
(
const
QVariant
&
);
...
...
src/actors/turtle/turtlemodule.h
View file @
21ded7e5
...
...
@@ -354,6 +354,7 @@ private:
qreal
AncX
,
AncY
;
QTimer
*
redrawTimer
;
TurtlePult
*
pult
;
};
...
...
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