Open hol353 opened 3 months ago
Agreed.
While doing this we should also look at some of the models that are using a GridTable, but store their data in a way that makes it very difficult to map it to a GridTable. Forages for example, requires a lot of manipulation to split rows of stored date, into multiple rows for the GUI, which is very messy. It would be good practice to have the underlying structure better represent how the data is used.
I would also recommend having a generic SheetDataProvider function for the models that don't require any specialised manipulation. Something that can take a class and property and build out the required GridTable description without needed to specifically outline each thing that needs to be displayed. Otherwise we will end up with like 15 SheetDataProviders with basically the same code in them, just with the names changing.
Where is the code located?
Many models display data in grids and allow that data to be edited.
What needs to be changed?
These models implement
interface IGridModel
and have the propertypublic List<GridTable> Tables
. Some classes also implement the methodConvertModelToDisplay(...)
. Classes Physical, Forages, TreeProxy are examples of this. The interface mentioned isn't really an interface because it has implementation in it. Because of that, there a multiple ways of returning data. We need a single way of doing things. Also, the code that implements this is user interface related and not model related i.e. it isn't executed when a simulation runs. I think the models assembly should only be simulation related, and not have user interface code.Possible implementation: The code should be moved from models into the ApsimNG assembly as a separate class for each model. These classes would be responsible for returning an ISheetDataProvider for a model:
A factory could then be written to create an instance of one of these for a given model:
Why does the code need changing?
The code needs to be cleaner so that new features can be more easily added. I'm trying to add the ability to display text in cells different colours - #8757. Currently, this is more difficult than it needs to be.