BP and the lawyers for plaintiffs in the trial over the 2010 oil spill in the Gulf of Mexico have agreed to settle their case.