The ScanImage architecture is based on the Model-View-Controller design pattern. This architecture divides the software into three parts:
|Model||Application logic and hardware control||hSI|
|View||GUI - display model state||hSICtl|
|Controller||GUI - glue layer to manipulate model||hSICtl|
This architecture ensures a strict separation between program logic and GUI. In principle, ScanImage can be run without a GUI. To get a better understanding of the concept, inspect the scanimage startup script. In the Matlab command window, type
Find the following section in the startup script:
Note that two objects are created: hSI and hSICtl; hSI is the ScanImage model and contains all program logic to control the microscope hardware, acquire frames and log data. Once the model is started and initialized, the GUI (hSICtl) is launched and initialized. Finally, both object handles are assigned in the base workspace to give the user direct access to ScanImage via the Matlab command window.
When a control in the GUI is changed, the controller manipulates the model accordingly. When the state of the model changes, the controller's event listeners notice the change and update the GUI. However, the model can be manipulated and queried directly by the user as well. As a first example, type the following command into the Matlab command window:
This command returns the current acquisition state of ScanImage. Next type:
Note that the appropriate control in the GUI is updated accordingly.