/***************************************************************************** # 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 "guiAddNewReads.h" #include #include #include #include #include #include "guiapp.h" #include "handleWindowManagerDelete2.h" #include #include "hp_exception_kludge.h" #include #include #include #include "bInputEventToWrongWindow.h" #include "assert.h" #include "popupErrorMessage2.h" static void cbUserPushedCancel( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAddNewReads* pGuiAddNewReads = (guiAddNewReads*) pClientData; TRY_CATCH_WRAPPER( pGuiAddNewReads->userPushedCancel() ); } static void cbAddNewReads( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAddNewReads* pGuiAddNewReads = (guiAddNewReads*) pClientData; TRY_CATCH_WRAPPER( pGuiAddNewReads->userPushedAddNewReads( pCallData ) ); } void guiAddNewReads :: createWindowAndWaitForUserResponse( bool& bUserPushedCancel, FileName& filFOF, bool& bRecalculateConsensusQuality, bool& bPutUnalignedReadsIntoOwnContigs ) { widPopupShell_ = XtVaCreatePopupShell( "Add New Reads", topLevelShellWidgetClass, GAPP->widGetTopLevel(), XmNnoResize, False, XmNtransient, False, XmNdeleteResponse, XmDO_NOTHING, NULL ); handleWindowManagerDelete2( widPopupShell_, cbUserPushedCancel, this ); // create a form widget Widget widTopForm = XtVaCreateManagedWidget( "top form", xmFormWidgetClass, widPopupShell_, XmNshadowThickness, 0, XmNborderWidth, 0, NULL ); // Widget widSolexaLabel = // XtVaCreateManagedWidget( "Solexa reads?", // xmLabelWidgetClass, // widTopForm, // XmNtopAttachment, XmATTACH_FORM, // XmNleftAttachment, XmATTACH_FORM, // NULL ); // Widget widSolexaRadioBox = XmCreateRadioBox( widTopForm, // "radio", // NULL, // 0 ); // XtVaSetValues( widSolexaRadioBox, // XmNtraversalOn, True, // XmNtopAttachment, XmATTACH_WIDGET, // XmNtopWidget, widSolexaLabel, // XmNleftAttachment, XmATTACH_FORM, // XmNorientation, XmHORIZONTAL, // XmNshadowThickness, 0, // XmNborderWidth, 0, // XmNmarginWidth, 0, // NULL ); // widSolexaReadsYes_ = // XtVaCreateManagedWidget( "yes", // xmToggleButtonWidgetClass, // widSolexaRadioBox, // XmNset, False, // NULL ); // Widget widSolexaReadsNo = // XtVaCreateManagedWidget( "no", // xmToggleButtonWidgetClass, // widSolexaRadioBox, // XmNset, True, // NULL ); // XtManageChild( widSolexaRadioBox ); XmString xmsRecalculate = XmStringCreateLtoR( "Do you want to recalculate the consensus quality values where each of the\nnew reads is aligned?", XmFONTLIST_DEFAULT_TAG ); Widget widRecalculateConsensusLabel = XtVaCreateManagedWidget( "recalculate", xmLabelWidgetClass, widTopForm, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNlabelString, xmsRecalculate, XmNalignment, XmALIGNMENT_BEGINNING, NULL ); Widget widRecalculateRadioBox = XmCreateRadioBox( widTopForm, "radio2", NULL, 0 ); XtVaSetValues( widRecalculateRadioBox, XmNtraversalOn, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widRecalculateConsensusLabel, XmNleftAttachment, XmATTACH_FORM, XmNorientation, XmHORIZONTAL, XmNshadowThickness, 0, XmNborderWidth, 0, XmNmarginWidth, 0, NULL ); widRecalculateQualityYes_ = XtVaCreateManagedWidget( "yes", xmToggleButtonWidgetClass, widRecalculateRadioBox, XmNset, True, NULL ); Widget widRecalculateQualityNo = XtVaCreateManagedWidget( "no", xmToggleButtonWidgetClass, widRecalculateRadioBox, XmNset, False, NULL ); XtManageChild( widRecalculateRadioBox ); XmString xmsContigByItself = XmStringCreateLtoR( "If a read doesn't align against any existing contig, do you want to have\nit go into a contig by itself? (otherwise it will just not be put\ninto the assembly)", XmFONTLIST_DEFAULT_TAG ); Widget widContigByItselfLabel = XtVaCreateManagedWidget( "contigByItself", xmLabelWidgetClass, widTopForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widRecalculateRadioBox, XmNleftAttachment, XmATTACH_FORM, XmNlabelString, xmsContigByItself, XmNalignment, XmALIGNMENT_BEGINNING, NULL ); Widget widContigByItselfRadioBox = XmCreateRadioBox( widTopForm, "radio3", NULL, 0 ); XtVaSetValues( widContigByItselfRadioBox, XmNtraversalOn, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widContigByItselfLabel, XmNleftAttachment, XmATTACH_FORM, XmNorientation, XmHORIZONTAL, XmNshadowThickness, 0, XmNborderWidth, 0, XmNmarginWidth, 0, NULL ); widContigByItselfYes_ = XtVaCreateManagedWidget( "yes", xmToggleButtonWidgetClass, widContigByItselfRadioBox, XmNset, True, NULL ); Widget widContigByItselfNo = XtVaCreateManagedWidget( "no", xmToggleButtonWidgetClass, widContigByItselfRadioBox, XmNset, False, NULL ); XtManageChild( widContigByItselfRadioBox ); Widget widConnectToWidgetOnTop = widContigByItselfRadioBox; // now work from bottom up // Widget widAddNewReadsButton = // XtVaCreateManagedWidget( "add new reads", // xmPushButtonWidgetClass, // widTopForm, // XmNbottomAttachment, XmATTACH_FORM, // XmNleftAttachment, XmATTACH_FORM, // NULL ); // XtAddCallback( widAddNewReadsButton, // XmNactivateCallback, // cbAddNewReads, // this ); // Widget widCancelButton = // XtVaCreateManagedWidget( "cancel", // xmPushButtonWidgetClass, // widTopForm, // XmNbottomAttachment, XmATTACH_FORM, // XmNrightAttachment, XmATTACH_FORM, // NULL ); // XtAddCallback( widCancelButton, // XmNactivateCallback, // cbUserPushedCancel, // this ); // Widget widConnectToWidgetOnBottom = widCancelButton; Arg aArg[100]; int nArgs = 0; XtSetArg( aArg[nArgs], XmNtopAttachment, XmATTACH_WIDGET ); nArgs++; XtSetArg( aArg[nArgs], XmNtopWidget, widConnectToWidgetOnTop ); nArgs++; XtSetArg( aArg[nArgs], XmNleftAttachment, XmATTACH_FORM ); nArgs++; XtSetArg( aArg[nArgs], XmNrightAttachment, XmATTACH_FORM ); nArgs++; XtSetArg( aArg[nArgs], XmNbottomAttachment, XmATTACH_FORM ); nArgs++; // XtSetArg( aArg[nArgs], XmNcursorPositionVisible, False ); nArgs++; widFileSelectionBox_ = XmCreateFileSelectionBox( widTopForm, "FileSelectionBox", aArg, nArgs ); XtManageChild( widFileSelectionBox_ ); XtUnmanageChild( XmSelectionBoxGetChild( widFileSelectionBox_, XmDIALOG_HELP_BUTTON )); XtAddCallback( widFileSelectionBox_, XmNokCallback, cbAddNewReads, this ); XtAddCallback( widFileSelectionBox_, XmNcancelCallback, cbUserPushedCancel, this ); // XtUnmanageChild( XmSelectionBoxGetChild( widFileSelectionBox_, XmDIALOG_OK_BUTTON )); // XtUnmanageChild( XmSelectionBoxGetChild( widFileSelectionBox_, XmDIALOG_CANCEL_BUTTON) ); // for some reason, if you start in directory A and then run // a script that first changes to directory B, and then runs consed, // X will still think you are in directory A. Thus I've worked // around this by explicitly doing a getcwd and then setting the // file filter mask to that. const int nBigNumber = 500; char szFileFilterMask[nBigNumber+10]; getcwd( szFileFilterMask, nBigNumber ); XmString xmsDirMask = XmStringCreateSimple( (char*) szFileFilterMask ); nArgs = 0; XtSetArg( aArg[nArgs], XmNdirSpec, xmsDirMask ); nArgs++; XtSetValues( widFileSelectionBox_, aArg, nArgs ); XmStringFree( xmsDirMask ); XmString xmsPattern = XmStringCreateSimple( (char*) "*.fof" ); XtVaSetValues( widFileSelectionBox_, XmNpattern, xmsPattern, NULL ); XmStringFree( xmsPattern ); bool bContinue = true; while( bContinue ) { bBlockApplication_ = true; XtPopup( widPopupShell_, XtGrabNone ); XEvent xevent; while( bBlockApplication_ ) { XtAppNextEvent( GAPP->ctxGetAppContext(), &xevent ); bool bWrongWindow = bInputEventToWrongWindow( xevent, widPopupShell_ ); XtDispatchEvent( &xevent ); if ( bWrongWindow ) { raiseWindow(); GuiApp::beep(); } } if ( bUserPushedCancel_ ) bContinue = false; else { if ( filFOF_.soGetBasename().isNull() ) { popupErrorMessage2( widPopupShell_, "You must specify a filename" ); } else { bContinue = false; } } } XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); bUserPushedCancel = bUserPushedCancel_; filFOF = filFOF_; bRecalculateConsensusQuality = bRecalculateConsensusQuality_; bPutUnalignedReadsIntoOwnContigs = bPutUnalignedReadsIntoOwnContigs_; delete this; } void guiAddNewReads :: userPushedAddNewReads( XtPointer pCallData ) { bRecalculateConsensusQuality_ = ( XmToggleButtonGetState( widRecalculateQualityYes_ ) == True ? true : false ); bPutUnalignedReadsIntoOwnContigs_ = ( XmToggleButtonGetState( widContigByItselfYes_ ) == True ? true : false ); XmFileSelectionBoxCallbackStruct* pCallbackStruct = (XmFileSelectionBoxCallbackStruct*) pCallData; char* szFilePath; assert( XmStringGetLtoR( pCallbackStruct->value, XmSTRING_DEFAULT_CHARSET, &szFilePath ) ); filFOF_ = szFilePath; bUserPushedCancel_ = false; bBlockApplication_ = false; } void guiAddNewReads :: raiseWindow() { XtMapWidget( widPopupShell_ ); XRaiseWindow( XtDisplay( widPopupShell_ ), XtWindow( widPopupShell_ ) ); } void guiAddNewReads :: userPushedCancel() { bUserPushedCancel_ = true; bBlockApplication_ = false; }