From 6e07ce8f0c6c77b61cfa2f8be54781160018ff91 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 9 Mar 2008 03:47:21 +0000 Subject: * graph/: Depamphletize. * include/addfile.h: Move from hyper. * include/addfile.H1: Move external declarations into addfile.h. Remove. --- src/graph/view2D/Makefile.in | 16 +- src/graph/view2D/buttons2d.c | 718 +++++++++++++++++++++++ src/graph/view2D/buttons2d.c.pamphlet | 738 ------------------------ src/graph/view2D/control2d.c | 621 ++++++++++++++++++++ src/graph/view2D/control2d.c.pamphlet | 641 --------------------- src/graph/view2D/globals2.h | 62 +- src/graph/view2D/graph2d.c | 168 ++++++ src/graph/view2D/graph2d.c.pamphlet | 188 ------ src/graph/view2D/header2.h | 62 +- src/graph/view2D/main2d.c | 503 ++++++++++++++++ src/graph/view2D/main2d.c.pamphlet | 523 ----------------- src/graph/view2D/pot2d.c | 63 ++ src/graph/view2D/pot2d.c.pamphlet | 83 --- src/graph/view2D/process2d.c | 938 ++++++++++++++++++++++++++++++ src/graph/view2D/process2d.c.pamphlet | 958 ------------------------------- src/graph/view2D/spadAction2d.c | 299 ++++++++++ src/graph/view2D/spadAction2d.c.pamphlet | 319 ---------- src/graph/view2D/stuff2d.c | 125 ++++ src/graph/view2D/stuff2d.c.pamphlet | 145 ----- src/graph/view2D/viewport2D.c | 713 +++++++++++++++++++++++ src/graph/view2D/viewport2D.c.pamphlet | 733 ----------------------- src/graph/view2D/write2d.c | 205 +++++++ src/graph/view2D/write2d.c.pamphlet | 225 -------- 23 files changed, 4421 insertions(+), 4625 deletions(-) create mode 100644 src/graph/view2D/buttons2d.c delete mode 100644 src/graph/view2D/buttons2d.c.pamphlet create mode 100644 src/graph/view2D/control2d.c delete mode 100644 src/graph/view2D/control2d.c.pamphlet mode change 100755 => 100644 src/graph/view2D/globals2.h create mode 100644 src/graph/view2D/graph2d.c delete mode 100644 src/graph/view2D/graph2d.c.pamphlet mode change 100755 => 100644 src/graph/view2D/header2.h create mode 100644 src/graph/view2D/main2d.c delete mode 100644 src/graph/view2D/main2d.c.pamphlet create mode 100644 src/graph/view2D/pot2d.c delete mode 100644 src/graph/view2D/pot2d.c.pamphlet create mode 100644 src/graph/view2D/process2d.c delete mode 100644 src/graph/view2D/process2d.c.pamphlet create mode 100644 src/graph/view2D/spadAction2d.c delete mode 100644 src/graph/view2D/spadAction2d.c.pamphlet create mode 100644 src/graph/view2D/stuff2d.c delete mode 100644 src/graph/view2D/stuff2d.c.pamphlet create mode 100644 src/graph/view2D/viewport2D.c delete mode 100644 src/graph/view2D/viewport2D.c.pamphlet create mode 100644 src/graph/view2D/write2d.c delete mode 100644 src/graph/view2D/write2d.c.pamphlet (limited to 'src/graph/view2D') diff --git a/src/graph/view2D/Makefile.in b/src/graph/view2D/Makefile.in index dcff96f4..905d8179 100644 --- a/src/graph/view2D/Makefile.in +++ b/src/graph/view2D/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007, Gabriel Dos Reis. +# Copyright (C) 2007-2008, Gabriel Dos Reis. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -41,12 +41,10 @@ build_libdir = $(abs_top_builddir)/src/lib bin_PROGRAMS = view2D$(EXEEXT) -view2D_sources = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \ +view2D_SOURCES = buttons2d.c control2d.c graph2d.c main2d.c pot2d.c \ process2d.c spadAction2d.c stuff2d.c viewport2D.c write2d.c -view2D_SOURCES = $(addsuffix .pamphlet, $(view2D_sources)) - -view2D_objects = $(view2D_sources:.c=.lo) +view2D_objects = $(view2D_SOURCES:.c=.lo) Gfun_objects = ../Gdraws/Gfun.lo @@ -56,8 +54,6 @@ view2D_DEPENDENCIES = $(Gfun_objects) subdir = src/graph/view2D/ -pamphlets = Makefile.pamphlet $(view2D_SOURCES) - AXIOM_CFLAGS = ${CCF} ${AXIOM_X11_CFLAGS} -I${LINC} -I${GINC} -I$(srcdir) \ $(axiom_includes) @@ -81,7 +77,6 @@ $(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES) $(LINK) -o $@ $(view2D_objects) $(Gfun_objects) \ $(view2D_LDADD) $(AXIOM_X11_LDFLAGS) -lm -.PRECIOUS: %.c .PRECIOUS: %.lo %.$(OBJEXT): $(HEADERS) @@ -89,13 +84,10 @@ $(axiom_target_libdir)/view2D$(EXEEXT): $(view2D_objects) $(view2D_DEPENDENCIES) %.lo: $(builddir)/%.c $(axiom_c_macros.h) $(COMPILE) -o $@ $(CFLAGS) $(AXIOM_CFLAGS) $< -%.c: $(srcdir)/%.c.pamphlet - $(axiom_build_document) --tangle --output=$@ $< - mostlyclean-local: clean-local: mostlyclean-local - @rm -f $(view2D_sources) $(view2D_objects) + @rm -f $(view2D_objects) @rm -f $(axiom_target_libdir)/view2D$(EXEEXT) distclean-local: clean-local diff --git a/src/graph/view2D/buttons2d.c b/src/graph/view2D/buttons2d.c new file mode 100644 index 00000000..3d7a4be6 --- /dev/null +++ b/src/graph/view2D/buttons2d.c @@ -0,0 +1,718 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _BUTTONS2D_C +#include "axiom-c-macros.h" + +#include + +#include "header2.h" +#include "buttons2d.H1" +#include "all_2d.H1" + + + + +#define bColor 98 +#define graphColor 138 + +/***************************************************** + * int initButtons(buttons) * + * * + * Creates the fields for each button window in the * + * two dimensional control panel, and returns the * + * number of buttons created. * + * * + *****************************************************/ + +int +#ifdef _NO_PROTO +initButtons (buttons) +buttonStruct *buttons; +#else +initButtons (buttonStruct *buttons) +#endif +{ + int ii, num = 0; + +/********** Scale(Zoom) and Translate Potentiometer Buttons **********/ + + /* Title: "Scale" */ + ii = scale2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 85; + buttons[ii].buttonWidth = 110; + buttons[ii].buttonHeight = 80; + buttons[ii].buttonKey = ii; + buttons[ii].pot = yes; /* scale is a potentiometer */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = potMASK; + buttons[ii].textColor = 164; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Title: "Translate" */ + ii = translate2D; + buttons[ii].buttonX = 121; + buttons[ii].buttonY = 85; + buttons[ii].buttonWidth = 110; + buttons[ii].buttonHeight = 80; + buttons[ii].buttonKey = ii; + buttons[ii].pot = yes; /* translate is a potentiometer */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = potMASK; + buttons[ii].textColor = 21; /* line color of translate arrow */ + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Scale potentiometer buttons */ + + /* Scale along X axis */ + ii = zoom2Dx; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"X On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Scale along Y axis */ + ii = zoom2Dy; + buttons[ii].buttonX = 62; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Y On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Translate along X axis */ + ii = translate2Dx; + buttons[ii].buttonX = 121; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"X On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Translate along Y axis */ + ii = translate2Dy; + buttons[ii].buttonX = 179; + buttons[ii].buttonY = 55; + buttons[ii].buttonWidth = 53; + buttons[ii].buttonHeight = 25; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Y On "); + buttons[ii].textColor = bColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + + /* Axes Turned On/Off */ + ii = axesOnOff2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 90; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Axes On "); + buttons[ii].textColor = 75; + buttons[ii].textHue = 10; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Units Turned On/Off */ + ii = unitsOnOff2D; + buttons[ii].buttonX = 100; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 90; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Units Off"); + buttons[ii].textColor = 75; + buttons[ii].textHue = 10; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Generate a Postscript file */ + ii = ps2D; + buttons[ii].buttonX = 195; + buttons[ii].buttonY = 292; + buttons[ii].buttonWidth = 36; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"PS"); + buttons[ii].textColor = 35; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Bounding Rectangle On/Off */ + ii = spline2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 66; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Box Off"); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Graph points On/Off */ + ii = pointsOnOff; + buttons[ii].buttonX = 75; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 67; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Pts On "); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Graph lines On/Off */ + ii = connectOnOff; + buttons[ii].buttonX = 147; + buttons[ii].buttonY = 329; + buttons[ii].buttonWidth = 84; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Lines On "); + buttons[ii].textColor = 7; + buttons[ii].textHue = 26; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Reset View Position Button */ + ii = reset2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 364; + buttons[ii].buttonWidth = 60; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Reset"); + buttons[ii].textColor = bColor; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Hide Control Panel */ + ii = hideControl2D; + buttons[ii].buttonX = 70; + buttons[ii].buttonY = 364; + buttons[ii].buttonWidth = 88; + buttons[ii].buttonHeight = 30; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Hide Panel"); + buttons[ii].textColor = bColor; + buttons[ii].textHue = 5; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Exits from the viewport running */ + ii = closeAll2D; + buttons[ii].buttonX = 169; + buttons[ii].buttonY = 370; + buttons[ii].buttonWidth = 61; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Quit"); + buttons[ii].textColor = 13; + buttons[ii].textHue = 29; + buttons[ii].textShade = 2; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the graph from a viewport is to be picked up. */ + ii = pick2D; + buttons[ii].buttonX = 190; + buttons[ii].buttonY = 217; + buttons[ii].buttonWidth = 40; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Pick"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the graph from a viewport is to be dropped into a slot. */ + ii = drop2D; + buttons[ii].buttonX = 190; + buttons[ii].buttonY = 245; + buttons[ii].buttonWidth = 40; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Drop"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Indicates that the status of the graphs being displayed in the viewport + is to be cleared. */ + ii = clear2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 217; + buttons[ii].buttonWidth = 49; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Clear"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* Asks for the scale and translation information for the specified graph. */ + ii = query2D; + buttons[ii].buttonX = 5; + buttons[ii].buttonY = 245; + buttons[ii].buttonWidth = 49; + buttons[ii].buttonHeight = 24; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = no; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"Query"); + buttons[ii].textColor = 123; + buttons[ii].textHue = 19; + buttons[ii].textShade = 3; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + /* These buttons indicate the 9 available slot numbers into which + a 2D graph can be placed, and the status of the graph, i.e. whether + it is displayed or not. */ + + ii = graph1; + buttons[ii].buttonX = graphBarLeft; + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"1"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect1; + buttons[ii].buttonX = graphBarLeft; + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"^"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph2; + buttons[ii].buttonX = graphBarLeft + (graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"2"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect2; + buttons[ii].buttonX = graphBarLeft + (graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph3; + buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"3"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect3; + buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /**** blend these three together ***/ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph4; + buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"4"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect4; + buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph5; + buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"5"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect5; + buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph6; + buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"6"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect6; + buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph7; + buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"7"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect7; + buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph8; + buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"8"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect8; + buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"-"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graph9; + buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); + buttons[ii].buttonY = graphBarTop; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = yes; + buttons[ii].graphSelect = no; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"9"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + ii = graphSelect9; + buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); + buttons[ii].buttonY = graphBarTop + graphBarHeight; + buttons[ii].buttonWidth = graphBarWidth; + buttons[ii].buttonHeight = graphBarHeight-2; + buttons[ii].buttonKey = ii; + buttons[ii].pot = no; /* this is a regular button */ + buttons[ii].graphNum = no; + buttons[ii].graphSelect = yes; + buttons[ii].mask = buttonMASK; + strcpy(buttons[ii].text,"*"); + buttons[ii].textColor = graphColor; + buttons[ii].xHalf = buttons[ii].buttonWidth/2; + buttons[ii].yHalf = buttons[ii].buttonHeight/2; + ++num; + + return(num); +} diff --git a/src/graph/view2D/buttons2d.c.pamphlet b/src/graph/view2D/buttons2d.c.pamphlet deleted file mode 100644 index c0c19185..00000000 --- a/src/graph/view2D/buttons2d.c.pamphlet +++ /dev/null @@ -1,738 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D buttons2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _BUTTONS2D_C -#include "axiom-c-macros.h" - -#include - -#include "header2.h" -#include "buttons2d.H1" -#include "all_2d.H1" - - - - -#define bColor 98 -#define graphColor 138 - -/***************************************************** - * int initButtons(buttons) * - * * - * Creates the fields for each button window in the * - * two dimensional control panel, and returns the * - * number of buttons created. * - * * - *****************************************************/ - -int -#ifdef _NO_PROTO -initButtons (buttons) -buttonStruct *buttons; -#else -initButtons (buttonStruct *buttons) -#endif -{ - int ii, num = 0; - -/********** Scale(Zoom) and Translate Potentiometer Buttons **********/ - - /* Title: "Scale" */ - ii = scale2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 85; - buttons[ii].buttonWidth = 110; - buttons[ii].buttonHeight = 80; - buttons[ii].buttonKey = ii; - buttons[ii].pot = yes; /* scale is a potentiometer */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = potMASK; - buttons[ii].textColor = 164; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Title: "Translate" */ - ii = translate2D; - buttons[ii].buttonX = 121; - buttons[ii].buttonY = 85; - buttons[ii].buttonWidth = 110; - buttons[ii].buttonHeight = 80; - buttons[ii].buttonKey = ii; - buttons[ii].pot = yes; /* translate is a potentiometer */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = potMASK; - buttons[ii].textColor = 21; /* line color of translate arrow */ - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Scale potentiometer buttons */ - - /* Scale along X axis */ - ii = zoom2Dx; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"X On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Scale along Y axis */ - ii = zoom2Dy; - buttons[ii].buttonX = 62; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Y On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Translate along X axis */ - ii = translate2Dx; - buttons[ii].buttonX = 121; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"X On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Translate along Y axis */ - ii = translate2Dy; - buttons[ii].buttonX = 179; - buttons[ii].buttonY = 55; - buttons[ii].buttonWidth = 53; - buttons[ii].buttonHeight = 25; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Y On "); - buttons[ii].textColor = bColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - - /* Axes Turned On/Off */ - ii = axesOnOff2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 90; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Axes On "); - buttons[ii].textColor = 75; - buttons[ii].textHue = 10; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Units Turned On/Off */ - ii = unitsOnOff2D; - buttons[ii].buttonX = 100; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 90; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Units Off"); - buttons[ii].textColor = 75; - buttons[ii].textHue = 10; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Generate a Postscript file */ - ii = ps2D; - buttons[ii].buttonX = 195; - buttons[ii].buttonY = 292; - buttons[ii].buttonWidth = 36; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"PS"); - buttons[ii].textColor = 35; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Bounding Rectangle On/Off */ - ii = spline2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 66; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Box Off"); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Graph points On/Off */ - ii = pointsOnOff; - buttons[ii].buttonX = 75; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 67; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Pts On "); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Graph lines On/Off */ - ii = connectOnOff; - buttons[ii].buttonX = 147; - buttons[ii].buttonY = 329; - buttons[ii].buttonWidth = 84; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Lines On "); - buttons[ii].textColor = 7; - buttons[ii].textHue = 26; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Reset View Position Button */ - ii = reset2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 364; - buttons[ii].buttonWidth = 60; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Reset"); - buttons[ii].textColor = bColor; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Hide Control Panel */ - ii = hideControl2D; - buttons[ii].buttonX = 70; - buttons[ii].buttonY = 364; - buttons[ii].buttonWidth = 88; - buttons[ii].buttonHeight = 30; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Hide Panel"); - buttons[ii].textColor = bColor; - buttons[ii].textHue = 5; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Exits from the viewport running */ - ii = closeAll2D; - buttons[ii].buttonX = 169; - buttons[ii].buttonY = 370; - buttons[ii].buttonWidth = 61; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Quit"); - buttons[ii].textColor = 13; - buttons[ii].textHue = 29; - buttons[ii].textShade = 2; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the graph from a viewport is to be picked up. */ - ii = pick2D; - buttons[ii].buttonX = 190; - buttons[ii].buttonY = 217; - buttons[ii].buttonWidth = 40; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Pick"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the graph from a viewport is to be dropped into a slot. */ - ii = drop2D; - buttons[ii].buttonX = 190; - buttons[ii].buttonY = 245; - buttons[ii].buttonWidth = 40; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Drop"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Indicates that the status of the graphs being displayed in the viewport - is to be cleared. */ - ii = clear2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 217; - buttons[ii].buttonWidth = 49; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Clear"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* Asks for the scale and translation information for the specified graph. */ - ii = query2D; - buttons[ii].buttonX = 5; - buttons[ii].buttonY = 245; - buttons[ii].buttonWidth = 49; - buttons[ii].buttonHeight = 24; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = no; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"Query"); - buttons[ii].textColor = 123; - buttons[ii].textHue = 19; - buttons[ii].textShade = 3; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - /* These buttons indicate the 9 available slot numbers into which - a 2D graph can be placed, and the status of the graph, i.e. whether - it is displayed or not. */ - - ii = graph1; - buttons[ii].buttonX = graphBarLeft; - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"1"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect1; - buttons[ii].buttonX = graphBarLeft; - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"^"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph2; - buttons[ii].buttonX = graphBarLeft + (graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"2"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect2; - buttons[ii].buttonX = graphBarLeft + (graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph3; - buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"3"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect3; - buttons[ii].buttonX = graphBarLeft + 2*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /**** blend these three together ***/ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph4; - buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"4"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect4; - buttons[ii].buttonX = graphBarLeft + 3*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph5; - buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"5"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect5; - buttons[ii].buttonX = graphBarLeft + 4*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph6; - buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"6"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect6; - buttons[ii].buttonX = graphBarLeft + 5*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph7; - buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"7"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect7; - buttons[ii].buttonX = graphBarLeft + 6*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph8; - buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"8"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect8; - buttons[ii].buttonX = graphBarLeft + 7*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"-"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graph9; - buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); - buttons[ii].buttonY = graphBarTop; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = yes; - buttons[ii].graphSelect = no; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"9"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - ii = graphSelect9; - buttons[ii].buttonX = graphBarLeft + 8*(graphBarWidth); - buttons[ii].buttonY = graphBarTop + graphBarHeight; - buttons[ii].buttonWidth = graphBarWidth; - buttons[ii].buttonHeight = graphBarHeight-2; - buttons[ii].buttonKey = ii; - buttons[ii].pot = no; /* this is a regular button */ - buttons[ii].graphNum = no; - buttons[ii].graphSelect = yes; - buttons[ii].mask = buttonMASK; - strcpy(buttons[ii].text,"*"); - buttons[ii].textColor = graphColor; - buttons[ii].xHalf = buttons[ii].buttonWidth/2; - buttons[ii].yHalf = buttons[ii].buttonHeight/2; - ++num; - - return(num); -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/control2d.c b/src/graph/view2D/control2d.c new file mode 100644 index 00000000..5645e2ec --- /dev/null +++ b/src/graph/view2D/control2d.c @@ -0,0 +1,621 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _CONTROL2D_C +#include "axiom-c-macros.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "header2.h" +#include "buttons2d.H1" +#include "all_2d.H1" +#include "Gfun.H1" +#include "XSpadFill.H1" +#include "util.H1" + + +#include "mouse11.bitmap" +#include "mouse11.mask" + +/* Defines the pixmap for the arrow displayed in the scale window */ + +#define scaleArrowN 11 +static XPoint scaleArrow[scaleArrowN] = { + {55,14},{64,23},{59,23}, + {66,45},{79,45}, + {55,69}, + {31,45},{44,45}, + {51,23},{46,23},{55,14} }; + +/* Defines the pixmap for the arrows displayed in the translate window */ + +#define translateArrowN 25 +static XPoint translateArrow[translateArrowN] = { + {55,2},{60,10},{58,10},{58,37}, + {85,37},{85,35},{93,40},{85,45},{85,43},{58,43}, + {58,70},{60,70},{55,78},{50,70},{52,70},{52,43}, + {25,43}, {25,45}, {17,40}, {25,35}, {25,37}, {52,37}, + {52,10},{50,10},{55,2} }; + +/**************************** + * void writeControlTitle() * + ****************************/ + +void +#ifdef _NO_PROTO +writeControlTitle() +#else +writeControlTitle(void) +#endif +{ + + int strlength; + + s = viewport->title; + strlength = strlen(s); + XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False); + GSetForeground(anotherGC,(float)controlTitleColor,Xoption); + GDrawImageString(anotherGC,control->controlWindow, + centerX(anotherGC,s,strlength,controlWidth), + 15,s,strlength,Xoption); + +} /* writeControlTitle() */ + +void +#ifdef _NO_PROTO +makeMessageFromData(whichGraph) +int whichGraph; +#else +makeMessageFromData(int whichGraph) +#endif +{ + if (viewport->haveControl) { + if ((graphStateArray[whichGraph].scaleX) > 99.0) { + strcpy(scaleXReport,"big"); + } else { + sprintf(scaleXReport,"%4.1f",graphStateArray[whichGraph].scaleX); + } + if ((graphStateArray[whichGraph].scaleY) > 99.0) { + strcpy(scaleYReport,"big"); + } else { + sprintf(scaleYReport,"%4.1f",graphStateArray[whichGraph].scaleY); + } + if ((graphStateArray[whichGraph].centerX) > 999.0) { + strcpy(deltaXReport,"+big"); + } else if ((graphStateArray[whichGraph].centerX) < -999.0) { + strcpy(deltaXReport,"-big"); + } else { + sprintf(deltaXReport,"%4.0f", + -graphStateArray[whichGraph].centerX / + graphArray[whichGraph].unitX); + } + if ((graphStateArray[whichGraph].centerY) > 999.0) { + strcpy(deltaYReport,"+big"); + } else if ((graphStateArray[whichGraph].centerY) < -999.0) { + strcpy(deltaYReport,"-big"); + } else { + sprintf(deltaYReport,"%4.0f", + -graphStateArray[whichGraph].centerY / + graphArray[whichGraph].unitY); + } + sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]", + scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport); + } /* if haveControl */ + +} /* makeMessageFromData() */ + + +void +#ifdef _NO_PROTO +writeControlMessage() +#else +writeControlMessage(void) +#endif +{ + int strlength; + controlPanelStruct *cp; + XWindowAttributes cwInfo; + + cp = viewport->controlPanel; + XGetWindowAttributes(dsply,cp->controlWindow,&cwInfo); + strlength = strlen(cp->message); + + + + GDrawImageString(controlMessageGC,cp->controlWindow, + centerX(globalGC1,cp->message,strlength,controlWidth), + controlMessageY + globalFont->max_bounds.ascent - 2, + cp->message,strlength,Xoption); +} + +/*********************************/ +/*** void drawControlPanel() ***/ +/*********************************/ + +void +#ifdef _NO_PROTO +drawControlPanel() +#else +drawControlPanel(void) +#endif +{ + + controlPanelStruct *cp; + int i,strlength; + char *s; + + cp = viewport->controlPanel; + /* Draw border lines to separate the potentiometer, message, graph select + and button regions of the control panel. */ + GSetForeground(trashGC,(float)foregroundColor,Xoption); + GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption); + GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption); + GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); + GDrawLine(trashGC, cp->controlWindow, 0, potB, controlWidth, potB, Xoption); + GDrawLine(trashGC, cp->controlWindow, 0, messageBot, + controlWidth, messageBot, Xoption); + GDrawLine(trashGC, cp->controlWindow, 0, 286, controlWidth, 286, Xoption); + + /** put the line width as 1 last because used below as well **/ + GSetLineAttributes(trashGC,1,LineSolid,CapButt,JoinMiter,Xoption); + GDrawRectangle(trashGC,cp->controlWindow,closeLeft,closeTop, + (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption); + + /* Write potentiometer titles on the control panel. */ + writeControlTitle(); + GSetForeground(globGC,(float)controlPotHeaderColor,Xoption); + s = "Scale"; + strlength = strlen(s); + GDrawString(globGC,cp->controlWindow, + centerX(globGC,s,strlength, + cp->buttonQueue[scale2D].buttonWidth) + + cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption); + + s = "Translate"; + strlength = strlen(s); + GDrawString(globGC,cp->controlWindow, + centerX(globGC,s,strlength, + cp->buttonQueue[translate2D].buttonWidth) + + cp->buttonQueue[translate2D].buttonX, + 31+headerHeight,s,strlen(s),Xoption); + + GSetForeground(globGC,(float)controlColorColor,Xoption); + + /* Write title of the graph selection window. */ + s = "Graphs"; + strlength = strlen(s); + GDrawString(globGC,cp->controlWindow, + centerX(globGC,s,strlength,controlWidth),graphHeaderHeight, + s,strlength,Xoption); + + /* Write titles on regular buttons and draw pixmaps on potentiometers. */ + + for (i=0; i<(maxButtons2D); i++) { + if ((cp->buttonQueue[i]).pot) { + + GSetForeground(globalGC1,(float)buttonColor,Xoption); + GDrawRectangle(globalGC1,cp->controlWindow, + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, + (cp->buttonQueue[i]).buttonHeight,Xoption); + + GSetForeground(trashGC, + (float)monoColor((cp->buttonQueue[i]).textColor),Xoption); + + GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ + (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, + (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, + (cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption); + GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ + (cp->buttonQueue[i]).buttonX, + (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf, + (cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf, + (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption); + switch (i) { + case scale2D: + GDrawLines(trashGC,cp->controlWindow,scaleArrow, + scaleArrowN,CoordModeOrigin,Xoption); + break; + case translate2D: + GDrawLines(trashGC,cp->controlWindow,translateArrow, + translateArrowN,CoordModeOrigin,Xoption); + break; + } /* switch i */ + } else if (cp->buttonQueue[i].graphNum) { + + if (mono) { + if (graphStateArray[i-graphStart].showing) { + GSetForeground(graphGC,(float)backgroundColor,Xoption); + GSetBackground(graphGC,(float)foregroundColor,Xoption); + } else { + GSetForeground(graphGC,(float)foregroundColor,Xoption); + GSetBackground(graphGC,(float)backgroundColor,Xoption); + } + strlength = strlen((cp->buttonQueue[i]).text); + GDrawImageString(graphGC,cp->controlWindow, + (cp->buttonQueue[i]).buttonX + + centerX(graphGC,cp->buttonQueue[i].text, + strlength,(cp->buttonQueue[i]).buttonWidth), + (cp->buttonQueue[i]).buttonY + + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), + cp->buttonQueue[i].text,strlength,Xoption); + } else { + if (graphStateArray[i-graphStart].showing) + GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); + else + GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); + strlength = strlen((cp->buttonQueue[i]).text); + GDrawString(graphGC,cp->controlWindow, + (cp->buttonQueue[i]).buttonX + + centerX(graphGC,cp->buttonQueue[i].text, + strlength,(cp->buttonQueue[i]).buttonWidth), + (cp->buttonQueue[i]).buttonY + + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), + cp->buttonQueue[i].text,strlength,Xoption); + } + } else if (cp->buttonQueue[i].graphSelect) { + /* The select characters are defined as: "^" for on and "-" for off. */ + if (graphStateArray[i-graphSelectStart].selected) { + GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); + strcpy((cp->buttonQueue[i]).text,"^"); + } else { + GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); + *(cp->buttonQueue[i]).text = '-'; + strcpy((cp->buttonQueue[i]).text,"-"); + } + GDrawString(graphGC,cp->controlWindow, + (cp->buttonQueue[i]).buttonX + + centerX(graphGC,cp->buttonQueue[i].text, + strlength,(cp->buttonQueue[i]).buttonWidth), + (cp->buttonQueue[i]).buttonY + + centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), + cp->buttonQueue[i].text,strlength,Xoption); + } + else { /* a regular button */ + int isOn = 1; + + switch(i) { + case pointsOnOff: + isOn = pointsON = graphStateArray[0].pointsOn; + if (graphStateArray[0].pointsOn) + strcpy((cp->buttonQueue[i]).text,"Pts On "); + else + strcpy((cp->buttonQueue[i]).text,"Pts Off"); + break; + + case spline2D: + isOn = splineON = graphStateArray[0].splineOn; + if (graphStateArray[0].splineOn) + strcpy((cp->buttonQueue[i]).text, "Box On "); + else + strcpy((cp->buttonQueue[i]).text, "Box Off"); + break; + + case connectOnOff: + isOn = connectON = graphStateArray[0].connectOn; + if (graphStateArray[0].connectOn) + strcpy((cp->buttonQueue[i]).text, "Lines On "); + else + strcpy((cp->buttonQueue[i]).text, "Lines Off"); + break; + + case axesOnOff2D: + isOn = axesON = graphStateArray[0].axesOn; + if (graphStateArray[0].axesOn) + strcpy((cp->buttonQueue[i]).text , "Axes On "); + else + strcpy((cp->buttonQueue[i]).text , "Axes Off"); + break; + + case unitsOnOff2D: + isOn = unitsON = graphStateArray[0].unitsOn; + if (graphStateArray[0].unitsOn) + strcpy( (cp->buttonQueue[i]).text , "Units On "); + else + strcpy( (cp->buttonQueue[i]).text , "Units Off"); + break; + case closeAll2D: + isOn = 0; + + default: + break; + } /* switch i */ + + s = (cp->buttonQueue[i]).text; + strlength = strlen(s); + + GDrawPushButton(dsply, globalGC1, trashGC, processGC, cp->controlWindow, + (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY, + (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight, + isOn, s,buttonColor, + monoColor((cp->buttonQueue[i]).textColor), Xoption); + + } /* else a regular button */ + } /* for each button */ + + /* Refresh the latest message */ + makeMessageFromData(0); + writeControlMessage(); + XFlush(dsply); + +} /*** drawControlPanel ***/ + +controlXY +#ifdef _NO_PROTO +getControlXY(whereDoYouWantPanel) +int whereDoYouWantPanel; +#else +getControlXY(int whereDoYouWantPanel) +#endif +{ + XWindowAttributes wAttr, wAttrib; + controlXY cXY; + int tmp=1; + Window rootW, parentW, *childrenWs, tmpW; + unsigned int nChildren; + + tmpW = viewport->titleWindow; + while(tmp) { + XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren); + XFree(childrenWs); + if (parentW == rtWindow) tmp = 0; + else tmpW = parentW; + } + XGetWindowAttributes(dsply,tmpW,&wAttrib); + + XGetWindowAttributes(dsply,viewport->titleWindow,&wAttr); + if (whereDoYouWantPanel) { + switch (whereDoYouWantPanel) { + case 1: /* right */ + cXY.putX = wAttrib.x + wAttrib.width; + cXY.putY = wAttrib.y; + break; + case 2: /* bottom */ + cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; /* center it */ + cXY.putY = wAttrib.y + wAttrib.height; + break; + case 3: /* left */ + cXY.putX = wAttrib.x - controlWidth - borderWidth; + cXY.putY = wAttrib.y; + break; + case 4: /* top */ + cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; + cXY.putY = wAttrib.y - controlHeight - borderHeight; + } + } else { + if ((physicalWidth - (wAttrib.x + wAttr.width)) >= controlWidth) { + cXY.putX = wAttrib.x + wAttrib.width; + cXY.putY = wAttrib.y; + } else if ((physicalHeight - (wAttrib.y + wAttr.height)) >= + controlHeight) { + cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; + cXY.putY = wAttrib.y + wAttrib.height; + } else if (wAttrib.x >= controlWidth) { + cXY.putX = wAttrib.x - controlWidth - borderWidth; + cXY.putY = wAttrib.y; + } else if (wAttrib.y >= controlHeight) { + cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; + cXY.putY = wAttrib.y - controlHeight - borderHeight; + } else { /* put inside of viewport */ + cXY.putX = wAttrib.x + wAttr.width - controlWidth; + cXY.putY = wAttrib.y + wAttr.height - controlHeight; + } + } + return(cXY); + +} + +/************************************************/ +/*** controlPanelStruct *makeControlPanel() ***/ +/************************************************/ + +controlPanelStruct * +#ifdef _NO_PROTO +makeControlPanel() +#else +makeControlPanel(void) +#endif +{ + + Window cw; + int i,num; + controlPanelStruct *control; + buttonStruct *buttons; + controlXY cXY; + XSetWindowAttributes cwAttrib, controlAttrib; + XSizeHints sizehints; + Pixmap mousebits,mousemask; + XColor foreColor, backColor; + + if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) { + fprintf(stderr,"Ran out of memory trying to create a control panel.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + + cXY = getControlXY(0); + + /* Define and assign a mouse cursor. */ + mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits, + mouseBitmap_width,mouseBitmap_height); + mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits, + mouseMask_width,mouseMask_height); + cwAttrib.background_pixel = backgroundColor; /* controlBackground; */ + cwAttrib.border_pixel = foregroundColor; + cwAttrib.backing_store = WhenMapped; + cwAttrib.event_mask = controlMASK; + cwAttrib.colormap = colorMap; + cwAttrib.override_redirect = overrideManager; + foreColor.pixel = controlCursorForeground; + XQueryColor(dsply,colorMap,&foreColor); + backColor.pixel = controlCursorBackground; + XQueryColor(dsply,colorMap,&backColor); + cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask, + &foreColor,&backColor, + mouseBitmap_x_hot,mouseBitmap_y_hot); + + cw = XCreateWindow(dsply,rtWindow, + cXY.putX,cXY.putY,controlWidth,controlHeight,3, + CopyFromParent,InputOutput,CopyFromParent, + controlCreateMASK,&cwAttrib); + + sizehints.flags = PPosition | PSize; + sizehints.x = cXY.putX; + sizehints.y = cXY.putY; + sizehints.width = controlWidth; + sizehints.height = controlHeight; + + /*** the None stands for icon pixmap...change.... ***/ + + XSetNormalHints(dsply,cw,&sizehints); + XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel", + None,NULL,0,&sizehints); + + control->controlWindow = cw; + num = initButtons(control->buttonQueue); + control->numOfButtons = num; + buttons = control->buttonQueue; + + for (i=0; ibuttonQueue[i]).mask; + (control->buttonQueue[i]).self = XCreateWindow(dsply,cw, + (control->buttonQueue[i]).buttonX, + (control->buttonQueue[i]).buttonY, + (control->buttonQueue[i]).buttonWidth, + (control->buttonQueue[i]).buttonHeight, + 0,0,InputOnly,CopyFromParent, + buttonCreateMASK,&controlAttrib); + + XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, + &((control->buttonQueue[i]).buttonKey)); + /* Use buttonKey instead of i because buttonKey has a permanent address */ + XMapWindow(dsply,(control->buttonQueue[i]).self); + } + + /* Create message window */ + control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY, + controlWidth,controlMessageHeight, + 0,0,InputOnly,CopyFromParent, + messageCreateMASK,&cwAttrib); + XMapWindow(dsply,control->messageWindow); + + for (i=0; ijustMadeControl = yes; + return(control); + +} /* makeControlPanel() */ + + + + + + +/*****************************************/ +/*** void putControlPanelSomewhere() ***/ +/*****************************************/ + +/* This routine puts up the control panel associated with the viewport + passed in. It first tries to put it to the right of the viewport. If + there isn't enough room there, it tries the bottom and so on going + clockwise. If the viewport is too big and there is no room to put the + control panel outside of it, it placed the control panel in the bottom + right hand corner of the viewport window. */ + +void +#ifdef _NO_PROTO +putControlPanelSomewhere(whereDoesPanelGo) +int whereDoesPanelGo; +#else +putControlPanelSomewhere(int whereDoesPanelGo) +#endif +{ + controlPanelStruct *control; + controlXY whereControl; + + control = viewport->controlPanel; + whereControl = getControlXY(whereDoesPanelGo); + + viewport->haveControl = yes; + + XRaiseWindow(dsply,control->controlWindow); + XMoveWindow(dsply,control->controlWindow,whereControl.putX, + whereControl.putY); + + drawControlPanel(); + if (viewport->justMadeControl) { + XMapWindow(dsply,control->controlWindow); + viewport->justMadeControl = no; + } + XMapWindow(dsply,control->controlWindow); +} + + + + + +/************************************/ +/*** void clearControlMessage() ***/ +/************************************/ + +void +#ifdef _NO_PROTO +clearControlMessage() +#else +clearControlMessage(void) +#endif +{ + + strcpy(viewport->controlPanel->message,""); + + XClearArea(dsply,viewport->controlPanel->controlWindow, + 0,controlMessageY-2,controlWidth,controlMessageHeight,False); +} + + diff --git a/src/graph/view2D/control2d.c.pamphlet b/src/graph/view2D/control2d.c.pamphlet deleted file mode 100644 index c45ba400..00000000 --- a/src/graph/view2D/control2d.c.pamphlet +++ /dev/null @@ -1,641 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D control2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _CONTROL2D_C -#include "axiom-c-macros.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "header2.h" -#include "buttons2d.H1" -#include "all_2d.H1" -#include "Gfun.H1" -#include "XSpadFill.H1" -#include "util.H1" - - -#include "mouse11.bitmap" -#include "mouse11.mask" - -/* Defines the pixmap for the arrow displayed in the scale window */ - -#define scaleArrowN 11 -static XPoint scaleArrow[scaleArrowN] = { - {55,14},{64,23},{59,23}, - {66,45},{79,45}, - {55,69}, - {31,45},{44,45}, - {51,23},{46,23},{55,14} }; - -/* Defines the pixmap for the arrows displayed in the translate window */ - -#define translateArrowN 25 -static XPoint translateArrow[translateArrowN] = { - {55,2},{60,10},{58,10},{58,37}, - {85,37},{85,35},{93,40},{85,45},{85,43},{58,43}, - {58,70},{60,70},{55,78},{50,70},{52,70},{52,43}, - {25,43}, {25,45}, {17,40}, {25,35}, {25,37}, {52,37}, - {52,10},{50,10},{55,2} }; - -/**************************** - * void writeControlTitle() * - ****************************/ - -void -#ifdef _NO_PROTO -writeControlTitle() -#else -writeControlTitle(void) -#endif -{ - - int strlength; - - s = viewport->title; - strlength = strlen(s); - XClearArea(dsply,control->controlWindow,0,0,controlWidth,potA,False); - GSetForeground(anotherGC,(float)controlTitleColor,Xoption); - GDrawImageString(anotherGC,control->controlWindow, - centerX(anotherGC,s,strlength,controlWidth), - 15,s,strlength,Xoption); - -} /* writeControlTitle() */ - -void -#ifdef _NO_PROTO -makeMessageFromData(whichGraph) -int whichGraph; -#else -makeMessageFromData(int whichGraph) -#endif -{ - if (viewport->haveControl) { - if ((graphStateArray[whichGraph].scaleX) > 99.0) { - strcpy(scaleXReport,"big"); - } else { - sprintf(scaleXReport,"%4.1f",graphStateArray[whichGraph].scaleX); - } - if ((graphStateArray[whichGraph].scaleY) > 99.0) { - strcpy(scaleYReport,"big"); - } else { - sprintf(scaleYReport,"%4.1f",graphStateArray[whichGraph].scaleY); - } - if ((graphStateArray[whichGraph].centerX) > 999.0) { - strcpy(deltaXReport,"+big"); - } else if ((graphStateArray[whichGraph].centerX) < -999.0) { - strcpy(deltaXReport,"-big"); - } else { - sprintf(deltaXReport,"%4.0f", - -graphStateArray[whichGraph].centerX / - graphArray[whichGraph].unitX); - } - if ((graphStateArray[whichGraph].centerY) > 999.0) { - strcpy(deltaYReport,"+big"); - } else if ((graphStateArray[whichGraph].centerY) < -999.0) { - strcpy(deltaYReport,"-big"); - } else { - sprintf(deltaYReport,"%4.0f", - -graphStateArray[whichGraph].centerY / - graphArray[whichGraph].unitY); - } - sprintf(viewport->controlPanel->message,"[%s,%s] >%d< [%s,%s]", - scaleXReport,scaleYReport,whichGraph+1,deltaXReport,deltaYReport); - } /* if haveControl */ - -} /* makeMessageFromData() */ - - -void -#ifdef _NO_PROTO -writeControlMessage() -#else -writeControlMessage(void) -#endif -{ - int strlength; - controlPanelStruct *cp; - XWindowAttributes cwInfo; - - cp = viewport->controlPanel; - XGetWindowAttributes(dsply,cp->controlWindow,&cwInfo); - strlength = strlen(cp->message); - - - - GDrawImageString(controlMessageGC,cp->controlWindow, - centerX(globalGC1,cp->message,strlength,controlWidth), - controlMessageY + globalFont->max_bounds.ascent - 2, - cp->message,strlength,Xoption); -} - -/*********************************/ -/*** void drawControlPanel() ***/ -/*********************************/ - -void -#ifdef _NO_PROTO -drawControlPanel() -#else -drawControlPanel(void) -#endif -{ - - controlPanelStruct *cp; - int i,strlength; - char *s; - - cp = viewport->controlPanel; - /* Draw border lines to separate the potentiometer, message, graph select - and button regions of the control panel. */ - GSetForeground(trashGC,(float)foregroundColor,Xoption); - GSetLineAttributes(trashGC,3,LineSolid,CapButt,JoinMiter,Xoption); - GDrawLine(trashGC, cp->controlWindow, 0, potA, controlWidth, potA, Xoption); - GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); - GDrawLine(trashGC, cp->controlWindow, 0, potB, controlWidth, potB, Xoption); - GDrawLine(trashGC, cp->controlWindow, 0, messageBot, - controlWidth, messageBot, Xoption); - GDrawLine(trashGC, cp->controlWindow, 0, 286, controlWidth, 286, Xoption); - - /** put the line width as 1 last because used below as well **/ - GSetLineAttributes(trashGC,1,LineSolid,CapButt,JoinMiter,Xoption); - GDrawRectangle(trashGC,cp->controlWindow,closeLeft,closeTop, - (controlWidth-closeLeft+8),(controlHeight-closeTop+8),Xoption); - - /* Write potentiometer titles on the control panel. */ - writeControlTitle(); - GSetForeground(globGC,(float)controlPotHeaderColor,Xoption); - s = "Scale"; - strlength = strlen(s); - GDrawString(globGC,cp->controlWindow, - centerX(globGC,s,strlength, - cp->buttonQueue[scale2D].buttonWidth) + - cp->buttonQueue[scale2D].buttonX, 31+headerHeight,s,strlength,Xoption); - - s = "Translate"; - strlength = strlen(s); - GDrawString(globGC,cp->controlWindow, - centerX(globGC,s,strlength, - cp->buttonQueue[translate2D].buttonWidth) + - cp->buttonQueue[translate2D].buttonX, - 31+headerHeight,s,strlen(s),Xoption); - - GSetForeground(globGC,(float)controlColorColor,Xoption); - - /* Write title of the graph selection window. */ - s = "Graphs"; - strlength = strlen(s); - GDrawString(globGC,cp->controlWindow, - centerX(globGC,s,strlength,controlWidth),graphHeaderHeight, - s,strlength,Xoption); - - /* Write titles on regular buttons and draw pixmaps on potentiometers. */ - - for (i=0; i<(maxButtons2D); i++) { - if ((cp->buttonQueue[i]).pot) { - - GSetForeground(globalGC1,(float)buttonColor,Xoption); - GDrawRectangle(globalGC1,cp->controlWindow, - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, - (cp->buttonQueue[i]).buttonHeight,Xoption); - - GSetForeground(trashGC, - (float)monoColor((cp->buttonQueue[i]).textColor),Xoption); - - GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ - (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, - (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonX + (cp->buttonQueue[i]).xHalf, - (cp->buttonQueue[i]).buttonY + 2*(cp->buttonQueue[i]).yHalf,Xoption); - GDrawLine(globalGC1,cp->controlWindow, /* trashGC, */ - (cp->buttonQueue[i]).buttonX, - (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf, - (cp->buttonQueue[i]).buttonX + 2*(cp->buttonQueue[i]).xHalf, - (cp->buttonQueue[i]).buttonY + (cp->buttonQueue[i]).yHalf,Xoption); - switch (i) { - case scale2D: - GDrawLines(trashGC,cp->controlWindow,scaleArrow, - scaleArrowN,CoordModeOrigin,Xoption); - break; - case translate2D: - GDrawLines(trashGC,cp->controlWindow,translateArrow, - translateArrowN,CoordModeOrigin,Xoption); - break; - } /* switch i */ - } else if (cp->buttonQueue[i].graphNum) { - - if (mono) { - if (graphStateArray[i-graphStart].showing) { - GSetForeground(graphGC,(float)backgroundColor,Xoption); - GSetBackground(graphGC,(float)foregroundColor,Xoption); - } else { - GSetForeground(graphGC,(float)foregroundColor,Xoption); - GSetBackground(graphGC,(float)backgroundColor,Xoption); - } - strlength = strlen((cp->buttonQueue[i]).text); - GDrawImageString(graphGC,cp->controlWindow, - (cp->buttonQueue[i]).buttonX + - centerX(graphGC,cp->buttonQueue[i].text, - strlength,(cp->buttonQueue[i]).buttonWidth), - (cp->buttonQueue[i]).buttonY + - centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), - cp->buttonQueue[i].text,strlength,Xoption); - } else { - if (graphStateArray[i-graphStart].showing) - GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); - else - GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); - strlength = strlen((cp->buttonQueue[i]).text); - GDrawString(graphGC,cp->controlWindow, - (cp->buttonQueue[i]).buttonX + - centerX(graphGC,cp->buttonQueue[i].text, - strlength,(cp->buttonQueue[i]).buttonWidth), - (cp->buttonQueue[i]).buttonY + - centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), - cp->buttonQueue[i].text,strlength,Xoption); - } - } else if (cp->buttonQueue[i].graphSelect) { - /* The select characters are defined as: "^" for on and "-" for off. */ - if (graphStateArray[i-graphSelectStart].selected) { - GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); - strcpy((cp->buttonQueue[i]).text,"^"); - } else { - GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); - *(cp->buttonQueue[i]).text = '-'; - strcpy((cp->buttonQueue[i]).text,"-"); - } - GDrawString(graphGC,cp->controlWindow, - (cp->buttonQueue[i]).buttonX + - centerX(graphGC,cp->buttonQueue[i].text, - strlength,(cp->buttonQueue[i]).buttonWidth), - (cp->buttonQueue[i]).buttonY + - centerY(graphGC,(cp->buttonQueue[i]).buttonHeight), - cp->buttonQueue[i].text,strlength,Xoption); - } - else { /* a regular button */ - int isOn = 1; - - switch(i) { - case pointsOnOff: - isOn = pointsON = graphStateArray[0].pointsOn; - if (graphStateArray[0].pointsOn) - strcpy((cp->buttonQueue[i]).text,"Pts On "); - else - strcpy((cp->buttonQueue[i]).text,"Pts Off"); - break; - - case spline2D: - isOn = splineON = graphStateArray[0].splineOn; - if (graphStateArray[0].splineOn) - strcpy((cp->buttonQueue[i]).text, "Box On "); - else - strcpy((cp->buttonQueue[i]).text, "Box Off"); - break; - - case connectOnOff: - isOn = connectON = graphStateArray[0].connectOn; - if (graphStateArray[0].connectOn) - strcpy((cp->buttonQueue[i]).text, "Lines On "); - else - strcpy((cp->buttonQueue[i]).text, "Lines Off"); - break; - - case axesOnOff2D: - isOn = axesON = graphStateArray[0].axesOn; - if (graphStateArray[0].axesOn) - strcpy((cp->buttonQueue[i]).text , "Axes On "); - else - strcpy((cp->buttonQueue[i]).text , "Axes Off"); - break; - - case unitsOnOff2D: - isOn = unitsON = graphStateArray[0].unitsOn; - if (graphStateArray[0].unitsOn) - strcpy( (cp->buttonQueue[i]).text , "Units On "); - else - strcpy( (cp->buttonQueue[i]).text , "Units Off"); - break; - case closeAll2D: - isOn = 0; - - default: - break; - } /* switch i */ - - s = (cp->buttonQueue[i]).text; - strlength = strlen(s); - - GDrawPushButton(dsply, globalGC1, trashGC, processGC, cp->controlWindow, - (cp->buttonQueue[i]).buttonX, (cp->buttonQueue[i]).buttonY, - (cp->buttonQueue[i]).buttonWidth, (cp->buttonQueue[i]).buttonHeight, - isOn, s,buttonColor, - monoColor((cp->buttonQueue[i]).textColor), Xoption); - - } /* else a regular button */ - } /* for each button */ - - /* Refresh the latest message */ - makeMessageFromData(0); - writeControlMessage(); - XFlush(dsply); - -} /*** drawControlPanel ***/ - -controlXY -#ifdef _NO_PROTO -getControlXY(whereDoYouWantPanel) -int whereDoYouWantPanel; -#else -getControlXY(int whereDoYouWantPanel) -#endif -{ - XWindowAttributes wAttr, wAttrib; - controlXY cXY; - int tmp=1; - Window rootW, parentW, *childrenWs, tmpW; - unsigned int nChildren; - - tmpW = viewport->titleWindow; - while(tmp) { - XQueryTree(dsply,tmpW,&rootW,&parentW,&childrenWs,&nChildren); - XFree(childrenWs); - if (parentW == rtWindow) tmp = 0; - else tmpW = parentW; - } - XGetWindowAttributes(dsply,tmpW,&wAttrib); - - XGetWindowAttributes(dsply,viewport->titleWindow,&wAttr); - if (whereDoYouWantPanel) { - switch (whereDoYouWantPanel) { - case 1: /* right */ - cXY.putX = wAttrib.x + wAttrib.width; - cXY.putY = wAttrib.y; - break; - case 2: /* bottom */ - cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; /* center it */ - cXY.putY = wAttrib.y + wAttrib.height; - break; - case 3: /* left */ - cXY.putX = wAttrib.x - controlWidth - borderWidth; - cXY.putY = wAttrib.y; - break; - case 4: /* top */ - cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; - cXY.putY = wAttrib.y - controlHeight - borderHeight; - } - } else { - if ((physicalWidth - (wAttrib.x + wAttr.width)) >= controlWidth) { - cXY.putX = wAttrib.x + wAttrib.width; - cXY.putY = wAttrib.y; - } else if ((physicalHeight - (wAttrib.y + wAttr.height)) >= - controlHeight) { - cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; - cXY.putY = wAttrib.y + wAttrib.height; - } else if (wAttrib.x >= controlWidth) { - cXY.putX = wAttrib.x - controlWidth - borderWidth; - cXY.putY = wAttrib.y; - } else if (wAttrib.y >= controlHeight) { - cXY.putX = wAttrib.x + (wAttr.width - controlWidth)/2; - cXY.putY = wAttrib.y - controlHeight - borderHeight; - } else { /* put inside of viewport */ - cXY.putX = wAttrib.x + wAttr.width - controlWidth; - cXY.putY = wAttrib.y + wAttr.height - controlHeight; - } - } - return(cXY); - -} - -/************************************************/ -/*** controlPanelStruct *makeControlPanel() ***/ -/************************************************/ - -controlPanelStruct * -#ifdef _NO_PROTO -makeControlPanel() -#else -makeControlPanel(void) -#endif -{ - - Window cw; - int i,num; - controlPanelStruct *control; - buttonStruct *buttons; - controlXY cXY; - XSetWindowAttributes cwAttrib, controlAttrib; - XSizeHints sizehints; - Pixmap mousebits,mousemask; - XColor foreColor, backColor; - - if (!(control = (controlPanelStruct *)malloc(sizeof(controlPanelStruct)))) { - fprintf(stderr,"Ran out of memory trying to create a control panel.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - - cXY = getControlXY(0); - - /* Define and assign a mouse cursor. */ - mousebits = XCreateBitmapFromData(dsply,rtWindow,mouseBitmap_bits, - mouseBitmap_width,mouseBitmap_height); - mousemask = XCreateBitmapFromData(dsply,rtWindow,mouseMask_bits, - mouseMask_width,mouseMask_height); - cwAttrib.background_pixel = backgroundColor; /* controlBackground; */ - cwAttrib.border_pixel = foregroundColor; - cwAttrib.backing_store = WhenMapped; - cwAttrib.event_mask = controlMASK; - cwAttrib.colormap = colorMap; - cwAttrib.override_redirect = overrideManager; - foreColor.pixel = controlCursorForeground; - XQueryColor(dsply,colorMap,&foreColor); - backColor.pixel = controlCursorBackground; - XQueryColor(dsply,colorMap,&backColor); - cwAttrib.cursor = XCreatePixmapCursor(dsply,mousebits,mousemask, - &foreColor,&backColor, - mouseBitmap_x_hot,mouseBitmap_y_hot); - - cw = XCreateWindow(dsply,rtWindow, - cXY.putX,cXY.putY,controlWidth,controlHeight,3, - CopyFromParent,InputOutput,CopyFromParent, - controlCreateMASK,&cwAttrib); - - sizehints.flags = PPosition | PSize; - sizehints.x = cXY.putX; - sizehints.y = cXY.putY; - sizehints.width = controlWidth; - sizehints.height = controlHeight; - - /*** the None stands for icon pixmap...change.... ***/ - - XSetNormalHints(dsply,cw,&sizehints); - XSetStandardProperties(dsply,cw,"2D Control Panel","2D Control Panel", - None,NULL,0,&sizehints); - - control->controlWindow = cw; - num = initButtons(control->buttonQueue); - control->numOfButtons = num; - buttons = control->buttonQueue; - - for (i=0; ibuttonQueue[i]).mask; - (control->buttonQueue[i]).self = XCreateWindow(dsply,cw, - (control->buttonQueue[i]).buttonX, - (control->buttonQueue[i]).buttonY, - (control->buttonQueue[i]).buttonWidth, - (control->buttonQueue[i]).buttonHeight, - 0,0,InputOnly,CopyFromParent, - buttonCreateMASK,&controlAttrib); - - XMakeAssoc(dsply,table,(control->buttonQueue[i]).self, - &((control->buttonQueue[i]).buttonKey)); - /* Use buttonKey instead of i because buttonKey has a permanent address */ - XMapWindow(dsply,(control->buttonQueue[i]).self); - } - - /* Create message window */ - control->messageWindow = XCreateWindow(dsply,cw,0,controlMessageY, - controlWidth,controlMessageHeight, - 0,0,InputOnly,CopyFromParent, - messageCreateMASK,&cwAttrib); - XMapWindow(dsply,control->messageWindow); - - for (i=0; ijustMadeControl = yes; - return(control); - -} /* makeControlPanel() */ - - - - - - -/*****************************************/ -/*** void putControlPanelSomewhere() ***/ -/*****************************************/ - -/* This routine puts up the control panel associated with the viewport - passed in. It first tries to put it to the right of the viewport. If - there isn't enough room there, it tries the bottom and so on going - clockwise. If the viewport is too big and there is no room to put the - control panel outside of it, it placed the control panel in the bottom - right hand corner of the viewport window. */ - -void -#ifdef _NO_PROTO -putControlPanelSomewhere(whereDoesPanelGo) -int whereDoesPanelGo; -#else -putControlPanelSomewhere(int whereDoesPanelGo) -#endif -{ - controlPanelStruct *control; - controlXY whereControl; - - control = viewport->controlPanel; - whereControl = getControlXY(whereDoesPanelGo); - - viewport->haveControl = yes; - - XRaiseWindow(dsply,control->controlWindow); - XMoveWindow(dsply,control->controlWindow,whereControl.putX, - whereControl.putY); - - drawControlPanel(); - if (viewport->justMadeControl) { - XMapWindow(dsply,control->controlWindow); - viewport->justMadeControl = no; - } - XMapWindow(dsply,control->controlWindow); -} - - - - - -/************************************/ -/*** void clearControlMessage() ***/ -/************************************/ - -void -#ifdef _NO_PROTO -clearControlMessage() -#else -clearControlMessage(void) -#endif -{ - - strcpy(viewport->controlPanel->message,""); - - XClearArea(dsply,viewport->controlPanel->controlWindow, - 0,controlMessageY-2,controlWidth,controlMessageHeight,False); -} - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/globals2.h b/src/graph/view2D/globals2.h old mode 100755 new mode 100644 index de0d132a..1544471d --- a/src/graph/view2D/globals2.h +++ b/src/graph/view2D/globals2.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ extern int scrn; diff --git a/src/graph/view2D/graph2d.c b/src/graph/view2D/graph2d.c new file mode 100644 index 00000000..47960cd7 --- /dev/null +++ b/src/graph/view2D/graph2d.c @@ -0,0 +1,168 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All right reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _GRAPH2D_C +#include "axiom-c-macros.h" + +#include +#include +#include + +#include "header2.h" + +#include "all_2d.H1" +#include "util.H1" + + +void +#ifdef _NO_PROTO +getGraphFromViewman(i) +int i; +#else +getGraphFromViewman(int i) +#endif +{ + /** This routine should be called right after a read of the graph key + was made from the viewport manager (or defined in some other way). **/ + + int j,k,xPointsNeeded; + pointListStruct *llPtr; + pointStruct *p; + + readViewman(&(graphArray[i].xmin),floatSize); + readViewman(&(graphArray[i].xmax),floatSize); + readViewman(&(graphArray[i].ymin),floatSize); + readViewman(&(graphArray[i].ymax),floatSize); + readViewman(&(graphArray[i].xNorm),floatSize); + readViewman(&(graphArray[i].yNorm),floatSize); + readViewman(&(graphArray[i].spadUnitX),floatSize); + readViewman(&(graphArray[i].spadUnitY),floatSize); + readViewman(&(graphArray[i].unitX),floatSize); + readViewman(&(graphArray[i].unitY),floatSize); + readViewman(&(graphArray[i].originX),floatSize); + readViewman(&(graphArray[i].originY),floatSize); + readViewman(&(graphArray[i].numberOfLists),intSize); + + if (!(llPtr = (pointListStruct *)malloc(graphArray[i].numberOfLists * sizeof(pointListStruct)))) { + fprintf(stderr,"VIEW2D: Fatal Error>> Ran out of memory trying to receive a graph.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + graphArray[i].listOfListsOfPoints = llPtr; + + xPointsNeeded = 0; + for (j=0; jnumberOfPoints),intSize); + if (!(p = (pointStruct *)malloc(llPtr->numberOfPoints * sizeof(pointStruct)))) { + fprintf(stderr,"VIEW2D: (pointStruct) ran out of memory trying to create a new graph.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + llPtr->listOfPoints = p; /** point to current point list **/ + for (k=0; knumberOfPoints; k++) { + readViewman(&(p->x),floatSize); + readViewman(&(p->y),floatSize); + readViewman(&(p->hue),floatSize); + readViewman(&(p->shade),floatSize); + p++; + } /* for k in list of points */ + readViewman(&(llPtr->pointColor),intSize); + readViewman(&(llPtr->lineColor),intSize); + readViewman(&(llPtr->pointSize),intSize); + + xPointsNeeded += llPtr->numberOfPoints; + llPtr++; + } /* for j in list of lists of points */ + + /* read in graph state for the existing graph (override default values) */ + readViewman(&(graphStateArray[i].scaleX),floatSize); + readViewman(&(graphStateArray[i].scaleY),floatSize); + readViewman(&(graphStateArray[i].deltaX),floatSize); + readViewman(&(graphStateArray[i].deltaY),floatSize); + readViewman(&(graphStateArray[i].pointsOn),intSize); + readViewman(&(graphStateArray[i].connectOn),intSize); + readViewman(&(graphStateArray[i].splineOn),intSize); + readViewman(&(graphStateArray[i].axesOn),intSize); + readViewman(&(graphStateArray[i].axesColor),intSize); + readViewman(&(graphStateArray[i].unitsOn),intSize); + readViewman(&(graphStateArray[i].unitsColor),intSize); + readViewman(&(graphStateArray[i].showing),intSize); + graphStateArray[i].selected = yes; + graphStateBackupArray[i] = graphStateArray[i]; + + graphStateArray[i].deltaX = graphStateArray[0].deltaX; + graphStateArray[i].deltaY = graphStateArray[0].deltaY; + graphStateArray[i].scaleX = graphStateArray[0].scaleX; + graphStateArray[i].scaleY = graphStateArray[0].scaleY; + + /* allocate memory for xPoints (used in drawViewport) */ + if (!(xPointsArray[i].xPoint = (XPoint *)malloc(xPointsNeeded * sizeof(XPoint)))) { + fprintf(stderr,"VIEW2D: (XPoint) Ran out of memory (malloc) trying to create a new graph.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + if (!(xPointsArray[i].x10Point = (Vertex *)malloc(xPointsNeeded * sizeof(Vertex)))) { + fprintf(stderr, + "VIEW2D: (X10Point) Ran out of memory (malloc) trying to create a new graph.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + if (!(xPointsArray[i].arc = (XArc *)malloc(xPointsNeeded * sizeof(XArc)))) { + fprintf(stderr,"VIEW2D: (XArc) Ran out of memory (malloc) trying to create a new graph.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + +} /* getGraphFromViewman */ + + + +void +#ifdef _NO_PROTO +freeGraph(i) +int i; +#else +freeGraph(int i) +#endif +{ + int j; + pointListStruct *llPtr; + + if (graphArray[i].key) { + graphArray[i].key = 0; /* 0 means no graph */ + for (j=0,llPtr=graphArray[i].listOfListsOfPoints; + jlistOfPoints); + free(llPtr); + free(xPointsArray[i].xPoint); + } else { + } + +} diff --git a/src/graph/view2D/graph2d.c.pamphlet b/src/graph/view2D/graph2d.c.pamphlet deleted file mode 100644 index add87b5b..00000000 --- a/src/graph/view2D/graph2d.c.pamphlet +++ /dev/null @@ -1,188 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D graph2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _GRAPH2D_C -#include "axiom-c-macros.h" - -#include -#include -#include - -#include "header2.h" - -#include "all_2d.H1" -#include "util.H1" - - -void -#ifdef _NO_PROTO -getGraphFromViewman(i) -int i; -#else -getGraphFromViewman(int i) -#endif -{ - /** This routine should be called right after a read of the graph key - was made from the viewport manager (or defined in some other way). **/ - - int j,k,xPointsNeeded; - pointListStruct *llPtr; - pointStruct *p; - - readViewman(&(graphArray[i].xmin),floatSize); - readViewman(&(graphArray[i].xmax),floatSize); - readViewman(&(graphArray[i].ymin),floatSize); - readViewman(&(graphArray[i].ymax),floatSize); - readViewman(&(graphArray[i].xNorm),floatSize); - readViewman(&(graphArray[i].yNorm),floatSize); - readViewman(&(graphArray[i].spadUnitX),floatSize); - readViewman(&(graphArray[i].spadUnitY),floatSize); - readViewman(&(graphArray[i].unitX),floatSize); - readViewman(&(graphArray[i].unitY),floatSize); - readViewman(&(graphArray[i].originX),floatSize); - readViewman(&(graphArray[i].originY),floatSize); - readViewman(&(graphArray[i].numberOfLists),intSize); - - if (!(llPtr = (pointListStruct *)malloc(graphArray[i].numberOfLists * sizeof(pointListStruct)))) { - fprintf(stderr,"VIEW2D: Fatal Error>> Ran out of memory trying to receive a graph.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - graphArray[i].listOfListsOfPoints = llPtr; - - xPointsNeeded = 0; - for (j=0; jnumberOfPoints),intSize); - if (!(p = (pointStruct *)malloc(llPtr->numberOfPoints * sizeof(pointStruct)))) { - fprintf(stderr,"VIEW2D: (pointStruct) ran out of memory trying to create a new graph.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - llPtr->listOfPoints = p; /** point to current point list **/ - for (k=0; knumberOfPoints; k++) { - readViewman(&(p->x),floatSize); - readViewman(&(p->y),floatSize); - readViewman(&(p->hue),floatSize); - readViewman(&(p->shade),floatSize); - p++; - } /* for k in list of points */ - readViewman(&(llPtr->pointColor),intSize); - readViewman(&(llPtr->lineColor),intSize); - readViewman(&(llPtr->pointSize),intSize); - - xPointsNeeded += llPtr->numberOfPoints; - llPtr++; - } /* for j in list of lists of points */ - - /* read in graph state for the existing graph (override default values) */ - readViewman(&(graphStateArray[i].scaleX),floatSize); - readViewman(&(graphStateArray[i].scaleY),floatSize); - readViewman(&(graphStateArray[i].deltaX),floatSize); - readViewman(&(graphStateArray[i].deltaY),floatSize); - readViewman(&(graphStateArray[i].pointsOn),intSize); - readViewman(&(graphStateArray[i].connectOn),intSize); - readViewman(&(graphStateArray[i].splineOn),intSize); - readViewman(&(graphStateArray[i].axesOn),intSize); - readViewman(&(graphStateArray[i].axesColor),intSize); - readViewman(&(graphStateArray[i].unitsOn),intSize); - readViewman(&(graphStateArray[i].unitsColor),intSize); - readViewman(&(graphStateArray[i].showing),intSize); - graphStateArray[i].selected = yes; - graphStateBackupArray[i] = graphStateArray[i]; - - graphStateArray[i].deltaX = graphStateArray[0].deltaX; - graphStateArray[i].deltaY = graphStateArray[0].deltaY; - graphStateArray[i].scaleX = graphStateArray[0].scaleX; - graphStateArray[i].scaleY = graphStateArray[0].scaleY; - - /* allocate memory for xPoints (used in drawViewport) */ - if (!(xPointsArray[i].xPoint = (XPoint *)malloc(xPointsNeeded * sizeof(XPoint)))) { - fprintf(stderr,"VIEW2D: (XPoint) Ran out of memory (malloc) trying to create a new graph.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - if (!(xPointsArray[i].x10Point = (Vertex *)malloc(xPointsNeeded * sizeof(Vertex)))) { - fprintf(stderr, - "VIEW2D: (X10Point) Ran out of memory (malloc) trying to create a new graph.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - if (!(xPointsArray[i].arc = (XArc *)malloc(xPointsNeeded * sizeof(XArc)))) { - fprintf(stderr,"VIEW2D: (XArc) Ran out of memory (malloc) trying to create a new graph.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - -} /* getGraphFromViewman */ - - - -void -#ifdef _NO_PROTO -freeGraph(i) -int i; -#else -freeGraph(int i) -#endif -{ - int j; - pointListStruct *llPtr; - - if (graphArray[i].key) { - graphArray[i].key = 0; /* 0 means no graph */ - for (j=0,llPtr=graphArray[i].listOfListsOfPoints; - jlistOfPoints); - free(llPtr); - free(xPointsArray[i].xPoint); - } else { - } - -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/header2.h b/src/graph/view2D/header2.h old mode 100755 new mode 100644 index b6b37848..c7d63985 --- a/src/graph/view2D/header2.h +++ b/src/graph/view2D/header2.h @@ -1,34 +1,36 @@ /* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights resrved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include diff --git a/src/graph/view2D/main2d.c b/src/graph/view2D/main2d.c new file mode 100644 index 00000000..8ff6b8e7 --- /dev/null +++ b/src/graph/view2D/main2d.c @@ -0,0 +1,503 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _MAIN2D_C +#include "axiom-c-macros.h" + +#include +#include +#include +#include +#include + +#include "header2.h" +#include "bsdsignal.h" +#include "globals2.h" +#include "bsdsignal.H1" +#include "all_2d.H1" +#include "Gfun.H1" +#include "util.H1" +#include "XSpadFill.H1" + + +/**********************/ +/** global variables **/ +/**********************/ +Window rtWindow,viewman; +Display *dsply; +XFontStruct *globalFont, + *buttonFont, + *headerFont, + *titleFont, + *graphFont, + *unitFont, + *serverFont; +GC globalGC1, + globalGC2, + anotherGC, + globGC, + trashGC, + controlMessageGC, + graphGC, + unitGC, + processGC; +XGCValues gcVals; +HashTable *table; +Colormap colorMap; + +XrmDatabase rDB; /* Resource database */ + + +char scaleXReport[5], + scaleYReport[5], + deltaXReport[5], + deltaYReport[5], + *s, + errorStr[80], + filename[256], /** For writing viewport data out to a file **/ + *xDefault; /** used for accessing .XDefaults **/ + + +unsigned long *spadColors; +unsigned long foregroundColor, backgroundColor; + +int followMouse = no, + viewportKeyNum = 0, + scrn, + Socket = 1, + ack = 1, + someInt, + drawMore, + spadMode=no, /* yes if receiving AXIOM command and calling drawViewport */ + spadDraw=no, /* yes if drawing viewport because of a AXIOM command */ + pointsON = yes, /* these would affect the choices in buttons.c */ + connectON = yes, + splineON = no, + axesON = yes, + unitsON = no, + zoomXON = yes, + zoomYON = yes, + transXON = yes, + transYON = yes, + currentGraph = 0, /* last graph selected */ + queriedGraph = 0, /* current graph queried */ + picking=0, + dropping=0, + viewAloned, /** if not connected to AXIOM **/ + mono, + totalColors, + totalSolid, + totalDithered, + maxGreyShade, + totalHues, + totalSolidShades, + totalDitheredAndSolids, + totalShades; +/* totalShades is initially set to totalShadesConst (probably 8). + If X cannot allocate 8 shades for each hue, totalShades is + decremented. There is currently only a check for this value + to be positive. ---> something to add: change over to monochrome + if totalShades=0. Just modify the spadcolors.c file. + spadcolors.c has been modified so that it returns the value for + totalShades. Since the return value had previously been unused, + a modification in this way ensures continued support of other + routines calling this function (e.g. hyperDoc stuff). */ + +viewPoints *viewport; +controlPanelStruct *control; +jmp_buf jumpFlag; +graphStruct graphArray[maxGraphs]; +graphStateStruct graphStateArray[maxGraphs], + graphStateBackupArray[maxGraphs]; +xPointStruct xPointsArray[maxGraphs]; +float aspectR = 1.0; +/* global ps variables */ +int psInit=no; /* need to call globalInitPs() each run */ +GCptr GChead=NULL; /* ptr to head of ps GC linked list */ +char *PSfilename, /* output file name used in user directory */ + *envAXIOM; /* used as ps file pathnames */ + +int +#ifdef _NO_PROTO +main() +#else +main(void) +#endif +{ + + XGCValues controlGCVals; + int i,code; + view2DStruct viewData; + + char property[256]; + char *prop = &property[0]; + char *str_type[20]; + XrmValue value; + + + /**** Set up display ****/ + if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL) + fprintf(stderr,"Could not open the display.\n"); + scrn = DefaultScreen(dsply); + rtWindow = RootWindow(dsply,scrn); + + /**** link Xwindows to viewports - X10 feature ****/ + table = XCreateAssocTable(nbuckets); + + /**** Create AXIOM color map ****/ + totalColors = XInitSpadFill(dsply,scrn,&colorMap, + &totalHues,&totalSolidShades, + &totalDitheredAndSolids,&totalShades); + + if (totalColors < 0) { + fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n"); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + + mergeDatabases(); + + + /*** Determine whether monochrome or color is used ***/ + if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop, "off"); + + mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0)); + + if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop, "off"); + + if (mono) + if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ + foregroundColor = WhitePixel(dsply,scrn); + backgroundColor = BlackPixel(dsply,scrn); + } else { /* off (no inverse video) */ + foregroundColor = BlackPixel(dsply,scrn); + backgroundColor = WhitePixel(dsply,scrn); + } + else /* inverse of inverse in color (for some strange reason) */ + if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ + foregroundColor = WhitePixel(dsply,scrn); + backgroundColor = BlackPixel(dsply,scrn); + } else { /* off (no inverse video) */ + foregroundColor = BlackPixel(dsply,scrn); + backgroundColor = WhitePixel(dsply,scrn); + } + + + /* read default file name for postScript output */ + if (XrmGetResource(rDB, + "Axiom.2D.postscriptFile", + "", + str_type, &value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop, "axiom2D.ps"); + + PSfilename = (char *)malloc(strlen(prop)+1); + strcpy(PSfilename,prop); + + + + /**** Open global fonts ****/ + serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn))); + + if (XrmGetResource(rDB, + "Axiom.2D.messageFont", + "Axiom.2D.Font", + str_type, &value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,messageFontDefault); + if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for messageFont\n",prop); + globalFont = serverFont; + } + + if (XrmGetResource(rDB, + "Axiom.2D.buttonFont", + "Axiom.2D.Font", + str_type, &value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,buttonFontDefault); + if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for buttonFont\n",prop); + buttonFont = serverFont; + } + + if (XrmGetResource(rDB, + "Axiom.2D.headerFont", + "Axiom.2D.Font", + str_type, &value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,headerFontDefault); + + if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for headerFont\n",prop); + headerFont = serverFont; + } + + if (XrmGetResource(rDB, + "Axiom.2D.titleFont", + "Axiom.2D.Font", + str_type,&value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,titleFontDefault); + + if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for titleFont\n",prop); + titleFont = serverFont; + } + + if (XrmGetResource(rDB, + "Axiom.2D.graphFont", + "Axiom.2D.Font", + str_type,&value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,graphFontDefault); + + if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for graphFont\n",prop); + graphFont = serverFont; + } + + if (XrmGetResource(rDB, + "Axiom.2D.unitFont", + "Axiom.2D.Font", + str_type,&value) == True) + (void) strncpy(prop,value.addr,(int)value.size); + else + (void) strcpy(prop,unitFontDefault); + + if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) { + fprintf(stderr, + "Warning: could not get the %s font for unitFont\n",prop); + unitFont = serverFont; + } + + + /**** Create widely used Graphic Contexts ****/ + PSGlobalInit(); + /* must initiate before using any G/PS functions + need character name: used as postscript GC variable + need to create ps GCs for all GCs used by drawings in viewWindow */ + + /* globalGC1 */ + + controlGCVals.foreground = monoColor(axesColorDefault); + controlGCVals.background = backgroundColor; + globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground , + &controlGCVals); + carefullySetFont(globalGC1,globalFont); + + + /* create the equivalent GCs for ps */ + PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* controlMessageGC */ + + controlGCVals.foreground = controlMessageColor; + controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground + ,&controlGCVals); + carefullySetFont(controlMessageGC,globalFont); + + /* globalGC2 */ + + controlGCVals.foreground = monoColor(labelColor); + controlGCVals.background = backgroundColor; + globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground, + &controlGCVals); + carefullySetFont(globalGC2,buttonFont); + PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* trashGC */ + + trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); + carefullySetFont(trashGC,buttonFont); + PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* globGC */ + + globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); + carefullySetFont(globGC,headerFont); + PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* anotherGC */ + + controlGCVals.line_width = colorWidth; + anotherGC = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals); + carefullySetFont(anotherGC,titleFont); + PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* processGC */ + + gcVals.background = backgroundColor; + processGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); + carefullySetFont(processGC,buttonFont); + + /* graphGC */ + + graphGC = XCreateGC(dsply,rtWindow,GCBackground,&gcVals); + carefullySetFont(graphGC,graphFont); + PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /* unitGC */ + + unitGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); + carefullySetFont(unitGC,unitFont); + PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap, + psMiterJoin, psWhite, psBlack); + + /**** Initialize Graph States ****/ + + for (i=0; icontrolPanel; + + bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls); + + /* send acknowledgement to viewport manager */ + i = 345; + check(write(Socket,&(viewport->viewWindow),sizeof(Window))); + + processEvents(); + + goodbye(-1); + return(0); /* control never reaches here but compiler complains */ +} /* main() */ + +void +#ifdef _NO_PROTO +mergeDatabases() +#else +mergeDatabases(void) +#endif +{ + /* using global + rDB + dsply + */ + XrmDatabase homeDB,serverDB,applicationDB; + char filenamebuf[1024]; + char *filename = &filenamebuf[0]; + char *classname = "OpenAxiom"; + char name[255]; + + (void) XrmInitialize(); + (void) strcpy(name, "/usr/lib/X11/app-defaults/"); + (void) strcat(name, classname); + applicationDB = XrmGetFileDatabase(name); + (void) XrmMergeDatabases(applicationDB, &rDB); + + if (XResourceManagerString(dsply) != NULL) + serverDB = XrmGetStringDatabase(XResourceManagerString(dsply)); + else { + (void) strcpy(filename,getenv("HOME")); + (void) strcat(filename,"/.Xdefaults"); + serverDB = XrmGetFileDatabase(filename); + } + XrmMergeDatabases(serverDB,&rDB); + if ( getenv ("XENVIRONMENT") == NULL) { + int len; + (void) strcpy(filename,getenv("HOME")); + (void) strcat(filename,"/.Xdefaults-"); + len = strlen(filename); + (void) gethostname(filename+len,1024-len); + } + else + (void) strcpy (filename,getenv ("XENVIRONMENT")); + + homeDB = XrmGetFileDatabase(filename); + XrmMergeDatabases(homeDB,&rDB); +} + diff --git a/src/graph/view2D/main2d.c.pamphlet b/src/graph/view2D/main2d.c.pamphlet deleted file mode 100644 index 72135f9a..00000000 --- a/src/graph/view2D/main2d.c.pamphlet +++ /dev/null @@ -1,523 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D main2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _MAIN2D_C -#include "axiom-c-macros.h" - -#include -#include -#include -#include -#include - -#include "header2.h" -#include "bsdsignal.h" -#include "globals2.h" -#include "bsdsignal.H1" -#include "all_2d.H1" -#include "Gfun.H1" -#include "util.H1" -#include "XSpadFill.H1" - - -/**********************/ -/** global variables **/ -/**********************/ -Window rtWindow,viewman; -Display *dsply; -XFontStruct *globalFont, - *buttonFont, - *headerFont, - *titleFont, - *graphFont, - *unitFont, - *serverFont; -GC globalGC1, - globalGC2, - anotherGC, - globGC, - trashGC, - controlMessageGC, - graphGC, - unitGC, - processGC; -XGCValues gcVals; -HashTable *table; -Colormap colorMap; - -XrmDatabase rDB; /* Resource database */ - - -char scaleXReport[5], - scaleYReport[5], - deltaXReport[5], - deltaYReport[5], - *s, - errorStr[80], - filename[256], /** For writing viewport data out to a file **/ - *xDefault; /** used for accessing .XDefaults **/ - - -unsigned long *spadColors; -unsigned long foregroundColor, backgroundColor; - -int followMouse = no, - viewportKeyNum = 0, - scrn, - Socket = 1, - ack = 1, - someInt, - drawMore, - spadMode=no, /* yes if receiving AXIOM command and calling drawViewport */ - spadDraw=no, /* yes if drawing viewport because of a AXIOM command */ - pointsON = yes, /* these would affect the choices in buttons.c */ - connectON = yes, - splineON = no, - axesON = yes, - unitsON = no, - zoomXON = yes, - zoomYON = yes, - transXON = yes, - transYON = yes, - currentGraph = 0, /* last graph selected */ - queriedGraph = 0, /* current graph queried */ - picking=0, - dropping=0, - viewAloned, /** if not connected to AXIOM **/ - mono, - totalColors, - totalSolid, - totalDithered, - maxGreyShade, - totalHues, - totalSolidShades, - totalDitheredAndSolids, - totalShades; -/* totalShades is initially set to totalShadesConst (probably 8). - If X cannot allocate 8 shades for each hue, totalShades is - decremented. There is currently only a check for this value - to be positive. ---> something to add: change over to monochrome - if totalShades=0. Just modify the spadcolors.c file. - spadcolors.c has been modified so that it returns the value for - totalShades. Since the return value had previously been unused, - a modification in this way ensures continued support of other - routines calling this function (e.g. hyperDoc stuff). */ - -viewPoints *viewport; -controlPanelStruct *control; -jmp_buf jumpFlag; -graphStruct graphArray[maxGraphs]; -graphStateStruct graphStateArray[maxGraphs], - graphStateBackupArray[maxGraphs]; -xPointStruct xPointsArray[maxGraphs]; -float aspectR = 1.0; -/* global ps variables */ -int psInit=no; /* need to call globalInitPs() each run */ -GCptr GChead=NULL; /* ptr to head of ps GC linked list */ -char *PSfilename, /* output file name used in user directory */ - *envAXIOM; /* used as ps file pathnames */ - -int -#ifdef _NO_PROTO -main() -#else -main(void) -#endif -{ - - XGCValues controlGCVals; - int i,code; - view2DStruct viewData; - - char property[256]; - char *prop = &property[0]; - char *str_type[20]; - XrmValue value; - - - /**** Set up display ****/ - if ((dsply = XOpenDisplay(getenv("DISPLAY"))) == NULL) - fprintf(stderr,"Could not open the display.\n"); - scrn = DefaultScreen(dsply); - rtWindow = RootWindow(dsply,scrn); - - /**** link Xwindows to viewports - X10 feature ****/ - table = XCreateAssocTable(nbuckets); - - /**** Create AXIOM color map ****/ - totalColors = XInitSpadFill(dsply,scrn,&colorMap, - &totalHues,&totalSolidShades, - &totalDitheredAndSolids,&totalShades); - - if (totalColors < 0) { - fprintf(stderr,">>Error: Could not allocate all the necessary colors.\n"); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - - mergeDatabases(); - - - /*** Determine whether monochrome or color is used ***/ - if (XrmGetResource(rDB,"Axiom.2D.monochrome","",str_type,&value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop, "off"); - - mono = ((totalSolid == 2) || (strcmp(prop,"on") == 0)); - - if (XrmGetResource(rDB,"Axiom.2D.inverse","",str_type,&value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop, "off"); - - if (mono) - if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ - foregroundColor = WhitePixel(dsply,scrn); - backgroundColor = BlackPixel(dsply,scrn); - } else { /* off (no inverse video) */ - foregroundColor = BlackPixel(dsply,scrn); - backgroundColor = WhitePixel(dsply,scrn); - } - else /* inverse of inverse in color (for some strange reason) */ - if (strcmp(prop,"on") == 0) { /* 0 if equal (inverse video) */ - foregroundColor = WhitePixel(dsply,scrn); - backgroundColor = BlackPixel(dsply,scrn); - } else { /* off (no inverse video) */ - foregroundColor = BlackPixel(dsply,scrn); - backgroundColor = WhitePixel(dsply,scrn); - } - - - /* read default file name for postScript output */ - if (XrmGetResource(rDB, - "Axiom.2D.postscriptFile", - "", - str_type, &value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop, "axiom2D.ps"); - - PSfilename = (char *)malloc(strlen(prop)+1); - strcpy(PSfilename,prop); - - - - /**** Open global fonts ****/ - serverFont = XQueryFont(dsply,XGContextFromGC(DefaultGC(dsply,scrn))); - - if (XrmGetResource(rDB, - "Axiom.2D.messageFont", - "Axiom.2D.Font", - str_type, &value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,messageFontDefault); - if ((globalFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for messageFont\n",prop); - globalFont = serverFont; - } - - if (XrmGetResource(rDB, - "Axiom.2D.buttonFont", - "Axiom.2D.Font", - str_type, &value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,buttonFontDefault); - if ((buttonFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for buttonFont\n",prop); - buttonFont = serverFont; - } - - if (XrmGetResource(rDB, - "Axiom.2D.headerFont", - "Axiom.2D.Font", - str_type, &value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,headerFontDefault); - - if ((headerFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for headerFont\n",prop); - headerFont = serverFont; - } - - if (XrmGetResource(rDB, - "Axiom.2D.titleFont", - "Axiom.2D.Font", - str_type,&value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,titleFontDefault); - - if ((titleFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for titleFont\n",prop); - titleFont = serverFont; - } - - if (XrmGetResource(rDB, - "Axiom.2D.graphFont", - "Axiom.2D.Font", - str_type,&value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,graphFontDefault); - - if ((graphFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for graphFont\n",prop); - graphFont = serverFont; - } - - if (XrmGetResource(rDB, - "Axiom.2D.unitFont", - "Axiom.2D.Font", - str_type,&value) == True) - (void) strncpy(prop,value.addr,(int)value.size); - else - (void) strcpy(prop,unitFontDefault); - - if ((unitFont = XLoadQueryFont(dsply, prop)) == NULL) { - fprintf(stderr, - "Warning: could not get the %s font for unitFont\n",prop); - unitFont = serverFont; - } - - - /**** Create widely used Graphic Contexts ****/ - PSGlobalInit(); - /* must initiate before using any G/PS functions - need character name: used as postscript GC variable - need to create ps GCs for all GCs used by drawings in viewWindow */ - - /* globalGC1 */ - - controlGCVals.foreground = monoColor(axesColorDefault); - controlGCVals.background = backgroundColor; - globalGC1 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground , - &controlGCVals); - carefullySetFont(globalGC1,globalFont); - - - /* create the equivalent GCs for ps */ - PSCreateContext(globalGC1, "globalGC1", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* controlMessageGC */ - - controlGCVals.foreground = controlMessageColor; - controlMessageGC = XCreateGC(dsply,rtWindow,GCForeground | GCBackground - ,&controlGCVals); - carefullySetFont(controlMessageGC,globalFont); - - /* globalGC2 */ - - controlGCVals.foreground = monoColor(labelColor); - controlGCVals.background = backgroundColor; - globalGC2 = XCreateGC(dsply,rtWindow,GCForeground | GCBackground, - &controlGCVals); - carefullySetFont(globalGC2,buttonFont); - PSCreateContext(globalGC2, "globalGC2", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* trashGC */ - - trashGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); - carefullySetFont(trashGC,buttonFont); - PSCreateContext(trashGC, "trashGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* globGC */ - - globGC = XCreateGC(dsply,rtWindow,0,&controlGCVals); - carefullySetFont(globGC,headerFont); - PSCreateContext(globGC, "globGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* anotherGC */ - - controlGCVals.line_width = colorWidth; - anotherGC = XCreateGC(dsply,rtWindow,GCBackground,&controlGCVals); - carefullySetFont(anotherGC,titleFont); - PSCreateContext(anotherGC, "anotherGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* processGC */ - - gcVals.background = backgroundColor; - processGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); - carefullySetFont(processGC,buttonFont); - - /* graphGC */ - - graphGC = XCreateGC(dsply,rtWindow,GCBackground,&gcVals); - carefullySetFont(graphGC,graphFont); - PSCreateContext(graphGC, "graphGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /* unitGC */ - - unitGC = XCreateGC(dsply,rtWindow,GCBackground ,&gcVals); - carefullySetFont(unitGC,unitFont); - PSCreateContext(unitGC, "unitGC", psNormalWidth, psButtCap, - psMiterJoin, psWhite, psBlack); - - /**** Initialize Graph States ****/ - - for (i=0; icontrolPanel; - - bsdSignal(SIGTERM,goodbye,DontRestartSystemCalls); - - /* send acknowledgement to viewport manager */ - i = 345; - check(write(Socket,&(viewport->viewWindow),sizeof(Window))); - - processEvents(); - - goodbye(-1); - return(0); /* control never reaches here but compiler complains */ -} /* main() */ - -void -#ifdef _NO_PROTO -mergeDatabases() -#else -mergeDatabases(void) -#endif -{ - /* using global - rDB - dsply - */ - XrmDatabase homeDB,serverDB,applicationDB; - char filenamebuf[1024]; - char *filename = &filenamebuf[0]; - char *classname = "OpenAxiom"; - char name[255]; - - (void) XrmInitialize(); - (void) strcpy(name, "/usr/lib/X11/app-defaults/"); - (void) strcat(name, classname); - applicationDB = XrmGetFileDatabase(name); - (void) XrmMergeDatabases(applicationDB, &rDB); - - if (XResourceManagerString(dsply) != NULL) - serverDB = XrmGetStringDatabase(XResourceManagerString(dsply)); - else { - (void) strcpy(filename,getenv("HOME")); - (void) strcat(filename,"/.Xdefaults"); - serverDB = XrmGetFileDatabase(filename); - } - XrmMergeDatabases(serverDB,&rDB); - if ( getenv ("XENVIRONMENT") == NULL) { - int len; - (void) strcpy(filename,getenv("HOME")); - (void) strcat(filename,"/.Xdefaults-"); - len = strlen(filename); - (void) gethostname(filename+len,1024-len); - } - else - (void) strcpy (filename,getenv ("XENVIRONMENT")); - - homeDB = XrmGetFileDatabase(filename); - XrmMergeDatabases(homeDB,&rDB); -} - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/pot2d.c b/src/graph/view2D/pot2d.c new file mode 100644 index 00000000..95443a4d --- /dev/null +++ b/src/graph/view2D/pot2d.c @@ -0,0 +1,63 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _POT2D_C +#include "axiom-c-macros.h" + +#include "header2.h" + +#include "all_2d.H1" + +mouseCoord +#ifdef _NO_PROTO +getPotValue(eX,eY,xH,yH) + short eX,eY,xH,yH; +#else +getPotValue(short eX,short eY,short xH,short yH) +#endif +{ + + mouseCoord whereMouse; + float x,y; + + x = (float)eX/xH - 1; + y = -((float)eY/yH -1); + /* make non-linear potentiometer */ + whereMouse.x = x*x*x; + whereMouse.y = y*y*y; + + return(whereMouse); + +} /* getPotValue() */ diff --git a/src/graph/view2D/pot2d.c.pamphlet b/src/graph/view2D/pot2d.c.pamphlet deleted file mode 100644 index af4addb7..00000000 --- a/src/graph/view2D/pot2d.c.pamphlet +++ /dev/null @@ -1,83 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D pot2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _POT2D_C -#include "axiom-c-macros.h" - -#include "header2.h" - -#include "all_2d.H1" - -mouseCoord -#ifdef _NO_PROTO -getPotValue(eX,eY,xH,yH) - short eX,eY,xH,yH; -#else -getPotValue(short eX,short eY,short xH,short yH) -#endif -{ - - mouseCoord whereMouse; - float x,y; - - x = (float)eX/xH - 1; - y = -((float)eY/yH -1); - /* make non-linear potentiometer */ - whereMouse.x = x*x*x; - whereMouse.y = y*y*y; - - return(whereMouse); - -} /* getPotValue() */ -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/process2d.c b/src/graph/view2D/process2d.c new file mode 100644 index 00000000..7df82480 --- /dev/null +++ b/src/graph/view2D/process2d.c @@ -0,0 +1,938 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _PROCESS2D_C +#include "axiom-c-macros.h" + +#include +#include +#include +#include +#include +#include +#ifdef RIOSplatform +#include +#endif + +#include "header2.h" + +#include "all_2d.H1" +#include "util.H1" +#include "Gfun.H1" +#include "XSpadFill.H1" + + +static int doit=0; /* globish variable for picking/dropping/clearing - all sorts of + 2 button sequence events (command & graph #). */ + + +void +#ifdef _NO_PROTO +doPick (i,bKey) + int i,bKey; +#else +doPick (int i,int bKey) +#endif +{ + int vCommand=pick2D; + + picking = no; + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + if (graphArray[currentGraph].key) { + check(write(Socket,&vCommand,intSize)); + check(write(Socket,&(graphArray[currentGraph].key),intSize)); + check(write(Socket,&(graphStateArray[currentGraph]), + sizeof(graphStateStruct))); + sprintf(control->message,"%s%d","Picked up graph ",currentGraph+1); + } else + sprintf(control->message,"%s","This graph is empty!"); + writeControlMessage(); + + +} + + +void +#ifdef _NO_PROTO +doDrop (i,bKey) + int i,bKey; +#else +doDrop (int i,int bKey) +#endif +{ + int vCommand=drop2D; + int viewGoAhead; + + dropping = no; + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + check(write(Socket,&(vCommand),intSize)); + readViewman(&viewGoAhead,intSize); + if (viewGoAhead < 0) { + sprintf(control->message,"%s%d","Couldn't drop to graph ",currentGraph+1); + writeControlMessage(); + } else { + sprintf(control->message,"%s%d","Dropped onto graph ",currentGraph+1); + writeControlMessage(); + freeGraph(currentGraph); + readViewman(&(graphArray[currentGraph].key),intSize); + getGraphFromViewman(currentGraph); + /* simulate a button press to turn display number on and select on */ + /* need !yes since it will be inverted */ + graphStateArray[currentGraph].selected = no; + graphStateArray[currentGraph].showing = + !(graphStateArray[currentGraph].showing); + clickedOnGraph(currentGraph,currentGraph+graphStart); + clickedOnGraphSelect(currentGraph,currentGraph+graphSelectStart); + } +} + +void +#ifdef _NO_PROTO +clickedOnGraphSelect (i,bKey) + int i,bKey; +#else +clickedOnGraphSelect (int i,int bKey) +#endif +{ + int strlength; + + switch (doit) { + case pick2D: + currentGraph = i; + doPick(i,bKey); + break; + case drop2D: + currentGraph = i; + doDrop(i,bKey); + break; + case query2D: + queriedGraph = i; + makeMessageFromData(queriedGraph); + writeControlMessage(); + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + break; + default: + graphStateArray[i].selected = !(graphStateArray[i].selected); + if (graphStateArray[i].selected) { + GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); + strcpy(control->buttonQueue[bKey].text,"^"); + strlength = strlen(control->buttonQueue[bKey].text); + } else { + GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); + strcpy(control->buttonQueue[bKey].text,"-"); + strlength = strlen(control->buttonQueue[bKey].text); + } + /* just to make sure the background is reset from clickedOnGraph */ + if (mono) { + GSetForeground(graphGC,(float)foregroundColor,Xoption); + GSetBackground(graphGC,(float)backgroundColor,Xoption); + } + + GDrawImageString(graphGC,control->controlWindow, + control->buttonQueue[bKey].buttonX + + centerX(graphGC, + control->buttonQueue[bKey].text,strlength, + control->buttonQueue[bKey].buttonWidth), + control->buttonQueue[bKey].buttonY + + centerY(graphGC, + control->buttonQueue[bKey].buttonHeight), + control->buttonQueue[bKey].text,strlength,Xoption); + GSetForeground(trashGC,(float)foregroundColor,Xoption); + GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); + GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption); + break; + } /* switch doit */ + +} + + +static void +#ifndef _NO_PROTO +drawControlPushButton(int isOn, int index) +#else + drawControlPushButton(isOn,index) + int isOn; + int index; +#endif +{ + GDrawPushButton(dsply, processGC, processGC, processGC, + control->controlWindow, + (control->buttonQueue[index]).buttonX, + (control->buttonQueue[index]).buttonY, + (control->buttonQueue[index]).buttonWidth, + (control->buttonQueue[index]).buttonHeight, + isOn, + (control->buttonQueue[index]).text, + buttonColor, + monoColor((control->buttonQueue[index]).textColor), Xoption); + XSync(dsply,False); +} + + + +void +#ifdef _NO_PROTO +buttonAction (bKey) + int bKey; +#else +buttonAction (int bKey) +#endif +{ + int i; + + switch (bKey) { + + case pick2D: + if (viewAloned) { + sprintf(control->message,"%s","Cannot pick without AXIOM!"); + writeControlMessage(); + XSync(dsply,False); + } + else { + doit = pick2D; + sprintf(control->message,"%s","Click on the graph to pick"); + writeControlMessage(); + XSync(dsply,False); + } + break; + + case drop2D: + if (viewAloned) { + sprintf(control->message,"%s","Cannot drop without AXIOM!"); + writeControlMessage(); + XSync(dsply,False); + } else { + doit = drop2D; + sprintf(control->message,"%s","Click on the graph to drop"); + writeControlMessage(); + XSync(dsply,False); + } + break; + + case query2D: + doit = query2D; + sprintf(control->message,"%s","Click on the graph to query"); + writeControlMessage(); + XSync(dsply,False); + break; + + + case zoom2Dx: + if (zoomXON) + strcpy((control->buttonQueue[zoom2Dx]).text , + "X Off"); + else + strcpy((control->buttonQueue[zoom2Dx]).text , + "X On "); + zoomXON = !zoomXON; + + drawControlPushButton(zoomXON, zoom2Dx); + XSync(dsply,False); + break; + + case zoom2Dy: + if (zoomYON) strcpy((control->buttonQueue[zoom2Dy]).text, + "Y Off"); + else strcpy((control->buttonQueue[zoom2Dy]).text , + "Y On "); + zoomYON = !zoomYON; + drawControlPushButton(zoomYON, zoom2Dy); + XSync(dsply,False); + break; + + + case translate2Dx: + if (transXON) strcpy((control->buttonQueue[translate2Dx]).text, + "X Off"); + else strcpy( (control->buttonQueue[translate2Dx]).text, + "X On "); + transXON = !transXON; + drawControlPushButton(transXON, translate2Dx); + XSync(dsply,False); + break; + + case translate2Dy: + if (transYON) strcpy((control->buttonQueue[translate2Dy]).text, + "Y Off"); + else strcpy( (control->buttonQueue[translate2Dy]).text, + "Y On"); + transYON = !transYON; + drawControlPushButton(transYON, translate2Dy); + XSync(dsply,False); + break; + + case pointsOnOff: + if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text, + "Pts Off"); + else strcpy( (control->buttonQueue[pointsOnOff]).text, + "Pts On "); + pointsON = !pointsON; + for (i=0; ibuttonQueue[connectOnOff]).text, + "Lines Off"); + else strcpy( (control->buttonQueue[connectOnOff]).text, + "Lines On "); + connectON = !connectON; + for (i=0; ibuttonQueue[spline2D]).text, + "Box Off"); + else strcpy ((control->buttonQueue[spline2D]).text , + "Box On "); + splineON = !splineON; + for (i=0; ibuttonQueue[axesOnOff2D]).text, + "Axes Off"); + else + strcpy ((control->buttonQueue[axesOnOff2D]).text , + "Axes On "); + axesON = !axesON; + for (i=0; ibuttonQueue[unitsOnOff2D]).text, + "Units Off"); + else + strcpy ((control->buttonQueue[unitsOnOff2D]).text, + "Units On "); + unitsON = !unitsON; + for (i=0; imessage,"Creating postscript now ..."); + writeControlMessage(); + drawControlPushButton(1, ps2D); + + if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { + strcpy(control->message,"Aborted: PSInit error."); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + return; /* make new temp name for new file */ + } + + drawViewport(PSoption); /* draw picture in PS; create ps script file */ + + if (PSCreateFile(viewBorderWidth, + viewport->viewWindow, + viewport->titleWindow, + viewport->title) == psError) { + strcpy(control->message,"Aborted: PSCreateFile error."); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + return; + } + + clearControlMessage(); + strcpy(control->message,PSfilename); + strcat(control->message," in working dir "); + writeControlMessage(); + drawControlPushButton(0, ps2D); + XSync(dsply,False); + break; + + case hideControl2D: + if (viewport->haveControl) { + viewport->haveControl = no; + XUnmapWindow(dsply,control->controlWindow); + XSync(dsply,False); + } + break; + + case reset2D: + /* reset view */ + for (i=0; ibuttonQueue[unitsOnOff2D]).text,s = "Units Off"); + for (i=0; ibuttonQueue[pointsOnOff]).text ,"Pts On "); + for (i=0; ibuttonQueue[axesOnOff2D]).text,"Axes On "); + for (i=0; ibuttonQueue[connectOnOff]).text,"Lines On "); + for (i=0; ibuttonQueue[connectOnOff]).text ,"Box Off"); + for (i=0; imessage," Click again to confirm "); + writeControlMessage(); + drawControlPushButton(1, closeAll2D); + XSync(dsply,False); + viewport->closing = yes; + break; + + case clear2D: + for (i=0; ibuttonQueue; + + while(1) { + + len=0; + while(len<=0) { + FD_ZERO(&rd); + if (externalControl==0) FD_SET(0, &rd); + FD_SET(Xcon,&rd); + + if (XEventsQueued(dsply, QueuedAlready)) { + len=1; + break; + } + if (!followMouse) + len=select(FD_SETSIZE,(void *) &rd,0,0,0); + else + len=1; + } + if (FD_ISSET(Xcon,&rd)|| + XEventsQueued(dsply, QueuedAfterFlush) || + followMouse) { + + if (followMouse) { + if (XPending(dsply)) + XNextEvent(dsply,event); + gotEvent++; + } else { + XNextEvent(dsply,event); + gotEvent++; + } + + if (gotToggle || !followMouse) + checkButton = no; + + if (gotEvent) { + whichWindow = ((XButtonEvent *)event)->window; + firstTime = no; + + switch(((XEvent *)event)->type) { + + case ClientMessage: + if (event->xclient.data.l[0] == wm_delete_window) { + goodbye(-1); + } + else { + fprintf(stderr,"Unknown Client Message ...\n"); + } + break; + case Expose: + if (whichWindow == viewport->titleWindow) { + /* get rid of redundant events */ + XCheckWindowEvent(dsply, + viewport->titleWindow, + ExposureMask, + &tempEvent); + writeTitle(); + XGetWindowAttributes(dsply, + whichWindow, + &graphWindowAttrib); + XResizeWindow(dsply, + viewport->viewWindow, + graphWindowAttrib.width, + graphWindowAttrib.height-titleHeight); + XSync(dsply,False); + break; + } else if (whichWindow == viewport->viewWindow) { + XCheckWindowEvent(dsply, + viewport->viewWindow, + ExposureMask, + &tempEvent); + XGetWindowAttributes(dsply, + viewport->titleWindow, + &graphWindowAttrib); + XResizeWindow(dsply, + viewport->viewWindow, + graphWindowAttrib.width, + graphWindowAttrib.height-titleHeight); + drawViewport(Xoption); + XMapWindow(dsply,whichWindow); + XSync(dsply,False); + break; + } else { /* it's gotta be the control panel */ + XGetWindowAttributes(dsply, + control->controlWindow, + &graphWindowAttrib); + /* do not allow resizing of control panel */ + if ((graphWindowAttrib.width != controlWidth) || + (graphWindowAttrib.height != controlHeight)) { + XResizeWindow(dsply, + control->controlWindow, + controlWidth, + controlHeight); + } + drawControlPanel(); + XSync(dsply,False); + break; + } + break; + + case MotionNotify: + if (followMouse) { + while (XCheckMaskEvent(dsply, + ButtonMotionMask, + event)); + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + } + if (controlButton->pot) { + gotToggle = no; + checkButton = yes; + } + break; + + case ButtonRelease: + if (followMouse==yes) { + followMouse = no; + toggleReady = yes; + checkButton = no; + drawViewport(Xoption); + } else { + followMouse = no; + toggleReady = yes; + checkButton = no; + } + break; + + case LeaveNotify: + /* + We still follow the mouse when we leave the pots. + */ + /* + followMouse = no; + toggleReady = yes; + checkButton = no; + */ + + break; + + case ButtonPress: + if (whichWindow == viewport->viewWindow) { + + /* mouse clicked on viewport */ + + switch (((XButtonEvent *)event)->button) { + case Button3: + + /* print out (x,y) object-space coordinates in message area */ + + XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); + sprintf(viewport->controlPanel->message, + " >%d<: [%6.2f,%6.2f] ", + queriedGraph+1, + projX((((XButtonEvent *)event)->x), + graphWindowAttrib.width,queriedGraph), + projY((((XButtonEvent *)event)->y), + graphWindowAttrib.height,queriedGraph)); + writeControlMessage(); + XFlush(dsply); + break; + default: + + /* Find where mouse is on the viewport => where to put the CP */ + + XGetWindowAttributes(dsply, + whichWindow, + &graphWindowAttrib); + mouseW4 = graphWindowAttrib.width/4; + if (((XButtonEvent *)event)->x > + (graphWindowAttrib.width - mouseW4)) + someInt = 1; + else { + mouseH4 = graphWindowAttrib.height/4; + if (((XButtonEvent *)event)->y > + (graphWindowAttrib.height - mouseH4)) + someInt = 2; + else if (((XButtonEvent *)event)->x < mouseW4) + someInt = 3; + else if (((XButtonEvent *)event)->y < mouseH4) + someInt = 4; + else someInt = 0; + } + if (viewport->haveControl) { + XUnmapWindow(dsply,control->controlWindow); + } + putControlPanelSomewhere(someInt); + XMapWindow(dsply,control->controlWindow); + XSync(dsply,False); + break; + } /* switch on mouse button */ + } else if (whichWindow == control->colormapWindow) { + + /* mouse clicked on colormap */ + + followMouse = yes; + gotToggle = no; + checkButton = yes; + firstTime = yes; + } else if (whichWindow != control->controlWindow) { + + /* mouse clicked on control window (not colormap) */ + + if (controlButton->self != whichWindow) { + buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); + controlButton = &(control->buttonQueue[buttonTablePtr]); + } + + if (controlButton->pot) { + /* figure out [x,y] for this button in the range [-1..1,-1..1] */ + mouseXY = getPotValue(((XButtonEvent *)event)->x, + ((XButtonEvent *)event)->y, + controlButton->xHalf, + controlButton->yHalf); + followMouse = yes; + gotToggle = no; + } else { + followMouse = no; + gotToggle = yes; /* auto-repeat on toggle buttons not allowed */ + if (toggleReady) { + toggleReady = no; + } + } + checkButton = yes; + firstTime = yes; + } + break; + + } /* switch */ + gotEvent--; + } /* if gotEvent */ + + + /* Allow repeat polling when mouse button clicked on a potentiometer. */ + + if (followMouse && !firstTime && (followMouse++ > mouseWait)) { + followMouse = yes; /* reset for next timing loop */ + checkButton = yes; + } + if (checkButton) { + if (viewport->closing && (controlButton->buttonKey == closeAll2D)) { + goodbye(-1); + } else { + clearControlMessage(); + viewport->closing = no; + drawControlPushButton(0, closeAll2D); + if ((doit) && + ((controlButton->buttonKey < graphStart) && + (controlButton->buttonKey > (graphSelectStart + maxGraphs)))) + doit = 0; + + switch(controlButton->buttonKey) { + + case translate2D: + for (i=0; i maxDelta) + graphStateArray[i].centerX = maxDelta; + else if (graphStateArray[i].centerX < -maxDelta) + graphStateArray[i].centerX = maxDelta; + } + if (transYON) { + graphStateArray[i].centerY -= mouseXY.y * 0.1; + if (graphStateArray[i].centerY > maxDelta) + graphStateArray[i].centerY = maxDelta; + else if (graphStateArray[i].centerY < -maxDelta) + graphStateArray[i].centerY = maxDelta; + } + } /* graph showing or selected */ + } /* for graphs */ + drawViewport(Xoption); + break; + + case scale2D: + for (i=0; i maxScale) + graphStateArray[i].scaleX = maxScale; + else if (graphStateArray[i].scaleX < minScale) + graphStateArray[i].scaleX = minScale; + } + if (zoomYON) { + graphStateArray[i].scaleY *= (1 - mouseXY.y * 0.3); + if (graphStateArray[i].scaleY > maxScale) + graphStateArray[i].scaleY = maxScale; + else if (graphStateArray[i].scaleY < minScale) + graphStateArray[i].scaleY = minScale; + } + } /* graph showing or selected */ + } /* for graphs */ + drawViewport(Xoption); + break; + + default: + buttonAction(controlButton->buttonKey); + } /* switch on buttonKey */ + } /* else - not closing */ + } /* if checkButton */ + } /* if FD_ISSET(Xcon.... */ + else if FD_ISSET(0,&rd) { + externalControl=spadAction(); /* returns (-1) if broken ,0 if success */ + if (spadDraw && (externalControl==0)) drawViewport(Xoption); + } + } /* while */ +} /* processEvents() */ + + + + + + +void +#ifdef _NO_PROTO +clickedOnGraph (i,bKey) + int i,bKey; +#else +clickedOnGraph (int i,int bKey) +#endif +{ + + switch (doit) { + case pick2D: + currentGraph = queriedGraph = i; + doPick(i,bKey); + break; + case drop2D: + currentGraph = queriedGraph = i; + doDrop(i,bKey); + break; + case query2D: + queriedGraph = i; + makeMessageFromData(queriedGraph); + writeControlMessage(); + /* reset indicator so that we're not in pick/drop/query mode anymore */ + doit = 0; + break; + default: + graphStateArray[i].showing = !(graphStateArray[i].showing); + if (mono) { + if (graphStateArray[i].showing) { + GSetForeground(graphGC,(float)backgroundColor,Xoption); + GSetBackground(graphGC,(float)foregroundColor,Xoption); + } else { + GSetForeground(graphGC,(float)foregroundColor,Xoption); + GSetBackground(graphGC,(float)backgroundColor,Xoption); + } + GDrawImageString(graphGC, + control->controlWindow, + (control->buttonQueue[bKey]).buttonX + + centerX(graphGC,(control->buttonQueue[bKey]).text,1, + (control->buttonQueue[bKey]).buttonWidth), + (control->buttonQueue[bKey]).buttonY + + centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), + (control->buttonQueue[bKey]).text, + 1, + Xoption); + } else { + if (graphStateArray[i].showing) + GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); + else + GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); + GDrawString(graphGC, + control->controlWindow, + (control->buttonQueue[bKey]).buttonX + + centerX(graphGC,(control->buttonQueue[bKey]).text,1, + (control->buttonQueue[bKey]).buttonWidth), + (control->buttonQueue[bKey]).buttonY + + centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), + (control->buttonQueue[bKey]).text,1,Xoption); + } + drawViewport(Xoption); + break; + } /* switch doit */ + +} + + + + + + + + + diff --git a/src/graph/view2D/process2d.c.pamphlet b/src/graph/view2D/process2d.c.pamphlet deleted file mode 100644 index 11c1c34b..00000000 --- a/src/graph/view2D/process2d.c.pamphlet +++ /dev/null @@ -1,958 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D process2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _PROCESS2D_C -#include "axiom-c-macros.h" - -#include -#include -#include -#include -#include -#include -#ifdef RIOSplatform -#include -#endif - -#include "header2.h" - -#include "all_2d.H1" -#include "util.H1" -#include "Gfun.H1" -#include "XSpadFill.H1" - - -static int doit=0; /* globish variable for picking/dropping/clearing - all sorts of - 2 button sequence events (command & graph #). */ - - -void -#ifdef _NO_PROTO -doPick (i,bKey) - int i,bKey; -#else -doPick (int i,int bKey) -#endif -{ - int vCommand=pick2D; - - picking = no; - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - if (graphArray[currentGraph].key) { - check(write(Socket,&vCommand,intSize)); - check(write(Socket,&(graphArray[currentGraph].key),intSize)); - check(write(Socket,&(graphStateArray[currentGraph]), - sizeof(graphStateStruct))); - sprintf(control->message,"%s%d","Picked up graph ",currentGraph+1); - } else - sprintf(control->message,"%s","This graph is empty!"); - writeControlMessage(); - - -} - - -void -#ifdef _NO_PROTO -doDrop (i,bKey) - int i,bKey; -#else -doDrop (int i,int bKey) -#endif -{ - int vCommand=drop2D; - int viewGoAhead; - - dropping = no; - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - check(write(Socket,&(vCommand),intSize)); - readViewman(&viewGoAhead,intSize); - if (viewGoAhead < 0) { - sprintf(control->message,"%s%d","Couldn't drop to graph ",currentGraph+1); - writeControlMessage(); - } else { - sprintf(control->message,"%s%d","Dropped onto graph ",currentGraph+1); - writeControlMessage(); - freeGraph(currentGraph); - readViewman(&(graphArray[currentGraph].key),intSize); - getGraphFromViewman(currentGraph); - /* simulate a button press to turn display number on and select on */ - /* need !yes since it will be inverted */ - graphStateArray[currentGraph].selected = no; - graphStateArray[currentGraph].showing = - !(graphStateArray[currentGraph].showing); - clickedOnGraph(currentGraph,currentGraph+graphStart); - clickedOnGraphSelect(currentGraph,currentGraph+graphSelectStart); - } -} - -void -#ifdef _NO_PROTO -clickedOnGraphSelect (i,bKey) - int i,bKey; -#else -clickedOnGraphSelect (int i,int bKey) -#endif -{ - int strlength; - - switch (doit) { - case pick2D: - currentGraph = i; - doPick(i,bKey); - break; - case drop2D: - currentGraph = i; - doDrop(i,bKey); - break; - case query2D: - queriedGraph = i; - makeMessageFromData(queriedGraph); - writeControlMessage(); - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - break; - default: - graphStateArray[i].selected = !(graphStateArray[i].selected); - if (graphStateArray[i].selected) { - GSetForeground(graphGC,(float)graphBarSelectColor,Xoption); - strcpy(control->buttonQueue[bKey].text,"^"); - strlength = strlen(control->buttonQueue[bKey].text); - } else { - GSetForeground(graphGC,(float)graphBarNotSelectColor,Xoption); - strcpy(control->buttonQueue[bKey].text,"-"); - strlength = strlen(control->buttonQueue[bKey].text); - } - /* just to make sure the background is reset from clickedOnGraph */ - if (mono) { - GSetForeground(graphGC,(float)foregroundColor,Xoption); - GSetBackground(graphGC,(float)backgroundColor,Xoption); - } - - GDrawImageString(graphGC,control->controlWindow, - control->buttonQueue[bKey].buttonX + - centerX(graphGC, - control->buttonQueue[bKey].text,strlength, - control->buttonQueue[bKey].buttonWidth), - control->buttonQueue[bKey].buttonY + - centerY(graphGC, - control->buttonQueue[bKey].buttonHeight), - control->buttonQueue[bKey].text,strlength,Xoption); - GSetForeground(trashGC,(float)foregroundColor,Xoption); - GSetLineAttributes(trashGC,2,LineSolid,CapButt,JoinMiter,Xoption); - GDrawLine(trashGC,control->controlWindow,0,286,controlWidth,286,Xoption); - break; - } /* switch doit */ - -} - - -static void -#ifndef _NO_PROTO -drawControlPushButton(int isOn, int index) -#else - drawControlPushButton(isOn,index) - int isOn; - int index; -#endif -{ - GDrawPushButton(dsply, processGC, processGC, processGC, - control->controlWindow, - (control->buttonQueue[index]).buttonX, - (control->buttonQueue[index]).buttonY, - (control->buttonQueue[index]).buttonWidth, - (control->buttonQueue[index]).buttonHeight, - isOn, - (control->buttonQueue[index]).text, - buttonColor, - monoColor((control->buttonQueue[index]).textColor), Xoption); - XSync(dsply,False); -} - - - -void -#ifdef _NO_PROTO -buttonAction (bKey) - int bKey; -#else -buttonAction (int bKey) -#endif -{ - int i; - - switch (bKey) { - - case pick2D: - if (viewAloned) { - sprintf(control->message,"%s","Cannot pick without AXIOM!"); - writeControlMessage(); - XSync(dsply,False); - } - else { - doit = pick2D; - sprintf(control->message,"%s","Click on the graph to pick"); - writeControlMessage(); - XSync(dsply,False); - } - break; - - case drop2D: - if (viewAloned) { - sprintf(control->message,"%s","Cannot drop without AXIOM!"); - writeControlMessage(); - XSync(dsply,False); - } else { - doit = drop2D; - sprintf(control->message,"%s","Click on the graph to drop"); - writeControlMessage(); - XSync(dsply,False); - } - break; - - case query2D: - doit = query2D; - sprintf(control->message,"%s","Click on the graph to query"); - writeControlMessage(); - XSync(dsply,False); - break; - - - case zoom2Dx: - if (zoomXON) - strcpy((control->buttonQueue[zoom2Dx]).text , - "X Off"); - else - strcpy((control->buttonQueue[zoom2Dx]).text , - "X On "); - zoomXON = !zoomXON; - - drawControlPushButton(zoomXON, zoom2Dx); - XSync(dsply,False); - break; - - case zoom2Dy: - if (zoomYON) strcpy((control->buttonQueue[zoom2Dy]).text, - "Y Off"); - else strcpy((control->buttonQueue[zoom2Dy]).text , - "Y On "); - zoomYON = !zoomYON; - drawControlPushButton(zoomYON, zoom2Dy); - XSync(dsply,False); - break; - - - case translate2Dx: - if (transXON) strcpy((control->buttonQueue[translate2Dx]).text, - "X Off"); - else strcpy( (control->buttonQueue[translate2Dx]).text, - "X On "); - transXON = !transXON; - drawControlPushButton(transXON, translate2Dx); - XSync(dsply,False); - break; - - case translate2Dy: - if (transYON) strcpy((control->buttonQueue[translate2Dy]).text, - "Y Off"); - else strcpy( (control->buttonQueue[translate2Dy]).text, - "Y On"); - transYON = !transYON; - drawControlPushButton(transYON, translate2Dy); - XSync(dsply,False); - break; - - case pointsOnOff: - if (pointsON) strcpy((control->buttonQueue[pointsOnOff]).text, - "Pts Off"); - else strcpy( (control->buttonQueue[pointsOnOff]).text, - "Pts On "); - pointsON = !pointsON; - for (i=0; ibuttonQueue[connectOnOff]).text, - "Lines Off"); - else strcpy( (control->buttonQueue[connectOnOff]).text, - "Lines On "); - connectON = !connectON; - for (i=0; ibuttonQueue[spline2D]).text, - "Box Off"); - else strcpy ((control->buttonQueue[spline2D]).text , - "Box On "); - splineON = !splineON; - for (i=0; ibuttonQueue[axesOnOff2D]).text, - "Axes Off"); - else - strcpy ((control->buttonQueue[axesOnOff2D]).text , - "Axes On "); - axesON = !axesON; - for (i=0; ibuttonQueue[unitsOnOff2D]).text, - "Units Off"); - else - strcpy ((control->buttonQueue[unitsOnOff2D]).text, - "Units On "); - unitsON = !unitsON; - for (i=0; imessage,"Creating postscript now ..."); - writeControlMessage(); - drawControlPushButton(1, ps2D); - - if (PSInit(viewport->viewWindow, viewport->titleWindow) == psError) { - strcpy(control->message,"Aborted: PSInit error."); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - return; /* make new temp name for new file */ - } - - drawViewport(PSoption); /* draw picture in PS; create ps script file */ - - if (PSCreateFile(viewBorderWidth, - viewport->viewWindow, - viewport->titleWindow, - viewport->title) == psError) { - strcpy(control->message,"Aborted: PSCreateFile error."); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - return; - } - - clearControlMessage(); - strcpy(control->message,PSfilename); - strcat(control->message," in working dir "); - writeControlMessage(); - drawControlPushButton(0, ps2D); - XSync(dsply,False); - break; - - case hideControl2D: - if (viewport->haveControl) { - viewport->haveControl = no; - XUnmapWindow(dsply,control->controlWindow); - XSync(dsply,False); - } - break; - - case reset2D: - /* reset view */ - for (i=0; ibuttonQueue[unitsOnOff2D]).text,s = "Units Off"); - for (i=0; ibuttonQueue[pointsOnOff]).text ,"Pts On "); - for (i=0; ibuttonQueue[axesOnOff2D]).text,"Axes On "); - for (i=0; ibuttonQueue[connectOnOff]).text,"Lines On "); - for (i=0; ibuttonQueue[connectOnOff]).text ,"Box Off"); - for (i=0; imessage," Click again to confirm "); - writeControlMessage(); - drawControlPushButton(1, closeAll2D); - XSync(dsply,False); - viewport->closing = yes; - break; - - case clear2D: - for (i=0; ibuttonQueue; - - while(1) { - - len=0; - while(len<=0) { - FD_ZERO(&rd); - if (externalControl==0) FD_SET(0, &rd); - FD_SET(Xcon,&rd); - - if (XEventsQueued(dsply, QueuedAlready)) { - len=1; - break; - } - if (!followMouse) - len=select(FD_SETSIZE,(void *) &rd,0,0,0); - else - len=1; - } - if (FD_ISSET(Xcon,&rd)|| - XEventsQueued(dsply, QueuedAfterFlush) || - followMouse) { - - if (followMouse) { - if (XPending(dsply)) - XNextEvent(dsply,event); - gotEvent++; - } else { - XNextEvent(dsply,event); - gotEvent++; - } - - if (gotToggle || !followMouse) - checkButton = no; - - if (gotEvent) { - whichWindow = ((XButtonEvent *)event)->window; - firstTime = no; - - switch(((XEvent *)event)->type) { - - case ClientMessage: - if (event->xclient.data.l[0] == wm_delete_window) { - goodbye(-1); - } - else { - fprintf(stderr,"Unknown Client Message ...\n"); - } - break; - case Expose: - if (whichWindow == viewport->titleWindow) { - /* get rid of redundant events */ - XCheckWindowEvent(dsply, - viewport->titleWindow, - ExposureMask, - &tempEvent); - writeTitle(); - XGetWindowAttributes(dsply, - whichWindow, - &graphWindowAttrib); - XResizeWindow(dsply, - viewport->viewWindow, - graphWindowAttrib.width, - graphWindowAttrib.height-titleHeight); - XSync(dsply,False); - break; - } else if (whichWindow == viewport->viewWindow) { - XCheckWindowEvent(dsply, - viewport->viewWindow, - ExposureMask, - &tempEvent); - XGetWindowAttributes(dsply, - viewport->titleWindow, - &graphWindowAttrib); - XResizeWindow(dsply, - viewport->viewWindow, - graphWindowAttrib.width, - graphWindowAttrib.height-titleHeight); - drawViewport(Xoption); - XMapWindow(dsply,whichWindow); - XSync(dsply,False); - break; - } else { /* it's gotta be the control panel */ - XGetWindowAttributes(dsply, - control->controlWindow, - &graphWindowAttrib); - /* do not allow resizing of control panel */ - if ((graphWindowAttrib.width != controlWidth) || - (graphWindowAttrib.height != controlHeight)) { - XResizeWindow(dsply, - control->controlWindow, - controlWidth, - controlHeight); - } - drawControlPanel(); - XSync(dsply,False); - break; - } - break; - - case MotionNotify: - if (followMouse) { - while (XCheckMaskEvent(dsply, - ButtonMotionMask, - event)); - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - } - if (controlButton->pot) { - gotToggle = no; - checkButton = yes; - } - break; - - case ButtonRelease: - if (followMouse==yes) { - followMouse = no; - toggleReady = yes; - checkButton = no; - drawViewport(Xoption); - } else { - followMouse = no; - toggleReady = yes; - checkButton = no; - } - break; - - case LeaveNotify: - /* - We still follow the mouse when we leave the pots. - */ - /* - followMouse = no; - toggleReady = yes; - checkButton = no; - */ - - break; - - case ButtonPress: - if (whichWindow == viewport->viewWindow) { - - /* mouse clicked on viewport */ - - switch (((XButtonEvent *)event)->button) { - case Button3: - - /* print out (x,y) object-space coordinates in message area */ - - XGetWindowAttributes(dsply,whichWindow,&graphWindowAttrib); - sprintf(viewport->controlPanel->message, - " >%d<: [%6.2f,%6.2f] ", - queriedGraph+1, - projX((((XButtonEvent *)event)->x), - graphWindowAttrib.width,queriedGraph), - projY((((XButtonEvent *)event)->y), - graphWindowAttrib.height,queriedGraph)); - writeControlMessage(); - XFlush(dsply); - break; - default: - - /* Find where mouse is on the viewport => where to put the CP */ - - XGetWindowAttributes(dsply, - whichWindow, - &graphWindowAttrib); - mouseW4 = graphWindowAttrib.width/4; - if (((XButtonEvent *)event)->x > - (graphWindowAttrib.width - mouseW4)) - someInt = 1; - else { - mouseH4 = graphWindowAttrib.height/4; - if (((XButtonEvent *)event)->y > - (graphWindowAttrib.height - mouseH4)) - someInt = 2; - else if (((XButtonEvent *)event)->x < mouseW4) - someInt = 3; - else if (((XButtonEvent *)event)->y < mouseH4) - someInt = 4; - else someInt = 0; - } - if (viewport->haveControl) { - XUnmapWindow(dsply,control->controlWindow); - } - putControlPanelSomewhere(someInt); - XMapWindow(dsply,control->controlWindow); - XSync(dsply,False); - break; - } /* switch on mouse button */ - } else if (whichWindow == control->colormapWindow) { - - /* mouse clicked on colormap */ - - followMouse = yes; - gotToggle = no; - checkButton = yes; - firstTime = yes; - } else if (whichWindow != control->controlWindow) { - - /* mouse clicked on control window (not colormap) */ - - if (controlButton->self != whichWindow) { - buttonTablePtr = *((int *)XLookUpAssoc(dsply,table,whichWindow)); - controlButton = &(control->buttonQueue[buttonTablePtr]); - } - - if (controlButton->pot) { - /* figure out [x,y] for this button in the range [-1..1,-1..1] */ - mouseXY = getPotValue(((XButtonEvent *)event)->x, - ((XButtonEvent *)event)->y, - controlButton->xHalf, - controlButton->yHalf); - followMouse = yes; - gotToggle = no; - } else { - followMouse = no; - gotToggle = yes; /* auto-repeat on toggle buttons not allowed */ - if (toggleReady) { - toggleReady = no; - } - } - checkButton = yes; - firstTime = yes; - } - break; - - } /* switch */ - gotEvent--; - } /* if gotEvent */ - - - /* Allow repeat polling when mouse button clicked on a potentiometer. */ - - if (followMouse && !firstTime && (followMouse++ > mouseWait)) { - followMouse = yes; /* reset for next timing loop */ - checkButton = yes; - } - if (checkButton) { - if (viewport->closing && (controlButton->buttonKey == closeAll2D)) { - goodbye(-1); - } else { - clearControlMessage(); - viewport->closing = no; - drawControlPushButton(0, closeAll2D); - if ((doit) && - ((controlButton->buttonKey < graphStart) && - (controlButton->buttonKey > (graphSelectStart + maxGraphs)))) - doit = 0; - - switch(controlButton->buttonKey) { - - case translate2D: - for (i=0; i maxDelta) - graphStateArray[i].centerX = maxDelta; - else if (graphStateArray[i].centerX < -maxDelta) - graphStateArray[i].centerX = maxDelta; - } - if (transYON) { - graphStateArray[i].centerY -= mouseXY.y * 0.1; - if (graphStateArray[i].centerY > maxDelta) - graphStateArray[i].centerY = maxDelta; - else if (graphStateArray[i].centerY < -maxDelta) - graphStateArray[i].centerY = maxDelta; - } - } /* graph showing or selected */ - } /* for graphs */ - drawViewport(Xoption); - break; - - case scale2D: - for (i=0; i maxScale) - graphStateArray[i].scaleX = maxScale; - else if (graphStateArray[i].scaleX < minScale) - graphStateArray[i].scaleX = minScale; - } - if (zoomYON) { - graphStateArray[i].scaleY *= (1 - mouseXY.y * 0.3); - if (graphStateArray[i].scaleY > maxScale) - graphStateArray[i].scaleY = maxScale; - else if (graphStateArray[i].scaleY < minScale) - graphStateArray[i].scaleY = minScale; - } - } /* graph showing or selected */ - } /* for graphs */ - drawViewport(Xoption); - break; - - default: - buttonAction(controlButton->buttonKey); - } /* switch on buttonKey */ - } /* else - not closing */ - } /* if checkButton */ - } /* if FD_ISSET(Xcon.... */ - else if FD_ISSET(0,&rd) { - externalControl=spadAction(); /* returns (-1) if broken ,0 if success */ - if (spadDraw && (externalControl==0)) drawViewport(Xoption); - } - } /* while */ -} /* processEvents() */ - - - - - - -void -#ifdef _NO_PROTO -clickedOnGraph (i,bKey) - int i,bKey; -#else -clickedOnGraph (int i,int bKey) -#endif -{ - - switch (doit) { - case pick2D: - currentGraph = queriedGraph = i; - doPick(i,bKey); - break; - case drop2D: - currentGraph = queriedGraph = i; - doDrop(i,bKey); - break; - case query2D: - queriedGraph = i; - makeMessageFromData(queriedGraph); - writeControlMessage(); - /* reset indicator so that we're not in pick/drop/query mode anymore */ - doit = 0; - break; - default: - graphStateArray[i].showing = !(graphStateArray[i].showing); - if (mono) { - if (graphStateArray[i].showing) { - GSetForeground(graphGC,(float)backgroundColor,Xoption); - GSetBackground(graphGC,(float)foregroundColor,Xoption); - } else { - GSetForeground(graphGC,(float)foregroundColor,Xoption); - GSetBackground(graphGC,(float)backgroundColor,Xoption); - } - GDrawImageString(graphGC, - control->controlWindow, - (control->buttonQueue[bKey]).buttonX + - centerX(graphGC,(control->buttonQueue[bKey]).text,1, - (control->buttonQueue[bKey]).buttonWidth), - (control->buttonQueue[bKey]).buttonY + - centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), - (control->buttonQueue[bKey]).text, - 1, - Xoption); - } else { - if (graphStateArray[i].showing) - GSetForeground(graphGC,(float)graphBarShowingColor,Xoption); - else - GSetForeground(graphGC,(float)graphBarHiddenColor,Xoption); - GDrawString(graphGC, - control->controlWindow, - (control->buttonQueue[bKey]).buttonX + - centerX(graphGC,(control->buttonQueue[bKey]).text,1, - (control->buttonQueue[bKey]).buttonWidth), - (control->buttonQueue[bKey]).buttonY + - centerY(graphGC,(control->buttonQueue[bKey]).buttonHeight), - (control->buttonQueue[bKey]).text,1,Xoption); - } - drawViewport(Xoption); - break; - } /* switch doit */ - -} - - - - - - - - - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/spadAction2d.c b/src/graph/view2D/spadAction2d.c new file mode 100644 index 00000000..900d4358 --- /dev/null +++ b/src/graph/view2D/spadAction2d.c @@ -0,0 +1,299 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _SPADACTION2D_C +#include "axiom-c-macros.h" + +#include +#include +#include + +#include "header2.h" + +#include "all_2d.H1" +#include "util.H1" + + +/****************************** + * int readViewman(info,size) * + ******************************/ + +int +#ifdef _NO_PROTO +readViewman(info,size) + void *info; + int size; +#else +readViewman(void * info,int size) +#endif +{ + int mold = 0; + + sprintf(errorStr,"%s %d %s","read of ",size, + " bytes from viewport manager\n"); + mold = check(read(0,info,size)); + return(mold); + +} + +/******************** + * int spadAction() * + ********************/ +extern int viewAloned; +int +#ifdef _NO_PROTO +spadAction() +#else +spadAction(void) +#endif +{ + int code,viewCommand; + float f1,f2; + int i1,i2,i3,viewGoAhead; + static int ack = 1; + + if (viewAloned==yes) { + close(0); + return(-1); + } + readViewman(&viewCommand,intSize); + + switch (viewCommand) { + + case hideControl2D: + readViewman(&i1,intSize); + if (i1) { /* show control panel */ + if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow); + putControlPanelSomewhere(someInt); + } else { /* turn off control panel */ + if (viewport->haveControl) { + viewport->haveControl = no; + XUnmapWindow(dsply,control->controlWindow); + } + } + break; + + case changeTitle: + readViewman(&i1,intSize); + readViewman(viewport->title,i1); + viewport->title[i1] = '\0'; + writeTitle(); + writeControlTitle(); + XFlush(dsply); + spadDraw=no; + break; + + case writeView: + readViewman(&i1,intSize); + readViewman(filename,i1); + filename[i1] = '\0'; + sprintf(errorStr,"writing of viewport data"); + i3 = 0; + readViewman(&i2,intSize); + while (i2) { + i3 = i3 | (1< maxScale) + graphStateArray[i1].scaleX = maxScale; + else + if (graphStateArray[i1].scaleX < minScale) + graphStateArray[i1].scaleX = minScale; + if (graphStateArray[i1].scaleY > maxScale) + graphStateArray[i1].scaleY = maxScale; + else + if (graphStateArray[i1].scaleY < minScale) + graphStateArray[i1].scaleY = minScale; + if (graphStateArray[i1].showing) spadDraw=yes; + break; /* scale2D */ + + + case translate2D: + readViewman(&i1,intSize); + i1--; /* passed index is [1..9] but internal representation is [0..8] */ + readViewman(&f1,floatSize); + readViewman(&f2,floatSize); + graphStateArray[i1].centerX = f1; + graphStateArray[i1].centerY = f2; + if (graphStateArray[i1].centerX > maxDelta) + graphStateArray[i1].centerX = maxDelta; + else if (graphStateArray[i1].centerX < -maxDelta) + graphStateArray[i1].centerX = maxDelta; + if (graphStateArray[i1].centerY > maxDelta) + graphStateArray[i1].centerY = maxDelta; + else if (graphStateArray[i1].centerY < -maxDelta) + graphStateArray[i1].centerY = maxDelta; + if (graphStateArray[i1].showing) spadDraw=yes; + break; /* translate2D */ + + case moveViewport: + readViewman(&i1,intSize); + readViewman(&i2,intSize); + XMoveWindow(dsply,viewport->titleWindow,i1,i2); + XSync(dsply,False); + break; + + case resizeViewport: + readViewman(&i1,intSize); + readViewman(&i2,intSize); + XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight); + XResizeWindow(dsply,viewport->viewWindow,i1,i2); + spadDraw=yes; + break; + + case putGraph: + readViewman(&i1,intSize); /* key of graph to get */ + readViewman(&i2,intSize); /* slot to drop graph onto 0..8*/ + readViewman(&viewGoAhead,intSize); + if (viewGoAhead < 0) { + sprintf(control->message,"%s%d","Couldn't put into graph ",i2+1); + writeControlMessage(); + } else { + sprintf(control->message,"%s%d","Dropped onto graph ",i2+1); + writeControlMessage(); + freeGraph(i2); + graphArray[i2].key = i1; + getGraphFromViewman(i2); + /* simulate a button press to turn display number on and select on */ + /* need !yes since it will be inverted */ + graphStateArray[i2].selected = no; + graphStateArray[i2].connectOn = yes; + graphStateArray[i2].showing = !(graphStateArray[i2].showing); + clickedOnGraph(i2,i2+graphStart); + clickedOnGraphSelect(i2,i2+graphSelectStart); + } + break; + + case spadPressedAButton: + readViewman(&i1,intSize); + buttonAction(i1); + break; + + default: + return(-1); + } /* switch */ + + + ack++; + code = check(write(Socket,&ack,intSize)); + return(0); + +} + diff --git a/src/graph/view2D/spadAction2d.c.pamphlet b/src/graph/view2D/spadAction2d.c.pamphlet deleted file mode 100644 index 69ed10bb..00000000 --- a/src/graph/view2D/spadAction2d.c.pamphlet +++ /dev/null @@ -1,319 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D spadAction2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _SPADACTION2D_C -#include "axiom-c-macros.h" - -#include -#include -#include - -#include "header2.h" - -#include "all_2d.H1" -#include "util.H1" - - -/****************************** - * int readViewman(info,size) * - ******************************/ - -int -#ifdef _NO_PROTO -readViewman(info,size) - void *info; - int size; -#else -readViewman(void * info,int size) -#endif -{ - int mold = 0; - - sprintf(errorStr,"%s %d %s","read of ",size, - " bytes from viewport manager\n"); - mold = check(read(0,info,size)); - return(mold); - -} - -/******************** - * int spadAction() * - ********************/ -extern int viewAloned; -int -#ifdef _NO_PROTO -spadAction() -#else -spadAction(void) -#endif -{ - int code,viewCommand; - float f1,f2; - int i1,i2,i3,viewGoAhead; - static int ack = 1; - - if (viewAloned==yes) { - close(0); - return(-1); - } - readViewman(&viewCommand,intSize); - - switch (viewCommand) { - - case hideControl2D: - readViewman(&i1,intSize); - if (i1) { /* show control panel */ - if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow); - putControlPanelSomewhere(someInt); - } else { /* turn off control panel */ - if (viewport->haveControl) { - viewport->haveControl = no; - XUnmapWindow(dsply,control->controlWindow); - } - } - break; - - case changeTitle: - readViewman(&i1,intSize); - readViewman(viewport->title,i1); - viewport->title[i1] = '\0'; - writeTitle(); - writeControlTitle(); - XFlush(dsply); - spadDraw=no; - break; - - case writeView: - readViewman(&i1,intSize); - readViewman(filename,i1); - filename[i1] = '\0'; - sprintf(errorStr,"writing of viewport data"); - i3 = 0; - readViewman(&i2,intSize); - while (i2) { - i3 = i3 | (1< maxScale) - graphStateArray[i1].scaleX = maxScale; - else - if (graphStateArray[i1].scaleX < minScale) - graphStateArray[i1].scaleX = minScale; - if (graphStateArray[i1].scaleY > maxScale) - graphStateArray[i1].scaleY = maxScale; - else - if (graphStateArray[i1].scaleY < minScale) - graphStateArray[i1].scaleY = minScale; - if (graphStateArray[i1].showing) spadDraw=yes; - break; /* scale2D */ - - - case translate2D: - readViewman(&i1,intSize); - i1--; /* passed index is [1..9] but internal representation is [0..8] */ - readViewman(&f1,floatSize); - readViewman(&f2,floatSize); - graphStateArray[i1].centerX = f1; - graphStateArray[i1].centerY = f2; - if (graphStateArray[i1].centerX > maxDelta) - graphStateArray[i1].centerX = maxDelta; - else if (graphStateArray[i1].centerX < -maxDelta) - graphStateArray[i1].centerX = maxDelta; - if (graphStateArray[i1].centerY > maxDelta) - graphStateArray[i1].centerY = maxDelta; - else if (graphStateArray[i1].centerY < -maxDelta) - graphStateArray[i1].centerY = maxDelta; - if (graphStateArray[i1].showing) spadDraw=yes; - break; /* translate2D */ - - case moveViewport: - readViewman(&i1,intSize); - readViewman(&i2,intSize); - XMoveWindow(dsply,viewport->titleWindow,i1,i2); - XSync(dsply,False); - break; - - case resizeViewport: - readViewman(&i1,intSize); - readViewman(&i2,intSize); - XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight); - XResizeWindow(dsply,viewport->viewWindow,i1,i2); - spadDraw=yes; - break; - - case putGraph: - readViewman(&i1,intSize); /* key of graph to get */ - readViewman(&i2,intSize); /* slot to drop graph onto 0..8*/ - readViewman(&viewGoAhead,intSize); - if (viewGoAhead < 0) { - sprintf(control->message,"%s%d","Couldn't put into graph ",i2+1); - writeControlMessage(); - } else { - sprintf(control->message,"%s%d","Dropped onto graph ",i2+1); - writeControlMessage(); - freeGraph(i2); - graphArray[i2].key = i1; - getGraphFromViewman(i2); - /* simulate a button press to turn display number on and select on */ - /* need !yes since it will be inverted */ - graphStateArray[i2].selected = no; - graphStateArray[i2].connectOn = yes; - graphStateArray[i2].showing = !(graphStateArray[i2].showing); - clickedOnGraph(i2,i2+graphStart); - clickedOnGraphSelect(i2,i2+graphSelectStart); - } - break; - - case spadPressedAButton: - readViewman(&i1,intSize); - buttonAction(i1); - break; - - default: - return(-1); - } /* switch */ - - - ack++; - code = check(write(Socket,&ack,intSize)); - return(0); - -} - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/stuff2d.c b/src/graph/view2D/stuff2d.c new file mode 100644 index 00000000..1d5d75a5 --- /dev/null +++ b/src/graph/view2D/stuff2d.c @@ -0,0 +1,125 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _STUFF2D_C +#include "axiom-c-macros.h" + +#include +#include + +#include "header2.h" + +#include "all_2d.H1" +#include "Gfun.H1" +#include "util.H1" + + +/**************************/ +/*** float absolute(x) ***/ +/**************************/ + +float +#ifdef _NO_PROTO +absolute(x) + float x; +#else +absolute(float x) +#endif +{ + if (x<0.0) { + return(-x); + } else { + return(x); + } +} + + + +/************************/ +/*** void goodbye() ***/ +/************************/ + +void +#ifdef _NO_PROTO +goodbye(sig) +int sig; +#else +goodbye(int sig) +#endif +{ + int Command,i; + +#ifdef DEBUG + fprintf(stderr,"view2D: Tidying up and exiting\n"); +#endif + PSClose(); /* free PS file and data structure space */ + + XFreeGC(dsply,globalGC1); + XFreeGC(dsply,globalGC2); + XFreeGC(dsply,globGC); + XFreeGC(dsply,trashGC); + XFreeGC(dsply,anotherGC); + XFreeGC(dsply,controlMessageGC); + XFreeGC(dsply,graphGC); + XFreeGC(dsply,unitGC); + + XFreeFont(dsply,globalFont); + XFreeFont(dsply,buttonFont); + XFreeFont(dsply,headerFont); + XFreeFont(dsply,titleFont); + XFreeFont(dsply,graphFont); + XFreeFont(dsply,unitFont); + + XFreeColormap(dsply,colorMap); + + /** send off the current graphs to viewport manager **/ + + Command = viewportClosing; + check(write(Socket,&Command,intSize)); + + for (i=0; i>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _STUFF2D_C -#include "axiom-c-macros.h" - -#include -#include - -#include "header2.h" - -#include "all_2d.H1" -#include "Gfun.H1" -#include "util.H1" - - -/**************************/ -/*** float absolute(x) ***/ -/**************************/ - -float -#ifdef _NO_PROTO -absolute(x) - float x; -#else -absolute(float x) -#endif -{ - if (x<0.0) { - return(-x); - } else { - return(x); - } -} - - - -/************************/ -/*** void goodbye() ***/ -/************************/ - -void -#ifdef _NO_PROTO -goodbye(sig) -int sig; -#else -goodbye(int sig) -#endif -{ - int Command,i; - -#ifdef DEBUG - fprintf(stderr,"view2D: Tidying up and exiting\n"); -#endif - PSClose(); /* free PS file and data structure space */ - - XFreeGC(dsply,globalGC1); - XFreeGC(dsply,globalGC2); - XFreeGC(dsply,globGC); - XFreeGC(dsply,trashGC); - XFreeGC(dsply,anotherGC); - XFreeGC(dsply,controlMessageGC); - XFreeGC(dsply,graphGC); - XFreeGC(dsply,unitGC); - - XFreeFont(dsply,globalFont); - XFreeFont(dsply,buttonFont); - XFreeFont(dsply,headerFont); - XFreeFont(dsply,titleFont); - XFreeFont(dsply,graphFont); - XFreeFont(dsply,unitFont); - - XFreeColormap(dsply,colorMap); - - /** send off the current graphs to viewport manager **/ - - Command = viewportClosing; - check(write(Socket,&Command,intSize)); - - for (i=0; i +#include +#include +#include +#include +#include +#include +#include +#include + +#define NotPoint (SHRT_MAX) +#define eqNANQ(x) (x == NotPoint) + +#include "header2.h" + +#include "all_2d.H1" +#include "Gfun.H1" +#include "util.H1" +#include "XSpadFill.H1" + +#include "spadBitmap.bitmap" +#include "spadMask.mask" + +#define rint(z) ((int)(z)) + +Atom wm_delete_window; + + +/*************************** + *** void writeTitle() *** + ***************************/ + +void +#ifdef _NO_PROTO +writeTitle() +#else +writeTitle(void) +#endif +{ + + int strlength; + XWindowAttributes attribInfo; + + XGetWindowAttributes(dsply,viewport->titleWindow,&attribInfo); + if (mono) GSetForeground(anotherGC,(float)foregroundColor,Xoption); + else GSetForeground(anotherGC,(float)titleColor,Xoption); + XClearWindow(dsply,viewport->titleWindow); /* it's behind the viewWindow */ + strlength = strlen(viewport->title); + GDrawImageString(anotherGC,viewport->titleWindow, + centerX(anotherGC,viewport->title,strlength,attribInfo.width), + 15,viewport->title,strlength,Xoption); + +} + + +/********************************/ +/*** void drawTheViewport() ***/ +/********************************/ + +void +#ifdef _NO_PROTO +drawTheViewport(dFlag) +int dFlag; /* display flag: X, PS,... */ +#else +drawTheViewport(int dFlag) +#endif +{ + + Window vw; + XWindowAttributes vwInfo; + pointListStruct *aList; + pointStruct *aPoint; + XPoint *anXPoint,*tempXpt; + XArc *anXarc; + Vertex *anX10Point; + float jj,diffX, diffY, tickStart,oneTickUnit; + int i,j,k,ii,halfSize; + int charlength,strlength,halflength,halfheight; + int ptX,ptY,ptX1,ptY1,clipped, clipped1; + int xAxis,yAxis,dummyInt, ascent, descent; + int unitWidth,boxX,boxY,boxW,boxH; + char aunit[20]; + XCharStruct overall; + + drawMore = yes; + vw = viewport->viewWindow; + XGetWindowAttributes(dsply,vw,&vwInfo); + aspectR = (float)vwInfo.width/(float)vwInfo.height; + + XTextExtents(unitFont,"o",1,&dummyInt,&ascent,&descent,&overall); + halfheight = (ascent + descent) / 2; + + /* Calculate various factors for use in projection. */ + /* Scale the plot, so that the scaling between the axes remains + constant and fits within the smaller of the two dimensions. */ + + charlength = overall.width; + + if (dFlag==Xoption) XClearWindow(dsply,vw); + + for (i=0; i=0) && (yAxis <= vwInfo.height)) + GDrawLine(globalGC1,vw, + 0,yAxis, + vwInfo.width,yAxis, + dFlag); + if ((xAxis >=0) && (xAxis <= vwInfo.width)) + GDrawLine(globalGC1,vw, + xAxis,0, + xAxis,vwInfo.height, + dFlag); + } + + + tempXpt = anXPoint = xPointsArray[i].xPoint; + anX10Point = xPointsArray[i].x10Point; + anXarc = xPointsArray[i].arc; + + for (j=0,aList=graphArray[i].listOfListsOfPoints; + (jlistOfPoints; + (knumberOfPoints); + k++,aPoint++) { + + if (graphStateArray[i].scaleX > 99.0) + graphStateArray[i].scaleX = 99.0; + if (graphStateArray[i].scaleY > 99.0) + graphStateArray[0].scaleY = 99.0; + if (i > 0) { + if (isNaN(aPoint->x)) { + anXPoint->x = anX10Point->x = NotPoint; + } + else { + diffX = graphArray[i].xmax-graphArray[i].xmin; + anXPoint->x = anX10Point->x = vwInfo.width * + ((aPoint->x * diffX/(graphArray[0].xmax-graphArray[0].xmin) + + (graphArray[0].originX - graphArray[i].originX*diffX / + (graphArray[0].xmax-graphArray[0].xmin)) + - graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5); + } + if (isNaN(aPoint->y)) { + anXPoint->y = anX10Point->y = NotPoint; + } + else { + diffY = graphArray[i].ymax-graphArray[i].ymin; + anXPoint->y = anX10Point->y = vwInfo.height * aspectR * + (1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin) + + (graphArray[0].originY - graphArray[i].originY* diffY/ + (graphArray[0].ymax-graphArray[0].ymin))*aspectR + - graphStateArray[0].centerY) * + graphStateArray[i].scaleY + 0.5*aspectR)); + } + } else { + if (isNaN(aPoint->x)) { + anXPoint->x = anX10Point->x = NotPoint; + } + else { + anXPoint->x = anX10Point->x = vwInfo.width * + ((aPoint->x - graphStateArray[i].centerX) * + graphStateArray[i].scaleX + 0.5); + } + if (isNaN(aPoint->y)) { + anXPoint->y = anX10Point->y = NotPoint; + } + else { + anXPoint->y = anX10Point->y = vwInfo.height * aspectR * + (1 - ((aPoint->y - graphStateArray[i].centerY) * + graphStateArray[i].scaleY + 0.5*aspectR)); + } + } + + /* first or last point */ + if (k == 0 || k == (aList->numberOfPoints - 1)) { + anX10Point->flags = 0; + } else { + anX10Point->flags = VertexCurved; + } + + anXPoint++; + anX10Point++; + anXarc++; + } /* for aPoint in pointList */ + + aPoint--; /* make it legal, the last one*/ + if (graphStateArray[i].connectOn || graphStateArray[i].pointsOn) { + halfSize = aList->pointSize/2; + ptX = tempXpt->x; + ptY = tempXpt->y; + clipped = ptX > vwInfo.x && ptX < vwInfo.width && + ptY > 0 && ptY < vwInfo.height; + if (graphStateArray[i].pointsOn) { + if (dFlag==Xoption) { + if (mono) { + GSetForeground(globalGC1, + (float)monoColor((int)(aPoint->hue)), + dFlag); + } else { + GSetForeground(globalGC1, + (float)XSolidColor((int)(aPoint->hue), + (int)(aPoint->shade)), + dFlag); + } + } + if (clipped && !eqNANQ(ptX) && !eqNANQ(ptY)) + GFillArc(globalGC1,vw,ptX-halfSize, + ptY-halfSize,aList->pointSize,aList->pointSize, + 0,360*64, dFlag); + + } /* if points on */ + for (ii=0, aPoint=aList->listOfPoints; + iinumberOfPoints; + ++ii, ++tempXpt, ++aPoint) { + ptX1 = tempXpt->x; + ptY1 = tempXpt->y; + clipped1 = ptX1 > vwInfo.x && ptX1 < vwInfo.width && + ptY1 > 0 && ptY1 < vwInfo.height; + if (graphStateArray[i].connectOn) { + if (dFlag==Xoption) { + if (mono) { + GSetForeground(globalGC1, + (float)monoColor((int)(aList->lineColor-1)/5), + dFlag); + } else { + GSetForeground(globalGC1, + (float)XSolidColor((int)(aList->lineColor-1)/5, + (int)((aList->lineColor-1)%5)/2), + dFlag); + } + } /* if X */ + if ((clipped || clipped1) && !eqNANQ(ptX) && !eqNANQ(ptY) && + !eqNANQ(ptX1) && !eqNANQ(ptY1)) + GDrawLine(globalGC1,vw, + ptX,ptY,ptX1,ptY1, + dFlag); + } /* if lines on */ + if (graphStateArray[i].pointsOn) { + if (dFlag==Xoption) { + if (mono) { + GSetForeground(globalGC1, + (float)monoColor((int)(aPoint->hue)), + dFlag); + } else { + GSetForeground(globalGC1, + (float)XSolidColor((int)(aPoint->hue), + (int)(aPoint->shade)), + dFlag); + } + } + if (clipped1 && !eqNANQ(ptX1) && !eqNANQ(ptY1)) + GFillArc(globalGC1,vw,ptX1-halfSize, + ptY1-halfSize,aList->pointSize,aList->pointSize, + 0,360*64, dFlag); + } /* if points on */ + ptX = ptX1; ptY = ptY1; clipped = clipped1; + } /* for all points */ + } /* if points or lines on */ + + if (graphStateArray[i].splineOn) { /* need spline color as well */ + if (dFlag==Xoption) /* do only for X, ps uses default of black */ + GSetForeground(globalGC1, + (float)monoColor(148), + dFlag); + boxX = vwInfo.width * + ((-0.5 - graphStateArray[i].centerX)* + graphStateArray[i].scaleX + 0.5); + boxY = vwInfo.height * aspectR * + (1 - ((0.5 - graphStateArray[i].centerY)* + graphStateArray[i].scaleY + 0.5*aspectR)); + + boxW = graphStateArray[i].scaleX * vwInfo.width + 1; + boxH = graphStateArray[i].scaleY * vwInfo.height * aspectR + 1; + + GDrawRectangle(globalGC1,vw, + boxX,boxY,boxW,boxH, + dFlag); + } + + tempXpt = anXPoint; + } /* for a aList in listofListsOfPoints */ + if (graphStateArray[i].unitsOn) { + /* do only for X, ps uses default of black */ + if (dFlag==Xoption) + GSetForeground(unitGC, + (float)monoColor(graphStateArray[i].unitsColor), + dFlag); + + + tickStart = calcUnitX(0); + oneTickUnit = calcUnitX(1) - tickStart; + + /* ticks along the positive X axis */ + + unitWidth = 5*overall.width; /* limit on acceptable separation : 5 chars */ + k = floor(unitWidth/oneTickUnit) +1; /* get skipping integer */ + for (ii=0, jj = tickStart; + jj < vwInfo.width; + ii=ii+k,jj =jj+k* oneTickUnit) { + if (jj >= 0) { + + /* ticks stuck to viewport*/ + GDrawLine(unitGC,vw, + (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); + strlength=strlen(aunit); + halflength=XTextWidth(unitFont,aunit,strlength)/2; + + if (dFlag == Xoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) - halflength, + vwInfo.height -8 -descent, + aunit, + strlength, + dFlag); + if (dFlag == PSoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) -(strlength*3) , + vwInfo.height -14, + aunit, + strlength, + dFlag); + /* these are "eyeball" parameters for the given PS font */ + + } + + } + /* ticks along the negative X axis */ + for (ii=-k,jj=tickStart - k*oneTickUnit; + jj > 0; + ii=ii-k,jj = jj-k*oneTickUnit) { + if (jj <= vwInfo.width) { + + /* ticks stuck to viewport*/ + GDrawLine(unitGC,vw, + (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); + strlength=strlen(aunit); + halflength=XTextWidth(unitFont,aunit,strlength)/2; + + if (dFlag == Xoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) - halflength, + vwInfo.height -8 -descent, + aunit, + strlength, + dFlag); + if (dFlag == PSoption) GDrawImageString(unitGC, + vw, + (int)rint(jj) -(strlength*3) , + vwInfo.height -14, + aunit, + strlength, + dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } + + tickStart = calcUnitY(0); + oneTickUnit = calcUnitY(1) - tickStart; + + /* ticks along the positive Y axis */ + unitWidth = 2*(ascent+descent); /* limit of acceptable separation */ + k = floor(unitWidth/fabs(oneTickUnit)) +1; /* get skipping integer */ + for (ii=0,jj = tickStart; + jj > 0; + ii=ii+k,jj =jj+k*oneTickUnit ) { + if (jj < vwInfo.height) { + + /* ticks stuck to viewport*/ + /* on the right */ + /* + GDrawLine(unitGC,vw, + vwInfo.width-6,(int)rint(jj), + vwInfo.width-2,(int)rint(jj),dFlag); + */ + /* on the left */ + GDrawLine(unitGC,vw, + 2,(int)rint(jj), + 6,(int)rint(jj), + dFlag); + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); + strlength=strlen(aunit); + XTextExtents(unitFont,aunit,strlength,&dummyInt, + &ascent,&descent,&overall); + halflength=overall.width; /* let's reuse that variable */ + + if(dFlag == Xoption){ + /* on the right */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width-halflength -6-descent, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + */ + /* on the left */ + GDrawImageString(unitGC, vw, + 8 + charlength/2, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + } + if(dFlag == PSoption){ + /* on the right */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width - 6 - (strlength*6), + (int)rint(jj)+4, + aunit, strlength, dFlag); + */ + /* on the left */ + GDrawImageString(unitGC, vw, + 8,(int)rint(jj)+4, + aunit, strlength, dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } + } + + /* ticks along the negative Y axis */ + + for (ii=(-k),jj = tickStart - k*oneTickUnit; + jj < vwInfo.height; + ii=ii-k,jj =jj-k*oneTickUnit) { + if (jj > 0) { + + /* ticks stuck to viewport*/ + /* on the right */ + /* + GDrawLine(unitGC,vw, + vwInfo.width-6,(int)rint(jj), + vwInfo.width-2,(int)rint(jj), + dFlag); + */ + /* on the left */ + GDrawLine(unitGC,vw, + 2,(int)rint(jj), + 6,(int)rint(jj), + dFlag); + + sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); + strlength=strlen(aunit); + XTextExtents(unitFont,aunit,strlength,&dummyInt, + &ascent,&descent,&overall); + halflength=overall.width; /* let's reuse that variable */ + + if(dFlag == Xoption){ + /* on the right */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width-halflength -6-descent, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + */ + /* on the left */ + GDrawImageString(unitGC, vw, + 8 + charlength/2, + (int)rint(jj)+ascent/2 , + aunit, strlength, dFlag); + } + if(dFlag == PSoption){ + /* on the right */ + /* + GDrawImageString(unitGC, vw, + vwInfo.width -6 -(strlength*6), + (int)rint(jj)+4 , + aunit, strlength, dFlag); + */ + /* on the left */ + GDrawImageString(unitGC, vw, + 8, + (int)rint(jj)+4 , + aunit, strlength, dFlag); + /* these are "eyeball" parameters for the given PS font */ + } + } + } + + } /* if unitsOn */ + } /* if graph i exists and is showing */ + } /* for i in graphs */ + + + if (dFlag==Xoption) { + if (!followMouse) { + /* no need to do this while autorepeating */ + makeMessageFromData(queriedGraph); + writeControlMessage(); + } + XFlush(dsply); + } + +} /* drawViewport() */ + + + +/************************************ + *** viewPoints *makeViewport() *** + ************************************/ + +viewPoints * +#ifdef _NO_PROTO +makeViewport(title,vX,vY,vW,vH,showCP) + char *title; + int vX,vY,vW,vH,showCP; +#else +makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) +#endif +{ + Pixmap spadbits,spadmask; + XSetWindowAttributes viewAttrib; + XSizeHints titleSizeHints,viewSizeHints; + Window viewTitleWindow,viewGraphWindow; + XColor foreColor, backColor; + +#ifdef DEBUG + fprintf(stderr,"view2D: About to make a viewport\n"); +#endif + + /* Create a viewport */ + if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) { + fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n"); + sleep(5); + exitWithAck(RootWindow(dsply,scrn),Window,-1); + } + +#ifdef DEBUG + fprintf(stderr,"view2D: Made a viewport\n"); +#endif + + strcpy(viewport->title,title); + + viewport->closing = no; + viewport->allowDraw = yes; /* just draw axes the first time around */ + viewport->axesOn = axesON; + viewport->unitsOn = unitsON; + viewport->pointsOn = pointsON; + viewport->linesOn = connectON; + viewport->splineOn = splineON; + + /**** Make the windows for the viewport ****/ + spadbits = XCreateBitmapFromData(dsply,rtWindow, + spadBitmap_bits, + spadBitmap_width,spadBitmap_height); + spadmask = XCreateBitmapFromData(dsply,rtWindow, + spadMask_bits, + spadMask_width,spadMask_height); + viewAttrib.background_pixel = backgroundColor; + viewAttrib.border_pixel = foregroundColor; + viewAttrib.override_redirect = overrideManager; + viewAttrib.colormap = colorMap; + + foreColor.pixel = foregroundColor; + backColor.pixel = backgroundColor; + XQueryColor(dsply,colorMap,&foreColor); + XQueryColor(dsply,colorMap,&backColor); + viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask, + &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); + + viewAttrib.event_mask = titleMASK; + if (vW) { + titleSizeHints.flags = PPosition | PSize; + titleSizeHints.x = vX; + titleSizeHints.y = vY; + titleSizeHints.width = vW; + titleSizeHints.height = vH; + } else { + titleSizeHints.flags = PSize; + titleSizeHints.width = viewWidth; + titleSizeHints.height = viewHeight; + } + + viewTitleWindow = XCreateWindow(dsply,rtWindow,vX,vY,vW,vH, + viewBorderWidth, + CopyFromParent,InputOutput,CopyFromParent, + viewportTitleCreateMASK,&viewAttrib); + + wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False); + (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1); + + XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); + XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 2D",viewport->title, + None,NULL,0,&titleSizeHints); + + viewport->titleWindow = viewTitleWindow; + viewAttrib.event_mask = viewportMASK; + viewSizeHints.flags = PPosition | PSize; + viewSizeHints.x = -viewBorderWidth; + viewSizeHints.y = titleHeight; + viewSizeHints.width = titleSizeHints.width; + viewSizeHints.height = titleSizeHints.height - + (titleHeight + appendixHeight); + viewGraphWindow = XCreateWindow(dsply,viewTitleWindow, + viewSizeHints.x,viewSizeHints.y, + viewSizeHints.width,viewSizeHints.height, + viewBorderWidth, + CopyFromParent,InputOutput,CopyFromParent, + viewportCreateMASK,&viewAttrib); + XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints); + XSetStandardProperties(dsply,viewGraphWindow,"2D Viewport","2D Viewport", + None,NULL,0,&viewSizeHints); + + viewport->viewWindow = viewGraphWindow; + + /*Make the control panel for the viewport. */ + viewport->controlPanel = makeControlPanel(); + if ((viewport->haveControl = showCP)) putControlPanelSomewhere(anywhere); + + XSync(dsply,False); + return(viewport); + +} + + +/********************************************* + ***** viewPoints *makeView2D(viewdata) **** + *********************************************/ + + +viewPoints * +#ifdef _NO_PROTO +makeView2D(viewdata) + view2DStruct *viewdata; +#else +makeView2D(view2DStruct *viewdata) +#endif +{ + viewPoints *vPoints; + + vPoints = makeViewport(viewdata->title, viewdata->vX,viewdata->vY, + viewdata->vW,viewdata->vH,viewdata->showCP); + + vPoints->allowDraw = yes; /* draw everything from now on */ + + if (viewdata->showCP) clearControlMessage(); + + writeTitle(); + + XMapWindow(dsply,vPoints->viewWindow); + XMapWindow(dsply,vPoints->titleWindow); + XSync(dsply,0); + + drawViewport(Xoption); /* draw viewport with X routines (as opposed to PS) */ + return(vPoints); + +} /* makeView2D */ + diff --git a/src/graph/view2D/viewport2D.c.pamphlet b/src/graph/view2D/viewport2D.c.pamphlet deleted file mode 100644 index c1632984..00000000 --- a/src/graph/view2D/viewport2D.c.pamphlet +++ /dev/null @@ -1,733 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D viewport2D} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _VIEWPORT2D_C -#include "axiom-c-macros.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NotPoint (SHRT_MAX) -#define eqNANQ(x) (x == NotPoint) - -#include "header2.h" - -#include "all_2d.H1" -#include "Gfun.H1" -#include "util.H1" -#include "XSpadFill.H1" - -#include "spadBitmap.bitmap" -#include "spadMask.mask" - -#define rint(z) ((int)(z)) - -Atom wm_delete_window; - - -/*************************** - *** void writeTitle() *** - ***************************/ - -void -#ifdef _NO_PROTO -writeTitle() -#else -writeTitle(void) -#endif -{ - - int strlength; - XWindowAttributes attribInfo; - - XGetWindowAttributes(dsply,viewport->titleWindow,&attribInfo); - if (mono) GSetForeground(anotherGC,(float)foregroundColor,Xoption); - else GSetForeground(anotherGC,(float)titleColor,Xoption); - XClearWindow(dsply,viewport->titleWindow); /* it's behind the viewWindow */ - strlength = strlen(viewport->title); - GDrawImageString(anotherGC,viewport->titleWindow, - centerX(anotherGC,viewport->title,strlength,attribInfo.width), - 15,viewport->title,strlength,Xoption); - -} - - -/********************************/ -/*** void drawTheViewport() ***/ -/********************************/ - -void -#ifdef _NO_PROTO -drawTheViewport(dFlag) -int dFlag; /* display flag: X, PS,... */ -#else -drawTheViewport(int dFlag) -#endif -{ - - Window vw; - XWindowAttributes vwInfo; - pointListStruct *aList; - pointStruct *aPoint; - XPoint *anXPoint,*tempXpt; - XArc *anXarc; - Vertex *anX10Point; - float jj,diffX, diffY, tickStart,oneTickUnit; - int i,j,k,ii,halfSize; - int charlength,strlength,halflength,halfheight; - int ptX,ptY,ptX1,ptY1,clipped, clipped1; - int xAxis,yAxis,dummyInt, ascent, descent; - int unitWidth,boxX,boxY,boxW,boxH; - char aunit[20]; - XCharStruct overall; - - drawMore = yes; - vw = viewport->viewWindow; - XGetWindowAttributes(dsply,vw,&vwInfo); - aspectR = (float)vwInfo.width/(float)vwInfo.height; - - XTextExtents(unitFont,"o",1,&dummyInt,&ascent,&descent,&overall); - halfheight = (ascent + descent) / 2; - - /* Calculate various factors for use in projection. */ - /* Scale the plot, so that the scaling between the axes remains - constant and fits within the smaller of the two dimensions. */ - - charlength = overall.width; - - if (dFlag==Xoption) XClearWindow(dsply,vw); - - for (i=0; i=0) && (yAxis <= vwInfo.height)) - GDrawLine(globalGC1,vw, - 0,yAxis, - vwInfo.width,yAxis, - dFlag); - if ((xAxis >=0) && (xAxis <= vwInfo.width)) - GDrawLine(globalGC1,vw, - xAxis,0, - xAxis,vwInfo.height, - dFlag); - } - - - tempXpt = anXPoint = xPointsArray[i].xPoint; - anX10Point = xPointsArray[i].x10Point; - anXarc = xPointsArray[i].arc; - - for (j=0,aList=graphArray[i].listOfListsOfPoints; - (jlistOfPoints; - (knumberOfPoints); - k++,aPoint++) { - - if (graphStateArray[i].scaleX > 99.0) - graphStateArray[i].scaleX = 99.0; - if (graphStateArray[i].scaleY > 99.0) - graphStateArray[0].scaleY = 99.0; - if (i > 0) { - if (isNaN(aPoint->x)) { - anXPoint->x = anX10Point->x = NotPoint; - } - else { - diffX = graphArray[i].xmax-graphArray[i].xmin; - anXPoint->x = anX10Point->x = vwInfo.width * - ((aPoint->x * diffX/(graphArray[0].xmax-graphArray[0].xmin) - + (graphArray[0].originX - graphArray[i].originX*diffX / - (graphArray[0].xmax-graphArray[0].xmin)) - - graphStateArray[0].centerX)*graphStateArray[i].scaleX+0.5); - } - if (isNaN(aPoint->y)) { - anXPoint->y = anX10Point->y = NotPoint; - } - else { - diffY = graphArray[i].ymax-graphArray[i].ymin; - anXPoint->y = anX10Point->y = vwInfo.height * aspectR * - (1 - ((aPoint->y * diffY/(graphArray[0].ymax-graphArray[0].ymin) - + (graphArray[0].originY - graphArray[i].originY* diffY/ - (graphArray[0].ymax-graphArray[0].ymin))*aspectR - - graphStateArray[0].centerY) * - graphStateArray[i].scaleY + 0.5*aspectR)); - } - } else { - if (isNaN(aPoint->x)) { - anXPoint->x = anX10Point->x = NotPoint; - } - else { - anXPoint->x = anX10Point->x = vwInfo.width * - ((aPoint->x - graphStateArray[i].centerX) * - graphStateArray[i].scaleX + 0.5); - } - if (isNaN(aPoint->y)) { - anXPoint->y = anX10Point->y = NotPoint; - } - else { - anXPoint->y = anX10Point->y = vwInfo.height * aspectR * - (1 - ((aPoint->y - graphStateArray[i].centerY) * - graphStateArray[i].scaleY + 0.5*aspectR)); - } - } - - /* first or last point */ - if (k == 0 || k == (aList->numberOfPoints - 1)) { - anX10Point->flags = 0; - } else { - anX10Point->flags = VertexCurved; - } - - anXPoint++; - anX10Point++; - anXarc++; - } /* for aPoint in pointList */ - - aPoint--; /* make it legal, the last one*/ - if (graphStateArray[i].connectOn || graphStateArray[i].pointsOn) { - halfSize = aList->pointSize/2; - ptX = tempXpt->x; - ptY = tempXpt->y; - clipped = ptX > vwInfo.x && ptX < vwInfo.width && - ptY > 0 && ptY < vwInfo.height; - if (graphStateArray[i].pointsOn) { - if (dFlag==Xoption) { - if (mono) { - GSetForeground(globalGC1, - (float)monoColor((int)(aPoint->hue)), - dFlag); - } else { - GSetForeground(globalGC1, - (float)XSolidColor((int)(aPoint->hue), - (int)(aPoint->shade)), - dFlag); - } - } - if (clipped && !eqNANQ(ptX) && !eqNANQ(ptY)) - GFillArc(globalGC1,vw,ptX-halfSize, - ptY-halfSize,aList->pointSize,aList->pointSize, - 0,360*64, dFlag); - - } /* if points on */ - for (ii=0, aPoint=aList->listOfPoints; - iinumberOfPoints; - ++ii, ++tempXpt, ++aPoint) { - ptX1 = tempXpt->x; - ptY1 = tempXpt->y; - clipped1 = ptX1 > vwInfo.x && ptX1 < vwInfo.width && - ptY1 > 0 && ptY1 < vwInfo.height; - if (graphStateArray[i].connectOn) { - if (dFlag==Xoption) { - if (mono) { - GSetForeground(globalGC1, - (float)monoColor((int)(aList->lineColor-1)/5), - dFlag); - } else { - GSetForeground(globalGC1, - (float)XSolidColor((int)(aList->lineColor-1)/5, - (int)((aList->lineColor-1)%5)/2), - dFlag); - } - } /* if X */ - if ((clipped || clipped1) && !eqNANQ(ptX) && !eqNANQ(ptY) && - !eqNANQ(ptX1) && !eqNANQ(ptY1)) - GDrawLine(globalGC1,vw, - ptX,ptY,ptX1,ptY1, - dFlag); - } /* if lines on */ - if (graphStateArray[i].pointsOn) { - if (dFlag==Xoption) { - if (mono) { - GSetForeground(globalGC1, - (float)monoColor((int)(aPoint->hue)), - dFlag); - } else { - GSetForeground(globalGC1, - (float)XSolidColor((int)(aPoint->hue), - (int)(aPoint->shade)), - dFlag); - } - } - if (clipped1 && !eqNANQ(ptX1) && !eqNANQ(ptY1)) - GFillArc(globalGC1,vw,ptX1-halfSize, - ptY1-halfSize,aList->pointSize,aList->pointSize, - 0,360*64, dFlag); - } /* if points on */ - ptX = ptX1; ptY = ptY1; clipped = clipped1; - } /* for all points */ - } /* if points or lines on */ - - if (graphStateArray[i].splineOn) { /* need spline color as well */ - if (dFlag==Xoption) /* do only for X, ps uses default of black */ - GSetForeground(globalGC1, - (float)monoColor(148), - dFlag); - boxX = vwInfo.width * - ((-0.5 - graphStateArray[i].centerX)* - graphStateArray[i].scaleX + 0.5); - boxY = vwInfo.height * aspectR * - (1 - ((0.5 - graphStateArray[i].centerY)* - graphStateArray[i].scaleY + 0.5*aspectR)); - - boxW = graphStateArray[i].scaleX * vwInfo.width + 1; - boxH = graphStateArray[i].scaleY * vwInfo.height * aspectR + 1; - - GDrawRectangle(globalGC1,vw, - boxX,boxY,boxW,boxH, - dFlag); - } - - tempXpt = anXPoint; - } /* for a aList in listofListsOfPoints */ - if (graphStateArray[i].unitsOn) { - /* do only for X, ps uses default of black */ - if (dFlag==Xoption) - GSetForeground(unitGC, - (float)monoColor(graphStateArray[i].unitsColor), - dFlag); - - - tickStart = calcUnitX(0); - oneTickUnit = calcUnitX(1) - tickStart; - - /* ticks along the positive X axis */ - - unitWidth = 5*overall.width; /* limit on acceptable separation : 5 chars */ - k = floor(unitWidth/oneTickUnit) +1; /* get skipping integer */ - for (ii=0, jj = tickStart; - jj < vwInfo.width; - ii=ii+k,jj =jj+k* oneTickUnit) { - if (jj >= 0) { - - /* ticks stuck to viewport*/ - GDrawLine(unitGC,vw, - (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); - strlength=strlen(aunit); - halflength=XTextWidth(unitFont,aunit,strlength)/2; - - if (dFlag == Xoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) - halflength, - vwInfo.height -8 -descent, - aunit, - strlength, - dFlag); - if (dFlag == PSoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) -(strlength*3) , - vwInfo.height -14, - aunit, - strlength, - dFlag); - /* these are "eyeball" parameters for the given PS font */ - - } - - } - /* ticks along the negative X axis */ - for (ii=-k,jj=tickStart - k*oneTickUnit; - jj > 0; - ii=ii-k,jj = jj-k*oneTickUnit) { - if (jj <= vwInfo.width) { - - /* ticks stuck to viewport*/ - GDrawLine(unitGC,vw, - (int)rint(jj),vwInfo.height-8,(int)rint(jj),vwInfo.height-4, - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitX); - strlength=strlen(aunit); - halflength=XTextWidth(unitFont,aunit,strlength)/2; - - if (dFlag == Xoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) - halflength, - vwInfo.height -8 -descent, - aunit, - strlength, - dFlag); - if (dFlag == PSoption) GDrawImageString(unitGC, - vw, - (int)rint(jj) -(strlength*3) , - vwInfo.height -14, - aunit, - strlength, - dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } - - tickStart = calcUnitY(0); - oneTickUnit = calcUnitY(1) - tickStart; - - /* ticks along the positive Y axis */ - unitWidth = 2*(ascent+descent); /* limit of acceptable separation */ - k = floor(unitWidth/fabs(oneTickUnit)) +1; /* get skipping integer */ - for (ii=0,jj = tickStart; - jj > 0; - ii=ii+k,jj =jj+k*oneTickUnit ) { - if (jj < vwInfo.height) { - - /* ticks stuck to viewport*/ - /* on the right */ - /* - GDrawLine(unitGC,vw, - vwInfo.width-6,(int)rint(jj), - vwInfo.width-2,(int)rint(jj),dFlag); - */ - /* on the left */ - GDrawLine(unitGC,vw, - 2,(int)rint(jj), - 6,(int)rint(jj), - dFlag); - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); - strlength=strlen(aunit); - XTextExtents(unitFont,aunit,strlength,&dummyInt, - &ascent,&descent,&overall); - halflength=overall.width; /* let's reuse that variable */ - - if(dFlag == Xoption){ - /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width-halflength -6-descent, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - */ - /* on the left */ - GDrawImageString(unitGC, vw, - 8 + charlength/2, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - } - if(dFlag == PSoption){ - /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width - 6 - (strlength*6), - (int)rint(jj)+4, - aunit, strlength, dFlag); - */ - /* on the left */ - GDrawImageString(unitGC, vw, - 8,(int)rint(jj)+4, - aunit, strlength, dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } - } - - /* ticks along the negative Y axis */ - - for (ii=(-k),jj = tickStart - k*oneTickUnit; - jj < vwInfo.height; - ii=ii-k,jj =jj-k*oneTickUnit) { - if (jj > 0) { - - /* ticks stuck to viewport*/ - /* on the right */ - /* - GDrawLine(unitGC,vw, - vwInfo.width-6,(int)rint(jj), - vwInfo.width-2,(int)rint(jj), - dFlag); - */ - /* on the left */ - GDrawLine(unitGC,vw, - 2,(int)rint(jj), - 6,(int)rint(jj), - dFlag); - - sprintf(aunit,"%0.3g",ii*graphArray[0].spadUnitY); - strlength=strlen(aunit); - XTextExtents(unitFont,aunit,strlength,&dummyInt, - &ascent,&descent,&overall); - halflength=overall.width; /* let's reuse that variable */ - - if(dFlag == Xoption){ - /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width-halflength -6-descent, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - */ - /* on the left */ - GDrawImageString(unitGC, vw, - 8 + charlength/2, - (int)rint(jj)+ascent/2 , - aunit, strlength, dFlag); - } - if(dFlag == PSoption){ - /* on the right */ - /* - GDrawImageString(unitGC, vw, - vwInfo.width -6 -(strlength*6), - (int)rint(jj)+4 , - aunit, strlength, dFlag); - */ - /* on the left */ - GDrawImageString(unitGC, vw, - 8, - (int)rint(jj)+4 , - aunit, strlength, dFlag); - /* these are "eyeball" parameters for the given PS font */ - } - } - } - - } /* if unitsOn */ - } /* if graph i exists and is showing */ - } /* for i in graphs */ - - - if (dFlag==Xoption) { - if (!followMouse) { - /* no need to do this while autorepeating */ - makeMessageFromData(queriedGraph); - writeControlMessage(); - } - XFlush(dsply); - } - -} /* drawViewport() */ - - - -/************************************ - *** viewPoints *makeViewport() *** - ************************************/ - -viewPoints * -#ifdef _NO_PROTO -makeViewport(title,vX,vY,vW,vH,showCP) - char *title; - int vX,vY,vW,vH,showCP; -#else -makeViewport(char *title,int vX,int vY,int vW,int vH,int showCP) -#endif -{ - Pixmap spadbits,spadmask; - XSetWindowAttributes viewAttrib; - XSizeHints titleSizeHints,viewSizeHints; - Window viewTitleWindow,viewGraphWindow; - XColor foreColor, backColor; - -#ifdef DEBUG - fprintf(stderr,"view2D: About to make a viewport\n"); -#endif - - /* Create a viewport */ - if (!(viewport = (viewPoints *)malloc(sizeof(viewPoints)))) { - fprintf(stderr,"Ran out of memory (malloc) trying to create a viewport.\n"); - sleep(5); - exitWithAck(RootWindow(dsply,scrn),Window,-1); - } - -#ifdef DEBUG - fprintf(stderr,"view2D: Made a viewport\n"); -#endif - - strcpy(viewport->title,title); - - viewport->closing = no; - viewport->allowDraw = yes; /* just draw axes the first time around */ - viewport->axesOn = axesON; - viewport->unitsOn = unitsON; - viewport->pointsOn = pointsON; - viewport->linesOn = connectON; - viewport->splineOn = splineON; - - /**** Make the windows for the viewport ****/ - spadbits = XCreateBitmapFromData(dsply,rtWindow, - spadBitmap_bits, - spadBitmap_width,spadBitmap_height); - spadmask = XCreateBitmapFromData(dsply,rtWindow, - spadMask_bits, - spadMask_width,spadMask_height); - viewAttrib.background_pixel = backgroundColor; - viewAttrib.border_pixel = foregroundColor; - viewAttrib.override_redirect = overrideManager; - viewAttrib.colormap = colorMap; - - foreColor.pixel = foregroundColor; - backColor.pixel = backgroundColor; - XQueryColor(dsply,colorMap,&foreColor); - XQueryColor(dsply,colorMap,&backColor); - viewAttrib.cursor = XCreatePixmapCursor(dsply,spadbits,spadmask, - &foreColor,&backColor,spadBitmap_x_hot,spadBitmap_y_hot); - - viewAttrib.event_mask = titleMASK; - if (vW) { - titleSizeHints.flags = PPosition | PSize; - titleSizeHints.x = vX; - titleSizeHints.y = vY; - titleSizeHints.width = vW; - titleSizeHints.height = vH; - } else { - titleSizeHints.flags = PSize; - titleSizeHints.width = viewWidth; - titleSizeHints.height = viewHeight; - } - - viewTitleWindow = XCreateWindow(dsply,rtWindow,vX,vY,vW,vH, - viewBorderWidth, - CopyFromParent,InputOutput,CopyFromParent, - viewportTitleCreateMASK,&viewAttrib); - - wm_delete_window = XInternAtom(dsply, "WM_DELETE_WINDOW", False); - (void) XSetWMProtocols(dsply, viewTitleWindow, &wm_delete_window, 1); - - XSetNormalHints(dsply,viewTitleWindow,&titleSizeHints); - XSetStandardProperties(dsply,viewTitleWindow,"AXIOM 2D",viewport->title, - None,NULL,0,&titleSizeHints); - - viewport->titleWindow = viewTitleWindow; - viewAttrib.event_mask = viewportMASK; - viewSizeHints.flags = PPosition | PSize; - viewSizeHints.x = -viewBorderWidth; - viewSizeHints.y = titleHeight; - viewSizeHints.width = titleSizeHints.width; - viewSizeHints.height = titleSizeHints.height - - (titleHeight + appendixHeight); - viewGraphWindow = XCreateWindow(dsply,viewTitleWindow, - viewSizeHints.x,viewSizeHints.y, - viewSizeHints.width,viewSizeHints.height, - viewBorderWidth, - CopyFromParent,InputOutput,CopyFromParent, - viewportCreateMASK,&viewAttrib); - XSetNormalHints(dsply,viewGraphWindow,&viewSizeHints); - XSetStandardProperties(dsply,viewGraphWindow,"2D Viewport","2D Viewport", - None,NULL,0,&viewSizeHints); - - viewport->viewWindow = viewGraphWindow; - - /*Make the control panel for the viewport. */ - viewport->controlPanel = makeControlPanel(); - if ((viewport->haveControl = showCP)) putControlPanelSomewhere(anywhere); - - XSync(dsply,False); - return(viewport); - -} - - -/********************************************* - ***** viewPoints *makeView2D(viewdata) **** - *********************************************/ - - -viewPoints * -#ifdef _NO_PROTO -makeView2D(viewdata) - view2DStruct *viewdata; -#else -makeView2D(view2DStruct *viewdata) -#endif -{ - viewPoints *vPoints; - - vPoints = makeViewport(viewdata->title, viewdata->vX,viewdata->vY, - viewdata->vW,viewdata->vH,viewdata->showCP); - - vPoints->allowDraw = yes; /* draw everything from now on */ - - if (viewdata->showCP) clearControlMessage(); - - writeTitle(); - - XMapWindow(dsply,vPoints->viewWindow); - XMapWindow(dsply,vPoints->titleWindow); - XSync(dsply,0); - - drawViewport(Xoption); /* draw viewport with X routines (as opposed to PS) */ - return(vPoints); - -} /* makeView2D */ - -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} diff --git a/src/graph/view2D/write2d.c b/src/graph/view2D/write2d.c new file mode 100644 index 00000000..7a00fc68 --- /dev/null +++ b/src/graph/view2D/write2d.c @@ -0,0 +1,205 @@ +/* + Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical ALgorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _WRITE2D_C +#include "axiom-c-macros.h" + +#include +#include + +#include "header2.h" +#include "write.h" + +#include "all_2d.H1" +#include "pixmap.H1" +#include "Gfun.H1" + + +#define numBits (8*sizeof(int)) + +int +#ifdef _NO_PROTO +writeViewport(thingsToWrite) + int thingsToWrite; +#else +writeViewport(int thingsToWrite) +#endif +{ + + FILE *viewDataFile; + char viewDirName[80], + viewBitmapFilename[80],viewDataFilename[80],command[80]; + int i,j,k,code,ii; + pointListStruct *aList; + pointStruct *aPoint; + XWindowAttributes vwInfo; + + XGetWindowAttributes(dsply,viewport->titleWindow,&vwInfo); + sprintf(viewDirName,"%s%s",filename,".VIEW"); + sprintf(command,"%s%s%s","rm -r ",viewDirName," > /dev/null 2>&1"); + code = system(command); + sprintf(command,"%s%s%s","mkdir ",viewDirName," > /dev/null 2>&1"); + if (system(command)) { + fprintf(stderr," Error: Cannot create %s\n",viewDirName); + return(-1); + } else { + /*** Create the data file ***/ + sprintf(viewDataFilename,"%s%s",viewDirName,"/data"); + if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) { + fprintf(stderr," Error: Cannot create %s\n",viewDataFilename); + perror("fopen"); + return(-1); + } else { + /*** write out the view2DStruct stuff ***/ + fprintf(viewDataFile,"%d\n",view2DType); + fprintf(viewDataFile,"%s\n",viewport->title); + fprintf(viewDataFile,"%d %d %d %d\n",vwInfo.x,vwInfo.y, + vwInfo.width,vwInfo.height); + for (i=0; inumberOfPoints); + fprintf(viewDataFile,"%d %d %d\n", + aList->pointColor,aList->lineColor,aList->pointSize); + for (k=0,aPoint=aList->listOfPoints; + knumberOfPoints; + k++,aPoint++) + fprintf(viewDataFile,"%g %g %g %g\n", + aPoint->x,aPoint->y,aPoint->hue,aPoint->shade); + } /* for j, aList */ + fclose(viewDataFile); + } /* else graph i */ + } /* if */ + } /* for */ + } /* else */ + + /* write out special files */ + for (ii=1; iiviewWindow,&vwInfo); + write_pixmap_file(dsply,scrn,viewBitmapFilename, + viewport->titleWindow,0,0,vwInfo.width, + vwInfo.height+titleHeight); + break; + case Bitmap: + /*** Create the bitmap (bitmaps need leaf name) ***/ + sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm"); + XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); + code = XWriteBitmapFile(dsply,viewBitmapFilename, + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); + break; + case Image: + /*** Create the pixmap (bitmaps need leaf name) ***/ + sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm"); + XResizeWindow(dsply,viewport->titleWindow,300,300+titleHeight); + XResizeWindow(dsply,viewport->viewWindow,300,300); + XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); + drawViewport(Xoption); + writeTitle(); + write_pixmap_file(dsply,scrn,viewBitmapFilename, + viewport->titleWindow,0,0,vwInfo.width, + vwInfo.height+titleHeight); + /*** Create the bitmap (bitmaps need leaf name) ***/ + mono = 1; + drawViewport(Xoption); + writeTitle(); + sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); + code = XWriteBitmapFile(dsply,viewBitmapFilename, + viewport->titleWindow,vwInfo.width, + vwInfo.height+vwInfo.border_width+20,-1,-1); + mono = 0; + break; + + case Postscript: + /*** Create postscript output for viewport (in axiom2D.ps) ***/ + sprintf(PSfilename,"%s%s",viewDirName,"/axiom2D.ps"); + if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) + return (-1); + drawViewport(PSoption); /* write new script file in /tmp */ + if (PSCreateFile(viewBorderWidth,viewport->viewWindow, + viewport->titleWindow, viewport->title) == psError) + return(-1); /* concat script & proc into axiom2D.ps */ + break; + + } /* switch on ii */ + } /* if thingsToWrite >> ii */ + } /* for ii */ + + return(0); + } /* else create directory okay */ + +} diff --git a/src/graph/view2D/write2d.c.pamphlet b/src/graph/view2D/write2d.c.pamphlet deleted file mode 100644 index 66eafe26..00000000 --- a/src/graph/view2D/write2d.c.pamphlet +++ /dev/null @@ -1,225 +0,0 @@ -\documentclass{article} -\usepackage{axiom} -\begin{document} -\title{\$SPAD/src/graph/view2D write2d.c} -\author{The Axiom Team} -\maketitle -\begin{abstract} -\end{abstract} -\eject -\tableofcontents -\eject -\section{License} -<>= -/* -Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical ALgorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -@ -<<*>>= -<> - -#define _WRITE2D_C -#include "axiom-c-macros.h" - -#include -#include - -#include "header2.h" -#include "write.h" - -#include "all_2d.H1" -#include "pixmap.H1" -#include "Gfun.H1" - - -#define numBits (8*sizeof(int)) - -int -#ifdef _NO_PROTO -writeViewport(thingsToWrite) - int thingsToWrite; -#else -writeViewport(int thingsToWrite) -#endif -{ - - FILE *viewDataFile; - char viewDirName[80], - viewBitmapFilename[80],viewDataFilename[80],command[80]; - int i,j,k,code,ii; - pointListStruct *aList; - pointStruct *aPoint; - XWindowAttributes vwInfo; - - XGetWindowAttributes(dsply,viewport->titleWindow,&vwInfo); - sprintf(viewDirName,"%s%s",filename,".VIEW"); - sprintf(command,"%s%s%s","rm -r ",viewDirName," > /dev/null 2>&1"); - code = system(command); - sprintf(command,"%s%s%s","mkdir ",viewDirName," > /dev/null 2>&1"); - if (system(command)) { - fprintf(stderr," Error: Cannot create %s\n",viewDirName); - return(-1); - } else { - /*** Create the data file ***/ - sprintf(viewDataFilename,"%s%s",viewDirName,"/data"); - if ((viewDataFile = fopen(viewDataFilename,"w")) == NULL) { - fprintf(stderr," Error: Cannot create %s\n",viewDataFilename); - perror("fopen"); - return(-1); - } else { - /*** write out the view2DStruct stuff ***/ - fprintf(viewDataFile,"%d\n",view2DType); - fprintf(viewDataFile,"%s\n",viewport->title); - fprintf(viewDataFile,"%d %d %d %d\n",vwInfo.x,vwInfo.y, - vwInfo.width,vwInfo.height); - for (i=0; inumberOfPoints); - fprintf(viewDataFile,"%d %d %d\n", - aList->pointColor,aList->lineColor,aList->pointSize); - for (k=0,aPoint=aList->listOfPoints; - knumberOfPoints; - k++,aPoint++) - fprintf(viewDataFile,"%g %g %g %g\n", - aPoint->x,aPoint->y,aPoint->hue,aPoint->shade); - } /* for j, aList */ - fclose(viewDataFile); - } /* else graph i */ - } /* if */ - } /* for */ - } /* else */ - - /* write out special files */ - for (ii=1; iiviewWindow,&vwInfo); - write_pixmap_file(dsply,scrn,viewBitmapFilename, - viewport->titleWindow,0,0,vwInfo.width, - vwInfo.height+titleHeight); - break; - case Bitmap: - /*** Create the bitmap (bitmaps need leaf name) ***/ - sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.bm"); - XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); - code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); - break; - case Image: - /*** Create the pixmap (bitmaps need leaf name) ***/ - sprintf(viewBitmapFilename,"%s%s",viewDirName,"/image.xpm"); - XResizeWindow(dsply,viewport->titleWindow,300,300+titleHeight); - XResizeWindow(dsply,viewport->viewWindow,300,300); - XGetWindowAttributes(dsply,viewport->viewWindow,&vwInfo); - drawViewport(Xoption); - writeTitle(); - write_pixmap_file(dsply,scrn,viewBitmapFilename, - viewport->titleWindow,0,0,vwInfo.width, - vwInfo.height+titleHeight); - /*** Create the bitmap (bitmaps need leaf name) ***/ - mono = 1; - drawViewport(Xoption); - writeTitle(); - sprintf(viewBitmapFilename,"%s%s%s",viewDirName,"/","image.bm"); - code = XWriteBitmapFile(dsply,viewBitmapFilename, - viewport->titleWindow,vwInfo.width, - vwInfo.height+vwInfo.border_width+20,-1,-1); - mono = 0; - break; - - case Postscript: - /*** Create postscript output for viewport (in axiom2D.ps) ***/ - sprintf(PSfilename,"%s%s",viewDirName,"/axiom2D.ps"); - if (PSInit(viewport->viewWindow,viewport->titleWindow) == psError) - return (-1); - drawViewport(PSoption); /* write new script file in /tmp */ - if (PSCreateFile(viewBorderWidth,viewport->viewWindow, - viewport->titleWindow, viewport->title) == psError) - return(-1); /* concat script & proc into axiom2D.ps */ - break; - - } /* switch on ii */ - } /* if thingsToWrite >> ii */ - } /* for ii */ - - return(0); - } /* else create directory okay */ - -} -@ -\eject -\begin{thebibliography}{99} -\bibitem{1} nothing -\end{thebibliography} -\end{document} -- cgit v1.2.3