1 # Copyright (C) 2016-2021 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from pyqtside.QtWidgets import QDialog, QColorDialog, QMessageBox
21 from pyqtside.QtGui import QIcon, QPixmap, QColor
22 from pyqtside.QtCore import pyqtSlot
23 from pyqtside.uic import loadUiGen
24 from .utils import completeResPath, Logger
26 class PlotSettings(QDialog):
28 QDialog.__init__(self)
29 loadUiGen(completeResPath("PlotSettings.ui"), self)
33 self.legendPositionComboBox.addItem("Bottom")
34 self.legendPositionComboBox.addItem("Right")
40 def onShowLegend(self, index):
42 self.legendPositionComboBox.setEnabled(True)
44 self.legendPositionComboBox.setEnabled(False)
47 def onChangeColor(self):
48 col = QColorDialog.getColor()
51 r, g, b = [c/255.0 for c in col.getRgb()[:3]]
54 def setSelectedCurveName(self, name):
55 self.nameCurve.setText(name)
57 Logger.Debug("show curve panel")
58 self.selectedCurvePanel.setTitle("Selected curve : " + name)
59 self.selectedCurvePanel.show()
61 Logger.Debug("hide curve panel")
62 self.selectedCurvePanel.hide()
64 def setRGB(self, r, g, b):
68 self.colorCurve.setIcon(QIcon(self.drawColorPixmap(int(r*255), int(g*255), int(b*255))))
71 return self._r, self._g, self._b
73 def drawColorPixmap(self, r, g, b):
74 pix = QPixmap( 16, 16 )
75 color = QColor(r, g, b)
80 xminText = str(self.axisXMinEdit.text())
81 xmaxText = str(self.axisXMaxEdit.text())
82 yminText = str(self.axisYMinEdit.text())
83 ymaxText = str(self.axisYMaxEdit.text())
84 if (yminText == "" or ymaxText == "") :
85 QMessageBox.critical(self, "Plot settings", "A field \"YMin\" or \"YMax\" is empty")
88 xmin = float(xminText)
90 QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMin")
92 xmax = float(xmaxText)
94 QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMax")
96 ymin = float(yminText)
98 QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMin")
100 ymax = float(ymaxText)
102 QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMax")
103 if ((xmax-xmin) == 0) :
104 QMessageBox.critical(self, "Plot settings", "XMax is is equal to XMin.")
106 if ((ymax-ymin) == 0) :
107 QMessageBox.critical(self, "Plot settings", "YMax is is equal to YMin.")
109 if ((xmax-xmin) < 0) :
110 QMessageBox.warning(self, "Plot settings", "XMax is less than XMin.")
111 if ((ymax-ymin) < 0) :
112 QMessageBox.warning(self, "Plot settings", "YMax is less than YMin.")
113 super(PlotSettings, self).accept()