Skip to content

Commit

Permalink
Instantiate nodata edom on supersize to lower memory needs
Browse files Browse the repository at this point in the history
on files with numerours attrs.  Delete on regularsize
  • Loading branch information
ColinTalbert committed May 4, 2018
1 parent ea4aa26 commit f52bb86
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 21 deletions.
54 changes: 37 additions & 17 deletions pymdwizard/gui/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, parent=None):
self.ef = 0

self.nodata = None
self.nodata_edom = edom.Edom()
self.nodata_content = (False, None) # nodata checked, last nodata node

WizardWidget.__init__(self, parent=parent)

Expand Down Expand Up @@ -129,10 +129,9 @@ def build_ui(self):
self.ui.fgdc_attrdefs.mousePressEvent = self.attrdefs_press
self.ui.comboBox.mousePressEvent = self.combo_press
self.ui.rbtn_nodata_yes.toggled.connect(self.include_nodata_change)
self.nodata_edom.ui.fgdc_edomv.textChanged.connect(self.nodata_changed)

self.domain = None
self.ui.nodata_content.hide()
self.ui.nodata_content.layout().addWidget(self.nodata_edom)
self.ui.rbtn_nodata_no.setChecked(True)
self.ui.comboBox.setCurrentIndex(3)

Expand All @@ -149,13 +148,12 @@ def include_nodata_change(self, b):
None
"""
if b:
# self.ui.nodata_section.show()
self.nodata
self.nodata_edom.show()
self.ui.nodata_section.show()
# self.nodata
# self.nodata_edom.show()
else:
# self.ui.nodata_section.hide()
self.nodata_edom.hide()
self.nodata = None
self.ui.nodata_section.hide()
# self.nodata = None

def mousePressEvent(self, event):
self.activate()
Expand All @@ -181,6 +179,11 @@ def clear_domain(self):
if isinstance(child, QWidget):
child.deleteLater()

try:
self.nodata_edom.deleteLater()
except:
pass

def set_series(self, series):
"""
store a series with this attri
Expand Down Expand Up @@ -248,6 +251,12 @@ def store_current_content(self):
elif cur_xml.tag == 'attr':
self._domain_content[0] = cur_xml

if self.ui.rbtn_nodata_yes.isChecked():
self.nodata_content = (True, self.nodata_edom.to_xml())
else:
self.nodata_content = (False, self.nodata_edom.to_xml())


def populate_domain_content(self, which='guess'):
"""
Fill out this widget with the content from it's associated series
Expand Down Expand Up @@ -353,11 +362,19 @@ def supersize_me(self):
self.animation.setEndValue(QSize(345, self.height()))
self.animation.start()
self.ui.attrdomv_contents.show()
self.ui.nodata_content.show()
self.ui.place_holder.hide()
cbo = self.ui.comboBox
self.populate_domain_content(cbo.currentIndex())

self.ui.nodata_content.show()
self.nodata_edom = edom.Edom()
self.ui.rbtn_nodata_yes.setChecked(self.nodata_content[0])
if self.nodata_content[1] is not None:
self.nodata_edom.from_xml(self.nodata_content[1])

self.nodata_edom.ui.fgdc_edomv.textChanged.connect(self.nodata_changed)
self.ui.nodata_section.layout().addWidget(self.nodata_edom)

def regularsize_me(self):
"""
Collapse this attribute and hide it's content
Expand Down Expand Up @@ -419,15 +436,18 @@ def sniff_nodata(self):
if nd in list(uniques):
self.nodata = nd

if self.nodata is not None:
self.ui.rbtn_nodata_yes.setChecked(True)
if self.nodata is None:
self.nodata_content = (False, self.nodata_content[1])
else:
temp_edom = edom.Edom()
if self.nodata == '':
self.nodata_edom.ui.fgdc_edomv.setText('<< empty cell >>')
temp_edom.ui.fgdc_edomv.setText('<< empty cell >>')
else:
self.nodata_edom.ui.fgdc_edomv.setText(str(self.nodata))
temp_edom.ui.fgdc_edomv.setText(str(self.nodata))

self.nodata_edom.ui.fgdc_edomvd.setPlainText('No Data')
self.clean_domain_nodata()
temp_edom.ui.fgdc_edomvd.setPlainText('No Data')
self.nodata_content = (True, temp_edom.to_xml())
temp_edom.deleteLater()

def contextMenuEvent(self, event):

Expand Down Expand Up @@ -586,7 +606,7 @@ def from_xml(self, attr):
if attrdomv.children[0].tag == 'edom' and \
(attrdomv.children[0].children[0].text in self.nodata_matches or \
attrdomv.children[0].children[1].text.lower() in ['nodata', 'no data']
or attr_domains.count('edom')==1):
or (attr_domains.count('edom')==1) and len(attr_domains) > 1):
self.ui.rbtn_nodata_yes.setChecked(True)
self.nodata_edom.from_xml(attrdomv.children[0].to_xml())
attrdomvs.remove(attrdomv)
Expand Down
8 changes: 6 additions & 2 deletions pymdwizard/gui/ui_files/UI_edom.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setupUi(self, fgdc_attrdomv):
self.widget_3.setObjectName("widget_3")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_3)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setSpacing(0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.fgdc_edomv = QtWidgets.QLineEdit(self.widget_3)
self.fgdc_edomv.setText("")
Expand Down Expand Up @@ -97,7 +98,7 @@ def setupUi(self, fgdc_attrdomv):
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.fgdc_edomvd.sizePolicy().hasHeightForWidth())
self.fgdc_edomvd.setSizePolicy(sizePolicy)
self.fgdc_edomvd.setMinimumSize(QtCore.QSize(0, 30))
self.fgdc_edomvd.setMinimumSize(QtCore.QSize(0, 45))
self.fgdc_edomvd.setObjectName("fgdc_edomvd")
self.horizontalLayout_9.addWidget(self.fgdc_edomvd)
self.label_25 = QtWidgets.QLabel(self.widget)
Expand Down Expand Up @@ -129,7 +130,8 @@ def setupUi(self, fgdc_attrdomv):
self.widget_2.setSizePolicy(sizePolicy)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setContentsMargins(0, 4, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label_22 = QtWidgets.QLabel(self.widget_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
Expand All @@ -143,6 +145,8 @@ def setupUi(self, fgdc_attrdomv):
self.label_22.setIndent(0)
self.label_22.setObjectName("label_22")
self.horizontalLayout.addWidget(self.label_22)
spacerItem = QtWidgets.QSpacerItem(4, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.fgdc_edomvds = QtWidgets.QLineEdit(self.widget_2)
self.fgdc_edomvds.setObjectName("fgdc_edomvds")
self.horizontalLayout.addWidget(self.fgdc_edomvds)
Expand Down
26 changes: 24 additions & 2 deletions pymdwizard/gui/ui_files/edom.ui
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
Expand Down Expand Up @@ -208,7 +211,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>45</height>
</size>
</property>
</widget>
Expand Down Expand Up @@ -274,11 +277,14 @@
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
Expand Down Expand Up @@ -320,6 +326,22 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>4</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="fgdc_edomvds">
<property name="text">
Expand Down
8 changes: 8 additions & 0 deletions pymdwizard/resources/spelling/words.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
microhabitats
microhabitat
geodatabase
georeferenced
arcgis
translocation
translocations
email
dendrochronology
borers
intraguild
Expand Down

0 comments on commit f52bb86

Please sign in to comment.