def paintEvent(self, event): self._painter = QtGui.QPainter() self._painter.begin(self) self._painter.fillRect(0, 0, self.width(), self.height(), self._bgColor) os.environ["GKSconid"] = getGKSConnectionId(self, self._painter) self.draw(self._clear, self._update) gr.updatews() self._painter.end()
def printDialog(self, documentName="qtgr-untitled"): printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution) printer.setDocName(documentName) painter = QtGui.QPainter() dlg = QtGui.QPrintDialog(printer) if dlg.exec_() == QtGui.QPrintDialog.Accepted: painter.begin(printer) os.environ["GKSconid"] = getGKSConnectionId(self, painter) # upscaling to paper size and # alignment (horizontal and vertical centering) xscale = printer.pageRect().width() / float(self.width()) yscale = printer.pageRect().height() / float(self.height()) scale = min(xscale, yscale) painter.translate( printer.paperRect().x() + printer.pageRect().width() / 2, printer.paperRect().y() + printer.pageRect().height() / 2) painter.scale(scale, scale) painter.translate(-self.width() / 2, -self.height() / 2) self.draw(True) gr.updatews() painter.end()
def main(*args): app = QtGui.QApplication(*args) grw = InteractiveGRWidget() viewport = [0.1, 0.88, 0.1, 0.88] xd = [3, 3, 10, 18, 18, 10, 10, 5, 1, 15, 20, 5, 15, 10, 7, 13, 16] yd = [3, 18, 18, 3, 18, 10, 1, 5, 10, 5, 10, 15, 15, 15, 20, 20, 8] zd = [25, 25, 25, 25, 25, -5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 25] axes = ContourAxes(viewport) axes.addCurves(PlotContour(xd, yd, zd, nx=40, ny=40)) axes.setGrid(False) plot = Plot(viewport).addAxes(axes) plot.title = "Plot contour lines using QtGR" grw.addPlot(plot) grw.resize(QtCore.QSize(500, 500)) grw.show() win = axes.getWindow() grw.update() sys.exit(app.exec_())
def main(*args): app = QtGui.QApplication(*args) grw = InteractiveGRWidget() viewport = [0.1, 0.88, 0.1, 0.88] z = readfile( os.path.join(os.path.dirname(os.path.realpath(__file__)), "fecr.dat")) zd = np.asarray(z) xd = yd = np.arange(1, 201) axes = ContourAxes(viewport) axes.addCurves(PlotSurface(xd, yd, zd, option=gr.OPTION_CELL_ARRAY)) axes.addCurves(PlotContour(xd, yd, zd)) axes.setGrid(False) plot = Plot(viewport).addAxes(axes) plot.title = "Plot surface and contour lines using QtGR" grw.addPlot(plot) grw.resize(QtCore.QSize(500, 500)) grw.show() win = axes.getWindow() grw.update() sys.exit(app.exec_())
def main(*args): app = QtGui.QApplication(sys.argv) mainWin = MainWindow() mainWin.resize(QtCore.QSize(500, 500)) mainWin.show() sys.exit(app.exec_())
# delta percent dpercent = event.getSteps() * .1 self._zoom(dpercent, event.getNDC()) def pickMove(self, event): self._pickEvent = event self.update() if __name__ == "__main__": import sys from gr import pygr logging.basicConfig(level=logging.CRITICAL) for name in [__name__, pygr.base.__name__, pygr.__name__]: logging.getLogger(name).setLevel(logging.DEBUG) app = QtGui.QApplication(sys.argv) grw = InteractiveGRWidget() grw.resize(QtCore.QSize(500, 500)) viewport = [0.1, 0.45, 0.1, 0.88] vp2 = [.6, .95, .1, .88] x = [-3.3 + t * .1 for t in range(66)] y = [t**5 - 13 * t**3 + 36 * t for t in x] n = 100 pi2_n = 2. * math.pi / n x2 = [i * pi2_n for i in range(0, n + 1)] y2 = map(lambda xi: math.sin(xi), x2) plot = Plot(viewport).addAxes( PlotAxes(viewport).plot(x, y),