From 16fbe4d905f9fbc3945b976f701ff93f8bad5e0b Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 25 Sep 2015 11:12:30 -0400 Subject: [PATCH] eod --- js/API/LatticeAPI.js | 98 +++++++++++++++++++++++++ js/API/MaterialAPI.js | 21 ++++++ js/lattice/Lattice.js | 6 -- js/materials/DMAMaterial.js | 4 +- js/menus/MenuWrapperView.js | 10 ++- js/menus/templates/LatticeMenuView.html | 6 +- 6 files changed, 133 insertions(+), 12 deletions(-) create mode 100644 js/API/LatticeAPI.js create mode 100644 js/API/MaterialAPI.js diff --git a/js/API/LatticeAPI.js b/js/API/LatticeAPI.js new file mode 100644 index 00000000..2f84fa34 --- /dev/null +++ b/js/API/LatticeAPI.js @@ -0,0 +1,98 @@ +/** + * Created by aghassaei on 9/25/15. + */ + + +define(['lattice'], function(lattice){ + + return { + + //getters + + getSize: function(){ + + }, + + getAspectRatio: function(){ + return lattice.get("aspectRatio").clone(); + }, + + getCellType: function(){ + return lattice.get("cellType"); + }, + + getConnectionType: function(){ + return lattice.get("connectionType"); + }, + + getApplicationType: function(){ + return lattice.get("latticeType"); + }, + + getPartType: function(){ + return lattice.get("partType"); + }, + + + //setters + + setAspectRatio: function(x, y, z){ + if (!x || !y || !z || x<0 || y<0 || z<0) {//no 0, undefined, null, or neg #'s + console.warn("invalid aspect ratio params"); + return; + } + lattice.set("aspectRatio", new THREE.Vector3(x, y, z)); + }, + + setCellType: function(cellType){ + + }, + + setConnectionType: function(connectionType){ + + }, + + setApplicationType: function(applicationType){ + + }, + + setPartType: function(partType){ + + }, + + setLatticeType: function(cellType, connectionType, applicationType, partType){ + + }, + + + //cells + + clearCells: function(){ + lattice.clearCells(); + }, + + getSparseCells: function(){ + + }, + + getCells: function(){ + + }, + + loopSparseCells: function(){ + + }, + + loopCells: function(){ + + }, + + + //general + + save: function(filename){ + + } + } + +}); \ No newline at end of file diff --git a/js/API/MaterialAPI.js b/js/API/MaterialAPI.js new file mode 100644 index 00000000..270fed12 --- /dev/null +++ b/js/API/MaterialAPI.js @@ -0,0 +1,21 @@ +/** + * Created by aghassaei on 9/25/15. + */ + + +define([], function(){ + + + function init(){ + + } + + function set(){ + + } + + function destroy(){ + + } + +}); \ No newline at end of file diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index bbb75416..4055942e 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -29,8 +29,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis __initialize: function(){ - this._checkURL(); - this.listenTo(this, "change:partType", this._updatePartType); this.listenTo(this, "change:cellType", function(){ @@ -58,10 +56,6 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlis this._reloadCells(); }, - _checkURL: function(){ - var path = window.location.path; -// console.log(path); - }, diff --git a/js/materials/DMAMaterial.js b/js/materials/DMAMaterial.js index 0cecddb3..35940b3a 100644 --- a/js/materials/DMAMaterial.js +++ b/js/materials/DMAMaterial.js @@ -71,7 +71,9 @@ define(['underscore', 'appState'], function(_, appState){ }; DMAMaterial.prototype.randomHexColor = function(){ - return '#' + Math.floor(Math.random()*16777215).toString(16); + var hex = '#' + Math.floor(Math.random()*16777215).toString(16); + if (hex.match(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i) !== null) return hex; + return "#000000"; }; DMAMaterial.prototype._makeMaterialObject = function(color, transparent){ diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 4f07aa82..193b720d 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -126,8 +126,14 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex _setNumber: function($target, newVal){ var min = $target.data("min"); var max = $target.data("max"); - if (min !== undefined && (min > newVal)) newVal = min; - else if (max !== undefined && (max < newVal)) newVal = max; + if (min !== undefined && (min > newVal)) { + console.warn("number must be " + min + " or above"); + newVal = min; + } + else if (max !== undefined && (max < newVal)) { + console.warn("number must be " + max + " or below"); + newVal = max; + } var property = $target.data("property"); if (!property) { diff --git a/js/menus/templates/LatticeMenuView.html b/js/menus/templates/LatticeMenuView.html index 38144c69..c57e9d86 100644 --- a/js/menus/templates/LatticeMenuView.html +++ b/js/menus/templates/LatticeMenuView.html @@ -37,9 +37,9 @@ Type: </div><br/><br/> <% } %> Aspect Ratio: - <input data-property="aspectRatio" data-key="x" value="<%= aspectRatio.x %>" placeholder="X" class="form-control lattice floatInput" type="text"> - <input data-property="aspectRatio" data-key="y" value="<%= aspectRatio.y %>" placeholder="Y" class="form-control lattice floatInput" type="text"> - <input data-property="aspectRatio" data-key="z" value="<%= aspectRatio.z %>" placeholder="Z" class="form-control lattice floatInput" type="text"><br/><br/> + <input data-property="aspectRatio" data-key="x" data-min="0.1" value="<%= aspectRatio.x %>" placeholder="X" class="form-control lattice floatInput" type="text"> + <input data-property="aspectRatio" data-key="y" data-min="0.1" value="<%= aspectRatio.y %>" placeholder="Y" class="form-control lattice floatInput" type="text"> + <input data-property="aspectRatio" data-key="z" data-min="0.1" value="<%= aspectRatio.z %>" placeholder="Z" class="form-control lattice floatInput" type="text"><br/><br/> <% if (connectionType == "gik") { %> Part Length: <input data-property="gikLength" value="<%= gikLength %>" placeholder="Length" class="form-control intInput appState" type="text"><br/><br/> <% } %> -- GitLab