Documentation

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, Stateflow.State, or Stateflow.Function object that contains a diagram

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 string or character array. Supported formats are:

  • auto — Image file format specified in the HG images option in the Report Generator panel of the MATLAB® Preferences dialog box

  • .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

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.

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

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

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

The specified template must be of the same type as the report to which this reporter is appended. For example, for a 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 template for this reporter, specified as a string or character array. 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, 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.

Example: firstchapter.LinkTarget = 'ch1_link';

Methods

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

Copy Semantics

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

Examples

Add Diagram Top Level of Model Diagram

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

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);

Introduced in R2017b

Was this topic helpful?