# Path: src/plugins/util/mygraphicsview.py
# class MyGraphicsView(pg.GraphicsView):
#   def __init__(self, project, parent=None, image_view_on=None):
#     super(MyGraphicsView, self).__init__(parent)
#     self.image_view_on = image_view_on
#     self.unit_per_pixel = 'units'
# 
#     self.project = project
#     self.shape = 0, 0
# 
#     self.setup_ui()
# 
#     self.update()
# 
#   def setup_ui(self):
#     self.setMinimumSize(200, 200)
#     l = QGraphicsGridLayout()
# 
#     self.centralWidget.setLayout(l)
#     l.setHorizontalSpacing(0)
#     l.setVerticalSpacing(0)
#     self.vb = MultiRoiViewBox(lockAspect=True, enableMenu=True)
# 
#     # if self.image_view_on:
#     #   self.vb = pg.ImageView()
#     # else:
#     #   self.vb = MultiRoiViewBox(lockAspect=True, enableMenu=True)
#     # todo: hovering for pyqtgraph
#     #self.vb.hovering.connect(self.vbc_hovering)
#     self.vb.enableAutoRange()
# 
#     # self.the_label = pg.LabelItem()
#     # l.addItem(self.the_label, 1, 0)
# 
#     l.addItem(self.vb, 0, 1)
#     self.xScale = pg.AxisItem(orientation='bottom', linkView=self.vb)
#     self.xScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>X</span>"
#        "<i>Width</i>", units=self.unit_per_pixel)
#     l.addItem(self.xScale, 1, 1)
# 
#     self.yScale = pg.AxisItem(orientation='left', linkView=self.vb)
#     self.yScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>Y</span>"
#       "<i>Height</i>", units=self.unit_per_pixel)
#     l.addItem(self.yScale, 0, 0)
# 
#     self.centralWidget.setLayout(l)
#  
#   def show(self, frame, min=None, max=None):
#     self.shape = frame.shape
#     self.vb.showImage(frame, min, max)
#     self.update()
# 
#   def _update_rect(self):
#     self.xScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>X</span>"
#        "<i>Width</i>", units=self.unit_per_pixel)
#     self.yScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>Y</span>"
#       "<i>Height</i>", units=self.unit_per_pixel)
#     w, h = self.shape[0], self.shape[1]
#     if not (not self.project):
#       ox, oy = self.project['origin']
#       unit_per_pixel = self.project['unit_per_pixel']
# 
#       x = -ox *unit_per_pixel
#       y = -oy * unit_per_pixel
#       w = w * unit_per_pixel
#       h = h * unit_per_pixel
# 
#       self.vb.update_rect(x, y, w, h)
# 
#   def update(self):
#     self._update_rect()
# 
#   def vbc_hovering(self, x, y):
#       #todo: hovering for pyqtgraph
#     x_origin, y_origin = self.project['origin']
#     unit_per_pixel = self.project['unit_per_pixel']
#     x = round(x * unit_per_pixel, 2)
#     y = round(y * unit_per_pixel, 2)
# 
#     try:
#         self.the_label.setText('X:{}, '.format(x) + 'Y:{}'.format(y))
#     except:
#         self.the_label.setText('X:-, Y:-')
# 
# Path: src/plugins/util/project_functions.py
# def save_project(video_path, project, frames, manip, file_type):
#             def callback_del(x):
#         def callback_save(x):
# def change_origin(project, video_path, origin):
# def refresh_list(project, ui_list, indices, types=None, last_manips_to_display=None):
# def refresh_video_list_via_combo_box(widget, list_display_type, trigger_item=None):
# def get_project_file_from_key_item(project, key, item):
# def add_combo_dropdown(widget, items):
# def flatten(foo):
# def get_list_of_project_manips(project):
# def selected_video_changed_multi(widget, selected, deselected):
# def video_triggered(widget, index, scaling=False):
# def update_plugin_params(widget, key, val):
# def save_dock_window_to_project(widget, window_type, pickle_path):
# def save_dock_windows(widget, window_type):
# def load_dock_windows(widget, window_type, DockWindow):
# class WrongNumberOfArguments(TypeError):
# 
# Path: src/plugins/util/file_io.py
# class UnknownFileFormatError(Exception):
# def load_npy(filename, progress_callback=None, segment=None):
# def get_name_after_no_overwrite(name_before, manip, project):
# def save_file(path, data):
# def load_file(filename, progress_callback=None, segment=None):
# def load_reference_frame_npy(filename, offset):
# def load_reference_frame(filename, offset=0):


import ast
import os
import sys
import traceback
import numpy as np
import qtutil
import imreg_dft as ird
from os import listdir
from os.path import isfile, join
from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from project import Project
from .util.mygraphicsview import MyGraphicsView
from .util import project_functions as pfs
from .util import file_io
#!/usr/bin/env python3



sys.path.append('..')


class NotConvertedError(Exception):
  pass

class FileAlreadyInProjectError(Exception):
  def __init__(self, filename):
    self.filename = filename

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

    if not project:
      return

    self.project = project

    # define ui components and global data

# Path: src/plugins/util/mygraphicsview.py
# class MyGraphicsView(pg.GraphicsView):
#   def __init__(self, project, parent=None, image_view_on=None):
#     super(MyGraphicsView, self).__init__(parent)
#     self.image_view_on = image_view_on
#     self.unit_per_pixel = 'units'
# 
#     self.project = project
#     self.shape = 0, 0
# 
#     self.setup_ui()
# 
#     self.update()
# 
#   def setup_ui(self):
#     self.setMinimumSize(200, 200)
#     l = QGraphicsGridLayout()
# 
#     self.centralWidget.setLayout(l)
#     l.setHorizontalSpacing(0)
#     l.setVerticalSpacing(0)
#     self.vb = MultiRoiViewBox(lockAspect=True, enableMenu=True)
# 
#     # if self.image_view_on:
#     #   self.vb = pg.ImageView()
#     # else:
#     #   self.vb = MultiRoiViewBox(lockAspect=True, enableMenu=True)
#     # todo: hovering for pyqtgraph
#     #self.vb.hovering.connect(self.vbc_hovering)
#     self.vb.enableAutoRange()
# 
#     # self.the_label = pg.LabelItem()
#     # l.addItem(self.the_label, 1, 0)
# 
#     l.addItem(self.vb, 0, 1)
#     self.xScale = pg.AxisItem(orientation='bottom', linkView=self.vb)
#     self.xScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>X</span>"
#        "<i>Width</i>", units=self.unit_per_pixel)
#     l.addItem(self.xScale, 1, 1)
# 
#     self.yScale = pg.AxisItem(orientation='left', linkView=self.vb)
#     self.yScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>Y</span>"
#       "<i>Height</i>", units=self.unit_per_pixel)
#     l.addItem(self.yScale, 0, 0)
# 
#     self.centralWidget.setLayout(l)
#  
#   def show(self, frame, min=None, max=None):
#     self.shape = frame.shape
#     self.vb.showImage(frame, min, max)
#     self.update()
# 
#   def _update_rect(self):
#     self.xScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>X</span>"
#        "<i>Width</i>", units=self.unit_per_pixel)
#     self.yScale.setLabel(text="<span style='color: #ff0000; font-weight: bold'>Y</span>"
#       "<i>Height</i>", units=self.unit_per_pixel)
#     w, h = self.shape[0], self.shape[1]
#     if not (not self.project):
#       ox, oy = self.project['origin']
#       unit_per_pixel = self.project['unit_per_pixel']
# 
#       x = -ox *unit_per_pixel
#       y = -oy * unit_per_pixel
#       w = w * unit_per_pixel
#       h = h * unit_per_pixel
# 
#       self.vb.update_rect(x, y, w, h)
# 
#   def update(self):
#     self._update_rect()
# 
#   def vbc_hovering(self, x, y):
#       #todo: hovering for pyqtgraph
#     x_origin, y_origin = self.project['origin']
#     unit_per_pixel = self.project['unit_per_pixel']
#     x = round(x * unit_per_pixel, 2)
#     y = round(y * unit_per_pixel, 2)
# 
#     try:
#         self.the_label.setText('X:{}, '.format(x) + 'Y:{}'.format(y))
#     except:
#         self.the_label.setText('X:-, Y:-')
# 
# Path: src/plugins/util/project_functions.py
# def save_project(video_path, project, frames, manip, file_type):
#             def callback_del(x):
#         def callback_save(x):
# def change_origin(project, video_path, origin):
# def refresh_list(project, ui_list, indices, types=None, last_manips_to_display=None):
# def refresh_video_list_via_combo_box(widget, list_display_type, trigger_item=None):
# def get_project_file_from_key_item(project, key, item):
# def add_combo_dropdown(widget, items):
# def flatten(foo):
# def get_list_of_project_manips(project):
# def selected_video_changed_multi(widget, selected, deselected):
# def video_triggered(widget, index, scaling=False):
# def update_plugin_params(widget, key, val):
# def save_dock_window_to_project(widget, window_type, pickle_path):
# def save_dock_windows(widget, window_type):
# def load_dock_windows(widget, window_type, DockWindow):
# class WrongNumberOfArguments(TypeError):
# 
# Path: src/plugins/util/file_io.py
# class UnknownFileFormatError(Exception):
# def load_npy(filename, progress_callback=None, segment=None):
# def get_name_after_no_overwrite(name_before, manip, project):
# def save_file(path, data):
# def load_file(filename, progress_callback=None, segment=None):
# def load_reference_frame_npy(filename, offset):
# def load_reference_frame(filename, offset=0):


# Path: src/plugins/shift_across_projects.py
import ast
import os
import sys
import traceback
import numpy as np
import qtutil
import imreg_dft as ird
from os import listdir
from os.path import isfile, join
from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from project import Project
from .util.mygraphicsview import MyGraphicsView
from .util import project_functions as pfs
from .util import file_io

#!/usr/bin/env python3



sys.path.append('..')


class NotConvertedError(Exception):
  pass

class FileAlreadyInProjectError(Exception):
  def __init__(self, filename):
    self.filename = filename

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

    if not project:
      return

    self.project = project

    # define ui components and global data

    self.view = MyGraphicsView(self.project)