Let $A$ be a tall $m \times n$ matrix with full column rank. Let $m \times m$ matrix
$$H=[h_{ij}] = A(A'A)^{-1}A'$$
denote the orthogonal projection onto the column space of $A$. I know that $0 \leq h_{ii} \leq 1$ for all $i = 1,2,\dots,m$, i.e., all the diagonal elements of projection matrix $H$ should be between $0$ and $1$.
I'm wondering in which case $H$ matrix is a given diagonal matrix $D$. In other words, what restriction on matrix $A$ will lead to a conclusion that $H=D$, where $D$ is given?
In order for your formula to make sense, $A$ must have linearly independent columns. We therefore assume that this is the case.
$H$ will be diagonal if and only if $A$ has an invertible $n \times n$ submatrix and $A$ has zeros in all entries outside this submatrix.