Changeset 828
- Timestamp:
- Feb 2, 2005, 11:31:04 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/pmesh.py
r825 r828 20 20 APPLICATION_NAME = 'Pmesh' 21 21 SET_COLOUR = 'red' 22 DEFAULT_ATTRIBUTE = 'elevation' 22 23 23 24 NO_SELECTION = 0 … … 213 214 ('threshold', self.threshold, 'threshold the set'), 214 215 ('Courant_threshold', self.Courant_threshold, 'Courant_threshold the set'), 215 ('polyset', self.triangles_to_polySet, 'make a poly set out of selected triangles'), 216 ('refineSet', self.refineSet, 'Refine the set')]: 216 ('gradient_threshold', self.gradient_threshold, 'gradient_threshold the set'), 217 ('polyset', self.triangles_to_polySet, 'make a poly set out of selected triangles')]: 218 #('refineSet', self.refineSet, 'Refine the set')]: 217 219 ToolBarButton(self, self.toolbar, key, '%s.gif' %key, 218 220 command=func, balloonhelp=balloon, … … 257 259 self.visualiseMesh(self.mesh) 258 260 259 260 261 def threshold(self, parent): 261 def general_threshold(self,parent,function,function_description): 262 262 """ 263 263 add a vertex using a window and entering x y values. … … 270 270 self.selectAllTriangles(parent) 271 271 272 dialog = ThresholdDialog(self.canvas)272 dialog = GeneralThresholdDialog(self.canvas,self.mesh.attributeTitles,function_description) 273 273 if dialog.minmaxValuesOk: 274 274 self.canvas.delete(ALL) 275 self.mesh.threshold(self.selSet,min=dialog.min,max=dialog.max) 275 min = dialog.min 276 max = dialog.max 277 attribute_name = dialog.attribute_name 278 self.mesh.general_threshold(self.selSet,min=min,max=max,attribute_name = attribute_name,function=function) 276 279 self.visualiseMesh(self.mesh) 277 280 278 def Courant_threshold(self, parent):281 def threshold(self, parent): 279 282 """ 280 283 add a vertex using a window and entering x y values. … … 284 287 get rid of it. 285 288 """ 286 if self.selSet == 'None': 287 self.selectAllTriangles(parent) 288 289 dialog = Courant_ThresholdDialog(self.canvas) 290 if dialog.minmaxValuesOk: 291 self.canvas.delete(ALL) 292 self.mesh.Courant_threshold(self.selSet,min=dialog.min,max=dialog.max) 293 self.visualiseMesh(self.mesh) 294 289 function = self.mesh.av_att 290 function_description = 'average attribute of triangle' 291 self.general_threshold(parent,function,function_description) 292 293 294 def Courant_threshold(self, parent): 295 """ 296 add a vertex using a window and entering x y values. 297 298 the parent attribute isn't used by this function. 299 need to userstand toolbarbutton.py to know how to 300 get rid of it. 301 """ 302 function = self.mesh.Courant_ratio 303 function_description = 'average attribute/area of triangle' 304 self.general_threshold(parent,function,function_description) 305 306 def gradient_threshold(self, parent): 307 """ 308 add a vertex using a window and entering x y values. 309 310 the parent attribute isn't used by this function. 311 need to userstand toolbarbutton.py to know how to 312 get rid of it. 313 """ 314 function = self.mesh.Gradient 315 function_description = 'average gradient of triangle' 316 self.general_threshold(parent,function,function_description) 295 317 296 318 def triangles_to_polySet(self,parent): … … 1463 1485 showerror('Bad mesh generation values', 1464 1486 'Values are out of range.') 1465 1466 1467 class ThresholdDialog(Dialog): 1487 class GeneralThresholdDialog(Dialog): 1468 1488 """ 1469 1489 Dialog box for thresholding a set by entering minimum 1470 1490 and maximum values 1471 1491 """ 1492 def __init__(self, 1493 parent, 1494 attribute_titles, 1495 function_description): 1496 self.attribute_titles=attribute_titles 1497 self.function_description=function_description 1498 1499 Dialog.__init__(self, parent) 1500 1501 1472 1502 def body(self, master): 1473 1503 """ … … 1475 1505 """ 1476 1506 self.title("Threshold selected set") 1477 1478 Label(master, text='minimum attribute:').grid(row=0, sticky=W) 1479 Label(master, text='maximum attribute:').grid(row=1, sticky=W) 1480 1481 self.minstr = Entry(master, width = 16, name ="entry") 1482 self.maxstr = Entry(master, width = 16) 1507 blurb1 = 'Threshold selected set between minimum' 1508 blurb2 = 'and maximum ' + self.function_description 1509 1510 Label(master,text=blurb1).grid(row=0, sticky=W) 1511 Label(master,text=blurb2).grid(row=1, sticky=W) 1512 1513 Label(master, text='minimum attribute:').grid(row=2, sticky=W) 1514 Label(master, text='maximum attribute:').grid(row=3, sticky=W) 1515 Label(master, text='attribute name').grid(row=4, sticky=W) 1516 1517 1518 nameVar = StringVar() 1519 nameVar.set('elevation') 1520 1521 self.minstr = Entry(master, width = 16, name ="entry") 1522 self.maxstr = Entry(master, width = 16) 1523 self.attstr = Entry(master, width = 16,textvariable = nameVar) 1483 1524 1484 self.minstr.grid(row=0, column=1, sticky=W) 1485 self.maxstr.grid(row=1, column=1, sticky=W) 1525 self.minstr.grid(row=2, column=1, sticky=W) 1526 self.maxstr.grid(row=3, column=1, sticky=W) 1527 self.attstr.grid(row=4, column=1, sticky=W) 1486 1528 self.minstr.focus_force() 1487 1529 self.min = 0 1488 1530 self.max = 0 1531 self.attribute_name = 'elevation' 1489 1532 self.minmaxValuesOk = False 1490 1533 … … 1495 1538 self.max = float(self.maxstr.get()) 1496 1539 except ValueError: 1497 self. ValuesOk = False1540 self.minmaxValuesOk = False 1498 1541 showerror('Bad mesh generation values', 1499 1542 ' Values are not numbers.') 1500 1501 1502 class Courant_ThresholdDialog(Dialog): 1543 try: 1544 self.attribute_titles.index(self.attstr.get())#dodgey. 1545 self.attribute_name = self.attstr.get() 1546 except ValueError: 1547 self.minmaxValuesOk = False 1548 showerror('Bad attribute name', 1549 ' Attribute not in mesh.') 1550 1551 class ThresholdDialog(Dialog): 1503 1552 """ 1504 Dialog box for Courant_thresholding a set by entering minimum1553 Dialog box for thresholding a set by entering minimum 1505 1554 and maximum values 1506 1555 """ 1556 def __init__(self, 1557 parent, 1558 attribute_titles): 1559 self.attribute_titles=attribute_titles 1560 Dialog.__init__(self, parent) 1561 1562 1507 1563 def body(self, master): 1508 1564 """ 1509 1565 GUI description 1510 1566 """ 1511 self.title(" Courant_Threshold selected set")1567 self.title("Threshold selected set") 1512 1568 1513 1569 Label(master, text='minimum attribute:').grid(row=0, sticky=W) 1514 1570 Label(master, text='maximum attribute:').grid(row=1, sticky=W) 1571 Label(master, text='attribute name').grid(row=2, sticky=W) 1572 1573 1574 nameVar = StringVar() 1575 nameVar.set('elevation') 1515 1576 1516 1577 self.minstr = Entry(master, width = 16, name ="entry") 1517 1578 self.maxstr = Entry(master, width = 16) 1579 self.attstr = Entry(master, width = 16,textvariable = nameVar) 1518 1580 1519 1581 self.minstr.grid(row=0, column=1, sticky=W) 1520 1582 self.maxstr.grid(row=1, column=1, sticky=W) 1583 self.attstr.grid(row=2, column=1, sticky=W) 1521 1584 self.minstr.focus_force() 1522 1585 self.min = 0 1523 1586 self.max = 0 1587 self.attribute_name = 'elevation' 1524 1588 self.minmaxValuesOk = False 1525 1589 … … 1530 1594 self.max = float(self.maxstr.get()) 1531 1595 except ValueError: 1532 self. ValuesOk = False1596 self.minmaxValuesOk = False 1533 1597 showerror('Bad mesh generation values', 1534 1598 ' Values are not numbers.') 1599 try: 1600 self.attribute_titles.index(self.attstr.get())#dodgey. 1601 self.attribute_name = self.attstr.get() 1602 except ValueError: 1603 self.minmaxValuesOk = False 1604 showerror('Bad attribute name', 1605 ' Attribute not in mesh.') 1606 1607 1608 class Courant_ThresholdDialog(Dialog): 1609 """ 1610 Dialog box for thresholding a set by entering minimum 1611 and maximum values 1612 """ 1613 def __init__(self, 1614 parent, 1615 attribute_titles): 1616 self.attribute_titles=attribute_titles 1617 Dialog.__init__(self, parent) 1618 1619 1620 def body(self, master): 1621 """ 1622 GUI description 1623 """ 1624 self.title("Courant_Threshold selected set") 1625 1626 Label(master, text='minimum attribute:').grid(row=0, sticky=W) 1627 Label(master, text='maximum attribute:').grid(row=1, sticky=W) 1628 Label(master, text='attribute name').grid(row=2, sticky=W) 1629 1630 1631 nameVar = StringVar() 1632 nameVar.set('elevation') 1633 1634 self.minstr = Entry(master, width = 16, name ="entry") 1635 self.maxstr = Entry(master, width = 16) 1636 self.attstr = Entry(master, width = 16,textvariable = nameVar) 1637 1638 self.minstr.grid(row=0, column=1, sticky=W) 1639 self.maxstr.grid(row=1, column=1, sticky=W) 1640 self.attstr.grid(row=2, column=1, sticky=W) 1641 self.minstr.focus_force() 1642 self.min = 0 1643 self.max = 0 1644 self.attribute_name = 'elevation' 1645 self.minmaxValuesOk = False 1646 1647 def apply(self): 1648 self.minmaxValuesOk = True 1649 try: 1650 self.min = float(self.minstr.get()) 1651 self.max = float(self.maxstr.get()) 1652 except ValueError: 1653 self.minmaxValuesOk = False 1654 showerror('Bad mesh generation values', 1655 ' Values are not numbers.') 1656 try: 1657 self.attribute_titles.index(self.attstr.get())#dodgey. 1658 self.attribute_name = self.attstr.get() 1659 except ValueError: 1660 self.minmaxValuesOk = False 1661 showerror('Bad attribute name', 1662 ' Attribute not in mesh.') 1535 1663 1536 1664
Note: See TracChangeset
for help on using the changeset viewer.