# Path: gsdview/mousemanager.py
# class MouseMode(QtCore.QObject):
#     """Base class for mouse mode desctiptors.
# 
#     Qt Graphics Framework mouse mode descriptors define some basic
#     property for mouse related matters:
# 
#     - cursor
#     - dragmode
#     - eventFilter
#     - name
#     - label
#     - icon
# 
#     The first three properties (not to be intended as Python programming
#     language property) are strongly characterizing of the way the mouse
#     works.
# 
#     In particular the eventFilter method is used to filter all events
#     coming from graphics scenes an graphics views.
# 
#     .. note:: in order to work properly the eventFilter should be installed
#               on both graphics scene and view and also on the scrollbars of
#               the graphics view.
#               So please always use the register method of MouseManager for
#               a proper installation of al event filters.
# 
#     """
# 
#     dragmode = QtWidgets.QGraphicsView.NoDrag
#     cursor = None
#     icon = QtGui.QIcon()
#     label = ''
#     name = ''
# 
#     def eventFilter(self, obj, event):
#         """Basic implementation of the eventFilter method.
# 
#         The dafault implementation makes some basic operation such setting
#         the mouse cursor anc dispatch the event to specific methods:
# 
#         - sceneEventFilter
#         - viewEventFilter
#         - scrollbarEventFilter
# 
#         In most of the cases derived classes only need to specialize one or
#         more of this specific methods.
# 
#         """
# 
#         if isinstance(obj, QtWidgets.QGraphicsScene):
#             return self.sceneEventFilter(obj, event)
#         elif isinstance(obj, QtWidgets.QGraphicsView):
#             if event.type() == QtCore.QEvent.Enter:
#                 obj.setDragMode(self.dragmode)
#                 if self.cursor:
#                     obj.setCursor(self.cursor)
#                 else:
#                     obj.unsetCursor()
#             return self.viewEventFilter(obj, event)
#         elif isinstance(obj, QtWidgets.QScrollBar):
#             return self.scrollbarEventFilter(obj, event)
#         else:
#             return False
# 
#     def sceneEventFilter(self, obj, event):
#         return False
# 
#     def viewEventFilter(self, obj, event):
#         return False
# 
#     def scrollbarEventFilter(self, obj, event):
#         return False


from qtpy import QtCore, QtWidgets, QtGui
from gsdview.mousemanager import MouseMode  # , RubberBandMode
    label = 'Draw Point'
    name = 'drawPoint'

    def sceneEventFilter(self, obj, event):
        if (event.type() == QtCore.QEvent.GraphicsSceneMousePress
                and event.button() == QtCore.Qt.LeftButton):
            return True

        elif (event.type() == QtCore.QEvent.GraphicsSceneMouseRelease
              and event.button() == QtCore.Qt.LeftButton):
            pen = QtGui.QPen()
            pen.setColor(QtCore.Qt.red)

            brush = QtGui.QBrush()
            brush.setColor(QtCore.Qt.red)
            brush.setStyle(QtCore.Qt.SolidPattern)

            RADIUS = 3
            point = event.scenePos()
            item = GraphicsPointItem(point.x(), point.y(), RADIUS)
            item.setPen(pen)
            item.setBrush(brush)
            item.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
            item.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
            obj.addItem(item)
            return True

        return False



# Path: gsdview/mousemanager.py
# class MouseMode(QtCore.QObject):
#     """Base class for mouse mode desctiptors.
# 
#     Qt Graphics Framework mouse mode descriptors define some basic
#     property for mouse related matters:
# 
#     - cursor
#     - dragmode
#     - eventFilter
#     - name
#     - label
#     - icon
# 
#     The first three properties (not to be intended as Python programming
#     language property) are strongly characterizing of the way the mouse
#     works.
# 
#     In particular the eventFilter method is used to filter all events
#     coming from graphics scenes an graphics views.
# 
#     .. note:: in order to work properly the eventFilter should be installed
#               on both graphics scene and view and also on the scrollbars of
#               the graphics view.
#               So please always use the register method of MouseManager for
#               a proper installation of al event filters.
# 
#     """
# 
#     dragmode = QtWidgets.QGraphicsView.NoDrag
#     cursor = None
#     icon = QtGui.QIcon()
#     label = ''
#     name = ''
# 
#     def eventFilter(self, obj, event):
#         """Basic implementation of the eventFilter method.
# 
#         The dafault implementation makes some basic operation such setting
#         the mouse cursor anc dispatch the event to specific methods:
# 
#         - sceneEventFilter
#         - viewEventFilter
#         - scrollbarEventFilter
# 
#         In most of the cases derived classes only need to specialize one or
#         more of this specific methods.
# 
#         """
# 
#         if isinstance(obj, QtWidgets.QGraphicsScene):
#             return self.sceneEventFilter(obj, event)
#         elif isinstance(obj, QtWidgets.QGraphicsView):
#             if event.type() == QtCore.QEvent.Enter:
#                 obj.setDragMode(self.dragmode)
#                 if self.cursor:
#                     obj.setCursor(self.cursor)
#                 else:
#                     obj.unsetCursor()
#             return self.viewEventFilter(obj, event)
#         elif isinstance(obj, QtWidgets.QScrollBar):
#             return self.scrollbarEventFilter(obj, event)
#         else:
#             return False
# 
#     def sceneEventFilter(self, obj, event):
#         return False
# 
#     def viewEventFilter(self, obj, event):
#         return False
# 
#     def scrollbarEventFilter(self, obj, event):
#         return False


# Path: gsdview/qtdraw.py
from qtpy import QtCore, QtWidgets, QtGui
from gsdview.mousemanager import MouseMode  # , RubberBandMode

    label = 'Draw Point'
    name = 'drawPoint'

    def sceneEventFilter(self, obj, event):
        if (event.type() == QtCore.QEvent.GraphicsSceneMousePress
                and event.button() == QtCore.Qt.LeftButton):
            return True

        elif (event.type() == QtCore.QEvent.GraphicsSceneMouseRelease
              and event.button() == QtCore.Qt.LeftButton):
            pen = QtGui.QPen()
            pen.setColor(QtCore.Qt.red)

            brush = QtGui.QBrush()
            brush.setColor(QtCore.Qt.red)
            brush.setStyle(QtCore.Qt.SolidPattern)

            RADIUS = 3
            point = event.scenePos()
            item = GraphicsPointItem(point.x(), point.y(), RADIUS)
            item.setPen(pen)
            item.setBrush(brush)
            item.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
            item.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
            obj.addItem(item)
            return True

        return False



class DrawLineMode(MouseMode):