def addMargin(self, margin, index=None):
        """Adds a new margin.
           index: index in the list of margins. Default: to the end of the list
        """
        if index is None:
            self._margins.append(margin)
        else:
            self._margins.insert(index, margin)
        if margin.isVisible():
            self.updateViewport()
Adds a new margin.
           index: index in the list of margins. Default: to the end of the list