jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.66k stars 515 forks source link

Enhancement: Support nested interactive parameters #85

Open thehans opened 9 years ago

thehans commented 9 years ago

Currently the getParameterDefinitions() function accepts 4 types: float, int, text, and choice

I am proposing a fifth type that would allow for nesting / grouping of parameters.

This would be useful for scripts which have multiple independent pieces with their own parameters.

Here is an example of how I would picture it being used:

{
  name: 'chassisBolt',     // a javacsript object will be created, filled with its own parameters
  type: 'parameterGroup',  // not sure best name for param type, other ideas include 'object', 'group', 'grouping'
  caption: 'Chassis Bolt', // optional, displayed as a heading above its own parameter list
                           // if omitted, the 'name' is displayed (i.e. 'chassisBolt')
  parameters: { // params go here in the same manner as at the 'top level', including possibly more parameter groups
      {  name: 'headDiameter',  type: 'float', initial: 6, caption: 'Head Diameter:' }
      {  name: 'shankDiameter',  type: 'float', initial: 3, caption: 'Shank Diameter:' }
      {  name: 'length',  type: 'float', initial: 20, caption: 'Length:' }
  }
}

When a parameter group is defined the interactive parameter window should generate a bold heading with the given caption or name, and list all contained parameters beneath it, indented some amount.

Then if I have a function that only needs the bolt related parameters I can pass in params.chassisBolt object and leave out all the other unrelated parameters.

z3dev commented 9 years ago

I agree. A group of the parameters is more important then a title, and allows more flexibility. I have this coded already but have to wait for some additional merges to occur first.

z3dev commented 9 years ago

@thehans please look at some of the designs at www.z3d.jp This website has support for "groups" already.

Basically, the "group" parameter becomes a new row in the table of parameters, and contains a single header (HTML "th" element). And of course, a new style is added to the CSS file.

Good?

thehans commented 9 years ago

I don't see any openjscad on that site, not sure what I'm supposed to be looking at.

z3dev commented 9 years ago

Sorry. I didn't provide a complete URL. Please review some of the designs at http://www.z3d.jp/lab/

z3dev commented 3 years ago

@thehans grouping of parameters has been implemented, and groups can be collapsed or expanded interactively.

please try the 'Birthday Ballons' example as www.openjscad.xyz