| 1629 | } |
| 1630 | |
| 1631 | void ShowPlotContextMenu(ImPlot3DPlot& plot) { |
| 1632 | char buf[16] = {}; |
| 1633 | for (int i = 0; i < 3; i++) { |
| 1634 | ImPlot3DAxis& axis = plot.Axes[i]; |
| 1635 | ImGui::PushID(i); |
| 1636 | ImFormatString(buf, sizeof(buf) - 1, i == 0 ? "X-Axis" : "X-Axis %d", i + 1); |
| 1637 | if (ImGui::BeginMenu(axis.HasLabel() ? axis.GetLabel() : axis_labels[i])) { |
| 1638 | ShowAxisContextMenu(plot, i); |
| 1639 | ImGui::EndMenu(); |
| 1640 | } |
| 1641 | ImGui::PopID(); |
| 1642 | } |
| 1643 | |
| 1644 | ImGui::Separator(); |
| 1645 | |
| 1646 | if ((ImGui::BeginMenu("Box"))) { |
| 1647 | ImGui::PushItemWidth(75); |
| 1648 | float temp_scale[3] = {(float)plot.Axes[0].NDCScale, (float)plot.Axes[1].NDCScale, (float)plot.Axes[2].NDCScale}; |
| 1649 | if (ImGui::DragFloat("Scale X", &temp_scale[0], 0.01f, 0.1f, 3.0f)) |
| 1650 | plot.Axes[0].NDCScale = ImMax(temp_scale[0], 0.01f); |
| 1651 | if (ImGui::DragFloat("Scale Y", &temp_scale[1], 0.01f, 0.1f, 3.0f)) |
| 1652 | plot.Axes[1].NDCScale = ImMax(temp_scale[1], 0.01f); |
| 1653 | if (ImGui::DragFloat("Scale Z", &temp_scale[2], 0.01f, 0.1f, 3.0f)) |
| 1654 | plot.Axes[2].NDCScale = ImMax(temp_scale[2], 0.01f); |
| 1655 | ImGui::PopItemWidth(); |
| 1656 | ImGui::EndMenu(); |
| 1657 | } |
| 1658 | |
| 1659 | ImGui::Separator(); |
| 1660 | |
| 1661 | if ((ImGui::BeginMenu("Legend"))) { |
| 1662 | if (ShowLegendContextMenu(plot.Items.Legend, !ImPlot3D::ImHasFlag(plot.Flags, ImPlot3DFlags_NoLegend))) |
| 1663 | ImFlipFlag(plot.Flags, ImPlot3DFlags_NoLegend); |
| 1664 | ImGui::EndMenu(); |
| 1665 | } |
| 1666 | |
| 1667 | if ((ImGui::BeginMenu("Settings"))) { |
| 1668 | if (ImGui::MenuItem("Equal", nullptr, ImHasFlag(plot.Flags, ImPlot3DFlags_Equal))) |
| 1669 | ImFlipFlag(plot.Flags, ImPlot3DFlags_Equal); |
| 1670 | ImGui::BeginDisabled(plot.Title.empty()); |
| 1671 | if (ImGui::MenuItem("Title", nullptr, plot.HasTitle())) |
| 1672 | ImFlipFlag(plot.Flags, ImPlot3DFlags_NoTitle); |
| 1673 | ImGui::EndDisabled(); |
| 1674 | if (ImGui::MenuItem("Clip", nullptr, !ImHasFlag(plot.Flags, ImPlot3DFlags_NoClip))) |
| 1675 | ImFlipFlag(plot.Flags, ImPlot3DFlags_NoClip); |
| 1676 | if (ImGui::MenuItem("Mouse Position", nullptr, !ImHasFlag(plot.Flags, ImPlot3DFlags_NoMouseText))) |
| 1677 | ImFlipFlag(plot.Flags, ImPlot3DFlags_NoMouseText); |
| 1678 | ImGui::EndMenu(); |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | //----------------------------------------------------------------------------- |
| 1683 | // [SECTION] Begin/End Plot |
no test coverage detected