The problem of initial thermal velocity and the space charge effect of electron guns in numerical simulations have been investigated deeply. In general, the current software can meet the engineering requirements. However, the electron's initial thermal velocity and the space charge effect lack sufficient consideration. The above two factors significantly limit the performances of electron guns. Moreover, the parameters of electron guns are approximated based on a limited number of electron trajectories. Thus, the statistical distribution of the beam electron resulting from its initial thermal velocity is not considered adequately in present software. This paper introduces the equivalent meridional projected trajectory equation and the curvilinear axis evolution theory of the current density of toroidal electron sub-beam, and subsequently the current and charge density distributions in electron guns can be derived through iteration calculation. Based upon, the virtual crossover of an electron gun is determined by its current density distribution. As well as, a relevant numerical algorithm is developed and the related program is modified based on the popular commercial software SOURCE. Tungsten cathode guns, LaB6 cathode guns, field mission guns and Pierce guns are simulated respectively by examples. The calculations prove that the modified software is effective and practical.