142 void setEvents(
const QVector<EventMarker> &events);
148 void setClippingVisible(
bool visible);
151 void setZScoreMode(
bool enabled);
160 void setAnnotations(
const QVector<AnnotationSpan> &annotations);
167 void setAnnotationSelectionEnabled(
bool enabled);
169 void setEventsVisible(
bool visible);
170 bool eventsVisible()
const;
172 void setAnnotationsVisible(
bool visible);
173 bool annotationsVisible()
const;
187 void setScrollSample(
float sample);
196 void setSamplesPerPixel(
float spp);
205 void scrollTo(
float targetSample,
int durationMs = 200);
214 void zoomTo(
float targetSpp,
int durationMs = 200);
222 void setBackgroundColor(
const QColor &color);
232 void setPrefetchFactor(
float factor);
239 int visibleFirstSample()
const;
245 int visibleSampleCount()
const;
256 void setChannelIndices(
const QVector<int> &indices);
262 int totalLogicalChannels()
const;
270 void setFirstVisibleChannel(
int ch);
279 void setVisibleChannelCount(
int count);
287 void setFrozen(
bool frozen);
294 void setGridVisible(
bool visible);
302 void setSfreq(
float sfreq);
311 void setFirstFileSample(
int first);
321 void setLastFileSample(
int last);
332 void setWheelScrollsChannels(
bool channelsMode);
335 void setScrollSpeedFactor(
float factor);
347 void setHideBadChannels(
bool hide);
358 void setCrosshairEnabled(
bool enabled);
373 void setScalebarsVisible(
bool visible);
382 void setButterflyMode(
bool enabled);
428 const QString &channelName,
const QString &unitLabel);
431 void initialize(QRhiCommandBuffer *cb)
override;
432 void render(QRhiCommandBuffer *cb)
override;
437 friend class ::CrosshairOverlay;
446 void resizeEvent(QResizeEvent *event)
override;
447 void wheelEvent(QWheelEvent *event)
override;
448 void mousePressEvent(QMouseEvent *event)
override;
449 void mouseMoveEvent(QMouseEvent *event)
override;
450 void mouseReleaseEvent(QMouseEvent *event)
override;
451 void mouseDoubleClickEvent(QMouseEvent *event)
override;
455 struct ChannelGpuData {
456 std::unique_ptr<QRhiBuffer> vbo;
458 int vboFirstSample = 0;
461 void ensurePipeline();
462 void rebuildVBOs(QRhiResourceUpdateBatch *batch);
463 void updateUBO(QRhiResourceUpdateBatch *batch);
464 bool isVboDirty()
const;
467 void ensureOverlayPipeline();
468 void rebuildOverlayImage(
int logicalWidth,
int logicalHeight, qreal devicePixelRatio);
470 std::unique_ptr<QRhiBuffer> m_overlayVbo;
471 std::unique_ptr<QRhiTexture> m_overlayTex;
472 std::unique_ptr<QRhiSampler> m_overlaySampler;
473 std::unique_ptr<QRhiShaderResourceBindings> m_overlaySrb;
474 std::unique_ptr<QRhiGraphicsPipeline> m_overlayPipeline;
475 std::unique_ptr<QRhiBuffer> m_overlayUbo;
476 bool m_overlayVboNeedsUpload =
false;
477 QImage m_overlayImage;
478 bool m_overlayDirty =
true;
479 QSize m_overlayTexSize;
484 static constexpr float kOverlayPrefetchFactor = 1.0f;
485 float m_overlayFirstSample = 0.f;
486 float m_overlayTotalSamples = 0.f;
491 float sampleFirst = 0.f;
492 float samplesPerPixel = 0.f;
493 int firstChannel = 0;
494 int visibleCount = 0;
497 void scheduleTileRebuild();
498 static TileResult buildTile(ChannelDataModel *model,
500 float samplesPerPixel,
501 int firstVisibleChannel,
502 int visibleChannelCount,
503 int viewWidth,
int viewHeight,
508 bool hideBadChannels,
509 const QVector<int> &channelIndices,
510 const QVector<EventMarker> &events,
511 const QVector<AnnotationSpan> &annotations,
512 const QVector<int> &epochMarkers,
515 bool isTileFresh()
const;
518 float m_tileSampleFirst = 0.f;
519 float m_tileSamplesPerPixel = 0.f;
520 int m_tileFirstChannel = -1;
521 int m_tileVisibleCount = 0;
522 bool m_tileDirty =
true;
524 QFutureWatcher<TileResult> m_tileWatcher;
525 bool m_tileRebuildPending =
false;
527 std::unique_ptr<QRhiBuffer> m_ubo;
528 std::unique_ptr<QRhiShaderResourceBindings> m_srb;
529 std::unique_ptr<QRhiGraphicsPipeline> m_pipeline;
530 std::vector<ChannelGpuData> m_gpuChannels;
531 int m_uboStride = 256;
532 bool m_pipelineDirty =
true;
533 bool m_vboDirty =
true;
536 QPointer<ChannelDataModel> m_model;
537 float m_scrollSample = 0.f;
538 float m_samplesPerPixel = 1.f;
539 float m_prefetchFactor = 1.0f;
540 QColor m_bgColor { 250, 250, 250 };
542 bool m_frozen =
false;
543 bool m_gridVisible =
true;
544 float m_sfreq = 1000.f;
545 int m_firstFileSample = 0;
546 int m_lastFileSample = -1;
547 bool m_wheelScrollsChannels =
true;
548 float m_scrollSpeedFactor = 1.0f;
549 bool m_hideBadChannels =
false;
552 int m_firstVisibleChannel = 0;
553 int m_visibleChannelCount = 12;
556 bool m_dragging =
false;
557 int m_dragStartX = 0;
558 float m_dragStartScroll = 0.f;
561 bool m_leftButtonDown =
false;
563 float m_leftDownScroll = 0.f;
564 bool m_leftDragActivated =
false;
566 struct VelocitySample {
int x; qint64 t; };
567 QVector<VelocitySample> m_velocityHistory;
568 QElapsedTimer m_dragTimer;
569 QPropertyAnimation* m_pInertialAnim =
nullptr;
573 QVector<int> m_filteredChannels;
576 QVector<EventMarker> m_events;
577 QVector<int> m_epochTriggerSamples;
578 QVector<AnnotationSpan> m_annotations;
579 bool m_annotationSelectionEnabled =
false;
580 bool m_bShowEvents =
true;
581 bool m_bShowAnnotations =
true;
582 bool m_bShowEpochMarkers =
true;
583 bool m_bShowClipping =
true;
584 bool m_bZScoreMode =
false;
587 bool m_annDragging =
false;
588 int m_annDragIndex = -1;
589 bool m_annDragIsStart =
true;
590 int m_annHoverIndex = -1;
591 bool m_annHoverIsStart =
true;
592 static constexpr int kAnnBoundaryHitPx = 5;
595 bool m_annSelecting =
false;
599 int hitTestAnnotationBoundary(
int px,
bool &isStart)
const;
602 int actualChannelAt(
int logicalIdx)
const;
603 QVector<int> effectiveChannelIndices()
const;
606 int m_vboWindowFirst = 0;
607 int m_vboWindowLast = 0;
612 bool m_rulerActive =
false;
613 RulerSnap m_rulerSnap = RulerSnap::Free;
618 int m_rulerRawX1 = 0;
619 int m_rulerRawY1 = 0;
622 bool m_crosshairEnabled =
false;
623 int m_crosshairX = -1;
624 int m_crosshairY = -1;
625 bool m_useClockTime =
false;
626 CrosshairOverlay* m_overlay =
nullptr;
629 bool m_scalebarsVisible =
false;
632 bool m_butterflyMode =
false;
634 struct ButterflyTypeGroup {
638 QVector<int> channelIndices;
641 QVector<ButterflyTypeGroup> butterflyTypeGroups()
const;
642 int butterflyLaneCount()
const;