Exemplo n.º 1
0
        private static void PopulateOperatorDefines(Operator root)
        {
            operatorDefines.Add(root.BindedCoreOperator.Name);

            foreach (Operator op in root.GetInputs())
                PopulateOperatorDefines(op);
        }
Exemplo n.º 2
0
 public Timeline(Operator operatorParent)
 {
     this.operatorParent = operatorParent;
     channels = new List<Channel>();
     clipStateChangedHandler = new Clip.EventHandler(this.clip_StateChanged);
     channelStateChangedHandler = new Channel.EventHandler(this.channel_StateChanged);
 }
Exemplo n.º 3
0
        private static ushort PopulateOldIdToNewIdAndOperatorsSortedOnNewId(Operator root, ushort id)
        {
            if (!oldIdToNewId.ContainsKey(root.BindedCoreOperator.Id))
            {
                oldIdToNewId.Add(root.BindedCoreOperator.Id, id);
                operatorsSortedOnNewId.Add(root);
            }
            foreach (Operator op in root.GetInputs())
                id = PopulateOldIdToNewIdAndOperatorsSortedOnNewId(op, ++id);

            return id;
        }
Exemplo n.º 4
0
        private ushort PopulateIdNormalizerHash(Operator root, ushort id)
        {
            if (!oldIdToNewId.ContainsKey(root.BindedOperator.Id))
            {
                oldIdToNewId.Add(root.BindedOperator.Id, id);
                operatorsSortedOnNewId.Add(root);
            }
            foreach (Operator op in root.GetInputs())
            {
                id = PopulateIdNormalizerHash(op, ++id);
            }

            return id;
        }
Exemplo n.º 5
0
        public static void Export(Operator root, String filename)
        {
            oldIdToNewId.Clear();
            operatorsSortedOnNewId.Clear();
            bytes.Clear();
            operatorDefines.Clear();

            PopulateOldIdToNewIdAndOperatorsSortedOnNewId(root, 0);
            PopulateOperatorDefines(root);
            
            AddOperatorInstances();
            AddOperatorProperties();
            AddOperatorConnections();
            AddOperatorPropertyAnimations();
            AddTimelineOperators();

            WriteToFile(filename);
        }
Exemplo n.º 6
0
        public bool Add(Operator op, Point point)
        {
            Point p = Operator.QuantizeLocation(point);
            op.Dimension = new Rectangle(p.X, p.Y, op.Width, op.Height);
            foreach (Operator presentOp in operators)
            {
                if (presentOp.Dimension.IntersectsWith(op.Dimension))
                    return false;
            }

            operators.Add(op);
            ICollection<Operator> added = new List<Operator>();
            added.Add(op);
            OnAdded(added);
            Connect(op);
            op.StateChanged += stateChangedHandler;

            // As present load operators might have this operator as target
            // we have to tell all load operators that an operator has been added.
            LoadOperator.PropagateOnOperatorAdded(op);

            return true;
        }
Exemplo n.º 7
0
 public void Remove(Operator op)
 {
     operators.Remove(op);
     ICollection<Operator> removed = new List<Operator>();
     removed.Add(op);
     OnRemoved(removed);
     Disconnect(op);
     op.StateChanged -= stateChangedHandler;
     op.Dispose();
 }
Exemplo n.º 8
0
 public virtual void RemoveSenderOperator(Operator op)
 {
     senders.Remove(op);
     StackConnectChangedUpwards();
     CascadeStackConnectChangedDownwards();
     op.StackConnectChangedUpwards();
     op.StackConnectChangedUpwards();
 }
Exemplo n.º 9
0
 public EventArgs(Operator op)
 {
     Operator = op;
 }
Exemplo n.º 10
0
        private bool Resize(Operator op, int width)
        {
            Size newSize = Operator.QuantizeSize(new Size(op.Width + width, op.Height));

            // Don't resize the operator if it hasn't been resized.
            if (newSize == op.Size)
                return false;

            op.Dimension = new Rectangle(op.Left, op.Top, newSize.Width, newSize.Height);
            Disconnect(op);
            Connect(op);
            return true;
        }
Exemplo n.º 11
0
 private void operator operatorPageView1_ViewedOperatorChanged(object sender, EventArgs e)
 {
     viewedOperator = operatorPageView1.ViewedOperator;
 }
Exemplo n.º 12
0
 protected void OnStateChanged(Operator op)
 {
     ICollection<Operator> operators = new List<Operator>();
     operators.Add(op);
     if (StateChanged != null)
         StateChanged(new Page.EventArgs(operators));
 }
Exemplo n.º 13
0
 private void Disconnect(Operator op)
 {
     Operator.Disconnect(op);
 }
Exemplo n.º 14
0
 public static void Disconnect(Operator op)
 {
     op.Disconnect();
 }
Exemplo n.º 15
0
 public virtual void ConnectWithLoadOperator(Operator op)
 {
     loads.Add(op);
     StackConnectChangedUpwards();
     CascadeStackConnectChangedDownwards();
 }
Exemplo n.º 16
0
 public override void OnDisposed(Operator op)
 {
 }
Exemplo n.º 17
0
 public static void Connect(Operator sender, Operator receiver)
 {
     sender.ConnectWithOperatorAsSender(receiver);
     receiver.ConnectWithOperatorAsReceiver(sender);
 }
Exemplo n.º 18
0
 private void operator operatorPageViewPanel1_ViewedOperatorPropertiesChanged(object sender, EventArgs e)
 {
     ViewedOperatorProperties = operatorPageViewPanel1.ViewedOperatorProperties;
 }
Exemplo n.º 19
0
        private void PaintOperator(Operator op, PaintEventArgs e)
        {
            Region clip = e.Graphics.Clip;
            e.Graphics.Clip = new Region(op.Dimension);

            double brightness = 1.0;
            if (op.IsSelected)
                brightness = 1.3;

            double saturation = 0.0;
            if (op.IsProcessable)
                saturation = 1.0;

            Color color = RGBHSL.ModifyBrightness(GetOperatorColor(op), brightness);
            color = RGBHSL.ModifySaturation(color, saturation);
            Color lightColor = RGBHSL.ModifyBrightness(color, 1.3);
            Color darkColor = RGBHSL.ModifyBrightness(color, 0.7);

            String displayName = op.Name;

            if (displayName == null || displayName == "")
                displayName = op.TypeName;

            Brush b = new SolidBrush(color);
            Pen lightPen = new Pen(lightColor);
            Pen darkPen = new Pen(darkColor);
            if (op.GetType() == typeof(CoreOperator) || op.GetType() == typeof(PropagateOperator))
            {
                e.Graphics.FillRectangle(b, op.Dimension);
                e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height));
                SizeF stringSize = e.Graphics.MeasureString(displayName, Font);
                e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top + op.Height / 2 - stringSize.Height / 2);
                e.Graphics.Clip = new Region(op.Dimension);
                e.Graphics.DrawLine(lightPen, op.Left, op.Top, op.Left + op.Width, op.Top);
                e.Graphics.DrawLine(lightPen, op.Left, op.Top + 1, op.Left, op.Top + op.Height - 2);
                e.Graphics.DrawLine(darkPen, op.Left + 1, op.Top + op.Height - 1, op.Left + op.Width, op.Top + op.Height - 1);
                e.Graphics.DrawLine(darkPen, op.Left + op.Width - 1, op.Top + 1, op.Left + op.Width - 1, op.Top + op.Height - 2);
            }
            else if (op.GetType() == typeof(StoreOperator))
            {
                Point[] points1 = new Point[3];
                points1[0] = new Point(op.Left, op.Top);
                points1[1] = new Point(op.Left + 10, op.Top);
                points1[2] = new Point(op.Left + 10, op.Top + op.Height - 6);
                e.Graphics.FillPolygon(b, points1);
                Point[] points2 = new Point[3];
                points2[0] = new Point(op.Left + op.Width - 1, op.Top);
                points2[1] = new Point(op.Left + op.Width - 10, op.Top + op.Height - 6);
                points2[2] = new Point(op.Left + op.Width - 10, op.Top);
                e.Graphics.FillPolygon(b, points2);
                e.Graphics.FillRectangle(b, new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height - 5));
                e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height - 5));
                SizeF stringSize = e.Graphics.MeasureString(displayName, Font);
                e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top + (op.Height - 5) / 2 - stringSize.Height / 2);
                e.Graphics.Clip = new Region(op.Dimension);
                e.Graphics.DrawLine(darkPen, op.Left, op.Top, op.Left + 9, op.Top + op.Height - 6);
                e.Graphics.DrawLine(darkPen, op.Left + 10, op.Top + op.Height - 6 , op.Left + op.Width - 11, op.Top + op.Height - 6);
                e.Graphics.DrawLine(darkPen, op.Left + op.Width - 10, op.Top + op.Height - 6, op.Left + op.Width - 1, op.Top);
                e.Graphics.DrawLine(lightPen, op.Left, op.Top, op.Left + op.Width - 2, op.Top);
            }
            else if (op.GetType() == typeof(LoadOperator))
            {
                Point[] points1 = new Point[3];
                points1[0] = new Point(op.Left, op.Top + op.Height);
                points1[1] = new Point(op.Left + 10, op.Top + op.Height);
                points1[2] = new Point(op.Left + 10, op.Top + 5);
                e.Graphics.FillPolygon(b, points1);
                Point[] points2 = new Point[3];
                points2[0] = new Point(op.Left + op.Width - 10, op.Top + 5);
                points2[1] = new Point(op.Left + op.Width, op.Top + op.Height);
                points2[2] = new Point(op.Left + op.Width - 10, op.Top + op.Height);
                e.Graphics.FillPolygon(b, points2);
                e.Graphics.FillRectangle(b, new Rectangle(op.Left + 10, op.Top + 5, op.Width - 20, op.Height - 5));
                e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top + 5, op.Width - 20, op.Height - 5));
                SizeF stringSize = e.Graphics.MeasureString(displayName, Font);
                e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top  + 5 + (op.Height - 5) / 2 - stringSize.Height / 2);
                e.Graphics.Clip = new Region(op.Dimension);
            }

            b.Dispose();
            lightPen.Dispose();
            darkPen.Dispose();

            if (!op.IsProcessable || op.IsWarningPresent)
                e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.warning_icon, op.Location.X + 1, op.Location.Y + 1);
            if (op == ViewedOperator)
                e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.eye_icon, op.Location.X + 1, op.Location.Y + 1);

            e.Graphics.Clip = clip;

            /*
            Rectangle rect = new Rectangle(op.Location, op.Size);
            SizeF stringSize = e.Graphics.MeasureString(op.Binding.DisplayName, Font);
            Point namePoint = new Point(rect.Width / 2 - (int)stringSize.Width / 2 + rect.X,
                                        rect.Height / 2 - (int)stringSize.Height / 2 + rect.Y);

            double brightness = 1.0;
            if (op.Selected)
                brightness = 1.3;
            double saturation = 0.0;
            if (op.Binding.IsProcessable())
                saturation = 1.0;

            Color color = RGBHSL.ModifyBrightness(op.Color, brightness);
            color = RGBHSL.ModifySaturation(color, saturation);
            Color lightColor = RGBHSL.ModifyBrightness(color, 1.3);
            Color darkColor = RGBHSL.ModifyBrightness(color, 0.7);
            Brush brush = new SolidBrush(color);
            Pen lightPen = new Pen(lightColor);
            Pen darkPen = new Pen(darkColor);

            Brush gradientBrush = new LinearGradientBrush(rect, lightColor, color, 0.0f);
            e.Graphics.FillRectangle(brush, rect);
            e.Graphics.DrawLine(lightPen,
                                op.Location.X,
                                op.Location.Y + op.Size.Height - 1,
                                op.Location.X,
                                op.Location.Y);
            e.Graphics.DrawLine(lightPen,
                                op.Location.X,
                                op.Location.Y,
                                op.Location.X + op.Size.Width - 1,
                                op.Location.Y);
            e.Graphics.DrawLine(darkPen,
                                op.Location.X + op.Size.Width - 1,
                                op.Location.Y,
                                op.Location.X + op.Size.Width - 1,
                                op.Location.Y + op.Size.Height - 1);
            e.Graphics.DrawLine(darkPen,
                                op.Location.X,
                                op.Location.Y + op.Size.Height - 1,
                                op.Location.X + op.Size.Width - 1,
                                op.Location.Y + op.Size.Height - 1);
            Brush textBrush = new SolidBrush(op.TextColor);
            e.Graphics.DrawString(op.Binding.DisplayName, Font, textBrush, namePoint);

            int x1 = op.GetAreaForResize().Left;
            int y1 = op.Location.Y + 3;
            int y2 = op.Location.Y + op.Size.Height - 4;

            for (int i = 0; i < 4; i++)
            {
                e.Graphics.DrawLine(lightPen,
                                    x1 + i * 3,
                                    y1,
                                    x1 + i * 3,
                                    y2);
                e.Graphics.DrawLine(darkPen,
                                    x1 + 1 + i * 3,
                                    y1,
                                    x1 + 1 + i * 3,
                                    y2);
            }

            if (!op.Binding.IsProcessable() || op.Binding.IsWarningPresent())
                e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.warning_icon, op.Location.X + 1, op.Location.Y + 1);
            if (op == Operators.ViewedOperator)
                e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.eye_icon, op.Location.X + 1, op.Location.Y + 1);
            */
        }
Exemplo n.º 20
0
 private void PaintResizingOperator(Operator op, PaintEventArgs e)
 {
     int width = CalculateResizeWidth(op.Width);
     Pen pen = new Pen(Color.White);
     e.Graphics.DrawRectangle(pen, op.Location.X, op.Location.Y, width - 1, op.Height - 1);
     pen.Dispose();
 }
Exemplo n.º 21
0
 public void operator _StateChanged(Operator.EventArgs e)
 {
     OnStateChanged(e.Operator);
 }
Exemplo n.º 22
0
 private void PaintMovingOperator(Operator op, PaintEventArgs e)
 {
     Point p = CalculateMovePoint();
     Point opLocation = op.Location;
     opLocation.X += p.X;
     opLocation.Y += p.Y;
     opLocation = Operator.QuantizeLocation(opLocation);
     Pen pen = new Pen(Color.White);
     e.Graphics.DrawRectangle(pen, opLocation.X, opLocation.Y, op.Width - 1, op.Height - 1);
     pen.Dispose();
 }
Exemplo n.º 23
0
 protected void OnResized(Operator op)
 {
     ICollection<Operator> operators = new List<Operator>();
     operators.Add(op);
     if (Resized != null)
         Resized(new Page.EventArgs(operators));
 }
Exemplo n.º 24
0
 public virtual void ConnectWithOperatorAsSender(Operator op)
 {
     receivers.Add(op);
     StackConnectChangedUpwards();
 }
Exemplo n.º 25
0
        private void Connect(Operator op)
        {
            ICollection<Operator> inConnections = GetIn(op.GetAreaForInConnections());
            foreach (Operator inOperator in inConnections)
                Operator.Connect(inOperator, op);

            ICollection<Operator> outConnections = GetIn(op.GetAreaForOutConnections());
            foreach (Operator outOperator in outConnections)
            {
                // Here we do a special trick with the outOperator.
                // Instead of simply connection the op operator we
                // disconnect the outOperator and reconnect it so it will
                // refresh it's input connection. By doing this we know
                // the order of inputs for the outOperator will stay fixed,
                // i.e. the left most input operator will be the first input
                // and the right most input operator will be the last input.
                // This is very important for operators that rely on a certain
                // order of inputs (like the distortion operator that takes
                // a texture to distort as the first input and a texture telling
                // the distortion operator how to the distort the first input as
                // second input).
                Disconnect(outOperator);
                Connect(outOperator);
            }
        }
Exemplo n.º 26
0
 public abstract void OnDisposed(Operator op);
Exemplo n.º 27
0
        private bool Move(Operator op, Point point)
        {
            Point newLocation = Operator.QuantizeLocation(new Point(op.Left + point.X,
                                                                    op.Top + point.Y));

            // Don't move the operator if it hasn't been moved.
            if (newLocation == op.Location)
                return false;

            op.Dimension = new Rectangle(newLocation.X, newLocation.Y, op.Width, op.Height);
            return true;
        }
Exemplo n.º 28
0
 public virtual void RemoveLoadOperator(Operator op)
 {
     loads.Remove(op);
     StackConnectChangedUpwards();
     CascadeStackConnectChangedDownwards();
     op.StackConnectChangedUpwards();
     op.StackConnectChangedUpwards();
 }
Exemplo n.º 29
0
 public virtual void ConnectWithOperatorAsReceiver(Operator op)
 {
     senders.Add(op);
     CascadeStackConnectChangedDownwards();
 }
Exemplo n.º 30
0
        private void PopulateOperatorDefines(Operator root)
        {
            String name = root.BindedOperator.Name + root.BindedOperator.Type.ToString();
            name = name.ToUpper().Replace(" ", "");
            operatorDefines.Add("#define DB_" + name + "FILTER 1");

            foreach (Operator op in root.GetInputs())
                PopulateOperatorDefines(op);
        }