Simulation with AnyLogic/Discrete Event Simulation/Ophthalmology Department Model/Step 2. Creating a model animation

Step 2. Creating a Model Animation
Now we will draw the model animation since the logical structure of the model is generated from the animation you draw. To simplify drawing, we will add the model layout first. You can draw the department layout using AnyLogic presentation shapes, or you can import any picture as the layout. The drawing approach is good for prototyping, when you want to experiment with draft layouts. The image approach is excellent for working with an existing layout.

Add department layout
 * 1) First, open the Presentation stencil of the Palette view. This stencil contains shapes and controls you can add on your presentation. To open some stencil of the Palette view, just click on the corresponding tab of the view. [[File:Step 2. Creating a model animation 1.png]]
 * 2) Drag the Image [[File:Step 2. Creating a model animation 2.gif]] element from the Presentation palette into the graphical editor (right in the place shown in the figure below). [[File:Step 2. Creating a model animation 3.png]]
 * 3) Set up the image properties in the Properties view. Click Add Image button and navigate to layout picture. You can find the layout here: \plugins\com.xj.anylogic.examples. \models\Ophthalmology Department\layout.png [[File:Step 2. Creating a model animation 4.png]]
 * 4) To preserve necessary picture size, select the Original Size option.
 * 5) The image should look like this: [[File:Step 2. Creating a model animation 5.png]]

Now we will draw the model animation. Drawing an animation, we define the transportation network, where rectangles represent network nodes and polylines — network links.

We will draw a rectangle for each department room and connect rectangles with polylines playing the role of moving paths in our model.

Draw network nodes
 * 1) Draw rectangles representing department rooms. Ophthalmology department has the following functional areas: waiting room, three procedure rooms, storage room for ophthalmoscopes and private office space for medical staff.
 * 2) To draw a rectangle, drag the Rectangle [[File:Step_3._Creating_a_model_animation_6.gif]] element from the Presentation page of the Palette view into the graphical editor.
 * 3) Resize rectangles by dragging to fit into the corresponding areas of the layout as shown in the figure below. To simplify drawing, switch binding to grid off by clicking the Enable/Disable Grid toolbar button. [[File:Step 2. Creating a model animation 6.png]]
 * 4) Name rectangles as shown in the figure. It is important since we will refer to nodes by their names in future.
 * 5) To make moving in our model more sophisticated, we will also add some additional rectangles to represent intermediate moving destinations. Draw four additional rectangles standing for intermediate network nodes and place them as shown in the figure: [[File:Step 2. Creating a model animation 7.png]]

Now we will define network segments by drawing polylines. In network-based model polylines represent moving paths.

Draw network segments
 * 1) Using the Polyline [[File:Step_3._Creating_a_model_animation_3.gif]] drawing tool, draw polylines as shown in the following figure: [[File:Step 2. Creating a model animation 8.png]]
 * 2) To draw a polyline, drag the Polyline [[File:Step_3._Creating_a_model_animation_3.gif]] element from the Presentation page of the Palette view into the graphical editor. Then double-click the drawn polyline to switch to editing points mode. In this mode you can add new points by double-clicking on the polyline and move points by dragging them.
 * 3) Note that all end points of polylines should necessarily lie inside the connected rectangles.

The logical structure of the network will be constructed from the presentation shapes added to the group we will specify as the Group of the network shapes. So now we should create a group and add all just drawn shapes to it.

Add shapes to a group
 * 1) Drag the Group [[File:Step 2. Creating a model animation 9.gif]] element from the Presentation palette into the graphical editor.
 * 2) Name the group networkGroup. [[File:Step 2. Creating a model animation 10.png]]
 * 3) Add all created shapes to the group. First, select shapes. The best way is to drag the mouse with the left button pressed over the area containing the shapes you want to select. [[File:Step 2. Creating a model animation 11.png]]
 * 4) The selected shapes will be highlighted in blue (see the figure below). If some shape has not been selected, you can press Ctrl and while holding it, click this shape with the left mouse button. The shape will be added to the selection. [[File:Step 2. Creating a model animation 12.png]]
 * 5) When finished selecting shapes, right-click the selection (you should click exactly on the outline of some selected shape), and then choose Grouping|Add to existing group from the popup menu. [[File:Step 2. Creating a model animation 13.png]]
 * 6) Finally, click on the networkGroup.

Define procedure rooms location
 * 1) Draw a polyline connecting rectangles representing the procedure rooms. We will use it later on. Place polyline points exactly inside the procRoom1, procRoom2 and procRoom3 rectangles. [[File:Step 2. Creating a model animation 14.png]]
 * 2) Name it roomsLocation</tt> and set custom line color. [[File:Step 2. Creating a model animation 15.png]]
 * 3) Make the polyline invisible. Go to the Dynamic page of the polyline's Properties and type <tt>false</tt> in the Visible field. [[File:Step 2. Creating a model animation 16.png]]