Magnetic ordering, orbital ordering, and resonant x-ray scattering in perovskite titanates