Astrophysics of gaseous nebulae and active galactic nuclei