wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ExerciseEngine.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <QObject>
7#include <QPointer>
8#include <QVector>
9
12
13class Scene;
14
15class ExerciseEngine : public QObject
16{
17 Q_OBJECT
18
19public:
20 explicit ExerciseEngine(QObject *parent = nullptr);
21
24 bool loadFromResource(const QString &resourcePath);
25
26 QString exerciseId() const { return m_core.id(); }
27 QString exerciseTitle() const { return m_core.title(); }
28
31 void setScene(Scene *scene);
32
33 int currentStep() const { return m_core.currentStep(); }
34 int totalSteps() const { return m_core.totalSteps(); }
35 bool isActive() const { return m_core.isActive(); }
36
38 const ExerciseStep &currentStepData() const;
39
40 void start();
41 void stop();
42 void goToPreviousStep();
43
45 void advanceStep();
46
51 void retranslate();
52
53signals:
54 void stepChanged(int step, int total, const ExerciseStep &data);
55 void stepCompleted(int step);
59
60private slots:
61 void onCircuitChanged();
62
63private:
66 bool validateCurrentStep() const;
67
68 bool validateElements(const QVector<ExerciseElementRequirement> &reqs) const;
69 bool validateConnections(const QVector<ExerciseConnectionRequirement> &reqs) const;
70
71 void emitCurrentStep();
72 void markCompleted();
73
76 void performAdvance();
77
79 QPointer<Scene> m_scene;
80};
Shared step-navigation state machine for ExerciseEngine/TourEngine.
void retranslated()
void setScene(Scene *scene)
bool loadFromResource(const QString &resourcePath)
void advanceStep()
Manually advances one step (used by the overlay Next/Finish button for observe steps).
void stepChanged(int step, int total, const ExerciseStep &data)
void stepCompleted(int step)
QString exerciseId() const
void exerciseCompleted()
const ExerciseStep & currentStepData() const
Returns the data for the current step. Caller must check isActive() first.
bool isActive() const
int totalSteps() const
int currentStep() const
QString exerciseTitle() const
ExerciseEngine(QObject *parent=nullptr)
void exerciseStopped()
Main circuit editing scene.
Definition Scene.h:56
Owns the id/title/step-list/progress state machine shared by ExerciseEngine and TourEngine,...