[longomatch] Use the new CameraConfig API for drawings too



commit 2479b2d0b823542b01a5df7950e54690864064da
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Apr 22 21:26:23 2015 +0200

    Use the new CameraConfig API for drawings too

 LongoMatch.Core/Common/EventsBroker.cs        |    4 ++--
 LongoMatch.Core/Handlers/Multimedia.cs        |    2 +-
 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs |    2 +-
 LongoMatch.Core/Store/FrameDrawing.cs         |    9 +++++++--
 LongoMatch.GUI.Multimedia/Gui/PlayerView.cs   |    6 +++---
 LongoMatch.GUI/Gui/Dialog/DrawingTool.cs      |    5 ++++-
 LongoMatch.GUI/Gui/GUIToolkit.cs              |    5 +++--
 LongoMatch.GUI/Gui/Menu/PlaysMenu.cs          |    2 +-
 LongoMatch.Services/EventsManager.cs          |   12 +++++++-----
 LongoMatch.Services/PlayerController.cs       |    3 ++-
 LongoMatch.Services/PlaylistManager.cs        |    2 +-
 LongoMatch.Services/RenderingJobsManager.cs   |    2 +-
 Tests/Core/Store/TestFrameDrawing.cs          |    4 ++--
 Tests/Services/TestPlayerController.cs        |    4 ++--
 14 files changed, 37 insertions(+), 25 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index 14912ba..279fbfc 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -382,10 +382,10 @@ namespace LongoMatch.Core.Common
                        }
                }
 
-               public void EmitDrawFrame (TimelineEvent play, int drawingIndex, int cameraIndex, bool 
current)
+               public void EmitDrawFrame (TimelineEvent play, int drawingIndex, CameraConfig camConfig, bool 
current)
                {
                        if (DrawFrame != null) {
-                               DrawFrame (play, drawingIndex, cameraIndex, current);
+                               DrawFrame (play, drawingIndex, camConfig, current);
                        }
                }
 
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 41d6222..ac31d28 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -33,7 +33,7 @@ namespace LongoMatch.Core.Handlers
        public delegate void PrevButtonClickedHandler ();
        public delegate void ProgressHandler (float progress);
        public delegate void FramesProgressHandler (int actual,int total,Image frame);
-       public delegate void DrawFrameHandler (TimelineEvent play,int drawingIndex,int cameraIndex,bool 
current);
+       public delegate void DrawFrameHandler (TimelineEvent play,int drawingIndex,CameraConfig 
camConfig,bool current);
        public delegate void EllpasedTimeHandler (Time ellapsedTime);
        public delegate void PlaybackRateChangedHandler (float rate);
        public delegate void SeekHandler (SeekType type,Time start,float rate);
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index db4fccd..3350531 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -109,7 +109,7 @@ namespace LongoMatch.Core.Interfaces.GUI
 
                void EditPlay (TimelineEvent play, Project project, bool editTags, bool editPositions, bool 
editPlayers, bool editNotes);
 
-               void DrawingTool (Image pixbuf, TimelineEvent play, FrameDrawing drawing, Project project);
+               void DrawingTool (Image pixbuf, TimelineEvent play, FrameDrawing drawing, CameraConfig 
config, Project project);
 
                string RemuxFile (string filePath, string outputFile, VideoMuxerType muxer);
 
diff --git a/LongoMatch.Core/Store/FrameDrawing.cs b/LongoMatch.Core/Store/FrameDrawing.cs
index 19202a2..a131bd7 100644
--- a/LongoMatch.Core/Store/FrameDrawing.cs
+++ b/LongoMatch.Core/Store/FrameDrawing.cs
@@ -53,8 +53,13 @@ namespace LongoMatch.Core.Store
                        set;
                }
 
+               public Area RegionOfInterest {
+                       get;
+                       set;
+               }
+
                /// <summary>
-               /// List of Drawable objects in the canvas
+               /// List of <see cref="Drawable"/> objects in the canvas
                /// </summary>
                public List<Drawable> Drawables {
                        get;
@@ -77,7 +82,7 @@ namespace LongoMatch.Core.Store
                        get;
                }
 
-               public int CameraIndex {
+               public CameraConfig CameraConfig {
                        get;
                        set;
                }
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
index bc2dbf2..3127768 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
@@ -170,9 +170,9 @@ namespace LongoMatch.Gui
                        }
                }
 
-               public List<int> CamerasVisible {
+               public List<CameraConfig> CamerasConfig {
                        get {
-                               return new List<int> { 0 };
+                               return new List<CameraConfig> { new CameraConfig (0) };
                        }
                        set {
                        }
@@ -521,7 +521,7 @@ namespace LongoMatch.Gui
 
                void HandleDrawButtonClicked (object sender, System.EventArgs e)
                {
-                       Config.EventsBroker.EmitDrawFrame (null, -1, CamerasVisible [0], true);
+                       Config.EventsBroker.EmitDrawFrame (null, -1, CamerasConfig [0], true);
                }
 
                void HandleJumpValueChanged (object sender, EventArgs e)
diff --git a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
index 8fb53cb..0095c91 100644
--- a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
@@ -37,6 +37,7 @@ namespace LongoMatch.Gui.Dialog
                readonly Blackboard blackboard;
                TimelineEvent play;
                FrameDrawing drawing;
+               CameraConfig camConfig;
                Drawable selectedDrawable;
                Gtk.Dialog playerDialog;
                Text playerText;
@@ -146,11 +147,13 @@ namespace LongoMatch.Gui.Dialog
                        base.Destroy ();
                }
 
-               public void LoadPlay (TimelineEvent play, Image frame, FrameDrawing drawing, Project project)
+               public void LoadPlay (TimelineEvent play, Image frame, FrameDrawing drawing,
+                                     CameraConfig camConfig, Project project)
                {
                        this.play = play;
                        this.drawing = drawing;
                        this.project = project;
+                       this.camConfig = camConfig;
                        scaleFactor = (double)frame.Width / 500;
                        blackboard.Background = frame;
                        savetoprojectbutton.Visible = true;
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 393482a..a319704 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -284,7 +284,8 @@ namespace LongoMatch.Gui
                        }
                }
 
-               public void DrawingTool (Image image, TimelineEvent play, FrameDrawing drawing, Project 
project)
+               public void DrawingTool (Image image, TimelineEvent play, FrameDrawing drawing,
+                                        CameraConfig camConfig, Project project)
                {
                        DrawingTool dialog = new DrawingTool ();
                        dialog.Show ();
@@ -293,7 +294,7 @@ namespace LongoMatch.Gui
                        if (play == null) {
                                dialog.LoadFrame (image, project);
                        } else {
-                               dialog.LoadPlay (play, image, drawing, project);
+                               dialog.LoadPlay (play, image, drawing, camConfig, project);
                        }
                        dialog.TransientFor = mainWindow as Gtk.Window;
                        dialog.Run ();
diff --git a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
index e269ddd..4565607 100644
--- a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
+++ b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
@@ -140,7 +140,7 @@ namespace LongoMatch.Gui.Menus
                                        drawingMenu.Append (deleteItem);
                                        editItem.Activated += (sender, e) => {
                                                Config.EventsBroker.EmitDrawFrame (plays [0], index,
-                                                       plays [0].Drawings [index].CameraIndex, false);
+                                                       plays [0].Drawings [index].CameraConfig, false);
                                        }; 
                                        deleteItem.Activated += (sender, e) => {
                                                plays [0].Drawings.RemoveAt (index);
diff --git a/LongoMatch.Services/EventsManager.cs b/LongoMatch.Services/EventsManager.cs
index be3acbe..d06944e 100644
--- a/LongoMatch.Services/EventsManager.cs
+++ b/LongoMatch.Services/EventsManager.cs
@@ -147,7 +147,7 @@ namespace LongoMatch.Services
                        guiToolkit.ShowProjectStats (project);
                }
 
-               void HandleDrawFrame (TimelineEvent play, int drawingIndex, int cameraIndex, bool current)
+               void HandleDrawFrame (TimelineEvent play, int drawingIndex, CameraConfig camConfig, bool 
current)
                {
                        Image pixbuf;
                        FrameDrawing drawing = null;
@@ -159,9 +159,11 @@ namespace LongoMatch.Services
                        }
                        if (play != null) {
                                if (drawingIndex == -1) {
-                                       drawing = new FrameDrawing ();
-                                       drawing.Render = player.CurrentTime;
-                                       drawing.CameraIndex = cameraIndex;
+                                       drawing = new FrameDrawing {
+                                               Render = player.CurrentTime,
+                                               CameraConfig = camConfig,
+                                               RegionOfInterest = camConfig.RegionOfInterest,
+                                       };
                                } else {
                                        drawing = play.Drawings [drawingIndex];
                                }
@@ -180,7 +182,7 @@ namespace LongoMatch.Services
                        if (pixbuf == null) {
                                guiToolkit.ErrorMessage (Catalog.GetString ("Error capturing video frame"));
                        } else {
-                               guiToolkit.DrawingTool (pixbuf, play, drawing, openedProject);
+                               guiToolkit.DrawingTool (pixbuf, play, drawing, camConfig, openedProject);
                        }
                }
 
diff --git a/LongoMatch.Services/PlayerController.cs b/LongoMatch.Services/PlayerController.cs
index c84ab7a..9ae0d04 100644
--- a/LongoMatch.Services/PlayerController.cs
+++ b/LongoMatch.Services/PlayerController.cs
@@ -933,7 +933,8 @@ namespace LongoMatch.Services
                                                if (drawings != null) {
                                                        /* Check if the event has drawings to display */
                                                        FrameDrawing fd = drawings.FirstOrDefault (f => 
f.Render > videoTS &&
-                                                                         f.Render <= currentTime && 
f.CameraIndex == CamerasConfig [0].Index);
+                                                                         f.Render <= currentTime &&
+                                                                         f.CameraConfig.Index == 
CamerasConfig [0].Index);
                                                        if (fd != null) {
                                                                LoadPlayDrawing (fd);
                                                        }
diff --git a/LongoMatch.Services/PlaylistManager.cs b/LongoMatch.Services/PlaylistManager.cs
index 5e84d21..1ae6a78 100644
--- a/LongoMatch.Services/PlaylistManager.cs
+++ b/LongoMatch.Services/PlaylistManager.cs
@@ -262,7 +262,7 @@ namespace LongoMatch.Services
                                                evt = (loadedElement as PlaylistPlayElement).Play;
                                        }
                                        if (evt != null) {
-                                               Config.EventsBroker.EmitDrawFrame (evt, -1, 
player.CamerasConfig [0].Index, true);
+                                               Config.EventsBroker.EmitDrawFrame (evt, -1, 
player.CamerasConfig [0], true);
                                        }
                                        return;
                                case KeyAction.TogglePlay:
diff --git a/LongoMatch.Services/RenderingJobsManager.cs b/LongoMatch.Services/RenderingJobsManager.cs
index 2015c29..c79893c 100644
--- a/LongoMatch.Services/RenderingJobsManager.cs
+++ b/LongoMatch.Services/RenderingJobsManager.cs
@@ -256,7 +256,7 @@ namespace LongoMatch.Services
                        } else {
                                file = element.FileSet [cameraIndex];
                        }
-                       drawings = play.Drawings.Where (d => d.CameraIndex == cameraIndex);
+                       drawings = play.Drawings.Where (d => d.CameraConfig.Index == cameraIndex);
 
                        if (file == null || drawings == null) {
                                return false;
diff --git a/Tests/Core/Store/TestFrameDrawing.cs b/Tests/Core/Store/TestFrameDrawing.cs
index f1cb9af..a13622a 100644
--- a/Tests/Core/Store/TestFrameDrawing.cs
+++ b/Tests/Core/Store/TestFrameDrawing.cs
@@ -34,7 +34,7 @@ namespace Tests.Core.Store
                        d.Miniature = Utils.LoadImageFromFile ();
                        d.Freehand = Utils.LoadImageFromFile ();
                        d.Drawables = new List<Drawable> { new Line (), new Rectangle () };
-                       d.CameraIndex = 2;
+                       d.CameraConfig = new CameraConfig (2);
                        d.Render = new Time (1000);
                        d.Pause = new Time (2000);
                        Utils.CheckSerialization (d);
@@ -42,7 +42,7 @@ namespace Tests.Core.Store
                        FrameDrawing d2 = Utils.SerializeDeserialize (d);
                        Assert.AreEqual (d.Render, d2.Render);
                        Assert.AreEqual (d.Pause, d2.Pause);
-                       Assert.AreEqual (d.CameraIndex, d2.CameraIndex);
+                       Assert.AreEqual (d.CameraConfig, d2.CameraConfig);
                        Assert.AreEqual (d2.Drawables.Count, d.Drawables.Count);
                        Assert.IsNotNull (d2.Freehand);
                        Assert.IsNotNull (d2.Miniature);
diff --git a/Tests/Services/TestPlayerController.cs b/Tests/Services/TestPlayerController.cs
index 6a11685..59dc90a 100644
--- a/Tests/Services/TestPlayerController.cs
+++ b/Tests/Services/TestPlayerController.cs
@@ -777,7 +777,7 @@ namespace Tests.Services
                        };
 
                        dr = new FrameDrawing { Render = evt.Start + 50,
-                               CameraIndex = 0
+                               CameraConfig = new CameraConfig (0),
                        };
                        currentTime = evt.Start;
                        PreparePlayer ();
@@ -794,7 +794,7 @@ namespace Tests.Services
                        Assert.IsNull (drSent); 
 
                        /* Check only drawings for the first camera are loaded */
-                       dr.CameraIndex = 1;
+                       dr.CameraConfig = new CameraConfig (1);
                        currentTime = evt.Start;
                        player.LoadEvent (mfs, evt, evt.Start, true);
                        Assert.IsTrue (player.Playing);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]