%SCRIPT VCONT
%%
% VARIABLE REAL XMIN XMAX YMIN YMAX STEPX STEPY MINX MINY
% VARIABLE REAL ZSECT MINZ STEPZ RESOL BORDER WIDTH
% VARIABLE CHARACTER CFILE
% VARIABLE INTEGER  RUNVIEWER
%%
% COPY '#MOLAX'
% COPY 'ATOM '
% BLOCK
% LOOP
%   ON END TERMINATE
%   CLEAR
%   INSERT 'CONTINUE '
%   GET SILENT FINAL TEXT 'Plane defining atom labels (END to finish)'
%   SEND
% END LOOP
% END BLOCK
% COPY 'PLANE'
% COPY 'SAVE'
% COPY 'END'
%%
%%
^^WI WINDOW VCONT 'Void map' MODAL
^^WI COMMIT='BOK' CANCEL='BXX'
^^WI GRID GRIDM NROWS=3 NCOLS=1
^^WI {
^^WI  @ 1,1 GRID TOP NROWS=1 NCOLS=2
^^WI  {
^^WI   @ 1,2 GRID GRIDB NROWS=6 NCOLS=3
^^WI   {
^^WI     @ 2,2 BUTTON BOK '&Ok' DEFAULT
^^WI     @ 4,2 BUTTON BXX '&Cancel'
^^WI     @ 6,2 BUTTON BHELP    '&Help'
^^WI   }
^^WI   @ 1,1 GRID GSIZE NROWS=4 NCOLS=6
^^WI   {
^^WI      @ 2,2 STATIC T1 'Section width'
^^WI      @ 2,4 EDITBOX EW '9.0' CHARS=8 REAL
^^WI      @ 2,6 STATIC T2 'angstroms.'
^^WI      @ 3,2 STATIC T3 'Resolution'
^^WI      @ 3,4 EDITBOX ER '0.25' CHARS=8 REAL
^^WI      @ 3,6 STATIC T4 'angstroms.'
^^WI      @ 4,2 STATIC T5 'Compute an extra'
^^WI      @ 4,4 EDITBOX ES '2' CHARS=8 INTEGER
^^WI      @ 4,6 STATIC T5 'sections each side.'
^^WI   }
^^WI  }
^^WI  @ 2,1 GRID BOTTOM NROWS=2 NCOLS=3
^^WI  {
^^WI   @ 1,2 GRID GMAPS NROWS=1 NCOLS=4 OUTLINE='Save map as'
^^WI   {
^^WI    @ 1,2 EDITBOX E1 'void.fou' CHARS=50 INFORM=NO
^^WI    @ 1,4 BUTTON BROWSE '&Choose'
^^WI   }
^^WI  }
^^WI  @ 3,1 GRID VBOTTOM NROWS=2 NCOLS=7
^^WI  {
% IF FILEEXISTS 'c:\progra~1\marchi~1\MarchingCubeELD.exe' -
   .OR. FILEEXISTS 'crysdir:MarchingCubeELD.exe' - 
   .OR. FILEEXISTS 'crysdir:MCE\MCE.exe' THEN
%%+GIL% IF FILEEXISTS 'CRYSDIR:MarchingCubeELD.exe' -
%%+GIL  .EQ. TRUE THEN
^^WI   @ 1,2 RADIOBUTTON XC 'Run CONTOUR'
^^WI   @ 1,4 RADIOBUTTON XM 'Run 3D ELD Viewer' STATE=ON
% ELSE
^^WI   @ 1,2 RADIOBUTTON XC 'Run CONTOUR' STATE=ON
% END IF
^^WI   @ 1,6 RADIOBUTTON XN 'Do not run viewer'
^^WI  }
^^WI }
^^WI SHOW
^^CR
% LOOP
%   VERIFY BXX BROWSE BHELP BOK
%   GET NOSTORE SILENT FINAL ABBREVIATED ' ' ' '
%   CASE VALUE
%     BLOCK                       % BXX
^^WI    DISPOSE VCONT
^^CR
%       FINISH
%     END BLOCK
%     BLOCK                       % BROWSE
%       ON ERROR REPEAT
%       CLEAR
^^WI    SYSSAVEFILE 'Slant.fou' '*.fou' 'Fourier map ascii file (*.fou)'
^^CR
%       GET SILENT FINAL FILENAME 'Filename for map' 'Slant.fou'
%       IF CVALUE .NE. 'CANCEL' THEN
%         TRANSFER "^^CO SET E1 TEXT " // CVALUE TO DISPLAY
%       END IF
%     END BLOCK
%     BLOCK                       % BHELP
%       COPY '#SCRIPT XHELP1'
Define a plane for a voids map.
Set the width of the section.
Set the number of additional sections above and below the plane.
Press OK.
 
A voids map is like a contour map. The distance to the nearest VDW
surface is represented by at each point in the figure field. Points
inside the VDW surface of an atom have negative values.
 
Choose appropriate levels of contouring to get an idea of the shape
of any voids in your structure.
%       COPY '#SCRIPT XHELP2'
%     END BLOCK
%     BLOCK                       % BOK
^^??    EW TEXT
%       GET NOSTORE SILENT REAL ' ' '8.5'
%       EVALUATE WIDTH = VALUE / 2.0
^^??    ER TEXT
%       GET NOSTORE SILENT REAL ' ' '0.25'
%       EVALUATE RESOL = VALUE
^^??    ES TEXT
%       GET NOSTORE SILENT REAL ' ' '2'
%       EVALUATE ZSECT = VALUE
^^??    E1 TEXT
%       GET NOSTORE SILENT TEXT ' ' 'void.fou'
%       EVALUATE CFILE = CVALUE
%       TRANSFER "#STORE CSYS MAP '" // CFILE // "'" TO CRYSTALS
^^??    XC STATE
%       VERIFY ON OFF
%       GET SILENT NOSTORE FINAL ABBREVIATED ' '
%       IF VALUE .EQ. 1 THEN
%          EVALUATE RUNVIEWER = 1
%       ELSE
%%
%% Sorry about the logic here. We can't check XM because it might
%% not exist.
%%
^^??       XN STATE
%          VERIFY OFF ON
%          GET SILENT NOSTORE FINAL ABBREVIATED ' '
%          IF VALUE .EQ. 1 THEN
%             EVALUATE RUNVIEWER = 2
%          ELSE
%             EVALUATE RUNVIEWER = 0
%          END IF
%       END IF
^^WI    DISPOSE VCONT
^^CR
%       BLOCK
%         EVALUATE XMIN = 0.0 - WIDTH
%         EVALUATE XMAX = WIDTH
%         EVALUATE YMIN = 0.0 - WIDTH
%         EVALUATE YMAX = WIDTH
%         EVALUATE BORDER = 0.25
%         EVALUATE MINX = ( XMIN - BORDER )
%         EVALUATE MINY = ( YMIN - BORDER )
%         EVALUATE STEPX = ( ( XMAX + BORDER ) - MINX ) / RESOL
%         EVALUATE STEPY = ( ( YMAX + BORDER ) - MINY ) / RESOL
%         EVALUATE STEPX = 1. + STEPX
%         EVALUATE STEPY = 1. + STEPY
%         BLOCK
%           QUEUE REWIND
%           CLEAR
%           INSERT 'MAP FILE=YES'
%           QUEUE SEND
%           CLEAR
%           STORE CHARACTER 'SAVE MOLAX'
%           QUEUE SEND
%           CLEAR
%           INSERT 'DOWN '
%           STORE FORMAT /(F7.1)/ LENGTH 7 REAL MINX
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL STEPX
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL RESOL
%           QUEUE SEND
%           CLEAR
%           INSERT 'ACROSS '
%           STORE FORMAT /(F7.1)/ LENGTH 7 REAL MINY
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL STEPY
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL RESOL
%           QUEUE SEND
%           CLEAR
%           INSERT 'SECTION '
%           EVALUATE MINZ = - 1.0 * RESOL * ZSECT
%           EVALUATE STEPZ = 1.0 + 2.0 * ZSECT
%           STORE FORMAT /(F7.1)/ LENGTH 7 REAL MINZ
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL STEPZ
%           STORE FORMAT /(F7.2)/ LENGTH 7 REAL RESOL
%           QUEUE SEND
%         END BLOCK
%         COPY '#VSLANT'
%            QUEUE PROCESS
%         COPY 'END'
 
 * Done. Slant void map complete.
 
^^CO SET PROGOUTPUT TEXT='Slant Fourier complete.'
%         CASE RUNVIEWER + 1
%           BLOCK    % Don't run
%             TRANSFER 'Map file saved as: ' // CFILE TO DISPLAY
%           END BLOCK
%           BLOCK    %Run contour
%             TRANSFER '#SPAWN "CRYSDIR:contour.exe" ' // CFILE TO CRYSTALS
%           END BLOCK
%           BLOCK    %Run marchingcubesELD viewer
* Starting Michal Husak's 3D ELD viewer. Wait while it loads ....
% IF FILEEXISTS 'crysdir:MCE\MCE.exe' THEN
%   TRANSFER '#SPAWN "CRYSDIR:MCE\MCE.exe" ' // CFILE TO CRYSTALS
% ELSE IF FILEEXISTS 'c:\progra~1\marchi~1\MarchingCubeELD.exe' THEN
%   TRANSFER '#SPAWN "C:\PROGRA~1\MARCHI~1\MarchingCubeELD.exe" ' -
      // CFILE TO CRYSTALS
% ELSE
%   TRANSFER '#SPAWN "CRYSDIR:MarchingCubeELD.exe" ' -
     // CFILE TO CRYSTALS
% END IF
%%+GIL%  TRANSFER '#SPAWN "CRYSDIR:MarchingCubeELD.exe" ' -
   // CFILE TO CRYSTALS
%           END BLOCK
%         END CASE
%         FINISH
%       END BLOCK
%     END BLOCK
%   END CASE
% END LOOP
%END SCRIPT
