class TracepointWaveController(QObject):
    '''Controller for Tracepoint Wave widget.
        Following datatypes can be displayed in waveform: bool, int, float, double
    '''

    def __init__(self, distributedObjects):
        '''CTOR'''
        QObject.__init__(self)

        self.distributedObjects = distributedObjects
        self.model = TracepointWaveModel()
        self.supportedTypes = ["bool", "int", "float", "double"]
        self.view = TracepointWaveView()
        self.view.setModel(self.model)
        delegate = TracepointWaveDelegate()

        # TracepointWaveView using TracepointWaveDelegate to paint waveforms
        self.view.setItemDelegate(delegate)
        self.view.getZoomInButton().clicked.connect(self.zoomIn)
        self.view.getZoomOutButton().clicked.connect(self.zoomOut)
        self.distributedObjects.signalProxy.insertDockWidgets.connect(self.insertDockWidgets)
        self.distributedObjects.signalProxy.cleanupModels.connect(self.model.cleanUp)

    def insertDockWidgets(self):
        '''Function invoked when mainwindow allows controllers to insert widgets'''
        self.distributedObjects.signalProxy.emitAddDockWidget(Qt.BottomDockWidgetArea, self.view.getDockWidget(), True)

    def updateTracepointWaveView(self, list_):
        ''' Repaint tracepoint waves
            @param list_: list of ValueList objects
        '''
        self.model.cleanUp(False)    # clean up without reseting zoom
        for item in list_:
            for v in item.values:
                self.__updateTracepointWave(item.name, item.type, v)

    def zoomIn(self):
        '''Zoom wave horizontally'''
        self.model.zoomIn()
        self.view.resizeColumnsToContents()

    def zoomOut(self):
        '''Zoom wave horizontally'''
        self.model.zoomOut()
        self.view.resizeColumnsToContents()

    def __updateTracepointWave(self, name, type_, value):
        ''' Append value to tracepoint wave. Creates new wave if model does not contain wave with name and value type
            @param name: string with variable name
            @param type_: string with type of variable ("bool", "int", "float", "double" supported).
            @param value: value of variable
        '''
        if type_ in self.supportedTypes:
            self.model.updateTracepointWave(name, type_, value)
            self.view.resizeColumnsToContents()
        else:
            logging.error("Could not update tracepoint wave. Illegal variable type.")
class TracepointWaveController(QObject):
    '''Controller for Tracepoint Wave widget.
        Following datatypes can be displayed in waveform: bool, int, float, double
    '''
    def __init__(self, distributedObjects):
        '''CTOR'''
        QObject.__init__(self)

        self.distributedObjects = distributedObjects
        self.model = TracepointWaveModel()
        self.supportedTypes = ["bool", "int", "float", "double"]
        self.view = TracepointWaveView()
        self.view.setModel(self.model)
        delegate = TracepointWaveDelegate()

        # TracepointWaveView using TracepointWaveDelegate to paint waveforms
        self.view.setItemDelegate(delegate)
        self.view.getZoomInButton().clicked.connect(self.zoomIn)
        self.view.getZoomOutButton().clicked.connect(self.zoomOut)
        self.distributedObjects.mainwindow.insertDockWidget(
            self.view.widget, "Tracepoint Wave", Qt.BottomDockWidgetArea, True)
        self.distributedObjects.signalProxy.cleanupModels.connect(
            self.model.cleanUp)

    def updateTracepointWaveView(self, list_):
        ''' Repaint tracepoint waves
            @param list_: list of ValueList objects
        '''
        self.model.cleanUp(False)  # clean up without reseting zoom
        for item in list_:
            for v in item.values:
                self.__updateTracepointWave(item.name, item.type, v)

    def zoomIn(self):
        '''Zoom wave horizontally'''
        self.model.zoomIn()
        self.view.resizeColumnsToContents()

    def zoomOut(self):
        '''Zoom wave horizontally'''
        self.model.zoomOut()
        self.view.resizeColumnsToContents()

    def __updateTracepointWave(self, name, type_, value):
        ''' Append value to tracepoint wave. Creates new wave if model does not contain wave with name and value type
            @param name: string with variable name
            @param type_: string with type of variable ("bool", "int", "float", "double" supported).
            @param value: value of variable
        '''
        if type_ in self.supportedTypes:
            self.model.updateTracepointWave(name, type_, value)
            self.view.resizeColumnsToContents()
        else:
            logging.error(
                "Could not update tracepoint wave. Illegal variable type.")
    def __init__(self, distributedObjects):
        '''CTOR'''
        QObject.__init__(self)

        self.distributedObjects = distributedObjects
        self.model = TracepointWaveModel()
        self.supportedTypes = ["bool", "int", "float", "double"]
        self.view = TracepointWaveView()
        self.view.setModel(self.model)
        delegate = TracepointWaveDelegate()

        # TracepointWaveView using TracepointWaveDelegate to paint waveforms
        self.view.setItemDelegate(delegate)
        self.view.getZoomInButton().clicked.connect(self.zoomIn)
        self.view.getZoomOutButton().clicked.connect(self.zoomOut)
        self.distributedObjects.mainwindow.insertDockWidget(
            self.view.widget, "Tracepoint Wave", Qt.BottomDockWidgetArea, True)
        self.distributedObjects.signalProxy.cleanupModels.connect(
            self.model.cleanUp)
    def __init__(self, distributedObjects):
        '''CTOR'''
        QObject.__init__(self)

        self.distributedObjects = distributedObjects
        self.model = TracepointWaveModel()
        self.supportedTypes = ["bool", "int", "float", "double"]
        self.view = TracepointWaveView()
        self.view.setModel(self.model)
        delegate = TracepointWaveDelegate()

        # TracepointWaveView using TracepointWaveDelegate to paint waveforms
        self.view.setItemDelegate(delegate)
        self.view.getZoomInButton().clicked.connect(self.zoomIn)
        self.view.getZoomOutButton().clicked.connect(self.zoomOut)
        self.distributedObjects.signalProxy.insertDockWidgets.connect(self.insertDockWidgets)
        self.distributedObjects.signalProxy.cleanupModels.connect(self.model.cleanUp)