2024-12-28 17:53:59 +00:00
|
|
|
#include "ScenarioWidget.hpp"
|
|
|
|
#include <Hardware/Widgets/IntervalWidget.hpp>
|
|
|
|
|
|
|
|
namespace Hardware
|
|
|
|
{
|
2025-01-03 23:27:19 +00:00
|
|
|
ScenarioWidget::ScenarioWidget(Scenario::ProcessModel* scenario,
|
|
|
|
bugui::container_widget* parent)
|
2024-12-31 16:11:11 +00:00
|
|
|
: bugui::container_widget{parent}
|
2024-12-28 17:53:59 +00:00
|
|
|
, model{scenario}
|
|
|
|
{
|
|
|
|
model->intervals.mutable_added.connect<&ScenarioWidget::on_interval_added>(this);
|
|
|
|
model->intervals.removed.connect<&ScenarioWidget::on_interval_removed>(this);
|
|
|
|
|
|
|
|
connect(model,
|
|
|
|
&Scenario::ProcessModel::intervalMoved,
|
|
|
|
[this] { update(); });
|
|
|
|
|
|
|
|
for(Scenario::IntervalModel& s : model->intervals)
|
2025-01-03 23:27:19 +00:00
|
|
|
add_widget<IntervalWidget>(s);
|
2024-12-30 12:32:54 +00:00
|
|
|
}
|
|
|
|
|
2024-12-28 17:53:59 +00:00
|
|
|
int ScenarioWidget::x() const
|
|
|
|
{
|
|
|
|
return bugui::base_widget::parent->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScenarioWidget::y() const
|
|
|
|
{
|
2025-01-03 23:27:19 +00:00
|
|
|
return bugui::base_widget::parent->y();
|
2024-12-28 17:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ScenarioWidget::width() const
|
|
|
|
{
|
|
|
|
return bugui::base_widget::parent->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScenarioWidget::height() const
|
|
|
|
{
|
|
|
|
return bugui::base_widget::parent->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScenarioWidget::on_interval_added(Scenario::IntervalModel& interval)
|
|
|
|
{
|
2025-01-03 23:27:19 +00:00
|
|
|
add_widget<IntervalWidget>(interval);
|
2024-12-28 17:53:59 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScenarioWidget::on_interval_removed(const Scenario::IntervalModel& interval)
|
|
|
|
{
|
2025-01-03 23:27:19 +00:00
|
|
|
remove_widget([&interval]
|
2024-12-31 16:11:11 +00:00
|
|
|
(const auto& w)
|
2024-12-29 23:23:03 +00:00
|
|
|
{
|
|
|
|
auto ntrvl = static_cast<IntervalWidget*>(w.get());
|
|
|
|
return ntrvl->get_model().id() == interval.id();
|
|
|
|
});
|
2024-12-28 17:53:59 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScenarioWidget::on_interval_changed(const Scenario::IntervalModel &)
|
|
|
|
{
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Hardware
|
|
|
|
|
|
|
|
#include "wobjectimpl.h"
|
|
|
|
W_OBJECT_IMPL(Hardware::ScenarioWidget)
|