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.

125 lines
3.4KB

  1. //
  2. // "$Id: CubeView.h 7913 2010-11-29 18:18:27Z greg.ercolano $"
  3. //
  4. // CubeView class definitions for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #ifndef CUBEVIEW_H
  28. #define CUBEVIEW_H 1
  29. #include <config.h>
  30. #include <FL/Fl.H>
  31. #if HAVE_GL
  32. # include <FL/Fl_Gl_Window.H>
  33. # include <FL/gl.h>
  34. #else
  35. # include <FL/Fl_Box.H>
  36. #endif /* HAVE_GL */
  37. #include <stdlib.h>
  38. #if HAVE_GL
  39. class CubeView : public Fl_Gl_Window {
  40. #else
  41. class CubeView : public Fl_Box {
  42. #endif /* HAVE_GL */
  43. public:
  44. // this value determines the scaling factor used to draw the cube.
  45. double size;
  46. CubeView(int x,int y,int w,int h,const char *l=0);
  47. /* Set the rotation about the vertical (y ) axis.
  48. *
  49. * This function is called by the horizontal roller in CubeViewUI and the
  50. * initialize button in CubeViewUI.
  51. */
  52. void v_angle(float angle){vAng=angle;};
  53. // Return the rotation about the vertical (y ) axis.
  54. float v_angle(){return vAng;};
  55. /* Set the rotation about the horizontal (x ) axis.
  56. *
  57. * This function is called by the vertical roller in CubeViewUI and the
  58. * initialize button in CubeViewUI.
  59. */
  60. void h_angle(float angle){hAng=angle;};
  61. // the rotation about the horizontal (x ) axis.
  62. float h_angle(){return hAng;};
  63. /* Sets the x shift of the cube view camera.
  64. *
  65. * This function is called by the slider in CubeViewUI and the
  66. * initialize button in CubeViewUI.
  67. */
  68. void panx(float x){xshift=x;};
  69. /* Sets the y shift of the cube view camera.
  70. *
  71. * This function is called by the slider in CubeViewUI and the
  72. * initialize button in CubeViewUI.
  73. */
  74. void pany(float y){yshift=y;};
  75. #if HAVE_GL
  76. /*The widget class draw() override.
  77. *
  78. *The draw() function initialize Gl for another round o f drawing
  79. * then calls specialized functions for drawing each of the
  80. * entities displayed in the cube view.
  81. *
  82. */
  83. void draw();
  84. #endif /* HAVE_GL */
  85. private:
  86. /* Draw the cube boundaries
  87. *
  88. *Draw the faces of the cube using the boxv[] vertices, using
  89. * GL_LINE_LOOP for the faces. The color is \#defined by CUBECOLOR.
  90. */
  91. #if HAVE_GL
  92. void drawCube();
  93. #else
  94. void drawCube() { }
  95. #endif /* HAVE_GL */
  96. float vAng,hAng;
  97. float xshift,yshift;
  98. float boxv0[3];float boxv1[3];
  99. float boxv2[3];float boxv3[3];
  100. float boxv4[3];float boxv5[3];
  101. float boxv6[3];float boxv7[3];
  102. };
  103. #endif
  104. //
  105. // End of "$Id: CubeView.h 7913 2010-11-29 18:18:27Z greg.ercolano $".
  106. //