AU-ExoMars / PCOT

Pancam Operations Toolkit
MIT License
3 stars 0 forks source link

Clashing macros! #16

Closed jimfinnis closed 3 years ago

jimfinnis commented 3 years ago

Macro definitions are global to the entire application, because they exist as custom XFormType objects. This is OK, and potentially useful, except for one thing. What happens if we open a file containing a macro "foo", and then open a different file (perhaps in a different window, perhaps in the same one) also containing a macro "foo"?

At the moment, the system throws an exception - "xform type name already in use." It's trying to add the new macro definition when one already exists. Not sure what the semantics should be here.

Options:

jimfinnis commented 3 years ago

OK, I'm actually going to make macros local to graphs. The other solutions are prone to user error. That means:

Macros now belong to graphs, so

Things to consider

jimfinnis commented 3 years ago

Dammit, what happens with macros embedded in macros? I think I'm going to have to go back to the original plan (macros are global). Otherwise, macros-as-graphs would have to own other macro prototypes, and that seems wrong, particularly when there might be a macro used inside several other macros. Each would have to hold a copy, only it wouldn't be a copy, it would be entirely separate - and that would cause confusion.

jimfinnis commented 3 years ago

Scratch that. Macros are NOT global. I'm now using a new Document class to keep the main graph, the graph's macros, and the settings. It seems to work, and it should be easy enough to write code to import macros from one Document into another. That's not done, but I will now close this bug.