# -*- coding: ISO-8859-1 -*- """ capellaScript -- Copyright (c) 2009, 2017 Peter Becker >>> Pausen unsichtbar Achtung : Die ausgewählten Pausen werden unsichtbar markiert|| Im Fehlerfall bitte eine Mail an peter_becker@freenet.de <<< Rests invisible

N.B. : The selected rests are made invisible.

In case of problems please mail to peter_becker@freenet.de

Pausen unsichtbar

Achtung : Die ausgewählten Pausen werden unsichtbar markiert.

Im Fehlerfall bitte eine Mail an peter_becker@freenet.de

Rusten onzichtbaar

Let op : De geselecteerde rusten worden onzichtbaar gemaakt.

Bij problemen graag een mail naar peter_becker@freenet.de

History: 15.08.09 - V 1.0.0 PB Erste Ausgabe 17.08.09 - V 1.0.1 PB kleine Korrekturen 04.08.17 - V 1.0.2 PB Bugfix wegen Python 2.7 ( Capella 8 ) 30.12.18 - V 1.0.3 WW Internationalisiert (en-de-nl) 20.08.20 - V 1.0.4 WW - Kleine Korrekturen in nl-Text - unnötige Elemente entfernt - Eingaben werden gespeichert - Versionsnummer in Titeltext """ #------------------ english = { 'error' :'Error', 'noScore' :'No active score', 'selNotes' :'Marked notes in the staff', '1VoiceStaff' :'One voice in the staff', 'allVoicesStaff' :'All voices in one staff', 'system' :'System', 'score' :'Score', 'rangeSel' :'Range selection', 'title' :'Rests Invisible Version : ' } german = { 'error' :'Fehler', 'noScore' :'keine aktive Partitur', 'selNotes' :'markierte Noten in der Zeile', '1VoiceStaff' :'eine Stimme in der Zeile', 'allVoicesStaff' :'alle Stimmen in einer Zeile', 'system' :'System', 'score' :'Partitur', 'rangeSel' :'Bereichswahl', 'title' :'Pausen unsichtbar Version : ' } dutch = { 'error' :'Fout', 'noScore' :'Geen actieve partituur', 'selNotes' :'Gemarkeerde noten in de notenbalk', '1VoiceStaff' :'Één stem in de notenbalk', 'allVoicesStaff' :'Alle stemmen in één notenbalk', 'system' :'Systeem', 'score' :'Partituur', 'rangeSel' :'Selectie van het bereik', 'title' :'Rusten onzichtbaar Versie : ' } try: setStringTable( ("en", english), ("de", german), ("nl", dutch)) except: def tr(s): return german[s] #-------------------------- import xml.dom, tempfile from caplib.capDOM import * from xml.dom.minidom import * doc = [] # parentNode von score version = '1.0.4' def latin1_e(u): return u.encode('Latin-1') def getCursor(): sel = curSelection() result = None if sel == 0: messageBox(tr('error'), tr('noScore')) return result return sel def getElementObjects(objList): # returns a List newList = NodeList() for n in range(objList.length): if objList[n].nodeType == objList[n].ELEMENT_NODE: newList.append(objList[n]) return newList def addNewElementNode(el,tagName): # add new Node with tagName "tagName" to el global doc newChild = doc.createElement(tagName) el.appendChild(newChild) return newChild def getBaseData(score): global sel, system, staff, voice, chord, system1, staff1, voice1, chord1, noteObject, objList global sy1,st1,vo1,ob1,sy2,st2,vo2,ob2 (sy1,st1,vo1,ob1),(sy2,st2,vo2,ob2) = sel system = score.getElementsByTagName('system')[sy1] staff = system.getElementsByTagName('staff')[st1] voice = staff.getElementsByTagName('voice')[vo1] nobjs = voice.getElementsByTagName('noteObjects')[0] objList = getElementObjects(nobjs.childNodes) def verbergen(score): global sel, system, staff,voice, noteObject, objList, vo, takt , auswahl global sy1,st1,vo1,ob1,sy2,st2,vo2,ob2,ix for ob in objList: if auswahl == 0: if ix < ob2: #messageBox('LST',str(objList[ix])) obj = objList[ix] #messageBox('SE',str(obj)) ix = ix+1 if obj.tagName == 'rest': display = obj.getElementsByTagName('display') #messageBox('SE',str(display)) if str(display) == '[]': display = addNewElementNode(obj,'display') display.setAttribute('invisible','true') else: display[0].setAttribute('invisible','true') else: break else : if ob.tagName == 'rest': display = ob.getElementsByTagName('display') #messageBox('SE',str(display)) if str(display) == '[]': display = addNewElementNode(ob,'display') display.setAttribute('invisible','true') else: display[0].setAttribute('invisible','true') # Hier kommt die Klasse die vom Ende her aufgerufen wird ------------------------------------------------- class ScoreChange(ScoreChange): def changeScore(self, score): global doc, sel, system, staff, voice, chord, system1, staff1, voice1, chord1, noteObject global sy1,st1,vo1,ob1,sy2,st2,vo2,ob2,ix global objList,vo, takt global auswahl doc = score.parentNode sel = getCursor() #messageBox('Markierung',str(sel)) if sel == None: return else: if auswahl == 0: # nur Note getBaseData(score) if sel <> 0: ix = ob1 verbergen(score) elif auswahl == 1: # eine Stimme in einer Zeile getBaseData(score) ix = 0 verbergen(score) elif auswahl == 2: # alle Stimmen in einer Zeile getBaseData(score) obj = objList[vo1] voiceList = getElementObjects(obj.parentNode.parentNode.parentNode.childNodes) #messageBox('VL',str(voiceList)) for voIx in range(voiceList.length): takt = 0 noteObject = voiceList[voIx].getElementsByTagName('noteObjects')[0] objList = getElementObjects(noteObject.childNodes) vo=activeScore().system(sy1).staff(st1).voice(voIx) voice=voiceList[voIx] for obj in range(objList.length): no = vo.noteObj(obj) ix = 0 verbergen(score) elif auswahl == 3: # System getBaseData(score) staves = staff.parentNode staffList = getElementObjects(staves.childNodes) for stIx in range(staffList.length): voicesList = getElementObjects(staffList[stIx].childNodes) for vsIx in range(voicesList.length): voiceList = getElementObjects(voicesList[vsIx].childNodes) for voIx in range(voiceList.length): vo=activeScore().system(sy1).staff(stIx).voice(voIx) voice=voiceList[voIx] noteObject = voiceList[voIx].getElementsByTagName('noteObjects')[0] objList = getElementObjects(noteObject.childNodes) for obj in range(objList.length): no = vo.noteObj(obj) ix = 0 verbergen(score) elif auswahl == 4: # Partitur getBaseData(score) systems = system.parentNode systemList = getElementObjects(systems.childNodes) for syIx in range(systemList.length): staves = getElementObjects(systemList[syIx].childNodes) for svIx in range(staves.length): staffList = getElementObjects(staves[svIx].childNodes) for stIx in range(staffList.length): voicesList = getElementObjects(staffList[stIx].childNodes) for vsIx in range(voicesList.length): voiceList = getElementObjects(voicesList[vsIx].childNodes) for voIx in range(voiceList.length): vo=activeScore().system(syIx).staff(stIx).voice(voIx) voice=voiceList[voIx] noteObject = voiceList[voIx].getElementsByTagName('noteObjects')[0] objList = getElementObjects(noteObject.childNodes) for obj in range(objList.length): no = vo.noteObj(obj) ix = 0 verbergen(score) return # Jetzt kommt der Code für den Dialog---------------------------------------------------------------------- def scriptDialog(): global auswahl options = ScriptOptions() opt = options.get() radAuswahl = Radio([tr('selNotes'),tr('1VoiceStaff'),tr('allVoicesStaff'),tr('system'),tr('score')],text=tr('rangeSel'),value=int(opt.get('auswahl', 0))) box = HBox([radAuswahl]) dlg = Dialog(tr('title') + version, box) # und nun wird der Dialog aufgerufen ---------------------------------------------------------------------- if dlg.run(): auswahl = radAuswahl.value() opt.update(dict(auswahl=auswahl)) options.set(opt) return True else: return False # das sollte immer am Ende stehen, denn sonst lassen sich die Aktionen des Skriptes nicht rückgängig machen if activeScore(): if scriptDialog(): activeScore().registerUndo("Pausen unsichtbar") tempInput = tempfile.mktemp('.capx') tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) ScoreChange(tempInput, tempOutput) # messageBox(tempInput, tempOutput) activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput)