X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=tools%2FCurvePlot%2Fsrc%2Fpython%2Fui%2FPlotSettings.py;h=530ea469c013345afc2983d112ea43210134c051;hb=52070c15a44138cd16c0545bec9e52c11993f544;hp=d264618953c992532a1d0eb768a50fee9c4f8f94;hpb=41279a9323521bc2e2d9f83921bb6d5ca7836d99;p=modules%2Fgui.git diff --git a/tools/CurvePlot/src/python/ui/PlotSettings.py b/tools/CurvePlot/src/python/ui/PlotSettings.py index d26461895..530ea469c 100644 --- a/tools/CurvePlot/src/python/ui/PlotSettings.py +++ b/tools/CurvePlot/src/python/ui/PlotSettings.py @@ -1,10 +1,31 @@ -from pyqtside import QtGui, QtCore +# Copyright (C) 2016-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from pyqtside.QtWidgets import QDialog, QColorDialog, QMessageBox +from pyqtside.QtGui import QIcon, QPixmap, QColor +from pyqtside.QtCore import pyqtSlot from pyqtside.uic import loadUiGen -from utils import completeResPath +from .utils import completeResPath, Logger -class PlotSettings(QtGui.QDialog): +class PlotSettings(QDialog): def __init__(self): - QtGui.QDialog.__init__(self) + QDialog.__init__(self) loadUiGen(completeResPath("PlotSettings.ui"), self) self.initialize() @@ -14,41 +35,44 @@ class PlotSettings(QtGui.QDialog): self._r = 0 self._g = 0 self._b = 1 - - @QtCore.Slot(int) + + @pyqtSlot(int) def onShowLegend(self, index): if index > 0 : self.legendPositionComboBox.setEnabled(True) else : self.legendPositionComboBox.setEnabled(False) - - @QtCore.Slot() + + @pyqtSlot() def onChangeColor(self): - col = QtGui.QColorDialog.getColor() + col = QColorDialog.getColor() if col.isValid(): r, g, b = [c/255.0 for c in col.getRgb()[:3]] self.setRGB(r, g, b) - + def setSelectedCurveName(self, name): + self.nameCurve.setText(name) if name : + Logger.Debug("show curve panel") self.selectedCurvePanel.setTitle("Selected curve : " + name) self.selectedCurvePanel.show() else : + Logger.Debug("hide curve panel") self.selectedCurvePanel.hide() - + def setRGB(self, r, g, b): self._r = r self._g = g self._b = b - self.colorCurve.setIcon(QtGui.QIcon(self.drawColorPixmap(int(r*255), int(g*255), int(b*255)))) - + self.colorCurve.setIcon(QIcon(self.drawColorPixmap(int(r*255), int(g*255), int(b*255)))) + def getRGB(self): return self._r, self._g, self._b - + def drawColorPixmap(self, r, g, b): - pix = QtGui.QPixmap( 16, 16 ) - color = QtGui.QColor(r, g, b) + pix = QPixmap( 16, 16 ) + color = QColor(r, g, b) pix.fill(color) return pix @@ -58,32 +82,32 @@ class PlotSettings(QtGui.QDialog): yminText = str(self.axisYMinEdit.text()) ymaxText = str(self.axisYMaxEdit.text()) if (yminText == "" or ymaxText == "") : - QtGui.QMessageBox.critical(self, "Plot settings", "A field \"YMin\" or \"YMax\" is empty") + QMessageBox.critical(self, "Plot settings", "A field \"YMin\" or \"YMax\" is empty") else : try: xmin = float(xminText) except ValueError: - QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMin") + QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMin") try: xmax = float(xmaxText) except ValueError: - QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMax") + QMessageBox.critical(self, "Plot settings", "It is not possible to convert XMax") try: ymin = float(yminText) except ValueError: - QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMin") + QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMin") try: ymax = float(ymaxText) except ValueError: - QtGui.QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMax") + QMessageBox.critical(self, "Plot settings", "It is not possible to convert YMax") if ((xmax-xmin) == 0) : - QtGui.QMessageBox.critical(self, "Plot settings", "XMax is is equal to XMin.") + QMessageBox.critical(self, "Plot settings", "XMax is is equal to XMin.") return if ((ymax-ymin) == 0) : - QtGui.QMessageBox.critical(self, "Plot settings", "YMax is is equal to YMin.") + QMessageBox.critical(self, "Plot settings", "YMax is is equal to YMin.") return if ((xmax-xmin) < 0) : - QtGui.QMessageBox.warning(self, "Plot settings", "XMax is less than XMin.") + QMessageBox.warning(self, "Plot settings", "XMax is less than XMin.") if ((ymax-ymin) < 0) : - QtGui.QMessageBox.warning(self, "Plot settings", "YMax is less than YMin.") + QMessageBox.warning(self, "Plot settings", "YMax is less than YMin.") super(PlotSettings, self).accept()