Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rdeditor/molViewWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def __init__(self, mol=None, parent=None, moldrawoptions: rdMolDraw2D.MolDrawOpt
self.sanitizeSignal.connect(self.changeSanitizeStatus)

# Initialize class with the mol passed
self.scale = 1
self.mol = mol
self.setMinimumSize(300, 300)

##Properties and their wrappers
@property
Expand Down Expand Up @@ -241,6 +243,14 @@ def changeSanitizeStatus(self, value):
else:
self.molecule_sanitizable = False

def resizeEvent(self, event):
super().resizeEvent(event)
self.draw()

def setScale(self, scale):
self.scale = scale
self.draw()

def computeNewCoords(self, ignoreExisting=False, canonOrient=False):
"""Computes new coordinates for the molecule taking into account all
existing positions (feeding these to the rdkit coordinate generation as
Expand Down Expand Up @@ -333,7 +343,8 @@ def sanitizeDrawMol(self, kekulize=False, drawkekulize=False):
finishedDrawing = QtCore.Signal(name="finishedDrawing")

def getMolSvg(self):
self.drawer = rdMolDraw2D.MolDraw2DSVG(300, 300)
width, height = int(self.width() / self.scale), int(self.height() / self.scale)
self.drawer = rdMolDraw2D.MolDraw2DSVG(width, height)
# TODO, what if self._drawmol doesn't exist?
if self._drawmol is not None:
# Chiral tags on R/S
Expand Down
7 changes: 6 additions & 1 deletion rdeditor/rdEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def initGUI(self, fileName=None):
self.setGeometry(100, 100, 200, 150)

self.center = self.editor
self.center.setFixedSize(650, 650)
self.setCentralWidget(self.center)
self.fileName = fileName

Expand Down Expand Up @@ -289,6 +288,12 @@ def CreateToolBars(self):
self.mainToolBar.addAction(self.saveAction)
self.mainToolBar.addAction(self.saveAsAction)
self.mainToolBar.addSeparator()
self.scalewidget = QtWidgets.QComboBox()
self.scalewidget.addItems(["75%", "100%", "125%", "150%", "175%", "200%"])
self.scalewidget.setCurrentIndex(1)
self.scalewidget.currentIndexChanged.connect(lambda: self.editor.setScale(float(self.scalewidget.currentText().strip('%'))/100))
self.mainToolBar.addWidget(self.scalewidget)
self.mainToolBar.addSeparator()
self.mainToolBar.addAction(self.selectAction)
self.mainToolBar.addAction(self.addAction)
# self.mainToolBar.addAction(self.addBondAction)
Expand Down