class scatterPlotWidgetNodeCtrlWidget(NodeCtrlWidget):
    def __init__(self, **kwargs):
        super(scatterPlotWidgetNodeCtrlWidget,
              self).__init__(update_on_statechange=False, **kwargs)
        self._spw = ScatterPlotWidget(self)
        self.setFields()

    def initUserSignalConnections(self):
        self.param('Plot').sigActivated.connect(self.on_plot_clicked)

    def spw(self):
        return self._spw

    @QtCore.pyqtSlot()  #default signal
    def on_plot_clicked(self):
        if self._spw.isHidden():
            self._spw.show()
        self._spw.activateWindow()

    @QtCore.pyqtSlot(object)  #default signal
    def on_param_valueChanged(self, sender):
        self.setFields()

    def addDfColumn(self, columnName):
        columnParam = columnScatterPlotWidgetGroupParameter(name=columnName)
        self.p.addChild(columnParam)

        self.param(columnName,
                   'name').sigValueChanged.connect(self.on_param_valueChanged)
        self.param(columnName,
                   'units').sigValueChanged.connect(self.on_param_valueChanged)

    def removeDfColumn(self, columnName):
        self.param(columnName, 'name').sigValueChanged.disconnect()
        self.param(columnName, 'units').sigValueChanged.disconnect()
        self.p.removeChild(self.param(columnName))

    def restoreState(self, state):
        # here i wold have to probably add constructor of the missing params
        #self.restoreState(state)
        pass

    def evaluateState(self):
        fields = list()
        for child in self.params(recursive=False):
            if child.name() != 'Plot':
                field = (child.name(), {'units': child.child('units').value()})
                fields.append(field)
        return fields

    def setFields(self, fields=None):
        if fields is None:
            fields = self.evaluateState()
        self._spw.setFields(fields)
class scatterPlotWidgetNodeCtrlWidget(NodeCtrlWidget):
    
    def __init__(self, **kwargs):
        super(scatterPlotWidgetNodeCtrlWidget, self).__init__(update_on_statechange=False, **kwargs)
        self._spw = ScatterPlotWidget(self)
        self.setFields()

    def initUserSignalConnections(self):
        self.param('Plot').sigActivated.connect(self.on_plot_clicked)

    def spw(self):
        return self._spw

    @QtCore.pyqtSlot()  #default signal
    def on_plot_clicked(self):
        if self._spw.isHidden():
            self._spw.show()
        self._spw.activateWindow()

    @QtCore.pyqtSlot(object)  #default signal
    def on_param_valueChanged(self, sender):
        self.setFields()

    def addDfColumn(self, columnName):
        columnParam = columnScatterPlotWidgetGroupParameter(name=columnName)
        self.p.addChild(columnParam)
        
        self.param(columnName, 'name').sigValueChanged.connect(self.on_param_valueChanged)
        self.param(columnName, 'units').sigValueChanged.connect(self.on_param_valueChanged)

    def removeDfColumn(self, columnName):
        self.param(columnName, 'name').sigValueChanged.disconnect()
        self.param(columnName, 'units').sigValueChanged.disconnect()
        self.p.removeChild(self.param(columnName))
    
    def restoreState(self, state):
        # here i wold have to probably add constructor of the missing params
        #self.restoreState(state)
        pass

    def evaluateState(self):
        fields = list()
        for child in self.params(recursive=False):
            if child.name() != 'Plot':
                field = (child.name(), {'units': child.child('units').value()})
                fields.append(field)
        return fields

    def setFields(self, fields=None):
        if fields is None:
            fields = self.evaluateState()
        self._spw.setFields(fields)
 def __init__(self, **kwargs):
     super(scatterPlotWidgetNodeCtrlWidget, self).__init__(update_on_statechange=False, **kwargs)
     self._spw = ScatterPlotWidget(self)
     self.setFields()
 def __init__(self, **kwargs):
     super(scatterPlotWidgetNodeCtrlWidget,
           self).__init__(update_on_statechange=False, **kwargs)
     self._spw = ScatterPlotWidget(self)
     self.setFields()