MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / start_latex_placement

Method start_latex_placement

SLiCAP/schematic/canvas.py:685–714  ·  view source on GitHub ↗
(self, latex_code: str, preamble_path: str,
                              width: int, height: int)

Source from the content-addressed store, hash-verified

683 self.placing_started.emit()
684
685 def start_latex_placement(self, latex_code: str, preamble_path: str,
686 width: int, height: int):
687 from PySide6.QtWidgets import QGraphicsPixmapItem
688 from PySide6.QtGui import QPixmap, QPainter as _QPainter
689 self._end_wire(commit=False)
690 self._cancel_placement()
691 from .latex_label import render_latex_raw
692 svg_bytes, _ = render_latex_raw(latex_code, preamble_path)
693 from PySide6.QtSvg import QSvgRenderer
694 from PySide6.QtCore import QByteArray
695 renderer = QSvgRenderer(QByteArray(svg_bytes)) if svg_bytes else None
696 w, h = max(1, width), max(1, height)
697 if renderer and renderer.isValid():
698 px = QPixmap(w, h)
699 px.fill(Qt.transparent)
700 p = _QPainter(px)
701 renderer.render(p)
702 p.end()
703 else:
704 px = QPixmap(w, h)
705 px.fill(QColor(240, 240, 180))
706 ghost = QGraphicsPixmapItem(px)
707 ghost.setOpacity(0.5)
708 ghost.setAcceptedMouseButtons(Qt.NoButton)
709 self._ghost = ghost
710 self._ghost.setPos(QPointF(-9999, -9999))
711 self.addItem(self._ghost)
712 self._latex_pending = (latex_code, preamble_path, width, height)
713 self._mode = _Mode.PLACING_LATEX
714 self.placing_started.emit()
715
716 def start_parameter_placement(self, params: list, preamble_path: str,
717 width: int, height: int):

Callers 1

_on_place_latexMethod · 0.80

Calls 3

_end_wireMethod · 0.95
_cancel_placementMethod · 0.95
render_latex_rawFunction · 0.85

Tested by

no test coverage detected