/// Returns signed 2 theta (signed scattering angle w.r.t. to beam direction). double DetectorInfo::signedTwoTheta(const std::pair<size_t, size_t> &index) const { if (isMonitor(index)) throw std::logic_error( "Two theta (scattering angle) is not defined for monitors."); const auto samplePos = samplePosition(); const auto beamLine = samplePos - sourcePosition(); if (beamLine.nullVector()) { throw Kernel::Exception::InstrumentDefinitionError( "Source and sample are at same position!"); } // Get the axis defining the sign const auto &instrumentUpAxis = m_instrument->getReferenceFrame()->vecThetaSign(); const auto sampleDetVec = position(index) - samplePos; double angle = sampleDetVec.angle(beamLine); const auto cross = beamLine.cross_prod(sampleDetVec); const auto normToSurface = beamLine.cross_prod(instrumentUpAxis); if (normToSurface.scalar_prod(cross) < 0) { angle *= -1; } return angle; }
void GUI::handleButtonPress() { // Get the QObject that triggered this signal QObject* sender = QObject::sender(); // Determine which callback to call with which parameters if (sender == _sourcePointButton) _sourceAddedCallback(SourceType::Point, sourcePosition(), sourceValue()); else if (sender == _sourceConeButton) _sourceAddedCallback(SourceType::Cone, sourcePosition(), sourceValue()); else if (sender == _effectGravityButton) _effectAddedCallback(EffectType::Gravity, effectPosition(), effectValue()); else if (sender == _effectWindButton) _effectAddedCallback(EffectType::Wind, effectPosition(), effectValue()); else LFATAL("Missing handler for button press"); }
qreal totalDistance() const { GeoDataLineString measure; GeoDataCoordinates sourcePosition(m_source.longitude(), m_source.latitude()); GeoDataCoordinates targetPosition(m_target.longitude(), m_target.latitude()); measure << sourcePosition << targetPosition; return measure.length(m_planetRadius); }
void suggestedPos(qreal t, qreal &lon, qreal &lat) const { Q_ASSERT( 0 <= t && t <= 1.0 ); GeoDataCoordinates sourcePosition(m_source.longitude(), m_source.latitude()); GeoDataCoordinates targetPosition(m_target.longitude(), m_target.latitude()); // Spherical interpolation for current position between source position // and target position. We can't use Nlerp here, as the "t-velocity" needs to be constant. const Quaternion itpos = Quaternion::slerp( sourcePosition.quaternion(), targetPosition.quaternion(), t ); itpos.getSpherical( lon, lat ); }
/// Returns 2 theta (scattering angle w.r.t. to beam direction). double DetectorInfo::twoTheta(const std::pair<size_t, size_t> &index) const { if (isMonitor(index)) throw std::logic_error( "Two theta (scattering angle) is not defined for monitors."); const auto samplePos = samplePosition(); const auto beamLine = samplePos - sourcePosition(); if (beamLine.nullVector()) { throw Kernel::Exception::InstrumentDefinitionError( "Source and sample are at same position!"); } const auto sampleDetVec = position(index) - samplePos; return sampleDetVec.angle(beamLine); }
virtual void SetUp() override { TestBase::SetUp(); Logger::getInstance(); projectionResolution = Vec2ui(2048, 2048); Vec3ui volumeResolution; if(framework->on64bitArchitecture()) { volumeResolution = Vec3ui(2000, 2000, 100); } else { volumeResolution = Vec3ui(2000, 2000, 100); } volumeOptions = new VolumeParameterSet(volumeResolution); subVolumeCount = 4; volume = new FloatVolume(volumeOptions->getResolution(), 1.0f, subVolumeCount); Vec3f sourcePosition(-1000.0f, -1000.0f, -100.0f); Vec3f detectorPosition(-1000.0f, -1000.0f, 100.0f); Vec3f horizontalPitch(1.0f, 0.0f, 0.0f); Vec3f verticalPitch(0.0f, 1.0f, 0.0f); ScannerGeometry* initialScannerGeometry = new ParallelScannerGeometry ( projectionResolution ); initialScannerGeometry->set(sourcePosition, detectorPosition, horizontalPitch, verticalPitch); satRotator->setBaseScannerGeometry(initialScannerGeometry); geometricSetup = new GeometricSetup(initialScannerGeometry->clone(), volume); accumulatedVolume = new GPUMappedVolume(framework->getOpenCLStack(), volume); residual = new GPUMapped<Image>(framework->getOpenCLStack(), projectionResolution); rayLengthImage = new GPUMapped<Image>(framework->getOpenCLStack(), projectionResolution); computeRayLength = new ComputeRayLengthKernel(framework, geometricSetup, rayLengthImage); backProjectKernel = new ParallelBeamsBackProjectionKernel(framework, geometricSetup, accumulatedVolume, nullptr, 1.0f, 1, false); backProjectKernel->SetInput(residual, computeRayLength->getOutput()); }
/** Returns L2 (distance from sample to spectrum). * * For monitors this is defined such that L1+L2 = source-detector distance, * i.e., for a monitor in the beamline between source and sample L2 is negative. */ double DetectorInfo::l2(const std::pair<size_t, size_t> &index) const { if (!isMonitor(index)) return position(index).distance(samplePosition()); else return position(index).distance(sourcePosition()) - l1(); }
void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { ASSERT(scriptExecutionContext); if (!scriptExecutionContext || scriptExecutionContext->isJSExecutionForbidden()) return; VM& vm = scriptExecutionContext->vm(); JSLockHolder lock(vm); auto scope = DECLARE_CATCH_SCOPE(vm); // See https://dom.spec.whatwg.org/#dispatching-events spec on calling handleEvent. // "If this throws an exception, report the exception." It should not propagate the // exception. JSObject* jsFunction = this->jsFunction(scriptExecutionContext); if (!jsFunction) return; JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, *m_isolatedWorld); if (!globalObject) return; if (scriptExecutionContext->isDocument()) { JSDOMWindow* window = jsCast<JSDOMWindow*>(globalObject); if (!window->wrapped().isCurrentlyDisplayedInFrame()) return; if (wasCreatedFromMarkup() && !scriptExecutionContext->contentSecurityPolicy()->allowInlineEventHandlers(sourceURL(), sourcePosition().m_line)) return; // FIXME: Is this check needed for other contexts? ScriptController& script = window->wrapped().frame()->script(); if (!script.canExecuteScripts(AboutToExecuteScript) || script.isPaused()) return; } ExecState* exec = globalObject->globalExec(); JSValue handleEventFunction = jsFunction; CallData callData; CallType callType = getCallData(handleEventFunction, callData); // If jsFunction is not actually a function, see if it implements the EventListener interface and use that if (callType == CallType::None) { handleEventFunction = jsFunction->get(exec, Identifier::fromString(exec, "handleEvent")); if (UNLIKELY(scope.exception())) { auto* exception = scope.exception(); scope.clearException(); event->target()->uncaughtExceptionInEventHandler(); reportException(exec, exception); return; } callType = getCallData(handleEventFunction, callData); } if (callType != CallType::None) { Ref<JSEventListener> protectedThis(*this); MarkedArgumentBuffer args; args.append(toJS(exec, globalObject, event)); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject); InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData); JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction; NakedPtr<JSC::Exception> exception; JSValue retval = scriptExecutionContext->isDocument() ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception) : JSC::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception); InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext); globalObject->setCurrentEvent(savedEvent); if (is<WorkerGlobalScope>(*scriptExecutionContext)) { auto scriptController = downcast<WorkerGlobalScope>(*scriptExecutionContext).script(); bool terminatorCausedException = (scope.exception() && isTerminatedExecutionException(scope.exception())); if (terminatorCausedException || scriptController->isTerminatingExecution()) scriptController->forbidExecution(); } if (exception) { event->target()->uncaughtExceptionInEventHandler(); reportException(exec, exception); } else { if (!retval.isUndefinedOrNull() && is<BeforeUnloadEvent>(*event)) downcast<BeforeUnloadEvent>(*event).setReturnValue(retval.toWTFString(exec)); if (m_isAttribute) { if (retval.isFalse()) event->preventDefault(); } } } }