| 1431 | } |
| 1432 | |
| 1433 | void Plane( MR::PlaneWidget& planeWidget, PlaneWidgetFlags flags ) |
| 1434 | { |
| 1435 | float dragspeed = planeWidget.box().diagonal() * 1e-3f; |
| 1436 | auto setDefaultPlane = [&] ( const MR::Vector3f& normal ) |
| 1437 | { |
| 1438 | planeWidget.definePlane(); |
| 1439 | planeWidget.updatePlane( MR::Plane3f::fromDirAndPt( normal, planeWidget.box().min + normal * dragspeed ) ); |
| 1440 | if ( planeWidget.isInLocalMode() ) |
| 1441 | planeWidget.setLocalShift( dragspeed ); |
| 1442 | }; |
| 1443 | ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, { MR::cDefaultItemSpacing * UI::scale(), MR::cDefaultWindowPaddingY * UI::scale() } ); |
| 1444 | ImGui::PushStyleVar( ImGuiStyleVar_ItemInnerSpacing, { MR::cDefaultItemSpacing * UI::scale(), MR::cDefaultItemSpacing * UI::scale() } ); |
| 1445 | |
| 1446 | float p = ImGui::GetStyle().FramePadding.x; |
| 1447 | ImVec2 iconSize = { 32 * UI::scale(), 32 * UI::scale() }; |
| 1448 | ImVec2 buttonSize = { ( GetContentRegionAvail().x - 3 * p ) / 4, 70.0f * UI::scale() }; |
| 1449 | if ( MR::UI::buttonIcon( "Plane YZ", iconSize, _tr( "Plane YZ" ), buttonSize ) ) |
| 1450 | setDefaultPlane( MR::Vector3f::plusX() ); |
| 1451 | ImGui::SameLine( 0, p ); |
| 1452 | if ( MR::UI::buttonIcon( "Plane XZ", iconSize, _tr( "Plane XZ" ), buttonSize ) ) |
| 1453 | setDefaultPlane( MR::Vector3f::plusY() ); |
| 1454 | ImGui::SameLine( 0, p ); |
| 1455 | if ( MR::UI::buttonIcon( "Plane XY", iconSize, _tr( "Plane XY" ), buttonSize ) ) |
| 1456 | setDefaultPlane( MR::Vector3f::plusZ() ); |
| 1457 | ImGui::SameLine( 0, p ); |
| 1458 | |
| 1459 | const bool importPlaneModeOld = planeWidget.importPlaneMode(); |
| 1460 | if ( importPlaneModeOld ) |
| 1461 | ImGui::PushStyleColor( ImGuiCol_Button, ImGui::GetStyleColorVec4( ImGuiCol_ButtonActive ) ); |
| 1462 | |
| 1463 | if ( MR::UI::buttonIcon( "Plane Import", iconSize, _tr( "Import Plane" ), buttonSize ) ) |
| 1464 | { |
| 1465 | planeWidget.setImportPlaneMode( !planeWidget.importPlaneMode() ); |
| 1466 | } |
| 1467 | else if ( ImGui::IsMouseReleased( ImGuiMouseButton_Left ) && importPlaneModeOld == planeWidget.importPlaneMode() ) |
| 1468 | { |
| 1469 | planeWidget.setImportPlaneMode( false ); |
| 1470 | } |
| 1471 | if ( importPlaneModeOld ) |
| 1472 | ImGui::PopStyleColor(); |
| 1473 | |
| 1474 | if ( planeWidget.importPlaneMode() ) |
| 1475 | ImGui::Text( "%s", _tr( "Click on the plane object in scene to import its parameters" ) ); |
| 1476 | |
| 1477 | if ( !planeWidget.getPlaneObject() ) |
| 1478 | { |
| 1479 | ImGui::PopStyleVar( 2 ); |
| 1480 | return; |
| 1481 | } |
| 1482 | |
| 1483 | ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, { ImGui::GetStyle().FramePadding.x, MR::cGradientButtonFramePadding * UI::scale() } ); |
| 1484 | |
| 1485 | auto localShift = planeWidget.getLocalShift(); |
| 1486 | auto planeBackUp = planeWidget.getPlane(); |
| 1487 | auto plane = planeWidget.getPlane(); |
| 1488 | |
| 1489 | ImGui::SetNextItemWidth( 200.0f * UI::scale() ); |
| 1490 | UI::drag<NoUnit>( _tr( "Normal" ), plane.n, 0.001f ); |
nothing calls this directly
no test coverage detected