Beispiel #1
0
    def _save_svg(self):
        file_name, _ = QFileDialog.getSaveFileName(self._widget, self.tr('Save as SVG'), 'rosgraph.svg', self.tr('Scalable Vector Graphic (*.svg)'))
        if file_name is None or file_name == '':
            return

        generator = QSvgGenerator()
        generator.setFileName(file_name)
        generator.setSize((self._scene.sceneRect().size() * 2.0).toSize())

        painter = QPainter(generator)
        painter.setRenderHint(QPainter.Antialiasing)
        self._scene.render(painter)
        painter.end()
    def _save_svg(self):
        file_name, _ = QFileDialog.getSaveFileName(self._widget, self.tr('Save as SVG'), 'rospackgraph.svg', self.tr('Scalable Vector Graphic (*.svg)'))
        if file_name is None or file_name == '':
            return

        generator = QSvgGenerator()
        generator.setFileName(file_name)
        generator.setSize((self._scene.sceneRect().size() * 2.0).toSize())

        painter = QPainter(generator)
        painter.setRenderHint(QPainter.Antialiasing)
        self._scene.render(painter)
        painter.end()
Beispiel #3
0
    def save_graph(self):
        """Save the current dot graph as an image."""
        if self.graph is None:
            return

        ret = QFileDialog.getSaveFileName(self._widget, "Save graph as",
                                          "untitled.png", self.image_filter,
                                          "*.png")
        if ret[0]:
            _, extension = os.path.splitext(ret[0])
            if extension == ".svg":
                gen = QSvgGenerator()
                gen.setFileName(ret[0])
                gen.setSize(self._widget.xdot_widget.size())
                gen.setViewBox(self._widget.xdot_widget.rect())
                self._widget.xdot_widget.grab().save(ret[0])
                self._widget.xdot_widget.render(gen)
            else:
                self._widget.xdot_widget.grab().save(ret[0])