Main simulation class, implements simulation logic. More...
#include <automataWorkSimulator.h>
Classes | |
struct | Configuration |
helper struct for storing configurations More... | |
Public Types | |
typedef QList< Configuration > | TConfigurationList |
Public Slots | |
void | generateSlideshow () |
processes all steps of simulation and stores it to slideshow | |
void | pause () |
stops automatic simulation | |
void | play () |
runs automatic simulation | |
void | reset () |
resets state of simulation | |
void | run () |
runs simulation dialog | |
bool | setInput (const QString &text) |
sets input string, if it's correctly defined | |
void | stepBackward () |
reverts last step | |
void | stepForward () |
process single step | |
Signals | |
void | finished () |
signal emited when simulation ends | |
void | setStatesMarked (QList< State * >, bool) |
signal catched by editor | |
Public Member Functions | |
AutomataWorkSimulator (Editor *editor, QUndoStack &undoStack, const QSharedPointer< AutomatonImpl > &automaton) | |
~AutomataWorkSimulator () | |
TConfigurationList | getConfigurations () const |
int | getPos () const |
returns current position in input string | |
bool | hasStateAfter () const |
determines, if it's possible to process next step | |
bool | hasStateBefore () const |
determines, if it's possible to do step back | |
bool | isPlaying () const |
determines, if automatic simulation is running | |
bool | isSet () const |
determines, if input is set correctly | |
Protected Slots | |
void | animate () |
processes single step of animation (called by timer) | |
void | animSpeedChanged (double) |
void | dialogClosed () |
void | processStep () |
processes single step of simulation | |
void | stepSpeedChanged (double) |
void | useAnimChanged (int) |
Protected Member Functions | |
bool | animateMove () |
void | doAnimation (const QList< QPainterPath > &paths) |
bool | getFileName (QString &fileName, bool &latexHeader) |
void | refreshPlayingStatus () |
QList< QPainterPath > | revertPaths (const QList< QPainterPath > &paths) const |
void | saveInputState (QTextStream &out) |
void | setActiveStatesMarked (bool) |
Private Types | |
enum | EAnimateState { eMoving, eStopped } |
Private Attributes | |
StateImpl::TStateList | m_activeStates |
bool | m_activeStatesAreMarked |
QVector< StateImpl::TStateList > | m_activeStatesMemory |
QVector< QList< QPainterPath > > | m_animationPathMemory |
float | m_animationSpeed |
EAnimateState | m_animationState |
QScopedPointer< QTimer > | m_animationTimer |
QSharedPointer< AutomatonImpl > | m_automaton |
int | m_backSteps |
step back uses undoStack, so when then is steping forward required again, only redo is done | |
TConfigurationList | m_configurationList |
QScopedPointer< SimulationDialog > | m_dialog |
Editor * | m_editor |
int | m_inputIndex |
position in input stringList | |
StringProcessor::TCharacterList | m_inputList |
QList< SimulationMarker * > | m_markers |
int | m_pathCount |
bool | m_playing |
QScopedPointer< QTimer > | m_simulationTimer |
Configuration::EStatus | m_status |
QUndoStack & | m_undoStack |
int | m_undoStackStartIdx |
bool | m_useAnimations |
Main simulation class, implements simulation logic.
Definition at line 20 of file automataWorkSimulator.h.
typedef QList<Configuration> AutomataWorkSimulator::TConfigurationList |
Definition at line 49 of file automataWorkSimulator.h.
enum AutomataWorkSimulator::EAnimateState [private] |
Definition at line 116 of file automataWorkSimulator.h.
AutomataWorkSimulator::AutomataWorkSimulator | ( | Editor * | editor, | |
QUndoStack & | undoStack, | |||
const QSharedPointer< AutomatonImpl > & | automaton | |||
) |
Definition at line 120 of file automataWorkSimulator.cpp.
References animate(), ANIMATION_FRAME_TIME, animSpeedChanged(), DBGLOG, DBGPAR, dialogClosed(), m_animationTimer, m_dialog, m_simulationTimer, m_undoStackStartIdx, processStep(), SIMULATION_STEP_DEFAULT, stepSpeedChanged(), and useAnimChanged().
AutomataWorkSimulator::~AutomataWorkSimulator | ( | ) |
Definition at line 143 of file automataWorkSimulator.cpp.
void AutomataWorkSimulator::animate | ( | ) | [protected, slot] |
processes single step of animation (called by timer)
Definition at line 350 of file automataWorkSimulator.cpp.
References animateMove(), DBGLOG_ANIM, eMoving, eStopped, m_animationState, m_animationTimer, m_editor, and Editor::update().
Referenced by AutomataWorkSimulator(), and doAnimation().
bool AutomataWorkSimulator::animateMove | ( | ) | [protected] |
Definition at line 367 of file automataWorkSimulator.cpp.
References DBGLOG_ANIM, DBGPAR, m_markers, and m_pathCount.
Referenced by animate().
void AutomataWorkSimulator::animSpeedChanged | ( | double | val | ) | [protected, slot] |
Definition at line 488 of file automataWorkSimulator.cpp.
References m_animationSpeed.
Referenced by AutomataWorkSimulator().
void AutomataWorkSimulator::dialogClosed | ( | ) | [protected, slot] |
Definition at line 498 of file automataWorkSimulator.cpp.
References finished(), m_activeStatesAreMarked, m_undoStack, m_undoStackStartIdx, and setActiveStatesMarked().
Referenced by AutomataWorkSimulator().
void AutomataWorkSimulator::doAnimation | ( | const QList< QPainterPath > & | paths | ) | [protected] |
Definition at line 315 of file automataWorkSimulator.cpp.
References animate(), ANIMATION_FRAME_TIME, m_animationSpeed, m_animationState, m_animationTimer, m_editor, m_markers, m_pathCount, and m_useAnimations.
Referenced by processStep(), and stepBackward().
void AutomataWorkSimulator::finished | ( | ) | [signal] |
signal emited when simulation ends
Definition at line 122 of file moc_automataWorkSimulator.cpp.
Referenced by dialogClosed().
void AutomataWorkSimulator::generateSlideshow | ( | ) | [slot] |
processes all steps of simulation and stores it to slideshow
Definition at line 556 of file automataWorkSimulator.cpp.
References DBGLOG, getFileName(), hasStateAfter(), m_dialog, m_editor, m_useAnimations, processStep(), RELLOG, reset(), Editor::saveFooter(), Editor::saveGraph(), Editor::saveHeader(), saveInputState(), Editor::saveLaTeXFooter(), Editor::saveLaTeXHeader(), Editor::saveVCSettings(), setInput(), and SimulationDialog::showMessageSetInputFailed().
AutomataWorkSimulator::TConfigurationList AutomataWorkSimulator::getConfigurations | ( | ) | const |
Definition at line 187 of file automataWorkSimulator.cpp.
References m_configurationList, and m_inputIndex.
Referenced by SimulationDialog::updateState().
bool AutomataWorkSimulator::getFileName | ( | QString & | fileName, | |
bool & | latexHeader | |||
) | [protected] |
Definition at line 521 of file automataWorkSimulator.cpp.
References appendFilenameSuffix(), m_dialog, and RELLOG.
Referenced by generateSlideshow().
int AutomataWorkSimulator::getPos | ( | ) | const |
returns current position in input string
Definition at line 178 of file automataWorkSimulator.cpp.
References m_dialog, m_inputIndex, and m_inputList.
Referenced by SimulationDialog::updateState().
bool AutomataWorkSimulator::hasStateAfter | ( | ) | const |
determines, if it's possible to process next step
Definition at line 159 of file automataWorkSimulator.cpp.
References AutomataWorkSimulator::Configuration::eError, m_backSteps, m_inputIndex, m_inputList, and m_status.
Referenced by generateSlideshow(), and SimulationDialog::updateState().
bool AutomataWorkSimulator::hasStateBefore | ( | ) | const |
determines, if it's possible to do step back
Definition at line 154 of file automataWorkSimulator.cpp.
References m_inputIndex.
Referenced by SimulationDialog::updateState().
bool AutomataWorkSimulator::isPlaying | ( | ) | const |
determines, if automatic simulation is running
Definition at line 167 of file automataWorkSimulator.cpp.
References m_playing, and m_simulationTimer.
Referenced by stepBackward(), stepForward(), and SimulationDialog::updateState().
bool AutomataWorkSimulator::isSet | ( | ) | const |
determines, if input is set correctly
Definition at line 173 of file automataWorkSimulator.cpp.
References m_inputList.
Referenced by SimulationDialog::play(), SimulationDialog::set(), SimulationDialog::stepForward(), and SimulationDialog::updateState().
void AutomataWorkSimulator::pause | ( | ) | [slot] |
stops automatic simulation
Definition at line 273 of file automataWorkSimulator.cpp.
References m_dialog, m_playing, and m_simulationTimer.
Referenced by stepBackward(), and stepForward().
void AutomataWorkSimulator::play | ( | ) | [slot] |
runs automatic simulation
Definition at line 260 of file automataWorkSimulator.cpp.
References m_animationTimer, m_dialog, m_playing, m_simulationTimer, and processStep().
Referenced by SimulationDialog::play().
void AutomataWorkSimulator::processStep | ( | ) | [protected, slot] |
processes single step of simulation
Definition at line 390 of file automataWorkSimulator.cpp.
References AutomataCreator::defaultEpsilonSymbList, doAnimation(), m_activeStates, m_activeStatesMemory, m_animationPathMemory, m_automaton, m_backSteps, m_configurationList, m_dialog, m_editor, m_inputIndex, m_inputList, m_simulationTimer, m_status, StringProcessor::parseSymbols(), Editor::redo(), refreshPlayingStatus(), and setActiveStatesMarked().
Referenced by AutomataWorkSimulator(), generateSlideshow(), play(), and stepForward().
void AutomataWorkSimulator::refreshPlayingStatus | ( | ) | [protected] |
Definition at line 380 of file automataWorkSimulator.cpp.
References m_inputIndex, m_inputList, m_playing, and m_simulationTimer.
Referenced by processStep().
void AutomataWorkSimulator::reset | ( | ) | [slot] |
resets state of simulation
Definition at line 284 of file automataWorkSimulator.cpp.
References m_activeStates, m_activeStatesAreMarked, m_activeStatesMemory, m_animationPathMemory, m_animationTimer, m_automaton, m_backSteps, m_configurationList, m_dialog, m_inputIndex, m_inputList, m_playing, m_simulationTimer, m_status, m_undoStack, m_undoStackStartIdx, and setActiveStatesMarked().
Referenced by generateSlideshow(), and run().
QList< QPainterPath > AutomataWorkSimulator::revertPaths | ( | const QList< QPainterPath > & | paths | ) | const [protected] |
Definition at line 509 of file automataWorkSimulator.cpp.
Referenced by stepBackward().
void AutomataWorkSimulator::run | ( | ) | [slot] |
runs simulation dialog
Definition at line 192 of file automataWorkSimulator.cpp.
References m_dialog, and reset().
Referenced by Editor::simulateAutomatonWork().
void AutomataWorkSimulator::saveInputState | ( | QTextStream & | out | ) | [protected] |
Definition at line 617 of file automataWorkSimulator.cpp.
References StringProcessor::CharacterInfo::character, DBGLOG, DBGPAR, Editor::getGridRect(), StringProcessor::isSpecialSymbol(), m_editor, m_inputIndex, and m_inputList.
Referenced by generateSlideshow().
void AutomataWorkSimulator::setActiveStatesMarked | ( | bool | marked | ) | [protected] |
Definition at line 465 of file automataWorkSimulator.cpp.
References m_activeStates, m_activeStatesAreMarked, m_editor, setStatesMarked(), and Editor::update().
Referenced by dialogClosed(), processStep(), and reset().
bool AutomataWorkSimulator::setInput | ( | const QString & | text | ) | [slot] |
sets input string, if it's correctly defined
Definition at line 198 of file automataWorkSimulator.cpp.
References StringProcessor::CharacterInfo::character, StringProcessor::computeCharacterList(), AutomataCreator::defaultEpsilonSymbList, AutomataWorkSimulator::Configuration::eAccepted, m_automaton, m_configurationList, m_dialog, m_inputList, and StringProcessor::parseSymbols().
Referenced by generateSlideshow(), and SimulationDialog::setInput().
void AutomataWorkSimulator::setStatesMarked | ( | QList< State * > | _t1, | |
bool | _t2 | |||
) | [signal] |
signal catched by editor
Definition at line 128 of file moc_automataWorkSimulator.cpp.
Referenced by setActiveStatesMarked().
void AutomataWorkSimulator::stepBackward | ( | ) | [slot] |
reverts last step
Definition at line 235 of file automataWorkSimulator.cpp.
References doAnimation(), isPlaying(), m_activeStates, m_activeStatesMemory, m_animationPathMemory, m_animationTimer, m_backSteps, m_dialog, m_editor, m_inputIndex, m_useAnimations, pause(), revertPaths(), and Editor::undo().
void AutomataWorkSimulator::stepForward | ( | ) | [slot] |
process single step
Definition at line 225 of file automataWorkSimulator.cpp.
References isPlaying(), m_animationTimer, pause(), and processStep().
Referenced by SimulationDialog::stepForward().
void AutomataWorkSimulator::stepSpeedChanged | ( | double | val | ) | [protected, slot] |
Definition at line 483 of file automataWorkSimulator.cpp.
References m_simulationTimer.
Referenced by AutomataWorkSimulator().
void AutomataWorkSimulator::useAnimChanged | ( | int | state | ) | [protected, slot] |
Definition at line 493 of file automataWorkSimulator.cpp.
References m_useAnimations.
Referenced by AutomataWorkSimulator().
Definition at line 110 of file automataWorkSimulator.h.
Referenced by processStep(), reset(), setActiveStatesMarked(), and stepBackward().
bool AutomataWorkSimulator::m_activeStatesAreMarked [private] |
Definition at line 111 of file automataWorkSimulator.h.
Referenced by dialogClosed(), reset(), and setActiveStatesMarked().
QVector<StateImpl::TStateList> AutomataWorkSimulator::m_activeStatesMemory [private] |
Definition at line 124 of file automataWorkSimulator.h.
Referenced by processStep(), reset(), and stepBackward().
QVector<QList<QPainterPath> > AutomataWorkSimulator::m_animationPathMemory [private] |
Definition at line 125 of file automataWorkSimulator.h.
Referenced by processStep(), reset(), and stepBackward().
float AutomataWorkSimulator::m_animationSpeed [private] |
Definition at line 121 of file automataWorkSimulator.h.
Referenced by animSpeedChanged(), and doAnimation().
Definition at line 118 of file automataWorkSimulator.h.
Referenced by animate(), and doAnimation().
QScopedPointer<QTimer> AutomataWorkSimulator::m_animationTimer [private] |
Definition at line 117 of file automataWorkSimulator.h.
Referenced by animate(), AutomataWorkSimulator(), doAnimation(), play(), reset(), stepBackward(), and stepForward().
QSharedPointer<AutomatonImpl> AutomataWorkSimulator::m_automaton [private] |
Definition at line 100 of file automataWorkSimulator.h.
Referenced by processStep(), reset(), and setInput().
int AutomataWorkSimulator::m_backSteps [private] |
step back uses undoStack, so when then is steping forward required again, only redo is done
Definition at line 108 of file automataWorkSimulator.h.
Referenced by hasStateAfter(), processStep(), reset(), and stepBackward().
Definition at line 123 of file automataWorkSimulator.h.
Referenced by getConfigurations(), processStep(), reset(), and setInput().
QScopedPointer<SimulationDialog> AutomataWorkSimulator::m_dialog [private] |
Definition at line 105 of file automataWorkSimulator.h.
Referenced by AutomataWorkSimulator(), generateSlideshow(), getFileName(), getPos(), pause(), play(), processStep(), reset(), run(), setInput(), and stepBackward().
Editor* AutomataWorkSimulator::m_editor [private] |
Definition at line 96 of file automataWorkSimulator.h.
Referenced by animate(), doAnimation(), generateSlideshow(), processStep(), saveInputState(), setActiveStatesMarked(), and stepBackward().
int AutomataWorkSimulator::m_inputIndex [private] |
position in input stringList
Definition at line 103 of file automataWorkSimulator.h.
Referenced by getConfigurations(), getPos(), hasStateAfter(), hasStateBefore(), processStep(), refreshPlayingStatus(), reset(), saveInputState(), and stepBackward().
Definition at line 104 of file automataWorkSimulator.h.
Referenced by getPos(), hasStateAfter(), isSet(), processStep(), refreshPlayingStatus(), reset(), saveInputState(), and setInput().
QList<SimulationMarker*> AutomataWorkSimulator::m_markers [private] |
Definition at line 101 of file automataWorkSimulator.h.
Referenced by animateMove(), doAnimation(), and ~AutomataWorkSimulator().
int AutomataWorkSimulator::m_pathCount [private] |
Definition at line 120 of file automataWorkSimulator.h.
Referenced by animateMove(), and doAnimation().
bool AutomataWorkSimulator::m_playing [private] |
Definition at line 114 of file automataWorkSimulator.h.
Referenced by isPlaying(), pause(), play(), refreshPlayingStatus(), and reset().
QScopedPointer<QTimer> AutomataWorkSimulator::m_simulationTimer [private] |
Definition at line 113 of file automataWorkSimulator.h.
Referenced by AutomataWorkSimulator(), isPlaying(), pause(), play(), processStep(), refreshPlayingStatus(), reset(), and stepSpeedChanged().
Definition at line 102 of file automataWorkSimulator.h.
Referenced by hasStateAfter(), processStep(), and reset().
QUndoStack& AutomataWorkSimulator::m_undoStack [private] |
Definition at line 97 of file automataWorkSimulator.h.
Referenced by dialogClosed(), and reset().
int AutomataWorkSimulator::m_undoStackStartIdx [private] |
Definition at line 98 of file automataWorkSimulator.h.
Referenced by AutomataWorkSimulator(), dialogClosed(), and reset().
bool AutomataWorkSimulator::m_useAnimations [private] |
Definition at line 119 of file automataWorkSimulator.h.
Referenced by doAnimation(), generateSlideshow(), stepBackward(), and useAnimChanged().