@@ -562,6 +562,12 @@ bool LfpDisplayCanvas::getDrawMethodState()
562562 return options->getDrawMethodState (); // drawMethodButton->getToggleState();
563563}
564564
565+ int LfpDisplayCanvas::getChannelSampleRate (int channel)
566+ {
567+ // TODO: (kelly) should this do a range check?
568+ return sampleRate[channel];
569+ }
570+
565571void LfpDisplayCanvas::redraw ()
566572{
567573 fullredraw=true ;
@@ -824,6 +830,24 @@ LfpDisplayOptions::LfpDisplayOptions(LfpDisplayCanvas* canvas_, LfpTimescale* ti
824830 channelDisplaySkipLabel->setFont (labelFont);
825831 channelDisplaySkipLabel->setColour (Label::textColourId, labelColour);
826832 addAndMakeVisible (channelDisplaySkipLabel);
833+
834+ // init stream rate displaying options
835+ streamRateDisplayedOptions.add (" High" );
836+ streamRateDisplayedOptions.add (" Low" );
837+ selectedStreamRateDisplayed = 1 ;
838+ selectedChannelDisplaySkipValue = streamRateDisplayedOptions[selectedStreamRateDisplayed - 1 ];
839+
840+ streamRateDisplayedSelection = new ComboBox (" Displayed Stream Rate" );
841+ streamRateDisplayedSelection->addItemList (streamRateDisplayedOptions, 1 );
842+ streamRateDisplayedSelection->setSelectedId (selectedStreamRateDisplayed, sendNotification);
843+ streamRateDisplayedSelection->setEditableText (false );
844+ streamRateDisplayedSelection->addListener (this );
845+ addAndMakeVisible (streamRateDisplayedSelection);
846+
847+ streamRateDisplayedLabel = new Label (" Displayed Stream Rate Label" , " Display Stream Rate" );
848+ streamRateDisplayedLabel->setFont (labelFont);
849+ streamRateDisplayedLabel->setColour (Label::textColourId, labelColour);
850+ addAndMakeVisible (streamRateDisplayedLabel);
827851
828852 // init show/hide options button
829853 showHideOptionsButton = new ShowHideOptionsButton (this );
@@ -1067,32 +1091,45 @@ void LfpDisplayOptions::resized()
10671091 pauseButton->setBounds (450 ,getHeight ()-50 ,50 ,44 );
10681092
10691093 // Channel Zoom Slider
1070- channelZoomSlider->setBounds (pauseButton->getRight () + 10 , getHeight () - 30 , 100 , 22 );
1094+ channelZoomSlider->setBounds (pauseButton->getRight () + 5 ,
1095+ getHeight () - 30 ,
1096+ 100 ,
1097+ 22 );
10711098 channelZoomSliderLabel->setBounds (channelZoomSlider->getX (),
10721099 channelZoomSlider->getY () - 20 ,
10731100 180 ,
10741101 22 );
10751102
10761103 // Reverse Channels Display
1077- reverseChannelsDisplayButton->setBounds (channelZoomSlider->getX () + channelZoomSlider->getWidth () + 25 ,
1104+ reverseChannelsDisplayButton->setBounds (channelZoomSlider->getX () + channelZoomSlider->getWidth () + 5 ,
10781105 getHeight ()-50 ,
10791106 20 ,
10801107 20 );
1081- reverseChannelsDisplayLabel->setBounds (reverseChannelsDisplayButton->getRight () + 5 ,
1108+ reverseChannelsDisplayLabel->setBounds (reverseChannelsDisplayButton->getRight (),
10821109 reverseChannelsDisplayButton->getY (),
10831110 180 ,
10841111 22 );
10851112
10861113 // Channel Display Skip Selector
1087- channelDisplaySkipSelection->setBounds (channelZoomSlider->getX () + channelZoomSlider-> getWidth () + 25 ,
1114+ channelDisplaySkipSelection->setBounds (channelZoomSlider->getX () + channelZoomSlider-> getWidth () + 5 ,
10881115 channelZoomSlider->getY (),
10891116 60 ,
10901117 25 );
1091- channelDisplaySkipLabel->setBounds (channelDisplaySkipSelection->getRight () + 5 ,
1092- channelDisplaySkipSelection->getY (),
1118+ channelDisplaySkipLabel->setBounds (channelDisplaySkipSelection->getRight (),
1119+ channelDisplaySkipSelection->getY () + 2 ,
10931120 100 ,
10941121 22 );
1095-
1122+
1123+ // Stream Rate Displayed Selector
1124+ streamRateDisplayedSelection->setBounds (reverseChannelsDisplayButton->getX () + 130 ,
1125+ channelDisplaySkipSelection->getY (),
1126+ 60 ,
1127+ 25 );
1128+ streamRateDisplayedLabel->setBounds (streamRateDisplayedSelection->getX () - 5 ,
1129+ reverseChannelsDisplayButton->getY (),
1130+ 150 ,
1131+ 22 );
1132+
10961133 // Saturation Warning Selection
10971134 saturationWarningSelection->setBounds (250 , getHeight ()-90 , 60 , 25 );
10981135
@@ -1194,6 +1231,7 @@ void LfpDisplayOptions::setRangeSelection(float range, bool canvasMustUpdate)
11941231
11951232void LfpDisplayOptions::setSpreadSelection (int spread, bool canvasMustUpdate)
11961233{
1234+
11971235 if (canvasMustUpdate)
11981236 {
11991237 spreadSelection->setText (String (spread),sendNotification);
@@ -1989,12 +2027,18 @@ void LfpDisplay::setNumChannels(int numChannels)
19892027 // lfpInfo->setColour(channelColours[i % channelColours.size()]);
19902028 lfpInfo->setRange (range[options->getChannelType (i)]);
19912029 lfpInfo->setChannelHeight (canvas->getChannelHeight ());
2030+
2031+ // TODO: (kelly) this won't work... samplerate gets set AFTER this method is called
2032+ lfpInfo->setChannelSampleRate (canvas->getChannelSampleRate (i));
19922033
19932034 addAndMakeVisible (lfpInfo);
19942035
19952036 channelInfo.add (lfpInfo);
19962037
1997- drawableChannels.add (LfpChannel{lfpChan, lfpInfo});
2038+ drawableChannels.add (LfpChannelTrack{
2039+ lfpChan,
2040+ lfpInfo
2041+ });
19982042
19992043 savedChannelState.add (true );
20002044
@@ -2394,8 +2438,22 @@ void LfpDisplay::mouseWheelMove(const MouseEvent& e, const MouseWheelDetails&
23942438
23952439 if (abs (h) > 100 ) // accelerate scrolling for large ranges
23962440 hdiff *= 3 ;
2441+
2442+ int newHeight = h+hdiff;
2443+
2444+ // constrain the spread resizing to max and min values;
2445+ if (newHeight < trackZoomInfo.minZoomHeight )
2446+ {
2447+ newHeight = trackZoomInfo.minZoomHeight ;
2448+ hdiff = 0 ;
2449+ }
2450+ else if (newHeight > trackZoomInfo.maxZoomHeight )
2451+ {
2452+ newHeight = trackZoomInfo.maxZoomHeight ;
2453+ hdiff = 0 ;
2454+ }
23972455
2398- setChannelHeight (h+hdiff );
2456+ setChannelHeight (newHeight );
23992457 int oldX=viewport->getViewPositionX ();
24002458 int oldY=viewport->getViewPositionY ();
24012459
@@ -2405,7 +2463,7 @@ void LfpDisplay::mouseWheelMove(const MouseEvent& e, const MouseWheelDetails&
24052463 int scrollBy = (mouseY/h)*hdiff*2 ;// compensate for motion of point under current mouse position
24062464 viewport->setViewPosition (oldX,oldY+scrollBy); // set back to previous position plus offset
24072465
2408- options->setSpreadSelection (h+hdiff ); // update combobox
2466+ options->setSpreadSelection (newHeight ); // update combobox
24092467
24102468 canvas->fullredraw = true ;// issue full redraw - scrolling without modifier doesnt require a full redraw
24112469 }
@@ -2450,8 +2508,6 @@ void LfpDisplay::mouseWheelMove(const MouseEvent& e, const MouseWheelDetails&
24502508
24512509void LfpDisplay::toggleSingleChannel (int chan)
24522510{
2453- // TODO: (kelly) this breaks with the new reversing and filtering mechanisms
2454-
24552511 // std::cout << "Toggle channel " << chan << std::endl;
24562512
24572513
@@ -2476,40 +2532,42 @@ void LfpDisplay::toggleSingleChannel(int chan)
24762532// channels[i]->setEnabledState(false);
24772533// }
24782534
2479- std::cout << " \n Single channel on (" << chan << " )" << std::endl;
2535+ std::cout << " Single channel on (" << chan << " )" << std::endl;
24802536 singleChan = chan;
24812537
24822538 int newHeight = viewport->getHeight ();
2483- LfpChannel lfpChannel {drawableChannels[chan].channel , drawableChannels[chan].channelInfo };
2539+ LfpChannelTrack lfpChannelTrack {drawableChannels[chan].channel , drawableChannels[chan].channelInfo };
24842540// drawableChannels[chan].channelInfo->setEnabledState(true);
24852541// drawableChannels[chan].channelInfo->setSingleChannelState(true);
2486- lfpChannel .channelInfo ->setEnabledState (true );
2487- lfpChannel .channelInfo ->setSingleChannelState (true );
2542+ lfpChannelTrack .channelInfo ->setEnabledState (true );
2543+ lfpChannelTrack .channelInfo ->setSingleChannelState (true );
24882544 setChannelHeight (newHeight, false );
24892545 setSize (getWidth (), numChans*getChannelHeight ());
24902546
24912547 viewport->setScrollBarsShown (false , false );
24922548 viewport->setViewPosition (Point<int >(0 , chan*newHeight));
24932549// viewport->setViewPosition(Point<int>(0, 0));
24942550
2551+ // disable unused channels
24952552 for (int i = 0 ; i < drawableChannels.size (); i++)
24962553 {
24972554 if (i != chan) drawableChannels[i].channel ->setEnabledState (false );
24982555 }
24992556
2500- Array<LfpChannel> channelsToDraw{lfpChannel};
2557+ // update drawableChannels, give only the single channel to focus on
2558+ Array<LfpChannelTrack> channelsToDraw{lfpChannelTrack};
25012559 drawableChannels = channelsToDraw;
25022560
25032561 // remove all other children and show this one channel
25042562 removeAllChildren ();
2505- addAndMakeVisible (lfpChannel .channel );
2506- addAndMakeVisible (lfpChannel .channelInfo );
2563+ addAndMakeVisible (lfpChannelTrack .channel );
2564+ addAndMakeVisible (lfpChannelTrack .channelInfo );
25072565
25082566 }
25092567// else if (chan == singleChan || chan == -2)
2510- else if ( getSingleChannelState ())
2568+ else
25112569 {
2512- std::cout << " \n Single channel off" << std::endl;
2570+ std::cout << " Single channel off" << std::endl;
25132571 for (int n = 0 ; n < numChans; n++)
25142572 {
25152573 channelInfo[n]->setSingleChannelState (false );
@@ -2533,12 +2591,10 @@ void LfpDisplay::reactivateChannels()
25332591void LfpDisplay::rebuildDrawableChannelsList ()
25342592{
25352593
2536- // TODO: (kelly) possible test here for singleChannel turned ON
2537-
25382594 if (displaySkipAmt != 0 ) removeAllChildren (); // start with clean slate
25392595
2540- Array<LfpChannel > channelsToDraw;
2541- drawableChannels = Array<LfpDisplay::LfpChannel >();
2596+ Array<LfpChannelTrack > channelsToDraw;
2597+ drawableChannels = Array<LfpDisplay::LfpChannelTrack >();
25422598
25432599
25442600 // iterate over all channels and select drawable ones
@@ -2549,7 +2605,7 @@ void LfpDisplay::rebuildDrawableChannelsList()
25492605 channels[i]->setHidden (false );
25502606 channelInfo[i]->setHidden (false );
25512607
2552- channelsToDraw.add (LfpDisplay::LfpChannel {
2608+ channelsToDraw.add (LfpDisplay::LfpChannelTrack {
25532609 channels[i],
25542610 channelInfo[i]
25552611 });
@@ -2564,7 +2620,7 @@ void LfpDisplay::rebuildDrawableChannelsList()
25642620 channels[i]->setHidden (false );
25652621 channelInfo[i]->setHidden (false );
25662622
2567- channelsToDraw.add (LfpDisplay::LfpChannel {
2623+ channelsToDraw.add (LfpDisplay::LfpChannelTrack {
25682624 channels[i],
25692625 channelInfo[i]
25702626 });
@@ -3300,6 +3356,89 @@ void LfpChannelDisplayInfo::setSingleChannelState(bool state)
33003356 isSingleChannel = state;
33013357}
33023358
3359+ int LfpChannelDisplayInfo::getChannelSampleRate ()
3360+ {
3361+ return samplerate;
3362+ }
3363+
3364+ void LfpChannelDisplayInfo::setChannelSampleRate (int samplerate_)
3365+ {
3366+ samplerate = samplerate_;
3367+ }
3368+
3369+ void LfpChannelDisplayInfo::mouseDrag (const MouseEvent &e)
3370+ {
3371+ if (e.mods .isLeftButtonDown ()) // double check that we initiate only for left click and hold
3372+ {
3373+ if (e.mods .isCommandDown () && !display->getSingleChannelState ()) // CTRL + drag -> change channel spacing
3374+ {
3375+ // init state in our track zooming info struct
3376+ if (!display->trackZoomInfo .isScrollingY )
3377+ {
3378+ display->trackZoomInfo .isScrollingY = true ;
3379+ display->trackZoomInfo .componentStartHeight = getChannelHeight ();
3380+ display->trackZoomInfo .zoomPivotRatioY = (getY () + e.getMouseDownY ())/(float )display->getHeight ();
3381+ display->trackZoomInfo .zoomPivotRatioX = (getX () + e.getMouseDownX ())/(float )display->getWidth ();
3382+ display->trackZoomInfo .zoomPivotViewportOffset = getPosition () + e.getMouseDownPosition () - canvas->viewport ->getViewPosition ();
3383+
3384+ }
3385+
3386+ int h = display->trackZoomInfo .componentStartHeight ;
3387+ int hdiff=0 ;
3388+ int dragDeltaY = -0.1 * (e.getScreenPosition ().getY () - e.getMouseDownScreenY ()); // invert so drag up -> scale up
3389+
3390+ // std::cout << dragDeltaY << std::endl;
3391+ if (dragDeltaY > 0 )
3392+ {
3393+ hdiff = 2 * dragDeltaY;
3394+ }
3395+ else
3396+ {
3397+ if (h > 5 )
3398+ hdiff = 2 * dragDeltaY;
3399+ }
3400+
3401+ if (abs (h) > 100 ) // accelerate scrolling for large ranges
3402+ hdiff *= 3 ;
3403+
3404+ int newHeight = h+hdiff;
3405+
3406+ // constrain the spread resizing to max and min values;
3407+ if (newHeight < display->trackZoomInfo .minZoomHeight )
3408+ {
3409+ newHeight = display->trackZoomInfo .minZoomHeight ;
3410+ }
3411+ else if (newHeight > display->trackZoomInfo .maxZoomHeight )
3412+ {
3413+ newHeight = display->trackZoomInfo .maxZoomHeight ;
3414+ }
3415+
3416+ // set channel heights for all channel
3417+ display->setChannelHeight (newHeight);
3418+ display->setBounds (0 ,0 ,display->getWidth ()-0 , display->getChannelHeight ()*display->drawableChannels .size ()); // update height so that the scrollbar is correct
3419+
3420+ canvas->viewport ->setViewPositionProportionately (display->trackZoomInfo .zoomPivotRatioX , display->trackZoomInfo .zoomPivotRatioY );
3421+
3422+ int newViewportY = display->trackZoomInfo .zoomPivotRatioY * display->getHeight () - display->trackZoomInfo .zoomPivotViewportOffset .getY ();
3423+ if (newViewportY < 0 ) newViewportY = 0 ; // make sure we don't adjust beyond the edge of the actual view
3424+
3425+ canvas->viewport ->setViewPosition (display->trackZoomInfo .zoomPivotRatioX , newViewportY);
3426+
3427+ options->setSpreadSelection (newHeight); // update combobox
3428+
3429+ canvas->fullredraw = true ;// issue full redraw - scrolling without modifier doesnt require a full redraw
3430+ }
3431+ }
3432+ }
3433+
3434+ void LfpChannelDisplayInfo::mouseUp (const MouseEvent &e)
3435+ {
3436+ if (e.mods .isLeftButtonDown ())
3437+ {
3438+ display->trackZoomInfo .isScrollingY = false ;
3439+ }
3440+ }
3441+
33033442void LfpChannelDisplayInfo::paint (Graphics& g)
33043443{
33053444
0 commit comments