diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index 7b7a501efc210f71d6ca1b156f94993910f3bf0a..b50d7ee9b492990711e2bf7d4b1f66fca73f2ddf 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -4,7 +4,7 @@ #add_subdirectory(ps) set(SOURCES ugdevices.cc sockcomm.cc - ppm/ppm.cc meta/metafile.cc ps/postscript.cc ps/postscriptbw.cc) + ppm/ppm.cc meta/metafile.cc) set(devinclude_HEADERS ugdevices.h) add_library(devices OBJECT ${SOURCES}) @@ -16,11 +16,4 @@ if(DUNE_BUILD_BOTH_LIBS) set_property(TARGET devices devSif PROPERTY POSITION_INDEPENDENT_CODE TRUE) endif() add_library(devR ${SOURCES} rif/remote.cc) -if(X11_FOUND) - add_library(devX xif/xmain.cc xif/xgraph.cc xif/xshell.cc - $<TARGET_OBJECTS:devices>) - target_compile_definitions(devX PRIVATE "-DUG_DIM_2") - target_link_libraries(devX "${X11_LIBRARIES}") - install(TARGETS devX DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(X11_FOUND) install(FILES ${devinclude_HEADERS} DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR}) diff --git a/dev/ps/.gitignore b/dev/ps/.gitignore deleted file mode 100644 index 9a196b32e949c1a865a1609720cb3852f2f7e9e7..0000000000000000000000000000000000000000 --- a/dev/ps/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.lo -*.la -*.o - -semantic.cache diff --git a/dev/ps/postscript.cc b/dev/ps/postscript.cc deleted file mode 100644 index 1e11e6bcc33c607c2f52c7b11c52e7ebf8ad96ac..0000000000000000000000000000000000000000 --- a/dev/ps/postscript.cc +++ /dev/null @@ -1,986 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: postscript.c */ -/* */ -/* Purpose: write graphics postscript files */ -/* */ -/* Author: Henrik Rentz-Reichert */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 07.05.96 begin, ug version 3.2 */ -/* */ -/* Remarks: used most of the code of m2ps by P. Bastian */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstddef> -#include <cstring> -#include <cstdio> -#include <cstdlib> -#include <cmath> -#include <ctime> - -#include "defaults.h" -#include "fileopen.h" -#include "ugdevices.h" -#include "initdev.h" -#include "general.h" - -USING_UG_NAMESPACE - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define TEXTSIZE 8 - -#define CREATOR "ug postscript output" - - -/* postscript defaults */ -#define PS_DEFAULT_LINE_WIDTH 1 -#define PS_DEFAULT_FONT "Monaco" -#define PS_FONT_FACTOR 10 -#define LW_FACTOR 0.03 -#define LW_SCALE 50.0 -#define PAPER_X 600 -#define PAPER_Y 850 - -#define REL_CHARWIDTH 0.7 - -#define COLORS 256 -#define GRAY 0.5 -#define GRAY_CC (~(short)0) - -#define TRFMX(pt) (((float)(pt.x))*mxx + ((float)(pt.y))*mxy + tx) -#define TRFMY(pt) (((float)(pt.x))*myx + ((float)(pt.y))*myy + ty) - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -typedef struct { - - FILE *psfile; /* output file */ - - short landscape; /* landscape format */ - - /* transformation */ - float tx,ty; /* translation */ - float mxx,mxy,myx,myy; /* matrix */ - - short PSmarker; - short PSmarkersize; - SHORT_POINT PScp; - short PSlw; - short PSts; - short PScc; -} PSWINDOW ; - -static OUTPUTDEVICE *PSOutputDevice=NULL; /* outputdevice that has been ini*/ -static PSWINDOW *currPSW=NULL; /* current postscript window */ -static FILE *currPSF; /* current postscript file */ -static short PSmarker; -static short PSmarkersize; - -static SHORT_POINT PScp; -static short PSlw, PSts; -static short PScc; -static float tx,ty,mxx,myy,mxy,myx; -static short landscape; - -/* static color table for all postscript files */ -static float red[COLORS]; -static float green[COLORS]; -static float blue[COLORS]; - - -/****************************************************************************/ -/* */ -/* forward declarations of functions used before they are defined */ -/* */ -/****************************************************************************/ - -static void PSDefaultValues( PSWINDOW *psw ) -{ - currPSW = psw; - - currPSW->psfile = currPSF = NULL; - currPSW->landscape = landscape = 0; - currPSW->tx = tx = 0.0; - currPSW->ty = ty = 0.0; - currPSW->mxx = mxx = 0.0; - currPSW->mxy = mxy = 0.0; - currPSW->myx = myx = 0.0; - currPSW->myy = myy = 0.0; - currPSW->PSmarker = PSmarker = 0; - currPSW->PSmarkersize = PSmarkersize = 1; - currPSW->PScp.x = PScp.x = 0; - currPSW->PScp.y = PScp.y = 0; - currPSW->PSlw = PSlw = -1; - currPSW->PSts = PSts = -1; - currPSW->PScc = PScc = 0; -} - -static void PSMoveTo (SHORT_POINT point) -{ - currPSW->PScp.x = PScp.x = point.x; currPSW->PScp.y = PScp.y = point.y; - return; -} - -static void PSDrawTo (SHORT_POINT point) -{ - fprintf(currPSF,"%g %g M %g %g S\n", - TRFMX(PScp),TRFMY(PScp),TRFMX(point),TRFMY(point)); - currPSW->PScp.x = PScp.x = point.x; currPSW->PScp.y = PScp.y = point.y; - return; -} - -static void PSCircle (SHORT_POINT point, short r) -{ - short xr,yr; - - xr = mxy*r; - yr = myy*r; - r = sqrt(xr*xr+yr*yr); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(point)+r,TRFMY(point)); - fprintf(currPSF,"%g %g %g %g %g arc\n",TRFMX(point),TRFMY(point),(float)r,(float)0,(float)360); - - fprintf(currPSF,"stroke\n"); - - return; -} - -static void PSFilledCircle (SHORT_POINT point, short r) -{ - short xr,yr; - - xr = mxy*r; - yr = myy*r; - r = sqrt(xr*xr+yr*yr); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(point)+r,TRFMY(point)); - fprintf(currPSF,"%g %g %g %g %g arc\n",TRFMX(point),TRFMY(point),(float)r,(float)0,(float)360); - - fprintf(currPSF,"C\n"); - - return; -} - -static void PSPolyline (SHORT_POINT *points, INT nb) -{ - int i; - - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"stroke\n"); - - return; -} - -static void PSPolygon (SHORT_POINT *points, INT nb) -{ - int i; - - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"C\n"); - - return; -} - -static void PSShadedPolygon(SHORT_POINT *points, INT nb, DOUBLE intensity) -{ - int i; - - fprintf(currPSF,"%4.3f I\n",intensity); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"C\n"); - currPSW->PScc = PScc = -1; -} - -static void PSInversePolygon (SHORT_POINT *points, INT nb) -{ - return; -} - -static void PSPrintColor (float color) -{ - if (color==0.0) fprintf(currPSF,"%d ",0); - else if (color==1.0) fprintf(currPSF,"%d ",1); - else fprintf(currPSF,"%.3f ",color); - return; -} - -static void PSErasePolygon (SHORT_POINT *points, INT nb) -{ - long saved; - - saved = PScc; - PSPrintColor(1.0); - PSPrintColor(1.0); - PSPrintColor(1.0); - fprintf(currPSF,"R\n"); - PSPolygon(points,nb); - PSPrintColor((float)red[PScc]); - PSPrintColor((float)green[PScc]); - PSPrintColor((float)blue[PScc]); - fprintf(currPSF,"R\n"); - - return; -} - -static void PSGrayForeground (void) -{ - if (PScc==GRAY_CC) return; - - fprintf(currPSF,"%.1f %.1f %.1f R\n",GRAY,GRAY,GRAY); - currPSW->PScc = PScc = GRAY_CC; - return; -} - -static void PSForeground (long index) -{ - if (PScc==index) return; - - PSPrintColor((float)red[index]); - PSPrintColor((float)green[index]); - PSPrintColor((float)blue[index]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = index; - return; -} - -static void PSMarker (short n, short s, SHORT_POINT point) -{ - short top, left, bottom, right; - SHORT_POINT points[10],pt; - unsigned long cc; - - s = s/2; - - top = point.y+s; bottom = point.y-s; - left = point.x-s; right = point.x+s; - - n = n%NMARKERS; - - switch (n) - { - case EMPTY_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - points[4].x = left; points[4].y = bottom; - PSPolyline(points,5); - break; - case GRAY_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - cc = PScc; - PSGrayForeground(); - PSPolygon(points,4); - PSForeground(cc); - break; - case FILLED_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - PSPolygon(points,4); - break; - case EMPTY_CIRCLE_MARKER : - PSCircle(point,s); - break; - case GRAY_CIRCLE_MARKER : - PSGrayForeground(); - PSFilledCircle(point,s); - cc = PScc; - PSForeground(cc); - break; - case FILLED_CIRCLE_MARKER : - PSFilledCircle(point,s); - break; - case EMPTY_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - points[4].x = point.x; points[4].y = bottom; - PSPolyline(points,5); - break; - case GRAY_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - cc = PScc; - PSGrayForeground(); - PSPolygon(points,4); - PSForeground(cc); - break; - case FILLED_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - PSPolygon(points,4); - break; - case PLUS_MARKER : - pt.x = point.x; pt.y = bottom; - PSMoveTo(pt); - pt.x = point.x; pt.y = top; - PSDrawTo(pt); - pt.x = right; pt.y = point.y; - PSMoveTo(pt); - pt.x = left; pt.y = point.y; - PSDrawTo(pt); - break; - case CROSS_MARKER : - pt.x = left; pt.y = bottom; - PSMoveTo(pt); - pt.x = right; pt.y = top; - PSDrawTo(pt); - pt.x = right; pt.y = bottom; - PSMoveTo(pt); - pt.x = left; pt.y = top; - PSDrawTo(pt); - break; - } -} - -static void PSPolymark (short n, SHORT_POINT *points) -{ - int i; - - for (i=0; i<n; i++) - PSMarker(PSmarker,PSmarkersize,points[i]); - - return; -} - -static void PSInvPolymark (short n, SHORT_POINT *points) -{} - -static void PrintPSString (const char *s) -{ - fputc('(',currPSF); - - while (*s != '\0') - { - switch (*s) - { - case '\\' : - case '(' : - case ')' : fputc('\\',currPSF); - default : fputc(*s,currPSF); - } - s++; - } - fputc(')',currPSF); -} - -static void PSDrawText (const char *s, INT mode) -{ - fprintf(currPSF,"%g %g M\n",TRFMX(PScp),TRFMY(PScp)); - if (landscape) fprintf(currPSF,"90 rotate\n"); - PrintPSString(s); - fprintf(currPSF," show N\n"); - if (landscape) fprintf(currPSF,"-90 rotate\n"); - return; -} - -static void PSCenteredText (SHORT_POINT point, const char *s, INT mode) -{ - /* centering?? */ - point.x -= 0.5*REL_CHARWIDTH*PSts*strlen(s); - PSMoveTo(point); - PSDrawText(s,mode); -} - -static void PSClearViewPort (void) -{ - return; -} - -static void PSSetLineWidth (short n) -{ - if (n<1) n=1; - if (n==PSlw) return; - - fprintf(currPSF,"%.3f W\n",LW_FACTOR+((float)(n-1))*LW_SCALE*LW_FACTOR); - currPSW->PSlw = PSlw = n; - return; -} - -static void PSSetTextSize (short n) -{ - if (n==PSts) return; - - fprintf(currPSF,"/%s findfont %d scalefont setfont\n",PS_DEFAULT_FONT,(int)n); - currPSW->PSts = PSts = n; - return; -} - -static void PSSetMarker (short n) -{ - currPSW->PSmarker = PSmarker = n; - return; -} - -static void PSSetMarkerSize (short n) -{ - currPSW->PSmarkersize = PSmarkersize = n; - return; -} - -static void PSSetPaletteEntry (long index, short r, short g, short b) -{ - red[index] = ((float)r)/255.0; - green[index] = ((float)g)/255.0; - blue[index] = ((float)b)/255.0; - PSPrintColor((float)red[index]); - PSPrintColor((float)green[index]); - PSPrintColor((float)blue[index]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = index; - return; -} - -static void PSSetPalette (long x, long count, short *r, short *g, short *b) -{ - int i,y; - - y = x+count; - for (i=x; i<y; i++) - { - red[i] = ((float)r[i-x])/255.0; - green[i] = ((float)g[i-x])/255.0; - blue[i] = ((float)b[i-x])/255.0; - } - PSPrintColor((float)red[x]); - PSPrintColor((float)green[x]); - PSPrintColor((float)blue[x]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = (unsigned char) x; - return; -} - -static void PSGetPaletteEntry (long index, short *r, short *g, short *b) -{ - return; -} - -static void PSFlush (void) -{ - return; -} - -/****************************************************************************/ -/* - InitPSPort - init port structure of output device 'ps' - - SYNOPSIS: - static void InitPSPort (OUTPUTDEVICE *thePort); - - PARAMETERS: - . thePort - port structure to initialize - - DESCRIPTION: - This function inits port structure of output device 'ps' - - RETURN VALUE: - void - */ -/****************************************************************************/ - -static void InitPSPort (OUTPUTDEVICE *thePort) -{ - short r,g,b,delta,i,j,max,res; - - /* init pointers to basic drawing functions */ - thePort->Move = PSMoveTo; - thePort->Draw = PSDrawTo; - thePort->Polyline = PSPolyline; - thePort->Polygon = PSPolygon; - thePort->ShadedPolygon = PSShadedPolygon; - thePort->InversePolygon = PSInversePolygon; - thePort->ErasePolygon = PSErasePolygon; - thePort->Polymark = PSPolymark; - thePort->InvPolymark = PSInvPolymark; - thePort->DrawText = PSDrawText; - thePort->CenteredText = PSCenteredText; - thePort->ClearViewPort = PSClearViewPort; - - /* init pointers to set functions */ - thePort->SetLineWidth = PSSetLineWidth; - thePort->SetTextSize = PSSetTextSize; - thePort->SetMarker = PSSetMarker; - thePort->SetMarkerSize = PSSetMarkerSize; - thePort->SetColor = PSForeground; - thePort->SetPaletteEntry= PSSetPaletteEntry; - thePort->SetNewPalette = PSSetPalette; - - /* init pointers to miscellaneous functions */ - thePort->GetPaletteEntry = PSGetPaletteEntry; - thePort->Flush = PSFlush; - thePort->PlotPixelBuffer = NULL; - - /* fill port */ - thePort->black = 255; - thePort->gray = 1; - thePort->white = 0; - thePort->red = 254; - thePort->green = 128; - thePort->blue = 2; - thePort->cyan = 65; - thePort->orange = 220; - thePort->yellow = 191; - thePort->darkyellow = 205; - thePort->magenta = 1; - thePort->hasPalette = 1; - thePort->range = 256; - thePort->spectrumStart = 2; - thePort->spectrumEnd = 254; - thePort->signx = 1; - thePort->signy = 1; - - /* initialize color table */ - res = 63; - delta = 4; - max = 252; - i = 0; - - /* fixed colors */ - red[i] = 255; green[i] = 255; blue[i++] = 255; /* 0 = white */ - red[i] = 180; green[i] = 180; blue[i++] = 180; /* 1 = gray */ - - /* color spectrum */ - r = g = 0; b = max; - red[i] = r; green[i] = g; blue[i++] = b; /* 2 = blue */ - - /* blue to cyan */ - for (j=0; j<res; j++) - { - g += delta; - red[i] = r; green[i] = g; blue[i++] = b; - } /* 65 = cyan */ - /* cyan to green */ - for (j=0; j<res; j++) - { - b -= delta; - red[i] = r; green[i] = g; blue[i++] = b; - } /* 128 = green */ - /* green to yellow */ - for (j=0; j<res; j++) - { - r += delta; - red[i] = r; green[i] = g; blue[i++] = b; - } /* 191 = yellow */ - /* yellow to rot */ - for (j=0; j<res; j++) - { - g -= delta; - red[i] = r; green[i] = g; blue[i++] = b; - } /* 254 = red */ - - red[i] = 0 ; green[i] = 0 ; blue[i++] = 0; /* 255 = black */ - - for (j=0; j<i; j++) - { - red[j] /= 255.0; - green[j] /= 255.0; - blue[j] /= 255.0; - } - - return; -} - -static INT WritePSHeader (FILE *file, const char *title, INT x, INT y, INT w, INT h) -{ - time_t tp; - char date[64]; - - /* read date */ - if (time(&tp)!=-1) - strcpy(date,ctime(&tp)); - else - strcpy(date,"\n"); - - /* write header */ - fprintf(file,"%%!PS-Adobe-2.0 EPSF-1.2\n"); - fprintf(file,"%%%%Title: %s\n", title); - fprintf(file,"%%%%Creator: %s\n",CREATOR); - fprintf(file,"%%%%CreationDate: %s", date); - fprintf(file,"%%%%BoundingBox: %d %d %d %d\n", - (int)x, (int)y, (int)w, (int)h ); - fprintf(file,"%%%%Pages: 1\n"); - fprintf(file,"%%%%DocumentsFonts: %s\n",PS_DEFAULT_FONT); - fprintf(file,"%%%%Copyright 1994 ug-group - All Rights Reserved Worldwide\n"); - fprintf(file,"%%%%EndComments\n\n"); - - /* write initialisation */ - fprintf(file,"1 setlinejoin\n"); - fprintf(file,"1 setlinecap\n"); - - fprintf(file,"/%s findfont %d scalefont setfont\n", PS_DEFAULT_FONT, PS_FONT_FACTOR); - - fprintf(file,"\n"); - - /* defines */ - fprintf(file,"/M {moveto} def\n"); - fprintf(file,"/S {lineto stroke} def\n"); - fprintf(file,"/L {lineto} def\n"); - fprintf(file,"/C {closepath fill} def\n"); - fprintf(file,"/N {newpath} def\n"); - fprintf(file,"/R {setrgbcolor} def\n"); - fprintf(file,"/W {setlinewidth} def\n"); - fprintf(file,"/I {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 4 -2 roll mul R} def\n"); - - fprintf(file,"\n"); - - /* write end of prolog */ - fprintf(file,"%%%%Endprolog\n%%\n"); - fprintf(file,"%%%%Page: 1 1\n%%\n\n"); - - return (0); -} - -static INT ComputeTransformation (PSWINDOW *PSWindow,INT *ox,INT *oy,INT *sx,INT *sy, INT ls) -{ - short j; - - /* compute transformation */ - if (!ls) - { - /* regular format */ - tx = (float) (*ox); - ty = (float) (*oy); - mxx = (float) (*sx); - myy = (float) (*sy); - mxy = myx = 0.0; - } - else - { - /* landscape format */ - tx = (float) (PAPER_X-(*ox)); - ty = (float) (*oy); - mxy =-(float) (*sy); - myx = (float) (*sx); - mxx = myy = 0.0; - *ox = PAPER_X-(*ox)-(*sy); - j = *sx; - *sx = *sy; - *sy = j; - } - PSWindow->landscape = landscape = ls; - PSWindow->tx = tx; - PSWindow->ty = ty; - PSWindow->mxx = mxx; - PSWindow->mxy = mxy; - PSWindow->myx = myx; - PSWindow->myy = myy; - - return (0); -} - -/****************************************************************************/ -/* - OpenDocumentWindow - Open a postscript file - - SYNOPSIS: - static WINDOWID OpenPSWindow (char *title, INT x, INT y, INT width, - INT height, INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, - INT *error); - - PARAMETERS: - . title - - . x - - . y - - . width - - . height - - . Global_LL - - . Global_UR - - . Local_LL - - . Local_UR - - . error - - - DESCRIPTION: - This function opens a psfile. - - RETURN VALUE: - WINDOWID - .n pointer to the window struct - .n NULL if an error occured. - */ -/****************************************************************************/ - -static WINDOWID OpenPSWindow (const char *title, INT rename, INT x, INT y, INT width, INT height, INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, INT *error) -{ - char pspath[BUFFLEN]; - INT sx,sy; - - *error = 0; - - /* create PSWINDOW structure */ - currPSW = (PSWINDOW*)malloc(sizeof(PSWINDOW)); - if (currPSW==NULL) {*error=1; return(0);} - - /* set default values */ - PSDefaultValues( currPSW ); - - /* init postscript window */ - if (GetDefaultValue(DEFAULTSFILENAME,"psfilesdir",pspath)==0) - currPSW->psfile = FileOpenUsingSearchPath_r(title,"w",pspath,rename); - else - currPSW->psfile = fileopen(title,"w"); - if (currPSW->psfile==NULL) - { - free(currPSW); - currPSW = NULL; - *error = 1; - return (0); - } - - /* set currents */ - currPSF = currPSW->psfile; - - /* return corners in devices coordinate system (before they are changed by ComputeTransformation) */ - Global_LL[0] = Local_LL[0] = x; Global_LL[1] = Local_LL[1] = y; - Global_UR[0] = Local_UR[0] = x + width; - Global_UR[1] = Local_UR[1] = y + height; - - /* transformation with default origin, scale and format (how could they be made to be changable?) */ - sx = sy = 1; - ComputeTransformation(currPSW,&x,&y,&sx,&sy,0); - - /* init psfile */ - WritePSHeader(currPSF,title,x,y,sx*width,sy*height); - - /* write pallette */ - /* PSSetPalette(0,256,red,green,blue); */ - /* default palette */ - - PSSetLineWidth(1); - PSSetTextSize(10); - - /* return window ptr */ - return((WINDOWID)currPSW); -} - -/****************************************************************************/ -/* - ClosePSPort - write trailer and close file - - SYNOPSIS: - static INT ClosePSWindow (WINDOWID win); - - PARAMETERS: - . win - - - DESCRIPTION: - This function writes the trailer and closes the file. - - RETURN VALUE: - INT - .n 0 if operation ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -static INT ClosePSWindow (WINDOWID win) -{ - currPSW = (PSWINDOW *) win; - if (currPSW==NULL) return (1); - currPSF = currPSW->psfile; - if (currPSF==NULL) return (0); - - /* write trailer */ - fprintf(currPSF,"\nshowpage\n\n"); - fprintf(currPSF,"%%%%Trailer\n"); - - fclose(currPSF); - free(currPSW); - - currPSW = NULL; - currPSF = NULL; - - return (0); -} - - -/****************************************************************************/ -/* - SetPSOutput - Activate the window associated with theView - - SYNOPSIS: - static INT SetPSOutput (WINDOWID win); - - PARAMETERS: - . win - - - DESCRIPTION: - This function activates the window associated with theView. - - RETURN VALUE: - INT - .n 0 if operation ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -static INT SetPSOutput (WINDOWID win) -{ - /* set current output window */ - currPSW = (PSWINDOW *) win; - currPSF = currPSW->psfile; - - /* set current transformation */ - tx = currPSW->tx; - ty = currPSW->ty; - mxx = currPSW->mxx; - mxy = currPSW->mxy; - myx = currPSW->myx; - myy = currPSW->myy; - - PSmarker = currPSW->PSmarker; - PSmarkersize = currPSW->PSmarkersize; - PScp.x = currPSW->PScp.x; - PScp.y = currPSW->PScp.y; - PSlw = currPSW->PSlw; - PSts = currPSW->PSts; - PScc = currPSW->PScc; - landscape = currPSW->landscape; - - return(0); -} - -/****************************************************************************/ -/* - UpdateOutput - Draws all controls and highlights active tool - - SYNOPSIS: - static INT UpdatePSOutput (WINDOWID win, char *s, INT tool) - - PARAMETERS: - . win - - . s - - . tool - - DESCRIPTION: - This function draws all controls and highlights active tool. - - RETURN VALUE: - INT - - 0, when OK - - 1, when error - */ -/****************************************************************************/ - -static INT UpdatePSOutput (WINDOWID win, INT tool) -{ - return(0); -} - -/****************************************************************************/ -/* - InitPSOutputDevice - Create psfile output device - - SYNOPSIS: - static OUTPUTDEVICE *InitPSOutputDevice (void); - - PARAMETERS: - . void - - DESCRIPTION: - This file creates psfile output device. - - RETURN VALUE: - OUTPUTDEVICE * - .n pointer to output device - .n NULL if an error occured. - - */ -/****************************************************************************/ - -static OUTPUTDEVICE *InitPSOutputDevice (void) -{ - /* create output device */ - if ( (PSOutputDevice=CreateOutputDevice("ps")) == NULL ) return(NULL); - - /* init output device 'meta' */ - PSOutputDevice->OpenOutput = OpenPSWindow; - PSOutputDevice->CloseOutput = ClosePSWindow; - PSOutputDevice->ActivateOutput = SetPSOutput; - PSOutputDevice->UpdateOutput = UpdatePSOutput; - - PSOutputDevice->v.locked = 1; - PSOutputDevice->PixelRatio = (DOUBLE) 1.0; - InitPSPort (PSOutputDevice); - - UserWrite("output device 'ps' created\n"); - - return (PSOutputDevice); -} - -/****************************************************************************/ -/* - InitPostScript - Initialize psfile - - SYNOPSIS: - INT InitPS (void); - - PARAMETERS: - . void - - DESCRIPTION: - This function initializes psfile. - - RETURN VALUE: - INT - .n 0 if ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -INT NS_PREFIX InitPostScript (void) -{ - if ((InitPSOutputDevice()) == NULL) return (1); - - return (0); -} diff --git a/dev/ps/postscriptbw.cc b/dev/ps/postscriptbw.cc deleted file mode 100644 index ae238e90eedf0501de354a8c967534a80d026e2d..0000000000000000000000000000000000000000 --- a/dev/ps/postscriptbw.cc +++ /dev/null @@ -1,944 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: postscript.c */ -/* */ -/* Purpose: write graphics postscript files */ -/* */ -/* Author: Henrik Rentz-Reichert */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 07.05.96 begin, ug version 3.2 */ -/* */ -/* Remarks: used most of the code of m2ps by P. Bastian */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstddef> -#include <cstring> -#include <cstdio> -#include <cstdlib> -#include <cmath> -#include <ctime> - -#include "defaults.h" -#include "fileopen.h" -#include "ugdevices.h" -#include "initdev.h" -#include "general.h" - - -USING_UG_NAMESPACE - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define TEXTSIZE 8 - -#define CREATOR "ug postscript output" - - -/* postscript defaults */ -#define PS_DEFAULT_LINE_WIDTH 1 -#define PS_DEFAULT_FONT "Monaco" -#define PS_FONT_FACTOR 10 -#define LW_FACTOR 0.03 -#define LW_SCALE 50.0 -#define PAPER_X 600 -#define PAPER_Y 850 - -#define REL_CHARWIDTH 0.7 - -#define COLORS 256 -#define GRAY 0.5 -#define GRAY_CC (~(short)0) - -#define TRFMX(pt) (((float)(pt.x))*mxx + ((float)(pt.y))*mxy + tx) -#define TRFMY(pt) (((float)(pt.x))*myx + ((float)(pt.y))*myy + ty) - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -typedef struct { - - FILE *psfile; /* output file */ - - short landscape; /* landscape format */ - - /* transformation */ - float tx,ty; /* translation */ - float mxx,mxy,myx,myy; /* matrix */ - - short PSmarker; - short PSmarkersize; - SHORT_POINT PScp; - short PSlw; - short PSts; - short PScc; -} PSWINDOW ; - -static OUTPUTDEVICE *PSOutputDevice=NULL; /* outputdevice that has been ini*/ -static PSWINDOW *currPSW=NULL; /* current postscript window */ -static FILE *currPSF; /* current postscript file */ -static short PSmarker; -static short PSmarkersize; - -static SHORT_POINT PScp; -static short PSlw, PSts; -static short PScc; -static float tx,ty,mxx,myy,mxy,myx; -static short landscape; - -/* static color table for all postscript files */ -static float red[COLORS]; -static float green[COLORS]; -static float blue[COLORS]; - - -/****************************************************************************/ -/* */ -/* forward declarations of functions used before they are defined */ -/* */ -/****************************************************************************/ - -static void PSDefaultValues( PSWINDOW *psw ) -{ - currPSW = psw; - - currPSW->psfile = currPSF = NULL; - currPSW->landscape = landscape = 0; - currPSW->tx = tx = 0.0; - currPSW->ty = ty = 0.0; - currPSW->mxx = mxx = 0.0; - currPSW->mxy = mxy = 0.0; - currPSW->myx = myx = 0.0; - currPSW->myy = myy = 0.0; - currPSW->PSmarker = PSmarker = 0; - currPSW->PSmarkersize = PSmarkersize = 1; - currPSW->PScp.x = PScp.x = 0; - currPSW->PScp.y = PScp.y = 0; - currPSW->PSlw = PSlw = -1; - currPSW->PSts = PSts = -1; - currPSW->PScc = PScc = 0; -} - - -static void PSMoveTo (SHORT_POINT point) -{ - currPSW->PScp.x = PScp.x = point.x; currPSW->PScp.y = PScp.y = point.y; - return; -} - -static void PSDrawTo (SHORT_POINT point) -{ - fprintf(currPSF,"%g %g M %g %g S\n", - TRFMX(PScp),TRFMY(PScp),TRFMX(point),TRFMY(point)); - currPSW->PScp.x = PScp.x = point.x; currPSW->PScp.y = PScp.y = point.y; - return; -} - -static void PSCircle (SHORT_POINT point, short r) -{ - SHORT_POINT aux; - short xr,yr; - - aux.x = 0; - aux.y = r; - xr = TRFMX(aux); - yr = TRFMY(aux); - r = sqrt(xr*xr+yr*yr); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(point)+r,TRFMY(point)); - fprintf(currPSF,"%g %g %g %g %g arc\n",TRFMX(point),TRFMY(point),(float)r,(float)0,(float)360); - - fprintf(currPSF,"stroke\n"); - - return; -} - -static void PSFilledCircle (SHORT_POINT point, short r) -{ - SHORT_POINT aux; - short xr,yr; - - aux.x = 0; - aux.y = r; - xr = TRFMX(aux); - yr = TRFMY(aux); - r = sqrt(xr*xr+yr*yr); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(point)+r,TRFMY(point)); - fprintf(currPSF,"%g %g %g %g %g arc\n",TRFMX(point),TRFMY(point),(float)r,(float)0,(float)360); - - fprintf(currPSF,"C\n"); - - return; -} - -static void PSPolyline (SHORT_POINT *points, INT nb) -{ - int i; - - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"stroke\n"); - - return; -} - -static void PSPolygon (SHORT_POINT *points, INT nb) -{ - int i; - - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"C\n"); - - return; -} - -static void PSShadedPolygon(SHORT_POINT *points, INT nb, DOUBLE intensity) -{ - int i; - - fprintf(currPSF,"%4.3f I\n",intensity); - fprintf(currPSF,"N\n"); - fprintf(currPSF,"%g %g M\n",TRFMX(points[0]),TRFMY(points[0])); - for (i=1; i<nb; i++) - fprintf(currPSF,"%g %g L\n",TRFMX(points[i]),TRFMY(points[i])); - fprintf(currPSF,"C\n"); - currPSW->PScc = PScc = -1; -} - -static void PSInversePolygon (SHORT_POINT *points, INT nb) -{ - return; -} - -static void PSErasePolygon (SHORT_POINT *points, INT nb) -{ - return; -} - -static void PSPrintColor (float color) -{ - if (color==0.0) fprintf(currPSF,"%d ",0); - else if (color==1.0) fprintf(currPSF,"%d ",1); - else fprintf(currPSF,"%.3f ",color); - return; -} - -static void PSGrayForeground (void) -{ - if (PScc==GRAY_CC) return; - - fprintf(currPSF,"%.1f %.1f %.1f R\n",GRAY,GRAY,GRAY); - currPSW->PScc = PScc = GRAY_CC; - return; -} - -static void PSForeground (long index) -{ - if (PScc==index) return; - - PSPrintColor((float)red[index]); - PSPrintColor((float)green[index]); - PSPrintColor((float)blue[index]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = index; - return; -} - -static void PSMarker (short n, short s, SHORT_POINT point) -{ - short top, left, bottom, right; - SHORT_POINT points[10],pt; - unsigned long cc; - - s = s/2; - - top = point.y+s; bottom = point.y-s; - left = point.x-s; right = point.x+s; - - n = n%NMARKERS; - - switch (n) - { - case EMPTY_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - points[4].x = left; points[4].y = bottom; - PSPolyline(points,5); - break; - case GRAY_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - cc = PScc; - PSGrayForeground(); - PSPolygon(points,4); - PSForeground(cc); - break; - case FILLED_SQUARE_MARKER : - points[0].x = left; points[0].y = bottom; - points[1].x = right; points[1].y = bottom; - points[2].x = right; points[2].y = top; - points[3].x = left; points[3].y = top; - PSPolygon(points,4); - break; - case EMPTY_CIRCLE_MARKER : - PSCircle(point,s); - break; - case GRAY_CIRCLE_MARKER : - PSGrayForeground(); - PSFilledCircle(point,s); - cc = PScc; - PSForeground(cc); - break; - case FILLED_CIRCLE_MARKER : - PSFilledCircle(point,s); - break; - case EMPTY_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - points[4].x = point.x; points[4].y = bottom; - PSPolyline(points,5); - break; - case GRAY_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - cc = PScc; - PSGrayForeground(); - PSPolygon(points,4); - PSForeground(cc); - break; - case FILLED_RHOMBUS_MARKER : - points[0].x = point.x; points[0].y = bottom; - points[1].x = right; points[1].y = point.y; - points[2].x = point.x; points[2].y = top; - points[3].x = left; points[3].y = point.y; - PSPolygon(points,4); - break; - case PLUS_MARKER : - pt.x = point.x; pt.y = bottom; - PSMoveTo(pt); - pt.x = point.x; pt.y = top; - PSDrawTo(pt); - pt.x = right; pt.y = point.y; - PSMoveTo(pt); - pt.x = left; pt.y = point.y; - PSDrawTo(pt); - break; - case CROSS_MARKER : - pt.x = left; pt.y = bottom; - PSMoveTo(pt); - pt.x = right; pt.y = top; - PSDrawTo(pt); - pt.x = right; pt.y = bottom; - PSMoveTo(pt); - pt.x = left; pt.y = top; - PSDrawTo(pt); - break; - } -} - -static void PSPolymark (short n, SHORT_POINT *points) -{ - int i; - - for (i=0; i<n; i++) - PSMarker(PSmarker,PSmarkersize,points[i]); - - return; -} - -static void PSInvPolymark (short n, SHORT_POINT *points) -{} - -static void PrintPSString (const char *s) -{ - fputc('(',currPSF); - - while (*s != '\0') - { - switch (*s) - { - case '\\' : - case '(' : - case ')' : fputc('\\',currPSF); - default : fputc(*s,currPSF); - } - s++; - } - fputc(')',currPSF); -} - -static void PSDrawText (const char *s, INT mode) -{ - fprintf(currPSF,"%g %g M\n",TRFMX(PScp),TRFMY(PScp)); - if (landscape) fprintf(currPSF,"90 rotate\n"); - PrintPSString(s); - fprintf(currPSF," show N\n"); - if (landscape) fprintf(currPSF,"-90 rotate\n"); - return; -} - -static void PSCenteredText (SHORT_POINT point, const char *s, INT mode) -{ - /* centering?? */ - point.x -= 0.5*REL_CHARWIDTH*PSts*strlen(s); - PSMoveTo(point); - PSDrawText(s,mode); -} - -static void PSClearViewPort (void) -{ - return; -} - -static void PSSetLineWidth (short n) -{ - if (n<1) n=1; - if (n==PSlw) return; - - fprintf(currPSF,"%.3f W\n",LW_FACTOR+((float)(n-1))*LW_SCALE*LW_FACTOR); - currPSW->PSlw = PSlw = n; - return; -} - -static void PSSetTextSize (short n) -{ - if (n==PSts) return; - - fprintf(currPSF,"/%s findfont %d scalefont setfont\n",PS_DEFAULT_FONT,(int)n); - currPSW->PSts = PSts = n; - return; -} - -static void PSSetMarker (short n) -{ - currPSW->PSmarker = PSmarker = n; - return; -} - -static void PSSetMarkerSize (short n) -{ - currPSW->PSmarkersize = PSmarkersize = n; - return; -} - -static void PSSetPaletteEntry (long index, short r, short g, short b) -{ - red[index] = ((float)r)/255.0; - green[index] = ((float)g)/255.0; - blue[index] = ((float)b)/255.0; - PSPrintColor((float)red[index]); - PSPrintColor((float)green[index]); - PSPrintColor((float)blue[index]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = index; - return; -} - -static void PSSetPalette (long x, long count, short *r, short *g, short *b) -{ - int i,y; - - y = x+count; - for (i=x; i<y; i++) - { - red[i] = ((float)r[i-x])/255.0; - green[i] = ((float)g[i-x])/255.0; - blue[i] = ((float)b[i-x])/255.0; - } - PSPrintColor((float)red[x]); - PSPrintColor((float)green[x]); - PSPrintColor((float)blue[x]); - fprintf(currPSF,"R\n"); - currPSW->PScc = PScc = (unsigned char) x; - return; -} - -static void PSGetPaletteEntry (long index, short *r, short *g, short *b) -{ - return; -} - -static void PSFlush (void) -{ - return; -} - -/****************************************************************************/ -/* - InitPSPort_BlackAndWhite - init port structure of output device 'psbw' - - SYNOPSIS: - static void InitPSPort_BlackAndWhite (OUTPUTDEVICE *thePort); - - PARAMETERS: - . thePort - port structure to initialize - - DESCRIPTION: - This function inits port structure of output device 'ps' - - RETURN VALUE: - void - */ -/****************************************************************************/ - -static void InitPSPort (OUTPUTDEVICE *thePort) -{ - short i; - - /* init pointers to basic drawing functions */ - thePort->Move = PSMoveTo; - thePort->Draw = PSDrawTo; - thePort->Polyline = PSPolyline; - thePort->Polygon = PSPolygon; - thePort->ShadedPolygon = PSShadedPolygon; - thePort->InversePolygon = PSInversePolygon; - thePort->ErasePolygon = PSErasePolygon; - thePort->Polymark = PSPolymark; - thePort->InvPolymark = PSInvPolymark; - thePort->DrawText = PSDrawText; - thePort->CenteredText = PSCenteredText; - thePort->ClearViewPort = PSClearViewPort; - - /* init pointers to set functions */ - thePort->SetLineWidth = PSSetLineWidth; - thePort->SetTextSize = PSSetTextSize; - thePort->SetMarker = PSSetMarker; - thePort->SetMarkerSize = PSSetMarkerSize; - thePort->SetColor = PSForeground; - thePort->SetPaletteEntry= PSSetPaletteEntry; - thePort->SetNewPalette = PSSetPalette; - - /* init pointers to miscellaneous functions */ - thePort->GetPaletteEntry = PSGetPaletteEntry; - thePort->Flush = PSFlush; - thePort->PlotPixelBuffer = NULL; - - /* fill port */ - thePort->black = 255; - thePort->gray = 1; - thePort->white = 0; - thePort->red = 150; - thePort->green = 100; - thePort->blue = 200; - thePort->cyan = 65; - thePort->orange = 128; - thePort->yellow = 25; - thePort->darkyellow = 40; - thePort->magenta = 128; - thePort->hasPalette = 1; - thePort->range = 256; - thePort->spectrumStart = 2; - thePort->spectrumEnd = 225; - thePort->signx = 1; - thePort->signy = 1; - - /* initialize color table */ - for (i=254; i>=2; i--) - { - red[i] = green[i] = blue[i] = i/255.0; - } - - red[0] = green[0] = blue[0] = 0.999; - red[1] = green[1] = blue[1] = 180.0/255.0; - red[255] = green[255] = blue[255] = 0.0; - - return; -} - - -static INT WritePSHeader (FILE *file, const char *title, INT x, INT y, INT w, INT h) -{ - time_t tp; - char date[64]; - - /* read date */ - if (time(&tp)!=-1) - strcpy(date,ctime(&tp)); - else - strcpy(date,"\n"); - - /* write header */ - fprintf(file,"%%!PS-Adobe-2.0 EPSF-1.2\n"); - fprintf(file,"%%%%Title: %s\n", title); - fprintf(file,"%%%%Creator: %s\n",CREATOR); - fprintf(file,"%%%%CreationDate: %s", date); - fprintf(file,"%%%%BoundingBox: %d %d %d %d\n", - (int)x, (int)y, (int)w, (int)h ); - fprintf(file,"%%%%Pages: 1\n"); - fprintf(file,"%%%%DocumentsFonts: %s\n",PS_DEFAULT_FONT); - fprintf(file,"%%%%Copyright 1994 ug-group - All Rights Reserved Worldwide\n"); - fprintf(file,"%%%%EndComments\n\n"); - - /* write initialisation */ - fprintf(file,"1 setlinejoin\n"); - fprintf(file,"1 setlinecap\n"); - - fprintf(file,"/%s findfont %d scalefont setfont\n", PS_DEFAULT_FONT, PS_FONT_FACTOR); - - fprintf(file,"\n"); - - /* defines */ - fprintf(file,"/M {moveto} def\n"); - fprintf(file,"/S {lineto stroke} def\n"); - fprintf(file,"/L {lineto} def\n"); - fprintf(file,"/C {closepath fill} def\n"); - fprintf(file,"/N {newpath} def\n"); - fprintf(file,"/R {setrgbcolor} def\n"); - fprintf(file,"/W {setlinewidth} def\n"); - fprintf(file,"/I {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 4 -2 roll mul R} def\n"); - - fprintf(file,"\n"); - - /* write end of prolog */ - fprintf(file,"%%%%Endprolog\n%%\n"); - fprintf(file,"%%%%Page: 1 1\n%%\n\n"); - - return (0); -} - -static INT ComputeTransformation (PSWINDOW *PSWindow,INT *ox,INT *oy,INT *sx,INT *sy, INT ls) -{ - short j; - - /* compute transformation */ - if (!ls) - { - /* regular format */ - tx = (float) (*ox); - ty = (float) (*oy); - mxx = (float) (*sx); - myy = (float) (*sy); - mxy = myx = 0.0; - } - else - { - /* landscape format */ - tx = (float) (PAPER_X-(*ox)); - ty = (float) (*oy); - mxy =-(float) (*sy); - myx = (float) (*sx); - mxx = myy = 0.0; - *ox = PAPER_X-(*ox)-(*sy); - j = *sx; - *sx = *sy; - *sy = j; - } - PSWindow->landscape = landscape = ls; - PSWindow->tx = tx; - PSWindow->ty = ty; - PSWindow->mxx = mxx; - PSWindow->mxy = mxy; - PSWindow->myx = myx; - PSWindow->myy = myy; - - return (0); -} - -/****************************************************************************/ -/* - OpenDocumentWindow - Open a postscript file - - SYNOPSIS: - static WINDOWID OpenPSWindow (char *title, INT x, INT y, INT width, - INT height, INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, - INT *error); - - PARAMETERS: - . title - - . x - - . y - - . width - - . height - - . Global_LL - - . Global_UR - - . Local_LL - - . Local_UR - - . error - - - DESCRIPTION: - This function opens a psfile. - - RETURN VALUE: - WINDOWID - .n pointer to the window struct - .n NULL if an error occured. - */ -/****************************************************************************/ - -static WINDOWID OpenPSWindow (const char *title, INT rename, INT x, INT y, INT width, INT height, INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, INT *error) -{ - char pspath[BUFFLEN]; - INT sx,sy; - - *error = 0; - - /* create PSWINDOW structure */ - currPSW = (PSWINDOW*)malloc(sizeof(PSWINDOW)); - if (currPSW==NULL) {*error=1; return(0);} - - /* set default values */ - PSDefaultValues( currPSW ); - - /* init postscript window */ - if (GetDefaultValue(DEFAULTSFILENAME,"psfilesdir",pspath)==0) - currPSW->psfile = FileOpenUsingSearchPath_r(title,"w",pspath,rename); - else - currPSW->psfile = fileopen(title,"w"); - if (currPSW->psfile==NULL) - { - free(currPSW); - currPSW = NULL; - *error = 1; - return (0); - } - - /* set currents */ - currPSF = currPSW->psfile; - - /* return corners in devices coordinate system (before they are changed by ComputeTransformation) */ - Global_LL[0] = Local_LL[0] = x; Global_LL[1] = Local_LL[1] = y; - Global_UR[0] = Local_UR[0] = x + width; - Global_UR[1] = Local_UR[1] = y + height; - - /* transformation with default origin, scale and format (how could they be made to be changable?) */ - sx = sy = 1; - ComputeTransformation(currPSW,&x,&y,&sx,&sy,0); - - /* init psfile */ - WritePSHeader(currPSF,title,x,y,sx*width,sy*height); - - /* write pallette */ - /* PSSetPalette(0,256,red,green,blue); */ - /* default palette */ - - PSSetLineWidth(1); - PSSetTextSize(10); - - /* return window ptr */ - return((WINDOWID)currPSW); -} - -/****************************************************************************/ -/* - ClosePSPort - write trailer and close file - - SYNOPSIS: - static INT ClosePSWindow (WINDOWID win); - - PARAMETERS: - . win - - - DESCRIPTION: - This function writes the trailer and closes the file. - - RETURN VALUE: - INT - .n 0 if operation ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -static INT ClosePSWindow (WINDOWID win) -{ - currPSW = (PSWINDOW *) win; - if (currPSW==NULL) return (1); - currPSF = currPSW->psfile; - if (currPSF==NULL) return (0); - - /* write trailer */ - fprintf(currPSF,"\nshowpage\n\n"); - fprintf(currPSF,"%%%%Trailer\n"); - - fclose(currPSF); - free(currPSW); - - currPSW = NULL; - currPSF = NULL; - - return (0); -} - - -/****************************************************************************/ -/* - SetPSOutput - Activate the window associated with theView - - SYNOPSIS: - static INT SetPSOutput (WINDOWID win); - - PARAMETERS: - . win - - - DESCRIPTION: - This function activates the window associated with theView. - - RETURN VALUE: - INT - .n 0 if operation ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -static INT SetPSOutput (WINDOWID win) -{ - /* set current output window */ - currPSW = (PSWINDOW *) win; - currPSF = currPSW->psfile; - - /* set current transformation */ - tx = currPSW->tx; - ty = currPSW->ty; - mxx = currPSW->mxx; - mxy = currPSW->mxy; - myx = currPSW->myx; - myy = currPSW->myy; - - PSmarker = currPSW->PSmarker; - PSmarkersize = currPSW->PSmarkersize; - PScp.x = currPSW->PScp.x; - PScp.y = currPSW->PScp.y; - PSlw = currPSW->PSlw; - PSts = currPSW->PSts; - PScc = currPSW->PScc; - landscape = currPSW->landscape; - - return(0); -} - -/****************************************************************************/ -/* - UpdateOutput - Draws all controls and highlights active tool - - SYNOPSIS: - static INT UpdatePSOutput (WINDOWID win, char *s, INT tool) - - PARAMETERS: - . win - - . s - - . tool - - DESCRIPTION: - This function draws all controls and highlights active tool. - - RETURN VALUE: - INT - - 0, when OK - - 1, when error - */ -/****************************************************************************/ - -static INT UpdatePSOutput (WINDOWID win, INT tool) -{ - return(0); -} - -/****************************************************************************/ -/* - InitPSOutputDevice - Create psfile output device - - SYNOPSIS: - static OUTPUTDEVICE *InitPSOutputDevice (void); - - PARAMETERS: - . void - - DESCRIPTION: - This file creates psfile output device. - - RETURN VALUE: - OUTPUTDEVICE * - .n pointer to output device - .n NULL if an error occured. - - */ -/****************************************************************************/ - -static OUTPUTDEVICE *InitPSOutputDevice (void) -{ - /* create output device */ - if ( (PSOutputDevice=CreateOutputDevice("psbw")) == NULL ) return(NULL); - - /* init output device 'meta' */ - PSOutputDevice->OpenOutput = OpenPSWindow; - PSOutputDevice->CloseOutput = ClosePSWindow; - PSOutputDevice->ActivateOutput = SetPSOutput; - PSOutputDevice->UpdateOutput = UpdatePSOutput; - - PSOutputDevice->v.locked = 1; - PSOutputDevice->PixelRatio = (DOUBLE) 1.0; - InitPSPort (PSOutputDevice); - - UserWrite("output device 'ps' created\n"); - - return (PSOutputDevice); -} - -/****************************************************************************/ -/* - InitPostScript - Initialize psfile - - SYNOPSIS: - INT InitPS (void); - - PARAMETERS: - . void - - DESCRIPTION: - This function initializes psfile. - - RETURN VALUE: - INT - .n 0 if ok - .n 1 if an error occured. - */ -/****************************************************************************/ - -INT NS_PREFIX InitPostScriptBW (void) -{ - if ((InitPSOutputDevice()) == NULL) return (1); - - return (0); -} diff --git a/dev/ugdevices.cc b/dev/ugdevices.cc index 52e354df24798ed44cde4b7e6b470a445c665a9e..f853d7d96456d70f40803d1ee362dfdb1feedac2 100644 --- a/dev/ugdevices.cc +++ b/dev/ugdevices.cc @@ -824,21 +824,6 @@ else return (error); } - /* init postscript device */ - if (InitPostScript()!=0) - { - SetHiWrd(error,__LINE__); - return (error); - } - - /* init postscript device */ - if (InitPostScriptBW()!=0) - { - SetHiWrd(error,__LINE__); - return (error); - } - - /* init ppm device */ if (InitPPMDevice()!=0) { diff --git a/dev/xif/.gitignore b/dev/xif/.gitignore deleted file mode 100644 index 9a196b32e949c1a865a1609720cb3852f2f7e9e7..0000000000000000000000000000000000000000 --- a/dev/xif/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.lo -*.la -*.o - -semantic.cache diff --git a/dev/xif/shades.h b/dev/xif/shades.h deleted file mode 100644 index 6d3be3921435d237caf498c6cd5f72b5d8ff6ae8..0000000000000000000000000000000000000000 --- a/dev/xif/shades.h +++ /dev/null @@ -1,105 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: shades.h */ -/* */ -/* Purpose: patterns for shading polygons */ -/* */ -/* */ -/* Author: Michael Lampe */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 10 .97 begin */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __SHADES__ -#define __SHADES__ - -#define NO_PATTERNS 65 -#define PATTERN_SIZE 8 - -static unsigned char pattern_data[NO_PATTERNS][8] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x80, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, - {0x88, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00}, - {0x88, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00}, - {0x88, 0x00, 0x20, 0x00, 0x88, 0x00, 0x00, 0x00}, - {0x88, 0x00, 0x20, 0x00, 0x88, 0x00, 0x02, 0x00}, - {0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x02, 0x00}, - {0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00}, - {0xa8, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00}, - {0xa8, 0x00, 0x22, 0x00, 0x8a, 0x00, 0x22, 0x00}, - {0xaa, 0x00, 0x22, 0x00, 0x8a, 0x00, 0x22, 0x00}, - {0xaa, 0x00, 0x22, 0x00, 0xaa, 0x00, 0x22, 0x00}, - {0xaa, 0x00, 0xa2, 0x00, 0xaa, 0x00, 0x22, 0x00}, - {0xaa, 0x00, 0xa2, 0x00, 0xaa, 0x00, 0x2a, 0x00}, - {0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00, 0x2a, 0x00}, - {0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00}, - {0xaa, 0x40, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0x00}, - {0xaa, 0x40, 0xaa, 0x00, 0xaa, 0x04, 0xaa, 0x00}, - {0xaa, 0x44, 0xaa, 0x00, 0xaa, 0x04, 0xaa, 0x00}, - {0xaa, 0x44, 0xaa, 0x00, 0xaa, 0x44, 0xaa, 0x00}, - {0xaa, 0x44, 0xaa, 0x10, 0xaa, 0x44, 0xaa, 0x00}, - {0xaa, 0x44, 0xaa, 0x10, 0xaa, 0x44, 0xaa, 0x01}, - {0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x01}, - {0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11}, - {0xaa, 0x54, 0xaa, 0x11, 0xaa, 0x44, 0xaa, 0x11}, - {0xaa, 0x54, 0xaa, 0x11, 0xaa, 0x45, 0xaa, 0x11}, - {0xaa, 0x55, 0xaa, 0x11, 0xaa, 0x45, 0xaa, 0x11}, - {0xaa, 0x55, 0xaa, 0x11, 0xaa, 0x55, 0xaa, 0x11}, - {0xaa, 0x55, 0xaa, 0x51, 0xaa, 0x55, 0xaa, 0x11}, - {0xaa, 0x55, 0xaa, 0x51, 0xaa, 0x55, 0xaa, 0x15}, - {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x15}, - {0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}, - {0xea, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55}, - {0xea, 0x55, 0xaa, 0x55, 0xae, 0x55, 0xaa, 0x55}, - {0xee, 0x55, 0xaa, 0x55, 0xae, 0x55, 0xaa, 0x55}, - {0xee, 0x55, 0xaa, 0x55, 0xee, 0x55, 0xaa, 0x55}, - {0xee, 0x55, 0xba, 0x55, 0xee, 0x55, 0xaa, 0x55}, - {0xee, 0x55, 0xba, 0x55, 0xee, 0x55, 0xab, 0x55}, - {0xee, 0x55, 0xbb, 0x55, 0xee, 0x55, 0xab, 0x55}, - {0xee, 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55}, - {0xfe, 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55}, - {0xfe, 0x55, 0xbb, 0x55, 0xef, 0x55, 0xbb, 0x55}, - {0xff, 0x55, 0xbb, 0x55, 0xef, 0x55, 0xbb, 0x55}, - {0xff, 0x55, 0xbb, 0x55, 0xff, 0x55, 0xbb, 0x55}, - {0xff, 0x55, 0xfb, 0x55, 0xff, 0x55, 0xbb, 0x55}, - {0xff, 0x55, 0xfb, 0x55, 0xff, 0x55, 0xbf, 0x55}, - {0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xbf, 0x55}, - {0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55}, - {0xff, 0xd5, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55}, - {0xff, 0xd5, 0xff, 0x55, 0xff, 0x5d, 0xff, 0x55}, - {0xff, 0xdd, 0xff, 0x55, 0xff, 0x5d, 0xff, 0x55}, - {0xff, 0xdd, 0xff, 0x55, 0xff, 0xdd, 0xff, 0x55}, - {0xff, 0xdd, 0xff, 0x75, 0xff, 0xdd, 0xff, 0x55}, - {0xff, 0xdd, 0xff, 0x75, 0xff, 0xdd, 0xff, 0x57}, - {0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff, 0x57}, - {0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff, 0x77}, - {0xff, 0xfd, 0xff, 0x77, 0xff, 0xdd, 0xff, 0x77}, - {0xff, 0xfd, 0xff, 0x77, 0xff, 0xdf, 0xff, 0x77}, - {0xff, 0xff, 0xff, 0x77, 0xff, 0xdf, 0xff, 0x77}, - {0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, 0x77}, - {0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0x77}, - {0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0x7f}, - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}, - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} -}; - -#endif diff --git a/dev/xif/shell-icon b/dev/xif/shell-icon deleted file mode 100644 index 1f112721f1b05436269b6c70d910b0682213ab9a..0000000000000000000000000000000000000000 --- a/dev/xif/shell-icon +++ /dev/null @@ -1,20 +0,0 @@ -#define shell_icon_width 40 -#define shell_icon_height 40 -static unsigned char shell_icon_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x88, 0x3f, 0x00, 0x00, 0x08, 0x48, 0x30, 0x00, 0x00, 0x08, 0x48, 0x10, - 0x00, 0x00, 0x08, 0x48, 0x10, 0x00, 0x00, 0x08, 0x48, 0x10, 0x00, 0x00, - 0x18, 0x48, 0x10, 0x00, 0x00, 0xf0, 0xcf, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x04, 0x00, 0x10, 0x00, - 0x20, 0x04, 0x00, 0x10, 0x00, 0x20, 0x04, 0x00, 0x10, 0x00, 0x20, 0x04, - 0x00, 0x10, 0x00, 0x20, 0x04, 0xf0, 0x13, 0xe0, 0x23, 0x04, 0x10, 0xf0, - 0x33, 0x22, 0x04, 0x10, 0x30, 0x16, 0x23, 0x04, 0x10, 0x10, 0xf4, 0x21, - 0x0c, 0xf0, 0x11, 0x14, 0x20, 0x08, 0x00, 0x13, 0x34, 0xc0, 0x39, 0x00, - 0x1a, 0xe4, 0x03, 0x00, 0xfc, 0x11, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/dev/xif/tool0 b/dev/xif/tool0 deleted file mode 100644 index 91b2e5b73121239c8b2925b6cec75dd4b5d69556..0000000000000000000000000000000000000000 --- a/dev/xif/tool0 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool0_width 24 -#define tool0_height 24 -static unsigned char tool0_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x31, 0x00, 0x00, - 0xf1, 0x01, 0x00, 0xe1, 0x0f, 0x00, 0xe1, 0x3f, 0x00, 0xe1, 0x1f, 0x00, - 0xc1, 0x0f, 0x00, 0xc1, 0x0f, 0x00, 0xc1, 0x1f, 0x00, 0x81, 0x39, 0x00, - 0x81, 0x70, 0x00, 0x01, 0xe0, 0x00, 0x01, 0xc0, 0x01, 0x01, 0x80, 0x03, - 0x01, 0x00, 0x07, 0x01, 0x00, 0x0e, 0x01, 0x00, 0x1c, 0x01, 0x00, 0x08, - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool1 b/dev/xif/tool1 deleted file mode 100644 index 07071293c872dae44248483c8d20f4545a2d7fc7..0000000000000000000000000000000000000000 --- a/dev/xif/tool1 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool1_width 24 -#define tool1_height 24 -static unsigned char tool1_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x19, 0x00, 0x18, - 0x39, 0x00, 0x1c, 0x71, 0x00, 0x0e, 0xe1, 0x00, 0x07, 0xc1, 0x81, 0x03, - 0x81, 0xc3, 0x01, 0x01, 0xe7, 0x00, 0x01, 0x7e, 0x00, 0x01, 0x3c, 0x00, - 0x01, 0x3c, 0x00, 0x01, 0x7e, 0x00, 0x01, 0xe7, 0x00, 0x81, 0xc3, 0x01, - 0xc1, 0x81, 0x03, 0xe1, 0x00, 0x07, 0x71, 0x00, 0x0e, 0x39, 0x00, 0x1c, - 0x19, 0x00, 0x18, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool2 b/dev/xif/tool2 deleted file mode 100644 index a4fc3d7281605608c0f65c448aa0246d49838ce5..0000000000000000000000000000000000000000 --- a/dev/xif/tool2 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool2_width 24 -#define tool2_height 24 -static unsigned char tool2_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, - 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, - 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0xfd, 0xff, 0x3f, - 0xfd, 0xff, 0x3f, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, - 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, - 0x01, 0x18, 0x00, 0x01, 0x18, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool3 b/dev/xif/tool3 deleted file mode 100644 index 2d82aade35e93bb1a7c0bc29cc261cc0e3dfd5cf..0000000000000000000000000000000000000000 --- a/dev/xif/tool3 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool3_width 24 -#define tool3_height 24 -static unsigned char tool3_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x7c, 0x00, - 0x01, 0xff, 0x01, 0xc1, 0x83, 0x07, 0xc1, 0x00, 0x06, 0x61, 0x00, 0x0c, - 0x61, 0x00, 0x0c, 0x31, 0x00, 0x18, 0x31, 0x00, 0x18, 0x31, 0x00, 0x18, - 0x31, 0x00, 0x18, 0x31, 0x00, 0x18, 0x61, 0x00, 0x0c, 0x61, 0x00, 0x0c, - 0xc1, 0x00, 0x06, 0xc1, 0x83, 0x07, 0x01, 0xff, 0x01, 0x01, 0x7c, 0x00, - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool4 b/dev/xif/tool4 deleted file mode 100644 index 09380b0bb0deb3ead848e61de344a019f4d80fb2..0000000000000000000000000000000000000000 --- a/dev/xif/tool4 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool4_width 24 -#define tool4_height 24 -static unsigned char tool4_bits[] = { - 0x01, 0x00, 0x00, 0x81, 0x3b, 0x00, 0x81, 0x2e, 0x00, 0x81, 0xa6, 0x07, - 0xc1, 0xe6, 0x04, 0x41, 0x64, 0x04, 0x41, 0x64, 0x1c, 0x79, 0x44, 0x24, - 0x6d, 0x44, 0x24, 0x45, 0x44, 0x24, 0x45, 0x40, 0x36, 0x05, 0x00, 0x16, - 0x09, 0x00, 0x10, 0x09, 0x00, 0x10, 0x19, 0x00, 0x18, 0x31, 0x00, 0x0c, - 0x21, 0x00, 0x06, 0x61, 0x80, 0x03, 0xc1, 0xc0, 0x00, 0xe1, 0xff, 0x00, - 0x31, 0x80, 0x01, 0x31, 0x80, 0x01, 0xf1, 0xff, 0x01, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool5 b/dev/xif/tool5 deleted file mode 100644 index 20996ca25aab94cd734884d7baa17fb1a57a272f..0000000000000000000000000000000000000000 --- a/dev/xif/tool5 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool5_width 24 -#define tool5_height 24 -static unsigned char tool5_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0xf1, 0x80, 0x0f, - 0x19, 0xc3, 0x18, 0x05, 0x66, 0x20, 0x05, 0x3c, 0x20, 0x05, 0x18, 0x20, - 0x05, 0x18, 0x20, 0x05, 0x00, 0x20, 0x0d, 0x00, 0x20, 0x09, 0x00, 0x10, - 0x19, 0x00, 0x18, 0x31, 0x00, 0x08, 0x21, 0x00, 0x0c, 0x61, 0x00, 0x06, - 0xc1, 0x00, 0x03, 0x81, 0x81, 0x01, 0x01, 0x63, 0x00, 0x01, 0x3c, 0x00, - 0x01, 0x18, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/tool6 b/dev/xif/tool6 deleted file mode 100644 index 91e74890146d4dfe47e471f52fd657211c4f8ed2..0000000000000000000000000000000000000000 --- a/dev/xif/tool6 +++ /dev/null @@ -1,9 +0,0 @@ -#define tool6_width 24 -#define tool6_height 24 -static unsigned char tool6_bits[] = { - 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0xf9, 0xff, 0x1f, - 0x09, 0x00, 0x00, 0xe9, 0xff, 0x1f, 0x29, 0x00, 0x10, 0xa9, 0xff, 0x17, - 0xa9, 0x00, 0x14, 0xa9, 0xfe, 0x15, 0xa9, 0x02, 0x15, 0xa9, 0x7a, 0x15, - 0xa9, 0x5a, 0x15, 0xa9, 0x42, 0x15, 0xa9, 0x7e, 0x15, 0xa9, 0x00, 0x15, - 0xa9, 0xff, 0x15, 0x29, 0x00, 0x14, 0xe9, 0xff, 0x17, 0x09, 0x00, 0x10, - 0xf9, 0xff, 0x1f, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00}; diff --git a/dev/xif/view-icon b/dev/xif/view-icon deleted file mode 100644 index 739d26e5da47932d98ba78290c64aa7ffad3d8ec..0000000000000000000000000000000000000000 --- a/dev/xif/view-icon +++ /dev/null @@ -1,20 +0,0 @@ -#define view_icon_width 40 -#define view_icon_height 40 -static unsigned char view_icon_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x08, 0x7e, 0x00, 0x00, 0x08, 0x88, 0x41, 0x00, 0x00, 0x08, 0x88, 0x40, - 0x00, 0x00, 0x08, 0x8c, 0x40, 0x00, 0x00, 0x08, 0x44, 0x40, 0x00, 0x00, - 0x18, 0x46, 0x60, 0x00, 0x00, 0xf0, 0xc3, 0x20, 0x00, 0x00, 0x00, 0x80, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x20, 0x18, 0x00, 0x00, 0x00, - 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x40, 0x10, 0x08, 0xc3, 0x4c, 0x40, 0x10, 0x08, - 0x41, 0x48, 0x40, 0x10, 0x08, 0x41, 0xcc, 0x40, 0x10, 0x88, 0xc1, 0x87, - 0x40, 0x30, 0x8c, 0x40, 0x80, 0x4c, 0x20, 0x84, 0xc0, 0x80, 0x4f, 0x20, - 0x82, 0x80, 0x01, 0x5b, 0x60, 0x83, 0x00, 0x3f, 0x33, 0x80, 0x81, 0x03, - 0x00, 0x22, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/dev/xif/xgraph.cc b/dev/xif/xgraph.cc deleted file mode 100644 index 46d6527af8865518b224a6c7c1e7270b32dc6120..0000000000000000000000000000000000000000 --- a/dev/xif/xgraph.cc +++ /dev/null @@ -1,1891 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xgraph.c */ -/* */ -/* Purpose: graphical output for ug based on X11 */ -/* */ -/* Author: Peter Bastian / Klaus Johannsen */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 17.02.94 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* this version uses read only color cells, therefore no */ -/* it does not allow to change the color table during run time */ -/* */ -/* Changing text size is not supported yet */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -/* X11 includes */ -#include <config.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/keysym.h> -#include <X11/cursorfont.h> -#include <X11/X.h> - -/* standard C includes */ -#include <cstdio> -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#include <cstddef> -#include <cstring> - -/* interface includes */ -#include "ugtypes.h" -#include "ugdevices.h" -#include "initdev.h" -#include "general.h" -#include "debug.h" -#include "commands.h" -#include "pixel.h" - -/* Xif includes */ -#include "xmain.h" -#include "xgraph.h" - -USING_UG_NAMESPACES - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define CSIZE 256 /* ug supports at most 256 colors */ - -#define DEFAULTXPOS 50 -#define DEFAULTYPOS 100 -#define DEFAULTFONT "9x15" -#define DEFAULTMINX 100 -#define DEFAULTMINY 100 -#define DEFAULTBORDER 4 -#define GRAPHICONNAME "ug3 view" -#define GRAPHWINNAME "ug3 view" -#define RESOURCENAME "ug3" - -#define NTOOLS 7 /* this is the number of tools */ - -/* bitmaps for icons */ -#include "view-icon" -#include "tool0" -#include "tool1" -#include "tool2" -#include "tool3" -#include "tool4" -#include "tool5" -#include "tool6" -#include "shades.h" - -/* hack for C++ */ -#define CLASS c_class - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -/* current context */ -static GraphWindow *gw; /* active output */ -static XColor ctab[CSIZE]; /* one static color table for all wi*/ -static int ncolors=0; /* number of entries used */ -static unsigned long pixels[CSIZE]; /* array to free color cells */ -static OUTPUTDEVICE *X11OutputDevice; /* outputdevice that has been initi */ -static GraphWindow *windowList=NULL; /* list of our windows */ -static Visual *default_visual; -static int default_depth; - -static Pixmap tools[NTOOLS]; /* bitmaps for toolbox */ -static Cursor cursors[NTOOLS]; /* id in cursor font */ - -static int MoveMouse = 1; /* some local vars for mouse ops */ -static int StoredMousePos = 0; -static int MouseX,MouseY; - -static Colormap our_cmap; /* may be a private one */ -static int true_color; /* whether we have true color visual */ -static int current_color; /* index to current foreground color */ - -/* pixmaps for shading patterns */ -static Pixmap pattern[NO_PATTERNS]; - -/* pixel structure for true color visual */ -static unsigned long red_mask, green_mask, blue_mask; -static int red_shift, green_shift, blue_shift; - - -unsigned long NS_PREFIX UGBlack (void) -{ - return(ctab[X11OutputDevice->black].pixel); -} - -unsigned long NS_PREFIX UGWhite (void) -{ - return(ctab[X11OutputDevice->white].pixel); -} - -/*==========================================================================*/ -/* */ -/* Initialization and port functions */ -/* */ -/*==========================================================================*/ - -static void IFMove (SHORT_POINT point) -{ - gw->x = (int) point.x; - gw->y = (int) point.y; -} - -static void IFDraw (SHORT_POINT point) -{ - int x1, y1, x2, y2; - - /* always draw from left to right to get the same pixels */ - if (point.x <= gw->x) { - x1 = point.x; y1 = point.y; - x2 = gw->x; y2 = gw->y; - } - else { - x1 = gw->x; y1 = gw->y; - x2 = point.x; y2 = point.y; - } - XDrawLine(display,gw->win,gw->gc,x1,y1,x2,y2); - if (!gw->backing_store) - XDrawLine(display,gw->pixmap,gw->gc,x1,y1,x2,y2); - gw->x = (int) point.x; - gw->y = (int) point.y; -} - -static void IFPolyline (SHORT_POINT *points, INT n) -{ - XDrawLines(display,gw->win,gw->gc,(XPoint *)points,n,CoordModeOrigin); - if (!gw->backing_store) - XDrawLines(display,gw->pixmap,gw->gc,(XPoint *)points,n,CoordModeOrigin); -} - -static void IFInversePolyline (SHORT_POINT *points, INT n) -{ - XGCValues values_return; - unsigned long valuemask,plane_mask; - int function; - - valuemask = GCPlaneMask; - XGetGCValues(display,gw->gc,valuemask,&values_return); - plane_mask = values_return.plane_mask; - valuemask = GCFunction; - XGetGCValues(display,gw->gc,valuemask,&values_return); - function = values_return.function; - XSetFunction(display,gw->gc,GXinvert); - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLines(display,gw->win,gw->gc,(XPoint *)points,n,CoordModeOrigin); - if (!gw->backing_store) - XDrawLines(display,gw->pixmap,gw->gc,(XPoint *)points,n,CoordModeOrigin); - XSetFunction(display,gw->gc,function); - XSetPlaneMask(display,gw->gc,plane_mask); -} - -static void IFPolygon (SHORT_POINT *points, INT n) -{ - XFillPolygon(display,gw->win,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - if (!gw->backing_store) - XFillPolygon(display,gw->pixmap,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); -} - -static void IFShadedPolygon(SHORT_POINT *points, INT n, DOUBLE intensity) -{ - if (!true_color) { - int s; - - XSetBackground(display,gw->gc,ctab[X11OutputDevice->black].pixel); - s = (int)(0.5 + intensity * (DOUBLE)(NO_PATTERNS-1)); - XSetFillStyle(display, gw->gc, FillOpaqueStippled); - XSetStipple(display, gw->gc, pattern[s]); - XFillPolygon(display,gw->win,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - if (!gw->backing_store) - XFillPolygon(display,gw->pixmap,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - XSetFillStyle(display, gw->gc, FillSolid); - XSetBackground(display,gw->gc,ctab[X11OutputDevice->white].pixel); - } - else { - unsigned long pixel; - DOUBLE red, green, blue; - - pixel = ctab[current_color].pixel; - red = (pixel & red_mask ) >> red_shift; - green = (pixel & green_mask) >> green_shift; - blue = (pixel & blue_mask ) >> blue_shift; - red *= intensity; - green *= intensity; - blue *= intensity; - pixel = ((unsigned long)(red +0.5) << red_shift ) + - ((unsigned long)(green+0.5) << green_shift) + - ((unsigned long)(blue +0.5) << blue_shift ); - XSetForeground(display, gw->gc, pixel); - XFillPolygon(display, gw->win, gw->gc, (XPoint *)points, n, Convex, CoordModeOrigin); - if (!gw->backing_store) - XFillPolygon(display,gw->pixmap,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - XSetForeground(display, gw->gc, ctab[current_color].pixel); - } -} - -static void IFInversePolygon (SHORT_POINT *points, INT n) -{ - XGCValues values_return; - unsigned long valuemask,plane_mask; - int function; - - valuemask = GCPlaneMask; - XGetGCValues(display,gw->gc,valuemask,&values_return); - plane_mask = values_return.plane_mask; - valuemask = GCFunction; - XGetGCValues(display,gw->gc,valuemask,&values_return); - function = values_return.function; - XSetFunction(display,gw->gc,GXinvert); - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XFillPolygon(display,gw->win,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - if (!gw->backing_store) - XFillPolygon(display,gw->pixmap,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - XSetFunction(display,gw->gc,function); - XSetPlaneMask(display,gw->gc,plane_mask); -} - -static void IFErasePolygon (SHORT_POINT *points, INT n) -{ - XGCValues gcv; - - XGetGCValues(display, gw->gc, GCForeground|GCBackground, &gcv); - XSetForeground(display,gw->gc,gcv.background); - XFillPolygon(display,gw->win,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - XDrawLines(display,gw->win,gw->gc,(XPoint *)points,n,CoordModeOrigin); - XDrawLine(display,gw->win,gw->gc,(int)points[n-1].x,(int)points[n-1].y,(int)points[0].x,(int)points[0].y); - if (!gw->backing_store) { - XFillPolygon(display,gw->pixmap,gw->gc,(XPoint *)points,n,Convex,CoordModeOrigin); - XDrawLines(display,gw->pixmap,gw->gc,(XPoint *)points,n,CoordModeOrigin); - XDrawLine(display,gw->pixmap,gw->gc,(int)points[n-1].x,(int)points[n-1].y,(int)points[0].x,(int)points[0].y); - } - XSetForeground(display,gw->gc,gcv.foreground); -} - -static void Marker (short n, short s, SHORT_POINT point) -{ - short x,y; - short top, left, bottom, right; - - x = point.x; - y = point.y; - top = y-s/2; bottom = y+s/2; - left = x-s/2; right = x+s/2; - n = n%11; - - switch (n) - { - case 0 : - XDrawRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XDrawRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case 1 : - XDrawRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XDrawRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case 2 : - XFillRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XFillRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case 3 : - XDrawArc( display, gw->win, gw->gc, left, top, s, s, 0, 360*64); - if (!gw->backing_store) - XDrawArc( display, gw->pixmap, gw->gc, left, top, s, s, 0, 360*64); - break; - case 4 : - XDrawArc( display, gw->win, gw->gc, left, top, s, s, 0, 360*64); - if (!gw->backing_store) - XDrawArc( display, gw->pixmap, gw->gc, left, top, s, s, 0, 360*64); - break; - case 5 : - XFillArc( display, gw->win, gw->gc, left, top, s+1, s+1, 0, 360*64); - if (!gw->backing_store) - XFillArc( display, gw->pixmap, gw->gc, left, top, s+1, s+1, 0, 360*64); - break; - case 6 : - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case 7 : - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case 8 : - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case 9 : - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x+s/2, y); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x+s/2, y); - } - break; - case 10 : - XDrawLine( display, gw->win, gw->gc, x-s/2, y+s/2, x+s/2, y-s/2); - XDrawLine( display, gw->win, gw->gc, x-s/2, y-s/2, x+s/2, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y+s/2, x+s/2, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y-s/2, x+s/2, y+s/2); - } - break; - } -} - - -static void IFPolymark (short n, SHORT_POINT *points) -{ - int i; - - for (i=0; i<n; i++) Marker(gw->marker_id,gw->marker_size,points[i]); -} - -static void InvMarker (short n, short s, SHORT_POINT point) -{ - XGCValues values_return; - unsigned long valuemask,plane_mask; - int function; - short x,y; - short top, left, bottom, right; - - x = point.x; - y = point.y; - top = y-s/2; bottom = y+s/2; - left = x-s/2; right = x+s/2; - n = n%11; - - /* save values */ - valuemask = GCPlaneMask; - XGetGCValues(display,gw->gc,valuemask,&values_return); - plane_mask = values_return.plane_mask; - valuemask = GCFunction; - XGetGCValues(display,gw->gc,valuemask,&values_return); - function = values_return.function; - XSetFunction(display,gw->gc,GXinvert); - - switch (n) - { - case EMPTY_SQUARE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XDrawRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case GRAY_SQUARE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XDrawRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case FILLED_SQUARE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XFillRectangle(display, gw->win, gw->gc, left, top, s, s); - if (!gw->backing_store) - XFillRectangle(display, gw->pixmap, gw->gc, left, top, s, s); - break; - case EMPTY_CIRCLE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawArc( display, gw->win, gw->gc, left, top, s, s, 0, 360*64); - if (!gw->backing_store) - XDrawArc( display, gw->pixmap, gw->gc, left, top, s, s, 0, 360*64); - break; - case GRAY_CIRCLE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawArc( display, gw->win, gw->gc, left, top, s, s, 0, 360*64); - if (!gw->backing_store) - XDrawArc( display, gw->pixmap, gw->gc, left, top, s, s, 0, 360*64); - break; - case FILLED_CIRCLE_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XFillArc( display, gw->win, gw->gc, left, top, s+1, s+1, 0, 360*64); - if (!gw->backing_store) - XFillArc( display, gw->pixmap, gw->gc, left, top, s+1, s+1, 0, 360*64); - break; - case EMPTY_RHOMBUS_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case GRAY_RHOMBUS_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case FILLED_RHOMBUS_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->win, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x+s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x+s/2, y, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x, y-s/2, x-s/2, y); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x, y+s/2); - } - break; - case PLUS_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLine( display, gw->win, gw->gc, x, y+s/2, x, y-s/2); - XDrawLine( display, gw->win, gw->gc, x-s/2, y, x+s/2, y); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x, y+s/2, x, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y, x+s/2, y); - } - break; - case CROSS_MARKER : - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawLine( display, gw->win, gw->gc, x-s/2, y+s/2, x+s/2, y-s/2); - XDrawLine( display, gw->win, gw->gc, x-s/2, y-s/2, x+s/2, y+s/2); - if (!gw->backing_store) { - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y+s/2, x+s/2, y-s/2); - XDrawLine( display, gw->pixmap, gw->gc, x-s/2, y-s/2, x+s/2, y+s/2); - } - break; - } - /* restore values */ - XSetFunction(display,gw->gc,function); - XSetPlaneMask(display,gw->gc,plane_mask); -} - - -static void IFInvPolymark (short n, SHORT_POINT *points) -{ - int i; - - for (i=0; i<n; i++) Marker(gw->marker_id,gw->marker_size,points[i]); -} - -static void IFDrawText (const char *s, INT mode) -{ - XGCValues values_return; - unsigned long valuemask,plane_mask; - int function; - - if (mode==TEXT_REGULAR) - { - XDrawString(display,gw->win,gw->gc,gw->x,gw->y,s,strlen(s)); - if (!gw->backing_store) - XDrawString(display,gw->pixmap,gw->gc,gw->x,gw->y,s,strlen(s)); - } - else - { - valuemask = GCPlaneMask; - XGetGCValues(display,gw->gc,valuemask,&values_return); - plane_mask = values_return.plane_mask; - valuemask = GCFunction; - XGetGCValues(display,gw->gc,valuemask,&values_return); - function = values_return.function; - XSetFunction(display,gw->gc,GXinvert); - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawString(display,gw->win,gw->gc,gw->x,gw->y,s,strlen(s)); - if (!gw->backing_store) - XDrawString(display,gw->pixmap,gw->gc,gw->x,gw->y,s,strlen(s)); - XSetFunction(display,gw->gc,function); - XSetPlaneMask(display,gw->gc,plane_mask); - } -} - -static void IFCenteredText (SHORT_POINT point, const char *s, INT mode) -{ - int ts,w; - XGCValues values_return; - unsigned long valuemask,plane_mask; - int function; - - w = XTextWidth(gw->font_info,s,strlen(s)); - ts = gw->font_height; - if (mode==TEXT_REGULAR) - { - XDrawString(display,gw->win,gw->gc,((int)point.x)-w/2,((int)point.y)+ts/2,s,strlen(s)); - if (!gw->backing_store) - XDrawString(display,gw->pixmap,gw->gc,((int)point.x)-w/2,((int)point.y)+ts/2,s,strlen(s)); - } - else - { - valuemask = GCPlaneMask; - XGetGCValues(display,gw->gc,valuemask,&values_return); - plane_mask = values_return.plane_mask; - valuemask = GCFunction; - XGetGCValues(display,gw->gc,valuemask,&values_return); - function = values_return.function; - XSetFunction(display,gw->gc,GXinvert); - XSetPlaneMask(display,gw->gc,0xFFFFFFFF); - XDrawString(display,gw->win,gw->gc,((int)point.x)-w/2,((int)point.y)+ts/2,s,strlen(s)); - if (!gw->backing_store) - XDrawString(display,gw->pixmap,gw->gc,((int)point.x)-w/2,((int)point.y)+ts/2,s,strlen(s)); - XSetFunction(display,gw->gc,function); - XSetPlaneMask(display,gw->gc,plane_mask); - } -} - -static void IFClearViewPort (void) -{ - XClearArea(display,gw->win,0,0,gw->window_width,gw->window_height-CONTROLSIZE-1,0); -} - -static void IFSetLineWidth (short w) -{ - XGCValues gcv; - if (w==1) - gcv.line_width = 0; - else - gcv.line_width = (int)w; - XChangeGC( display, gw->gc, GCLineWidth, &gcv); -} - -static void IFSetTextSize (short s) -{ - return; -} - -static void IFSetMarkerSize (short s) -{ - gw->marker_size = s; - return; -} - -static void IFSetMarker (short s) -{ - gw->marker_id = s; - return; -} - -static void IFSetColor (long index) -{ - if (index<0 || index>=CSIZE) - return; - XSetForeground(display,gw->gc,ctab[(int)index].pixel); - current_color = index; -} - -static void IFSetPaletteEntry (long index, short r, short g, short b) -{ - return; -} - -static void IFSetNewPalette (long start, long count, short *r, short *g, short *b) -{ - return; -} - -static void IFGetPaletteEntry (long index, short *r, short *g, short *b) -{ - *r = (short) ctab[(int)index].red>>8; - *g = (short) ctab[(int)index].green>>8; - *b = (short) ctab[(int)index].blue>>8; -} - -static void IFFlush (void) -{ - if (gw->gc==NULL) return; - XFlushGC(display,gw->gc); - return; -} - -/*--------------------------------------------------------------------------* -* Convert pixel buffer to XImage data: one has to copy the 16 or 32 * -* lower bits of the pixel values keeping the clients byte order. * -*--------------------------------------------------------------------------*/ - -static void MakeXImageData(void *buffer, void *data, int len, int pad) -{ - int i, c; - unsigned long pixel, r, g, b, f; - char *d; - PIXEL *p; - - p = (PIXEL *)buffer; - d = (char *)data; - - for (i = 0; i < len; i++) { - c = p->cindex; - f = p->intensity; - p++; - r = (ctab[c].pixel & red_mask ) >> red_shift; - g = (ctab[c].pixel & green_mask) >> green_shift; - b = (ctab[c].pixel & blue_mask ) >> blue_shift; - r = r*f/255; - g = g*f/255; - b = b*f/255; - pixel = (r << red_shift) + (g << green_shift) + (b << blue_shift); - switch (pad) - { - case 16 : -#ifdef __SWAPBYTES__ - d[0] = ((char*)&pixel)[0]; - d[1] = ((char*)&pixel)[1]; -#else - d[0] = ((char*)&pixel)[sizeof(pixel)-2]; - d[1] = ((char*)&pixel)[sizeof(pixel)-1]; -#endif - d += 2; - break; - case 32 : -#ifdef __SWAPBYTES__ - d[0] = ((char*)&pixel)[0]; - d[1] = ((char*)&pixel)[1]; - d[2] = ((char*)&pixel)[2]; - d[3] = ((char*)&pixel)[3]; -#else - d[0] = ((char*)&pixel)[sizeof(pixel)-4]; - d[1] = ((char*)&pixel)[sizeof(pixel)-3]; - d[2] = ((char*)&pixel)[sizeof(pixel)-2]; - d[3] = ((char*)&pixel)[sizeof(pixel)-1]; -#endif - d += 4; - } - - } -} - -/*--------------------------------------------------------------------------* -* write the pixel buffer to the screen * -*--------------------------------------------------------------------------*/ - -static void IFPlotPixelBuffer(void *buffer, void *data, - int x, int y, int w, int h) -{ - HEAP *heap; - XImage *image; - int bitmap_pad; - INT mem_allocated, key; - - /* We support only TrueColor, this is 2004! */ - if (default_visual->CLASS != TrueColor) { - UserWrite("IFPlotPixelBuffer: Sorry, only TrueColor visuals supported.\n"); - return; - } - - /* how many bits per pixel do we need? */ - if (default_depth <= 16) - bitmap_pad = 16; - else - bitmap_pad = 32; - - /* allocate mem for XImage data if necessary */ - mem_allocated = NO; - if (data == NULL) { - heap = GetCurrentMultigrid()->theHeap; - MarkTmpMem(heap, &key); - if ((data = GetTmpMem(heap, w*h*bitmap_pad/8, key)) == NULL) { - UserWrite("IFPlotPixelBuffer: Sorry, not enough memory.\n"); - ReleaseTmpMem(heap, key); - return; - } - mem_allocated = YES; - } - - MakeXImageData(buffer, data, w*h, bitmap_pad); - - /* create XImage structure and write image to the screen */ - image = XCreateImage(display, default_visual, default_depth, ZPixmap, 0, - (char*)data, w, h, bitmap_pad, 0); -#ifdef __SWAPBYTES__ - image->byte_order = LSBFirst; -#else - image->byte_order = MSBFirst; -#endif - XPutImage(display, gw->win, gw->gc, image, 0, 0, x, y, w, h); - if (!gw->backing_store) - XPutImage(display, gw->pixmap, gw->gc, image, 0, 0, x, y, w, h); - image->data = NULL; - XDestroyImage(image); - - if (mem_allocated) ReleaseTmpMem(heap, key); -} - -/*--------------------------------------------------------------------------*/ - -static int get_component_shift(unsigned long mask) -{ - int shift; - - shift=0; - while (!(mask & 1)) { - shift++; - mask >>= 1; - } - return shift; -} - -/****************************************************************************/ -/* - InitXPort - implement basic drawing functions by X11 - - SYNOPSIS: - void InitXPort (OUTPUTDEVICE *thePort); - - PARAMETERS: - . thePort - PORT structure to initialize - - DESCRIPTION: - This function implements basic drawing functions by X11. - - RETURN VALUE: - void - */ -/****************************************************************************/ - -static void InitXPort (OUTPUTDEVICE *thePort) -{ - Colormap default_cmap; - int i,j,Private; - unsigned short res,delta,max,r,g,b; - - if (ncolors!=0) return; - - thePort->signx = 1; - thePort->signy = -1; - - /* init color table */ - ncolors = 0; - - /* get default values */ - default_depth = DefaultDepth(display,screen_num); - default_visual = DefaultVisual(display,screen_num); - default_cmap = DefaultColormap(display,screen_num); - - /* print display type */ - switch (default_visual->CLASS) - { - case PseudoColor : - printf("visual=%s depth=%d\n","PseudoColor",default_depth); - break; - case GrayScale : - printf("visual=%s depth=%d\n","GrayScale",default_depth); - break; - case DirectColor : - printf("visual=%s depth=%d\n","DirectColor",default_depth); - break; - case TrueColor : - printf("visual=%s depth=%d\n","TrueColor",default_depth); - break; - case StaticGray : - printf("visual=%s depth=%d\n","StaticGray",default_depth); - break; - case StaticColor : - printf("visual=%s depth=%d\n","StaticColor",default_depth); - break; - default : - printf("visual=%s depth=%d\n","unknown",default_depth); - break; - } - - /* get info on pixel structure if true color */ - if (true_color = (default_visual->CLASS == TrueColor)) { - red_mask = default_visual->red_mask; - green_mask = default_visual->green_mask; - blue_mask = default_visual->blue_mask; - - red_shift = get_component_shift(red_mask); - green_shift= get_component_shift(green_mask); - blue_shift = get_component_shift(blue_mask); - } - - our_cmap = default_cmap; - - /* check for B&W */ - if (default_depth==1) - { - ncolors = 2; - ctab[0].pixel = WhitePixel(display,screen_num); - ctab[0].red = 0xFFFF; - ctab[0].green = 0xFFFF; - ctab[0].blue = 0xFFFF; - ctab[1].pixel = BlackPixel(display,screen_num); - ctab[1].red = 0; - ctab[1].green = 0; - ctab[1].blue = 0; - thePort->black = 1; - thePort->gray = 1; - thePort->white = 0; - thePort->red = 1; - thePort->green = 1; - thePort->blue = 1; - thePort->cyan = 1; - thePort->orange = 1; - thePort->yellow = 1; - thePort->darkyellow = 1; - thePort->magenta = 1; - thePort->hasPalette = 0; - thePort->range = 2; - thePort->spectrumStart = 0; - thePort->spectrumEnd = 1; - printf("Using B&W color map\n"); - } - - if ((default_depth>=6)&&(ncolors==0)&&((default_visual->CLASS==GrayScale)||(default_visual->CLASS==StaticGray))) - { - /* lets try 64 gray scale map */ - ncolors = 64; - for (i=0; i<64; i++) - { - ctab[63-i].red = 1024*i; - ctab[63-i].green = 1024*i; - ctab[63-i].blue = 1024*i; - if (XAllocColor(display,our_cmap,&(ctab[i]))==0) - { - ncolors = 0; - for (j=0; j<i; j++) pixels[j] = ctab[j].pixel; - XFreeColors(display,our_cmap,pixels,i,0); - break; - } - } - thePort->black = 63; - thePort->gray = 48; - thePort->white = 0; - thePort->red = 36; - thePort->green = 27; - thePort->blue = 54; - thePort->cyan = 18; - thePort->yellow = 9; - thePort->darkyellow = 10; - thePort->magenta = 42; - thePort->orange = 29; - thePort->hasPalette = 1; - thePort->range = 64; - thePort->spectrumStart = 6; - thePort->spectrumEnd = 63; - if (ncolors>0) printf("Using 64 grayscale color map\n"); - } - - if ((default_depth>=4)&&(ncolors==0)&&((default_visual->CLASS==GrayScale)||(default_visual->CLASS==StaticGray))) - { - /* lets try a 16 gray scale map */ - ncolors = 16; - for (i=0; i<16; i++) - { - ctab[15-i].red = 4096*i; - ctab[15-i].green = 4096*i; - ctab[15-i].blue = 4096*i; - if (XAllocColor(display,our_cmap,&(ctab[i]))==0) - { - ncolors = 0; - for (j=0; j<i; j++) pixels[j] = ctab[j].pixel; - XFreeColors(display,our_cmap,pixels,i,0); - break; - } - } - thePort->black = 15; - thePort->gray = 13; - thePort->white = 0; - thePort->red = 11; - thePort->green = 9; - thePort->blue = 13; - thePort->cyan = 5; - thePort->yellow = 5; - thePort->darkyellow = 5; - thePort->magenta = 7; - thePort->orange = 10; - thePort->hasPalette = 1; - thePort->range = 16; - thePort->spectrumStart = 1; - thePort->spectrumEnd = 15; - if (ncolors>0) printf("Using 16 grayscale color map\n"); - } - - if ((default_depth>=8)&&(ncolors==0)) - { - /* should be a color device */ - res = 31; - delta = 2048; - max = 63488; - - /* fixed colors */ - i = 0; - ctab[i].red = 0xFFFF; ctab[i].green = 0xFFFF; ctab[i].blue = 0xFFFF; i++; - ctab[i].red = 0xD000; ctab[i].green = 0xD000; ctab[i].blue = 0xD000; i++; - ctab[i].red = 0xFFFF; ctab[i].green = 0xFFFF; ctab[i].blue = 0x0 ; i++; - ctab[i].red = 0xFFFF; ctab[i].green = 0x0 ; ctab[i].blue = 0xFFFF; i++; - ctab[i].red = 0xFFFF; ctab[i].green = 0x0 ; ctab[i].blue = 0x0 ; i++; - ctab[i].red = 0x0 ; ctab[i].green = 0xFFFF; ctab[i].blue = 0xFFFF; i++; - ctab[i].red = 0x0 ; ctab[i].green = 0xFFFF; ctab[i].blue = 0x0 ; i++; - ctab[i].red = 0x0 ; ctab[i].green = 0x0 ; ctab[i].blue = 0xFFFF; i++; - ctab[i].red = 0x0 ; ctab[i].green = 0x0 ; ctab[i].blue = 0x0 ; i++; - ctab[i].red = 65520 ; ctab[i].green = 32240 ; ctab[i].blue = 0x0 ; i++; - ctab[i].red = 65520 ; ctab[i].green = 60000 ; ctab[i].blue = 0x0 ; i++; - - /* color spectrum */ - r = g = 0; b = max; - ctab[i].red = r; ctab[i].green = g; ctab[i].blue = b; i++; - - /* blau nach cyan */ - for (j=0; j<res; j++) - { - g += delta; - ctab[i].red = r; ctab[i].green = g; ctab[i].blue = b; i++; - } - /* cyan nach gruen */ - for (j=0; j<res; j++) - { - b -= delta; - ctab[i].red = r; ctab[i].green = g; ctab[i].blue = b; i++; - } - /* gruen nach gelb */ - for (j=0; j<res; j++) - { - r += delta; - ctab[i].red = r; ctab[i].green = g; ctab[i].blue = b; i++; - } - /* gelb nach rot */ - for (j=0; j<res; j++) - { - g -= delta; - ctab[i].red = r; ctab[i].green = g; ctab[i].blue = b; i++; - } - - thePort->black = 8; - thePort->gray = 1; - thePort->white = 0; - thePort->red = 4; - thePort->green = 6; - thePort->blue = 7; - thePort->cyan = 5; - thePort->yellow = 2; - thePort->darkyellow = 10; - thePort->magenta = 3; - thePort->orange = 9; - thePort->hasPalette = 1; - thePort->range = i; - thePort->spectrumStart = 11; - thePort->spectrumEnd = i-1; - - ncolors = i; - Private = NO; - - for (i=0; i<ncolors; i++) - if (!XAllocColor(display, our_cmap, &ctab[i])) { - Private = YES; - our_cmap = XCopyColormapAndFree(display, our_cmap); - i--; /* allocate the color that failed again! */ - } - - if (Private) - printf("Using private color map with %d entries\n",ncolors); - else - printf("Using default color map with %d entries\n",ncolors); - } - - if (ncolors==0) - { - /* settle with b&w */ - ncolors = 2; - ctab[0].pixel = WhitePixel(display,screen_num); - ctab[0].red = 0xFFFF; - ctab[0].green = 0xFFFF; - ctab[0].blue = 0xFFFF; - ctab[1].pixel = BlackPixel(display,screen_num); - ctab[1].red = 0; - ctab[1].green = 0; - ctab[1].blue = 0; - thePort->black = 1; - thePort->gray = 1; - thePort->white = 0; - thePort->red = 1; - thePort->green = 1; - thePort->blue = 1; - thePort->cyan = 1; - thePort->orange = 1; - thePort->yellow = 1; - thePort->darkyellow = 1; - thePort->magenta = 1; - thePort->hasPalette = 0; - thePort->range = 2; - thePort->spectrumStart = 0; - thePort->spectrumEnd = 1; - printf("Using B&W color map\n"); - } - - thePort->PixelRatio = 1; - - /* init pointers to basic drawing functions */ - thePort->Move = IFMove; - thePort->Draw = IFDraw; - thePort->Polyline = IFPolyline; - thePort->InversePolyline= IFInversePolyline; - thePort->Polygon = IFPolygon; - thePort->ShadedPolygon = IFShadedPolygon; - thePort->InversePolygon = IFInversePolygon; - thePort->ErasePolygon = IFErasePolygon; - thePort->Polymark = IFPolymark; - thePort->InvPolymark = IFInvPolymark; - thePort->DrawText = IFDrawText; - thePort->CenteredText = IFCenteredText; - thePort->ClearViewPort = IFClearViewPort; - - /* init pointers to set functions */ - thePort->SetLineWidth = IFSetLineWidth; - thePort->SetTextSize = IFSetTextSize; - thePort->SetMarker = IFSetMarker; - thePort->SetMarkerSize = IFSetMarkerSize; - thePort->SetColor = IFSetColor; - thePort->SetPaletteEntry = IFSetPaletteEntry; - thePort->SetNewPalette = IFSetNewPalette; - - /* init pointers to miscellaneous functions */ - thePort->GetPaletteEntry = IFGetPaletteEntry; - thePort->Flush = IFFlush; - thePort->PlotPixelBuffer = IFPlotPixelBuffer; -} - -/*==========================================================================*/ -/* */ -/* The windows controls (statistics, toolbox, ...) */ -/* */ -/*==========================================================================*/ - -/****************************************************************************/ -/* - InitControls - Load bitmaps from "tooli" include files - - SYNOPSIS: - int InitControls (Window win); - - PARAMETERS: - . win - - - DESCRIPTION: - This function loads bitmaps from "tooli" include files. - - RETURN VALUE: - int - .n 0 if ok - .n 1 if error occured. - */ -/****************************************************************************/ - -int NS_PREFIX InitControls (Window win) -{ - int i; - - /* make bitmaps from included files */ - tools[0] = XCreateBitmapFromData(display,win,(const char*)tool0_bits,tool0_width,tool0_height); - tools[1] = XCreateBitmapFromData(display,win,(const char*)tool1_bits,tool1_width,tool1_height); - tools[2] = XCreateBitmapFromData(display,win,(const char*)tool2_bits,tool2_width,tool2_height); - tools[3] = XCreateBitmapFromData(display,win,(const char*)tool3_bits,tool3_width,tool3_height); - tools[4] = XCreateBitmapFromData(display,win,(const char*)tool4_bits,tool4_width,tool4_height); - tools[5] = XCreateBitmapFromData(display,win,(const char*)tool5_bits,tool5_width,tool5_height); - tools[6] = XCreateBitmapFromData(display,win,(const char*)tool6_bits,tool6_width,tool6_height); - - /* set cursor id's */ - cursors[0] = XCreateFontCursor(display,XC_top_left_arrow); - cursors[1] = XCreateFontCursor(display,XC_X_cursor); - cursors[2] = XCreateFontCursor(display,XC_crosshair); - cursors[3] = XCreateFontCursor(display,XC_circle); - cursors[4] = XCreateFontCursor(display,XC_hand1); - cursors[5] = XCreateFontCursor(display,XC_heart); - cursors[6] = XCreateFontCursor(display,XC_box_spiral); - - /* make stipples for shading */ - if (!true_color) - for (i = 0; i < NO_PATTERNS; i++) - pattern[i] = XCreateBitmapFromData(display, win, (const char*)pattern_data[i], - PATTERN_SIZE, PATTERN_SIZE); - return 0; -} - -/****************************************************************************/ -/* - WhichTool - check if a tool has been hit - - SYNOPSIS: - int WhichTool (GraphWindow *gwin, int x, int y, int *tool); - - PARAMETERS: - . gwin - - . x - pointer to the array of coordinates - . y - pointer to the array of coordinates - . tool - return tool number - - RETURN VALUE: - INT - .n 0 if no tool has been hit - .n 1 if a valid tool number is returned in tool - */ -/****************************************************************************/ - -INT NS_PREFIX WhichTool (WINDOWID win, const INT mouse[2], INT *tool) -{ - GraphWindow *gwin; - int xx,yy,w,h,i; - - gwin = (GraphWindow *)(win); - - xx = gwin->window_width-NTOOLS*CONTROLSIZE; - yy = gwin->window_height-CONTROLSIZE; - w = mouse[0]-xx; - h = mouse[1]-yy; - - if ((h<0)||(h>=CONTROLSIZE)||(w<0)) return(0); - i = w/CONTROLSIZE; - if ((i<0)||(i>=NTOOLS)) return(0); - *tool = i; - return(1); -} - -/****************************************************************************/ -/* */ -/* Function: DrawRegion */ -/* */ -/* Purpose: check if draw region has been hit */ -/* */ -/* Input: GraphWindow *gwin the window */ -/* int x where */ -/* int y */ -/* */ -/* Output: 0: draw region has not been hit */ -/* 1: draw region has been hit */ -/* */ -/****************************************************************************/ - -int NS_PREFIX DrawRegion (GraphWindow *gwin, int x, int y) -{ - int xx,yy; - - xx = gwin->window_width; - yy = gwin->window_height-CONTROLSIZE; - - if ((x<0)||(x>xx)) return(0); - if ((y<0)||(y>yy)) return(0); - return(1); -} - -void NS_PREFIX DrawInfoBox (WINDOWID win, const char *info) -{ - GraphWindow *gwin; - XRectangle rect; - int h,x,y,w; - int ts; - - /*char buffer[INFO_SIZE]; - strncpy(buffer,info,INFO_SIZE); - buffer[INFO_LEN] = '\0';*/ - - gw = gwin = (GraphWindow *)(win); - - /* set clipping region to info box */ - rect.x = x = 0; - rect.y = y = gwin->window_height-CONTROLSIZE; - rect.width = w = gwin->window_width-NTOOLS*CONTROLSIZE; - rect.height = h = CONTROLSIZE-1; - XSetClipRectangles(display,gwin->gc,0,0,&rect,1,YSorted); - - /* erase info box */ - XClearArea(display,gwin->win,x,y,w,h,0); - - /* draw info string */ - IFSetColor(X11OutputDevice->black); - x = (gwin->window_width-NTOOLS*CONTROLSIZE)/2; - y = gwin->window_height-(CONTROLSIZE/2); - w = XTextWidth(gwin->font_info,info,strlen(info)); - ts = gwin->font_height; - XDrawString(display,gwin->win,gwin->gc,x-w/2,y+ts/2,info,strlen(info)); - if (!gwin->backing_store) - XDrawString(display,gwin->pixmap,gwin->gc,x-w/2,y+ts/2,info,strlen(info)); - /* restore clipping region */ - rect.x = 0; - rect.y = 0; - rect.width = gwin->window_width; - rect.height = gwin->window_height-CONTROLSIZE-1; - XSetClipRectangles(display,gwin->gc,0,0,&rect,1,YSorted); -} - -/*==========================================================================*/ -/* */ -/* Outputdevice functions */ -/* */ -/*==========================================================================*/ - -/****************************************************************************/ -/* */ -/* Function: WhichGW */ -/* */ -/* Purpose: return GraphWindow with a given window */ -/* */ -/* Input: Window win window to find */ -/* */ -/* Output: GraphWIndow * if found */ -/* NULL if not found */ -/* */ -/****************************************************************************/ - -GraphWindow *NS_PREFIX WhichGW (Window win) -{ - GraphWindow *g; - - for (g=windowList; g!=NULL; g=g->next) - if (g->win==win) return(g); - return(NULL); -} - - -/****************************************************************************/ -/* */ -/* Function: SetCurrentGW */ -/* */ -/* Purpose: set active output window */ -/* */ -/* Input: GraphWindow *g */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void NS_PREFIX SetCurrentGW (GraphWindow *g) -{ - gw = g; -} - -/****************************************************************************/ -/* */ -/* Function: GraphOpen */ -/* */ -/* Purpose: Open a graph window and initialize a GraphWindow data str. */ -/* */ -/* Input: GraphWindow *gw */ -/* char *window_name */ -/* */ -/* Output: 0: OK */ -/* 1: error, could not complete */ -/* */ -/****************************************************************************/ - -static int GraphOpen (GraphWindow *gw, char *window_name, int x, int y, int width, int height) -{ - unsigned int border_width = DEFAULTBORDER; - char *icon_name = (char *) GRAPHICONNAME; - const char *Fontname; - const char *ug_name = RESOURCENAME; - unsigned long valuemask = 0; - static char dash_list[] = {12,24}; - XGCValues values; - XSizeHints size_hints; - XWMHints wm_hints; - XClassHint class_hints; - XEvent report; - - /* first load font to know size of window */ - Fontname = XGetDefault(display,ug_name,"viewfont"); - if (Fontname==NULL) - strcpy(gw->font_name,DEFAULTFONT); - else - strcpy(gw->font_name,Fontname); - if ( (gw->font_info=XLoadQueryFont(display,gw->font_name))==NULL) - { - /* font could not be loaded, try default font */ - strcpy(gw->font_name,DEFAULTFONT); - if ( (gw->font_info=XLoadQueryFont(display,gw->font_name))==NULL) - { - fprintf(stderr,"%s could not load font %s\n",prog_name,gw->font_name); - return(1); - } - } - gw->font_ascent = gw->font_info->ascent; - gw->font_height = gw->font_info->ascent+gw->font_info->descent; - gw->font_width = gw->font_info->max_bounds.width; - - /* open a window */ - gw->window_width = width; - gw->window_height = height; - gw->window_x = x; - gw->window_y = y; - gw->win = XCreateSimpleWindow(display,RootWindow(display,screen_num), - x,y,width,height,border_width,ctab[X11OutputDevice->black].pixel, - ctab[X11OutputDevice->white].pixel); - - /* use backing store for window if possible */ - { - XSetWindowAttributes attr; - unsigned long mask; - - if (gw->backing_store = DoesBackingStore(DefaultScreenOfDisplay(display))) { - attr.backing_store = Always; - mask = CWBackingStore; - XChangeWindowAttributes(display, gw->win, mask, &attr); - } - } - - /* set the window's color map (may be a private one) */ - XSetWindowColormap(display, gw->win, our_cmap); - - /* create a pixmap with white background */ - if (!gw->backing_store) { - gw->pixmap_depth=DefaultDepth(display,screen_num); - gw->pixmap_width=gw->window_width; - gw->pixmap_height=gw->window_height; - gw->pixmap=XCreatePixmap(display,gw->win,gw->pixmap_width,gw->pixmap_height,gw->pixmap_depth); - gw->gc=XCreateGC(display,gw->win, valuemask,&values); - XSetForeground(display,gw->gc,ctab[X11OutputDevice->white].pixel); - XFillRectangle(display,gw->pixmap,gw->gc,0,0,gw->pixmap_width,gw->pixmap_height); - XFreeGC(display,gw->gc); - } - - /* generate icon, needed for properties */ - gw->icon_pixmap = XCreateBitmapFromData(display,gw->win,(const char*)view_icon_bits,view_icon_width, - view_icon_height); - - /* set standard properties */ - size_hints.flags = USPosition | USSize | PMinSize; - size_hints.min_width = DEFAULTMINX; - size_hints.min_height = DEFAULTMINY; - if (XStringListToTextProperty(&window_name,1,&(gw->window_name))==0) - { - fprintf(stderr,"%s: structure alloc for window_name failed.\n",prog_name); - exit(-1); - } - if (XStringListToTextProperty(&icon_name,1,&(gw->icon_name))==0) - { - fprintf(stderr,"%s: structure alloc for icon_name failed.\n",prog_name); - exit(-1); - } - wm_hints.initial_state = NormalState; - wm_hints.input = True; - wm_hints.icon_pixmap = gw->icon_pixmap; - wm_hints.flags = StateHint | IconPixmapHint | InputHint; - class_hints.res_name = prog_name; - class_hints.res_class = (char*) ug_name; - XSetWMProperties(display,gw->win,&gw->window_name,&gw->icon_name,if_argv,if_argc, - &size_hints,&wm_hints,&class_hints); - - /* select event types that will be received */ - XSelectInput(display,gw->win,EnterWindowMask|ExposureMask|KeyPressMask|PointerMotionMask| - ButtonPressMask|StructureNotifyMask|ButtonReleaseMask|ButtonMotionMask|PointerMotionHintMask); - - /* prepare graphics context */ - gw->gc = XCreateGC(display,gw->win,valuemask,&values); - XSetFont(display,gw->gc,gw->font_info->fid); - XSetForeground(display,gw->gc,ctab[X11OutputDevice->black].pixel); - XSetBackground(display,gw->gc,ctab[X11OutputDevice->white].pixel); - XSetLineAttributes(display,gw->gc,0,LineSolid,CapRound,JoinRound); - XSetDashes(display,gw->gc,0,dash_list,2); - - /* now map the window */ - XMapWindow(display,gw->win); - - /* create a region to accumulate update region */ - gw->region = XCreateRegion(); - - /* wait here for window to become visible, i.e. wait for */ - /* first expose event. I'm not sure that this is the best way, but */ - /* if opened from a script we will not be in the event loop for */ - /* a long time. */ - while (1) { - XNextEvent(display,&report); - if (report.xexpose.window==gw->win) break; - } - - /* und tschuess */ - return(0); -} - -/****************************************************************************/ -/* */ -/* Function: OpenDocumentWindow */ -/* */ -/* Purpose: open a X window and associate it with theView */ -/* */ -/* Input: char *Windowtitle: window title */ -/* UGWINDOW *theUgWindow: view for that window */ -/* */ -/* Output: void *: pointer the window struct or */ -/* NULL if an error occured */ -/* */ -/****************************************************************************/ - -static WINDOWID X11_OpenOutput (const char *title, INT rename, INT x, INT y, INT width, INT height, INT *Global_LL, INT *Global_UR, INT *Local_LL, INT *Local_UR, INT *error) -{ - GraphWindow *gw; - - *error = 0; - - /* create GraphWindow structure */ - gw = (GraphWindow *) malloc(sizeof(GraphWindow)); - if (gw==NULL) return((WINDOWID) NULL); - gw->next = windowList; - windowList = gw; - - /* x,y,width,height is in coordinate system with x to the right and y up */ - /* clip requested window against screen and return clipped values */ - if (x<0) x=0; - if (y<0) y=0; - if ((x)+(width)>display_width) width = display_width-x; - if ((y)+(height)+CONTROLSIZE>display_height) height = display_height-y-CONTROLSIZE; - if ((width<DEFAULTMINX)||(height<DEFAULTMINY)) - { - *error=1; - UserWriteF("X11_OpenOutput(): ERROR inappropriate window size\n"); - return(0); - } - - /* open new window */ - /* the following (char *) cast is ugly, but can not really be avoided, since the - XStringListToTextProperty in GraphOpen wansts a (char **) pointer */ - if (GraphOpen(gw,(char *)title,x,display_height-y-height-CONTROLSIZE,width+1,height+CONTROLSIZE+2)>0) - { - *error=1; - UserWriteF("X11_OpenOutput(): ERROR failed to open window\n"); - return(0); - } - - /* fill lower left and upper right in the devices coordinate system */ - Global_LL[0] = x; Global_LL[1] = display_height-y; - Global_UR[0] = Global_LL[0]+width; Global_UR[1] = Global_LL[1]+height; - Local_LL[0] = 0; Local_LL[1] = height; - Local_UR[0] = width; Local_UR[1] = 0; - - /* return window ptr */ - return((WINDOWID)gw); -} - - -/****************************************************************************/ -/* */ -/* Function: CloseDocumentWindow */ -/* */ -/* Purpose: close the X11 window associated with theView */ -/* */ -/* Input: VIEW *theView: Port of that View will be inited */ -/* */ -/* Output: INT: 0 if all was done well */ -/* 1 if an error ocurred */ -/* */ -/****************************************************************************/ - -static INT X11_CloseOutput (WINDOWID win) -{ - GraphWindow *old,*g; - - /* get window */ - old = (GraphWindow *)(win); - - /* remove from window list */ - if (windowList==old) - windowList = old->next; - else - { - for (g=windowList; g!=NULL; g=g->next) - if (g->next==old) break; - if (g==NULL) return(1); /* not found */ - g->next = old->next; - } - - /* close window on screen */ - XDestroyWindow(display,old->win); - - /* free memory */ - free(old); - - /* no error */ - return(0); -} - - -/****************************************************************************/ -/* */ -/* Functions: X11_ActivateOutput */ -/* */ -/* Purpose: activate the window win */ -/* */ -/* Input: WINDOWID win */ -/* */ -/* Output: 0 is OK */ -/* */ -/****************************************************************************/ - -static INT X11_ActivateOutput (WINDOWID win) -{ - XRectangle rect; - - /* set current output window */ - gw = (GraphWindow *)(win); - - /* set proper clipping region without toolbox */ - rect.x = 0; - rect.y = 0; - rect.width = gw->window_width; - rect.height = gw->window_height-CONTROLSIZE-1; - XSetClipRectangles(display,gw->gc,0,0,&rect,1,YSorted); - - return(0); -} - -/****************************************************************************/ -/* */ -/* Function: UpdateOutput */ -/* */ -/* Purpose: Draws all controls and highlights active tool */ -/* */ -/* Input: GraphWindow *gwin */ -/* */ -/* Output: 0: OK */ -/* 1: error, could not complete */ -/* */ -/****************************************************************************/ - -static INT X11_UpdateOutput (WINDOWID win, INT tool) -{ - int x,y,w,h,i; - int lw; - unsigned long fg,bg; - XGCValues gcv; - XRectangle rect; - GraphWindow *gwin; - - IFDEBUG(dev,1) - printf("Draw Controls\n"); - ENDDEBUG - - gwin = (GraphWindow *) win; - - /* save some values of graphics context */ - XGetGCValues(display, gwin->gc, GCForeground|GCBackground|GCLineWidth, &gcv); - lw = gcv.line_width; - fg = gcv.foreground; - bg = gcv.background; - - /* check window and pixmap size */ - if (!gwin->backing_store) { - if((gwin->window_width!=gwin->pixmap_width)||(gwin->window_height!=gwin->pixmap_height)) - { /* window size has changed, create a new empty pixmap with the new size */ - XFreePixmap(display,gwin->pixmap); - gwin->pixmap_width=gwin->window_width; - gwin->pixmap_height=gwin->window_height; - gwin->pixmap=XCreatePixmap(display,gwin->win,gwin->pixmap_width,gwin->pixmap_height,gwin->pixmap_depth); - XSetForeground(display,gwin->gc,ctab[X11OutputDevice->white].pixel); - XFillRectangle(display,gwin->pixmap,gwin->gc,0,0,gwin->pixmap_width,gwin->pixmap_height); - XSetForeground(display,gwin->gc,ctab[X11OutputDevice->black].pixel); - } - else - { /* no changes in size */ - XClearWindow(display,gwin->win); - XCopyArea(display, gwin->pixmap, gwin->win,gwin->gc, 0, 0,gwin->pixmap_width,gwin->pixmap_height,0,0); - } - } - - /* set clipping to whole window */ - rect.x = 0; - rect.y = 0; - rect.width = gwin->window_width; - rect.height = gwin->window_height; - XSetClipRectangles(display,gwin->gc,0,0,&rect,1,YSorted); - - /* set to black onto white and lw=1, important for copy plane */ - gcv.line_width = 0; - gcv.foreground = ctab[X11OutputDevice->black].pixel; - gcv.background = ctab[X11OutputDevice->white].pixel; - XChangeGC(display, gwin->gc, GCForeground|GCBackground|GCLineWidth, &gcv); - - /* clear controls area including line */ - x = 0; - y = gwin->window_height-1-CONTROLSIZE; - w = gwin->window_width; - h = CONTROLSIZE; - XClearArea(display,gwin->win,x,y,w,h,0); - - /* draw tools */ - y = gwin->window_height-CONTROLSIZE; - w = h = CONTROLSIZE; - for (i=0; i<NTOOLS; i++) - { - x = gwin->window_width-(NTOOLS-i)*CONTROLSIZE; - XCopyPlane(display,tools[i],gwin->win,gwin->gc,0,0,w,h,x,y,1); - if (!gwin->backing_store) - XCopyPlane(display,tools[i],gwin->pixmap,gwin->gc,0,0,w,h,x,y,1); - } - - /* highlite active tool */ - i = tool; - if ((i<0)||(i>=NTOOLS)) i=0; - x = gwin->window_width-(NTOOLS-i)*CONTROLSIZE; - y = gwin->window_height-CONTROLSIZE; - w = h = CONTROLSIZE; - gcv.foreground = ctab[X11OutputDevice->white].pixel; - gcv.background = ctab[X11OutputDevice->black].pixel; - XChangeGC(display, gwin->gc, GCForeground|GCBackground, &gcv); - XCopyPlane(display,tools[i],gwin->win,gwin->gc,0,0,w,h,x,y,1); - gcv.foreground = ctab[X11OutputDevice->black].pixel; - gcv.background = ctab[X11OutputDevice->white].pixel; - XChangeGC(display, gwin->gc, GCForeground|GCBackground, &gcv); - - /* set cursor */ - XDefineCursor(display,gwin->win,cursors[i]); - - /* draw separation line */ - y = gwin->window_height-CONTROLSIZE-1; - w = gwin->window_width; - XDrawLine(display,gwin->win,gwin->gc,0,y,w-1,y); - if (!gwin->backing_store) - XDrawLine(display,gwin->pixmap,gwin->gc,0,y,w-1,y); - - /* restore GC */ - gcv.line_width = lw; - gcv.foreground = fg; - gcv.background = bg; - XChangeGC(display, gwin->gc, GCForeground|GCBackground|GCLineWidth, &gcv); - - /* restore clipping region */ - rect.x = 0; - rect.y = 0; - rect.width = gwin->window_width; - rect.height = gwin->window_height-CONTROLSIZE-1; - XSetClipRectangles(display,gwin->gc,0,0,&rect,1,YSorted); - - return(0); -} - -/****************************************************************************/ -/* - InitOutputDevice - Install output device 'x11' - - SYNOPSIS: - OUTPUTDEVICE *InitXOutputDevice (void); - - PARAMETERS: - . void - - DESCRIPTION: - This function installs output device 'x11'. - - RETURN VALUE: - OUTPUTDEVICE * - .n pointer to - .n NULL if an error occured. - */ -/****************************************************************************/ - -OUTPUTDEVICE *NS_PREFIX InitXOutputDevice (void) -{ - /* create output device */ - if ((X11OutputDevice=CreateOutputDevice("screen"))==NULL) return(NULL); - - /* init output device 'x11' */ - X11OutputDevice->OpenOutput = X11_OpenOutput; - X11OutputDevice->CloseOutput = X11_CloseOutput; - X11OutputDevice->ActivateOutput = X11_ActivateOutput; - X11OutputDevice->UpdateOutput = X11_UpdateOutput; - - X11OutputDevice->v.locked = 1; - InitXPort(X11OutputDevice); - - printf("output device 'screen' for x11 window manager created\n"); - - return(X11OutputDevice); -} - - -/****************************************************************************/ -/* - MousePosition - Get current mouse position - - SYNOPSIS: - void MousePosition (INT *ScreenPoint); - - PARAMETERS: - . ScreenPoint - return result in this vector - - DESCRIPTION: - This function gets current mouse position. - - - RETURN VALUE: - void - */ -/****************************************************************************/ - -void NS_PREFIX MousePosition (INT *ScreenPoint) -{ - XEvent report; - int where_x,where_y; - int exitLoop; - int root_x,root_y; - Window root,child; - unsigned int keys_buttons; - - /* if a mouse pos is stored, return it */ - if (StoredMousePos) - { - ScreenPoint[0] = MouseX; - ScreenPoint[1] = MouseY; - StoredMousePos = 0; - return; - } - - /* get events until the mouse has been moved or button released */ - exitLoop=0; - while (!exitLoop) - { - - /* get next event, all events except button and motion are discarded */ - XNextEvent(display,&report); - - /* examine event */ - switch (report.type) - { - case ButtonRelease : - MoveMouse = 0; - where_x = report.xbutton.x; - where_y = report.xbutton.y; - exitLoop=1; - break; - - case MotionNotify : - while (XCheckMaskEvent(display,ButtonMotionMask,&report)) ; - if (!XQueryPointer(display,report.xmotion.window,&root,&child, - &root_x,&root_y,&where_x,&where_y,&keys_buttons)) - break; - exitLoop=1; - break; - - default : - break; - } - } - ScreenPoint[0] = where_x; - ScreenPoint[1] = where_y; - - return; -} - -/****************************************************************************/ -/* - MouseStillDown - Determine if mouse button is still pressed - - - SYNOPSIS: - INT MouseStillDown (void); - - PARAMETERS: - no parameters - - DESCRIPTION: - This function returns true (1) if the mouse button is still pressed. - The function should only be called after a button pressed event has been - reported. - - - RETURN VALUE: - INT - .n 0 if mouse button has been released - .n 1 if mouse button is still pressed - */ -/****************************************************************************/ - -static Bool callback (Display *d, XEvent *report, char *arg) -{ - return(True); -} - -INT NS_PREFIX MouseStillDown (void) -{ - XEvent report; - int where_x,where_y; - int root_x,root_y; - Window root,child; - unsigned int keys_buttons; - - /* if button has been released already */ - if (MoveMouse==0) - { - MoveMouse = 1; - return(0); - } - - /* get next event, all events except button and motion are discarded */ - if (!XCheckIfEvent(display,&report,callback,NULL)) return(1); - - /* examine event */ - switch (report.type) - { - case ButtonRelease : - MoveMouse = 1; - return(0); - - case MotionNotify : - while (XCheckMaskEvent(display,ButtonMotionMask,&report)) ; - if (!XQueryPointer(display,report.xmotion.window,&root,&child, - &root_x,&root_y,&where_x,&where_y,&keys_buttons)) - break; - StoredMousePos = 1; - MouseX = where_x; - MouseY = where_y; - return(1); - - default : - break; - } - - return (1); -} diff --git a/dev/xif/xgraph.h b/dev/xif/xgraph.h deleted file mode 100644 index 7ad22dd62c011c8b73b366329e2555bf7c2a800f..0000000000000000000000000000000000000000 --- a/dev/xif/xgraph.h +++ /dev/null @@ -1,121 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xgraph.h */ -/* */ -/* Purpose: header file for graph window functionality */ -/* */ -/* Author: Peter Bastian */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* internet: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 17.02.94 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __XGRAPH__ -#define __XGRAPH__ - -#include "namespace.h" - -START_UG_NAMESPACE - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define CONTROLSIZE 24 /* total size is 32 including line */ - -/****************************************************************************/ -/* */ -/* data structures exported by the corresponding source file */ -/* */ -/****************************************************************************/ - -typedef struct graphwindow { - - /* this is a linked list */ - struct graphwindow *next; /* pointer to next window */ - - /* drawing parameters */ - short marker_size; /* size of markers in pixels */ - short marker_id; /* number of marker */ - - /* font metrics for fast access */ - int font_ascent; /* font ascent */ - int font_height; /* ascent+descent */ - int font_width; /* widest character */ - - /* window size and position to filter resize & drag events */ - int window_x; - int window_y; - int window_width; - int window_height; - - /* pixmap size and depth */ - Pixmap pixmap; - int pixmap_depth; - int pixmap_width; - int pixmap_height; - - /* windows current point */ - int x; - int y; - - /* X things */ - Window win; /* window id */ - GC gc; /* a graphics context */ - XFontStruct *font_info; /* the font structure */ - Region region; /* accumulate clipping region */ - char font_name[128]; /* font name from resource */ - Pixmap icon_pixmap; /* icon to use */ - XTextProperty icon_name; /* icons name */ - XTextProperty window_name; /* windows name */ - int backing_store; -} GraphWindow ; - - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -NS_PREFIX OUTPUTDEVICE *InitXOutputDevice (void); -unsigned long UGBlack (void); -unsigned long UGWhite (void); -int DrawControls (GraphWindow *gw); -int InitControls (Window win); -int DrawRegion (GraphWindow *gwin, int x, int y); -GraphWindow *WhichGW (Window win); -void SetCurrentGW (GraphWindow *g); - -END_UG_NAMESPACE - -#endif diff --git a/dev/xif/xmain.cc b/dev/xif/xmain.cc deleted file mode 100644 index a6da7112be1bb190f3f99c2e19f60d6eb076541a..0000000000000000000000000000000000000000 --- a/dev/xif/xmain.cc +++ /dev/null @@ -1,766 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xmain.c */ -/* */ -/* Purpose: main file for X11 interface */ -/* */ -/* Author: Klaus Johannsen */ -/* Peter Bastian */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* */ -/* History: 15.02.94 begin, ug3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> - -/* X11 includes */ -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/keysym.h> - -#ifdef USE_XAW -/* Xt & Xaw includes */ -#include <X11/Intrinsic.h> -#include <X11/Vendor.h> -#include <X11/StringDefs.h> -#include <X11/Shell.h> -#include <X11/Xaw/XawInit.h> -#include <X11/Xaw/AsciiText.h> -#include <X11/Xaw/Text.h> -#endif /* USE_XAW */ - -/* standard C includes */ -#include <cstring> -#include <cmath> -#include <cstddef> -#include <cstdlib> -#include <cstdio> -#include <cassert> - -/* interface includes */ -#include "ugtypes.h" -#include "ugdevices.h" -#include "initdev.h" -#include "debug.h" -#include "general.h" - -/* Xif includes */ -#include "xshell.h" -#include "xgraph.h" -#include "xmain.h" - -#ifdef __GUI__ -#include "gui.h" -#endif - -USING_UG_NAMESPACES - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define DBG_LEVEL 4 - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -static ShellWindow shell; /* our only shell window */ -FILE *i_pipe=NULL; /* input to ug */ -FILE *o_pipe=NULL; /* output from ug */ - - -/****************************************************************************/ -/* */ -/* export global variables */ -/* */ -/****************************************************************************/ - -/* global data needed everywhere */ -#ifdef USE_XAW -XtAppContext context; /* application context */ -Widget toplevel, - ugshell; -XawTextPosition CursorPos, - CutBeginPos = 0; -#endif - -Display * NS_PREFIX display; /* the display */ -int NS_PREFIX screen_num; /* screen on display */ -char * NS_PREFIX prog_name; /* my own name */ -Screen * NS_PREFIX screen_ptr; /* dont know for what */ -unsigned int NS_PREFIX display_width; /* size of screen if needed */ -unsigned int NS_PREFIX display_height; -int NS_PREFIX if_argc; /* command line args */ -char ** NS_PREFIX if_argv; -#ifndef __GUI__ -int NS_PREFIX user_interface = XUI; /* user interface to open */ -#else -int NS_PREFIX user_interface = GUI; /* user interface to open */ -#endif -int cui = 0; /* reset toggle for cui */ - -/****************************************************************************/ -/* */ -/* export global variables per function call */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* - GetScreenSize - Return sreen size - - SYNOPSIS: - INT GetScreenSize (INT size[2]); - - PARAMETERS: - . size[2] - pointer to the size of screen - - RETURN VALUE: - INT - .n 0 if ok - .n 1 if error occured. - */ -/****************************************************************************/ - -INT NS_PREFIX GetScreenSize (INT size[2]) -{ - size[0] = display_width; - size[1] = display_height; - - return (true); -} - -/****************************************************************************/ -/* */ -/* Function: GUI_GetNextEvent */ -/* */ -/* Purpose: process an event from the system and pass it to ug if nec. */ -/* */ -/* Input: EVENT *theEvent pointer to ug event to be filled */ -/* */ -/* return: INT 0: no event occurred (ug or system) */ -/* 1: an event occurred (ug or system) */ -/* */ -/****************************************************************************/ - -static Bool callback (Display *d, XEvent *report, char *arg) -{ - return(True); -} - -/****************************************************************************/ -/* - GUI_GetNextEvent - Process an event from the system and pass it to ug - - SYNOPSIS: - INT GetNextUGEvent (EVENT *theEvent, INT EventMask); - - PARAMETERS: - . theEvent - pointer to ug event - - . EventMask - - - DESCRIPTION: - This function processes an event from the system and passes it to ug if necessary. - - RETURN VALUE: - INT - .n 0 if no event occurred (ug or system) - .n 1 if an event occurred (ug or system). - */ -/****************************************************************************/ - -static INT GetNextUGEvent_XUI (EVENT *theEvent, INT Eventmask); - -void PUI_CreatePipes (char *extension) -{ - char i_name[128]; - char o_name[128]; - - sprintf(i_name,".I_PIPE_%s",extension); - sprintf(o_name,".O_PIPE_%s",extension); - - - o_pipe=fopen(o_name,"w"); - assert(o_pipe!=NULL); - fflush(o_pipe); - - i_pipe=fopen(i_name,"r"); - assert(i_pipe!=NULL); - - return; -} - -static INT GetNextUGEvent_PUI (EVENT *theEvent, INT EventMask) -{ - /* no event as default */ - theEvent->Type = NO_EVENT; - theEvent->NoEvent.InterfaceEvent = 0; - - /* we have no command keys */ - if (EventMask==TERM_CMDKEY) return(0); - - /* read in a string from the user and store it in event structure */ - if (i_pipe==NULL) return(0); - fgets(theEvent->TermString.String,INPUTBUFFERLEN,i_pipe); - theEvent->Type = TERM_STRING; - - /* ready */ - return(0); -} - -static INT GetNextUGEvent_CUI (EVENT *theEvent, INT EventMask) -{ - /* cancel X events */ - if(!NUI_ON) GetNextUGEvent_XUI(theEvent,EventMask); - - /* no event as default */ - theEvent->Type = NO_EVENT; - theEvent->NoEvent.InterfaceEvent = 0; - - /* we have no command keys */ - if (EventMask==TERM_CMDKEY) return(0); - - /* read in a string from the user and store it in event structure */ - if (fgets(theEvent->TermString.String,INPUTBUFFERLEN,stdin) == NULL) { - /* stop if input is at EOF */ - theEvent->Type = TERM_GOAWAY; - return 0; - }; - theEvent->Type = TERM_STRING; - - /* ready */ - return(0); -} - -static INT GetNextUGEvent_XUI (EVENT *theEvent, INT Eventmask) -{ - XEvent report; - Window root,child; - int root_x,root_y; - char *s; - GraphWindow *gw; - int where_x,where_y; - INT tool,pt[2]; - int x,y,w,h; - int cmdKey, onlyCmdKey; -#ifdef USE_XAW - int flag; -#endif - unsigned int keys_buttons; - static int count = 0; - - /* no event as default */ - theEvent->Type = NO_EVENT; - theEvent->NoEvent.InterfaceEvent = 0; - theEvent->NoEvent.GraphWinActive = 0; - /*if (!XQueryPointer(display,report.xmotion.window,&root,&child, - &root_x,&root_y,&where_x,&where_y,&keys_buttons))*/ - - /* event loop */ - switch (Eventmask) - { - case EVERY_EVENT : - if (!XCheckIfEvent(display,&report,callback,NULL)) return(0); - PRINTDEBUG(dev,DBG_LEVEL,("XCheckIfEvent(): matching event found count=%d\n",count++)); - onlyCmdKey = 0; - break; - case TERM_STRING : - if (!XCheckMaskEvent(display,KeyPressMask,&report)) return(0); - onlyCmdKey = 0; - break; - case TERM_CMDKEY : - if (!XCheckMaskEvent(display,KeyPressMask,&report)) return(0); - onlyCmdKey = 1; - break; - default : - return (0); - } - - switch (report.type) - { - case Expose : - if (report.xexpose.window==shell.win) - { - #ifndef USE_XAW - ShellHandleExposeEvent(&shell,&report); - #endif - theEvent->NoEvent.InterfaceEvent = 1; - break; - } - if (report.xexpose.count!=0) return(0); - gw = WhichGW(report.xexpose.window); - if (gw==NULL) break; - theEvent->Type = DOC_UPDATE; - theEvent->DocUpdate.win = (WINDOWID) gw; - break; - - case EnterNotify : - gw = WhichGW(report.xcrossing.window); - if (gw==NULL) break; - theEvent->Type = DOC_ACTIVATE; - theEvent->DocActivate.win = (WINDOWID) gw; - SetCurrentGW(gw); - /* - IFDEBUG(dev,DBG_LEVEL) - printf("reporting DOC_ACTIVATE for view %s\n",MY_VIEW(gw)->name); - ENDDEBUG - */ - break; - - case ConfigureNotify : - if (report.xconfigure.window==shell.win) - { - #ifdef USE_XAW - flag=XtDispatchEvent(&report); - IFDEBUG(dev,DBG_LEVEL) - if (flag==false) { - PRINTDEBUG(dev,DBG_LEVEL,("XtDispatchEvent(): NO handler for this event found\n")); - } - else { - PRINTDEBUG(dev,DBG_LEVEL,("XtDispatchEvent(): handler for this event found\n")); - } - ENDDEBUG - #else /* USE_XAW */ - ShellHandleResizeEvent(&shell,&report); - theEvent->NoEvent.InterfaceEvent = 1; - #endif /* USE_XAW */ - break; - } - gw = WhichGW(report.xconfigure.window); - if (gw==NULL) break; - /* check if size of window changed */ - if ( (report.xconfigure.width!=gw->window_width) - ||(report.xconfigure.height!=gw->window_height)) - { - /* new size, origin may have changed also ! */ - /* CAUTION: windows new position could not be determined ! */ - x = report.xconfigure.x; - y = report.xconfigure.y; - w = report.xconfigure.width; - h = report.xconfigure.height; - theEvent->Type = DOC_GROW; - theEvent->DocGrow.win = (WINDOWID) gw; - /*theEvent->DocGrow.Global_LL[0] = x; - theEvent->DocGrow.Global_LL[1] = display_height-y; - theEvent->DocGrow.Global_UR[0] = x+w; - theEvent->DocGrow.Global_UR[1] = display_height-(y+h);*/ - theEvent->DocGrow.Global_LL[0] = x; - theEvent->DocGrow.Global_LL[1] = y+h; - theEvent->DocGrow.Global_UR[0] = x+w; - theEvent->DocGrow.Global_UR[1] = y; - theEvent->DocGrow.Local_LL[0] = 0; - theEvent->DocGrow.Local_LL[1] = h-CONTROLSIZE-2; - theEvent->DocGrow.Local_UR[0] = w-1; - theEvent->DocGrow.Local_UR[1] = 0; - gw->window_x = x; - gw->window_y = y; - gw->window_width = w; - gw->window_height = h; - /* - IFDEBUG(dev,DBG_LEVEL) - printf("reporting DOC_GROW dxmin=%g dymin=%g dxmax=%g dymax=%g\n", - theEvent->DocGrow.LowerLeft[0],theEvent->DocGrow.LowerLeft[1], - theEvent->DocGrow.UpperRight[0],theEvent->DocGrow.UpperRight[1]); - ENDDEBUG - */ - break; - } - if ( (report.xconfigure.x!=gw->window_x) - ||(report.xconfigure.y!=gw->window_y)) - { - /* it's a drag event */ - x = report.xconfigure.x; - y = report.xconfigure.y; - w = gw->window_width; - h = gw->window_height; - theEvent->Type = DOC_DRAG; - theEvent->DocDrag.win = (WINDOWID) gw; - theEvent->DocDrag.Global_LL[0] = x; - theEvent->DocDrag.Global_LL[1] = display_height-y; - theEvent->DocDrag.Global_UR[0] = x+w; - theEvent->DocDrag.Global_UR[1] = display_height-(y+h); - gw->window_x = report.xconfigure.x; - gw->window_y = report.xconfigure.y; - /* - IFDEBUG(dev,DBG_LEVEL) - printf("reporting DOC_DRAG dxmin=%g dymin=%g dxmax=%g dymax=%g\n", - theEvent->DocDrag.LowerLeft[0],theEvent->DocDrag.LowerLeft[1], - theEvent->DocDrag.UpperRight[0],theEvent->DocDrag.UpperRight[1]); - ENDDEBUG - */ - break; - } - break; - - case ButtonPress : - #ifdef USE_XAW - if (report.xbutton.window == shell.win) - { - if (report.xbutton.button == Button1 || - report.xbutton.button == Button3 ) - { - CursorPos = XawTextGetInsertionPoint(shell.wid); - XawTextDisplayCaret(shell.wid,false); - if (report.xbutton.button == Button3) - XawTextSetInsertionPoint(shell.wid,CutBeginPos); - } - break; - } - #endif /* USE_XAW */ - gw = WhichGW(report.xbutton.window); - if (gw==NULL) break; - pt[0] = where_x = report.xbutton.x; - pt[1] = where_y = report.xbutton.y; - if (WhichTool((WINDOWID)gw,pt,&tool)) - { - theEvent->Type = DOC_CHANGETOOL; - theEvent->DocChangeTool.win = (WINDOWID) gw; - theEvent->DocChangeTool.Tool = tool; - theEvent->DocChangeTool.MousePosition[0] = where_x; - theEvent->DocChangeTool.MousePosition[1] = where_y; - IFDEBUG(dev,DBG_LEVEL) - printf("reporting DOC_CHANGETOOL tool=%d\n",tool); - ENDDEBUG - break; - } - if (DrawRegion(gw,where_x,where_y)) - { - theEvent->Type = DOC_CONTENTCLICK; - theEvent->DocContentClick.win = (WINDOWID) gw; - theEvent->DocContentClick.MousePosition[0] = where_x; - theEvent->DocContentClick.MousePosition[1] = where_y; - } - - break; - - #ifdef USE_XAW - case ButtonRelease : - if (report.xbutton.window == shell.win) - { - if (report.xbutton.button == Button2) - { - char *cutbuffer; - int cnt; - - cutbuffer = XFetchBytes(display,&cnt); - if (cutbuffer == NULL) - { - IFDEBUG(dev,DBG_LEVEL) - printf("cut buffer empty\n"); - ENDDEBUG - break; - } - IFDEBUG(dev,DBG_LEVEL) - printf("ButtonRelease with cnt=%d cutbuffer=%s\n",cnt,cutbuffer); - ENDDEBUG - - AppendOrInsertCutbuffer(&shell,cutbuffer,cnt); - XFree(cutbuffer); - } - } - break; - #endif /* USE_XAW */ - - case KeyPress : - s = ShellHandleKeybordEvent(&shell,&report,&cmdKey,onlyCmdKey); - if (s==NULL) - { - theEvent->NoEvent.InterfaceEvent = 1; - break; - } - if (cmdKey) - { - theEvent->Type = TERM_CMDKEY; - theEvent->TermCmdKey.CmdKey = s[0]; - break; - } - theEvent->Type = TERM_STRING; - strcpy(theEvent->TermString.String,s); - break; - - case MotionNotify : - while (XCheckMaskEvent(display,PointerMotionMask,&report)) ; - if (!XQueryPointer(display,report.xmotion.window,&root,&child, - &root_x,&root_y,&where_x,&where_y,&keys_buttons)) - break; - - gw = WhichGW(report.xmotion.window); - if (gw!=NULL) - { - theEvent->NoEvent.GraphWinActive = (WINDOWID) gw; - theEvent->NoEvent.Mouse[0] = where_x; - theEvent->NoEvent.Mouse[1] = where_y; - } - break; - - default : - break; - } - - #ifdef USE_XAW - /* Send all events to shell widget */ - flag=XtDispatchEvent(&report); - IFDEBUG(dev,DBG_LEVEL) - if (flag==false) { - PRINTDEBUG(dev,DBG_LEVEL,("XtDispatchEvent(): NO handler for this event found\n")); - } - else { - PRINTDEBUG(dev,DBG_LEVEL,("XtDispatchEvent(): Handler for this event found\n")); - } - ENDDEBUG - - switch (report.type) - { - case ButtonRelease : - if (report.xbutton.window == shell.win) - { - if (report.xbutton.button == Button1) - CutBeginPos = XawTextGetInsertionPoint(shell.wid); - - if (report.xbutton.button == Button1 || - report.xbutton.button == Button3 ) - { - XawTextSetInsertionPoint(shell.wid,CursorPos); - XawTextDisplayCaret(shell.wid,true); - } - } - break; - } - #endif - - return(0); -} - -INT NS_PREFIX GetNextUGEvent (EVENT *theEvent, INT EventMask) -{ - if (PUI_ON) GetNextUGEvent_PUI (theEvent,EventMask); - else if (CUI_ON) GetNextUGEvent_CUI (theEvent,EventMask); - else if (!NUI_ON) GetNextUGEvent_XUI (theEvent,EventMask); - return(0); -} - -/****************************************************************************/ -/* - InitScreen - Init rest of GUI and return pointer to screen outputdevice - - SYNOPSIS: - OUTPUTDEVICE *InitScreen (int *argcp, char **argv, INT *error); - - PARAMETERS: - . argcp - pointer to argument counter - . argv - argument vector - . error - errorcode - - DESCRIPTION: - This function inits rest of GUI and return ptr to screen outputdevice. - - RETURN VALUE: - OUTPUTDEVICE * - .n POINTER if all is o.k. - .n NULL if an error occurred. - - */ -/****************************************************************************/ - -OUTPUTDEVICE * NS_PREFIX InitScreen (int *argcp, char **argv, INT *error) -{ - OUTPUTDEVICE *d; - static char buf[128]; - char buffer[128]; - int i,j; - #ifdef USE_XAW - int n; - Arg args[20]; - #endif - - /* copy parameters to globals */ - if_argc = *argcp; - if_argv = argv; - - /* connect procedure */ - prog_name = argv[0]; - strcpy(buf,SHELLWINNAME); - argv[0] = buf; - - /* now set user interface */ - for (i=1; i<*argcp; i++) - if (strcmp(argv[i],"-ui")==0) - { - int ok = 0; - if (sscanf(argv[i+1],"%s",buffer)!=1) - { - fprintf(stderr,"%s: invalid use of option -ui [selected_ui]\n",prog_name); - fprintf(stderr,"%s: choose for option -ui [" XUI_STRING "|" CUI_STRING "|" - NUI_STRING "|" GUI_STRING "|" XGUI_STRING "|" - CGUI_STRING "|" CNUI_STRING "]\n",prog_name); - exit(-1); - } - - user_interface=0; - if (strcmp(buffer,XUI_STRING)==0) { user_interface |= XUI; ok = 1; } - if (strcmp(buffer,CUI_STRING)==0) { user_interface |= CUI; ok = 1; } - if (strcmp(buffer,GUI_STRING)==0) { user_interface |= GUI; ok = 1; } - if (strcmp(buffer,NUI_STRING)==0) { user_interface |= NUI; ok = 1; } - if (strcmp(buffer,XGUI_STRING)==0) { user_interface |= XGUI; ok = 1; } - if (strcmp(buffer,CGUI_STRING)==0) { user_interface |= CGUI; ok = 1; } - if (strcmp(buffer,CNUI_STRING)==0) { user_interface |= CNUI; ok = 1; } - - if (!ok) - { - fprintf(stderr,"%s: invalid use of option -ui [selected_ui]\n",prog_name); - fprintf(stderr,"%s: choose for option -ui [" XUI_STRING "|" CUI_STRING "|" - NUI_STRING "|" GUI_STRING "|" XGUI_STRING "|" - CGUI_STRING "|" CNUI_STRING "]\n",prog_name); - exit(-1); - } - - /* erase arguments from arglist */ - for (j=i+2; j<*argcp; j++) argv[j-2] = argv[j]; - i -= 1; - *argcp -= 2; - } - else if (strcmp(argv[i],"-np")==0) - { - if (sscanf(argv[i+1],"%s",buffer)!=1) - { - fprintf(stderr,"%s: invalid use of option -np\n",prog_name); - fprintf(stderr,"%s: choose for option -np name extension for named pipes\n",prog_name); - exit(-1); - } - user_interface |= PUI; - PUI_CreatePipes(buffer); - - /* erase arguments from arglist */ - for (j=i+2; j<*argcp; j++) argv[j-2] = argv[j]; - i -= 1; - *argcp -= 2; - } - - - if (NUI_ON) { *error = 0; return(NULL); } - - #ifdef USE_XAW - /* set input focus to true, due to problems with some - window manager implemtations, DEC, LINUX, SUN */ - n=0; - XtSetArg(args[n], XtNinput, true); n++; - - toplevel = XtAppInitialize (&context, "Xug3", - (XrmOptionDescRec*)NULL, 0, - argcp, argv, - (String*)NULL, - args, n); - - display = XtDisplay(toplevel); - #else /* USE_XAW */ - display=XOpenDisplay(NULL); - #endif /* USE_XAW */ - if (display == NULL) - { - fprintf(stderr,"%s: cannot connect to X server %s\n",prog_name,XDisplayName(NULL)); - exit(-1); - } - screen_num = DefaultScreen(display); - screen_ptr = DefaultScreenOfDisplay(display); - display_width = DisplayWidth(display,screen_num); - display_height = DisplayHeight(display,screen_num); - - /* make output device first to have color table */ - d = InitXOutputDevice(); - if (d==NULL) {*error=1; return(NULL);} - - /* create shell window */ - ShellOpen(&shell); - - /* init cursors and tools */ - InitControls(shell.win); - - #ifdef __GUI__ - /* init gui */ - if(GUI_Init(display,context)) - { - printf("InitScreen(): GUI_Init() returned error"); - return(NULL); - } - #endif - - *error = 0; - return(d); -} - - - -void NS_PREFIX ExitScreen () -{} - - - -/****************************************************************************/ -/* - WriteString - write a string to a terminal window - - SYNOPSIS: - void WriteString (const char *s); - - PARAMETERS: - . s - - - DESCRIPTION: - This function writes a string to a terminal window. - - RETURN VALUE: - void - */ -/****************************************************************************/ - -void NS_PREFIX WriteString (const char *s) -{ - if (PUI_ON) - { - if (o_pipe==NULL) return; - fprintf(o_pipe,"%s",s); - fflush(o_pipe); - } - else if (CUI_ON) - { - fputs(s,stdout); - #ifdef Debug - fflush(stdout); - #endif - /* printf("%s",s); */ - } - else if (!NUI_ON) - { - ShellInsertString(&shell,s); - return; - } -} diff --git a/dev/xif/xmain.h b/dev/xif/xmain.h deleted file mode 100644 index 2d608ef9f7396bf1ad3d2ee0718ba5b27df013ff..0000000000000000000000000000000000000000 --- a/dev/xif/xmain.h +++ /dev/null @@ -1,119 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xmain.h */ -/* */ -/* Purpose: global variables exported by xmain */ -/* */ -/* Author: Peter Bastian */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* internet: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 17.02.94 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __XMAIN__ -#define __XMAIN__ - -#include "namespace.h" - -START_UG_NAMESPACE - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define XUI 0x1 -#define CUI 0x2 -#define GUI 0x4 -#define NUI 0x8 -#define XGUI 0x5 -#define CGUI 0x6 -#define CNUI 0xa -#define PUI 0x10 - -#define CUITOGGLE 0x2 - -#define XUI_STRING "x" -#define CUI_STRING "c" -#define GUI_STRING "g" -#define NUI_STRING "n" -#define XGUI_STRING "xg" -#define CGUI_STRING "cg" -#define CNUI_STRING "cn" - -#define CUI_ON (user_interface & CUI) -#define XUI_ON (user_interface & XUI) -#define GUI_ON (user_interface & GUI) -#define NUI_ON (user_interface & NUI) -#define PUI_ON (user_interface & PUI) - -#define SET_CUI_ON (user_interface |= CUI) -#define SET_XUI_ON (user_interface |= XUI) -#define SET_GUI_ON (user_interface |= GUI) -#define SET_NUI_ON (user_interface |= NUI) - -#define SET_CUI_OFF (user_interface &= ~CUI) -#define SET_XUI_OFF (user_interface &= ~XUI) -#define SET_GUI_OFF (user_interface &= ~GUI) -#define SET_NUI_OFF (user_interface &= ~NUI) - -#define TOGGLE_CUI {int tmp=cui; cui=CUI_ON; \ - if (tmp) SET_CUI_ON;else SET_CUI_OFF;} - -/****************************************************************************/ -/* */ -/* data structures exported by the corresponding source file */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -extern Display *display; /* the display */ -extern int screen_num; /* screen on display */ -extern char *prog_name; /* my own name */ -extern Screen *screen_ptr; /* dont know for what */ -extern unsigned int display_width; /* size of screen if needed */ -extern unsigned int display_height; -extern int if_argc; /* command line args */ -extern char **if_argv; -extern int user_interface; /* user interface to open */ -extern int cui; /* toggle for cui */ - - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -END_UG_NAMESPACE - -#endif diff --git a/dev/xif/xshell.cc b/dev/xif/xshell.cc deleted file mode 100644 index 5900cc14b6ca897fa3b185d403437db5f941177b..0000000000000000000000000000000000000000 --- a/dev/xif/xshell.cc +++ /dev/null @@ -1,1358 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xshell.c */ -/* */ -/* Purpose: shell window for ug3 based on Xlib or X Athena Widget set */ -/* */ -/* Author: Peter Bastian */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 16.02.94 begin, ug version 3.0 */ -/* 06.06.95 implementation of Athena Text widget as Shellwindow */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> - -/* X11 includes */ -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/keysym.h> - -#ifdef USE_XAW -/* Xt & Xaw includes */ -#include <X11/Intrinsic.h> -#include <X11/Vendor.h> -#include <X11/StringDefs.h> -#include <X11/Xaw/XawInit.h> -#include <X11/Xaw/AsciiText.h> -#include <X11/Xaw/Text.h> -#endif /* USE_XAW */ - -/* standard C includes */ -#include <cstdio> -#include <cstdlib> -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#include <cstring> -#include <ctype.h> - -/* interface includes */ -#include "ugtypes.h" -#include "ugdevices.h" -#include "initdev.h" -#include "defaults.h" -#include "general.h" -#include "debug.h" - -/* Xif includes */ -#include "xmain.h" -#include "xshell.h" -#include "xgraph.h" - -USING_UG_NAMESPACES - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -/* hardcoded default values */ -#define DEFAULTXPOS 50 -#define DEFAULTYPOS 100 -#define DEFAULTLINES 24 -#define DEFAULTCOLS 80 -#define DEFAULTFONT "9x15" -#define DEFAULTMINX 300 -#define DEFAULTMINY 200 -#define DEFAULTBORDER 4 - -/* bitmaps for icons */ -#include "shell-icon" - -/* macros for access to text buffer */ -#define MIN(x,y) (((x)<(y)) ? (x) : (y)) -#define MAX(x,y) (((x)>(y)) ? (x) : (y)) -#define TEXTLINE(sh,i) (sh)->lineStart[((sh)->topLine+(i))%((sh)->numLines)] -#define XPOS(sh,i,j) XTextWidth((sh)->font_info,TEXTLINE(sh,j),MIN(strlen(TEXTLINE(sh,j)),i)) -#define YPOS(sh,i,j) (sh)->font_ascent+(j)*((sh)->font_height) - -/* change color */ -#define BLACK(sh) XSetForeground(display,(sh)->gc,UGBlack()) -#define WHITE(sh) XSetForeground(display,(sh)->gc,UGWhite()) - -#ifdef USE_XAW -#define HISTLEN 30 -#define HISTNEXT(pos) (((pos)+INPUTBUFFERLEN)%(HISTLEN*INPUTBUFFERLEN)) -#define HISTPREV(pos) ((pos==0) ? ((HISTLEN-1)*INPUTBUFFERLEN) : ((pos)-INPUTBUFFERLEN)%(HISTLEN*INPUTBUFFERLEN)) -#endif - -/****************************************************************************/ -/* */ -/* data structures used in this source file (exported data structures are */ -/* in the corresponding include file!) */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -#ifdef USE_XAW -extern Widget toplevel; -extern Widget ugshell; -extern XtAppContext context; -#endif /* USE_XAW */ - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -static char buf[INPUTBUFFERLEN]; /* input line buffer */ -static int nchars=0; /* number of charcters in input */ -static char cmdKeyBuf; /* buffer for a command key */ -static int AltFlag; /* 1 if Alt has been pressed */ -static int InsertPos=0; /* only used with Xaw */ - -#ifdef USE_XAW -static int HistLastPos=0; -static int HistInsertPos=0; -static int HistReadPos=0; -static char HistBuf[HISTLEN*INPUTBUFFERLEN]; -static int MaxLines=400; -static int s=0; -static int *LineBuffer; -static int LineFirst=0; -static int LineInsert=0; -#endif - - -/****************************************************************************/ -/* */ -/* forward declarations of functions used before they are defined */ -/* */ -/****************************************************************************/ - -#ifdef USE_XAW -void UpAction (Widget w, XEvent *event, String *params, Cardinal *num_params); -void DownAction (Widget w, XEvent *event, String *params, Cardinal *num_params); -void LeftAction (Widget w, XEvent *event, String *params, Cardinal *num_params); -void RightAction (Widget w, XEvent *event, String *params, Cardinal *num_params); -#endif - - -/****************************************************************************/ -/* */ -/* Function: ShellShowCursor, ShellHideCursor */ -/* */ -/* Purpose: show/hide cursor at current point */ -/* */ -/* Input: ShellWindow *sh */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellShowCursor (ShellWindow *sh) -{ - int x,y; - - /* get current position */ - x = XPOS(sh,sh->col,sh->line); - y = YPOS(sh,sh->col,sh->line); - - BLACK(sh); - XFillRectangle(display,sh->win,sh->gc,x,y-sh->font_ascent,sh->font_width,sh->font_height); -} - -void ShellHideCursor (ShellWindow *sh) -{ - int x,y; - - /* get current position */ - x = XPOS(sh,sh->col,sh->line); - y = YPOS(sh,sh->col,sh->line); - - WHITE(sh); - XFillRectangle(display,sh->win,sh->gc,x,y-sh->font_ascent,sh->font_width,sh->font_height); -} - - -/****************************************************************************/ -/* */ -/* Function: ShellOpen */ -/* */ -/* Purpose: Open a shell window and initialize a ShellWindow data str. */ -/* */ -/* Input: ShellWindow *sh */ -/* */ -/* Output: 0: OK */ -/* 1: error, could not complete */ -/* */ -/****************************************************************************/ - -int ShellOpen (ShellWindow *sh) -{ - unsigned int width, height; - int x, y, i; - unsigned int border_width = DEFAULTBORDER; - const char *window_name = SHELLWINNAME; - const char *icon_name = SHELLICONNAME; - char *Geometry, *Fontname; - const char *ug_name = RESOURCENAME; - int flags; - unsigned long valuemask = 0; - static char dash_list[] = {12,24}; - XGCValues values; - XSizeHints size_hints; - XWMHints wm_hints; - XClassHint class_hints; - #ifdef USE_XAW - char buffer[128]; - int n; - Arg args[20]; - XtTranslations NewTranslations; - XtActionsRec actions[] = { - {(char*) "UpAction", UpAction}, - {(char*) "DownAction", DownAction}, - {(char*) "LeftAction", LeftAction}, - {(char*) "RightAction",RightAction}, - }; - #endif /* USE_XAW */ - - /* allocate text buffer see, to know that memory is sufficient */ - sh->topLine = 0; - sh->line = 0; - sh->col = 0; - for (i=0; i<MAXLINES; i++) - { - /* malloc a buffer line */ - sh->lineStart[i] = (char *)calloc(MAXCOLS+1,sizeof(char)); - if (sh->lineStart[i] == NULL) - { - fprintf(stderr,"%s could not allocate line %d\n",prog_name,i); - return(1); - } - } - - /* find out geometry */ - width = DEFAULTCOLS; - height = DEFAULTLINES; - x = DEFAULTXPOS; - y = DEFAULTYPOS; - Geometry = XGetDefault(display,ug_name,"shellgeom"); - if (Geometry!=NULL) - { - flags = XParseGeometry(Geometry,&x,&y,&width,&height); - if (!(WidthValue & flags)) width = DEFAULTCOLS; - if (!(HeightValue & flags)) height = DEFAULTLINES; - if (XValue & flags) - if (XNegative&flags) x = display_width+x; - if (YValue & flags) - if (YNegative&flags) y = display_height+y; - } - width = MIN(width,MAXCOLS); /* width & height in characters! */ - height = MIN(height,MAXLINES); - sh->numLines = height; - sh->numCols = width; - - /* first load font to know size of window */ - Fontname = XGetDefault(display,ug_name,"shellfont"); - if (Fontname==NULL) - { - printf("font 'shellfont' not found in Xdefaults\n" - "using default " DEFAULTFONT "\n"); - strcpy(sh->font_name,DEFAULTFONT); - } - else - strcpy(sh->font_name,Fontname); - if ( (sh->font_info=XLoadQueryFont(display,sh->font_name))==NULL) - { - /* font could not be loaded, try default font */ - strcpy(sh->font_name,DEFAULTFONT); - if ( (sh->font_info=XLoadQueryFont(display,sh->font_name))==NULL) - { - fprintf(stderr,"%s could not load font %s\n",prog_name,sh->font_name); - return(1); - } - } - sh->font_ascent = sh->font_info->ascent; - sh->font_height = sh->font_info->ascent+sh->font_info->descent; - sh->font_width = sh->font_info->max_bounds.width; - - width = width*sh->font_width; - height = height*sh->font_height; - sh->window_width = width; - sh->window_height = height; - - #ifdef USE_XAW - n=0; - XtSetArg(args[n], (char*) XtNx, x); n++; - XtSetArg(args[n], (char*) XtNy, y); n++; - XtSetArg(args[n], (char*) XtNwidth, width+sh->font_width); n++; - XtSetArg(args[n], (char*) XtNheight, height+sh->font_height+sh->font_info->descent); n++; - XtSetArg(args[n], (char*) XtNborderWidth, border_width); n++; - XtSetArg(args[n], (char*) XtNscrollVertical, XawtextScrollWhenNeeded); n++; - XtSetArg(args[n], (char*) XtNscrollHorizontal, XawtextScrollWhenNeeded); n++; - XtSetArg(args[n], (char*) XtNstring, sh->lineStart[0]); n++; - XtSetArg(args[n], (char*) XtNlength, MAXLINES*(MAXCOLS+1)); n++; - XtSetArg(args[n], (char*) XtNpieceSize, MAXLINES*(MAXCOLS+1)); n++; - XtSetArg(args[n], (char*) XtNeditType, XawtextEdit); n++; - /* TODO: delete this, line wrapping does not work correctly - XtSetArg(args[n], XtNwrap,XawtextWrapLine); n++; */ - XtSetArg(args[n], (char*) XtNfont,sh->font_info); n++; - XtSetArg(args[n], XtNbackground,WhitePixel(display,screen_num)); n++; - XtSetArg(args[n], XtNforeground,BlackPixel(display,screen_num)); n++; - - ugshell = XtCreateManagedWidget ("ugshell", asciiTextWidgetClass, - toplevel, args, n); - - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: no-op(RingBell)\n\ - <Key>Delete: no-op(RingBell)\n\ - <Key>Up: no-op(RingBell)\n\ - <Key>Down: no-op(RingBell)\n\ - <Key>Left: no-op(RingBell)\n\ - <Key>Right: no-op(RingBell)\n"); - /* - Ctrl<Key>/: search(forward,"")\n\ - Ctrl Shift<Key>/: search(backward,"")\n"); - */ - XtOverrideTranslations(ugshell,NewTranslations); - - /* add special actions */ - XtAppAddActions(context,actions,XtNumber(actions)); - - /* realize widget tree */ - if (XUI_ON) - XtRealizeWidget (toplevel); - - sh->wid = ugshell; - if (XUI_ON) - sh->win = XtWindow(ugshell); - else - sh->win = RootWindow(display,screen_num); - - #else /* USE_XAW */ - - /* open a window */ - sh->win = XCreateSimpleWindow(display,RootWindow(display,screen_num), - x,y,width,height,border_width,BlackPixel(display,screen_num), - WhitePixel(display,screen_num)); - #endif /* USE_XAW */ - - /* use backing store for window if possible */ - { - XSetWindowAttributes attr; - unsigned long mask; - - if (DoesBackingStore(DefaultScreenOfDisplay(display))) { - attr.backing_store = Always; - mask = CWBackingStore; - XChangeWindowAttributes(display, sh->win, mask, &attr); - } - } - - /* generate icon, needed for properties */ - sh->icon_pixmap = XCreateBitmapFromData(display,sh->win,(const char*)shell_icon_bits,shell_icon_width, - shell_icon_height); - - /* set standard properties */ - size_hints.flags = USPosition | USSize | PMinSize; - size_hints.min_width = DEFAULTMINX; - size_hints.min_height = DEFAULTMINY; - if (XStringListToTextProperty((char**) &window_name,1,&(sh->window_name))==0) - { - fprintf(stderr,"%s: structure alloc for window_name failed.\n",prog_name); - exit(-1); - } - if (XStringListToTextProperty((char**) &icon_name,1,&(sh->icon_name))==0) - { - fprintf(stderr,"%s: structure alloc for icon_name failed.\n",prog_name); - exit(-1); - } - wm_hints.initial_state = NormalState; - wm_hints.input = True; - wm_hints.icon_pixmap = sh->icon_pixmap; - wm_hints.flags = StateHint | IconPixmapHint | InputHint; - class_hints.res_name = prog_name; - class_hints.res_class = (char*) ug_name; - XSetWMProperties(display,sh->win,&sh->window_name,&sh->icon_name,if_argv,if_argc, - &size_hints,&wm_hints,&class_hints); - - #ifndef USE_XAW - /* select event types that will be received */ - XSelectInput(display,sh->win,ExposureMask|KeyPressMask|ButtonPressMask|StructureNotifyMask); - #endif - - /* prepare graphics context */ - sh->gc = XCreateGC(display,sh->win,valuemask,&values); - XSetFont(display,sh->gc,sh->font_info->fid); - XSetForeground(display,sh->gc,BlackPixel(display,screen_num)); - XSetLineAttributes(display,sh->gc,0,LineSolid,CapRound,JoinRound); - XSetDashes(display,sh->gc,0,dash_list,2); - - /* now map the window */ - if (XUI_ON) - XMapWindow(display,sh->win); - - /* create a region to accumulate update region */ - sh->region = XCreateRegion(); - - #ifndef USE_XAW - /* show cursor for first time */ - ShellShowCursor(sh); - #endif - - #ifdef USE_XAW - if (GetDefaultValue(DEFAULTSFILENAME,"shellbuffersize",buffer)==0) - { - sscanf(buffer," %d ",&n); - if (n>0) MaxLines = n; - else printf("shellbuffersize variable in defaults file = %d - should be a positive integer (>0)\n",n); - } - LineBuffer = (int *) calloc(MaxLines,sizeof(int)); - #endif - - /* und tschuess */ - return(0); -} - - -/****************************************************************************/ -/* */ -/* Function: ShellScrollLine */ -/* */ -/* Purpose: scroll forward and backward by a number of lines */ -/* */ -/* Input: ShellWindow *sh */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellScrollLine (ShellWindow *sh) -{ - /* copy area up one line */ - XCopyArea(display,sh->win,sh->win,sh->gc,0,sh->font_height,sh->window_width, - sh->window_height-sh->font_height,0,0); - - /* delete last line */ - WHITE(sh); - XFillRectangle(display,sh->win,sh->gc,0,sh->window_height-sh->font_height, - sh->window_width,sh->font_height); - - /* wrap text buffer */ - sh->topLine = (sh->topLine+1)%(sh->numLines); - - return; -} - - -/****************************************************************************/ -/* */ -/* Function: ShellInsertChar */ -/* */ -/* Purpose: Insert a character into shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* char c */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellInsertChar (ShellWindow *sh, char c) -{ - int x,y; - int error; - #ifdef USE_XAW - Cardinal n; - Arg args[10]; - XawTextPosition appendPos; - XawTextBlock text; - char t = c; - char NewString[INPUTBUFFERLEN]; - - text.firstPos = 0; - text.length = 1; - text.ptr = &t; - text.format = FMT8BIT; - - appendPos = XawTextGetInsertionPoint(sh->wid); - if (nchars > InsertPos) - { - n=0; - XtSetArg(args[n], XtNeditType, XawtextEdit); n++; - XtSetValues(ugshell,args,n); - } - error = XawTextReplace(sh->wid,appendPos,appendPos,&text); - if (nchars > InsertPos) - { - n=0; - XtSetArg(args[n], XtNeditType, XawtextAppend); n++; - XtSetValues(ugshell,args,n); - } - XawTextSetInsertionPoint(sh->wid,appendPos+1); - #else /* USE_XAW */ - - /* hide cursor */ - ShellHideCursor(sh); - - switch (c) - { - /* backspace */ - case 8 : - /* decrement buffer position */ - if (sh->col>0) - (sh->col)--; - else - { - if (sh->line>0) - { - (sh->line)--; - sh->col = strlen(TEXTLINE(sh,sh->line))-1; - } - } - - /* put 0 character at new position */ - TEXTLINE(sh,sh->line)[sh->col] = (char) 0; - break; - - /* return */ - case '\n' : - if (sh->line==sh->numLines-1) - ShellScrollLine(sh); - else - (sh->line)++; - sh->col = 0; - TEXTLINE(sh,sh->line)[sh->col] = (char) 0; - - break; - - /* printable */ - default : - if ((c<32)||(c>=127)) break; - - /* print character on screen */ - x = XPOS(sh,sh->col,sh->line); - y = YPOS(sh,sh->col,sh->line); - BLACK(sh); - #ifndef USE_XAW - XDrawString(display,sh->win,sh->gc,x,y,&c,1); - #endif /* USE_XAW */ - /* insert character in text buffer */ - TEXTLINE(sh,sh->line)[sh->col] = c; - - /* place end of string after character */ - TEXTLINE(sh,sh->line)[sh->col+1] = (char) 0; - - /* advance cursor */ - (sh->col)++; - if (sh->col>=sh->numCols) { - if (sh->line==sh->numLines-1) - ShellScrollLine(sh); - else - (sh->line)++; - sh->col = 0; - } - IFDEBUG(dev,1) - printf("char = %d x=%d y=%d line=%d col=%d bufferline=%d\n",(int)c,x,y,sh->line,sh->col, - (sh->topLine+sh->line)%sh->numLines); - ENDDEBUG - break; - } - - /* show cursor again */ - ShellShowCursor(sh); - #endif /* USE_XAW */ -} - -/************************************************************************/ -/* */ -/* Function: ShellUpdateTextBuffer */ -/* */ -/* Purpose: Update the buffer of a shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* number of characters to remove int i */ -/* */ -/* Output: none */ -/* */ -/************************************************************************/ - - -#ifdef USE_XAW -void ShellUpdateTextBuffer (ShellWindow *sh,int i) -{ - XawTextPosition appendPos; - XawTextBlock textInsert; - - textInsert.firstPos = 0; - textInsert.length = 0; - textInsert.ptr = NULL; - textInsert.format = FMT8BIT; - - LineInsert=LineInsert%MaxLines; - LineBuffer[LineInsert]=i; - LineInsert=(LineInsert+1)%MaxLines; - - if(LineInsert==LineFirst) - { - appendPos=XawTextGetInsertionPoint(sh->wid); - LineFirst=(LineFirst+1)%MaxLines; - XawTextReplace(sh->wid,0,LineBuffer[LineInsert]-s,&textInsert); - s=LineBuffer[LineInsert]; - XawTextSetInsertionPoint(sh->wid,appendPos); - } -} -#endif - -/****************************************************************************/ -/* */ -/* Function: ShellInsertString */ -/* */ -/* Purpose: Insert a string into shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* char *s */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellInsertString (ShellWindow *sh, const char *s) -{ - int i; - #ifdef USE_XAW - char ss[INPUTBUFFERLEN]; - XawTextPosition appendPos; - XawTextBlock text; - - for (i=0; i<strlen(s); i++) - ss[i] = (s[i]== '\r') ? '\n' : s[i]; - - text.firstPos = 0; - text.length = strlen(s); - text.ptr = ss; - text.format = FMT8BIT; - appendPos=XawTextGetInsertionPoint(sh->wid); - if( text.length!=0 && (s[text.length-1]=='\n') ) - ShellUpdateTextBuffer(sh,appendPos+text.length); - XawTextSetInsertionPoint(sh->wid,appendPos); - XawTextReplace(sh->wid,appendPos,appendPos+text.length,&text); - XawTextSetInsertionPoint(sh->wid,appendPos+text.length); - #else - for (i=0; i<strlen(s); i++) ShellInsertChar(sh,s[i]); - #endif -} - - -/****************************************************************************/ -/* */ -/* Function: ShellRefresh */ -/* */ -/* Purpose: refresh contents of shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellRefresh (ShellWindow *sh) -{ - int i,x,y,l; - XRectangle rectangle; - - /* set clipping region to accumulated region in shell */ - XSetRegion(display,sh->gc,sh->region); - - /* draw characters */ - BLACK(sh); - for (i=0; i<sh->numLines; i++) - if ((l=strlen(TEXTLINE(sh,i)))>0) - { - x = 0; - y = YPOS(sh,0,i); - XDrawString(display,sh->win,sh->gc,x,y,TEXTLINE(sh,i),l); - } - - /* show cursor */ - ShellShowCursor(sh); - - /* set clipping region to whole window for subsequent drawings */ - rectangle.x = 0; - rectangle.y = 0; - rectangle.width = (short) sh->window_width; - rectangle.height = (short) sh->window_height; - XUnionRectWithRegion(&rectangle,sh->region,sh->region); - XSetRegion(display,sh->gc,sh->region); - - /* clear clipping region */ - XDestroyRegion(sh->region); - sh->region = XCreateRegion(); - -} - - -/****************************************************************************/ -/* */ -/* Function: ShellResize */ -/* */ -/* Purpose: resize the shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* int width new size of window in pixels ! */ -/* int height */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellResize (ShellWindow *sh, int width, int height) -{ - int i; - int c_width,c_height; - int obl,ntl; - - /* compute new size in characters */ - c_width = MIN(width/sh->font_width,MAXCOLS); - c_height = MIN(height/sh->font_height,MAXLINES); - IFDEBUG(dev,1) - printf("RESIZE: OLD: top=%2d nl=%2d line=%2d ",sh->topLine,sh->numLines,sh->line); - ENDDEBUG - /* clear lines not in use */ - for (i=sh->numLines; i<MAXLINES; i++) sh->lineStart[i][0] = (char) 0; - - /* adjust buffer vertically */ - if (c_height!=sh->numLines) - { - obl = (sh->topLine+sh->numLines-1)%sh->numLines; - if (c_height>sh->numLines) - { - ntl = obl+1; - for (i=0; i<sh->numLines-ntl; i++) - strcpy(sh->lineStart[c_height-1-i],sh->lineStart[sh->numLines-1-i]); - for (i=0; i<sh->numLines-ntl; i++) - sh->lineStart[ntl+i][0] = (char) 0; - sh->line += c_height-sh->numLines; - } - else - { - if (obl<=c_height-1) - { - ntl = (obl+1)%c_height; - for (i=0; i<c_height-1-obl; i++) - strcpy(sh->lineStart[(obl+1)+i],sh->lineStart[(sh->numLines-c_height)+(obl+1)+i]); - - } - else - { - ntl = 0; - for (i=0; i<=c_height-1; i++) - strcpy(sh->lineStart[i],sh->lineStart[obl-c_height+1+i]); - } - sh->line = MAX(0,sh->line-(sh->numLines-c_height)); - } - sh->topLine = ntl; - sh->numLines = c_height; - } - - /* adjust buffer horizontally */ - for (i=0; i<MAXLINES; i++) sh->lineStart[i][c_width] = (char) 0; - sh->numCols = c_width; - sh->col = MIN(sh->col,c_width-1); - IFDEBUG(dev,1) - printf("NEW: top=%2d nl=%2d line=%2d\n",sh->topLine,sh->numLines,sh->line); - ENDDEBUG -} - - -/****************************************************************************/ -/* */ -/* Function: ShellHandleExposeEvent */ -/* */ -/* Purpose: handle expose event for shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* XEvent *report */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellHandleExposeEvent (ShellWindow *sh, XEvent *report) -{ - XRectangle rectangle; - - rectangle.x = (short) report->xexpose.x; - rectangle.y = (short) report->xexpose.y; - rectangle.width = (short) report->xexpose.width; - rectangle.height = (short) report->xexpose.height; - XUnionRectWithRegion(&rectangle,sh->region,sh->region); - IFDEBUG(dev,1) - printf("EXPOSE EVENT: rect= %d %d %d %d cnt= %d\n",rectangle.x,rectangle.y, - rectangle.width,rectangle.height,report->xexpose.count); - ENDDEBUG - if (report->xexpose.count!=0) return; - ShellRefresh(sh); -} - - -/****************************************************************************/ -/* */ -/* Function: ShellHandleResizeEvent */ -/* */ -/* Purpose: handle resize event for shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* XEvent *report */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellHandleResizeEvent (ShellWindow *sh, XEvent *report) -{ - XRectangle rectangle; - - if ( (report->xconfigure.width==sh->window_width) - &&(report->xconfigure.height==sh->window_height)) return; - rectangle.x = 0; - rectangle.y = 0; - rectangle.width = (short) report->xconfigure.width; - rectangle.height = (short) report->xconfigure.height; - XUnionRectWithRegion(&rectangle,sh->region,sh->region); - WHITE(sh); - XFillRectangle(display,sh->win,sh->gc,0,0,report->xconfigure.width, - report->xconfigure.height); - sh->window_width = report->xconfigure.width; - sh->window_height = report->xconfigure.height; - - ShellResize(sh,report->xconfigure.width,report->xconfigure.height); -} - - -/****************************************************************************/ -/* */ -/* Function: ShellHandleKeybordEvent */ -/* */ -/* Purpose: handle keypress event for shell window */ -/* */ -/* Input: ShellWindow *sh */ -/* XEvent *report */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -char *ShellHandleKeybordEvent (ShellWindow *sh, XEvent *report,int *cmdKey, int onlyCmdKey) -{ - char buffer[32]; - int bufsize = 32; - KeySym keysym; - XKeyEvent keyevent; - XComposeStatus compose; - int count; - char c; - #ifdef USE_XAW - Cardinal n; - Arg args[10]; - XtTranslations NewTranslations; - #endif - - /* no command key is default */ - *cmdKey = 0; - keyevent = report->xkey; - count = XLookupString(&keyevent,buffer,bufsize,&keysym,&compose); - /* vorher XLookupString(report,buffer,bufsize,&keysym,&compose) */ - - if((keysym==XK_Alt_L)||(keysym==XK_Alt_R)|| - (keysym==XK_Meta_L)||(keysym==XK_Meta_R)) - { - AltFlag = 1; - return(NULL); - } - else if (((keysym==XK_Return)||(keysym==XK_KP_Enter)||(keysym==XK_Linefeed)) && !onlyCmdKey) - { - c = '\n'; - #ifndef USE_XAW - ShellInsertChar(sh,c); - #endif - buf[nchars] = (char) 0; - #ifdef USE_XAW - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: no-op(RingBell)\n\ - <Key>Delete: no-op(RingBell)\n\ - <Key>Left: no-op(RingBell)\n"); - XtOverrideTranslations(ugshell,NewTranslations); - if (nchars>0) - { - memcpy(&HistBuf[HistInsertPos],buf,nchars); - NewTranslations = XtParseTranslationTable - ("<Key>Up: UpAction()\n\ - <Key>Down:no-op(RingBell)\n"); - XtOverrideTranslations(ugshell,NewTranslations); - HistInsertPos = HISTNEXT(HistInsertPos); - HistBuf[HistInsertPos] = (char) 0; - if (HistInsertPos == HistLastPos) - HistLastPos = HISTNEXT(HistLastPos); - HistReadPos = HistInsertPos; - } - - XawTextSetInsertionPoint(ugshell,XawTextGetInsertionPoint(ugshell)-InsertPos+nchars); - #endif /* USE_XAW */ - - nchars = 0; - InsertPos = nchars; - AltFlag = 0; - return(buf); - } - else if ((keysym==XK_BackSpace)||(keysym==XK_Delete)) - { - if (nchars>0) - { - #ifdef USE_XAW - if (nchars==InsertPos) - { - #endif - c = (char)8; - #ifndef USE_XAW - ShellInsertChar(sh,c); - #endif - nchars--; - InsertPos = nchars; - #ifdef USE_XAW - } - else - { - memmove(&buf[InsertPos-1],&buf[InsertPos],nchars-InsertPos); - nchars--; - InsertPos--; - } - #endif - } - #ifdef USE_XAW - else - { - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: no-op(RingBell)\n\ - <Key>Delete: no-op(RingBell)\n\ - <Key>Left: no-op(RingBell)\n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - #endif - - - AltFlag = 0; - return(NULL); - } - - else if ( ((keysym>=XK_KP_Space)&&(keysym<=XK_KP_9)) - ||((keysym>=XK_space)&&(keysym<=XK_asciitilde))) - { - - /* vorher if (report->xkey.state&Mod1Mask) */ - if(AltFlag) - { - cmdKeyBuf = buffer[0]; - *cmdKey = 1; - AltFlag = 0; - return(&cmdKeyBuf); - } - c = buffer[0]; - #ifndef USE_XAW - ShellInsertChar(sh,c); - #else - if (nchars==0) - { - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: delete-previous-character() \n\ - <Key>Delete: delete-previous-character() \n\ - <Key>Left: LeftAction() \n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - #endif - #ifdef USE_XAW - if (InsertPos==nchars) - { - #endif - buf[nchars] = c; - nchars++; - InsertPos = nchars; - #ifdef USE_XAW - } - else - { - memmove(&buf[InsertPos+1],&buf[InsertPos],nchars-InsertPos+1); - buf[InsertPos] = c; - nchars++; - InsertPos++; - } - #endif - - if (nchars==INPUTBUFFERLEN-1) - { - buf[nchars] = (char) 0; - #ifdef USE_XAW - memcpy(&HistBuf[HistReadPos],buf,nchars); - HistInsertPos = HISTNEXT(HistInsertPos); - HistReadPos = HistInsertPos; - #endif - nchars = 0; - InsertPos = nchars; - AltFlag = 0; - return(buf); - } - AltFlag = 0; - return(NULL); - } - - AltFlag = 0; - return(NULL); -} - -#ifdef USE_XAW -/****************************************************************************/ -/* */ -/* Function: ShellReplaceString */ -/* */ -/* Purpose: Replace textposition 'from' to 'to' in shell window by */ -/* string s. The textposition is counted from the end. */ -/* */ -/* Input: ShellWindow *sh */ -/* char *s */ -/* int from */ -/* int to */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ShellReplaceString (ShellWindow *sh, const char *s, int from, int to) -{ - XawTextPosition appendPos; - XawTextBlock text; - - text.firstPos = 0; - text.length = strlen(s); - text.ptr = (char *)s; - text.format = FMT8BIT; - - appendPos = XawTextGetInsertionPoint(ugshell); - XawTextReplace(ugshell,appendPos-from,appendPos-to,&text); - XawTextSetInsertionPoint(ugshell,appendPos+text.length); -} - -/****************************************************************************/ -/* */ -/* Function: AppendOrInsertCutbuffer */ -/* */ -/* Purpose: insert X cutbuffer to the shell cmdline buffer and */ -/* display modified cmdline in ugshell window, if insertion */ -/* */ -/* Input: char *cutbuf */ -/* int cnt */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void AppendOrInsertCutbuffer (ShellWindow *sh, char *cutbuf, int cnt) -{ - int i; - Cardinal n; - XtTranslations NewTranslations; - Arg args[10]; - - if (nchars != InsertPos) - { - n=0; - XtSetArg(args[n], XtNeditType, XawtextEdit); n++; - XtSetValues(ugshell,args,n); - } - - if (cnt>0) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: delete-previous-character() \n\ - <Key>Delete: delete-previous-character() \n\ - <Key>Left: LeftAction() \n"); - XtOverrideTranslations(sh->wid,NewTranslations); - } - - for (i=0; (i<cnt) && (nchars<INPUTBUFFERLEN-1); i++) - { - if (isgraph(cutbuf[i])||isspace(cutbuf[i])) - { - if (InsertPos==nchars) - { - buf[nchars] = cutbuf[i]; - nchars++; - InsertPos = nchars; - } - else - { - memmove(&buf[InsertPos+1],&buf[InsertPos],nchars-InsertPos+1); - buf[InsertPos] = cutbuf[i]; - nchars++; - InsertPos++; - } - } - } -} - -/****************************************************************************/ -/* */ -/* Function: ReplaceCmd */ -/* */ -/* Purpose: replace the commandbuffer by a command from history */ -/* */ -/* Input: Widget w: widget, which has gotten the action */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void ReplaceCmd(Widget w) -{ - char *ActCommandPtr; - int ActCommandLen; - XawTextPosition ReplacePos; - XawTextBlock text; - XtTranslations NewTranslations; - - ActCommandPtr = &HistBuf[HistReadPos]; - ActCommandLen = strlen(ActCommandPtr); - memcpy(buf,ActCommandPtr,ActCommandLen); - - text.firstPos = 0; - text.length = ActCommandLen; - text.ptr = ActCommandPtr; - text.format = FMT8BIT; - - ReplacePos = XawTextGetInsertionPoint(w); - XawTextReplace(w,ReplacePos-nchars,ReplacePos,&text); - XawTextSetInsertionPoint(w,ReplacePos-nchars+ActCommandLen); - - nchars = ActCommandLen; - InsertPos = nchars; - if (nchars <=0) - { - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: no-op(RingBell) \n\ - <Key>Delete: no-op(RingBell) \n\ - <Key>Left: no-op(RingBell) \n\ - <Key>Right: no-op(RingBell) \n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - else - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>BackSpace: delete-previous-character() \n\ - <Key>Delete: delete-previous-character() \n\ - <Key>Left: LeftAction() \n\ - <Key>Right: no-op(RingBell) \n"); - XtOverrideTranslations(ugshell,NewTranslations); - } -} - -/****************************************************************************/ -/* */ -/* Function: UpAction */ -/* */ -/* Purpose: display previous command from history, if exists */ -/* */ -/* Input: Widget w: widget, which has gotten the action */ -/* XEvent event, String *params, Cardinal *num_params: */ -/* dummy parameter to match funktionprototype */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void UpAction (Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - XtTranslations NewTranslations; - - if (HistReadPos == HistInsertPos) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Down: DownAction()\n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - - HistReadPos = HISTPREV(HistReadPos); - if (HistReadPos == HistLastPos) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Up: no-op(RingBell)\n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - - ReplaceCmd(w); -} - -/****************************************************************************/ -/* */ -/* Function: DownAction */ -/* */ -/* Purpose: display next command from history, if exists */ -/* */ -/* Input: Widget w: widget, which has gotten the action */ -/* XEvent event, String *params, Cardinal *num_params: */ -/* dummy parameter to match funktionprototype */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void DownAction (Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - XtTranslations NewTranslations; - - if (HistReadPos == HistLastPos) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Up: UpAction()\n"); - XtOverrideTranslations(ugshell,NewTranslations); - } - HistReadPos = HISTNEXT(HistReadPos); - if (HistReadPos == HistInsertPos) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Down: no-op(RingBell)\n"); - - XtOverrideTranslations(ugshell,NewTranslations); - } - ReplaceCmd(w); -} - -/****************************************************************************/ -/* */ -/* Function: LeftAction */ -/* */ -/* Purpose: move cursor one position left in cmdline */ -/* */ -/* Input: Widget w: widget, which has gotten the action */ -/* XEvent event, String *params, Cardinal *num_params: */ -/* dummy parameter to match funktionprototype */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void LeftAction (Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - int NewPos; - Cardinal n; - Arg args[10]; - XtTranslations NewTranslations; - - if (InsertPos == nchars) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Right: RightAction()\n"); - - XtOverrideTranslations(ugshell,NewTranslations); - } - - NewPos = XawTextGetInsertionPoint(ugshell); - NewPos--; - XawTextSetInsertionPoint(ugshell,NewPos); - InsertPos--; - - if (InsertPos == 0) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Left: no-op(RingBell)\n"); - - XtOverrideTranslations(ugshell,NewTranslations); - } -} - -/****************************************************************************/ -/* */ -/* Function: RightAction */ -/* */ -/* Purpose: move cursor one position right in cmdline */ -/* */ -/* Input: Widget w: widget, which has gotten the action */ -/* XEvent event, String *params, Cardinal *num_params: */ -/* dummy parameter to match funktionprototype */ -/* */ -/* Output: none */ -/* */ -/****************************************************************************/ - -void RightAction (Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - int NewPos; - Cardinal n; - Arg args[10]; - XtTranslations NewTranslations; - - if (InsertPos == 0) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Left: LeftAction()\n"); - - XtOverrideTranslations(ugshell,NewTranslations); - } - - NewPos = XawTextGetInsertionPoint(ugshell); - NewPos++; - XawTextSetInsertionPoint(ugshell,NewPos); - InsertPos++; - - if (InsertPos == nchars) - { - /* modify Translation table */ - NewTranslations = XtParseTranslationTable - ("<Key>Right: no-op(RingBell)\n"); - - XtOverrideTranslations(ugshell,NewTranslations); - } -} - -#endif /* USE_XAW */ diff --git a/dev/xif/xshell.h b/dev/xif/xshell.h deleted file mode 100644 index 1104364fcf21552c637200f83f17e5d05c73d521..0000000000000000000000000000000000000000 --- a/dev/xif/xshell.h +++ /dev/null @@ -1,114 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: xshell.h */ -/* */ -/* Purpose: header file for shell window functionality */ -/* */ -/* Author: Peter Bastian */ -/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 6900 Heidelberg */ -/* internet: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 17.02.94 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __XSHELL__ -#define __XSHELL__ - -#ifndef __GENERAL__ -#include "general.h" -#endif - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -/* maximum size of text buffer */ -#define MAXLINES 100 -#define MAXCOLS 130 - -#define SHELLICONNAME UG_VERSION " shell" -#define SHELLWINNAME UG_VERSION " shell" -#define RESOURCENAME "ug3" - -/****************************************************************************/ -/* */ -/* data structures exported by the corresponding source file */ -/* */ -/****************************************************************************/ - -typedef struct { - /* the text buffer */ - char *lineStart[MAXLINES]; /* pointers to start of lines */ - int topLine; /* index of top line on screen */ - int numLines; /* current size of shell in x */ - int numCols; /* current size of shell in y */ - int line; /* current line position */ - int col; /* current col position */ - - /* font metrics for fast access */ - int font_ascent; /* font ascent */ - int font_height; /* ascent+descent */ - int font_width; /* widest character */ - - /* window size to filter resize event */ - int window_width; - int window_height; - - /* X things */ - #ifdef USE_XAW - Widget wid; /* widget id */ - #endif /* USE_XAW */ - Window win; /* window id */ - GC gc; /* a graphics context */ - XFontStruct *font_info; /* the font structure */ - Region region; /* accumulate clipping region */ - char font_name[128]; /* font name from resource */ - Pixmap icon_pixmap; /* icon to use */ - XTextProperty icon_name; /* icons name */ - XTextProperty window_name; /* windows name */ -} ShellWindow ; - - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -int ShellOpen (ShellWindow *sh); -void ShellInsertChar (ShellWindow *sh, char c); -void ShellInsertString (ShellWindow *sh, const char *s); -void ShellHandleExposeEvent (ShellWindow *sh, XEvent *report); -void ShellHandleResizeEvent (ShellWindow *sh, XEvent *report); -char *ShellHandleKeybordEvent (ShellWindow *sh, XEvent *report,int *cmdKey, int onlyCmdKey); -void AppendOrInsertCutbuffer (ShellWindow *sh, char *cutbuf, int cnt); - -#endif diff --git a/graphics/covise/coviseif.cpp b/graphics/covise/coviseif.cpp deleted file mode 100644 index af54c031a59ca46fa7936b4ddcd4685f37feed1a..0000000000000000000000000000000000000000 --- a/graphics/covise/coviseif.cpp +++ /dev/null @@ -1,714 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: coviseif.cpp */ -/* */ -/* Purpose: interface ug <-> covise */ -/* */ -/* Author: Stefan Lang, Klaus Birken */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70550 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 10.12.97 begin */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <string.h> - -#ifdef __HP__ -#include <stdio.h> -#include <fcntl.h> -#endif - -extern "C" { - - /* ug includes */ -#define ListElement UG_ListElement -#ifdef __HP__ -#undef __cplusplus -#endif -#include "gm.h" -#include "evm.h" -#include "general.h" -#undef ListElement -#ifdef __HP__ -#define __cplusplus -#endif - -#ifdef ModelP -#include "parallel.h" -#define DDD_InfoPriority(ddd_hdr) ((ddd_hdr)->prio) -#endif - -} /* extern "C" */ - -#ifdef __HP__ -#undef _INCLUDE_POSIX_SOURCE -#endif - -/* covise includes */ -#include "covise_connect.h" -#include "covise_msg.h" - - - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define MAX_STRLEN 64 -#define MAX_SOLUTIONS 16 -#define MAX_COMPONENTS 3 - -#define MAX_ITEMS_SENT 4096 - - -/* communication constants */ -#define DFLT_PORT 31700 - - -enum CommonConsts { - MT_NONE, - MT_UGHEADER, - MT_UGGRIDV, - MT_UGGRIDE, - MT_UGSCALAR, - MT_UGVECT -}; - - -/****************************************************************************/ -/* */ -/* data structures used in this source file (exported data structures are */ -/* in the corresponding include file!) */ -/* */ -/****************************************************************************/ - - -/* common data types (for communication UG<->Covise) */ -typedef int INT32; -typedef float FLOAT32; - - - -typedef struct -{ - INT n_components; - - /* external name, for user */ - char name[MAX_STRLEN]; - - /* UG components */ - INT comps[MAX_COMPONENTS]; - -} SOLUTION_DESC; - - -typedef struct -{ - /* multigrid description */ - INT min_level; /* coarsest grid level, may be <0 for algebraic methods */ - INT max_level; /* ==TOPLEVEL in ug */ - - /* surface grid description */ - INT n_vertices; /* number of surface grid vertices */ - INT n_elems; /* number of surface grid elements */ - INT n_conns; /* sum of corners over all surface elements */ - - /* numerical data */ - INT num_solutions; /* number of solutions (may be scalar or vector) */ - SOLUTION_DESC solutions[MAX_SOLUTIONS]; /* solution descriptors */ - -} COVISE_HEADER; - - - - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -/* ug: */ - - -/* covise: */ -static ClientConnection* covise_connection=NULL; - - -/****************************************************************************/ -/* */ -/* forward declarations of functions used before they are defined */ -/* */ -/****************************************************************************/ - - -/****************************************************************************/ -/* */ -/* functions */ -/* */ -/****************************************************************************/ - - -static INT ComputeSurfaceGridStats (MULTIGRID *theMG, COVISE_HEADER *covise) -{ - NODE *theNode; - INT l, n_vertices, n_elem, n_conn; - - /* surface grid up to current level */ - n_vertices = n_elem = n_conn = 0; - for (l=covise->min_level; l<=covise->max_level; l++) - { - ELEMENT *theElement; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - /* reset USED flags in all vertices to be counted */ - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - { - SETUSED(MYVERTEX(theNode),0); - } - - /* count geometric objects */ - for (theElement=FIRSTELEMENT(theGrid); - theElement!=NULL; theElement=SUCCE(theElement)) - { - if ((EstimateHere(theElement)) || (l==covise->max_level)) - { - int i, coe = CORNERS_OF_ELEM(theElement); - n_elem++; - - for (i=0; i<coe; i++) - { - theNode = CORNER(theElement,i); - - n_conn++; - - if (USED(MYVERTEX(theNode))) continue; - SETUSED(MYVERTEX(theNode),1); - - if ((SONNODE(theNode)==NULL) || (l==covise->max_level)) - { - #ifdef ModelP - if (PRIO(theNode) == PrioMaster) - #endif - n_vertices++; - } - } - } - } - } - #ifdef ModelP - n_vertices = UG_GlobalSumINT(n_vertices); - n_elem = UG_GlobalSumINT(n_elem); - n_conn = UG_GlobalSumINT(n_conn); - #endif - covise->n_vertices = n_vertices; - covise->n_elems = n_elem; - covise->n_conns = n_conn; - - return(0); -} - - -static INT GetSolutionDescs (MULTIGRID *theMG, COVISE_HEADER *covise) -{ - /* TODO replace by UI */ - covise->num_solutions = 2; - - strcpy(covise->solutions[0].name, "Concentration"); - covise->solutions[0].n_components = 1; - covise->solutions[0].comps[0] = 0; - - strcpy(covise->solutions[1].name, "Pressure"); - covise->solutions[1].n_components = 1; - covise->solutions[1].comps[0] = 1; - - return(0); -} - - - -static INT FillCoviseHeader (MULTIGRID *theMG, COVISE_HEADER *covise) -{ - /* extract multigrid statistics */ - /* currently no negative levels, complete grid up to TOPLEVEL */ - covise->min_level = 0; - covise->max_level = TOPLEVEL(theMG); - - /* extract surface grid statistics */ - ComputeSurfaceGridStats(theMG, covise); - - /* extract solution descriptions */ - GetSolutionDescs(theMG, covise); - - return(0); -} - - - -/****************************************************************************/ - - -static INT ResetVertexFlags (MULTIGRID *theMG, INT min_level, INT max_level) -{ - INT l; - - /* reset used flags in vertices */ - for (l=min_level; l<=max_level; l++) - { - NODE *theNode; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - /* reset USED flags in all vertices */ - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - { - SETUSED(MYVERTEX(theNode),0); - } - } - - return(0); /* no error */ -} - - -/* TODO renumber doesn't work in parallel */ -static INT RenumberVertices (MULTIGRID *theMG, INT min_level, INT max_level) -{ - INT l, i; - - ResetVertexFlags(theMG, min_level, max_level); - - /* reset used flags in vertices */ - i = 0; - for (l=min_level; l<=max_level; l++) - { - NODE *theNode; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - /* reset USED flags in all vertices */ - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - { - if (USED(MYVERTEX(theNode))) continue; - SETUSED(MYVERTEX(theNode),1); - - ID(MYVERTEX(theNode)) = i; - i++; - } - } - - return(0); -} - - -static INT SendSurfaceGrid (MULTIGRID *theMG, COVISE_HEADER *covise) -{ - INT l, remaining, sent; - TokenBuffer tb; - Message* msg = new Message; - msg->type = (covise_msg_type)0; - printf("CoviseIF: SendSurfaceGrid start\n"); - - /* renumber vertex IDs */ - /* TODO doesn't work in ModelP */ - RenumberVertices(theMG, covise->min_level, covise->max_level); - - /* send surface vertices, part1: set flags */ - ResetVertexFlags(theMG, covise->min_level, covise->max_level); - - /* send surface vertices, part2: send data */ - sent = 0; - - /* start first buffer */ - tb.reset(); - remaining = MIN(covise->n_vertices,MAX_ITEMS_SENT); - tb << MT_UGGRIDV; - tb << remaining; - - for (l=covise->min_level; l<=covise->max_level; l++) - { - NODE *theNode; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - { - INT vid; - DOUBLE *pos; - - if (USED(MYVERTEX(theNode))) continue; - SETUSED(MYVERTEX(theNode),1); - - /* extract data from vertex */ - /* TODO use VXGID in ModelP */ - vid = ID(MYVERTEX(theNode)); - pos = CVECT(MYVERTEX(theNode)); - - tb << (INT32)vid; - tb << (FLOAT32)pos[0]; - tb << (FLOAT32)pos[1]; - tb << (FLOAT32)pos[2]; - remaining--; - sent++; - - if (remaining==0) - { - /* send this buffer */ - msg->data = (char*)tb.get_data(); - msg->length = tb.get_length(); - covise_connection->send_msg(msg); - - /* start next buffer */ - tb.reset(); - tb << MT_UGGRIDV; - remaining = MIN(covise->n_vertices - sent, MAX_ITEMS_SENT); - tb << remaining; - } - } - } - - printf("CoviseIF: SendSurfaceGrid ...\n"); - - /* next buffer */ - tb.reset(); - tb << MT_UGGRIDE; - remaining = MIN(covise->n_elems,MAX_ITEMS_SENT); - tb << remaining; - sent = 0; - - /* send surface elems and connectivity */ - for (l=covise->min_level; l<=covise->max_level; l++) - { - ELEMENT *theElement; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - for (theElement=FIRSTELEMENT(theGrid); - theElement!=NULL; theElement=SUCCE(theElement)) - { - if ((EstimateHere(theElement)) || (l==covise->max_level)) - { - int i, coe = CORNERS_OF_ELEM(theElement); - - tb << (INT32)coe; - - for (i=0; i<coe; i++) - { - NODE *theNode = CORNER(theElement,i); - INT vid; - - vid = ID(MYVERTEX(theNode)); - /* TODO use VXGID in ModelP */ - tb << (INT32)vid; - } - - remaining--; - sent++; - - if (remaining==0) - { - /* send this buffer */ - msg->data = (char*)tb.get_data(); - msg->length = tb.get_length(); - covise_connection->send_msg(msg); - - /* start next buffer */ - tb.reset(); - tb << MT_UGGRIDE; - remaining = MIN(covise->n_elems - sent, MAX_ITEMS_SENT); - tb << remaining; - } - } - } - } - - /* cleanup */ - delete msg; - - printf("CoviseIF: SendSurfaceGrid stop\n"); - return(0); -} - - - -static INT SendSolution (MULTIGRID *theMG, COVISE_HEADER *covise, INT idx_sol) -{ - INT l, remaining, sent, n_comp_sol; - TokenBuffer tb; - Message* msg = new Message; - msg->type = (covise_msg_type)0; - - printf("CoviseIF: SendSolution start, idx_sol=%d\n", idx_sol); - - n_comp_sol = covise->solutions[idx_sol].n_components; - - /* reset vertex flags */ - ResetVertexFlags(theMG, covise->min_level, covise->max_level); - - - /* start first buffer */ - tb.reset(); - remaining = MIN(covise->n_vertices,MAX_ITEMS_SENT); - tb << MT_UGSCALAR; - tb << idx_sol; - tb << remaining; - sent = 0; - - - /* extract data, loop from max_level to min_level! */ - /* TODO: special handling in ModelP */ - for (l=covise->max_level; l>=covise->min_level; l--) - { - NODE *theNode; - GRID *theGrid = GRID_ON_LEVEL(theMG,l); - - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - { - VECTOR *theVector; - INT i; - INT vid; - - if (USED(MYVERTEX(theNode))) continue; - SETUSED(MYVERTEX(theNode),1); - - - /* NOTE: vid is sent along with data! this increases msg sizes, but - is the secure solution (resistent to message order a.s.o.) */ - vid = ID(MYVERTEX(theNode)); - tb << (INT32)vid; - - theVector = NVECTOR(theNode); - - /* extract data from vector */ - for(i=0; i<n_comp_sol; i++) - { - INT comp = covise->solutions[idx_sol].comps[i]; - tb << (FLOAT32) VVALUE(theVector,comp); - } - - remaining--; - sent++; - - if (remaining==0) - { - /* send this buffer */ - msg->data = (char*)tb.get_data(); - msg->length = tb.get_length(); - covise_connection->send_msg(msg); - - /* start next buffer */ - tb.reset(); - remaining = MIN(covise->n_vertices - sent, MAX_ITEMS_SENT); - tb << MT_UGSCALAR; - tb << idx_sol; - tb << remaining; - } - } - } - - delete msg; - printf("CoviseIF: SendSolution stop\n"); - return(0); -} - - - -/****************************************************************************/ - - -/****************************************************************************/ - - - -extern "C" INT ConnectCovise (MULTIGRID *theMG, char *hostname) -{ - COVISE_HEADER covise; - Host *remotehost=new Host(hostname); - int quit_loop; - - printf("CoviseIF: trying to connect to %s\n", hostname); - - int wait_for_header=FALSE; - if (covise_connection==NULL) - { - covise_connection = - new ClientConnection(remotehost, DFLT_PORT, 0, (sender_type)0, 0); - printf("CoviseIF: new ClientConnection =%08x\n"); - - if (! covise_connection->is_connected()) - { - delete covise_connection; - covise_connection=NULL; - } - else - { - wait_for_header=TRUE; - } - } - - if (covise_connection!=NULL && covise_connection->is_connected()) - { - printf("CoviseIF: ok, connected to %s\n", hostname); - - Message* msg = new Message(); - int i; - - if (covise_connection->check_for_input()||wait_for_header) - { - printf("CoviseIF: input from %s\n", hostname); - - quit_loop = FALSE; - do { - covise_connection->recv_msg(msg); - printf("CoviseIF: received msg from %s, type %d\n", hostname, msg->type); - - switch (msg->type) - { - case (covise_msg_type)0 : - { - TokenBuffer tb(msg); - int headerRequest,gridRequest,numSolutions,solutions[MAX_SOLUTIONS]; - tb >> headerRequest; - tb >> gridRequest; - tb >> numSolutions; - for(i=0; i<numSolutions; i++) - tb >> solutions[i]; - - if (headerRequest) - { - printf("CoviseIF: headerRequest\n"); - - TokenBuffer rtb; - FillCoviseHeader(theMG, &covise); - rtb << MT_UGHEADER; - rtb << covise.min_level; - rtb << covise.max_level; - rtb << covise.n_vertices; - rtb << covise.n_elems; - rtb << covise.n_conns; - rtb << covise.num_solutions; - for(i=0; i<covise.num_solutions; i++) - { - printf("CoviseIF: sol #%d: comp=%d name=%s\n", i, covise.solutions[i].n_components, covise.solutions[i].name); - rtb << covise.solutions[i].n_components; - rtb << covise.solutions[i].name; - } - - Message rmsg(rtb); - rmsg.type = (covise_msg_type)0; - covise_connection->send_msg(&rmsg); - } - - if (gridRequest) - { - printf("CoviseIF: gridRequest\n"); - - SendSurfaceGrid(theMG, &covise); - } - - if (numSolutions>0) - { - printf("CoviseIF: solRequest, numSol=%d\n", numSolutions); - - for(i=0; i<numSolutions; i++) - { - SendSolution(theMG,&covise,solutions[i]); - } - } - } - break; - - /* 'continue without sending grid or solution' message */ - case (covise_msg_type)1 : - { - printf("CoviseIF: continue\n"); - - quit_loop = TRUE; - } - break; - - case SOCKET_CLOSED : - case CLOSE_SOCKET : - case EMPTY : - { - printf("CoviseIF: SOCKET_CLOSED\n"); - - delete covise_connection; - covise_connection = NULL; - - quit_loop = TRUE; - } - break; - - case QUIT : - { - printf("CoviseIF: QUIT\n"); - - delete covise_connection; - covise_connection = NULL; - - quit_loop = TRUE; - - /* TODO exit UG itself */ - } - break; - } - } while (!quit_loop); - } - - delete msg; - } - - - /* cleanup */ - delete remotehost; - - return(0); /* no error */ -} - - - -extern "C" INT InitCoviseIF (void) -{ - return(0); /* no error */ -} - - -extern "C" INT ExitCoviseIF (void) -{ - if (covise_connection!=NULL) - { - delete covise_connection; - covise_connection=NULL; - } - - return(0); /* no error */ -} - - -/****************************************************************************/ diff --git a/graphics/covise/coviseif.h b/graphics/covise/coviseif.h deleted file mode 100644 index e26ea4f8b22f067350afeb365c953d115348b58b..0000000000000000000000000000000000000000 --- a/graphics/covise/coviseif.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: coviseif.h */ -/* */ -/* Purpose: header for Covise<->UG interface */ -/* */ -/* Author: Stefan Lang, Klaus Birken */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 971216 begin */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __COVISEIF_H__ -#define __COVISEIF_H__ - -#include <stdio.h> - -#include "ugtypes.h" - -#ifndef __UGENV__ -#include "ugenv.h" -#endif - - -/****************************************************************************/ -/* */ -/* constants */ -/* */ -/****************************************************************************/ - - -/****************************************************************************/ -/* */ -/* macros */ -/* */ -/****************************************************************************/ - - -/****************************************************************************/ -/* */ -/* data types */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* function exported by this module */ -/* */ -/****************************************************************************/ - - -/* initialization and clean up */ -INT InitCoviseIF (void); -INT ExitCoviseIF (void); - -/* connect */ -INT ConnectCovise(MULTIGRID *, char *); - -#endif diff --git a/graphics/graphics.cc b/graphics/graphics.cc index f008e11848d5aa6046f4647344d5a401f76b8400..8300e02fd2e0122fb2df98729a3f8e1be25ef3f1 100644 --- a/graphics/graphics.cc +++ b/graphics/graphics.cc @@ -50,12 +50,6 @@ #include "initgraph.h" -#ifdef _COVISE -#include "coviseif.h" -#endif -#ifdef _PV3 -#include "pv3if.h" -#endif /* own header */ #include "graphics.h" @@ -134,19 +128,6 @@ INT NS_DIM_PREFIX InitGraphics (void) if (error!=0) return(error); -#ifdef _COVISE - /* init Covise interface */ - error = InitCoviseIF(); - if (error!=0) - return(error); -#endif - -#ifdef _PV3 - error = InitPV3(); - if (error!=0) - return(error); -#endif - return(0); /* no error */ } @@ -154,14 +135,5 @@ INT NS_DIM_PREFIX InitGraphics (void) INT NS_DIM_PREFIX ExitGraphics (void) { - #ifdef _COVISE - INT error; - - /* close Covise interface */ - error = ExitCoviseIF(); - if (error!=0) - return(error); - #endif - return(0); /* no error */ } diff --git a/graphics/pv3/.gitignore b/graphics/pv3/.gitignore deleted file mode 100644 index eb8d0d2f2d816222a3957a87d0fe7e7e061c3532..0000000000000000000000000000000000000000 --- a/graphics/pv3/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -*.lo -*.la -semantic.cache diff --git a/graphics/pv3/pv3if.c b/graphics/pv3/pv3if.c deleted file mode 100644 index 6c74d56c76dd2bb72bf0d34d239a95a1511495f4..0000000000000000000000000000000000000000 --- a/graphics/pv3/pv3if.c +++ /dev/null @@ -1,465 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: pv3if.c */ -/* */ -/* Purpose: Interface to pV3 */ -/* */ -/* Author: Michael Lampe */ -/* IWR Uni Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 69120 Heidelberg */ -/* Email: Michael.Lampe@iwr.uni-heidelberg.de */ -/* */ -/* History: 20030130 begin, ug3.8 */ -/* */ -/* Remarks: Don't despair. pV3 is written in Fortran 77 ;-) */ -/* */ -/* TODO: 1) support for on-line visualization */ -/* 2) give pV3 info about partition boundaries */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <string.h> -#include <pV3.h> - -#include "general.h" -#include "parallel.h" -#include "gm.h" -#include "shapes.h" -#include "commands.h" -#include "pv3if.h" - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define MAX_ITEM 50 - -#undef MIN -#define MIN(a, b) ((a)<=(b) ? (a) : (b)) - -#define SURFACE_LOOP_BEGIN(mg, e) \ - { \ - int _i; \ - for (_i = 0; _i <= TOPLEVEL(mg); _i++) \ - for (e = FIRSTELEMENT(GRID_ON_LEVEL(mg, _i)); e != NULL; e = SUCCE(e)) { \ - if (!EstimateHere(e)) continue; - -#define SURFACE_LOOP_END \ - } \ - } - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - -/* initialization data */ -static char title[]="UG Output"; /* title string */ -static int cid; /* client id */ -static char cname[]=" "; /* client name */ -static char dname[]=" "; /* not needed */ -static int iopt; /* unsteady control parameter */ -static int npgcut=0; /* # of programmer defined cuts */ -static char tpgcut[MAX_ITEM][32]; /* title for each cut */ -static int nkeys=0; /* # of active keyboard keys */ -static int ikeys[MAX_ITEM]; /* X-keypress return code for each key */ -static char tkeys[MAX_ITEM][32]; /* title for each key */ -static int fkeys[MAX_ITEM]; /* type of function controlled */ -static float flims[MAX_ITEM][2]; /* function limits/scales */ -static int mirror=0; /* not needed */ -static float repmat[16]; /* not needed */ -static int maxblk=0; /* not needed */ -static int istat; /* startup/terminate state */ - -/* evaluation data */ -static union { - EVALUES *s; - EVECTOR *v; -} eval[MAX_ITEM]; -static char eval_name[MAX_ITEM][NAMESIZE]; - -/****************************************************************************/ -/* */ -/* utility functions */ -/* */ -/****************************************************************************/ - -static void fstring(char *d, const char *s, size_t n) -{ - int i; - - strncpy(d, s, n); - for(i = MIN(strlen(s), n); i < n; i++) - d[i]=' '; -} - -static void ClearVertexMarkers(MULTIGRID *mg) -{ - VERTEX *v; - int i; - - for (i = 0; i <= TOPLEVEL(mg); i++) - for (v = FIRSTVERTEX(GRID_ON_LEVEL(mg, i)); v != NULL; v = SUCCV(v)) - SETUSED(v,0); -} - -/****************************************************************************/ -/* */ -/* callback for grid statistics */ -/* */ -/****************************************************************************/ - -void pVSTRUC(int *knode, int *kequiv, int *kcel1, int *kcel2, int *kcel3, - int *kcel4, int *knptet, int *kptet, int *knblock, int *blocks, - int *kphedra, int *ksurf, int *knsurf, int *hint) -{ - MULTIGRID *mg; - ELEMENT *e; - VERTEX *v; - int i; - - *knode = *kcel1 = *kcel2 = *kcel3 = *kcel4 = *ksurf = 0; - mg = GetCurrentMultigrid(); - ClearVertexMarkers(mg); - SURFACE_LOOP_BEGIN(mg, e) - switch (TAG(e)) - { - case TETRAHEDRON : - (*kcel1)++; - break; - case PYRAMID : - (*kcel2)++; - break; - case PRISM : - (*kcel3)++; - break; - case HEXAHEDRON : - (*kcel4)++; - } - for (i = 0; i < CORNERS_OF_ELEM(e); i++) { - v = MYVERTEX(CORNER(e, i)); - if (USED(v)) continue; - SETUSED(v, 1); - ID(v) = *knode; /* number vertices */ - (*knode)++; - } - /* check for domain boundary sides */ - if (OBJT(e) == BEOBJ) { - for (i = 0; i < SIDES_OF_ELEM(e); i++) - if (SIDE_ON_BND(e, i) && !InnerBoundary(e, i)) - (*ksurf)++; - } - SURFACE_LOOP_END - *kequiv = 0; - *knptet = 0; - *kptet = 0; - *knblock = 0; - *kphedra = 0; - *knsurf = 1; -} - -/****************************************************************************/ -/* */ -/* callback for element vertices */ -/* */ -/****************************************************************************/ - -void pVCELL(int *cel1, int *cel2, int *cel3, int *cel4, int *nptet, int *ptet) -{ - MULTIGRID *mg; - ELEMENT *e; - - mg = GetCurrentMultigrid(); - SURFACE_LOOP_BEGIN(mg, e) - switch (TAG(e)) - { - case TETRAHEDRON : - cel1[0] = ID(MYVERTEX(CORNER(e, 3)))+1; - cel1[1] = ID(MYVERTEX(CORNER(e, 0)))+1; - cel1[2] = ID(MYVERTEX(CORNER(e, 1)))+1; - cel1[3] = ID(MYVERTEX(CORNER(e, 2)))+1; - cel1 += 4; - break; - case PYRAMID : - cel2[0] = ID(MYVERTEX(CORNER(e, 0)))+1; - cel2[1] = ID(MYVERTEX(CORNER(e, 1)))+1; - cel2[2] = ID(MYVERTEX(CORNER(e, 2)))+1; - cel2[3] = ID(MYVERTEX(CORNER(e, 3)))+1; - cel2[4] = ID(MYVERTEX(CORNER(e, 4)))+1; - cel2 += 5; - break; - case PRISM : - cel3[0] = ID(MYVERTEX(CORNER(e, 1)))+1; - cel3[1] = ID(MYVERTEX(CORNER(e, 4)))+1; - cel3[2] = ID(MYVERTEX(CORNER(e, 5)))+1; - cel3[3] = ID(MYVERTEX(CORNER(e, 2)))+1; - cel3[4] = ID(MYVERTEX(CORNER(e, 3)))+1; - cel3[5] = ID(MYVERTEX(CORNER(e, 0)))+1; - cel3 += 6; - break; - case HEXAHEDRON : - cel4[0] = ID(MYVERTEX(CORNER(e, 0)))+1; - cel4[1] = ID(MYVERTEX(CORNER(e, 1)))+1; - cel4[2] = ID(MYVERTEX(CORNER(e, 2)))+1; - cel4[3] = ID(MYVERTEX(CORNER(e, 3)))+1; - cel4[4] = ID(MYVERTEX(CORNER(e, 4)))+1; - cel4[5] = ID(MYVERTEX(CORNER(e, 5)))+1; - cel4[6] = ID(MYVERTEX(CORNER(e, 6)))+1; - cel4[7] = ID(MYVERTEX(CORNER(e, 7)))+1; - cel4 += 8; - break; - } - SURFACE_LOOP_END -} - -/****************************************************************************/ -/* */ -/* callback for vertex coordinates */ -/* */ -/****************************************************************************/ - -void pVGRID(float *xyz) -{ - MULTIGRID *mg; - ELEMENT *e; - VERTEX *v; - int i; - - mg = GetCurrentMultigrid(); - ClearVertexMarkers(mg); - SURFACE_LOOP_BEGIN(mg, e) - for (i = 0; i < CORNERS_OF_ELEM(e); i++) { - v = MYVERTEX(CORNER(e, i)); - if (USED(v)) continue; - SETUSED(v, 1); - *xyz++ = XC(v); - *xyz++ = YC(v); - *xyz++ = ZC(v); - } - SURFACE_LOOP_END -} - -/****************************************************************************/ -/* */ -/* callback for surface data */ -/* */ -/****************************************************************************/ - -void pVSURFACE(int *nsurf, int *scon, int *scel, char *tsurf, int tsurf_len) -{ - MULTIGRID *mg; - ELEMENT *e; - VERTEX *v; - int i, j, n; - - mg = GetCurrentMultigrid(); - - /* domain surface */ - n = 0; - SURFACE_LOOP_BEGIN(mg, e) - if (OBJT(e) == BEOBJ) { - for (i = 0; i < SIDES_OF_ELEM(e); i++) - if (SIDE_ON_BND(e, i) && !InnerBoundary(e, i)) { - *scon++ = 0; - scel[3] = 0; - for (j = 0; j < CORNERS_OF_SIDE(e, i); j++) - scel[j] = ID(MYVERTEX(CORNER(e, CORNER_OF_SIDE(e, i, j))))+1; - scel += 4; - n++; - } - } - SURFACE_LOOP_END - nsurf[0] = n; - nsurf[1] = 2; - nsurf[2] = 1; - fstring(tsurf, "Domain Surface", 20); -} - -/****************************************************************************/ -/* */ -/* callback for scalar data */ -/* */ -/****************************************************************************/ - -void pVSCAL(int *key, float *s) -{ - MULTIGRID *mg; - ELEMENT *e; - VERTEX *v; - PreprocessingProcPtr pre; - ElementEvalProcPtr foo; - double *cc[MAX_CORNERS_OF_ELEM], lc[3]; - int i, k; - - k = (*key)-1; - mg = GetCurrentMultigrid(); - pre = eval[k].s->PreprocessProc; - if (pre != NULL) pre(eval_name[k], mg); - foo = eval[k].s->EvalProc; - mg = GetCurrentMultigrid(); - ClearVertexMarkers(mg); - SURFACE_LOOP_BEGIN(mg, e) - for (i = 0; i < CORNERS_OF_ELEM(e); i++) - cc[i] = CVECT(MYVERTEX(CORNER(e, i))); - for (i = 0; i < CORNERS_OF_ELEM(e); i++) { - v = MYVERTEX(CORNER(e, i)); - if (USED(v)) continue; - SETUSED(v, 1); - LocalCornerCoordinates(3, TAG(e), i, lc); - *s++ = (float)foo(e, cc, lc); - } - SURFACE_LOOP_END -} - -/****************************************************************************/ -/* */ -/* callback for vector data */ -/* */ -/****************************************************************************/ - -void pVVECT(int *key, float *V) -{ - MULTIGRID *mg; - ELEMENT *e; - VERTEX *v; - PreprocessingProcPtr pre; - ElementVectorProcPtr foo; - double *cc[MAX_CORNERS_OF_ELEM], lc[3], vv[3]; - int i, k; - - k = (*key)-1; - mg = GetCurrentMultigrid(); - pre = eval[k].v->PreprocessProc; - if (pre != NULL) pre(eval_name[k], mg); - foo = eval[k].v->EvalProc; - mg = GetCurrentMultigrid(); - ClearVertexMarkers(mg); - SURFACE_LOOP_BEGIN(mg, e) - for (i = 0; i < CORNERS_OF_ELEM(e); i++) - cc[i] = CVECT(MYVERTEX(CORNER(e, i))); - for (i = 0; i < CORNERS_OF_ELEM(e); i++) { - v = MYVERTEX(CORNER(e, i)); - if (USED(v)) continue; - SETUSED(v, 1); - LocalCornerCoordinates(3, TAG(e), i, lc); - foo(e, cc, lc, vv); - *V++ = (float)vv[0]; - *V++ = (float)vv[1]; - *V++ = (float)vv[2]; - } - SURFACE_LOOP_END -} - -/****************************************************************************/ -/* */ -/* pv3scal $k <key> $T <title> $ns <eval> $s <scal> $f <from> $t <to> */ -/* */ -/****************************************************************************/ - -static INT pv3ScalCommand(INT argc, char **argv) -{ - char k, T[32], ns[NAMELEN], s[NAMELEN]; - float f, t; - - if (strncmp(argv[1],"k",1) != 0) return PARAMERRORCODE; - sscanf(argv[1], "k %c", &k); - if (strncmp(argv[2],"T",1) != 0) return PARAMERRORCODE; - sscanf(argv[2], "T %s", T); - if (strncmp(argv[3],"ns",2) != 0) return PARAMERRORCODE; - sscanf(argv[3], "ns %s", ns); - if (strncmp(argv[4],"s",1) != 0) return PARAMERRORCODE; - sscanf(argv[4], "s %s", s); - if (strncmp(argv[5],"f",1) != 0) return PARAMERRORCODE; - sscanf(argv[5], "f %f", &f); - if (strncmp(argv[6],"t",1) != 0) return PARAMERRORCODE; - sscanf(argv[6], "t %f", &t); - ikeys[nkeys] = k; - fstring(tkeys[nkeys], T, 32); - fkeys[nkeys] = 1; - flims[nkeys][0] = f; - flims[nkeys][1] = t; - eval[nkeys].s = GetElementValueEvalProc(ns); - strcpy(eval_name[nkeys], s); - nkeys++; - return OKCODE; -} - -/****************************************************************************/ -/* */ -/* pv3vect $k <key> $T <title> $nv <eval> $s <vect> $f <scale> */ -/* */ -/****************************************************************************/ - -static INT pv3VectCommand(INT argc, char **argv) -{ - char k, T[32], nv[NAMELEN], s[NAMELEN]; - float f; - - if (strncmp(argv[1],"k",1) != 0) return PARAMERRORCODE; - sscanf(argv[1], "k %c", &k); - if (strncmp(argv[2],"T",1) != 0) return PARAMERRORCODE; - sscanf(argv[2], "T %s", T); - if (strncmp(argv[3],"nv",2) != 0) return PARAMERRORCODE; - sscanf(argv[3], "nv %s", nv); - if (strncmp(argv[4],"s",1) != 0) return PARAMERRORCODE; - sscanf(argv[4], "s %s", s); - if (strncmp(argv[5],"f",1) != 0) return PARAMERRORCODE; - sscanf(argv[5], "f %f", &f); - ikeys[nkeys] = k; - fstring(tkeys[nkeys], T, 32); - fkeys[nkeys] = 2; - flims[nkeys][0] = f; - flims[nkeys][1] = f; - eval[nkeys].v = GetElementVectorEvalProc(nv); - strcpy(eval_name[nkeys], s); - nkeys++; - return OKCODE; -} - -/****************************************************************************/ -/* */ -/* pv3plot */ -/* */ -/****************************************************************************/ - -static INT pv3PlotCommand(INT argc, char **argv) -{ - iopt = 0; /* steady grid & data */ - istat = 3; /* wait for and terminate with pV3 server */ - cid = me+1; - pV_INIT(title, &cid, cname, dname, &iopt, &npgcut, tpgcut[0], - &nkeys, ikeys, tkeys[0], fkeys, flims[0], &mirror, repmat, - &maxblk, &istat, strlen(title), strlen(cname), strlen(dname), - 32, 32); - if (istat != 0) return CMDERRORCODE; - return OKCODE; -} - -/****************************************************************************/ - -INT InitPV3(void) -{ - if (CreateCommand("pv3scal", pv3ScalCommand) == NULL) return __LINE__; - if (CreateCommand("pv3vect", pv3VectCommand) == NULL) return __LINE__; - if (CreateCommand("pv3plot", pv3PlotCommand) == NULL) return __LINE__; - return 0; -} diff --git a/graphics/pv3/pv3if.h b/graphics/pv3/pv3if.h deleted file mode 100644 index f09b0704529a3ce6ecac6544f8b911749c92c6d1..0000000000000000000000000000000000000000 --- a/graphics/pv3/pv3if.h +++ /dev/null @@ -1,28 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: pv3if.h */ -/* */ -/* Purpose: Interface to pV3 */ -/* */ -/* Author: Michael Lampe */ -/* IWR Uni Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 69120 Heidelberg */ -/* Email: Michael.Lampe@iwr.uni-heidelberg.de */ -/* */ -/* History: 20030130 begin, ug3.8 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -#ifndef __PV3IF__ -#define __PV3IF__ - -#include "ugtypes.h" - -INT InitPV3(void); - -#endif diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index ed3bc9f2c2a13e3c9359cc1a59050967674c03cc..2c53f2e5f52dda442ffcec57054031ba14031acb 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -1,6 +1,6 @@ set(SOURCES uginterface.cc initui.cc cmdint.cc cmdline.cc - dataexplorer.cc commands.cc helpmsg.cc avs.cc - tecplot.cc mmio.cc fieldio.cc) + commands.cc helpmsg.cc + mmio.cc fieldio.cc) install(FILES cmdint.h cmdline.h commands.h DESTINATION ${CMAKE_INSTALL_PKGINCLUDEDIR}) ug_add_dim_libs(ugui OBJECT SOURCES ${SOURCES}) diff --git a/ui/avs.cc b/ui/avs.cc deleted file mode 100644 index d645afba0e97e4b8c45c4f5585f1e710839c7d08..0000000000000000000000000000000000000000 --- a/ui/avs.cc +++ /dev/null @@ -1,944 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: avs.c */ -/* */ -/* Purpose: avs output */ -/* */ -/* Author: Peter Bastian */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: peter@ica3.uni-stuttgart.de */ -/* fon: 0049-(0)711-685-7003 */ -/* fax: 0049-(0)711-685-7000 */ -/* */ -/* History: 07.11.96 begin, ug version 3.4, derived from tecplot.c */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstdio> -#include <cstring> -#include <ctype.h> -#include <cmath> -#include <ctime> - -#include "ugdevices.h" -#include "enrol.h" -#include "ugtypes.h" -#include "misc.h" -#include "general.h" -#include "pfile.h" - -#include "gm.h" -#include "cw.h" -#include "elements.h" -#include "ugenv.h" -#include "ugm.h" -#include "algebra.h" -#include "cmdint.h" -#include "commands.h" -#include "helpmsg.h" -#include "shapes.h" -#include "cmdline.h" -#include "num.h" -#include "rm.h" - -#include "avs.h" - -USING_UG_NAMESPACES -using namespace PPIF; - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define MAXVARIABLES 20 /* max number of eval procs */ -#define VALUES_PER_LINE 10 /* number of data values per line */ - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - - - -#ifdef ModelP -static INT get_offset (INT n) -{ - INT i,subtreesize[50],sum,offset; - - /* get number of objects downtree */ - sum = n; - for (i=0; i<degree; i++) { - GetConcentrate(i,subtreesize+i,sizeof(INT)); - sum += subtreesize[i]; - } - - /* get offset */ - if (me==master) - { - offset = 0; - } - else - { - Concentrate(&sum,sizeof(INT)); - GetSpread(&offset,sizeof(INT)); - } - - /* send offsets for downtree nodes */ - sum = offset+n; - for (i=0; i<degree; i++) { - Spread(i,&sum,sizeof(INT)); - sum += subtreesize[i]; - } - - return(offset); -} - -static INT GloballyUniqueIDs (MULTIGRID *theMG) -{ - GRID *theGrid; - VERTEX *theVertex; - NODE *theNode; - ELEMENT *theElement; - INT nv,nn,ne; - INT ov,on,oe; - int k,j; - - nv = ne = nn = 0; - - j = theMG->topLevel; - for (k=0; k<=j; k++) - { - theGrid = GRID_ON_LEVEL(theMG,k); - - /* vertices */ - for (theVertex=FIRSTVERTEX(theGrid); theVertex!=NULL; theVertex=SUCCV(theVertex)) - ID(theVertex) = nv++; - - /* nodes */ - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - ID(theNode) = nn++; - - /* elements */ - for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) - ID(theElement) = ne++; - } - - theMG->vertIdCounter = nv; - theMG->nodeIdCounter = nn; - theMG->elemIdCounter = ne; - - ov = get_offset(nv); - on = get_offset(nn); - oe = get_offset(ne); - - for (k=0; k<=j; k++) - { - theGrid = GRID_ON_LEVEL(theMG,k); - - /* vertices */ - for (theVertex=FIRSTVERTEX(theGrid); theVertex!=NULL; theVertex=SUCCV(theVertex)) - ID(theVertex) += ov; - - /* nodes */ - for (theNode=FIRSTNODE(theGrid); theNode!=NULL; theNode=SUCCN(theNode)) - ID(theNode) += on; - - /* elements */ - for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) - ID(theElement) += oe; - } - - return(0); -} - -static INT AVS_GlobalSumINT (INT i) -{ - int l; - INT n; - - for (l=degree-1; l>=0; l--) - { - GetConcentrate(l,&n,sizeof(INT)); - i += n; - } - Concentrate(&i,sizeof(INT)); - Broadcast(&i,sizeof(INT)); - return(i); -} -#endif - -/****************************************************************************/ -/* */ -/* definition of functions */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/*D - avs - file output in AVS format - - DESCRIPTION: - The avs command stores grid and multiple vector or scalar grid functions - in AVS readable format to file. - - 'avs <filename> [$scale <factor>] [$zcoord <nep> $s <vd>] - [$ns <nep> $s <vd>]* [$nv <nep> $s <vd>]* - [$es <eep> $s <vd>]* [$ev <eep> $s <vd>]*' - - . $scale~<factor> - ? - . $zcoord... - plot function to be drawn on z-coordinate (2D grids only) - . $ns... - plot function for scalar nodal values - . $nv... - plot function for vector nodal values - . $es... - plot function for scalar element values - . $ev... - plot function for vector element values - - . <vd> - vecdata desc - . <nep> - eval proc (nodal values) - . <eep> - eval proc (element values) - - KEYWORDS: - graphics, plot, file, output, AVS - - EXAMPLE: - 'avs NavierStokesSolution.avs $ns nvalue $s psol $nv nvector $s velsol' - D*/ -/****************************************************************************/ - -static INT AVSCommand (INT argc, char **argv) -{ - INT i,j,k,v; /* counters etc. */ - INT counter; /* for formatting output */ - char item[1024],it[256]; /* item buffers */ - INT ic=0; /* item length */ - VERTEX *vx; /* a vertex pointer */ - ELEMENT *el; /* an element pointer */ - - MULTIGRID *mg; /* our multigrid */ - char filename[NAMESIZE]; /* file name for output file */ - PFILE *pf; /* the output file pointer */ - - EVALUES *zcoord; /* use scalar as z coordinate in 2D only */ - char zcoord_name[NAMESIZE]; /* name for eval functions */ - - INT ns; /* number of scalar eval procs */ - INT nv; /* number of vector eval procs */ - EVALUES *es[MAXVARIABLES]; /* pointers to scalar eval function desc */ - char es_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - EVECTOR *ev[MAXVARIABLES]; /* pointers to vector eval function desc */ - char ev_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - INT ns_cell; /* number of scalar eval procs */ - INT nv_cell; /* number of vector eval procs */ - EVALUES *es_cell[MAXVARIABLES]; /* pointers to scalar eval function desc*/ - char es_cell_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - EVECTOR *ev_cell[MAXVARIABLES]; /* pointers to vector eval function desc*/ - char ev_cell_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char s[NAMESIZE]; /* name of eval proc */ - INT numNodes; /* number of data points locally */ - INT numElements; /* number of elements locally */ - INT gnumNodes; /* number of data points globally */ - INT gnumElements; /* number of elements globallay */ - PreprocessingProcPtr pre; /* pointer to prepare function */ - ElementEvalProcPtr eval_s; /* pointer to scalar evaluation function */ - ElementVectorProcPtr eval_v; /* pointer to vector evaluation function */ - DOUBLE *CornersCoord[MAX_CORNERS_OF_ELEM]; /* pointers to coordinates */ - DOUBLE LocalCoord[DIM]; /* is one of the corners local coordinates */ - DOUBLE local[DIM]; /* local coordinate in DOUBLE */ - DOUBLE value; /* returned by user eval proc */ - DOUBLE x,y,z; /* scalar values */ - DOUBLE vval[DIM]; /* result of vector evaluation function */ - DOUBLE scale; - VECDATA_DESC *displacement; - const SHORT *comp; - time_t ltime; - double scaling=1.0; - INT oe,on,n; - - - /* get current multigrid */ - mg = GetCurrentMultigrid(); - if (mg==NULL) - { - PrintErrorMessage('W',"avs","no multigrid open\n"); - return (OKCODE); - } - - /* scan options */ - ns = nv = ns_cell = nv_cell = 0; - zcoord = NULL; - displacement = ReadArgvVecDesc(mg,"displacement",argc,argv); - if (displacement != NULL) { - comp = VD_ncmp_cmpptr_of_otype(displacement,NODEVEC,&n); - if (n < DIM) - return(CMDERRORCODE); - if (ReadArgvDOUBLE("scale",&scale,argc,argv)) - scale = 1.0; - } - for(i=1; i<argc; i++) - { - if (strncmp(argv[i],"scale",5)==0) { - sscanf(argv[i],"scale %s", s); - sscanf(s,"%lg",&scaling); - continue; - } - - if (strncmp(argv[i],"zcoord",6)==0) { - sscanf(argv[i],"zcoord %s", s); - zcoord = GetElementValueEvalProc(s); - if (zcoord==NULL) - { - PrintErrorMessageF('E',"avs:","could not find scalar eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(zcoord_name,s); - i++; - } - else - strcpy(zcoord_name,zcoord->v.name); - continue; - } - - if (strncmp(argv[i],"ns",2)==0) { - if (ns>=MAXVARIABLES) - { - PrintErrorMessage('E',"avs:","too many scalar variables specified\n"); - break; - } - sscanf(argv[i],"ns %s", s); - es[ns] = GetElementValueEvalProc(s); - if (es[ns]==NULL) - { - PrintErrorMessageF('E',"avs:","could not find scalar eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(es_name[ns],s); - i++; - } - else - strcpy(es_name[ns],es[ns]->v.name); - ns++; - continue; - } - - if (strncmp(argv[i],"nv",2)==0) { - if (nv>=MAXVARIABLES) - { - PrintErrorMessage('E',"avs:","too many vector variables specified\n"); - break; - } - sscanf(argv[i],"nv %s", s); - ev[nv] = GetElementVectorEvalProc(s); - if (ev[nv]==NULL) - { - PrintErrorMessageF('E',"avs:","could not find vector eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_name[nv],s); - i++; - } - else - strcpy(ev_name[nv],ev[nv]->v.name); - nv++; - continue; - } - - if (strncmp(argv[i],"cs",2)==0) { - if (ns_cell>=MAXVARIABLES) - { - PrintErrorMessage('E',"avs:","too many scalar variables specified\n"); - break; - } - sscanf(argv[i],"cs %s", s); - es_cell[ns_cell] = GetElementValueEvalProc(s); - if (es_cell[ns_cell]==NULL) - { - PrintErrorMessageF('E',"avs:","could not find scalar eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(es_cell_name[ns_cell],s); - i++; - } - else - strcpy(es_cell_name[ns_cell],es_cell[ns_cell]->v.name); - ns_cell++; - continue; - } - - if (strncmp(argv[i],"cv",2)==0) { - if (nv_cell>=MAXVARIABLES) - { - PrintErrorMessage('E',"avs:","too many vector variables specified\n"); - break; - } - sscanf(argv[i],"cv %s", s); - ev_cell[nv_cell] = GetElementVectorEvalProc(s); - if (ev_cell[nv_cell]==NULL) - { - PrintErrorMessageF('E',"avs:","could not find vector eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_cell_name[nv_cell],s); - i++; - } - else - strcpy(ev_cell_name[nv_cell],ev_cell[nv_cell]->v.name); - nv_cell++; - continue; - } - - } - if (ns==0 && nv==0) UserWrite("avs: no variables given, printing mesh data only\n"); - - /* get file name and open output file */ - if (sscanf(argv[0],expandfmt(CONCAT3(" avs %",NAMELENSTR,"[ -~]")),filename)!=1) - { - PrintErrorMessage('E',"avs","could not read name of output file"); - return(PARAMERRORCODE); - } - pf = pfile_open(filename); - if (pf==NULL) return(PARAMERRORCODE); - - /********************************/ - /* TITLE */ - /********************************/ - - time(<ime); - sprintf(it,"# AVS data produced by UG\n"); - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"# multigrid: %s\n",mg->v.name); - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"# date: %s",ctime(<ime)); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* compute sizes */ - /********************************/ - - /* clear USED flag in vertices on all levels */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - - /* run thru all levels of elements and set index */ - numNodes = numElements = 0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - numElements++; /* increase element counter */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; /* we have this one already */ - - ++numNodes; /* number of data points, begins with 1 ! */ - SETUSED(vx,1); /* tag vector as visited */ - } - } - - #ifdef ModelP - gnumNodes = AVS_GlobalSumINT(numNodes); - gnumElements = AVS_GlobalSumINT(numElements); - on=get_offset(numNodes); - oe=get_offset(numElements); - GloballyUniqueIDs(mg); /* renumber objects */ - #else - gnumNodes = numNodes; - gnumElements = numElements; - oe=on=0; - #endif - - /********************************/ - /* (1) now we are ready to write*/ - /* the sizes to the file */ - /********************************/ - - sprintf(it,"%d %d %d %d %d\n", - gnumNodes, /* total number of nodes to write */ - gnumElements, /* total number of cells */ - ns+1+nv*DIM, /* number of doubles per node */ - ns_cell+nv_cell*DIM, /* doubles per cell is always zero !*/ - 0); /* doubles per model */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* (2) next are the coordinates */ - /* of nodes in point block form */ - /* This is pfile segment 0 */ - /********************************/ - - if (DIM==2 && zcoord!=NULL) - { - pre = zcoord->PreprocessProc; - if (pre!=NULL) pre(zcoord_name,mg); - } - - /* clear USED flag in vertices on all levels */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); /* x,y,z of corners */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; /* we have this one already */ - SETUSED(vx,1); /* tag vector as visited */ - - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; - - x = XC(vx); - y = YC(vx); - if (DIM==3) - { - z = ZC(vx); - } - else - { - if (zcoord!=NULL) - { - eval_s = zcoord->EvalProc; - z = scaling*eval_s(el,(const DOUBLE **)CornersCoord,LocalCoord); - } - else - z = 0.0; - } - if (displacement != NULL) { - x += scale * VVALUE(NVECTOR(CORNER(el,i)),comp[0]); - y += scale * VVALUE(NVECTOR(CORNER(el,i)),comp[1]); - #ifdef __THREEDIM__ - z += scale * VVALUE(NVECTOR(CORNER(el,i)),comp[2]); - #endif - } - sprintf(it,"%d %g %g %g\n",ID(vx),x,y,z); - pfile_tagged_puts(pf,it,counter+on); - counter++; - } - } - - pfile_sync(pf); /* end of segment */ - - /********************************/ - /* (3) next is the cell */ - /* connectivity list */ - /********************************/ - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - - /* cell number and material id */ - #ifdef ModelP - sprintf(it,"%d %d ",ID(el),me); - #else - sprintf(it,"%d %d ",ID(el),SUBDOMAIN(el)); - #endif - strcpy(item+ic,it); ic+=strlen(it); - - if (DIM==2) - { - switch (CORNERS_OF_ELEM(el)) - { - case 3 : - sprintf(it,"tri %d %d %d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2)))); - break; - case 4 : - sprintf(it,"quad %d %d %d %d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3)))); - break; - } - } - else /* DIM==3 */ - { - switch (CORNERS_OF_ELEM(el)) - { - case 4 : - sprintf(it,"tet %d %d %d %d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,3)))); - break; - case 5 : - sprintf(it,"pyr %d %d %d %d %d\n", - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3)))); - break; - case 6 : - sprintf(it,"prism %d %d %d %d %d %d\n", - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,5))), - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2)))); - break; - case 8 : - sprintf(it,"hex %d %d %d %d %d %d %d %d\n", - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,5))), - ID(MYVERTEX(CORNER(el,6))), - ID(MYVERTEX(CORNER(el,7))), - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3)))); - break; - } - } - strcpy(item+ic,it); ic+=strlen(it); - pfile_tagged_puts(pf,item,counter+oe); ic=0; - counter++; - } - - pfile_sync(pf); /* end of segment */ - - /********************************/ - /* node data */ - /********************************/ - - if (1+ns+nv>0) - { - - /********************************/ - /* (4) data associated with */ - /* nodes */ - /********************************/ - - sprintf(it,"%d ",ns+nv+1); /* number of components */ - strcpy(item+ic,it); ic+=strlen(it); - for (k=0; k<ns; k++) { - sprintf(it,"1 "); /* scalar component */ - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"1 "); /* scalar component me */ - strcpy(item+ic,it); ic+=strlen(it); - for (k=0; k<nv; k++) { - sprintf(it,"%d ",DIM); /* vector component */ - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* (5) component labels */ - /* */ - /********************************/ - - /* now all scalar variables */ - for (i=0; i<ns; i++) { - sprintf(it,"%s, \n",ENVITEM_NAME(es[i])); /* no units */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - sprintf(it,"%s, \n","procid"); /* no units */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - for (i=0; i<nv; i++) { - sprintf(it,"%s, \n",ENVITEM_NAME(ev[i])); /* no units */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - /********************************/ - /* (6) all the node data */ - /* */ - /********************************/ - - /* CAUTION: AVS supports only a point block format. Therefore - all prepare functions are called at the beginning. - PREPARE FUNCTIONS MUST NOT INTERFERE WITH EACH OTHER ! - */ - - /* execute all prepare functions */ - for (v=0; v<ns; v++) - { - pre = es[v]->PreprocessProc; - - /* execute prepare function */ - if (pre!=NULL) pre(es_name[v],mg); - } - for (v=0; v<nv; v++) - { - pre = ev[v]->PreprocessProc; - - /* execute prepare function */ - if (pre!=NULL) pre(ev_name[v],mg); - } - - /* now the data in point block format */ - /* clear USED flag in vertices on all levels */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); /* x,y,z of corners */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; /* we have this one already */ - SETUSED(vx,1); /* tag vector as visited */ - - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; - - /* write node id */ - sprintf(it,"%d ",ID(MYVERTEX(CORNER(el,i)))); - strcpy(item+ic,it); ic+=strlen(it); - - /* scalar components */ - for (v=0; v<ns; v++) - { - eval_s = es[v]->EvalProc; - value = eval_s(el,(const DOUBLE **)CornersCoord,LocalCoord); - sprintf(it,"%g ",value); - strcpy(item+ic,it); ic+=strlen(it); - } - - #ifdef ModelP - value = (DOUBLE) me; - #else - value = SUBDOMAIN(el); - #endif - sprintf(it,"%g ",value); - strcpy(item+ic,it); ic+=strlen(it); - - /* vector components */ - for (v=0; v<nv; v++) - { - eval_v = ev[v]->EvalProc; - eval_v(el,(const DOUBLE **)CornersCoord,LocalCoord,vval); - if (DIM==2) - sprintf(it,"%g %g ",vval[0],vval[1]); - else - sprintf(it,"%g %g %g ",vval[0],vval[1],vval[2]); - strcpy(item+ic,it); ic+=strlen(it); - } - - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_tagged_puts(pf,item,counter+on); ic=0; - counter++; - } - } - } - - pfile_sync(pf); /* end of segment */ - - /********************************/ - /* cell data */ - /********************************/ - - if (ns_cell+nv_cell>0) - { - - /********************************/ - /* (4) data associated with */ - /* elements */ - /********************************/ - - sprintf(it,"%d ",ns_cell+nv_cell); /* number of components */ - strcpy(item+ic,it); ic+=strlen(it); - for (k=0; k<ns_cell; k++) { - sprintf(it,"1 "); /* scalar component */ - strcpy(item+ic,it); ic+=strlen(it); - } - for (k=0; k<nv_cell; k++) { - sprintf(it,"%d ",DIM); /* vector component */ - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* (5) component labels */ - /* */ - /********************************/ - - /* now all scalar variables */ - for (i=0; i<ns_cell; i++) { - sprintf(it,"%s, \n",ENVITEM_NAME(es_cell[i])); /* no units */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - for (i=0; i<nv_cell; i++) { - sprintf(it,"%s, \n",ENVITEM_NAME(ev_cell[i])); /* no units */ - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - /********************************/ - /* (6) all the cell data */ - /* */ - /********************************/ - - /* CAUTION: AVS supports only a point block format. Therefore - all prepare functions are called at the beginning. - PREPARE FUNCTIONS MUST NOT INTERFERE WITH EACH OTHER ! - */ - - /* execute all prepare functions */ - for (v=0; v<ns_cell; v++) - { - pre = es_cell[v]->PreprocessProc; - - /* execute prepare function */ - if (pre!=NULL) pre(es_cell_name[v],mg); - } - for (v=0; v<nv_cell; v++) - { - pre = ev_cell[v]->PreprocessProc; - - /* execute prepare function */ - if (pre!=NULL) pre(ev_cell_name[v],mg); - } - - /* now the data in point block format */ - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); /* x,y,z of corners */ - /* compute center in local coordinates */ - for (j=0; j<DIM; j++) LocalCoord[j] = 0.0; - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] += local[j]; - } - for (j=0; j<DIM; j++) LocalCoord[j] /= ((DOUBLE)CORNERS_OF_ELEM(el)); - - /* write cell id */ - sprintf(it,"%d ",ID(el)); - strcpy(item+ic,it); ic+=strlen(it); - - /* scalar components */ - for (v=0; v<ns_cell; v++) - { - eval_s = es_cell[v]->EvalProc; - value = eval_s(el,(const DOUBLE **)CornersCoord,LocalCoord); - sprintf(it,"%g ",value); - strcpy(item+ic,it); ic+=strlen(it); - } - - /* vector components */ - for (v=0; v<nv_cell; v++) - { - eval_v = ev_cell[v]->EvalProc; - eval_v(el,(const DOUBLE **)CornersCoord,LocalCoord,vval); - if (DIM==2) - sprintf(it,"%g %g ",vval[0],vval[1]); - else - sprintf(it,"%g %g %g ",vval[0],vval[1],vval[2]); - strcpy(item+ic,it); ic+=strlen(it); - } - - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_tagged_puts(pf,item,counter+oe); ic=0; - counter++; - } - } - - pfile_sync(pf); /* end of segment */ - - /********************************/ - /* IN THIS VERSION: */ - /* no cell and model data, we */ - /* are ready ! */ - /********************************/ - - pfile_close(pf); - - return(OKCODE); -} - -/****************************************************************************/ -/* */ -/* Function: InitAVS */ -/* */ -/* Purpose: register all formats for porous media library */ -/* */ -/* Input: void */ -/* */ -/* Output: INT 0: ok */ -/* else line number where error occured */ -/* */ -/****************************************************************************/ - -INT NS_DIM_PREFIX InitAVS () -{ - if (CreateCommand("avs",AVSCommand)==NULL) return (__LINE__); - - return(0); -} diff --git a/ui/avs.h b/ui/avs.h deleted file mode 100644 index 63418d74eca50d1436b9a0c5eb04fda37bd5a6aa..0000000000000000000000000000000000000000 --- a/ui/avs.h +++ /dev/null @@ -1,49 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: avs.h */ -/* */ -/* Purpose: avs output header file */ -/* */ -/* Author: Peter Bastian */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 29.06.95 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __AVS__ -#define __AVS__ - -#include "ugtypes.h" -#include "namespace.h" - -START_UGDIM_NAMESPACE - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -/* exports only the init function */ -INT InitAVS (); - -END_UGDIM_NAMESPACE - -#endif diff --git a/ui/commands.cc b/ui/commands.cc index 857bd11b7204a114ac45bde031078a55df280a88..39509e56671a5d905704b610c6f03734da9225e6 100644 --- a/ui/commands.cc +++ b/ui/commands.cc @@ -110,9 +110,6 @@ #include "wop.h" #include "graph.h" #include "graphics/grape/connectuggrape.h" -#ifdef _COVISE -#include "graphics/covise/coviseif.h" -#endif /* user interface module */ #include "uginterface.h" @@ -7202,38 +7199,6 @@ static INT CallGrapeCommand (INT argc, char **argv) } -#ifdef _COVISE - -/** \brief Implementation of \ref covise. */ -static INT CoviseCommand (INT argc, char **argv) -{ - MULTIGRID *theCurrMG; - char hostname[NAMESIZE]; - - /* see if multigrid exists */ - theCurrMG = currMG; - if (theCurrMG==NULL) - { - UserWrite("cannot start covise without multigrid\n"); - return (CMDERRORCODE); - } - - - if (sscanf(argv[0],"covise %s",hostname)!=1) - { - UserWrite("covise: specify hostname to connect to!\n"); - return(PARAMERRORCODE); - } - - /* call covise */ - if (ConnectCovise(theCurrMG, hostname)) return (CMDERRORCODE); - - return (OKCODE); -} -#endif - - - /** \brief Implementation of \ref screensize. */ static INT ScreenSizeCommand (INT argc, char **argv) { @@ -11579,10 +11544,6 @@ INT NS_DIM_PREFIX InitCommands () /* commands for grape */ if (CreateCommand("grape", CallGrapeCommand )==NULL) return (__LINE__); -#ifdef _COVISE - /* commands for covise */ - if (CreateCommand("covise", CoviseCommand )==NULL) return (__LINE__); -#endif /* commands for window and picture management */ if (CreateCommand("screensize", ScreenSizeCommand )==NULL) return (__LINE__); diff --git a/ui/commands.doc b/ui/commands.doc index 009573517f7107bc281e1c7f1fa524a15f58dc21..98f4246bef0fecfa8201e6b8de604466b4e0aed1 100644 --- a/ui/commands.doc +++ b/ui/commands.doc @@ -1663,21 +1663,6 @@ freeaverage $nv uwTrans $s sol $nv unTrans $s sol; */ /****************************************************************************/ -/****************************************************************************/ -/** \page covise covise - Enable covise interface - - \section Description - This command enables docking of a Covise user interface by a remote - workstation. - -\section Syntax - <li> hostname - hostname of workstation which runs Covise - - \section Keywords - multigrid, graphics, Covise, plot -*/ -/****************************************************************************/ - /****************************************************************************/ /** \page screensize screensize - Print the size of the monitor screen in pixels diff --git a/ui/dataexplorer.cc b/ui/dataexplorer.cc deleted file mode 100644 index a55c3ae3bc85ea34891f9414896a7bf17fc54681..0000000000000000000000000000000000000000 --- a/ui/dataexplorer.cc +++ /dev/null @@ -1,1980 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: dataexplorer.c */ -/* */ -/* Purpose: dataexplorer output */ -/* */ -/* Author: Volker Reichenberger / Michael Lampe */ -/* IWR Technische Simulation */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 69120 Heidelberg */ -/* email: volker.reichenberger@iwr.uni-heidelberg.de */ -/* michael.lampe@iwr.uni-heidelberg.de */ -/* */ -/* History: 23.03.2000 begin */ -/* */ -/* Remarks: DX supports only irregular grids made of triangles/ */ -/* quadrilaterals (2D) or tetrahedrons/hexahedrons (3D), */ -/* respectively -- and you can't mix the two types. So we */ -/* use degenerate quadrilaterals/hexahedrons to emulate the */ -/* missing element types. Let's hope this works in all cases! */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstdio> -#include <cstring> -#include <ctype.h> -#include <cmath> -#include <ctime> - -#include "architecture.h" -#include "ugdevices.h" -#include "enrol.h" -#include "ugtypes.h" -#include "misc.h" -#include "general.h" -#include "pfile.h" - -#include "gm.h" -#include "elements.h" -#include "ugenv.h" -#include "ugm.h" -#include "algebra.h" -#include "cmdint.h" -#include "commands.h" -#include "helpmsg.h" -#include "shapes.h" -#include "cmdline.h" -#include "num.h" -#include "rm.h" -#include "udm.h" - -#include "dataexplorer.h" -#include "cw.h" - -USING_UG_NAMESPACES -using namespace PPIF; - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - -#define MAXVARIABLES 50 /* max number of eval procs */ - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* definition of functions */ -/* */ -/****************************************************************************/ - -#ifdef ModelP -static INT get_offset (INT n) -{ - INT i,subtreesize[50],sum,offset; - - /* get number of objects downtree */ - sum = n; - for (i=0; i<degree; i++) { - GetConcentrate(i,subtreesize+i,sizeof(INT)); - sum += subtreesize[i]; - } - - /* get offset */ - if (me==master) - { - offset = 0; - } - else - { - Concentrate(&sum,sizeof(INT)); - GetSpread(&offset,sizeof(INT)); - } - - /* send offsets for downtree nodes */ - sum = offset+n; - for (i=0; i<degree; i++) { - Spread(i,&sum,sizeof(INT)); - sum += subtreesize[i]; - } - - return(offset); -} - -static void LocallyUniqueIDs (MULTIGRID *mg) -{ - VERTEX *vx; - ELEMENT *el; - INT i, k, nv; - - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - - nv=0; - /* first set master ids */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - for (i=0; i<CORNERS_OF_ELEM(el); i++) { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - if (DDD_InfoPriority(PARHDR(CORNER(el,i)))!=PrioMaster) continue; - SETUSED(vx,1); - ID(vx) = nv++; - } - } - - /* next set remaining ids */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - for (i=0; i<CORNERS_OF_ELEM(el); i++) { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); - ID(vx) = nv++; - } - } -} - -static int Gather_VertexID (DDD_OBJ obj, void *data) -{ - VECTOR *pv = (VECTOR *)obj; - - ((INT *)data)[0] = ID(MYVERTEX((NODE *)VOBJECT(pv))); - - return (NUM_OK); -} -static int Scatter_VertexID (DDD_OBJ obj, void *data) -{ - VECTOR *pv = (VECTOR *)obj; - - ID(MYVERTEX((NODE *)VOBJECT(pv))) = ((INT *)data)[0]; - - return (NUM_OK); -} -#endif - -static double clampf(double x) -{ - if (x < (double)FLT_MIN && x > (double)(-FLT_MIN)) - return 0.0; - else - return x; -} - -/****************************************************************************/ -/*D - dataexplorer - file output in DataExplorer format - - DESCRIPTION: - The dataexplorer command writes the grid and multiple vector or scalar - grid functions in DataExplorer readable format to a header and a - data file. The data file is written as a text file (default) or in - binary format. In order to save disk space it is possible to write - only the data and not the grid at later time steps (if the grid is - not changing). - - 'dataexplorer <filename> [$ns <nep> $s <vd> [$v <ref>]]* [$nv <nep> $s <vd> [$v <ref>]]* - [$cs <eep> $s <vd> [$v <ref>]]* [$cv <eep> $s <vd> [$v <ref>]]* - [$b 0|1|2]* [$bin]* [$fgrid]* [$s [+|-]id]*' - - . $ns... - plot function for scalar nodal values - . $nv... - plot function for vector nodal values - . $cs... - plot function for scalar element values - . $cv... - plot function for vector element values - . $v... - variable name to be used in DataExplorer - . $b... - write boundary data 0=no (default) | 1=inner | 2=all - . $bin... - write grid and data in binary format - . $fgrid... - if not initial time step grid is not written - . $s... - write only specified subdomains. Positive id means that the - subdomain is written. Negative id means that the subdomain is - not included. If you use $s, default is that subdomains are not - written unless specified. However, if the first argument - to $s is negative, all subdomains are selected for output (except - the specified one). - - . <vd> - vecdata desc - . <nep> - eval proc (nodal values) - . <eep> - eval proc (element values) - - KEYWORDS: - graphics, plot, file, output, DataExplorer - - EXAMPLE: - 'dataexplorer NavierStokesSolution.dx $ns nvalue $s psol $v pressure $nv nvector $s velsol $v velocity' - D*/ -/****************************************************************************/ - -static INT DataExplorerCommand (INT argc, char **argv) -{ - INT i,j,k,v; /* counters etc. */ - INT counter; /* for formatting output */ - INT dat_pos; /* indicates offset in data file */ - INT old_pos; - char item[1024],it[256]; /* item buffers */ - char out_form[256]; - INT ic=0; /* item length */ - VERTEX *vx; /* a vertex pointer */ - ELEMENT *el; /* an element pointer */ - - MULTIGRID *mg; /* our multigrid */ - HEAP *heap; - - char filename[NAMESIZE]; /* file name for header file */ - char filename_dat[NAMESIZE]; /* file name for data output file */ - char filename_grid[NAMESIZE]; /* file name for grid output file */ - char *c_ptr; - PFILE *pf; /* the output header file pointer */ - PFILE *pf_txt; /* file pointer for ascii output */ - PFILE_BIN *pf_bin; /* file pointer for binary output */ - - INT np; /* number of eval procs */ - INT ns; /* number of scalar eval procs */ - INT nv; /* number of vector eval procs */ - EVALUES *es[MAXVARIABLES]; /* pointers to scalar eval function desc */ - char es_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char es_var[MAXVARIABLES][NAMESIZE]; /* DX variable name */ - EVECTOR *ev[MAXVARIABLES]; /* pointers to vector eval function desc */ - char ev_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char ev_var[MAXVARIABLES][NAMESIZE]; /* DX variable name */ - INT ns_cell; /* number of scalar eval procs */ - INT nv_cell; /* number of vector eval procs */ - EVALUES *es_cell[MAXVARIABLES]; /* pointers to scalar eval function desc*/ - char es_cell_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char es_cell_var[MAXVARIABLES][NAMESIZE]; /* DX variable names */ - EVECTOR *ev_cell[MAXVARIABLES]; /* pointers to vector eval function desc*/ - char ev_cell_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char ev_cell_var[MAXVARIABLES][NAMESIZE]; /* DX variable names */ - char s[NAMESIZE]; /* name of eval proc */ - - INT nv_bcell; /* number of vector eval procs for inner bnd*/ - EVECTOR *ev_bcell[MAXVARIABLES]; /* pointers to vector eval function desc*/ - char ev_bcell_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char ev_bcell_var[MAXVARIABLES][NAMESIZE]; /* DX variable names */ - - INT numVertices; /* number of data points locally */ - INT numVerticesTot; /* total number of data points locally */ - INT numElements; /* number of elements locally */ - INT gnumVertices; /* number of data points globally */ - INT gnumElements; /* number of elements globallay */ - - PreprocessingProcPtr pre; /* pointer to prepare function */ - ElementEvalProcPtr eval_s; /* pointer to scalar evaluation function */ - ElementVectorProcPtr eval_v; /* pointer to vector evaluation function */ - - DOUBLE *CornersCoord[MAX_CORNERS_OF_ELEM]; /* pointers to coordinates */ - DOUBLE LocalCoord[DIM]; /* is one of the corners local coordinates */ - DOUBLE local[DIM]; /* local coordinate in DOUBLE */ - DOUBLE value; /* returned by user eval proc */ - DOUBLE vval[DIM]; /* result of vector evaluation function */ - - INT notOnlyTetra; /* flag for tetrahedrons only grids */ - INT notOnlyTriang; /* flag for triangles only boundaries */ - INT nibnd; /* number of inner boundary faces/lines */ - INT gnibnd; /* global number of inner bndary faces/lines*/ - INT nobnd; /* number of outer boundary faces/lines */ - INT gnobnd; /* global number of outer bndary faces/lines*/ - INT writeBnds=0; /* flag: write boundaries? (1=Inner, 2=All) */ - INT binaryOutput=0; /* flag: write data in binary? (0=No|1=Yes) */ - INT writeGrid=1; /* flag: write grid? (0=No|1=Yes) */ - INT buffer_INT[8]; - FLOAT buffer_FLOAT[8]; - INT usedBuf; - INT *subdom=NULL; /* which subdomains to draw */ - INT subdomains=0; /* flag: draw only some subdomains */ - INT sdkey; - time_t ltime; - - INT oe,ov; - INT oibnd,oobnd; - INT blocks; - - /* get current multigrid */ - mg = GetCurrentMultigrid(); - if (mg==NULL) - { - PrintErrorMessage('W',"dataexplorer","no multigrid open\n"); - return (OKCODE); - } - - /* scan options */ - ns = nv = ns_cell = nv_cell = nv_bcell = 0; - np = 1; - - for(i=1; i<argc; i++) - { - if (strncmp(argv[i],"ns",2)==0) { - if (ns>=MAXVARIABLES) - { - PrintErrorMessage('E',"dataexplorer:","too many scalar variables "\ - "specified\n"); - break; - } - sscanf(argv[i],"ns %s", s); - es[ns] = GetElementValueEvalProc(s); - if (es[ns]==NULL) - { - PrintErrorMessageF('E',"dataexplorer:","could not find scalar "\ - "eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(es_name[ns],s); - i++; - } - else - strcpy(es_name[ns],es[ns]->v.name); - - if (sscanf(argv[i+1],"v %s", s) == 1) - { - strcpy(es_var[ns],s); - i++; - } - else - sprintf(es_var[ns],"data%d",np++); - - ns++; - continue; - } - - if (strncmp(argv[i],"nv",2)==0) { - if (nv>=MAXVARIABLES) - { - PrintErrorMessage('E',"dataexplorer:","too many vector variables "\ - "specified\n"); - break; - } - sscanf(argv[i],"nv %s", s); - ev[nv] = GetElementVectorEvalProc(s); - if (ev[nv]==NULL) - { - PrintErrorMessageF('E',"dataexplorer:","could not find vector "\ - "eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_name[nv],s); - i++; - } - else - strcpy(ev_name[nv],ev[nv]->v.name); - - if (sscanf(argv[i+1],"v %s", s) == 1) - { - strcpy(ev_var[nv],s); - i++; - } - else - sprintf(ev_var[nv],"data%d",np++); - - nv++; - continue; - } - - if (strncmp(argv[i],"cs",2)==0) { - if (ns_cell>=MAXVARIABLES) - { - PrintErrorMessage('E',"dataexplorer:","too many scalar variables "\ - "specified\n"); - break; - } - sscanf(argv[i],"cs %s", s); - es_cell[ns_cell] = GetElementValueEvalProc(s); - if (es_cell[ns_cell]==NULL) - { - PrintErrorMessageF('E',"dataexplorer:","could not find scalar "\ - "eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(es_cell_name[ns_cell],s); - i++; - } - else - strcpy(es_cell_name[ns_cell],es_cell[ns_cell]->v.name); - - if (sscanf(argv[i+1],"v %s", s) == 1) - { - strcpy(es_cell_var[ns_cell],s); - i++; - } - else - sprintf(es_cell_var[ns_cell],"data%d",np++); - - ns_cell++; - continue; - } - - if (strncmp(argv[i],"cv",2)==0) { - if (nv_cell>=MAXVARIABLES) - { - PrintErrorMessage('E',"dataexplorer:","too many vector variables "\ - "specified\n"); - break; - } - sscanf(argv[i],"cv %s", s); - ev_cell[nv_cell] = GetElementVectorEvalProc(s); - if (ev_cell[nv_cell]==NULL) - { - PrintErrorMessageF('E',"dataexplorer:","could not find vector "\ - "eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_cell_name[nv_cell],s); - i++; - } - else - strcpy(ev_cell_name[nv_cell],ev_cell[nv_cell]->v.name); - - if (sscanf(argv[i+1],"v %s", s) == 1) - { - strcpy(ev_cell_var[nv_cell],s); - i++; - } - else - sprintf(ev_cell_var[nv_cell],"data%d",np++); - - nv_cell++; - continue; - } - - /* - * Vector values for inner boundaries. Use centers of inner boundary element sides. - */ - if (strncmp(argv[i],"bv",2)==0) { - if (nv_bcell>=MAXVARIABLES) - { - PrintErrorMessage('E',"dataexplorer","too many vector variables "\ - "specified in bv argument\n"); - break; - } - sscanf(argv[i],"bv %s", s); - ev_bcell[nv_bcell] = GetElementVectorEvalProc(s); - if (ev_bcell[nv_bcell]==NULL) - { - PrintErrorMessageF('E',"dataexplorer","could not find vector "\ - "eval proc %s in bv argument\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_bcell_name[nv_bcell],s); - i++; - } - else - strcpy(ev_bcell_name[nv_bcell],ev_bcell[nv_bcell]->v.name); - - if (sscanf(argv[i+2],"v %s", s) == 1) - { - strcpy(ev_bcell_var[nv_bcell],s); - i++; - } - else - sprintf(ev_bcell_var[nv_bcell],"data%d",np++); - - nv_bcell++; - continue; - } - - /* write data in binary format? */ - if (strncmp(argv[i],"bin",3)==0) - binaryOutput=1; - - /* write grid or use existing data file as reference? */ - if (strncmp(argv[i],"fgrid",5)==0) - writeGrid=0; - - if (strncmp(argv[i],"sd",1)==0) { - if ( sscanf(argv[i],"sd %d",&j) ) - { - if ( subdom==NULL ) - { - heap = mg->theHeap; - MarkTmpMem(heap, &sdkey); - subdom = (INT *)GetTmpMem(heap, (mg->theBVPD.nSubDomains+1)*sizeof(INT), sdkey); - if ( subdom==NULL ) { - ReleaseTmpMem(heap, sdkey); - PrintErrorMessage('E',"dataexplorer","could not allocate memory"); - return(PARAMERRORCODE); - } - /* default is that all subdomains are used */ - for (k=1; k<=mg->theBVPD.nSubDomains; k++) subdom[k]=(j>0) ? 0 : 1; - } - - k = (j>0) ? j : -j; - if ( k <= mg->theBVPD.nSubDomains && k > 0) subdom[k] = (j>0) ? 1 : 0; - else UserWriteF("There is no subdomain %d\n",k); - subdomains = 1; - } - } - } - - if (ns==0 && nv==0 && ns_cell==0 && nv_cell==0) - UserWrite("dataexplorer: no variables given, printing mesh data only\n"); - - /* are inner and/or outer boundaries to be written? */ - if (ReadArgvINT("b",&writeBnds,argc,argv)) - writeBnds = 0; - if (writeBnds>2) writeBnds=2; - if (writeBnds<0) writeBnds=0; - - /* get file name and open output file */ - if (sscanf(argv[0],expandfmt(CONCAT3(" dataexplorer %",NAMELENSTR,"[ -~]")), - filename)!=1) - { - PrintErrorMessage('E',"dataexplorer","could not read name of output file"); - return(PARAMERRORCODE); - } - pf = pfile_open(filename); - if (pf==NULL) { - PrintErrorMessage('E',"dataexplorer","could not open output file"); - return(PARAMERRORCODE); - } - - /* on first time step always write grid */ - if (strstr(filename,"0000")!=NULL) - writeGrid=1; - - if (binaryOutput) { - strcpy(filename_dat,filename); - c_ptr=strrchr(filename_dat,'.'); - if (c_ptr!=NULL) - memset(c_ptr, '\0', 1); - strcat(filename_dat, ".bin"); - pf_bin = pfile_open_bin(filename_dat); - if (pf_bin==NULL) { - PrintErrorMessage('E',"dataexplorer","could not open data file"); - return(PARAMERRORCODE); - } - strcpy(out_form,"binary"); - } else { - strcpy(filename_dat,filename); - c_ptr=strrchr(filename_dat,'.'); - if (c_ptr!=NULL) - memset(c_ptr, '\0', 1); - strcat(filename_dat, ".dat"); - pf_txt = pfile_open(filename_dat); - if (pf_txt==NULL) { - PrintErrorMessage('E',"dataexplorer","could not open data file"); - return(PARAMERRORCODE); - } - strcpy(out_form,"text"); - } - if (writeGrid) - strcpy(filename_grid, filename_dat); - else { - strcpy(filename_grid, filename); - c_ptr=strrchr(filename_grid,'.'); - if ( c_ptr!=NULL ) memset(c_ptr, '\0', 1); - if (binaryOutput) - strcat(filename_grid, ".bin"); - else - strcat(filename_grid, ".dat"); - } - - /********************************/ - /* TITLE */ - /********************************/ - - time(<ime); - sprintf(it,"#\n# DataExplorer file written by UG\n"); - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"# Date: %s#\n",ctime(<ime)); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"# Command: "); - strcpy(item+ic,it); ic+=strlen(it); - for ( i=0; i<argc; i++ ) { - sprintf(it," %s",argv[i]); - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"\n#\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* compute sizes */ - /********************************/ - - /* count vertices */ - /* - numVertices = 0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - numVertices++; - */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - numVertices = 0; numVerticesTot=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - for (i=0; i<CORNERS_OF_ELEM(el); i++) { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); -#ifdef ModelP - if (DDD_InfoPriority(PARHDR(CORNER(el,i)))==PrioMaster) /* count only Master vertices */ -#endif - numVertices++; - numVerticesTot++; - } - } - - if (subdomains) - { - /* - * Total #vertices neccessary for correct data allocation. - * If only some subdomains are drawn, we still need the total - * number of vertices. - */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - numVerticesTot = 0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - for (i=0; i<CORNERS_OF_ELEM(el); i++) { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); - numVerticesTot++; - } - } - } - - /* count surface elements */ - numElements = 0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - numElements++; - } - -#ifdef ModelP - gnumVertices = UG_GlobalSumINT(numVertices); - gnumElements = UG_GlobalSumINT(numElements); - /* LocallyUniqueIDs(mg); */ - ov = get_offset(numVertices); - oe = get_offset(numElements); -#else - gnumVertices = numVertices; - gnumElements = numElements; - ov = oe = 0; -#endif - - /****************************************************************/ - /* 1. write vertex coordinates */ - /****************************************************************/ - - sprintf(it,"\n#\n# positions\n#\n"); - strcpy(item+ic,it); ic+=strlen(it); - dat_pos = old_pos = 0; - sprintf(it,"object \"positions\" class array type float rank 1 shape %d items %d %s\ndata file %s,%d\n", - DIM, gnumVertices, out_form, filename_grid, dat_pos); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - if (binaryOutput) - dat_pos+=DIM*gnumVertices*sizeof(FLOAT); - - /* unmark vertices */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - - /* write vertex coordinates */ - { -#ifdef ModelP - INT count_rest = 0; -#endif - - counter=ov; - for (k=0; k<=TOPLEVEL(mg); k++) { - if (binaryOutput && !writeGrid) break; - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); - -#ifdef ModelP - if (DDD_InfoPriority(PARHDR(CORNER(el,i)))==PrioMaster) { -#endif - ID(vx) = counter; - /* write the thing */ - if (binaryOutput) { - buffer_FLOAT[0]=clampf(XC(vx)); - buffer_FLOAT[1]=clampf(YC(vx)); - buffer_FLOAT[2]=clampf(ZC(vx)); - } else { -#ifdef __TWODIM__ - sprintf(it,"\t%g\t%g\n", clampf(XC(vx)), clampf(YC(vx))); -#else - sprintf(it,"\t%g\t%g\t%g\n", clampf(XC(vx)), clampf(YC(vx)), - clampf(ZC(vx))); -#endif - } - if (binaryOutput) - pfile_tagged_write_FLOAT(pf_bin, buffer_FLOAT, DIM, counter); - else { - if (writeGrid) - pfile_tagged_puts(pf_txt,it,counter); - old_pos+=strlen(it); - } - counter++; -#ifdef ModelP - } - else { - ID(vx) = ov+numVertices+count_rest; - count_rest++; - } -#endif - } - } - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos = UG_GlobalSumINT(old_pos); -#else - dat_pos = old_pos; -#endif - old_pos = 0; - } - -#ifdef ModelP - { - /* communicate local IDs */ - for (k=0; k<=TOPLEVEL(mg); k++) { - DDD_IFAOneway(BorderVectorIF,GRID_ATTR(GRID_ON_LEVEL(mg,k)),IF_BACKWARD,sizeof(INT),Gather_VertexID, Scatter_VertexID); - } - } -#endif - - /* check if grid consists of tetrahedrons or triangles (in 2D) only */ - notOnlyTetra=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; -#ifdef __TWODIM__ - if (CORNERS_OF_ELEM(el)!=3) { - notOnlyTetra = 1; - break; - } -#else - if (CORNERS_OF_ELEM(el)!=4) { - notOnlyTetra = 1; - break; - } -#endif - } - if (notOnlyTetra) break; - } - -#ifdef ModelP - k = UG_GlobalSumINT(notOnlyTetra); - notOnlyTetra = k; -#endif - - /****************************************************************/ - /* 2. write connections for domain */ - /****************************************************************/ - - sprintf(it,"\n#\n# connections\n#\n"); - strcpy(item+ic,it); ic+=strlen(it); - if (notOnlyTetra) { - sprintf(it,"object \"connections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 4*(DIM-1), gnumElements, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=4*(DIM-1)*gnumElements*sizeof(INT); - } else { - sprintf(it,"object \"connections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - DIM+1, gnumElements, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=(DIM+1)*gnumElements*sizeof(INT); - } - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - pfile_sync(pf); - - counter = 0; - for (k=0; k<=TOPLEVEL(mg); k++) { - if (binaryOutput && !writeGrid) break; - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - switch(CORNERS_OF_ELEM(el)) - { - case 3 : - if (notOnlyTetra) { /* in 2D and NOT only triangles */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,2)))); - } else { /* in 2D and only triangles */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,2))); - usedBuf=3; - } else - sprintf(it,"\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2)))); - } - break; - - case 4 : -#ifdef __TWODIM__ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,2)))); -#else - if (notOnlyTetra) { /* in 3D and NOT only Tetrahedrons */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[4]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[5]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[6]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[7]=ID(MYVERTEX(CORNER(el,3))); - usedBuf=8; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,3)))); - } else { /* in 3D and only Tetrahedrons in grid */ - /* if ((ID(MYVERTEX(CORNER(el,0))) > numVerticesTot+1) || */ - /* (ID(MYVERTEX(CORNER(el,1))) > numVerticesTot+1) || */ - /* (ID(MYVERTEX(CORNER(el,2))) > numVerticesTot+1) || */ - /* (ID(MYVERTEX(CORNER(el,3))) > numVerticesTot+1)) { */ - /* assert(0); */ - /* } */ - - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,3))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3)))); - } -#endif - break; - - case 5 : - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[4]=ID(MYVERTEX(CORNER(el,4))); - buffer_INT[5]=ID(MYVERTEX(CORNER(el,4))); - buffer_INT[6]=ID(MYVERTEX(CORNER(el,4))); - buffer_INT[7]=ID(MYVERTEX(CORNER(el,4))); - usedBuf=8; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,4)))); - break; - - case 6 : - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[4]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[5]=ID(MYVERTEX(CORNER(el,4))); - buffer_INT[6]=ID(MYVERTEX(CORNER(el,5))); - buffer_INT[7]=ID(MYVERTEX(CORNER(el,5))); - usedBuf=8; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,5))), - ID(MYVERTEX(CORNER(el,5)))); - break; - - case 8 : - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el,0))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el,1))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el,3))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el,2))); - buffer_INT[4]=ID(MYVERTEX(CORNER(el,4))); - buffer_INT[5]=ID(MYVERTEX(CORNER(el,5))); - buffer_INT[6]=ID(MYVERTEX(CORNER(el,7))); - buffer_INT[7]=ID(MYVERTEX(CORNER(el,6))); - usedBuf=8; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el,0))), - ID(MYVERTEX(CORNER(el,1))), - ID(MYVERTEX(CORNER(el,3))), - ID(MYVERTEX(CORNER(el,2))), - ID(MYVERTEX(CORNER(el,4))), - ID(MYVERTEX(CORNER(el,5))), - ID(MYVERTEX(CORNER(el,7))), - ID(MYVERTEX(CORNER(el,6)))); - break; - } - if (binaryOutput) - pfile_tagged_write_INT(pf_bin, buffer_INT, usedBuf, counter+oe); - else { - if (writeGrid) - pfile_tagged_puts(pf_txt,it,counter+oe); - old_pos+=strlen(it); - } - counter++; - } - } - - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - -#ifdef __TWODIM__ - if (notOnlyTetra) - sprintf(it,"attribute \"element type\" string \"quads\"\n"); - else - sprintf(it,"attribute \"element type\" string \"triangles\"\n"); -#else - if (notOnlyTetra) - sprintf(it,"attribute \"element type\" string \"cubes\"\n"); - else - sprintf(it,"attribute \"element type\" string \"tetrahedra\"\n"); -#endif - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"attribute \"ref\" string \"positions\"\n\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /**************************************************/ - /* 2.a write connections for boundaries */ - /**************************************************/ - - if (writeBnds) { - /* unmark all elements */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - SETUSED(el,0); - - /* count number of sides on inner/outer boundaries */ - nibnd=0; - nobnd=0; - notOnlyTriang=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if ((!EstimateHere(el)) || (OBJT(el)!=BEOBJ)) continue; - - SETUSED(el,1); - for (i=0; i<SIDES_OF_ELEM(el); i++) { -#ifndef ModelP - if (NBELEM(el,i)!=NULL && USED(NBELEM(el,i))) continue; -#else - if (NBELEM(el,i)!=NULL && !EGHOST(NBELEM(el,i)) && USED(NBELEM(el,i))) continue; -#endif - if (SIDE_ON_BND(el,i)) { - if (NBELEM(el,i)==NULL) nobnd++; - else nibnd++; -#ifdef __THREEDIM - if (CORNERS_OF_SIDE(el,i)!=3) notOnlyTriang=1; -#endif - } - } - } - } -#ifdef ModelP - k = UG_GlobalSumINT(notOnlyTriang); - notOnlyTetra = k; - gnibnd = UG_GlobalSumINT(nibnd); - oibnd = get_offset(nibnd); - - gnobnd = UG_GlobalSumINT(nobnd); - oobnd = get_offset(nobnd); - -#else - gnibnd = nibnd; - gnobnd = nobnd; - oibnd = 0; - oobnd = 0; -#endif - - } - - if (writeBnds) { - /* unmark all elements yet again */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - SETUSED(el,0); - - /* now writing inner boundary faces or lines */ - sprintf(it,"\n#\n# connections for inner boundaries\n#\n"); - strcpy(item+ic,it); ic+=strlen(it); -#ifdef __TWODIM__ - sprintf(it,"object \"ibndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 2, gnibnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=2*gnibnd*sizeof(INT); -#else - if (notOnlyTriang) { - sprintf(it,"object \"ibndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 4, gnibnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=4*gnibnd*sizeof(INT); - } else { - sprintf(it,"object \"ibndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 3, gnibnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=3*gnibnd*sizeof(INT); - } -#endif - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - counter = 0; - for (k=0; k<=TOPLEVEL(mg); k++) { - if (binaryOutput && !writeGrid) break; - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if ((!EstimateHere(el)) || (OBJT(el)!=BEOBJ)) continue; - - SETUSED(el,1); - for (i=0; i<SIDES_OF_ELEM(el); i++) { -#ifndef ModelP - if (NBELEM(el,i)!=NULL && USED(NBELEM(el,i))) continue; -#else - if (NBELEM(el,i)!=NULL && !EGHOST(NBELEM(el,i)) && USED(NBELEM(el,i))) continue; -#endif - if (SIDE_ON_BND(el,i) && NBELEM(el,i)!=NULL) { - switch(CORNERS_OF_SIDE(el,i)) - { - case 2 : /* in 2D sides are edges => only two points */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - usedBuf=2; - } else - sprintf(it,"\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1))))); - break; - case 3 : /* has to be 3D */ - if (notOnlyTriang) { /* not only faces with 3 corners */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - } else { /* only triangles as faces */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=3; - } else - sprintf(it,"\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - } - break; - case 4 : /* has to be 3D and quads */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,3)))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,3)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - break; - } - if (binaryOutput) - pfile_tagged_write_INT(pf_bin, buffer_INT, usedBuf, counter+oibnd); - else { - if (writeGrid) - pfile_tagged_puts(pf_txt,it,counter+oibnd); - old_pos+=strlen(it); - } - counter++; - } - } - } - } - if(binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - -#ifdef __TWODIM__ - sprintf(it,"attribute \"element type\" string \"lines\"\n"); -#else - if (notOnlyTriang) - sprintf(it,"attribute \"element type\" string \"quads\"\n"); - else - sprintf(it,"attribute \"element type\" string \"triangles\"\n"); -#endif - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"attribute \"ref\" string \"positions\"\n\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - if (writeBnds==2) { - /* unmark all elements again */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - SETUSED(el,0); - - /* now writing outer boundary faces or lines */ - sprintf(it,"\n#\n# connections for outer boundaries\n#\n"); - strcpy(item+ic,it); ic+=strlen(it); -#ifdef __TWODIM__ - sprintf(it,"object \"obndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 2, gnobnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=2*gnobnd*sizeof(INT); -#else - if (notOnlyTriang) { - sprintf(it,"object \"obndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 4, gnobnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=4*gnobnd*sizeof(INT); - } else { - sprintf(it,"object \"obndconnections\" class array type int rank 1 shape %d items %d %s\ndata file %s,%d\n", - 3, gnobnd, out_form, filename_grid, dat_pos); - if (binaryOutput) - dat_pos+=3*gnobnd*sizeof(INT); - } -#endif - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - counter = 0; - for (k=0; k<=TOPLEVEL(mg); k++) { - if (binaryOutput && !writeGrid) break; - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if ((!EstimateHere(el)) || (OBJT(el)!=BEOBJ)) continue; - - SETUSED(el,1); - for (i=0; i<SIDES_OF_ELEM(el); i++) { - if ( NBELEM(el,i)!=NULL ) continue; - if (SIDE_ON_BND(el,i) && NBELEM(el,i)==NULL) { - switch(CORNERS_OF_SIDE(el,i)) - { - case 2 : /* in 2D sides are edges => only two points */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - usedBuf=2; - } else - sprintf(it,"\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1))))); - break; - case 3 : /* has to be 3D */ - if (notOnlyTriang) { /* not only faces with 3 corners */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - } else { /* only triangles as faces */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=3; - } else - sprintf(it,"\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - } - break; - case 4 : /* has to be 3D and quads */ - if (binaryOutput) { - buffer_INT[0]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))); - buffer_INT[1]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))); - buffer_INT[2]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,3)))); - buffer_INT[3]=ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2)))); - usedBuf=4; - } else - sprintf(it,"\t%d\t%d\t%d\t%d\n", - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,0)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,1)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,3)))), - ID(MYVERTEX(CORNER(el, CORNER_OF_SIDE(el,i,2))))); - break; - } - if (binaryOutput) - pfile_tagged_write_INT(pf_bin, buffer_INT, usedBuf, counter+oobnd); - else { - if (writeGrid) - pfile_tagged_puts(pf_txt,it,counter+oobnd); - old_pos+=strlen(it); - } - counter++; - } - } - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - -#ifdef __TWODIM__ - sprintf(it,"attribute \"element type\" string \"lines\"\n"); -#else - if (notOnlyTriang) - sprintf(it,"attribute \"element type\" string \"quads\"\n"); - else - sprintf(it,"attribute \"element type\" string \"triangles\"\n"); -#endif - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"attribute \"ref\" string \"positions\"\n\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - /* reset data file position counter if grid has not been written */ - if (!writeGrid) - dat_pos=0; - - /****************************************************************/ - /* 3. write node data */ - /****************************************************************/ - - blocks = 1; - - /* write all scalar node data */ - for (v=0; v<ns; v++) - { - pre = es[v]->PreprocessProc; - if (pre!=NULL) pre(es_name[v],mg); - - sprintf(it,"#\n# data block %d\n#\n", blocks); - strcpy(item+ic,it); ic+=strlen(it); - - sprintf(it,"object \"%s_data\" class array type float rank 0 items %d %s\ndata file %s,%d\n", - es_var[v], gnumVertices, out_form, filename_dat, dat_pos); - if (binaryOutput) - dat_pos+=gnumVertices*sizeof(FLOAT); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { -#ifdef ModelP - if (DDD_InfoPriority(PARHDR(CORNER(el,i)))!=PrioMaster) continue; -#endif - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); - - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; - - /* scalar components */ - eval_s = es[v]->EvalProc; - value = eval_s(el,(const DOUBLE **)CornersCoord,LocalCoord); - if (binaryOutput) { - buffer_FLOAT[0]=clampf(value); - pfile_tagged_write_FLOAT(pf_bin, buffer_FLOAT, 1, counter+ov); - } else { - sprintf(it,"\t%g\n",clampf(value)); - pfile_tagged_puts(pf_txt,it,counter+ov); - old_pos+=strlen(it); - } - counter++; - } - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - - /* domain data fields */ - sprintf(it,"\nobject \"%s\" class field\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - if (writeBnds) { - /* inner boundaries data fields */ - sprintf(it,"\nobject \"%s_ibnd\" class field\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"ibndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - if (writeBnds==2) { - /* outer boundaries data fields */ - sprintf(it,"\nobject \"%s_obnd\" class field\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"obndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", es_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - blocks++; - } - - /* write all vector node data */ - for (v=0; v<nv; v++) - { - pre = ev[v]->PreprocessProc; - if (pre!=NULL) pre(ev_name[v],mg); - - sprintf(it,"#\n# data block %d\n#\n", blocks); - strcpy(item+ic,it); ic+=strlen(it); - - sprintf(it,"object \"%s_data\" class array type float rank 1 shape %d items %d %s\ndata file %s,%d\n", - ev_var[v], DIM, gnumVertices, out_form, filename_dat, dat_pos); - if (binaryOutput) - dat_pos+=DIM*gnumVertices*sizeof(FLOAT); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - for (k=0; k<=TOPLEVEL(mg); k++) - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,k)); vx!=NULL; vx=SUCCV(vx)) - SETUSED(vx,0); - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { -#ifdef ModelP - if (DDD_InfoPriority(PARHDR(CORNER(el,i)))!=PrioMaster) continue; -#endif - vx = MYVERTEX(CORNER(el,i)); - if (USED(vx)) continue; - SETUSED(vx,1); - - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; - - /* vector components */ - eval_v = ev[v]->EvalProc; - eval_v(el,(const DOUBLE **)CornersCoord,LocalCoord,vval); -#ifdef __TWODIM__ - if (binaryOutput) { - buffer_FLOAT[0]=clampf(vval[0]); - buffer_FLOAT[1]=clampf(vval[1]); - } else - sprintf(it,"\t%g\t%g\n",clampf(vval[0]),clampf(vval[1])); -#else - if (binaryOutput) { - buffer_FLOAT[0]=clampf(vval[0]); - buffer_FLOAT[1]=clampf(vval[1]); - buffer_FLOAT[2]=clampf(vval[2]); - } else - sprintf(it,"\t%g\t%g\t%g\n",clampf(vval[0]),clampf(vval[1]), - clampf(vval[2])); -#endif - if (binaryOutput) - pfile_tagged_write_FLOAT(pf_bin, buffer_FLOAT, DIM, counter+ov); - else { - pfile_tagged_puts(pf_txt,it,counter+ov); - old_pos+=strlen(it); - } - counter++; - } - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - - /* domain data fields */ - sprintf(it,"\nobject \"%s\" class field\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - if (writeBnds) { - /* inner boundaries data fields */ - sprintf(it,"\nobject \"%s_ibnd\" class field\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"ibndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - if (writeBnds==2) { - /* outer boundaries data fields */ - sprintf(it,"\nobject \"%s_obnd\" class field\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"obndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - blocks++; - } - - /****************************************************************/ - /* 3. element data */ - /****************************************************************/ - - /* write all scalar element data */ - for (v=0; v<ns_cell; v++) - { - pre = es_cell[v]->PreprocessProc; - if (pre!=NULL) pre(es_cell_name[v],mg); - - sprintf(it,"#\n# data block %d\n#\n", blocks); - strcpy(item+ic,it); ic+=strlen(it); - - sprintf(it,"object \"%s_data\" class array type float rank 0 items %d %s\ndata file %s,%d\n", - es_cell_var[v], gnumElements, out_form, filename_dat, dat_pos); - if (binaryOutput) - dat_pos+=gnumElements*sizeof(FLOAT); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); - for (j=0; j<DIM; j++) LocalCoord[j] = 0.0; - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] += local[j]; - } - for (j=0; j<DIM; j++) LocalCoord[j] /= ((DOUBLE)CORNERS_OF_ELEM(el)); - - /* scalar component */ - eval_s = es_cell[v]->EvalProc; - value = eval_s(el,(const DOUBLE **)CornersCoord,LocalCoord); - if (binaryOutput) { - buffer_FLOAT[0]=clampf(value); - pfile_tagged_write_FLOAT(pf_bin, buffer_FLOAT, 1, counter+oe); - } else { - sprintf(it,"\t%g\n",clampf(value)); - pfile_tagged_puts(pf_txt,it,counter+oe); - old_pos+=strlen(it); - } - counter++; - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - - sprintf(it,"attribute \"dep\" string \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /* domain data fields */ - sprintf(it,"\nobject \"%s\" class field\n", es_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", es_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - if (writeBnds) { - /* inner boundaries data fields */ - sprintf(it,"\nobject \"%s_ibnd\" class field\n", es_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"ibndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", es_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - if (writeBnds==2) { - /* outer boundaries data fields */ - sprintf(it,"\nobject \"%s_obnd\" class field\n", blocks); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"obndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", es_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - blocks++; - } - - /* write all element vector data */ - for (v=0; v<nv_cell; v++) - { - pre = ev_cell[v]->PreprocessProc; - if (pre!=NULL) pre(ev_cell_name[v],mg); - - sprintf(it,"#\n# data block %d\n#\n", blocks); - strcpy(item+ic,it); ic+=strlen(it); - - sprintf(it,"object \"%s_data\" class array type float rank 1 shape %d items %d %s\ndata file %s,%d\n", - ev_cell_var[v], DIM, gnumElements, out_form, filename_dat, dat_pos); - if (binaryOutput) - dat_pos+=DIM*gnumElements*sizeof(FLOAT); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - pfile_sync(pf); - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - if ( subdomains && !subdom[SUBDOMAIN(el)] ) continue; - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); - for (j=0; j<DIM; j++) LocalCoord[j] = 0.0; - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] += local[j]; - } - for (j=0; j<DIM; j++) LocalCoord[j] /= ((DOUBLE)CORNERS_OF_ELEM(el)); - eval_v = ev_cell[v]->EvalProc; - eval_v(el,(const DOUBLE **)CornersCoord,LocalCoord,vval); -#ifdef __TWODIM__ - if (binaryOutput) { - buffer_FLOAT[0]=clampf(vval[0]); - buffer_FLOAT[1]=clampf(vval[1]); - } else - sprintf(it,"\t%g\t%g\n",clampf(vval[0]),clampf(vval[1])); -#else - if (binaryOutput) { - buffer_FLOAT[0]=clampf(vval[0]); - buffer_FLOAT[1]=clampf(vval[1]); - buffer_FLOAT[2]=clampf(vval[2]); - } else - sprintf(it,"\t%g\t%g\t%g\n",clampf(vval[0]),clampf(vval[1]), - clampf(vval[2])); -#endif - if (binaryOutput) - pfile_tagged_write_FLOAT(pf_bin, buffer_FLOAT, DIM, counter+ov); - else { - pfile_tagged_puts(pf_txt,it,counter+ov); - old_pos+=strlen(it); - } - counter++; - } - } - if (binaryOutput) - pfile_sync_bin(pf_bin); - else { - pfile_sync(pf_txt); -#ifdef ModelP - dat_pos += UG_GlobalSumINT(old_pos); -#else - dat_pos += old_pos; -#endif - old_pos = 0; - } - - sprintf(it,"attribute \"dep\" string \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /* domain data fields */ - sprintf(it,"\nobject \"%s\" class field\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"connections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - if (writeBnds) { - /* inner boundaries data fields */ - sprintf(it,"\nobject \"%s_ibnd\" class field\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"ibndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - if (writeBnds==2) { - /* outer boundaries data fields */ - sprintf(it,"\nobject \"%s_obnd\" class field\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"positions\" value \"positions\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"connections\" value \"obndconnections\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - sprintf(it,"component \"data\" value \"%s_data\"\n", ev_cell_var[v]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - - blocks++; - } - - /* put all data blocks into a group for select module */ - if (blocks > 1) { - sprintf(it,"\nobject \"default\" class group\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - k=0; - for (i = 0; i < ns; i++) { - sprintf(it,"member \"data%d\" value \"%s\"\n", ++k, es_var[i]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - for (i = 0; i < nv; i++) { - sprintf(it,"member \"data%d\" value \"%s\"\n", ++k, ev_var[i]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - for (i = 0; i < ns_cell; i++) { - sprintf(it,"member \"data%d\" value \"%s\"\n", ++k, es_cell_var[i]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - for (i = 0; i < nv_cell; i++) { - sprintf(it,"member \"data%d\" value \"%s\"\n", ++k, ev_cell_var[i]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - for (i = 0; i < nv_bcell; i++) { - sprintf(it,"member \"data%d\" value \"%s\"\n", ++k, ev_bcell_var[i]); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - } - } - - pfile_close(pf); - if (binaryOutput) - pfile_close_bin(pf_bin); - else - pfile_close(pf_txt); - - if ( subdomains ) - ReleaseTmpMem(heap, sdkey); - - return(OKCODE); -} - -/****************************************************************************/ -/* */ -/* Function: InitDataExplorer */ -/* */ -/* Purpose: register all formats for porous media library */ -/* */ -/* Input: void */ -/* */ -/* Output: INT 0: ok */ -/* else line number where error occured */ -/* */ -/****************************************************************************/ - -INT NS_DIM_PREFIX InitDataExplorer () -{ - if (CreateCommand("dataexplorer",DataExplorerCommand)==NULL) return (__LINE__); - - return(0); -} diff --git a/ui/dataexplorer.h b/ui/dataexplorer.h deleted file mode 100644 index 9478d59ffc1e5b9d8897ed67981c209d938f02ee..0000000000000000000000000000000000000000 --- a/ui/dataexplorer.h +++ /dev/null @@ -1,49 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: dataexplorer.h */ -/* */ -/* Purpose: dataexplorer output header file */ -/* */ -/* Author: Volker Reichenberger */ -/* IWR Technische Simulation */ -/* Universitaet Heidelberg */ -/* Im Neuenheimer Feld 368 */ -/* 69120 Heidelberg */ -/* email: volker.reichenberger@iwr.uni-heidelberg.de */ -/* */ -/* History: 23.03.2000 begin */ -/* */ -/* Remarks: based on avs.h */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __DATAEXPLORER_H__ -#define __DATAEXPLORER_H__ - -#include "ugtypes.h" -#include "namespace.h" - -START_UGDIM_NAMESPACE - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -/* exports only the init function */ -INT InitDataExplorer (); - -END_UGDIM_NAMESPACE - -#endif diff --git a/ui/initui.cc b/ui/initui.cc index be54f1982097d7664bac024dea5e161d0196ae48..e68de3b3059d36309fc345481f22298a3a20f0ba 100644 --- a/ui/initui.cc +++ b/ui/initui.cc @@ -45,9 +45,6 @@ #include "ugstruct.h" #include "commands.h" #include "mmio.h" -#include "tecplot.h" -#include "avs.h" -#include "dataexplorer.h" #include "fieldio.h" /* own header */ @@ -147,27 +144,6 @@ INT NS_DIM_PREFIX InitUi (INT argc, char **argv) return (err); } - /* tecplot output */ - if ((err=InitTecplot())!=0) - { - SetHiWrd(err,__LINE__); - return (err); - } - - /* avs output */ - if ((err=InitAVS())!=0) - { - SetHiWrd(err,__LINE__); - return (err); - } - - /* DataExplorer output */ - if ((err=InitDataExplorer())!=0) - { - SetHiWrd(err,__LINE__); - return (err); - } - /* matrix market input/output */ if ((err=InitMMIO())!=0) { diff --git a/ui/paraview.cc b/ui/paraview.cc deleted file mode 100644 index becacfbcea5ef52957e599857b46f433a2b3c25b..0000000000000000000000000000000000000000 --- a/ui/paraview.cc +++ /dev/null @@ -1,663 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: paraview.c */ -/* */ -/* Purpose: paraview output file */ -/* */ -/* History: 25.02.2005 begin */ -/* */ -/* Usage: paraview <filename> $a <sol> */ -/* */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstdio> -#include <cstring> -#include <ctype.h> -#include <cmath> -#include <ctime> - -#include "ugdevices.h" -#include "enrol.h" -#include "ugtypes.h" -#include "misc.h" -#include "general.h" -#include "pfile.h" - -#include "gm.h" -#include "elements.h" -#include "ugenv.h" -#include "ugm.h" -#include "algebra.h" - -#include "cmdint.h" -#include "commands.h" -#include "helpmsg.h" -#include "shapes.h" -#include "cmdline.h" -#include "num.h" -#include "rm.h" -#include "udm.h" - -#include "paraview.h" -#include "cw.h" - - -USING_UG_NAMESPACES - - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - - -/* max number of eval procs */ -#define MAXVARIABLES 50 - - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - - - - -/****************************************************************************/ -/* */ -/* definition of functions */ -/* */ -/****************************************************************************/ - - -#ifdef ModelP - -static INT WriteMetaFile(char* filename, VECDATA_DESC* vd) -{ - - /*counters*/ - int p, level, counterEquations, numEquations; - - /*file stuff*/ - char buffer[1024]; /*buffer for outputfile*/ - char* c_ptr; /*for searching patterns in strings, resp. a dot in filename*/ - FILE* metaOutputFile; /*file pointer for output file*/ - - /*ug topology*/ - MULTIGRID* mg; /*our multigrid*/ - GRID* g; /*the grid*/ - - - /*************************************************************************/ - /*GET CURRENT MULTIGRID */ - /*************************************************************************/ - - - mg = GetCurrentMultigrid(); - if (mg==NULL) - { - PrintErrorMessage('W',"dataexplorer","no multigrid open\n"); - return (OKCODE); - } - - - /*************************************************************************/ - /*GET FILENAME AND OPEN METAOUTPUTFILE */ - /*************************************************************************/ - - - c_ptr = strrchr(filename, '.'); - if (c_ptr != NULL) memset(c_ptr, '\0', 1); - - strcat(filename, ".MetaFile.pvtu"); - - metaOutputFile = fopen(filename, "w"); - - if(metaOutputFile == NULL) - { - PrintErrorMessage('E', "paraview", "could not open output file"); - return(PARAMERRORCODE); - } - - - /**************************************************************************/ - /*TITLE */ - /**************************************************************************/ - - - sprintf(buffer, "<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); - fputs(buffer, metaOutputFile); - - sprintf(buffer, "\t<PUnstructuredGrid Ghostlevel=\"0\">\n"); - fputs(buffer, metaOutputFile); - - - /****************************************************************************/ - /*WRITE PPOINTS */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t\t<PPoints>\n"); - fputs(buffer, metaOutputFile); - - sprintf(buffer, "\t\t\t\t<PDataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"/>\n\t\t\t\t\t"); - fputs(buffer, metaOutputFile); - - sprintf(buffer, "\n\t\t\t</PPoints>\n"); - fputs(buffer, metaOutputFile); - - - /****************************************************************************/ - /*WRITE PPOINT DATA */ - /****************************************************************************/ - - /*vector data*/ - - sprintf(buffer, "\t\t\t<PPointData>\n"); - fputs(buffer, metaOutputFile); - - for (level=0; level<=TOPLEVEL(mg); level++) - { - g = GRID_ON_LEVEL(mg,level); - numEquations = VD_NCMPS_IN_TYPE(vd,VTYPE(FIRSTVECTOR(g))); - - for (counterEquations=0; counterEquations<numEquations; counterEquations++) - { - sprintf(buffer, "\t\t\t\t<PDataArray type=\"Float64\" Name=\"%c\" format=\"ascii\"/>\n\t\t\t\t\t", VM_COMP_NAME(vd,counterEquations)); - fputs(buffer, metaOutputFile); - } - } - - sprintf(buffer, "\n\t\t\t</PPointData>\n"); - fputs(buffer, metaOutputFile); - - - /****************************************************************************/ - /*WRITE PIECES (SOURCES) */ - /****************************************************************************/ - - - c_ptr = strrchr(filename, '.'); - if (c_ptr != NULL) memset(c_ptr, '\0', 1); - - c_ptr = strrchr(filename, '.'); - if (c_ptr != NULL) memset(c_ptr, '\0', 1); - - for(p=0; p<procs; p++) - { - sprintf(buffer, "\t\t\t<Piece Source=\"%s.%d.vtu\"/>\n", filename, p); - fputs(buffer, metaOutputFile); - } - - - /****************************************************************************/ - /*WRITE END OF FILE AND CLOSE FILE */ - /****************************************************************************/ - - - sprintf(buffer, "\t</PUnstructuredGrid>\n"); - fputs(buffer, metaOutputFile); - - sprintf(buffer, "</VTKFile>"); - fputs(buffer, metaOutputFile); - - - fclose(metaOutputFile); - - - return(0); -} - -#endif - - -static INT ParaViewCommand (INT argc, char **argv) -{ - - /*counters*/ - int i, counterCorners, level, counterEquations, numVertices, numElements, offset, numEquations; - - /*file stuff*/ - char buffer[1024], it[5]; /*buffers for outputfile*/ - char filename[NAMESIZE]; /*filename for output file*/ - char* c_ptr; /*for searching patterns in strings, resp. a dot in filename*/ - FILE *outputFile; /*file pointer for output file*/ - - /*ug topology*/ - MULTIGRID *mg; /*our multigrid*/ - GRID *g; /*the grid*/ - ELEMENT *el; /*an element*/ - VERTEX *vx; /*a vertex*/ - - /*ug vector solutions*/ - VECTOR *v; /*vector*/ - VECDATA_DESC *vd; /*the vector data descriptor*/ - DOUBLE value; /*solution value*/ - - /*special cases*/ - int ugPrismArray[6]; /*for renumbering vertex IDs*/ - int vtkWedgeArray[6]; /*for renumbering vertex IDs*/ - - - /*************************************************************************/ - /*GET CURRENT MULTIGRID */ - /*************************************************************************/ - - - mg = GetCurrentMultigrid(); - if (mg==NULL) - { - PrintErrorMessage('W',"dataexplorer","no multigrid open\n"); - return (OKCODE); - } - - - /*************************************************************************/ - /*GET FILENAME AND OPEN OUTPUTFILE */ - /*************************************************************************/ - - -#ifdef ModelP - - if (sscanf(argv[0],expandfmt(CONCAT3(" paraview %",NAMELENSTR,"[ -~]")), - filename)!=1) - { - PrintErrorMessage('E',"paraview","could not read name of output file"); - return(PARAMERRORCODE); - } - - c_ptr = strrchr(filename, '.'); - if (c_ptr != NULL) memset(c_ptr, '\0', 1); - - sprintf(it, ".%d", me); /*process id*/ - strcat(filename, it); - - strcat(filename, ".vtu"); - - outputFile = fopen(filename, "w"); - - if(outputFile == NULL) - { - PrintErrorMessage('E', "paraview", "could not open output file"); - return(PARAMERRORCODE); - } - -#endif - -#ifndef ModelP - - if (sscanf(argv[0],expandfmt(CONCAT3(" paraview %",NAMELENSTR,"[ -~]")), - filename)!=1) - { - PrintErrorMessage('E',"paraview","could not read name of output file"); - return(PARAMERRORCODE); - } - - c_ptr = strrchr(filename, '.'); - if (c_ptr != NULL) memset(c_ptr, '\0', 1); - strcat(filename, ".vtu"); - - outputFile = fopen(filename, "w"); - - if(outputFile == NULL) - { - PrintErrorMessage('E', "paraview", "could not open output file"); - return(PARAMERRORCODE); - } - -#endif - - - /**************************************************************************/ - /*TITLE */ - /**************************************************************************/ - - - sprintf(buffer, "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "\t<UnstructuredGrid Ghostlevel=\"0\">\n"); - fputs(buffer, outputFile); - - - /**************************************************************************/ - /*WRITE NUMBER OF VERTICES AND ELEMENTS */ - /**************************************************************************/ - - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,level)); vx!=NULL; vx=SUCCV(vx)) - { - SETUSED(vx,0); - } - } - - numVertices = 0; - numElements = 0; - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - - numElements ++; - - for (counterCorners=0; counterCorners<CORNERS_OF_ELEM(el); counterCorners++) - { - vx = MYVERTEX(CORNER(el,counterCorners)); - if (USED(vx)) continue; - SETUSED(vx,1); - - ID(vx) = numVertices; - - numVertices++; - } - } - } - - sprintf(buffer, "\t\t<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", numVertices, numElements); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE POINTS */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t\t<Points>\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "\t\t\t\t<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">\n\t\t\t\t\t"); - fputs(buffer, outputFile); - - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,level)); vx!=NULL; vx=SUCCV(vx)) - { - SETUSED(vx,0); - } - } - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - - for (counterCorners=0; counterCorners<CORNERS_OF_ELEM(el); counterCorners++) - { - vx = MYVERTEX(CORNER(el,counterCorners)); - if (USED(vx)) continue; - SETUSED(vx,1); - - sprintf(buffer, "%g %g %g \n", XC(vx), YC(vx), ZC(vx)); - fputs(buffer, outputFile); - } - } - } - - sprintf(buffer, "\n\t\t\t\t</DataArray>"); - fputs(buffer, outputFile); - - sprintf(buffer, "\n\t\t\t</Points>\n"); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE CELLS: */ - /****************************************************************************/ - - - /****************************************************************************/ - /*WRITE CELL CONNECTIVITY */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t\t<Cells>\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "\t\t\t\t<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n\t\t\t\t\t"); - fputs(buffer, outputFile); - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (vx=FIRSTVERTEX(GRID_ON_LEVEL(mg,level)); vx!=NULL; vx=SUCCV(vx)) - { - SETUSED(vx,0); - } - } - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - sprintf(buffer, "\n"); - fputs(buffer, outputFile); - - if (!EstimateHere(el)) continue; - - for (counterCorners=0; counterCorners<CORNERS_OF_ELEM(el); counterCorners++) - { - vx = MYVERTEX(CORNER(el,counterCorners)); - - /*if the element is a prism: reorder vertex IDs: UG(0,1,2,3,4,5) -> VTK(0,2,1,3,5,4) */ - - if(TAG(el) == PRISM) - { - ugPrismArray[counterCorners] = ID(vx); - - vtkWedgeArray[0] = ugPrismArray[0]; - vtkWedgeArray[1] = ugPrismArray[2]; - vtkWedgeArray[2] = ugPrismArray[1]; - vtkWedgeArray[3] = ugPrismArray[3]; - vtkWedgeArray[4] = ugPrismArray[5]; - vtkWedgeArray[5] = ugPrismArray[4]; - - for(i=0; i<6; i++) - { - sprintf(buffer, "%d ", vtkWedgeArray[i]); - fputs(buffer, outputFile); - } - } - - else - { - sprintf(buffer, "%d ", ID(vx)); - fputs(buffer, outputFile); - } - } - } - } - - sprintf(buffer, "\n\t\t\t\t</DataArray>\n"); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE CELL OFFSETS */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t\t\t<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n\t\t\t\t\t"); - fputs(buffer, outputFile); - - offset = 0; - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - - offset += CORNERS_OF_ELEM(el); - - sprintf(buffer, "%d \n", offset); - fputs(buffer, outputFile); - } - } - - sprintf(buffer, "\n\t\t\t\t</DataArray>\n"); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE CELL TYPES */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t\t\t<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n\t\t\t\t\t"); - fputs(buffer, outputFile); - - for (level=0; level<=TOPLEVEL(mg); level++) - { - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - - if(TAG(el) == TRIANGLE) sprintf(buffer, "5 \n"); - else if(TAG(el) == QUADRILATERAL) sprintf(buffer, "9 \n"); - else if(TAG(el) == TETRAHEDRON) sprintf(buffer, "10 \n"); - else if(TAG(el) == PYRAMID) sprintf(buffer, "14 \n"); - else if(TAG(el) == PRISM) sprintf(buffer, "13 \n"); - else if(TAG(el) == HEXAHEDRON) sprintf(buffer, "12 \n"); - else sprintf(buffer, " TAG NOT FOUND \n"); - - fputs(buffer, outputFile); - } - } - - sprintf(buffer, "\n\t\t\t\t</DataArray>\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "\t\t\t</Cells>\n"); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE POINT DATA */ - /****************************************************************************/ - - /*vector data*/ - - sprintf(buffer, "\t\t\t<PointData>\n"); - fputs(buffer, outputFile); - - if ((vd = ReadArgvVecDesc(mg,"a",argc,argv))==NULL) - { - PrintErrorMessage('E',"paraview","could not read vec symbol"); - return (PARAMERRORCODE); - } - - for (level=0; level<=TOPLEVEL(mg); level++) - { - g = GRID_ON_LEVEL(mg,level); - numEquations = VD_NCMPS_IN_TYPE(vd,VTYPE(FIRSTVECTOR(g))); - - for (counterEquations=0; counterEquations<numEquations; counterEquations++) - { - sprintf(buffer, "\t\t\t\t<DataArray type=\"Float64\" Name=\"%c\" format=\"ascii\">\n\t\t\t\t\t", VM_COMP_NAME(vd,counterEquations)); - fputs(buffer, outputFile); - - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,level)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; - - for (counterCorners=0; counterCorners<CORNERS_OF_ELEM(el); counterCorners++) - { - v = NVECTOR(CORNER(el,counterCorners)); - - value = VVALUE(v,VD_CMP_OF_TYPE(vd,VTYPE(v),counterEquations)); - sprintf(buffer,"%g\n",value); - fputs(buffer, outputFile); - } - } - - sprintf(buffer, "\n\t\t\t\t</DataArray>\n"); - fputs(buffer, outputFile); - } - } - - sprintf(buffer, "\t\t\t</PointData>\n"); - fputs(buffer, outputFile); - - - /****************************************************************************/ - /*WRITE END OF FILE AND CLOSE FILE */ - /****************************************************************************/ - - - sprintf(buffer, "\t\t</Piece>\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "\t</UnstructuredGrid>\n"); - fputs(buffer, outputFile); - - sprintf(buffer, "</VTKFile>"); - fputs(buffer, outputFile); - - - fclose(outputFile); - - - - /****************************************************************************/ - /*WRITE METAFILE */ - /****************************************************************************/ - - -#ifdef ModelP - - if(me == master) - { - WriteMetaFile(filename, vd); - } - -#endif - - - return(0); - -} - - -/****************************************************************************/ -/* */ -/* Function: InitParaView */ -/* */ -/* Purpose: */ -/* */ -/* Input: void */ -/* */ -/* Output: INT 0: ok */ -/* else line number where error occured */ -/* */ -/****************************************************************************/ - - -INT InitParaView (void) -{ - if (CreateCommand("paraview",ParaViewCommand)==NULL) return (__LINE__); - - return(0); -} diff --git a/ui/paraview.h b/ui/paraview.h deleted file mode 100644 index 6601b504a5fc241e8fec3ed65550fee77b24cc71..0000000000000000000000000000000000000000 --- a/ui/paraview.h +++ /dev/null @@ -1,35 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: paraview.h */ -/* */ -/* Purpose: paraview output header file */ -/* */ -/* History: 25.02.2005 begin */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __PARAVIEW_H__ -#define __PARAVIEW_H__ - -#include "ugtypes.h" - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -/* exports only the init function */ -INT InitParaView (void); - -#endif diff --git a/ui/tecplot.cc b/ui/tecplot.cc deleted file mode 100644 index 0b35be6e35e0d79f6d46ddbadf98b43c22eb9e13..0000000000000000000000000000000000000000 --- a/ui/tecplot.cc +++ /dev/null @@ -1,566 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: tecplot.c */ -/* */ -/* Purpose: tecplot output */ -/* */ -/* Author: Peter Bastian */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: peter@ica3.uni-stuttgart.de */ -/* fon: 0049-(0)711-685-7003 */ -/* fax: 0049-(0)711-685-7000 */ -/* */ -/* History: 29.06.95 begin, ug version 3.0 */ -/* 22.08.96 revised version for 3D,local refinement,user eval pr */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - -/****************************************************************************/ -/* */ -/* include files */ -/* system include files */ -/* application include files */ -/* */ -/****************************************************************************/ - -#include <config.h> -#include <cstdio> -#include <cstring> -#include <ctype.h> -#include <cmath> - -#include "ugdevices.h" -#include "enrol.h" -#include "ugtypes.h" -#include "misc.h" -#include "general.h" -#include "pfile.h" - -#include "gm.h" -#include "elements.h" -#include "ugenv.h" -#include "ugm.h" -#include "algebra.h" -#include "cmdint.h" -#include "commands.h" -#include "helpmsg.h" -#include "shapes.h" -#include "cmdline.h" - -#include "tecplot.h" - -USING_UG_NAMESPACES - -#ifdef ModelP -using namespace PPIF; -#endif - -/****************************************************************************/ -/* */ -/* defines in the following order */ -/* */ -/* compile time constants defining static data size (i.e. arrays) */ -/* other constants */ -/* macros */ -/* */ -/****************************************************************************/ - - -/****************************************************************************/ -/* */ -/* definition of exported global variables */ -/* */ -/****************************************************************************/ - -#define MAXVARIABLES 20 /* max number of eval procs */ -#define VALUES_PER_LINE 10 /* number of data values per line */ - -/****************************************************************************/ -/* */ -/* definition of variables global to this source file only (static!) */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* definition of functions */ -/* */ -/****************************************************************************/ - -#ifdef ModelP -static INT get_offset (INT n) -{ - INT i,subtreesize[50],sum,offset; - - /* get number of objects downtree */ - sum = n; - for (i=0; i<degree; i++) { - GetConcentrate(i,subtreesize+i,sizeof(INT)); - sum += subtreesize[i]; - } - - /* get offset */ - if (me==master) - { - offset = 0; - } - else - { - Concentrate(&sum,sizeof(INT)); - GetSpread(&offset,sizeof(INT)); - } - - /* send offsets for downtree nodes */ - sum = offset+n; - for (i=0; i<degree; i++) { - Spread(i,&sum,sizeof(INT)); - sum += subtreesize[i]; - } - - return(offset); -} - -static INT TPL_GlobalSumINT (INT i) -{ - int l; - INT n; - - for (l=degree-1; l>=0; l--) - { - GetConcentrate(l,&n,sizeof(INT)); - i += n; - } - Concentrate(&i,sizeof(INT)); - Broadcast(&i,sizeof(INT)); - return(i); -} -#endif - -/****************************************************************************/ -/*D - tecplot - file output in Tecplot format - - DESCRIPTION: - The tecplot command writes the grid and scalar - grid functions in Tecplot readable format to a file. - The data in the written file as tecplot-zone in FEPOINT format, - the plot funtion is evaluated at the nodes of the elements. - - 'tecplot <filename> [$e <nep> $s <vd>]* $z <zonename>' - - . $e... - plot function for scalar node values - . $s... - pass this vecdatadesc to the plot function - . $z... - specify a name for the zone-record written in filename - . $g... - save geometry, this flag is parsed but not any action on it is implemented - - - <vd> - vecdata desc - <nep> - eval proc (nodal values) - <zonename> - string which appears in the zone-header of the written file - - KEYWORDS: - graphics, plot, file, output, tecplot - - EXAMPLE: - 'tecplot tplfilm $e evalue $s sol $z @TIME' - Here it is assumed that in a time depend calculation the variable TIME is defined - and to be used to identify the zones in tecplot. - D*/ -/****************************************************************************/ - -static INT TecplotCommand (INT argc, char **argv) -{ - INT i,j,k,v; /* counters etc. */ - INT counter; /* for formatting output */ - char item[1024],it[256]; /* item buffers */ - INT ic=0; /* item length */ - VECTOR *vc; /* a vector pointer */ - ELEMENT *el; /* an element pointer */ - - MULTIGRID *mg; /* our multigrid */ - char filename[NAMESIZE]; /* file name for output file */ - PFILE *pf; /* the output file pointer */ - - - INT nv; /* number of variables (eval functions) */ - EVALUES *ev[MAXVARIABLES]; /* pointers to eval function descriptors */ - char ev_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ - char s[NAMESIZE]; /* name of eval proc */ - char zonename[NAMESIZE+7] = ""; /* name for zone (initialized to - empty string) */ - INT numNodes; /* number of data points */ - INT numElements; /* number of elements */ - INT gnumNodes; /* number of data points globally */ - INT gnumElements; /* number of elements globallay */ - PreprocessingProcPtr pre; /* pointer to prepare function */ - ElementEvalProcPtr eval; /* pointer to evaluation function */ - DOUBLE *CornersCoord[MAX_CORNERS_OF_ELEM]; /* pointers to coordinates */ - DOUBLE LocalCoord[DIM]; /* is one of the corners local coordinates */ - DOUBLE local[DIM]; /* local coordinate in DOUBLE */ - DOUBLE value; /* returned by user eval proc */ - INT oe,on; - - INT saveGeometry; /* save geometry flag */ - - - /* get current multigrid */ - mg = GetCurrentMultigrid(); - if (mg==NULL) - { - PrintErrorMessage('W',"tecplot","no multigrid open\n"); - return (OKCODE); - } - - /* scan options */ - nv = 0; saveGeometry = 0; - for(i=1; i<argc; i++) - { - switch(argv[i][0]) - { - case 'e' : /* read eval proc */ - if (nv>=MAXVARIABLES) - { - PrintErrorMessage('E',"tecplot","too many variables specified\n"); - break; - } - sscanf(argv[i],"e %s", s); - ev[nv] = GetElementValueEvalProc(s); - if (ev[nv]==NULL) - { - PrintErrorMessageF('E',"tecplot","could not find eval proc %s\n",s); - break; - } - if (sscanf(argv[i+1],"s %s", s) == 1) - { - strcpy(ev_name[nv],s); - i++; - } - else - strcpy(ev_name[nv],ev[nv]->v.name); - nv++; - break; - - case 'z' : - sscanf(argv[i],"z %s", zonename+3); - memcpy(zonename, "T=\"", 3); - memcpy(zonename+strlen(zonename), "\", \0", 4); - break; - - case 'g' : - sscanf(argv[i],"g %d", &saveGeometry); - if (saveGeometry<0) saveGeometry=0; - if (saveGeometry>1) saveGeometry=1; - break; - } - } - if (nv==0) UserWrite("tecplot: no variables given, printing mesh data only\n"); - - /* get file name and open output file */ - if (sscanf(argv[0],expandfmt(CONCAT3(" tecplot %",NAMELENSTR,"[ -~]")),filename)!=1) - { - PrintErrorMessage('E',"tecplot","could not read name of logfile"); - return(PARAMERRORCODE); - } - pf = pfile_open(filename); - if (pf==NULL) return(PARAMERRORCODE); - - /********************************/ - /* TITLE */ - /********************************/ - - ic = 0; - sprintf(it,"TITLE = \"UG TECPLOT OUTPUT\"\n"); - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it,"VARIABLES = \"X\", \"Y\""); - strcpy(item+ic,it); ic+=strlen(it); - if (DIM==3) { - sprintf(it,", \"Z\""); - strcpy(item+ic,it); ic+=strlen(it); - } - for (i=0; i<nv; i++) { - sprintf(it,", \"%s\"",ev[i]->v.name); - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /********************************/ - /* compute sizes */ - /********************************/ - - /* clear VCFLAG on all levels */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) - SETVCFLAG(vc,0); - - /* run thru all levels of elements and set index */ - numNodes = numElements = 0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - numElements++; /* increase element counter */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vc = NVECTOR(CORNER(el,i)); - if (VCFLAG(vc)) continue; /* we have this one already */ - - VINDEX(vc) = ++numNodes; /* number of data points, begins with 1 ! */ - SETVCFLAG(vc,1); /* tag vector as visited */ - } - } - - #ifdef ModelP - gnumNodes = TPL_GlobalSumINT(numNodes); - gnumElements = TPL_GlobalSumINT(numElements); - on=get_offset(numNodes); - oe=get_offset(numElements); - - /* clear VCFLAG on all levels */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) - SETVCFLAG(vc,0); - - /* number in unique way */ - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vc = NVECTOR(CORNER(el,i)); - if (VCFLAG(vc)) continue; /* we have this one already */ - - VINDEX(vc) += on; /* add offset */ - SETVCFLAG(vc,1); /* tag vector as visited */ - } - } - #else - gnumNodes = numNodes; - gnumElements = numElements; - oe=on=0; - #endif - - - /********************************/ - /* write ZONE data */ - /* uses FEPOINT for data */ - /* uses QUADRILATERAL in 2D */ - /* and BRICK in 3D */ - /********************************/ - - /* write zone record header */ - if (DIM==2) sprintf(it,"ZONE %sN=%d, E=%d, F=FEPOINT, ET=QUADRILATERAL\n", zonename, gnumNodes,gnumElements); - if (DIM==3) sprintf(it,"ZONE %sN=%d, E=%d, F=FEPOINT, ET=BRICK\n", zonename, gnumNodes,gnumElements); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /* write data in FEPOINT format, i.e. all variables of a node per line*/ - - for (k=0; k<=TOPLEVEL(mg); k++) - for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) - SETVCFLAG(vc,0); /* clear all flags */ - - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); /* x,y,z of corners */ - - for (i=0; i<CORNERS_OF_ELEM(el); i++) - { - vc = NVECTOR(CORNER(el,i)); - if (VCFLAG(vc)) continue; /* we have this one alre ady */ - SETVCFLAG(vc,1); /* tag vector as visited */ - - sprintf(it,"%g",(double)XC(MYVERTEX(CORNER(el,i)))); - strcpy(item+ic,it); ic+=strlen(it); - sprintf(it," %g",(double)YC(MYVERTEX(CORNER(el,i)))); - strcpy(item+ic,it); ic+=strlen(it); - if (DIM == 3) - { - sprintf(it," %g",(double)ZC(MYVERTEX(CORNER(el,i)))); - strcpy(item+ic,it); ic+=strlen(it); - } - - /* now all the user variables */ - - /* get local coordinate of corner */ - LocalCornerCoordinates(DIM,TAG(el),i,local); - for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; - - for (v=0; v<nv; v++) - { - pre = ev[v]->PreprocessProc; - eval = ev[v]->EvalProc; - - /* execute prepare function */ - /* This is not really equivalent to - the FEBLOCK-version sinc we call "pre" more - often than there. D.Werner */ - - if (pre!=NULL) pre(ev_name[v],mg); - - /* call eval function */ - value = eval(el,(const DOUBLE **)CornersCoord,LocalCoord); - sprintf(it," %g",value); - strcpy(item+ic,it); ic+=strlen(it); - } - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_tagged_puts(pf,item,counter+on); ic=0; - counter++; - } - } - pfile_sync(pf); /* end of segment */ - - sprintf(it,"\n"); - strcpy(item+ic,it); ic+=strlen(it); - pfile_master_puts(pf,item); ic=0; - - /* finally write the connectivity list */ - counter=0; - for (k=0; k<=TOPLEVEL(mg); k++) - for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) - { - if (!EstimateHere(el)) continue; /* process finest level elements only */ - - switch(DIM) { - case 2 : - switch(TAG(el)) { - case TRIANGLE : - sprintf(it,"%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,2))) - ); - break; - case QUADRILATERAL : - sprintf(it,"%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,3))) - ); - break; - default : - UserWriteF("tecplot: unknown 2D element type with tag(el) = %d detected. Aborting further processing of command tecplot\n", TAG(el)); - return CMDERRORCODE; - break; - } - break; - case 3 : - switch(TAG(el)) { - case HEXAHEDRON : - sprintf(it,"%d %d %d %d " - "%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,4))), - VINDEX(NVECTOR(CORNER(el,5))), - VINDEX(NVECTOR(CORNER(el,6))), - VINDEX(NVECTOR(CORNER(el,7))) - ); - break; - case TETRAHEDRON : - sprintf(it,"%d %d %d %d " - "%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,3))) - ); - break; - case PYRAMID : - sprintf(it,"%d %d %d %d " - "%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,4))), - VINDEX(NVECTOR(CORNER(el,4))), - VINDEX(NVECTOR(CORNER(el,4))), - VINDEX(NVECTOR(CORNER(el,4))) - ); - break; - case PRISM : - sprintf(it,"%d %d %d %d " - "%d %d %d %d\n", - VINDEX(NVECTOR(CORNER(el,0))), - VINDEX(NVECTOR(CORNER(el,1))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,2))), - VINDEX(NVECTOR(CORNER(el,3))), - VINDEX(NVECTOR(CORNER(el,4))), - VINDEX(NVECTOR(CORNER(el,5))), - VINDEX(NVECTOR(CORNER(el,5))) - ); - break; - default : - UserWriteF("tecplot: unknown 3D element type with tag(el) = %d detected. Aborting further processing of command tecplot\n", TAG(el)); - return CMDERRORCODE; - break; - } - break; - } - strcpy(item+ic,it); ic+=strlen(it); - pfile_tagged_puts(pf,item,counter+oe); ic=0; - counter++; - - } - - pfile_sync(pf); /* end of segment */ - - /********************************/ - /* GEOMETRY */ - /* we will do this later, since */ - /* domain interface will change */ - /********************************/ - - pfile_close(pf); - - return(OKCODE); -} - - - -/****************************************************************************/ -/* */ -/* Function: InitTecplot */ -/* */ -/* Purpose: register all formats for porous media library */ -/* */ -/* Input: void */ -/* */ -/* Output: INT 0: ok */ -/* else line number where error occured */ -/* */ -/****************************************************************************/ - -INT NS_DIM_PREFIX InitTecplot () -{ - if (CreateCommand("tecplot",TecplotCommand)==NULL) return (__LINE__); - - return(0); -} diff --git a/ui/tecplot.h b/ui/tecplot.h deleted file mode 100644 index 30ce509cd8b958465d9ec8fa961621207c367125..0000000000000000000000000000000000000000 --- a/ui/tecplot.h +++ /dev/null @@ -1,49 +0,0 @@ -// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -// vi: set et ts=4 sw=2 sts=2: -/****************************************************************************/ -/* */ -/* File: tecplot.h */ -/* */ -/* Purpose: tecplot output header file */ -/* */ -/* Author: Peter Bastian */ -/* Institut fuer Computeranwendungen III */ -/* Universitaet Stuttgart */ -/* Pfaffenwaldring 27 */ -/* 70569 Stuttgart */ -/* email: ug@ica3.uni-stuttgart.de */ -/* */ -/* History: 29.06.95 begin, ug version 3.0 */ -/* */ -/* Remarks: */ -/* */ -/****************************************************************************/ - - - -/****************************************************************************/ -/* */ -/* auto include mechanism and other include files */ -/* */ -/****************************************************************************/ - -#ifndef __TECPLOT__ -#define __TECPLOT__ - -#include "ugtypes.h" -#include "namespace.h" - -START_UGDIM_NAMESPACE - -/****************************************************************************/ -/* */ -/* function declarations */ -/* */ -/****************************************************************************/ - -/* exports only the init function */ -INT InitTecplot (); - -END_UGDIM_NAMESPACE - -#endif