# Path: PyContact/gui/ErrorBox.py
# class ErrorBox(QMessageBox):
#     """Creates an Error dialog which displays the corresponding error message 'msg'."""
#     def __init__(self, msg):
#         super(ErrorBox, self).__init__()
#         self.msg = msg
#         self.setIcon(QMessageBox.Warning)
#         self.setText(self.msg)
#         self.setWindowTitle("Error")
#         self.setStandardButtons(QMessageBox.Ok)
# 
# Path: PyContact/gui/ErrorMessages.py
# class ErrorMessages():
#     """Error message shortcuts for the ErrorBox dialog."""
# 
#     NOEXPDATA = "No data to export."
# 
#     NODATA_PROMPTLOAD = "No data loaded. Click on \"Files -> Import Trajectory Data\" and load your MD trajectory."
# 
#     NOSCORES_PROMPTANALYSIS = "No data loaded. Click on \"Files -> Import Trajectory Data\" " \
#                               "and load your MD trajectory."
# 
#     CHOOSEFILE = "Please choose a topology and trajectory file!"
# 
#     RESID_REQUIRED = "Please analyze the trajectory with the resid box checked for both atom selections!"
# 
#     NOCONTACTS = "No data loaded or no filtered contacts available."
# 
#     FILE_NOT_FOUND = "Attempt to load trajectory failed. File does not exist."


import sip
import os
from PyQt5.QtWidgets import QTabWidget, QWidget, QGridLayout, QLabel, QPushButton, QComboBox, QLineEdit, QCheckBox, \
    QFileDialog
from PyQt5.QtCore import pyqtSignal
from .Plotters import *
from .ErrorBox import ErrorBox
from .ErrorMessages import ErrorMessages
            self.tab3.mapPlot.saveFigure(path, self.tab3.formatBox.currentText())

    def pushPlot(self):
        """Triggers the histogram plotter."""
        self.plotHist()

    def pushMapPlot(self):
        """Triggers the contact map plotter."""
        self.plotMap()

    def plotHist(self):
        """Plots the histogram."""
        sip.delete(self.tab2.histPlot)
        self.tab2.histPlot = HistPlotter(None, width=8, height=5, dpi=60)
        self.grid1.addWidget(self.tab2.histPlot, 3, 0, 1, 4)
        if self.tab2.histTypeBox.currentText() == "General Histogram":
            self.tab2.histPlot.plotGeneralHist(self.contacts, self.tab2.attributeBox.currentText(), self.threshold,
                                               self.nsPerFrame)
        elif self.tab2.histTypeBox.currentText() == "Bin per Contact":
            self.tab2.histPlot.plotContactHist(self.contacts, self.tab2.attributeBox.currentText(), self.threshold,
                                               self.nsPerFrame, int(self.tab2.xTicksFontSizeField.text()))

        self.tab2.histPlot.update()

    def plotMap(self):
        """Plots the contact map."""
        sip.delete(self.tab3.mapPlot)
        self.tab3.mapPlot = MapPlotter(None, width=8, height=5, dpi=60)
        self.grid2.addWidget(self.tab3.mapPlot, 3, 0, 1, 4)
        if self.map1 is None or self.map2 is None or self.contacts is None or len(self.contacts) == 0:

# Path: PyContact/gui/ErrorBox.py
# class ErrorBox(QMessageBox):
#     """Creates an Error dialog which displays the corresponding error message 'msg'."""
#     def __init__(self, msg):
#         super(ErrorBox, self).__init__()
#         self.msg = msg
#         self.setIcon(QMessageBox.Warning)
#         self.setText(self.msg)
#         self.setWindowTitle("Error")
#         self.setStandardButtons(QMessageBox.Ok)
# 
# Path: PyContact/gui/ErrorMessages.py
# class ErrorMessages():
#     """Error message shortcuts for the ErrorBox dialog."""
# 
#     NOEXPDATA = "No data to export."
# 
#     NODATA_PROMPTLOAD = "No data loaded. Click on \"Files -> Import Trajectory Data\" and load your MD trajectory."
# 
#     NOSCORES_PROMPTANALYSIS = "No data loaded. Click on \"Files -> Import Trajectory Data\" " \
#                               "and load your MD trajectory."
# 
#     CHOOSEFILE = "Please choose a topology and trajectory file!"
# 
#     RESID_REQUIRED = "Please analyze the trajectory with the resid box checked for both atom selections!"
# 
#     NOCONTACTS = "No data loaded or no filtered contacts available."
# 
#     FILE_NOT_FOUND = "Attempt to load trajectory failed. File does not exist."


# Path: PyContact/gui/ExportTabWidget.py
import sip
import os
from PyQt5.QtWidgets import QTabWidget, QWidget, QGridLayout, QLabel, QPushButton, QComboBox, QLineEdit, QCheckBox, \
    QFileDialog
from PyQt5.QtCore import pyqtSignal
from .Plotters import *
from .ErrorBox import ErrorBox
from .ErrorMessages import ErrorMessages

            self.tab3.mapPlot.saveFigure(path, self.tab3.formatBox.currentText())

    def pushPlot(self):
        """Triggers the histogram plotter."""
        self.plotHist()

    def pushMapPlot(self):
        """Triggers the contact map plotter."""
        self.plotMap()

    def plotHist(self):
        """Plots the histogram."""
        sip.delete(self.tab2.histPlot)
        self.tab2.histPlot = HistPlotter(None, width=8, height=5, dpi=60)
        self.grid1.addWidget(self.tab2.histPlot, 3, 0, 1, 4)
        if self.tab2.histTypeBox.currentText() == "General Histogram":
            self.tab2.histPlot.plotGeneralHist(self.contacts, self.tab2.attributeBox.currentText(), self.threshold,
                                               self.nsPerFrame)
        elif self.tab2.histTypeBox.currentText() == "Bin per Contact":
            self.tab2.histPlot.plotContactHist(self.contacts, self.tab2.attributeBox.currentText(), self.threshold,
                                               self.nsPerFrame, int(self.tab2.xTicksFontSizeField.text()))

        self.tab2.histPlot.update()

    def plotMap(self):
        """Plots the contact map."""
        sip.delete(self.tab3.mapPlot)
        self.tab3.mapPlot = MapPlotter(None, width=8, height=5, dpi=60)
        self.grid2.addWidget(self.tab3.mapPlot, 3, 0, 1, 4)
        if self.map1 is None or self.map2 is None or self.contacts is None or len(self.contacts) == 0:

            box = ErrorBox(ErrorMessages.RESID_REQUIRED)