|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/ddv/ddvmain.c |
source navigation diff markup identifier search freetext search file search |
1 /* $Id: ddvmain.c,v 1.26 2000/07/17 13:32:33 lewisg Exp $
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: ddvmain.c
27 *
28 * Author: Patrick Durand
29 *
30 * Version Creation Date: 06/19/99
31 *
32 * $Revision: 1.26 $
33 *
34 * File Description: starter module of DeuxD-Viewer (DDV). Onlu use to
35 * start DDV as a standalone software.
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * $Log: ddvmain.c,v $
40 * Revision 1.26 2000/07/17 13:32:33 lewisg
41 * move DDV_args out of the library
42 *
43 * Revision 1.25 2000/07/17 12:38:53 kans
44 * DDV_myargs is extern in header, instantiated in ddvpanel.c, since it is accessed from that library file
45 *
46 * Revision 1.24 2000/07/14 22:24:55 lewisg
47 * fix scroll, click, visual c++ build bugs. add command line arg parse to ddv
48 *
49 * Revision 1.23 2000/07/05 19:23:13 lewisg
50 * add two panes to ddv, update msvc project files
51 *
52 * Revision 1.22 2000/06/06 14:44:16 hurwitz
53 * fixed bug that SetAppProperty(dde_nogaps)
54 *
55 * Revision 1.21 2000/05/31 23:07:26 hurwitz
56 * made NoGaps a runtime parameter, fixed bug with vertical scroll of show/hide list, save edits query is not performed if nothing to save
57 *
58 * Revision 1.20 2000/04/21 23:00:50 hurwitz
59 * can launch DDE from DDV
60 *
61 * Revision 1.19 2000/04/17 13:30:43 durand
62 * removed g_hParent and unused functions DDV_LaunchAlignViewer and DDV_LaunchAlignEditor
63 *
64 * Revision 1.18 2000/03/30 21:58:06 durand
65 * made standalone DDV a viewer, not the editor
66 *
67 * Revision 1.17 2000/03/21 14:22:42 durand
68 * fixed a problem with menus setup
69 *
70 * Revision 1.16 2000/03/16 18:38:38 durand
71 * fixed the starter function for the GUI
72 *
73 * Revision 1.15 2000/02/04 16:05:41 durand
74 * add click action to select a row
75 *
76 * Revision 1.14 2000/02/02 14:44:32 durand
77 * added function to create data structure for block editor, fixed some bugs
78 *
79 * Revision 1.13 2000/01/26 13:38:55 durand
80 * update the GUI for the editor. Add functions to create the data to be used by the editor
81 *
82 * Revision 1.12 2000/01/11 15:29:48 durand
83 * add a cast to use EntrezSeqEntryGet instead of ID1SeqEntryGet
84 *
85 * Revision 1.11 2000/01/11 15:05:23 durand
86 * remove network stuff
87 *
88 * Revision 1.10 2000/01/10 15:09:46 durand
89 * Use Entrez instead of ID1
90 *
91 * Revision 1.9 2000/01/05 21:11:14 durand
92 * update mouse click actions and DrawSequence function for a better use from ddv and cn3d
93 *
94 * Revision 1.8 1999/12/03 23:17:23 lewisg
95 * Patrick's new global update msg, argument passing when launching ddv, experimental editing
96 *
97 * Revision 1.7 1999/11/29 15:26:25 durand
98 * designed a new GUI to fix problems under MacOS, Linux and SGI
99 *
100 * Revision 1.6 1999/11/04 22:11:38 durand
101 * add the Desktop to DDV. Add a better set of cleanup functions when closing DDV. Before creating color tables, try to get them from the SeqAlign
102 *
103 * Revision 1.5 1999/10/29 14:15:40 durand
104 * add simple mouse selection functions
105 *
106 * Revision 1.4 1999/10/23 21:20:45 lewisg
107 * move g_hParent to ddvopen.c
108 *
109 * Revision 1.3 1999/10/23 14:54:33 durand
110 * resolve external symbol g_hParent
111 *
112 * Revision 1.2 1999/10/22 14:19:43 durand
113 * update the code for the startup functions of DDV drawing panel
114 *
115 * Revision 1.1 1999/09/30 14:10:27 durand
116 * add ddv to toolkit
117 *
118 * Revision 1.7 1999/09/23 19:06:50 lewisg
119 * increase maxtemp number of cached sequences
120 *
121 * Revision 1.6 1999/09/23 17:44:32 lewisg
122 * increase maxtemp number of cached sequences
123 *
124 * Revision 1.5 1999/07/01 15:28:28 durand
125 * validate function loaders of DDV
126 *
127 * Revision 1.2 1999/06/28 22:07:18 durand
128 * add loader functions and clean the code with Lint and Purify
129 *
130 * Revision 1.1 1999/06/19 17:21:05 durand
131 * add Vibrant DDV code
132 *
133 *
134 *
135 * ==========================================================================
136 */
137
138 #include <ncbi.h>
139 #include <accentr.h>
140 #include <udviewer.h>
141 #include <ddvopen.h>
142 #include <ddvmain.h>
143 #include <ddvpanel.h>
144 #include <vibrant.h>
145 #include <netcnfg.h>
146
147 extern Args DDV_myargs[NUMARGS] = {
148 /*0*/ { "Gaps allowed", "T", NULL, NULL, TRUE, 'g', ARG_BOOLEAN, 0.0,0,NULL},
149 /*1*/ { "Allow Edits", "T", NULL, NULL, TRUE , 'e', ARG_BOOLEAN, 0.0,0,NULL},
150 };
151
152 /*******************************************************************************
153
154 Function : DDV_ConfigAccepted()
155
156 Purpose : Entrez Network COnfiguration Dialog Box; accept a new config
157
158 Return value : none
159
160 *******************************************************************************/
161 static void DDV_ConfigAccepted(void)
162 {
163 SetAppParam("DDV", "SETTINGS", "NETWORKAVAILABLE", "TRUE");
164 Message(MSG_OK, "Setting will take affect when you restart DDV");
165 }
166
167 /*******************************************************************************
168
169 Function : DDV_ConfigAccepted()
170
171 Purpose : Entrez Network COnfiguration Dialog Box; close dlg without modif.
172
173 Return value : none
174
175 *******************************************************************************/
176 static void DDV_ConfigCancelled(void)
177 {
178 }
179
180 /*******************************************************************************
181
182 Function : DDV_ConfigTurnedOff()
183
184 Purpose : Entrez Network COnfiguration Dialog Box; cancel Entrez connection
185
186 Return value : none
187
188 *******************************************************************************/
189 static void DDV_ConfigTurnedOff(void)
190 {
191 SetAppParam("DDV", "SETTINGS", "NETWORKAVAILABLE", "FALSE");
192 Message(MSG_OK, "Setting will take affect when you restart DDV");
193 }
194
195 /*******************************************************************************
196
197 Function : DDV_ConfigNetwork()
198
199 Purpose : call the Entrez Network COnfiguration Dialog Box
200
201 Return value : none
202
203 *******************************************************************************/
204 static void DDV_ConfigNetwork(IteM i)
205 {
206 DdvMainWinPtr dmwp;
207 WindoW hParent;
208
209 /*get main data block*/
210 hParent=(WindoW)ParentWindow(i);
211 if (!hParent) return;
212 dmwp=(DdvMainWinPtr)GetObjectExtra(hParent);
213
214 if (dmwp->UseNetwork) ShowNetConfigForm(NULL,
215 NULL, DDV_ConfigAccepted, DDV_ConfigCancelled, DDV_ConfigTurnedOff, TRUE);
216 else ShowNetConfigForm(NULL, NULL, DDV_ConfigAccepted, DDV_ConfigCancelled,
217 DDV_ConfigTurnedOff, FALSE);
218 }
219
220 /*******************************************************************************
221
222 Function : DDV_StartEntrez()
223
224 Purpose : start connection to Entrez Server.
225
226 Return value : -
227
228 *******************************************************************************/
229 static Boolean DDV_StartEntrez(Boolean UseNetwork)
230 {
231 Boolean bRet;
232
233 bRet=FALSE;
234
235 if (!UseNetwork) {
236 bRet=FALSE;
237 }
238 else{
239 if (!EntrezIsInited()) {
240 if(EntrezBioseqFetchEnable(szAppName, FALSE)) {
241 if (EntrezInit(szAppName, TRUE, NULL))
242 bRet=TRUE;
243 else
244 bRet=FALSE;
245 }
246 else {
247 bRet=FALSE;
248 }
249 }
250 else{
251 bRet=TRUE;
252 }
253 }
254 return(bRet);
255 }
256
257
258 /*****************************************************************************
259
260 Function: DDV_UseNetwork()
261
262 Purpose: Determines if DDV should use the network
263
264 Returns: TRUE if yes
265
266 *****************************************************************************/
267 static Boolean DDV_UseNetwork(void)
268 {
269 Char str[64];
270
271 if (GetAppParam
272 ("DDV", "SETTINGS", "NETWORKAVAILABLE", NULL, str, sizeof(str))) {
273 if (StringICmp(str, "TRUE") == 0) return TRUE;
274 }
275 return FALSE;
276 }
277
278 /*******************************************************************************
279
280 Function : DDV_StartMainWin_Master()
281
282 Purpose : start DDV main window as a standalone application. Never use this
283 function for other purpose. If you want to start DDV as a slave, take a
284 look at the functions below.
285
286 Parameters : mWin_d; main program data
287 ldp; logo data
288
289 Return value : handle to the DDV main window
290
291 *******************************************************************************/
292 static WindoW DDV_StartMainWin_Master(DdvMainWinPtr mWin_d,UDVLogoDataPtr ldp)
293 {
294 Int2 Margins;
295 WindoW w;
296 Boolean bRet;
297
298 /*main window*/
299 Margins=10*stdCharWidth;
300
301 w=DocumentWindow(Margins,Margins ,-10,-10,
302 szAppName,
303 DDV_WinMainProgQuit,
304 DDV_WinMainResize);
305
306 if (w==NULL){
307 Message (MSG_ERROR, "Viewer creation failed.");
308 return(NULL);
309 }
310
311 SetObjectExtra (w, (Pointer)mWin_d, (FreeProc)DDV_WinMainCleanup);
312 SetAppProperty("UDVLogoData",(Pointer)ldp);
313
314 mWin_d->hWndMain=w;
315 /*this is an autonomous viewer*/
316 mWin_d->AutonomeViewer=TRUE;
317
318 /*use the Network ?*/
319 mWin_d->UseNetwork=TRUE;/*DDV_UseNetwork();*/
320
321 bRet=DDV_CreateViewerPanel(w,mWin_d,NULL,FALSE); /*FALSE for viewer */
322 if (!bRet) return(NULL);
323
324 /*init logo_panel*/
325 LogoFontCreate(&ldp->f1,&ldp->f2,&ldp->f3);
326 StringCpy(ldp->szTitle,"DDV");
327 StringCpy(ldp->szDesc,", a MSA viewer/editor");
328 mWin_d->Show_logo=TRUE;
329
330 /*set the function to get a gi over the network*/
331 mWin_d->fetchSepProc=(UdvFetchSeqEntryProc)EntrezSeqEntryGet;
332 mWin_d->NetCfgMenuProc=DDV_ConfigNetwork;
333 mWin_d->NetStartProc=DDV_StartEntrez;
334
335 return(w);
336 }
337
338 /*******************************************************************************
339
340 Function : Main()
341
342 Purpose : Entry point of the software
343
344 Parameters :
345
346 Return value :
347
348 *******************************************************************************/
349
350 Int2 Main(void)
351 {
352 UDVLogoDataPtr ldp;
353 Boolean UseNetwork;
354 WindoW w;
355 DdvMainWinPtr mWin_d;/*main window data*/
356 ObjMgrPtr omp = NULL;
357 Boolean NoGaps;
358
359 if ( !Nlm_GetArgsSilent("DDV 1.0", NUMARGS, DDV_myargs) ) return 1;
360
361 ErrSetMessageLevel(SEV_WARNING);
362 ErrSetOptFlags(EO_SHOW_CODES);
363 ErrSetOptFlags(EO_XLATE_CODES);
364
365 /*init some important stuffs*/
366 UseLocalAsnloadDataAndErrMsg();
367
368 if (! AllObjLoad()){
369 Message (MSG_ERROR, "AsnObjLoad() failed.");
370 return(1);
371 }
372
373 if (! SubmitAsnLoad()){
374 Message (MSG_ERROR, "SeqSubmitLoad() failed.");
375 return(1);
376 }
377
378 if (!SeqCodeSetLoad ()){
379 Message (MSG_ERROR, "SeqCodeSetLoad () failed.");
380 return(1);
381 }
382
383 if (!GeneticCodeTableLoad()){
384 Message (MSG_ERROR, "GeneticCodeTableLoad() failed.");
385 return(1);
386 }
387
388 if (!FeatDefSetLoad()){
389 Message (MSG_ERROR, "FeatDefSeqLoad() failed.");
390 return(1);
391 }
392
393 /*init data blocks*/
394 mWin_d=(DdvMainWinPtr)MemNew(sizeof(DdvMainWin));
395 if (!mWin_d){
396 Message (MSG_ERROR, "Viewer creation failed.");
397 return(1);
398 }
399
400 /* look for "nogaps" runtime parameter */
401 NoGaps = (Boolean)DDV_myargs[0].intvalue;
402 SetAppProperty("dde_nogaps",(void*)&NoGaps);
403
404 mWin_d->EditAllowed = (Boolean)DDV_myargs[1].intvalue;
405
406 /*init data blocks*/
407 ldp=(UDVLogoDataPtr)MemNew(sizeof(UDVLogoData));
408 if (ldp){
409 MemSet(ldp,0,sizeof(UDVLogoData));
410 }
411 else{
412 Message (MSG_ERROR, "Viewer creation failed.");
413 return(1);
414 }
415
416 /*OBjMgr Callback Function declaration*/
417 /* REG_DDV_AUTO_EDIT; */
418 REG_DDV_AUTO_VIEW;
419 REGISTER_UDV_AUTONOMOUS;
420 REG_DDV_SLA_EDIT;
421
422 /* increment maximum # of objects held in memory */
423 omp = ObjMgrWriteLock();
424 if(omp != NULL ) omp->maxtemp = DDV_MAXTEMP;
425 ObjMgrUnlock();
426
427 w=DDV_StartMainWin_Master(mWin_d,ldp);
428 if (w==NULL) goto fin;
429
430 ProcessUpdatesFirst(FALSE);
431 UseNetwork=mWin_d->UseNetwork;
432
433 /*display main window*/
434 RealizeWindow(w);
435 Show(w);
436
437 /*enter loop events*/
438 ProcessEvents();
439 fin:
440 /*close network connection, if needed*/
441 if (UseNetwork && EntrezIsInited()) EntrezBioseqFetchDisable();
442 /*clean up*/
443 if (ldp) MemFree(ldp);
444 RemoveAppProperty("UDVLogoData");
445 return(0);
446 }
447
448 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |