/***************************************************************************** # 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 "guiAssemblyViewReadDepth.h" #include "assemblyView.h" #include #include #include #include #include #include #include #include #include "hp_exception_kludge.h" #include "handleWindowManagerDelete2.h" #include #include "bIsNumericMaybeWithWhitespace.h" #include "consedParameters.h" #include "popupErrorMessage.h" static void cbGuiShowDocumentationForAssemblyView( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAssemblyViewReadDepth* pGuiReadDepth = (guiAssemblyViewReadDepth*) pClientData; TRY_CATCH_WRAPPER( pGuiReadDepth->pAssemblyView_->showDocumentationForAssemblyView() ); } static void cbApply( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAssemblyViewReadDepth* pGuiReadDepth = (guiAssemblyViewReadDepth*) pClientData; TRY_CATCH_WRAPPER( pGuiReadDepth->userClickedApply(); ); } static void cbDismiss( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAssemblyViewReadDepth* pGuiReadDepth = (guiAssemblyViewReadDepth*) pClientData; TRY_CATCH_WRAPPER( delete pGuiReadDepth ); } static void cbShowReadDepthValueChanged( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiAssemblyViewReadDepth* pGuiReadDepth = (guiAssemblyViewReadDepth*) pClientData; TRY_CATCH_WRAPPER( pGuiReadDepth->showReadDepthValueChanged() ); } #ifdef NO_POUND_POUND_MACROS #define makeLabelAndToggleButtonCP( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = \ XtVaCreateManagedWidget( "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmToggleButtonWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, False, \ XmNlabelString, xmsEmpty, \ XmNmarginHeight, 0, \ XmNmarginWidth, 0, \ XmNshadowThickness, 0, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNleftOffset, 10, \ XmNset, pCP->b ## parameterNameWithoutPrefix ## _, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = \ XtVaCreateManagedWidget( \ label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_WIDGET, \ XmNleftWidget, wid ## parameterNameWithoutPrefix ## _, \ XmNalignment, XmALIGNMENT_BEGINNING, \ NULL ); \ #else #define makeLabelAndToggleButtonCP( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = \ XtVaCreateManagedWidget( "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmToggleButtonWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, False, \ XmNlabelString, xmsEmpty, \ XmNmarginHeight, 0, \ XmNmarginWidth, 0, \ XmNshadowThickness, 0, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNleftOffset, 10, \ XmNset, pCP->b ## parameterNameWithoutPrefix ## _, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = \ XtVaCreateManagedWidget( \ ##label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_WIDGET, \ XmNleftWidget, wid ## parameterNameWithoutPrefix ## _, \ XmNalignment, XmALIGNMENT_BEGINNING, \ NULL ); \ #endif static const int nRightPositionOfLabels = 70; static const int nLeftPositionOfInputFields = 80; #ifdef NO_POUND_POUND_MACROS #define makeLabelAndIntegerTextField( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = XtVaCreateManagedWidget( \ "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## Label_ = XtVaCreateManagedWidget( \ label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_POSITION, \ XmNrightPosition, nRightPositionOfLabels, \ XmNalignment, XmALIGNMENT_END, \ NULL ); \ \ char sz ## parameterNameWithoutPrefix[200]; \ sprintf( sz ## parameterNameWithoutPrefix, "%d", \ consedParameters::pGetConsedParameters()->n ## parameterNameWithoutPrefix ## _ ); \ \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmTextFieldWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, True, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_POSITION, \ XmNleftPosition, nLeftPositionOfInputFields, \ XmNrightAttachment, XmATTACH_FORM, \ XmNvalue, sz ## parameterNameWithoutPrefix , \ NULL ); \ \ XtAddCallback( wid ## parameterNameWithoutPrefix ## _, \ XmNactivateCallback, \ (XtCallbackProc )XmProcessTraversal, \ (XtPointer) XmTRAVERSE_NEXT_TAB_GROUP ); #else #define makeLabelAndIntegerTextField( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = XtVaCreateManagedWidget( \ "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## Label_ = XtVaCreateManagedWidget( \ ##label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_POSITION, \ XmNrightPosition, nRightPositionOfLabels, \ XmNalignment, XmALIGNMENT_END, \ NULL ); \ \ char sz ## parameterNameWithoutPrefix ## [200]; \ sprintf( sz ## parameterNameWithoutPrefix, "%d", \ consedParameters::pGetConsedParameters()->n ## parameterNameWithoutPrefix ## _ ); \ \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmTextFieldWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, True, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_POSITION, \ XmNleftPosition, nLeftPositionOfInputFields, \ XmNrightAttachment, XmATTACH_FORM, \ XmNvalue, sz ## parameterNameWithoutPrefix , \ NULL ); \ \ XtAddCallback( wid ## parameterNameWithoutPrefix ## _, \ XmNactivateCallback, \ (XtCallbackProc )XmProcessTraversal, \ (XtPointer) XmTRAVERSE_NEXT_TAB_GROUP ); #endif #define checkIfNumeric( AssemblyViewParameter ) \ szValue = XmTextFieldGetString( wid ## AssemblyViewParameter ## _ );\ soValue = szValue; \ XtFree( szValue ); \ int nPerhaps ## AssemblyViewParameter; \ if ( !bIsNumericMaybeWithWhitespace( soValue, nPerhaps ## AssemblyViewParameter ) ) { \ RWCString soError = #AssemblyViewParameter " must be numeric but instead is: \""; \ soError += soValue; \ soError += "\""; \ popupErrorMessage( soError ); \ return; \ } guiAssemblyViewReadDepth :: ~guiAssemblyViewReadDepth() { XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); } void guiAssemblyViewReadDepth :: createWindow() { widPopupShell_ = XtVaCreatePopupShell( "Show Read Depth", topLevelShellWidgetClass, pAssemblyView_->widPopupShell_, XmNtransient, False, XmNdeleteResponse, XmDO_NOTHING, NULL ); handleWindowManagerDelete2( widPopupShell_, cbDismiss, this ); // put on a main window so we can have a menu bar Widget widMainWin = XtVaCreateManagedWidget( "mainwin", xmMainWindowWidgetClass, widPopupShell_, XmNancestorSensitive, True, NULL ); // put menu bar on the main window int nArgs = 0; Arg aArg[30]; Widget widMenuBar = XmCreateMenuBar( widMainWin, "menubar", aArg, nArgs ); XtManageChild( widMenuBar ); // create help menu button nArgs = 0; Widget widHelpMenu = XmCreatePulldownMenu( widMenuBar, "Help", aArg, nArgs ); nArgs = 0; XtSetArg( aArg[ nArgs ], XmNsubMenuId, widHelpMenu ); ++nArgs; Widget widHelpCascade = XmCreateCascadeButton( widMenuBar, "Help", aArg, nArgs ); XtManageChild( widHelpCascade ); XtVaSetValues( widMenuBar, XmNmenuHelpWidget, widHelpCascade, NULL ); // now add help menu item Widget widShowDocumentation = XtVaCreateManagedWidget( "Show Documentation for Assembly View", xmPushButtonWidgetClass, widHelpMenu, NULL ); XtAddCallback( widShowDocumentation, XmNactivateCallback, cbGuiShowDocumentationForAssemblyView, this ); Widget widForm = XtVaCreateManagedWidget( "form", xmFormWidgetClass, widMainWin, XmNancestorSensitive, True, NULL ); widDismiss_ = XtVaCreateManagedWidget( "Dismiss", xmPushButtonWidgetClass, widForm, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 70, NULL ); XtAddCallback( widDismiss_, XmNactivateCallback, cbDismiss, this ); widApply_ = XtVaCreateManagedWidget( "Apply", xmPushButtonWidgetClass, widForm, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 10, NULL ); XtAddCallback( widApply_, XmNactivateCallback, cbApply, this ); Widget widRowCol = XtVaCreateManagedWidget( "rowcol", xmRowColumnWidgetClass, widForm, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, widDismiss_, NULL ); XmString xmsEmpty = XmStringCreateSimple( "" ); makeLabelAndToggleButtonCP( AssemblyViewShowReadDepth, "show read depth" ); XtAddCallback( widAssemblyViewShowReadDepth_, XmNvalueChangedCallback, cbShowReadDepthValueChanged, this ); makeLabelAndIntegerTextField( AssemblyViewReadDepthQuality, "quality to be used for read depth calc" ); makeLabelAndToggleButtonCP( AssemblyViewShowMultipleHighQualityDiscrepancies, "show multiple discrepancies (substitions--yellow, indels--magenta)" ); makeLabelAndIntegerTextField( NavigateByHighlyDiscrepantPositionsIgnoreBasesBelowThisQuality, "multiple discrepancies min quality" ); showReadDepthValueChanged(); XtPopup( widPopupShell_, XtGrabNone ); } void guiAssemblyViewReadDepth :: showReadDepthValueChanged() { pCP->bAssemblyViewShowReadDepth_ = ( XmToggleButtonGetState( widAssemblyViewShowReadDepth_ ) == True ) ? true : false; if ( pCP->bAssemblyViewShowReadDepth_ ) { XtVaSetValues( widAssemblyViewReadDepthQualityLabel_, XmNsensitive, True, NULL ); XtVaSetValues( widAssemblyViewReadDepthQuality_, XmNsensitive, True, NULL ); } else { XtVaSetValues( widAssemblyViewReadDepthQualityLabel_, XmNsensitive, False, NULL ); XtVaSetValues( widAssemblyViewReadDepthQuality_, XmNsensitive, False, NULL ); } } void guiAssemblyViewReadDepth :: userClickedApply() { pCP->bAssemblyViewShowReadDepth_ = ( XmToggleButtonGetState( widAssemblyViewShowReadDepth_ ) == True ) ? true : false; char* szValue; RWCString soValue; checkIfNumeric( AssemblyViewReadDepthQuality ); pCP->nAssemblyViewReadDepthQuality_ = nPerhapsAssemblyViewReadDepthQuality; pCP->bAssemblyViewShowMultipleHighQualityDiscrepancies_ = ( XmToggleButtonGetState( widAssemblyViewShowMultipleHighQualityDiscrepancies_ ) == True ) ? true : false; checkIfNumeric( NavigateByHighlyDiscrepantPositionsIgnoreBasesBelowThisQuality ); pCP->nNavigateByHighlyDiscrepantPositionsIgnoreBasesBelowThisQuality_ = nPerhapsNavigateByHighlyDiscrepantPositionsIgnoreBasesBelowThisQuality; pAssemblyView_->drawEverything( true, // calculate positions true ); // first erase }