def test_init(): with mockCmaps() as (assetDir, sdir): fslcm.init() cmap1 = op.join(assetDir, 'colourmaps', 'cmap1.cmap') cmap2 = op.join(sdir, 'colourmaps', 'cmap2.cmap') lut1 = op.join(assetDir, 'luts', 'lut1.lut') lut2 = op.join(sdir, 'luts', 'lut2.lut') assert fslcm.getColourMaps() == ['cmap1', 'cmap2'] assert fslcm.getColourMapLabel( 'cmap1') == 'cmap1' assert fslcm.getColourMapLabel( 'cmap2') == 'cmap2' assert fslcm.getColourMapFile( 'cmap1') == cmap1 assert fslcm.getColourMapFile( 'cmap2') == cmap2 assert fslcm.getLookupTableFile('lut1') == lut1 assert fslcm.getLookupTableFile('lut2') == lut2 assert fslcm.isColourMapInstalled( 'cmap1') assert fslcm.isColourMapInstalled( 'cmap2') assert fslcm.isColourMapRegistered( 'cmap1') assert fslcm.isColourMapRegistered( 'cmap2') assert fslcm.isLookupTableInstalled( 'lut1') assert fslcm.isLookupTableInstalled( 'lut2') assert fslcm.isLookupTableRegistered('lut1') assert fslcm.isLookupTableRegistered('lut2') luts = fslcm.getLookupTables() assert len(luts) == 2 assert luts[0].key == 'lut1' assert luts[1].key == 'lut2'
def promptForLutName(initial=None): """Prompts the user to enter a name for a newly created :class:`.LookupTable`. """ if initial is None: initial = strings.labels[LookupTablePanel, 'newLutDefault'] nameMsg = strings.messages[LookupTablePanel, 'newlut'] nameTitle = strings.titles[LookupTablePanel, 'newlut'] while True: dlg = wx.TextEntryDialog(wx.GetApp().GetTopWindow(), nameMsg, nameTitle, initial) if dlg.ShowModal() != wx.ID_OK: return None, None lutName = dlg.GetValue() lutKey = fslcmaps.makeValidMapKey(lutName) # a lut with the specified name already exists if fslcmaps.isLookupTableRegistered(lutKey): nameMsg = strings.messages[LookupTablePanel, 'alreadyinstalled'] continue break return lutKey, lutName
def test_register(): cmap = tw.dedent(""" 0 0 0 0 0 1 0 1 1 1 1 1 """).strip() lut = tw.dedent(""" 1 0 0 0 label 1 2 0 0 1 label 2 3 0 1 1 label 3 4 1 1 1 label 4 """).strip() with mockCmaps() as (assetDir, sdir): fslcm.init() with open('cmap.txt', 'wt') as f: f.write(cmap) with open('lut.txt', 'wt') as f: f.write(lut) assert not fslcm.isColourMapRegistered('mycmap') fslcm.registerColourMap('cmap.txt', key='mycmap', name='My cmap') fslcm.getColourMap('mycmap') assert fslcm.isColourMapRegistered('mycmap') assert not fslcm.isColourMapInstalled( 'mycmap') assert fslcm.getColourMapLabel('mycmap') == 'My cmap' fslcm.installColourMap('mycmap') assert fslcm.isColourMapInstalled( 'mycmap') assert not fslcm.isLookupTableRegistered('mylut') fslcm.registerLookupTable('lut.txt', key='mylut', name='My lut') assert fslcm.isLookupTableRegistered('mylut') assert not fslcm.isLookupTableInstalled( 'mylut') assert fslcm.getLookupTable('mylut').name == 'My lut' fslcm.installLookupTable('mylut') assert fslcm.isLookupTableInstalled( 'mylut')