Exemple #1
0
        private void checkVisible_CheckStateChanged(object sender, EventArgs e)
        {
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            // 多重呼び出しの禁止
            if (!_mutex.WaitOne(0))
            {
                return;
            }
            try {
                if (_infoContentChanging)
                {
                    return;
                }
                _infoContentChanging = true;
                try {
                    var infoList = dataSet.GetSelectedObjectInfoList();
                    checkVisible.ThreeState = false;
                    bool visible = checkVisible.Checked;
                    if (infoList.Count > 0)
                    {
                        foreach (var info in infoList)
                        {
                            info.IsVisible = visible;
                        }
                        dataSet.DoObjectInfoSetChanged();
                    }
                } finally { _infoContentChanging = false; }
            } finally { _mutex.ReleaseMutex(); }
        }
Exemple #2
0
        private void textGroup_Validated(object sender, EventArgs e)
        {
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            var    infoList = dataSet.GetSelectedObjectInfoList();
            string to       = PathEx.NormalizePath(textGroup.Text);

            if (to == _currentGroup)
            {
                return;
            }
            bool found = false;

            foreach (var info in infoList)
            {
                if (PathEx.IsSubPath(info.Name, _currentGroup))
                {
                    string subName = PathEx.GetRelativePath(info.Name, _currentGroup);
                    _dataSet.RenameObjectInfo(info, PathEx.CombineName(to, subName), this);
                    found = true;
                }
            }
            _currentGroup = to;
            if (found)
            {
                dataSet.DoObjectInfoSetChanged();
            }
        }
Exemple #3
0
 private void numericColorAlpha_ValueChanged(object sender, EventArgs e)
 {
     // 多重呼び出しの禁止
     if (!_mutex.WaitOne(0))
     {
         return;
     }
     try {
         if (_infoContentChanging)
         {
             return;
         }
         _infoContentChanging = true;
         try {
             // _dataSetの途中変更を防ぐ
             MotionDataSet dataSet = _dataSet;
             if (dataSet == null)
             {
                 return;
             }
             var infoList = dataSet.GetSelectedObjectInfoList();
             int alpha    = (int)(Math.Round(2.55 * (int)numericColorAlpha.Value));
             if (infoList.Count > 0)
             {
                 foreach (var info in infoList)
                 {
                     info.Color = Color.FromArgb(alpha, info.Color);
                 }
                 dataSet.DoObjectInfoSetChanged();
             }
         } finally { _infoContentChanging = false; }
     } finally { _mutex.ReleaseMutex(); }
 }
Exemple #4
0
 private void askColor()
 {
     // 多重呼び出しの禁止
     if (!_mutex.WaitOne(0))
     {
         return;
     }
     try {
         // _dataSetの途中変更を防ぐ
         MotionDataSet dataSet = _dataSet;
         if (dataSet == null)
         {
             return;
         }
         var infoList = dataSet.GetSelectedObjectInfoList();
         if (infoList.Count > 0)
         {
             dialogColor.Color = Color.FromArgb(255, infoList[0].Color);
             if (dialogColor.ShowDialog() == DialogResult.OK)
             {
                 foreach (var info in infoList)
                 {
                     info.Color = Color.FromArgb(info.Color.A, dialogColor.Color);
                 }
                 dataSet.DoObjectInfoSetChanged();
             }
         }
     } finally {
         _mutex.ReleaseMutex();
     }
 }
Exemple #5
0
        private void buttonDown_Click(object sender, EventArgs e)
        {
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            dataSet.ReorderObjectInfo(dataSet.GetSelectedObjectInfoList(), 1);
        }
Exemple #6
0
        private void showToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            foreach (var info in dataSet.GetSelectedObjectInfoList())
            {
                info.IsVisible = true;
            }
            dataSet.DoObjectInfoSetChanged();
        }
Exemple #7
0
 private void numericColorAlpha_MouseClick(object sender, MouseEventArgs e)
 {
     // 複数選択時に値が異なる場合には無効状態になるけどクリックしたら有効にする仕様
     if (!numericColorAlpha.Enabled)
     {
         MotionDataSet dataSet = _dataSet;
         if (dataSet == null)
         {
             return;
         }
         var infoList = dataSet.GetSelectedObjectInfoList();
         if (infoList.Count > 0)
         {
             numericColorAlpha.Enabled = true;
         }
     }
 }
Exemple #8
0
        private void replaceFirstToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            foreach (var info in dataSet.GetSelectedObjectInfoList())
            {
                int ub = info.Name.IndexOf('_');
                if (ub >= 0)
                {
                    dataSet.RenameObjectInfo(info, info.Name.Substring(0, ub) + "/" + info.Name.Substring(ub + 1), this);
                }
            }
        }
        /// <summary>
        /// 処理が実行可能かを判定して
        /// </summary>
        private void updateMenuEnabled()
        {
            IList <MotionObjectInfo> infoList = _dataSet.GetSelectedObjectInfoList();

            foreach (OperationMenuItem item in _menuAllItems)
            {
                string errorMessage = "";
                IList <MotionObjectInfo> subInfoList = infoList.Where(info => item.Operation.FilterSelection(info)).ToList();
                if (item.MenuItem.Enabled = item.Operation.ValidateSelection(subInfoList, ref errorMessage))
                {
                    item.MenuItem.ToolTipText = null;
                }
                else
                {
                    item.MenuItem.ToolTipText = errorMessage;
                }
            }
        }
Exemple #10
0
        private void DoUpdateObjectInfoControls()
        {
            // フォーム以外のスレッドから呼び出された場合にフォームのスレッドで処理する
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Action(DoUpdateObjectInfoControls));
                return;
            }
            // 多重呼び出しの禁止
            if (!_mutex.WaitOne(0))
            {
                return;
            }
            try {
                if (_infoContentChanging)
                {
                    return;
                }
                _infoContentChanging = true;
                try {
                    // _dataSetの途中変更を防ぐ
                    MotionDataSet dataSet = _dataSet;
                    if (dataSet == null)
                    {
                        return;
                    }
                    var infoList = dataSet.GetSelectedObjectInfoList();
                    // その他のコントロールの更新
                    if (infoList.Count == 0)
                    {
                        // 選択なしのとき
                        textColor.Enabled         = false;
                        textName.Enabled          = false;
                        numericColorAlpha.Enabled = false;
                        checkVisible.Enabled      = false;
                        textGroup.Enabled         = false;
                        textColor.BackColor       = Color.White;
                        textColor.ForeColor       = Color.Black;
                        textColor.Text            = "Color";
                        textName.Text             = "Nothing selected";
                        numericColorAlpha.Value   = 0;
                        checkVisible.Checked      = false;
                    }
                    else
                    {
                        textColor.Enabled         = true;
                        textName.Enabled          = true;
                        numericColorAlpha.Enabled = true;
                        checkVisible.Enabled      = true;
                        textGroup.Enabled         = true;

                        // 名前
                        if (infoList.Count == 1)
                        {
                            textName.Text = PathEx.GetRelativePath(infoList[0].Name, _currentGroup);
                        }
                        else
                        {
                            textName.Text = _defaultName;
                        }
                        // 色
                        Color color = Color.FromArgb(255, infoList[0].Color);
                        if (infoList.All(info => color == Color.FromArgb(255, info.Color)))
                        {
                            textColor.BackColor = color;
                            textColor.ForeColor = ColorEx.GetComplementaryColor(color);
                            textColor.Text      = "Color: " + ColorTranslator.ToHtml(color);
                        }
                        else
                        {
                            textColor.BackColor = Color.White;
                            textColor.ForeColor = Color.Black;
                            textColor.Text      = "Color: ...";
                        }
                        // visible
                        bool visible = infoList[0].IsVisible;
                        if (infoList.All(info => visible == info.IsVisible))
                        {
                            checkVisible.ThreeState = false;
                            checkVisible.Checked    = visible;
                        }
                        else
                        {
                            checkVisible.ThreeState = true;
                            checkVisible.CheckState = CheckState.Indeterminate;
                        }
                        // 色のアルファ
                        int alpha = infoList[0].Color.A;
                        if (infoList.All(info => info.Color.A == alpha))
                        {
                            numericColorAlpha.Value     = (int)Math.Round(100.0 * alpha / 255);
                            numericColorAlpha.ForeColor = SystemColors.ControlText;
                        }
                        else
                        {
                            numericColorAlpha.Value     = (int)Math.Round(100.0 * alpha / 255);
                            numericColorAlpha.ForeColor = SystemColors.GrayText;
                        }
                    }
                } finally { _infoContentChanging = false; }
            } finally { _mutex.ReleaseMutex(); }
        }
Exemple #11
0
        public void OnSelectionChanged(object sender, EventArgs e)
        {
            // フォーム以外のスレッドから呼び出された場合にフォームのスレッドで処理する
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new EventHandler(OnSelectionChanged), sender, e);
                return;
            }
            // _dataSetの途中変更を防ぐ
            MotionDataSet dataSet = _dataSet;

            if (dataSet == null)
            {
                return;
            }
            // 多重呼び出しの禁止
            if (!_mutex.WaitOne(0))
            {
                return;
            }
            try {
                if (_selectionChanging)
                {
                    return;
                }
                _selectionChanging = true;
                try {
                    // リストビューの更新
                    listObjectInfo.SuspendLayout();
                    try {
                        var infoList = dataSet.GetSelectedObjectInfoList();
                        // 選択されたオブジェクトが現在の選択グループ以外のものを含む場合にグループの選択を上位に変更
                        if (infoList.Count != 0)
                        {
                            string common = PathEx.GetCommonDir(infoList.Select(info => info.Name).ToList());
                            if (_currentGroup != common && !PathEx.IsSubPath(common, _currentGroup))
                            {
                                _currentGroup = common;
                                this.DoSelectedGroupChanged();
                                return;
                            }
                        }
                        ListViewItem lastSelected = null;
                        // 選択が変更されたオブジェクトについてのリストビューのアイテムを更新
                        foreach (ListViewItem item in listObjectInfo.Items)
                        {
                            uint id   = uint.Parse(item.SubItems[1].Text);
                            var  info = dataSet.GetObjectInfoById(id);
                            if (info != null)
                            {
                                if (item.Selected != dataSet.IsSelecting(info))
                                {
                                    if (dataSet.IsSelecting(info))
                                    {
                                        lastSelected = item;
                                    }
                                    item.Text     = formatNameText(info);
                                    item.Selected = dataSet.IsSelecting(info);
                                    item.Font     = new Font(item.Font, dataSet.IsSelecting(info) ? FontStyle.Bold : FontStyle.Regular);
                                }
                            }
                        }
                        if (lastSelected != null)
                        {
                            lastSelected.EnsureVisible();
                        }
                    } finally { listObjectInfo.ResumeLayout(); }
                    this.DoUpdateObjectInfoControls();
                } finally { _selectionChanging = false; }
            } finally { _mutex.ReleaseMutex(); }
        }
        private void bgwRender_DoWork(object sender, DoWorkEventArgs e)
        {
            TimeController timeController = _timeController;
            MotionDataSet  dataSet        = _dataSet;

            if (dataSet == null || timeController == null)
            {
                Bitmap infoImage = new Bitmap(_width, _height);
                using (Graphics gfx = Graphics.FromImage(infoImage)) {
                    gfx.Clear(Color.DimGray);
                    gfx.DrawString("Error...", this.Font, Brushes.LightGray, new PointF());
                }
                setPictureImage(pictGraph, infoImage);
                return;
            }

            RangeSet <int> existAll    = null;             // 選択されたオブジェクトが被欠損なインデックス
            List <int>     clipIndices = new List <int>(); // グラフ上の各x座標のインデックスの範囲
            Collection <MotionObjectInfo> infoList;

            // メッセージを表示
            setText(labelInfo, "データ欠損情報");
            infoList = dataSet.GetSelectedObjectInfoList();
            if (infoList.Count == 0)
            {
                Bitmap infoImage = new Bitmap(_width, _height);
                using (Graphics gfx = Graphics.FromImage(infoImage)) {
                    gfx.Clear(Color.DimGray);
                    gfx.DrawString("選択オブジェクトなし", this.Font, Brushes.Ivory, new PointF());
                }
                setPictureImage(pictGraph, infoImage);
                return;
            }
            else
            {
                Bitmap infoImage = new Bitmap(_width, _height);
                using (Graphics gfx = Graphics.FromImage(infoImage)) {
                    gfx.Clear(Color.DimGray);
                    gfx.DrawString("読み込み中...", this.Font, Brushes.LightGray, new PointF());
                }
                setPictureImageImmediate(pictGraph, infoImage);
            }
            // 選択された全オブジェクトの非欠損のandを取る
            foreach (var info in infoList)
            {
                if (bgwRender.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                if (existAll == null)
                {
                    existAll = getExistenceList(info.Id);
                }
                else
                {
                    existAll = existAll.GetIntersect(getExistenceList(info.Id));
                }
            }
            // 各x座標に対応する時間に対応するフレームのインデックスを求める
            // clipIndices[0] から (clipIndices[1] - 1)には,[x=0に対応する時刻]から[x=1に対応する時刻の直前]までに含まれるインデックスが入るようにする
            for (int x = 0; x <= _width; x++)
            {
                decimal time  = positionToTime(x);
                int     index = dataSet.GetFrameIndexAt(time);
                // ちょうどtimeの値がフレームの時間と一緒のときだけ特別対応
                Motion.MotionFrame frame = dataSet.GetFrameByIndex(index);
                if (frame == null || frame.Time != time)
                {
                    index++; // 取得されたインデックスは,今回のループのx座標に対応する時間範囲に入らない
                }
                clipIndices.Add(index);
            }
            lock (_lockAccessGraphImage) {
                // グラフの作成
                _graphImage = new Bitmap(_width, _height);
                using (Graphics gfx = Graphics.FromImage(_graphImage)) {
                    gfx.Clear(Color.Black);

                    for (int x = 0; x < _width; x++)
                    {
                        // 今回のx座標に対応するフレームインデックスの範囲
                        int clipCount = clipIndices[x + 1] - clipIndices[x];
                        RangeSet <int> .Range clipRange = new RangeSet <int> .Range(clipIndices[x], clipIndices[x + 1]);

                        // 今回の範囲の被欠損情報を取得
                        RangeSet <int> existClipped = existAll.GetClipped(clipRange);
                        int            existCount   = existClipped.Total();

                        Pen pen = Pens.LightGreen;
                        if (existCount == clipCount)
                        {
                            pen = Pens.YellowGreen;
                        }
                        if (existCount > 0)
                        {
                            gfx.DrawLine(pen, new Point(x, _height - 1), new Point(x, _height - 1 - _height * existCount / clipCount));
                        }
                    }
                    // 選択範囲の欠損割合の計算
                    decimal     selectBegin      = timeController.VisibleBeginTime;
                    decimal     selectEnd        = timeController.VisibleEndTime;
                    int         selectBeginIndex = dataSet.GetFrameIndexAt(selectBegin);
                    int         selectEndIndex   = dataSet.GetFrameIndexAt(selectEnd);
                    MotionFrame selectBeginFrame = dataSet.GetFrameByIndex(selectBeginIndex);
                    MotionFrame selectEndFrame   = dataSet.GetFrameByIndex(selectEndIndex);
                    if (selectBeginFrame == null || selectBeginFrame.Time != selectBegin)
                    {
                        selectBeginIndex++; // clipIndicesを求めるときと同じ処理
                    }
                    if (selectEndFrame == null || selectEndFrame.Time != selectEnd)
                    {
                        selectEndIndex++;
                    }
                    RangeSet <int> whole            = existAll.GetClipped(new RangeSet <int> .Range(selectBeginIndex, selectEndIndex));
                    int            selectClipCount  = selectEndIndex - selectBeginIndex;
                    int            selectExistCount = whole.Total();
                    int            missingCount     = selectClipCount - selectExistCount;
                    double         percentage       = selectClipCount == 0 ? 0 : (100.0 - 100.0 * selectExistCount / selectClipCount);
                    setText(labelInfo, string.Format("欠落フレーム数: {0} (選択フレーム数 {1}, {2}% 欠損) ({3} オブジェクト)", missingCount, selectClipCount, Math.Round(percentage, 2), infoList.Count));
                }
            }
        }