You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.4KB

  1. /* SpiralPlugin
  2. * Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "ScopePluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. static const int GUI_COLOUR = 179;
  22. static const int GUIBG_COLOUR = 144;
  23. static const int GUIBG2_COLOUR = 145;
  24. ScopeWidget::ScopeWidget(int x,int y,int w,int h,const char *l, int BUFSIZE) :
  25. Fl_Widget(x,y,w,h,l),
  26. m_Data(NULL),
  27. m_Channels(1),
  28. m_Bufsize(BUFSIZE)
  29. {
  30. }
  31. void ScopeWidget::draw()
  32. {
  33. int ho=h()/2;
  34. fl_color(GUIBG_COLOUR);
  35. fl_rectf(x(), y(), w(), h());
  36. if (!m_Data) return;
  37. fl_push_clip(x(), y(), w(), h());
  38. float Value=0,NextValue=0;
  39. fl_color(FL_WHITE);
  40. for(int n=0; n<m_Bufsize-1 && n<w(); n+=m_Channels)
  41. {
  42. Value = NextValue;
  43. NextValue = m_Data[n]*ho;
  44. fl_line(x()+n-2, y()+ho-(int)Value,
  45. x()+n-1, y()+ho-(int)NextValue);
  46. }
  47. fl_pop_clip();
  48. }
  49. ////////////////////////////////////////////
  50. ScopePluginGUI::ScopePluginGUI(int w, int h,ScopePlugin *o,const HostInfo *Info) :
  51. SpiralPluginGUI(w,h,o),
  52. m_Bypass(false)
  53. {
  54. m_Plugin=o;
  55. m_Scope = new ScopeWidget(5, 20, 210, 85, "Scope", Info->BUFSIZE);
  56. Bypass = new Fl_Button(175, 107, 40, 16, "Bypass");
  57. Bypass->labelsize(10);
  58. Bypass->type(1);
  59. Bypass->callback((Fl_Callback*)cb_Bypass);
  60. end();
  61. }
  62. void ScopePluginGUI::Display(const float *data)
  63. {
  64. m_Scope->m_Data=data;
  65. if (!m_Bypass) m_Scope->redraw();
  66. }
  67. void ScopePluginGUI::draw()
  68. {
  69. SpiralGUIType::draw();
  70. if (m_Plugin->GetInput(0)!=NULL)
  71. {
  72. Display(m_Plugin->GetInput(0)->GetBuffer());
  73. }
  74. else
  75. {
  76. Display(NULL);
  77. }
  78. }
  79. void ScopePluginGUI::UpdateValues()
  80. {
  81. }
  82. void ScopePluginGUI::cb_Bypass_i(Fl_Button* o, void* v)
  83. {m_Bypass=o->value();}
  84. void ScopePluginGUI::cb_Bypass(Fl_Button* o, void* v)
  85. {((ScopePluginGUI*)(o->parent()))->cb_Bypass_i(o,v);}