6 Creation of a schema from scratch
7 ---------------------------------
8 In order to describe each main action let's describe step by step the creation of a simple schema from scratch.
10 After launching of SALOME activate YACS module with help of :ref:`modules`. In order to create a new schema it is needed to choose **New Schema** command from :ref:`file` or from the corresponding toolbar button on the :ref:`schema`. Having these operations done the state of the SALOME
11 application would be like the following:
15 .. image:: images/functionality_list_83.jpg
20 **A new empty schema is created**
23 Create an inline script node by using the context menu on the **newSchema_1** node.
25 .. image:: images/scratch1.jpg
28 As a result a new inline script node ( **PyScript0** in our example) without ports will be displayed in the 2D Viewer
29 and the corresponding node object will be published in the edition Tree View under the schema object **newSchema_1**.
31 .. image:: images/functionality_list_84.jpg
36 **Schema with a new created inline script node**
39 Further by the same way it is easy to create, for example, a FOR loop node by choosing **For Loop Node** entry
40 in the context menu. To simplify schema presentation in the 2D Viewer and makes it easier for the user perception
41 it is recommended to use auto-arrange graph nodes operation which is accessible from the context menu : entry **arrange local nodes**
42 for an automatic placement on one level of nodes or entry **arrange nodes recursion** for an automatic placement
45 .. image:: images/functionality_list_85.jpg
50 **FOR loop node has been added into the schema**
53 Let's create a block node as a body of the new FOR loop node. For this purpose it is needed to select this node object ( **ForLoop1**
54 in our example) in the Tree View and call **Create Node --> bloc Node** item from its context popup menu. This operation is also possible
55 from the node context menu in the 2D Viewer.
59 .. image:: images/functionality_list_86.jpg
64 **Creation of a body node**
67 As a result of this operation a block node with empty content will be added inside FOR loop node as its body node. The presentation of
68 the schema in the 2D Viewer will be changed and block node item ( **Bloc2** in our example) will appear in the Tree View structure
69 under its father FOR loop node.
73 .. image:: images/functionality_list_87.jpg
78 **Tree View structure and presentation in the 2D Viewer after body block node creation**
81 Now it's time to fill in created block node with a child nodes. Select block node item in the Tree View and call
82 **Create Node --> Node from Catalog** item from context popup menu.
86 .. image:: images/functionality_list_88.jpg
91 **Fill in block node content**
94 Input Panel with catalogs' content is displayed on the right side of the applications' desktop. Choose **Add** service
95 from **AddComponent** component and drag and drop it onto the bloc node.
99 .. image:: images/functionality_list_89.jpg
104 **Choose a SALOME service node from the session catalog**
107 After the drag and drop, we can see the following representation of a schema in the 2D Viewer.
111 .. image:: images/functionality_list_90.jpg
116 **SALOME service node is created inside the block**
119 Tree View structure is changed and now block node contains one SALOME service node ( **Add3** in our case), which executes
120 the service named **Add** from **AddComponent** component of SALOME.
122 So, the structure of the schema is defined and now it is time to create input/output ports of schemas' nodes.
124 Firstly, let's consider inline script node **PyScript0**. To show Input Panel with node properties select **PyScript0** node
125 either in the Tree View or in the 2D Viewer. Then activate "Output Ports" tab in the "Edit Ports" group of the Input Panel
126 and choose a data type (**int**) in the drop down menu. A new line corresponding to a new output port is added to the table.
127 This new port is a dataflow port and has a type of int. Let's input **stepNum** in the "Name" column as the name of the
130 .. sourcecode:: python
134 in the built-in python code editor as an inline python script of the node. Finally, click on the **Apply** button to validate all
135 the changes. The structure of the Tree View and nodes’ presentation in the 2D Viewer are changed in order to reflect these modifications.
138 .. image:: images/functionality_list_92.jpg
143 **2D Viewer and Tree View updates after port addition**
146 Further, link **stepNum** output port of the **PyScript0** node with **nsteps** input port of the **ForLoop1** node. For this purpose
147 the user should select **stepNum** output port object in the 2D Viewer and drag and drop it onto input port **nsteps** of the **ForLoop1** node.
148 This port is considered as the end port of the newly created link. Now the state of the SALOME application should be as the following:
152 .. image:: images/functionality_list_94.jpg
157 **A dataflow link is added**
160 In order to make the presentation of the schema more convenient from the user point of view the links and nodes can be
161 automatically placed with help of **arrange nodes recursion** command from the context menu of **newShema_1** node.
165 .. image:: images/functionality_list_95.jpg
170 **A schema 2D Viewer representation after nodes placement**
173 To create a valid schema it is needed also to set the values for input ports of the **Add3** node. For this purpose the user should
174 activate the Input Panel with SALOME service node properties by selecting **Add3** node either in the Tree View or in the 2D Viewer
175 and change the content of "Value" column to, for example, **4.4** and **-3.1** double values for **x** and **y** input
176 port correspondingly.
180 .. image:: images/functionality_list_96.jpg
185 **Set input ports values for SALOME service node**
187 Now the schema is completely created. The user, for example, can export the schema into XML file (see :ref:`export_schema` section)
188 for future import or execute this schema immediately (see :ref:`execute_schema` section).