Esempio n. 1
0
class ObjectManager:
    def __init__(self, parent):
        self.parent = parent
        self.nobj = 0
        self.objs = {}
        self.table = ParTable(self)
        self.tableVisible = False

    def deleteObject(self, name):
        del self.objs[name]
        self.nobj -= 1
        # Rename objects so they aren't overwritten
        keys = self.objs.keys()
        keys.sort()
        objs = {}
        for i in range(len(keys)):
            newkey = "%s %d" % (self.label, i + 1)
            objs[newkey] = self.objs[keys[i]]
            objs[newkey].name = newkey
        self.objs = objs
        if self.tableVisible:
            if len(self.objs) == 0:
                self.table.closeTable()
            else:
                self.table.drawTable()
        self.parent.fitLight()

    def tableClosed(self):
        self.tableVisible = False
        return

    def load(self, objs):
        self.nobj = len(objs)
        self.objs = {}
        keys = objs.keys()
        keys.sort()
        for name in keys:
            pars = objs[name]
            self.objs[name] = self.lfObject(0, 0, name, self)
            self.objs[name].pars = pars

    def getSave(self):
        objs = {}
        for name, obj in self.objs.iteritems():
            obj.reset()
            objs[name] = obj.pars
        return objs

    def addModel(self, x, y):
        self.nobj += 1
        name = "%s %d" % (self.label, self.nobj)
        self.objs[name] = self.lfObject(x, y, name, self)
        self.parent.fitLight()
        return name
Esempio n. 2
0
 def __init__(self, parent):
     self.parent = parent
     self.nobj = 0
     self.objs = {}
     self.table = ParTable(self)
     self.tableVisible = False