- Worked on problem that if we change the default value in .scad then it does not change value in model and parametric Wind
- Study how present ParameterWidget interact with mainwindow and how we can solve below problem.
- Designed alternative way for solving the problem.
- Evaluated both the designed and choose one and wrote the pseudo code to implement it.
- Coded to solve above problem( prototype ).
- changed the way parameterwidget interact with mainwindow.
Design 1:
It is the exiting way how the parameterWindow interact with mainwindow i.e.
- First, applyParameter() is called that inject all the parameter in AST from parameterObject container.
- Then setParameter() is called which first clear the container of parameterObject and then it make new parameterObjects and insert in the container.
- After This, GUI is given to all the parameterObject and displayed on the screen.
- If value of parameter is changed then the signal is emitted which eventually execute the compileTopLevelDocument()
- goto step1.
We can improve this to solve the above issue by differentiating who (parameteric widget or .scad ) updated the the value in AST . We need to define a new slot to connect to refresh signal by parameterWidget and thne pass a bool to tell whether parameters value was updated by through .scad file or parameterWidget. and then accordingly inject the parameter in AST.
This approach was not so logical and was just a hack.
Design 2:
- First, setParameter() is called by mainwindow which extract the parameters from AST and then add them to a container and mark them as set.
- GUI applied to given parameterObjects and displayed on screen.
- When value of parameter is updated then applyParameter() is called through compileTopLevelDocument().
- applyParameter() update the value in AST and mark them as injected.
- Again setParameter() is called and it update the parameter whose default value is changed and add new parameters in container and mark them as set.
- GUI is given to parameterObject those marked as set and those which are not are deleted.
- and again got to step 1.
This is better and more logical approach which also solved the issue of being that we are unable to apply changes to parameter value from .scad file.