'Process changes to the state of the ROI.
If there are any changes, then the positions of handles are updated accordingly
and sigRegionChanged is emitted. If finish is True, then
sigRegionChangeFinished will also be emitted.'

def stateChanged(self, finish=True):

    changed = False
    if (self.lastState is None):
        changed = True
    else:
        state = self.getState()
        for k in list(state.keys()):
            if (state[k] != self.lastState[k]):
                changed = True
    self.prepareGeometryChange()
    if changed:
        for h in self.handles:
            if (h['item'] in self.childItems()):
                p = h['pos']
                h['item'].setPos((h['pos'] * self.state['size']))
        self.update()
        self.sigRegionChanged.emit(self)
    elif self.freeHandleMoved:
        self.sigRegionChanged.emit(self)
    self.freeHandleMoved = False
    self.lastState = self.getState()
    if finish:
        self.stateChangeFinished()
        self.informViewBoundsChanged()
