1 # Copyright (C) 2016-2019 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 import QtGui, QtCore
21 from pyqtside.uic import loadUiGen
22 from utils import completeResPath
24 class PlotSettings(QtGui.QDialog):
26 QtGui.QDialog.__init__(self)
27 loadUiGen(completeResPath("PlotSettings.ui"), self)
31 self.legendPositionComboBox.addItem("Bottom")
32 self.legendPositionComboBox.addItem("Right")
38 def onShowLegend(self, index):
40 self.legendPositionComboBox.setEnabled(True)
42 self.legendPositionComboBox.setEnabled(False)
45 def onChangeColor(self):
46 col = QtGui.QColorDialog.getColor()
49 r, g, b = [c/255.0 for c in col.getRgb()[:3]]
52 def setSelectedCurveName(self, name):
54 self.selectedCurvePanel.setTitle("Selected curve : " + name)
55 self.selectedCurvePanel.show()
57 self.selectedCurvePanel.hide()
59 def setRGB(self, r, g, b):
63 self.colorCurve.setIcon(QtGui.QIcon(self.drawColorPixmap(int(r*255), int(g*255), int(b*255))))
66 return self._r, self._g, self._b
68 def drawColorPixmap(self, r, g, b):
69 pix = QtGui.QPixmap( 16, 16 )
70 color = QtGui.QColor(r, g, b)
75 xminText = str(self.axisXMinEdit.text())
76 xmaxText = str(self.axisXMaxEdit.text())
77 yminText = str(self.axisYMinEdit.text())
78 ymaxText = str(self.axisYMaxEdit.text())
79 if (yminText == "" or ymaxText == "") :
80 QtGui.QMessageBox.critical(self, "Plot settings", "A field \"YMin\" or \"YMax\" is empty")
83 xmin = float(xminText)
85 QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMin")
87 xmax = float(xmaxText)
89 QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMax")
91 ymin = float(yminText)
93 QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMin")
95 ymax = float(ymaxText)
97 QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMax")
98 if ((xmax-xmin) == 0) :
99 QtGui.QMessageBox.critical(self, "Plot settings", "XMax is is equal to XMin.")
101 if ((ymax-ymin) == 0) :
102 QtGui.QMessageBox.critical(self, "Plot settings", "YMax is is equal to YMin.")
104 if ((xmax-xmin) < 0) :
105 QtGui.QMessageBox.warning(self, "Plot settings", "XMax is less than XMin.")
106 if ((ymax-ymin) < 0) :
107 QtGui.QMessageBox.warning(self, "Plot settings", "YMax is less than YMin.")
108 super(PlotSettings, self).accept()