3471
3479
CopyGraphicalToClipboard, PrintGraphical,
3472
3480
NULL, NULL, ResizeDesktop, NULL
3483
/* new graphical viewer - sequin integration */
3485
#include <asn2graphicp.h>
3487
static void Asn2GphSelectRegion (VieweR viewer, SegmenT segment, PrimitivE primitive,
3488
SeqLocPtr region, Uint2 entityID)
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);
3518
ObjectRect (viewer, &s);
3519
InsetRect (&s, 2, 2);
3520
SectRect (&r, &s, &d);
3521
tempPort = SavePort (viewer);
3526
RestorePort (tempPort);
3530
static Boolean Asn2GphDrawSelectionPrim (SegmenT seg, PrimitivE prim, Uint2 segID,
3531
Uint2 primID, Uint2 primCt, VoidPtr userdata)
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);
3553
static void Asn2GphDrawSelectionRange (VieweR viewer, SegmenT segment)
3561
sd.sel = ObjMgrGetSelected ();
3567
for (sel = sd.sel; sel != NULL; sel = sel->next) {
3568
if (sel->itemtype == OBJ_BIOSEQ && sel->region != NULL) {
3573
ExploreSegment (segment, (Pointer) &sd, Asn2GphDrawSelectionPrim);
3577
static void CopyAsn2GphGraphicToClipboard (BioseqViewPtr bvp)
3579
if (bvp == NULL || bvp->vwr == NULL) return;
3580
CopyViewer (bvp->vwr);
3583
static void PrintAsn2GphGraphic (BioseqViewPtr bvp)
3587
if (bvp == NULL || bvp->vwr == NULL) return;
3588
Message (MSG_OK, "Printing of graphics under MOTIF is not supported at this time.");
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);
3596
PrintAllViewer (bvp->vwr);
3601
static Boolean SelectAsn2GphPrim (
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);
3623
HighlightSegment (sp->vwr, seg, FRAME_SEGMENT);
3629
static Boolean DeselectAsn2GphPrim (
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);
3651
HighlightSegment (sp->vwr, seg, PLAIN_SEGMENT);
3657
static void SelectAsn2GphView (
3670
if (bvp == NULL) return;
3671
if (! bvp->highlightSelections) return;
3673
sd.sel = ObjMgrGetSelected ();
3674
sd.entityID = selentityID;
3675
sd.itemID = selitemID;
3676
sd.itemtype = selitemtype;
3679
ExploreSegment (bvp->pict, (Pointer) &sd, SelectAsn2GphPrim);
3681
ExploreSegment (bvp->pict, (Pointer) &sd, DeselectAsn2GphPrim);
3685
static Boolean InitSelectAsn2GphPrim (
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);
3713
static void InitSelectAsn2GphView (BioseqViewPtr bvp)
3718
if (bvp == NULL) return;
3719
if (! bvp->highlightSelections) return;
3721
sd.sel = ObjMgrGetSelected ();
3726
ExploreSegment (bvp->pict, (Pointer) &sd, InitSelectAsn2GphPrim);
3729
static void ClickAsn2GphGraphic (
3738
bvp = (BioseqViewPtr) GetObjectExtra (vwr);
3739
if (bvp == NULL) return;
3740
bvp->wasDoubleClick = dblClick;
3741
bvp->wasShiftKey = shftKey;
3742
bvp->old_rect_shown = FALSE;
3744
bvp->pnt_start = pt;
3749
static void ReleaseAsn2GphGraphic (
3763
SegmenT smallestSeg;
3765
bvp = (BioseqViewPtr) GetObjectExtra (vwr);
3767
ObjMgrDeSelect (0, 0, 0, 0, NULL);
3771
smallestSeg = FindSegPrim (vwr, pt, NULL, NULL, &thisPrim);
3772
if (smallestSeg == NULL || thisPrim == NULL) {
3773
ObjMgrDeSelect (0, 0, 0, 0, NULL);
3777
GetPrimitiveIDs (thisPrim, &entityID, &itemID, &itemtype, NULL);
3779
if (entityID == 0 && itemID == 0 && (itemtype == OBJ_SEQFEAT || itemtype == 0)) {
3780
ObjMgrDeSelect (0, 0, 0, 0, NULL);
3783
if (bvp->wasDoubleClick) {
3785
seg = FindSegPrim (vwr, bvp->pnt_start, NULL, NULL, &thatPrim);
3786
if (seg == smallestSeg && thisPrim == thatPrim) {
3788
sep = GetTopSeqEntryForEntityID (entityID);
3789
if (bvp->launchSubviewers) {
3792
LaunchNewBioseqViewer (bvp->bsp, entityID, itemID, itemtype);
3796
} else if (LaunchViewerNotEditor (bvp, sep, entityID, itemID, itemtype)) {
3799
LaunchNewBioseqViewer (bvp->bsp, entityID, itemID, itemtype);
3803
} else if (bvp->launchEditors) {
3806
GatherProcLaunch (OMPROC_EDIT, FALSE, entityID, itemID,
3807
itemtype, 0, 0, itemtype, 0);
3813
if (! bvp->sendSelectMessages) return;
3814
if (bvp->wasShiftKey) {
3815
ObjMgrAlsoSelect (entityID, itemID, itemtype, 0, NULL);
3817
ObjMgrSelect (entityID, itemID, itemtype, 0, NULL);
3822
typedef struct multiBioseqDrawState {
3824
SegmenT topLevelSegment;
3827
LayoutAlgorithm overrideLayout;
3829
} MultiBioseqDrawState, PNTR MultiBioseqDrawStatePtr;
3831
static void VisitAndDrawBioseqs (
3837
MultiBioseqDrawStatePtr state;
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;
3847
#define TEST_SEQLOC_LIMIT
3848
static float START_FRACTION = 0.3;
3849
static float STOP_FRACTION = 0.6;
3852
static void PopulateAsn2GphGraphic (
3864
SeqEntryPtr oldscope = NULL;
3874
CharPtr PNTR nameList;
3875
CharPtr appearanceName;
3879
CharPtr alignScoreName;
3881
CharPtr alignScoreCutoff;
3882
GraphicViewExtras gvExtras;
3884
ViewerConfigsPtr myVCP;
3886
MultiBioseqDrawState drawState;
3888
SeqViewProcsPtr svpp;
3890
if (bvp == NULL) return;
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;
3902
bvp->moveToOldPos = FALSE;
3906
bvp->pict = DeletePicture (bvp->pict);
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);
3922
if (bvp->scaleNotCalculated) {
3923
SafeHide (bvp->newGphScale);
3924
Reset (bvp->newGphScale);
3925
ObjectRect (bvp->vwr, &r);
3926
InsetRect (&r, 4, 4);
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;
3933
/* while (i < MAXZOOMSCALEVAL && min > zoomScaleVal[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]);
3942
PopupItem (bvp->newGphScale, str);
3945
SetValue (bvp->newGphScale, MAX (i - bvp->minIndex, 1));
3946
bvp->scaleNotCalculated = FALSE;
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];
3954
scaleX = bvp->minIndex;
3957
i = GetValue (bvp->newGphFilter) - 1;
3958
nameList = GetFilterNameList ();
3959
if (i < GetFilterCount ()) {
3960
filterName = nameList [i];
3962
filterName = "default"; /* as good a guess as any, and it _should_ exist in the config file*/
3965
i = GetValue (bvp->newGphStyle) - 1;
3966
nameList = GetStyleNameList ();
3967
if (i < GetAppearanceCount ()) {
3968
appearanceName = nameList [i];
3970
appearanceName = "default";
3973
i = GetValue (bvp->newGphLayout) - 1;
3974
nameList = GetLayoutNameList ();
3975
if (i < GetLayoutCount()) {
3976
layoutName = nameList[i];
3978
layoutName = NULL; /* no need to pass a dummy string for an optional value */
3981
MemSet ((Pointer) &gvExtras, 0, sizeof (GraphicViewExtras));
3982
if (GetAppProperty("GPHVIEWSCOREALIGNS") != NULL) {
3984
i = GetValue (bvp->newGphAlnScore) - 1;
3985
nameList = GetAlnScoreNameList ();
3986
if (i < GetAlnScoreCount ()) {
3987
alignScoreName = nameList [i];
3989
alignScoreName = nameList[0];
3991
gvExtras.alignScoreName = alignScoreName;
3993
i = GetValue (bvp->newGphAlnCutoff) - 1;
3994
nameList = GetAlnScoreCutoffList ();
3995
if (i < GetAlnScoreCutoffCount ()) {
3996
alignScoreCutoff = nameList [i];
3998
alignScoreCutoff = nameList[0];
4000
gvExtras.alignScoreCutoff = alignScoreCutoff;
4002
gvExtras.alignScoreName = "";
4003
gvExtras.alignScoreCutoff = "";
4006
if (!bvp->viewWholeEntity) {
4007
sep = SeqMgrGetSeqEntryForData (bsp);
4008
entityID = ObjMgrGetEntityIDForChoice (sep);
4010
sep = GetBestTopParentForData (entityID, bsp);
4011
oldscope = SeqEntrySetScope (sep);
4014
#ifdef TEST_SEQLOC_LIMIT
4019
MemSet ((Pointer) (&si), 0, sizeof (SeqInt));
4020
MemSet ((Pointer) (&vn), 0, sizeof (ValNode));
4022
si.from = bsp->length * START_FRACTION;
4023
si.to = bsp->length * STOP_FRACTION;
4024
si.strand = Seq_strand_plus;
4027
vn.choice = SEQLOC_INT;
4028
vn.data.ptrvalue = &si;
4030
bvp->pict = CreateGraphicView (bsp, &vn, scaleX, appearanceName, filterName, layoutName, &gvExtras);
4033
bvp->pict = CreateGraphicView (bsp, NULL, scaleX, appearanceName, filterName, layoutName, &gvExtras);
4037
SeqEntrySetScope (oldscope);
4041
sep = SeqMgrGetSeqEntryForData (bsp);
4042
entityID = ObjMgrGetEntityIDForChoice (sep);
4044
sep = GetTopSeqEntryForEntityID (entityID);
4045
oldscope = SeqEntrySetScope (sep);
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);
4056
VisitBioseqsInSep (sep, &drawState, VisitAndDrawBioseqs);
4057
bvp->pict = drawState.topLevelSegment;
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);
4063
InitSelectAsn2GphView (bvp);
4068
static void ShowAsn2GphGraphic (
4077
SafeShow (bvp->vwr);
4078
SafeShow (bvp->newGphControlGrp);
4079
EnableDisableLegendItem (bvp, TRUE);
4080
SafeHide (bvp->findGeneGrp);
4081
SafeShow (bvp->clickMe);
4083
SafeHide (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);
4098
static void ResizeAsn2GphGraphic (BioseqViewPtr bvp)
4101
if (bvp == NULL) return;
4102
if (bvp->vwr != NULL) {
4103
if (Visible (bvp->vwr) && AllParentsVisible (bvp->vwr)) {
4104
ViewerWasResized (bvp->vwr);
4109
BioseqPageData asn2gphGphPageData = {
4110
"Graphic", TRUE, TRUE, TRUE, FALSE, -1,
4111
PopulateAsn2GphGraphic, ShowAsn2GphGraphic, SelectAsn2GphView,
4112
CopyAsn2GphGraphicToClipboard, PrintAsn2GphGraphic, NULL, NULL,
4113
ResizeAsn2GphGraphic, NULL