Esempio n. 1
0
        /// <summary>
        /// Creates a horizontal (Y axis) measurement cursor.
        /// </summary>
        private static ScopeCursor CreateYAxisMeasurementCursor(bool isReferenceCursor,
                                                                Func <String> valueTextProvider, Color cursorColor
                                                                )
        {
            var cairoColor = CairoHelpers.ToCairoColor(cursorColor);

            ScopeCursorMarkers     markers;
            ScopeVerticalAlignment valueAlignment;

            if (isReferenceCursor)
            {
                markers        = ScopeCursorMarkers.YLower;
                valueAlignment = ScopeVerticalAlignment.Top;
            }
            else
            {
                markers        = ScopeCursorMarkers.YUpper;
                valueAlignment = ScopeVerticalAlignment.Bottom;
            }

            return(new ScopeCursor
            {
                Lines = ScopeCursorLines.Y,
                LineWeight = ScopeCursorLineWeight.Medium,
                SelectableLines = ScopeCursorLines.Y,
                Markers = markers,
                Color = cairoColor,
                Captions = new []
                {
                    new ScopePositionCaption(valueTextProvider, ScopeHorizontalAlignment.Right, valueAlignment, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, cairoColor),
                },
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a reference line cursor for a single channel.
        /// </summary>
        internal static BoundCursor CreateChannelReferenceCursor(ChannelViewModel channelVM)
        {
            var channelCaption = channelVM.Caption;
            var channelColor   = CairoHelpers.ToCairoColor(channelVM.Color);

            var cursor = new ScopeCursor
            {
                Lines           = ScopeCursorLines.Y,
                LineWeight      = ScopeCursorLineWeight.Low,
                SelectableLines = ScopeCursorLines.Y,
                Markers         = ScopeCursorMarkers.YFull,
                Color           = channelColor,
                Captions        = new []
                {
                    new ScopePositionCaption(() => channelCaption, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, channelColor),
                    new ScopePositionCaption(() => channelCaption, ScopeHorizontalAlignment.Right, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, channelColor),
                },
            };

            // === Create bindings. ===

            // Bind the cursor's position.
            var binding = PB.Binding.Create(() => cursor.Position.Y == channelVM.ReferencePointPosition.Y);

            return(new BoundCursor(cursor, new [] { binding }));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a trigger criteria cursor for a level-based trigger.
        /// </summary>
        private static BoundCursor CreateTriggerCriteriaCursor(
            char triggerModeSymbol,
            Func <double> valueProvider,
            Func <ScopeCursor, ValueConverter <double, double>, PB.Binding> valueBindingProvider,
            Func <double> valueScaleFactorProvider,
            Func <double> referencePointPositionProvider,
            Func <double> referenceLevelProvider,
            string baseUnitString,
            Color levelColor,
            IEnumerable <INotifyPropertyChanged> influencingObjects)
        {
            var           triggerCaption    = string.Format("{0}{1}", _triggerSymbol, triggerModeSymbol);
            Func <String> levelTextProvider = () =>
                                              UnitHelper.BuildValueText(baseUnitString, valueProvider());

            var cairoColor = CairoHelpers.ToCairoColor(levelColor);

            var cursor = new ScopeCursor
            {
                Lines           = ScopeCursorLines.Y,
                LineWeight      = ScopeCursorLineWeight.Low,
                SelectableLines = ScopeCursorLines.Y,
                Markers         = ScopeCursorMarkers.YFull,
                Color           = cairoColor,
                Captions        = new []
                {
                    new ScopePositionCaption(() => triggerCaption, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, cairoColor),
                    new ScopePositionCaption(() => triggerCaption, ScopeHorizontalAlignment.Right, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, cairoColor),
                    new ScopePositionCaption(levelTextProvider, ScopeHorizontalAlignment.Right, ScopeVerticalAlignment.Top, ScopeAlignmentReference.YPositionAndHorizontalRangeEdge, true, cairoColor),
                },
            };

            // === Create value converters. ===

            var valueConverter = new ValueConverter <double, double>(
                val => (val - referenceLevelProvider()) * valueScaleFactorProvider() + referencePointPositionProvider(),
                val => ((val - referencePointPositionProvider()) / valueScaleFactorProvider()) + referenceLevelProvider());

            // === Create bindings. ===

            // Bind the cursor's position.
            var binding = valueBindingProvider(cursor, valueConverter);

            // The trigger cursor's position depends on some additional values (except the primary value
            // it is bound to). Update it if any of these values changes. ===
            influencingObjects.ForEachDo(influencingObject =>
            {
                influencingObject.PropertyChanged += (sender, e) =>
                {
                    PB.Binding.InvalidateMember(() => valueConverter.DerivedValue);
                };
            });

            return(new BoundCursor(cursor, new [] { binding }));
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a scope graph from a channel configuration and a sample sequence provider.
        /// </summary>
        private ScopeGraph CreateScopeGraph(ChannelViewModel channelVM, Func <SampleSequence> sampleSequenceProvider)
        {
            var graphbaseVM          = _viewModel.GraphbaseVM;
            var triggerPointPosition = graphbaseVM.TriggerVM.HorizontalPosition;

            var sampleSequence = sampleSequenceProvider();

            return(new ScopeGraph
            {
                LineType = _graphLineType,
                ReferencePointPosition =
                    new Cairo.PointD(
                        channelVM.ReferencePointPosition.X + triggerPointPosition,
                        channelVM.ReferencePointPosition.Y),
                Color = CairoHelpers.ToCairoColor(channelVM.Color),
                XScaleFactor = channelVM.XScaleFactor,
                YScaleFactor = channelVM.YScaleFactor,
                ReferencePoint =
                    new Cairo.PointD(sampleSequence.ReferenceX, _referenceLevel),
                Vertices = sampleSequence.Values
                           .Select((value, counter) => new Cairo.PointD(counter * sampleSequence.SampleInterval * graphbaseVM.ScaleFactor, value)),
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a trigger point cursor.
        /// </summary>
        internal static BoundCursor CreateTriggerPointCursor(GraphbaseViewModel graphbaseVM)
        {
            var triggerVM = graphbaseVM.TriggerVM;

            Func <String> triggerStateCaptionProvider = () =>
                                                        triggerVM.State == TriggerState.Armed ? _armedCaption
                : triggerVM.State == TriggerState.Triggered ? _triggeredCaption
                : "";

            Func <String> positionTextProvider = () =>
                                                 UnitHelper.BuildValueText(graphbaseVM.BaseUnitString,
                                                                           triggerVM.HorizontalPosition / graphbaseVM.ScaleFactor);

            var markerColor = CairoHelpers.ToCairoColor(graphbaseVM.Color);

            var cursor = new ScopeCursor
            {
                Lines           = ScopeCursorLines.X,
                LineWeight      = ScopeCursorLineWeight.Low,
                SelectableLines = ScopeCursorLines.X,
                Markers         = ScopeCursorMarkers.XFull,
                Color           = markerColor,
                Captions        = new []
                {
                    new ScopePositionCaption(triggerStateCaptionProvider, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Top, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                    new ScopePositionCaption(triggerStateCaptionProvider, ScopeHorizontalAlignment.Left, ScopeVerticalAlignment.Bottom, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                    new ScopePositionCaption(positionTextProvider, ScopeHorizontalAlignment.Right, ScopeVerticalAlignment.Top, ScopeAlignmentReference.XPositionAndVerticalRangeEdge, true, markerColor),
                },
            };

            // === Create bindings. ===

            // Bind the cursor's position.
            var binding = PB.Binding.Create(() => cursor.Position.X == triggerVM.HorizontalPosition);

            return(new BoundCursor(cursor, new [] { binding }));
        }