49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from qgis.core import (
|
|
QgsLayoutItem,
|
|
QgsLayoutItemRegistry,
|
|
QgsLayoutItemAbstractMetadata,
|
|
QgsNetworkAccessManager,
|
|
QgsMessageLog,
|
|
QgsGeometry
|
|
)
|
|
|
|
|
|
ITEM_TYPE = QgsLayoutItemRegistry.PluginItem + 1338
|
|
|
|
|
|
class PlotLayoutItem(QgsLayoutItem):
|
|
|
|
def __init__(self, layout):
|
|
super().__init__(layout)
|
|
|
|
def draw(self, context):
|
|
pass
|
|
# if not self.html_loaded:
|
|
# self.load_content()
|
|
|
|
# if not self.layout().renderContext().isPreviewRender():
|
|
# # this is NOT safe to do when rendering in the gui (i.e. a preview render), but for exports we have
|
|
# # to loop around until the HTML has fully loaded
|
|
# while not self.html_loaded:
|
|
# QCoreApplication.processEvents()
|
|
|
|
# # almost a direct copy from QgsLayoutItemLabel!
|
|
# painter = context.renderContext().painter()
|
|
# painter.save()
|
|
|
|
# # painter is scaled to dots, so scale back to layout units
|
|
# painter.scale(context.renderContext().scaleFactor() / self.html_units_to_layout_units,
|
|
# context.renderContext().scaleFactor() / self.html_units_to_layout_units)
|
|
# self.web_page.mainFrame().render(painter)
|
|
# painter.restore()
|
|
|
|
def type(self):
|
|
return ITEM_TYPE
|
|
|
|
class PlotLayoutItemMetadata(QgsLayoutItemAbstractMetadata):
|
|
|
|
def __init__(self):
|
|
super().__init__(ITEM_TYPE, 'layoutItem')
|
|
|
|
def createItem(self, layout):
|
|
return PlotLayoutItem(layout) |