  We present a new model for computing consistently the line and continuum
emission from galaxies, based on a combination of recent population synthesis
and photoionization codes. We use effective parameters to describe the HII
regions and the diffuse gas ionized by single stellar generations in a galaxy
[...]. We calibrate the nebular properties of our model using the observed
[OIII]/Hbeta, [OII]/[OIII], [SII]/Halpha, and [NII]/[SII] ratios of a
representative sample of nearby spiral and irregular, starburst, and HII
galaxies. To compute whole (line plus continuum) spectral energy distributions,
we include the absorption by dust in the neutral interstellar medium (ISM)
using a recent simple prescription, which is consistent with observations of
nearby starburst galaxies. Our model enables us to interpret quantitatively the
observed optical spectra of galaxies in terms of stars, gas, and dust
parameters. We find that the range of ionized-gas properties spanned by nearby
galaxies implies factors of 3.5 and 14 variations in the Halpha and [OII]
luminosities produced per unit star formation rate (SFR). When accounting for
stellar Halpha absorption and absorption by dust in the neutral ISM, the actual
uncertainties in SFR estimates based on the emergent Halpha and [OII]
luminosities are as high as several decades. We derive new estimators of the
SFR, the gas-phase oxygen abundance, and the effective absorption optical depth
of the dust in galaxies. We show that, with the help of other lines such as
[OII], Hbeta, [OIII], [NII], or [SII], the uncertainties in SFR estimates based
on Halpha can be reduced to a factor of only 2-3, even if the Halpha line is
blended with the adjacent [NII] lines. Without Halpha, however, the SFR is
difficult to estimate from the [OII], Hbeta, and [OIII] lines. (abridged)
