| 158 | } |
| 159 | |
| 160 | qreal UBGraphicsTriangle::heightAtPosition(qreal position) |
| 161 | { |
| 162 | /* B____C |
| 163 | | / |
| 164 | D|_/E <-- triangle height at given position |
| 165 | |/ |
| 166 | A |
| 167 | */ |
| 168 | qreal AD; |
| 169 | switch(mOrientation) |
| 170 | { |
| 171 | case BottomLeft: |
| 172 | AD = QLineF(rect().bottomRight(), QPointF(position, rotationCenter().y())).length(); |
| 173 | break; |
| 174 | case TopLeft: |
| 175 | AD = QLineF(rect().topRight(), QPointF(position, rotationCenter().y())).length(); |
| 176 | break; |
| 177 | case TopRight: |
| 178 | AD = QLineF(rect().topLeft(), QPointF(position, rotationCenter().y())).length(); |
| 179 | break; |
| 180 | case BottomRight: |
| 181 | AD = QLineF(rect().bottomLeft(), QPointF(position, rotationCenter().y())).length(); |
| 182 | break; |
| 183 | } |
| 184 | |
| 185 | qreal AB = rect().width(); |
| 186 | qreal BC = rect().height(); |
| 187 | return (AD * BC / AB); //DE |
| 188 | } |
| 189 | |
| 190 | |
| 191 | QRectF UBGraphicsTriangle::bounding_Rect() const |