Main Content

組み込み Web ビュー レポートのハイパーリンクの作成

ドキュメント ペインとレポートに組み込まれた Web ビューとの間に一方向および双方向のハイパーリンクを作成するには、以下のメソッドを使用します。これらのリンク作成メソッドは、Report Generator の slreportgen.webview.EmbeddedWebViewDocument 基底クラスから継承されます。

  • createDiagramTwoWayLink — ドキュメントの場所と組み込み Web ビューのブロック線図との間に双方向のリンクを作成します。このメソッドで作成されたリンクをドキュメント内でクリックすると、ターゲットのブロック線図が Web ビューで開きます。ブロック線図内でクリックすると、ドキュメント ペインがドキュメント内の目的の場所までスクロールします。

  • createElementTwoWayLink — ドキュメントの場所と組み込み Web ビューのブロック線図の要素との間に双方向のリンクを作成します。このメソッドで作成されたリンクをドキュメント内でクリックすると、モデル要素を含むブロック線図が開き、その要素が点滅します。ブロック線図内で要素をクリックすると、ドキュメント ペインがドキュメント内の目的の場所までスクロールします。

  • createDiagramLink — ドキュメントから組み込み Web ビューのブロック線図へのリンクを作成します。

  • createElementLink — ドキュメントから組み込み Web ビューのブロック線図の要素へのリンクを作成します。

次のコマンドを実行して、この例で使用するサポート ファイルにアクセスします。

openExample('rptgenext/SimulinkReportGeneratorFilesExample');

次のサンプル クラス ExampleWebView では、fillcontent メソッドは createDiagramTwoWayLinkcreateElementTwoWayLink を使用して、組み込み Web ビュー レポート内にドキュメント パネルと組み込み Web ビューとの間の双方向リンクを作成します。ドキュメント パネルから組み込み Web ビューへの一方向リンクを作成するには、createDiagramTwoWayLinkcreateDiagramLink に、createElementTwoWayLinkcreateElementLink に置き換えます。

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 = createDiagramTwoWayLink(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 = createElementTwoWayLink(wvdoc,elemHandle, ...
                        mlreportgen.dom.Heading(3,get_param(elemHandle,'Name')));
                    
                    append(wvdoc,elemHeading);
                end
                
            end
        end
    end
end

次のコードはクラス ExampleWebView を使用して、slrgex_vdp モデルの組み込み Web ビュー レポートを作成します。

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

レポートは以下のとおりです。

Embedded web view report of the slrgex_vdp model. The left pane contains the table of contents. The middle pane contains the diagrams and blocks in the model. The third pane contains the embedded Web View.

レポート内のリンクを使用するには、以下を行います。

  1. ドキュメント ペイン内のブロック線図名 (たとえば More Info) をクリックします。関連付けられたブロック線図が開きます。

    More Info diagram, which contains "Model Description: The van der Pol Equation. This is a simulation of a nonlinear second order system."

  2. 組み込み Web ビューの More Info タブで slrgex_vdp をクリックします。

    slrgex_vdp のブロック線図が開き、ドキュメント ペインの slrgex_vdp が一時的に強調表示されます。

    Document pane showing the slrgex_vdp link highlighted in yellow.

  3. ドキュメント ペインの Square をクリックすると、組み込み Web ビューで Square ブロックが強調表示されます。

    Square block name is selected and the Square block in the diagram is highlighted in blue.

  4. 組み込み Web ビューで Mu ブロックをダブルクリックします。ドキュメント ペインの Mu リンクが一時的に強調表示されます。

    The Mu block is highlighted in blue in the slrgex_vdp diagram. In the document pane, Mu is highlighted in yellow.

組み込み Web ビュー ジェネレーターを作成する他のタスクについては、以下を参照してください。

組み込み Web ビュー レポートを生成するには、組み込み Web ビュー レポートの生成を参照してください。

参考

関連するトピック