source: orange/Orange/OrangeCanvas/canvas/scene.py @ 11182:70ae8e72389b

Revision 11182:70ae8e72389b, 24.5 KB checked in by Ales Erjavec <ales.erjavec@…>, 17 months ago (diff)

Showing the dynamic link state in the canvas.

Line 
1"""
2Canvas Graphics Scene
3
4"""
5
6import logging
7from operator import attrgetter
8
9from xml.sax.saxutils import escape
10
11from PyQt4.QtGui import QGraphicsScene, QPainter, QBrush, \
12                        QGraphicsItem
13
14from PyQt4.QtCore import Qt, QPointF, QRectF, QSizeF, QLineF, QBuffer
15
16from PyQt4.QtCore import pyqtSignal as Signal
17from PyQt4.QtCore import PYQT_VERSION_STR
18
19
20from .. import scheme
21
22from . import items
23from .layout import AnchorLayout
24from .items.utils import toGraphicsObjectIfPossible, typed_signal_mapper
25
26log = logging.getLogger(__name__)
27
28
29NodeItemSignalMapper = typed_signal_mapper(items.NodeItem)
30
31
32class CanvasScene(QGraphicsScene):
33    """A Graphics Scene for displaying and editing an Orange Scheme.
34    """
35
36    node_item_added = Signal(items.NodeItem)
37    """An node item has been added to the scene"""
38
39    node_item_removed = Signal(items.LinkItem)
40    """An node item has been removed from the scene"""
41
42    node_item_position_changed = Signal(items.NodeItem, QPointF)
43    """The position of a node has changed"""
44
45    node_item_double_clicked = Signal(items.NodeItem)
46    """An node item has been double clicked"""
47
48    node_item_activated = Signal(items.NodeItem)
49    """An node item has been activated (clicked)"""
50
51    node_item_hovered = Signal(items.NodeItem)
52    """An node item has been hovered"""
53
54    link_item_added = Signal(items.LinkItem)
55    """A new link item has been added to the scene"""
56
57    link_item_removed = Signal(items.LinkItem)
58    """Link item has been removed"""
59
60    link_item_hovered = Signal(items.LinkItem)
61    """Link item has been hovered"""
62
63    annotation_added = Signal(items.annotationitem.Annotation)
64    """Annotation item has been added"""
65
66    annotation_removed = Signal(items.annotationitem.Annotation)
67    """Annotation item has been removed"""
68
69    def __init__(self, *args, **kwargs):
70        QGraphicsScene.__init__(self, *args, **kwargs)
71
72        self.scheme = None
73        self.registry = None
74
75        # All node items
76        self.__node_items = []
77        # Mapping from SchemeNodes to canvas items
78        self.__item_for_node = {}
79        # All link items
80        self.__link_items = []
81        # Mapping from SchemeLinks to canvas items.
82        self.__item_for_link = {}
83
84        # All annotation items
85        self.__annotation_items = []
86        # Mapping from SchemeAnnotations to canvas items.
87        self.__item_for_annotation = {}
88
89        # Is the scene editable
90        self.editable = True
91
92        # Anchor Layout
93        self.__anchor_layout = AnchorLayout()
94        self.addItem(self.__anchor_layout)
95
96        self.__channel_names_visible = True
97
98        self.user_interaction_handler = None
99
100        self.activated_mapper = NodeItemSignalMapper(self)
101        self.activated_mapper.pyMapped.connect(
102            self.node_item_activated
103        )
104
105        self.hovered_mapper = NodeItemSignalMapper(self)
106        self.hovered_mapper.pyMapped.connect(
107            self.node_item_hovered
108        )
109
110        self.position_change_mapper = NodeItemSignalMapper(self)
111        self.position_change_mapper.pyMapped.connect(
112            self._on_position_change
113        )
114
115        log.info("'%s' intitialized." % self)
116
117    def clear_scene(self):
118        self.scheme = None
119        self.__node_items = []
120        self.__item_for_node = {}
121        self.__link_items = []
122        self.__item_for_link = {}
123        self.__annotation_items = []
124        self.__item_for_annotation = {}
125
126        self.__anchor_layout.deleteLater()
127
128        self.user_interaction_handler = None
129
130        self.clear()
131        log.info("'%s' cleared." % self)
132
133    def set_scheme(self, scheme):
134        """Set the scheme to display and edit. Populates the scene
135        with nodes and links already in the scheme.
136
137        """
138        if self.scheme is not None:
139            # Clear the old scheme
140            self.scheme.node_added.disconnect(self.add_node)
141            self.scheme.node_removed.disconnect(self.remove_node)
142
143            self.scheme.link_added.disconnect(self.add_link)
144            self.scheme.link_removed.disconnect(self.remove_link)
145
146            self.scheme.annotation_added.disconnect(self.add_annotation)
147            self.scheme.annotation_removed.disconnect(self.remove_annotation)
148
149            self.scheme.node_state_changed.disconnect(
150                self.on_widget_state_change
151            )
152            self.scheme.channel_state_changed.disconnect(
153                self.on_link_state_change
154            )
155
156            self.clear_scene()
157
158        log.info("Setting scheme '%s' on '%s'" % (scheme, self))
159
160        self.scheme = scheme
161        if self.scheme is not None:
162            self.scheme.node_added.connect(self.add_node)
163            self.scheme.node_removed.connect(self.remove_node)
164
165            self.scheme.link_added.connect(self.add_link)
166            self.scheme.link_removed.connect(self.remove_link)
167
168            self.scheme.annotation_added.connect(self.add_annotation)
169            self.scheme.annotation_removed.connect(self.remove_annotation)
170
171            self.scheme.node_state_changed.connect(
172                self.on_widget_state_change
173            )
174            self.scheme.channel_state_changed.connect(
175                self.on_link_state_change
176            )
177
178            self.scheme.topology_changed.connect(self.on_scheme_change)
179
180        for node in scheme.nodes:
181            self.add_node(node)
182
183        for link in scheme.links:
184            self.add_link(link)
185
186        for annot in scheme.annotations:
187            self.add_annotation(annot)
188
189    def set_registry(self, registry):
190        """Set the widget registry.
191        """
192        log.info("Setting registry '%s on '%s'." % (registry, self))
193        self.registry = registry
194
195    def set_anchor_layout(self, layout):
196        if self.__anchor_layout != layout:
197            if self.__anchor_layout:
198                self.__anchor_layout.deleteLater()
199                self.__anchor_layout = None
200
201            self.__anchor_layout = layout
202
203    def anchor_layout(self):
204        return self.__anchor_layout
205
206    def set_channel_names_visible(self, visible):
207        self.__channel_names_visible = visible
208        for link in self.__link_items:
209            link.setChannelNamesVisible(visible)
210
211    def channel_names_visible(self):
212        return self.__channel_names_visible
213
214    def add_node_item(self, item):
215        """Add a :class:`NodeItem` instance to the scene.
216        """
217        if item in self.__node_items:
218            raise ValueError("%r is already in the scene." % item)
219
220        if item.pos().isNull():
221            if self.__node_items:
222                pos = self.__node_items[-1].pos() + QPointF(150, 0)
223            else:
224                pos = QPointF(150, 150)
225
226            item.setPos(pos)
227
228        # Set signal mappings
229        self.activated_mapper.setPyMapping(item, item)
230        item.activated.connect(self.activated_mapper.pyMap)
231
232        self.hovered_mapper.setPyMapping(item, item)
233        item.hovered.connect(self.hovered_mapper.pyMap)
234
235        self.position_change_mapper.setPyMapping(item, item)
236        item.positionChanged.connect(self.position_change_mapper.pyMap)
237
238        self.addItem(item)
239
240        self.__node_items.append(item)
241
242        self.node_item_added.emit(item)
243
244        log.info("Added item '%s' to '%s'" % (item, self))
245        return item
246
247    def add_node(self, node):
248        """Add and return a default constructed `NodeItem` for a
249        `SchemeNode` instance. If the node is already in the scene
250        do nothing and just return its item.
251
252        """
253        if node in self.__item_for_node:
254            # Already added
255            return self.__item_for_node[node]
256
257        item = self.new_node_item(node.description)
258
259        if node.position:
260            pos = QPointF(*node.position)
261            item.setPos(pos)
262
263        self.__item_for_node[node] = item
264
265        node.position_changed.connect(self.__on_node_pos_changed)
266        node.title_changed.connect(item.setTitle)
267        node.progress_changed.connect(item.setProgress)
268        node.processing_state_changed.connect(item.setProcessingState)
269        return self.add_node_item(item)
270
271    def new_node_item(self, widget_desc, category_desc=None):
272        """Construct an new `NodeItem` from a `WidgetDescription`.
273        Optionally also set `CategoryDescription`.
274
275        """
276        item = items.NodeItem()
277        item.setWidgetDescription(widget_desc)
278
279        if category_desc is None and self.registry and widget_desc.category:
280            category_desc = self.registry.category(widget_desc.category)
281
282        if category_desc is None and self.registry is not None:
283            try:
284                category_desc = self.registry.category(widget_desc.category)
285            except KeyError:
286                pass
287
288        if category_desc is not None:
289            item.setWidgetCategory(category_desc)
290
291        return item
292
293    def remove_node_item(self, item):
294        """Remove `item` (:class:`NodeItem`) from the scene.
295        """
296        self.activated_mapper.removePyMappings(item)
297        self.hovered_mapper.removePyMappings(item)
298
299        item.hide()
300        self.removeItem(item)
301        self.__node_items.remove(item)
302
303        self.node_item_removed.emit(item)
304
305        log.info("Removed item '%s' from '%s'" % (item, self))
306
307    def remove_node(self, node):
308        """Remove the `NodeItem` instance that was previously constructed for
309        a `SchemeNode` node using the `add_node` method.
310
311        """
312        item = self.__item_for_node.pop(node)
313
314        node.position_changed.disconnect(self.__on_node_pos_changed)
315        node.title_changed.disconnect(item.setTitle)
316        node.progress_changed.disconnect(item.setProgress)
317        node.processing_state_changed.disconnect(item.setProcessingState)
318
319        self.remove_node_item(item)
320
321    def node_items(self):
322        """Return all :class:`NodeItem` instances in the scene.
323        """
324        return list(self.__node_items)
325
326    def add_link_item(self, item):
327        """Add a link (:class:`LinkItem`)to the scene.
328        """
329        if item.scene() is not self:
330            self.addItem(item)
331
332        self.__link_items.append(item)
333
334        self.link_item_added.emit(item)
335
336        log.info("Added link %r -> %r to '%s'" % \
337                 (item.sourceItem.title, item.sinkItem.title, self))
338
339        self.__anchor_layout.invalidateLink(item)
340
341        return item
342
343    def add_link(self, scheme_link):
344        """Create and add a `LinkItem` instance for a `SchemeLink`
345        instance. If the link is already in the scene do nothing
346        and just return its `LinkItem`.
347
348        """
349        if scheme_link in self.__item_for_link:
350            return self.__item_for_link[scheme_link]
351
352        source = self.__item_for_node[scheme_link.source_node]
353        sink = self.__item_for_node[scheme_link.sink_node]
354
355        item = self.new_link_item(source, scheme_link.source_channel,
356                                  sink, scheme_link.sink_channel)
357
358        item.setEnabled(scheme_link.enabled)
359        scheme_link.enabled_changed.connect(item.setEnabled)
360
361        if scheme_link.is_dynamic():
362            item.setDynamic(True)
363            item.setDynamicEnabled(scheme_link.dynamic_enabled)
364            scheme_link.dynamic_enabled_changed.connect(item.setDynamicEnabled)
365
366        self.add_link_item(item)
367        self.__item_for_link[scheme_link] = item
368        return item
369
370    def new_link_item(self, source_item, source_channel,
371                      sink_item, sink_channel):
372        """Construct and return a new `LinkItem`
373        """
374        item = items.LinkItem()
375        item.setSourceItem(source_item)
376        item.setSinkItem(sink_item)
377        fmt = "<b>{0}</b>&nbsp;-->&nbsp;<b>{1}</b>"
378        item.setToolTip(
379            fmt.format(escape(source_channel.name),
380                       escape(sink_channel.name))
381        )
382
383        item.setSourceName(source_channel.name)
384        item.setSinkName(sink_channel.name)
385        item.setChannelNamesVisible(self.__channel_names_visible)
386
387        return item
388
389    def remove_link_item(self, item):
390        """Remove a link (:class:`LinkItem`) from the scene.
391        """
392        self.__link_items.remove(item)
393
394        # Remove the anchor points.
395        item.removeLink()
396        self.removeItem(item)
397        self.link_item_removed.emit(item)
398
399        log.info("Removed link '%s' from '%s'" % (item, self))
400
401        return item
402
403    def remove_link(self, scheme_link):
404        """ Remove a `LinkItem` instance that was previously constructed for
405        a `SchemeLink` node using the `add_link` method.
406
407        """
408        item = self.__item_for_link.pop(scheme_link)
409        scheme_link.enabled_changed.disconnect(item.setEnabled)
410        self.remove_link_item(item)
411
412    def link_items(self):
413        """Return all :class:`LinkItems` in the scene.
414
415        """
416        return list(self.__link_items)
417
418    def add_annotation_item(self, annotation):
419        """Add an `Annotation` item to the scene.
420
421        """
422        self.__annotation_items.append(annotation)
423        self.addItem(annotation)
424        self.annotation_added.emit(annotation)
425        return annotation
426
427    def add_annotation(self, scheme_annot):
428        """Create a new item for :class:`SchemeAnnotation` and add it
429        to the scene. If the `scheme_annot` is already in the scene do
430        nothing and just return its item.
431
432        """
433        if scheme_annot in self.__item_for_annotation:
434            # Already added
435            return self.__item_for_annotation[scheme_annot]
436
437        if isinstance(scheme_annot, scheme.SchemeTextAnnotation):
438            item = items.TextAnnotation()
439            item.setPlainText(scheme_annot.text)
440            x, y, w, h = scheme_annot.rect
441            item.setPos(x, y)
442            item.resize(w, h)
443            item.setTextInteractionFlags(Qt.TextEditorInteraction)
444            scheme_annot.text_changed.connect(item.setPlainText)
445
446        elif isinstance(scheme_annot, scheme.SchemeArrowAnnotation):
447            item = items.ArrowAnnotation()
448            start, end = scheme_annot.start_pos, scheme_annot.end_pos
449            item.setLine(QLineF(QPointF(*start), QPointF(*end)))
450
451        scheme_annot.geometry_changed.connect(
452            self.__on_scheme_annot_geometry_change
453        )
454
455        self.add_annotation_item(item)
456        self.__item_for_annotation[scheme_annot] = item
457
458        return item
459
460    def remove_annotation_item(self, annotation):
461        """Remove an `Annotation` item from the scene.
462
463        """
464        self.__annotation_items.remove(annotation)
465        self.removeItem(annotation)
466        self.annotation_removed.emit(annotation)
467
468    def remove_annotation(self, scheme_annotation):
469        item = self.__item_for_annotation.pop(scheme_annotation)
470
471        scheme_annotation.geometry_changed.disconnect(
472            self.__on_scheme_annot_geometry_change
473        )
474
475        if isinstance(scheme_annotation, scheme.SchemeTextAnnotation):
476            scheme_annotation.text_changed.disconnect(
477                item.setPlainText
478            )
479
480        self.remove_annotation_item(item)
481
482    def annotation_items(self):
483        """Return all `Annotation` items in the scene.
484
485        """
486        return self.__annotation_items
487
488    def item_for_annotation(self, scheme_annotation):
489        return self.__item_for_annotation[scheme_annotation]
490
491    def annotation_for_item(self, item):
492        rev = dict(reversed(item) \
493                   for item in self.__item_for_annotation.items())
494        return rev[item]
495
496    def commit_scheme_node(self, node):
497        """Commit the `node` into the scheme.
498        """
499        if not self.editable:
500            raise Exception("Scheme not editable.")
501
502        if node not in self.__item_for_node:
503            raise ValueError("No 'NodeItem' for node.")
504
505        item = self.__item_for_node[node]
506
507        try:
508            self.scheme.add_node(node)
509        except Exception:
510            log.error("An unexpected error occurred while commiting node '%s'",
511                      node, exc_info=True)
512            # Cleanup (remove the node item)
513            self.remove_node_item(item)
514            raise
515
516        log.info("Commited node '%s' from '%s' to '%s'" % \
517                 (node, self, self.scheme))
518
519    def commit_scheme_link(self, link):
520        """Commit a scheme link.
521        """
522        if not self.editable:
523            raise Exception("Scheme not editable")
524
525        if link not in self.__item_for_link:
526            raise ValueError("No 'LinkItem' for link.")
527
528        self.scheme.add_link(link)
529        log.info("Commited link '%s' from '%s' to '%s'" % \
530                 (link, self, self.scheme))
531
532    def node_for_item(self, item):
533        """Return the `SchemeNode` for the `item`.
534        """
535        rev = dict([(v, k) for k, v in self.__item_for_node.items()])
536        return rev[item]
537
538    def item_for_node(self, node):
539        """Return the :class:`NodeItem` instance for a :class:`SchemeNode`.
540        """
541        return self.__item_for_node[node]
542
543    def link_for_item(self, item):
544        """Return the `SchemeLink for `item` (:class:`LinkItem`).
545        """
546        rev = dict([(v, k) for k, v in self.__item_for_link.items()])
547        return rev[item]
548
549    def item_for_link(self, link):
550        """Return the :class:`LinkItem` for a :class:`SchemeLink`
551        """
552        return self.__item_for_link[link]
553
554    def selected_node_items(self):
555        """Return the selected :class:`NodeItem`'s.
556        """
557        return [item for item in self.__node_items if item.isSelected()]
558
559    def selected_annotation_items(self):
560        """Return the selected :class:`Annotation`'s
561        """
562        return [item for item in self.__annotation_items if item.isSelected()]
563
564    def node_links(self, node_item):
565        """Return all links from the `node_item` (:class:`NodeItem`).
566        """
567        return self.node_output_links(node_item) + \
568               self.node_input_links(node_item)
569
570    def node_output_links(self, node_item):
571        """Return a list of all output links from `node_item`.
572        """
573        return [link for link in self.__link_items
574                if link.sourceItem == node_item]
575
576    def node_input_links(self, node_item):
577        """Return a list of all input links for `node_item`.
578        """
579        return [link for link in self.__link_items
580                if link.sinkItem == node_item]
581
582    def neighbor_nodes(self, node_item):
583        """Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes.
584        """
585        neighbors = map(attrgetter("sourceItem"),
586                        self.node_input_links(node_item))
587
588        neighbors.extend(map(attrgetter("sinkItem"),
589                             self.node_output_links(node_item)))
590        return neighbors
591
592    def on_widget_state_change(self, widget, state):
593        pass
594
595    def on_link_state_change(self, link, state):
596        pass
597
598    def on_scheme_change(self, ):
599        pass
600
601    def _on_position_change(self, item):
602        # Invalidate the anchor point layout and schedule a layout.
603        self.__anchor_layout.invalidateNode(item)
604
605        self.node_item_position_changed.emit(item, item.pos())
606
607    def __on_node_pos_changed(self, pos):
608        node = self.sender()
609        item = self.__item_for_node[node]
610        item.setPos(*pos)
611
612    def __on_scheme_annot_geometry_change(self):
613        annot = self.sender()
614        item = self.__item_for_annotation[annot]
615        if isinstance(annot, scheme.SchemeTextAnnotation):
616            item.setGeometry(QRectF(*annot.rect))
617        elif isinstance(annot, scheme.SchemeArrowAnnotation):
618            p1 = item.mapFromScene(QPointF(*annot.start_pos))
619            p2 = item.mapFromScene(QPointF(*annot.end_pos))
620            item.setLine(QLineF(p1, p2))
621        else:
622            pass
623
624    def item_at(self, pos, type_or_tuple=None):
625        rect = QRectF(pos - QPointF(1.5, 1.5), QSizeF(3, 3))
626        items = self.items(rect)
627        if type_or_tuple:
628            items = [i for i in items if isinstance(i, type_or_tuple)]
629
630        return items[0] if items else None
631
632    if PYQT_VERSION_STR < "4.9":
633        # For QGraphicsObject subclasses items, itemAt ... return a
634        # QGraphicsItem wrapper instance and not the actual class instance.
635        def itemAt(self, *args, **kwargs):
636            item = QGraphicsScene.itemAt(self, *args, **kwargs)
637            return toGraphicsObjectIfPossible(item)
638
639        def items(self, *args, **kwargs):
640            items = QGraphicsScene.items(self, *args, **kwargs)
641            return map(toGraphicsObjectIfPossible, items)
642
643        def selectedItems(self, *args, **kwargs):
644            return map(toGraphicsObjectIfPossible,
645                       QGraphicsScene.selectedItems(self, *args, **kwargs))
646
647        def collidingItems(self, *args, **kwargs):
648            return map(toGraphicsObjectIfPossible,
649                       QGraphicsScene.collidingItems(self, *args, **kwargs))
650
651        def focusItem(self, *args, **kwargs):
652            item = QGraphicsScene.focusItem(self, *args, **kwargs)
653            return toGraphicsObjectIfPossible(item)
654
655        def mouseGrabberItem(self, *args, **kwargs):
656            item = QGraphicsScene.mouseGrabberItem(self, *args, **kwargs)
657            return toGraphicsObjectIfPossible(item)
658
659    def mousePressEvent(self, event):
660        if self.user_interaction_handler and \
661                self.user_interaction_handler.mousePressEvent(event):
662            return
663
664        # Right (context) click on the node item. If the widget is not
665        # in the current selection then select the widget (only the widget).
666        # Else simply return and let customContextMenuReqested signal
667        # handle it
668        shape_item = self.item_at(event.scenePos(), items.NodeItem)
669        if shape_item and event.button() == Qt.RightButton and \
670                shape_item.flags() & QGraphicsItem.ItemIsSelectable:
671            if not shape_item.isSelected():
672                self.clearSelection()
673                shape_item.setSelected(True)
674
675        return QGraphicsScene.mousePressEvent(self, event)
676
677    def mouseMoveEvent(self, event):
678        if self.user_interaction_handler and \
679                self.user_interaction_handler.mouseMoveEvent(event):
680            return
681
682        return QGraphicsScene.mouseMoveEvent(self, event)
683
684    def mouseReleaseEvent(self, event):
685        if self.user_interaction_handler and \
686                self.user_interaction_handler.mouseReleaseEvent(event):
687            return
688        return QGraphicsScene.mouseReleaseEvent(self, event)
689
690    def mouseDoubleClickEvent(self, event):
691        if self.user_interaction_handler and \
692                self.user_interaction_handler.mouseDoubleClickEvent(event):
693            return
694
695        return QGraphicsScene.mouseDoubleClickEvent(self, event)
696
697    def keyPressEvent(self, event):
698        if self.user_interaction_handler and \
699                self.user_interaction_handler.keyPressEvent(event):
700            return
701        return QGraphicsScene.keyPressEvent(self, event)
702
703    def keyReleaseEvent(self, event):
704        if self.user_interaction_handler and \
705                self.user_interaction_handler.keyReleaseEvent(event):
706            return
707        return QGraphicsScene.keyReleaseEvent(self, event)
708
709    def set_user_interaction_handler(self, handler):
710        if self.user_interaction_handler and \
711                not self.user_interaction_handler.finished:
712            self.user_interaction_handler.cancel()
713
714        log.info("Setting interaction '%s' to '%s'" % (handler, self))
715
716        self.user_interaction_handler = handler
717        if handler:
718            handler.start()
719
720    def __str__(self):
721        return "%s(objectName=%r, ...)" % \
722                (type(self).__name__, str(self.objectName()))
723
724
725def grab_svg(scene):
726    """Return a SVG rendering of the scene contents.
727    """
728    from PyQt4.QtSvg import QSvgGenerator
729    svg_buffer = QBuffer()
730    gen = QSvgGenerator()
731    gen.setOutputDevice(svg_buffer)
732
733    items_rect = scene.itemsBoundingRect().adjusted(-10, -10, 10, 10)
734
735    if items_rect.isNull():
736        items_rect = QRectF(0, 0, 10, 10)
737
738    width, height = items_rect.width(), items_rect.height()
739    rect_ratio = float(width) / height
740
741    # Keep a fixed aspect ratio.
742    aspect_ratio = 1.618
743    if rect_ratio > aspect_ratio:
744        height = int(height * rect_ratio / aspect_ratio)
745    else:
746        width = int(width * aspect_ratio / rect_ratio)
747
748    target_rect = QRectF(0, 0, width, height)
749    source_rect = QRectF(0, 0, width, height)
750    source_rect.moveCenter(items_rect.center())
751
752    gen.setSize(target_rect.size().toSize())
753    gen.setViewBox(target_rect)
754
755    painter = QPainter(gen)
756
757    # Draw background.
758    painter.setBrush(QBrush(Qt.white))
759    painter.drawRect(target_rect)
760
761    # Render the scene
762    scene.render(painter, target_rect, source_rect)
763    painter.end()
764
765    return unicode(svg_buffer.buffer())
Note: See TracBrowser for help on using the repository browser.