Salome HOME
[EDF26936] : End of the 2GB limit.
[modules/yacs.git] / doc / scratch.rst
1
2 :tocdepth: 3
3
4
5
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.
9
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:
12
13
14
15 .. image:: images/functionality_list_83.jpg
16   :align: center
17
18
19 .. centered::
20   **A new empty schema is created**
21
22
23 Create an inline script node by using the context menu on the **newSchema_1** node. 
24
25 .. image:: images/scratch1.jpg
26   :align: center
27
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**.
30
31 .. image:: images/functionality_list_84.jpg
32   :align: center
33
34
35 .. centered::
36   **Schema with a new created inline script node**
37
38
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
43 on all levels.
44
45 .. image:: images/functionality_list_85.jpg
46   :align: center
47
48
49 .. centered::
50   **FOR loop node has been added into the schema**
51
52
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.
56
57
58
59 .. image:: images/functionality_list_86.jpg
60   :align: center
61
62
63 .. centered::
64   **Creation of a body node**
65
66
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.
70
71
72
73 .. image:: images/functionality_list_87.jpg
74   :align: center
75
76
77 .. centered::
78   **Tree View structure and presentation in the 2D Viewer after body block node creation**
79
80
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.
83
84
85
86 .. image:: images/functionality_list_88.jpg
87   :align: center
88
89
90 .. centered::
91   **Fill in block node content**
92
93
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.
96
97
98
99 .. image:: images/functionality_list_89.jpg
100   :align: center
101
102
103 .. centered::
104   **Choose a SALOME service node from the session catalog**
105
106
107 After the drag and drop, we can see the following representation of a schema in the 2D Viewer.
108
109
110
111 .. image:: images/functionality_list_90.jpg
112   :align: center
113
114
115 .. centered::
116   **SALOME service node is created inside the block**
117
118
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.
121
122 So, the structure of the schema is defined and now it is time to create input/output ports of schemas' nodes.
123
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 
128 new port and type
129
130 .. sourcecode:: python
131
132     stepNum=3
133
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.
136
137
138 .. image:: images/functionality_list_92.jpg
139   :align: center
140
141
142 .. centered::
143   **2D Viewer and Tree View updates after port addition**
144
145
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:
149
150
151
152 .. image:: images/functionality_list_94.jpg
153   :align: center
154
155
156 .. centered::
157   **A dataflow link is added**
158
159
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.
162
163
164
165 .. image:: images/functionality_list_95.jpg
166   :align: center
167
168
169 .. centered::
170   **A schema 2D Viewer representation after nodes placement**
171
172
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.
177
178
179
180 .. image:: images/functionality_list_96.jpg
181   :align: center
182
183
184 .. centered::
185   **Set input ports values for SALOME service node**
186
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).
189