def setCache(self, val = 1):
        """ Sets cache on (or updates), or turns off """
        # first clear the old cached values
        self.cacheConnections = []
        self.cacheLayers = []
        if val:
            for layer in self.layers:
                if layer.active and not layer.frozen:
                    self.cacheLayers.append( layer )
            for connection in self.connections:
                if connection.active and not connection.frozen:
                    self.cacheConnections.append( connection )