from PyQt4.QtGui import QGraphicsView, QPainter

class DiagramView(QGraphicsView):
    
    def __init__(self, scene, parent = None):
        QGraphicsView.__init__(self, scene, parent)
        self.scene = scene
        self.viewScaleMatrixX = 1.0
        self.viewScaleMatrixY = 1.0
        self.viewScaleRHierarchyX = 1.0
        self.viewScaleRHierarchyY = 1.0
        self.viewScaleCoterieX = 1.0
        self.viewScaleCoterieY = 1.0
        self.setRenderHint(QPainter.HighQualityAntialiasing, True)
        
    def fitGeneralGraph(self):
        pass
#         topLeftX = self.viewport().width()
#         topLeftY = self.viewport().height()
#         bottomRightX = 0
#         bottomRightY = 0
#         for item in self.scene().items():
#             if isinstance(item, ClearanceNode):
#                 p = item.pos()
#                 if p.x() < topLeftX:
#                     topLeftX = p.x()
#                 if p.y() < topLeftY:
#                     topLeftY = p.y()
#                 if p.x() > bottomRightX:
#                     bottomRightX = p.x()
#                 if p.y() > bottomRightY:
#                     bottomRightY = p.y()
#         topLeftX -= self.viewport().width()/100
#         topLeftY -= self.viewport().height()/100
#         bottomRightX += self.viewport().width()/100
#         bottomRightY += self.viewport().height()/100
#         self.fitInView(topLeftX, topLeftY, bottomRightX-topLeftX, bottomRightY-topLeftY, mode = Qt.KeepAspectRatio)
        
    def fitTypeGraph(self):
        pass
#         topLeftX = self.geometry().width()
#         topLeftY = self.geometry().height()
#         bottomRightX = 0
#         bottomRightY = 0
#         
#         for item in self.scene().items():
#             if isinstance(item, FileNode):
#                 p = item.pos()
#                 if p.x() < topLeftX:
#                     topLeftX = p.x()
#                 if p.y() < topLeftY:
#                     topLeftY = p.y()
#                 if p.x() > bottomRightX:
#                     bottomRightX = p.x()
#                 if p.y() > bottomRightY:
#                     bottomRightY = p.y()
#         topLeftX -= self.geometry().width()/100
#         topLeftY -= self.geometry().height()/100
#         bottomRightX += self.geometry().width()/100
#         bottomRightY += self.geometry().height()/100
#         self.fitInView(topLeftX, topLeftY, bottomRightX-topLeftX, bottomRightY-topLeftY, mode = Qt.KeepAspectRatio)