Beispiel #1
0
        /// <summary>
        /// 値の書き換え
        /// </summary>
        /// <param name="target"></param>
        /// <param name="incomingData"></param>
        /// <returns></returns>
        public override object CreateReplacementObject(object target, Stream incomingData)
        {
            // プロキシデータの復元
            BinaryFormatter bf    = new BinaryFormatter();
            CvMatProxy      proxy = bf.Deserialize(incomingData) as CvMatProxy;

            if (proxy == null)
            {
                throw new Exception("Failed to cast");
            }
            // 元データのCvMat
            CvMat mat = target as CvMat;

            if (proxy == null || mat == null)
            {
                throw new Exception("Failed to cast");
            }

            // 手作業で値を移し変え
            int rows = mat.Rows;
            int cols = mat.Cols;

            CvScalar[,] data = proxy.Data;
            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    Cv.Set2D(mat, r, c, data[r, c]);
                }
            }

            return(mat);
            //return base.CreateReplacementObject(target, incomingData);
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="proxy"></param>
 public CvMatViewer(CvMatProxy proxy)
     : this()
 {
     _proxy = proxy;
     _data  = new CvScalar[proxy.Rows, proxy.Cols];
     for (int r = 0; r < proxy.Rows; r++)
     {
         for (int c = 0; c < proxy.Cols; c++)
         {
             _data[r, c] = proxy.Data[r, c];
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// チャンネル数設定のComboBoxの初期化
        /// </summary>
        /// <param name="_proxy"></param>
        private void InitializeComboBox(CvMatProxy proxy)
        {
            ToolStripComboBox cb = toolStripComboBox_NChannels;

            cb.Items.Clear();
            cb.Items.Add("All channels");
            for (int i = 1; i <= proxy.ElemChannels; i++)
            {
                cb.Items.Add(string.Format("Channel {0}", i));
            }

            cb.SelectedIndex = 0;
        }
Beispiel #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="proxy"></param>
 public CvMatViewer(CvMatProxy proxy)
     : this()
 {
     _proxy = proxy;
     _data = new CvScalar[proxy.Rows, proxy.Cols];
     for (int r = 0; r < proxy.Rows; r++)
     {
         for (int c = 0; c < proxy.Cols; c++)
         {
             _data[r, c] = proxy.Data[r, c];
         }
     }
 }
Beispiel #5
0
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            // 送られてくるはずのCvMatProxyを受け取る
            using (CvMatProxy proxy = objectProvider.GetObject() as CvMatProxy)
            {
                if (proxy == null)
                {
                    throw new ArgumentException();
                }
                using (CvMatViewer form = new CvMatViewer(proxy))
                {
                    // 行列データ表示用フォームを開く
                    windowService.ShowDialog(form);

                    // 値の変更を元データのCvMatに反映
                    if (objectProvider.IsObjectReplaceable)
                    {
                        objectProvider.ReplaceObject(form.ModifiedProxy);
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// DataGridViewを初期化
        /// </summary>
        /// <param name="proxy"></param>
        private void InitializeDataGridView(CvMatProxy proxy)
        {
            // 行数、列数の指定
            dataGridView.RowCount    = proxy.Rows;
            dataGridView.ColumnCount = proxy.Cols;

            // ヘッダセルの設定
            for (int i = 0; i < dataGridView.ColumnCount; i++)
            {
                DataGridViewColumn c = dataGridView.Columns[i];
                c.HeaderText = string.Format("Col {0}", i);
                c.SortMode   = DataGridViewColumnSortMode.NotSortable;  // 並び替え禁止
            }
            for (int i = 0; i < dataGridView.RowCount; i++)
            {
                DataGridViewRow r = dataGridView.Rows[i];
                r.HeaderCell.Value = string.Format("Row {0}", i);
            }
            dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            // 値の設定
            FillCellValue(0);
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 public CvMatViewer()
 {
     InitializeComponent();
     _proxy = null;
     _data  = null;
 }
Beispiel #8
0
 /// <summary>
 /// 
 /// </summary>
 public CvMatViewer()
 {
     InitializeComponent();
     _proxy = null;
     _data = null;
 }
Beispiel #9
0
        /// <summary>
        /// チャンネル数設定のComboBoxの初期化
        /// </summary>
        /// <param name="_proxy"></param>
        private void InitializeComboBox(CvMatProxy proxy)
        {
            ToolStripComboBox cb = toolStripComboBox_NChannels;
            cb.Items.Clear();
            cb.Items.Add("All channels");
            for (int i = 1; i <= proxy.ElemChannels; i++)
            {
                cb.Items.Add(string.Format("Channel {0}", i));
            }            

            cb.SelectedIndex = 0;
        }
Beispiel #10
0
        /// <summary>
        /// DataGridViewを初期化
        /// </summary>
        /// <param name="proxy"></param>
        private void InitializeDataGridView(CvMatProxy proxy)
        {
            // 行数、列数の指定
            dataGridView.RowCount = proxy.Rows;
            dataGridView.ColumnCount = proxy.Cols;

            // ヘッダセルの設定
            for (int i = 0; i < dataGridView.ColumnCount; i++)
            {
                DataGridViewColumn c = dataGridView.Columns[i];
                c.HeaderText = string.Format("Col {0}", i);
                c.SortMode = DataGridViewColumnSortMode.NotSortable;    // 並び替え禁止
            }
            for (int i = 0; i < dataGridView.RowCount; i++)
            {
                DataGridViewRow r = dataGridView.Rows[i];
                r.HeaderCell.Value = string.Format("Row {0}", i);
            }
            dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            // 値の設定
            FillCellValue(0);
        }