/*************************************************************************** * RasMol 2.7.1 * * * * RasMol * * Molecular Graphics Visualisation Tool * * 22 June 1999 * * * * Based on RasMol 2.6 by Roger Sayle * * Biomolecular Structures Group, Glaxo Wellcome Research & Development, * * Stevenage, Hertfordshire, UK * * Version 2.6, August 1995, Version 2.6.4, December 1998 * * Copyright (C) Roger Sayle 1992-1999 * * * * and Based on Mods by Arne Mueller * * Version 2.6x1, May 1998 * * Copyright (C) Arne Mueller 1998 * * * * Version 2.7.0, 2.7.1 Mods by Herbert J. Bernstein * * Bernstein + Sons, P.O. Box 177, Bellport, NY, USA * * yaya@bernstein-plus-sons.com * * 2.7.0 March 1999, 2.7.1 June 1999 * * Copyright (C) Herbert J. Bernstein 1998-1999 * * * * Please read the file NOTICE for important notices which apply to this * * package. If you are not going to make changes to RasMol, you are not * * only permitted to freely make copies and distribute them, you are * * encouraged to do so, provided you do the following: * * * 1. Either include the complete documentation, especially the file * * NOTICE, with what you distribute or provide a clear indication * * where people can get a copy of the documentation; and * * * 2. Please give credit where credit is due citing the version and * * original authors properly; and * * * 3. Please do not give anyone the impression that the original * * authors are providing a warranty of any kind. * * * * If you would like to use major pieces of RasMol in some other program, * * make modifications to RasMol, or in some other way make what a lawyer * * would call a "derived work", you are not only permitted to do so, you * * are encouraged to do so. In addition to the things we discussed above, * * please do the following: * * * 4. Please explain in your documentation how what you did differs * * from this version of RasMol; and * * * 5. Please make your modified source code available. * * * * This version of RasMol is not in the public domain, but it is given * * freely to the community in the hopes of advancing science. If you make * * changes, please make them in a responsible manner, and please offer us * * the opportunity to include those changes in future versions of RasMol. * ***************************************************************************/ /* rastxt.c */ #ifndef sun386 #include #endif #include #include #include #include #include #define RASMOL #define GRAPHICS #include "rasmol.h" #include "graphics.h" #include "molecule.h" #include "infile.h" #include "abstree.h" #include "transfor.h" #include "cmndline.h" #include "command.h" #include "render.h" #include "repres.h" #include "pixutils.h" #include "outfile.h" #ifdef IBMPC #include #endif #ifdef UNIX #include #endif #ifdef TERMIOS #include #include #include #ifdef esv #include #else #include #endif #endif /* TERMIOS */ #define TwoPi 6.28318531 #define IsIdentChar(x) ((isalnum(x))||((x)=='_')||((x)=='$')) /* Either stdout or stderr */ #define OutFp stdout #ifdef TERMIOS static struct termios OrigTerm; static struct termios IntrTerm; #endif static int InitialWide; static int InitialHigh; static char *FileNamePtr; static char *ScriptNamePtr; static int FileFormat; static int ProfCount; void WriteChar( int ch ) { putc(ch,OutFp); } void WriteString( char *ptr ) { fputs(ptr,OutFp); } static int InitTerminal( void ) { #ifdef TERMIOS register int fd; #endif setbuf(stdin,(char*)NULL); #ifdef SIGTTIN signal(SIGTTIN,SIG_IGN); #endif #ifdef SIGTTOU signal(SIGTTOU,SIG_IGN); #endif #ifdef TERMIOS fd = fileno(stdin); if( !isatty(fd) ) return False; if( tcgetattr(fd,&OrigTerm) < 0 ) return False; IntrTerm = OrigTerm; IntrTerm.c_iflag |= IGNBRK|IGNPAR; IntrTerm.c_iflag &= ~(BRKINT|PARMRK|INPCK|IXON|IXOFF); IntrTerm.c_lflag &= ~(ICANON|ISIG|ECHO|ECHOE|ECHOK|ECHONL|NOFLSH); /* IntrTerm.c_lflag |= ISIG; */ IntrTerm.c_cc[VMIN] = 1; IntrTerm.c_cc[VTIME] = 0; #ifdef VSUSP /* Disable ^Z */ IntrTerm.c_cc[VSUSP] = 0; #endif tcsetattr(fd,TCSANOW,&IntrTerm); #endif /* TERMIOS */ return True; } static void ResetTerminal( void ) { #ifdef TERMIOS register int fd; fd = fileno(stdin); if( isatty(fd) ) tcsetattr(fd,TCSANOW,&OrigTerm); #endif } void RasMolExit( void ) { WriteChar('\n'); if( CommandActive ) WriteChar('\n'); ResetTerminal(); exit(0); } void RasMolFatalExit( char *msg ) { WriteChar('\n'); WriteString(msg); WriteChar('\n'); WriteChar(0x07); ResetTerminal(); exit(1); } void RasMolSignalExit( int i ) { UnusedArgument(i); RasMolFatalExit("*** Quit ***"); } static int FetchCharacter( void ) { #ifdef IBMPC return _getch(); #else return getc(stdin); #endif } static int ReadCharacter( void ) { register int ch; ch = FetchCharacter(); #ifdef IBMPC if( ch && (ch!=0xe0) ) return ch; ch = FetchCharacter(); switch( ch ) { case('H'): return( 0x10 ); /* Up */ case('P'): return( 0x0e ); /* Down */ case('K'): return( 0x02 ); /* Left */ case('M'): return( 0x06 ); /* Right */ } #else if( ch != 0x1b ) return ch; ch = FetchCharacter(); if( (ch!='[') && (ch!='O') ) return ch; ch = FetchCharacter(); switch( ch ) { case('A'): return( 0x10 ); /* Up */ case('B'): return( 0x0e ); /* Down */ case('C'): return( 0x06 ); /* Right */ case('D'): return( 0x02 ); /* Left */ } #endif return 0; } static void LoadInitFile( void ) { register char *src,*dst; register FILE *initrc; register char *fname; char fnamebuf[128]; fname = "RASMOL.INI"; initrc = fopen(fname,"rb"); if( !initrc && (src=(char*)getenv("HOME")) ) { dst = fnamebuf; while( *src ) *dst++ = *src++; *dst++ = '\\'; src = fname; fname = fnamebuf; while( (*dst++ = *src++) ); initrc = fopen(fname,"rb"); } if( !initrc && (src=(char*)getenv("RASMOLPATH")) ) { dst = fnamebuf; while( *src ) *dst++ = *src++; *dst++ = '\\'; src = "rasmolrc"; fname = fnamebuf; while( (*dst++ = *src++) ); initrc = fopen(fname,"rb"); } if( initrc ) LoadScriptFile(initrc,fname); } int CreateImage( void ) { register Long size; if( FBuffer ) _ffree(FBuffer); size = (Long)XRange*YRange*sizeof(Pixel); FBuffer = (Pixel*)_fmalloc( size+32 ); return( (int)FBuffer ); } void TransferImage( void ) { } int ClipboardImage( void ) { return False; } void ClearImage( void ) { } int PrintImage( void ) { return False; } void AllocateColourMap( void ) { } void UpdateScrollBars( void ) { } int LookUpColour( char *name, int *r, int *g, int *b ) { UnusedArgument(name); UnusedArgument(r); UnusedArgument(g); UnusedArgument(b); return False; } void SetMouseUpdateStatus( int bool ) { MouseUpdateStatus = bool; } void SetMouseCaptureStatus( int bool ) { MouseCaptureStatus = bool; } void SetCanvasTitle( char *ptr ) { UnusedArgument(ptr); } void EnableMenus( int flag ) { UnusedArgument(flag); } void CloseDisplay( void ) { } void BeginWait( void ) { } void EndWait( void ) { } int OpenDisplay( int x, int y ) { register int i; for( i=0; i<8; i++ ) DialValue[i] = 0.0; XRange = x; WRange = XRange>>1; YRange = y; HRange = YRange>>1; Range = MinFun(XRange,YRange); /* Initialise Palette! */ for( i=0; i<256; i++ ) ULut[i] = False; AllocateColourMap(); return False; } void AdviseUpdate( int item ) { UnusedArgument(item); } void RefreshScreen( void ) { if( !UseSlabPlane ) { ReDrawFlag &= ~RFTransZ|RFSlab; } else ReDrawFlag &= ~RFTransZ; if( ReDrawFlag ) { if( ReDrawFlag & RFReSize ) ReSizeScreen(); if( ReDrawFlag & RFColour ) DefineColourMap(); if( Database ) { if( ReDrawFlag & RFApply ) ApplyTransform(); DrawFrame(); } ReDrawFlag = 0; } } static void ProfileExecution( void ) { register long start,stop; register Real delta; register int i; delta = TwoPi/ProfCount; printf("Profiling Execution!\n"); start = time((time_t *)NULL); for( i=0; i