// public Rectangle PaintReactionSet( // IReactionSet reactionSet, IDrawVisitor drawVisitor) { // // total up the bounding boxes // Rectangle2D totalBounds = CreateRectangle(); // foreach (var reaction in reactionSet.reactions()) { // Rectangle2D modelBounds = BoundsCalculator.CalculateBounds(reaction); // if (totalBounds == null) { // totalBounds = modelBounds; // } else { // totalBounds = totalBounds.CreateUnion(modelBounds); // } // } // // // setup and draw // this.SetupTransformNatural(totalBounds); // ElementGroup diagram = new ElementGroup(); // foreach (var reaction in reactionSet.reactions()) { // diagram.Add(this.GenerateDiagram(reaction)); // } // this.Paint(drawVisitor, diagram); // // // the size of the painted diagram is returned // return this.ConvertToDiagramBounds(totalBounds); // } // // public Rectangle PaintReaction( // IReaction reaction, IDrawVisitor drawVisitor) { // // // calculate the bounds // Rectangle2D modelBounds = BoundsCalculator.CalculateBounds(reaction); // // // setup and draw // this.SetupTransformNatural(modelBounds); // IRenderingElement diagram = this.GenerateDiagram(reaction); // this.Paint(drawVisitor, diagram); // // return this.ConvertToDiagramBounds(modelBounds); // } /// <summary> /// Paint a ChemModel. /// </summary> /// <param name="chemModel"></param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds of the area to paint on.</param> /// <param name="resetCenter">if true, set the modelCenter to the center of the ChemModel's bounds.</param> public void Paint(IChemModel chemModel, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // check for an empty model var moleculeSet = chemModel.MoleculeSet; IReactionSet reactionSet = chemModel.ReactionSet; // nasty, but it seems that reactions can be read in as ChemModels // with BOTH a ReactionSet AND a MoleculeSet... if (moleculeSet == null || reactionSet != null) { if (reactionSet != null) { reactionSetRenderer.Paint(reactionSet, drawVisitor, bounds, resetCenter); } return; } // calculate the total bounding box var modelBounds = BoundsCalculator.CalculateBounds(moleculeSet); this.SetupTransformToFit(bounds, modelBounds, AverageBondLengthCalculator.CalculateAverageBondLength(chemModel), resetCenter); // generate the elements IRenderingElement diagram = moleculeSetRenderer.GenerateDiagram(moleculeSet); // paint it this.Paint(drawVisitor, diagram); }
/// <summary> /// Set the scale for an <see cref="IChemObjectSet{T}"/>. It calculates the average bond length /// of the model and calculates the multiplication factor to transform this /// to the bond length that is set in the RendererModel. /// </summary> /// <param name="moleculeSet">the <see cref="IChemObjectSet{T}"/> for what to set the scale</param> public void SetScale(IChemObjectSet <IAtomContainer> moleculeSet) { double bondLength = AverageBondLengthCalculator.CalculateAverageBondLength(moleculeSet); double scale = this.CalculateScaleForBondLength(bondLength); // store the scale so that other components can access it this.rendererModel.SetScale(scale); }
/// <summary> /// Set the scale for an IReaction. It calculates the average bond length /// of the model and calculates the multiplication factor to transform this /// to the bond length that is set in the RendererModel. /// </summary> /// <param name="reaction"></param> public void SetScale(IReaction reaction) { double bondLength = AverageBondLengthCalculator.CalculateAverageBondLength(reaction); double scale = this.CalculateScaleForBondLength(bondLength); // store the scale so that other components can access it this.rendererModel.SetScale(scale); }
/// <summary> /// Set the scale for an IChemModel. It calculates the average bond length of /// the model and calculates the multiplication factor to transform this /// to the bond length that is set in the RendererModel. /// </summary> /// <param name="chemModel"></param> public void SetScale(IChemModel chemModel) { var bondLength = AverageBondLengthCalculator.CalculateAverageBondLength(chemModel); var scale = this.CalculateScaleForBondLength(bondLength); // store the scale so that other components can access it this.rendererModel.SetScale(scale); }
/// <summary> /// Paint a set of molecules. /// </summary> /// <param name="molecules">the <see cref="IChemObjectSet{T}"/> to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">if true, set the draw center to be the center of bounds</param> public void Paint(IChemObjectSet <IAtomContainer> molecules, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(molecules); this.SetupTransformToFit(bounds, totalBounds, AverageBondLengthCalculator.CalculateAverageBondLength(molecules), resetCenter); IRenderingElement diagram = this.GenerateDiagram(molecules); this.Paint(drawVisitor, diagram); }
/// <summary> /// Paint a reaction. /// </summary> /// <param name="reaction">the reaction to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">/// if true, set the draw center to be the center of bounds</param> public void Paint(IReaction reaction, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // calculate the bounds var modelBounds = BoundsCalculator.CalculateBounds(reaction).Value; this.SetupTransformToFit(bounds, modelBounds, AverageBondLengthCalculator.CalculateAverageBondLength(reaction), resetCenter); // generate the elements var diagram = this.GenerateDiagram(reaction); // paint it this.Paint(drawVisitor, diagram); }
/// <summary> /// Paint a set of reactions. /// </summary> /// <param name="reactionSet">the reaction to paint</param> /// <param name="drawVisitor">the visitor that does the drawing</param> /// <param name="bounds">the bounds on the screen</param> /// <param name="resetCenter">if true, set the draw center to be the center of bounds</param> public void Paint(IReactionSet reactionSet, IDrawVisitor drawVisitor, Rect bounds, bool resetCenter) { // total up the bounding boxes var totalBounds = BoundsCalculator.CalculateBounds(reactionSet); this.SetupTransformToFit(bounds, totalBounds, AverageBondLengthCalculator.CalculateAverageBondLength(reactionSet), resetCenter); ElementGroup diagram = new ElementGroup(); foreach (var reaction in reactionSet) { diagram.Add(reactionRenderer.GenerateDiagram(reaction)); } // paint them all this.Paint(drawVisitor, diagram); }