# Path: hearinglosssimulator/gui/myqt.py
# QT = ModuleProxy(['', 'Q', 'Qt'], [QtCore.Qt, QtCore, QtGui, QtWidgets])
# 
# Path: hearinglosssimulator/gui/gpuselection.py
# class GpuDeviceSelection(QT.QWidget):
#     def __init__(self, parent = None):
#         QT.QWidget.__init__(self, parent)
#         mainlayout  =QT.QVBoxLayout()
#         self.setLayout(mainlayout)
# 
#         mainlayout.addWidget(QT.QLabel(u'OpenCL Platform'))
#         self.combo_platform = QT.QComboBox()
#         mainlayout.addWidget(self.combo_platform)
#         
#         mainlayout.addWidget(QT.QLabel(u'OpenCL Device'))
#         self.combo_dev = QT.QComboBox()
#         mainlayout.addWidget(self.combo_dev)
#         
#         mainlayout.addStretch()
#         
#         self.resfresh_platform_list()
#         self.combo_platform.currentIndexChanged.connect(self.resfresh_device_list)
#         
#         if len(pyopencl.get_platforms())>0:
#             self.resfresh_device_list(0)
#     
#     def set_configuration(self, platform_index = 0, device_index = 0):
#         self.combo_platform.currentIndexChanged.disconnect(self.resfresh_device_list)
#         try: 
#             self.combo_platform.setCurrentIndex(platform_index)
#         except: 
#             pass
#         try:
#             self.resfresh_device_list(platform_index)
#         except:
#             pass
#         try:
#             self.combo_dev.setCurrentIndex(device_index)
#         except: 
#             pass
#         self.combo_platform.currentIndexChanged.connect(self.resfresh_device_list)
#     
#     def get_configuration(self):
#         config = {'platform_index': int(self.combo_platform.currentIndex()),
#                         'device_index':int(self.combo_dev.currentIndex()),
#                         }
#         return config
#     
#     def resfresh_platform_list(self):
#         self.combo_platform.clear()
#         for i, platform in enumerate(pyopencl.get_platforms()):
#             self.combo_platform.addItem(u'{}: {}'.format(i, platform.name))
#         
#     def resfresh_device_list(self, platform_index):
#         self.combo_dev.clear()
#         platform = pyopencl.get_platforms()[platform_index]
#         
#         for i, dev in enumerate(platform.get_devices()):
#             self.combo_dev.addItem(u'{}: {}'.format(i, dev.name))


import hearinglosssimulator as hls
import pyqtgraph as pg
import numpy as np
    import pyqtgraph as pg
from hearinglosssimulator.gui.myqt import QT
from hearinglosssimulator.gui.gpuselection import GpuDeviceSelection
_params = [
    {'name': 'chunksize', 'type': 'list', 'values': [256, 1024] },
    {'name': 'sample_rate', 'type': 'float', 'value':44100., 'suffix': 'Hz', 'siPrefix': True},
    {'name': 'nloop', 'type': 'int', 'value': 100 },
    {'name': 'nb_channel', 'type': 'int', 'value': 2 },
]



class WindowDebugGPU(QT.QWidget):
    def __init__(self,parent = None):
        QT.QWidget.__init__(self, parent)
        
        self.resize(600,600)
        
        mainlayout  =QT.QVBoxLayout()
        self.setLayout(mainlayout)
        
        self.gpuDeviceSelection = GpuDeviceSelection()
        mainlayout.addWidget(self.gpuDeviceSelection)


        self.params = pg.parametertree.Parameter.create(name='params', type='group', children=_params)
        
        self.tree_params = pg.parametertree.ParameterTree(parent  = self)
        self.tree_params.header().hide()
        self.tree_params.setParameters(self.params, showTop=True)
        mainlayout.addWidget(self.tree_params)
        
        

# Path: hearinglosssimulator/gui/myqt.py
# QT = ModuleProxy(['', 'Q', 'Qt'], [QtCore.Qt, QtCore, QtGui, QtWidgets])
# 
# Path: hearinglosssimulator/gui/gpuselection.py
# class GpuDeviceSelection(QT.QWidget):
#     def __init__(self, parent = None):
#         QT.QWidget.__init__(self, parent)
#         mainlayout  =QT.QVBoxLayout()
#         self.setLayout(mainlayout)
# 
#         mainlayout.addWidget(QT.QLabel(u'OpenCL Platform'))
#         self.combo_platform = QT.QComboBox()
#         mainlayout.addWidget(self.combo_platform)
#         
#         mainlayout.addWidget(QT.QLabel(u'OpenCL Device'))
#         self.combo_dev = QT.QComboBox()
#         mainlayout.addWidget(self.combo_dev)
#         
#         mainlayout.addStretch()
#         
#         self.resfresh_platform_list()
#         self.combo_platform.currentIndexChanged.connect(self.resfresh_device_list)
#         
#         if len(pyopencl.get_platforms())>0:
#             self.resfresh_device_list(0)
#     
#     def set_configuration(self, platform_index = 0, device_index = 0):
#         self.combo_platform.currentIndexChanged.disconnect(self.resfresh_device_list)
#         try: 
#             self.combo_platform.setCurrentIndex(platform_index)
#         except: 
#             pass
#         try:
#             self.resfresh_device_list(platform_index)
#         except:
#             pass
#         try:
#             self.combo_dev.setCurrentIndex(device_index)
#         except: 
#             pass
#         self.combo_platform.currentIndexChanged.connect(self.resfresh_device_list)
#     
#     def get_configuration(self):
#         config = {'platform_index': int(self.combo_platform.currentIndex()),
#                         'device_index':int(self.combo_dev.currentIndex()),
#                         }
#         return config
#     
#     def resfresh_platform_list(self):
#         self.combo_platform.clear()
#         for i, platform in enumerate(pyopencl.get_platforms()):
#             self.combo_platform.addItem(u'{}: {}'.format(i, platform.name))
#         
#     def resfresh_device_list(self, platform_index):
#         self.combo_dev.clear()
#         platform = pyopencl.get_platforms()[platform_index]
#         
#         for i, dev in enumerate(platform.get_devices()):
#             self.combo_dev.addItem(u'{}: {}'.format(i, dev.name))


# Path: hearinglosssimulator/gui/window_debug_gpu.py
import hearinglosssimulator as hls
import pyqtgraph as pg
import numpy as np
    import pyqtgraph as pg
from hearinglosssimulator.gui.myqt import QT
from hearinglosssimulator.gui.gpuselection import GpuDeviceSelection

_params = [
    {'name': 'chunksize', 'type': 'list', 'values': [256, 1024] },
    {'name': 'sample_rate', 'type': 'float', 'value':44100., 'suffix': 'Hz', 'siPrefix': True},
    {'name': 'nloop', 'type': 'int', 'value': 100 },
    {'name': 'nb_channel', 'type': 'int', 'value': 2 },
]



class WindowDebugGPU(QT.QWidget):
    def __init__(self,parent = None):
        QT.QWidget.__init__(self, parent)
        
        self.resize(600,600)
        
        mainlayout  =QT.QVBoxLayout()
        self.setLayout(mainlayout)
        
        self.gpuDeviceSelection = GpuDeviceSelection()
        mainlayout.addWidget(self.gpuDeviceSelection)


        self.params = pg.parametertree.Parameter.create(name='params', type='group', children=_params)
        
        self.tree_params = pg.parametertree.ParameterTree(parent  = self)
        self.tree_params.header().hide()
        self.tree_params.setParameters(self.params, showTop=True)
        mainlayout.addWidget(self.tree_params)
        
        

        but = QT.QPushButton('run benchmark')