#Author: Miguel Molero <miguel.molero@gmail.com>

import numpy as np


from PyQt5.QtCore import  *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

from PyQt5.QtCore import pyqtSignal as Signal


from vtk import vtkInteractorStyleImage, vtkInteractorStyleTrackballCamera, vtkActor, vtkImageActor
from vtk import vtkAreaPicker, vtkContourWidget, vtkOrientedGlyphContourRepresentation, vtkImplicitSelectionLoop
from vtk import vtkCleanPolyData, vtkImplicitBoolean, vtkDataSetSurfaceFilter, vtkExtractGeometry, vtkExtractPolyDataGeometry

from ..graphics.QVTKWidget import QVTKWidget

from ..utils.qhelpers import *
from ..ManagerLayer import ManagerLayer

from pcloudpy.core.utils.vtkhelpers import actor_from_polydata


class QVTKWidgetKeyEvents(QVTKWidget):
    def __init__(self, parent = None):
        super(QVTKWidgetKeyEvents, self).__init__(parent)

    keyEventRequested = Signal(int)

    def keyPressEvent(self, ev):
        super(QVTKWidgetKeyEvents, self).keyPressEvent(ev)
        self.keyEventRequested.emit(ev.key())


class ViewWidget(QWidget):
    def __init__(self, parent=None):
        super(ViewWidget,self).__init__(parent)

        self.setAttribute(Qt.WA_DeleteOnClose)

        self._is_extract = False
        self._contour_widget = None