3
Compur. Cbem. Vol. II, No. 4, pp. 301L303, 1987 Printed in Great Britain. All rights reserved 0097-8485187 $3.00+ 0.00 Copyright 0 1987 Pergamon Journals Ltd NOTE FURTHER MODIFICATIONS TO PROGRAM SPACEFIL TO PRODUCE THREE-DIMENSIONAL COLOR MOLECULAR GRAPHICS MARVIN BISHOP, SHARON FRINKS and ANNMARIE M. MEIER Department of Mathematics/Computer Science, Manhattan College, Riverdale, NY 10471, U.S.A. (Received 2 December 1986) Abstract-Further modifications to program Spa&l are described which allow color graphics. Moreover, the device-independentapproach to computer graphics is illustrated with the NCAR graphics package. A recent note in this journal (Henry, 1983) has presented a modification of the Spacefil program (Smith & Gund, 1978) which includes prespective and shading. Henry’s program also allows the plot- ting of ORTEP-like ball and stick figures. We have further extended this program to do color graphics. Moreover, we have replaced the hardware specific graphics routines by device independent ones. The revised program uses the NCAR (National Center for Atmospheric Research) graphics package for its basic graphics operations such as drawing a line segment between two points. The NCAR pack- age is highly portable; detailed information on the package can be obtained from Sue Long, c/o NCAR/SCD, P.O. Box 3000, Boulder, CO 80307. The package consists of a collection of FORTRAN- callable subroutines. Calls to the subroutines cause specially formatted graphics instructions to be gener- ated and written to an external file. This file contains device-independent data (metacode) which is later processed by a translator program for viewing on a variety of graphics terminals and pen plotters. In this manner the program conforms to the modern style of device-independent graphics (Foley & VanDam, 1984). The graphics primatives which have been employed from the NCAR package are listed in Table 1. Table 2 lists the call statements in Henry’s program which have been replaced by the corresponding NCAR routines. In addition, CALL SET has been added to perform the coordinate scahng. Table 3 gives the FORTRAN code to set the colors. IAT(MATOM) is an array which stores the atomic numbers of the MATOMs. If MATOM is 0 then a bond is drawn in the current default color (initially black). This mod- ule selects the colors so that carbon atoms will be black, nitrogens will be blue and hydrogens will be orange. We have used the test data of Henry for 9-anilinoacridine which has four aromatic rings and two nitrogen atoms. Figure 1 presents a pair of stero images. Clearly color enhances our abilities to visual- ize molecular configurations. Table I. NCAR Routines SET-maps from user space to device spaoc FRSTF’T-moves to given point with the “pen up” (e.g. no line is drawn from current “pen” position) VECTOR-moves to given point with the “pen down” (e.g. a line is drawn from the current “pen” position) PWRITdraws a character string OFTN-used to set the color FRAME-closes down the plot, flushes the plot bulk and ad- vances to the next frame Table 2. Routines replaced in Henry’s program CALL INITT-not needed in NCAR CALL FINITTZALL FRAME CALL NEWPAG--CALL FRAME CALL BELL-not needed in NCAR CALL LINE-renamed to DRWLINE sina there is a NCAR routine with this name CALL ANMODE and CALL ANCHO-CALL PWRIT CALL MOVABMALL FRSTPT CALL DRWABMALL VECTOR Table 3. FORTRAN module to set color for different atoms SUBROUTINE DRAW(X,Y,MATOM) COMMON/ATOMICNWMIIAT~Z~O~ IF (MATOkf.E&) GO TO IO IF fJAT(MATOMj.EQ.6) CALL OFTN(SHCOL43R,SHBLACK) IF (IAT(MAT0M)E.Q. I) CALL OPTN(5HCDLORGB) IF (IAT(MATOM).EQ.7) CALL OPTN(5HCOLOR.4HBLUE) 10 CONTINUE CALL VECTOR(X,Y) RETURN END 301

Further modifications to program spacefil to produce three-dimensional color molecular graphics

Embed Size (px)

Citation preview

Page 1: Further modifications to program spacefil to produce three-dimensional color molecular graphics

Compur. Cbem. Vol. II, No. 4, pp. 301L303, 1987 Printed in Great Britain. All rights reserved

0097-8485187 $3.00 + 0.00 Copyright 0 1987 Pergamon Journals Ltd

NOTE

FURTHER MODIFICATIONS TO PROGRAM SPACEFIL TO PRODUCE THREE-DIMENSIONAL

COLOR MOLECULAR GRAPHICS

MARVIN BISHOP, SHARON FRINKS and ANNMARIE M. MEIER Department of Mathematics/Computer Science, Manhattan College, Riverdale, NY 10471, U.S.A.

(Received 2 December 1986)

Abstract-Further modifications to program Spa&l are described which allow color graphics. Moreover, the device-independent approach to computer graphics is illustrated with the NCAR graphics package.

A recent note in this journal (Henry, 1983) has presented a modification of the Spacefil program (Smith & Gund, 1978) which includes prespective and shading. Henry’s program also allows the plot- ting of ORTEP-like ball and stick figures. We have further extended this program to do color graphics. Moreover, we have replaced the hardware specific graphics routines by device independent ones.

The revised program uses the NCAR (National Center for Atmospheric Research) graphics package for its basic graphics operations such as drawing a line segment between two points. The NCAR pack- age is highly portable; detailed information on the package can be obtained from Sue Long, c/o NCAR/SCD, P.O. Box 3000, Boulder, CO 80307. The package consists of a collection of FORTRAN- callable subroutines. Calls to the subroutines cause specially formatted graphics instructions to be gener- ated and written to an external file. This file contains device-independent data (metacode) which is later processed by a translator program for viewing on a variety of graphics terminals and pen plotters. In this manner the program conforms to the modern style of device-independent graphics (Foley & VanDam, 1984).

The graphics primatives which have been employed from the NCAR package are listed in Table 1. Table 2 lists the call statements in Henry’s program which have been replaced by the corresponding NCAR routines. In addition, CALL SET has been added to perform the coordinate scahng. Table 3 gives the FORTRAN code to set the colors. IAT(MATOM) is an array which stores the atomic numbers of the MATOMs. If MATOM is 0 then a bond is drawn in

the current default color (initially black). This mod- ule selects the colors so that carbon atoms will be

black, nitrogens will be blue and hydrogens will be orange.

We have used the test data of Henry for 9-anilinoacridine which has four aromatic rings and two nitrogen atoms. Figure 1 presents a pair of stero images. Clearly color enhances our abilities to visual- ize molecular configurations.

Table I. NCAR Routines

SET-maps from user space to device spaoc FRSTF’T-moves to given point with the “pen up” (e.g. no line is drawn from current “pen” position) VECTOR-moves to given point with the “pen down” (e.g. a line is drawn from the current “pen” position) PWRITdraws a character string OFTN-used to set the color FRAME-closes down the plot, flushes the plot bulk and ad- vances to the next frame

Table 2. Routines replaced in Henry’s program

CALL INITT-not needed in NCAR CALL FINITTZALL FRAME CALL NEWPAG--CALL FRAME CALL BELL-not needed in NCAR CALL LINE-renamed to DRWLINE sina there is a NCAR routine with this name CALL ANMODE and CALL ANCHO-CALL PWRIT CALL MOVABMALL FRSTPT CALL DRWABMALL VECTOR

Table 3. FORTRAN module to set color for different atoms

SUBROUTINE DRAW(X,Y,MATOM) COMMON/ATOMICNWMIIAT~Z~O~ IF (MATOkf.E&) GO TO IO

IF fJAT(MATOMj.EQ.6) CALL OFTN(SHCOL43R,SHBLACK) IF (IAT(MAT0M)E.Q. I) CALL OPTN(5HCDLORGB) IF (IAT(MATOM).EQ.7) CALL OPTN(5HCOLOR.4HBLUE)

10 CONTINUE

CALL VECTOR(X,Y) RETURN END

301

Page 2: Further modifications to program spacefil to produce three-dimensional color molecular graphics

302 Note

Acknowledgemenrs-This research has been supported by REFERENCES the Donors of the Petroleum Research Fund, administered by the American Chemistry Society, and by the Manhattan Foley J. D. & VanDam A. (1984) Fundutnentals of Infer- College Computer Center. We wish to thank Professor active Computer Graphics. Addison-Wesley, Reading, Dominick Samperi for helpful discussions about the NCAR Mass. graphics package. Henry D. R. (1983) Compuf. &em. 7, 119.

Smith G. M. & Grund P. (1978) J. Chem. I$ Compur. Sri. 18, 207.

Page 3: Further modifications to program spacefil to produce three-dimensional color molecular graphics

Fig. I. Color, stereo view of 9-anilinoacridme.

303