Skip to content

Commit

Permalink
Added initial Design of Root and Precision fields to layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamelsawaf committed Apr 28, 2017
1 parent 5fae4a8 commit e45091c
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 25 deletions.
19 changes: 17 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def __init__(self, ):
self.setupUi(self)
self.fig1 = Figure()
self.plt = self.fig1.add_subplot(111)
self.plt.grid(true)
# self.plt.axis([-6, 6, -1, 1])
self.plt.autoscale(true, tight=false)
self.resultsTabWidget.clear()
# self.mTw.addWidget()
self.rootField.setReadOnly(True)
self.precisionField.setReadOnly(True)

def drawFig(self, fig):
self.canvas = FigureCanvas(fig)
Expand All @@ -40,7 +46,6 @@ def plotFunctions(self, functions):
xs = np.arange(-100.0, 100.0, 0.1)
for function in functions:
self.plt.plot(xs, function(xs), c=np.random.rand(3, 1))
self.plt.axis([-6, 6, -1, 1])
self.drawFig(self.fig1)

def plotVLines(self, vLines):
Expand Down Expand Up @@ -76,12 +81,22 @@ def drawTable(self, table):
qTable.setItem(row, column,
QtGui.QTableWidgetItem(str(('%g' % table.getData()[row][column]))))

def drawRoot(self, root):
assert type(root) is float or int, "root is not of type float nor int!: " + str(type(root))
self.rootField.setText(str(root))

def drawPrecision(self, precision):
assert type(precision) is float or int, "precision is not of type float nor int!: " + str(type(precision))
self.precisionField.setText(str(precision))

def drawResultSet(self, resultSet):
assert type(resultSet) is ResultSet, "table is not of type Table!: " + str(type(resultSet))
self.plotFunctions(resultSet.getEquations())
self.plotHLines(resultSet.getHLines())
self.plotVLines(resultSet.getVLines())
self.drawTable(resultSet.getTable())
self.drawRoot(resultSet.getRoot())
self.drawPrecision(resultSet.getPrecision())


if __name__ == '__main__':
Expand All @@ -90,6 +105,6 @@ def drawResultSet(self, resultSet):
app = QtGui.QApplication(sys.argv)
main = Main()
main.show()
main.drawResultSet(bisection(0.00, 0.11, parseExpr("x^3 - 0.165x^2 + 10^-4")))
main.drawResultSet(bisection(0, 0.5, parseExpr("x^3 - 0.165x^2 ")))

sys.exit(app.exec_())
104 changes: 81 additions & 23 deletions window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -236,32 +236,90 @@
</widget>
</item>
<item row="7" column="0">
<widget class="QTabWidget" name="resultsTabWidget">
<property name="minimumSize">
<size>
<width>245</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="table1Tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="rTw">
<item>
<widget class="QTabWidget" name="resultsTabWidget">
<property name="minimumSize">
<size>
<width>245</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="table1Tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="resultsTable"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="table2Tab">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel">
<property name="text">
<string>Root</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="resultsTable"/>
<widget class="QLineEdit" name="rootField">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="table2Tab">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel">
<property name="text">
<string>Precision</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="precisionField">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down

0 comments on commit e45091c

Please sign in to comment.