Przeglądaj źródła

解决墙面移动Symbol不跟着移动问题

zhibin 6 lat temu
rodzic
commit
f52e65c8c6

Plik diff jest za duży
+ 1295 - 870
css/wanaplan.min.css


+ 9 - 538
index.html

@@ -1,107 +1,19 @@
 <!DOCTYPE html>
 <html lang="fr">
-
 <head>
 	<meta charset="utf-8" />
 	<title>四维时代-家具平台</title>
 	<meta http-equiv="content-type" content="text/html; charset=UTF8" />
 	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
 	<link rel="stylesheet" href="css/wanaplan.min.css" />
-
-	<style>
-		.notFound {                
-    		text-align:center;                
-    		font-size:18px;                
-    		width:100%;                
-    		margin-top:100px;                
-    		margin-left: 50px;            
-    		}            
-    	div.planItem {                
-    		cursor : pointer;                
-    		background:#fafafa;                
-    		margin:10px;                
-    		border:1px solid #CCC;                
-    		position: relative;            
-    		}            
-    	div.planItem img {               
-    		 width:288px            
-    		 }            
-    	div.planItem p {                
-    		border-top:1px solid #CCC;                
-    		padding: 5px;                
-    		margin: 0px;                
-    		color: #333;                
-    		background: #FFF;            
-    		}            
-    	div.planItem div.toolbarPlan {                
-    		display: none;                
-    		background: #CCC;                
-    		position: absolute;                
-    		right: 0px;                
-    		top: 0px;                
-    		color: #222;                
-    		opacity: 0.9;                
-    		z-index: 9999;            
-    		}             
-    	div.planItem div.toolbarPlan .fa {                
-    		padding: 5px;            
-    	  }            
-    	div.planItem div.toolbarPlan .fa-times {                
-    		padding-left: 15px;            
-    		}            
-    	div.planItem:hover div.toolbarPlan {                
-    		display: block;            
-    		}            
-    	div.planItem div.overall{                
-    		background: #222;                
-    		opacity: 0.8;                
-    		width:100%;                
-    		height:100%;                
-    		color:#FFF;                
-    		top: 0px;                
-    		position:absolute;                
-    		text-align:center;                
-    		vertical-align:middle;            
-    		}            
-    	div.planItem div.editForm{                
-    		width:100%;                
-    		height:100%;                
-    		color:#FFF;                
-    		top: 60px;                
-    		position:absolute;                
-    		text-align:center;                
-    		vertical-align:middle;            
-    		}            
-    	div.planItem .editPlanInput{                
-    		height:30px;                
-    		width:90%;                
-    		font-size: 15px;                
-    		border: 1px solid #999;            
-    		}            
-    	div.planItem div.overall span{                
-    		font-size:16px;            
-    		}            
-    	div.planItem .overall-cercle{                
-    		opacity: 1;                
-    		padding-left: 0;                
-    		padding-right: 0;                
-    		margin-left: auto;               
-    		margin-right: auto;                
-    		bottom: 25px;                
-    		width:100%;                
-    		position:absolute;            
-    		}            
-    	div.planItem div.editForm .window-action-bar{                
-    		margin-top:10px;                
-    		text-align: right;            
-    		}        
-    		</style>
 </head>
-
 <body>
+
 	<img src='images/pattern.png' style='display:none' id='imgWall' />
 	<img src='images/pattern_tmp.png' style='display:none' id='imgTempWall' />
 	<img src='images/grid2.jpg' style='display:none' id='img' />
+
+
 	<div id="subMenuContainer">
 		<div id="subMenu">
 			<ul id="subMenuList">
@@ -118,6 +30,8 @@
 			</ul>
 		</div>
 	</div>
+
+
 	<section id="main-ui" class="show">
 		<div id="toolbar">
 			<div id="toolbar-bar">
@@ -164,6 +78,8 @@
 			</div>
 		</section>
 	</section>
+
+	
 	<!-- Splashscreen -->
 	<div style="display: none;" id="splashscreen">
 		<div id="custom-splash" style="display:none" class="splash-text">
@@ -692,453 +608,8 @@
 
 
 	<!--<script src="js/wanaplan.min.js"></script>-->
-	<script src="libs/CanvasSketch.js"></script>
-	<script type="text/javascript">
-
-		var TESTREFRESH = 0;
-
-		//var circleStyle = {fillColor:"blue", fill:true, stroke:true, fillOpacity:1, strokeOpacity:1};
-		var div = document.getElementById("container2d");
-		var width = window.outerWidth - 260;
-		var height = window.outerHeight;
-		var stepx = 50;
-		var stepy = 50;
-		var backgroundSize = 50;
-		var startx = -stepx * backgroundSize;
-		//var starty=-parseInt(stepy*backgroundSize*height/width);
-		var starty = -stepx * backgroundSize;
-		var MixZoom = 20;
-
-		var MixMark = -1;
-		var MaxMark = 139;
-		var startMarkX = -width / 2 + 150;
-		var startMarkY = -height / 2 + 150;
-
-
-		var wallleftX = -500;
-		var wallleftY = 400;
-		var wallrightX = 500;
-		var wallrightY = -400;
-
-		var wallThickness = 30;
-		var partitionThickness = 15;
-
-		var door = 80;
-		var window = 50;
-
-		var meter = width / 20;
-		var meterpositionX = 100;
-
-		var redrawCount = 0;
-		var backgroundcanvasMax = 5000;
-		var Sector_r = 70;
-		var slid_r = 10;
-		var point_r = 5;
-
-		var sysmbolCircleR = 10;
-		var symbolMinLen = 10;
-		var show3D = false;
-		var three3D;
-		var center;
-		var my3DEngine = null;
-
-		var wallId = null;
-		var Overlay;
-		var vectors = [];
-		var layer;
-
-		var initMesh = 0;
-		var one2d = false;
-		var one3d = false;
-
-		var TESTCOUNT = 0;
-
-		function init() {
-			layer = new Layer(width, height);
-			layer.renderer.drawBackGround();
-
-			wallThickness = layer.parameter.wallThickness;
-			partitionThickness = layer.parameter.partitionThickness;
-
-			door = 80;
-			window = 50;
-
-
-			addWall();
-			//layer.addSymbol2D.wallIds.push(wallId);
-			if (!one2d) {
-				//initRoom();
-				one2d = true;
-			}
-
-			initLoad();
-		}
-		init();
-
-		window.requestAnimationFrame || (window.requestAnimationFrame = function () {
-			return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a) {
-				window.setTimeout(a, 1e3 / 60);
-			};
-		}());
-		window.cancelRequestAnimationFrame || (window.cancelRequestAnimationFrame = function () {
-			return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame || window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || clearTimeout
-		}());
-
-
-		//document.getElementById("closeproduct").addEventListener("click",layer.menu.closeProduct);
-		window.onresize = function () {
-			width = window.outerWidth - 260;
-			height = window.outerHeight;
-			startMarkX = -width / 2 + 50;
-			startMarkY = -height / 2 + 50;
-
-			layer.size = new CanvasSketch.Size(parseInt(width), parseInt(height));
-			//layer.renderer.setSize(layer.size);
-			layer.maxBounds = new CanvasSketch.Bounds(-layer.size.w / 2, -layer.size.h / 2, layer.size.w / 2, layer.size.h / 2);
-			layer.bounds = new CanvasSketch.Bounds(-layer.size.w / 2, -layer.size.h / 2, layer.size.w / 2, layer.size.h / 2);
-			//layer.renderer.redraw(0);
-			//layer.renderer.drawBackGround();
-			layer.control.refreshCanvas = true;
-			layer.control.refreshBackgroundCanvas = true;
-			layer.control.refreshSelectCanvas = true;
-			layer.renderer.autoRedraw();
-		};
-
-		document.getElementById("aboutWindow").addEventListener("click", function (e) {
-			//console.log("aboutWindow");
-			if (document.getElementById("aboutWindow").style.display == "block") {
-				if (e.target.className == "window-close" || e.target.innerText == "关闭") {
-					document.getElementById("aboutWindow").style.display = "none";
-				}
-			}
-
-		});
-
-
-
-		document.getElementById("subMenuContainer").addEventListener("click", function (e) {
-			if (e.target.parentElement.parentElement.id == "toolbarScreenshot") {
-				var saveAsLocalImage = function (canvasid, type) {
-					var canvas = document.getElementById(canvasid);
-					// 图片导出为 png 格式
-					var type = 'png';
-					var imgData = canvas.toDataURL(type);
-
-					// 加工image data,替换mime type
-					imgData = imgData.replace(_fixType(type), 'image/octet-stream');
-					// 下载后的图片名
-					var filename = '4dage_' + (new Date()).getTime() + '.' + type;
-					// download
-					saveFile(imgData, filename);
-				};
-
-				/**
-				 * 获取mimeType
-				 * @param  {String} type the old mime-type
-				 * @return the new mime-type
-				 */
-				var _fixType = function (type) {
-					type = type.toLowerCase().replace(/jpg/i, 'jpeg');
-					var r = type.match(/png|jpeg|bmp|gif/)[0];
-					return 'image/' + r;
-				};
-
-				/**
-				 * 在本地进行文件保存
-				 * @param  {String} data     要保存到本地的图片数据
-				 * @param  {String} filename 文件名
-				 */
-				var saveFile = function (data, filename) {
-					var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
-					save_link.href = data;
-					save_link.download = filename;
-
-					var event = document.createEvent('MouseEvents');
-					event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
-					save_link.dispatchEvent(event);
-				};
-				if (show3D) {
-					BABYLON.Tools.CreateScreenshot(my3DEngine.scene3D.engine, my3DEngine.scene3D.camera, { width: my3DEngine.scene3D.canvas.width, height: my3DEngine.scene3D.canvas.height });
-				}
-				else {
-					saveAsLocalImage("dynamiccanvas2d", "png");
-				}
-			}
-			else if (e.target.parentElement.parentElement.id == "fullscreen-btn") {
-				var element = document.documentElement;
-				var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
-
-				if (requestMethod) {
-					requestMethod.call(element);
-				}
-				else if (typeof window.ActiveXObject !== "undefined") {
-					var wscript = new ActiveXObject("WScript.Shell");
-					if (wscript !== null) {
-						wscript.SendKeys("{F11}");
-					}
-				}
-			}
-			else if (e.target.parentElement.parentElement.id == "transparencyButton") {
-				//alert("透明");
-				if (e.target.src.indexOf("icon-transparency.png") > -1) {
-					/*
-					for(var i=0;i<my3DEngine.decorate3D.roomWallMeshes.length;++i)
-					{
-						if(my3DEngine.decorate3D.roomWallMeshes[i].name=="wall"||my3DEngine.decorate3D.roomWallMeshes[i].name=="walltop")   
-						{
-							my3DEngine.decorate3D.roomWallMeshes[i].visibility=0.1;
-						}
-					}
-					*/
-					my3DEngine.decorate3D.transparentWall(0.05);
-					e.target.src = e.target.src.replace("icon-transparency.png", "icon-opacity.png");
-				}
-				else if (e.target.src.indexOf("icon-opacity.png") > -1) {
-					/*
-					for(var i=0;i<my3DEngine.decorate3D.roomWallMeshes.length;++i)
-					{
-						if(my3DEngine.decorate3D.roomWallMeshes[i].name=="wall"||my3DEngine.decorate3D.roomWallMeshes[i].name=="walltop")
-						{
-							my3DEngine.decorate3D.roomWallMeshes[i].visibility=1;
-						}
-					}
-					*/
-					my3DEngine.decorate3D.transparentWall(1);
-					e.target.src = e.target.src.replace("icon-opacity.png", "icon-transparency.png");
-				}
-
-			}
-			else if (e.target.parentElement.parentElement.id == "lock-icon") {
-				//alert("锁");
-				if (e.target.className == "fa fa-unlock") {
-					my3DEngine.action3D.lock = true;
-					e.target.className = "fa fa-lock";
-				}
-				else if (e.target.className == "fa fa-lock") {
-					my3DEngine.action3D.lock = false;
-					e.target.className = "fa fa-unlock";
-				}
-			}
-		});
-		// Grid..........................................................
-
-		function initLoad() {
-			var div = document.getElementById("loaddiv");
-			var img = document.getElementById("loadimg");
-
-			var width = window.innerWidth;
-			var height = window.innerHeight;
-
-			var imgwidth = img.width;
-			var imgheight = img.height;
-
-			var ptwidth = (width - imgwidth) / 2 + "px";
-			var ptheight = (height - imgheight) / 2 + "px";
-
-			div.style.width = width + "px";
-			div.style.height = height + "px";
-			div.width = width;
-			div.height = height;
-
-			img.style.marginLeft = ptwidth;
-			img.style.marginTop = ptheight;
-		}
-
-		function showPicture() {
-			if (my3DEngine == null) {
-				my3DEngine = layer.layer3D;
-				my3DEngine.initialize();
-			}
-			var src = this.id.replace("product", "") + ".babylon";
-			layer.menu.closeProduct();
-			my3DEngine.modelLoader.showPicture(src);
-		}
-
-		function showPhoFrame() {
-			if (my3DEngine == null) {
-				my3DEngine = layer.layer3D;
-				my3DEngine.initialize();
-			}
-			var src = this.id.replace("product", "") + ".obj";
-			layer.menu.closeProduct();
-			my3DEngine.modelLoader.showPhoFrame(src);
-		}
-
-		function showProduct3D() {
-			if (my3DEngine == null) {
-				my3DEngine = new Symbol3D();
-				my3DEngine.initialize();
-			}
-			var src;
-			var src = this.id.replace("product", "") + ".babylon";
-			layer.menu.closeProduct();
-			my3DEngine.modelLoader.showProduct(src);
-		}
-
-		function drawGrid(stepx, stepy) {
-			layer.renderer.addGrid();
-		}
-
-		function addWall() {
-			var vectors = [];
-			var points = [];
-			var point1 = new Point(wallleftX, wallleftY);
-			points.push(point1);
-
-			var point2 = new Point(wallrightX, wallleftY);
-			points.push(point2);
-
-			var point3 = new Point(wallrightX, wallrightY);
-			points.push(point3);
-
-			var point4 = new Point(wallleftX, wallrightY);
-			points.push(point4);
-
-
-			var wall = new Wall(points, document.getElementById("imgWall"));
-			var vector = new Vector(wall, wallStyle);
-
-			wallId = vector.id;
-			layer.data2d.wallIds.push(wallId);
-			vectors.push(vector);
-			layer.addVectors(vectors);
-
-
-		}
-
-		function Show3DBase() {
-			if (!show3D) {
-				if (my3DEngine == null) {
-					my3DEngine = layer.layer3D;
-					my3DEngine.initialize();
-				}
-
-				//my3DEngine.clearSymbol();
-				my3DEngine.decorate3D.deleteRoomMeshes();
-				GetWallPoints(layer);
-				if (!one3d) {
-					//initRoom3D();
-					one3d = true;
-				}
-
-				my3DEngine.scene3D.render();
-			}
-			show3D = true;
-		}
-
-		function GetWallPoints(layer) {
-			var wallIds = layer.data2d.wallIds;
-			var calculateLine = layer.calculateLine;
-			for (var i = 0; i < wallIds.length; ++i) {
-				var id = wallIds[i];
-
-				var points = layer.vectors[id].geometry.points;
-
-				var syms = [];
-
-
-				for (var key in layer.vectors[id].symbol2Ds) {
-					var symbol2d = layer.vectors[id].symbol2Ds[key];
-
-					var line = calculateLine.createLine(symbol2d.geometry.point1, symbol2d.geometry.point2);
-					var sym = {};
-
-					if (line.a != 0) {
-						sym.angle = Math.atan(line.a);
-					}
-					else if (line.hasOwnProperty('x')) {
-						sym.angle = Math.PI / 2;
-					}
-					else if (line.hasOwnProperty('y')) {
-						sym.angle = 0;
-					}
-					sym.point = { x: (symbol2d.geometry.point1.x + symbol2d.geometry.point2.x) / 2, y: (symbol2d.geometry.point1.y + symbol2d.geometry.point2.y) / 2 };
-					//sym.type=symbol2d.geoType;
-					sym.id = id;
-					sym.type = symbol2d.geometry.geoType;
-					sym.len = BABYLON.Vector2.Distance(symbol2d.geometry.point1, symbol2d.geometry.point2);
-					sym.index = Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex);
-					syms.push(sym);
-				}
-
-				if (i == 0) {
-					//var inout=calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.border1,layer.vectors[id].geometry.border2);  
-					var inout = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
-					var inline = inout.use;
-					var outline = inout.build;
-					var height = inout.height;
-					//my3DEngine.decorate3D.drawFloor(layer.vectors[id].geometry.points,layer.vectors[id].geometry.floor);
-					my3DEngine.decorate3D.drawFloor(id);
-					my3DEngine.decorate3D.drawCloseWallSymbols(outline, inline, height, syms, layer.vectors[id].geometry.wallType, id, layer.vectors[id].geometry.floor);
-				}
-				else {
-					if (layer.vectors[id].geometry.state == 0) {
-						//var inout=calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.border1,layer.vectors[id].geometry.border2); 
-						var inout = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
-						var inline = inout.use;
-						var outline = inout.build;
-						var height = inout.height;
-						//my3DEngine.decorate3D.drawFloor(layer.vectors[id].geometry.points,layer.vectors[id].geometry.floor);
-						my3DEngine.decorate3D.drawFloor(id);
-
-						if (calculateLine.isClockWise(outline) > 0) {
-							outline.reverse();
-							inline.reverse();
-						}
-						my3DEngine.decorate3D.drawCloseWallSymbols(outline, inline, height, syms, layer.vectors[id].geometry.wallType, id, layer.vectors[id].geometry.floor);
-					}
-					else {
-						var clockpoints = [];
-
-						//var floorpoints=calculateLine.outinwallside(points,layer.vectors[id].geometry.wallType);
-						//var floorpoints=calculateLine.outinwallside(layer.vectors[id].geometry);
-						var floorpoints = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
-						var height = floorpoints.height;
-						if (floorpoints.use.length == 2) {
-							var temp1 = [];
-							var temp2 = [];
-
-							temp1[0] = floorpoints.use[0];
-							temp1[1] = floorpoints.build[0];
-
-							temp2[0] = floorpoints.use[1];
-							temp2[1] = floorpoints.build[1];
-
-							floorpoints.use = temp1;
-							floorpoints.build = temp2;
-
-							clockpoints.push(temp1[0]);
-							clockpoints.push(temp1[1]);
-							clockpoints.push(temp2[1]);
-							clockpoints.push(temp2[0]);
-						}
-						else {
-							//var line1= calculateLine.createLine(floorpoints.side1[0], floorpoints.side1[1]);
-							//var line2= calculateLine.createLine(floorpoints.side1[floorpoints.side1.length-2], floorpoints.side1[floorpoints.side1.length-1]);
-
-							for (var n = 0; n < floorpoints.use.length; ++n) {
-								clockpoints.push(floorpoints.use[n]);
-							}
-							for (var n = floorpoints.build.length - 1; n > -1; --n) {
-								clockpoints.push(floorpoints.build[n]);
-							}
-						}
-
-						if (calculateLine.isClockWise(clockpoints) > 0) {
-							floorpoints.use.reverse();
-							floorpoints.build.reverse();
-							height.reverse();
-						}
-						my3DEngine.decorate3D.drawOpenWallSymbols(floorpoints, height, syms, layer.vectors[id].geometry.wallType, id, layer.vectors[id].geometry.floor);
-
-					}
-
-				}
-			}
-			my3DEngine.decorate3D.hideFloors(parseInt(layer.selectFloor));
-		}
-
-	</script>
+<script src="libs/CanvasSketch.js"></script>
+<script src="./js/index.js"></script>
 </body>
 
 </html>

+ 449 - 0
js/index.js

@@ -0,0 +1,449 @@
+var TESTREFRESH = 0;
+
+//var circleStyle = {fillColor:"blue", fill:true, stroke:true, fillOpacity:1, strokeOpacity:1};
+var div = document.getElementById("container2d");
+var width = window.outerWidth - 260;
+var height = window.outerHeight;
+// 放个均分多少份
+var stepx = 50;
+var stepy = 50;
+var backgroundSize = 50;
+var startx = -stepx * backgroundSize;
+var starty = -stepx * backgroundSize;
+var MixZoom = 20;
+
+var MixMark = -1;
+var MaxMark = 139;
+var startMarkX = -width / 2 + 150;
+var startMarkY = -height / 2 + 150;
+
+
+var wallleftX = -500;
+var wallleftY = 400;
+var wallrightX = 500;
+var wallrightY = -400;
+
+var wallThickness = 30;
+var partitionThickness = 15;
+
+var door = 80;
+var window = 50;
+
+var meter = width / 20;
+var meterpositionX = 100;
+
+var redrawCount = 0;
+// canvas最大正方形宽高
+var backgroundcanvasMax = 5000;
+var Sector_r = 70;
+var slid_r = 10;
+var point_r = 5;
+
+var sysmbolCircleR = 10;
+var symbolMinLen = 10;
+var show3D = false;
+var three3D;
+var center;
+var my3DEngine = null;
+
+var wallId = null;
+var Overlay;
+var vectors = [];
+var layer;
+
+var initMesh = 0;
+var one2d = false;
+var one3d = false;
+
+var TESTCOUNT = 0;
+
+function init() {
+  layer = new Layer(width, height);
+  layer.renderer.drawBackGround();
+
+  wallThickness = layer.parameter.wallThickness;
+  partitionThickness = layer.parameter.partitionThickness;
+
+  door = 80;
+  window = 50;
+
+
+  addWall();
+  //layer.addSymbol2D.wallIds.push(wallId);
+  if (!one2d) {
+    //initRoom();
+    one2d = true;
+  }
+
+  initLoad();
+}
+init();
+
+
+//document.getElementById("closeproduct").addEventListener("click",layer.menu.closeProduct);
+window.onresize = function () {
+  width = window.outerWidth - 260;
+  height = window.outerHeight;
+  startMarkX = -width / 2 + 50;
+  startMarkY = -height / 2 + 50;
+
+  layer.size = new CanvasSketch.Size(parseInt(width), parseInt(height));
+  //layer.renderer.setSize(layer.size);
+  layer.maxBounds = new CanvasSketch.Bounds(-layer.size.w / 2, -layer.size.h / 2, layer.size.w / 2, layer.size.h / 2);
+  layer.bounds = new CanvasSketch.Bounds(-layer.size.w / 2, -layer.size.h / 2, layer.size.w / 2, layer.size.h / 2);
+  //layer.renderer.redraw(0);
+  //layer.renderer.drawBackGround();
+  layer.control.refreshCanvas = true;
+  layer.control.refreshBackgroundCanvas = true;
+  layer.control.refreshSelectCanvas = true;
+  layer.renderer.autoRedraw();
+};
+
+
+// 关于4维弹出框
+document.getElementById("aboutWindow").addEventListener("click", function (e) {
+  //console.log("aboutWindow");
+  if (document.getElementById("aboutWindow").style.display == "block") {
+    if (e.target.className == "window-close" || e.target.innerText == "关闭") {
+      document.getElementById("aboutWindow").style.display = "none";
+    }
+  }
+
+});
+
+
+// 放大跟保存图片
+document.getElementById("subMenuContainer").addEventListener("click", function (e) {
+  if (e.target.parentElement.parentElement.id == "toolbarScreenshot") {
+    var saveAsLocalImage = function (canvasid, type) {
+      var canvas = document.getElementById(canvasid);
+      // 图片导出为 png 格式
+      var type = 'png';
+      var imgData = canvas.toDataURL(type);
+
+      // 加工image data,替换mime type
+      imgData = imgData.replace(_fixType(type), 'image/octet-stream');
+      // 下载后的图片名
+      var filename = '4dage_' + (new Date()).getTime() + '.' + type;
+      // download
+      saveFile(imgData, filename);
+    };
+
+    /**
+     * 获取mimeType
+     * @param  {String} type the old mime-type
+     * @return the new mime-type
+     */
+    var _fixType = function (type) {
+      type = type.toLowerCase().replace(/jpg/i, 'jpeg');
+      var r = type.match(/png|jpeg|bmp|gif/)[0];
+      return 'image/' + r;
+    };
+
+    /**
+     * 在本地进行文件保存
+     * @param  {String} data     要保存到本地的图片数据
+     * @param  {String} filename 文件名
+     */
+    var saveFile = function (data, filename) {
+      var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
+      save_link.href = data;
+      save_link.download = filename;
+
+      var event = document.createEvent('MouseEvents');
+      event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+      save_link.dispatchEvent(event);
+    };
+    if (show3D) {
+      BABYLON.Tools.CreateScreenshot(my3DEngine.scene3D.engine, my3DEngine.scene3D.camera, {
+        width: my3DEngine.scene3D.canvas.width,
+        height: my3DEngine.scene3D.canvas.height
+      });
+    } else {
+      saveAsLocalImage("dynamiccanvas2d", "png");
+    }
+  } else if (e.target.parentElement.parentElement.id == "fullscreen-btn") {
+    var element = document.documentElement;
+    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen ||
+      element.msRequestFullScreen;
+
+    if (requestMethod) {
+      requestMethod.call(element);
+    } else if (typeof window.ActiveXObject !== "undefined") {
+      var wscript = new ActiveXObject("WScript.Shell");
+      if (wscript !== null) {
+        wscript.SendKeys("{F11}");
+      }
+    }
+  } else if (e.target.parentElement.parentElement.id == "transparencyButton") {
+    //alert("透明");
+    if (e.target.src.indexOf("icon-transparency.png") > -1) {
+      /*
+      for(var i=0;i<my3DEngine.decorate3D.roomWallMeshes.length;++i)
+      {
+        if(my3DEngine.decorate3D.roomWallMeshes[i].name=="wall"||my3DEngine.decorate3D.roomWallMeshes[i].name=="walltop")   
+        {
+          my3DEngine.decorate3D.roomWallMeshes[i].visibility=0.1;
+        }
+      }
+      */
+      my3DEngine.decorate3D.transparentWall(0.05);
+      e.target.src = e.target.src.replace("icon-transparency.png", "icon-opacity.png");
+    } else if (e.target.src.indexOf("icon-opacity.png") > -1) {
+      /*
+      for(var i=0;i<my3DEngine.decorate3D.roomWallMeshes.length;++i)
+      {
+        if(my3DEngine.decorate3D.roomWallMeshes[i].name=="wall"||my3DEngine.decorate3D.roomWallMeshes[i].name=="walltop")
+        {
+          my3DEngine.decorate3D.roomWallMeshes[i].visibility=1;
+        }
+      }
+      */
+      my3DEngine.decorate3D.transparentWall(1);
+      e.target.src = e.target.src.replace("icon-opacity.png", "icon-transparency.png");
+    }
+
+  } else if (e.target.parentElement.parentElement.id == "lock-icon") {
+    //alert("锁");
+    if (e.target.className == "fa fa-unlock") {
+      my3DEngine.action3D.lock = true;
+      e.target.className = "fa fa-lock";
+    } else if (e.target.className == "fa fa-lock") {
+      my3DEngine.action3D.lock = false;
+      e.target.className = "fa fa-unlock";
+    }
+  }
+});
+// Grid..........................................................
+
+
+
+// loadding 位置
+function initLoad() {
+  var div = document.getElementById("loaddiv");
+  var img = document.getElementById("loadimg");
+
+  var width = window.innerWidth;
+  var height = window.innerHeight;
+
+  var imgwidth = img.width;
+  var imgheight = img.height;
+
+  var ptwidth = (width - imgwidth) / 2 + "px";
+  var ptheight = (height - imgheight) / 2 + "px";
+
+  div.style.width = width + "px";
+  div.style.height = height + "px";
+  div.width = width;
+  div.height = height;
+
+  img.style.marginLeft = ptwidth;
+  img.style.marginTop = ptheight;
+}
+
+
+// 3D部分选中图片加载模型
+function showPicture() {
+  if (my3DEngine == null) {
+    my3DEngine = layer.layer3D;
+    my3DEngine.initialize();
+  }
+  var src = this.id.replace("product", "") + ".babylon";
+  layer.menu.closeProduct();
+  my3DEngine.modelLoader.showPicture(src);
+}
+
+// 3D部分选中图片加载模型
+function showPhoFrame() {
+  if (my3DEngine == null) {
+    my3DEngine = layer.layer3D;
+    my3DEngine.initialize();
+  }
+  var src = this.id.replace("product", "") + ".obj";
+  layer.menu.closeProduct();
+  my3DEngine.modelLoader.showPhoFrame(src);
+}
+
+// 3D部分选中图片加载模型
+function showProduct3D() {
+  if (my3DEngine == null) {
+    my3DEngine = new Symbol3D();
+    my3DEngine.initialize();
+  }
+  var src;
+  var src = this.id.replace("product", "") + ".babylon";
+  layer.menu.closeProduct();
+  my3DEngine.modelLoader.showProduct(src);
+}
+
+
+// 未知作用
+// function drawGrid(stepx, stepy) {
+//   console.log('???? ---')
+//   layer.renderer.addGrid();
+// }
+
+
+// 一开始添加墙面  默认添加
+function addWall() {
+  var vectors = [];
+  var points = [];
+  var point1 = new Point(wallleftX, wallleftY);
+  points.push(point1);
+
+  var point2 = new Point(wallrightX, wallleftY);
+  points.push(point2);
+
+  var point3 = new Point(wallrightX, wallrightY);
+  points.push(point3);
+
+  var point4 = new Point(wallleftX, wallrightY);
+  points.push(point4);
+
+
+  var wall = new Wall(points, document.getElementById("imgWall"));
+  var vector = new Vector(wall, wallStyle);
+
+  wallId = vector.id;
+  layer.data2d.wallIds.push(wallId);
+  vectors.push(vector);
+  layer.addVectors(vectors);
+
+
+}
+
+// 显示3D  效果  3D效果入口
+function Show3DBase() {
+  if (!show3D) {
+    if (my3DEngine == null) {
+      my3DEngine = layer.layer3D;
+      my3DEngine.initialize();
+    }
+
+    //my3DEngine.clearSymbol();
+    my3DEngine.decorate3D.deleteRoomMeshes();
+    GetWallPoints(layer);
+    if (!one3d) {
+      //initRoom3D();
+      one3d = true;
+    }
+
+    my3DEngine.scene3D.render();
+  }
+  show3D = true;
+}
+
+
+// 获取2维信息以供给3维使用
+function GetWallPoints(layer) {
+  var wallIds = layer.data2d.wallIds;
+  var calculateLine = layer.calculateLine;
+  for (var i = 0; i < wallIds.length; ++i) {
+    var id = wallIds[i];
+
+    var points = layer.vectors[id].geometry.points;
+
+    var syms = [];
+
+
+    for (var key in layer.vectors[id].symbol2Ds) {
+      var symbol2d = layer.vectors[id].symbol2Ds[key];
+
+      var line = calculateLine.createLine(symbol2d.geometry.point1, symbol2d.geometry.point2);
+      var sym = {};
+
+      if (line.a != 0) {
+        sym.angle = Math.atan(line.a);
+      } else if (line.hasOwnProperty('x')) {
+        sym.angle = Math.PI / 2;
+      } else if (line.hasOwnProperty('y')) {
+        sym.angle = 0;
+      }
+      sym.point = {
+        x: (symbol2d.geometry.point1.x + symbol2d.geometry.point2.x) / 2,
+        y: (symbol2d.geometry.point1.y + symbol2d.geometry.point2.y) / 2
+      };
+      //sym.type=symbol2d.geoType;
+      sym.id = id;
+      sym.type = symbol2d.geometry.geoType;
+      sym.len = BABYLON.Vector2.Distance(symbol2d.geometry.point1, symbol2d.geometry.point2);
+      sym.index = Math.min(symbol2d.attributes.wallstartindex, symbol2d.attributes.wallendindex);
+      syms.push(sym);
+    }
+
+    if (i == 0) {
+      //var inout=calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.border1,layer.vectors[id].geometry.border2);  
+      var inout = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
+      var inline = inout.use;
+      var outline = inout.build;
+      var height = inout.height;
+      //my3DEngine.decorate3D.drawFloor(layer.vectors[id].geometry.points,layer.vectors[id].geometry.floor);
+      my3DEngine.decorate3D.drawFloor(id);
+      my3DEngine.decorate3D.drawCloseWallSymbols(outline, inline, height, syms, layer.vectors[id].geometry.wallType, id,
+        layer.vectors[id].geometry.floor);
+    } else {
+      if (layer.vectors[id].geometry.state == 0) {
+        //var inout=calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.border1,layer.vectors[id].geometry.border2); 
+        var inout = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
+        var inline = inout.use;
+        var outline = inout.build;
+        var height = inout.height;
+        //my3DEngine.decorate3D.drawFloor(layer.vectors[id].geometry.points,layer.vectors[id].geometry.floor);
+        my3DEngine.decorate3D.drawFloor(id);
+
+        if (calculateLine.isClockWise(outline) > 0) {
+          outline.reverse();
+          inline.reverse();
+        }
+        my3DEngine.decorate3D.drawCloseWallSymbols(outline, inline, height, syms, layer.vectors[id].geometry.wallType, id,
+          layer.vectors[id].geometry.floor);
+      } else {
+        var clockpoints = [];
+
+        //var floorpoints=calculateLine.outinwallside(points,layer.vectors[id].geometry.wallType);
+        //var floorpoints=calculateLine.outinwallside(layer.vectors[id].geometry);
+        var floorpoints = calculateLine.divisionBuildUseWall(layer.vectors[id].geometry.wallInfo);
+        var height = floorpoints.height;
+        if (floorpoints.use.length == 2) {
+          var temp1 = [];
+          var temp2 = [];
+
+          temp1[0] = floorpoints.use[0];
+          temp1[1] = floorpoints.build[0];
+
+          temp2[0] = floorpoints.use[1];
+          temp2[1] = floorpoints.build[1];
+
+          floorpoints.use = temp1;
+          floorpoints.build = temp2;
+
+          clockpoints.push(temp1[0]);
+          clockpoints.push(temp1[1]);
+          clockpoints.push(temp2[1]);
+          clockpoints.push(temp2[0]);
+        } else {
+          //var line1= calculateLine.createLine(floorpoints.side1[0], floorpoints.side1[1]);
+          //var line2= calculateLine.createLine(floorpoints.side1[floorpoints.side1.length-2], floorpoints.side1[floorpoints.side1.length-1]);
+
+          for (var n = 0; n < floorpoints.use.length; ++n) {
+            clockpoints.push(floorpoints.use[n]);
+          }
+          for (var n = floorpoints.build.length - 1; n > -1; --n) {
+            clockpoints.push(floorpoints.build[n]);
+          }
+        }
+
+        if (calculateLine.isClockWise(clockpoints) > 0) {
+          floorpoints.use.reverse();
+          floorpoints.build.reverse();
+          height.reverse();
+        }
+        my3DEngine.decorate3D.drawOpenWallSymbols(floorpoints, height, syms, layer.vectors[id].geometry.wallType, id,
+          layer.vectors[id].geometry.floor);
+
+      }
+
+    }
+  }
+  my3DEngine.decorate3D.hideFloors(parseInt(layer.selectFloor));
+}

+ 42 - 40
libs/CanvasSketch.js

@@ -1,36 +1,38 @@
-(function() {
+(function () {
 	window.CanvasSketch = {
-		vesion: "1.0.0",		
+		vesion: "1.0.0",
 		author: "xst",
 	};
-	
+
 	var scriptName = "CanvasSketch.js";
-	
-	CanvasSketch.getScriptLocation = (function() {
+
+	CanvasSketch.getScriptLocation = (function () {
 		var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)"),
 			s = document.getElementsByTagName('script'),
 			src, m, l = "";
-		for(var i=0, len=s.length; i<len; i++) {
+		for (var i = 0, len = s.length; i < len; i++) {
 			src = s[i].getAttribute('src');
-			if(src) {
+			if (src) {
 				var m = src.match(r);
-				if(m) {
+				if (m) {
 					l = m[1];
 					break;
 				}
 			}
 		}
-		return (function() { return l; });
+		return (function () {
+			return l;
+		});
 	})();
-	
+
 	var jsFile = [
-        "CanvasSketch_Packer.js",
-        "Renderer/CurrentState.js",
-        "Renderer/PreviousState.js",
-        "Util/util.js",
-        
-	    "Layer/Layer.js",
-		
+		"CanvasSketch_Packer.js",
+		"Renderer/CurrentState.js",
+		"Renderer/PreviousState.js",
+		"Util/util.js",
+
+		"Layer/Layer.js",
+
 		"3D/Scene3D.js",
 		"3D/Material.js",
 		"3D/decorate3D.js",
@@ -41,19 +43,19 @@
 		"3D/engine/babylon.js",
 		"3D/engine/poly2tri.js",
 		"3D/engine/objFileLoader.js",
-		
-	    "Build/Build.js",
-	    
-	    "Calculate/CalculateElement.js",
-	    "Calculate/CalculateLine.js",
-	    "Renderer/Canvas.js",
-	    "Controls/Control.js",
-	    "Controls/Move.js",
-	    "Controls/Pan.js",
-	    "Controls/Scale.js",
-	    "Controls/Select.js",
-	    
-	    "Data/data2d.js",
+
+		"Build/Build.js",
+
+		"Calculate/CalculateElement.js",
+		"Calculate/CalculateLine.js",
+		"Renderer/Canvas.js",
+		"Controls/Control.js",
+		"Controls/Move.js",
+		"Controls/Pan.js",
+		"Controls/Scale.js",
+		"Controls/Select.js",
+
+		"Data/data2d.js",
 
 		"Geometry/Circle.js",
 		"Geometry/Geometry.js",
@@ -66,36 +68,36 @@
 		"Geometry/Point.js",
 		"Geometry/Sector.js",
 		"Geometry/Sector2.js",
-		
+
 		"Geometry/OpenDoor.js",
 		"Geometry/SimpleDoor.js",
 		"Geometry/BiFoldDoor.js",
 		"Geometry/SlidingDoor.js",
-		
+
 		"Geometry/OpenWindow.js",
 		"Geometry/SingleCasement.js",
 		"Geometry/DoubleCasement.js",
 		"Geometry/SlidingWindow.js",
-		
+
 		"Geometry/WinderStair.js",
 		"Geometry/Spiral.js",
-		
+
 		"Geometry/Text.js",
 		"Geometry/Wall.js",
 
-		"Manager/ManagerSymbol2D.js",		
+		"Manager/ManagerSymbol2D.js",
 		"Parameter.js",
 		"Style.js",
 		"Vector/Vector.js",
 		"Web/Menu.js",
-		"Variable.js"	
+		"Variable.js"
 	];
-	
+
 	var jsTags = "";
 	var host = CanvasSketch.getScriptLocation();
-	for(var i = 0, len = jsFile.length; i < len; i++) {
-		jsTags += "<script src='"+ host + jsFile[i] +"'></script>"
+	for (var i = 0, len = jsFile.length; i < len; i++) {
+		jsTags += "<script src='" + host + jsFile[i] + "'></script>"
 	}
-	
+
 	document.write(jsTags);
 })();

+ 3 - 2
libs/Controls/Move.js

@@ -945,9 +945,10 @@ Move.prototype.moveSymbolEndpoint = function (point, selectindex) {
 Move.prototype.moveSymbolsWithWallCorner = function (wallid, index) {
 	var symbol2ds = [];
 	var movPoint = this.layer.vectors[wallid].geometry.points[index];
-	var fixPoint = null;
 
+	console.log(this.layer.vectors[wallid].symbol2Ds)
 	for (var key in this.layer.vectors[wallid].symbol2Ds) {
+		var fixPoint = null;
 		var symbol2d = this.layer.vectors[wallid].symbol2Ds[key];
 		if (symbol2d.attributes.wallstartindex == index) {
 			symbol2ds.push(symbol2d);
@@ -958,7 +959,7 @@ Move.prototype.moveSymbolsWithWallCorner = function (wallid, index) {
 			fixPoint = this.layer.vectors[wallid].geometry.points[symbol2d.attributes.wallstartindex];
 		}
 		else {
-			break;
+			// break;
 		}
 
 		if (fixPoint != null) {

+ 10 - 9
libs/Layer/Layer.js

@@ -63,7 +63,9 @@ Layer.prototype.addBackGround = function () {
 Layer.prototype.addVectors = function (vectors) {
     this.renderer.lock = true;
     for (var i = 0, len = vectors.length; i < len; i++) {
-        if (i == len - 1) { this.renderer.lock = false; }
+        if (i == len - 1) {
+            this.renderer.lock = false;
+        }
         this.vectors[vectors[i].id] = vectors[i];
         this.drawVector(vectors[i]);
     }
@@ -146,8 +148,7 @@ Layer.prototype.moveTo = function (zoom, center) {
     if (width / 2 > -startx) {
         left = -width / 2;
         right = width / 2;
-    }
-    else {
+    } else {
         if (right > -startx) {
             right = -startx;
             left = -startx - width;
@@ -195,8 +196,10 @@ Layer.prototype.moveTo = function (zoom, center) {
 
 //通过屏幕坐标设定center。
 Layer.prototype.getPositionFromPx = function (px) {
-    return new CanvasSketch.Position((px.x + this.bounds.left / this.res) * this.res,
-        (this.bounds.top / this.res - px.y) * this.res);
+    return new CanvasSketch.Position(
+        (px.x + this.bounds.left / this.res) * this.res,
+        (this.bounds.top / this.res - px.y) * this.res
+    );
 };
 /*
 Layer.prototype.getWallThickness=function(id)
@@ -234,13 +237,11 @@ Layer.prototype.getThickness2 = function (geometry) {
     if (geometry != null && typeof (geometry.wallType) != "undefined") {
         if (geometry.wallType == 1) {
             this.thickness = wallThickness;
-        }
-        else {
+        } else {
             this.thickness = partitionThickness;
         }
         return this.thickness;
-    }
-    else {
+    } else {
         return null;
     }
 };

Plik diff jest za duży
+ 129 - 107
libs/Parameter.js


+ 77 - 47
libs/Renderer/Canvas.js

@@ -4,9 +4,11 @@ function Canvas(layer) {
 	this.canvas = document.getElementById("dynamiccanvas2d");
 	this.context = this.canvas.getContext("2d");
 
+	// 背景层canvas 栅栏格子
 	this.backgroundcanvas = document.getElementById("backgroundcanvas2d");
 	this.backgroundcontext = this.backgroundcanvas.getContext("2d");
 
+	// 选择层canvas
 	this.selectcanvas = document.getElementById("selectcanvas2d");
 	this.selectcontext = this.selectcanvas.getContext("2d");
 
@@ -25,6 +27,7 @@ function Canvas(layer) {
 	this.layer.div.appendChild(this.canvas);
 };
 
+
 //设置canvas元素的大小。
 Canvas.prototype.setSize = function (size) {
 	this.canvas.width = size.w;
@@ -44,18 +47,27 @@ Canvas.prototype.setSize = function (size) {
 
 };
 
+// 绘制放大缩小层canvas
 Canvas.prototype.drawBackGround = function () {
 	this.backgroundcontext.clearRect(0, 0, this.layer.size.w, this.layer.size.h);
 	this.addGrid();
 	this.addMeter();
 };
 
+// 绘画格子
 Canvas.prototype.addGrid = function () {
-	var leftdown = { x: 0, y: height };
-	var rightup = { x: width, y: 0 };
+	var leftdown = {
+		x: 0,
+		y: height
+	};
+	var rightup = {
+		x: width,
+		y: 0
+	};
 	leftdown = this.layer.getPositionFromPx(leftdown);
 	rightup = this.layer.getPositionFromPx(rightup);
 
+	console.log(leftdown, rightup)
 	var Maxh = height;
 	var Maxw = width;
 	var Minw = 0;
@@ -88,8 +100,14 @@ Canvas.prototype.addGrid = function () {
 	var context = this.backgroundcontext;
 	context.save();
 
-	var startPoint = { x: leftcount * stepx, y: downcount * stepy };
-	var endPoint = { x: rightcount * stepx, y: upcount * stepy };
+	var startPoint = {
+		x: leftcount * stepx,
+		y: downcount * stepy
+	};
+	var endPoint = {
+		x: rightcount * stepx,
+		y: upcount * stepy
+	};
 	context.shadowColor = undefined;
 	context.beginPath();
 
@@ -118,15 +136,28 @@ Canvas.prototype.addGrid = function () {
 	context.restore();
 };
 
+
 Canvas.prototype.addMeter = function () {
 	var context = this.backgroundcontext;
 	context.save();
 	context.globalAlpha = 1;
 	context.beginPath();
-	var pt1 = { x: meterpositionX, y: height - meterpositionX };
-	var pt2 = { x: meterpositionX, y: height - meterpositionX + 5 };
-	var pt3 = { x: meterpositionX + meter / this.layer.res, y: height - meterpositionX + 5 };
-	var pt4 = { x: meterpositionX + meter / this.layer.res, y: height - meterpositionX };
+	var pt1 = {
+		x: meterpositionX,
+		y: height - meterpositionX
+	};
+	var pt2 = {
+		x: meterpositionX,
+		y: height - meterpositionX + 5
+	};
+	var pt3 = {
+		x: meterpositionX + meter / this.layer.res,
+		y: height - meterpositionX + 5
+	};
+	var pt4 = {
+		x: meterpositionX + meter / this.layer.res,
+		y: height - meterpositionX
+	};
 
 	context.moveTo(pt1.x, pt1.y);
 	context.lineTo(pt2.x, pt2.y);
@@ -144,6 +175,7 @@ Canvas.prototype.addMeter = function () {
 
 //这个方法用于收集所有需要绘制的矢量元素。    
 Canvas.prototype.drawGeometry = function (geometry, style, contextindex) {
+	console.log(arguments)
 	this.geometrys[geometry.id] = [geometry, style];
 	//如果渲染器没有被锁定则可以进行重绘。
 	if (!this.lock) {
@@ -160,11 +192,9 @@ Canvas.prototype.drawSingleGeometry = function (geometry, style) {
 Canvas.prototype.clearCanvas = function (contextIndex) {
 	if (contextIndex == this.layer.parameter.contextIndex) {
 		this.context.clearRect(0, 0, width, height);
-	}
-	else if (contextIndex == this.layer.parameter.backgroundcontext) {
+	} else if (contextIndex == this.layer.parameter.backgroundcontext) {
 		this.backgroundcontext.clearRect(0, 0, width, height);
-	}
-	else if (contextIndex == this.layer.parameter.selectcontext) {
+	} else if (contextIndex == this.layer.parameter.selectcontext) {
 		this.selectcontext.clearRect(0, 0, width, height);
 	}
 };
@@ -204,16 +234,17 @@ Canvas.prototype.redraw = function (contextindex) {
 	//0是正常,1是背景,2是选中
 	if (contextindex == 1) {
 		this.drawBackGround();
-	}
-	else {
+	} else {
 		var geometry, style;
 
 		if (!this.lock) {
 
+			// 画墙
 			for (var i = 0; i < this.layer.data2d.wallIds.length; ++i) {
 				var geometryid = this.layer.vectors[this.layer.data2d.wallIds[i]].geometry.id;
 				geometry = this.geometrys[geometryid][0];
 				if (geometry.contextIndex == contextindex) {
+					// 
 					if (geometry.floor == this.layer.selectFloor) {
 						style = this.geometrys[geometryid][1];
 						this.draw(geometry, style, geometry.contextIndex);
@@ -286,7 +317,6 @@ Canvas.prototype.draw = function (geometry, style, contextIndex, floorstyle) {
 		"LineMeasure": 'drawLineWithMeasure'
 	}
 
-	console.log(geometry.geoType)
 	this[strategy[geometry.geoType]](geometry, style, contextIndex)
 	//{todo} 我们在这里判断各种矢量要素的绘制。        
 };
@@ -294,14 +324,11 @@ Canvas.prototype.draw = function (geometry, style, contextIndex, floorstyle) {
 Canvas.prototype.getContext = function (contextIndex) {
 	if (contextIndex == 0) {
 		return this.context;
-	}
-	else if (contextIndex == 1) {
+	} else if (contextIndex == 1) {
 		return this.backgroundcontext;
-	}
-	else if (contextIndex == 2) {
+	} else if (contextIndex == 2) {
 		return this.selectcontext;
-	}
-	else {
+	} else {
 		alert("Canvas:237");
 		return null;
 	}
@@ -564,8 +591,7 @@ Canvas.prototype.drawWinderStair = function (geometry, style, contextIndex) {
 	var lines = null;
 	if (geometry.temp_points.length > 0) {
 		lines = this.layer.calculateElement.getWallMappingPoints(measurepoints, geometry.temp_points, 1);
-	}
-	else {
+	} else {
 		lines = this.layer.calculateElement.getWallMappingPoints(measurepoints, geometry.points, 1);
 	}
 
@@ -682,8 +708,7 @@ Canvas.prototype.rendererWinderStair = function (geometry, style, contextIndex)
 	this.setCanvasStyle(style, contextIndex);
 	if (points.length == 0) {
 		return;
-	}
-	else if (points.length == 1 && geometry.linkedpoints.length == 0) {
+	} else if (points.length == 1 && geometry.linkedpoints.length == 0) {
 		var radius = this.layer.parameter.selectCircle_R;
 		var twoPi = Math.PI * 2;
 		var pt = this.getLocalXY(points[0]);
@@ -693,8 +718,7 @@ Canvas.prototype.rendererWinderStair = function (geometry, style, contextIndex)
 		context.arc(pt.x, pt.y, radius, 0, twoPi, true);
 		context.closePath();
 		context.fill();
-	}
-	else if (geometry.linkedpoints.length > 0) {
+	} else if (geometry.linkedpoints.length > 0) {
 		context.beginPath();
 		for (var i = 0; i < geometry.linkedpoints.length; ++i) {
 			var p1 = this.getLocalXY(geometry.linkedpoints[i][1]);
@@ -891,10 +915,15 @@ Canvas.prototype.rendererSector = function (geometry, style, contextIndex) {
 	var text = Math.round(angle) + " °";
 	var textpoint;
 	if (flag) {
-		textpoint = { x: pt.x - r * Math.cos((end + start) / 2), y: pt.y - r * Math.sin((end + start) / 2) };
-	}
-	else {
-		textpoint = { x: pt.x + r * Math.cos((end + start) / 2), y: pt.y + r * Math.sin((end + start) / 2) };
+		textpoint = {
+			x: pt.x - r * Math.cos((end + start) / 2),
+			y: pt.y - r * Math.sin((end + start) / 2)
+		};
+	} else {
+		textpoint = {
+			x: pt.x + r * Math.cos((end + start) / 2),
+			y: pt.y + r * Math.sin((end + start) / 2)
+		};
 	}
 	context.fillStyle = "#FAFAFA";
 	context.beginPath();
@@ -964,14 +993,16 @@ Canvas.prototype.drawSymbolMeasure = function (point1, point2, type, contextInde
 	var distance2;
 	if (type == 1) {
 		distance2 = 30;
-	}
-	else {
+	} else {
 		distance2 = 15;
 	}
 
 	var arrows = calculateLine.getParallelLineForDistance(calculateLine.createLine(point1, point2), distance2);
 
-	var mid = { x: (point1.x + point2.x) / 2, y: (point1.y + point2.y) / 2 };
+	var mid = {
+		x: (point1.x + point2.x) / 2,
+		y: (point1.y + point2.y) / 2
+	};
 
 	var inpt1 = calculateLine.getJoinLinePoint(point1, arrows.line1);
 	var inpt2 = calculateLine.getJoinLinePoint(point2, arrows.line1);
@@ -1124,7 +1155,8 @@ Canvas.prototype.rendererLineTagging = function (ps, inlinecenter, indistance, c
 	var text = indistance.toFixed(2) + "m"
 	var rectW = text.length * textWidth + 2 * spaceWidth
 	var rectH = 2 * textWidth
-	var start = ps[0], end = ps[1];
+	var start = ps[0],
+		end = ps[1];
 
 	if (Math.abs(ps[0].x - ps[1].x) > Math.abs(ps[0].y - ps[1].y)) {
 		if (ps[0].x > ps[1].x) {
@@ -1210,8 +1242,7 @@ Canvas.prototype.drawArrow = function (p0, p1, index) {
 	var context;
 	if (typeof (index) == "undefined") {
 		context = this.context;
-	}
-	else {
+	} else {
 		context = this.getContext(index);
 	}
 
@@ -1270,8 +1301,7 @@ Canvas.prototype.rendererWallPath = function (geometry, rendererType, contextInd
 	context.beginPath();
 	if (geometry.wallType == 1) {
 		context.lineWidth = wallThickness / this.layer.res;
-	}
-	else {
+	} else {
 		context.lineWidth = partitionThickness / this.layer.res;
 	}
 	var img = geometry.image;
@@ -1290,8 +1320,7 @@ Canvas.prototype.rendererWallPath = function (geometry, rendererType, contextInd
 		context.moveTo(x, y);
 		if (len == 1) {
 			return;
-		}
-		else if (len == 2) {
+		} else if (len == 2) {
 			var pt = this.getLocalXY(points[1]);
 			context.lineTo(pt.x, pt.y);
 			if (rendererType.f_stroke) {
@@ -1307,7 +1336,7 @@ Canvas.prototype.rendererWallPath = function (geometry, rendererType, contextInd
 		if (geometry.state == 0) {
 			context.closePath();
 			if (rendererType.f_fill) {
-				context.fillStyle = 'white';//填充白色
+				context.fillStyle = 'white'; //填充白色
 				context.fill();
 			}
 		}
@@ -1392,8 +1421,7 @@ Canvas.prototype.setCanvasStyle = function (style, contextIndex) {
 		//}
 		context.restore();
 		return;
-	}
-	else {
+	} else {
 		context.save();
 		for (var key in style) {
 			if (key != "fill" && key != "stroke") {
@@ -1412,11 +1440,13 @@ Canvas.prototype.getLocalXY = function (point) {
 	var y = ((extent.top / resolution) - point.y / resolution);
 	x = (0.5 + x) << 0;
 	y = (0.5 + y) << 0;
-	return { x: Math.floor(x), y: Math.floor(y) };
+	return {
+		x: Math.floor(x),
+		y: Math.floor(y)
+	};
 };
 
 Canvas.prototype.getInt = function (value) {
 	value = (0.5 + value) << 0;
 	return value;
-};
-
+};

+ 55 - 60
libs/Renderer/CurrentState.js

@@ -1,88 +1,83 @@
 function CurrentState() {
-	
+
    //画什么
-   this.startbuild=null;
+   this.startbuild = null;
    //添加元素
-   this.addSymbol=null;
-   
+   this.addSymbol = null;
+
    //选中门时候的两个端点
-   this.currentSymbolCircleId1=null;
-   this.currentSymbolCircleId2=null;
-   
+   this.currentSymbolCircleId1 = null;
+   this.currentSymbolCircleId2 = null;
+
    //当前元素是否存在
-   this.currentSymbol=false;
+   this.currentSymbol = false;
    //当前活动的墙
-   this.currentWallId=null;
-   
+   this.currentWallId = null;
+
    //选中的线段所在位置的起始点
    //选中点的位置
-   this.currentstartlinePointIndex=null;
+   this.currentstartlinePointIndex = null;
    //选中的线段所在位置的终点
-   this.currentendlinePointIndex=null;
-   
+   this.currentendlinePointIndex = null;
+
    //当前选中的圆圈
-   this.currentCircleId=null;
+   this.currentCircleId = null;
    //当前选中的点
-   this.currentPointId=null;
+   this.currentPointId = null;
    //当前选中的扇形
-   this.currentSecotrId=null;
-   
+   this.currentSecotrId = null;
+
    //当前选中的线段
-   this.currentLineId=null;
+   this.currentLineId = null;
 
    //当前选中的symbol的id
-   this.currentSymbolId=null;
+   this.currentSymbolId = null;
    //当前选中的楼梯的id
-   this.currentStairId=null;
+   this.currentStairId = null;
    //选中的线段上的端点所在id
-   this.currentLinePoint1Id=null;
-   this.currentLinePoint2Id=null;
+   this.currentLinePoint1Id = null;
+   this.currentLinePoint2Id = null;
    //当前点是否被墙包含
    //id表示墙的vectorid,index表示墙对应的点的index,endindex表示墙的另一端对应的点的index,type表示对应的是墙角还是墙面
-   this.selectWallSet=null;
-   this.selectStairSet=null;
+   this.selectWallSet = null;
+   this.selectStairSet = null;
 
    //当前所处的状态
    //0表示什么也没有选中,1表示选中的是墙,2表示选中的是墙角,3表示选中的是墙上的门或窗户等元素
    //this.state=0;
-   
+
    //当前状态和上一个状态一致
-   CurrentState.prototype.isRetain=function(laststate)
-   {
-	   if(this.currentstartlinePointIndex===laststate.currentstartlinePointIndex&&this.currentendlinePointIndex===laststate.currentendlinePointIndex)
-	   {
-		   if(this.currentWallId===laststate.currentWallId&&this.currentStairId===laststate.currentStairId)
-		   {
-			   return true;
-		   }
-		   
-	   }
-	   return false;
+   CurrentState.prototype.isRetain = function (laststate) {
+      if (this.currentstartlinePointIndex === laststate.currentstartlinePointIndex && this.currentendlinePointIndex === laststate.currentendlinePointIndex) {
+         if (this.currentWallId === laststate.currentWallId && this.currentStairId === laststate.currentStairId) {
+            return true;
+         }
+
+      }
+      return false;
    };
-   
-   CurrentState.prototype.clearSelectSymbol=function()
-   {
-	   this.currentSymbolCircleId1=null;
-	   this.currentSymbolCircleId2=null;
-	   this.currentSymbol=false;
-	   this.currentSymbolId=null;	
+
+   CurrentState.prototype.clearSelectSymbol = function () {
+      this.currentSymbolCircleId1 = null;
+      this.currentSymbolCircleId2 = null;
+      this.currentSymbol = false;
+      this.currentSymbolId = null;
    };
-   
-   CurrentState.prototype.clearSelects=function()
-   {
-	   this.currentSymbolCircleId1=null;
-	   this.currentSymbolCircleId2=null;
-	   this.currentSymbol=false;
-	   this.currentWallId=null;
-	   this.currentstartlinePointIndex=null;
-	   this.currentendlinePointIndex=null;
-	   this.currentCircleId=null;
-	   this.currentPointId=null;
-	   this.currentSecotrId=null;
-	   this.currentLineId=null;
-	   this.currentSymbolId=null;
-	   this.currentLinePoint1Id=null;
-	   this.currentLinePoint2Id=null;
-	   //this.selectWallSet=null;	
+
+   CurrentState.prototype.clearSelects = function () {
+      this.currentSymbolCircleId1 = null;
+      this.currentSymbolCircleId2 = null;
+      this.currentSymbol = false;
+      this.currentWallId = null;
+      this.currentstartlinePointIndex = null;
+      this.currentendlinePointIndex = null;
+      this.currentCircleId = null;
+      this.currentPointId = null;
+      this.currentSecotrId = null;
+      this.currentLineId = null;
+      this.currentSymbolId = null;
+      this.currentLinePoint1Id = null;
+      this.currentLinePoint2Id = null;
+      //this.selectWallSet=null;	
    };
 };

+ 5 - 5
libs/Renderer/PreviousState.js

@@ -1,12 +1,12 @@
-function PreviousState() {
+锘縡unction PreviousState() {
 	this.type=null;
-	//当前活动的墙
+	//褰撳墠娲诲姩鐨勫�
     this.currentWallId=null;
 	this.currentStairId=null;
-	//选中的线段所在位置的起始点
-    //选中点的位置
+	//选中的线段所在位置的起始点
+    //閫変腑鐐圭殑浣嶇疆
     this.currentstartlinePointIndex;
-    //选中的线段所在位置的终点
+    //閫変腑鐨勭嚎娈垫墍鍦ㄤ綅缃�殑缁堢偣
     this.currentendlinePointIndex;
 };
 

+ 240 - 26
libs/Style.js

@@ -1,51 +1,265 @@
-var gridStyle = {strokeStyle:"#999999", f_fill:false, f_stroke:true,lineWidth:1,globalAlpha:0.3};
-var wallStyle = {fillStyle:"white",f_fill:true,f_stroke:true,globalAlpha:1,globalCompositeOperation:"source-over",lineCap:"butt",lineJoin:"miter"};
-var measureStyle={fillStyle:"#000000",font:"10px Arial",globalAlpha:1,lineWidth:1,textAlign:"start",textBaseline:"alphabetic",name:"measure"};
+var gridStyle = {
+  strokeStyle: "#999999",
+  f_fill: false,
+  f_stroke: true,
+  lineWidth: 1,
+  globalAlpha: 0.3
+};
+var wallStyle = {
+  fillStyle: "white",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 1,
+  globalCompositeOperation: "source-over",
+  lineCap: "butt",
+  lineJoin: "miter"
+};
+var measureStyle = {
+  fillStyle: "#000000",
+  font: "10px Arial",
+  globalAlpha: 1,
+  lineWidth: 1,
+  textAlign: "start",
+  textBaseline: "alphabetic",
+  name: "measure"
+};
 //绿色
 //var selectlineStyle = {strokeStyle:"#89b808", f_fill:false,f_stroke:true, globalAlpha:1,lineWidth:5,globalCompositeOperation:"source-over",lineCap:"round"};
-var lineStyle = {strokeStyle:"#89b808", strokeStyle:"#89b808",f_fill:false,f_stroke:true, globalAlpha:1,lineWidth:5,globalCompositeOperation:"source-over",lineCap:"round"};
+var lineStyle = {
+  strokeStyle: "#89b808",
+  strokeStyle: "#89b808",
+  f_fill: false,
+  f_stroke: true,
+  globalAlpha: 1,
+  lineWidth: 5,
+  globalCompositeOperation: "source-over",
+  lineCap: "round"
+};
 //open门和窗户
-var openStyle = {strokeStyle:"#999999", f_fill:true,f_stroke:true, globalAlpha:1,lineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineCap:"butt",name:"open"};
+var openStyle = {
+  strokeStyle: "#999999",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 1,
+  lineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineCap: "butt",
+  name: "open"
+};
 //simple门
-var simpleStyle = {strokeStyle:"#000000", fillStyle:"#EEEEEE",f_fill:true,f_stroke:true, globalAlpha:0.5,lineWidth:1,openLineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineJoin:"miter",imageSmoothingEnabled:true,lineCap:"butt",name:"simple"};
+var simpleStyle = {
+  strokeStyle: "#000000",
+  fillStyle: "#EEEEEE",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 0.5,
+  lineWidth: 1,
+  openLineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineJoin: "miter",
+  imageSmoothingEnabled: true,
+  lineCap: "butt",
+  name: "simple"
+};
 //BiFoldDoor
-var biFoldStyle = {strokeStyle:"#000000", fillStyle:"#EEEEEE",f_fill:true,f_stroke:true, globalAlpha:0.5,lineWidth:1,openLineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineJoin:"miter",imageSmoothingEnabled:true,lineCap:"butt",name:"biFold"};
+var biFoldStyle = {
+  strokeStyle: "#000000",
+  fillStyle: "#EEEEEE",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 0.5,
+  lineWidth: 1,
+  openLineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineJoin: "miter",
+  imageSmoothingEnabled: true,
+  lineCap: "butt",
+  name: "biFold"
+};
 //singleCasement窗
-var singleStyle = {strokeStyle:"#000000", fillStyle:"#EEEEEE",f_fill:true,f_stroke:true, globalAlpha:0.5,lineWidth:1,openLineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineJoin:"miter",imageSmoothingEnabled:true,lineCap:"butt",name:"single"};
+var singleStyle = {
+  strokeStyle: "#000000",
+  fillStyle: "#EEEEEE",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 0.5,
+  lineWidth: 1,
+  openLineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineJoin: "miter",
+  imageSmoothingEnabled: true,
+  lineCap: "butt",
+  name: "single"
+};
 //double窗
-var doubleStyle = {strokeStyle:"#000000", fillStyle:"#EEEEEE",f_fill:true,f_stroke:true, globalAlpha:0.5,lineWidth:1,openLineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineJoin:"miter",imageSmoothingEnabled:true,lineCap:"butt",name:"double"};
+var doubleStyle = {
+  strokeStyle: "#000000",
+  fillStyle: "#EEEEEE",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 0.5,
+  lineWidth: 1,
+  openLineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineJoin: "miter",
+  imageSmoothingEnabled: true,
+  lineCap: "butt",
+  name: "double"
+};
 //slid门和窗户
-var slidingStyle = {strokeStyle:"#000000", fillStyle:"#EEEEEE",f_fill:true,f_stroke:true, globalAlpha:0.5,lineWidth:1,openLineWidth:this.wallThickness,globalCompositeOperation:"source-over",lineJoin:"miter",imageSmoothingEnabled:true,lineCap:"butt",name:"sliding"};
+var slidingStyle = {
+  strokeStyle: "#000000",
+  fillStyle: "#EEEEEE",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 0.5,
+  lineWidth: 1,
+  openLineWidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineJoin: "miter",
+  imageSmoothingEnabled: true,
+  lineCap: "butt",
+  name: "sliding"
+};
 //var doorStyle = {strokeStyle:"#89b808", f_fill:false,f_stroke:true, globalAlpha:1,lineWidth:this.wallThickness,globalCompositeOperation:"source-over"};
 //winder楼梯
 var winderStyle = {};
-var spiralStyle = {strokeStyle:"#999999",strokeStyle2:"#000000", fillStyle:"white",f_fill:true, f_stroke:true,lineWidth:1,globalAlpha:0.05,globalAlpha2:1};
+var spiralStyle = {
+  strokeStyle: "#999999",
+  strokeStyle2: "#000000",
+  fillStyle: "white",
+  f_fill: true,
+  f_stroke: true,
+  lineWidth: 1,
+  globalAlpha: 0.05,
+  globalAlpha2: 1
+};
 
 //var selectdwpointStyle={fillColor:"#FAFAFA",strokeStyle:"#89b808", f_fill:true, f_stroke:true,globalAlpha:1,lineWidth:2,r:this.selectCircle_R};
 //选择的元素上的点的样式
-var selectCircleStyle={fillStyle:"white",strokeStyle:"#89b808", f_fill:true, f_stroke:true,globalAlpha:1,lineWidth:2,r:this.selectCircle_R};
-var selectLineStyle={strokeStyle:"#89b808", strokeStyle:"#89b808",f_fill:false,f_stroke:true, globalAlpha:1,lineWidth:5,globalCompositeOperation:"source-over",lineCap:"round"};
+var selectCircleStyle = {
+  fillStyle: "white",
+  strokeStyle: "#89b808",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 1,
+  lineWidth: 2,
+  r: this.selectCircle_R
+};
+var selectLineStyle = {
+  strokeStyle: "#89b808",
+  strokeStyle: "#89b808",
+  f_fill: false,
+  f_stroke: true,
+  globalAlpha: 1,
+  lineWidth: 5,
+  globalCompositeOperation: "source-over",
+  lineCap: "round"
+};
 //var selectdwlineStyle = {strokeStyle:"#777777", f_fill:false, f_stroke:true,lineWidth:1,globalAlpha:1,globalCompositeOperation:"source-over"};
 
-var circleStyle = {strokeStyle:"#89b808",strokeStyle:"#89b808", f_fill:false, f_stroke:true, fillOpacity:1, strokeOpacity:1,lineWidth:5};
-var meterStyle = {strokeStyle:"black", f_fill:false, f_stroke:true,lineWidth:1,globalAlpha:1};
-var defaultStyle={strokeStyle:"black", f_fill:false, f_stroke:true,lineWidth:1,globalAlpha:1,globalCompositeOperation:"source-over"};
-var pointStyle = {fillStyle:"#89b808", strokeStyle:"#89b808",f_fill:true, f_stroke:true, fillOpacity:1, strokeOpacity:1,linewidth:1};
+var circleStyle = {
+  strokeStyle: "#89b808",
+  strokeStyle: "#89b808",
+  f_fill: false,
+  f_stroke: true,
+  fillOpacity: 1,
+  strokeOpacity: 1,
+  lineWidth: 5
+};
+var meterStyle = {
+  strokeStyle: "black",
+  f_fill: false,
+  f_stroke: true,
+  lineWidth: 1,
+  globalAlpha: 1
+};
+var defaultStyle = {
+  strokeStyle: "black",
+  f_fill: false,
+  f_stroke: true,
+  lineWidth: 1,
+  globalAlpha: 1,
+  globalCompositeOperation: "source-over"
+};
+var pointStyle = {
+  fillStyle: "#89b808",
+  strokeStyle: "#89b808",
+  f_fill: true,
+  f_stroke: true,
+  fillOpacity: 1,
+  strokeOpacity: 1,
+  linewidth: 1
+};
 
-var textStyle={ font:"10px Arial",fillStyle:"#000000",globalAlpha:1};
+var textStyle = {
+  font: "10px Arial",
+  fillStyle: "#000000",
+  globalAlpha: 1
+};
 
-var addcontext={fillStyle:0,lineCap:0,strokeStyle:0,lineWidth:0,globalAlpha:0};
+var addcontext = {
+  fillStyle: 0,
+  lineCap: 0,
+  strokeStyle: 0,
+  lineWidth: 0,
+  globalAlpha: 0
+};
 
 
-var doorStyle = {strokeColor:"#89b808", f_fill:false,f_stroke:true, globalAlpha:0.3,linewidth:this.wallThickness,globalCompositeOperation:"source-over",lineCap:"butt"};
-var doorStyle2 = {strokeColor:"#777777", f_fill:false,f_stroke:true, globalAlpha:1,linewidth:this.wallThickness,globalCompositeOperation:"source-over",lineCap:"butt"};
-var slidingdoor = {strokeColor:"#aaaaaa", fillColor:"#770000", globalAlpha:1,linewidth:this.wallThickness,globalCompositeOperation:"source-over",lineCap:"butt"};
-var doorPointStyle={fillStyle:"#FAFAFA",strokeColor:"#89b808", f_fill:true, f_stroke:true,globalAlpha:1,linewidth:2,r:this.selectCircle_R};
-var doorlineStyle = {strokeColor:"#777777", f_fill:false, f_stroke:true,linewidth:1,globalAlpha:1,globalCompositeOperation:"source-over"};
+var doorStyle = {
+  strokeColor: "#89b808",
+  f_fill: false,
+  f_stroke: true,
+  globalAlpha: 0.3,
+  linewidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineCap: "butt"
+};
+var doorStyle2 = {
+  strokeColor: "#777777",
+  f_fill: false,
+  f_stroke: true,
+  globalAlpha: 1,
+  linewidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineCap: "butt"
+};
+var slidingdoor = {
+  strokeColor: "#aaaaaa",
+  fillColor: "#770000",
+  globalAlpha: 1,
+  linewidth: this.wallThickness,
+  globalCompositeOperation: "source-over",
+  lineCap: "butt"
+};
+var doorPointStyle = {
+  fillStyle: "#FAFAFA",
+  strokeColor: "#89b808",
+  f_fill: true,
+  f_stroke: true,
+  globalAlpha: 1,
+  linewidth: 2,
+  r: this.selectCircle_R
+};
+var doorlineStyle = {
+  strokeColor: "#777777",
+  f_fill: false,
+  f_stroke: true,
+  linewidth: 1,
+  globalAlpha: 1,
+  globalCompositeOperation: "source-over"
+};
 
 
-var sectorStyle={fillStyle:"rgba(137, 137, 137, 0.5)",strokeStyle:"#89b808",lineWidth:1,globalAlpha:1,globalCompositeOperation:"source-over"};
+var sectorStyle = {
+  fillStyle: "rgba(137, 137, 137, 0.5)",
+  strokeStyle: "#89b808",
+  lineWidth: 1,
+  globalAlpha: 1,
+  globalCompositeOperation: "source-over"
+};
 
 
 
-//var selectdwpointStyle={fillStyle:"#FFFFFF",strokeStyle:"#89b808", f_fill:true, f_stroke:true,globalAlpha:1,lineWidth:2,r:this.selectCircle_R};
+//var selectdwpointStyle={fillStyle:"#FFFFFF",strokeStyle:"#89b808", f_fill:true, f_stroke:true,globalAlpha:1,lineWidth:2,r:this.selectCircle_R};

+ 12 - 1
libs/Util/util.js

@@ -1,4 +1,15 @@
-//工具类型文件
+window.requestAnimationFrame || (window.requestAnimationFrame = function () {
+	return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
+		window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a) {
+			window.setTimeout(a, 1e3 / 60);
+		};
+}());
+window.cancelRequestAnimationFrame || (window.cancelRequestAnimationFrame = function () {
+	return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.mozCancelRequestAnimationFrame ||
+		window.oCancelRequestAnimationFrame || window.msCancelRequestAnimationFrame || clearTimeout
+}());
+
+//工具类型文件
 CanvasSketch.lastId = 0;
 //取得id。
 CanvasSketch.getId = function (preString) {

+ 44 - 65
libs/Vector/Vector.js

@@ -1,11 +1,11 @@
 //CLASS:矢量图形类
 function Vector(geometry, style, attributes) {
-    this.id = CanvasSketch.getId("vector");
-    this.geometry = geometry;
-    this.symbol2Ds={};
-    this.symbol2dsCount=0;
+	this.id = CanvasSketch.getId("vector");
+	this.geometry = geometry;
+	this.symbol2Ds = {};
+	this.symbol2dsCount = 0;
 	this.style = style;
-	
+
 	/*
 	墙有这种属性,主要是墙上面的symbol
 	children
@@ -34,45 +34,41 @@ function Vector(geometry, style, attributes) {
 	exist=false;
 	selectSymbolIds=[];
 	*/
-    if(attributes) {
-        this.attributes = attributes;
-    }
-	else
-	{
-		this.attributes={};
+	if (attributes) {
+		this.attributes = attributes;
+	} else {
+		this.attributes = {};
 	}
 };
 
-Vector.prototype.setwallInfo = function (wallid,startindex,endindex) {
-	this.attributes.wallId=wallid;
-	this.attributes.wallstartindex=startindex;
-	this.attributes.wallendindex=endindex;
+Vector.prototype.setwallInfo = function (wallid, startindex, endindex) {
+	this.attributes.wallId = wallid;
+	this.attributes.wallstartindex = startindex;
+	this.attributes.wallendindex = endindex;
 };
 
-Vector.prototype.update = function (layer,wallid,startindex,endindex,point){
-	
+Vector.prototype.update = function (layer, wallid, startindex, endindex, point) {
+
 	//向symbol设置墙的信息
-	this.setwallInfo(wallid,startindex,endindex);
+	this.setwallInfo(wallid, startindex, endindex);
 	//更新其他点
-	var thick=layer.getThickness(wallid,startindex);
-	this.geometry.wallType=layer.vectors[this.attributes.wallId].geometry.wallType;
-	if(point!=null)
-	{
-		this.attributes.toward = layer.calculateLine.getToward(this.geometry.point1,this.geometry.point2,point);
+	var thick = layer.getThickness(wallid, startindex);
+	this.geometry.wallType = layer.vectors[this.attributes.wallId].geometry.wallType;
+	if (point != null) {
+		this.attributes.toward = layer.calculateLine.getToward(this.geometry.point1, this.geometry.point2, point);
 	}
-	
-	this.geometry.points=layer.calculateElement.getSymbolPoints(this.geometry.point1,this.geometry.point2,this.geometry.geoType,this.attributes.toward,thick);
-	
-	if(!this.attributes.draw)
-	{
+
+	this.geometry.points = layer.calculateElement.getSymbolPoints(this.geometry.point1, this.geometry.point2, this.geometry.geoType, this.attributes.toward, thick);
+
+	if (!this.attributes.draw) {
 		layer.drawSingleVector(this);
 		layer.vectors[this.id] = this;
-		this.attributes.draw=true;
+		this.attributes.draw = true;
 	}
 };
 
 Vector.prototype.getSymbolLen = function () {
-    /*
+	/*
 	if(this.geometry.geoType=="Symbol2D_OpeningWindow")
     {
     	return layer.parameter.windowLength[0];
@@ -98,41 +94,24 @@ Vector.prototype.getSymbolLen = function () {
     	return layer.parameter.windowLength[2];
     }
     */
-	if(this.geometry.points!=null&&this.geometry.points.length>0)
-	{
+	if (this.geometry.points != null && this.geometry.points.length > 0) {
 		//return BABYLON.Vector2.Distance(this.points[0],this.points[1]);
-		return BABYLON.Vector2.Distance(this.geometry.point1,this.geometry.point2);
+		return BABYLON.Vector2.Distance(this.geometry.point1, this.geometry.point2);
+	} else if (this.geometry.geoType == "OpenDoor") {
+		return 80;
+	} else if (this.geometry.geoType == "OpenWindow") {
+		return 60;
+	} else if (this.geometry.geoType == "SimpleDoor") {
+		return 80;
+	} else if (this.geometry.geoType == "SingleCasement") {
+		return 60;
+	} else if (this.geometry.geoType == "BiFoldDoor") {
+		return 120;
+	} else if (this.geometry.geoType == "DoubleCasement") {
+		return 100;
+	} else if (this.geometry.geoType == "SlidingDoor") {
+		return 120;
+	} else if (this.geometry.geoType == "SlidingWindow") {
+		return 100;
 	}
-    else if(this.geometry.geoType=="OpenDoor")
-    {
-    	return 80;
-    }
-	else if(this.geometry.geoType=="OpenWindow")
-    {
-    	return 60;
-    }
-	else if(this.geometry.geoType=="SimpleDoor")
-    {
-    	return 80;
-    }
-	else if(this.geometry.geoType=="SingleCasement")
-    {
-    	return 60;
-    }
-	else if(this.geometry.geoType=="BiFoldDoor")
-    {
-    	return 120;
-    }
-	else if(this.geometry.geoType=="DoubleCasement")
-    {
-    	return 100;
-    }
-	else if(this.geometry.geoType=="SlidingDoor")
-    {
-    	return 120;
-    }
-	else if(this.geometry.geoType=="SlidingWindow")
-    {
-    	return 100;
-    }
 };

+ 40 - 67
libs/Web/Menu.js

@@ -98,11 +98,9 @@ Menu.prototype.dragWindow = function () {
 		var value = null;
 		if (id == "edit2D1") {
 			value = document.getElementById("edit2D11");
-		}
-		else if (id == "edit2D2") {
+		} else if (id == "edit2D2") {
 			value = document.getElementById("edit2D22");
-		}
-		else {
+		} else {
 			return;
 		}
 
@@ -116,8 +114,7 @@ Menu.prototype.dragWindow = function () {
 				this.layer.vectors[id].geometry.wallInfo[index].thick = parseInt(range.value);
 				this.layer.control.refreshCanvas = true;
 				this.layer.renderer.autoRedraw();
-			}
-			else if (range.id == "edit2D2") {
+			} else if (range.id == "edit2D2") {
 				this.layer.vectors[id].geometry.wallInfo[index].height = parseInt(range.value);
 				this.layer.control.refreshCanvas = true;
 				this.layer.renderer.autoRedraw();
@@ -173,8 +170,7 @@ Menu.prototype.addfloorAddMenuItem = function () {
 	check1.addEventListener("click", function (e) {
 		if (e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = false;
-		}
-		else if (!e.currentTarget.children[0].checked) {
+		} else if (!e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = true;
 		}
 	}.bind(this));
@@ -182,8 +178,7 @@ Menu.prototype.addfloorAddMenuItem = function () {
 	check2.addEventListener("click", function (e) {
 		if (e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = false;
-		}
-		else if (!e.currentTarget.children[0].checked) {
+		} else if (!e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = true;
 		}
 	}.bind(this));
@@ -191,8 +186,7 @@ Menu.prototype.addfloorAddMenuItem = function () {
 	check3.addEventListener("click", function (e) {
 		if (e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = false;
-		}
-		else if (!e.currentTarget.children[0].checked) {
+		} else if (!e.currentTarget.children[0].checked) {
 			e.currentTarget.children[0].checked = true;
 		}
 	}.bind(this));
@@ -306,8 +300,7 @@ Menu.prototype.copyFloor = function () {
 						var symbol = this.layer.build.createSymbol2(this.layer.vectors[symbolid].geometry.geoType);
 						if (symbol == null) {
 							alert("149");
-						}
-						else {
+						} else {
 							symbol.geometry.point1 = {};
 							symbol.geometry.point1.x = this.layer.vectors[symbolid].geometry.point1.x;
 							symbol.geometry.point1.y = this.layer.vectors[symbolid].geometry.point1.y;
@@ -319,8 +312,7 @@ Menu.prototype.copyFloor = function () {
 									symbol.geometry.points[i] = {};
 									symbol.geometry.points[i].x = symbolpoints[i].x;
 									symbol.geometry.points[i].y = symbolpoints[i].y;
-								}
-								else {
+								} else {
 									symbol.geometry.points[i] = symbolpoints[i];
 								}
 							}
@@ -356,14 +348,12 @@ Menu.prototype.seleteFloor = function (e) {
 	if (document.getElementById("mainMenuTitle").innerHTML == "绘图") {
 		this.layer.control.refreshCanvas = true;
 		this.layer.renderer.autoRedraw();
-	}
-	else {
+	} else {
 		my3DEngine.decorate3D.showFloors(parseInt(this.layer.selectFloor));
 		my3DEngine.decorate3D.hideFloors(parseInt(this.layer.selectFloor));
 		if (document.getElementById("transparencyButton").children[0].children[0].src.indexOf("icon-opacity.png") > -1) {
 			my3DEngine.decorate3D.transparentWall(0.05);
-		}
-		else {
+		} else {
 			my3DEngine.decorate3D.transparentWall(1);
 		}
 	}
@@ -396,14 +386,12 @@ Menu.prototype.deleteFloors = function (e) {
 				if (i != -1) {
 					this.layer.selectFloor = i + 1;
 					controlFloor.children[i].classList.add("selected");
-				}
-				else {
+				} else {
 					this.layer.selectFloor = i;
 					controlFloor.children[0].classList.add("selected");
 				}
 				continue;
-			}
-			else if (deletefloor) {
+			} else if (deletefloor) {
 				var floor = controlFloor.children[i].rel;
 				floor = parseInt(floor);
 				--floor;
@@ -566,11 +554,9 @@ Menu.prototype.addSymbolMenuItem = function (id, name, menuitems, flag) {
 			var type = this.Events[0][0];
 			var listener = this.Events[0][1];
 			li.addEventListener(type, listener.bind(this), true);
-		}
-		else if (flag == 1) {
+		} else if (flag == 1) {
 			li.addEventListener("click", Menu.prototype.openProduct);
-		}
-		else if (flag == 2) {
+		} else if (flag == 2) {
 			var type = this.Events[2][0];
 			var listener = this.Events[2][1];
 			li.addEventListener(type, listener.bind(this), true);
@@ -623,7 +609,7 @@ Menu.prototype.add2DSymbol = (function () {
 			this.tryAddSymbol = null
 			this.layer.currentState.addSymbol = null;
 			this.layer.currentState.startbuild = index ? "partition" : "wall";
-			
+
 		},
 		menuitemdoors: function (index, id) {
 			this.layer.currentState.startbuild = null
@@ -641,7 +627,7 @@ Menu.prototype.add2DSymbol = (function () {
 		var result = /\d$/.exec(target.id)
 		var instructions = result && target.id.substr(0, result.index)
 
-		if (strategy[instructions]){
+		if (strategy[instructions]) {
 			strategy[instructions].call(this, Number(result[0]), result.input)
 			e.stopPropagation()
 		}
@@ -828,8 +814,7 @@ Menu.prototype.addGround = function (e) {
 Menu.prototype.opened = function (e) {
 	if (e.currentTarget.className == "menu-item menu-subitem") {
 		e.currentTarget.className = "menu-item menu-subitem selected opened";
-	}
-	else if (e.currentTarget.className == "menu-item menu-subitem selected opened") {
+	} else if (e.currentTarget.className == "menu-item menu-subitem selected opened") {
 		e.currentTarget.className = "menu-item menu-subitem";
 	}
 };
@@ -837,15 +822,12 @@ Menu.prototype.opened = function (e) {
 Menu.prototype.opened2 = function (e) {
 	if (e.currentTarget.className == "menu-item menu-subitem") {
 		e.currentTarget.className = "menu-item menu-subitem selected opened";
-	}
-	else if (e.currentTarget.className == "menu-item menu-subitem selected opened") {
+	} else if (e.currentTarget.className == "menu-item menu-subitem selected opened") {
 		if (e.target.id == this.layer.parameter.drawDecorateMenuItemsId[0]) {
 			e.currentTarget.className = "menu-item menu-subitem";
-		}
-		else if (e.target.id == this.layer.parameter.drawDecorateMenuItemsId[1]) {
+		} else if (e.target.id == this.layer.parameter.drawDecorateMenuItemsId[1]) {
 			e.currentTarget.className = "menu-item menu-subitem";
-		}
-		else if (e.target.id == this.layer.parameter.drawDecorateMenuItemsId[2]) {
+		} else if (e.target.id == this.layer.parameter.drawDecorateMenuItemsId[2]) {
 			e.currentTarget.className = "menu-item menu-subitem";
 		}
 	}
@@ -885,8 +867,7 @@ Menu.prototype.addSelectTab = function (e) {
 	var container3d = document.getElementById("container3d");
 	if (e.currentTarget.id == "draw2D") {
 		this.show2D();
-	}
-	else if (e.currentTarget.id == "furnishing3D") {
+	} else if (e.currentTarget.id == "furnishing3D") {
 		container3d.style.display = "block";
 		container3d.style.cursor = "default";
 		container2d.style.display = "none";
@@ -901,11 +882,11 @@ Menu.prototype.addSelectTab = function (e) {
 		for (var i = 0; i < this.layer.parameter.draw3DMenuItemsId.length; ++i) {
 			document.getElementById(this.layer.parameter.draw3DMenuItemsId[i]).style.display = "block";
 		}
+
 		Show3DBase();
 		document.getElementById("lock-icon").classList.remove("hidden");
 		document.getElementById("transparencyButton").classList.remove("hidden");
-	}
-	else if (e.currentTarget.id == "decorate3D") {
+	} else if (e.currentTarget.id == "decorate3D") {
 		if (container2d.style.display == "block") {
 			container3d.style.display = "block";
 			container3d.style.cursor = "default";
@@ -915,8 +896,7 @@ Menu.prototype.addSelectTab = function (e) {
 				document.getElementById(this.layer.parameter.draw2DMenuItemsId[i]).style.display = "none";
 			}
 			Show3DBase();
-		}
-		else {
+		} else {
 			for (var i = 0; i < this.layer.parameter.draw3DMenuItemsId.length; ++i) {
 				document.getElementById(this.layer.parameter.draw3DMenuItemsId[i]).style.display = "none";
 			}
@@ -1148,8 +1128,7 @@ Menu.prototype.editProduct = function (e) {
 			mesh.refreshBoundingInfo();
 
 			my3DEngine.refreshSelectMesh(mesh);
-		}
-		else if (my3DEngine.modelLoader.currentPhotoMesh != null) {
+		} else if (my3DEngine.modelLoader.currentPhotoMesh != null) {
 			var mesh = my3DEngine.modelLoader.currentPhotoMesh;
 			var newscal = new BABYLON.Vector2(length / lastlength * mesh.scaling.x.toFixed(2), height / lastheight * mesh.scaling.y.toFixed(2));
 			if (length != lastlength) {
@@ -1212,11 +1191,9 @@ Menu.prototype.openProduct = function (e) {
 		img.id = "product" + id;
 		if (type == 1) {
 			img.addEventListener("click", showPhoFrame);
-		}
-		else if (type == 2) {
+		} else if (type == 2) {
 			img.addEventListener("click", showPicture);
-		}
-		else {
+		} else {
 			img.addEventListener("click", showProduct3D);
 		}
 
@@ -1250,8 +1227,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("c2", "床2");
 		addProductItem("c3", "床3");
 		addProductItem("c4", "床4");
-	}
-	else if (e.target.innerHTML.indexOf(">沙发</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">沙发</span>") > 0) {
 		productCount = 12;
 		addProductItem("s1", "沙发1");
 		addProductItem("d", "沙发2");
@@ -1265,8 +1241,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("s10", "沙发10");
 		addProductItem("s11", "沙发11");
 		addProductItem("s12", "沙发12");
-	}
-	else if (e.target.innerHTML.indexOf(">椅子</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">椅子</span>") > 0) {
 		productCount = 10;
 		addProductItem("y1", "椅子1");
 		addProductItem("y2", "椅子2");
@@ -1278,8 +1253,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("y8", "椅子8");
 		addProductItem("y9", "椅子9");
 		addProductItem("y10", "椅子10");
-	}
-	else if (e.target.innerHTML.indexOf(">柜子</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">柜子</span>") > 0) {
 		productCount = 24;
 		addProductItem("g1", "柜子1");
 		addProductItem("g2", "柜子2");
@@ -1306,8 +1280,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("g23", "柜子23");
 		addProductItem("g24", "柜子24");
 		addProductItem("g25", "柜子25");
-	}
-	else if (e.target.innerHTML.indexOf(">桌子</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">桌子</span>") > 0) {
 		productCount = 6;
 		addProductItem("z1", "桌子1");
 		addProductItem("z2", "桌子2");
@@ -1326,8 +1299,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("test1","桌子13");
 		addProductItem("test2","桌子14");
 		*/
-	}
-	else if (e.target.innerHTML.indexOf(">古董</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">古董</span>") > 0) {
 		productCount = 17;
 		addProductItem("11", "古董1");
 		addProductItem("12", "古董2");
@@ -1346,8 +1318,7 @@ Menu.prototype.openProduct = function (e) {
 		addProductItem("67", "古董16");
 		addProductItem("84", "古董17");
 		addProductItem("86", "古董18");
-	}
-	else if (e.target.innerHTML.indexOf(">相框</span>") > 0) {
+	} else if (e.target.innerHTML.indexOf(">相框</span>") > 0) {
 		//productCount=11;
 		productCount = 1;
 
@@ -1395,8 +1366,7 @@ Menu.prototype.deleteWall = function (e) {
 				var symbol2d = this.layer.vectors[id].symbol2Ds[key];
 				if (symbol2d.attributes.wallstartindex == index) {
 					this.layer.deleteSymbol(symbol2d.id, symbol2d.attributes.wallId);
-				}
-				else {
+				} else {
 					symbol2d.wallstartindex = mapping[symbol2d.wallstartindex];
 					symbol2d.wallendindex = mapping[symbol2d.wallendindex];
 				}
@@ -1469,8 +1439,7 @@ Menu.prototype.deleteWall = function (e) {
 				var symbol2d = this.layer.vectors[id].symbol2Ds[key];
 				if (symbol2d.attributes.wallstartindex == index) {
 					this.layer.deleteSymbol(symbol2d.id, symbol2d.attributes.wallId);
-				}
-				else if (symbol2d.attributes.wallstartindex > index) {
+				} else if (symbol2d.attributes.wallstartindex > index) {
 					symbol2d.wallstartindex = mapping[symbol2d.wallstartindex];
 					symbol2d.wallendindex = mapping[symbol2d.wallendindex];
 				}
@@ -1524,4 +1493,8 @@ Menu.prototype.initEdit2D = function (wallid, index) {
 
 };
 
-Menu.prototype.Events = [["click", Menu.prototype.add2DSymbol], ["click", Menu.prototype.addSelectTab], ["click", Menu.prototype.addGround]];
+Menu.prototype.Events = [
+	["click", Menu.prototype.add2DSymbol],
+	["click", Menu.prototype.addSelectTab],
+	["click", Menu.prototype.addGround]
+];