Skip to content

Commit

Permalink
cabana: Insert newly split charts directly after the original chart (c…
Browse files Browse the repository at this point in the history
…ommaai#33748)

split charts under current chart
  • Loading branch information
deanlee authored Oct 8, 2024
1 parent 19fdf90 commit 196fb0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tools/cabana/chart/chartswidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,15 @@ ChartView *ChartsWidget::findChart(const MessageId &id, const cabana::Signal *si
return nullptr;
}

ChartView *ChartsWidget::createChart() {
ChartView *ChartsWidget::createChart(int pos) {
auto chart = new ChartView(can->timeRange().value_or(display_range), this);
chart->setFixedHeight(settings.chart_height);
chart->setMinimumWidth(CHART_MIN_WIDTH);
chart->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
QObject::connect(chart, &ChartView::axisYLabelWidthChanged, align_timer, qOverload<>(&QTimer::start));
charts.push_front(chart);
currentCharts().push_front(chart);
pos = std::clamp(pos, 0, charts.size());
charts.insert(pos, chart);
currentCharts().insert(pos, chart);
updateLayout(true);
updateToolBar();
return chart;
Expand All @@ -281,8 +282,9 @@ void ChartsWidget::showChart(const MessageId &id, const cabana::Signal *sig, boo

void ChartsWidget::splitChart(ChartView *src_chart) {
if (src_chart->sigs.size() > 1) {
int pos = charts.indexOf(src_chart) + 1;
for (auto it = src_chart->sigs.begin() + 1; it != src_chart->sigs.end(); /**/) {
auto c = createChart();
auto c = createChart(pos);
src_chart->chart()->removeSeries(it->series);

// Restore to the original color
Expand Down
2 changes: 1 addition & 1 deletion tools/cabana/chart/chartswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public slots:
bool event(QEvent *event) override;
void alignCharts();
void newChart();
ChartView *createChart();
ChartView *createChart(int pos = 0);
void removeChart(ChartView *chart);
void splitChart(ChartView *chart);
QRect chartVisibleRect(ChartView *chart);
Expand Down

0 comments on commit 196fb0a

Please sign in to comment.