[go: up one dir, main page]

Menu

[r19]: / src / rasmol / rasmol.c  Maximize  Restore  History

Download this file

322 lines (273 with data), 10.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/***************************************************************************
* RasMol 2.7.2.1.1 *
* *
* RasMol *
* Molecular Graphics Visualisation Tool *
* 26 January 2004 *
* *
* 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 *
*Author Version, Date Copyright *
*Arne Mueller RasMol 2.6x1 May 98 (C) Arne Mueller 1998 *
*Gary Grossman and RasMol 2.5-ucb Nov 95 (C) UC Regents/ModularCHEM *
*Marco Molinaro RasMol 2.6-ucb Nov 96 Consortium 1995, 1996 *
* *
*Philippe Valadon RasTop 1.3 Aug 00 (C) Philippe Valadon 2000 *
* *
*Herbert J. RasMol 2.7.0 Mar 99 (C) Herbert J. Bernstein *
*Bernstein RasMol 2.7.1 Jun 99 1998-2001 *
* RasMol 2.7.1.1 Jan 01 *
* RasMol 2.7.2 Aug 00 *
* RasMol 2.7.2.1 Apr 01 *
* RasMol 2.7.2.1.1 Jan 04 *
* *
* and Incorporating Translations by *
* Author Item Language*
* Isabel Serván Martínez, *
* José Miguel Fernández Fernández 2.6 Manual Spanish *
* José Miguel Fernández Fernández 2.7.1 Manual Spanish *
* Fernando Gabriel Ranea 2.7.1 menus and messages Spanish *
* Jean-Pierre Demailly 2.7.1 menus and messages French *
* Giuseppe Martini, Giovanni Paolella, 2.7.1 menus and messages *
* A. Davassi, M. Masullo, C. Liotto 2.7.1 help file Italian *
* *
* This Release by *
* Herbert J. Bernstein, Bernstein + Sons, P.O. Box 177, Bellport, NY, USA *
* yaya@bernstein-plus-sons.com *
* Copyright(C) Herbert J. Bernstein 1998-2001 *
* *
* 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. *
***************************************************************************/
/* rasmol.c
*/
#include "rasmol.h"
#ifdef IBMPC
#include <windows.h>
#include <shellapi.h>
#include <malloc.h>
#endif
#ifdef APPLEMAC
#include <Types.h>
#include <Errors.h>
#ifdef __CONDITIONALMACROS__
#include <Printing.h>
#else
#include <PrintTraps.h>
#endif
#endif
#ifndef sun386
#include <stdlib.h>
#endif
#include <string.h>
#if defined(IBMPC) || defined(VMS) || defined(APPLEMAC)
#include "string_case.h"
#else
#include <strings.h>
#endif
#include <ctype.h>
#include <stdio.h>
#if !defined(IBMPC) && !defined(VMS) && !defined(APPLEMAC)
#include <pwd.h>
#endif
#define RASMOL
#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"
#include "multiple.h"
#include "vector.h"
#include "brotate.h"
#include "prefer.h"
#include "langsel.h"
#include "help.h"
static void GetRasMolPath( void )
{
register int i,d;
#ifdef MSWIN
LPTSTR* name = NULL;
#endif
*RasMolPath = '\0';
#ifdef MSWIN
SearchPath(NULL,"RasTop.exe","exe",1023,RasMolPath,name);
#endif
i = d = 0;
while( RasMolPath[i] )
if( RasMolPath[i++]==DirChar )
d = i;
RasMolPath[d] = '\0';
}
static void WriteCredits( void )
{
register FILE *fp;
char * dst;
char creditsdir[1024];
char buffer[82];
if( *RasMolPath )
{ dst = strcpy(creditsdir,RasMolPath);
while( *dst++ ) {};
dst--;
dst = strcpy(dst,"credits.txt");
fp=fopen(creditsdir,"rb");
if( !fp )
return;
while( xfgets(buffer,80,fp) )
WriteString(buffer);
fclose(fp);
}
}
int InitialiseRasmol( void )
{ static char VersionStr[255];
Interactive = TRUE;
CalcBondsFlag = TRUE;
ReDrawFlag = RFInitial;
CommandActive = FALSE;
AllowWrite = FALSE;
FileDepth = -1;
SeqFormat = TRUE;
if( !OpenDisplay(NULL,0) )
return(FALSE);
/* Full GUI */
WindowMain = TRUE;
WindowSelection = TRUE;
WindowScripting = TRUE;
WindowCommandPanel = TRUE;
WindowCommandLine = TRUE;
WindowColour = TRUE;
WindowStatus = TRUE;
/* WindowMaximized
* = 1 when maximized
* = -1 when minimized (restore default)
* = 0 otherwise (restore old values)
*/
WindowMaximized = -1;
WindowLeft = 100;
WindowTop = 100;
WindowWidth = 500;
WindowHeight = 500;
CommandLeft = 150;
CommandTop = 250;
CommandWidth = 500;
CommandHeight = 250;
ColourLeft = 550;
ColourTop = 150;
GetRasMolPath();
WriteCredits();
InitialiseCmndLine();
InitialiseCommand();
InitialiseTransform();
InitialiseDatabase();
InitialiseRenderer();
InitialisePixUtils();
InitialiseAbstree();
InitialiseOutFile();
InitialiseRepres();
InitialiseMultiple();
InitialiseBRotate();
InitialiseLangSel();
InitialisePrefs();
InitializeHelp();
ReadPrefs();
ShowMain(WindowMain);
ShowSelection(WindowSelection);
ShowScripting(WindowScripting);
ShowCommandPanel(WindowCommandPanel);
ShowCommandLine(WindowCommandLine);
ShowColour(WindowColour);
ShowStatus(WindowStatus);
/* Transfered to initinstance for smooth opening
ShowRasMol(); */
// Make sure to reset
PrefsModified = FALSE;
WriteString("\n");
ResetCommandLine(2);
return( TRUE );
}
void ExitRasmol( void )
{
WritePrefs();
#ifdef EIGHTBIT
if(Palette) free(Palette);
#endif
if(BitInfo) free(BitInfo);
if(CurMolecule) free(CurMolecule);
if(CurChain) free(CurChain);
if(CurGroup) free(CurGroup);
if(CurAtom) free(CurAtom);
if(Array) free(Array);
if(LookUp) free(LookUp);
if(HashTable) free(HashTable);
if(ColConst) free(ColConst);
UpdatePixutils();
UpdateRender(1);
UpdateOutfile();
PurgeDatabase();
ExitLangSel();
}
void RefreshScreen()
{
/* Force Drawing */
if( IsPaused )
RefreshState = True;
if( ReDrawFlag )
{
if( ReDrawFlag & RFReSize )
{ ReSizeScreen();
PrepareWorldZoom(0);
}
if( ReDrawFlag & RFColour )
{ ClearImage();
DefineColourMap();
}
if( Database )
{ DrawWorld();
if( RefreshState )
TransferImage();
} else if( RefreshState )
{ ClearBuffers();
TransferImage();
}
if( !FileModified && (ReDrawFlag & RFSave) )
{ /*Not modified if RFInitial&~RFSize*/
if( !((ReDrawFlag & 0xFF)==0xFF) )
FileModified = True;
}
FastDraw = False;
ReDrawFlag = 0;
}
}