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

Method start_image_placement

SLiCAP/schematic/canvas.py:648–683  ·  view source on GitHub ↗
(self, file_path: str, width: int, height: int)

Source from the content-addressed store, hash-verified

646 self.placing_started.emit()
647
648 def start_image_placement(self, file_path: str, width: int, height: int):
649 from pathlib import Path as _Path
650 from PySide6.QtWidgets import QGraphicsPixmapItem
651 from PySide6.QtGui import QPixmap, QPainter as _QPainter
652 self._end_wire(commit=False)
653 self._cancel_placement()
654 w, h = max(1, width), max(1, height)
655 ext = _Path(file_path).suffix.lower()
656 if ext == ".svg":
657 from PySide6.QtSvg import QSvgRenderer
658 renderer = QSvgRenderer(file_path)
659 if renderer.isValid():
660 px = QPixmap(w, h)
661 px.fill(Qt.transparent)
662 p = _QPainter(px)
663 renderer.render(p)
664 p.end()
665 else:
666 px = QPixmap(w, h)
667 px.fill(Qt.lightGray)
668 else:
669 px = QPixmap(file_path)
670 if not px.isNull():
671 px = px.scaled(w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation)
672 else:
673 px = QPixmap(w, h)
674 px.fill(Qt.lightGray)
675 ghost = QGraphicsPixmapItem(px)
676 ghost.setOpacity(0.5)
677 ghost.setAcceptedMouseButtons(Qt.NoButton)
678 self._ghost = ghost
679 self._ghost.setPos(QPointF(-9999, -9999))
680 self.addItem(self._ghost)
681 self._image_pending = (file_path, width, height)
682 self._mode = _Mode.PLACING_IMAGE
683 self.placing_started.emit()
684
685 def start_latex_placement(self, latex_code: str, preamble_path: str,
686 width: int, height: int):

Callers 1

_on_place_imageMethod · 0.80

Calls 2

_end_wireMethod · 0.95
_cancel_placementMethod · 0.95

Tested by

no test coverage detected