Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[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 4.1 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 4.1 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 calling **Inline script** command from :ref:`creation`. As a result a new inline script node ( **PyScript0** in our example) without ports will be displayed in the 2D Viewer and the corresponding node object will be published in **Nodes** folder in the edition Tree View under the schema object.
24
25
26
27 .. image:: images/functionality_list_84.jpg
28   :align: center
29
30
31 .. centered::
32   **Schema with a new created inline script node**
33
34
35 Further by the same way it is easy to create, for example, FOR loop node by choosing **FOR loop** command from :ref:`creation`. To simplify schema presentation in the 2D Viewer and makes it easier for the user perception it is recommended to use auto-arrange graph nodes operation which is accessible from :ref:`visualization`.
36
37
38
39 .. image:: images/functionality_list_85.jpg
40   :align: center
41
42
43 .. centered::
44   **FOR loop node has been added into the schema and 'Arrange nodes' operation has been applied**
45
46
47 Let's create a block node as a body of a new FOR loop node. For this purpose it is needed to select this node object ( **ForLoop0** in our example) in the Tree View and call **Create a body --> Block** item from its context popup menu.
48
49
50
51 .. image:: images/functionality_list_86.jpg
52   :align: center
53
54
55 .. centered::
56   **Creation of a body node**
57
58
59 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 the schema in the 2D Viewer will be changed and block node item ( **Bloc0** in our example) will appear in the Tree View structure under its father FOR loop node.
60
61
62
63 .. image:: images/functionality_list_87.jpg
64   :align: center
65
66
67 .. centered::
68   **Tree View structure and presentation in the 2D Viewer after body block node creation**
69
70
71 Now it's time to fill in created block node with a child nodes. Select block node item in the Tree View and call **Create a node --> From catalog** item from context popup menu.
72
73
74
75 .. image:: images/functionality_list_88.jpg
76   :align: center
77
78
79 .. centered::
80   **Fill in block node content**
81
82
83 Input Panel with catalogs' content is displayed on the right side of the applications' desktop. Choose **Add** method from **AddComponent** component and press "Apply" button.
84
85
86
87 .. image:: images/functionality_list_89.jpg
88   :align: center
89
90
91 .. centered::
92   **Choose a SALOME service node from the session catalog**
93
94
95 After closing the Input Panel we can see the following representation of a schema in the 2D Viewer.
96
97
98
99 .. image:: images/functionality_list_90.jpg
100   :align: center
101
102
103 .. centered::
104   **SALOME service node is created inside the block**
105
106
107 Tree View structure is changed and now block node contains one SALOME service node ( **SalomeNode0** in our case), which executes the method named **Add** from **AddComponent** component of Salome.
108
109 So, the structure of the schema is defined and now it is the time to create input/output ports of schemas' nodes.
110
111 Firstly, let's consider inline script node **PyScript0** . To show Input Panel with node properties select **PyScript0** object either in the Tree View or in the 2D Viewer. Then activate "Output Ports" tab in the "Edit Ports" group of the Input Panel and click **+** button above the table of output ports. A new line corresponding to a new output port is added to the table. By default a new port is
112 a dataflow port and has a type of double. Let's input **stepNum** in the "Name" column as a name of a new port, change the type of port to **int** with help of pull-down list of the "Type" column and type
113
114 .. sourcecode:: python
115
116     stepNum=3
117
118 in the built-in python code editor as an inline python script of the node.
119
120
121
122 .. image:: images/functionality_list_91.jpg
123   :align: center
124
125
126 .. centered::
127   **Addition of output port and fill in python script for the PyScript0 node**
128
129
130 After pressing "Apply" button on the Input Panel a new output port **stepNum** is added to the **PyScript0** node and the structure of the Tree View and nodes' presentation in the 2D Viewer are changed in order to reflect these modifications.
131
132
133
134 .. image:: images/functionality_list_92.jpg
135   :align: center
136
137
138 .. centered::
139   **2D Viewer and Tree View updates after port addition**
140
141
142 Further, link **stepNum** output port of the **PyScript0** node with **nsteps** input port of the **ForLoop0** node. For this purpose the user should to select **stepNum** output port object in the Tree View and call **Add dataflow link** command from its context popup menu.
143
144
145
146 .. image:: images/functionality_list_93.jpg
147   :align: center
148
149
150 .. centered::
151   **Activate command for dataflow link addition**
152
153
154 After that select the **nsteps** input port of the **ForLoop0** node either in the Tree View or in the 2D Viewer. This port is considered as the end port of a new created link. Now the state of the Salome 4.1 application should be as the following:
155
156
157
158 .. image:: images/functionality_list_94.jpg
159   :align: center
160
161
162 .. centered::
163   **A dataflow link is added**
164
165
166 In order to make the presentation of the schema more convenient from the user point of view the links can be rebuilt with help of **Rebuild links** command from :ref:`visualization`.
167
168
169
170 .. image:: images/functionality_list_95.jpg
171   :align: center
172
173
174 .. centered::
175   **A schema 2D Viewer representation after links rebuilding**
176
177
178 To create a valid schema it is needed also to set the values for input ports of the **SalomeNode0** node. For this purpose the user should to activate the Input Panel with SALOME service node properties by selecting **SalomeNode0** node either in the Tree View or in the 2D Viewer and change the content of "Value" column to, for example, **4.4** and **-3.1** double values for **x** and **y** input
179 port correspondingly.
180
181
182
183 .. image:: images/functionality_list_96.jpg
184   :align: center
185
186
187 .. centered::
188   **Set input ports values for SALOME service node**
189
190
191 On the figure below the presentation of the schema after applying these changes is represented.
192
193
194
195 .. image:: images/functionality_list_97.jpg
196   :align: center
197
198
199 .. centered::
200   **Completely created schema**
201
202
203 Now the schema is completely created. The user, for example, can export the schema into XML file (see :ref:`export_schema` section) for future import or execute this schema immediately (see :ref:`execute_schema` section).
204