Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
420a3874
Commit
420a3874
authored
Aug 21, 2015
by
Amanda Ghassaei
Browse files
load custom scripts
parent
a98232ec
Changes
10
Hide whitespace changes
Inline
Side-by-side
dependencies/jsonfn.js
0 → 100755
View file @
420a3874
/**
* JSONfn - javascript (both node.js and browser) plugin to stringify,
* parse and clone objects with Functions, Regexp and Date.
*
* Version - 0.60.00
* Copyright (c) 2012 - 2014 Vadim Kiryukhin
* vkiryukhin @ gmail.com
* http://www.eslinstructor.net/jsonfn/
*
* Licensed under the MIT license ( http://www.opensource.org/licenses/mit-license.php )
*
* USAGE:
* browser:
* JSONfn.stringify(obj);
* JSONfn.parse(str[, date2obj]);
* JSONfn.clone(obj[, date2obj]);
*
* nodejs:
* var JSONfn = require('path/to/json-fn');
* JSONfn.stringify(obj);
* JSONfn.parse(str[, date2obj]);
* JSONfn.clone(obj[, date2obj]);
*
*
* @obj - Object;
* @str - String, which is returned by JSONfn.stringify() function;
* @date2obj - Boolean (optional); if true, date string in ISO8061 format
* is converted into a Date object; otherwise, it is left as a String.
*/
"
use strict
"
;
(
function
(
exports
)
{
exports
.
stringify
=
function
(
obj
)
{
return
JSON
.
stringify
(
obj
,
function
(
key
,
value
)
{
if
(
value
instanceof
Function
||
typeof
value
==
'
function
'
)
{
return
value
.
toString
();
}
if
(
value
instanceof
RegExp
)
{
return
'
_PxEgEr_
'
+
value
;
}
return
value
;
});
};
exports
.
parse
=
function
(
str
,
date2obj
)
{
var
iso8061
=
date2obj
?
/^
(\d{4})
-
(\d{2})
-
(\d{2})
T
(\d{2})
:
(\d{2})
:
(\d{2}(?:\.\d
*
)?)
Z$/
:
false
;
return
JSON
.
parse
(
str
,
function
(
key
,
value
)
{
var
prefix
;
if
(
typeof
value
!=
'
string
'
)
{
return
value
;
}
if
(
value
.
length
<
8
)
{
return
value
;
}
prefix
=
value
.
substring
(
0
,
8
);
if
(
iso8061
&&
value
.
match
(
iso8061
))
{
return
new
Date
(
value
);
}
if
(
prefix
===
'
function
'
)
{
return
eval
(
'
(
'
+
value
+
'
)
'
);
}
if
(
prefix
===
'
_PxEgEr_
'
)
{
return
eval
(
value
.
slice
(
8
));
}
return
value
;
});
};
exports
.
clone
=
function
(
obj
,
date2obj
)
{
return
exports
.
parse
(
exports
.
stringify
(
obj
),
date2obj
);
};
}(
typeof
exports
===
'
undefined
'
?
(
window
.
JSONfn
=
{})
:
exports
));
js/cam/assemblers/Assembler.js
View file @
420a3874
...
...
@@ -310,6 +310,17 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
rapidSpeeds
:
cam
.
get
(
"
rapidSpeeds
"
),
feedRate
:
cam
.
get
(
"
feedRate
"
)
};
json
.
customPost
=
{
customFunctionsContext
:
this
.
customFunctionsContext
,
customHeader
:
this
.
customHeader
.
toString
(),
customFooter
:
this
.
customFooter
.
toString
(),
customHome
:
this
.
customHome
.
toString
(),
customPickUpStock
:
this
.
customPickUpStock
.
toString
(),
customChangeZLayer
:
this
.
customChangeZLayer
.
toString
(),
customMoveXY
:
this
.
customMoveXY
.
toString
(),
customPlacePart
:
this
.
customPlacePart
.
toString
(),
customCalcPositionOffsets
:
this
.
customCalcPositionOffsets
.
toString
()
};
return
{
assembler
:
json
};
};
...
...
@@ -328,9 +339,6 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
stock
:
stockJSON
,
tree
:
this
.
tree
||
this
.
buildComponentTree
()
});
json
.
customPost
=
{
};
return
json
;
};
...
...
js/cam/assemblers/AssemblerPost.js
View file @
420a3874
...
...
@@ -20,7 +20,7 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
// stockPosition: THREE.Vector3 - not used for your machine
// units: mm
this
.
customFunctionsContext
=
{
this
.
customFunctionsContext
=
json
.
customPost
.
customFunctionsContext
||
{
zClearHeight
:
8
,
//height above part to clear during assembly
zPreload
:
0.2
,
stockWait
:
0.75
,
//seconds
...
...
@@ -33,6 +33,7 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
data
+=
this
.
customHome
(
exporter
,
settings
,
context
);
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customHeader
"
);
this
.
customFooter
=
function
(
exporter
,
settings
,
context
){
var
data
=
""
;
...
...
@@ -40,17 +41,23 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customFooter
"
);
this
.
customHome
=
function
(
exporter
,
settings
,
context
){
var
data
=
""
;
data
+=
exporter
.
goHome
(
settings
);
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customHome
"
);
this
.
customPickUpStock
=
function
(
exporter
,
settings
,
context
){
//not relevant for your assembler
var
data
=
""
;
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customPickUpStock
"
);
this
.
customChangeZLayer
=
function
(
currentIndex
,
lastIndex
,
exporter
,
settings
,
context
){
var
data
=
""
;
if
(
lastIndex
===
null
||
(
currentIndex
.
z
-
lastIndex
.
z
)
%
2
!=
0
){
...
...
@@ -60,6 +67,8 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customChangeZLayer
"
);
this
.
customMoveXY
=
function
(
position
,
lastPosition
,
index
,
exporter
,
settings
,
context
){
//already offset for dual heads
var
data
=
""
;
...
...
@@ -83,6 +92,8 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customMoveXY
"
);
this
.
customPlacePart
=
function
(
position
,
index
,
material
,
exporter
,
settings
,
context
){
//already offset for dual heads
var
data
=
""
;
data
+=
exporter
.
rapidZ
(
position
.
z
+
settings
.
safeHeight
,
settings
);
...
...
@@ -103,6 +114,8 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
return
data
;
};
this
.
_loadFunction
(
json
.
customPost
,
"
customPlacePart
"
);
this
.
customCalcPositionOffsets
=
function
(
index
,
position
,
material
,
settings
,
context
){
//this feeds into moveXY and placePart functions
...
...
@@ -123,13 +136,13 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
return
null
;
}
position
.
sub
(
stock
.
getPosition
().
multiplyScalar
(
settings
.
scale
));
return
position
;
}
this
.
_loadFunction
(
json
.
customPost
,
"
customCalcPositionOffsets
"
);
}
...
...
@@ -140,6 +153,16 @@ define(['underscore', 'appState', 'lattice', 'cam'], function(_, appState, latti
AssemblerPost
.
prototype
.
_loadFunction
=
function
(
json
,
name
){
if
(
json
[
name
]
===
undefined
)
return
;
var
js
=
"
js =
"
+
json
[
name
];
try
{
eval
(
js
);
this
[
name
]
=
js
;
}
catch
(
error
){
console
.
log
(
error
.
message
);
}
};
...
...
js/cam/assemblers/Component.js
View file @
420a3874
...
...
@@ -50,7 +50,6 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
var
wrapper
=
new
THREE
.
Object3D
();
wrapper
.
add
(
child
.
getObject3D
());
wrapper
.
position
.
set
(
-
this
.
centerOfRotation
.
x
,
-
this
.
centerOfRotation
.
y
,
-
this
.
centerOfRotation
.
z
);
console
.
log
(
"
here
"
);
this
.
secondWrapper
=
new
THREE
.
Object3D
();
this
.
secondWrapper
.
add
(
wrapper
);
this
.
object3D
.
add
(
this
.
secondWrapper
);
...
...
js/cells/DMACell.js
View file @
420a3874
...
...
@@ -90,7 +90,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
DMACell
.
prototype
.
getIndex
=
function
(){
if
(
!
this
.
index
)
{
console
.
warn
(
"
no index for this cell
"
);
//
console.warn("no index for this cell");
return
null
;
}
return
this
.
index
.
clone
();
...
...
@@ -98,7 +98,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', '
DMACell
.
prototype
.
getAbsoluteIndex
=
function
(){
if
(
!
this
.
index
)
{
console
.
warn
(
"
no index for this cell
"
);
//
console.warn("no index for this cell");
return
null
;
}
if
(
!
this
.
superCell
)
return
this
.
getIndex
();
...
...
js/main.js
View file @
420a3874
...
...
@@ -16,7 +16,7 @@ require.config({
numeric
:
'
../dependencies/numeric-1.2.6
'
,
codeMirrorJS
:
'
../dependencies/codemirror/javascript
'
,
codeMirror
:
'
../dependencies/codemirror/codemirror
'
,
acor
n
:
'
../dependencies/
acorn/acor
n
'
,
jsonF
n
:
'
../dependencies/
jsonf
n
'
,
//three
three
:
'
../dependencies/three
'
,
...
...
@@ -235,6 +235,9 @@ require.config({
},
'
numeric
'
:
{
exports
:
'
numeric
'
},
'
jsonFn
'
:
{
exports
:
'
JSONfn
'
}
}
...
...
js/menus/ScriptView.js
View file @
420a3874
...
...
@@ -4,8 +4,8 @@
define
([
'
jquery
'
,
'
underscore
'
,
'
backbone
'
,
'
appState
'
,
'
codeMirror
'
,
'
acorn
'
,
'
globals
'
,
'
text!menus/templates/ScriptView.html
'
,
'
codeMirrorJS
'
],
function
(
$
,
_
,
Backbone
,
appState
,
CodeMirror
,
acorn
,
globals
,
template
){
define
([
'
jquery
'
,
'
underscore
'
,
'
backbone
'
,
'
appState
'
,
'
codeMirror
'
,
'
globals
'
,
'
text!menus/templates/ScriptView.html
'
,
'
codeMirrorJS
'
],
function
(
$
,
_
,
Backbone
,
appState
,
CodeMirror
,
globals
,
template
){
var
ScriptView
=
Backbone
.
View
.
extend
({
...
...
js/menus/templates/AssemblerMenuView.html
View file @
420a3874
...
...
@@ -32,7 +32,8 @@ Strategy:
</ul>
</div><br/><br/>
<
%
if
(camStrategy =
=
"
raster
"){
%
>
Raster Order:
<input
value=
"<%= placementOrder %>"
placeholder=
"Placement Order"
class=
"form-control placementOrder halfWidth"
type=
"text"
><br/><br/>
Raster Order:
<input
value=
"<%= placementOrder %>"
placeholder=
"Placement Order"
class=
"form-control placementOrder halfWidth"
type=
"text"
><br/>
<label>
"YXZ" or "X-YZ" etc
</label><br/><br/>
<
%
}
%
>
<
%
if
(
thisAssembler.numMaterials
>
-1
&&
thisAssembler.numMaterials
<
allCAMMaterialTypes.length
){
%
>
<div
class=
"inlineWarning"
>
Number of materials in assembly exceeds available materials (
<
%=
thisAssembler.numMaterials
%
>
) for assembler type.
</div>
...
...
js/models/FileSaver.js
View file @
420a3874
...
...
@@ -6,8 +6,10 @@
define
([
'
underscore
'
,
'
fileSaverLib
'
,
'
lattice
'
,
'
materials
'
,
'
ribbon
'
,
'
menuWrapper
'
],
function
(
_
,
saveAs
,
lattice
,
materials
,
ribbon
,
menuWrapper
){
function
_saveFile
(
data
,
name
,
extension
){
var
blob
=
new
Blob
([
JSON
.
stringify
(
data
,
null
,
'
\t
'
)],
{
type
:
"
text/plain;charset=utf-8
"
});
saveAs
(
blob
,
name
+
extension
);
// require(['jsonFn'], function(JSONfn){
var
blob
=
new
Blob
([
JSON
.
stringify
(
data
,
null
,
'
\t
'
)],
{
type
:
"
text/plain;charset=utf-8
"
});
saveAs
(
blob
,
name
+
extension
);
// });
}
// function save(name){
...
...
js/plists/CamPList.js
View file @
420a3874
...
...
@@ -133,7 +133,8 @@ define(['three'], function(THREE){
originPosition
:
new
THREE
.
Vector3
(
0
,
0
,
0
),
rapidSpeeds
:{
xy
:
250
,
z
:
250
},
feedRate
:{
xy
:
6
,
z
:
6
}
}
},
customPost
:
{}
}
},
...
...
Write
Preview
Markdown
is supported
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