def retranslateUi(self): """ Set user interface locale strings. """ self.form.setWindowTitle(Translator.translate("Set labels")) self.form.findChild(QtGui.QLabel, "axesLabel").setText(Translator.translate("Active axes")) self.form.findChild(QtGui.QLabel, "titleLabel").setText(Translator.translate("Title")) self.form.findChild(QtGui.QLabel, "xLabel").setText(Translator.translate("X label")) self.form.findChild(QtGui.QLabel, "yLabel").setText(Translator.translate("Y label"))
def retranslateUi(self): """ Set user interface locale strings. """ self.form.setWindowTitle(Translator.translate("Set positions and sizes")) self.form.isLabel.setText(Translator.translate("No label")) self.form.remove.setText(Translator.translate("Remove serie")) self.form.findChild(QtGui.QLabel, "styleLabel").setText(Translator.translate("Line style")) self.form.findChild(QtGui.QLabel, "markerLabel").setText(Translator.translate("Marker"))
def Activated(self): import Plot from plotUtils import Translator plt = Plot.getPlot() if not plt: msg = Translator.translate("Legend must be activated on top of a plot document.") FreeCAD.Console.PrintError(msg+"\n") return flag = plt.isLegend() Plot.legend(not flag)
def accept(self): plt = Plot.getPlot() if not plt: msg = Translator.translate("Plot document must be selected in order to save it.") App.Console.PrintError(msg+"\n") return False path = unicode(self.form.path.text()) size = (self.form.sizeX.value(), self.form.sizeY.value()) dpi = self.form.dpi.value() Plot.save(path, size, dpi) return True
def onRemove(self): """ Executed when axes must be deleted. """ plt = Plot.getPlot() if not plt: self.updateUI() return # Don't remove first axes if not self.form.axId.value(): msg = Translator.translate("Axes 0 can't be deleted") App.Console.PrintError(msg+"\n") return # Remove axes ax = plt.axes ax.set_axis_off() plt.axesList.pop(self.form.axId.value()) # Ensure that active axes is correct index = min(self.form.axId.value(), len(plt.axesList)-1) self.form.axId.setValue(index) plt.update()
# Plot module from plotUtils import Paths, Translator # PyQt4 from PyQt4 import QtCore, QtGui # Matplot lib try: import matplotlib import matplotlib.pyplot as plt from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.figure import Figure except ImportError: msg = Translator.translate("matplotlib not installed, so Plot module is disabled.\n") FreeCAD.Console.PrintError(msg) raise ImportError("matplotlib not installed") def getMainWindow(): """ getMainWindow(): Gets FreeCAD main window. """ toplevel = QtGui.qApp.topLevelWidgets() for i in toplevel: if i.metaObject().className() == "Gui::MainWindow": return i return None def getMdiArea(): """ getMdiArea(): Gets FreeCAD MdiArea. """ mw = getMainWindow() if not mw:
def retranslateUi(self): """ Set user interface locale strings. """ self.form.setWindowTitle(Translator.translate("Configure axes")) self.form.findChild(QtGui.QLabel, "axesLabel").setText(Translator.translate("Active axes")) self.form.all.setText(Translator.translate("Apply to all axes")) self.form.findChild(QtGui.QLabel, "dimLabel").setText(Translator.translate("Dimensions")) self.form.findChild(QtGui.QLabel, "xPosLabel").setText(Translator.translate("X axis position")) self.form.findChild(QtGui.QLabel, "yPosLabel").setText(Translator.translate("Y axis position")) self.form.findChild(QtGui.QLabel, "scalesLabel").setText(Translator.translate("Scales")) self.form.xAuto.setText(Translator.translate("X auto")) self.form.yAuto.setText(Translator.translate("Y auto")) self.form.findChild(QtGui.QCheckBox, "allAxes").setText(Translator.translate("Apply to all axes")) self.form.findChild(QtGui.QLabel, "dimLabel").setText(Translator.translate("Dimensions")) self.form.findChild(QtGui.QLabel, "xPosLabel").setText(Translator.translate("X axis position")) self.form.findChild(QtGui.QLabel, "yPosLabel").setText(Translator.translate("Y axis position"))
def retranslateUi(self): """ Set user interface locale strings. """ self.form.setWindowTitle(Translator.translate("Set positions and sizes")) self.form.findChild(QtGui.QLabel, "posLabel").setText(Translator.translate("Position")) self.form.findChild(QtGui.QLabel, "sizeLabel").setText(Translator.translate("Size"))
def retranslateUi(self): """ Set user interface locale strings. """ self.form.setWindowTitle(Translator.translate("Save figure")) self.form.findChild(QtGui.QLabel, "sizeLabel").setText(Translator.translate("Inches")) self.form.findChild(QtGui.QLabel, "dpiLabel").setText(Translator.translate("Dots per Inch"))
#* * #*************************************************************************** class PlotWorkbench ( Workbench ): """ @brief Workbench of Plot module. Here toolbars & icons are append. """ from plotUtils import Paths, Translator import PlotGui Icon = Paths.iconsPath() + "/Icon.svg" MenuText = str(Translator.translate("Plot")) ToolTip = str(Translator.translate("Plot")) def Initialize(self): from plotUtils import Translator # ToolBar list = ["Plot_SaveFig", "Plot_Axes", "Plot_Series", "Plot_Grid", "Plot_Legend", "Plot_Labels", "Plot_Positions"] self.appendToolbar("Plot",list) # Menu list = ["Plot_SaveFig", "Plot_Axes", "Plot_Series", "Plot_Grid", "Plot_Legend", "Plot_Labels", "Plot_Positions"] self.appendMenu("Plot",list) try: import matplotlib Gui.addWorkbench(PlotWorkbench()) except ImportError: from plotUtils import Translator msg = Translator.translate("matplotlib not found, Plot module will be disabled.\n") FreeCAD.Console.PrintMessage(msg)
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Legend.svg" MenuText = str(Translator.translate('Show/Hide legend')) ToolTip = str(Translator.translate('Show/Hide legend on selected plot')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Series.svg" MenuText = str(Translator.translate('Configure series')) ToolTip = str(Translator.translate('Configure series drawing style and label.')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Axes.svg" MenuText = str(Translator.translate('Configure axes')) ToolTip = str(Translator.translate('Configure axes parameters.')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Save.svg" MenuText = str(Translator.translate('Save plot')) ToolTip = str(Translator.translate('Save plot as image file.')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Positions.svg" MenuText = str(Translator.translate('Set positions and sizes')) ToolTip = str(Translator.translate('Set labels and legend positions and sizes.')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from plotUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Labels.svg" MenuText = str(Translator.translate('Set labels')) ToolTip = str(Translator.translate('Set title and axes labels')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}