<?xml version="1.0" encoding="UTF-8"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<!-- Рабочая область конструктора -->
	<image name="CBaseMCImage">
		<script>
			this.bDrag=false;
			this.iMMovedDelay=1;
			this.iMMovedCount=0;
			this.myPlugin=null;
			dragPoint = new Position3D();
		</script>
		<script event="onPress">
			this.bDrag=true;
			dragPoint.x = scene.xMouse;
			dragPoint.y = scene.yMouse;
			this.myPlugin.parent.rotation = new Rotation3D(0,0,1,0);
			this.call("ST_DOWN", this.xMouse+":"+this.yMouse);
			if( typeof(scene.tools) != "undefined")
			{
				this.call("selectedatom", scene.tools.selected_id);
			}
		</script>
		<script event="onRelease">
			handleOnRelease();
		</script>
		<script event="onReleaseOutside">
			handleOnRelease();
		</script>

		<script event="onMouseMove"><![CDATA[
			if( this.bDrag)
			{
				dx = scene.xMouse - dragPoint.x;
				dy = scene.yMouse - dragPoint.y;

				var nr = new Rotation3D(0,0,1,dx);
				var ny = new Rotation3D(1,0,0,dy);
				nr.mult(ny);
				nr.mult(myPlugin.parent.rotation);
				this.myPlugin.parent.rotation = nr.clone();

				dragPoint.x = scene.xMouse;
				dragPoint.y = scene.yMouse;
			}
			this.iMMovedCount=this.iMMovedCount+1;
			if( this.iMMovedCount == this.iMMovedDelay)
			{
				this.iMMovedCount=0;
			}
			else
			{
				exit();
			}
			if((this.xMouse>0 && this.xMouse<this.width &&
				this.yMouse>0 && this.yMouse<this.height) || this.bDrag)
			{
				this.call("ST_MOVED", this.xMouse+":"+this.yMouse);
			}

		]]></script>
		<script>
			function handleOnRelease()
			{
				if(this.bDrag)
				{
					this.call("ST_UP", this.xMouse+":"+this.yMouse);
				}
				this.bDrag=false;
			}

			function call( message, params)
			{
				if( this.myPlugin != null)
					this.myPlugin.call("", ""+message, ""+params);
			}
		</script>
  	</image>

	<scene3d _name="CAtomScene">
		<light src="eval(KMRESPATH+'lights.xml')"/>
		<camera src="eval(KMRESPATH+'camera.xml')" _name="main_camera"/>
		<object _name="molconst">
			<script>
				this.clouds = eval('\"' + KMRESPATH + '\"');
				this.clouds = this.clouds;
			</script>
			<plugin name="dll" src="eval(KMRESPATH+'molconst.dll')" uid="mmlabMolconstPlugin"/>

			<!-- Обработка ошибок -->
			<script><![CDATA[
				function callExternalHandle(s,p)
				{
					trace("##### callExternalHandle("+s+","+p+")");
					if( typeof(scene.tools)!="undefined" && typeof(scene.tools.handleKMMessage) == "function")
					{
						scene.tools.handleKMMessage( s, p);
					}
				}

				function selectlink(param)
				{
					this.callExternalHandle("selectlink", param);
				}

				function delroot()
				{
					this.callExternalHandle("delroot", "");
				}

				function selectcharge(param)
				{
					this.callExternalHandle("selectcharge", param);
				}

				function noselected()
				{
					this.callExternalHandle("noselected", "");
				}

				function nocycle(param)
				{
					this.callExternalHandle("nocycle", param);
				}

				function showwarning(param)
				{
					this.callExternalHandle("showwarning", param);
				}

				function onWarning(param)
				{
					this.callExternalHandle("showwarning", param);
				}
			]]></script>
		</object>
	</scene3d>
</rmml>