private void toolStripButtonNewMap_Click(object sender, EventArgs e) { if (m_map != null) { m_map.Dispose(); } //todo Use a form to create the new map CVZ_MMCM newMap = new CVZ_MMCM("newMap", 10, 10, 3, false); newMap.AddModality(new RandomModality("newMap", "defaultRandomModality", 10), 1.0f); Initialise(newMap); }
public override bool updateModule() { bool error = base.updateModule(); //Broadcast the activity CVZ_MMCM mmcm = cvz as CVZ_MMCM; for (int i = 0; i < mmcm.Layers; i++) { ImageRgb img = layersActivity[i].prepare(); img = mmcm.GetVisualization(i).toImgRgb(); layersActivity[i].write(); } return(error); }
public override bool configure(ResourceFinder rf) { if (base.configure(rf)) { //Open ports for visualizing the activity CVZ_MMCM mmcm = cvz as CVZ_MMCM; for (int i = 0; i < mmcm.Layers; i++) { BufferedPortImageRgb p = new BufferedPortImageRgb(); p.open("/" + mmcm.name + "/activity/layer_" + i + ":o"); layersActivity.Add(p); } return(true); } else { return(false); } }
private void toolStripButtonLoadMap_Click(object sender, EventArgs e) { openFileDialog1.Filter = "MMCM Parameters Files (*.ini)|*.ini | MMCM Weights Files (*.mmcm)|*.mmcm"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Dispose the previous map if (m_map != null) { m_map.Dispose(); } string filePath = openFileDialog1.FileName; CVZ_MMCM m = null; Stream stream = File.Open(filePath, FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); m = (CVZ_MMCM)bformatter.Deserialize(stream); stream.Close(); Initialise(m); } }
public void Initialise(CVZ_MMCM linkedMMCM) { if (m_mapThread == null) { m_mapThread = new System.Threading.Thread(StimulateMap); //m_mapThread.Start(); } if (m_mapThread.ThreadState == System.Threading.ThreadState.Running) { buttonStop_Click(null, null); while (m_mapThread.ThreadState != System.Threading.ThreadState.Suspended) { System.Threading.Thread.Sleep(10); } } //if (m_map != null) // m_map.Dispose(); m_map = linkedMMCM; m_enactionFactor = new Dictionary <string, float>(m_map.modalities.Count + 1); flowLayoutPanelModalities.Controls.Clear(); chartPredictionError.Series.Clear(); chartElectrodes.Series.Clear(); foreach (IModality m in m_map.modalities.Values) { m_enactionFactor.Add(m.name, 0.0f); //Create the modalities tab if (displayModalities) { //flowLayoutPanelModalities.Controls.Add(m.GetControl(!(m is YarpModalityString))); UserControl ctrl; if (!(m is YarpModalityString)) { ctrl = new ImageModalityCtrl(); (ctrl as ImageModalityCtrl).LinkToModality(m); } else { ctrl = new IModalityControl(); (ctrl as IModalityControl).LinkToModality(m); } flowLayoutPanelModalities.Controls.Add(ctrl); } //Create the chart tab chartPredictionError.Series.Add(m.name); chartPredictionError.Series[m.name].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chartCheckListModalities.Items.Add(m.name, true); } //Display info about the map (change to some panel related organization) GetParameters(null, null); //Handle graphical display of maps panel1.Controls.Clear(); m_layers = new List <PictureBox>(m_map.Layers); for (int i = 0; i < m_map.Layers; i++) { PictureBox p = new PictureBox(); p.Height = 200; p.Width = 200; p.SizeMode = PictureBoxSizeMode.StretchImage; m_layers.Add(p); //Hook to the double click event (for stimulation purposes) p.DoubleClick += new EventHandler(p_DoubleClick); p.Click += new EventHandler(p_Click); panel1.Controls.Add(p); } checkBoxLogError_CheckedChanged(null, null); }
public MMCM_ControlPanel(CVZ_MMCM linkedMMCM) { InitializeComponent(); Initialise(linkedMMCM); onStimulationDone += RefreshGUI; }