If you see a well behaved dog and want to pet it, please ask permission! If the owner said no, don't get offended! I've worked hard getting my dogs to this point and an excited human, at the wrong time, can destroy that hard work. Be calm, be willing to cooperate, and say "thank you" when the greeting is over!
If you're a dog owner, regardless of how well it's trained, don't feel obligated to the general public to let them pet your dog. He's your dog! Not public property! If you or your dog aren't comfortable, or ready for the encounter, then politely decline. My favorite reply is, "Sorry, now's not a good time/Not right now, he's in training."
Read more from Dream Come True K9