********> bugfix.23 Author: Bill Ross Date: 3/19/98 Programs: xleap Severity: major inconvenience Description: bugfix.9 introduced a major slowdown in xleap by always checking the graphics update queue when various operations are performed. This fix turns off graphical updates during times when mostly non-graphical operations are being performed, restoring the speed to that of tleap for such operations as solvation and saving parm files. Fix: Apply the following changes to: basics.c, displayer.c, xaUnitEditor.c, commands.c ----------------------------------------------------------------------------- *** OLD basics.c --- NEW basics.c *************** *** 61,67 BOOL GbInterrupt = FALSE; ! /* * ------------------------------------------------------------------ --- 61,67 ----- BOOL GbInterrupt = FALSE; ! int GiUnitEditors = 0; /* * ------------------------------------------------------------------ ----------------------------------------------------------------------------- *** OLD displayer.c --- NEW displayer.c *************** *** 64,69 extern BOOL GbGraphicalEnvironment; /* *---------------------------------------------------------- --- 64,70 ----- extern BOOL GbGraphicalEnvironment; + extern int GiUnitEditors; /* *---------------------------------------------------------- *************** *** 264,269 RETURNV; if ( GbGraphicalEnvironment == FALSE ) RETURNV; /* If we are not supposed to update DISPLAYERs but instead */ /* accumulate the updates then accumulate and continue */ --- 263,270 ----- RETURNV; if ( GbGraphicalEnvironment == FALSE ) RETURNV; + if ( GiUnitEditors == 0 ) + RETURNV; /* If we are not supposed to update DISPLAYERs but instead */ /* accumulate the updates then accumulate and continue */ *************** *** 341,344 SdDisplayerAccumulateList = NULL; } END } --- 342,373 ----- SdDisplayerAccumulateList = NULL; } END + } + + /* + * TurnOffDisplayerUpdates(), TurnOnDisplayerUpdates() + * + * Recommended that these only be called from commands.c + * and that ContainerDisplayerUpdate( ) be called + * right after. + */ + static int iOffed = 0; + + void TurnOffDisplayerUpdates() + { + if ( GbGraphicalEnvironment ) { + if ( iOffed ) + DFATAL(( + " programmer error - TurnOffDisplayerUpdates\n" )); + iOffed++; + GbGraphicalEnvironment = FALSE; + } + } + + void TurnOnDisplayerUpdates() + { + if ( iOffed ) { + iOffed = 0; + GbGraphicalEnvironment = TRUE; + } } ----------------------------------------------------------------------------- *** OLD xaUnitEditor.c --- NEW xaUnitEditor.c *************** *** 81,86 #include "xaUnitEditor.h" /* *---------------------------------------------------------------------- * --- 81,88 ----- #include "xaUnitEditor.h" + extern int GiUnitEditors; + /* *---------------------------------------------------------------------- * *************** *** 1841,1846 zXAUERemoveUnitEditor(wCur); XtDestroyWidget( wTop ); END } --- 1843,1849 ----- zXAUERemoveUnitEditor(wCur); XtDestroyWidget( wTop ); + GiUnitEditors--; END } *************** *** 1971,1976 XAUEDisplayerUpdate, wShell ); END; } --- 1974,1980 ----- XAUEDisplayerUpdate, wShell ); + GiUnitEditors++; END; } ----------------------------------------------------------------------------- *** OLD commands.c --- NEW commands.c *************** *** 1743,1749 /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); DisplayerReleaseUpdates(); --- 1743,1750 ----- /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! TurnOffDisplayerUpdates(); ! ToolCenterUnitByRadii( uSolute, FALSE ); TurnOnDisplayerUpdates(); *************** *** 1745,1751 DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); - DisplayerReleaseUpdates(); /* Solvate the solute */ --- 1746,1751 ----- TurnOffDisplayerUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); TurnOnDisplayerUpdates(); ContainerDisplayerUpdate( uSolute ); *************** *** 1747,1752 ToolCenterUnitByRadii( uSolute, FALSE ); DisplayerReleaseUpdates(); /* Solvate the solute */ iInitialSize = iContainerNumberOfChildren( uSolute ); --- 1747,1755 ----- ToolCenterUnitByRadii( uSolute, FALSE ); + TurnOnDisplayerUpdates(); + ContainerDisplayerUpdate( uSolute ); + /* Solvate the solute */ *************** *** 1749,1754 /* Solvate the solute */ iInitialSize = iContainerNumberOfChildren( uSolute ); DisplayerAccumulateUpdates(); ToolSolvate( uSolute, uSolvent, --- 1752,1760 ----- /* Solvate the solute */ + + TurnOffDisplayerUpdates(); + iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], *************** *** 1750,1756 /* Solvate the solute */ iInitialSize = iContainerNumberOfChildren( uSolute ); - DisplayerAccumulateUpdates(); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, TRUE ); --- 1756,1761 ----- TurnOffDisplayerUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, TRUE ); *************** *** 1754,1761 ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, TRUE ); - DisplayerReleaseUpdates(); - /* * Get rid of solvent copy */ --- 1759,1764 ----- ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, TRUE ); /* * Get rid of solvent copy */ *************** *** 1762,1767 ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); RETURN(NULL); --- 1765,1774 ----- ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); + TurnOnDisplayerUpdates(); + ContainerDisplayerUpdate(uSolute); + + VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); RETURN(NULL); *************** *** 1863,1869 /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); DisplayerReleaseUpdates(); --- 1870,1876 ----- /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! TurnOffDisplayerUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); TurnOnDisplayerUpdates(); *************** *** 1865,1871 DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); ! DisplayerReleaseUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); DisplayerAccumulateUpdates(); --- 1872,1878 ----- TurnOffDisplayerUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); ! TurnOnDisplayerUpdates(); ContainerDisplayerUpdate(uSolute); *************** *** 1867,1872 ToolCenterUnitByRadii( uSolute, FALSE ); DisplayerReleaseUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); DisplayerAccumulateUpdates(); ToolSolvate( uSolute, uSolvent, --- 1874,1882 ----- ToolCenterUnitByRadii( uSolute, FALSE ); TurnOnDisplayerUpdates(); + ContainerDisplayerUpdate(uSolute); + + TurnOffDisplayerUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], *************** *** 1868,1874 DisplayerReleaseUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); - DisplayerAccumulateUpdates(); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, FALSE ); --- 1878,1883 ----- TurnOffDisplayerUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, FALSE ); *************** *** 1872,1878 ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, FALSE ); - DisplayerReleaseUpdates(); /* * Get rid of solvent copy --- 1881,1886 ----- ToolSolvate( uSolute, uSolvent, daBuffer[0], daBuffer[1], daBuffer[2], dCloseness, FALSE ); /* * Get rid of solvent copy *************** *** 1880,1885 ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); RETURN(NULL); --- 1888,1896 ----- ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); + TurnOnDisplayerUpdates(); + ContainerDisplayerUpdate(uSolute); + VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); RETURN(NULL); *************** *** 1949,1955 /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); DisplayerReleaseUpdates(); --- 1960,1966 ----- /* Orient the principle axis of the solute along the */ /* coordinate axis, setting a box */ ! TurnOffDisplayerUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); TurnOnDisplayerUpdates(); ContainerDisplayerUpdate(uSolute); *************** *** 1951,1957 DisplayerAccumulateUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); ! DisplayerReleaseUpdates(); dThickness = dODouble(oAssocObject(aaArgs[2])); iInitialSize = iContainerNumberOfChildren( uSolute ); --- 1962,1969 ----- TurnOffDisplayerUpdates(); ToolCenterUnitByRadii( uSolute, FALSE ); ! TurnOnDisplayerUpdates(); ! ContainerDisplayerUpdate(uSolute); dThickness = dODouble(oAssocObject(aaArgs[2])); *************** *** 1954,1960 DisplayerReleaseUpdates(); dThickness = dODouble(oAssocObject(aaArgs[2])); - iInitialSize = iContainerNumberOfChildren( uSolute ); DisplayerAccumulateUpdates(); zToolSolvateAndShell( uSolute, uSolvent, --- 1966,1971 ----- ContainerDisplayerUpdate(uSolute); dThickness = dODouble(oAssocObject(aaArgs[2])); TurnOffDisplayerUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); *************** *** 1956,1962 dThickness = dODouble(oAssocObject(aaArgs[2])); iInitialSize = iContainerNumberOfChildren( uSolute ); ! DisplayerAccumulateUpdates(); zToolSolvateAndShell( uSolute, uSolvent, dThickness, dThickness, dThickness, dCloseness, dThickness, TRUE, TRUE ); --- 1967,1974 ----- dThickness = dODouble(oAssocObject(aaArgs[2])); ! TurnOffDisplayerUpdates(); ! iInitialSize = iContainerNumberOfChildren( uSolute ); zToolSolvateAndShell( uSolute, uSolvent, dThickness, dThickness, dThickness, dCloseness, dThickness, TRUE, TRUE ); *************** *** 1960,1966 zToolSolvateAndShell( uSolute, uSolvent, dThickness, dThickness, dThickness, dCloseness, dThickness, TRUE, TRUE ); - DisplayerReleaseUpdates(); /* * Get rid of solvent copy --- 1972,1977 ----- zToolSolvateAndShell( uSolute, uSolvent, dThickness, dThickness, dThickness, dCloseness, dThickness, TRUE, TRUE ); /* * Get rid of solvent copy *************** *** 1968,1973 ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); --- 1979,1987 ----- ContainerDestroy( &uSolvent ); iFinalSize = iContainerNumberOfChildren( uSolute ); + TurnOnDisplayerUpdates(); + ContainerDisplayerUpdate(uSolute); + VP0(( " Added %d residues.\n", iFinalSize - iInitialSize )); *************** *** 2526,2532 RETURN(NULL); } ! DisplayerAccumulateUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, FALSE ); DisplayerReleaseUpdates(); --- 2540,2546 ----- RETURN(NULL); } ! TurnOffDisplayerUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, FALSE ); TurnOnDisplayerUpdates(); *************** *** 2528,2534 DisplayerAccumulateUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, FALSE ); ! DisplayerReleaseUpdates(); fclose( fOut ); fclose( fCrd ); --- 2542,2548 ----- TurnOffDisplayerUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, FALSE ); ! TurnOnDisplayerUpdates(); fclose( fOut ); fclose( fCrd ); *************** *** 2580,2586 sCmd, sOString(oAssocObject(aaArgs[1])))); RETURN(NULL); } ! DisplayerAccumulateUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, TRUE ); DisplayerReleaseUpdates(); --- 2594,2601 ----- sCmd, sOString(oAssocObject(aaArgs[1])))); RETURN(NULL); } ! ! TurnOffDisplayerUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, TRUE ); TurnOnDisplayerUpdates(); *************** *** 2582,2589 } DisplayerAccumulateUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, TRUE ); ! DisplayerReleaseUpdates(); ! fclose( fOut ); fclose( fCrd ); RETURN(NULL); --- 2597,2604 ----- TurnOffDisplayerUpdates(); UnitSaveAmberParmFile( uUnit, fOut, fCrd, GplAllParameters, TRUE ); ! TurnOnDisplayerUpdates(); ! fclose( fOut ); fclose( fCrd ); RETURN(NULL); *************** *** 2616,2622 RETURN(NULL); } ! DisplayerAccumulateUpdates(); UnitIOSaveAmberPrep( uUnit, fOut ); DisplayerReleaseUpdates(); --- 2631,2637 ----- RETURN(NULL); } ! TurnOffDisplayerUpdates(); UnitIOSaveAmberPrep( uUnit, fOut ); TurnOnDisplayerUpdates(); *************** *** 2618,2624 DisplayerAccumulateUpdates(); UnitIOSaveAmberPrep( uUnit, fOut ); ! DisplayerReleaseUpdates(); fclose( fOut ); VP0(( " -- Remember to delete unwanted IMPROPER terms!\n" )); --- 2633,2639 ----- TurnOffDisplayerUpdates(); UnitIOSaveAmberPrep( uUnit, fOut ); ! TurnOnDisplayerUpdates(); fclose( fOut ); VP0(( " -- Remember to delete unwanted IMPROPER terms!\n" )); *************** *** 3582,3588 RETURN(NULL); } - DisplayerAccumulateUpdates(); dRadius = dODouble(oAssocObject(aaArgs[3])); if ( dRadius < 0.0 ) { --- 3597,3602 ----- RETURN(NULL); } dRadius = dODouble(oAssocObject(aaArgs[3])); if ( dRadius < 0.0 ) { *************** *** 3590,3595 RETURN(NULL); } iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolventSphere( uSolute, uSolvent, dCloseness, &vPos, dRadius ); iFinalSize = iContainerNumberOfChildren( uSolute ); --- 3604,3610 ----- RETURN(NULL); } + TurnOffDisplayerUpdates(); iInitialSize = iContainerNumberOfChildren( uSolute ); ToolSolventSphere( uSolute, uSolvent, dCloseness, &vPos, dRadius ); iFinalSize = iContainerNumberOfChildren( uSolute ); *************** *** 3601,3607 UnitSetSolventCap( uSolute, dVX(&vPos), dVY(&vPos), dVZ(&vPos), dRadius ); UnitSetUseSolventCap( uSolute, TRUE ); ! DisplayerReleaseUpdates(); RETURN(NULL); } --- 3616,3623 ----- UnitSetSolventCap( uSolute, dVX(&vPos), dVY(&vPos), dVZ(&vPos), dRadius ); UnitSetUseSolventCap( uSolute, TRUE ); ! TurnOnDisplayerUpdates(); ! ContainerDisplayerUpdate( uSolute ); RETURN(NULL); } *************** *** 4010,4016 dDist = dODouble(oAssocObject(aaArgs[1])); } ! DisplayerAccumulateUpdates(); iBonds = iToolDistanceSearch( oAssocObject(aaArgs[0]), dDist, TRUE, DISTANCE_SEARCH_CREATE_BONDS ); --- 4026,4032 ----- dDist = dODouble(oAssocObject(aaArgs[1])); } ! TurnOffDisplayerUpdates(); iBonds = iToolDistanceSearch( oAssocObject(aaArgs[0]), dDist, TRUE, DISTANCE_SEARCH_CREATE_BONDS ); *************** *** 4017,4023 VP0(( "Created %d bonds.\n", iBonds )); ! DisplayerReleaseUpdates(); RETURN(NULL); } --- 4033,4040 ----- VP0(( "Created %d bonds.\n", iBonds )); ! TurnOnDisplayerUpdates(); ! ContainerDisplayerUpdate( oAssocObject(aaArgs[0]) ); RETURN(NULL); } *************** *** 4706,4712 } else VP0((" (no solvent present)\n" )); ! DisplayerAccumulateUpdates(); OctTreeInitCharges( octTreeSolute, AT_OCTREE, iDielectricFlag, dIonSize1, &vMinPot, &vMaxPot ); --- 4723,4729 ----- } else VP0((" (no solvent present)\n" )); ! TurnOffDisplayerUpdates(); OctTreeInitCharges( octTreeSolute, AT_OCTREE, iDielectricFlag, dIonSize1, &vMinPot, &vMaxPot ); *************** *** 4792,4798 OctTreeDestroy( &octTreeSolute ); if ( vaSolvent ) VarArrayDestroy( &vaSolvent ); ! DisplayerReleaseUpdates(); RETURN(NULL); CANCEL: --- 4809,4816 ----- OctTreeDestroy( &octTreeSolute ); if ( vaSolvent ) VarArrayDestroy( &vaSolvent ); ! TurnOnDisplayerUpdates(); ! ContainerDisplayerUpdate( uUnit ); RETURN(NULL); CANCEL: *************** *** 5031,5037 ToolInitSolventPotential( uUnit, vaSolvent, &iMinPotRes, &iMaxPotRes ); VP0(( "placing ions..\n" )); ! DisplayerAccumulateUpdates(); while ( iIon1 || iIon2 ) { if ( bBasicsInterrupt() ) goto CANCEL; if ( iIon1 ) { --- 5049,5055 ----- ToolInitSolventPotential( uUnit, vaSolvent, &iMinPotRes, &iMaxPotRes ); VP0(( "placing ions..\n" )); ! TurnOffDisplayerUpdates(); while ( iIon1 || iIon2 ) { if ( bBasicsInterrupt() ) goto CANCEL; if ( iIon1 ) { *************** *** 5063,5069 } VP0(( "\nDone adding ions.\n" )); VarArrayDestroy( &vaSolvent ); ! DisplayerReleaseUpdates(); RETURN(NULL); CANCEL: --- 5081,5088 ----- } VP0(( "\nDone adding ions.\n" )); VarArrayDestroy( &vaSolvent ); ! TurnOnDisplayerUpdates(); ! ContainerDisplayerUpdate( uUnit ); RETURN(NULL); CANCEL: -----------------------------------------------------------------------------