Main Content

createDiagramLink

Class: slreportgen.webview.EmbeddedWebViewDocument
Package: slreportgen.webview

Link to embedded Web view report

Syntax

diaglink = createDiagramLink(wvdoc,dhandle,domlabel)

Description

diaglink = createDiagramLink(wvdoc,dhandle,domlabel) updates a DOM object in an embedded Web view Document panel so that it links to a diagram anchor handle in the Simulink® Web view. The diaglink DOM object is of the same type as domlabel or if domlabel is a string, an mlreportgen.DOM.Text object is created.

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

Use createDiagramLink to create links from level-two headings in the document pane to the associated diagrams in the embedded web view. This example also uses createElementLink to create links from block names in the document pane to blocks in the embedded web view.

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');

Write a class, ExampleWebView, that is a subclass of slreportgen.webview.EmbeddedWebViewDocument. Use createDiagramLink and createElementLink in the fillContent method.

classdef ExampleWebView < slreportgen.webview.EmbeddedWebViewDocument
        
    methods
        function wvdoc = ExampleWebView(reportPath,modelName)
            % Invoke the EmbeddedWebViewDocument constructor, which
            % saves the report path and model name for use by the
            % report's fill methods.
            wvdoc@slreportgen.webview.EmbeddedWebViewDocument(reportPath,modelName);
        end
        
        function fillContent(wvdoc)
            % Fill the Content hole in the report template with design
            % variable information. You can 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

Create an object of the ExampleWebView class and use its methods to generate the embedded web view report.

model = 'slrgex_vdp';
open_system(model);
wvdoc = ExampleWebView('myReport',model);
open(wvdoc);
fill(wvdoc);
close(wvdoc);
rptview(wvdoc);

More About

expand all

Version History

Introduced in R2017a