/// <summary> /// Initialize the Preview Query and associated QueryManager and Grid View /// </summary> public void InitializeView() { if (SwQuery != null) { return; } SwQuery = BuildStructureSearchQuery(); DataTableMx dt = DataTableManager.BuildDataTable(SwQuery); Qm = ToolHelper.SetupQueryManager(SwQuery, dt); MoleculeGridPageControl mgpc = MoleculeGridPageControl; ToolHelper.SetupGridPanelForDisplay(Qm, mgpc.MoleculeGridPanel); MoleculeGridControl grid = mgpc.MoleculeGrid; if (grid != null && grid.GV != null) { grid.GV.IndicatorWidth = 40; // narrow indicator col a bit } ClearDataAndGrid(); return; }
public CriteriaStructurePreview() { if (SystemUtil.InDesignMode) { InitializeComponent(); return; } MoleculeGridPageControl.RemoveToolPanelInConstructor = false; // keep tool panel and properly layout of controls InitializeComponent(); MoleculeGridPageControl.RemoveToolPanelInConstructor = true; MoleculeGridPageControl mgpc = MoleculeGridPageControl; mgpc.EditQueryButton.Visible = false; //PreviewCtl.MarkDataButton.Visible = false; mgpc.FormattingButton.Visible = false; mgpc.AdjustToolPanelButtonSpacing(); mgpc.Dock = DockStyle.Fill; Timer = new System.Windows.Forms.Timer(); Timer.Tick += new System.EventHandler(Timer_Tick); return; }
/// <summary> /// Allocate a new MoleculeGridPageControl /// and link into any associated QueryResultsContol /// </summary> /// <param name="qm"></param> /// <param name="container"></param> /// <returns></returns> public static MoleculeGridPageControl AllocateNewMoleculeGridPageControl( QueryManager qm, Control container) { QueryResultsControl qrc = null; PopupGrid pug = null; MoleculeGridPageControl page; MoleculeGridPanel panel; MoleculeGridControl grid; Query q = qm.Query; ResultsFormat rf = qm.ResultsFormat; page = new MoleculeGridPageControl(); // Create a new, clean page, panel and grids panel = page.MoleculeGridPanel; grid = panel.SelectBaseGridViewGrid(qm); qm.LinkMember(grid); // link grid into qm grid.ShowCheckMarkCol = q.ShowGridCheckBoxes; if (container is QueryResultsControl && rf.NotPopupOutputFormContext) // normal query results { qrc = container as QueryResultsControl; qrc.RemoveExistingControlsFromResultsPageControlContainer(); // properly dispose of any existing DevExpress controls qrc.MoleculeGridPageControl = page; // link query results to this page qrc.ResultsPageControlContainer.Controls.Add(page); page.Dock = DockStyle.Fill; } return(page); }
/// <summary> /// Clear any pointers to UI resources (e.g. forms, controls) /// </summary> public override void FreeControlReferences() { GridPageControl = null; base.FreeControlReferences(); return; }
/// <summary> /// Build the Query, QueryManager and DataTable for the matching structure display /// </summary> public void BuildStructureDisplayQuery() { MetaTable mt = MetaTableCollection.Get("QuickSearchRelatedStructures"); if (mt == null) { DebugLog.Message("QuickSearchRelatedStructures MetaTable not found"); RSC.MoleculeGridPageControl.Visible = false; return; } Query q = ToolHelper.InitEmbeddedDataToolQuery(mt); QueryTable qt = q.Tables[0]; q.UserObject.Name = qt.MetaTable.Label; StructureDisplayQuery = q; QueryColumn qc = qt.FirstStructureQueryColumn; if (qc != null) // setup dummy criteria { ParsedStructureCriteria pssc = new ParsedStructureCriteria(); pssc.SearchType = StructureSearchType.FullStructure; // just full structure search for now pssc.Molecule = new MoleculeMx(MoleculeFormat.Smiles, "C"); // placeholder structure pssc.ConvertToQueryColumnCriteria(qc); qc.DisplayFormatString = "Highlight=true;Align=true"; } string title = "Related Structures"; qt.Label = title; DataTableMx dt = q.ResultsDataTable as DataTableMx; Qm = ToolHelper.SetupQueryManager(q, dt); MoleculeGridPageControl mgpc = RSC.MoleculeGridPageControl; MoleculeGridPanel gp = mgpc.MoleculeGridPanel; mgpc.Width = RSC.Width - 3; // be sure we have page control correctly sized mgpc.Height = RSC.Height - mgpc.Top - 3; ToolHelper.SetupGridPanelForDisplay(Qm, mgpc.MoleculeGridPanel, true, true); MoleculeGridControl grid = mgpc.MoleculeGrid; if (grid != null && grid.GV != null) { grid.GV.IndicatorWidth = 40; // narrow indicator a bit } //ToolHelper.DisplayData // build and display empty grid for query with columns scaled to fit the grid // (q, dt, RSC.MoleculeGridPageControl.MoleculeGridPanel, true, true); return; }
/// <summary> /// Create the view display controls and link them into the QueryResultsControl and the ResultsView object /// </summary> /// <returns></returns> public override Control AllocateRenderingControl() { GridPageControl = new MoleculeGridPageControl(); GridPanel.View = this; // link the grid control panel to this view GridPanel.BandedViewGrid.Visible = false; // initially hidden GridPanel.LayoutViewGrid.Visible = false; // initially hidden GridPanel.Dock = DockStyle.Fill; // dock full grid panel RenderingControl = GridPanel; ConfigureCount = 0; return(RenderingControl); }
/// <summary> /// Dispose /// </summary> public new void Dispose() { ResultsPage = null; PageControl = null; View = null; Grid = null; if (LayoutViewGrid != null) { LayoutViewGrid.Dispose(); } if (BandedViewGrid != null) { BandedViewGrid.Dispose(); } base.Dispose(); return; }
/// <summary> /// Setup/format a MoleculeGridPanel/MoleculeGrid for display of results for the supplied QueryManager /// </summary> /// <param name="qm"></param> /// <param name="gridPanel"></param> /// <param name="embedDataInQuery"></param> /// <param name="fitDataToGridWidth"></param> public static void SetupGridPanelForDisplay( QueryManager qm, MoleculeGridPanel gridPanel, bool embedDataInQuery = false, bool fitDataToGridWidth = false) { MoleculeGridControl grid = null; bool displayAsNormalQueryResults = (gridPanel == null); // if grid panel not defined assume display is in normal results panel //bool displayAsPopupGrid = (gridPanel != null && gridPanel.Parent is PopupGrid); // display in popup grid Query q = qm.Query; q.SetupQueryPagesAndViews(); // be sure we have a default view page if (embedDataInQuery) { // no database behind this table so persist within the query MetaTable mt = q.Tables[0].MetaTable; // assume just one metatable foreach (MetaColumn mc in mt.MetaColumns) // no criteria allowed { mc.IsSearchable = false; } q.SerializeMetaTablesWithQuery = true; // if no broker then save the metatable definition q.SerializeResultsWithQuery = true; // also save results when saving the query q.BrowseSavedResultsUponOpen = true; // open the results when the query is opened q.ResultsDataTable = qm.DataTable; // point the query to this results table } ResultsFormatFactory rff = new ResultsFormatFactory(qm, OutputDest.WinForms); rff.Build(); // build format ResultsFormatter fmtr = new ResultsFormatter(qm); // and formatter if (displayAsNormalQueryResults) { MoleculeGridPageControl mgpc = MoleculeGridPanel.AllocateNewMoleculeGridPageControl(qm, SessionManager.Instance.QueryResultsControl); gridPanel = mgpc.MoleculeGridPanel; //gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; // (old) QbUtil.AddQuery(qm.Query); // add to the list of visible queries QueriesControl.Instance.CurrentBrowseQuery = qm.Query; // make it current } grid = gridPanel.SelectBaseGridViewGrid(qm); //if (qm.ResultsFormat.UseBandedGridView) // grid = gridPanel.BandedViewGrid; //else grid = gridPanel.LayoutViewGrid; qm.MoleculeGrid = grid; grid.QueryManager = qm; DataTableMx dt = qm.DataTable; // save ref to data table grid.DataSource = null; // clear source for header build if (fitDataToGridWidth && grid.BGV != null) { grid.BGV.OptionsView.ColumnAutoWidth = true; // set view for auto width to fit within view } grid.FormatGridHeaders(qm.ResultsFormat); qm.DataTable = dt; // restore data table qm.DataTableManager.SetResultsKeysFromDatatable(); // set the results keys //if (displayAsNormalQueryResults) // QbUtil.SetMode(QueryMode.Browse); // put into browse mode (need this?) //else if (displayAsPopupGrid) // obsolete //{ // PopupGrid pug = gridPanel.Parent as PopupGrid; // pug.Initialize(qm); // be sure popup is initialized // pug.Show(); //} //gridPanel.Visible = true; //grid.Visible = true; //grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable //RefreshDataDisplay(qm); return; }
/// <summary> /// Display the related counts /// </summary> /// <param name="rss"></param> /// public void DisplayRelatedCidCounts( RelatedStructureSearchResults rss) { int altCnt, mmpCnt, swCnt, simCnt, allMatchCnt; //MoleculeGridPageControl.Width = this.Width - 3; //MoleculeGridPageControl.Height = this.Height - MoleculeGridPageControl.Top - 3; MoleculeGridPageControl mgpc = MoleculeGridPageControl; if (mgpc.EditQueryButton.Visible) // adjust tool panel for proper display { mgpc.EditQueryButton.Visible = false; //mgpc.MarkDataButton.Visible = false; mgpc.FormattingButton.Visible = false; mgpc.AdjustToolPanelButtonSpacing(); } if (rss == null) { DisplayEmptyCidCountsGrid(); return; } altCnt = SetRelatedCidCount(AltForms, SumByDb(rss.AltCorpDbCnt, rss.AltChemblCnt)); // alternate forms mmpCnt = SetRelatedCidCount(MatchedPairs, SumByDb(rss.MmpCorpDbCnt, rss.MmpChemblCnt)); // matched pairs, no ChEMBL for now if (SmallWorldAvailable) { swCnt = SetRelatedCidCount(SmallWorld, SumByDb(rss.SwCorpDbCnt, rss.SwChemblCnt)); // SmallWorld } else { SmallWorld.Checked = false; if (MatchCountsPanel.RowCount == 5) // remove SmallWorld from the MatchCountsPanel { MatchCountsPanel.SetRow(labelControl3, 2); MatchCountsPanel.SetRow(SimilarStructure, 2); MatchCountsPanel.SetRow(labelControl6, 3); MatchCountsPanel.SetRow(AllMatches, 3); MatchCountsPanel.SetRow(SmallWorldLabel, 4); MatchCountsPanel.SetRow(SmallWorld, 4); SmallWorldLabel.Visible = SmallWorld.Visible = false; SmallWorld.Checked = false; MatchCountsPanel.RowCount = 4; } swCnt = 0; } simCnt = SetRelatedCidCount(SimilarStructure, SumByDb(rss.SimCorpDbCnt, rss.SimChemblCnt)); // similar allMatchCnt = SetRelatedCidCount(AllMatches, altCnt + mmpCnt + swCnt + simCnt); // total SetRelatedCidCount(CorpDB, rss.CorpDbCnt); // these values don't change during life of search results SetRelatedCidCount(ChemblDB, rss.ChemblCnt); return; }
/// <summary> /// Format grid and show the data /// </summary> /// <param name="qm"></param> /// <param name="container">Either a QueryResultsControl or a PopupGrid</param> public static void ConfigureAndShow( QueryManager qm, Control container) { QueryResultsControl qrc = null; PopupGrid pug = null; MoleculeGridPageControl page; MoleculeGridPanel panel; MoleculeGridControl grid; Query q = qm.Query; ResultsFormat rf = qm.ResultsFormat; //qm.QueryResultsControl = null; page = new MoleculeGridPageControl(); // Create a new, clean page, panel and grids panel = page.MoleculeGridPanel; grid = panel.SelectBaseGridViewGrid(qm); qm.LinkMember(grid); // link grid into qm grid.ShowCheckMarkCol = q.ShowGridCheckBoxes; DataTableMx dt = qm.DataTable; // save ref to data table grid.DataSource = null; // clear source for header build qm.DataTable = dt; // restore data table grid.FormatGridHeaders(qm.ResultsFormat); // qm.MoleculeGrid.V.Columns.Count should be set for proper cols if (container is QueryResultsControl && rf.NotPopupOutputFormContext) // normal query results { qrc = container as QueryResultsControl; qrc.RemoveExistingControlsFromResultsPageControlContainer(); // properly dispose of any existing DevExpress controls qrc.MoleculeGridPageControl = page; // link query results to this page qrc.ResultsPageControlContainer.Controls.Add(page); page.Dock = DockStyle.Fill; //qm.QueryResultsControl = qrc; // link view set into query manager (used for filtering) if (q.Parent == null) // switch display to browse mode if root query { QbUtil.SetMode(QueryMode.Browse, q); } if (rf.Query.LogicType == QueryLogicType.And) // log grid query by logic type { UsageDao.LogEvent("QueryGridAnd", ""); } else if (rf.Query.LogicType == QueryLogicType.Or) { UsageDao.LogEvent("QueryGridOr", ""); } else if (rf.Query.LogicType == QueryLogicType.Complex) { UsageDao.LogEvent("QueryGridComplex", ""); } } else if (container is PopupGrid || rf.PopupOutputFormContext) // popup results { if (container is PopupGrid) { pug = container as PopupGrid; } else // create a popup { pug = new PopupGrid(qm); pug.Text = q.UserObject.Name; } if (pug.Controls.ContainsKey(panel.Name)) // remove any existing panel control { pug.Controls.RemoveByKey(panel.Name); } pug.Controls.Add(panel); pug.MoleculeGridPanel = panel; // restore direct link as well grid.ScaleView(q.ViewScale); UIMisc.PositionPopupForm(pug); pug.Text = q.UserObject.Name; pug.Show(); } else { throw new Exception("Invalid container type: " + container.GetType()); } // Set the DataSource to the real DataTable panel.SetDataSource(qm, dt); return; }