thegrumpys / odop

Open Design Optimization Platform (ODOP) - Coil spring design app; mechanical springs; compression spring, extension spring, torsion spring
https://www.springdesignsoftware.org
MIT License
4 stars 5 forks source link

Experimental: In Calculator View replace Symbol Value with Plot Value #745

Open 1fifoto opened 2 years ago

1fifoto commented 2 years ago

Add a mini-plot using PlotValue to replace a SymbolValue in Calculator View for Compression Spring

Screen Shot 2022-09-11 at 4 20 38 PM

This also includes creating a "shadow" or local store to aid in computing the X & Y data. This removes React display/DOM updates.

...
      const { store } = this.context;
      var design = JSON.parse(JSON.stringify(store.getState())); // local non-React clone
      const local_store = createStore(reducers, design, applyMiddleware(dispatcher));
      var local_design = local_store.getState();
      ...
      local_store.dispatch(fixSymbolValue(name));
      ...
      for (let i = min_value; i < max_value; i += step) {
          local_design = local_store.getState();
          if (element.type === "equationset" && element.input) {
              local_store.dispatch(changeSymbolValue(name, i)); // X value
          }
          ...
          // Invoke Pattern Search and Compute Objective Value
          ...
      }
      ...
      local_store.dispatch(freeSymbolValue(name));
...
PlotValue.contextTypes = {
    store: PropTypes.object
};
...