예제 #1
0
        public static string BuildFieldCaption(
            PivotGridFieldMx f)
        {
            ResultsField rfld = f.ResultsField as ResultsField;

            if (rfld == null)
            {
                return("Unknown");
            }
            QueryColumn    qc = rfld.QueryColumn;
            ResultsTable   rt = rfld.ResultsTable;
            ResultsFormat  rf = rt.ResultsFormat;
            AggregationDef ad = f.Aggregation;

            string caption = qc.GetActiveLabel(includeAggregationType: false);

            if (rf.Tables.Count > 1)
            {
                caption = "T" + (rt.Position + 1) + "." + caption;
            }

            if (f.Role == AggregationRole.DataSummary)
            {
                if (!ad.IsGroupingType)
                {
                    caption += " " + ad.TypeLabel;
                }
            }

            f.Caption = caption;

            return(caption);
        }
예제 #2
0
/// <summary>
/// SetFieldGridDataRow
/// </summary>
/// <param name="dr"></param>
/// <param name="f"></param>

        void SetFieldGridDataRow(DataRow dr, PivotGridFieldMx f)
        {
            string label, txt;

            ResultsField  rfld = f.ResultsField as ResultsField;
            ResultsTable  rt   = rfld.ResultsTable;
            ResultsFormat rf   = rt.ResultsFormat;
            MetaColumn    mc   = rfld.MetaColumn;
            QueryColumn   qc   = rfld.QueryColumn;
            QueryTable    qt   = qc.QueryTable;
            Query         q    = qt.Query;

            dr["ColTypeImageCol"] = QueryTableControl.GetMetaColumnDataTypeImage(mc);
            dr["PivotFieldCol"]   = f;           // store reference to pivot field
            dr["FieldNameCol"]    = f.Caption;

            dr["AggRoleCol"] = f.Aggregation.RoleLabel;

            dr["AggTypeCol"] = f.Aggregation.TypeLabel;

            //			txt = GroupingTypeLabel(f);
            //			dr["HeaderBinningCol"] = txt;

            dr["SourceColumnCol"] = PivotGridControlMx.BuildFieldCaption(f);

            label = qt.ActiveLabel;
            if (rf.Tables.Count > 1)
            {
                label = "T" + (rt.Position + 1) + " - " + label;
            }
            dr["SourceTableCol"] = label;

            return;
        }
예제 #3
0
/// <summary>
/// Get column count for results format
/// Explicitly sums counts for tables
/// </summary>
/// <returns></returns>

        public int ColumnCount()
        {
            int colcnt = 0;

            for (int ti = 0; ti < Tables.Count; ti++)
            {
                ResultsTable rt = this.Tables[ti];
                colcnt += rt.Fields.Count;
            }

            return(colcnt);
        }
예제 #4
0
/// <summary>
/// Get column count for results format (grid only)
/// Checks last column to get count
/// </summary>
/// <returns></returns>

        public int GridColumnCount()
        {
            for (int ti = this.Tables.Count - 1; ti >= 0; ti--)         // scan backwards til we find a table with columns
            {
                ResultsTable rt = this.Tables[ti];
                if (rt.Fields.Count == 0)
                {
                    continue;                                     // table may have zero cols
                }
                ResultsField rfld   = rt.Fields[rt.Fields.Count - 1];
                int          colcnt = rfld.FieldPosition + 1;        // number of data-containing columns in grid
                if (Query.ShowGridCheckBoxes)
                {
                    colcnt++;
                }
                return(colcnt);
            }

            return(0);            // no columns (shouldn't happen)
        }
예제 #5
0
        /// <summary>
        /// Initialize for any structure hilighting
        /// </summary>

        void InitializeStructureHilighting()
        {
            QueryColumn qc = null;

            if (StructureHighlightingInitialized)
            {
                return;
            }

            // Structure match hilighting / orienting

            try
            {
                do
                {
                    qc = Query.GetFirstStructureCriteriaColumn();
                    if (qc == null)
                    {
                        break;
                    }
                    if (Lex.IsUndefined(qc.Criteria))
                    {
                        break;
                    }

                    ParsedSingleCriteria psc = MqlUtil.ParseQueryColumnCriteria(qc);
                    if (psc == null || Lex.IsUndefined(psc.Value))
                    {
                        break;
                    }

                    ParsedStructureCriteria pssc = ParsedStructureCriteria.ConvertFromPscToPssc(psc);

                    StructureDisplayFormat sdf = StructureDisplayFormat.Deserialize(qc.DisplayFormatString);                     // get any hilighting info from format

                    if (pssc.SearchType == StructureSearchType.Substructure)
                    {
                        string chime = MoleculeMx.MolfileStringToChimeString(qc.MolString);
                        if (!String.IsNullOrEmpty(chime))
                        {
                            AlignStructureToQuery     = Lex.Contains(psc.Value2, "Orient") || Lex.Contains(psc.Value2, "Align=True");
                            HighlightStructureMatches = !(Lex.Contains(psc.Value2, "NoHighlight") || Lex.Contains(psc.Value2, "Highlight=false"));
                            MoleculeMx cs = new MoleculeMx(MoleculeFormat.Chime, chime);
                            StrMatcher = new StructureMatcher();
                            StrMatcher.SetSSSQueryMolecule(cs);                             // set query used for highlighting
                        }
                    }

                    else if (pssc.SearchType == StructureSearchType.SmallWorld && pssc.SmallWorldParameters != null)
                    {
                        SmallWorldPredefinedParameters swp = pssc.SmallWorldParameters;
                        HighlightStructureMatches = swp.Highlight;
                        AlignStructureToQuery     = swp.Align;
                        //SmallWorldDepictions = null; // depiction cache
                    }

                    else if (pssc.SearchType == StructureSearchType.Related)                     //
                    {
                        string chime = MoleculeMx.MolfileStringToChimeString(qc.MolString);
                        if (!String.IsNullOrEmpty(chime))
                        {
                            AlignStructureToQuery     = Lex.Contains(psc.Value2, "Orient") || Lex.Contains(psc.Value2, "Align=True");
                            HighlightStructureMatches = !(Lex.Contains(psc.Value2, "NoHighlight") || Lex.Contains(psc.Value2, "Highlight=false"));
                            MoleculeMx cs = new MoleculeMx(MoleculeFormat.Chime, chime);
                            StrMatcher = new StructureMatcher();
                            StrMatcher.SetSSSQueryMolecule(cs);                             // set query used for SSS highlighting
                        }
                    }

                    else if (sdf.Highlight || sdf.Align)                     // other cases
                    {
                        HighlightStructureMatches = sdf.Highlight;
                        AlignStructureToQuery     = sdf.Align;
                    }

                    else
                    {
                        break;                      // no hilighting / orienting
                    }
                    StructureHighlightQc   = qc;
                    StructureHighlightPssc = pssc;
                } while (false);
            }

            catch (Exception ex)             // log & ignore any errors
            {
                string msg = DebugLog.FormatExceptionMessage(ex);
                if (qc != null)
                {
                    msg += "\r\n" +
                           "Criteria: " + qc.Criteria + "\r\n" +
                           "Molstring: " + qc.MolString;
                }

                DebugLog.Message(msg);
                return;
            }

            // Atom number display (not currently used)

            SS.I.DisplayAtomNumbers = (int)AtomNumberDisplayMode.None;             // see if need to display atom numbers
            for (int ti = 1; ti < Rf.Tables.Count; ti++)
            {
                ResultsTable rt = Rf.Tables[ti];
                MetaTable    mt = rt.MetaTable;
                if (mt.Name.IndexOf("todo: table that needs atom number display") >= 0)
                {
                    SS.I.DisplayAtomNumbers = (int)AtomNumberDisplayMode.All;
                    break;
                }
            }

            StructureHighlightingInitialized = true;
            return;
        }
예제 #6
0
        /// <summary>
        /// Build tooltip for data row
        /// </summary>
        /// <param name="dri">Data row index</param>
        /// <returns></returns>

        internal SuperToolTip BuildDataRowTooltip(
            TooltipDimensionDef ttDim,
            int dri)
        {
            ColumnMapMsx cm;
            QueryTable   qt;
            QueryColumn  qc;
            MetaTable    mt;
            MetaColumn   mc;
            int          i1, i2;

            if (BaseQuery == null || BaseQuery.Tables.Count == 0 || Dtm == null)
            {
                return(null);
            }
            qt = BaseQuery.Tables[0];

            SuperToolTip s = new SuperToolTip();

            s.MaxWidth      = 200;
            s.AllowHtmlText = DefaultBoolean.True;

            ToolTipItem i = new ToolTipItem();

            i.AllowHtmlText = DefaultBoolean.True;
            i.Appearance.TextOptions.WordWrap = WordWrap.Wrap;

            ColumnMapCollection cml2 = new ColumnMapCollection();             // list of fields we'll actually display

            int strPos = -1;

            ColumnMapCollection cml = ttDim.Fields;

            if (cml.Count == 0)
            {
                return(s);
            }

            for (i1 = 0; i1 < cml.Count; i1++)
            {
                cm = cml[i1];
                qc = cm.QueryColumn;
                if (qc == null || !cm.Selected)
                {
                    continue;
                }
                //if (qc.IsKey) continue;
                if (qc.MetaColumn.DataType == MetaColumnType.Structure)
                {
                    strPos = i1;
                }

                for (i2 = 0; i2 < cml2.Count; i2++)                 // see if already have the column
                {
                    if (qc == cml2[i2].QueryColumn)
                    {
                        break;
                    }
                }
                if (i2 < cml2.Count)
                {
                    continue;
                }

                cml2.Add(cm);
            }

            if (cml2.Count == 0)
            {
                return(null);                             // no fields
            }
            if (strPos < 0 && ttDim.IncludeStructure)
            {                                  // include str if requested & not already included
                qc     = qt.FirstStructureQueryColumn;
                strPos = cml2.Count;           // put str at end
                //strPos = keyPos + 1; // place str after key
                if (qc != null && qc.Selected) // regular selected Qc?
                {
                    cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc));
                }

                else                 // look in root table for a structure
                {
                    mt = qt.MetaTable.Root;
                    if (mt.FirstStructureMetaColumn != null)
                    {
                        qt            = new QueryTable(mt);
                        qc            = new QueryColumn();              // add qc with no vo pos as indicator that must be selected
                        qc.MetaColumn = mt.FirstStructureMetaColumn;
                        qc.Selected   = true;
                        qt.AddQueryColumn(qc);
                        cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc));
                    }
                }
            }

            string keyVal = "";

            foreach (ColumnMapMsx fli0 in cml2.ColumnMapList)             // format each field
            {
                qc = fli0.QueryColumn;
                mc = qc.MetaColumn;

                i.Text += "<b>";                 // build label
                if (!Lex.IsNullOrEmpty(fli0.ParameterName))
                {
                    i.Text += fli0.ParameterName;
                }
                else
                {
                    i.Text += fli0.QueryColumn.ActiveLabel;
                }
                i.Text += ": </b>";

                if (qc.VoPosition >= 0)
                {
                    int       ti   = qc.QueryTable.TableIndex;
                    int       dri2 = Dtm.AdjustDataRowToCurrentDataForTable(dri, ti, true);
                    DataRowMx dr   = Qm.DataTable.Rows[dri2];
                    if (dr == null)
                    {
                        continue;
                    }
                    ResultsTable rt         = Rf.Tables[ti];
                    object       fieldValue = dr[qc.VoPosition];
                    if (!NullValue.IsNull(fieldValue))
                    {
                        if (qc.IsKey)
                        {
                            keyVal = fieldValue.ToString();
                        }
                        MobiusDataType     mdt = MobiusDataType.ConvertToMobiusDataType(qc.MetaColumn.DataType, fieldValue);
                        FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatField(qc, mdt);

                        if (mc.DataType != MetaColumnType.Structure)
                        {
                            i.Text += ffi.FormattedText;
                            i.Text += "<br>";
                        }
                        else
                        {
                            i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap);
                        }
                    }

                    else
                    {
                        i.Text += "<br>";                      // no data
                    }
                }

                else if (!Lex.IsNullOrEmpty(keyVal))                 // select structure from db (may already have)
                {
                    MoleculeMx cs = MoleculeUtil.SelectMoleculeForCid(keyVal, qc.MetaColumn.MetaTable);
                    if (cs != null)
                    {
                        int width = ResultsFormatFactory.QcWidthInCharsToDisplayColWidthInMilliinches(mc.Width, ResultsFormat);
                        FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatStructure(cs, new CellStyleMx(), 's', 0, width, -1);
                        i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap);
                    }
                }
            }

            if (i.Text.Length > 0)
            {
                s.Items.Add(i);
            }

            if (s.Items.Count == 0)
            {             // show something by default
                i            = new ToolTipItem();
                i.Text       = "No fields selected";
                i.LeftIndent = 6;
                i.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
                s.Items.Add(i);
            }

            //ToolTipTitleItem ti = new ToolTipTitleItem();
            //ti.Text = "Dude";
            //s.Items.Add(ti);

            //ToolTipItem i = new ToolTipItem();
            //i.Text = "Subtext that is fairly long longer longest";
            //i.LeftIndent = 6;
            //i.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            //s.Items.Add(i);

            //i = new ToolTipItem();
            //Image img = Bitmap.FromFile(@"C:\Mobius_OpenSource\Mobius-3.0\ClientComponents\Resources\Mobius76x76DkBlueBack.bmp");
            //i.Image = img;
            //s.Items.Add(i);

            //ToolTipSeparatorItem si = new ToolTipSeparatorItem();

            return(s);

            //ChartPanel.ToolTipController.ToolTipLocation = ToolTipLocation.TopCenter;
            //ChartPanel.ToolTipController.AllowHtmlText = true;
            //string s = point.SeriesPointID.ToString();
            //s = "This <b>SuperToolTip</b> supports <i>HTML formatting</i>";
        }