~ubuntu-branches/ubuntu/maverick/ncbi-tools6/maverick

« back to all changes in this revision

Viewing changes to biostruc/cn3d/objcn3d.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2002-04-04 22:13:09 UTC
  • Revision ID: james.westby@ubuntu.com-20020404221309-vfze028rfnlrldct
Tags: upstream-6.1.20011220a
ImportĀ upstreamĀ versionĀ 6.1.20011220a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <asn.h>
 
2
 
 
3
#define NLM_GENERATED_CODE_PROTO
 
4
 
 
5
#include <mapcn3d.h>
 
6
#include <objcn3d.h>
 
7
 
 
8
static Boolean loaded = FALSE;
 
9
 
 
10
#include <cn3d.h>
 
11
 
 
12
#ifndef NLM_EXTERN_LOADS
 
13
#define NLM_EXTERN_LOADS {}
 
14
#endif
 
15
 
 
16
NLM_EXTERN Boolean LIBCALL
 
17
objcn3dAsnLoad(void)
 
18
{
 
19
 
 
20
   if ( ! loaded) {
 
21
      NLM_EXTERN_LOADS
 
22
 
 
23
      if ( ! AsnLoad ())
 
24
      return FALSE;
 
25
      loaded = TRUE;
 
26
   }
 
27
 
 
28
   return TRUE;
 
29
}
 
30
 
 
31
 
 
32
 
 
33
/**************************************************
 
34
*    Generated object loaders for Module NCBI-Cn3d
 
35
*    Generated using ASNCODE Revision: 6.12 at Oct 17, 2001 12:45 PM
 
36
*
 
37
**************************************************/
 
38
 
 
39
 
 
40
/**************************************************
 
41
*
 
42
*    Cn3dStyleDictionaryNew()
 
43
*
 
44
**************************************************/
 
45
NLM_EXTERN 
 
46
Cn3dStyleDictionaryPtr LIBCALL
 
47
Cn3dStyleDictionaryNew(void)
 
48
{
 
49
   Cn3dStyleDictionaryPtr ptr = MemNew((size_t) sizeof(Cn3dStyleDictionary));
 
50
 
 
51
   return ptr;
 
52
 
 
53
}
 
54
 
 
55
 
 
56
/**************************************************
 
57
*
 
58
*    Cn3dStyleDictionaryFree()
 
59
*
 
60
**************************************************/
 
61
NLM_EXTERN 
 
62
Cn3dStyleDictionaryPtr LIBCALL
 
63
Cn3dStyleDictionaryFree(Cn3dStyleDictionaryPtr ptr)
 
64
{
 
65
 
 
66
   if(ptr == NULL) {
 
67
      return NULL;
 
68
   }
 
69
   Cn3dStyleSettingsFree(ptr -> global_style);
 
70
   AsnGenericUserSeqOfFree(ptr -> style_table, (AsnOptFreeFunc) Cn3dStyleTableItemFree);
 
71
   return MemFree(ptr);
 
72
}
 
73
 
 
74
 
 
75
/**************************************************
 
76
*
 
77
*    Cn3dStyleDictionaryAsnRead()
 
78
*
 
79
**************************************************/
 
80
NLM_EXTERN 
 
81
Cn3dStyleDictionaryPtr LIBCALL
 
82
Cn3dStyleDictionaryAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
83
{
 
84
   DataVal av;
 
85
   AsnTypePtr atp;
 
86
   Boolean isError = FALSE;
 
87
   AsnReadFunc func;
 
88
   Cn3dStyleDictionaryPtr ptr;
 
89
 
 
90
   if (! loaded)
 
91
   {
 
92
      if (! objcn3dAsnLoad()) {
 
93
         return NULL;
 
94
      }
 
95
   }
 
96
 
 
97
   if (aip == NULL) {
 
98
      return NULL;
 
99
   }
 
100
 
 
101
   if (orig == NULL) {         /* Cn3dStyleDictionary ::= (self contained) */
 
102
      atp = AsnReadId(aip, amp, CN3D_STYLE_DICTIONARY);
 
103
   } else {
 
104
      atp = AsnLinkType(orig, CN3D_STYLE_DICTIONARY);
 
105
   }
 
106
   /* link in local tree */
 
107
   if (atp == NULL) {
 
108
      return NULL;
 
109
   }
 
110
 
 
111
   ptr = Cn3dStyleDictionaryNew();
 
112
   if (ptr == NULL) {
 
113
      goto erret;
 
114
   }
 
115
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
116
      goto erret;
 
117
   }
 
118
 
 
119
   atp = AsnReadId(aip,amp, atp);
 
120
   func = NULL;
 
121
 
 
122
   if (atp == CN3D_STYLE_DICTIONARY_global_style) {
 
123
      ptr -> global_style = Cn3dStyleSettingsAsnRead(aip, atp);
 
124
      if (aip -> io_failure) {
 
125
         goto erret;
 
126
      }
 
127
      atp = AsnReadId(aip,amp, atp);
 
128
   }
 
129
   if (atp == CN3D_STYLE_DICTIONARY_style_table) {
 
130
      ptr -> style_table = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dStyleTableItemAsnRead, (AsnOptFreeFunc) Cn3dStyleTableItemFree);
 
131
      if (isError && ptr -> style_table == NULL) {
 
132
         goto erret;
 
133
      }
 
134
      atp = AsnReadId(aip,amp, atp);
 
135
   }
 
136
 
 
137
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
138
      goto erret;
 
139
   }
 
140
   /* end struct */
 
141
 
 
142
ret:
 
143
   AsnUnlinkType(orig);       /* unlink local tree */
 
144
   return ptr;
 
145
 
 
146
erret:
 
147
   aip -> io_failure = TRUE;
 
148
   ptr = Cn3dStyleDictionaryFree(ptr);
 
149
   goto ret;
 
150
}
 
151
 
 
152
 
 
153
 
 
154
/**************************************************
 
155
*
 
156
*    Cn3dStyleDictionaryAsnWrite()
 
157
*
 
158
**************************************************/
 
159
NLM_EXTERN Boolean LIBCALL 
 
160
Cn3dStyleDictionaryAsnWrite(Cn3dStyleDictionaryPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
161
{
 
162
   DataVal av;
 
163
   AsnTypePtr atp;
 
164
   Boolean retval = FALSE;
 
165
 
 
166
   if (! loaded)
 
167
   {
 
168
      if (! objcn3dAsnLoad()) {
 
169
         return FALSE;
 
170
      }
 
171
   }
 
172
 
 
173
   if (aip == NULL) {
 
174
      return FALSE;
 
175
   }
 
176
 
 
177
   atp = AsnLinkType(orig, CN3D_STYLE_DICTIONARY);   /* link local tree */
 
178
   if (atp == NULL) {
 
179
      return FALSE;
 
180
   }
 
181
 
 
182
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
183
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
184
      goto erret;
 
185
   }
 
186
 
 
187
   if (ptr -> global_style != NULL) {
 
188
      if ( ! Cn3dStyleSettingsAsnWrite(ptr -> global_style, aip, CN3D_STYLE_DICTIONARY_global_style)) {
 
189
         goto erret;
 
190
      }
 
191
   }
 
192
   AsnGenericUserSeqOfAsnWrite(ptr -> style_table, (AsnWriteFunc) Cn3dStyleTableItemAsnWrite, aip, CN3D_STYLE_DICTIONARY_style_table, CN3D_STYLE_DICTIONARY_style_table_E);
 
193
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
194
      goto erret;
 
195
   }
 
196
   retval = TRUE;
 
197
 
 
198
erret:
 
199
   AsnUnlinkType(orig);       /* unlink local tree */
 
200
   return retval;
 
201
}
 
202
 
 
203
 
 
204
 
 
205
/**************************************************
 
206
*
 
207
*    Cn3dUserAnnotationsNew()
 
208
*
 
209
**************************************************/
 
210
NLM_EXTERN 
 
211
Cn3dUserAnnotationsPtr LIBCALL
 
212
Cn3dUserAnnotationsNew(void)
 
213
{
 
214
   Cn3dUserAnnotationsPtr ptr = MemNew((size_t) sizeof(Cn3dUserAnnotations));
 
215
 
 
216
   return ptr;
 
217
 
 
218
}
 
219
 
 
220
 
 
221
/**************************************************
 
222
*
 
223
*    Cn3dUserAnnotationsFree()
 
224
*
 
225
**************************************************/
 
226
NLM_EXTERN 
 
227
Cn3dUserAnnotationsPtr LIBCALL
 
228
Cn3dUserAnnotationsFree(Cn3dUserAnnotationsPtr ptr)
 
229
{
 
230
 
 
231
   if(ptr == NULL) {
 
232
      return NULL;
 
233
   }
 
234
   AsnGenericUserSeqOfFree(ptr -> annotations, (AsnOptFreeFunc) Cn3dUserAnnotationFree);
 
235
   Cn3dViewSettingsFree(ptr -> view);
 
236
   return MemFree(ptr);
 
237
}
 
238
 
 
239
 
 
240
/**************************************************
 
241
*
 
242
*    Cn3dUserAnnotationsAsnRead()
 
243
*
 
244
**************************************************/
 
245
NLM_EXTERN 
 
246
Cn3dUserAnnotationsPtr LIBCALL
 
247
Cn3dUserAnnotationsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
248
{
 
249
   DataVal av;
 
250
   AsnTypePtr atp;
 
251
   Boolean isError = FALSE;
 
252
   AsnReadFunc func;
 
253
   Cn3dUserAnnotationsPtr ptr;
 
254
 
 
255
   if (! loaded)
 
256
   {
 
257
      if (! objcn3dAsnLoad()) {
 
258
         return NULL;
 
259
      }
 
260
   }
 
261
 
 
262
   if (aip == NULL) {
 
263
      return NULL;
 
264
   }
 
265
 
 
266
   if (orig == NULL) {         /* Cn3dUserAnnotations ::= (self contained) */
 
267
      atp = AsnReadId(aip, amp, CN3D_USER_ANNOTATIONS);
 
268
   } else {
 
269
      atp = AsnLinkType(orig, CN3D_USER_ANNOTATIONS);
 
270
   }
 
271
   /* link in local tree */
 
272
   if (atp == NULL) {
 
273
      return NULL;
 
274
   }
 
275
 
 
276
   ptr = Cn3dUserAnnotationsNew();
 
277
   if (ptr == NULL) {
 
278
      goto erret;
 
279
   }
 
280
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
281
      goto erret;
 
282
   }
 
283
 
 
284
   atp = AsnReadId(aip,amp, atp);
 
285
   func = NULL;
 
286
 
 
287
   if (atp == CN3D_USER_ANNOTATIONS_annotations) {
 
288
      ptr -> annotations = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dUserAnnotationAsnRead, (AsnOptFreeFunc) Cn3dUserAnnotationFree);
 
289
      if (isError && ptr -> annotations == NULL) {
 
290
         goto erret;
 
291
      }
 
292
      atp = AsnReadId(aip,amp, atp);
 
293
   }
 
294
   if (atp == CN3D_USER_ANNOTATIONS_view) {
 
295
      ptr -> view = Cn3dViewSettingsAsnRead(aip, atp);
 
296
      if (aip -> io_failure) {
 
297
         goto erret;
 
298
      }
 
299
      atp = AsnReadId(aip,amp, atp);
 
300
   }
 
301
 
 
302
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
303
      goto erret;
 
304
   }
 
305
   /* end struct */
 
306
 
 
307
ret:
 
308
   AsnUnlinkType(orig);       /* unlink local tree */
 
309
   return ptr;
 
310
 
 
311
erret:
 
312
   aip -> io_failure = TRUE;
 
313
   ptr = Cn3dUserAnnotationsFree(ptr);
 
314
   goto ret;
 
315
}
 
316
 
 
317
 
 
318
 
 
319
/**************************************************
 
320
*
 
321
*    Cn3dUserAnnotationsAsnWrite()
 
322
*
 
323
**************************************************/
 
324
NLM_EXTERN Boolean LIBCALL 
 
325
Cn3dUserAnnotationsAsnWrite(Cn3dUserAnnotationsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
326
{
 
327
   DataVal av;
 
328
   AsnTypePtr atp;
 
329
   Boolean retval = FALSE;
 
330
 
 
331
   if (! loaded)
 
332
   {
 
333
      if (! objcn3dAsnLoad()) {
 
334
         return FALSE;
 
335
      }
 
336
   }
 
337
 
 
338
   if (aip == NULL) {
 
339
      return FALSE;
 
340
   }
 
341
 
 
342
   atp = AsnLinkType(orig, CN3D_USER_ANNOTATIONS);   /* link local tree */
 
343
   if (atp == NULL) {
 
344
      return FALSE;
 
345
   }
 
346
 
 
347
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
348
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
349
      goto erret;
 
350
   }
 
351
 
 
352
   AsnGenericUserSeqOfAsnWrite(ptr -> annotations, (AsnWriteFunc) Cn3dUserAnnotationAsnWrite, aip, CN3D_USER_ANNOTATIONS_annotations, CN3D_USER_ANNOTATIONS_annotations_E);
 
353
   if (ptr -> view != NULL) {
 
354
      if ( ! Cn3dViewSettingsAsnWrite(ptr -> view, aip, CN3D_USER_ANNOTATIONS_view)) {
 
355
         goto erret;
 
356
      }
 
357
   }
 
358
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
359
      goto erret;
 
360
   }
 
361
   retval = TRUE;
 
362
 
 
363
erret:
 
364
   AsnUnlinkType(orig);       /* unlink local tree */
 
365
   return retval;
 
366
}
 
367
 
 
368
 
 
369
 
 
370
/**************************************************
 
371
*
 
372
*    Cn3dColorNew()
 
373
*
 
374
**************************************************/
 
375
NLM_EXTERN 
 
376
Cn3dColorPtr LIBCALL
 
377
Cn3dColorNew(void)
 
378
{
 
379
   Cn3dColorPtr ptr = MemNew((size_t) sizeof(Cn3dColor));
 
380
 
 
381
   ptr -> scale_factor = 255;
 
382
   ptr -> alpha = 255;
 
383
   return ptr;
 
384
 
 
385
}
 
386
 
 
387
 
 
388
/**************************************************
 
389
*
 
390
*    Cn3dColorFree()
 
391
*
 
392
**************************************************/
 
393
NLM_EXTERN 
 
394
Cn3dColorPtr LIBCALL
 
395
Cn3dColorFree(Cn3dColorPtr ptr)
 
396
{
 
397
 
 
398
   if(ptr == NULL) {
 
399
      return NULL;
 
400
   }
 
401
   return MemFree(ptr);
 
402
}
 
403
 
 
404
 
 
405
/**************************************************
 
406
*
 
407
*    Cn3dColorAsnRead()
 
408
*
 
409
**************************************************/
 
410
NLM_EXTERN 
 
411
Cn3dColorPtr LIBCALL
 
412
Cn3dColorAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
413
{
 
414
   DataVal av;
 
415
   AsnTypePtr atp;
 
416
   Boolean isError = FALSE;
 
417
   AsnReadFunc func;
 
418
   Cn3dColorPtr ptr;
 
419
 
 
420
   if (! loaded)
 
421
   {
 
422
      if (! objcn3dAsnLoad()) {
 
423
         return NULL;
 
424
      }
 
425
   }
 
426
 
 
427
   if (aip == NULL) {
 
428
      return NULL;
 
429
   }
 
430
 
 
431
   if (orig == NULL) {         /* Cn3dColor ::= (self contained) */
 
432
      atp = AsnReadId(aip, amp, CN3D_COLOR);
 
433
   } else {
 
434
      atp = AsnLinkType(orig, CN3D_COLOR);
 
435
   }
 
436
   /* link in local tree */
 
437
   if (atp == NULL) {
 
438
      return NULL;
 
439
   }
 
440
 
 
441
   ptr = Cn3dColorNew();
 
442
   if (ptr == NULL) {
 
443
      goto erret;
 
444
   }
 
445
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
446
      goto erret;
 
447
   }
 
448
 
 
449
   atp = AsnReadId(aip,amp, atp);
 
450
   func = NULL;
 
451
 
 
452
   if (atp == CN3D_COLOR_scale_factor) {
 
453
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
454
         goto erret;
 
455
      }
 
456
      ptr -> scale_factor = av.intvalue;
 
457
      atp = AsnReadId(aip,amp, atp);
 
458
   }
 
459
   if (atp == CN3D_COLOR_red) {
 
460
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
461
         goto erret;
 
462
      }
 
463
      ptr -> red = av.intvalue;
 
464
      atp = AsnReadId(aip,amp, atp);
 
465
   }
 
466
   if (atp == CN3D_COLOR_green) {
 
467
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
468
         goto erret;
 
469
      }
 
470
      ptr -> green = av.intvalue;
 
471
      atp = AsnReadId(aip,amp, atp);
 
472
   }
 
473
   if (atp == CN3D_COLOR_blue) {
 
474
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
475
         goto erret;
 
476
      }
 
477
      ptr -> blue = av.intvalue;
 
478
      atp = AsnReadId(aip,amp, atp);
 
479
   }
 
480
   if (atp == CN3D_COLOR_alpha) {
 
481
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
482
         goto erret;
 
483
      }
 
484
      ptr -> alpha = av.intvalue;
 
485
      atp = AsnReadId(aip,amp, atp);
 
486
   }
 
487
 
 
488
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
489
      goto erret;
 
490
   }
 
491
   /* end struct */
 
492
 
 
493
ret:
 
494
   AsnUnlinkType(orig);       /* unlink local tree */
 
495
   return ptr;
 
496
 
 
497
erret:
 
498
   aip -> io_failure = TRUE;
 
499
   ptr = Cn3dColorFree(ptr);
 
500
   goto ret;
 
501
}
 
502
 
 
503
 
 
504
 
 
505
/**************************************************
 
506
*
 
507
*    Cn3dColorAsnWrite()
 
508
*
 
509
**************************************************/
 
510
NLM_EXTERN Boolean LIBCALL 
 
511
Cn3dColorAsnWrite(Cn3dColorPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
512
{
 
513
   DataVal av;
 
514
   AsnTypePtr atp;
 
515
   Boolean retval = FALSE;
 
516
 
 
517
   if (! loaded)
 
518
   {
 
519
      if (! objcn3dAsnLoad()) {
 
520
         return FALSE;
 
521
      }
 
522
   }
 
523
 
 
524
   if (aip == NULL) {
 
525
      return FALSE;
 
526
   }
 
527
 
 
528
   atp = AsnLinkType(orig, CN3D_COLOR);   /* link local tree */
 
529
   if (atp == NULL) {
 
530
      return FALSE;
 
531
   }
 
532
 
 
533
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
534
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
535
      goto erret;
 
536
   }
 
537
 
 
538
   av.intvalue = ptr -> scale_factor;
 
539
   retval = AsnWrite(aip, CN3D_COLOR_scale_factor,  &av);
 
540
   av.intvalue = ptr -> red;
 
541
   retval = AsnWrite(aip, CN3D_COLOR_red,  &av);
 
542
   av.intvalue = ptr -> green;
 
543
   retval = AsnWrite(aip, CN3D_COLOR_green,  &av);
 
544
   av.intvalue = ptr -> blue;
 
545
   retval = AsnWrite(aip, CN3D_COLOR_blue,  &av);
 
546
   av.intvalue = ptr -> alpha;
 
547
   retval = AsnWrite(aip, CN3D_COLOR_alpha,  &av);
 
548
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
549
      goto erret;
 
550
   }
 
551
   retval = TRUE;
 
552
 
 
553
erret:
 
554
   AsnUnlinkType(orig);       /* unlink local tree */
 
555
   return retval;
 
556
}
 
557
 
 
558
 
 
559
 
 
560
/**************************************************
 
561
*
 
562
*    Cn3dBackboneStyleNew()
 
563
*
 
564
**************************************************/
 
565
NLM_EXTERN 
 
566
Cn3dBackboneStylePtr LIBCALL
 
567
Cn3dBackboneStyleNew(void)
 
568
{
 
569
   Cn3dBackboneStylePtr ptr = MemNew((size_t) sizeof(Cn3dBackboneStyle));
 
570
 
 
571
   return ptr;
 
572
 
 
573
}
 
574
 
 
575
 
 
576
/**************************************************
 
577
*
 
578
*    Cn3dBackboneStyleFree()
 
579
*
 
580
**************************************************/
 
581
NLM_EXTERN 
 
582
Cn3dBackboneStylePtr LIBCALL
 
583
Cn3dBackboneStyleFree(Cn3dBackboneStylePtr ptr)
 
584
{
 
585
 
 
586
   if(ptr == NULL) {
 
587
      return NULL;
 
588
   }
 
589
   Cn3dColorFree(ptr -> user_color);
 
590
   return MemFree(ptr);
 
591
}
 
592
 
 
593
 
 
594
/**************************************************
 
595
*
 
596
*    Cn3dBackboneStyleAsnRead()
 
597
*
 
598
**************************************************/
 
599
NLM_EXTERN 
 
600
Cn3dBackboneStylePtr LIBCALL
 
601
Cn3dBackboneStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
602
{
 
603
   DataVal av;
 
604
   AsnTypePtr atp;
 
605
   Boolean isError = FALSE;
 
606
   AsnReadFunc func;
 
607
   Cn3dBackboneStylePtr ptr;
 
608
 
 
609
   if (! loaded)
 
610
   {
 
611
      if (! objcn3dAsnLoad()) {
 
612
         return NULL;
 
613
      }
 
614
   }
 
615
 
 
616
   if (aip == NULL) {
 
617
      return NULL;
 
618
   }
 
619
 
 
620
   if (orig == NULL) {         /* Cn3dBackboneStyle ::= (self contained) */
 
621
      atp = AsnReadId(aip, amp, CN3D_BACKBONE_STYLE);
 
622
   } else {
 
623
      atp = AsnLinkType(orig, CN3D_BACKBONE_STYLE);
 
624
   }
 
625
   /* link in local tree */
 
626
   if (atp == NULL) {
 
627
      return NULL;
 
628
   }
 
629
 
 
630
   ptr = Cn3dBackboneStyleNew();
 
631
   if (ptr == NULL) {
 
632
      goto erret;
 
633
   }
 
634
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
635
      goto erret;
 
636
   }
 
637
 
 
638
   atp = AsnReadId(aip,amp, atp);
 
639
   func = NULL;
 
640
 
 
641
   if (atp == CN3D_BACKBONE_STYLE_type) {
 
642
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
643
         goto erret;
 
644
      }
 
645
      ptr -> type = av.intvalue;
 
646
      atp = AsnReadId(aip,amp, atp);
 
647
   }
 
648
   if (atp == CN3D_BACKBONE_STYLE_style) {
 
649
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
650
         goto erret;
 
651
      }
 
652
      ptr -> style = av.intvalue;
 
653
      atp = AsnReadId(aip,amp, atp);
 
654
   }
 
655
   if (atp == CN3D_BACKBONE_STYLE_color_scheme) {
 
656
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
657
         goto erret;
 
658
      }
 
659
      ptr -> color_scheme = av.intvalue;
 
660
      atp = AsnReadId(aip,amp, atp);
 
661
   }
 
662
   if (atp == CN3D_BACKBONE_STYLE_user_color) {
 
663
      ptr -> user_color = Cn3dColorAsnRead(aip, atp);
 
664
      if (aip -> io_failure) {
 
665
         goto erret;
 
666
      }
 
667
      atp = AsnReadId(aip,amp, atp);
 
668
   }
 
669
 
 
670
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
671
      goto erret;
 
672
   }
 
673
   /* end struct */
 
674
 
 
675
ret:
 
676
   AsnUnlinkType(orig);       /* unlink local tree */
 
677
   return ptr;
 
678
 
 
679
erret:
 
680
   aip -> io_failure = TRUE;
 
681
   ptr = Cn3dBackboneStyleFree(ptr);
 
682
   goto ret;
 
683
}
 
684
 
 
685
 
 
686
 
 
687
/**************************************************
 
688
*
 
689
*    Cn3dBackboneStyleAsnWrite()
 
690
*
 
691
**************************************************/
 
692
NLM_EXTERN Boolean LIBCALL 
 
693
Cn3dBackboneStyleAsnWrite(Cn3dBackboneStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
694
{
 
695
   DataVal av;
 
696
   AsnTypePtr atp;
 
697
   Boolean retval = FALSE;
 
698
 
 
699
   if (! loaded)
 
700
   {
 
701
      if (! objcn3dAsnLoad()) {
 
702
         return FALSE;
 
703
      }
 
704
   }
 
705
 
 
706
   if (aip == NULL) {
 
707
      return FALSE;
 
708
   }
 
709
 
 
710
   atp = AsnLinkType(orig, CN3D_BACKBONE_STYLE);   /* link local tree */
 
711
   if (atp == NULL) {
 
712
      return FALSE;
 
713
   }
 
714
 
 
715
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
716
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
717
      goto erret;
 
718
   }
 
719
 
 
720
   av.intvalue = ptr -> type;
 
721
   retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_type,  &av);
 
722
   av.intvalue = ptr -> style;
 
723
   retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_style,  &av);
 
724
   av.intvalue = ptr -> color_scheme;
 
725
   retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_color_scheme,  &av);
 
726
   if (ptr -> user_color != NULL) {
 
727
      if ( ! Cn3dColorAsnWrite(ptr -> user_color, aip, CN3D_BACKBONE_STYLE_user_color)) {
 
728
         goto erret;
 
729
      }
 
730
   }
 
731
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
732
      goto erret;
 
733
   }
 
734
   retval = TRUE;
 
735
 
 
736
erret:
 
737
   AsnUnlinkType(orig);       /* unlink local tree */
 
738
   return retval;
 
739
}
 
740
 
 
741
 
 
742
 
 
743
/**************************************************
 
744
*
 
745
*    Cn3dGeneralStyleNew()
 
746
*
 
747
**************************************************/
 
748
NLM_EXTERN 
 
749
Cn3dGeneralStylePtr LIBCALL
 
750
Cn3dGeneralStyleNew(void)
 
751
{
 
752
   Cn3dGeneralStylePtr ptr = MemNew((size_t) sizeof(Cn3dGeneralStyle));
 
753
 
 
754
   return ptr;
 
755
 
 
756
}
 
757
 
 
758
 
 
759
/**************************************************
 
760
*
 
761
*    Cn3dGeneralStyleFree()
 
762
*
 
763
**************************************************/
 
764
NLM_EXTERN 
 
765
Cn3dGeneralStylePtr LIBCALL
 
766
Cn3dGeneralStyleFree(Cn3dGeneralStylePtr ptr)
 
767
{
 
768
 
 
769
   if(ptr == NULL) {
 
770
      return NULL;
 
771
   }
 
772
   Cn3dColorFree(ptr -> user_color);
 
773
   return MemFree(ptr);
 
774
}
 
775
 
 
776
 
 
777
/**************************************************
 
778
*
 
779
*    Cn3dGeneralStyleAsnRead()
 
780
*
 
781
**************************************************/
 
782
NLM_EXTERN 
 
783
Cn3dGeneralStylePtr LIBCALL
 
784
Cn3dGeneralStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
785
{
 
786
   DataVal av;
 
787
   AsnTypePtr atp;
 
788
   Boolean isError = FALSE;
 
789
   AsnReadFunc func;
 
790
   Cn3dGeneralStylePtr ptr;
 
791
 
 
792
   if (! loaded)
 
793
   {
 
794
      if (! objcn3dAsnLoad()) {
 
795
         return NULL;
 
796
      }
 
797
   }
 
798
 
 
799
   if (aip == NULL) {
 
800
      return NULL;
 
801
   }
 
802
 
 
803
   if (orig == NULL) {         /* Cn3dGeneralStyle ::= (self contained) */
 
804
      atp = AsnReadId(aip, amp, CN3D_GENERAL_STYLE);
 
805
   } else {
 
806
      atp = AsnLinkType(orig, CN3D_GENERAL_STYLE);
 
807
   }
 
808
   /* link in local tree */
 
809
   if (atp == NULL) {
 
810
      return NULL;
 
811
   }
 
812
 
 
813
   ptr = Cn3dGeneralStyleNew();
 
814
   if (ptr == NULL) {
 
815
      goto erret;
 
816
   }
 
817
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
818
      goto erret;
 
819
   }
 
820
 
 
821
   atp = AsnReadId(aip,amp, atp);
 
822
   func = NULL;
 
823
 
 
824
   if (atp == CN3D_GENERAL_STYLE_is_on) {
 
825
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
826
         goto erret;
 
827
      }
 
828
      ptr -> is_on = av.boolvalue;
 
829
      atp = AsnReadId(aip,amp, atp);
 
830
   }
 
831
   if (atp == CN3D_GENERAL_STYLE_style) {
 
832
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
833
         goto erret;
 
834
      }
 
835
      ptr -> style = av.intvalue;
 
836
      atp = AsnReadId(aip,amp, atp);
 
837
   }
 
838
   if (atp == CN3D_GENERAL_STYLE_color_scheme) {
 
839
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
840
         goto erret;
 
841
      }
 
842
      ptr -> color_scheme = av.intvalue;
 
843
      atp = AsnReadId(aip,amp, atp);
 
844
   }
 
845
   if (atp == CN3D_GENERAL_STYLE_user_color) {
 
846
      ptr -> user_color = Cn3dColorAsnRead(aip, atp);
 
847
      if (aip -> io_failure) {
 
848
         goto erret;
 
849
      }
 
850
      atp = AsnReadId(aip,amp, atp);
 
851
   }
 
852
 
 
853
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
854
      goto erret;
 
855
   }
 
856
   /* end struct */
 
857
 
 
858
ret:
 
859
   AsnUnlinkType(orig);       /* unlink local tree */
 
860
   return ptr;
 
861
 
 
862
erret:
 
863
   aip -> io_failure = TRUE;
 
864
   ptr = Cn3dGeneralStyleFree(ptr);
 
865
   goto ret;
 
866
}
 
867
 
 
868
 
 
869
 
 
870
/**************************************************
 
871
*
 
872
*    Cn3dGeneralStyleAsnWrite()
 
873
*
 
874
**************************************************/
 
875
NLM_EXTERN Boolean LIBCALL 
 
876
Cn3dGeneralStyleAsnWrite(Cn3dGeneralStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
877
{
 
878
   DataVal av;
 
879
   AsnTypePtr atp;
 
880
   Boolean retval = FALSE;
 
881
 
 
882
   if (! loaded)
 
883
   {
 
884
      if (! objcn3dAsnLoad()) {
 
885
         return FALSE;
 
886
      }
 
887
   }
 
888
 
 
889
   if (aip == NULL) {
 
890
      return FALSE;
 
891
   }
 
892
 
 
893
   atp = AsnLinkType(orig, CN3D_GENERAL_STYLE);   /* link local tree */
 
894
   if (atp == NULL) {
 
895
      return FALSE;
 
896
   }
 
897
 
 
898
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
899
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
900
      goto erret;
 
901
   }
 
902
 
 
903
   av.boolvalue = ptr -> is_on;
 
904
   retval = AsnWrite(aip, CN3D_GENERAL_STYLE_is_on,  &av);
 
905
   av.intvalue = ptr -> style;
 
906
   retval = AsnWrite(aip, CN3D_GENERAL_STYLE_style,  &av);
 
907
   av.intvalue = ptr -> color_scheme;
 
908
   retval = AsnWrite(aip, CN3D_GENERAL_STYLE_color_scheme,  &av);
 
909
   if (ptr -> user_color != NULL) {
 
910
      if ( ! Cn3dColorAsnWrite(ptr -> user_color, aip, CN3D_GENERAL_STYLE_user_color)) {
 
911
         goto erret;
 
912
      }
 
913
   }
 
914
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
915
      goto erret;
 
916
   }
 
917
   retval = TRUE;
 
918
 
 
919
erret:
 
920
   AsnUnlinkType(orig);       /* unlink local tree */
 
921
   return retval;
 
922
}
 
923
 
 
924
 
 
925
 
 
926
/**************************************************
 
927
*
 
928
*    Cn3dBackboneLabelStyleNew()
 
929
*
 
930
**************************************************/
 
931
NLM_EXTERN 
 
932
Cn3dBackboneLabelStylePtr LIBCALL
 
933
Cn3dBackboneLabelStyleNew(void)
 
934
{
 
935
   Cn3dBackboneLabelStylePtr ptr = MemNew((size_t) sizeof(Cn3dBackboneLabelStyle));
 
936
 
 
937
   return ptr;
 
938
 
 
939
}
 
940
 
 
941
 
 
942
/**************************************************
 
943
*
 
944
*    Cn3dBackboneLabelStyleFree()
 
945
*
 
946
**************************************************/
 
947
NLM_EXTERN 
 
948
Cn3dBackboneLabelStylePtr LIBCALL
 
949
Cn3dBackboneLabelStyleFree(Cn3dBackboneLabelStylePtr ptr)
 
950
{
 
951
 
 
952
   if(ptr == NULL) {
 
953
      return NULL;
 
954
   }
 
955
   return MemFree(ptr);
 
956
}
 
957
 
 
958
 
 
959
/**************************************************
 
960
*
 
961
*    Cn3dBackboneLabelStyleAsnRead()
 
962
*
 
963
**************************************************/
 
964
NLM_EXTERN 
 
965
Cn3dBackboneLabelStylePtr LIBCALL
 
966
Cn3dBackboneLabelStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
967
{
 
968
   DataVal av;
 
969
   AsnTypePtr atp;
 
970
   Boolean isError = FALSE;
 
971
   AsnReadFunc func;
 
972
   Cn3dBackboneLabelStylePtr ptr;
 
973
 
 
974
   if (! loaded)
 
975
   {
 
976
      if (! objcn3dAsnLoad()) {
 
977
         return NULL;
 
978
      }
 
979
   }
 
980
 
 
981
   if (aip == NULL) {
 
982
      return NULL;
 
983
   }
 
984
 
 
985
   if (orig == NULL) {         /* Cn3dBackboneLabelStyle ::= (self contained) */
 
986
      atp = AsnReadId(aip, amp, CN3D_BACKBONE_LABEL_STYLE);
 
987
   } else {
 
988
      atp = AsnLinkType(orig, CN3D_BACKBONE_LABEL_STYLE);
 
989
   }
 
990
   /* link in local tree */
 
991
   if (atp == NULL) {
 
992
      return NULL;
 
993
   }
 
994
 
 
995
   ptr = Cn3dBackboneLabelStyleNew();
 
996
   if (ptr == NULL) {
 
997
      goto erret;
 
998
   }
 
999
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
1000
      goto erret;
 
1001
   }
 
1002
 
 
1003
   atp = AsnReadId(aip,amp, atp);
 
1004
   func = NULL;
 
1005
 
 
1006
   if (atp == CN3D_BACKBONE_LABEL_STYLE_spacing) {
 
1007
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1008
         goto erret;
 
1009
      }
 
1010
      ptr -> spacing = av.intvalue;
 
1011
      atp = AsnReadId(aip,amp, atp);
 
1012
   }
 
1013
   if (atp == CN3D_BACKBONE_LABEL_STYLE_type) {
 
1014
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1015
         goto erret;
 
1016
      }
 
1017
      ptr -> type = av.intvalue;
 
1018
      atp = AsnReadId(aip,amp, atp);
 
1019
   }
 
1020
   if (atp == CN3D_BACKBONE_LABEL_STYLE_number) {
 
1021
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1022
         goto erret;
 
1023
      }
 
1024
      ptr -> number = av.intvalue;
 
1025
      atp = AsnReadId(aip,amp, atp);
 
1026
   }
 
1027
   if (atp == CN3D_BACKBONE_LABEL_STYLE_termini) {
 
1028
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1029
         goto erret;
 
1030
      }
 
1031
      ptr -> termini = av.boolvalue;
 
1032
      atp = AsnReadId(aip,amp, atp);
 
1033
   }
 
1034
   if (atp == CN3D_BACKBONE_LABEL_STYLE_white) {
 
1035
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1036
         goto erret;
 
1037
      }
 
1038
      ptr -> white = av.boolvalue;
 
1039
      atp = AsnReadId(aip,amp, atp);
 
1040
   }
 
1041
 
 
1042
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
1043
      goto erret;
 
1044
   }
 
1045
   /* end struct */
 
1046
 
 
1047
ret:
 
1048
   AsnUnlinkType(orig);       /* unlink local tree */
 
1049
   return ptr;
 
1050
 
 
1051
erret:
 
1052
   aip -> io_failure = TRUE;
 
1053
   ptr = Cn3dBackboneLabelStyleFree(ptr);
 
1054
   goto ret;
 
1055
}
 
1056
 
 
1057
 
 
1058
 
 
1059
/**************************************************
 
1060
*
 
1061
*    Cn3dBackboneLabelStyleAsnWrite()
 
1062
*
 
1063
**************************************************/
 
1064
NLM_EXTERN Boolean LIBCALL 
 
1065
Cn3dBackboneLabelStyleAsnWrite(Cn3dBackboneLabelStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
1066
{
 
1067
   DataVal av;
 
1068
   AsnTypePtr atp;
 
1069
   Boolean retval = FALSE;
 
1070
 
 
1071
   if (! loaded)
 
1072
   {
 
1073
      if (! objcn3dAsnLoad()) {
 
1074
         return FALSE;
 
1075
      }
 
1076
   }
 
1077
 
 
1078
   if (aip == NULL) {
 
1079
      return FALSE;
 
1080
   }
 
1081
 
 
1082
   atp = AsnLinkType(orig, CN3D_BACKBONE_LABEL_STYLE);   /* link local tree */
 
1083
   if (atp == NULL) {
 
1084
      return FALSE;
 
1085
   }
 
1086
 
 
1087
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
1088
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
1089
      goto erret;
 
1090
   }
 
1091
 
 
1092
   av.intvalue = ptr -> spacing;
 
1093
   retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_spacing,  &av);
 
1094
   av.intvalue = ptr -> type;
 
1095
   retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_type,  &av);
 
1096
   av.intvalue = ptr -> number;
 
1097
   retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_number,  &av);
 
1098
   av.boolvalue = ptr -> termini;
 
1099
   retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_termini,  &av);
 
1100
   av.boolvalue = ptr -> white;
 
1101
   retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_white,  &av);
 
1102
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
1103
      goto erret;
 
1104
   }
 
1105
   retval = TRUE;
 
1106
 
 
1107
erret:
 
1108
   AsnUnlinkType(orig);       /* unlink local tree */
 
1109
   return retval;
 
1110
}
 
1111
 
 
1112
 
 
1113
 
 
1114
/**************************************************
 
1115
*
 
1116
*    Cn3dStyleSettingsNew()
 
1117
*
 
1118
**************************************************/
 
1119
NLM_EXTERN 
 
1120
Cn3dStyleSettingsPtr LIBCALL
 
1121
Cn3dStyleSettingsNew(void)
 
1122
{
 
1123
   Cn3dStyleSettingsPtr ptr = MemNew((size_t) sizeof(Cn3dStyleSettings));
 
1124
 
 
1125
   return ptr;
 
1126
 
 
1127
}
 
1128
 
 
1129
 
 
1130
/**************************************************
 
1131
*
 
1132
*    Cn3dStyleSettingsFree()
 
1133
*
 
1134
**************************************************/
 
1135
NLM_EXTERN 
 
1136
Cn3dStyleSettingsPtr LIBCALL
 
1137
Cn3dStyleSettingsFree(Cn3dStyleSettingsPtr ptr)
 
1138
{
 
1139
 
 
1140
   if(ptr == NULL) {
 
1141
      return NULL;
 
1142
   }
 
1143
   MemFree(ptr -> name);
 
1144
   Cn3dBackboneStyleFree(ptr -> protein_backbone);
 
1145
   Cn3dBackboneStyleFree(ptr -> nucleotide_backbone);
 
1146
   Cn3dGeneralStyleFree(ptr -> protein_sidechains);
 
1147
   Cn3dGeneralStyleFree(ptr -> nucleotide_sidechains);
 
1148
   Cn3dGeneralStyleFree(ptr -> heterogens);
 
1149
   Cn3dGeneralStyleFree(ptr -> solvents);
 
1150
   Cn3dGeneralStyleFree(ptr -> connections);
 
1151
   Cn3dGeneralStyleFree(ptr -> helix_objects);
 
1152
   Cn3dGeneralStyleFree(ptr -> strand_objects);
 
1153
   Cn3dColorFree(ptr -> virtual_disulfide_color);
 
1154
   Cn3dColorFree(ptr -> background_color);
 
1155
   Cn3dBackboneLabelStyleFree(ptr -> protein_labels);
 
1156
   Cn3dBackboneLabelStyleFree(ptr -> nucleotide_labels);
 
1157
   return MemFree(ptr);
 
1158
}
 
1159
 
 
1160
 
 
1161
/**************************************************
 
1162
*
 
1163
*    Cn3dStyleSettingsAsnRead()
 
1164
*
 
1165
**************************************************/
 
1166
NLM_EXTERN 
 
1167
Cn3dStyleSettingsPtr LIBCALL
 
1168
Cn3dStyleSettingsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
1169
{
 
1170
   DataVal av;
 
1171
   AsnTypePtr atp;
 
1172
   Boolean isError = FALSE;
 
1173
   AsnReadFunc func;
 
1174
   Cn3dStyleSettingsPtr ptr;
 
1175
 
 
1176
   if (! loaded)
 
1177
   {
 
1178
      if (! objcn3dAsnLoad()) {
 
1179
         return NULL;
 
1180
      }
 
1181
   }
 
1182
 
 
1183
   if (aip == NULL) {
 
1184
      return NULL;
 
1185
   }
 
1186
 
 
1187
   if (orig == NULL) {         /* Cn3dStyleSettings ::= (self contained) */
 
1188
      atp = AsnReadId(aip, amp, CN3D_STYLE_SETTINGS);
 
1189
   } else {
 
1190
      atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS);
 
1191
   }
 
1192
   /* link in local tree */
 
1193
   if (atp == NULL) {
 
1194
      return NULL;
 
1195
   }
 
1196
 
 
1197
   ptr = Cn3dStyleSettingsNew();
 
1198
   if (ptr == NULL) {
 
1199
      goto erret;
 
1200
   }
 
1201
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
1202
      goto erret;
 
1203
   }
 
1204
 
 
1205
   atp = AsnReadId(aip,amp, atp);
 
1206
   func = NULL;
 
1207
 
 
1208
   if (atp == CN3D_STYLE_SETTINGS_name) {
 
1209
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1210
         goto erret;
 
1211
      }
 
1212
      ptr -> name = av.ptrvalue;
 
1213
      atp = AsnReadId(aip,amp, atp);
 
1214
   }
 
1215
   if (atp == CN3D_STYLE_SETTINGS_protein_backbone) {
 
1216
      ptr -> protein_backbone = Cn3dBackboneStyleAsnRead(aip, atp);
 
1217
      if (aip -> io_failure) {
 
1218
         goto erret;
 
1219
      }
 
1220
      atp = AsnReadId(aip,amp, atp);
 
1221
   }
 
1222
   if (atp == CN3D_STYLE_SETTINGS_nucleotide_backbone) {
 
1223
      ptr -> nucleotide_backbone = Cn3dBackboneStyleAsnRead(aip, atp);
 
1224
      if (aip -> io_failure) {
 
1225
         goto erret;
 
1226
      }
 
1227
      atp = AsnReadId(aip,amp, atp);
 
1228
   }
 
1229
   if (atp == CN3D_STYLE_SETTINGS_protein_sidechains) {
 
1230
      ptr -> protein_sidechains = Cn3dGeneralStyleAsnRead(aip, atp);
 
1231
      if (aip -> io_failure) {
 
1232
         goto erret;
 
1233
      }
 
1234
      atp = AsnReadId(aip,amp, atp);
 
1235
   }
 
1236
   if (atp == CN3D_STYLE_SETTINGS_nucleotide_sidechains) {
 
1237
      ptr -> nucleotide_sidechains = Cn3dGeneralStyleAsnRead(aip, atp);
 
1238
      if (aip -> io_failure) {
 
1239
         goto erret;
 
1240
      }
 
1241
      atp = AsnReadId(aip,amp, atp);
 
1242
   }
 
1243
   if (atp == CN3D_STYLE_SETTINGS_heterogens) {
 
1244
      ptr -> heterogens = Cn3dGeneralStyleAsnRead(aip, atp);
 
1245
      if (aip -> io_failure) {
 
1246
         goto erret;
 
1247
      }
 
1248
      atp = AsnReadId(aip,amp, atp);
 
1249
   }
 
1250
   if (atp == CN3D_STYLE_SETTINGS_solvents) {
 
1251
      ptr -> solvents = Cn3dGeneralStyleAsnRead(aip, atp);
 
1252
      if (aip -> io_failure) {
 
1253
         goto erret;
 
1254
      }
 
1255
      atp = AsnReadId(aip,amp, atp);
 
1256
   }
 
1257
   if (atp == CN3D_STYLE_SETTINGS_connections) {
 
1258
      ptr -> connections = Cn3dGeneralStyleAsnRead(aip, atp);
 
1259
      if (aip -> io_failure) {
 
1260
         goto erret;
 
1261
      }
 
1262
      atp = AsnReadId(aip,amp, atp);
 
1263
   }
 
1264
   if (atp == CN3D_STYLE_SETTINGS_helix_objects) {
 
1265
      ptr -> helix_objects = Cn3dGeneralStyleAsnRead(aip, atp);
 
1266
      if (aip -> io_failure) {
 
1267
         goto erret;
 
1268
      }
 
1269
      atp = AsnReadId(aip,amp, atp);
 
1270
   }
 
1271
   if (atp == CN3D_STYLE_SETTINGS_strand_objects) {
 
1272
      ptr -> strand_objects = Cn3dGeneralStyleAsnRead(aip, atp);
 
1273
      if (aip -> io_failure) {
 
1274
         goto erret;
 
1275
      }
 
1276
      atp = AsnReadId(aip,amp, atp);
 
1277
   }
 
1278
   if (atp == CN3D_STYLE_SETTINGS_virtual_disulfides_on) {
 
1279
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1280
         goto erret;
 
1281
      }
 
1282
      ptr -> virtual_disulfides_on = av.boolvalue;
 
1283
      atp = AsnReadId(aip,amp, atp);
 
1284
   }
 
1285
   if (atp == CN3D_STYLE_SETTINGS_virtual_disulfide_color) {
 
1286
      ptr -> virtual_disulfide_color = Cn3dColorAsnRead(aip, atp);
 
1287
      if (aip -> io_failure) {
 
1288
         goto erret;
 
1289
      }
 
1290
      atp = AsnReadId(aip,amp, atp);
 
1291
   }
 
1292
   if (atp == CN3D_STYLE_SETTINGS_hydrogens_on) {
 
1293
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1294
         goto erret;
 
1295
      }
 
1296
      ptr -> hydrogens_on = av.boolvalue;
 
1297
      atp = AsnReadId(aip,amp, atp);
 
1298
   }
 
1299
   if (atp == CN3D_STYLE_SETTINGS_background_color) {
 
1300
      ptr -> background_color = Cn3dColorAsnRead(aip, atp);
 
1301
      if (aip -> io_failure) {
 
1302
         goto erret;
 
1303
      }
 
1304
      atp = AsnReadId(aip,amp, atp);
 
1305
   }
 
1306
   if (atp == CN3D_STYLE_SETTINGS_scale_factor) {
 
1307
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1308
         goto erret;
 
1309
      }
 
1310
      ptr -> scale_factor = av.intvalue;
 
1311
      atp = AsnReadId(aip,amp, atp);
 
1312
   }
 
1313
   if (atp == CN3D_STYLE_SETTINGS_space_fill_proportion) {
 
1314
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1315
         goto erret;
 
1316
      }
 
1317
      ptr -> space_fill_proportion = av.intvalue;
 
1318
      atp = AsnReadId(aip,amp, atp);
 
1319
   }
 
1320
   if (atp == CN3D_STYLE_SETTINGS_ball_radius) {
 
1321
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1322
         goto erret;
 
1323
      }
 
1324
      ptr -> ball_radius = av.intvalue;
 
1325
      atp = AsnReadId(aip,amp, atp);
 
1326
   }
 
1327
   if (atp == CN3D_STYLE_SETTINGS_stick_radius) {
 
1328
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1329
         goto erret;
 
1330
      }
 
1331
      ptr -> stick_radius = av.intvalue;
 
1332
      atp = AsnReadId(aip,amp, atp);
 
1333
   }
 
1334
   if (atp == CN3D_STYLE_SETTINGS_tube_radius) {
 
1335
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1336
         goto erret;
 
1337
      }
 
1338
      ptr -> tube_radius = av.intvalue;
 
1339
      atp = AsnReadId(aip,amp, atp);
 
1340
   }
 
1341
   if (atp == CN3D_STYLE_SETTINGS_tube_worm_radius) {
 
1342
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1343
         goto erret;
 
1344
      }
 
1345
      ptr -> tube_worm_radius = av.intvalue;
 
1346
      atp = AsnReadId(aip,amp, atp);
 
1347
   }
 
1348
   if (atp == CN3D_STYLE_SETTINGS_helix_radius) {
 
1349
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1350
         goto erret;
 
1351
      }
 
1352
      ptr -> helix_radius = av.intvalue;
 
1353
      atp = AsnReadId(aip,amp, atp);
 
1354
   }
 
1355
   if (atp == CN3D_STYLE_SETTINGS_strand_width) {
 
1356
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1357
         goto erret;
 
1358
      }
 
1359
      ptr -> strand_width = av.intvalue;
 
1360
      atp = AsnReadId(aip,amp, atp);
 
1361
   }
 
1362
   if (atp == CN3D_STYLE_SETTINGS_strand_thickness) {
 
1363
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1364
         goto erret;
 
1365
      }
 
1366
      ptr -> strand_thickness = av.intvalue;
 
1367
      atp = AsnReadId(aip,amp, atp);
 
1368
   }
 
1369
   if (atp == CN3D_STYLE_SETTINGS_protein_labels) {
 
1370
      ptr -> protein_labels = Cn3dBackboneLabelStyleAsnRead(aip, atp);
 
1371
      if (aip -> io_failure) {
 
1372
         goto erret;
 
1373
      }
 
1374
      atp = AsnReadId(aip,amp, atp);
 
1375
   }
 
1376
   if (atp == CN3D_STYLE_SETTINGS_nucleotide_labels) {
 
1377
      ptr -> nucleotide_labels = Cn3dBackboneLabelStyleAsnRead(aip, atp);
 
1378
      if (aip -> io_failure) {
 
1379
         goto erret;
 
1380
      }
 
1381
      atp = AsnReadId(aip,amp, atp);
 
1382
   }
 
1383
   if (atp == CN3D_STYLE_SETTINGS_ion_labels) {
 
1384
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1385
         goto erret;
 
1386
      }
 
1387
      ptr -> ion_labels = av.boolvalue;
 
1388
      atp = AsnReadId(aip,amp, atp);
 
1389
   }
 
1390
 
 
1391
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
1392
      goto erret;
 
1393
   }
 
1394
   /* end struct */
 
1395
 
 
1396
ret:
 
1397
   AsnUnlinkType(orig);       /* unlink local tree */
 
1398
   return ptr;
 
1399
 
 
1400
erret:
 
1401
   aip -> io_failure = TRUE;
 
1402
   ptr = Cn3dStyleSettingsFree(ptr);
 
1403
   goto ret;
 
1404
}
 
1405
 
 
1406
 
 
1407
 
 
1408
/**************************************************
 
1409
*
 
1410
*    Cn3dStyleSettingsAsnWrite()
 
1411
*
 
1412
**************************************************/
 
1413
NLM_EXTERN Boolean LIBCALL 
 
1414
Cn3dStyleSettingsAsnWrite(Cn3dStyleSettingsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
1415
{
 
1416
   DataVal av;
 
1417
   AsnTypePtr atp;
 
1418
   Boolean retval = FALSE;
 
1419
 
 
1420
   if (! loaded)
 
1421
   {
 
1422
      if (! objcn3dAsnLoad()) {
 
1423
         return FALSE;
 
1424
      }
 
1425
   }
 
1426
 
 
1427
   if (aip == NULL) {
 
1428
      return FALSE;
 
1429
   }
 
1430
 
 
1431
   atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS);   /* link local tree */
 
1432
   if (atp == NULL) {
 
1433
      return FALSE;
 
1434
   }
 
1435
 
 
1436
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
1437
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
1438
      goto erret;
 
1439
   }
 
1440
 
 
1441
   if (ptr -> name != NULL) {
 
1442
      av.ptrvalue = ptr -> name;
 
1443
      retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_name,  &av);
 
1444
   }
 
1445
   if (ptr -> protein_backbone != NULL) {
 
1446
      if ( ! Cn3dBackboneStyleAsnWrite(ptr -> protein_backbone, aip, CN3D_STYLE_SETTINGS_protein_backbone)) {
 
1447
         goto erret;
 
1448
      }
 
1449
   }
 
1450
   if (ptr -> nucleotide_backbone != NULL) {
 
1451
      if ( ! Cn3dBackboneStyleAsnWrite(ptr -> nucleotide_backbone, aip, CN3D_STYLE_SETTINGS_nucleotide_backbone)) {
 
1452
         goto erret;
 
1453
      }
 
1454
   }
 
1455
   if (ptr -> protein_sidechains != NULL) {
 
1456
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> protein_sidechains, aip, CN3D_STYLE_SETTINGS_protein_sidechains)) {
 
1457
         goto erret;
 
1458
      }
 
1459
   }
 
1460
   if (ptr -> nucleotide_sidechains != NULL) {
 
1461
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> nucleotide_sidechains, aip, CN3D_STYLE_SETTINGS_nucleotide_sidechains)) {
 
1462
         goto erret;
 
1463
      }
 
1464
   }
 
1465
   if (ptr -> heterogens != NULL) {
 
1466
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> heterogens, aip, CN3D_STYLE_SETTINGS_heterogens)) {
 
1467
         goto erret;
 
1468
      }
 
1469
   }
 
1470
   if (ptr -> solvents != NULL) {
 
1471
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> solvents, aip, CN3D_STYLE_SETTINGS_solvents)) {
 
1472
         goto erret;
 
1473
      }
 
1474
   }
 
1475
   if (ptr -> connections != NULL) {
 
1476
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> connections, aip, CN3D_STYLE_SETTINGS_connections)) {
 
1477
         goto erret;
 
1478
      }
 
1479
   }
 
1480
   if (ptr -> helix_objects != NULL) {
 
1481
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> helix_objects, aip, CN3D_STYLE_SETTINGS_helix_objects)) {
 
1482
         goto erret;
 
1483
      }
 
1484
   }
 
1485
   if (ptr -> strand_objects != NULL) {
 
1486
      if ( ! Cn3dGeneralStyleAsnWrite(ptr -> strand_objects, aip, CN3D_STYLE_SETTINGS_strand_objects)) {
 
1487
         goto erret;
 
1488
      }
 
1489
   }
 
1490
   av.boolvalue = ptr -> virtual_disulfides_on;
 
1491
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_virtual_disulfides_on,  &av);
 
1492
   if (ptr -> virtual_disulfide_color != NULL) {
 
1493
      if ( ! Cn3dColorAsnWrite(ptr -> virtual_disulfide_color, aip, CN3D_STYLE_SETTINGS_virtual_disulfide_color)) {
 
1494
         goto erret;
 
1495
      }
 
1496
   }
 
1497
   av.boolvalue = ptr -> hydrogens_on;
 
1498
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_hydrogens_on,  &av);
 
1499
   if (ptr -> background_color != NULL) {
 
1500
      if ( ! Cn3dColorAsnWrite(ptr -> background_color, aip, CN3D_STYLE_SETTINGS_background_color)) {
 
1501
         goto erret;
 
1502
      }
 
1503
   }
 
1504
   av.intvalue = ptr -> scale_factor;
 
1505
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_scale_factor,  &av);
 
1506
   av.intvalue = ptr -> space_fill_proportion;
 
1507
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_space_fill_proportion,  &av);
 
1508
   av.intvalue = ptr -> ball_radius;
 
1509
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_ball_radius,  &av);
 
1510
   av.intvalue = ptr -> stick_radius;
 
1511
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_stick_radius,  &av);
 
1512
   av.intvalue = ptr -> tube_radius;
 
1513
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_tube_radius,  &av);
 
1514
   av.intvalue = ptr -> tube_worm_radius;
 
1515
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_tube_worm_radius,  &av);
 
1516
   av.intvalue = ptr -> helix_radius;
 
1517
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_helix_radius,  &av);
 
1518
   av.intvalue = ptr -> strand_width;
 
1519
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_strand_width,  &av);
 
1520
   av.intvalue = ptr -> strand_thickness;
 
1521
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_strand_thickness,  &av);
 
1522
   if (ptr -> protein_labels != NULL) {
 
1523
      if ( ! Cn3dBackboneLabelStyleAsnWrite(ptr -> protein_labels, aip, CN3D_STYLE_SETTINGS_protein_labels)) {
 
1524
         goto erret;
 
1525
      }
 
1526
   }
 
1527
   if (ptr -> nucleotide_labels != NULL) {
 
1528
      if ( ! Cn3dBackboneLabelStyleAsnWrite(ptr -> nucleotide_labels, aip, CN3D_STYLE_SETTINGS_nucleotide_labels)) {
 
1529
         goto erret;
 
1530
      }
 
1531
   }
 
1532
   av.boolvalue = ptr -> ion_labels;
 
1533
   retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_ion_labels,  &av);
 
1534
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
1535
      goto erret;
 
1536
   }
 
1537
   retval = TRUE;
 
1538
 
 
1539
erret:
 
1540
   AsnUnlinkType(orig);       /* unlink local tree */
 
1541
   return retval;
 
1542
}
 
1543
 
 
1544
 
 
1545
 
 
1546
/**************************************************
 
1547
*
 
1548
*    Cn3dStyleSettingsSetFree()
 
1549
*
 
1550
**************************************************/
 
1551
NLM_EXTERN 
 
1552
Cn3dStyleSettingsSetPtr LIBCALL
 
1553
Cn3dStyleSettingsSetFree(Cn3dStyleSettingsSetPtr ptr)
 
1554
{
 
1555
 
 
1556
   if(ptr == NULL) {
 
1557
      return NULL;
 
1558
   }
 
1559
   AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) Cn3dStyleSettingsFree);
 
1560
   return NULL;
 
1561
}
 
1562
 
 
1563
 
 
1564
/**************************************************
 
1565
*
 
1566
*    Cn3dStyleSettingsSetAsnRead()
 
1567
*
 
1568
**************************************************/
 
1569
NLM_EXTERN 
 
1570
Cn3dStyleSettingsSetPtr LIBCALL
 
1571
Cn3dStyleSettingsSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
1572
{
 
1573
   DataVal av;
 
1574
   AsnTypePtr atp;
 
1575
   Boolean isError = FALSE;
 
1576
   AsnReadFunc func;
 
1577
   Cn3dStyleSettingsSetPtr ptr;
 
1578
 
 
1579
   if (! loaded)
 
1580
   {
 
1581
      if (! objcn3dAsnLoad()) {
 
1582
         return NULL;
 
1583
      }
 
1584
   }
 
1585
 
 
1586
   if (aip == NULL) {
 
1587
      return NULL;
 
1588
   }
 
1589
 
 
1590
   if (orig == NULL) {         /* Cn3dStyleSettingsSet ::= (self contained) */
 
1591
      atp = AsnReadId(aip, amp, CN3D_STYLE_SETTINGS_SET);
 
1592
   } else {
 
1593
      atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS_SET);
 
1594
   }
 
1595
   /* link in local tree */
 
1596
   if (atp == NULL) {
 
1597
      return NULL;
 
1598
   }
 
1599
 
 
1600
   func = NULL;
 
1601
 
 
1602
   ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dStyleSettingsAsnRead, (AsnOptFreeFunc) Cn3dStyleSettingsFree);
 
1603
   if (isError && ptr  == NULL) {
 
1604
      goto erret;
 
1605
   }
 
1606
 
 
1607
 
 
1608
 
 
1609
ret:
 
1610
   AsnUnlinkType(orig);       /* unlink local tree */
 
1611
   return ptr;
 
1612
 
 
1613
erret:
 
1614
   aip -> io_failure = TRUE;
 
1615
   ptr = Cn3dStyleSettingsSetFree(ptr);
 
1616
   goto ret;
 
1617
}
 
1618
 
 
1619
 
 
1620
 
 
1621
/**************************************************
 
1622
*
 
1623
*    Cn3dStyleSettingsSetAsnWrite()
 
1624
*
 
1625
**************************************************/
 
1626
NLM_EXTERN Boolean LIBCALL 
 
1627
Cn3dStyleSettingsSetAsnWrite(Cn3dStyleSettingsSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
1628
{
 
1629
   DataVal av;
 
1630
   AsnTypePtr atp;
 
1631
   Boolean retval = FALSE;
 
1632
 
 
1633
   if (! loaded)
 
1634
   {
 
1635
      if (! objcn3dAsnLoad()) {
 
1636
         return FALSE;
 
1637
      }
 
1638
   }
 
1639
 
 
1640
   if (aip == NULL) {
 
1641
      return FALSE;
 
1642
   }
 
1643
 
 
1644
   atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS_SET);   /* link local tree */
 
1645
   if (atp == NULL) {
 
1646
      return FALSE;
 
1647
   }
 
1648
 
 
1649
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
1650
   retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) Cn3dStyleSettingsAsnWrite, aip, atp, CN3D_STYLE_SETTINGS_SET_E);
 
1651
   retval = TRUE;
 
1652
 
 
1653
erret:
 
1654
   AsnUnlinkType(orig);       /* unlink local tree */
 
1655
   return retval;
 
1656
}
 
1657
 
 
1658
 
 
1659
 
 
1660
/**************************************************
 
1661
*
 
1662
*    Cn3dStyleTableItemNew()
 
1663
*
 
1664
**************************************************/
 
1665
NLM_EXTERN 
 
1666
Cn3dStyleTableItemPtr LIBCALL
 
1667
Cn3dStyleTableItemNew(void)
 
1668
{
 
1669
   Cn3dStyleTableItemPtr ptr = MemNew((size_t) sizeof(Cn3dStyleTableItem));
 
1670
 
 
1671
   return ptr;
 
1672
 
 
1673
}
 
1674
 
 
1675
 
 
1676
/**************************************************
 
1677
*
 
1678
*    Cn3dStyleTableItemFree()
 
1679
*
 
1680
**************************************************/
 
1681
NLM_EXTERN 
 
1682
Cn3dStyleTableItemPtr LIBCALL
 
1683
Cn3dStyleTableItemFree(Cn3dStyleTableItemPtr ptr)
 
1684
{
 
1685
 
 
1686
   if(ptr == NULL) {
 
1687
      return NULL;
 
1688
   }
 
1689
   Cn3dStyleSettingsFree(ptr -> style);
 
1690
   return MemFree(ptr);
 
1691
}
 
1692
 
 
1693
 
 
1694
/**************************************************
 
1695
*
 
1696
*    Cn3dStyleTableItemAsnRead()
 
1697
*
 
1698
**************************************************/
 
1699
NLM_EXTERN 
 
1700
Cn3dStyleTableItemPtr LIBCALL
 
1701
Cn3dStyleTableItemAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
1702
{
 
1703
   DataVal av;
 
1704
   AsnTypePtr atp;
 
1705
   Boolean isError = FALSE;
 
1706
   AsnReadFunc func;
 
1707
   Cn3dStyleTableItemPtr ptr;
 
1708
 
 
1709
   if (! loaded)
 
1710
   {
 
1711
      if (! objcn3dAsnLoad()) {
 
1712
         return NULL;
 
1713
      }
 
1714
   }
 
1715
 
 
1716
   if (aip == NULL) {
 
1717
      return NULL;
 
1718
   }
 
1719
 
 
1720
   if (orig == NULL) {         /* Cn3dStyleTableItem ::= (self contained) */
 
1721
      atp = AsnReadId(aip, amp, CN3D_STYLE_TABLE_ITEM);
 
1722
   } else {
 
1723
      atp = AsnLinkType(orig, CN3D_STYLE_TABLE_ITEM);
 
1724
   }
 
1725
   /* link in local tree */
 
1726
   if (atp == NULL) {
 
1727
      return NULL;
 
1728
   }
 
1729
 
 
1730
   ptr = Cn3dStyleTableItemNew();
 
1731
   if (ptr == NULL) {
 
1732
      goto erret;
 
1733
   }
 
1734
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
1735
      goto erret;
 
1736
   }
 
1737
 
 
1738
   atp = AsnReadId(aip,amp, atp);
 
1739
   func = NULL;
 
1740
 
 
1741
   if (atp == CN3D_STYLE_TABLE_ITEM_id) {
 
1742
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1743
         goto erret;
 
1744
      }
 
1745
      ptr -> id = av.intvalue;
 
1746
      atp = AsnReadId(aip,amp, atp);
 
1747
   }
 
1748
   if (atp == CN3D_STYLE_TABLE_ITEM_style) {
 
1749
      ptr -> style = Cn3dStyleSettingsAsnRead(aip, atp);
 
1750
      if (aip -> io_failure) {
 
1751
         goto erret;
 
1752
      }
 
1753
      atp = AsnReadId(aip,amp, atp);
 
1754
   }
 
1755
 
 
1756
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
1757
      goto erret;
 
1758
   }
 
1759
   /* end struct */
 
1760
 
 
1761
ret:
 
1762
   AsnUnlinkType(orig);       /* unlink local tree */
 
1763
   return ptr;
 
1764
 
 
1765
erret:
 
1766
   aip -> io_failure = TRUE;
 
1767
   ptr = Cn3dStyleTableItemFree(ptr);
 
1768
   goto ret;
 
1769
}
 
1770
 
 
1771
 
 
1772
 
 
1773
/**************************************************
 
1774
*
 
1775
*    Cn3dStyleTableItemAsnWrite()
 
1776
*
 
1777
**************************************************/
 
1778
NLM_EXTERN Boolean LIBCALL 
 
1779
Cn3dStyleTableItemAsnWrite(Cn3dStyleTableItemPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
1780
{
 
1781
   DataVal av;
 
1782
   AsnTypePtr atp;
 
1783
   Boolean retval = FALSE;
 
1784
 
 
1785
   if (! loaded)
 
1786
   {
 
1787
      if (! objcn3dAsnLoad()) {
 
1788
         return FALSE;
 
1789
      }
 
1790
   }
 
1791
 
 
1792
   if (aip == NULL) {
 
1793
      return FALSE;
 
1794
   }
 
1795
 
 
1796
   atp = AsnLinkType(orig, CN3D_STYLE_TABLE_ITEM);   /* link local tree */
 
1797
   if (atp == NULL) {
 
1798
      return FALSE;
 
1799
   }
 
1800
 
 
1801
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
1802
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
1803
      goto erret;
 
1804
   }
 
1805
 
 
1806
   av.intvalue = ptr -> id;
 
1807
   retval = AsnWrite(aip, CN3D_STYLE_TABLE_ITEM_id,  &av);
 
1808
   if (ptr -> style != NULL) {
 
1809
      if ( ! Cn3dStyleSettingsAsnWrite(ptr -> style, aip, CN3D_STYLE_TABLE_ITEM_style)) {
 
1810
         goto erret;
 
1811
      }
 
1812
   }
 
1813
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
1814
      goto erret;
 
1815
   }
 
1816
   retval = TRUE;
 
1817
 
 
1818
erret:
 
1819
   AsnUnlinkType(orig);       /* unlink local tree */
 
1820
   return retval;
 
1821
}
 
1822
 
 
1823
 
 
1824
 
 
1825
/**************************************************
 
1826
*
 
1827
*    Cn3dResidueRangeNew()
 
1828
*
 
1829
**************************************************/
 
1830
NLM_EXTERN 
 
1831
Cn3dResidueRangePtr LIBCALL
 
1832
Cn3dResidueRangeNew(void)
 
1833
{
 
1834
   Cn3dResidueRangePtr ptr = MemNew((size_t) sizeof(Cn3dResidueRange));
 
1835
 
 
1836
   return ptr;
 
1837
 
 
1838
}
 
1839
 
 
1840
 
 
1841
/**************************************************
 
1842
*
 
1843
*    Cn3dResidueRangeFree()
 
1844
*
 
1845
**************************************************/
 
1846
NLM_EXTERN 
 
1847
Cn3dResidueRangePtr LIBCALL
 
1848
Cn3dResidueRangeFree(Cn3dResidueRangePtr ptr)
 
1849
{
 
1850
 
 
1851
   if(ptr == NULL) {
 
1852
      return NULL;
 
1853
   }
 
1854
   return MemFree(ptr);
 
1855
}
 
1856
 
 
1857
 
 
1858
/**************************************************
 
1859
*
 
1860
*    Cn3dResidueRangeAsnRead()
 
1861
*
 
1862
**************************************************/
 
1863
NLM_EXTERN 
 
1864
Cn3dResidueRangePtr LIBCALL
 
1865
Cn3dResidueRangeAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
1866
{
 
1867
   DataVal av;
 
1868
   AsnTypePtr atp;
 
1869
   Boolean isError = FALSE;
 
1870
   AsnReadFunc func;
 
1871
   Cn3dResidueRangePtr ptr;
 
1872
 
 
1873
   if (! loaded)
 
1874
   {
 
1875
      if (! objcn3dAsnLoad()) {
 
1876
         return NULL;
 
1877
      }
 
1878
   }
 
1879
 
 
1880
   if (aip == NULL) {
 
1881
      return NULL;
 
1882
   }
 
1883
 
 
1884
   if (orig == NULL) {         /* Cn3dResidueRange ::= (self contained) */
 
1885
      atp = AsnReadId(aip, amp, CN3D_RESIDUE_RANGE);
 
1886
   } else {
 
1887
      atp = AsnLinkType(orig, CN3D_RESIDUE_RANGE);
 
1888
   }
 
1889
   /* link in local tree */
 
1890
   if (atp == NULL) {
 
1891
      return NULL;
 
1892
   }
 
1893
 
 
1894
   ptr = Cn3dResidueRangeNew();
 
1895
   if (ptr == NULL) {
 
1896
      goto erret;
 
1897
   }
 
1898
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
1899
      goto erret;
 
1900
   }
 
1901
 
 
1902
   atp = AsnReadId(aip,amp, atp);
 
1903
   func = NULL;
 
1904
 
 
1905
   if (atp == CN3D_RESIDUE_RANGE_from) {
 
1906
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1907
         goto erret;
 
1908
      }
 
1909
      ptr -> from = av.intvalue;
 
1910
      atp = AsnReadId(aip,amp, atp);
 
1911
   }
 
1912
   if (atp == CN3D_RESIDUE_RANGE_to) {
 
1913
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
1914
         goto erret;
 
1915
      }
 
1916
      ptr -> to = av.intvalue;
 
1917
      atp = AsnReadId(aip,amp, atp);
 
1918
   }
 
1919
 
 
1920
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
1921
      goto erret;
 
1922
   }
 
1923
   /* end struct */
 
1924
 
 
1925
ret:
 
1926
   AsnUnlinkType(orig);       /* unlink local tree */
 
1927
   return ptr;
 
1928
 
 
1929
erret:
 
1930
   aip -> io_failure = TRUE;
 
1931
   ptr = Cn3dResidueRangeFree(ptr);
 
1932
   goto ret;
 
1933
}
 
1934
 
 
1935
 
 
1936
 
 
1937
/**************************************************
 
1938
*
 
1939
*    Cn3dResidueRangeAsnWrite()
 
1940
*
 
1941
**************************************************/
 
1942
NLM_EXTERN Boolean LIBCALL 
 
1943
Cn3dResidueRangeAsnWrite(Cn3dResidueRangePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
1944
{
 
1945
   DataVal av;
 
1946
   AsnTypePtr atp;
 
1947
   Boolean retval = FALSE;
 
1948
 
 
1949
   if (! loaded)
 
1950
   {
 
1951
      if (! objcn3dAsnLoad()) {
 
1952
         return FALSE;
 
1953
      }
 
1954
   }
 
1955
 
 
1956
   if (aip == NULL) {
 
1957
      return FALSE;
 
1958
   }
 
1959
 
 
1960
   atp = AsnLinkType(orig, CN3D_RESIDUE_RANGE);   /* link local tree */
 
1961
   if (atp == NULL) {
 
1962
      return FALSE;
 
1963
   }
 
1964
 
 
1965
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
1966
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
1967
      goto erret;
 
1968
   }
 
1969
 
 
1970
   av.intvalue = ptr -> from;
 
1971
   retval = AsnWrite(aip, CN3D_RESIDUE_RANGE_from,  &av);
 
1972
   av.intvalue = ptr -> to;
 
1973
   retval = AsnWrite(aip, CN3D_RESIDUE_RANGE_to,  &av);
 
1974
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
1975
      goto erret;
 
1976
   }
 
1977
   retval = TRUE;
 
1978
 
 
1979
erret:
 
1980
   AsnUnlinkType(orig);       /* unlink local tree */
 
1981
   return retval;
 
1982
}
 
1983
 
 
1984
 
 
1985
 
 
1986
/**************************************************
 
1987
*
 
1988
*    Cn3dMoleculeLocationNew()
 
1989
*
 
1990
**************************************************/
 
1991
NLM_EXTERN 
 
1992
Cn3dMoleculeLocationPtr LIBCALL
 
1993
Cn3dMoleculeLocationNew(void)
 
1994
{
 
1995
   Cn3dMoleculeLocationPtr ptr = MemNew((size_t) sizeof(Cn3dMoleculeLocation));
 
1996
 
 
1997
   return ptr;
 
1998
 
 
1999
}
 
2000
 
 
2001
 
 
2002
/**************************************************
 
2003
*
 
2004
*    Cn3dMoleculeLocationFree()
 
2005
*
 
2006
**************************************************/
 
2007
NLM_EXTERN 
 
2008
Cn3dMoleculeLocationPtr LIBCALL
 
2009
Cn3dMoleculeLocationFree(Cn3dMoleculeLocationPtr ptr)
 
2010
{
 
2011
 
 
2012
   if(ptr == NULL) {
 
2013
      return NULL;
 
2014
   }
 
2015
   AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dResidueRangeFree);
 
2016
   return MemFree(ptr);
 
2017
}
 
2018
 
 
2019
 
 
2020
/**************************************************
 
2021
*
 
2022
*    Cn3dMoleculeLocationAsnRead()
 
2023
*
 
2024
**************************************************/
 
2025
NLM_EXTERN 
 
2026
Cn3dMoleculeLocationPtr LIBCALL
 
2027
Cn3dMoleculeLocationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2028
{
 
2029
   DataVal av;
 
2030
   AsnTypePtr atp;
 
2031
   Boolean isError = FALSE;
 
2032
   AsnReadFunc func;
 
2033
   Cn3dMoleculeLocationPtr ptr;
 
2034
 
 
2035
   if (! loaded)
 
2036
   {
 
2037
      if (! objcn3dAsnLoad()) {
 
2038
         return NULL;
 
2039
      }
 
2040
   }
 
2041
 
 
2042
   if (aip == NULL) {
 
2043
      return NULL;
 
2044
   }
 
2045
 
 
2046
   if (orig == NULL) {         /* Cn3dMoleculeLocation ::= (self contained) */
 
2047
      atp = AsnReadId(aip, amp, CN3D_MOLECULE_LOCATION);
 
2048
   } else {
 
2049
      atp = AsnLinkType(orig, CN3D_MOLECULE_LOCATION);
 
2050
   }
 
2051
   /* link in local tree */
 
2052
   if (atp == NULL) {
 
2053
      return NULL;
 
2054
   }
 
2055
 
 
2056
   ptr = Cn3dMoleculeLocationNew();
 
2057
   if (ptr == NULL) {
 
2058
      goto erret;
 
2059
   }
 
2060
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2061
      goto erret;
 
2062
   }
 
2063
 
 
2064
   atp = AsnReadId(aip,amp, atp);
 
2065
   func = NULL;
 
2066
 
 
2067
   if (atp == CN3D_MOLECULE_LOCATION_molecule_id) {
 
2068
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2069
         goto erret;
 
2070
      }
 
2071
      ptr -> molecule_id = av.intvalue;
 
2072
      atp = AsnReadId(aip,amp, atp);
 
2073
   }
 
2074
   if (atp == CN3D_MOLECULE_LOCATION_residues) {
 
2075
      ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dResidueRangeAsnRead, (AsnOptFreeFunc) Cn3dResidueRangeFree);
 
2076
      if (isError && ptr -> residues == NULL) {
 
2077
         goto erret;
 
2078
      }
 
2079
      atp = AsnReadId(aip,amp, atp);
 
2080
   }
 
2081
 
 
2082
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2083
      goto erret;
 
2084
   }
 
2085
   /* end struct */
 
2086
 
 
2087
ret:
 
2088
   AsnUnlinkType(orig);       /* unlink local tree */
 
2089
   return ptr;
 
2090
 
 
2091
erret:
 
2092
   aip -> io_failure = TRUE;
 
2093
   ptr = Cn3dMoleculeLocationFree(ptr);
 
2094
   goto ret;
 
2095
}
 
2096
 
 
2097
 
 
2098
 
 
2099
/**************************************************
 
2100
*
 
2101
*    Cn3dMoleculeLocationAsnWrite()
 
2102
*
 
2103
**************************************************/
 
2104
NLM_EXTERN Boolean LIBCALL 
 
2105
Cn3dMoleculeLocationAsnWrite(Cn3dMoleculeLocationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2106
{
 
2107
   DataVal av;
 
2108
   AsnTypePtr atp;
 
2109
   Boolean retval = FALSE;
 
2110
 
 
2111
   if (! loaded)
 
2112
   {
 
2113
      if (! objcn3dAsnLoad()) {
 
2114
         return FALSE;
 
2115
      }
 
2116
   }
 
2117
 
 
2118
   if (aip == NULL) {
 
2119
      return FALSE;
 
2120
   }
 
2121
 
 
2122
   atp = AsnLinkType(orig, CN3D_MOLECULE_LOCATION);   /* link local tree */
 
2123
   if (atp == NULL) {
 
2124
      return FALSE;
 
2125
   }
 
2126
 
 
2127
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2128
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2129
      goto erret;
 
2130
   }
 
2131
 
 
2132
   av.intvalue = ptr -> molecule_id;
 
2133
   retval = AsnWrite(aip, CN3D_MOLECULE_LOCATION_molecule_id,  &av);
 
2134
   AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dResidueRangeAsnWrite, aip, CN3D_MOLECULE_LOCATION_residues, CN3D_MOLECULE_LOCATION_residues_E);
 
2135
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2136
      goto erret;
 
2137
   }
 
2138
   retval = TRUE;
 
2139
 
 
2140
erret:
 
2141
   AsnUnlinkType(orig);       /* unlink local tree */
 
2142
   return retval;
 
2143
}
 
2144
 
 
2145
 
 
2146
 
 
2147
/**************************************************
 
2148
*
 
2149
*    Cn3dObjectLocationNew()
 
2150
*
 
2151
**************************************************/
 
2152
NLM_EXTERN 
 
2153
Cn3dObjectLocationPtr LIBCALL
 
2154
Cn3dObjectLocationNew(void)
 
2155
{
 
2156
   Cn3dObjectLocationPtr ptr = MemNew((size_t) sizeof(Cn3dObjectLocation));
 
2157
 
 
2158
   return ptr;
 
2159
 
 
2160
}
 
2161
 
 
2162
 
 
2163
/**************************************************
 
2164
*
 
2165
*    Cn3dObjectLocationFree()
 
2166
*
 
2167
**************************************************/
 
2168
NLM_EXTERN 
 
2169
Cn3dObjectLocationPtr LIBCALL
 
2170
Cn3dObjectLocationFree(Cn3dObjectLocationPtr ptr)
 
2171
{
 
2172
 
 
2173
   if(ptr == NULL) {
 
2174
      return NULL;
 
2175
   }
 
2176
   BiostrucIdFree(ptr -> structure_id);
 
2177
   AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dMoleculeLocationFree);
 
2178
   return MemFree(ptr);
 
2179
}
 
2180
 
 
2181
 
 
2182
/**************************************************
 
2183
*
 
2184
*    Cn3dObjectLocationAsnRead()
 
2185
*
 
2186
**************************************************/
 
2187
NLM_EXTERN 
 
2188
Cn3dObjectLocationPtr LIBCALL
 
2189
Cn3dObjectLocationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2190
{
 
2191
   DataVal av;
 
2192
   AsnTypePtr atp;
 
2193
   Boolean isError = FALSE;
 
2194
   AsnReadFunc func;
 
2195
   Cn3dObjectLocationPtr ptr;
 
2196
 
 
2197
   if (! loaded)
 
2198
   {
 
2199
      if (! objcn3dAsnLoad()) {
 
2200
         return NULL;
 
2201
      }
 
2202
   }
 
2203
 
 
2204
   if (aip == NULL) {
 
2205
      return NULL;
 
2206
   }
 
2207
 
 
2208
   if (orig == NULL) {         /* Cn3dObjectLocation ::= (self contained) */
 
2209
      atp = AsnReadId(aip, amp, CN3D_OBJECT_LOCATION);
 
2210
   } else {
 
2211
      atp = AsnLinkType(orig, CN3D_OBJECT_LOCATION);
 
2212
   }
 
2213
   /* link in local tree */
 
2214
   if (atp == NULL) {
 
2215
      return NULL;
 
2216
   }
 
2217
 
 
2218
   ptr = Cn3dObjectLocationNew();
 
2219
   if (ptr == NULL) {
 
2220
      goto erret;
 
2221
   }
 
2222
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2223
      goto erret;
 
2224
   }
 
2225
 
 
2226
   atp = AsnReadId(aip,amp, atp);
 
2227
   func = NULL;
 
2228
 
 
2229
   if (atp == CN3D_OBJECT_LOCATION_structure_id) {
 
2230
      ptr -> structure_id = BiostrucIdAsnRead(aip, atp);
 
2231
      if (aip -> io_failure) {
 
2232
         goto erret;
 
2233
      }
 
2234
      atp = AsnReadId(aip,amp, atp);
 
2235
   }
 
2236
   if (atp == CN3D_OBJECT_LOCATION_residues) {
 
2237
      ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dMoleculeLocationAsnRead, (AsnOptFreeFunc) Cn3dMoleculeLocationFree);
 
2238
      if (isError && ptr -> residues == NULL) {
 
2239
         goto erret;
 
2240
      }
 
2241
      atp = AsnReadId(aip,amp, atp);
 
2242
   }
 
2243
 
 
2244
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2245
      goto erret;
 
2246
   }
 
2247
   /* end struct */
 
2248
 
 
2249
ret:
 
2250
   AsnUnlinkType(orig);       /* unlink local tree */
 
2251
   return ptr;
 
2252
 
 
2253
erret:
 
2254
   aip -> io_failure = TRUE;
 
2255
   ptr = Cn3dObjectLocationFree(ptr);
 
2256
   goto ret;
 
2257
}
 
2258
 
 
2259
 
 
2260
 
 
2261
/**************************************************
 
2262
*
 
2263
*    Cn3dObjectLocationAsnWrite()
 
2264
*
 
2265
**************************************************/
 
2266
NLM_EXTERN Boolean LIBCALL 
 
2267
Cn3dObjectLocationAsnWrite(Cn3dObjectLocationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2268
{
 
2269
   DataVal av;
 
2270
   AsnTypePtr atp;
 
2271
   Boolean retval = FALSE;
 
2272
 
 
2273
   if (! loaded)
 
2274
   {
 
2275
      if (! objcn3dAsnLoad()) {
 
2276
         return FALSE;
 
2277
      }
 
2278
   }
 
2279
 
 
2280
   if (aip == NULL) {
 
2281
      return FALSE;
 
2282
   }
 
2283
 
 
2284
   atp = AsnLinkType(orig, CN3D_OBJECT_LOCATION);   /* link local tree */
 
2285
   if (atp == NULL) {
 
2286
      return FALSE;
 
2287
   }
 
2288
 
 
2289
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2290
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2291
      goto erret;
 
2292
   }
 
2293
 
 
2294
   if (ptr -> structure_id != NULL) {
 
2295
      if ( ! BiostrucIdAsnWrite(ptr -> structure_id, aip, CN3D_OBJECT_LOCATION_structure_id)) {
 
2296
         goto erret;
 
2297
      }
 
2298
   }
 
2299
   AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dMoleculeLocationAsnWrite, aip, CN3D_OBJECT_LOCATION_residues, CN3D_OBJECT_LOCATION_residues_E);
 
2300
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2301
      goto erret;
 
2302
   }
 
2303
   retval = TRUE;
 
2304
 
 
2305
erret:
 
2306
   AsnUnlinkType(orig);       /* unlink local tree */
 
2307
   return retval;
 
2308
}
 
2309
 
 
2310
 
 
2311
 
 
2312
/**************************************************
 
2313
*
 
2314
*    Cn3dUserAnnotationNew()
 
2315
*
 
2316
**************************************************/
 
2317
NLM_EXTERN 
 
2318
Cn3dUserAnnotationPtr LIBCALL
 
2319
Cn3dUserAnnotationNew(void)
 
2320
{
 
2321
   Cn3dUserAnnotationPtr ptr = MemNew((size_t) sizeof(Cn3dUserAnnotation));
 
2322
 
 
2323
   return ptr;
 
2324
 
 
2325
}
 
2326
 
 
2327
 
 
2328
/**************************************************
 
2329
*
 
2330
*    Cn3dUserAnnotationFree()
 
2331
*
 
2332
**************************************************/
 
2333
NLM_EXTERN 
 
2334
Cn3dUserAnnotationPtr LIBCALL
 
2335
Cn3dUserAnnotationFree(Cn3dUserAnnotationPtr ptr)
 
2336
{
 
2337
 
 
2338
   if(ptr == NULL) {
 
2339
      return NULL;
 
2340
   }
 
2341
   MemFree(ptr -> name);
 
2342
   MemFree(ptr -> description);
 
2343
   AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dObjectLocationFree);
 
2344
   return MemFree(ptr);
 
2345
}
 
2346
 
 
2347
 
 
2348
/**************************************************
 
2349
*
 
2350
*    Cn3dUserAnnotationAsnRead()
 
2351
*
 
2352
**************************************************/
 
2353
NLM_EXTERN 
 
2354
Cn3dUserAnnotationPtr LIBCALL
 
2355
Cn3dUserAnnotationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2356
{
 
2357
   DataVal av;
 
2358
   AsnTypePtr atp;
 
2359
   Boolean isError = FALSE;
 
2360
   AsnReadFunc func;
 
2361
   Cn3dUserAnnotationPtr ptr;
 
2362
 
 
2363
   if (! loaded)
 
2364
   {
 
2365
      if (! objcn3dAsnLoad()) {
 
2366
         return NULL;
 
2367
      }
 
2368
   }
 
2369
 
 
2370
   if (aip == NULL) {
 
2371
      return NULL;
 
2372
   }
 
2373
 
 
2374
   if (orig == NULL) {         /* Cn3dUserAnnotation ::= (self contained) */
 
2375
      atp = AsnReadId(aip, amp, CN3D_USER_ANNOTATION);
 
2376
   } else {
 
2377
      atp = AsnLinkType(orig, CN3D_USER_ANNOTATION);
 
2378
   }
 
2379
   /* link in local tree */
 
2380
   if (atp == NULL) {
 
2381
      return NULL;
 
2382
   }
 
2383
 
 
2384
   ptr = Cn3dUserAnnotationNew();
 
2385
   if (ptr == NULL) {
 
2386
      goto erret;
 
2387
   }
 
2388
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2389
      goto erret;
 
2390
   }
 
2391
 
 
2392
   atp = AsnReadId(aip,amp, atp);
 
2393
   func = NULL;
 
2394
 
 
2395
   if (atp == CN3D_USER_ANNOTATION_name) {
 
2396
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2397
         goto erret;
 
2398
      }
 
2399
      ptr -> name = av.ptrvalue;
 
2400
      atp = AsnReadId(aip,amp, atp);
 
2401
   }
 
2402
   if (atp == CN3D_USER_ANNOTATION_description) {
 
2403
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2404
         goto erret;
 
2405
      }
 
2406
      ptr -> description = av.ptrvalue;
 
2407
      atp = AsnReadId(aip,amp, atp);
 
2408
   }
 
2409
   if (atp == CN3D_USER_ANNOTATION_style_id) {
 
2410
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2411
         goto erret;
 
2412
      }
 
2413
      ptr -> style_id = av.intvalue;
 
2414
      atp = AsnReadId(aip,amp, atp);
 
2415
   }
 
2416
   if (atp == CN3D_USER_ANNOTATION_residues) {
 
2417
      ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dObjectLocationAsnRead, (AsnOptFreeFunc) Cn3dObjectLocationFree);
 
2418
      if (isError && ptr -> residues == NULL) {
 
2419
         goto erret;
 
2420
      }
 
2421
      atp = AsnReadId(aip,amp, atp);
 
2422
   }
 
2423
   if (atp == CN3D_USER_ANNOTATION_is_on) {
 
2424
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2425
         goto erret;
 
2426
      }
 
2427
      ptr -> is_on = av.boolvalue;
 
2428
      atp = AsnReadId(aip,amp, atp);
 
2429
   }
 
2430
 
 
2431
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2432
      goto erret;
 
2433
   }
 
2434
   /* end struct */
 
2435
 
 
2436
ret:
 
2437
   AsnUnlinkType(orig);       /* unlink local tree */
 
2438
   return ptr;
 
2439
 
 
2440
erret:
 
2441
   aip -> io_failure = TRUE;
 
2442
   ptr = Cn3dUserAnnotationFree(ptr);
 
2443
   goto ret;
 
2444
}
 
2445
 
 
2446
 
 
2447
 
 
2448
/**************************************************
 
2449
*
 
2450
*    Cn3dUserAnnotationAsnWrite()
 
2451
*
 
2452
**************************************************/
 
2453
NLM_EXTERN Boolean LIBCALL 
 
2454
Cn3dUserAnnotationAsnWrite(Cn3dUserAnnotationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2455
{
 
2456
   DataVal av;
 
2457
   AsnTypePtr atp;
 
2458
   Boolean retval = FALSE;
 
2459
 
 
2460
   if (! loaded)
 
2461
   {
 
2462
      if (! objcn3dAsnLoad()) {
 
2463
         return FALSE;
 
2464
      }
 
2465
   }
 
2466
 
 
2467
   if (aip == NULL) {
 
2468
      return FALSE;
 
2469
   }
 
2470
 
 
2471
   atp = AsnLinkType(orig, CN3D_USER_ANNOTATION);   /* link local tree */
 
2472
   if (atp == NULL) {
 
2473
      return FALSE;
 
2474
   }
 
2475
 
 
2476
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2477
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2478
      goto erret;
 
2479
   }
 
2480
 
 
2481
   if (ptr -> name != NULL) {
 
2482
      av.ptrvalue = ptr -> name;
 
2483
      retval = AsnWrite(aip, CN3D_USER_ANNOTATION_name,  &av);
 
2484
   }
 
2485
   if (ptr -> description != NULL) {
 
2486
      av.ptrvalue = ptr -> description;
 
2487
      retval = AsnWrite(aip, CN3D_USER_ANNOTATION_description,  &av);
 
2488
   }
 
2489
   av.intvalue = ptr -> style_id;
 
2490
   retval = AsnWrite(aip, CN3D_USER_ANNOTATION_style_id,  &av);
 
2491
   AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dObjectLocationAsnWrite, aip, CN3D_USER_ANNOTATION_residues, CN3D_USER_ANNOTATION_residues_E);
 
2492
   av.boolvalue = ptr -> is_on;
 
2493
   retval = AsnWrite(aip, CN3D_USER_ANNOTATION_is_on,  &av);
 
2494
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2495
      goto erret;
 
2496
   }
 
2497
   retval = TRUE;
 
2498
 
 
2499
erret:
 
2500
   AsnUnlinkType(orig);       /* unlink local tree */
 
2501
   return retval;
 
2502
}
 
2503
 
 
2504
 
 
2505
 
 
2506
/**************************************************
 
2507
*
 
2508
*    Cn3dGLMatrixNew()
 
2509
*
 
2510
**************************************************/
 
2511
NLM_EXTERN 
 
2512
Cn3dGLMatrixPtr LIBCALL
 
2513
Cn3dGLMatrixNew(void)
 
2514
{
 
2515
   Cn3dGLMatrixPtr ptr = MemNew((size_t) sizeof(Cn3dGLMatrix));
 
2516
 
 
2517
   return ptr;
 
2518
 
 
2519
}
 
2520
 
 
2521
 
 
2522
/**************************************************
 
2523
*
 
2524
*    Cn3dGLMatrixFree()
 
2525
*
 
2526
**************************************************/
 
2527
NLM_EXTERN 
 
2528
Cn3dGLMatrixPtr LIBCALL
 
2529
Cn3dGLMatrixFree(Cn3dGLMatrixPtr ptr)
 
2530
{
 
2531
 
 
2532
   if(ptr == NULL) {
 
2533
      return NULL;
 
2534
   }
 
2535
   return MemFree(ptr);
 
2536
}
 
2537
 
 
2538
 
 
2539
/**************************************************
 
2540
*
 
2541
*    Cn3dGLMatrixAsnRead()
 
2542
*
 
2543
**************************************************/
 
2544
NLM_EXTERN 
 
2545
Cn3dGLMatrixPtr LIBCALL
 
2546
Cn3dGLMatrixAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2547
{
 
2548
   DataVal av;
 
2549
   AsnTypePtr atp;
 
2550
   Boolean isError = FALSE;
 
2551
   AsnReadFunc func;
 
2552
   Cn3dGLMatrixPtr ptr;
 
2553
 
 
2554
   if (! loaded)
 
2555
   {
 
2556
      if (! objcn3dAsnLoad()) {
 
2557
         return NULL;
 
2558
      }
 
2559
   }
 
2560
 
 
2561
   if (aip == NULL) {
 
2562
      return NULL;
 
2563
   }
 
2564
 
 
2565
   if (orig == NULL) {         /* Cn3dGLMatrix ::= (self contained) */
 
2566
      atp = AsnReadId(aip, amp, CN3D_GL_MATRIX);
 
2567
   } else {
 
2568
      atp = AsnLinkType(orig, CN3D_GL_MATRIX);
 
2569
   }
 
2570
   /* link in local tree */
 
2571
   if (atp == NULL) {
 
2572
      return NULL;
 
2573
   }
 
2574
 
 
2575
   ptr = Cn3dGLMatrixNew();
 
2576
   if (ptr == NULL) {
 
2577
      goto erret;
 
2578
   }
 
2579
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2580
      goto erret;
 
2581
   }
 
2582
 
 
2583
   atp = AsnReadId(aip,amp, atp);
 
2584
   func = NULL;
 
2585
 
 
2586
   if (atp == CN3D_GL_MATRIX_m0) {
 
2587
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2588
         goto erret;
 
2589
      }
 
2590
      ptr -> m0 = av.realvalue;
 
2591
      atp = AsnReadId(aip,amp, atp);
 
2592
   }
 
2593
   if (atp == CN3D_GL_MATRIX_m1) {
 
2594
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2595
         goto erret;
 
2596
      }
 
2597
      ptr -> m1 = av.realvalue;
 
2598
      atp = AsnReadId(aip,amp, atp);
 
2599
   }
 
2600
   if (atp == CN3D_GL_MATRIX_m2) {
 
2601
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2602
         goto erret;
 
2603
      }
 
2604
      ptr -> m2 = av.realvalue;
 
2605
      atp = AsnReadId(aip,amp, atp);
 
2606
   }
 
2607
   if (atp == CN3D_GL_MATRIX_m3) {
 
2608
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2609
         goto erret;
 
2610
      }
 
2611
      ptr -> m3 = av.realvalue;
 
2612
      atp = AsnReadId(aip,amp, atp);
 
2613
   }
 
2614
   if (atp == CN3D_GL_MATRIX_m4) {
 
2615
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2616
         goto erret;
 
2617
      }
 
2618
      ptr -> m4 = av.realvalue;
 
2619
      atp = AsnReadId(aip,amp, atp);
 
2620
   }
 
2621
   if (atp == CN3D_GL_MATRIX_m5) {
 
2622
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2623
         goto erret;
 
2624
      }
 
2625
      ptr -> m5 = av.realvalue;
 
2626
      atp = AsnReadId(aip,amp, atp);
 
2627
   }
 
2628
   if (atp == CN3D_GL_MATRIX_m6) {
 
2629
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2630
         goto erret;
 
2631
      }
 
2632
      ptr -> m6 = av.realvalue;
 
2633
      atp = AsnReadId(aip,amp, atp);
 
2634
   }
 
2635
   if (atp == CN3D_GL_MATRIX_m7) {
 
2636
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2637
         goto erret;
 
2638
      }
 
2639
      ptr -> m7 = av.realvalue;
 
2640
      atp = AsnReadId(aip,amp, atp);
 
2641
   }
 
2642
   if (atp == CN3D_GL_MATRIX_m8) {
 
2643
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2644
         goto erret;
 
2645
      }
 
2646
      ptr -> m8 = av.realvalue;
 
2647
      atp = AsnReadId(aip,amp, atp);
 
2648
   }
 
2649
   if (atp == CN3D_GL_MATRIX_m9) {
 
2650
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2651
         goto erret;
 
2652
      }
 
2653
      ptr -> m9 = av.realvalue;
 
2654
      atp = AsnReadId(aip,amp, atp);
 
2655
   }
 
2656
   if (atp == CN3D_GL_MATRIX_m10) {
 
2657
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2658
         goto erret;
 
2659
      }
 
2660
      ptr -> m10 = av.realvalue;
 
2661
      atp = AsnReadId(aip,amp, atp);
 
2662
   }
 
2663
   if (atp == CN3D_GL_MATRIX_m11) {
 
2664
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2665
         goto erret;
 
2666
      }
 
2667
      ptr -> m11 = av.realvalue;
 
2668
      atp = AsnReadId(aip,amp, atp);
 
2669
   }
 
2670
   if (atp == CN3D_GL_MATRIX_m12) {
 
2671
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2672
         goto erret;
 
2673
      }
 
2674
      ptr -> m12 = av.realvalue;
 
2675
      atp = AsnReadId(aip,amp, atp);
 
2676
   }
 
2677
   if (atp == CN3D_GL_MATRIX_m13) {
 
2678
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2679
         goto erret;
 
2680
      }
 
2681
      ptr -> m13 = av.realvalue;
 
2682
      atp = AsnReadId(aip,amp, atp);
 
2683
   }
 
2684
   if (atp == CN3D_GL_MATRIX_m14) {
 
2685
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2686
         goto erret;
 
2687
      }
 
2688
      ptr -> m14 = av.realvalue;
 
2689
      atp = AsnReadId(aip,amp, atp);
 
2690
   }
 
2691
   if (atp == CN3D_GL_MATRIX_m15) {
 
2692
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2693
         goto erret;
 
2694
      }
 
2695
      ptr -> m15 = av.realvalue;
 
2696
      atp = AsnReadId(aip,amp, atp);
 
2697
   }
 
2698
 
 
2699
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2700
      goto erret;
 
2701
   }
 
2702
   /* end struct */
 
2703
 
 
2704
ret:
 
2705
   AsnUnlinkType(orig);       /* unlink local tree */
 
2706
   return ptr;
 
2707
 
 
2708
erret:
 
2709
   aip -> io_failure = TRUE;
 
2710
   ptr = Cn3dGLMatrixFree(ptr);
 
2711
   goto ret;
 
2712
}
 
2713
 
 
2714
 
 
2715
 
 
2716
/**************************************************
 
2717
*
 
2718
*    Cn3dGLMatrixAsnWrite()
 
2719
*
 
2720
**************************************************/
 
2721
NLM_EXTERN Boolean LIBCALL 
 
2722
Cn3dGLMatrixAsnWrite(Cn3dGLMatrixPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2723
{
 
2724
   DataVal av;
 
2725
   AsnTypePtr atp;
 
2726
   Boolean retval = FALSE;
 
2727
 
 
2728
   if (! loaded)
 
2729
   {
 
2730
      if (! objcn3dAsnLoad()) {
 
2731
         return FALSE;
 
2732
      }
 
2733
   }
 
2734
 
 
2735
   if (aip == NULL) {
 
2736
      return FALSE;
 
2737
   }
 
2738
 
 
2739
   atp = AsnLinkType(orig, CN3D_GL_MATRIX);   /* link local tree */
 
2740
   if (atp == NULL) {
 
2741
      return FALSE;
 
2742
   }
 
2743
 
 
2744
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2745
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2746
      goto erret;
 
2747
   }
 
2748
 
 
2749
   av.realvalue = ptr -> m0;
 
2750
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m0,  &av);
 
2751
   av.realvalue = ptr -> m1;
 
2752
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m1,  &av);
 
2753
   av.realvalue = ptr -> m2;
 
2754
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m2,  &av);
 
2755
   av.realvalue = ptr -> m3;
 
2756
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m3,  &av);
 
2757
   av.realvalue = ptr -> m4;
 
2758
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m4,  &av);
 
2759
   av.realvalue = ptr -> m5;
 
2760
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m5,  &av);
 
2761
   av.realvalue = ptr -> m6;
 
2762
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m6,  &av);
 
2763
   av.realvalue = ptr -> m7;
 
2764
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m7,  &av);
 
2765
   av.realvalue = ptr -> m8;
 
2766
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m8,  &av);
 
2767
   av.realvalue = ptr -> m9;
 
2768
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m9,  &av);
 
2769
   av.realvalue = ptr -> m10;
 
2770
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m10,  &av);
 
2771
   av.realvalue = ptr -> m11;
 
2772
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m11,  &av);
 
2773
   av.realvalue = ptr -> m12;
 
2774
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m12,  &av);
 
2775
   av.realvalue = ptr -> m13;
 
2776
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m13,  &av);
 
2777
   av.realvalue = ptr -> m14;
 
2778
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m14,  &av);
 
2779
   av.realvalue = ptr -> m15;
 
2780
   retval = AsnWrite(aip, CN3D_GL_MATRIX_m15,  &av);
 
2781
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2782
      goto erret;
 
2783
   }
 
2784
   retval = TRUE;
 
2785
 
 
2786
erret:
 
2787
   AsnUnlinkType(orig);       /* unlink local tree */
 
2788
   return retval;
 
2789
}
 
2790
 
 
2791
 
 
2792
 
 
2793
/**************************************************
 
2794
*
 
2795
*    Cn3dVectorNew()
 
2796
*
 
2797
**************************************************/
 
2798
NLM_EXTERN 
 
2799
Cn3dVectorPtr LIBCALL
 
2800
Cn3dVectorNew(void)
 
2801
{
 
2802
   Cn3dVectorPtr ptr = MemNew((size_t) sizeof(Cn3dVector));
 
2803
 
 
2804
   return ptr;
 
2805
 
 
2806
}
 
2807
 
 
2808
 
 
2809
/**************************************************
 
2810
*
 
2811
*    Cn3dVectorFree()
 
2812
*
 
2813
**************************************************/
 
2814
NLM_EXTERN 
 
2815
Cn3dVectorPtr LIBCALL
 
2816
Cn3dVectorFree(Cn3dVectorPtr ptr)
 
2817
{
 
2818
 
 
2819
   if(ptr == NULL) {
 
2820
      return NULL;
 
2821
   }
 
2822
   return MemFree(ptr);
 
2823
}
 
2824
 
 
2825
 
 
2826
/**************************************************
 
2827
*
 
2828
*    Cn3dVectorAsnRead()
 
2829
*
 
2830
**************************************************/
 
2831
NLM_EXTERN 
 
2832
Cn3dVectorPtr LIBCALL
 
2833
Cn3dVectorAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2834
{
 
2835
   DataVal av;
 
2836
   AsnTypePtr atp;
 
2837
   Boolean isError = FALSE;
 
2838
   AsnReadFunc func;
 
2839
   Cn3dVectorPtr ptr;
 
2840
 
 
2841
   if (! loaded)
 
2842
   {
 
2843
      if (! objcn3dAsnLoad()) {
 
2844
         return NULL;
 
2845
      }
 
2846
   }
 
2847
 
 
2848
   if (aip == NULL) {
 
2849
      return NULL;
 
2850
   }
 
2851
 
 
2852
   if (orig == NULL) {         /* Cn3dVector ::= (self contained) */
 
2853
      atp = AsnReadId(aip, amp, CN3D_VECTOR);
 
2854
   } else {
 
2855
      atp = AsnLinkType(orig, CN3D_VECTOR);
 
2856
   }
 
2857
   /* link in local tree */
 
2858
   if (atp == NULL) {
 
2859
      return NULL;
 
2860
   }
 
2861
 
 
2862
   ptr = Cn3dVectorNew();
 
2863
   if (ptr == NULL) {
 
2864
      goto erret;
 
2865
   }
 
2866
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2867
      goto erret;
 
2868
   }
 
2869
 
 
2870
   atp = AsnReadId(aip,amp, atp);
 
2871
   func = NULL;
 
2872
 
 
2873
   if (atp == CN3D_VECTOR_x) {
 
2874
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2875
         goto erret;
 
2876
      }
 
2877
      ptr -> x = av.realvalue;
 
2878
      atp = AsnReadId(aip,amp, atp);
 
2879
   }
 
2880
   if (atp == CN3D_VECTOR_y) {
 
2881
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2882
         goto erret;
 
2883
      }
 
2884
      ptr -> y = av.realvalue;
 
2885
      atp = AsnReadId(aip,amp, atp);
 
2886
   }
 
2887
   if (atp == CN3D_VECTOR_z) {
 
2888
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
2889
         goto erret;
 
2890
      }
 
2891
      ptr -> z = av.realvalue;
 
2892
      atp = AsnReadId(aip,amp, atp);
 
2893
   }
 
2894
 
 
2895
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2896
      goto erret;
 
2897
   }
 
2898
   /* end struct */
 
2899
 
 
2900
ret:
 
2901
   AsnUnlinkType(orig);       /* unlink local tree */
 
2902
   return ptr;
 
2903
 
 
2904
erret:
 
2905
   aip -> io_failure = TRUE;
 
2906
   ptr = Cn3dVectorFree(ptr);
 
2907
   goto ret;
 
2908
}
 
2909
 
 
2910
 
 
2911
 
 
2912
/**************************************************
 
2913
*
 
2914
*    Cn3dVectorAsnWrite()
 
2915
*
 
2916
**************************************************/
 
2917
NLM_EXTERN Boolean LIBCALL 
 
2918
Cn3dVectorAsnWrite(Cn3dVectorPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2919
{
 
2920
   DataVal av;
 
2921
   AsnTypePtr atp;
 
2922
   Boolean retval = FALSE;
 
2923
 
 
2924
   if (! loaded)
 
2925
   {
 
2926
      if (! objcn3dAsnLoad()) {
 
2927
         return FALSE;
 
2928
      }
 
2929
   }
 
2930
 
 
2931
   if (aip == NULL) {
 
2932
      return FALSE;
 
2933
   }
 
2934
 
 
2935
   atp = AsnLinkType(orig, CN3D_VECTOR);   /* link local tree */
 
2936
   if (atp == NULL) {
 
2937
      return FALSE;
 
2938
   }
 
2939
 
 
2940
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2941
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2942
      goto erret;
 
2943
   }
 
2944
 
 
2945
   av.realvalue = ptr -> x;
 
2946
   retval = AsnWrite(aip, CN3D_VECTOR_x,  &av);
 
2947
   av.realvalue = ptr -> y;
 
2948
   retval = AsnWrite(aip, CN3D_VECTOR_y,  &av);
 
2949
   av.realvalue = ptr -> z;
 
2950
   retval = AsnWrite(aip, CN3D_VECTOR_z,  &av);
 
2951
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2952
      goto erret;
 
2953
   }
 
2954
   retval = TRUE;
 
2955
 
 
2956
erret:
 
2957
   AsnUnlinkType(orig);       /* unlink local tree */
 
2958
   return retval;
 
2959
}
 
2960
 
 
2961
 
 
2962
 
 
2963
/**************************************************
 
2964
*
 
2965
*    Cn3dViewSettingsNew()
 
2966
*
 
2967
**************************************************/
 
2968
NLM_EXTERN 
 
2969
Cn3dViewSettingsPtr LIBCALL
 
2970
Cn3dViewSettingsNew(void)
 
2971
{
 
2972
   Cn3dViewSettingsPtr ptr = MemNew((size_t) sizeof(Cn3dViewSettings));
 
2973
 
 
2974
   return ptr;
 
2975
 
 
2976
}
 
2977
 
 
2978
 
 
2979
/**************************************************
 
2980
*
 
2981
*    Cn3dViewSettingsFree()
 
2982
*
 
2983
**************************************************/
 
2984
NLM_EXTERN 
 
2985
Cn3dViewSettingsPtr LIBCALL
 
2986
Cn3dViewSettingsFree(Cn3dViewSettingsPtr ptr)
 
2987
{
 
2988
 
 
2989
   if(ptr == NULL) {
 
2990
      return NULL;
 
2991
   }
 
2992
   Cn3dGLMatrixFree(ptr -> matrix);
 
2993
   Cn3dVectorFree(ptr -> rotation_center);
 
2994
   return MemFree(ptr);
 
2995
}
 
2996
 
 
2997
 
 
2998
/**************************************************
 
2999
*
 
3000
*    Cn3dViewSettingsAsnRead()
 
3001
*
 
3002
**************************************************/
 
3003
NLM_EXTERN 
 
3004
Cn3dViewSettingsPtr LIBCALL
 
3005
Cn3dViewSettingsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
3006
{
 
3007
   DataVal av;
 
3008
   AsnTypePtr atp;
 
3009
   Boolean isError = FALSE;
 
3010
   AsnReadFunc func;
 
3011
   Cn3dViewSettingsPtr ptr;
 
3012
 
 
3013
   if (! loaded)
 
3014
   {
 
3015
      if (! objcn3dAsnLoad()) {
 
3016
         return NULL;
 
3017
      }
 
3018
   }
 
3019
 
 
3020
   if (aip == NULL) {
 
3021
      return NULL;
 
3022
   }
 
3023
 
 
3024
   if (orig == NULL) {         /* Cn3dViewSettings ::= (self contained) */
 
3025
      atp = AsnReadId(aip, amp, CN3D_VIEW_SETTINGS);
 
3026
   } else {
 
3027
      atp = AsnLinkType(orig, CN3D_VIEW_SETTINGS);
 
3028
   }
 
3029
   /* link in local tree */
 
3030
   if (atp == NULL) {
 
3031
      return NULL;
 
3032
   }
 
3033
 
 
3034
   ptr = Cn3dViewSettingsNew();
 
3035
   if (ptr == NULL) {
 
3036
      goto erret;
 
3037
   }
 
3038
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
3039
      goto erret;
 
3040
   }
 
3041
 
 
3042
   atp = AsnReadId(aip,amp, atp);
 
3043
   func = NULL;
 
3044
 
 
3045
   if (atp == CN3D_VIEW_SETTINGS_camera_distance) {
 
3046
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3047
         goto erret;
 
3048
      }
 
3049
      ptr -> camera_distance = av.realvalue;
 
3050
      atp = AsnReadId(aip,amp, atp);
 
3051
   }
 
3052
   if (atp == CN3D_VIEW_SETTINGS_camera_angle_rad) {
 
3053
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3054
         goto erret;
 
3055
      }
 
3056
      ptr -> camera_angle_rad = av.realvalue;
 
3057
      atp = AsnReadId(aip,amp, atp);
 
3058
   }
 
3059
   if (atp == CN3D_VIEW_SETTINGS_camera_look_at_X) {
 
3060
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3061
         goto erret;
 
3062
      }
 
3063
      ptr -> camera_look_at_X = av.realvalue;
 
3064
      atp = AsnReadId(aip,amp, atp);
 
3065
   }
 
3066
   if (atp == CN3D_VIEW_SETTINGS_camera_look_at_Y) {
 
3067
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3068
         goto erret;
 
3069
      }
 
3070
      ptr -> camera_look_at_Y = av.realvalue;
 
3071
      atp = AsnReadId(aip,amp, atp);
 
3072
   }
 
3073
   if (atp == CN3D_VIEW_SETTINGS_camera_clip_near) {
 
3074
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3075
         goto erret;
 
3076
      }
 
3077
      ptr -> camera_clip_near = av.realvalue;
 
3078
      atp = AsnReadId(aip,amp, atp);
 
3079
   }
 
3080
   if (atp == CN3D_VIEW_SETTINGS_camera_clip_far) {
 
3081
      if ( AsnReadVal(aip, atp, &av) <= 0) {
 
3082
         goto erret;
 
3083
      }
 
3084
      ptr -> camera_clip_far = av.realvalue;
 
3085
      atp = AsnReadId(aip,amp, atp);
 
3086
   }
 
3087
   if (atp == CN3D_VIEW_SETTINGS_matrix) {
 
3088
      ptr -> matrix = Cn3dGLMatrixAsnRead(aip, atp);
 
3089
      if (aip -> io_failure) {
 
3090
         goto erret;
 
3091
      }
 
3092
      atp = AsnReadId(aip,amp, atp);
 
3093
   }
 
3094
   if (atp == CN3D_VIEW_SETTINGS_rotation_center) {
 
3095
      ptr -> rotation_center = Cn3dVectorAsnRead(aip, atp);
 
3096
      if (aip -> io_failure) {
 
3097
         goto erret;
 
3098
      }
 
3099
      atp = AsnReadId(aip,amp, atp);
 
3100
   }
 
3101
 
 
3102
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
3103
      goto erret;
 
3104
   }
 
3105
   /* end struct */
 
3106
 
 
3107
ret:
 
3108
   AsnUnlinkType(orig);       /* unlink local tree */
 
3109
   return ptr;
 
3110
 
 
3111
erret:
 
3112
   aip -> io_failure = TRUE;
 
3113
   ptr = Cn3dViewSettingsFree(ptr);
 
3114
   goto ret;
 
3115
}
 
3116
 
 
3117
 
 
3118
 
 
3119
/**************************************************
 
3120
*
 
3121
*    Cn3dViewSettingsAsnWrite()
 
3122
*
 
3123
**************************************************/
 
3124
NLM_EXTERN Boolean LIBCALL 
 
3125
Cn3dViewSettingsAsnWrite(Cn3dViewSettingsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
3126
{
 
3127
   DataVal av;
 
3128
   AsnTypePtr atp;
 
3129
   Boolean retval = FALSE;
 
3130
 
 
3131
   if (! loaded)
 
3132
   {
 
3133
      if (! objcn3dAsnLoad()) {
 
3134
         return FALSE;
 
3135
      }
 
3136
   }
 
3137
 
 
3138
   if (aip == NULL) {
 
3139
      return FALSE;
 
3140
   }
 
3141
 
 
3142
   atp = AsnLinkType(orig, CN3D_VIEW_SETTINGS);   /* link local tree */
 
3143
   if (atp == NULL) {
 
3144
      return FALSE;
 
3145
   }
 
3146
 
 
3147
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
3148
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
3149
      goto erret;
 
3150
   }
 
3151
 
 
3152
   av.realvalue = ptr -> camera_distance;
 
3153
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_distance,  &av);
 
3154
   av.realvalue = ptr -> camera_angle_rad;
 
3155
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_angle_rad,  &av);
 
3156
   av.realvalue = ptr -> camera_look_at_X;
 
3157
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_look_at_X,  &av);
 
3158
   av.realvalue = ptr -> camera_look_at_Y;
 
3159
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_look_at_Y,  &av);
 
3160
   av.realvalue = ptr -> camera_clip_near;
 
3161
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_clip_near,  &av);
 
3162
   av.realvalue = ptr -> camera_clip_far;
 
3163
   retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_clip_far,  &av);
 
3164
   if (ptr -> matrix != NULL) {
 
3165
      if ( ! Cn3dGLMatrixAsnWrite(ptr -> matrix, aip, CN3D_VIEW_SETTINGS_matrix)) {
 
3166
         goto erret;
 
3167
      }
 
3168
   }
 
3169
   if (ptr -> rotation_center != NULL) {
 
3170
      if ( ! Cn3dVectorAsnWrite(ptr -> rotation_center, aip, CN3D_VIEW_SETTINGS_rotation_center)) {
 
3171
         goto erret;
 
3172
      }
 
3173
   }
 
3174
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
3175
      goto erret;
 
3176
   }
 
3177
   retval = TRUE;
 
3178
 
 
3179
erret:
 
3180
   AsnUnlinkType(orig);       /* unlink local tree */
 
3181
   return retval;
 
3182
}
 
3183