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.

129 lines
3.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 "TrigPluginGUI.h"
  19. #include <FL/fl_draw.h>
  20. #include <FL/fl_draw.H>
  21. #include <stdio.h>
  22. using namespace std;
  23. ////////////////////////////////////////////
  24. TrigPluginGUI::TrigPluginGUI(int w, int h,TrigPlugin *o,ChannelHandler *ch,const HostInfo *Info) :
  25. SpiralPluginGUI(w,h,o,ch)
  26. {
  27. m_Sin = new Fl_Button (10, 15, 60, 20, "Sin");
  28. m_Sin->labelsize (8);
  29. m_Sin->type (FL_TOGGLE_BUTTON);
  30. m_Sin->box (FL_PLASTIC_UP_BOX);
  31. m_Sin->value (1);
  32. m_Sin->color (Info->GUI_COLOUR);
  33. m_Sin->selection_color (Info->GUI_COLOUR);
  34. m_Sin->callback ((Fl_Callback*)cb_Sin);
  35. m_Cos = new Fl_Button (10, 35, 60, 20, "Cos");
  36. m_Cos->labelsize (8);
  37. m_Cos->type (FL_TOGGLE_BUTTON);
  38. m_Cos->box (FL_PLASTIC_UP_BOX);
  39. m_Cos->color (Info->GUI_COLOUR);
  40. m_Cos->selection_color (Info->GUI_COLOUR);
  41. m_Cos->callback ((Fl_Callback*)cb_Cos);
  42. m_Tan = new Fl_Button (10, 55, 60, 20, "Tan");
  43. m_Tan->labelsize (8);
  44. m_Tan->type (FL_TOGGLE_BUTTON);
  45. m_Tan->box (FL_PLASTIC_UP_BOX);
  46. m_Tan->color (Info->GUI_COLOUR);
  47. m_Tan->selection_color (Info->GUI_COLOUR);
  48. m_Tan->callback ((Fl_Callback*)cb_Tan);
  49. end();
  50. }
  51. void TrigPluginGUI::UpdateValues(SpiralPlugin *o)
  52. {
  53. TrigPlugin* Plugin = (TrigPlugin*)o;
  54. m_Sin->value(false);
  55. m_Cos->value(false);
  56. m_Tan->value(false);
  57. switch (Plugin->GetOperator())
  58. {
  59. case TrigPlugin::SIN : m_Sin->value(true); break;
  60. case TrigPlugin::COS : m_Cos->value(true); break;
  61. case TrigPlugin::TAN : m_Tan->value(true); break;
  62. default: break;
  63. }
  64. }
  65. //// Callbacks ////
  66. inline void TrigPluginGUI::cb_Sin_i(Fl_Button* o, void* v)
  67. {
  68. if (o->value())
  69. {
  70. m_Cos->value(false);
  71. m_Tan->value(false);
  72. m_GUICH->Set("Operator",(int)TrigPlugin::SIN);
  73. }
  74. else
  75. {
  76. o->value(true);
  77. }
  78. }
  79. void TrigPluginGUI::cb_Sin(Fl_Button* o, void* v)
  80. { ((TrigPluginGUI*)(o->parent()))->cb_Sin_i(o,v);}
  81. inline void TrigPluginGUI::cb_Cos_i(Fl_Button* o, void* v)
  82. {
  83. if (o->value())
  84. {
  85. m_Sin->value(false);
  86. m_Tan->value(false);
  87. m_GUICH->Set("Operator",(int)TrigPlugin::COS);
  88. }
  89. else
  90. {
  91. o->value(true);
  92. }
  93. }
  94. void TrigPluginGUI::cb_Cos(Fl_Button* o, void* v)
  95. { ((TrigPluginGUI*)(o->parent()))->cb_Cos_i(o,v);}
  96. inline void TrigPluginGUI::cb_Tan_i(Fl_Button* o, void* v)
  97. {
  98. if (o->value())
  99. {
  100. m_Sin->value(false);
  101. m_Cos->value(false);
  102. m_GUICH->Set("Operator",(int)TrigPlugin::TAN);
  103. }
  104. else
  105. {
  106. o->value(true);
  107. }
  108. }
  109. void TrigPluginGUI::cb_Tan(Fl_Button* o, void* v)
  110. { ((TrigPluginGUI*)(o->parent()))->cb_Tan_i(o,v);}
  111. const string TrigPluginGUI::GetHelpText(const string &loc){
  112. return string("")
  113. + "Calculates the sin/cos/tan of the input value, 1.0=360 degrees.";
  114. }