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

« back to all changes in this revision

Viewing changes to desktop/gphview.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   2/5/97
31
31
*
32
 
* $Revision: 6.45 $
 
32
* $Revision: 6.64 $
33
33
*
34
34
* File Description:
35
35
*
990
990
  Int4           vwr_x;
991
991
  Int4           vwr_y;
992
992
  Int2           vwr_align;
 
993
  SeqViewProcsPtr  svpp;
993
994
 
994
995
  if (bvp == NULL) return;
995
996
  sep = SeqMgrGetSeqEntryForData (bvp->bsp);
996
997
  entityID = ObjMgrGetEntityIDForChoice (sep);
 
998
 
 
999
  svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
 
1000
  if (svpp != NULL && svpp->lockFarComponents) {
 
1001
    sep = GetTopSeqEntryForEntityID (entityID);
 
1002
    LookupFarSeqIDs (sep, TRUE, FALSE, FALSE, TRUE, FALSE);
 
1003
  }
 
1004
 
997
1005
  sep = GetBestTopParentForData (entityID, bvp->bsp);
998
1006
  if (! bvp->hasTargetControl) {
999
1007
    PopulateSimpleGraphic (bvp); /* Nentrez should do this until more work is done */
3445
3453
};
3446
3454
 
3447
3455
BioseqPageData gphPageData = {
3448
 
  "Graphic", TRUE, TRUE, TRUE, FALSE, -1,
 
3456
  "OldGraphic", TRUE, TRUE, TRUE, FALSE, -1,
3449
3457
  PopulateGraphic, ShowGraphical, SelectGraphical,
3450
3458
  CopyGraphicalToClipboard, PrintGraphical,
3451
3459
  NULL, GifGraphical, ResizeGraphical, NULL
3452
3460
};
3453
3461
 
3454
3462
BioseqPageData alnPageData = {
3455
 
  "Alignment", TRUE, TRUE, TRUE, TRUE, -1,
 
3463
  "OldAlignment", TRUE, TRUE, TRUE, TRUE, -1,
3456
3464
  PopulateAlignment, ShowAlignment, SelectGraphical,
3457
3465
  CopyGraphicalToClipboard, PrintGraphical,
3458
3466
  NULL, NULL, ResizeGraphical, NULL
3459
3467
};
3460
3468
 
3461
3469
BioseqPageData seqPageData = {
3462
 
  "Sequence", TRUE, TRUE, FALSE, FALSE, -1,
 
3470
  "OldSequence", TRUE, TRUE, FALSE, FALSE, -1,
3463
3471
  PopulateSalsa, ShowSalsa, SelectSalsa,
3464
3472
  NULL, NULL,
3465
3473
  ExportSalsa, NULL, ResizeSalsa, NULL
3471
3479
  CopyGraphicalToClipboard, PrintGraphical,
3472
3480
  NULL, NULL, ResizeDesktop, NULL
3473
3481
};
 
3482
 
 
3483
/* new graphical viewer - sequin integration */
 
3484
 
 
3485
#include <asn2graphicp.h>
 
3486
 
 
3487
static void Asn2GphSelectRegion (VieweR viewer, SegmenT segment, PrimitivE primitive,
 
3488
                              SeqLocPtr region, Uint2 entityID)
 
3489
 
 
3490
{
 
3491
  BioseqPtr  bsp;
 
3492
  RecT       d;
 
3493
  ViewPData  extra;
 
3494
  RecT       r;
 
3495
  RecT       s;
 
3496
  SegPPtr    seg;
 
3497
  WindoW     tempPort;
 
3498
  BoxInfo    pLimits;
 
3499
 
 
3500
  if (viewer == NULL || segment == NULL || primitive == NULL || region == NULL) return;
 
3501
  seg = (SegPPtr) segment;
 
3502
  if (seg->base.code != SEGMENT && seg->base.code != PICTURE) return;
 
3503
  if (! seg->seg.visible) return;
 
3504
  if (Visible (viewer) && AllParentsVisible (viewer)) {
 
3505
    GetPanelExtra ((PaneL) viewer, &extra);
 
3506
    TryGetPrimitiveLimits ((BasePPtr) primitive, extra.scale.scaleX,
 
3507
                           extra.scale.scaleY, &pLimits);
 
3508
    bsp = GetBioseqGivenSeqLoc (region, entityID);
 
3509
    if (bsp == NULL) return;
 
3510
    if (ABS (pLimits.left - pLimits.right) < bsp->length) return;
 
3511
    pLimits.left = SeqLocStart (region);
 
3512
    pLimits.right = SeqLocStop (region);
 
3513
    if (! BoxInViewport (&r, &(pLimits), &(extra.scale))) return;
 
3514
    InsetRect (&r, 0, -3);
 
3515
    if (ABS (r.left - r.right) < 2) {
 
3516
      InsetRect (&r, -1, 0);
 
3517
    }
 
3518
    ObjectRect (viewer, &s);
 
3519
    InsetRect (&s, 2, 2);
 
3520
    SectRect (&r, &s, &d);
 
3521
    tempPort = SavePort (viewer);
 
3522
    Select (viewer);
 
3523
    Dotted ();
 
3524
    FrameRect (&d);
 
3525
    Solid ();
 
3526
    RestorePort (tempPort);
 
3527
  }
 
3528
}
 
3529
 
 
3530
static Boolean Asn2GphDrawSelectionPrim (SegmenT seg, PrimitivE prim, Uint2 segID,
 
3531
                                  Uint2 primID, Uint2 primCt, VoidPtr userdata)
 
3532
 
 
3533
{
 
3534
  Uint2         entityID;
 
3535
  Uint4         itemID;
 
3536
  Uint2         itemtype;
 
3537
  SelStructPtr  sel;
 
3538
  SelectPtr     sp;
 
3539
 
 
3540
  sp = (SelectPtr) userdata;
 
3541
  GetPrimitiveIDs (prim, &entityID, &itemID, &itemtype, NULL);
 
3542
  for (sel = sp->sel; sel != NULL; sel = sel->next) {
 
3543
    if (entityID == sel->entityID &&
 
3544
        itemID == sel->itemID &&
 
3545
        itemtype == sel->itemtype &&
 
3546
        sel->region != NULL) {
 
3547
      Asn2GphSelectRegion (sp->vwr, seg, prim, sel->region, entityID);
 
3548
    }
 
3549
  }
 
3550
  return TRUE;
 
3551
}
 
3552
 
 
3553
static void Asn2GphDrawSelectionRange (VieweR viewer, SegmenT segment)
 
3554
 
 
3555
{
 
3556
  Boolean       okay;
 
3557
  SelectData    sd;
 
3558
  SelStructPtr  sel;
 
3559
 
 
3560
  sd.vwr = viewer;
 
3561
  sd.sel = ObjMgrGetSelected ();
 
3562
  sd.entityID = 0;
 
3563
  sd.itemID = 0;
 
3564
  sd.itemtype = 0;
 
3565
  sd.region = NULL;
 
3566
  okay = FALSE;
 
3567
  for (sel = sd.sel; sel != NULL; sel = sel->next) {
 
3568
    if (sel->itemtype == OBJ_BIOSEQ && sel->region != NULL) {
 
3569
      okay = TRUE;
 
3570
    }
 
3571
  }
 
3572
  if (okay) {
 
3573
    ExploreSegment (segment, (Pointer) &sd, Asn2GphDrawSelectionPrim);
 
3574
  }
 
3575
}
 
3576
 
 
3577
static void CopyAsn2GphGraphicToClipboard (BioseqViewPtr bvp)
 
3578
{
 
3579
  if (bvp == NULL || bvp->vwr == NULL) return;
 
3580
  CopyViewer (bvp->vwr);
 
3581
}
 
3582
 
 
3583
static void PrintAsn2GphGraphic (BioseqViewPtr bvp)
 
3584
 
 
3585
{
 
3586
#ifdef WIN_MOTIF
 
3587
  if (bvp == NULL || bvp->vwr == NULL) return;
 
3588
  Message (MSG_OK, "Printing of graphics under MOTIF is not supported at this time.");
 
3589
#else
 
3590
  MsgAnswer ans;
 
3591
  if (bvp == NULL || bvp->vwr == NULL) return;
 
3592
  ans = Message (MSG_YN, "Do you want to print just the visible area?");
 
3593
  if (ans == ANS_YES) {
 
3594
    PrintViewer (bvp->vwr);
 
3595
  } else {
 
3596
    PrintAllViewer (bvp->vwr);
 
3597
  }
 
3598
#endif
 
3599
}
 
3600
 
 
3601
static Boolean SelectAsn2GphPrim (
 
3602
  SegmenT seg,
 
3603
  PrimitivE prim,
 
3604
  Uint2 segID,
 
3605
  Uint2 primID,
 
3606
  Uint2 primCt,
 
3607
  VoidPtr userdata
 
3608
)
 
3609
 
 
3610
{
 
3611
  Uint2      entityID;
 
3612
  Uint4      itemID;
 
3613
  Uint2      itemtype;
 
3614
  SelectPtr  sp;
 
3615
 
 
3616
  sp = (SelectPtr) userdata;
 
3617
  GetPrimitiveIDs (prim, &entityID, &itemID, &itemtype, NULL);
 
3618
  if (entityID == sp->entityID &&
 
3619
      itemID == sp->itemID &&
 
3620
      itemtype == sp->itemtype) {
 
3621
    HighlightPrimitive (sp->vwr, seg, prim, FRAME_PRIMITIVE);
 
3622
    /*
 
3623
    HighlightSegment (sp->vwr, seg, FRAME_SEGMENT);
 
3624
    */
 
3625
  }
 
3626
  return TRUE;
 
3627
}
 
3628
 
 
3629
static Boolean DeselectAsn2GphPrim (
 
3630
  SegmenT seg,
 
3631
  PrimitivE prim,
 
3632
  Uint2 segID,
 
3633
  Uint2 primID,
 
3634
  Uint2 primCt,
 
3635
  VoidPtr userdata
 
3636
)
 
3637
 
 
3638
{
 
3639
  Uint2      entityID;
 
3640
  Uint4      itemID;
 
3641
  Uint2      itemtype;
 
3642
  SelectPtr  sp;
 
3643
 
 
3644
  sp = (SelectPtr) userdata;
 
3645
  GetPrimitiveIDs (prim, &entityID, &itemID, &itemtype, NULL);
 
3646
  if (entityID == sp->entityID &&
 
3647
      itemID == sp->itemID &&
 
3648
      itemtype == sp->itemtype) {
 
3649
    HighlightPrimitive (sp->vwr, seg, prim, PLAIN_PRIMITIVE);
 
3650
    /*
 
3651
    HighlightSegment (sp->vwr, seg, PLAIN_SEGMENT);
 
3652
    */
 
3653
  }
 
3654
  return TRUE;
 
3655
}
 
3656
 
 
3657
static void SelectAsn2GphView (
 
3658
  BioseqViewPtr bvp,
 
3659
  Uint2 selentityID,
 
3660
  Uint2 selitemID,
 
3661
  Uint2 selitemtype,
 
3662
  SeqLocPtr region,
 
3663
  Boolean select,
 
3664
  Boolean scrollto
 
3665
)
 
3666
 
 
3667
{
 
3668
  SelectData  sd;
 
3669
 
 
3670
  if (bvp == NULL) return;
 
3671
  if (! bvp->highlightSelections) return;
 
3672
  sd.vwr = bvp->vwr;
 
3673
  sd.sel = ObjMgrGetSelected ();
 
3674
  sd.entityID = selentityID;
 
3675
  sd.itemID = selitemID;
 
3676
  sd.itemtype = selitemtype;
 
3677
  sd.region = region;
 
3678
  if (select) {
 
3679
    ExploreSegment (bvp->pict, (Pointer) &sd, SelectAsn2GphPrim);
 
3680
  } else {
 
3681
    ExploreSegment (bvp->pict, (Pointer) &sd, DeselectAsn2GphPrim);
 
3682
  }
 
3683
}
 
3684
 
 
3685
static Boolean InitSelectAsn2GphPrim (
 
3686
  SegmenT seg,
 
3687
  PrimitivE prim,
 
3688
  Uint2 segID,
 
3689
  Uint2 primID,
 
3690
  Uint2 primCt,
 
3691
  VoidPtr userdata
 
3692
)
 
3693
 
 
3694
{
 
3695
  Uint2         entityID;
 
3696
  Uint4         itemID;
 
3697
  Uint2         itemtype;
 
3698
  SelStructPtr  sel;
 
3699
  SelectPtr     sp;
 
3700
 
 
3701
  sp = (SelectPtr) userdata;
 
3702
  GetPrimitiveIDs (prim, &entityID, &itemID, &itemtype, NULL);
 
3703
  for (sel = sp->sel; sel != NULL; sel = sel->next) {
 
3704
    if (entityID == sel->entityID &&
 
3705
        itemID == sel->itemID &&
 
3706
        itemtype == sel->itemtype) {
 
3707
      HighlightPrimitive (sp->vwr, seg, prim, FRAME_PRIMITIVE);
 
3708
    }
 
3709
  }
 
3710
  return TRUE;
 
3711
}
 
3712
 
 
3713
static void InitSelectAsn2GphView (BioseqViewPtr bvp)
 
3714
 
 
3715
{
 
3716
  SelectData  sd;
 
3717
 
 
3718
  if (bvp == NULL) return;
 
3719
  if (! bvp->highlightSelections) return;
 
3720
  sd.vwr = bvp->vwr;
 
3721
  sd.sel = ObjMgrGetSelected ();
 
3722
  sd.entityID = 0;
 
3723
  sd.itemID = 0;
 
3724
  sd.itemtype = 0;
 
3725
  sd.region = NULL;
 
3726
  ExploreSegment (bvp->pict, (Pointer) &sd, InitSelectAsn2GphPrim);
 
3727
}
 
3728
 
 
3729
static void ClickAsn2GphGraphic (
 
3730
  VieweR vwr,
 
3731
  SegmenT seg,
 
3732
  PoinT pt
 
3733
)
 
3734
 
 
3735
{
 
3736
  BioseqViewPtr  bvp;
 
3737
 
 
3738
  bvp = (BioseqViewPtr) GetObjectExtra (vwr);
 
3739
  if (bvp == NULL) return;
 
3740
  bvp->wasDoubleClick = dblClick;
 
3741
  bvp->wasShiftKey = shftKey;
 
3742
  bvp->old_rect_shown = FALSE;
 
3743
  if (! dblClick) {
 
3744
    bvp->pnt_start = pt;
 
3745
  }
 
3746
  bvp->pnt_stop = pt;
 
3747
}
 
3748
 
 
3749
static void ReleaseAsn2GphGraphic (
 
3750
  VieweR vwr,
 
3751
  SegmenT seg,
 
3752
  PoinT pt
 
3753
)
 
3754
 
 
3755
{
 
3756
  BioseqViewPtr  bvp;
 
3757
  Uint2          entityID;
 
3758
  Uint4          itemID;
 
3759
  Uint2          itemtype;
 
3760
  SeqEntryPtr    sep;
 
3761
  PrimitivE      thatPrim;
 
3762
  PrimitivE      thisPrim;
 
3763
  SegmenT        smallestSeg;
 
3764
 
 
3765
  bvp = (BioseqViewPtr) GetObjectExtra (vwr);
 
3766
  if (bvp == NULL) {
 
3767
    ObjMgrDeSelect (0, 0, 0, 0, NULL);
 
3768
    return;
 
3769
  }
 
3770
 
 
3771
  smallestSeg = FindSegPrim (vwr, pt, NULL, NULL, &thisPrim);
 
3772
  if (smallestSeg == NULL || thisPrim == NULL) {
 
3773
    ObjMgrDeSelect (0, 0, 0, 0, NULL);
 
3774
    return;
 
3775
  }
 
3776
 
 
3777
  GetPrimitiveIDs (thisPrim, &entityID, &itemID, &itemtype, NULL);
 
3778
 
 
3779
  if (entityID == 0 && itemID == 0 && (itemtype == OBJ_SEQFEAT || itemtype == 0)) {
 
3780
    ObjMgrDeSelect (0, 0, 0, 0, NULL);
 
3781
    return;
 
3782
  }
 
3783
  if (bvp->wasDoubleClick) {
 
3784
 
 
3785
    seg = FindSegPrim (vwr, bvp->pnt_start, NULL, NULL, &thatPrim);
 
3786
    if (seg == smallestSeg && thisPrim == thatPrim) {
 
3787
 
 
3788
      sep = GetTopSeqEntryForEntityID (entityID);
 
3789
      if (bvp->launchSubviewers) {
 
3790
        WatchCursor ();
 
3791
        Update ();
 
3792
        LaunchNewBioseqViewer (bvp->bsp, entityID, itemID, itemtype);
 
3793
        ArrowCursor ();
 
3794
        Update ();
 
3795
        return;
 
3796
      } else if (LaunchViewerNotEditor (bvp, sep, entityID, itemID, itemtype)) {
 
3797
        WatchCursor ();
 
3798
        Update ();
 
3799
        LaunchNewBioseqViewer (bvp->bsp, entityID, itemID, itemtype);
 
3800
        ArrowCursor ();
 
3801
        Update ();
 
3802
        return;
 
3803
      } else if (bvp->launchEditors) {
 
3804
        WatchCursor ();
 
3805
        Update ();
 
3806
        GatherProcLaunch (OMPROC_EDIT, FALSE, entityID, itemID,
 
3807
                          itemtype, 0, 0, itemtype, 0);
 
3808
        ArrowCursor ();
 
3809
        Update ();
 
3810
      }
 
3811
    }
 
3812
  }
 
3813
  if (! bvp->sendSelectMessages) return;
 
3814
  if (bvp->wasShiftKey) {
 
3815
    ObjMgrAlsoSelect (entityID, itemID, itemtype, 0, NULL);
 
3816
  } else {
 
3817
    ObjMgrSelect (entityID, itemID, itemtype, 0, NULL);
 
3818
  }
 
3819
}
 
3820
 
 
3821
 
 
3822
typedef struct multiBioseqDrawState {
 
3823
  Int4 ceiling;
 
3824
  SegmenT topLevelSegment;
 
3825
  FilterPtr FP;
 
3826
  AppearancePtr AP;
 
3827
  LayoutAlgorithm overrideLayout;
 
3828
  Int4 scale;
 
3829
} MultiBioseqDrawState, PNTR MultiBioseqDrawStatePtr;
 
3830
 
 
3831
static void VisitAndDrawBioseqs (
 
3832
  BioseqPtr bsp,
 
3833
  Pointer userdata
 
3834
)
 
3835
 
 
3836
{
 
3837
  MultiBioseqDrawStatePtr state;
 
3838
  state = userdata;
 
3839
  if (state == NULL) return;
 
3840
  CreateGraphicViewFromBsp (bsp, NULL, state->scale, &state->ceiling,
 
3841
                            state->topLevelSegment, state->AP,
 
3842
                            state->FP, state->overrideLayout, NULL);
 
3843
  state->ceiling -= 25;
 
3844
}
 
3845
 
 
3846
/*
 
3847
#define TEST_SEQLOC_LIMIT
 
3848
static float START_FRACTION = 0.3;
 
3849
static float STOP_FRACTION = 0.6;
 
3850
*/
 
3851
 
 
3852
static void PopulateAsn2GphGraphic (
 
3853
  BioseqViewPtr bvp
 
3854
)
 
3855
 
 
3856
{
 
3857
  BioseqPtr    bsp;
 
3858
  Uint2        entityID;
 
3859
  Uint2        i;
 
3860
  Int4         len;
 
3861
  Int4         max;
 
3862
  Int4         min;
 
3863
 
 
3864
  SeqEntryPtr  oldscope = NULL;
 
3865
  RecT         r;
 
3866
  Int4         scaleX;
 
3867
 
 
3868
  SeqEntryPtr  sep;
 
3869
  Char         str[32];
 
3870
  Int4         vwr_x;
 
3871
  Int4         vwr_y;
 
3872
  Int2         vwr_align;
 
3873
 
 
3874
  CharPtr PNTR nameList;
 
3875
  CharPtr      appearanceName;
 
3876
  CharPtr      filterName;
 
3877
  CharPtr      layoutName;
 
3878
  /*
 
3879
  CharPtr      alignScoreName;
 
3880
  */
 
3881
  CharPtr      alignScoreCutoff;
 
3882
  GraphicViewExtras gvExtras;
 
3883
 
 
3884
  ViewerConfigsPtr  myVCP;
 
3885
 
 
3886
  MultiBioseqDrawState drawState;
 
3887
 
 
3888
  SeqViewProcsPtr  svpp;
 
3889
 
 
3890
  if (bvp == NULL) return;
 
3891
 
 
3892
  WatchCursor ();
 
3893
 
 
3894
  vwr_x = INT4_MIN;
 
3895
  vwr_y = INT4_MAX;
 
3896
  vwr_align = UPPER_LEFT;
 
3897
  if (bvp->moveToOldPos) {
 
3898
    if (bvp->pict != NULL) {
 
3899
      get_viewer_position (bvp->vwr, &(vwr_x), &(vwr_y));
 
3900
      vwr_align = MIDDLE_CENTER;
 
3901
    }
 
3902
    bvp->moveToOldPos = FALSE;
 
3903
  }
 
3904
 
 
3905
  Reset (bvp->vwr);
 
3906
  bvp->pict = DeletePicture (bvp->pict);
 
3907
  Update ();
 
3908
 
 
3909
  bsp = bvp->bsp;
 
3910
  if (bsp == NULL) {
 
3911
    ArrowCursor ();
 
3912
    return;
 
3913
  }
 
3914
 
 
3915
  svpp = (SeqViewProcsPtr) GetAppProperty ("SeqDisplayForm");
 
3916
  if (svpp != NULL && svpp->lockFarComponents) {
 
3917
    entityID = ObjMgrGetEntityIDForPointer (bsp);
 
3918
    sep = GetTopSeqEntryForEntityID (entityID);
 
3919
    LookupFarSeqIDs (sep, TRUE, FALSE, FALSE, FALSE, FALSE);
 
3920
  }
 
3921
 
 
3922
  if (bvp->scaleNotCalculated) {
 
3923
    SafeHide (bvp->newGphScale);
 
3924
    Reset (bvp->newGphScale);
 
3925
    ObjectRect (bvp->vwr, &r);
 
3926
    InsetRect (&r, 4, 4);
 
3927
    len = bsp->length;
 
3928
    max = (Int4) MAX (len / (Int4) (r.right - r.left), 1) + 2;
 
3929
    max = (Int4) MIN (max, 50000L);
 
3930
    min = (Int4) MAX (len / 320000L, 1L);
 
3931
    bvp->maxScale = max;
 
3932
    i = 1;
 
3933
    /*      while (i < MAXZOOMSCALEVAL && min > zoomScaleVal[i]) {
 
3934
      i++;
 
3935
      }*/
 
3936
    bvp->minIndex = i;
 
3937
    while (i < MAXZOOMSCALEVAL && max > zoomScaleVal[i - 1]) {
 
3938
      sprintf (str, "%ld", (long) (zoomScaleVal[i]));
 
3939
      if (max < zoomScaleVal[i]) {
 
3940
        sprintf (str, "%ld", (long) zoomScaleVal[i]);
 
3941
      }
 
3942
      PopupItem (bvp->newGphScale, str);
 
3943
      i++;
 
3944
    }
 
3945
    SetValue (bvp->newGphScale, MAX (i - bvp->minIndex, 1));
 
3946
    bvp->scaleNotCalculated = FALSE;
 
3947
  }
 
3948
  SafeShow (bvp->newGphScale);
 
3949
  i = GetValue (bvp->newGphScale) - 1 + bvp->minIndex;
 
3950
  if (i < MAXZOOMSCALEVAL && i > 0) {
 
3951
    /*    scaleX = MIN (zoomScaleVal[i], bvp->maxScale);*/
 
3952
    scaleX = zoomScaleVal[i];
 
3953
  } else {
 
3954
    scaleX = bvp->minIndex;
 
3955
  }
 
3956
 
 
3957
  i = GetValue (bvp->newGphFilter) - 1;
 
3958
  nameList = GetFilterNameList ();
 
3959
  if (i < GetFilterCount ()) {
 
3960
    filterName = nameList [i];
 
3961
  } else {
 
3962
    filterName = "default"; /* as good a guess as any, and it _should_ exist in the config file*/
 
3963
  }
 
3964
 
 
3965
  i = GetValue (bvp->newGphStyle) - 1;
 
3966
  nameList = GetStyleNameList ();
 
3967
  if (i < GetAppearanceCount ()) {
 
3968
    appearanceName = nameList [i];
 
3969
  } else {
 
3970
    appearanceName = "default";
 
3971
  }
 
3972
 
 
3973
  i = GetValue (bvp->newGphLayout) - 1;
 
3974
  nameList = GetLayoutNameList ();
 
3975
  if (i < GetLayoutCount()) {
 
3976
    layoutName = nameList[i];
 
3977
  } else {
 
3978
    layoutName = NULL; /* no need to pass a dummy string for an optional value */
 
3979
  }
 
3980
 
 
3981
  MemSet ((Pointer) &gvExtras, 0, sizeof (GraphicViewExtras));
 
3982
  if (GetAppProperty("GPHVIEWSCOREALIGNS") != NULL) {
 
3983
  /*
 
3984
    i = GetValue (bvp->newGphAlnScore) - 1;
 
3985
    nameList = GetAlnScoreNameList ();
 
3986
    if (i < GetAlnScoreCount ()) {
 
3987
      alignScoreName = nameList [i];
 
3988
    } else {
 
3989
      alignScoreName = nameList[0];
 
3990
    }
 
3991
    gvExtras.alignScoreName = alignScoreName;
 
3992
  */
 
3993
    i = GetValue (bvp->newGphAlnCutoff) - 1;
 
3994
    nameList = GetAlnScoreCutoffList ();
 
3995
    if (i < GetAlnScoreCutoffCount ()) {
 
3996
      alignScoreCutoff = nameList [i];
 
3997
    } else {
 
3998
      alignScoreCutoff = nameList[0];
 
3999
    }
 
4000
    gvExtras.alignScoreCutoff = alignScoreCutoff;
 
4001
  } else {
 
4002
    gvExtras.alignScoreName = "";
 
4003
    gvExtras.alignScoreCutoff = "";
 
4004
  }
 
4005
 
 
4006
  if (!bvp->viewWholeEntity) {
 
4007
    sep = SeqMgrGetSeqEntryForData (bsp);
 
4008
    entityID = ObjMgrGetEntityIDForChoice (sep);
 
4009
    if (entityID > 0) {
 
4010
      sep = GetBestTopParentForData (entityID, bsp);
 
4011
      oldscope = SeqEntrySetScope (sep);
 
4012
    }
 
4013
 
 
4014
#ifdef TEST_SEQLOC_LIMIT
 
4015
{
 
4016
   SeqInt si;
 
4017
   ValNode vn;
 
4018
 
 
4019
     MemSet ((Pointer) (&si), 0, sizeof (SeqInt));
 
4020
     MemSet ((Pointer) (&vn), 0, sizeof (ValNode));
 
4021
 
 
4022
     si.from = bsp->length * START_FRACTION;
 
4023
     si.to = bsp->length * STOP_FRACTION;
 
4024
     si.strand = Seq_strand_plus;
 
4025
     si.id = bsp->id;
 
4026
 
 
4027
     vn.choice = SEQLOC_INT;
 
4028
     vn.data.ptrvalue = &si;
 
4029
 
 
4030
     bvp->pict = CreateGraphicView (bsp, &vn, scaleX, appearanceName, filterName, layoutName, &gvExtras);
 
4031
}
 
4032
#else
 
4033
     bvp->pict = CreateGraphicView (bsp, NULL, scaleX, appearanceName, filterName, layoutName, &gvExtras);
 
4034
#endif
 
4035
 
 
4036
     if (entityID > 0) {
 
4037
       SeqEntrySetScope (oldscope);
 
4038
     }
 
4039
 
 
4040
   } else {
 
4041
     sep = SeqMgrGetSeqEntryForData (bsp);
 
4042
     entityID = ObjMgrGetEntityIDForChoice (sep);
 
4043
     if (entityID > 0) {
 
4044
       sep = GetTopSeqEntryForEntityID (entityID);
 
4045
       oldscope = SeqEntrySetScope (sep);
 
4046
     }
 
4047
 
 
4048
     drawState.scale = scaleX;
 
4049
     drawState.ceiling = 0;
 
4050
     drawState.topLevelSegment = CreatePicture ();
 
4051
     myVCP = GetGraphicConfigParseResults ();
 
4052
     drawState.FP = FindFilterByName (filterName, myVCP);
 
4053
     drawState.AP = FindAppearanceByName (appearanceName, myVCP);
 
4054
     drawState.overrideLayout = FindLayoutByName (layoutName);
 
4055
 
 
4056
     VisitBioseqsInSep (sep, &drawState, VisitAndDrawBioseqs);
 
4057
     bvp->pict = drawState.topLevelSegment;
 
4058
   }
 
4059
 
 
4060
   AttachPicture (bvp->vwr, bvp->pict, vwr_x, vwr_y, vwr_align, scaleX, 1, bvp->highlightSelections ? Asn2GphDrawSelectionRange : NULL);
 
4061
   SetViewerProcs (bvp->vwr, ClickAsn2GphGraphic, NULL, ReleaseAsn2GphGraphic, NULL);
 
4062
 
 
4063
   InitSelectAsn2GphView (bvp);
 
4064
 
 
4065
   ArrowCursor ();
 
4066
}
 
4067
 
 
4068
static void ShowAsn2GphGraphic (
 
4069
  BioseqViewPtr bvp,
 
4070
  Boolean show
 
4071
)
 
4072
 
 
4073
{
 
4074
  if (bvp == NULL)
 
4075
    return;
 
4076
  if (show) {
 
4077
    SafeShow (bvp->vwr);
 
4078
    SafeShow (bvp->newGphControlGrp);
 
4079
    EnableDisableLegendItem (bvp, TRUE);
 
4080
    SafeHide (bvp->findGeneGrp);
 
4081
    SafeShow (bvp->clickMe);
 
4082
  } else {
 
4083
    SafeHide (bvp->vwr);
 
4084
    Reset (bvp->vwr);
 
4085
    bvp->pict = DeletePicture (bvp->pict);
 
4086
    SafeHide (bvp->styleControlGrp);
 
4087
    SafeHide (bvp->scaleControlGrp);
 
4088
    EnableDisableLegendItem (bvp, FALSE);
 
4089
    SafeHide (bvp->findGeneGrp);
 
4090
    SafeHide (bvp->docTxtControlGrp);
 
4091
    SafeHide (bvp->baseCtgControlGrp);
 
4092
    SafeHide (bvp->modeControlGrp);
 
4093
    SafeHide (bvp->newGphControlGrp);
 
4094
    SafeHide (bvp->clickMe);
 
4095
  }
 
4096
}
 
4097
 
 
4098
static void ResizeAsn2GphGraphic (BioseqViewPtr bvp)
 
4099
 
 
4100
{
 
4101
  if (bvp == NULL) return;
 
4102
  if (bvp->vwr != NULL) {
 
4103
    if (Visible (bvp->vwr) && AllParentsVisible (bvp->vwr)) {
 
4104
      ViewerWasResized (bvp->vwr);
 
4105
    }
 
4106
  }
 
4107
}
 
4108
 
 
4109
BioseqPageData  asn2gphGphPageData = {
 
4110
  "Graphic", TRUE, TRUE, TRUE, FALSE, -1,
 
4111
  PopulateAsn2GphGraphic, ShowAsn2GphGraphic, SelectAsn2GphView,
 
4112
  CopyAsn2GphGraphicToClipboard, PrintAsn2GphGraphic, NULL, NULL,
 
4113
  ResizeAsn2GphGraphic, NULL
 
4114
};
 
4115