﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?application progid="SMath Studio Desktop" version="0.97.5154.6193"?>
<regions>
  <settings>
    <identity>
      <id>64dfdeb3-c6bb-4bf5-bcb6-dd8ea08cde1e</id>
      <revision>50</revision>
    </identity>
    <metadata lang="eng">
      <title>Shape containers for Modeller</title>
      <author>Andrey Ivashov</author>
      <description>This example shows how it is possible to handle Shapes as containers for others. Which means possibility to add Shapes on another Shapes to support one Shapes dependence from others.</description>
      <company>SMath, http://smath.info/</company>
    </metadata>
    <calculation>
      <precision>4</precision>
      <exponentialThreshold>5</exponentialThreshold>
      <fractions>decimal</fractions>
    </calculation>
    <pageModel active="true" printAreas="true" simpleEqualsOnly="false" printBackgroundImages="true">
      <paper id="1" orientation="Portrait" width="850" height="1100" />
      <margins left="39" right="39" top="39" bottom="39" />
      <header alignment="Center" color="#a9a9a9">&amp;[DATE] &amp;[TIME] - &amp;[FILENAME]</header>
      <footer alignment="Center" color="#a9a9a9">&amp;[PAGENUM] / &amp;[COUNT]</footer>
      <backgrounds />
    </pageModel>
    <dependences>
      <assembly name="SMath Studio Desktop" version="0.97.5154.6193" guid="a37cba83-b69c-4c71-9992-55ff666763bd" />
      <assembly name="Text Region" version="1.10.5154.6555" guid="485d28c5-349a-48b6-93be-12a35a1c1e39" />
      <assembly name="Math Region" version="0.97.5154.6193" guid="02f1ab51-215b-466e-a74d-5d8b1cf85e8d" />
      <assembly name="Special Functions" version="1.11.5154.6552" guid="2814e667-4e12-48b1-8d51-194e480eabc5" />
      <assembly name="Modeller Region" version="1.0.5147.447" guid="d5139464-68f1-4c95-bb0a-66f7ac41f86c" />
    </dependences>
  </settings>
  <region id="0" left="0" top="9" width="768" height="40" border="true" color="#000000" bgColor="#b9ffb9" fontSize="10">
    <text lang="eng">
      <p>This example shows how it is possible to handle Shapes as containers for others. Which means possibility to add Shapes on another Shapes to support one Shapes dependence from others.</p>
    </text>
  </region>
  <region id="1" top="54" color="#000000" bgColor="#ffffff">
    <area collapsed="false">
      <title lang="eng">
        <p>Objects</p>
      </title>
    </area>
    <region id="2" left="9" top="72" width="471" height="57" color="#000000" bgColor="#ffffff" fontSize="10">
      <math>
        <description active="true" position="Right" lang="eng">
          <p>Template of Rectangle Shape.</p>
        </description>
        <input>
          <e type="operand">rect</e>
          <e type="operand" style="string">Rectangle</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operand">0</e>
          <e type="operand">2</e>
          <e type="operand">5</e>
          <e type="function" preserve="true" args="12">mat</e>
          <e type="function" preserve="true" args="1">transpose</e>
          <e type="operand" style="string">Black</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="operand">3</e>
          <e type="function" preserve="true" args="5">mat</e>
          <e type="operand">1</e>
          <e type="operand">60</e>
          <e type="operand">60</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">mat</e>
          <e type="operand">30</e>
          <e type="operand">30</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">mat</e>
          <e type="operand">0</e>
          <e type="operand">3</e>
          <e type="operand">1</e>
          <e type="operand">7</e>
          <e type="function" preserve="true" args="9">mat</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region id="3" left="783" top="72" width="799" height="120" border="true" color="#000000" bgColor="#b9ffb9" fontSize="10">
      <text lang="eng">
        <p>Important note: the last argument (arg #7) determins container template supported by current                                 Shape template. I.e. Modeller's palette will show button for current Shape                                 only if required container is focused. Value of this argument must be equal to                                 the # of Shape templates in templates variable for Modeller.So, button for "Rectangle" Shape will be shown on Modeller's palette only if "id" argument of"predifined()" function will be equal to "3" (see description of "id" for "predefined()" below).</p>
      </text>
    </region>
    <region id="4" left="9" top="126" width="412" height="104" color="#000000" bgColor="#ffffff" fontSize="10">
      <math>
        <description active="true" position="Right" lang="eng">
          <p>Template of  Arrow Shape.</p>
        </description>
        <input>
          <e type="operand">arrow</e>
          <e type="operand" style="string">Arrow</e>
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">2</e>
          <e type="operand">2</e>
          <e type="function" preserve="true" args="6">mat</e>
          <e type="operand" style="string">Black</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operator" args="1">-</e>
          <e type="operand">0.5</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operand">0.5</e>
          <e type="operand">3</e>
          <e type="operand">2</e>
          <e type="function" preserve="true" args="8">mat</e>
          <e type="operand" style="string">Brown</e>
          <e type="operand">2</e>
          <e type="operand">2</e>
          <e type="operand">3</e>
          <e type="function" preserve="true" args="8">mat</e>
          <e type="operand">1</e>
          <e type="operand">20</e>
          <e type="operand">40</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">mat</e>
          <e type="operand">10</e>
          <e type="operand">40</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">mat</e>
          <e type="operand">0</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="operand">7</e>
          <e type="function" preserve="true" args="9">mat</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region id="5" top="225" color="#000000" bgColor="#ffffff">
      <area terminator="true" />
    </region>
  </region>
  <region id="6" top="234" color="#000000" bgColor="#ffffff">
    <area collapsed="false">
      <title lang="eng">
        <p>Settings</p>
      </title>
    </area>
    <region id="7" left="9" top="252" width="155" height="44" color="#000000" bgColor="#ffffff" fontSize="10">
      <math>
        <description active="true" position="Right" lang="eng">
          <p>List of templates supportedby Modeller.</p>
        </description>
        <input>
          <e type="operand">templates</e>
          <e type="operand">rect</e>
          <e type="operand">arrow</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">sys</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region id="8" left="387" top="261" width="127" height="26" color="#000000" bgColor="#ffffff" fontSize="10">
      <math>
        <description active="true" position="Right" lang="eng">
          <p>Scale of the Modeller.</p>
        </description>
        <input>
          <e type="operand">layout</e>
          <e type="operand">0</e>
          <e type="operand">100</e>
          <e type="operand">1</e>
          <e type="operand">2</e>
          <e type="function" preserve="true" args="4">mat</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region id="9" left="9" top="306" width="569" height="226" color="#000000" bgColor="#ffffff" fontSize="10">
      <math>
        <description active="true" position="Top" lang="eng">
          <p>Function to provide logic for Modeller before output variable composing. Every argument value can be changed within function to affect Modeller's logic.objs    - Matrix of drawn shapes. It will be returned as output variable of Modeller. Change it to                   control Shapes drawn on the canvas.ratio - Zoom ratio of Modeller canvas.x           - X position of the canvas.y           - Y position of the canvas.id        - If positive: id of the Shape to be used as container and current context                  (every next added Shape become a child of container).                  If negative: value means template # to be used as current context                  (to limit tempates shown on pallette at right).Returns - list of predefined static (with no possibility to interact) Shapes to be drawn on canvas.</p>
        </description>
        <input>
          <e type="operand">objs</e>
          <e type="operand">ratio</e>
          <e type="operand">x</e>
          <e type="operand">y</e>
          <e type="operand">id</e>
          <e type="function" args="5">predefined</e>
          <e type="operand">objs</e>
          <e type="operand">0</e>
          <e type="operator" args="2">≠</e>
          <e type="operand">selected</e>
          <e type="operand">objs</e>
          <e type="operand">1</e>
          <e type="operand">6</e>
          <e type="function" preserve="true" args="3">findrows</e>
          <e type="operator" args="2">:</e>
          <e type="operand">selected</e>
          <e type="operand">0</e>
          <e type="operator" args="2">≠</e>
          <e type="operand">selected</e>
          <e type="operand">1</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="3">el</e>
          <e type="operand">1</e>
          <e type="operator" args="2">≡</e>
          <e type="operand">id</e>
          <e type="operand">selected</e>
          <e type="operand">1</e>
          <e type="operand">8</e>
          <e type="function" preserve="true" args="3">el</e>
          <e type="operator" args="2">:</e>
          <e type="operand">0</e>
          <e type="function" preserve="true" args="3">if</e>
          <e type="operand">id</e>
          <e type="operand">3</e>
          <e type="operator" args="1">-</e>
          <e type="operator" args="2">:</e>
          <e type="function" preserve="true" args="3">if</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">line</e>
          <e type="operand">id</e>
          <e type="operand">3</e>
          <e type="operator" args="1">-</e>
          <e type="operator" args="2">:</e>
          <e type="function" preserve="true" args="3">if</e>
          <e type="operand">0</e>
          <e type="operand">2</e>
          <e type="operand">1</e>
          <e type="function" preserve="true" args="4">line</e>
          <e type="operator" args="2">:</e>
        </input>
      </math>
    </region>
    <region id="10" left="783" top="531" width="802" height="216" border="true" color="#000000" bgColor="#b9ffb9" fontSize="10">
      <text lang="eng">
        <p>if objs≠0                                                - no need to do anything if no Shapes drawn  | selected:=findrows(objs;1;6)   - searching for currently focused Shape  | if selected≠0                                  - ensures at least one Shape is focused  |   | if selected 1 1 = 1                - checks if current type of the Shape is "Rectangle"  |   |    id:=selected 1 8                   - sets "id" of currently selected Shape to make it a container  |   | else  |   |    0                                                  - otherwise leave "id" as is  | else  |    id:=-3                                              - if no Shape focused sets context to container # supported by else                                                               "Rectangle" Shape (see last argument of "Rectengle" Template)   id:=-3                                                    - if no Shapes drawn palette should show only "Rectangle" Shape                                                                        (see also comment for previous line)0                                                                  - no need to draw any static predefined Shape</p>
      </text>
    </region>
    <region id="11" top="747" color="#000000" bgColor="#ffffff">
      <area terminator="true" />
    </region>
  </region>
  <region id="12" left="9" top="765" width="751" height="209" color="#000000" bgColor="#ffffff" fontSize="10">
    <modeller templates="templates" predifinedLayout="predefined" factor="1">
      <shapes />
      <description active="true" position="Top" lang="eng">
        <p>Modeller Region with canvas to draw Shapes on  and palette to add new Shapes from.</p>
      </description>
      <input>
        <e type="operand">output</e>
      </input>
    </modeller>
  </region>
  <region id="13" left="783" top="792" width="94" height="24" color="#000000" bgColor="#ffffff" fontSize="10">
    <math>
      <input>
        <e type="operand">output</e>
      </input>
      <result action="numeric">
        <e type="operand">0</e>
      </result>
    </math>
  </region>
</regions>