jan: thuban/Thuban/UI classifier.py,1.67,1.68
cvs@intevation.de
cvs at intevation.de
Sun Oct 3 23:23:27 CEST 2004
Author: jan
Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv6111
Modified Files:
classifier.py
Log Message:
(ClassDataPreviewer.Draw): Added doc-string.
Also, now there is a return value that indicates whether the drawing
size exceeded the given rect extent and if so the new extent.
Finally, point objects are drawn depending on the size. If either
the width or height is exceeded, the new extent is returned.
(ClassRenderer.Draw): Now when calling the previewer drawing function,
evaluate the return value and, if not None, adapt the grid widget size
accordingly and redraw again.
Index: classifier.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- classifier.py 1 Oct 2004 18:24:10 -0000 1.67
+++ classifier.py 3 Oct 2004 21:23:25 -0000 1.68
@@ -331,7 +331,7 @@
row = -1
self.clazz = clazz
-
+
self.__NotifyRowChanges(old_len, self.GetNumberRows())
#
@@ -439,11 +439,11 @@
"""
self.SetValueAsCustom(row, col, None, value)
-
+
def GetValueAsCustom(self, row, col, typeName):
"""Return the object that is used to represent the given
cell coordinates. This may not be a string.
-
+
typeName -- unused, but needed to overload wxPyGridTableBase
"""
@@ -915,13 +915,13 @@
table.SetValueAsCustom(row, COL_SYMBOL, None, new_prop)
self.Enable(True)
propDlg.Destroy()
-
+
def _SetClassification(self, clazz):
"""Called from the ClassGen dialog when a new classification has
been created and should be set in the table.
"""
# FIXME: This could be implemented using a message
-
+
self.fields.SetClientData(self.__cur_field, clazz)
self.classGrid.GetTable().SetClassification(clazz)
@@ -1266,10 +1266,10 @@
topBox.Add(buttonBox, 0, wxALIGN_RIGHT|wxBOTTOM|wxTOP, 10)
button_ok.SetDefault()
-
+
#EVT_BUTTON(self, wxID_OK, self._OnOK)
#EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)
-
+
self.SetAutoLayout(True)
self.SetSizer(topBox)
topBox.Fit(self)
@@ -1296,7 +1296,7 @@
dialog.Destroy()
return ret
-
+
def _OnChangeLineColor(self, event):
clr = self.__GetColor(self.prop.GetLineColor())
if clr is not None:
@@ -1306,7 +1306,7 @@
def _OnChangeLineColorTrans(self, event):
self.prop.SetLineColor(Transparent)
self.previewWin.Refresh() # XXX: work around, see ClassDataPreviewer
-
+
def _OnChangeFillColor(self, event):
clr = self.__GetColor(self.prop.GetFill())
if clr is not None:
@@ -1360,6 +1360,13 @@
"""Class that actually draws a group property preview."""
def Draw(self, dc, rect, prop, shapeType):
+ """Draw the property.
+
+ returns: (w, h) as adapted extend if the drawing size
+ exceeded the given rect. This can only be the case
+ for point symbols. If the symbol fits the given rect,
+ None is returned.
+ """
assert dc is not None
assert isinstance(prop, ClassGroupProperties)
@@ -1399,12 +1406,20 @@
elif shapeType == SHAPETYPE_POINT:
- dc.DrawCircle(x + w/2, y + h/2,
- (min(w, h) - prop.GetLineWidth())/2)
+ dc.DrawCircle(x + w/2, y + h/2, prop.GetSize())
+ circle_size = prop.GetSize() * 2 + prop.GetLineWidth() * 2
+ new_h = h
+ new_w = w
+ if h < circle_size: new_h = circle_size
+ if w < circle_size: new_w = circle_size
+ if new_h > h or new_w > w:
+ return (new_w, new_h)
elif shapeType == SHAPETYPE_POLYGON:
dc.DrawRectangle(x, y, w, h)
+ return None
+
class ClassRenderer(wxPyGridCellRenderer):
"""A wrapper class that can be used to draw group properties in a
grid table.
@@ -1426,7 +1441,26 @@
rect.GetWidth(), rect.GetHeight())
if not isinstance(data, ClassGroupMap):
- self.previewer.Draw(dc, rect, data.GetProperties(), self.shapeType)
+ new_size = self.previewer.Draw(dc, rect, data.GetProperties(),
+ self.shapeType)
+ if new_size is not None:
+ (new_w, new_h) = new_size
+ grid.SetRowSize(row, new_h)
+ grid.SetColSize(col, new_h)
+ grid.ForceRefresh()
+
+ # now that we know the height, redraw everything
+ rect.SetHeight(new_h)
+ rect.SetWidth(new_w)
+ dc.DestroyClippingRegion()
+ dc.SetClippingRegion(rect.GetX(), rect.GetY(),
+ rect.GetWidth(), rect.GetHeight())
+ dc.SetPen(wxPen(wxLIGHT_GREY))
+ dc.SetBrush(wxBrush(wxLIGHT_GREY, wxSOLID))
+ dc.DrawRectangle(rect.GetX(), rect.GetY(),
+ rect.GetWidth(), rect.GetHeight())
+ self.previewer.Draw(dc, rect, data.GetProperties(),
+ self.shapeType)
if isSelected:
dc.SetPen(wxPen(wxBLACK, 1, wxSOLID))
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)