Modif seq lin

This commit is contained in:
tzim 2013-04-18 11:53:41 +00:00
parent b44dbd914d
commit 58337e6c23
7 changed files with 158 additions and 48 deletions

View file

@ -1,13 +1,12 @@
<Properties> <Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
<MonoDevelop.Ide.Workbench ActiveDocument="DMX-2.0/MainWindow.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="DMX-2.0/SeqLinUI.cs">
<Files> <Files>
<File FileName="DMX-2.0/SeqLinUI.cs" Line="93" Column="16" /> <File FileName="DMX-2.0/SequenceurLineaire.cs" Line="152" Column="36" />
<File FileName="DMX-2.0/SequenceurLineaire.cs" Line="73" Column="50" /> <File FileName="DMX-2.0/Conduite.cs" Line="129" Column="4" />
<File FileName="DMX-2.0/Conduite.cs" Line="128" Column="4" /> <File FileName="DMX-2.0/SeqLinUI.cs" Line="92" Column="3" />
<File FileName="DMX-2.0/Sequenceur.cs" Line="42" Column="4" /> <File FileName="DMX-2.0/GestionCircuits.cs" Line="66" Column="49" />
<File FileName="DMX-2.0/SequenceurUI.cs" Line="20" Column="42" /> <File FileName="DMX-2.0/MainWindow.cs" Line="137" Column="1" />
<File FileName="DMX-2.0/MainWindow.cs" Line="130" Column="5" />
</Files> </Files>
</MonoDevelop.Ide.Workbench> </MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.Breakpoints>

View file

@ -106,28 +106,29 @@ namespace DMX2
void Tick () void Tick ()
{ {
DateTime tickTime = DateTime.Now; DateTime tickTime = DateTime.Now;
TimeSpan ts = tickTime-lastTick; TimeSpan ts = tickTime - lastTick;
lastTick = tickTime; lastTick = tickTime;
lock (this) {
// 'Actionne' les sequenceurs // 'Actionne' les sequenceurs
foreach (var seq in sequenceurs) { foreach (var seq in sequenceurs) {
seq.Tick(ts); seq.Tick (ts);
} }
// Mets a jour les valeurs circuits. // Mets a jour les valeurs circuits.
foreach (var c in circuits) { foreach (var c in circuits) {
int val=0; int val = 0;
foreach (var seq in Sequenceurs) { foreach (var seq in Sequenceurs) {
val = Math.Max(val, seq.ValeurCircuit(c)); val = Math.Max (val, seq.ValeurCircuit (c));
}
c.ValeurCourante = val;
} }
c.ValeurCourante=val;
} }
// Cette fonction retourne quasi immédiatement, même si il y'a beaucoup a faire sur l'affichage // Cette fonction retourne quasi immédiatement, même si il y'a beaucoup a faire sur l'affichage
MainWindow.Win.ScheduleUpdate(); MainWindow.Win.ScheduleUpdate();
/*if( DateTime.Now - tickTime > TimeSpan.FromMilliseconds(1) ) /*if( ts > TimeSpan.FromMilliseconds(12) )
Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,ts);*/ Console.WriteLine ("{0} {1}", DateTime.Now - tickTime,ts);*/
} }

View file

@ -16,7 +16,7 @@ namespace DMX2
var nameCell = new Gtk.CellRendererText(); var nameCell = new Gtk.CellRendererText();
nameCol.Title = "Circuit"; nameCol.Title = "Circuit";
nameCol.PackStart(nameCell,true); nameCol.PackStart(nameCell,true);
nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) );
nameCell.Editable =true; nameCell.Editable =true;
nameCell.Edited += OnNameCellEdited; nameCell.Edited += OnNameCellEdited;
this.listeCircuits.AppendColumn(nameCol); this.listeCircuits.AppendColumn(nameCol);
@ -25,7 +25,7 @@ namespace DMX2
var snameCell = new Gtk.CellRendererText(); var snameCell = new Gtk.CellRendererText();
snameCol.Title = "Nom Court"; snameCol.Title = "Nom Court";
snameCol.PackStart(snameCell,true); snameCol.PackStart(snameCell,true);
snameCol.SetCellDataFunc(snameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitShortName) )); snameCol.SetCellDataFunc(snameCell, new Gtk.TreeCellDataFunc(RenderCircuitShortName) );
snameCell.Editable =true; snameCell.Editable =true;
snameCell.Edited += OnShortNameCellEdited; snameCell.Edited += OnShortNameCellEdited;
this.listeCircuits.AppendColumn(snameCol); this.listeCircuits.AppendColumn(snameCol);

View file

@ -26,7 +26,7 @@ namespace DMX2
var allNameCell = new Gtk.CellRendererText(); var allNameCell = new Gtk.CellRendererText();
allnameCol.Title = "Circuits"; allnameCol.Title = "Circuits";
allnameCol.PackStart(allNameCell,true); allnameCol.PackStart(allNameCell,true);
allnameCol.SetCellDataFunc(allNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); allnameCol.SetCellDataFunc(allNameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) );
this.listeToutCircuits.AppendColumn(allnameCol); this.listeToutCircuits.AppendColumn(allnameCol);
lsAll = new Gtk.ListStore(typeof (Circuit)); lsAll = new Gtk.ListStore(typeof (Circuit));
@ -39,7 +39,7 @@ namespace DMX2
var selNameCell = new Gtk.CellRendererText(); var selNameCell = new Gtk.CellRendererText();
selNameCol.Title = "Circuits du Sequenceur"; selNameCol.Title = "Circuits du Sequenceur";
selNameCol.PackStart(selNameCell,true); selNameCol.PackStart(selNameCell,true);
selNameCol.SetCellDataFunc(selNameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); selNameCol.SetCellDataFunc(selNameCell, new Gtk.TreeCellDataFunc( RenderCircuitName) );
this.listeSelCircuits.AppendColumn(selNameCol); this.listeSelCircuits.AppendColumn(selNameCol);
lsSel = new Gtk.ListStore(typeof (Circuit)); lsSel = new Gtk.ListStore(typeof (Circuit));

View file

@ -10,6 +10,7 @@ namespace DMX2
bool fullUpdFlag = true; bool fullUpdFlag = true;
SequenceurLineaire sequenceur; SequenceurLineaire sequenceur;
ListStore lsEffets=null;
public SeqLinUI (SequenceurLineaire s ) : base (s) public SeqLinUI (SequenceurLineaire s ) : base (s)
{ {
@ -17,13 +18,84 @@ namespace DMX2
titreLabel.Text = s.Name; titreLabel.Text = s.Name;
sequenceur = s; sequenceur = s;
Update(true); Update(true);
#region Construction listeEffets
// Construction de la liste d'effets
var numCol = new TreeViewColumn();
var nomCol = new TreeViewColumn();
var dureeCol = new TreeViewColumn();
var transCol = new TreeViewColumn();
var numCell = new CellRendererText();
var nomCell = new CellRendererText();
var dureeCell = new CellRendererText();
var transCell = new CellRendererText();
numCol.Title = "N°";
nomCol.Title = "Effet";
dureeCol.Title = "Duree";
transCol.Title = "Transition";
numCol.PackEnd(numCell,true);
nomCol.PackStart(nomCell,true);
dureeCol.PackEnd(dureeCell,true);
transCol.PackEnd(transCell,true);
numCol.SetCellDataFunc(numCell, new TreeCellDataFunc(RenderNum));
nomCol.SetCellDataFunc(nomCell, new TreeCellDataFunc(RenderNom));
dureeCol.SetCellDataFunc(dureeCell, new TreeCellDataFunc(RenderDuree));
transCol.SetCellDataFunc(transCell, new TreeCellDataFunc(RenderTrans));
effetsListe.AppendColumn(numCol);
effetsListe.AppendColumn(nomCol);
effetsListe.AppendColumn(dureeCol);
effetsListe.AppendColumn(transCol);
lsEffets = new ListStore(typeof(SequenceurLineaire.Effet));
effetsListe.Model = lsEffets;
#endregion
} }
#region Affichage Liste d'Effets
void RenderNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet;
(cell as Gtk.CellRendererText).Text = "";
}
void RenderNom (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet;
(cell as Gtk.CellRendererText).Text = e.Nom;
}
void RenderDuree (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet;
(cell as Gtk.CellRendererText).Text = (e.Duree.TotalMilliseconds/100).ToString();
}
void RenderTrans (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
SequenceurLineaire.Effet e = tree_model.GetValue (iter, 0) as SequenceurLineaire.Effet;
(cell as Gtk.CellRendererText).Text = (e.Transition.TotalMilliseconds/100).ToString();
}
void UpdListeEffets ()
{
lsEffets.Clear();
foreach (var effet in sequenceur.Effets) {
lsEffets.AppendValues(effet);
}
}
#endregion
public override void Update (bool full) public override void Update (bool full)
{ {
if(fullUpdFlag || full) FullUpdate(); if(fullUpdFlag || full) FullUpdate();
UpdateValues(); UpdateValues();
timeLabel.LabelProp = sequenceur.TimeStamp.ToString(); timeLabel.LabelProp = string.Format(@"<big>{0:0\.0}</big>", sequenceur.TimeStamp.TotalMilliseconds/100);
} }
protected void OnCircuitsActionActivated (object sender, EventArgs e) protected void OnCircuitsActionActivated (object sender, EventArgs e)
@ -120,8 +192,10 @@ namespace DMX2
fullUpdFlag=false; fullUpdFlag=false;
} }
bool updating=false;
void TiretteActionee (object sender, EventArgs e) void TiretteActionee (object sender, EventArgs e)
{ {
if (updating)return;
VScale t = sender as VScale; VScale t = sender as VScale;
Circuit c = t.Data[circuitKey] as Circuit; Circuit c = t.Data[circuitKey] as Circuit;
sequenceur.ChangeValeur(c,(int)(t.Value)); sequenceur.ChangeValeur(c,(int)(t.Value));
@ -129,9 +203,11 @@ namespace DMX2
protected void UpdateValues() protected void UpdateValues()
{ {
updating = true;
foreach (Circuit c in tirettes.Keys) { foreach (Circuit c in tirettes.Keys) {
tirettes[c].Value = sequenceur.ValeurCircuit(c); tirettes[c].Value = sequenceur.ValeurCircuit(c);
} }
updating=false;
} }
protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args) protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args)
@ -143,6 +219,20 @@ namespace DMX2
} }
protected void OnSaveActionActivated (object sender, EventArgs e)
{
int d,t;
if(!int.TryParse(dureeEntry.Text,out d) || !int.TryParse(transEntry.Text,out t)) return;
sequenceur.SauveEffet("Nom", TimeSpan.FromMilliseconds(100*d),TimeSpan.FromMilliseconds(t*100));
UpdListeEffets();
}
protected void OnGoForwardActionActivated (object sender, EventArgs e)
{
sequenceur.IndexEffetCourrant++;
}
} }
} }

View file

@ -98,6 +98,7 @@ namespace DMX2
public void ChangeCircuits (System.Collections.Generic.List<Circuit> list) public void ChangeCircuits (System.Collections.Generic.List<Circuit> list)
{ {
lock (this) {
foreach (var c in circuitsSeq.ToArray()) { foreach (var c in circuitsSeq.ToArray()) {
if (!list.Contains (c)) if (!list.Contains (c))
RetireCircuit (c); RetireCircuit (c);
@ -107,6 +108,7 @@ namespace DMX2
AjouteCircuit (c); AjouteCircuit (c);
circuitsSeq = list; circuitsSeq = list;
} }
}
void AjouteCircuit (Circuit c) void AjouteCircuit (Circuit c)
{ {
@ -126,11 +128,13 @@ namespace DMX2
public override void MajCircuitsSupprimes () public override void MajCircuitsSupprimes ()
{ {
lock (this) {
foreach (var c in circuitsSeq.ToArray()) { foreach (var c in circuitsSeq.ToArray()) {
if (!Conduite.Courante.Circuits.Contains (c)) if (!Conduite.Courante.Circuits.Contains (c))
RetireCircuit (c); RetireCircuit (c);
} }
} }
}
public override int ValeurCircuit (Circuit c) public override int ValeurCircuit (Circuit c)
{ {
@ -153,11 +157,13 @@ namespace DMX2
public override void Tick (TimeSpan time) public override void Tick (TimeSpan time)
{ {
timeStamp += time; timeStamp += time;
if (enTransition) { if (enTransition) {
if (timeStamp < effetcourrant.Transition) { if (timeStamp < effetcourrant.Transition) {
double progression = timeStamp.TotalMilliseconds / effetcourrant.Transition.TotalMilliseconds;
foreach (Circuit c in circuitsSeq) { foreach (Circuit c in circuitsSeq) {
if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) { if (valeurscourantes [c] != effetcourrant [c] && !valeurschangees.ContainsKey (c)) {
valeurscourantes [c] = (effetcourrant [c] - valeursinitiales [c]) * effetcourrant.Duree.Milliseconds / time.Milliseconds + valeursinitiales [c]; valeurscourantes [c] = (int)(progression * (effetcourrant [c] - valeursinitiales [c]) + valeursinitiales [c]);
} }
} }
} else { } else {
@ -167,7 +173,7 @@ namespace DMX2
if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) { if (effetcourrant.Duree != TimeSpan.Zero && timeStamp >= effetcourrant.Duree) {
int index = effets.IndexOf (effetcourrant) + 1; int index = effets.IndexOf (effetcourrant) + 1;
if (index < effets.Count) if (index < effets.Count)
ChangeEffet (index); ChangeEffetCourrant (index);
} }
} }
@ -178,7 +184,17 @@ namespace DMX2
valeurscourantes [c] = effetcourrant [c]; valeurscourantes [c] = effetcourrant [c];
} }
public void ChangeEffet (int index) public int IndexEffetCourrant {
get {
return effets.IndexOf(effetcourrant);
}
set {
if(value>=0 && value < effets.Count)
ChangeEffetCourrant(value);
}
}
void ChangeEffetCourrant (int index)
{ {
effetcourrant = effets [index]; effetcourrant = effets [index];
valeurschangees.Clear (); valeurschangees.Clear ();
@ -189,8 +205,12 @@ namespace DMX2
public void SauveEffet (string nom, TimeSpan duree, TimeSpan transition) public void SauveEffet (string nom, TimeSpan duree, TimeSpan transition)
{ {
lock (this) {
effets.Add (new Effet (nom, valeurscourantes, duree, transition)); effets.Add (new Effet (nom, valeurscourantes, duree, transition));
} }
}
public override System.Xml.XmlElement Save () public override System.Xml.XmlElement Save ()
{ {
@ -213,7 +233,5 @@ namespace DMX2
{ {
ui = null; ui = null;
} }
} }
} }

View file

@ -447,7 +447,7 @@
</widget> </widget>
</child> </child>
</widget> </widget>
<widget class="Gtk.Bin" id="DMX2.SeqLinUI" design-size="618 410"> <widget class="Gtk.Bin" id="DMX2.SeqLinUI" design-size="766 410">
<action-group name="Default"> <action-group name="Default">
<action id="goBackAction"> <action id="goBackAction">
<property name="Type">Action</property> <property name="Type">Action</property>
@ -458,6 +458,7 @@
<property name="Type">Action</property> <property name="Type">Action</property>
<property name="Label" translatable="yes" /> <property name="Label" translatable="yes" />
<property name="StockId">gtk-go-forward</property> <property name="StockId">gtk-go-forward</property>
<signal name="Activated" handler="OnGoForwardActionActivated" />
</action> </action>
<action id="revertToSavedAction"> <action id="revertToSavedAction">
<property name="Type">Action</property> <property name="Type">Action</property>
@ -478,6 +479,7 @@
<property name="Type">Action</property> <property name="Type">Action</property>
<property name="Label" translatable="yes" /> <property name="Label" translatable="yes" />
<property name="StockId">gtk-save</property> <property name="StockId">gtk-save</property>
<signal name="Activated" handler="OnSaveActionActivated" />
</action> </action>
<action id="saveAsAction"> <action id="saveAsAction">
<property name="Type">Action</property> <property name="Type">Action</property>
@ -541,7 +543,7 @@
<property name="MemberName" /> <property name="MemberName" />
<property name="HasWindow">False</property> <property name="HasWindow">False</property>
<child> <child>
<widget class="Gtk.Entry" id="entry1"> <widget class="Gtk.Entry" id="dureeEntry">
<property name="MemberName" /> <property name="MemberName" />
<property name="WidthRequest">45</property> <property name="WidthRequest">45</property>
<property name="CanFocus">True</property> <property name="CanFocus">True</property>
@ -553,7 +555,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="Gtk.Entry" id="entry2"> <widget class="Gtk.Entry" id="transEntry">
<property name="MemberName" /> <property name="MemberName" />
<property name="WidthRequest">45</property> <property name="WidthRequest">45</property>
<property name="CanFocus">True</property> <property name="CanFocus">True</property>
@ -696,7 +698,7 @@
<property name="HscrollbarPolicy">Never</property> <property name="HscrollbarPolicy">Never</property>
<property name="ShadowType">In</property> <property name="ShadowType">In</property>
<child> <child>
<widget class="Gtk.TreeView" id="treeview1"> <widget class="Gtk.TreeView" id="effetsListe">
<property name="MemberName" /> <property name="MemberName" />
<property name="CanFocus">True</property> <property name="CanFocus">True</property>
<property name="ShowScrollbars">True</property> <property name="ShowScrollbars">True</property>