Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
923cda7e
Commit
923cda7e
authored
Aug 20, 2015
by
Amanda Ghassaei
Browse files
save assembler file
parent
ec150bde
Changes
9
Hide whitespace changes
Inline
Side-by-side
css/main.css
View file @
923cda7e
...
...
@@ -468,12 +468,12 @@ label {
left
:
245px
;
}
.a
ssemblerTree
>
label
{
.a
lternatingColorList
>
label
{
padding-right
:
10px
;
width
:
100%
;
}
.a
ssemblerTree
{
.a
lternatingColorList
{
display
:
inline-block
;
width
:
100%
;
height
:
35px
;
...
...
@@ -481,6 +481,10 @@ label {
border
:
1px
solid
#ddd
;
}
.alternatingColorList.evenListItem
{
background-color
:
#ddd
;
}
.dropdown-menu
>
li
>
a
{
padding
:
6px
9px
;
}
...
...
js/cam/assemblers/Assembler.js
View file @
923cda7e
...
...
@@ -18,6 +18,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
this
.
relative
=
json
.
relative
;
this
.
camProcesses
=
json
.
camProcesses
;
this
.
numMaterials
=
json
.
numMaterials
;
this
.
name
=
json
.
name
;
this
.
object3D
=
new
THREE
.
Object3D
();
...
...
@@ -292,9 +293,23 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
};
Assembler
.
prototype
.
saveJSON
=
function
(){
return
{
}
var
json
=
this
.
toJSON
();
json
.
lattice
=
{
scale
:
lattice
.
get
(
"
scale
"
),
units
:
lattice
.
get
(
"
units
"
)
};
json
.
defaults
=
{
camStrategy
:
cam
.
get
(
"
camStrategy
"
),
placementOrder
:
cam
.
get
(
"
placementOrder
"
),
camProcess
:
cam
.
get
(
"
camProcess
"
),
rapidHeight
:
cam
.
get
(
"
rapidHeight
"
),
rapidHeightRelative
:
cam
.
get
(
"
rapidHeightRelative
"
),
safeHeight
:
cam
.
get
(
"
safeHeight
"
),
originPosition
:
cam
.
get
(
"
originPosition
"
),
rapidSpeeds
:
cam
.
get
(
"
rapidSpeeds
"
),
feedRate
:
cam
.
get
(
"
feedRate
"
)
};
return
json
;
};
Assembler
.
prototype
.
toJSON
=
function
(){
...
...
@@ -307,6 +322,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
stockJSON
[
id
]
=
thisStock
.
toJSON
();
});
return
{
name
:
this
.
name
,
components
:
componentsJSON
,
stock
:
stockJSON
,
translation
:
this
.
translation
,
...
...
js/cam/assemblers/Component.js
View file @
923cda7e
...
...
@@ -20,6 +20,7 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
this
.
motionVector
=
new
THREE
.
Vector3
();
if
(
json
.
centerOfRotation
)
this
.
centerOfRotation
=
new
THREE
.
Vector3
(
json
.
centerOfRotation
.
x
,
json
.
centerOfRotation
.
y
,
json
.
centerOfRotation
.
z
);
if
(
json
.
motionVector
)
this
.
motionVector
.
set
(
json
.
motionVector
.
x
,
json
.
motionVector
.
y
,
json
.
motionVector
.
z
);
this
.
stlJSON
=
json
.
stl
;
this
.
postReset
();
...
...
@@ -300,7 +301,8 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
isStatic
:
this
.
isStatic
,
rotary
:
this
.
rotary
,
motionVector
:
this
.
motionVector
,
centerOfRotation
:
this
.
centerOfRotation
centerOfRotation
:
this
.
centerOfRotation
,
stl
:
this
.
stlJSON
}
};
...
...
js/cam/assemblers/StockComponent.js
View file @
923cda7e
...
...
@@ -14,7 +14,7 @@ define(['underscore', 'cam', 'three', 'component', 'lattice', 'threeModel'],
var
self
=
this
;
this
.
_makeCell
(
json
.
description
,
function
(
cell
){
self
.
cell
=
cell
;
self
.
_setPosition
(
cell
,
json
.
posi
tion
,
json
.
rotation
);
self
.
_setPosition
(
cell
,
json
.
transla
tion
,
json
.
rotation
);
self
.
object3D
.
add
(
cell
.
getObject3D
());
});
}
...
...
@@ -81,7 +81,10 @@ define(['underscore', 'cam', 'three', 'component', 'lattice', 'threeModel'],
StockComponent
.
prototype
.
toJSON
=
function
(){
var
json
=
Component
.
prototype
.
toJSON
.
call
(
this
);
json
.
material
=
this
.
cell
.
materialName
json
.
description
=
{
materialName
:
this
.
cell
.
materialName
,
length
:
this
.
cell
.
getLength
()
};
return
json
;
};
...
...
js/menus/AssemblerSetupMenuView.js
View file @
923cda7e
...
...
@@ -11,7 +11,8 @@ define(['jquery', 'underscore', 'menuParent', 'camPlist', 'cam', 'text!assembler
events
:
{
"
click .editMachineComponent
"
:
"
_editMachineComponent
"
,
"
click .editMachineCode
"
:
"
_editMachineCode
"
,
"
click #newMachineComponent
"
:
"
_newComponent
"
"
click #newMachineComponent
"
:
"
_newComponent
"
,
"
click #saveMachineConfig
"
:
"
_save
"
},
_initialize
:
function
(){
...
...
@@ -52,6 +53,13 @@ define(['jquery', 'underscore', 'menuParent', 'camPlist', 'cam', 'text!assembler
this
.
model
.
set
(
"
currentNav
"
,
"
navMachineComponent
"
);
},
_save
:
function
(
e
){
e
.
preventDefault
();
require
([
'
fileSaver
'
],
function
(
fileSaver
){
fileSaver
.
saveMachineConfig
(
cam
.
get
(
"
assembler
"
).
saveJSON
());
});
},
_makeTemplateJSON
:
function
(){
return
_
.
extend
(
this
.
model
.
toJSON
(),
cam
.
toJSON
(),
cam
.
get
(
"
assembler
"
).
toJSON
());
},
...
...
js/menus/templates/AssemblerSetupMenuView.html
View file @
923cda7e
...
...
@@ -3,8 +3,10 @@ Parent/Child Tree:<br/><br/>
<
%
_.each
(
tree
,
function
(
level
,
id
){
%
>
<
%
var
component =
components[id]
||
stock
[
id
];
%
>
<
%
treeLevel
++;
%
>
<div
class=
"assemblerTree"
<%
if
(
treeLevel
%2
==
0){
%
>
style="background-color:#ddd"
<
%
}
%
>
>
<label
style=
"padding-left:<%= level*10 + 20 %>px"
><
%=
component.name
%
>
<a
data-id=
"<%= id %>"
class=
"editMachineComponent pull-right"
href=
"#"
>
Edit
</a></label></div><br/>
<div
class=
"alternatingColorList<% if (treeLevel%2 == 0){ %> evenListItem <% } %>"
>
<label
style=
"padding-left:<%= level*10 + 20 %>px"
><
%=
component.name
%
>
<a
data-id=
"<%= id %>"
class=
"editMachineComponent pull-right"
href=
"#"
>
Edit
</a></label>
</div><br/>
<
%
});
%
><br/>
<a
href=
"#"
id=
"newMachineComponent"
class=
" btn halfWidth btn-lg btn-default"
>
+ Component
</a>
<a
href=
"#"
id=
"addStock"
class=
" btn halfWidth btn-lg btn-default pull-right"
>
+ Stock
</a><br/><br/>
...
...
@@ -16,6 +18,7 @@ Rotation (xyz):
<input
data-property=
"rotation"
data-key=
"x"
value=
"<%= rotation.x %>"
placeholder=
"X"
class=
"form-control floatInput assembler"
type=
"text"
>
<input
data-property=
"rotation"
data-key=
"y"
value=
"<%= rotation.y %>"
placeholder=
"Y"
class=
"form-control floatInput assembler"
type=
"text"
>
<input
data-property=
"rotation"
data-key=
"z"
value=
"<%= rotation.z %>"
placeholder=
"Z"
class=
"form-control floatInput assembler"
type=
"text"
><br/><br/>
Scale:
<input
data-property=
"scale"
value=
"<%= scale %>"
placeholder=
"Scale"
class=
"form-control floatInput assembler"
type=
"text"
><br/><br/>
Edit Code:
<br/><br/>
Context Variables
<a
class=
"editMachineCode"
data-name=
"customFunctionsContext"
href=
"#"
>
Edit
</a><br/>
...
...
@@ -27,4 +30,4 @@ Move XY <a class="editMachineCode" data-name="customMoveXY" href="#">Edit</a><br
Change Z
<a
class=
"editMachineCode"
data-name=
"customChangeZLayer"
href=
"#"
>
Edit
</a><br/>
Place part
<a
class=
"editMachineCode"
data-name=
"customPlacePart"
href=
"#"
>
Edit
</a><br/>
Footer
<a
class=
"editMachineCode"
data-name=
"customFooter"
href=
"#"
>
Edit
</a><br/><br/>
<a
href=
"#"
id=
"saveMachine
ToFiles
"
class=
" btn btn-block btn-lg btn-success"
>
Save Machine Files
</a><br/>
<a
href=
"#"
id=
"saveMachine
Config
"
class=
" btn btn-block btn-lg btn-success"
>
Save Machine Files
</a><br/>
js/menus/templates/EditComponentMenuView.html
View file @
923cda7e
...
...
@@ -62,7 +62,7 @@ Parent:
<
%
}
else
{
%
>
Material:
<div
class=
"btn-group"
>
<button
data-toggle=
"dropdown"
class=
"btn dropdown-toggle"
type=
"button"
><
%=
materials
[
thisComponent.material
].
name
%
><span
class=
"caret"
></span></button>
<button
data-toggle=
"dropdown"
class=
"btn dropdown-toggle"
type=
"button"
><
%=
materials
[
thisComponent.
description.
material
Name
].
name
%
><span
class=
"caret"
></span></button>
<ul
role=
"menu"
class=
"dropdown-menu"
>
<
%
_.each
(
allMaterials
[
materialClass
],
function
(
material
,
key
){
%
>
<li><a
class=
"stockMaterial dropdownSelector"
data-id=
"<%= key %>"
href=
"#"
>
...
...
js/models/FileSaver.js
View file @
923cda7e
...
...
@@ -6,25 +6,25 @@
define
([
'
underscore
'
,
'
fileSaverLib
'
,
'
lattice
'
,
'
materials
'
,
'
ribbon
'
,
'
menuWrapper
'
],
function
(
_
,
saveAs
,
lattice
,
materials
,
ribbon
,
menuWrapper
){
function
_saveFile
(
data
,
name
,
extension
){
var
blob
=
new
Blob
([
data
],
{
type
:
"
text/plain;charset=utf-8
"
});
var
blob
=
new
Blob
([
JSON
.
stringify
(
data
,
null
,
'
\t
'
)
],
{
type
:
"
text/plain;charset=utf-8
"
});
saveAs
(
blob
,
name
+
extension
);
}
// function save(name){
// if (!name || name == "" || name == undefined) name = "file";
// var data =
JSON.stringify(
{
// var data = {
// lattice:_getLatticeDataToSave(),
//// assembler:_getAssemblerDataToSave()
// }
)
;
// };
// _saveFile(data, name, ".json");
// }
function
save
(
name
){
if
(
!
name
||
name
==
""
||
name
==
undefined
)
name
=
"
DM Assembly
"
;
var
data
=
JSON
.
stringify
(
{
var
data
=
{
assembly
:
_getLatticeDataToSave
(),
materials
:
_getMaterialsDataToSave
()
}
)
;
};
_saveFile
(
data
,
name
,
"
.json
"
);
}
...
...
@@ -36,17 +36,21 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
if
(
!
name
||
name
==
""
||
name
==
undefined
)
name
=
"
user
"
;
var
latticeData
=
_
.
omit
(
_getLatticeDataToSave
(),
[
"
cells
"
,
"
cellsMin
"
,
"
cellsMax
"
,
"
numCells
"
]);
var
assemblerData
=
_
.
omit
(
_getAssemblerDataToSave
(),
[
"
dataOut
"
,
"
needsPostProcessing
"
,
"
editsMadeToProgram
"
]);
var
data
=
JSON
.
stringify
(
{
var
data
=
{
lattice
:
latticeData
,
assembler
:
assemblerData
}
)
;
};
_saveFile
(
data
,
name
,
"
.user
"
);
}
function
saveMaterial
(
id
,
material
){
var
data
=
{
materials
:{}};
data
.
materials
[
id
]
=
material
||
_getMaterialDataToSave
(
id
);
_saveFile
(
JSON
.
stringify
(
data
),
data
.
materials
[
id
].
name
,
"
.json
"
);
_saveFile
(
data
,
data
.
materials
[
id
].
name
,
"
.json
"
);
}
function
saveMachineConfig
(
data
){
_saveFile
(
data
,
"
Machine Config
"
,
"
.json
"
);
}
function
_getAssemblerDataToSave
(){
...
...
@@ -110,6 +114,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
// save: save,
save
:
save
,
saveMaterial
:
saveMaterial
,
saveMachineConfig
:
saveMachineConfig
,
// saveAssembler: saveAssembler,
// saveUser: saveUser,
loadFile
:
loadFile
...
...
js/plists/CamPList.js
View file @
923cda7e
...
...
@@ -106,7 +106,7 @@ define(['three'], function(THREE){
},
name
:
"
Stock 1
"
,
parent
:
"
zAxis
"
,
posi
tion
:
{
x
:
0
,
y
:
0
,
z
:
0
}
transla
tion
:
{
x
:
0
,
y
:
0
,
z
:
0
}
},
stock2
:
{
description
:{
...
...
@@ -115,7 +115,7 @@ define(['three'], function(THREE){
},
name
:
"
Stock 2
"
,
parent
:
"
zAxis
"
,
posi
tion
:
{
x
:
26
,
y
:
0.236
,
z
:
0
}
transla
tion
:
{
x
:
26
,
y
:
0.236
,
z
:
0
}
}
},
lattice
:{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment