Esempio n. 1
0
 private void ChangeHostControlAccordingToNewLight(IDiscreteLight newLightValue)
 {
     if (null == newLightValue)
     {
         ChangeHostControl(null);
     }
     else if (newLightValue is DirectionalLight)
     {
         var ctrl = new DirectionalLightControl
         {
             SelectedValue = newLightValue as DirectionalLight
         };
         ChangeHostControl(ctrl);
     }
     else if (newLightValue is PointLight)
     {
         var ctrl = new PointLightControl
         {
             SelectedValue = newLightValue as PointLight
         };
         ChangeHostControl(ctrl);
     }
     else if (newLightValue is SpotLight)
     {
         var ctrl = new SpotLightControl
         {
             SelectedValue = newLightValue as SpotLight
         };
         ChangeHostControl(ctrl);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Called when the radio button signals that the user want to change the light type.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs" /> instance containing the event data.</param>
        private void EhLightTypeChanged(object sender, RoutedEventArgs e)
        {
            if (_lock.IsNotLocked)
            {
                IDiscreteLight newLight = null;
                if (object.ReferenceEquals(sender, _guiNotUsed))
                {
                    newLight = null;
                }
                else if (object.ReferenceEquals(sender, _guiDirectional))
                {
                    newLight = new Altaxo.Graph.Graph3D.Lighting.DirectionalLight();
                }
                else if (object.ReferenceEquals(sender, _guiPoint))
                {
                    newLight = new Altaxo.Graph.Graph3D.Lighting.PointLight();
                }
                else if (object.ReferenceEquals(sender, _guiSpot))
                {
                    newLight = new Altaxo.Graph.Graph3D.Lighting.SpotLight();
                }
                else
                {
                    throw new NotImplementedException();
                }

                if (newLight?.GetType() != SelectedValue?.GetType())
                {
                    ChangeHostControlAccordingToNewLight(newLight);
                    SelectedValueChanged?.Invoke(this, EventArgs.Empty);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a new instance of <see cref="LightSettings"/> with the provided value for one of the discrete lights with index 0..3.
        /// </summary>
        /// <param name="idx">One of the indices of the discrete lights (0..3).</param>
        /// <param name="discreteLight">The new value for the discrete light. This value can be null (in this case, the discrete light is removed).</param>
        /// <returns>New instance of <see cref="LightSettings"/> with the provided value for the discrete light.</returns>
        public LightSettings WithDiscreteLight(int idx, IDiscreteLight discreteLight)
        {
            var result = (LightSettings)MemberwiseClone();

            switch (idx)
            {
            case 0:
                result._discreteLight0 = discreteLight;
                break;

            case 1:
                result._discreteLight1 = discreteLight;
                break;

            case 2:
                result._discreteLight2 = discreteLight;
                break;

            case 3:
                result._discreteLight3 = discreteLight;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(idx));
            }

            result.CalculateIsAnyAffixedToCamera();

            return(result);
        }
Esempio n. 4
0
 private void SetRadioButtonAccordingToNewLight(IDiscreteLight newLightValue)
 {
     if (newLightValue == null)
     {
         _guiNotUsed.IsChecked = true;
     }
     else if (newLightValue is DirectionalLight)
     {
         _guiDirectional.IsChecked = true;
     }
     else if (newLightValue is PointLight)
     {
         _guiPoint.IsChecked = true;
     }
     else if (newLightValue is SpotLight)
     {
         _guiSpot.IsChecked = true;
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 5
0
		private void SetRadioButtonAccordingToNewLight(IDiscreteLight newLightValue)
		{
			if (newLightValue == null)
			{
				_guiNotUsed.IsChecked = true;
			}
			else if (newLightValue is DirectionalLight)
			{
				_guiDirectional.IsChecked = true;
			}
			else if (newLightValue is PointLight)
			{
				_guiPoint.IsChecked = true;
			}
			else if (newLightValue is SpotLight)
			{
				_guiSpot.IsChecked = true;
			}
			else
			{
				throw new NotImplementedException();
			}
		}
Esempio n. 6
0
		private void ChangeHostControlAccordingToNewLight(IDiscreteLight newLightValue)
		{
			if (null == newLightValue)
			{
				ChangeHostControl(null);
			}
			else if (newLightValue is DirectionalLight)
			{
				var ctrl = new DirectionalLightControl();
				ctrl.SelectedValue = newLightValue as DirectionalLight;
				ChangeHostControl(ctrl);
			}
			else if (newLightValue is PointLight)
			{
				var ctrl = new PointLightControl();
				ctrl.SelectedValue = newLightValue as PointLight;
				ChangeHostControl(ctrl);
			}
			else if (newLightValue is SpotLight)
			{
				var ctrl = new SpotLightControl();
				ctrl.SelectedValue = newLightValue as SpotLight;
				ChangeHostControl(ctrl);
			}
			else
			{
				throw new NotImplementedException();
			}
		}
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LightSettings"/> class with default values.
 /// </summary>
 public LightSettings()
 {
     _ambientLight   = new HemisphericAmbientLight(0.8, NamedColors.LightGray, NamedColors.White, new VectorD3D(0, 0, 1), false);
     _discreteLight0 = new DirectionalLight(0.2, NamedColors.White, new VectorD3D(-0.5, -0.5, Math.Sqrt(0.5)), false);
 }
Esempio n. 8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LightSettings"/> class with default values.
		/// </summary>
		public LightSettings()
		{
			_ambientLight = new HemisphericAmbientLight(0.8, NamedColors.LightGray, NamedColors.White, new VectorD3D(0, 0, 1), false);
			_discreteLight0 = new DirectionalLight(0.2, NamedColors.White, new VectorD3D(-0.5, -0.5, Math.Sqrt(0.5)), false);
		}
Esempio n. 9
0
		/// <summary>
		/// Gets a new instance of <see cref="LightSettings"/> with the provided value for one of the discrete lights with index 0..3.
		/// </summary>
		/// <param name="idx">One of the indices of the discrete lights (0..3).</param>
		/// <param name="discreteLight">The new value for the discrete light. This value can be null (in this case, the discrete light is removed).</param>
		/// <returns>New instance of <see cref="LightSettings"/> with the provided value for the discrete light.</returns>
		public LightSettings WithDiscreteLight(int idx, IDiscreteLight discreteLight)
		{
			var result = (LightSettings)this.MemberwiseClone();
			switch (idx)
			{
				case 0:
					result._discreteLight0 = discreteLight;
					break;

				case 1:
					result._discreteLight1 = discreteLight;
					break;

				case 2:
					result._discreteLight2 = discreteLight;
					break;

				case 3:
					result._discreteLight3 = discreteLight;
					break;

				default:
					throw new ArgumentOutOfRangeException(nameof(idx));
			}

			result.CalculateIsAnyAffixedToCamera();

			return result;
		}