/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/classifier.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/classifier.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2200 by jan, Fri May 7 20:20:43 2004 UTC revision 2376 by jan, Sun Oct 3 21:23:25 2004 UTC
# Line 331  class ClassTable(wxPyGridTableBase): Line 331  class ClassTable(wxPyGridTableBase):
331    
332          row = -1          row = -1
333          self.clazz = clazz          self.clazz = clazz
334    
335          self.__NotifyRowChanges(old_len, self.GetNumberRows())          self.__NotifyRowChanges(old_len, self.GetNumberRows())
336    
337          #          #
# Line 439  class ClassTable(wxPyGridTableBase): Line 439  class ClassTable(wxPyGridTableBase):
439          """          """
440    
441          self.SetValueAsCustom(row, col, None, value)          self.SetValueAsCustom(row, col, None, value)
442          
443      def GetValueAsCustom(self, row, col, typeName):      def GetValueAsCustom(self, row, col, typeName):
444          """Return the object that is used to represent the given          """Return the object that is used to represent the given
445             cell coordinates. This may not be a string.             cell coordinates. This may not be a string.
446    
447          typeName -- unused, but needed to overload wxPyGridTableBase          typeName -- unused, but needed to overload wxPyGridTableBase
448          """          """
449    
# Line 685  class Classifier(NonModalNonParentDialog Line 685  class Classifier(NonModalNonParentDialog
685                     FIELDTYPE_INT:    _("Integer"),                     FIELDTYPE_INT:    _("Integer"),
686                     FIELDTYPE_DOUBLE: _("Decimal")}                     FIELDTYPE_DOUBLE: _("Decimal")}
687    
688      def __init__(self, parent, name, map, layer, group = None):      def __init__(self, parent, name, layer, group = None):
689          """Create a Properties/Classification dialog for a layer.          """Create a Properties/Classification dialog for a layer.
690          The layer is part of map. If group is not None, select that          The layer is part of map. If group is not None, select that
691          group in the classification table.          group in the classification table.
# Line 697  class Classifier(NonModalNonParentDialog Line 697  class Classifier(NonModalNonParentDialog
697    
698          self.parent.Subscribe(MAP_REPLACED, self.map_replaced)          self.parent.Subscribe(MAP_REPLACED, self.map_replaced)
699          self.layer = layer          self.layer = layer
700          self.map = map          self.map = parent.Map()
701    
702          self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)          self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)
703          self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED,          self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED,
# Line 915  class Classifier(NonModalNonParentDialog Line 915  class Classifier(NonModalNonParentDialog
915              table.SetValueAsCustom(row, COL_SYMBOL, None, new_prop)              table.SetValueAsCustom(row, COL_SYMBOL, None, new_prop)
916          self.Enable(True)          self.Enable(True)
917          propDlg.Destroy()          propDlg.Destroy()
918            
919      def _SetClassification(self, clazz):      def _SetClassification(self, clazz):
920          """Called from the ClassGen dialog when a new classification has          """Called from the ClassGen dialog when a new classification has
921          been created and should be set in the table.          been created and should be set in the table.
922          """          """
923          # FIXME: This could be implemented using a message          # FIXME: This could be implemented using a message
924            
925          self.fields.SetClientData(self.__cur_field, clazz)          self.fields.SetClientData(self.__cur_field, clazz)
926          self.classGrid.GetTable().SetClassification(clazz)          self.classGrid.GetTable().SetClassification(clazz)
927    
# Line 1266  class SelectPropertiesDialog(wxDialog): Line 1266  class SelectPropertiesDialog(wxDialog):
1266          topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10)          topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10)
1267    
1268          button_ok.SetDefault()          button_ok.SetDefault()
1269                                                                                    
1270          #EVT_BUTTON(self, wxID_OK, self._OnOK)          #EVT_BUTTON(self, wxID_OK, self._OnOK)
1271          #EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)          #EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)
1272                                                                                    
1273          self.SetAutoLayout(True)          self.SetAutoLayout(True)
1274          self.SetSizer(topBox)          self.SetSizer(topBox)
1275          topBox.Fit(self)          topBox.Fit(self)
# Line 1296  class SelectPropertiesDialog(wxDialog): Line 1296  class SelectPropertiesDialog(wxDialog):
1296          dialog.Destroy()          dialog.Destroy()
1297    
1298          return ret          return ret
1299            
1300      def _OnChangeLineColor(self, event):      def _OnChangeLineColor(self, event):
1301          clr = self.__GetColor(self.prop.GetLineColor())          clr = self.__GetColor(self.prop.GetLineColor())
1302          if clr is not None:          if clr is not None:
# Line 1306  class SelectPropertiesDialog(wxDialog): Line 1306  class SelectPropertiesDialog(wxDialog):
1306      def _OnChangeLineColorTrans(self, event):      def _OnChangeLineColorTrans(self, event):
1307          self.prop.SetLineColor(Transparent)          self.prop.SetLineColor(Transparent)
1308          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer          self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
1309            
1310      def _OnChangeFillColor(self, event):      def _OnChangeFillColor(self, event):
1311          clr = self.__GetColor(self.prop.GetFill())          clr = self.__GetColor(self.prop.GetFill())
1312          if clr is not None:          if clr is not None:
# Line 1360  class ClassDataPreviewer: Line 1360  class ClassDataPreviewer:
1360      """Class that actually draws a group property preview."""      """Class that actually draws a group property preview."""
1361    
1362      def Draw(self, dc, rect, prop, shapeType):      def Draw(self, dc, rect, prop, shapeType):
1363            """Draw the property.
1364    
1365            returns: (w, h) as adapted extend if the drawing size
1366            exceeded the given rect. This can only be the case
1367            for point symbols. If the symbol fits the given rect,
1368            None is returned.
1369            """
1370    
1371          assert dc is not None          assert dc is not None
1372          assert isinstance(prop, ClassGroupProperties)          assert isinstance(prop, ClassGroupProperties)
# Line 1399  class ClassDataPreviewer: Line 1406  class ClassDataPreviewer:
1406    
1407          elif shapeType == SHAPETYPE_POINT:          elif shapeType == SHAPETYPE_POINT:
1408    
1409              dc.DrawCircle(x + w/2, y + h/2,              dc.DrawCircle(x + w/2, y + h/2, prop.GetSize())
1410                            (min(w, h) - prop.GetLineWidth())/2)              circle_size =  prop.GetSize() * 2 + prop.GetLineWidth() * 2
1411                new_h = h
1412                new_w = w
1413                if h < circle_size: new_h = circle_size
1414                if w < circle_size: new_w = circle_size
1415                if new_h > h or new_w > w:
1416                    return (new_w, new_h)
1417    
1418          elif shapeType == SHAPETYPE_POLYGON:          elif shapeType == SHAPETYPE_POLYGON:
1419              dc.DrawRectangle(x, y, w, h)              dc.DrawRectangle(x, y, w, h)
1420    
1421            return None
1422    
1423  class ClassRenderer(wxPyGridCellRenderer):  class ClassRenderer(wxPyGridCellRenderer):
1424      """A wrapper class that can be used to draw group properties in a      """A wrapper class that can be used to draw group properties in a
1425      grid table.      grid table.
# Line 1426  class ClassRenderer(wxPyGridCellRenderer Line 1441  class ClassRenderer(wxPyGridCellRenderer
1441                           rect.GetWidth(), rect.GetHeight())                           rect.GetWidth(), rect.GetHeight())
1442    
1443          if not isinstance(data, ClassGroupMap):          if not isinstance(data, ClassGroupMap):
1444              self.previewer.Draw(dc, rect, data.GetProperties(), self.shapeType)              new_size = self.previewer.Draw(dc, rect, data.GetProperties(),
1445                                               self.shapeType)
1446                if new_size is not None:
1447                    (new_w, new_h) = new_size
1448                    grid.SetRowSize(row, new_h)
1449                    grid.SetColSize(col, new_h)
1450                    grid.ForceRefresh()
1451    
1452                    # now that we know the height, redraw everything
1453                    rect.SetHeight(new_h)
1454                    rect.SetWidth(new_w)
1455                    dc.DestroyClippingRegion()
1456                    dc.SetClippingRegion(rect.GetX(), rect.GetY(),
1457                                         rect.GetWidth(), rect.GetHeight())
1458                    dc.SetPen(wxPen(wxLIGHT_GREY))
1459                    dc.SetBrush(wxBrush(wxLIGHT_GREY, wxSOLID))
1460                    dc.DrawRectangle(rect.GetX(), rect.GetY(),
1461                                     rect.GetWidth(), rect.GetHeight())
1462                    self.previewer.Draw(dc, rect, data.GetProperties(),
1463                                        self.shapeType)
1464    
1465          if isSelected:          if isSelected:
1466              dc.SetPen(wxPen(wxBLACK, 1, wxSOLID))              dc.SetPen(wxPen(wxBLACK, 1, wxSOLID))
# Line 1510  class ClassGroupPropertiesCtrl(wxWindow, Line 1544  class ClassGroupPropertiesCtrl(wxWindow,
1544    
1545      def _OnLeftDClick(self, event):      def _OnLeftDClick(self, event):
1546          self.DoEdit()          self.DoEdit()
1547    
1548    from Thuban.UI.mainwindow import layer_properties_dialogs
1549    layer_properties_dialogs.add(Layer, Classifier)
1550    layer_properties_dialogs.add(RasterLayer, Classifier)

Legend:
Removed from v.2200  
changed lines
  Added in v.2376

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26