slreportgen.report.Diagram class

Package: slreportgen.report
Superclasses:

Create diagram reporter

Description

Create a diagram reporter, including a diagram snapshot and caption, for a Simulink® or Stateflow® diagram.

Note

To use a Diagram reporter in a report, you must create the report using the slreportgen.report.Report class.

Construction

diagram = Diagram() creates an empty diagram reporter. Set its properties to capture a Simulink or Stateflow diagram.

diagram = Diagram(source) creates a diagram reporter for the Simulink or Stateflow diagram specified by source. Adding this reporter to a report creates a snapshot of the diagram. Then, the snapshot displays in the report as an image with a caption. The snapshot image is stored in the temporary folder of the report. When the report is closed, the snapshot image is copied into the report and then, the image is deleted from the temporary folder. To prevent the snapshot image file from being deleted, use the Debug property of the report. See slreportgen.report.Report

diagram = Diagram(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

Input Arguments

expand all

See the Source property.

Properties

expand all

Diagram snapshot image source, specified as one of these values.

  • Name of an open or loaded Simulink model

  • Path of a Simulink subsystem block that contains the Simulink diagram or Stateflow chart

  • Handle to a subsystem block containing a Simulink diagram or Stateflow chart

  • Stateflow.Chart or Stateflow subchart object. Subcharts are graphical objects that can contain the same objects as a top-level chart, including other subcharts. Subcharts are commonly specified by a Stateflow.State, Stateflow.Function, or Stateflow.Box object.

Snapshot reporter, set by default to an object of the mlreportgen.report.FormalImage class. You do not need to set this property yourself. The FormalImage object adds the diagram snapshot to a report. To control the size of the snapshot, set the mlreportgen.report.FormalImage properties.

Snapshot image format, specified as a character vector or string scalar. Supported formats are:

  • 'bmp' — Bitmap image.

  • 'gif' — Graphics Interchange format.

  • 'jpg' — JPEG image.

  • 'png' — PNG image.

  • 'emf' — Enhanced metafile, supported only in DOCX output on Windows® platforms.

  • 'svg' — Scalable Vector Graphics.

  • 'tif' — Tag Image File format, not supported in HTML output.

  • 'pdf' — PDF image.

See Compatibility Considerations.

Choice to include a hyperlink of each diagram element, specified as a logical. If this property is true, each element becomes a hyperlink to an object in the report that describes it. This property applies only to PDF and HTML reports. Hyperlinks allow you to navigate the report using Simulink and Stateflow charts.

The Diagram, SimulinkObjectProperties, and StateflowObjectProperties reporters work together to enable navigation using hyperlinks. Each reporter prefaces the report object it creates with a hyperlink target. The ID of that target is based on the path of the reported element in the model. The Diagram reporter also overlays elements of a diagram snapshot with hyperlinks to the corresponding element-based target ID. The report object to which a diagram element links depends on the element type.

  • A diagram-based block (subsystem, chart, model) links to the diagram of the block.

  • Other blocks link to textual block descriptions, typically block property tables.

  • Masked subsystem blocks that have mask parameters link to the textual description of the block, such as the mask parameter tables. This linking to the textual descriptions is true only if the MaskedSystemLinkPolicy property of the Diagram reporter is set to 'block' or 'default'. Otherwise, the masked system block links to its diagram.

  • Masked subsystem blocks that do not have mask parameters link to the diagram of the block.

To customize diagram-based navigation, create custom link targets based on target IDs generated by the slreportgen.utils.getObjectID utility function.

Policy to determine the targets for the hyperlinks of masked system blocks, specified as one of these values.

  • 'default' — Masked system blocks that have parameters link to textual descriptions, such as mask parameter tables. Masked system blocks that do not have parameters link to the corresponding block diagram in the report.

  • 'system' — Masked system blocks link to their block diagram in the report.

  • 'block' — Masked system blocks link to their textual description, such as a table of masked parameters or subsystem parameters.

Scaling options for diagram snapshot image, specified as the string, auto, custom, or zoom. Scaling controls size of the diagram snapshot image in the image file.

  • auto — For PDF or Word (docx) output, auto scales the diagram snapshot image to fit in the current page layout while maintaining its aspect ratio. First, the diagram snapshot image is scaled to the page width. If the image height exceeds the page height, then the image is again scaled down. This additional scaling assures that the image fits in the current page with an extra 1" spacing. The extra spacing allows for extra text, such as a caption. Scaling does not apply to HTML output.

  • custom — Scales the diagram snapshot image based on the values of the Height and Width properties

  • zoom — Enlarges or reduces the snapshot image size to the percent value specified by the Zoom property. To specify the maximum image height and maximum image width, use the MaxHeight and MaxWidth properties, respectively.

Note

A java.lang.OutOfMemoryError can occur when either of these combinations of property settings occur:

  • Scaling set to zoom, and Zoom, MaxHeight, and MaxWidth properties set to large values

  • Scaling set to custom, and Height and Width properties set to large values

To avoid this error, for zoom Scaling, use smaller Zoom, MaxHeight, and MaxWidth property values. For custom Scaling, use smaller Height and Width property values. Using smaller values ensures that the diagram fits on the page.

Height of snapshot image for custom scaling, specified as a character vector or string scalar. This property applies only if Scaling is set to 'custom'.

The Height format is valueUnits, where Units is an abbreviation for the height units and value is the number of units. The table shows the valid Units abbreviations.

UnitsUnits Abbreviation
pixelspx
centimeterscm
inchesin
millimetersmm
picaspc
pointspt

Example: '3in'

Width of snapshot image for custom scaling, specified as a character vector or string scalar. This property applies only if Scaling is set to custom.

The Width format is valueUnits, where Units is an abbreviation for the units of the width and value is the number of units. See the Height property for a table of valid Units abbreviations.

Example: '3in'

Amount to zoom the diagram snapshot image, specified as a string. The Zoom format is value%, where value is the percentage by which the diagram snapshot image is enlarged or reduced.

Maximum height for zoom scaling, specified as a string. This property applies only if Scaling is set to zoom.

The MaxHeight format is valueUnits, where Units is an abbreviation for the height units and value is the number of units. See the Height property for a table of valid Units abbreviations.

Maximum width for zoom scaling, specified as a string. This property applies only if Scaling is set to zoom.

The MaxWidth format is valueUnits, where Units is an abbreviation for the height units and value is the number of units. See the Height property for a table of valid Units abbreviations.

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which this reporter is appended. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string or character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Methods

createTemplate Create diagram template
customizeReporter Create custom diagram reporter class
getClassFolder Diagram class definition file location
getSnapshotImage Diagram snapshot image file location

Inherited Methods

getImplGet implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Add Top Level of Model Diagram

Add a snapshot of the top level of the vdp model to a report.

load_system('vdp')
import slreportgen.report.*
import mlreportgen.report.*
rpt = slreportgen.report.Report('output','pdf');
 
chapter = Chapter();
chapter.Title = 'Diagram Reporter Example';
 
diagram = Diagram("vdp");
diagram.Snapshot.Caption = 'The van der Pol Equation';
diagram.SnapshotFormat = 'svg';
diagram.Snapshot.Height = '4in';

add(chapter,diagram);
add(rpt,chapter);
rptview(rpt);

Add Hyperlinked Diagram to a Report

Create a PDF report and add diagram snapshots of the root system and a subsystem from the sf_car model to it. Add a hyperlink to the transmission subsystem and add a paragraph as the target for that link.

import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.utils.*
import mlreportgen.dom.*
rpt = slreportgen.report.Report('output','pdf');
chapter = Chapter('sf_car');

load_system('sf_car');
diag1 = Diagram('sf_car');
diag1.Snapshot.Caption = 'Root System: sf_car';
add(chapter,diag1);
add(chapter,PageBreak);

diag2 = Diagram('sf_car/Engine');
diag2.Snapshot.Caption = 'Subsystem: sf_car/Engine';
add(chapter,diag2);
add(chapter, PageBreak);

para = Paragraph('Custom target for sf_car/transmission');
id = getObjectID('sf_car/transmission');
append(para,mlreportgen.dom.LinkTarget(id));
add(chapter,para);
add(chapter,PageBreak);

add(rpt, chapter);
close(rpt);
rptview(rpt);

Compatibility Considerations

expand all

Behavior changed in R2019b

Introduced in R2017b