| 323 | } |
| 324 | |
| 325 | void mitk::PlanarFigureInteractor::AddPoint(StateMachineAction *, InteractionEvent *interactionEvent) |
| 326 | { |
| 327 | auto positionEvent = dynamic_cast<InteractionPositionEvent*>(interactionEvent); |
| 328 | if (nullptr == positionEvent) |
| 329 | { |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * Added check for "initiallyplaced" due to bug 13097: |
| 335 | * |
| 336 | * There are two possible cases in which a point can be inserted into a PlanarPolygon: |
| 337 | * |
| 338 | * 1. The figure is currently drawn -> the point will be appended at the end of the figure |
| 339 | * 2. A point is inserted at a userdefined position after the initial placement of the figure is finished |
| 340 | * |
| 341 | * In the second case we need to determine the proper insertion index. In the first case the index always has |
| 342 | * to be -1 so that the point is appended to the end. |
| 343 | * |
| 344 | * These changes are necessary because of a macOS specific issue: If a users draws a PlanarPolygon then the |
| 345 | * next point to be added moves according to the mouse position. If then the user left clicks in order to add |
| 346 | * a point one would assume the last move position is identical to the left click position. This is actually the |
| 347 | * case for windows and linux but somehow NOT for mac. Because of the insertion logic of a new point in the |
| 348 | * PlanarFigure then for mac the wrong current selected point is determined. |
| 349 | * |
| 350 | * With this check here this problem can be avoided. However a redesign of the insertion logic should be considered |
| 351 | */ |
| 352 | |
| 353 | const DataNode::Pointer node = this->GetDataNode(); |
| 354 | const BaseData::Pointer data = node->GetData(); |
| 355 | |
| 356 | bool isFigureFinished = false; |
| 357 | data->GetPropertyList()->GetBoolProperty("initiallyplaced", isFigureFinished); |
| 358 | |
| 359 | bool selected = false; |
| 360 | bool isEditable = true; |
| 361 | |
| 362 | node->GetBoolProperty("selected", selected); |
| 363 | node->GetBoolProperty("planarfigure.iseditable", isEditable); |
| 364 | |
| 365 | if (!selected || !isEditable) |
| 366 | { |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | auto planarFigure = dynamic_cast<PlanarFigure*>(data.GetPointer()); |
| 371 | if (nullptr == planarFigure) |
| 372 | { |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | // We can't derive a new control point from a polyline of a Bezier curve |
| 377 | // as all control points contribute to each polyline point. |
| 378 | if (dynamic_cast<PlanarBezierCurve *>(planarFigure) != nullptr && isFigureFinished) |
| 379 | return; |
| 380 | |
| 381 | auto planarFigureGeometry = planarFigure->GetPlaneGeometry(); |
| 382 | if (nullptr == planarFigureGeometry) |
nothing calls this directly
no test coverage detected