Main Content

createDiagramLink

Class: slreportgen.webview.EmbeddedWebViewDocument
Namespace: slreportgen.webview

Link to embedded web view report

Syntax

diaglink = createDiagramLink(wvdoc,dhandle,domlabel)

Description

diaglink = createDiagramLink(wvdoc,dhandle,domlabel) links a DOM object in an embedded web view document pane to a diagram anchor handle in the Simulink® web view. The generated diaglink DOM object is of the same type as domlabel or, if domlabel is a string, the DOM object is an mlreportgen.DOM.Text object.

Input Arguments

expand all

Web view document, specified as an slreportgen.webview.WebViewDocument object.

Handle of web view diagram anchor, specified as a character vector of the path or as an object handle. You can use the getExportDiagrams method to obtain the diagram paths and handles.

Example: Character vector: 'slrgex_vdp'. Object handle: get_param('slrgex_vdp','handle')

DOM object from which to link, specified as a valid DOM object or as a character vector. If you enter a character vector, an mlreportgen.DOM.Text object is created.

Output Arguments

expand all

Examples

expand all

This example shows how to create links from second level headings and block names in the document pane to the associated diagrams and blocks in the embedded web view.

Write a class called LinkWebView that is a subclass of slreportgen.webview.EmbeddedWebViewDocument. In the fillContent method, use createDiagramLink and createElementLink to create links to the embedded web view.

classdef LinkWebView < slreportgen.webview.EmbeddedWebViewDocument

    methods
        function wvdoc = LinkWebView(reportPath,modelName)
            % Invoke the EmbeddedWebViewDocument constructor, which
            % saves the report path and model name for use by the fill
            % methods of the report.
            wvdoc@slreportgen.webview.EmbeddedWebViewDocument( ...
                reportPath,modelName);
        end

        function fillContent(wvdoc)
            % Fill the Content hole in the report template with design
            % variable information. Use DOM or Report API methods to
            % create, format, add, and append content to this report.

            [~, handles] = getExportDiagrams(wvdoc);

            n = numel(handles);
            for i = 1:n
                diagHandle = handles{i};
                diagHeading = createDiagramLink(wvdoc, ...
                    diagHandle, ...
                    mlreportgen.dom.Heading(2, ...
                        get_param(diagHandle,'Name')));
                append(wvdoc,diagHeading);

                blockFinder = slreportgen.finder.BlockFinder( ...
                    diagHandle);

                while hasNext(blockFinder)
                    r = next(blockFinder);
                    elemHandle = r.Object;
                    elemHeading = createElementLink(wvdoc, ...
                        elemHandle, ...
                        mlreportgen.dom.Heading(3, ...
                            get_param(elemHandle,'Name')));
                    append(wvdoc,elemHeading);
                end

            end
        end
    end
end

Load the model.

model_name = "sf_car";
load_system(model_name);

Create an object of the LinkWebView class.

wvdoc = LinkWebView("myReport",model_name);

Use the methods in the class to generate the embedded web view report.

open(wvdoc);
fill(wvdoc);

Close the report and open the viewer.

close(wvdoc);
rptview(wvdoc);

More About

expand all

Version History

Introduced in R2017a