Made design and requirement document for New feature i.e to save set of parameters in JSON format.
New Feature:
Add feature to save the set of parameters of models in JSON file format and add the ability to read that file and append.
Functionality:
- This feature should be supported both by UI and cmd line.
- Basically, store the currently selected values of parameter into a file. ( get values and parameters from parameterObject ).
- It will consist of primarily of parameter – value pairs but We can add create time and update time in this.
- The GUI would be responsible to make ComboBox to select the set of Parameter, add new set ,delete set, update set.
- To apply set of parameter from .json file we need to define a function applyModelParameter() which would be accessible
from both GUI and cmdlin this will probably in new class or part of ParameterExtractor class.- In GUI we need to select the model from combo box to apply it.
- for cmdline we need to give cmd something like:
- openscad -o model-2.stl -p parameters.json -P model-2 model.scad
- Advance:
- There could even be an automatic “custom” parameter set which just tracks what the user has currently entered
- Basically, tracking the latest selection
Points to ponder:
- What to do if the file is not saved yet, so we don’t have a file name for the scad script itself.
- solution:
- On clicking add parameter set button, we will ask to first save file.
- Disable the combo box
- solution:
- What if value saved in json gets out of range from that described by current parameter in .scad file.
- e.g. if we saved variable with value 50. i.e. variable:50 in json file and in .scad file we have.
@parameter([1:40])
variable=30;
Similarly if we have in scad file.
@parameter([10,15,20,25])
variable=20;
-
Question:
- Then should we apply the value or not
- if we apply should we reflect new values with input widgets for parameters or not or should we give a message.
- e.g. if we saved variable with value 50. i.e. variable:50 in json file and in .scad file we have.
- What if we change the type of parameter in .scad file and apply parameter set from json file with parameters with different type.
- When to save parameter in file on updating, on saving the .scad file or when we close the openscad software.
Design:
- Function to be used:
- Part of ParameterExtractor:
- getParameterSet() // to read json file and make a data structure to store them.
- applyfromSetl() // to apply parameter from selected set
- ParameterWidget:
- addToCombox() // add the name of set of Parameter to the combobox in parameterWidget.
- onSetSelect() // apply selected set of parameters to the AST
- deleteSet() // delete given set of parameters
- addNewSetl() // It will add new set or update the current selected set
- Part of ParameterExtractor:
- Data structure to be used:
- map< name of set, setOfParameter>
- setOfParameter:
Vector: Vector< parameterPair>- ParameterPair: struct parameterPair{ string name; ValuePtr value};
- Map: map<string,ValuePtr>