@@ -132,17 +132,18 @@ void LfpChannelDisplay::pxPaint()
132132 Graphics overlayGraphics (display->lfpChannelBitmap );
133133
134134 int center = getHeight () / 2 ;
135+ const int channelTop = getY () - display->getChannelBitmapYOrigin ();
135136
136137 // int ifrom = canvasSplit->lastScreenBufferIndex[0]; // base everything on the first channel
137138 // int ito = screenBufferIndex;
138139
139140 // max and min of channel in absolute px coords for event displays etc - actual data might be drawn outside of this range
140- int jfrom_wholechannel = (int ) (getY () + center - channelHeight / 2 ) + 1 + 0 ;
141- int jto_wholechannel = (int ) (getY () + center + channelHeight / 2 ) - 0 ;
141+ int jfrom_wholechannel = (int ) (channelTop + center - channelHeight / 2 ) + 1 + 0 ;
142+ int jto_wholechannel = (int ) (channelTop + center + channelHeight / 2 ) - 0 ;
142143
143144 // max and min of channel, this is the range where actual data is drawn
144- int jfrom_wholechannel_clip = (int ) (getY () + center - (channelHeight) *canvasSplit->channelOverlapFactor ) + 1 ;
145- int jto_wholechannel_clip = (int ) (getY () + center + (channelHeight) *canvasSplit->channelOverlapFactor ) - 0 ;
145+ int jfrom_wholechannel_clip = (int ) (channelTop + center - (channelHeight) *canvasSplit->channelOverlapFactor ) + 1 ;
146+ int jto_wholechannel_clip = (int ) (channelTop + center + (channelHeight) *canvasSplit->channelOverlapFactor ) - 0 ;
146147
147148 if (jfrom_wholechannel < 0 )
148149 {
@@ -196,27 +197,31 @@ void LfpChannelDisplay::pxPaint()
196197 LfpBitmapPlotterInfo plotterInfo; // hold and pass plotting info for each plotting method class
197198
198199 const bool showRangeMarkers = isSelected || display->getSingleChannelState ();
200+ const bool showMidline = channelHeight > 4 ;
199201
200202 for (int ii = ifrom; ii <= endIndex; ii++)
201203 {
202204 int i = (ifrom_local + ii - ifrom) % getWidth ();
203205 int index = ii % canvasSplit->screenBufferWidth ;
204206
205207 // draw zero line
206- int m = getY () + center;
207-
208- if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
208+ if (showMidline)
209209 {
210- bdLfpChannelBitmap.setPixelColour (i, m, Colour (50 , 50 , 50 ));
210+ int m = channelTop + center;
211+
212+ if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
213+ {
214+ bdLfpChannelBitmap.setPixelColour (i, m, Colour (50 , 50 , 50 ));
215+ }
211216 }
212217
213218 // draw range markers
214219 if (showRangeMarkers)
215220 {
216- int start = getY () + center - channelHeight / 2 ;
221+ int start = channelTop + center - channelHeight / 2 ;
217222 int jump = jmax (1 , channelHeight / 4 );
218223
219- for (m = start; m <= start + jump * 4 ; m += jump)
224+ for (int m = start; m <= start + jump * 4 ; m += jump)
220225 {
221226 if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
222227 {
@@ -228,7 +233,8 @@ void LfpChannelDisplay::pxPaint()
228233
229234 // draw event markers
230235 const int rawEventState = canvasSplit->getEventState (index); // get event state
231- drawEventOverlay (rawEventState, i, jfrom_wholechannel, jto_wholechannel, overlayGraphics); // draw event markers
236+ if (rawEventState != 0 )
237+ drawEventOverlay (rawEventState, i, jfrom_wholechannel, jto_wholechannel, overlayGraphics); // draw event markers
232238
233239 // get y-coordinates for plotting
234240 double a_raw = canvasSplit->getYCoordMax (chan, index);
@@ -317,7 +323,7 @@ void LfpChannelDisplay::pxPaint()
317323 int samplerange = to - from;
318324
319325 plotterInfo.channelID = chan;
320- plotterInfo.y = getY () ;
326+ plotterInfo.y = channelTop ;
321327 plotterInfo.from = from;
322328 plotterInfo.to = to;
323329 plotterInfo.samp = i;
@@ -408,14 +414,15 @@ void LfpChannelDisplay::pxPaintHistory (int playhead, int rightEdge, int maxScre
408414 Graphics overlayGraphics (display->lfpChannelBitmap );
409415
410416 int center = getHeight () / 2 ;
417+ const int channelTop = getY () - display->getChannelBitmapYOrigin ();
411418
412419 // max and min of channel in absolute px coords for event displays etc - actual data might be drawn outside of this range
413- int jfrom_wholechannel = (int ) (getY () + center - channelHeight / 2 ) + 1 + 0 ;
414- int jto_wholechannel = (int ) (getY () + center + channelHeight / 2 ) - 0 ;
420+ int jfrom_wholechannel = (int ) (channelTop + center - channelHeight / 2 ) + 1 + 0 ;
421+ int jto_wholechannel = (int ) (channelTop + center + channelHeight / 2 ) - 0 ;
415422
416423 // max and min of channel, this is the range where actual data is drawn
417- int jfrom_wholechannel_clip = (int ) (getY () + center - (channelHeight) *canvasSplit->channelOverlapFactor ) + 1 ;
418- int jto_wholechannel_clip = (int ) (getY () + center + (channelHeight) *canvasSplit->channelOverlapFactor ) - 0 ;
424+ int jfrom_wholechannel_clip = (int ) (channelTop + center - (channelHeight) *canvasSplit->channelOverlapFactor ) + 1 ;
425+ int jto_wholechannel_clip = (int ) (channelTop + center + (channelHeight) *canvasSplit->channelOverlapFactor ) - 0 ;
419426
420427 if (jfrom_wholechannel < 0 )
421428 {
@@ -453,6 +460,7 @@ void LfpChannelDisplay::pxPaintHistory (int playhead, int rightEdge, int maxScre
453460 LfpBitmapPlotterInfo plotterInfo; // hold and pass plotting info for each plotting method class
454461
455462 const bool showRangeMarkers = isSelected || display->getSingleChannelState ();
463+ const bool showMidline = channelHeight > 4 ;
456464
457465 for (int ii = 0 ; ii < rightEdge; ii++)
458466 {
@@ -489,22 +497,25 @@ void LfpChannelDisplay::pxPaintHistory (int playhead, int rightEdge, int maxScre
489497 // std::cout << "First screenBufferIndex: " << index << std::endl;
490498
491499 // draw zero line
492- int m = getY () + center;
493-
494- if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
500+ if (showMidline)
495501 {
496- // if (bdLfpChannelBitmap.getPixelColour(i, m).isTransparent()) { // make sure we're not drawing over an existing plot from another channel
497- bdLfpChannelBitmap.setPixelColour (i, m, Colour (50 , 50 , 50 ));
498- // }
502+ int m = channelTop + center;
503+
504+ if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
505+ {
506+ // if (bdLfpChannelBitmap.getPixelColour(i, m).isTransparent()) { // make sure we're not drawing over an existing plot from another channel
507+ bdLfpChannelBitmap.setPixelColour (i, m, Colour (50 , 50 , 50 ));
508+ // }
509+ }
499510 }
500511
501512 // draw range markers
502513 if (showRangeMarkers)
503514 {
504- int start = getY () + center - channelHeight / 2 ;
515+ int start = channelTop + center - channelHeight / 2 ;
505516 int jump = jmax (1 , channelHeight / 4 );
506517
507- for (m = start; m <= start + jump * 4 ; m += jump)
518+ for (int m = start; m <= start + jump * 4 ; m += jump)
508519 {
509520 if (m > 0 && m < display->lfpChannelBitmap .getHeight ())
510521 {
@@ -515,7 +526,8 @@ void LfpChannelDisplay::pxPaintHistory (int playhead, int rightEdge, int maxScre
515526
516527 // draw event markers
517528 const int rawEventState = canvasSplit->getEventState (index); // get event state
518- drawEventOverlay (rawEventState, i, jfrom_wholechannel, jto_wholechannel, overlayGraphics); // draw event markers
529+ if (rawEventState != 0 )
530+ drawEventOverlay (rawEventState, i, jfrom_wholechannel, jto_wholechannel, overlayGraphics); // draw event markers
519531
520532 // get y max-min for plotting
521533 double a_raw = canvasSplit->getYCoordMax (chan, index);
@@ -604,7 +616,7 @@ void LfpChannelDisplay::pxPaintHistory (int playhead, int rightEdge, int maxScre
604616 int samplerange = to - from;
605617
606618 plotterInfo.channelID = chan;
607- plotterInfo.y = getY () ;
619+ plotterInfo.y = channelTop ;
608620 plotterInfo.from = from;
609621 plotterInfo.to = to;
610622 plotterInfo.samp = i;
0 commit comments