| 21 | } |
| 22 | |
| 23 | void _SimulationParametersSourceWidgets::process() |
| 24 | { |
| 25 | auto& editService = SimulationParametersEditService::get(); |
| 26 | |
| 27 | auto parameters = _simulationFacade->getSimulationParameters(); |
| 28 | auto origParameters = _simulationFacade->getOriginalSimulationParameters(); |
| 29 | |
| 30 | auto worldSize = _simulationFacade->getWorldSize(); |
| 31 | auto sourceIndex = LocationHelper::findLocationArrayIndex(parameters, _locationIndex); |
| 32 | |
| 33 | RadiationSource& source = parameters.radiationSource[sourceIndex]; |
| 34 | auto lastSource = source; |
| 35 | RadiationSource& origSource = origParameters.radiationSource[sourceIndex]; |
| 36 | _sourceName = std::string(source.name); |
| 37 | |
| 38 | /** |
| 39 | * General |
| 40 | */ |
| 41 | if (AlienImGui::BeginTreeNode(AlienImGui::TreeNodeParameters().name("General"))) { |
| 42 | AlienImGui::InputText( |
| 43 | AlienImGui::InputTextParameters().name("Name").textWidth(RightColumnWidth).defaultValue(origSource.name), |
| 44 | source.name, |
| 45 | sizeof(Char64) / sizeof(char)); |
| 46 | |
| 47 | } |
| 48 | AlienImGui::EndTreeNode(); |
| 49 | |
| 50 | /** |
| 51 | * Location |
| 52 | */ |
| 53 | if (AlienImGui::BeginTreeNode(AlienImGui::TreeNodeParameters().name("Location"))) { |
| 54 | if (AlienImGui::Switcher( |
| 55 | AlienImGui::SwitcherParameters() |
| 56 | .name("Shape") |
| 57 | .values({"Circular", "Rectangular"}) |
| 58 | .textWidth(RightColumnWidth) |
| 59 | .defaultValue(origSource.shapeType), |
| 60 | source.shapeType)) { |
| 61 | if (source.shapeType == RadiationSourceShapeType_Circular) { |
| 62 | source.shapeData.circularRadiationSource.radius = 1; |
| 63 | } else { |
| 64 | source.shapeData.rectangularRadiationSource.width = 40; |
| 65 | source.shapeData.rectangularRadiationSource.height = 10; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | auto getMousePickerEnabledFunc = [&]() { return SimulationInteractionController::get().isPositionSelectionMode(); }; |
| 70 | auto setMousePickerEnabledFunc = [&](bool value) { SimulationInteractionController::get().setPositionSelectionMode(value); }; |
| 71 | auto getMousePickerPositionFunc = [&]() { return SimulationInteractionController::get().getPositionSelectionData(); }; |
| 72 | AlienImGui::SliderFloat2( |
| 73 | AlienImGui::SliderFloat2Parameters() |
| 74 | .name("Position (x,y)") |
| 75 | .textWidth(RightColumnWidth) |
| 76 | .min({0, 0}) |
| 77 | .max(toRealVector2D(worldSize)) |
| 78 | .defaultValue(RealVector2D{origSource.posX, origSource.posY}) |
| 79 | .format("%.2f") |
| 80 | .getMousePickerEnabledFunc(getMousePickerEnabledFunc) |
nothing calls this directly
no test coverage detected