/// <summary>
 /// If the Shift-Key is pressed, this zooms into the Canvas, keeping true the scroll-wheel-acceleration.
 /// Functionality: This uses the ScaleTransform-property of the canvas.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <author>Jannik Arndt</author>
 private void Zoom(object sender, MouseWheelEventArgs e)
 {
     if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
     {
         VisualizationHelpers.ZoomFunction(ProcessModelCanvas, ScrollViewer, "", e, sender);
     }
 }
 /// <summary>
 /// If the Shift-Key is pressed, this zooms into the Canvas, keeping true the scroll-wheel-acceleration.
 /// Functionality: This uses the ScaleTransform-property of the canvas.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <author>Jannik Arndt</author>
 private void Zoom(object sender, MouseWheelEventArgs e)
 {
     if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
     {
         VisualizationHelpers.ZoomFunction(CanvasConformanceChecking, ScrollViewer, "", e, sender);
     }
 }
        /// <summary>
        /// Shows the ProcessModel in the Preview-Box
        /// </summary>
        /// <param name="field"></param>
        /// <author>Jannik Arndt, Bernhard Bruns</author>
        private void ShowPreviewOfField(Field field)
        {
            if (field.ProcessModel == null)
            {
                throw new ArgumentNullException("field", @"No processmodel can be found for this field");
            }
            if (field.ProcessModel.GetHashCode() == _currentPreviewModel)
            {
                return;
            }

            ProcessModelPreviewCanvas.Children.Clear();
            ProcessModelPreviewCanvas.Width  = 300;
            ProcessModelPreviewCanvas.Height = 100;
            VisualizationHelpers.GetOrCreatePetriNetVisualization(field, ProcessModelPreviewCanvas, false);
            _currentPreviewModel = field.ProcessModel.GetHashCode();
        }
Beispiel #4
0
        protected void OnGUI()
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            // If we have a parent, offset our rect by the parent.
            var rect = m_Rect;

            if (m_Parent != null)
            {
                rect.position += m_Parent.m_Rect.position;
            }

            if (m_Visualizer != null)
            {
                m_Visualizer.OnDraw(rect);
            }
            else
            {
                VisualizationHelpers.DrawRectangle(rect, new Color(1, 1, 1, 0.1f));
            }

            // Draw label, if we have one.
            if (!string.IsNullOrEmpty(m_Label))
            {
                if (m_LabelContent == null)
                {
                    m_LabelContent = new GUIContent(m_Label);
                }
                if (s_LabelStyle == null)
                {
                    s_LabelStyle = new GUIStyle();
                    s_LabelStyle.normal.textColor = Color.yellow;
                }

                ////FIXME: why does CalcSize not calculate the rect width correctly?
                var labelSize = s_LabelStyle.CalcSize(m_LabelContent);
                var labelRect = new Rect(rect.x + 4, rect.y, labelSize.x + 4, rect.height);

                s_LabelStyle.Draw(labelRect, m_LabelContent, false, false, false, false);
            }
        }
        protected new void OnGUI()
        {
            if (m_Visualization == Visualization.None)
            {
                return;
            }

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            base.OnGUI();

            if (m_ShowControlName && m_ActiveControlName != null)
            {
                VisualizationHelpers.DrawText(m_ActiveControlName, new Vector2(m_Rect.x, m_Rect.yMax),
                                              VisualizationHelpers.ValueTextStyle);
            }
        }
        /// <summary>
        /// Catches Key-events (handler is set in the constructor)
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        /// <author>Jannik Arndt, Thomas Meents, Bernd Nottbeck, Bernhard Bruns</author>
        private void HandleShortcuts(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                switch (e.Key)
                {
                case Key.P: Printer.PrintCanvas(ProcessModelCanvas); break;

                case Key.S:
                {
                    if (Exporter.Export(ProcessModelCanvas, null))
                    {
                        ModernDialog.ShowMessage("File saved successfully!", "Export", MessageBoxButton.OK);
                    }
                    break;
                }
                }
            }
            else
            {
                switch (e.Key)
                {
                case Key.OemPlus: VisualizationHelpers.ZoomFunction(ProcessModelCanvas, ScrollViewer, "in"); break;

                case Key.OemMinus: VisualizationHelpers.ZoomFunction(ProcessModelCanvas, ScrollViewer, "out"); break;

                case Key.Left: VisualizationHelpers.ScrollToDirection(VisualizationHelpers.Direction.Left, ProcessModelCanvas); break;

                case Key.Right: VisualizationHelpers.ScrollToDirection(VisualizationHelpers.Direction.Right, ProcessModelCanvas); break;

                case Key.Up: VisualizationHelpers.ScrollToDirection(VisualizationHelpers.Direction.Up, ProcessModelCanvas); break;

                case Key.Down: VisualizationHelpers.ScrollToDirection(VisualizationHelpers.Direction.Down, ProcessModelCanvas); break;
                }
            }
        }
        /// <summary>
        /// Conformance Check between the eventlog and generated process model.
        /// The criticized transitions are shown in the process model.
        /// </summary>
        /// <autor>Andrej Albrecht</autor>
        public void DrawConformanceModelInCanvas(Field field, Canvas canvas)
        {
            try
            {
                // Create Footprints
                ComparingFootprint             footPrintEventlog = ComparingFootprintAlgorithm.CreateFootprint(field.EventLog);
                ComparingFootprint             footPrintPetrinet = ComparingFootprintAlgorithm.CreateFootprint((PetriNet)field.ProcessModel);
                ComparingFootprintResultMatrix resultFootprint   = new ComparingFootprintResultMatrix(footPrintEventlog, footPrintPetrinet);

                // Calculate Fitness
                double fitnessComparingFootprint = ComparingFootprintAlgorithm.CalculateFitness(resultFootprint.GetNumberOfDifferences(), resultFootprint.GetNumberOfOpportunities());
                FitnessComparingFootprints.Content = "Fitness Comparing Footprints: " + Math.Round(fitnessComparingFootprint * 100, 2) + " %";

                // Prepare Canvas & draw model
                RemoveListenerFromCanvas(canvas);
                canvas.Children.Clear();
                VisualizationHelpers.GetOrCreatePetriNetVisualization(field, canvas);
                AddListenertoTransitions(canvas);

                // Color the transitions in
                List <String>         listOfGreenTransitions = new List <String>();
                List <String>         listOfRedTransitions   = new List <String>();
                List <List <String> > listOfLinesToBeRemoved = new List <List <String> >();

                int row = 0;
                foreach (String rowHeaderName in resultFootprint.HeaderWithEventNames)
                {
                    int column = 0;
                    foreach (String columnHeaderName in resultFootprint.HeaderWithEventNames)
                    {
                        if (resultFootprint.ResultMatrix[row, column].Equals(ResultCellType.NoDifferences) && rowHeaderName.Equals(columnHeaderName))
                        {
                            listOfGreenTransitions.Add(rowHeaderName);
                        }

                        else if (resultFootprint.ResultMatrix[row, column].Equals(ResultCellType.NothingAndRight))
                        {
                            listOfLinesToBeRemoved.Add(new List <String> {
                                rowHeaderName, columnHeaderName
                            });
                        }

                        // else if (ResultFootprint.ResultMatrix[Row, Column].Equals(ResultCellType.RightAndNothing))
                        // Model enhacement: here you can fill a list of lines that are must to be add to the petrinet
                        // example: listOfLinesToAddTo.Add(new TransitionCombination(yHeaderName, xHeaderName));

                        else if (rowHeaderName.Equals(columnHeaderName))
                        {
                            listOfRedTransitions.Add(rowHeaderName);
                        }

                        column++;
                    }
                    row++;
                }

                SetColorInCanvas(listOfGreenTransitions, Brushes.Green, canvas);
                SetColorInCanvas(listOfRedTransitions, Brushes.Red, canvas);
                SetColorOnLinesToBeRemoved(listOfLinesToBeRemoved, canvas, (PetriNet)field.ProcessModel);
            }
            catch (Exception Ex)
            {
                ErrorHandling.ReportErrorToUser("Error: " + Ex.Message + Ex.StackTrace);
            }
        }
 private void ZoomOutClick(object sender, RoutedEventArgs e)
 {
     VisualizationHelpers.ZoomFunction(ProcessModelCanvas, ScrollViewer, "out");
 }
 private void ShowProcessModelInCanvas(bool forceRedraw = false)
 {
     ProcessModelCanvas.Children.Clear();
     VisualizationHelpers.GetOrCreatePetriNetVisualization(CurrentField, ProcessModelCanvas, forceRedraw: forceRedraw);
 }