summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1999-02-22 21:33:55 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1999-02-22 21:33:55 +0000
commit636b6de26ddcb58c4e5bf317bad104115c0465b3 (patch)
treefe1158c20f7abfaba0abd0e0260ed69df095207d
parentdf01cba1240932472b939564f1854268a6b0b06f (diff)
Added CubeView source files.
Added CubeView to the makefile and demo.menu. git-svn-id: file:///fltk/svn/fltk/trunk@321 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--test/CubeMain.cxx46
-rw-r--r--test/CubeView.cxx94
-rw-r--r--test/CubeView.h113
-rw-r--r--test/CubeViewUI.fl78
-rw-r--r--test/Makefile12
-rw-r--r--test/demo.menu1
6 files changed, 340 insertions, 4 deletions
diff --git a/test/CubeMain.cxx b/test/CubeMain.cxx
new file mode 100644
index 000000000..72a7d25ed
--- /dev/null
+++ b/test/CubeMain.cxx
@@ -0,0 +1,46 @@
+//
+// "$Id: CubeMain.cxx,v 1.1 1999/02/22 21:33:53 mike Exp $"
+//
+// CubeView class definitions for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-1999 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@easysw.com".
+//
+
+#include <config.h>
+#include <FL/Fl.H>
+#include "CubeViewUI.h"
+
+main(int argc, char **argv) {
+
+ CubeViewUI *cvui=new CubeViewUI;
+
+//Initial global objects.
+
+ Fl::visual(FL_DOUBLE|FL_INDEX);
+
+ cvui->show();
+
+ return Fl::run();
+}
+
+
+//
+// End of "$Id: CubeMain.cxx,v 1.1 1999/02/22 21:33:53 mike Exp $".
+//
diff --git a/test/CubeView.cxx b/test/CubeView.cxx
new file mode 100644
index 000000000..a8a846d70
--- /dev/null
+++ b/test/CubeView.cxx
@@ -0,0 +1,94 @@
+//
+// "$Id: CubeView.cxx,v 1.1 1999/02/22 21:33:54 mike Exp $"
+//
+// CubeView class implementation for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-1999 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@easysw.com".
+//
+
+#include "CubeView.h"
+#include <math.h>
+
+
+CubeView::CubeView(int x,int y,int w,int h,const char *l)
+ : Fl_Gl_Window(x,y,w,h,l)
+{
+ vAng = 0.0;
+ hAng=0.0;
+ size=10.0;
+
+ /* The cube definition. These are the vertices of a unit cube
+ * centered on the origin.*/
+
+ boxv0[0] = -0.5; boxv0[1] = -0.5; boxv0[2] = -0.5;
+ boxv1[0] = 0.5; boxv1[1] = -0.5; boxv1[2] = -0.5;
+ boxv2[0] = 0.5; boxv2[1] = 0.5; boxv2[2] = -0.5;
+ boxv3[0] = -0.5; boxv3[1] = 0.5; boxv3[2] = -0.5;
+ boxv4[0] = -0.5; boxv4[1] = -0.5; boxv4[2] = 0.5;
+ boxv5[0] = 0.5; boxv5[1] = -0.5; boxv5[2] = 0.5;
+ boxv6[0] = 0.5; boxv6[1] = 0.5; boxv6[2] = 0.5;
+ boxv7[0] = -0.5; boxv7[1] = 0.5; boxv7[2] = 0.5;
+};
+
+// The color used for the edges of the bounding cube.
+#define CUBECOLOR 255,255,255,255
+
+void CubeView::drawCube() {
+/* Draw a colored cube */
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd();
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv5); v3f(boxv4); v3f(boxv7); v3f(boxv6); glEnd();
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd();
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv2); v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd();
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd();
+ glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv1); v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd();
+#define ALPHA 128
+ glBegin(GL_QUADS); glColor4ub( 0, 0, 255, ALPHA); v3f(boxv0); v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd();
+ glBegin(GL_QUADS); glColor4ub(255, 255, 0, ALPHA); v3f(boxv0); v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd();
+ glBegin(GL_QUADS); glColor4ub( 0, 255, 255, ALPHA); v3f(boxv2); v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd();
+ glBegin(GL_QUADS); glColor4ub(255, 0, 0, ALPHA); v3f(boxv4); v3f(boxv5); v3f(boxv6); v3f(boxv7); glEnd();
+ glBegin(GL_QUADS); glColor4ub(255, 0, 255, ALPHA); v3f(boxv0); v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd();
+ glBegin(GL_QUADS); glColor4ub( 0, 255, 0, ALPHA); v3f(boxv1); v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd();
+};//drawCube
+
+void CubeView::draw() {
+ if (!valid()) {
+ glLoadIdentity();
+ glViewport(0,0,w(),h());
+ glOrtho(-10,10,-10,10,-20000,10000);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+
+ glTranslatef(xshift, yshift, 0);
+ glRotatef(hAng,0,1,0); glRotatef(vAng,1,0,0);
+ glScalef(float(size),float(size),float(size));
+
+ drawCube();
+
+ glPopMatrix();
+};
+
+//
+// End of "$Id: CubeView.cxx,v 1.1 1999/02/22 21:33:54 mike Exp $".
+//
diff --git a/test/CubeView.h b/test/CubeView.h
new file mode 100644
index 000000000..c58060099
--- /dev/null
+++ b/test/CubeView.h
@@ -0,0 +1,113 @@
+//
+// "$Id: CubeView.h,v 1.1 1999/02/22 21:33:54 mike Exp $"
+//
+// CubeView class definitions for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-1999 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@easysw.com".
+//
+
+#ifndef CUBEVIEW_H
+#define CUBEVIEW_H 1
+#include <config.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Gl_Window.H>
+#include <FL/gl.h>
+#include <GL/glu.h>
+
+#include <stdlib.h>
+
+// shorthand to save some bits.
+#define v3f(x) glVertex3fv(x)
+
+
+class CubeView : public Fl_Gl_Window {
+
+public:
+ // this value determines the scaling factor used to draw the cube.
+ double size;
+
+ CubeView(int x,int y,int w,int h,const char *l=0);
+
+ /* Set the rotation about the vertical (y ) axis.
+ *
+ * This function is called by the horizontal roller in CubeViewUI and the
+ * initialize button in CubeViewUI.
+ */
+ void v_angle(float angle){vAng=angle;};
+
+ // Return the rotation about the vertical (y ) axis.
+ float v_angle(){return vAng;};
+
+ /* Set the rotation about the horizontal (x ) axis.
+ *
+ * This function is called by the vertical roller in CubeViewUI and the
+ * initialize button in CubeViewUI.
+ */
+
+ void h_angle(float angle){hAng=angle;};
+
+ // the rotation about the horizontal (x ) axis.
+ float h_angle(){return hAng;};
+
+ /* Sets the x shift of the cube view camera.
+ *
+ * This function is called by the slider in CubeViewUI and the
+ * initialize button in CubeViewUI.
+ */
+ void panx(float x){xshift=x;};
+ /* Sets the y shift of the cube view camera.
+ *
+ * This function is called by the slider in CubeViewUI and the
+ * initialize button in CubeViewUI.
+ */
+ void pany(float y){yshift=y;};
+
+ /*The widget class draw() override.
+ *
+ *The draw() function initialize Gl for another round o f drawing
+ * then calls specialized functions for drawing each of the
+ * entities displayed in the cube view.
+ *
+ */
+ void draw();
+private:
+
+ /* Draw the cube boundaries
+ *
+ *Draw the faces of the cube using the boxv[] vertices, using
+ * GL_LINE_LOOP for the faces. The color is \#defined by CUBECOLOR.
+ */
+ void drawCube();
+
+ float vAng,hAng;
+ float xshift,yshift;
+
+
+ float boxv0[3];float boxv1[3];
+ float boxv2[3];float boxv3[3];
+ float boxv4[3];float boxv5[3];
+ float boxv6[3];float boxv7[3];
+
+};
+#endif
+
+//
+// End of "$Id: CubeView.h,v 1.1 1999/02/22 21:33:54 mike Exp $".
+//
diff --git a/test/CubeViewUI.fl b/test/CubeViewUI.fl
new file mode 100644
index 000000000..e619ff82f
--- /dev/null
+++ b/test/CubeViewUI.fl
@@ -0,0 +1,78 @@
+# data file for the Fltk User Interface Designer (fluid)
+version 1.00
+header_name {.h}
+code_name {.cxx}
+gridx 2
+gridy 2
+snap 2
+class CubeViewUI {open
+} {
+ Function {CubeViewUI()} {open
+ } {
+ Fl_Window mainWindow {
+ label CubeView open selected
+ private xywh {428 124 419 406} box UP_BOX labelsize 12 resizable visible
+ } {
+ Fl_Group {} {open
+ xywh {5 3 374 399}
+ } {
+ Fl_Group VChange {open
+ xywh {5 100 37 192}
+ } {
+ Fl_Roller vrot {
+ label {V Rot}
+ callback {cube->v_angle(((Fl_Roller *)o)->value());
+cube->redraw();}
+ xywh {5 100 17 186} labeltype NO_LABEL labelsize 12 align 128 minimum -180 maximum 180 step 1
+ code0 {\#include <stdio.h>}
+ }
+ Fl_Slider ypan {
+ label {V Pan}
+ callback {cube->pany(((Fl_Slider *)o)->value());
+cube->redraw();}
+ xywh {25 100 17 186} type {Vert Knob} selection_color 136 labeltype NO_LABEL labelsize 12 align 0 minimum -25 maximum 25 step 0.1
+ }
+ }
+ Fl_Group HChange {open
+ xywh {120 362 190 40}
+ } {
+ Fl_Slider xpan {
+ label {H Pan}
+ callback {cube->panx(((Fl_Slider *)o)->value());
+cube->redraw();}
+ xywh {122 364 186 17} type {Horz Knob} selection_color 136 labeltype NO_LABEL labelsize 12 align 16 minimum 25 maximum -25 step 0.1
+ }
+ Fl_Roller hrot {
+ label {H Rotation}
+ callback {cube->h_angle(((Fl_Roller *)o)->value());
+cube->redraw();}
+ xywh {122 383 186 17} type Horizontal labeltype NO_LABEL labelsize 12 align 8 minimum -180 maximum 180 step 1
+ }
+ }
+ Fl_Group MainView {open
+ xywh {46 27 333 333}
+ } {
+ Fl_Box cframe {
+ xywh {46 27 333 333} box DOWN_FRAME color 4 selection_color 69
+ }
+ Fl_Box cube {
+ label {This is the cube_view}
+ xywh {48 29 329 329}
+ code0 {\#include "CubeView.h"}
+ class CubeView
+ }
+ }
+ Fl_Value_Slider zoom {
+ label Zoom
+ callback {cube->size=((Fl_Value_Slider *)o)->value();
+cube->redraw();}
+ xywh {106 3 227 19} type {Horz Knob} selection_color 136 labelfont 1 labelsize 12 align 4 minimum 1 maximum 50 step 0.1 value 10 textfont 1
+ }
+ }
+ }
+ }
+ Function {show()} {open
+ } {
+ code {mainWindow->show();} {}
+ }
+}
diff --git a/test/Makefile b/test/Makefile
index 5fad8ffd3..7a7be305b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile,v 1.16 1999/01/31 07:43:16 bill Exp $"
+# "$Id: Makefile,v 1.17 1999/02/22 21:33:54 mike Exp $"
#
# Test/example program makefile for the Fast Light Tool Kit (FLTK).
#
@@ -24,6 +24,7 @@
#
CPPFILES =\
+ CubeMain.cxx CubeView.cxx \
adjuster.cxx arc.cxx ask.cxx bitmap.cxx boxtype.cxx browser.cxx button.cxx \
buttons.cxx checkers.cxx clock.cxx colbrowser.cxx color_chooser.cxx \
cube.cxx cursor.cxx curve.cxx demo.cxx doublebuffer.cxx editor.cxx \
@@ -35,7 +36,7 @@ CPPFILES =\
subwindow.cxx symbols.cxx tabs.cxx tile.cxx valuators.cxx fast_slow.cxx \
resize.cxx pack.cxx inactive.cxx
-ALL = adjuster arc ask bitmap boxtype browser button buttons checkers \
+ALL = CubeView adjuster arc ask bitmap boxtype browser button buttons checkers \
clock colbrowser color_chooser cube cursor curve demo doublebuffer \
editor file_chooser fonts forms fractals fullscreen gl_overlay \
glpuzzle hello iconize image input keyboard label list_visuals \
@@ -49,7 +50,7 @@ include ../makeinclude
$(ALL): ../lib/$(LIBNAME)
-.SUFFIXES: .cxx .c .o .fl .H
+.SUFFIXES: .cxx .c .o .fl .h
.cxx:
$(CXX) -I.. $(CXXFLAGS) $< -L../lib -lfltk $(LDLIBS) -o $@
@@ -62,6 +63,9 @@ $(ALL): ../lib/$(LIBNAME)
$(CXX) -I.. $(CXXFLAGS) $@.cxx -L../lib -lfltk $(LDLIBS) -o $@
# Other programs needing special "help"...
+CubeView: CubeMain.o CubeView.o CubeViewUI.o
+ $(CXX) -I.. $(CXXFLAGS) CubeMain.o CubeView.o CubeViewUI.o \
+ -L../lib -lfltk $(LDLIBS) -o $@
shiny: shiny.cxx shiny_panel.cxx
$(CXX) -I.. $(CXXFLAGS) shiny.cxx -L../lib -lfltk $(LDLIBS) -o $@
keyboard: keyboard.cxx keyboard_ui.cxx
@@ -84,5 +88,5 @@ install:
@echo Nothing to install in test directory.
#
-# End of "$Id: Makefile,v 1.16 1999/01/31 07:43:16 bill Exp $".
+# End of "$Id: Makefile,v 1.17 1999/02/22 21:33:54 mike Exp $".
#
diff --git a/test/demo.menu b/test/demo.menu
index 5a2546e55..97950db43 100644
--- a/test/demo.menu
+++ b/test/demo.menu
@@ -67,6 +67,7 @@
@main:Tutorial\nfrom\nManual:@j
@j:ask\n(modified):ask
@j:button:button
+ @j:CubeView:CubeView
@j:editor:editor editor.cxx
@j:hello:hello
@j:shape:shape