OEAddSVGClickEventΒΆ

Attention

PRELIMINARY-IMAGE This is a preliminary API until 2018.Feb and may be improved based on user feedback. It is currently available in C++ and Python.

bool OEAddSVGClickEvent(OE2DMolDisplay&, const OE2DAtomDisplay*,
                        const std::string& message);

bool OEAddSVGClickEvent(OE2DMolDisplay&, const OE2DBondDisplay*,
                        const std::string& message);

Creates and interactive .svg image in which atom / bond displays will be associated with and SVG event. When clicking at the position defined by the given atom / bond display the event is triggered with the given message.

Note

This functionality is only available for .svg image format.

See also

disp
The OE2DMolDisplay object that holds the data necessary to depict the molecule with which it is initialized.
adisp
The OE2DAtomDisplay object that defines the mouse click position.
bdisp
The OE2DBondDisplay object that defines the mouse click position
message
The text that will be emitted when an event is triggered on mouse click.

Example for adding event for atom displays

#include <openeye.h>

#include <oesystem.h>
#include <oechem.h>
#include <oedepict.h>

using namespace std;
using namespace OESystem;
using namespace OEChem;
using namespace OEDepict;

int main()
{
  const unsigned int width  = 400;
  const unsigned int height = 200;

  OEImage image(width, height);

  OEGraphMol mol;
  OESmilesToMol(mol, "Cc1cccnc1/C=C/[C@H](C(=O)O)O");
  OEPrepareDepiction(mol);

  OE2DMolDisplayOptions opts(width, height, OEScale::AutoScale);
  OE2DMolDisplay disp(mol, opts);

  for (OEIter<OE2DAtomDisplay> ai = disp.GetAtomDisplays(); ai; ++ai)
  {
    const OE2DAtomDisplay* adisp = ai;
    const OEAtomBase* atom = adisp->GetAtom();
    const string message = "atom idx=" + OENumberToString(atom->GetIdx());
    OEAddSVGClickEvent(disp, adisp, message);
  }
  OERenderMolecule("AddAtomClickEvent.svg", disp);

  return 0;
}

Download code

AddAtomClickEvent.cpp

Example for adding event for bond displays

#include <openeye.h>

#include <oesystem.h>
#include <oechem.h>
#include <oedepict.h>

using namespace std;
using namespace OESystem;
using namespace OEChem;
using namespace OEDepict;

int main()
{
  const unsigned int width  = 400;
  const unsigned int height = 200;

  OEImage image(width, height);

  OEGraphMol mol;
  OESmilesToMol(mol, "Cc1cccnc1/C=C/[C@H](C(=O)O)O");
  OEPrepareDepiction(mol);

  OE2DMolDisplayOptions opts(width, height, OEScale::AutoScale);
  OE2DMolDisplay disp(mol, opts);

  for (OEIter<OE2DBondDisplay> bi = disp.GetBondDisplays(); bi; ++bi)
  {
    const OE2DBondDisplay* bdisp = bi;
    const OEBondBase* bond = bdisp->GetBond();
    const string message = "bond idx=" + OENumberToString(bond->GetIdx());
    OEAddSVGClickEvent(disp, bdisp, message);
  }
  OERenderMolecule("AddBondClickEvent.svg", disp);

  return 0;
}

Download code

AddBondClickEvent.cpp

See also