'Recalculate the optimal zoom and fits the content into view.
Should be called if the scene contents change, so that the optimal zoom
can be recalculated.
Returns'

def recalculate_and_fit(self):

    if (self.__central_widget is not None):
        self.fitInView(self.central_widget_rect(), Qt.KeepAspectRatio)
    else:
        self.fitInView(self.scene().sceneRect(), Qt.KeepAspectRatio)
    self.__initial_zoom = self.transform().m11()
    self.zoom = self.__initial_zoom
