| 1332 | } |
| 1333 | |
| 1334 | void DemoAutoFittingData() { |
| 1335 | IMGUI_DEMO_MARKER("Axes/Auto-Fitting Data"); |
| 1336 | ImGui::BulletText("Axes can be configured to auto-fit to data extents."); |
| 1337 | ImGui::BulletText("Try panning and zooming to see the axes adjust."); |
| 1338 | ImGui::BulletText("Disable AutoFit on an axis to fix its range."); |
| 1339 | |
| 1340 | static ImPlot3DAxisFlags xflags = ImPlot3DAxisFlags_None; |
| 1341 | static ImPlot3DAxisFlags yflags = ImPlot3DAxisFlags_None; |
| 1342 | static ImPlot3DAxisFlags zflags = ImPlot3DAxisFlags_AutoFit; |
| 1343 | |
| 1344 | ImGui::TextUnformatted("X: "); |
| 1345 | ImGui::SameLine(); |
| 1346 | ImGui::CheckboxFlags("ImPlot3DAxisFlags_AutoFit##X", (unsigned int*)&xflags, ImPlot3DAxisFlags_AutoFit); |
| 1347 | |
| 1348 | ImGui::TextUnformatted("Y: "); |
| 1349 | ImGui::SameLine(); |
| 1350 | ImGui::CheckboxFlags("ImPlot3DAxisFlags_AutoFit##Y", (unsigned int*)&yflags, ImPlot3DAxisFlags_AutoFit); |
| 1351 | |
| 1352 | ImGui::TextUnformatted("Z: "); |
| 1353 | ImGui::SameLine(); |
| 1354 | ImGui::CheckboxFlags("ImPlot3DAxisFlags_AutoFit##Z", (unsigned int*)&zflags, ImPlot3DAxisFlags_AutoFit); |
| 1355 | |
| 1356 | static double data_x[101], data_y[101], data_z[101]; |
| 1357 | static bool initialized = false; |
| 1358 | if (!initialized) { |
| 1359 | srand(0); |
| 1360 | for (int i = 0; i < 101; ++i) { |
| 1361 | data_x[i] = i * 0.1; |
| 1362 | data_y[i] = i * 0.1; |
| 1363 | data_z[i] = 1 + sin(i / 10.0); |
| 1364 | } |
| 1365 | initialized = true; |
| 1366 | } |
| 1367 | |
| 1368 | if (ImPlot3D::BeginPlot("##AutoFitting")) { |
| 1369 | ImPlot3D::SetupAxes("X-Axis", "Y-Axis", "Z-Axis", xflags, yflags, zflags); |
| 1370 | ImPlot3D::PlotLine("Wave", data_x, data_y, data_z, 101); |
| 1371 | ImPlot3D::EndPlot(); |
| 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | //----------------------------------------------------------------------------- |
| 1376 | // [SECTION] Tools |