A Plug-in in Tinkercell has much control over how the program runs. However, there is a suggested framework that it should follow in order to behave as a “good plug-in”.
Before designing your plug-in ...
- Feel comfortable with Qt’s signal/slot framework
- Look at all the signals and slots in the MainWindow class
- Look at all the functions in the GraphicsScene class
- Write down a list of features that you would like to add to TinkerCell
Things to know
loadTCTool(Tinkercell::MainWindow * main)
so be sure it is defined. See example (next blog)
Guidelines- All Plug-ins inherit from the Tool class.
- Almost all the new features are added through the signal/slot framework.
- Avoid defining new graphics item classes unless necessary; for most cases, the signal/slot framework is easier.
- All non-trivial actions should have a QUndoCommand associated with it. When performing that action, you should add this undo command to the current scene’s history stack instead of directly performing that action. Note: since GraphicsScene provides most of the basic commands, many new commands can be constructed by using the CompositeCommand.
- Use GraphicsScene’s functions when possible. These functions automatically add undo commands to the history stack and send signals informing other plug-ins about the changes.
- If you do not use GraphicsScene’s functions, be sure to signal to the MainWindow whenever you make changes to items or their data. Do this in the setMainWindow method.
- Define new signals whenever you suspect that another tool might use it.
No comments:
Post a Comment