Main Content

slreq.View.create

Create view settings

Since R2022b

    Description

    view = slreq.View.create(viewName) creates a view with the name viewName. Requirements Toolbox™ saves the view in the preferences folder.

    example

    view = slreq.View.create(viewName,reqSetName) saves the view settings in the requirement set specified by reqSetName.

    example

    view = slreq.View.create(___,existingView) saves a copy of the existing view settings, existingView.

    example

    Examples

    collapse all

    This example shows how to create a view and apply it to the Requirements Editor and Requirements Perspective.

    Open the myAddRequirements requirement set, which contains requirements with Type set to Functional.

    rs = slreq.open("myAddRequirements");

    Create a view with the name NewView.

    myView = slreq.View.create("NewView")
    myView = 
      View with properties:
    
              Name: 'NewView'
         ReqFilter: ''
        LinkFilter: ''
              Host: ''
    
    

    Set the requirement filter to only display requirements that have Type set to Container.

    myView.ReqFilter = "{'ReqType','Container'};"
    myView = 
      View with properties:
    
              Name: 'NewView'
         ReqFilter: '{'ReqType','Container'};'
        LinkFilter: ''
              Host: ''
    
    

    Check if the view is valid.

    tf = isValid(myView)
    tf = logical
       1
    
    

    Apply the view to the Requirements Editor and Requirements Perspective.

    activate(myView)

    Confirm that the active view is NewView.

    appliedView = slreq.View.getActiveView
    appliedView = 
      View with properties:
    
              Name: 'NewView'
         ReqFilter: '{'ReqType','Container'};'
        LinkFilter: ''
              Host: ''
    
    

    The myAddRequirements requirement set does not contain any requirements with Type set to Container, so all of the requirements are filtered out.

    filtered-requirements-editor.png

    This example shows how to create a view and store it in a requirement set.

    Load and open the myAddRequirements requirement set.

    rs = slreq.open("myAddRequirements");

    Create a view and store it in the requirement set.

    myView = slreq.View.create("NewView","myAddRequirements");

    This example shows how to create a copy of an existing view.

    Load the myAddRequirements requirement set.

    rs = slreq.open("myAddRequirements");

    Load the view settings file ViewFile2.mat, which contains a view stored in the preferences folder.

    slreq.importViewSettings("ViewFile2")

    Get the existing views from the view settings file.

    views = slreq.View.getViews
    views=1×2 View array with properties:
        Name
        ReqFilter
        LinkFilter
        Host
    
    

    Assign the second view in the array to a variable.

    viewToCopy = views(2)
    viewToCopy = 
      View with properties:
    
              Name: 'NewView'
         ReqFilter: '{'ReqType','Container'};'
        LinkFilter: ''
              Host: ''
    
    

    Create a copy of the view and store it in the requirement set.

    copiedView = slreq.View.create("CopiedView","myAddRequirements",viewToCopy);

    Input Arguments

    collapse all

    View name, specified as a string scalar or a character vector.

    Example: "myView"

    Requirement set name, specified as a string scalar or a character vector.

    Example: "myReqSet"

    Existing view name, specified as a string scalar or a character vector.

    Example: "myView"

    Output Arguments

    collapse all

    View settings, returned as an slreq.View object.

    Version History

    Introduced in R2022b