MCPcopy Create free account
hub / github.com/chrxh/alien / onAddSource

Method onAddSource

source/Gui/SimulationParametersMainWindow.cpp:519–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void 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
558void SimulationParametersMainWindow::onCloneLocation()
559{

Callers

nothing calls this directly

Calls 8

toFloatFunction · 0.85
getRadiationStrengthsMethod · 0.80
getWorldSizeMethod · 0.80

Tested by

no test coverage detected