Commit bf0688d7 authored by amandaghassaei's avatar amandaghassaei
Browse files

save fold options

parent 2269d703
......@@ -336,6 +336,6 @@ svg{
.smallTxt{
font-size: 14px;
}
#stlFilename{
input.form-control.bigInput{
width:300px;
}
......@@ -374,6 +374,7 @@
<script type="text/javascript" src="js/dynamic/dynamicSolver.js"></script>
<script type="text/javascript" src="js/pattern.js"></script>
<script type="text/javascript" src="js/saveSTL.js"></script>
<script type="text/javascript" src="js/saveFOLD.js"></script>
<script type="text/javascript" src="js/importer.js"></script>
......@@ -411,6 +412,7 @@
<li><a class="loadFile" href="#">Import... (SVG / FOLD / txt)</a></li>
<li class="divider"></li>
<li><a id="exportFOLD" href="#">Save Simulation as FOLD...</a></li>
<li><a id="exportSTL" href="#">Save Simulation as STL...</a></li>
<li><a id="saveSVG" href="#">Save Pattern as SVG...</a></li>
<!--<li><a id="saveSVGScreenshot" href="#">Save SVG screenshot</a></li>-->
......@@ -597,9 +599,9 @@
<span aria-hidden="true">&times;</span>
</button>
<p><b>Export STL</b><br/><br/>
Filename: &nbsp;&nbsp;<input id="stlFilename" value="" placeholder="" class="text form-control" type="text"> .stl<br/><br/>
Scale: &nbsp;&nbsp;<input id="stlScale" value="" placeholder="" class="form-control" type="text"><br/><br/>
Dimensions: &nbsp;&nbsp;<b><span id="stlDimensions"></span></b><br/>
Filename: &nbsp;&nbsp;<input id="stlFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/>
Scale: &nbsp;&nbsp;<input value="" placeholder="" class="exportScale form-control" type="text"><br/><br/>
Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/>
<span class="smallTxt">(the STL file format is unitless, but typically assumed to be either in inches or mm)</span><br/><br/>
<label class="bigLabel checkbox" for="doublesidedSTL">
<input id="doublesidedSTL" data-toggle="checkbox" class="custom-checkbox layersSelector" type="checkbox"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
......@@ -614,6 +616,29 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="exportFOLDModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-med">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<p><b>Export FOLD</b><br/><br/>
Filename: &nbsp;&nbsp;<input id="foldFilename" value="" placeholder="" class="bigInput text form-control" type="text"> .stl<br/><br/>
Author: &nbsp;&nbsp;<input id="foldAuthor" value="Amanda Ghassaei" placeholder="" class="bigInput text form-control" type="text"><br/><br/>
Scale: &nbsp;&nbsp;<input value="" placeholder="" class="exportScale form-control" type="text"><br/><br/>
Dimensions: &nbsp;&nbsp;<b><span class="exportDimensions"></span></b><br/>
<span class="smallTxt">(the FOLD file format is unitless)</span><br/><br/>
</p>
</div>
<div class="modal-footer">
<button id="doFOLDsave" type="button" class="btn btn-success" data-dismiss="modal">Save</button>
<button type="button" class="btn btn default" data-dismiss="modal">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="importFoldModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-med">
<div class="modal-content">
......
......@@ -21,19 +21,24 @@ function initControls(globals){
$('#tipsModal').modal('show');
});
setLink("#exportFOLD", function(){
updateDimensions();
$("#foldFilename").val(globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded");
$('#exportFOLDModal').modal('show');
});
setLink("#exportSTL", function(){
updateDimensions();
$("#stlFilename").val(globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded");
$('#exportSTLModal').modal('show');
});
setInput("#stlScale", globals.stlScale, function(val){
globals.stlScale = val;
setInput(".exportScale", globals.exportScale, function(val){
globals.exportScale = val;
updateDimensions();
}, 0);
function updateDimensions(){
var dim = globals.model.getDimensions();
dim.multiplyScalar(globals.stlScale/globals.scale);
$("#stlDimensions").html(dim.x.toFixed(2) + " x " + dim.y.toFixed(2) + " x " + dim.z.toFixed(2));
dim.multiplyScalar(globals.exportScale/globals.scale);
$(".exportDimensions").html(dim.x.toFixed(2) + " x " + dim.y.toFixed(2) + " x " + dim.z.toFixed(2));
}
setCheckbox("#doublesidedSTL", globals.doublesidedSTL, function(val){
globals.doublesidedSTL = val;
......@@ -42,6 +47,9 @@ function initControls(globals){
setLink("#doSTLsave", function(){
saveSTL();
});
setLink("#doFOLDsave", function(){
saveFOLD();
});
setLink("#navPattern", function(){
......
......@@ -55,7 +55,7 @@ function initGlobals(){
filename: null,
extension: null,
doublesidedSTL: false,
stlScale: 1,
exportScale: 1,
userInteractionEnabled: false
......
/**
* Created by amandaghassaei on 5/6/17.
*/
function saveFOLD(){
var geo = new THREE.Geometry().fromBufferGeometry( globals.model.getGeometry() );
if (geo.vertices.length == 0 || geo.faces.length == 0) {
globals.warn("No geometry to save.");
return;
}
if (globals.exportScale != 1){
for (var i=0;i<geo.vertices.length;i++){
geo.vertices[i].multiplyScalar(globals.exportScale);
}
}
// var data = [];
// data.push({geo: geo, offset:new THREE.Vector3(0,0,0), orientation:new THREE.Quaternion(0,0,0,1)});
// var stlBin = geometryToSTLBin(data);
// if (!stlBin) return;
// var blob = new Blob([stlBin], {type: 'application/octet-binary'});
var filename = $("#foldFilename").val();
if (filename == "") filename = globals.filename;
saveAs(blob, filename + ".fold");
}
\ No newline at end of file
......@@ -11,9 +11,9 @@ function saveSTL(){
return;
}
if (globals.stlScale != 1){
if (globals.exportScale != 1){
for (var i=0;i<geo.vertices.length;i++){
geo.vertices[i].multiplyScalar(globals.stlScale);
geo.vertices[i].multiplyScalar(globals.exportScale);
}
}
......
Markdown is supported
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