Location: PHPKode > projects > Modular Railroad Asset/Meeting Mgmt > fredl-2-1-9-Release/module/modulecalc.php
<?php
    require_once('../php/fredlSession.php');
    /****************************************************************
     * FREMO Asset Management
     * Module: modulecalc.php
     * Description: Calculate module graphic parameters
     *
     * Created: 12/2004, Dirk Jahnke
     *
     * $Log: modulecalc.php,v $
     * Revision 1.1  2005/01/20 21:53:43  dirkj
     * Draft version, not stable yet.
     *
     ****************************************************************/
	require_once '../php/sessionhelpers.inc.php';
	$usrObj=getUserObject();
	require_once '../php/uihelpers.inc.php';
	require_once '../php/apphelpers.inc.php';

	print "<html>";
	print "<head>";
	print '<link rel="stylesheet" type="text/css" href="../'.$myStyleSheet.'">';
?>
<script type="text/javascript">
<!--
   function makeVisible(divName)
   {
	   document.getElementsByName("Standard-Gerade").style.visibility = 'none';
	   document.getElementsByName("Standard-Bogen").style.visibility = 'none';
	   document.getElementsByName("Modulvermessung").style.visibility = 'none';
	   document.getElementsByName(divName).style.visibility = 'visible';
   }

   function createStdGerade()
   {
      var length = Number(document.getElementsByName("stdlength")[0].value);
      var width = Number(document.getElementsByName("stdwidth")[0].value);
      document.getElementsByName("newNumconnections")[0].value = 2;
      document.getElementsByName("newC1x")[0].value = 0;
      document.getElementsByName("newC1y")[0].value = 0;
      document.getElementsByName("newC1angle")[0].value = 0;
      document.getElementsByName("newC2x")[0].value = length; 
      document.getElementsByName("newC2y")[0].value = 0;
      document.getElementsByName("newC2angle")[0].value = 180;
      /* create svg sequence */
      document.getElementsByName("svgcopy")[0].value = 
           '<rext x="0" y="-' 
           + width/2 
           + '" height=' 
           + width 
           + '" width="' 
           + length 
           + '" stroke="black" fill="red" />\n'
           + '<line x1="0" y1="0" x2="'
           + length
           + '" y2="0" stroke="black" stroke-width="3" />\n';
   }

   function createStdBogen()
   {
      var radius = Number(document.getElementsByName("stdradius")[0].value);
      var angle = Number(document.getElementsByName("stdangle")[0].value);
      var width=Number(document.getElementsByName("stdwidth")[1].value);
      var width2=width/2.0;
      var anglerad=angle*Math.PI/180.0;
      var anglerad2=anglerad/2.0;
      var shortside=2.0*(radius-width2)*Math.sin(anglerad2);
      var longside=2.0*(radius+width2)*Math.sin(anglerad2);
      var midside=2.0*radius*Math.sin(anglerad2);
      // var trackendx=radius*Math.tan(anglerad);
      // var trackendy=2.0*radius*Math.sin(anglerad2)*Math.tan(anglerad);
      var trackendx = midside * Math.cos(anglerad2);
      var trackendy = midside * Math.sin(anglerad2);

      document.getElementsByName("newNumconnections")[0].value = 2;
      document.getElementsByName("newC1x")[0].value = 0;
      document.getElementsByName("newC1y")[0].value = 0;
      document.getElementsByName("newC1angle")[0].value = 0;
      document.getElementsByName("newC2x")[0].value = trackendx;
      document.getElementsByName("newC2y")[0].value = trackendy;
      document.getElementsByName("newC2angle")[0].value = angle+180;

      /* create svg sequence */
      var p1x=0, p1y=width2;
      var p2x=shortside*Math.cos(anglerad2), p2y=p1y+shortside*Math.sin(anglerad2);
      var p4x=0, p4y=-width2;
      var p3x=longside*Math.cos(anglerad2), p3y=p4y+longside*Math.sin(anglerad2);

      document.getElementsByName("svgcopy")[0].value = 
           '<path d="M'+p1x+','+p1y+'\n\tL'+p2x+','+p2y+'\n\tL'+p3x+','+p3y+'\n\tL'+p4x+','+p4y+' Z"\n\t'
           + 'fill="grey" stroke="black" stroke-width="1" />\n'
           + '<path d="M0,0 Q'+radius*Math.tan(anglerad2)+',0\n\t'
           +  trackendx+','+trackendy+'"\n\t'
           + ' stroke="black" fill="none" stroke-width="9" />\n'
           ;
   }

//-->
</script>
<title>Modul-Rechner</title>
</head>
<!-- ************************************* BODY ********************************* -->
<body class=right>
<p>
<select name="calctype" size="1">
<option onSelect="javascript:makeVisible('Standard-Gerade')">Standard-Gerade</option>
<option>Standard-Bogen</option>
<option>Modulvermessung</option>
</select>
<hr></p>
<p>

<!-- *********************** Standard-Gerade *************************** -->
<div name="Standard-Gerade">
<table>
	<tr bgcolor="#aa8866">
		<td><table>
			<tr><td>Standard-Gerade</td></tr>
			<tr><td><label>Länge: </label></td><td><input type="Text" name="stdlength" size="10" value="0" ></input></td></tr>
			<tr><td><label>Breite: </label></td><td><input type="Text" name="stdwidth" size="10" value="0" ></input></td></tr>
			<tr><td><input type="Button" value="Erzeugen" onClick="javascript:createStdGerade()"></td></tr>
		</table></td>
	</tr>
</table>
</div>

<!-- *********************** Standard-Bogen *************************** -->
<div name="Standard-Bogen">
<table>
	<tr bgcolor="#aa8866">
		<td><table>
			<tr><td>Standard-Bogen</td></tr>
			<tr><td><label>Radius: </label></td><td><input type="Text" name="stdradius" size=10 value="0" /></td></tr>
			<tr><td><label>Winkel: </label></td><td><input type="Text" name="stdangle" size=10 value="0" /></td></tr>
			<tr><td><label>Breite: </label></td><td><input type="Text" name="stdwidth" size="10" value="0" ></input></td></tr>
			<tr><td><input type="Button" value="Erzeugen" onClick="javascript:createStdBogen()"></td></tr>
		</table></td>
	</tr>
</table>
</div>

<!-- *********************** Modulvermessung *************************** -->
<div name="Modulvermessung">
</div>

<!-- *********************** SVGOutput *************************** -->
<hr>
<div name="SVGOutput">
	<table bgcolor="#dddddd">
		<tr>
			<td><label>Anzahl Anschlüsse: </label></td>
			<td><input type="Text" name="newNumconnections" size="20" maxlength="20"></td>
		</tr>
		<tr>
			<td><b>Anschluß 1:</b></td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><label>X: </label></td>
			<td><input type="Text" name="newC1x" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Y: </label></td>
			<td><input type="Text" name="newC1y" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Winkel: </label></td>
			<td><input type="Text" name="newC1angle" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><b>Anschluß 2:</b></td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><label>X: </label></td>
			<td><input type="Text" name="newC2x" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Y: </label></td>
			<td><input type="Text" name="newC2y" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Winkel: </label></td>
			<td><input type="Text" name="newC2angle" size="5" maxlength="5" ></td>
		</tr>
		<!-- Anschluß 3 und 4 werden derzeit nicht verwendet
		<tr>
			<td><b>Anschluß 3:</b></td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><label>X: </label></td>
			<td><input type="Text" name="newC3x" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Y: </label></td>
			<td><input type="Text" name="newC3y" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Winkel: </label></td>
			<td><input type="Text" name="newC3angle" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><b>Anschluß 4:</b></td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><label>X: </label></td>
			<td><input type="Text" name="newC4x" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Y: </label></td>
			<td><input type="Text" name="newC4y" size="5" maxlength="5" ></td>
		</tr>
		<tr>
			<td><label>Winkel: </label></td>
			<td><input type="Text" name="newC4angle" size="5" maxlength="5" ></td>
		</tr>
		-->
	</table>
<p>
SVG-Vorlage:<br>
<textarea cols="80" rows="15" name="svgcopy" readonly></textarea>
</p>
</div>


</p>

</body>
</html>

Return current item: Modular Railroad Asset/Meeting Mgmt