| 268 | } |
| 269 | |
| 270 | void RenderLabelObject::renderLeaderLine_( const ModelRenderParams& renderParams ) |
| 271 | { |
| 272 | GL_EXEC( glBindVertexArray( llineArrayObjId_ ) ); |
| 273 | |
| 274 | auto shader = GLStaticHolder::getShaderId( GLStaticHolder::Labels ); |
| 275 | GL_EXEC( glUseProgram( shader ) ); |
| 276 | |
| 277 | const auto shift = objLabel_->getPivotShift(); |
| 278 | auto box = meshBox_; |
| 279 | applyPadding( box, objLabel_->getBackgroundPadding() * ( box.max.y - box.min.y ) / objLabel_->getFontHeight() ); |
| 280 | const std::array<Vector3f, 5> leaderLineVertices { |
| 281 | Vector3f{ shift.x, shift.y, 0.f }, |
| 282 | Vector3f{ box.min.x, box.min.y, 0.f }, |
| 283 | Vector3f{ box.max.x, box.min.y, 0.f }, |
| 284 | Vector3f{ box.min.x, box.max.y, 0.f }, |
| 285 | Vector3f{ box.max.x, box.max.y, 0.f }, |
| 286 | }; |
| 287 | bindVertexAttribArray( shader, "position", llineVertPosBuffer_, leaderLineVertices, 3, dirtyLLine_ ); |
| 288 | |
| 289 | std::array<Vector2i, 3> llineEdgesIndices { |
| 290 | Vector2i{ 1, 2 }, |
| 291 | Vector2i{ 0, 1 }, |
| 292 | Vector2i{ 1, 3 }, |
| 293 | }; |
| 294 | size_t llineEdgesIndicesSize; |
| 295 | const auto middleX = ( box.max.x - box.min.x ) / 2.f; |
| 296 | if ( shift.x < box.min.x || box.max.x < shift.x || shift.y < box.min.y ) |
| 297 | { |
| 298 | llineEdgesIndicesSize = 2; |
| 299 | // lead to closest lower corner |
| 300 | if ( shift.x < middleX ) |
| 301 | llineEdgesIndices[1] = Vector2i{ 0, 1 }; |
| 302 | else |
| 303 | llineEdgesIndices[1] = Vector2i{ 0, 2 }; |
| 304 | } |
| 305 | else if ( box.max.y < shift.y ) |
| 306 | { |
| 307 | llineEdgesIndicesSize = 3; |
| 308 | // lead to closest upper corner and then to bottom |
| 309 | if ( shift.x < middleX ) |
| 310 | { |
| 311 | llineEdgesIndices[1] = Vector2i{ 0, 3 }; |
| 312 | llineEdgesIndices[2] = Vector2i{ 1, 3 }; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | llineEdgesIndices[1] = Vector2i{ 0, 4 }; |
| 317 | llineEdgesIndices[2] = Vector2i{ 2, 4 }; |
| 318 | } |
| 319 | } |
| 320 | else |
| 321 | { |
| 322 | // source point is hidden |
| 323 | llineEdgesIndicesSize = 1; |
| 324 | } |
| 325 | assert( llineEdgesIndicesSize <= llineEdgesIndices.size() ); |
| 326 | |
| 327 | llineEdgesIndicesBuffer_.loadDataOpt( GL_ELEMENT_ARRAY_BUFFER, dirtyLLine_, llineEdgesIndices.data(), llineEdgesIndicesSize ); |
nothing calls this directly
no test coverage detected