Source code for ccpn.ui.gui.lib.SpectrumDisplay

"""
Module Documentation here
"""
#=========================================================================================
# Licence, Reference and Credits
#=========================================================================================
__copyright__ = "Copyright (C) CCPN project (http://www.ccpn.ac.uk) 2014 - 2022"
__credits__ = ("Ed Brooksbank, Joanna Fox, Victoria A Higman, Luca Mureddu, Eliza Płoskoń",
               "Timothy J Ragan, Brian O Smith, Gary S Thompson & Geerten W Vuister")
__licence__ = ("CCPN licence. See http://www.ccpn.ac.uk/v3-software/downloads/license")
__reference__ = ("Skinner, S.P., Fogh, R.H., Boucher, W., Ragan, T.J., Mureddu, L.G., & Vuister, G.W.",
                 "CcpNmr AnalysisAssign: a flexible platform for integrated NMR analysis",
                 "J.Biomol.Nmr (2016), 66, 111-124, http://doi.org/10.1007/s10858-016-0060-y")
#=========================================================================================
# Last code modification
#=========================================================================================
__modifiedBy__ = "$modifiedBy: Ed Brooksbank $"
__dateModified__ = "$dateModified: 2022-01-13 17:30:50 +0000 (Thu, January 13, 2022) $"
__version__ = "$Revision: 3.0.4 $"
#=========================================================================================
# Created
#=========================================================================================
__author__ = "$Author: CCPN $"
__date__ = "$Date: 2021-09-17 15:02:29 +0100 (Fri, September 17, 2021) $"
#=========================================================================================
# Start of code
#=========================================================================================

from ccpn.core.NmrAtom import NmrAtom
from ccpn.core.Peak import Peak
from ccpn.core.Project import Project
from typing import List
from ccpn.ui.gui.lib.GuiSpectrumDisplay import GuiSpectrumDisplay
from ccpn.ui.gui.lib.StripLib import navigateToPositionInStrip, navigateToNmrAtomsInStrip
from ccpn.core.lib.ContextManagers import undoBlockWithoutSideBar, undoStackBlocking
from ccpn.util.Logging import getLogger








[docs]def makeStripPlot(spectrumDisplay: GuiSpectrumDisplay, nmrAtomPairs: List[List[NmrAtom]], autoWidth=True, widths=None): if not nmrAtomPairs: return # with undoBlockWithoutSideBar(): with undoStackBlocking() as _: # Do not add to undo/redo stack numberOfStrips = len(spectrumDisplay.strips) # Make sure there are enough strips to display nmrAtomPairs if numberOfStrips < len(nmrAtomPairs): for ii in range(numberOfStrips, len(nmrAtomPairs)): # spectrumDisplay.strips[-1].clone() spectrumDisplay.addStrip() else: # numberOfStrips >= len(nmrAtomPairs): # too many strips if > for ii in range(len(nmrAtomPairs), numberOfStrips): spectrumDisplay.deleteStrip(spectrumDisplay.strips[-1]) # spectrumDisplay.removeLastStrip() # loop through strips and navigate to appropriate position in strip for ii, strip in enumerate(spectrumDisplay.strips): if autoWidth: widths = ['default'] * len(strip.axisCodes) elif not widths: widths = None navigateToNmrAtomsInStrip(strip, nmrAtomPairs[ii], widths=widths)
[docs]def makeStripPlotFromSingles(spectrumDisplay: GuiSpectrumDisplay, nmrAtoms: List[NmrAtom], autoWidth=True): numberOfStrips = len(spectrumDisplay.strips) with undoStackBlocking() as _: # Do not add to undo/redo stack # Make sure there are enough strips to display nmrAtomPairs if numberOfStrips < len(nmrAtoms): for ii in range(numberOfStrips, len(nmrAtoms)): # spectrumDisplay.strips[-1].clone() spectrumDisplay.addStrip() # print(spectrumDisplay, nmrAtomPairs, len(nmrAtomPairs), len(spectrumDisplay.strips)) # loop through strips and navigate to appropriate position in strip for ii, strip in enumerate(spectrumDisplay.strips): if autoWidth: widths = ['default'] * len(strip.axisCodes) else: widths = None navigateToNmrAtomsInStrip(strip, [nmrAtoms[ii]], widths=widths)
# strip.header.headerVisible = True # strip.header.headerVisible = True