MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / onSocketReadyRead

Method onSocketReadyRead

pj_widgets/src/RasterStreamView.cpp:76–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void RasterStreamView::onSocketReadyRead() {
77 while (socket_->bytesAvailable() >= pj_raster::kMessageBytes) {
78 const QByteArray bytes = socket_->read(pj_raster::kMessageBytes);
79 const pj_raster::Message msg = pj_raster::decodeMessage(reinterpret_cast<const uint8_t*>(bytes.constData()));
80 if (msg.type == pj_raster::MsgType::kFrameReady && shm_ != nullptr) {
81 if (!shm_->lock()) {
82 continue;
83 }
84 const QImage view = imageForActiveFrame(static_cast<const unsigned char*>(shm_->constData()), shm_->size());
85 frame_ = view.copy();
86 shm_->unlock();
87 if (!frame_.isNull()) {
88 scaled_ = QImage(); // invalidate the cached scale; recomputed on next paint
89 update();
90 }
91 } else if (msg.type == pj_raster::MsgType::kBye) {
92 endSession();
93 }
94 }
95}
96
97void RasterStreamView::paintEvent(QPaintEvent* /*event*/) {
98 QPainter painter(this);

Callers

nothing calls this directly

Calls 6

decodeMessageFunction · 0.85
imageForActiveFrameFunction · 0.85
QImageClass · 0.50
sizeMethod · 0.45
copyMethod · 0.45
isNullMethod · 0.45

Tested by

no test coverage detected