Commit d80facaa authored by Jennie Yoder's avatar Jennie Yoder

added examples to the Help Menu. Examples added are a cube, a box, linear

extrude, rotate_extrude, and fishyBlocks.
parent 12c0cfd8
...@@ -32,7 +32,7 @@ var BSUtils = BSUtils || {}; ...@@ -32,7 +32,7 @@ var BSUtils = BSUtils || {};
Blockscad.version = "1.1.2"; Blockscad.version = "1.1.2";
Blockscad.offline = true; Blockscad.offline = true; // true unless using a cloud service backend for file management
// -- BEGIN OPENJSCAD STUFF -- // -- BEGIN OPENJSCAD STUFF --
...@@ -193,12 +193,12 @@ Blockscad.init = function() { ...@@ -193,12 +193,12 @@ Blockscad.init = function() {
// set up the delete-confirm button's function. // set up the delete-confirm button's function.
$('#throw-it-away').click(function() { $('#throw-it-away').click(function() {
Blockscad.clearProject(); Blockscad.clearProject();
Blockscad.clearUndo();
Blockscad.workspaceChanged(); Blockscad.workspaceChanged();
Blockscad.clearUndo();
}); });
// handle the project->new menu option // handle the project->new menu option
$('#main').on('click', '.new-project', Blockscad.newProject); $('#main').on('change', '.new-project', Blockscad.newProject);
//FileSaver.js stuff //FileSaver.js stuff
// Loading a blocks xml file // Loading a blocks xml file
...@@ -463,6 +463,11 @@ Blockscad.init = function() { ...@@ -463,6 +463,11 @@ Blockscad.init = function() {
// file should be saved in the "examples" folder. // file should be saved in the "examples" folder.
$("#examples_torus").click({msg: "torus.xml"}, Blockscad.showExample); $("#examples_torus").click({msg: "torus.xml"}, Blockscad.showExample);
$("#examples_box").click({msg: "box.xml"}, Blockscad.showExample);
$("#examples_linear_extrude").click({msg: "linear_extrude.xml"}, Blockscad.showExample);
$("#examples_rotate_extrude").click({msg: "rotate_extrude.xml"}, Blockscad.showExample);
$("#examples_cube_with_cutouts").click({msg: "cube_with_cutouts.xml"}, Blockscad.showExample);
$("#examples_anthias_fish").click({msg: "anthias_fish.xml"}, Blockscad.showExample);
// to get sub-menus to work with bootstrap 3 navbar // to get sub-menus to work with bootstrap 3 navbar
$(function(){ $(function(){
...@@ -545,13 +550,14 @@ Blockscad.clearStlBlocks = function() { ...@@ -545,13 +550,14 @@ Blockscad.clearStlBlocks = function() {
Blockscad.newProject = function() { Blockscad.newProject = function() {
// should I prompt a save here? If I have a current project, I should just save it? Or not? // should I prompt a save here? If I have a current project, I should just save it? Or not?
// if the user is logged in, I should auto-save to the backend. // if the user is logged in, I should auto-save to the backend.
console.log("in Blockscad.newProject");
if (Blockscad.undo.undoStack.length > 0) { if (Blockscad.undo.undoStack.length > 0) {
if (!Blockscad.offline && Blockscad.Auth.isLoggedIn) { if (!Blockscad.offline && Blockscad.Auth.isLoggedIn) {
console.log("autosaving"); console.log("autosaving");
Blockscad.Auth.saveBlocksToAccount(); Blockscad.Auth.saveBlocksToAccount();
Blockscad.clearProject(); Blockscad.clearProject();
Blockscad.clearUndo();
Blockscad.workspaceChanged(); Blockscad.workspaceChanged();
Blockscad.clearUndo();
} }
else { else {
// I'm going to ask if they really want to delete their current work. // I'm going to ask if they really want to delete their current work.
...@@ -559,7 +565,11 @@ Blockscad.newProject = function() { ...@@ -559,7 +565,11 @@ Blockscad.newProject = function() {
$('#delete-confirm').modal('show'); $('#delete-confirm').modal('show');
} }
} }
else Blockscad.clearProject(); else {
Blockscad.clearProject();
Blockscad.workspaceChanged();
Blockscad.clearUndo();
}
// if the user was on the code tab, switch them to the blocks tab. // if the user was on the code tab, switch them to the blocks tab.
$('#displayBlocks').click(); $('#displayBlocks').click();
...@@ -586,6 +596,10 @@ Blockscad.showExample = function(e) { ...@@ -586,6 +596,10 @@ Blockscad.showExample = function(e) {
Blockscad.clearProject(); Blockscad.clearProject();
} }
} }
else {
Blockscad.clearProject();
}
Blockscad.workspaceChanged();
// turn xml data object into a string that Blockly can use // turn xml data object into a string that Blockly can use
var xmlString; var xmlString;
//IE //IE
...@@ -602,7 +616,7 @@ Blockscad.showExample = function(e) { ...@@ -602,7 +616,7 @@ Blockscad.showExample = function(e) {
Blockly.Xml.domToWorkspace(Blockscad.workspace, xml); Blockly.Xml.domToWorkspace(Blockscad.workspace, xml);
Blockly.fireUiEvent(window, 'resize'); Blockly.fireUiEvent(window, 'resize');
// update project name // update project name
$('#project-name').val(name); $('#project-name').val(name + ' example');
}); });
} }
......
This diff is collapsed.
<xml xmlns="http://www.w3.org/1999/xhtml"><version num="1.1.0"></version><block type="variables_set" id="30" x="-994" y="-298"><field name="VAR">width</field><value name="VALUE"><block type="math_number" id="31"><field name="NUM">20</field></block></value><next><block type="variables_set" id="32"><field name="VAR">height</field><value name="VALUE"><block type="math_number" id="33"><field name="NUM">20</field></block></value><next><block type="variables_set" id="34"><field name="VAR">depth</field><value name="VALUE"><block type="math_number" id="35"><field name="NUM">20</field></block></value><next><block type="variables_set" id="36"><field name="VAR">wall thickness</field><value name="VALUE"><block type="math_number" id="37"><field name="NUM">2</field></block></value></block></next></block></next></block></next></block><block type="difference" id="38" x="-992" y="-4"><comment pinned="true" h="105" w="368">Parametric box
change the numbers in the variable blocks to change the dimensions of the box and the wall thickness.</comment><statement name="A"><block type="cube" id="39"><field name="CENTERDROPDOWN">true</field><value name="XVAL"><block type="variables_get" id="40"><field name="VAR">width</field></block></value><value name="YVAL"><block type="variables_get" id="41"><field name="VAR">depth</field></block></value><value name="ZVAL"><block type="variables_get" id="42"><field name="VAR">height</field></block></value></block></statement><statement name="MINUS0"><block type="translate" id="43"><value name="XVAL"><block type="math_number" id="44"><field name="NUM">0</field></block></value><value name="YVAL"><block type="math_number" id="45"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="variables_get" id="46"><field name="VAR">wall thickness</field></block></value><statement name="A"><block type="cube" id="47" inline="false"><field name="CENTERDROPDOWN">true</field><value name="XVAL"><block type="math_arithmetic" id="48"><field name="OP">MINUS</field><value name="A"><block type="variables_get" id="49"><field name="VAR">width</field></block></value><value name="B"><block type="math_arithmetic" id="50"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="51"><field name="NUM">2</field></block></value><value name="B"><block type="variables_get" id="52"><field name="VAR">wall thickness</field></block></value></block></value></block></value><value name="YVAL"><block type="math_arithmetic" id="53"><field name="OP">MINUS</field><value name="A"><block type="variables_get" id="54"><field name="VAR">depth</field></block></value><value name="B"><block type="math_arithmetic" id="55"><field name="OP">MULTIPLY</field><value name="A"><block type="math_number" id="56"><field name="NUM">2</field></block></value><value name="B"><block type="variables_get" id="57"><field name="VAR">wall thickness</field></block></value></block></value></block></value><value name="ZVAL"><block type="variables_get" id="58"><field name="VAR">height</field></block></value></block></statement></block></statement></block></xml>
\ No newline at end of file
<xml xmlns="http://www.w3.org/1999/xhtml"><version num="1.1.2"></version><block type="difference" id="136" x="-935" y="20"><mutation minus="2"></mutation><statement name="A"><block type="cube" id="128"><field name="CENTERDROPDOWN">true</field><comment pinned="false" h="80" w="160">original cube</comment><value name="XVAL"><block type="math_number" id="129"><field name="NUM">10</field></block></value><value name="YVAL"><block type="math_number" id="130"><field name="NUM">10</field></block></value><value name="ZVAL"><block type="math_number" id="131"><field name="NUM">10</field></block></value></block></statement><statement name="MINUS0"><block type="cube" id="152"><field name="CENTERDROPDOWN">true</field><comment pinned="false" h="80" w="160">Z-aligned cutout</comment><value name="XVAL"><block type="math_number" id="153"><field name="NUM">8</field></block></value><value name="YVAL"><block type="math_number" id="154"><field name="NUM">8</field></block></value><value name="ZVAL"><block type="math_number" id="155"><field name="NUM">12</field></block></value></block></statement><statement name="MINUS1"><block type="cube" id="156"><field name="CENTERDROPDOWN">true</field><comment pinned="false" h="80" w="160">X-aligned cutout</comment><value name="XVAL"><block type="math_number" id="157"><field name="NUM">12</field></block></value><value name="YVAL"><block type="math_number" id="158"><field name="NUM">8</field></block></value><value name="ZVAL"><block type="math_number" id="159"><field name="NUM">8</field></block></value></block></statement><statement name="MINUS2"><block type="cube" id="160"><field name="CENTERDROPDOWN">true</field><comment pinned="false" h="80" w="160">Y-aligned cutout</comment><value name="XVAL"><block type="math_number" id="161"><field name="NUM">8</field></block></value><value name="YVAL"><block type="math_number" id="162"><field name="NUM">12</field></block></value><value name="ZVAL"><block type="math_number" id="163"><field name="NUM">8</field></block></value></block></statement></block></xml>
\ No newline at end of file
<xml xmlns="http://www.w3.org/1999/xhtml"><version num="1.1.2"></version><block type="color" id="149" x="-999" y="-272"><value name="COLOR"><block type="colour_picker" id="150"><field name="COLOUR">#ffff00</field></block></value><statement name="A"><block type="linearextrude" id="151"><field name="CENTERDROPDOWN">false</field><value name="HEIGHT"><block type="math_number" id="152"><field name="NUM">30</field></block></value><value name="TWIST"><block type="math_angle" id="153"><field name="NUM">0</field></block></value><statement name="A"><block type="circle" id="186"><value name="RAD"><block type="math_number" id="187"><field name="NUM">5</field></block></value></block></statement></block></statement></block><block type="color" id="157" x="-995" y="-127"><value name="COLOR"><block type="colour_picker" id="158"><field name="COLOUR">#ff0000</field></block></value><statement name="A"><block type="linearextrude" id="159"><field name="CENTERDROPDOWN">false</field><value name="HEIGHT"><block type="math_number" id="160"><field name="NUM">40</field></block></value><value name="TWIST"><block type="math_angle" id="161"><field name="NUM">360</field></block></value><statement name="A"><block type="translate" id="162"><value name="XVAL"><block type="math_number" id="163"><field name="NUM">10</field></block></value><value name="YVAL"><block type="math_number" id="164"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="math_number" id="165"><field name="NUM">0</field></block></value><statement name="A"><block type="square" id="166"><field name="CENTERDROPDOWN">false</field><value name="XVAL"><block type="math_number" id="167"><field name="NUM">10</field></block></value><value name="YVAL"><block type="math_number" id="168"><field name="NUM">10</field></block></value></block></statement></block></statement></block></statement></block><block type="color" id="169" x="-988" y="79"><value name="COLOR"><block type="colour_picker" id="170"><field name="COLOUR">#3333ff</field></block></value><statement name="A"><block type="translate" id="171"><value name="XVAL"><block type="math_number" id="172"><field name="NUM">40</field></block></value><value name="YVAL"><block type="math_number" id="173"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="math_number" id="174"><field name="NUM">0</field></block></value><statement name="A"><block type="linearextrude" id="175"><field name="CENTERDROPDOWN">false</field><value name="HEIGHT"><block type="math_number" id="176"><field name="NUM">40</field></block></value><value name="TWIST"><block type="math_angle" id="177"><field name="NUM">90</field></block></value><statement name="A"><block type="square" id="178"><field name="CENTERDROPDOWN">true</field><value name="XVAL"><block type="math_number" id="179"><field name="NUM">15</field></block></value><value name="YVAL"><block type="math_number" id="180"><field name="NUM">10</field></block></value></block></statement></block></statement></block></statement></block></xml>
\ No newline at end of file
<xml xmlns="http://www.w3.org/1999/xhtml"><version num="1.1.2"></version><block type="color" id="223" x="-905" y="-15"><value name="COLOR"><block type="colour_picker" id="224"><field name="COLOUR">#33ccff</field></block></value><statement name="A"><block type="rotateextrude" id="190"><value name="FACES"><block type="math_number" id="191"><field name="NUM">6</field></block></value><statement name="A"><block type="translate" id="155"><value name="XVAL"><block type="math_number" id="156"><field name="NUM">10</field></block></value><value name="YVAL"><block type="math_number" id="157"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="math_number" id="158"><field name="NUM">0</field></block></value><statement name="A"><block type="$fn" id="278"><value name="SIDES"><block type="math_number" id="279"><field name="NUM">30</field></block></value><statement name="A"><block type="circle" id="280"><value name="RAD"><block type="math_number" id="281"><field name="NUM">5</field></block></value></block></statement></block></statement></block></statement></block></statement></block><block type="color" id="235" x="-902" y="221"><value name="COLOR"><block type="colour_picker" id="236"><field name="COLOUR">#33cc00</field></block></value><statement name="A"><block type="rotateextrude" id="237"><value name="FACES"><block type="math_number" id="238"><field name="NUM">22</field></block></value><statement name="A"><block type="translate" id="239"><value name="XVAL"><block type="math_number" id="240"><field name="NUM">22</field></block></value><value name="YVAL"><block type="math_number" id="241"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="math_number" id="242"><field name="NUM">0</field></block></value><statement name="A"><block type="$fn" id="276"><value name="SIDES"><block type="math_number" id="277"><field name="NUM">4</field></block></value><statement name="A"><block type="circle" id="243"><value name="RAD"><block type="math_number" id="244"><field name="NUM">5</field></block></value></block></statement></block></statement></block></statement></block></statement></block><block type="color" id="225" x="-904" y="464"><value name="COLOR"><block type="colour_picker" id="226"><field name="COLOUR">#ff0000</field></block></value><statement name="A"><block type="rotateextrude" id="227"><value name="FACES"><block type="math_number" id="228"><field name="NUM">3</field></block></value><statement name="A"><block type="translate" id="229"><value name="XVAL"><block type="math_number" id="230"><field name="NUM">60</field></block></value><value name="YVAL"><block type="math_number" id="231"><field name="NUM">0</field></block></value><value name="ZVAL"><block type="math_number" id="232"><field name="NUM">0</field></block></value><statement name="A"><block type="circle" id="233"><value name="RAD"><block type="math_number" id="234"><field name="NUM">5</field></block></value></block></statement></block></statement></block></statement></block></xml>
\ No newline at end of file
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
<script type="text/javascript" src="blockscad/text.js"></script> <script type="text/javascript" src="blockscad/text.js"></script>
<script src="blockscad/lightgl.js"></script> <script src="blockscad/lightgl.js"></script>
<!-- <!--
<script type="text/javascript" src="backend_compressed.js"></script> <script type="text/javascript" src="backend_compressed.js"></script>
--> -->
...@@ -131,7 +130,12 @@ ...@@ -131,7 +130,12 @@
<li> <li>
<a class="trigger right-caret">Examples</a> <a class="trigger right-caret">Examples</a>
<ul class="dropdown-menu sub-menu"> <ul class="dropdown-menu sub-menu">
<li><a href="#" id="examples_cube_with_cutouts">Cube with cutouts</a></li>
<li><a href="#" id="examples_anthias_fish">Anthias fish</a></li>
<li><a href="#" id="examples_torus">Torus</a></li> <li><a href="#" id="examples_torus">Torus</a></li>
<li><a href="#" id="examples_box">Parametric Box</a></li>
<li><a href="#" id="examples_linear_extrude">Linear Extrude</a></li>
<li><a href="#" id="examples_rotate_extrude">Rotate Extrude</a></li>
</ul> </ul>
</li> </li>
<li class="divider"></li> <li class="divider"></li>
......
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