Privacy
An open-source, flexible 3D physical simulation framework
GraphicsTimer.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2013 DFKI GmbH Robotics Innovation Center
3
*
4
* This file is part of the MARS simulation framework.
5
*
6
* MARS is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License
8
* as published by the Free Software Foundation, either version 3
9
* of the License, or (at your option) any later version.
10
*
11
* MARS is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with MARS. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
#include "
GraphicsTimer.h
"
22
#include <mars/utils/misc.h>
23
24
namespace
mars
{
25
namespace
viz {
26
27
using
mars::interfaces::GraphicsManagerInterface
;
28
29
GraphicsTimer::GraphicsTimer
(
GraphicsManagerInterface
*graphics_)
30
: graphics(graphics_) {
31
graphicsTimer
=
new
QTimer();
32
connect(
graphicsTimer
, SIGNAL(timeout()),
this
, SLOT(
timerEvent
()));
33
connect(
this
, SIGNAL(
internalRun
()),
this
, SLOT(
runOnceInternal
()),
34
Qt::QueuedConnection);
35
}
36
37
void
GraphicsTimer::run
() {
38
graphicsTimer
->start(10);
39
}
40
41
void
GraphicsTimer::stop
() {
42
graphicsTimer
->stop();
43
}
44
45
46
void
GraphicsTimer::runOnce
(){
47
runFinished
=
false
;
48
emit
internalRun
();
49
while
(!
runFinished
){
50
mars::utils::msleep
(1);
51
}
52
}
53
54
void
GraphicsTimer::runOnceInternal
(){
55
timerEvent
();
56
runFinished
=
true
;
57
}
58
59
void
GraphicsTimer::timerEvent
(
void
) {
60
graphics
->
draw
();
61
}
62
63
}
// end of namespace viz
64
}
// end of namespace mars
mars::viz::GraphicsTimer::graphics
mars::interfaces::GraphicsManagerInterface * graphics
Definition:
GraphicsTimer.h:54
mars::viz::GraphicsTimer::runOnceInternal
void runOnceInternal(void)
Definition:
GraphicsTimer.cpp:54
mars::viz::GraphicsTimer::run
void run()
Definition:
GraphicsTimer.cpp:37
mars::utils::msleep
void msleep(unsigned int milliseconds)
sleeps for at least the specified time.
Definition:
misc.h:96
mars::viz::GraphicsTimer::internalRun
void internalRun()
mars::viz::GraphicsTimer::stop
void stop()
Definition:
GraphicsTimer.cpp:41
mars::viz::GraphicsTimer::graphicsTimer
QTimer * graphicsTimer
Definition:
GraphicsTimer.h:53
mars::interfaces::GraphicsManagerInterface::draw
virtual void draw()=0
mars
Copyright 2012, DFKI GmbH Robotics Innovation Center.
Definition:
GraphicsTimer.cpp:25
mars::viz::GraphicsTimer::runOnce
void runOnce()
Definition:
GraphicsTimer.cpp:46
mars::viz::GraphicsTimer::runFinished
bool runFinished
Definition:
GraphicsTimer.h:55
GraphicsTimer.h
mars::interfaces::GraphicsManagerInterface
Definition:
GraphicsManagerInterface.h:54
mars::viz::GraphicsTimer::GraphicsTimer
GraphicsTimer(mars::interfaces::GraphicsManagerInterface *graphics_)
Definition:
GraphicsTimer.cpp:29
mars::viz::GraphicsTimer::timerEvent
void timerEvent(void)
Definition:
GraphicsTimer.cpp:59
viz
src
GraphicsTimer.cpp
Generated on Fri May 25 2018 11:46:19 by
1.8.13