public void TestSquareMolecule() { IAtomContainer square = MakeSquare(); var generators = new List <IGenerator <IAtomContainer> > { new BasicSceneGenerator(), new BasicBondGenerator() }; BasicAtomGenerator atomGenerator = new BasicAtomGenerator(); generators.Add(atomGenerator); AtomContainerRenderer renderer = new AtomContainerRenderer(generators, new WPFFontManager()); RendererModel model = renderer.GetRenderer2DModel(); model.SetCompactShape(AtomShapeType.Oval); model.SetCompactAtom(true); model.SetKekuleStructure(true); model.SetShowEndCarbons(true); ElementUtility visitor = new ElementUtility(); var screen = new Rect(0, 0, 100, 100); renderer.Setup(square, screen); renderer.Paint(square, visitor); foreach (var element in visitor.GetElements()) { Assert.IsTrue(visitor.ToString(element).Contains("Line") || visitor.ToString(element).Contains("Oval")); } }
protected internal ReactionSetRenderer(RendererModel rendererModel, IEnumerable <IGenerator <IAtomContainer> > generators, IEnumerable <IGenerator <IReaction> > reactionGenerators, IFontManager fontManager) : base(rendererModel) { this.fontManager = fontManager; reactionRenderer = new ReactionRenderer(generators, reactionGenerators, fontManager); this.Setup(); }
public ReactionSetRenderer(RendererModel rendererModel, IEnumerable <IGenerator <IAtomContainer> > generators, IFontManager fontManager) : base(rendererModel) { this.fontManager = fontManager; reactionRenderer = new ReactionRenderer(rendererModel, generators, fontManager); this.Setup(); }
public void TestMerge() { RendererModel model = new RendererModel(); Assert.IsNotNull(model.Merge); // any further testing I can do here? }
public MoleculeSetRenderer(RendererModel rendererModel, IEnumerable <IGenerator <IAtomContainer> > generators, IFontManager fontManager) : base(rendererModel) { this.fontManager = fontManager; atomContainerRenderer = new AtomContainerRenderer(rendererModel, generators, fontManager); this.generators = Array.Empty <IGenerator <IChemObjectSet <IAtomContainer> > >(); this.Setup(); }
public void TestNoDefaultToolTips() { RendererModel model = new RendererModel(); // test: no default tool tips Assert.IsNull(model.GetToolTipText(new Atom())); // but a non-null map Assert.IsNotNull(model.GetToolTipTextMap()); }
public void TestGetSetNotification() { RendererModel model = new RendererModel(); // test the default setting Assert.IsTrue(model.Notification); model.Notification = false; Assert.IsFalse(model.Notification); model.Notification = true; Assert.IsTrue(model.Notification); }
public void TestToolTipFunctionality() { var tips = new Dictionary <IAtom, string>(); IAtom anonAtom = new Atom(); tips[anonAtom] = "Repelsteeltje"; RendererModel model = new RendererModel(); model.SetToolTipTextMap(tips); Assert.AreEqual(tips, model.GetToolTipTextMap()); Assert.AreEqual("Repelsteeltje", model.GetToolTipText(anonAtom)); }
public void TestHighlightedAtom() { RendererModel model = new RendererModel(); // test default Assert.IsNull(model.GetHighlightedAtom()); IAtom content = new Atom(); model.SetHighlightedAtom(content); Assert.AreEqual(content, model.GetHighlightedAtom()); model.SetHighlightedAtom(null); Assert.IsNull(model.GetHighlightedAtom()); }
public void TestExternalSelectedPart() { RendererModel model = new RendererModel(); // test default Assert.IsNull(model.GetExternalSelectedPart()); IAtomContainer content = new AtomContainer(); model.SetExternalSelectedPart(content); Assert.AreEqual(content, model.GetExternalSelectedPart()); model.SetExternalSelectedPart(null); Assert.IsNull(model.GetExternalSelectedPart()); }
public void TestSelection() { RendererModel model = new RendererModel(); // test default Assert.IsNull(model.GetSelection()); IChemObjectSelection content = new MockSelection(); model.SetSelection(content); Assert.AreEqual(content, model.GetSelection()); model.SetSelection(null); Assert.IsNull(model.GetSelection()); }
public void TestListening() { RendererModel model = new RendererModel(); // test default MockListener listener = new MockListener(); model.Listeners.Add(listener); Assert.IsFalse(listener.IsChanged); model.OnStateChanged(null); Assert.IsTrue(listener.IsChanged); // test unregistering listener.IsChanged = false; Assert.IsFalse(listener.IsChanged); model.Listeners.Remove(listener); model.OnStateChanged(null); Assert.IsFalse(listener.IsChanged); }
public void IupacCarbonParallel() { IAtom a1 = new Atom("C"); IAtom a2 = new Atom("C"); IAtom a3 = new Atom("C"); a1.Point2D = new Vector2(0, 0); a2.Point2D = new Vector2(0, -0.5); a3.Point2D = new Vector2(0, 0.5); IBond bond1 = new Bond(a1, a2); IBond bond2 = new Bond(a1, a3); a1.ImplicitHydrogenCount = 2; a2.ImplicitHydrogenCount = 3; a3.ImplicitHydrogenCount = 3; var model = new RendererModel(); Assert.IsTrue(SymbolVisibility.IupacRecommendations.Visible(a1, new[] { bond1, bond2 }, model)); }
/// <inheritdoc/> public override bool Visible(IAtom atom, IEnumerable <IBond> bonds_, RendererModel model) { var bonds = bonds_.ToList(); // all non-carbons are displayed if (atom.AtomicNumber != AtomicNumbers.Carbon) { return(true); } // methane if (bonds.Count == 0) { return(true); } // methyl (optional) if (bonds.Count == 1 && terminal) { return(true); } // abnormal valence, could be due to charge or unpaired electrons if (!IsFourValent(atom, bonds)) { return(true); } // charge, normally caught by previous rule but can have bad input: C=[CH-]C if (atom.FormalCharge != null && atom.FormalCharge != 0) { return(true); } // carbon isotopes are displayed var mass = atom.MassNumber; if (mass != null) { return(true); } // no kink between bonds to imply the presence of a carbon and it must // be displayed if the bonds have the same bond order if (bonds.Count == 2 && bonds[0].Order == bonds[1].Order) { var bndord = bonds[0].Order; if (bndord == BondOrder.Double || HasParallelBonds(atom, bonds)) { return(true); } } // special case ethane if (bonds.Count == 1) { var begHcnt = atom.ImplicitHydrogenCount; var end = bonds[0].GetOther(atom); var endHcnt = end.ImplicitHydrogenCount; if (begHcnt != null && endHcnt != null && begHcnt == 3 && endHcnt == 3) { return(true); } } // ProblemMarker ? return(false); }
public override bool Visible(IAtom atom, IEnumerable <IBond> neighbors, RendererModel model) => true;
/// <summary> /// Determine if an atom with the specified bonds is visible. /// </summary> /// <param name="atom">an atom</param> /// <param name="neighbors">neighboring bonds</param> /// <returns>whether the atom symbol is visible</returns> public abstract bool Visible(IAtom atom, IEnumerable <IBond> neighbors, RendererModel model);
public AtomContainerRenderer(RendererModel rendererModel, IEnumerable <IGenerator <IAtomContainer> > generators, IFontManager fontManager) : base(rendererModel) { this.generators = generators.ToList(); this.fontManager = fontManager; }
public AbstractRenderer(RendererModel rendererModel) { this.rendererModel = rendererModel; }
public IRenderingElement Generate(IChemObject obj, RendererModel model) => null;