| 1549 | } |
| 1550 | |
| 1551 | void ShowAxisContextMenu(ImPlot3DPlot& plot, ImAxis3D axis_id) { |
| 1552 | ImGui::PushItemWidth(75); |
| 1553 | ImPlot3DAxis& axis = plot.Axes[axis_id]; |
| 1554 | bool always_locked = axis.IsRangeLocked() || axis.IsAutoFitting(); |
| 1555 | bool label = axis.HasLabel(); |
| 1556 | bool grid = axis.HasGridLines(); |
| 1557 | bool ticks = axis.HasTickMarks(); |
| 1558 | bool labels = axis.HasTickLabels(); |
| 1559 | double drag_speed = |
| 1560 | (axis.Range.Size() <= DBL_EPSILON) ? DBL_EPSILON * 1.0e+13 : 0.01 * axis.Range.Size(); // Recover from almost equal axis limits |
| 1561 | const bool equal_aspect = ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_Equal); |
| 1562 | |
| 1563 | ImGui::BeginDisabled(always_locked); |
| 1564 | ImGui::CheckboxFlags("##LockMin", (unsigned int*)&axis.Flags, ImPlot3DAxisFlags_LockMin); |
| 1565 | ImGui::EndDisabled(); |
| 1566 | ImGui::SameLine(); |
| 1567 | |
| 1568 | ImGui::BeginDisabled(axis.IsLockedMin() || always_locked); |
| 1569 | double temp_min = axis.Range.Min; |
| 1570 | if (ImGui::DragScalar("Min", ImGuiDataType_Double, &temp_min, (float)drag_speed, &axis.ConstraintRange.Min, &axis.Range.Max)) { |
| 1571 | axis.SetMin(temp_min, true); |
| 1572 | // Apply equal aspect if needed |
| 1573 | if (equal_aspect) |
| 1574 | plot.ApplyEqualAspect(axis_id); |
| 1575 | } |
| 1576 | ImGui::EndDisabled(); |
| 1577 | |
| 1578 | ImGui::BeginDisabled(always_locked); |
| 1579 | ImGui::CheckboxFlags("##LockMax", (unsigned int*)&axis.Flags, ImPlot3DAxisFlags_LockMax); |
| 1580 | ImGui::EndDisabled(); |
| 1581 | ImGui::SameLine(); |
| 1582 | ImGui::BeginDisabled(axis.IsLockedMax() || always_locked); |
| 1583 | double temp_max = axis.Range.Max; |
| 1584 | if (ImGui::DragScalar("Max", ImGuiDataType_Double, &temp_max, (float)drag_speed, &axis.Range.Min, &axis.ConstraintRange.Max)) { |
| 1585 | axis.SetMax(temp_max, true); |
| 1586 | // Apply equal aspect if needed |
| 1587 | if (equal_aspect) |
| 1588 | plot.ApplyEqualAspect(axis_id); |
| 1589 | } |
| 1590 | ImGui::EndDisabled(); |
| 1591 | |
| 1592 | ImGui::Separator(); |
| 1593 | |
| 1594 | // Flags |
| 1595 | ImGui::CheckboxFlags("Auto-Fit", (unsigned int*)&axis.Flags, ImPlot3DAxisFlags_AutoFit); |
| 1596 | ImGui::Separator(); |
| 1597 | |
| 1598 | bool inverted = ImPlot3D::ImHasFlag(axis.Flags, ImPlot3DAxisFlags_Invert); |
| 1599 | if (ImGui::Checkbox("Invert", &inverted)) |
| 1600 | ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_Invert); |
| 1601 | |
| 1602 | ImGui::Separator(); |
| 1603 | |
| 1604 | ImGui::BeginDisabled(axis.Label.empty()); |
| 1605 | if (ImGui::Checkbox("Label", &label)) |
| 1606 | ImFlipFlag(axis.Flags, ImPlot3DAxisFlags_NoLabel); |
| 1607 | ImGui::EndDisabled(); |
| 1608 |
no test coverage detected