wolfhece.report.common ====================== .. py:module:: wolfhece.report.common Module Contents --------------- .. py:data:: wolfgpu_version :value: 'not installed' .. py:function:: pts2cm(pts) Convert points to centimeters for PyMuPDF. One point equals 1/72 inches. .. py:function:: pt2inches(pts) Convert points to inches for PyMuPDF. One point equals 1/72 inches. .. py:function:: inches2cm(inches) Convert inches to centimeters. One inch equals 2.54 centimeters. .. py:function:: cm2pts(cm) Convert centimeters to points for PyMuPDF. One point equals 1/72 inches. .. py:function:: cm2inches(cm) Convert centimeters to inches. One inch equals 2.54 centimeters. .. py:function:: A4_rect() Return the A4 rectangle in PyMuPDF units. (0, 0) is the top-left corner in PyMuPDF coordinates. .. py:function:: rect_cm(x, y, width, height) Create a rectangle in PyMuPDF units from centimeters. (0, 0) is the top-left corner in PyMuPDF coordinates. .. py:function:: get_rect_from_text(text, width, fontsize=10, padding=5) Get a rectangle that fits the text in PyMuPDF units. :param text: The text to fit in the rectangle. :param width: The width of the rectangle in centimeters. :param fontsize: The font size in points. :param padding: Padding around the text in points. :return: A PyMuPDF rectangle that fits the text. .. py:function:: single_line_to_html(text, font_size='10pt', font_family='Helvetica') .. py:function:: list_to_html(list_items, font_size='10pt', font_family='Helvetica') .. py:function:: list_to_html_aligned(list_items, font_size='10pt', font_family='Helvetica') .. py:function:: dict_to_html(data_dict: dict, font_size='10pt', font_family='Helvetica') Convert a dictionary to an HTML table with dataframe_image .. py:function:: dataframe_to_html(data: pandas.DataFrame, font_size='10pt', font_family='Helvetica') Convert a DataFrame to an HTML table with dataframe_image .. py:function:: convert_report_to_images(pdf_path: str | pathlib.Path, dpi=150) -> list[PIL.Image.Image] Convert the PDF report to a list of images (one per page). :param dpi: Dots per inch for the output images. :return: List of Images, one per page. .. py:data:: PAGE_WIDTH :value: 21 .. py:data:: PAGE_HEIGHT :value: 29.7 .. py:data:: SLIDE_HEIGHT :value: 19.05 .. py:data:: SLIDE_WIDTH :value: 33.866582 .. py:class:: DefaultLayoutA4(title: str, filename='', ox=0, oy=0, tx=0, ty=0, parent=None, is2D=True, idx='', plotted=True, mapviewer=None, need_for_wx=False, bbox=None, find_minmax=True, shared=False, colors=None) Bases: :py:obj:`wolfhece.PyVertexvectors.Zones` .. autoapi-inheritance-diagram:: wolfhece.report.common.DefaultLayoutA4 :parts: 1 :private-bases: Global layout for A4 report. This class inherits from Zones and defines a standard layout for A4 reports. It includes predefined areas for the title, versions, logo, and footer. .. py:attribute:: title .. py:attribute:: left_right_margin :value: 1 .. py:attribute:: top_bottom_margin :value: 0.5 .. py:attribute:: padding :value: 0.5 .. py:attribute:: _doc :value: None .. py:attribute:: _pdf_path :value: None .. py:method:: add_element(name: str, width: float, height: float, x: float = 0, y: float = 0) -> wolfhece.PyVertexvectors.vector Add a single element to the page. :param name: Name of the element. :param width: Width of the element in cm. :param height: Height of the element in cm. :param x: X coordinate of the bottom-left corner in cm. :param y: Y coordinate of the bottom-left corner in cm. :return: The created vector representing the element. .. py:method:: add_element_repeated(name: str, width: float, height: float, first_x: float = 0, first_y: float = 0, count_x: int = 1, count_y: int = 1, padding: float = None) -> wolfhece.PyVertexvectors.zone Add multiple elements to the page in a grid. :param name: Base name for the elements. :param width: Width of each element in cm. :param height: Height of each element in cm. :param first_x: X coordinate of the first element in cm. :param first_y: Y coordinate of the first element in cm. :param count_x: Number of elements in the X direction (positive for right, negative for left). :param count_y: Number of elements in the Y direction (positive for up, negative for down). :param padding: Padding between elements in cm. If None, use self.padding. :return: A zone containing the added elements. .. py:method:: check_if_overlap(vec: wolfhece.PyVertexvectors.vector) -> bool Check if the vector overlaps with any existing vector in the page layout. :param vec: The vector to check. :return: True if there is an overlap, False otherwise. .. py:property:: useful_part :type: wolfhece.PyVertexvectors.vector Get the useful part of the page, excluding margins. .. py:property:: page_dimension :type: tuple[float, float] Get the dimensions of the page in centimeters. .. py:property:: keys :type: list[str] Get the keys of the page layout. .. py:property:: layout :type: dict Get the layout as a dictionary. .. py:method:: get_item_in_layout(name: str) Override the indexing to access layout elements by name. .. py:method:: _to_dict() Convert the layout Zones to a dictionary. .. py:method:: plot(scale=1.0) Plot the page layout using matplotlib. :param scale: Scale factor for the plot. .. py:method:: _summary_versions() Find the versions of the simulation, wolfhece and the wolfgpu package .. py:method:: _insert_to_page(page: pymupdf.Page) Insert the layout into the PDF page. .. py:method:: create_report() -> pymupdf.Document Create the PDF report for the default LayoutA4. .. py:method:: save_report(output_path: pathlib.Path | str) Save the report to a PDF file .. py:property:: pdf_path Return the PDF document