/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ #include #include "guiCompareContigs.h" #include "compareContigs.h" #include #include #include #include #include #include #include "guiapp.h" #include #include #include #include "assert.h" #include "guicolortext.h" #include "compareContigsTypes.h" #include #include "hp_exception_kludge.h" #include "colorDefaults.h" #include "centerWidgetOnWidget.h" #include "handleWindowManagerDelete.h" #include #include "contig.h" #include "contigwin.h" #include "guicontigwin.h" static const int nNumberOfBasesToOverlapWhenPaging2 = 15; static const int nSpaceBetweenButtons = 10; static void cbComplementContig1( Widget wid, XtPointer pClientData, XtPointer pCallData ) { TRY_CATCH_WRAPPER( guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; pGuiCompareContigs->pCompareContigs_->complementContig( eContig1 ); ); } static void cbComplementContig2( Widget wid, XtPointer pClientData, XtPointer pCallData ) { TRY_CATCH_WRAPPER( guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; pGuiCompareContigs->pCompareContigs_->complementContig( eContig2 ); ); } static void cbPreviousDiscrepancy( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; TRY_CATCH_WRAPPER( pGuiCompareContigs->pCompareContigs_->prevNextDiscrepancy( compareContigs::ePrevDiscrepancy ) ); } static void cbNextDiscrepancy( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; TRY_CATCH_WRAPPER( pGuiCompareContigs->pCompareContigs_->prevNextDiscrepancy( compareContigs::eNextDiscrepancy ) ); } guiCompareContigs :: guiCompareContigs(compareContigs* pCompareContigs ) : pCompareContigs_( pCompareContigs ) { int nArgs; Arg aArg[50]; if ( pCompareContigs_->pContigWin1_ ) { // place the window somewhat below the Aligned Reads Window Dimension nHeight; Dimension nWidth; Position nY; Position nX; XtVaGetValues( pCompareContigs_->pContigWin1_->pGcw_->widGetGuiContigWinTopLevel(), XmNheight, &nHeight, XmNwidth, &nWidth, XmNy, &nY, XmNx, &nX, NULL ); widPopupShell_ = XtVaCreatePopupShell("consed", topLevelShellWidgetClass, GuiApp::pGetGuiApp()->widGetTopLevel(), XmNtitle, "Compare Contigs", XmNnoResize, False, XmNautoUnmanage, False, XmNtransient, False, XmNdeleteResponse, XmDO_NOTHING, XmNy, nY + 40, XmNx, nX + 40, NULL ); } else { widPopupShell_ = XtVaCreatePopupShell("consed", topLevelShellWidgetClass, GuiApp::pGetGuiApp()->widGetTopLevel(), XmNtitle, "Compare Contigs", XmNnoResize, False, XmNautoUnmanage, False, XmNtransient, False, XmNdeleteResponse, XmDO_NOTHING, NULL ); } handleWindowManagerDelete( widPopupShell_ ); // the immediate child of the application shell is a // main window Widget widMainWin = XtVaCreateManagedWidget("mainwin", xmMainWindowWidgetClass, widPopupShell_, XmNancestorSensitive, True, NULL ); // // create the form widget // nArgs = 0; XtSetArg(aArg[nArgs],XmNshadowThickness,0); nArgs++; XtSetArg(aArg[nArgs],XmNborderWidth,0); nArgs++; XtSetArg(aArg[nArgs],XmNwidth, (Dimension) (GuiApp::pGetGuiApp()->nGetDisplayWidth() * .8 )); nArgs++; Widget widForm = XmCreateForm(widMainWin, "form", aArg, nArgs); XtManageChild(widForm); Widget widFormContig1 = XtVaCreateManagedWidget( "contig1form", xmFormWidgetClass, widForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 20, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNshadowThickness, 0, XmNborderWidth, 0, NULL ); widContigName1_ = XtVaCreateManagedWidget( "contig name2", xmTextWidgetClass, widFormContig1, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNeditable, false, XmNcursorPositionVisible, false, XmNtraversalOn, false, XmNcolumns, 20, XmNvalue, "(no contig)", NULL ); widComplementContig1_ = XtVaCreateManagedWidget( "complement_contig1", xmPushButtonWidgetClass, widFormContig1, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widContigName1_, XmNleftOffset, 20, NULL ); XtAddCallback( widComplementContig1_, XmNactivateCallback, cbComplementContig1, this ); setComplementContigButton( eContig1 ); // // create the 1st scrollbar // widScrollBar1_ = XtVaCreateManagedWidget("scrollbar1", xmScrollBarWidgetClass, widForm, XmNorientation, XmHORIZONTAL, XmNminimum, 0, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widFormContig1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL ); // add scrollbar callbacks XtAddCallback(widScrollBar1_, XmNvalueChangedCallback, (XtCallbackProc )scrollBarXtCb, this); XtAddCallback(widScrollBar1_, XmNdragCallback, (XtCallbackProc )scrollBarXtCb, this); Widget widFrame1 = XtVaCreateManagedWidget( "frame1", xmFrameWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widScrollBar1_, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNshadowType, XmSHADOW_IN, NULL ); widDrawingArea1_ = XtVaCreateManagedWidget( "drawing area1", xmDrawingAreaWidgetClass, widFrame1, XmNheight, nDrawingArea1Height(), NULL ); XtAddCallback( widDrawingArea1_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); XtAddEventHandler( widDrawingArea1_, ButtonPressMask, False, (XtEventHandler) guiCompareContigsButtonPressXtEventHandler, this ); Widget widFrame2 = XtVaCreateManagedWidget( "frame2", xmFrameWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widFrame1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNshadowType, XmSHADOW_IN, NULL ); widDrawingArea2_ = XtVaCreateManagedWidget( "drawing area2", xmDrawingAreaWidgetClass, widFrame2, XmNheight, nDrawingArea2Height(), NULL ); XtAddCallback( widDrawingArea2_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); XtAddEventHandler( widDrawingArea2_, ButtonPressMask, False, (XtEventHandler) guiCompareContigsButtonPressXtEventHandler, this ); // // create the 2nd scrollbar // widScrollBar2_ = XtVaCreateManagedWidget("scrollbar2", xmScrollBarWidgetClass, widForm, XmNorientation, XmHORIZONTAL, XmNminimum, 0, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widFrame2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL ); // add scrollbar callbacks XtAddCallback(widScrollBar2_, XmNvalueChangedCallback, (XtCallbackProc )scrollBarXtCb, this); XtAddCallback(widScrollBar2_, XmNdragCallback, (XtCallbackProc )scrollBarXtCb, this); Widget widFormContig2 = XtVaCreateManagedWidget( "formContig2", xmFormWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widScrollBar2_, XmNbottomOffset, 20, XmNshadowThickness, 0, XmNborderWidth, 0, NULL ); widContigName2_ = XtVaCreateManagedWidget( "contig name2", xmTextWidgetClass, widFormContig2, XmNeditable, false, XmNcursorPositionVisible, false, XmNtraversalOn, false, XmNcolumns, 20, XmNvalue, "(no contig)", XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL ); widComplementContig2_ = XtVaCreateManagedWidget( "complement_contig2", xmPushButtonWidgetClass, widFormContig2, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widContigName2_, XmNleftOffset, 20, NULL ); XtAddCallback( widComplementContig2_, XmNactivateCallback, cbComplementContig2, this ); setComplementContigButton( eContig2 ); widAlignButton_ = XtVaCreateManagedWidget( "Align", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widFormContig2, XmNalignment, XmALIGNMENT_CENTER, XmNtraversalOn, false, NULL ); centerWidgetOnWidget( widAlignButton_, widForm ); XtAddCallback(widAlignButton_, XmNactivateCallback, (XtCallbackProc )alignButtonCb, this); Widget widAlignmentFrame = XtVaCreateManagedWidget( "alignment frame", xmFrameWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widAlignButton_, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomOffset, 50, XmNshadowType, XmSHADOW_IN, NULL ); widAlignmentDrawingArea_ = XtVaCreateManagedWidget( "alignment", xmDrawingAreaWidgetClass, widAlignmentFrame, XmNheight, nAlignmentDrawingAreaHeight(), NULL ); XtAddCallback( widAlignmentDrawingArea_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); XtAddEventHandler( widAlignmentDrawingArea_, ButtonPressMask, False, (XtEventHandler) guiCompareContigsButtonPressXtEventHandler, this ); widAlignmentScrollBar_ = XtVaCreateManagedWidget("alignment scrollbar", xmScrollBarWidgetClass, widForm, XmNorientation, XmHORIZONTAL, XmNminimum, 0, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widAlignmentFrame, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL ); // add scrollbar callbacks XtAddCallback(widAlignmentScrollBar_, XmNvalueChangedCallback, (XtCallbackProc )scrollBarXtCb, this); XtAddCallback(widAlignmentScrollBar_, XmNdragCallback, (XtCallbackProc )scrollBarXtCb, this); Widget widConnectWidgetsToThis = widAlignmentScrollBar_; Widget widFormWithScrollBothAlignedReads = XtVaCreateManagedWidget( "formWithScrollBothAlignedReads", xmFormWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widConnectWidgetsToThis, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNshadowThickness, 0, NULL ); widConnectWidgetsToThis = widFormWithScrollBothAlignedReads; Widget widNumberOfDiscrepanciesLabel = XtVaCreateManagedWidget( "# discrepancies:", xmLabelWidgetClass, widFormWithScrollBothAlignedReads, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, NULL ); widNumberOfDiscrepancies_ = XtVaCreateManagedWidget( "numberOfDiscrepancies", xmTextWidgetClass, widFormWithScrollBothAlignedReads, XmNeditable, false, XmNcursorPositionVisible, false, XmNtraversalOn, false, XmNcolumns, 10, XmNvalue, "(doing...)", XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widNumberOfDiscrepanciesLabel, NULL ); Widget widDiscrepancyRateLabel = XtVaCreateManagedWidget( "discrep %", xmLabelWidgetClass, widFormWithScrollBothAlignedReads, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widNumberOfDiscrepancies_, NULL ); widDiscrepancyRate_ = XtVaCreateManagedWidget( "discrepancyRate", xmTextWidgetClass, widFormWithScrollBothAlignedReads, XmNeditable, false, XmNcursorPositionVisible, false, XmNtraversalOn, false, XmNcolumns, 10, XmNvalue, "(doing...)", XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widDiscrepancyRateLabel, NULL ); widPrevDiscrepancyButton_ = XtVaCreateManagedWidget( "Prev Discrepancy", xmPushButtonWidgetClass, widFormWithScrollBothAlignedReads, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widDiscrepancyRate_, XmNtraversalOn, false, NULL ); XtAddCallback( widPrevDiscrepancyButton_, XmNactivateCallback, (XtCallbackProc) cbPreviousDiscrepancy, this ); widScrollContigwinsButton_ = XtVaCreateManagedWidget( "Scroll Both Aligned Reads Windows", xmPushButtonWidgetClass, widFormWithScrollBothAlignedReads, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widPrevDiscrepancyButton_, XmNtraversalOn, false, NULL ); XtAddCallback(widScrollContigwinsButton_, XmNactivateCallback, (XtCallbackProc )scrollContigWinButtonCb, this); widNextDiscrepancyButton_ = XtVaCreateManagedWidget( "Next Discrepancy", xmPushButtonWidgetClass, widFormWithScrollBothAlignedReads, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widScrollContigwinsButton_, NULL ); XtAddCallback( widNextDiscrepancyButton_, XmNactivateCallback, (XtCallbackProc) cbNextDiscrepancy, this ); Widget widHighlightRightReadsForm = XtVaCreateManagedWidget( "highlightRightReadsForm", xmFormWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widConnectWidgetsToThis, XmNleftAttachment, XmATTACH_FORM, NULL ); Widget widHighlightRightReadsLabel = XtVaCreateManagedWidget( "If join, highlight reads from old right contig?", xmLabelWidgetClass, widHighlightRightReadsForm, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNtraversalOn, False, NULL ); Widget widHighlightRightReadsRadioBox = XmCreateRadioBox( widHighlightRightReadsForm, "radio", NULL, 0 ); XtVaSetValues( widHighlightRightReadsRadioBox, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, widHighlightRightReadsLabel, XmNtraversalOn, True, XmNorientation, XmHORIZONTAL, XmNshadowThickness, 0, XmNborderWidth, 0, XmNmarginWidth, 0, NULL ); widHighlightRightReadsTrue_ = XtVaCreateManagedWidget( "True", xmToggleButtonWidgetClass, widHighlightRightReadsRadioBox, XmNset, True, NULL ); Widget widHighlightRightReadsFalse = XtVaCreateManagedWidget( "False", xmToggleButtonWidgetClass, widHighlightRightReadsRadioBox, XmNset, False, NULL ); XtManageChild( widHighlightRightReadsRadioBox ); widConnectWidgetsToThis = widHighlightRightReadsForm; // bottom row widDismissButton_ = XtVaCreateManagedWidget( "Dismiss", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widConnectWidgetsToThis, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, nSpaceBetweenButtons, XmNalignment, XmALIGNMENT_CENTER, XmNtraversalOn, false, NULL ); // centerWidgetOnWidget( widDismissButton_, widForm ); XtAddCallback(widDismissButton_, XmNactivateCallback, (XtCallbackProc )dismissButtonCb, this); widJoinContigsButton_ = XtVaCreateManagedWidget( "Join Contigs", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widConnectWidgetsToThis, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, widDismissButton_, XmNrightOffset, nSpaceBetweenButtons, XmNalignment, XmALIGNMENT_CENTER, XmNtraversalOn, false, NULL ); XtAddCallback( widJoinContigsButton_, XmNactivateCallback, (XtCallbackProc) joinContigsButtonCb, this ); widCreateFakeReadButton_ = XtVaCreateManagedWidget( "Create Fake Read to Direct Phrap", xmPushButtonWidgetClass, widForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widConnectWidgetsToThis, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, widJoinContigsButton_, XmNrightOffset, nSpaceBetweenButtons, XmNtraversalOn, False, NULL ); XtAddCallback( widCreateFakeReadButton_, XmNactivateCallback, (XtCallbackProc )createFakeReadButtonCb, this ); // widCompareContigsOptionsButton_ = XtVaCreateManagedWidget( // "Options", // xmPushButtonWidgetClass, // widForm, // XmNtopAttachment, XmATTACH_WIDGET, // XmNtopWidget, widScrollContigwin2Button_, // XmNrightAttachment, XmATTACH_WIDGET, // XmNrightWidget, widJoinContigsButton_, // XmNrightOffset, nSpaceBetweenButtons, // XmNalignment, XmALIGNMENT_CENTER, // XmNtraversalOn, false, // NULL ); // XtAddCallback( widCompareContigsOptionsButton_, // XmNactivateCallback, // (XtCallbackProc) compareContigsOptionsButtonCb, // this ); // first get a graphics context for writing the contigs // (The background should be set to the same as consed*background // in guiapp.cpp pGuiColorTextContigs_ = new GuiColorText( "black", "Grey77" ); pGuiColorTextScale_ = new GuiColorText( "black", "Grey77" ); pGuiColorTextCursor_ = new GuiColorText( ColorDefaults::pGetColorDefaults()->soColorMode_editCursorForeground_, ColorDefaults::pGetColorDefaults()->soColorMode_editCursorBackground_ ); XtPopup( widPopupShell_, XtGrabNone ); } guiCompareContigs :: ~guiCompareContigs() { XtRemoveCallback( widDrawingArea1_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); XtRemoveCallback( widDrawingArea2_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); XtRemoveCallback( widAlignmentDrawingArea_, XmNexposeCallback, (XtCallbackProc ) contigExposureXtCb, this ); // this is needed because XtDestroyWidget is not synchronous--doesn't // happen right away and then exposure events come in before it // is completed coming down and then there are segmentation faults. XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); delete pGuiColorTextContigs_; delete pGuiColorTextScale_; delete pGuiColorTextCursor_; } void alignButtonCb(Widget w, XtPointer client_data, XtPointer call_data) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) client_data; TRY_CATCH_WRAPPER( pGuiCompareContigs->pCompareContigs_->doCompareContigs() ); } void scrollContigWinButtonCb( Widget wid, XtPointer client_data, XtPointer call_data) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) client_data; TRY_CATCH_WRAPPER( pGuiCompareContigs->guiScrollContigWins() ); } void scrollBarXtCb(Widget wid, XtPointer client_data, XtPointer call_data) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) client_data; XmScrollBarCallbackStruct *pScrollBarCallbackStruct = (XmScrollBarCallbackStruct*) call_data; TRY_CATCH_WRAPPER( pGuiCompareContigs->guiHorizontalScrollBarMoved(wid, pScrollBarCallbackStruct->value) ); } void guiCompareContigs :: guiHorizontalScrollBarMoved( const Widget wid, const int nNewScrollBarPosition ) { compareContigsWindowTypes eWindow; if (wid == widAlignmentScrollBar_ ) eWindow = eAlignmentWindow; else if ( wid == widScrollBar1_ ) eWindow = eContig1Window; else if (wid == widScrollBar2_ ) eWindow = eContig2Window; else assert( false ); pCompareContigs_->horizontalScrollBarMoved( eWindow, nNewScrollBarPosition ); } void joinContigsButtonCb( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; XmScrollBarCallbackStruct *pScrollBarCallbackStruct = (XmScrollBarCallbackStruct*) pCallData; TRY_CATCH_WRAPPER( pGuiCompareContigs->pCompareContigs_->joinContigs(); ); } void createFakeReadButtonCb( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) pClientData; TRY_CATCH_WRAPPER( pGuiCompareContigs->pCompareContigs_->createFakeRead() ); } void compareContigsOptionsButtonCb( Widget wid, XtPointer pClientData, XtPointer pCallData ) { } void dismissButtonCb(Widget w, XtPointer client_data, XtPointer call_data) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) client_data; TRY_CATCH_WRAPPER( delete pGuiCompareContigs->pCompareContigs_ ); } void contigExposureXtCb( Widget wid, XtPointer client_data, XtPointer call_data ) { guiCompareContigs* pGuiCompareContigs = (guiCompareContigs*) client_data; TRY_CATCH_WRAPPER( pGuiCompareContigs->guiCompareContigsExposure( wid ) ); } void guiCompareContigs :: guiCompareContigsExposure( const Widget wid ) { compareContigsTypes eContig1OrContig2; if (wid == widAlignmentDrawingArea_ ) pCompareContigs_->alignmentWindowExposure(); else { if (wid == widDrawingArea1_ ) eContig1OrContig2 = eContig1; else if (wid == widDrawingArea2_ ) eContig1OrContig2 = eContig2; else assert( false ); pCompareContigs_->contigExposure( eContig1OrContig2 ); } } void guiCompareContigs :: guiDrawContigBases( const compareContigsTypes eContig1OrContig2, const RWCString& soPartOfContigToDraw ) { Widget wid = (eContig1OrContig2 == eContig1 ) ? widDrawingArea1_ : widDrawingArea2_; int nBaseline = (eContig1OrContig2 == eContig1) ? nContig1BaselinePixelY() : nContig2BaselinePixelY(); XDrawImageString( XtDisplay( wid ), XtWindow( wid ), pGuiColorTextContigs_->gcGet(), 0, nBaseline, soPartOfContigToDraw.data(), soPartOfContigToDraw.length() ); } void guiCompareContigs :: guiDrawAlignmentWindowBases( const compareContigsAlignmentWindowLineTypes eLine, const RWCString& soBasesToDisplay ) { Widget wid = widAlignmentDrawingArea_; int nBaseline; if (eLine == eLine1 ) nBaseline = nAlignmentWindowContig1BaselinePixelY(); else if (eLine == eLine2 ) nBaseline = nAlignmentWindowMiddleLineBaselinePixelY(); else if (eLine == eLine3 ) nBaseline = nAlignmentWindowContig2BaselinePixelY(); else assert( false ); XDrawImageString( XtDisplay( wid ), XtWindow( wid ), pGuiColorTextContigs_->gcGet(), 0, nBaseline, (char*) soBasesToDisplay.data(), soBasesToDisplay.length() ); } void guiCompareContigs :: guiDrawAlignmentWindowBases( const compareContigsAlignmentWindowLineTypes eLine, const int nZeroBasedPosOfBasesToDisplay, const RWCString& soBasesToDisplay, GuiColorText* pGuiColorTextOfBasesToDisplay ) { Widget wid = widAlignmentDrawingArea_; int nBaseline; if (eLine == eLine1 ) nBaseline = nAlignmentWindowContig1BaselinePixelY(); else if (eLine == eLine2 ) nBaseline = nAlignmentWindowMiddleLineBaselinePixelY(); else if (eLine == eLine3 ) nBaseline = nAlignmentWindowContig2BaselinePixelY(); else assert( false ); int nX = ( nZeroBasedPosOfBasesToDisplay - pCompareContigs_->nAlignmentWindowLeftEdgeZeroBasedPos_ ) * GuiApp::nGetFontWidth(); XDrawImageString( XtDisplay( wid ), XtWindow( wid ), pGuiColorTextOfBasesToDisplay->gcGet(), nX, nBaseline, (char*) soBasesToDisplay.data(), soBasesToDisplay.length() ); } void guiCompareContigs :: guiDrawAlignmentWindowCursor( const compareContigsTypes eContig1OrContig2, const int nScreenCharPosX, const char cBaseToDisplay, GuiColorText* pGuiColorText ) { Widget wid = widAlignmentDrawingArea_; int nBaseline; if (eContig1OrContig2 == eContig1 ) nBaseline = nAlignmentWindowContig1BaselinePixelY(); else if (eContig1OrContig2 == eContig2 ) nBaseline = nAlignmentWindowContig2BaselinePixelY(); else assert( false ); GC gc = pGuiColorText->gcGet(); int nPixelX = nPixelXFromScreenChar( nScreenCharPosX ); XDrawImageString( XtDisplay( wid ), XtWindow( wid ), gc, nPixelX, nBaseline, &cBaseToDisplay, 1 ); } void guiCompareContigs :: guiDrawContigCursor( const compareContigsTypes eContig1OrContig2, const int nScreenCharPosX, const bool bBlinkOn, const char cBaseToDisplay ) { compareContigsWindowTypes eWindowType = (eContig1OrContig2 == eContig1 ) ? eContig1Window : eContig2Window; Widget wid = widGetWidget( eWindowType ); int nBaseline; if (eContig1OrContig2 == eContig1 ) nBaseline = nContig1BaselinePixelY(); else if (eContig1OrContig2 == eContig2 ) nBaseline = nContig2BaselinePixelY(); else assert( false ); GC gc; if (bBlinkOn ) gc = pGuiColorTextCursor_->gcGet(); else gc = pGuiColorTextContigs_->gcGet(); int nPixelX = nPixelXFromScreenChar( nScreenCharPosX ); XDrawImageString( XtDisplay( wid ), XtWindow( wid ), gc, nPixelX, nBaseline, &cBaseToDisplay, 1 ); } int guiCompareContigs :: nScreenWidthInChars( ) { int nDisplayedBasesPixelsWide = nGetContigWindowPixelWidth(); int nRoundUpDisplayedBasesWide = ( nDisplayedBasesPixelsWide + GuiApp::pGetGuiApp()->nGetFontWidth() - 1) / GuiApp::pGetGuiApp()->nGetFontWidth(); return (nRoundUpDisplayedBasesWide ); } int guiCompareContigs :: nScreenWidthInCharsNotRoundedUp( ) { int nDisplayedBasesPixelsWide = nGetContigWindowPixelWidth(); int nNotRoundUpDisplayedBasesWide = ( nDisplayedBasesPixelsWide ) / GuiApp::pGetGuiApp()->nGetFontWidth(); return (nNotRoundUpDisplayedBasesWide ); } int guiCompareContigs :: nGetContigWindowPixelWidth() const { Dimension nPixelsWide; Arg aArg[10]; int nArgs = 0; XtSetArg (aArg[nArgs], XtNwidth, &nPixelsWide); nArgs++; XtGetValues( widDrawingArea1_, aArg, nArgs); return( (int) nPixelsWide ); } void guiCompareContigs :: guiClearContigWindow( const compareContigsTypes eContig1OrContig2 ) { Widget wid = (eContig1OrContig2 == eContig1 ) ? widDrawingArea1_ : widDrawingArea2_; XClearArea( XtDisplay( wid ), XtWindow( wid ), 0, 0, 0, 0, false ); } void guiCompareContigs :: guiClearAlignmentWindow( ) { XClearArea( XtDisplay( widAlignmentDrawingArea_ ), XtWindow( widAlignmentDrawingArea_ ), 0, 0, 0, 0, false ); } void guiCompareContigs :: guiResetScrollBar(const int nVal, const int nMin, const int nMax, const int nSize, const compareContigsWindowTypes eWindow ) { Arg aArg[20]; int nArgs; nArgs = 0; XtSetArg(aArg[nArgs], XmNminimum, nMin); nArgs++; // note that the slider will report a maximum XmNvalue of // XmNmaximum - XmNsliderSize // This means that the window will display values from // XmNmaximum - XmNsliderSize to // XmNmaximum - XmNsliderSize + width_of_screen - 1 // If we make the width of the screen be XmNsliderSize, // then the maximum column value will be XmNmaximum - 1. // Hence the + 1 below. XtSetArg(aArg[nArgs], XmNmaximum, nMax + 1); nArgs++; XtSetArg(aArg[nArgs], XmNvalue, nVal ); nArgs++; XtSetArg(aArg[nArgs], XmNsliderSize, nSize); nArgs++; int nPageByThisManyBases = nSize - nNumberOfBasesToOverlapWhenPaging2; if (nPageByThisManyBases < 1) nPageByThisManyBases = 1; XtSetArg(aArg[nArgs], XmNpageIncrement, nPageByThisManyBases); nArgs++; Widget wid = widGetScrollBarWidget( eWindow ); XtSetValues(wid, aArg, nArgs); } void guiCompareContigs :: guiResetScrollBarMax( const int nMax, const compareContigsTypes eContig1OrContig2 ) { Arg aArg[20]; int nArgs; nArgs = 0; // note that the slider will report a maximum XmNvalue of // XmNmaximum - XmNsliderSize // This means that the window will display values from // XmNmaximum - XmNsliderSize to // XmNmaximum - XmNsliderSize + width_of_screen - 1 // If we make the width of the screen be XmNsliderSize, // then the maximum column value will be XmNmaximum - 1. // Hence the + 1 below. XtSetArg(aArg[nArgs], XmNmaximum, nMax + 1); nArgs++; Widget wid = (eContig1OrContig2 == eContig1) ? widScrollBar1_ : widScrollBar2_; XtSetValues(wid, aArg, nArgs); } void guiCompareContigs :: guiResizeScrollBar( const compareContigsWindowTypes eWindow ) { Arg aArg[20]; int nArgs; nArgs = 0; XtSetArg(aArg[nArgs], XmNsliderSize, nScreenWidthInChars()); nArgs++; int nPageByThisManyBases = nScreenWidthInChars() - nNumberOfBasesToOverlapWhenPaging2; if (nPageByThisManyBases < 1) nPageByThisManyBases = 1; XtSetArg(aArg[nArgs], XmNpageIncrement, nPageByThisManyBases); nArgs++; Widget wid = widGetScrollBarWidget( eWindow ); XtSetValues(wid, aArg, nArgs); } void guiCompareContigs :: guiSetScrollBarPos(const int nPos, const compareContigsWindowTypes eWindow ) { Arg aArg[10]; int nArgs; nArgs = 0; XtSetArg(aArg[nArgs], XmNvalue, nPos); nArgs++; Widget wid = widGetScrollBarWidget( eWindow ); XtSetValues( wid, aArg, nArgs); } void guiCompareContigs :: programMovesAlignmentWindowScrollBarInCenter( const int n0VisiblePos ) { // how wide is the window? int nNewAlignmentWindowLeftEdgeZeroBasedPos = n0VisiblePos - nScreenWidthInCharsNotRoundedUp() / 2; if ( nNewAlignmentWindowLeftEdgeZeroBasedPos < 0 ) { nNewAlignmentWindowLeftEdgeZeroBasedPos = 0; } else { // check that the value is not too big int nSliderMax; int nSliderSize; XtVaGetValues( widAlignmentScrollBar_, XmNsliderSize, &nSliderSize, XmNmaximum, &nSliderMax, NULL ); int nMaxValueForLeftEdge = nSliderMax - nSliderSize; if ( nNewAlignmentWindowLeftEdgeZeroBasedPos > nMaxValueForLeftEdge ) { nNewAlignmentWindowLeftEdgeZeroBasedPos = nMaxValueForLeftEdge; } } programMovesAlignmentWindowScrollBar2( nNewAlignmentWindowLeftEdgeZeroBasedPos ); } void guiCompareContigs :: programMovesAlignmentWindowScrollBar2( const int n0NewPos ) { // this will assume that n0NewPos is within the range of the scrollbar XtVaSetValues( widAlignmentScrollBar_, XmNvalue, n0NewPos, NULL ); pCompareContigs_->nAlignmentWindowLeftEdgeZeroBasedPos_ = n0NewPos; pCompareContigs_->drawAlignmentWindowScaleAndBases(); } // void guiCompareContigs :: guiResetScrollbarForComplementContig( // const compareContigsTypes eContig1OrContig2 ) { // Widget wid = widGetScrollBarWidget( // eGetCompareContigsWindowType(eContig1OrContig2 ) ); // int nValue; // bool bComplemented; // if ( eContig1OrContig2 == eContig1 ) { // bComplemented = pCompareContigs_->bContig1ComplementedWRTAlignedReadsWindow_; // nValue = pCompareContigs_->nContig1LeftEdgeConsensusPosition_; // } // else { // bComplemented = pCompareContigs_->bContig2ComplementedWRTAlignedReadsWindow_; // nValue = pCompareContigs_->nContig2LeftEdgeConsensusPosition_; // } // int nIncrement = 1; // int nPageSize = nScreenWidthInChars() - nNumberOfBasesToOverlapWhenPaging2; // if ( bComplemented ) { // nIncrement = -1; // nPageSize = -nPageSize; // } // XtVaSetValues( wid, // XmNvalue, nValue, // XmNincrement, nIncrement, // XmNpageIncrement, nPageSize, // NULL ); // } void guiCompareContigs :: guiDrawScaleTick( const compareContigsTypes eContig1OrContig2, const scaleTickSizeTypes eBigTickOrLittleTick, const int nCharScreenPosition ) { int nPixelScreenPosition = nPixelXFromScreenChar( nCharScreenPosition ); int nMiddleOfCharPosition = (int) (nPixelScreenPosition + .5 * GuiApp::pGetGuiApp()->nGetFontWidth() ); int nTickSize = nScaleMarksHeight(); if (eBigTickOrLittleTick == eLittleTick ) nTickSize = (.3) * nTickSize; Widget wid; int nY1; int nY2; if (eContig1OrContig2 == eContig1 ) { wid = widDrawingArea1_; nY1 = nContig1ScaleLinePixelY(); nY2 = nY1 + nTickSize; } else { wid = widDrawingArea2_; nY2 = nContig2ScaleLinePixelY(); nY1 = nY2 - nTickSize; } XDrawLine(XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), nMiddleOfCharPosition, // x1 nY1, nMiddleOfCharPosition, // x2 nY2 ); // y2 } void guiCompareContigs :: guiDrawAlignmentWindowScaleTick( const compareContigsTypes eContig1OrContig2, const scaleTickSizeTypes eBigTickOrLittleTick, const int nCharScreenPosition ) { int nPixelScreenPosition = nPixelXFromScreenChar( nCharScreenPosition ); int nMiddleOfCharPosition = (int) (nPixelScreenPosition + .5 * GuiApp::pGetGuiApp()->nGetFontWidth() ); int nTickSize = nScaleMarksHeight(); if (eBigTickOrLittleTick == eLittleTick ) nTickSize = (.3) * nTickSize; Widget wid = widAlignmentDrawingArea_; int nY1; int nY2; if (eContig1OrContig2 == eContig1 ) { nY1 = nAlignmentWindowContig1ScaleLinePixelY(); nY2 = nY1 + nTickSize; } else { nY2 = nAlignmentWindowContig2ScaleLinePixelY(); nY1 = nY2 - nTickSize; } XDrawLine(XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), nMiddleOfCharPosition, // x1 nY1, nMiddleOfCharPosition, // x2 nY2 ); // y2 } void guiCompareContigs :: guiDrawScaleNumber( const compareContigsTypes eContig1OrContig2, const int nCharScreenPosition, char* szLabel ) { int nPixelScreenPosition = nPixelXFromScreenChar( nCharScreenPosition ); int nLen = strlen( szLabel ); // center the number around the base that it is numbering // Why the +1 ? This moves the number to the right another // half character width, thus centering it over the base. int nPixelOffset = ( ( nLen - 1 ) * GuiApp::pGetGuiApp()->nGetFontWidth() ) / 2; nPixelScreenPosition -= nPixelOffset; Widget wid; int nY; if ( eContig1OrContig2 == eContig1 ) { wid = widDrawingArea1_; nY = nContig1ScaleNumbersBaseline(); } else { wid = widDrawingArea2_; nY = nContig2ScaleNumbersBaseline(); } XDrawImageString( XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), nPixelScreenPosition, nY, szLabel, nLen ); } void guiCompareContigs :: guiDrawAlignmentWindowScaleNumber( const compareContigsTypes eContig1OrContig2, const int nCharScreenPosition, char* szLabel ) { int nPixelScreenPosition = nPixelXFromScreenChar( nCharScreenPosition ); int nLen = strlen( szLabel ); // center the number around the base that it is numbering // Why the +1 ? This moves the number to the right another // half character width, thus centering it over the base. int nPixelOffset = ( ( nLen - 1 ) * GuiApp::pGetGuiApp()->nGetFontWidth() ) / 2; nPixelScreenPosition -= nPixelOffset; Widget wid = widAlignmentDrawingArea_; int nY; if ( eContig1OrContig2 == eContig1 ) { nY = nAlignmentWindowContig1ScaleNumbersBaseline(); } else { nY = nAlignmentWindowContig2ScaleNumbersBaseline(); } XDrawImageString( XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), nPixelScreenPosition, nY, szLabel, nLen ); } void guiCompareContigs :: guiDrawScaleHorizontalLine( const compareContigsTypes eContig1OrContig2 ) { Widget wid = (eContig1OrContig2 == eContig1) ? widDrawingArea1_ : widDrawingArea2_; int nY = (eContig1OrContig2 == eContig1) ? nContig1ScaleLinePixelY() : nContig2ScaleLinePixelY(); XDrawLine( XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), 0, nY, nGetContigWindowPixelWidth(), nY ); } void guiCompareContigs :: guiDrawAlignmentWindowScaleHorizontalLine( const compareContigsTypes eContig1OrContig2 ) { Widget wid = widAlignmentDrawingArea_; int nY = (eContig1OrContig2 == eContig1) ? nAlignmentWindowContig1ScaleLinePixelY() : nAlignmentWindowContig2ScaleLinePixelY(); XDrawLine( XtDisplay(wid), XtWindow( wid ), pGuiColorTextScale_->gcGet(), 0, nY, nGetContigWindowPixelWidth(), nY ); } void guiCompareContigs :: setContigName( const compareContigsTypes eContig1OrContig2, const RWCString& soContigName ) { Widget wid = ( eContig1OrContig2 == eContig1 ) ? widContigName1_ : widContigName2_; XtVaSetValues( wid, XmNvalue, (char*) soContigName.data(), NULL ); } // used? Widget guiCompareContigs :: widGetWidget( const compareContigsWindowTypes eWindow ) { if (eWindow == eContig1Window ) return( widDrawingArea1_ ); else if ( eWindow == eContig2Window ) return( widDrawingArea2_ ); else if ( eWindow == eAlignmentWindow ) return( widAlignmentDrawingArea_ ); else assert( false ); } Widget guiCompareContigs :: widGetScrollBarWidget( const compareContigsWindowTypes eWindow ) { if (eWindow == eContig1Window ) return( widScrollBar1_ ); else if ( eWindow == eContig2Window ) return( widScrollBar2_ ); else if ( eWindow == eAlignmentWindow ) return( widAlignmentScrollBar_ ); else assert( false ); } void guiCompareContigsButtonPressXtEventHandler( Widget wid, XtPointer client_data, XEvent* pEvent, Boolean* ) { guiCompareContigs *pGuiCompareContigs = (guiCompareContigs*) client_data; int nPixelX = pEvent->xbutton.x; int nPixelY = pEvent->xbutton.y; unsigned int uButton = pEvent->xbutton.button; // is this button 1 or 2? if (pEvent->xbutton.button == Button1) { TRY_CATCH_WRAPPER( pGuiCompareContigs->guiSetCursor( wid, nPixelX, nPixelY ) ); } } void guiCompareContigs :: guiSetCursor( const Widget wid, const int nPixelX, const int nPixelY ) { assert( wid == widAlignmentDrawingArea_ || wid == widDrawingArea1_ || wid == widDrawingArea2_ ); int nScreenCharX = nScreenCharFromPixelX( nPixelX ); if (wid == widAlignmentDrawingArea_ ) { compareContigsTypes eContig1OrContig2; if ( nPixelY <= nAlignmentWindowMiddleLineBaselinePixelY() ) eContig1OrContig2 = eContig1; else eContig1OrContig2 = eContig2; pCompareContigs_->setAlignmentCursor( nScreenCharX ); } else { compareContigsTypes eContig1OrContig2 = (wid == widDrawingArea1_ ) ? eContig1 : eContig2; pCompareContigs_->setTopContigCursorByScreenPos(eContig1OrContig2, nScreenCharX ); } } void guiCompareContigs :: guiScrollContigWins() { pCompareContigs_->scrollContigWin( eContig1 ); pCompareContigs_->scrollContigWin( eContig2 ); } void guiCompareContigs :: raiseWindow() { XRaiseWindow( XtDisplay( widPopupShell_ ), XtWindow( widPopupShell_ ) ); } void guiCompareContigs :: makeAlignButtonInsensitive() { XtVaSetValues( widAlignButton_, XmNsensitive, False, NULL ); } void guiCompareContigs :: makeJoinButtonInsensitive() { XtVaSetValues( widJoinContigsButton_, XmNsensitive, False, NULL ); } bool guiCompareContigs :: bHighlightRightReads() { if ( XmToggleButtonGetState( widHighlightRightReadsTrue_ ) == True ) return( true ); else return( false ); } void guiCompareContigs :: setComplementContigButton( const compareContigsTypes eContig1OrContig2 ) { Contig* pContig; Widget widButton; bool bComplemented; if ( eContig1OrContig2 == eContig1 ) { pContig = pCompareContigs_->pContig1_; widButton = widComplementContig1_; bComplemented = pCompareContigs_->bContig1ComplementedWRTAlignedReadsWindow_; } else { pContig = pCompareContigs_->pContig2_; widButton = widComplementContig2_; bComplemented = pCompareContigs_->bContig2ComplementedWRTAlignedReadsWindow_; } XmString xmsLabel; if ( bComplemented ) { xmsLabel = XmStringCreateLtoR( "uncomplement just in this window", XmSTRING_DEFAULT_CHARSET ); } else { xmsLabel = XmStringCreateLtoR( "complement just in this window", XmSTRING_DEFAULT_CHARSET ); } XtVaSetValues( widButton, XmNlabelString, xmsLabel, NULL ); XmStringFree( xmsLabel ); }