public void AddRow(ReqTraceNode reqTraceNode)
        {
            DataGridViewListBoxCell lbCell;
            DataGridViewRow         row;

            string[] astrReq;

            string        strTraceTo   = "";
            string        strTraceFrom = "";
            List <string> arrTracesTo;
            List <string> arrTracesFrom;

            reqTraceNode.GetTraceToString(out arrTracesTo);
            foreach (string str in arrTracesTo)
            {
                strTraceTo += str + "\r\n";
            }

            reqTraceNode.GetTraceFromString(out arrTracesFrom);
            foreach (string str in arrTracesFrom)
            {
                strTraceFrom += str + "\r\n";
            }

            astrReq = new string[]
            {
                reqTraceNode.Tag,
                reqTraceNode.TagName,
                reqTraceNode.Text,
            };

            row = new DataGridViewRow();
            row.CreateCells(this, astrReq);
            if (reqTraceNode.IsRootNode)
            {
                row.Cells[1].Style.BackColor = Color.FromArgb(200, 255, 200);
            }
            row.Height                      = Font.Height * 11 / 2;
            row.ContextMenuStrip            = mnuCtxRow;
            row.HeaderCell.ContextMenuStrip = mnuCtxRow;
            row.Tag = reqTraceNode.Key;
            Rows.Add(row);

            lbCell = (DataGridViewListBoxCell)row.Cells[3];
            foreach (string str in arrTracesTo)
            {
                lbCell.Items.Add(str);
            }

            lbCell = (DataGridViewListBoxCell)row.Cells[4];
            foreach (string str in arrTracesFrom)
            {
                lbCell.Items.Add(str);
            }
        }
Exemple #2
0
        public ReqTraceDotNode(int nYOffset,
                               ReqTraceNode reqTraceNode) : base(nYOffset, reqTraceNode)
        {
            int[]  nTraceToX;
            int[]  nTraceToY;
            string strCurrent;
            int    nTraces;
            bool   bAdditionalTraces;
            string strAttribute = "";

            strDOT = "";

            strCurrent = CoordToString(nXPos, nYPos);

            if (reqTraceNode.IsRootNode)
            {
                strAttribute = "style=filled, fillcolor=\"#C8FFC8\", ";
            }

            strDOT = "  " + strCurrent + " [shape = record, " + strAttribute + "label=\"{" +
                     DotFormat(reqTraceNode.TagName.Replace("\"", "\\\""), 2) +
                     "|" +
                     DotFormat(reqTraceNode.Text.Replace("\"", "\\\""), 8) + "}\"];\r\n";

            if (reqTraceNode.AreTooManyTracesTo(out nTraces, out bAdditionalTraces))
            {
                strDOT += "  " + strCurrent +
                          "_To [shape=none, label=\"" +
                          (bAdditionalTraces ? "+" : "") + nTraces.ToString() + " REQs\"];\r\n";
                strDOT += "  " + strCurrent + " -> " + strCurrent + "_To;\r\n";
            }

            if (reqTraceNode.AreTooManyTracesFrom(out nTraces, out bAdditionalTraces))
            {
                strDOT += "  " + strCurrent +
                          "_From [shape=none, label=\"" +
                          (bAdditionalTraces ? "+" : "") + nTraces.ToString() + " REQs\"];\r\n";
                strDOT += "  " + strCurrent + "_From -> " + strCurrent + ";\r\n";
            }

            reqTraceNode.GetTraceToCoord(out nTraceToX, out nTraceToY);

            for (int i = nTraceToX.GetLength(0) - 1; i >= 0; i--)
            {
                if ((nTraceToX[i] != int.MinValue) && (reqTraceNode.X != int.MinValue))
                {
                    strDOT += "  " + strCurrent + " -> " + CoordToString(nTraceToX[i], nYOffset - nTraceToY[i]) + ";\r\n";
                }
            }
        }
 public static int CompareReqTraceNodebyRelationDegree(ReqTraceNode x, ReqTraceNode y)
 {
     if (x == null)
     {
         if (y == null)
         {
             // If x is null and y is null, they're equal.
             return(0);
         }
         else
         {
             // If x is null and y is not null, x is greater.
             return(1);
         }
     }
     else
     {
         // If x is not null...
         if (y == null)
         {
             // ...and y is null, y is greater.
             return(-1);
         }
         else
         {
             // ...and y is not null, compare the lengths of the two strings.
             if (x.ulDegreeRel == y.ulDegreeRel)
             {
                 return(0);
             }
             else
             if (x.ulDegreeRel > y.ulDegreeRel)
             {
                 return(1);
             }
             else
             {
                 return(-1);
             }
         }
     }
 }
Exemple #4
0
        private void ShowRequirements(ArrayList arrKeys, string strTreePathName, bool bWithFilter)
        {
            ReqProRequirementPrx rpxReq;
            FormGenericTable     genTable;
            int    nCount;
            string strCell;
            int    nTraceCountTo;
            int    nTraceCountFrom;

            ReqProRequirementPrx[] arpxReqTracesTo;
            ReqProRequirementPrx[] arpxReqTracesFrom;
            ReqTraceNode           reqTN;

            string[]      arrStringTrace;
            List <string> listTrace = new List <string>();

            string[,] astrGrid;
            List <string[]> aastrCells;
            List <string>   rowHdrCells = new List <string>();

            string[] rowCells;

            string[]      astrCol;
            string[]      astrValue;
            int           nColCount;
            List <string> colTraceTo;
            List <string> colTraceFrom;

            ReqProRequirementPrx.eTraceAbortReason eAbortReason = ReqProRequirementPrx.eTraceAbortReason.eNoAbort;

            if (bWithFilter)
            {
                if (!ToContinueAfterFilter(true, false))
                {
                    return;
                }
            }

            genTable = new FormGenericTable("Requirements - Package: " + strTreePathName, null, null, FormGenericTableLayout.eFormGenericTableToken.eReqDetails);
            nCount   = 0;

            /* at least we have: Tag, Name, Text, Version, Date, User,  */
            rowHdrCells.Add("Tag");
            rowHdrCells.Add("Name");
            rowHdrCells.Add("Text");
            rowHdrCells.Add("Version");
            rowHdrCells.Add("Date");
            rowHdrCells.Add("User");
            rowHdrCells.Add("Path");
            rowHdrCells.Add("Package");

            colTraceTo   = new List <string>();
            colTraceFrom = new List <string>();

            colTraceTo.Add("Trace To");
            colTraceFrom.Add("Trace From");

            aastrCells = new List <string[]> ();


            foreach (int nKey in arrKeys)
            {
                int nColIdx;
                rowCells = new string [rowHdrCells.Count];

                rpxReq = reqDBBrowser.GetRequirementPrx(nKey);

                if (!listnReqTypeRootKeyExcl.Contains(rpxReq.ReqTypeKey))
                {
                    rowCells[0] = rpxReq.Tag;
                    rowCells[1] = rpxReq.Name;
                    rowCells[2] = rpxReq.Text;
                    rowCells[3] = rpxReq.VersionNumber;
                    rowCells[4] = rpxReq.VersionDateTime;
                    rowCells[5] = rpxReq.VersionUser;
                    rowCells[6] = rpxReq.PackagePathName;
                    rowCells[7] = rpxReq.PackageName;

                    nColCount = rpxReq.GetAttributes(out astrCol, out astrValue);

                    for (int i = 0; i < nColCount; i++)
                    {
                        nColIdx = rowHdrCells.IndexOf(astrCol[i]);
                        if (nColIdx == -1)
                        {
                            int      nOldCnt     = rowHdrCells.Count;
                            string[] rowCellsOld = rowCells;
                            rowCells = new string[nOldCnt + 1];
                            rowHdrCells.Add(astrCol[i]);
                            for (int j = 0; j < nOldCnt; j++)
                            {
                                rowCells[j] = rowCellsOld[j];
                            }
                            nColIdx = rowHdrCells.Count - 1;
                        }
                        rowCells[nColIdx] = astrValue[i];
                        if (rowCells[nColIdx] == null)
                        {
                            rowCells[nColIdx] = "";
                        }
                        System.Diagnostics.Trace.Write(rowHdrCells[nColIdx] + "(" + rowCells[nColIdx] + "); ");
                    }

                    aastrCells.Add(rowCells);
                    arpxReqTracesTo   = rpxReq.GetRequirementTracesTo(20, ref eAbortReason, out nTraceCountTo, null);
                    arpxReqTracesFrom = rpxReq.GetRequirementTracesFrom(20, ref eAbortReason, out nTraceCountFrom, null);
                    reqTN             = new ReqTraceNode(rpxReq, 0, true, arpxReqTracesFrom, arpxReqTracesTo,
                                                         nTraceCountFrom, nTraceCountTo, eAbortReason, 0, 0);

                    reqTN.GetTraceFromString(out listTrace);
                    arrStringTrace = listTrace.ToArray();
                    colTraceFrom.Add(string.Join("\n", arrStringTrace));

                    reqTN.GetTraceToString(out listTrace);
                    arrStringTrace = listTrace.ToArray();
                    colTraceTo.Add(string.Join("\n", arrStringTrace));

                    nCount++;
                }
            }

            aastrCells.Insert(0, rowHdrCells.ToArray());

            // we want some additional space for Trace To and From
            astrGrid = new string[aastrCells.Count, rowHdrCells.Count + 2];
            for (int i = 0; i < aastrCells.Count; i++)
            {
                int j;
                for (j = 0; j < rowHdrCells.Count; j++)
                {
                    if (j < aastrCells[i].GetLength(0))
                    {
                        strCell = aastrCells[i][j];
                    }
                    else
                    {
                        strCell = null;
                    }
                    if (strCell == null)
                    {
                        strCell = "n/a";
                    }
                    astrGrid[i, j] = strCell;
                }
                astrGrid[i, j]     = colTraceTo[i];
                astrGrid[i, j + 1] = colTraceFrom[i];
            }

            genTable.SetGridContent(astrGrid, nCount + " Requirements");
            genTable.Show();
        }
Exemple #5
0
 public ReqTraceUIRendererNode(int nYOffset,
                               ReqTraceNode reqTraceNode)
 {
     nXPos = reqTraceNode.X;
     nYPos = nYOffset - reqTraceNode.Y;
 }
        private void AddReq(ReqProRequirementPrx reqReqPrx,
                            int nTraceLevel, int nTraceFromHopCount, int nTraceToHopCount, ulong ulDegreeOffset,
                            ReqProRequirementPrx reqReqPrxTracesPreceder)
        {
            ReqTraceNode reqTraceNode = null;

            ReqProRequirementPrx.eTraceAbortReason eAbort = ReqProRequirementPrx.eTraceAbortReason.eNoAbort;

            if (dictReqKey.ContainsKey(reqReqPrx.Key))
            /* this requirement was already handled */
            {
                reqTraceNode = dictReqKey[reqReqPrx.Key];
                if (reqReqPrxTracesPreceder == null)
                {
                    reqTraceNode.MakeRootNode();
                }
                if (!(reqTraceNode.TunedUp(nTraceFromHopCount, nTraceToHopCount)))
                {
                    return;
                }
            }

            if (reqReqPrxTracesPreceder != null)
            {
                if (listnReqTypeTracedKeyExcl.Contains(reqReqPrx.ReqTypeKey))
                {
                    eAbort |= ReqProRequirementPrx.eTraceAbortReason.eReqTypeFilter;
                    showProgressReqTraceGrid(0, 0, "Filtered: " + reqReqPrx.Tag);
                    return;
                }
            }

            int nTracesTo;
            int nTracesFrom;

            ReqProRequirementPrx[] aTracesTo;
            ReqProRequirementPrx[] aTracesFrom;
            ulong ulDegreeInc = 1UL;

            for (int i = 0; i < (nTraceLevel + nMaxLevelTo); i++)
            {
                ulDegreeInc *= ulLevelMultiplier * ((ulong)nTraceLevel + (ulong)nMaxLevelTo);
            }

            Tracer tracer = new Tracer("Traces from/to Req " + reqReqPrx.Tag);

            aTracesTo   = reqReqPrx.GetRequirementTracesTo(nMaxTraceCount, ref eAbort, out nTracesTo, reqReqPrxTracesPreceder);
            aTracesFrom = reqReqPrx.GetRequirementTracesFrom(nMaxTraceCount, ref eAbort, out nTracesFrom, reqReqPrxTracesPreceder);
            tracer.Stop("Traces from/to Req " + reqReqPrx.Tag);

            if (reqTraceNode == null)
            {
                reqTraceNode = new ReqTraceNode(reqReqPrx, ulDegreeOffset, reqReqPrxTracesPreceder == null,
                                                aTracesFrom, aTracesTo, nTracesFrom, nTracesTo, eAbort, nTraceFromHopCount, nTraceToHopCount);
                dictReqKey.Add(reqReqPrx.Key, reqTraceNode);
                grid[TraceLevel2Index(nTraceLevel)].Add(reqTraceNode);
            }
            else
            {
                reqTraceNode.OnceAgain(ulDegreeOffset, reqReqPrxTracesPreceder == null,
                                       aTracesFrom, aTracesTo, nTracesFrom, nTracesTo, eAbort, nTraceFromHopCount, nTraceToHopCount);
            }

            showProgressReqTraceGrid(0, 1, "Adding: " + reqTraceNode.Tag);

            if (aTracesFrom.GetLength(0) > 0)
            {
                if (nTraceLevel < this.nMaxLevelFrom)
                {
                    if (reqTraceNode.TraceFromHopCount < this.nMaxFromTraceHops)
                    {
                        int   nNextTraceFromHopCount = nTraceFromHopCount;
                        ulong ulLocOffset            = ulDegreeOffset * ulLevelMultiplier;
                        showProgressReqTraceGrid(aTracesFrom.GetLength(0), 0, null);
                        foreach (ReqProRequirementPrx reqReqPrxFrom in aTracesFrom)
                        {
                            if (dictReqKey.ContainsKey(reqReqPrxFrom.Key))
                            {
                                ReqTraceNode reqTN = dictReqKey[reqReqPrxFrom.Key];
                                reqTN.SetRelDegree(ulLocOffset);
                                reqTN.AddTraceTo(reqReqPrx);
                            }
                            else
                            {
                                ulLocOffset += ulDegreeInc;
                                AddReq(reqReqPrxFrom, nTraceLevel + 1, ++nNextTraceFromHopCount, nTraceToHopCount,
                                       ulLocOffset, reqReqPrx);
                            }
                        }
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("From Hops exceeded at: " + reqReqPrx.TagName);
                        showProgressReqTraceGrid(0, 0, "tracing from hops exceeded at: " + reqTraceNode.Tag);
                        eAbort |= ReqProRequirementPrx.eTraceAbortReason.eMaxFromHopsExceeded;
                    }
                }
                else
                {
                    eAbort |= ReqProRequirementPrx.eTraceAbortReason.eMaxFromLevelReached;
                }
            }


            if (aTracesTo.GetLength(0) > 0)
            {
                if (nTraceLevel > -this.nMaxLevelTo)
                {
                    if (reqTraceNode.TraceToHopCount + 1 <= this.nMaxToTraceHops)
                    {
                        int   nNextTraceToHopCount = reqTraceNode.TraceToHopCount + 1;
                        ulong ulLocOffset          = ulDegreeOffset;
                        showProgressReqTraceGrid(aTracesTo.GetLength(0), 0, null);
                        foreach (ReqProRequirementPrx reqReqPrxTo in aTracesTo)
                        {
                            if (dictReqKey.ContainsKey(reqReqPrxTo.Key))
                            {
                                ReqTraceNode reqTN = dictReqKey[reqReqPrxTo.Key];
                                reqTN.SetRelDegree(ulLocOffset);
                                reqTN.AddTraceFrom(reqReqPrx);
                            }
                            else
                            {
                                ulLocOffset += ulDegreeInc;
                                AddReq(reqReqPrxTo, nTraceLevel - 1, nTraceFromHopCount, nTraceToHopCount,
                                       ulLocOffset, reqReqPrx);
                            }
                        }
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("To Hops exceeded at: " + reqReqPrx.TagName);
                        showProgressReqTraceGrid(0, 0, "tracing to exceeded at: " + reqTraceNode.Tag);
                        eAbort |= ReqProRequirementPrx.eTraceAbortReason.eMaxToHopsExceeded;
                    }
                }
                else
                {
                    eAbort |= ReqProRequirementPrx.eTraceAbortReason.eMaxToLevelReached;
                }
            }
            reqTraceNode.AbortReason = eAbort;
        }
        public ReqTraceUIGraphNode(int nYOffset,
                                   ReqTraceNode reqTraceNode) : base(nYOffset, reqTraceNode)
        {
            TextBox tb;
            ToolTip tt;
            int     nTraces;
            bool    bAdditionalTraces;

            int[] nTraceToX;
            int[] nTraceToY;

            this.reqTraceNode = reqTraceNode;

            tb           = new TextBox();
            tb.Location  = new Point(nXPos * nXSpacing + nXSpacing / 2, nYPos * nYSpacing + nYSpacing / 2);
            tb.Size      = sizeTagName;
            tb.Multiline = true;
            tb.ReadOnly  = true;
            tb.Text      = reqTraceNode.TagName;
            if (reqTraceNode.IsRootNode)
            {
                tb.BackColor = Color.FromArgb(200, 255, 200);
            }
            tt           = new ToolTip();
            tt.BackColor = Color.Yellow;
            tt.SetToolTip(tb, reqTraceNode.TagName);
            tb.ContextMenuStrip = mnuCtxTag;
            tb.MouseEnter      += tb_MouseEnter;
            ctrls.Add(tb);
            tbReqTag = tb;

            tb                  = new TextBox();
            tb.Location         = new Point(nXPos * nXSpacing + nXSpacing / 2, nYPos * nYSpacing + sizeTagName.Height + nYSpacing / 2);
            tb.Size             = sizeText;
            tb.Multiline        = true;
            tb.ReadOnly         = true;
            tb.ScrollBars       = ScrollBars.Vertical;
            tb.Text             = reqTraceNode.Text;
            tb.ContextMenuStrip = mnuCtxName;
            tb.MouseEnter      += tb_MouseEnter;
            ctrls.Add(tb);
            tbReqText = tb;

            arrFGUI = new List <ReqTraceUI>();
            arrBGUI = new List <ReqTraceUI>();

            if (reqTraceNode.AreTooManyTracesFrom(out nTraces, out bAdditionalTraces))
            {
                arrBGUI.Add(new ReqTraceUIArrowDwn(nTraces, bAdditionalTraces,
                                                   nXPos * nXSpacing + nXSpacing / 2 + sizeTagName.Width / 2,
                                                   nYPos * nYSpacing + nYSpacing / 2));
            }

            if (reqTraceNode.AreTooManyTracesTo(out nTraces, out bAdditionalTraces))
            {
                arrBGUI.Add(new ReqTraceUIArrowUp(nTraces, bAdditionalTraces,
                                                  nXPos * nXSpacing + nXSpacing / 2 + sizeTagName.Width / 2,
                                                  nYPos * nYSpacing + sizeTagName.Height + sizeText.Height + nYSpacing / 2));
            }

            reqTraceNode.GetTraceToCoord(out nTraceToX, out nTraceToY);

            for (int i = nTraceToX.GetLength(0) - 1; i >= 0; i--)
            {
                if ((nTraceToX[i] != int.MinValue) && (reqTraceNode.X != int.MinValue))
                {
                    arrFGUI.Add(new ReqTraceUITraceArrow(
                                    nXPos * nXSpacing + sizeText.Width / 2 + nXSpacing / 2,
                                    nYPos * nYSpacing + sizeTagName.Height + sizeText.Height + nYSpacing / 2,
                                    nTraceToX[i] * nXSpacing + sizeText.Width / 2 + nXSpacing / 2,
                                    (nYOffset - nTraceToY[i]) * nYSpacing + nYSpacing / 2));
                }
            }
        }