-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
How Simulator UI is Setup?
Contributing author: @shubhankarsharma00
Please read this article by @fpintos to get basic information on different parts of the simulator before you read this article.
The view for the CircuiVerse simulator hosted at URL/simulator can be found in app/simulator/edit.html.erb but the main files that are responsible for generating the whole simulator are in public/js. Currently, all these files are included in edit.html.erb and setup()
function is called as soon as DOM gets loaded.
The setup function is defined in logix.js
which calls 4 functions:
-
setupElementsList
- It initializes some useful array which is helpful while simulating, saving, and loading projects. It also draws icons in the sidebar. -
setupEnvironment
- function to setup environment variables for a new like projectId and Pixel Ratio. It also calls resetup which draws the grid and calls update function responsible for UI update. -
setupUI
- adds some UI elements to the sidebar and menu. It also attaches listeners to the sidebar. -
startListeners
- Which start all the listeners in the simulation area.
If we are loading a preexisting project it calls load()
function. Further, the function looks for previous unsaved data and if there is some unsaved project simulator loads that too. In case we load a project default environment variables declared during setupEnvironment
function call are overwritten else we proceed with those default variables.
Now if anyone clicks any circuit element icon (say AndGate icon) in the sidebar, a constructor(in this case new AndGate()) is called by mouse down listener defined (during setupUI function call). Most of these constructors are declared in modules.js, sequential.js, or in a standalone file in case od RAM or Counter.
Any Element drawn has nodes (of class Node
) attached to it. This can be an input node or output node. In case this node is selected and dragged a wire (of class Wire
) is drawn and another node is drawn wherever dragging stop if no node already exists. If the node is not part of any element it is an intermediatory node and it's parent is the whole Scope.
CircuitVerse is a web-based simulation software for creating and testing digital circuits. The easy drag and drop feature makes it easier and a fun way to learn about logic circuits and also compatible to be used by teachers as well as students. From simple gates to complex sequential circuits, plot timing diagrams, automatic circuit generation, explore standard ICs, and much more, CircuitVerse has got you covered. It also lets the user store and access the previously built circuits to build yet more complex circuits and generate truth tables for the constructed circuits.
- Home
- Running the server
- Simulator
- Internationalization (I18n)
- GSoC '19
- GSoC '20
- GSoC '21
- GSoC '22
- GSoC '23
- GSoC '24
- GCI 2019
- Google Season of Docs 2020