|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/cn3d/cn3dmain.c |
source navigation diff markup identifier search freetext search file search |
1 /* cn3dmain.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: cn3dmain.c
27 *
28 * Author: Christopher Hogue
29 *
30 * Version Creation Date: 1/31/96
31 *
32 * File Description: Main entry point for Cn3d
33 *
34 * Modifications:
35 * --------------------------------------------------------------------------
36 * $Log: cn3dmain.c,v $
37 * Revision 6.57 2000/06/12 23:02:41 hurwitz
38 * enable launch of DDE from Cn3D, swith from DDV_ComputeRuler to DDE_ReMakeRuler, get rid of styles option for DDE
39 *
40 * Revision 6.56 2000/06/08 21:00:59 lewisg
41 * force dde into nogap mode
42 *
43 * Revision 6.55 2000/03/20 18:18:33 thiessen
44 * fixed header problem causing network unavailability
45 *
46 * Revision 6.54 2000/03/15 19:32:20 lewisg
47 * launch only single udv window
48 *
49 * Revision 6.53 2000/03/08 21:46:14 lewisg
50 * cn3d saves viewport, misc bugs
51 *
52 * Revision 6.52 2000/02/17 15:41:11 thiessen
53 * added CSC algorithm selection submenu
54 *
55 * Revision 6.51 2000/01/11 01:16:46 lewisg
56 * fix color selection in Cn3D, other misc. bugs
57 *
58 * Revision 6.50 2000/01/08 00:47:53 lewisg
59 * fixes to selection, update, color
60 *
61 * Revision 6.49 2000/01/04 15:55:50 lewisg
62 * don't hang on disconnected network and fix memory leak/hang at exit
63 *
64 * Revision 6.48 1999/11/22 14:46:41 thiessen
65 * moved _OPENGL code blocks to only vibrant and ncbicn3d libraries
66 *
67 * Revision 6.46 1999/11/10 23:19:40 lewisg
68 * rewrite of selection code for ddv
69 *
70 * Revision 6.45 1999/11/03 16:24:20 lewisg
71 * get rid of non-existing includes
72 *
73 * Revision 6.44 1999/10/29 14:15:27 thiessen
74 * ran all Cn3D source through GNU Indent to prettify
75 *
76 * Revision 6.43 1999/10/05 23:18:19 lewisg
77 * add ddv and udv to cn3d with memory management
78 *
79 * Revision 6.42 1999/09/21 18:09:16 lewisg
80 * binary search added to color manager, various bug fixes, etc.
81 *
82 * Revision 6.41 1999/09/21 13:59:22 thiessen
83 * port of Lewis's OpenGL code to X/Motif
84 *
85 * Revision 6.40 1999/09/16 17:16:20 ywang
86 * open multiple salsa window for data with multiple seq-annot data
87 *
88 * Revision 6.39 1999/08/04 21:18:01 lewisg
89 * modularized open operations to allow sequin to launch cn3d
90 *
91 * Revision 6.38 1999/07/02 22:11:24 ywang
92 * call EntrezInit besides EntrezBioseqFetchEnable
93 *
94 * Revision 6.37 1999/06/15 19:08:17 kans
95 * instantiate Cn3D_useEntrez in library
96 *
97 * Revision 6.36 1999/06/15 17:57:53 ywang
98 * rename useEntrez as Cn3D_useEntrez
99 *
100 * Revision 6.35 1999/06/14 17:38:43 ywang
101 * remove 'static' on Cn3D_useEntrez
102 *
103 * Revision 6.34 1999/05/10 21:50:30 chappey
104 * bug in SeqEdDownload
105 *
106 * Revision 6.32 1999/04/27 20:47:37 lewisg
107 * add cn3d gif batch mode to cn3d
108 *
109 * Revision 6.31 1999/02/10 23:49:42 lewisg
110 * use RGB values instead of indexed palette
111 *
112 * Revision 6.30 1999/01/20 18:21:19 ywang
113 * include salmedia.h due to the move around of MediaInfo from cn3dmsg.h to the new created salmedia.h
114 *
115 * Revision 6.29 1999/01/14 19:07:16 kans
116 * network availability is configurable
117 *
118 * Revision 6.28 1998/12/08 16:53:09 kans
119 * new params to ShowNetConfigForm to simplify configuration
120 *
121 * Revision 6.27 1998/08/03 18:33:12 lewisg
122 * added netentcf to cn3d
123 *
124 * Revision 6.26 1998/06/17 22:41:26 kans
125 * now uses UseLocalAsnloadDataAndErrMsg from sqnutils.h
126 *
127 * Revision 6.25 1998/06/15 14:26:06 ywang
128 * automatic launch salsa when mime data got in either through command line or via local reading in
129 *
130 * Revision 6.24 1998/06/11 20:07:38 chappey
131 * Added SetAppProperty ("SeqEditDisplayForm") to pass flags to sequence editor
132 *
133 * Revision 6.23 1998/06/05 21:14:22 ywang
134 * A solution for ensure getting bsp
135 *
136 * Revision 6.22 1998/06/04 16:48:34 ywang
137 * fix bug triggered by automatic salsa launch
138 *
139 * Revision 6.20 1998/05/06 23:50:21 lewisg
140 * fixed launching problem with sequin
141 *
142 * Revision 6.19 1998/04/28 19:39:58 lewisg
143 * codewarrior fixes
144 *
145 * Revision 6.18 1998/04/28 19:38:35 lewisg
146 * codewarrior fixes
147 *
148 * Revision 6.17 1998/04/28 18:54:01 ywang
149 * slight modification
150 *
151 * Revision 6.15 1998/04/28 15:14:25 lewisg
152 * moved OpenMimeFileWithDeletion to cn3dopen
153 *
154 * Revision 6.14 1998/04/27 23:23:02 lewisg
155 * added ability to open mime files
156 *
157 * Revision 6.13 1998/04/21 23:00:56 lewisg
158 * added show aligned/unaligned
159 *
160 * Revision 6.12 1998/04/15 00:51:36 lewisg
161 * bug fixes for multiple alignment mode and alignment pane
162 *
163 * Revision 6.11 1998/04/04 18:07:45 lewisg
164 * get rid of typo
165 *
166 * Revision 6.10 1998/04/04 05:57:52 lewisg
167 * got rid of dos line breaks
168 *
169 * Revision 6.9 1998/04/04 00:53:45 lewisg
170 * added support for multiple alignments
171 *
172 * Revision 6.8 1998/04/01 23:26:16 lewisg
173 * added new startup mode + fixed slave rendering
174 *
175 * Revision 6.7 1998/03/26 22:42:10 lewisg
176 * added seqentry and seq annot to msd
177 *
178 * Revision 6.6 1998/03/13 22:30:34 lewisg
179 * fix neighbor mode
180 *
181 * Revision 6.5 1998/03/07 20:43:51 kans
182 * moved Cn3D_fEntrezOn to cn3dwin.c
183 *
184 * Revision 6.4 1998/03/06 23:19:14 lewisg
185 * codewarrior fixes
186 *
187 * Revision 6.3 1998/03/06 01:19:32 lewisg
188 * merge
189 *
190 * Revision 6.2 1997/10/09 13:01:54 epstein
191 * add return values for OpenMimeFile
192 *
193 * Revision 6.1 1997/09/30 20:09:21 epstein
194 * ADD ABILITY TO PERFORM cN3d demos driven from configuration files
195 *
196 * Revision 6.0 1997/08/25 18:13:31 madden
197 * Revision changed to 6.0
198 *
199 * Revision 5.20 1997/07/16 20:55:48 vakatov
200 * Use "Nlm_GetArg[vc]()" instead of "arg[vc]"
201 *
202 * Revision 5.19 1997/03/20 19:04:08 vakatov
203 * Now contains only standalone-specific code; the generic Cn3D code has
204 * been moved to "cn3dwin.c", and the Entrez-specific code -- to "cn3dentr.c".
205 *
206 *
207 * ==========================================================================
208 */
209
210 #include <ncbi.h>
211 #include <vibrant.h> /* for netentcf */
212 #include <netcnfg.h>
213 #include <cn3dmain.h>
214 #include <objmime.h>
215 #include <accentr.h>
216 #include <accutils.h>
217 #include <objalign.h>
218 #include <objseq.h>
219 #include <objmgr.h>
220 #include <sequtil.h>
221 #include <saledit.h>
222 #include <lsqfetch.h>
223 #include <cn3dopen.h>
224 #include <salmedia.h>
225 #include <sqnutils.h>
226 #include <ddvmain.h>
227
228 /* note - this module shouldn't include any headers that have #ifdef _OPENGL blocks! */
229
230 extern void Cn3D_SaveActiveCam(void);
231 extern Nlm_Boolean Nlm_Call_SetPosition3D(Nlm_RecT *);
232 extern Nlm_Boolean Nlm_Call_SaveImageGIF(CharPtr);
233
234 static Boolean LIBCALLBACK OpenMimeFile(CharPtr filename)
235 {
236 /*#ifdef OS_MAC
237 /* the Web browsers on other platforms get upset if you delete the file, */
238 /* but apparently on the Mac you must delete it */
239 /*return OpenMimeFileWithDeletion(filename, TRUE);
240 #else */
241 return OpenMimeFileWithDeletion(filename, FALSE);
242 /*#endif */
243 }
244
245 /******* SEQUENCE EDITOR *********/
246 static SeqEditViewProcs seqedprocs;
247 /******** END ************/
248
249 static void ConfigAccepted(void)
250 {
251 SetAppParam("CN3D", "SETTINGS", "NETWORKAVAILABLE", "TRUE");
252 Message(MSG_OK, "Setting will take affect when you restart Cn3D");
253 }
254
255 static void ConfigCancelled(void)
256 {
257 }
258
259 static void ConfigTurnedOff(void)
260 {
261 SetAppParam("CN3D", "SETTINGS", "NETWORKAVAILABLE", "FALSE");
262 Message(MSG_OK, "Setting will take affect when you restart Cn3D");
263 }
264
265 static void NetConfigureProc(IteM i)
266 {
267 Boolean netCurrentlyOn = FALSE;
268
269 if (Cn3D_UsingEntrez())
270 ShowNetConfigForm(NULL, NULL, ConfigAccepted, ConfigCancelled, ConfigTurnedOff, TRUE);
271 else
272 ShowNetConfigForm(NULL, NULL, ConfigAccepted, ConfigCancelled, ConfigTurnedOff, FALSE);
273 }
274
275
276 static void Cn3D_PrintImage(Char * str)
277 /* this is only used in batch mode to create a gifs of the structure */
278 {
279 BiostrucPtr pbsBiostruc = NULL;
280 PDNMS pdnmsModelstruc = NULL;
281 PMSD pmsdThis = NULL;
282 Int4 MdlNo, MdlLvl;
283 PDNML pdnmlThis = NULL;
284 PDNML pdnmlFirst = NULL;
285 PMLD pmldThis = NULL;
286 PMLD pmldOne = NULL;
287 PMLD pmldAll = NULL;
288 PMLD pmldVec = NULL;
289
290 SetNeighborOff(); /* we don't load in neighbors thru this route */
291 Cn3D_SaveActiveCam();
292 ClearStructures();
293
294 MdlLvl = ALLSIMPLEMDL;
295 MdlNo = 1;
296
297 pbsBiostruc = FetchBS(str, INP_GI, MdlLvl, MdlNo, GetMMDBAPIbExtent());
298 if (pbsBiostruc != NULL) {
299 pdnmsModelstruc = MakeAModelstruc(pbsBiostruc);
300 }
301 if (pdnmsModelstruc == NULL) {
302 /* return a not found error here */
303 return;
304 }
305 /* turn off backbone model if "All" models present */
306 pmsdThis = (PMSD) pdnmsModelstruc->data.ptrvalue;
307 pdnmlThis = pmsdThis->pdnmlModels;
308 /* set up for doing one model or animation */
309 while (pdnmlThis) {
310 pmldThis = (PMLD) pdnmlThis->data.ptrvalue;
311 if (pmldThis->iType == Model_type_ncbi_vector)
312 pmldVec = pmldThis;
313 if (pmldThis->iType == Model_type_ncbi_backbone)
314 pmldOne = pmldThis;
315 if (pmldThis->iType == Model_type_ncbi_all_atom)
316 pmldAll = pmldThis;
317 pdnmlThis = pdnmlThis->next;
318 }
319 if ((pmldOne != NULL) && (pmldAll != NULL))
320 pmldOne->bSelected &= (Byte) 0xFE;
321
322 Cn3D_ResetActiveStrucProc();
323 Cn3D_Redraw(TRUE); /* always a new structure */
324
325 return;
326 }
327
328
329
330 Int2 Main(void)
331 {
332 char buffer[PATH_MAX];
333 WindoW www;
334 Boolean netCurrentlyOn = FALSE;
335 ObjMgrPtr omp;
336 Boolean NoGaps;
337
338
339 ErrSetFatalLevel(SEV_MAX);
340
341 UseLocalAsnloadDataAndErrMsg();
342 if (!OpenMMDBAPI(0, NULL)) {
343 /* make user hit OK, so has time to read MMDBAPI's error postings */
344 Message(MSG_ERROR, "Unable to open MMDB-API");
345 return 1;
346 }
347
348 SeqAsnLoad();
349
350 #ifdef WIN_MAC
351 DeskAccGroup(AppleMenu(NULL));
352 #endif
353
354 /* increment maximum # of objects held in memory */
355 omp = ObjMgrWriteLock();
356 if (omp != NULL)
357 omp->maxtemp = DDV_MAXTEMP;
358 ObjMgrUnlock();
359
360 /*register the sequence and alignment viewers */
361 REGISTER_UDV_AUTONOMOUS; /* udv */
362 REG_DDV_SLA_VIEW; /* ddv */
363 REG_DDV_SLA_EDIT; /* dde */
364 REGISTER_UDV_SEQENTRY; /* udv launch seqentry */
365
366 /* force DDE to not allow gaps in alignments */
367 NoGaps = TRUE;
368 SetAppProperty("dde_nogaps",(void*)&NoGaps);
369
370 Cn3D_CheckNetworkUse();
371
372 www = Cn3DWin(NULL, NULL, NetConfigureProc, TRUE);
373 if (www) {
374 if (GetAppParam
375 ("Cn3D", "demo", "mandatory_file", "", buffer,
376 sizeof(buffer)) > 0) {
377 OpenMimeFileWithDeletion(buffer, FALSE);
378 } else {
379 #if defined(OS_UNIX) || defined(WIN_MSWIN)
380 if (GetArgc() == 2)
381 OpenMimeFile(GetArgv()[1]);
382 else if (GetArgc() == 4) {
383 /*
384 runs Cn3D in batch mode to produce gifs. Arguments are mmdb id, width, and height.
385 gifs are saved with a file name constructed using the mmdb id.
386 */
387 CharPtr defname;
388 Nlm_RecT rect;
389
390 rect.left = 0;
391 rect.right = atoi(GetArgv()[2]);
392 rect.top = 0;
393 rect.bottom = atoi(GetArgv()[3]);
394 if (rect.right < 1 || rect.bottom < 1)
395 return 0;
396
397 defname = StringSave(GetArgv()[1]);
398 if (atoi(defname) < 1)
399 return 0;
400 Cn3D_PrintImage(defname);
401 StringCat(defname, ".gif");
402 Show(www);
403 Cn3D_Redraw(TRUE);
404 Nlm_Call_SetPosition3D(&rect);
405 Update();
406 Nlm_Call_SaveImageGIF(defname);
407 return 0;
408 }
409 else {
410 if (GetAppParam
411 ("Cn3D", "demo", "optional_file", "", buffer,
412 sizeof(buffer)) > 0) {
413 OpenMimeFileWithDeletion(buffer, FALSE);
414 }
415 }
416 #endif
417 #if defined(WIN_MAC) || defined(WIN_MSWIN)
418 RegisterDropProc(OpenMimeFile);
419 #endif
420 }
421
422 Show(www);
423 ProcessEvents();
424 }
425
426 CloseMMDBAPI();
427
428
429 /* to do: delete OGL global information in viewer3D. lyg */
430 if (Cn3D_EntrezOn()) {
431 EntrezBioseqFetchDisable();
432 EntrezFini();
433 }
434
435 return 0;
436 }
437 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |