| 517 | } |
| 518 | |
| 519 | void SimulationParametersMainWindow::onAddSource() |
| 520 | { |
| 521 | auto& editService = SimulationParametersEditService::get(); |
| 522 | |
| 523 | auto parameters = _simulationFacade->getSimulationParameters(); |
| 524 | auto origParameters = _simulationFacade->getOriginalSimulationParameters(); |
| 525 | |
| 526 | if (!checkNumSources(parameters)) { |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | ++_selectedLocationIndex; |
| 531 | LocationHelper::adaptLocationIndex(parameters, _selectedLocationIndex, 1); |
| 532 | LocationHelper::adaptLocationIndex(origParameters, _selectedLocationIndex, 1); |
| 533 | |
| 534 | auto strengths = editService.getRadiationStrengths(parameters); |
| 535 | auto newStrengths = editService.calcRadiationStrengthsForAddingZone(strengths); |
| 536 | |
| 537 | auto worldSize = _simulationFacade->getWorldSize(); |
| 538 | |
| 539 | RadiationSource source; |
| 540 | StringHelper::copy(source.name, sizeof(source.name), LocationHelper::generateSourceName(parameters)); |
| 541 | source.locationIndex = _selectedLocationIndex; |
| 542 | source.posX = toFloat(worldSize.x / 2); |
| 543 | source.posY = toFloat(worldSize.y / 2); |
| 544 | |
| 545 | auto index = parameters.numRadiationSources; |
| 546 | parameters.radiationSource[index] = source; |
| 547 | origParameters.radiationSource[index] = source; |
| 548 | ++parameters.numRadiationSources; |
| 549 | ++origParameters.numRadiationSources; |
| 550 | |
| 551 | editService.applyRadiationStrengths(parameters, newStrengths); |
| 552 | editService.applyRadiationStrengths(origParameters, newStrengths); |
| 553 | |
| 554 | _simulationFacade->setSimulationParameters(parameters); |
| 555 | _simulationFacade->setOriginalSimulationParameters(origParameters); |
| 556 | } |
| 557 | |
| 558 | void SimulationParametersMainWindow::onCloneLocation() |
| 559 | { |
nothing calls this directly
no test coverage detected