示例#1
0
 def readfile(self, fpath):
     furno, fixed, comment = 0, True, ''
     with open(fpath) as f:
         for l in f.readlines():
             l = l.strip('\t \r\n')
             if not l:
                 pass
             elif l.startswith('#'):
                 if fixed:
                     self.content.append(l[1:].strip())
                 else:
                     comment += l+'\n'
             elif l.startswith('$'):
                 fixed = False
             else:
                 if furno:
                     if fixed:
                         self.content.append(Contour(l).getPoints())
                     else:
                         self.buff.append((Contour(l), comment))
                         comment = ''
                 else:
                     self.contour = Contour(l)
                     self.autofit()
                 furno += 1
示例#2
0
 def dragFixedStaff(self, *pos):
     if self.contentIdxLocked:
         self.dragStaff.origin = self.rossecorp(Point(*pos))
         self.content[self.contentIdx] = self.dragStaff.getPoints()
         self.dragStaff = None
         self.contentIdx = -1
         self.contentIdxLocked = False
     elif self.content and 0<=self.contentIdx<len(self.content) and type(self.content[self.contentIdx]) is list:
         cnt = Contour()
         cnt.points = self.content[self.contentIdx]
         cnt.setInstruct(cnt.getInstruct())
         self.dragStaff = cnt
         self.content[self.contentIdx] = None
         self.contentIdxLocked = True
示例#3
0
 def writefile(self, fpath):
     with open(fpath,'w+') as f:
         f.write(self.contour.getInstruct())
         f.write('\n')
         for c in self.content:
             if type(c) is str:
                 f.write("# "+c)
             else:
                 cnt = Contour()
                 cnt.points = c
                 cnt.origin = c[0]
                 f.write(cnt.getInstruct())
             f.write('\n')
         f.write('$ fixed components end and drag ones begin\n')
         for b in self.buff:
             f.write(b[1])
             f.write(b[0].getInstruct(False))
             f.write('\n')