Отчет - Report
¶
-
class
axipy.render.
Report
(printer)¶ План отчета для последующей печати.
-
draw
(context)¶ Выводит отчета в заданном контексте.
- Параметры
context (
Context
) – Контекст, в котором будет отрисован отчет.
Пример:
# Пример создания отчета с геометрическим элементом и вывод его в pdf printer = QPrinter() printer.setPaperSize(QPrinter.A4) printer.setOutputFormat(QPrinter.PdfFormat) printer.setOutputFileName('report.pdf') painterReport = QPainter(printer) contextReport = Context(painterReport) report = Report(printer) geometryReportItem = GeometryReportItem() geometryReportItem.geometry = Geometry.from_wkt('POLYGON ((10 10, 10 100, 100 100, 10 10))') geometryReportItem.style = Style.from_mapinfo(mapbasic.brush(45, 255, 65535)) report.items.add(geometryReportItem) report.draw(contextReport)
-
fill_on_pages
()¶ Максимально заполняет страницу(ы) отчета.
-
property
items
¶ Элементы отчета.
- Тип результата
-
property
need_redraw
¶ Signal[]
Сигнал о необходимости перерисовки части или всего отчета.
-
property
unit
¶ Единицы измерения в отчете.
- Тип результата
-
Список элементов отчета - ReportItems
¶
-
class
axipy.render.
ReportItems
¶ Список элементов отчета.
-
add
(item)¶ Добавляет новый элемент в отчет.
- Параметры
item (
ReportItem
) – Вставляемый элемент
-
Элемент отчета - ReportItem
¶
digraph geometry {
node [shape="box", style=filled, fillcolor="lightgray"]
rankdir=LR
labelloc="t";
label="Элементы отчета:";
ReportItem [ href="#ref-label-reportitem-class" ];
GeometryReportItem [ href="#ref-label-geometryreportitem-class" ];
MapReportItem [ href="#ref-label-mapreportitem-class" ];
RasterReportItem [ href="#ref-label-rasterreportitem-class" ];
TableReportItem [ href="#ref-label-tablereportitem-class" ];
LegendReportItem [ href="#ref-label-legendreportitem-class" ];
ScaleBarReportItem [ href="#ref-label-scalebarreportitem-class" ];
ReportItem -> GeometryReportItem;
ReportItem -> MapReportItem;
ReportItem -> RasterReportItem;
ReportItem -> TableReportItem;
ReportItem -> LegendReportItem;
ReportItem -> ScaleBarReportItem;
}-
class
axipy.render.
ReportItem
¶ Базовый класс элемента отчета.
-
intersects
(checkRect)¶ Пересекается ли с переданным прямоугольником.
-
Элемент отчета: геометрия - GeometryReportItem
¶
Элемент отчета: карта - MapReportItem
¶
-
class
axipy.render.
MapReportItem
(rect, map)¶ Базовые классы:
axipy.render.ReportItem
Элемент отчета, основанный на созданной ранее карте.
Примечание
Перед созданием элемента отчета необходимо предварительно создать карту, на основе которой будет создан элемент отчета.
- Параметры
Пример:
mapReportItem = MapReportItem(Rect(10, 10, 200, 100), map) mapReportItem.scale = 200000000 report.items.add(mapReportItem)
-
map
()¶ Возвращает элемент типа карта, на основании которой создается элемент отчета.
- Тип результата
Элемент отчета: растр - RasterReportItem
¶
-
class
axipy.render.
RasterReportItem
(rect, data)¶ Базовые классы:
axipy.render.ReportItem
Элемент отчета, основанный на растре.
Примечание
В качестве источника может быть как локальный файл, расположенный в файловой системе, так и базе растра, размещенного на Web ресурсе.
- Параметры
Пример:
# Растр на базе URL rasterReportItem = RasterReportItem(Rect(10, 10, 140, 70), 'https://upload.wikimedia.org/wikipedia/en/7/72/World_Map_WSF.svg.png') report.items.add(rasterReportItem)
Пример:
# Растр на базе локального файла rasterReportItem = RasterReportItem(Rect(10, 10, 140, 70), 'TrueMarble.tif') report.items.add(rasterReportItem)
Элемент отчета: таблица - TableReportItem
¶
-
class
axipy.render.
TableReportItem
(rect, table)¶ Базовые классы:
axipy.render.ReportItem
Элемент отчета табличного представления данных.
Примечание
Позволяет отображать как таблицу целиком, так и накладывая дополнительные ограничения при отображении.
- Параметры
Пример:
table_world = io.openfile('world.tab') tableReportItem = TableReportItem(Rect(10, 150, 180, 100), table_world) tableReportItem.columns = table_world.schema.attribute_names()[:3] # Берем для показа первые три атрибута tableReportItem.rowFrom = 5 # С 5-й сторки tableReportItem.rowCount = 5 # Показываем 5 строк tableReportItem.startNumber = 5 # Нумерация с 5 tableReportItem.borderStyle = Style.from_mapinfo("Pen (1, 2, 0)") # Стиль рамки tableReportItem.fillStyle = Style.from_mapinfo("Brush (8, 65535)") # Стиль фона report.items.add(tableReportItem)
-
property
columns
¶ Перечень наименований для отображения. Если задать пустой список, будут отображены все поля таблицы.
- Тип результата
-
refreshValues
()¶ «Обновление данных из таблицы.
-
property
rowCount
¶ Количество записей. Если указано -1, то берутся все оставшиеся записи.
- Тип результата
Элемент отчета: легенда - LegendReportItem
¶
-
class
axipy.render.
LegendReportItem
(rect, legend)¶ Базовые классы:
axipy.render.ReportItem
Элемент отчета, основанный на легенде векторного или тематического слоя.
- Параметры
Пример создания легенды для тематического слоя:
world = Layer.create(table_world) # Базовый слой range_ = RangeThematicLayer("Население") # Тематический слой world.thematic.add(range_) legend = Legend(range_) # Легенда legendReportItem = LegendReportItem(Rect(100, 130, 50, 70), legend) # Элемент отчета report.items.add(legendReportItem) # Добавляем в отчет
Элемент отчета: масштабная линейка - ScaleBarReportItem
¶
-
class
axipy.render.
ScaleBarReportItem
(rect, map)¶ Базовые классы:
axipy.render.ReportItem
Элемент отчета - масштабная линейка для карты.
Пример:
scaleBarReportItem = ScaleBarReportItem(Rect(120, 130, 80, 50), mapReportItem) report.items.add(scaleBarReportItem)