Commit 4639dcab authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

tree edits

parent 7793b66c
......@@ -479,3 +479,17 @@ label {
background-color: #eee;
border: 1px solid #ddd;
}
.dropdown-menu>li>a{
padding: 6px 9px;
}
.navbar-inverse .navbar-nav > .dropdown > a .caret {
border-top-color: #ddd;
border-bottom-color: #ddd;
}
.navbar-inverse .navbar-nav > .dropdown > a:hover .caret {
border-top-color: #aaa;
border-bottom-color: #aaa;
}
\ No newline at end of file
......@@ -98,6 +98,20 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
});
};
Assembler.prototype.addChild = function(child, object3D){
child._addParent(this, null);
var object3D = object3D || this.object3D;
object3D.add(child.getObject3D());
};
Assembler.prototype._removeChild = function(child){
if (this.object3D.children.indexOf(child.stl) == -1){
console.warn("not a child");
return;
}
this.object3D.remove(child.getObject3D());
};
Assembler.prototype.setVisibility = function(visible){
this.object3D.visible = visible;
this._setTranslucent();
......@@ -119,12 +133,18 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
this.hideStock();
};
Assembler.prototype.buildComponentTree = function(index, parent, tree){
Assembler.prototype.getComponent = function(id){
return this.components[id] || this.stock[id];
};
Assembler.prototype.buildComponentTree = function(){
var tree = this._recursiveTreeBuilding(0, null, {});
console.log(tree);
this.tree = tree;
};
Assembler.prototype._recursiveTreeBuilding = function(index, parent, tree){
var self = this;
if (parent === undefined){
index = 0;
tree = {};
}
_.each(this.stock, function(thisStock, key){
if (thisStock.parent == parent) {
tree[key] = index;
......@@ -133,10 +153,10 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
_.each(this.components, function(component, key){
if (component.parent == parent) {
tree[key] = index;
self.buildComponentTree(index+1, key, tree);
self._recursiveTreeBuilding(index+1, key, tree);
}
});
this.tree = tree;
return tree;
};
......
......@@ -11,9 +11,14 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
this.object3D = new THREE.Object3D();
this.id = id || "id" + id++;
this.name = json.name || "";
this.parent = json.parent;
this.parent = null;
if (json.parent) this.parent = json.parent;
this.parentObject = null;
this.children = [];
this.isStatic = json.isStatic;
this.rotary = json.rotary;
this.motionVector = new THREE.Vector3();
if (json.motionVector) this.motionVector.set(json.motionVector.x, json.motionVector.y, json.motionVector.z);
}
//assembler setup
......@@ -34,7 +39,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
return;
}
this.children.push(child);
child.addParent(this);
child._addParent(this, this.id);
this.object3D.add(child.getObject3D());
};
......@@ -46,7 +51,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
return false;
};
Component.prototype.removeChild = function(child){
Component.prototype._removeChild = function(child){
if (this.children.indexOf(child) == -1){
console.warn("not a child");
return;
......@@ -55,13 +60,13 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
this.object3D.remove(child.getObject3D());
};
Component.prototype.addParent = function(parent){
Component.prototype._addParent = function(parent, id){
if (this.parentObject) {
this.parentObject.removeChild(this);
this.parentObject._removeChild(this);
this.parentObject = null;
}
this.parentObject = parent;
this.parent = parent.id;
this.parent = id;
};
Component.prototype.getID = function(){
......@@ -176,12 +181,12 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
//helper
Component.prototype.destroy = function(){
if (this.parentObject) this.parentObject.removeChild(this);
if (this.parentObject) this.parentObject._removeChild(this);
this.parentObject = null;
this.parent = null;
var self = this;
_.each(this.children, function(child){
self.removeChild(child);
self._removeChild(child);
});
this.children = null;
this.name = null;
......@@ -201,7 +206,10 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
parent: this.parent || "",
translation: this.object3D.position,
scale: this.object3D.scale.x,
rotation: this.object3D.rotation
rotation: this.object3D.rotation,
isStatic: this.isStatic,
rotary: this.rotary,
motionVector: this.motionVector
}
};
......
......@@ -18,6 +18,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'text!editComponen
_initialize: function(){
},
getPropertyOwner: function($target){
if ($target.hasClass("component")) return cam.get("assembler").getComponent(cam.get("editingComponent"));
return null;
},
_save: function(e){
e.preventDefault();
console.log("save component");
......@@ -42,11 +47,17 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'text!editComponen
_removeChild: function(e){
e.preventDefault();
console.log("remove child");
var id = $(e.target).data("id");
var assembler = cam.get("assembler");
assembler.addChild(assembler.getComponent(id));//add subtree to root
assembler.buildComponentTree();
this.render();
},
_makeTemplateJSON: function(){
return _.extend(this.model.toJSON(), cam.toJSON(), cam.get("assembler").toJSON());
var assembler = cam.get("assembler");
var component = assembler.getComponent(cam.get("editingComponent"));
return _.extend(this.model.toJSON(), cam.toJSON(), assembler.toJSON(), {thisComponent: component.toJSON()});
},
template: _.template(template)
......
......@@ -203,7 +203,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex
_setOwnerProperty: function(owner, property, value){
if (owner instanceof Backbone.Model) owner.set(property, value);
else owner[property] = value;
else {
owner[property] = value;
this.menu.render();
}
},
......
<% var thisComponent = components[editingComponent] || stock[editingComponent]; %>
<% var isStock = stock[editingComponent]; %>
Name: &nbsp;&nbsp;<input data-property="name" value="<%= thisComponent.name %>" placeholder="Enter Name" class="seventyFiveWidth form-control textInput component" type="text"><br/><br/>
Parent: &nbsp;&nbsp;
......@@ -31,20 +30,37 @@ Parent: &nbsp;&nbsp;
<% var component = components[id] || stock[id]; %>
<% treeLevel++; %>
<div class="assemblerTree" <% if (treeLevel%2 == 0){ %> style="background-color:#ddd"<% } %> ><label style="padding-left:<%= (level-tree[editingComponent]-1)*10 + 20 %>px"><%= component.name %>
<% if(tree[editingComponent]+1 == level){ %><a data-id="<%= id %>" class="editMachineComponent pull-right" href="#">Remove</a><% } %></label></div><br/>
<% if(tree[editingComponent]+1 == level){ %><a data-id="<%= id %>" class="removeChild pull-right" href="#">Remove</a><% } %></label></div><br/>
<% }); %><br/>
STL: &nbsp;&nbsp;STL Name<br/><br/>
<a id="uploadStl" href="#" class="btn btn-block btn-lg btn-default">Upload STL</a><br/>
Motion:<label class="checkbox pull-right" for="isStatic">
<input id="isStatic" data-property="isStatic" type="checkbox" <% if (thisComponent.isStatic){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="component custom-checkbox">
<span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
Is Static</label><br/>
<% if (!thisComponent.isStatic){ %>
<label class="checkbox" for="isRotary">
<input id="isRotary" data-property="rotary" type="checkbox" <% if (thisComponent.rotary){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="component custom-checkbox">
<span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
Rotary Axis (default is Linear)</label>
Vector (xyz):&nbsp;&nbsp;
<input data-property="motionVector" data-key="x" value="<%= thisComponent.motionVector.x %>" placeholder="X" class="form-control floatInput component" type="text">&nbsp;
<input data-property="motionVector" data-key="y" value="<%= thisComponent.motionVector.y %>" placeholder="Y" class="form-control floatInput component" type="text">&nbsp;
<input data-property="motionVector" data-key="z" value="<%= thisComponent.motionVector.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/>
<!--Jog<br/>-->
<% } %>
<br/>
<!--STL: &nbsp;&nbsp;STL Name<br/><br/>-->
<!--<a id="uploadStl" href="#" class="btn btn-block btn-lg btn-default">Upload STL</a><br/>-->
<% } %>
Offset (xyz):&nbsp;&nbsp;
<input data-property="translation" data-key="x" value="<%= translation.x %>" placeholder="X" class="form-control floatInput component" type="text">&nbsp;
<input data-property="translation" data-key="y" value="<%= translation.y %>" placeholder="Y" class="form-control floatInput component" type="text">&nbsp;
<input data-property="translation" data-key="z" value="<%= translation.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/><br/>
Rotation (xyz):&nbsp;&nbsp;
<input data-property="rotation" data-key="x" value="<%= rotation.x %>" placeholder="X" class="form-control floatInput component" type="text">&nbsp;
<input data-property="rotation" data-key="y" value="<%= rotation.y %>" placeholder="Y" class="form-control floatInput component" type="text">&nbsp;
<input data-property="rotation" data-key="z" value="<%= rotation.z %>" placeholder="Z" class="form-control floatInput component" type="text"><br/><br/>
<% if(!isStock){ %> Scale: &nbsp;&nbsp;<input data-property="scale" value="<%= scale %>" placeholder="Scale" class="form-control floatInput component" type="text"><br/><br/><% } %>
<!--Offset (xyz):&nbsp;&nbsp;-->
<!--<input data-property="translation" data-key="x" value="<%= translation.x %>" placeholder="X" class="form-control floatInput stl" type="text">&nbsp;-->
<!--<input data-property="translation" data-key="y" value="<%= translation.y %>" placeholder="Y" class="form-control floatInput stl" type="text">&nbsp;-->
<!--<input data-property="translation" data-key="z" value="<%= translation.z %>" placeholder="Z" class="form-control floatInput stl" type="text"><br/><br/>-->
<!--Rotation (xyz):&nbsp;&nbsp;-->
<!--<input data-property="rotation" data-key="x" value="<%= rotation.x %>" placeholder="X" class="form-control floatInput stl" type="text">&nbsp;-->
<!--<input data-property="rotation" data-key="y" value="<%= rotation.y %>" placeholder="Y" class="form-control floatInput stl" type="text">&nbsp;-->
<!--<input data-property="rotation" data-key="z" value="<%= rotation.z %>" placeholder="Z" class="form-control floatInput stl" type="text"><br/><br/>-->
<!--<% if(!isStock){ %> Scale: &nbsp;&nbsp;<input data-property="scale" value="<%= scale %>" placeholder="Scale" class="form-control floatInput stl" type="text"><br/><br/><% } %>-->
<a id="finishComponent" href="#" class="btn btn-block btn-lg btn-success">Save <% if(isStock){ %>Stock<% }else{ %>Component<% } %></a><br/>
<a id="deleteComponent" href="#" class="btn btn-halfWidth btn-lg btn-default"><span class="fui-trash"></span> Delete</a>
<a id="cancelComponent" href="#" class="btn btn-halfWidth pull-right btn-lg btn-default">Cancel / Exit</a><br/><br/>
......@@ -45,7 +45,7 @@ define(['three'], function(THREE){
//minBound
//maxBound
parent: "yAxis",
children: ["zAxis"],
motionVector: {x:1, y:0, z:0},
stl: {
filename: "assets/stls/stapler/xAxis.stl",
offset: {x:0,y:0,z:0},
......@@ -60,7 +60,7 @@ define(['three'], function(THREE){
//minBound
//maxBound
parent: "substrate",
children: ["yAxis"],
motionVector: {x:0, y:1, z:0},
stl: {
filename: "assets/stls/stapler/yAxis.stl",
offset: {x:0,y:0,z:0},
......@@ -75,7 +75,7 @@ define(['three'], function(THREE){
//minBound
//maxBound
parent: "xAxis",
children: [],//stock
motionVector: {x:0, y:0, z:1},
stl: {
filename: "assets/stls/stapler/zAxis.stl",
offset: {x:0,y:0,z:0},
......@@ -90,7 +90,7 @@ define(['three'], function(THREE){
//minBound
//maxBound
parent: "frame",
children: ["xAxis"],
isStatic: true,
stl: {
filename: "assets/stls/stapler/frame.stl",
offset: {x:0,y:0,z:0},
......@@ -106,7 +106,7 @@ define(['three'], function(THREE){
//minBound
//maxBound
parent: null,
children: ["yAxis"],
motionVector: {x:0, y:0, z:1},
stl: {
filename: "assets/stls/stapler/substrate.stl",
offset: {x:0,y:0,z:0},
......
import - offset, scale, rotation
parse sparseCells -> cells
hierarchical
- gik dimensions
- single layer gik throwing error on parse
- origin
- rotation
- load composite materials
......@@ -14,4 +14,7 @@ material transformations -> change material of a cell, change in bulk
rendering callbacks
highligher - check mode, do not add cells except in design/composite/material modes
\ No newline at end of file
highligher - check mode, do not add cells except in design/composite/material modes
part stl import and orientation - settings to json
same for machine
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment