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

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

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

revision 677 by jonathan, Tue Apr 15 19:21:01 2003 UTC revision 781 by jonathan, Tue Apr 29 16:53:38 2003 UTC
# Line 23  import classifier Line 23  import classifier
23    
24  import resource  import resource
25    
 from Thuban.common import Str2Num  
   
26  ID_CLASSGEN_GEN = 4001  ID_CLASSGEN_GEN = 4001
27  ID_CLASSGEN_CLOSE = 4002  ID_CLASSGEN_CLOSE = 4002
28  ID_CLASSGEN_GENCOMBO = 4007  ID_CLASSGEN_GENCOMBO = 4007
# Line 88  class ClassGenDialog(wxDialog): Line 86  class ClassGenDialog(wxDialog):
86          psizer.Add(wxStaticText(self, -1, _("Generate:")),          psizer.Add(wxStaticText(self, -1, _("Generate:")),
87              0, wxALIGN_CENTER_VERTICAL, 0)              0, wxALIGN_CENTER_VERTICAL, 0)
88    
89          self.genCombo = wxComboBox(self,          self.genChoice = wxChoice(self, ID_CLASSGEN_GENCOMBO)
90                                     ID_CLASSGEN_GENCOMBO,          psizer.Add(self.genChoice, 1, wxALL | wxGROW, 4)
91                                     "", style = wxCB_READONLY)          EVT_CHOICE(self, ID_CLASSGEN_GENCOMBO, self._OnGenTypeSelect)
         psizer.Add(self.genCombo, 1, wxALL | wxGROW, 4)  
         EVT_COMBOBOX(self, ID_CLASSGEN_GENCOMBO, self._OnGenTypeSelect)  
92    
93          sizer.Add(psizer, 0, wxALL | wxGROW, 4)          sizer.Add(psizer, 0, wxALL | wxGROW, 4)
94    
# Line 101  class ClassGenDialog(wxDialog): Line 97  class ClassGenDialog(wxDialog):
97          self.genPanel = None          self.genPanel = None
98    
99          panel = GenUniquePanel(self, layer, fieldName, self.type)          panel = GenUniquePanel(self, layer, fieldName, self.type)
100          self.genCombo.Append(GENCOMBOSTR_UNIQUE, panel)          self.genChoice.Append(GENCOMBOSTR_UNIQUE, panel)
101          sizer.Add(panel, 1, wxGROW | wxALL, 4)          sizer.Add(panel, 1, wxGROW | wxALL, 4)
102    
103          self.genPanel = panel          self.genPanel = panel
104    
105          if self.type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE):          if self.type in (FIELDTYPE_INT, FIELDTYPE_DOUBLE):
106              panel = GenUniformPanel(self, layer, fieldName, self.type)              panel = GenUniformPanel(self, layer, fieldName, self.type)
107              self.genCombo.Append(GENCOMBOSTR_UNIFORM, panel)              self.genChoice.Append(GENCOMBOSTR_UNIFORM, panel)
108              sizer.Add(panel, 1, wxGROW | wxALL, 4)              sizer.Add(panel, 1, wxGROW | wxALL, 4)
109              sizer.Show(panel, False)              sizer.Show(panel, False)
110    
111          self.genCombo.SetSelection(0)          self.genChoice.SetSelection(0)
112    
113          #############          #############
114    
# Line 120  class ClassGenDialog(wxDialog): Line 116  class ClassGenDialog(wxDialog):
116          psizer.Add(wxStaticText(self, -1, _("Color Scheme:")),          psizer.Add(wxStaticText(self, -1, _("Color Scheme:")),
117              0, wxALIGN_CENTER_VERTICAL, 0)              0, wxALIGN_CENTER_VERTICAL, 0)
118    
119          self.propCombo = wxComboBox(self,          self.propCombo = wxChoice(self, ID_CLASSGEN_PROPCOMBO)
                                    ID_CLASSGEN_PROPCOMBO,  
                                    "", style = wxCB_READONLY)  
120          psizer.Add(self.propCombo, 1, wxALL | wxGROW, 4)          psizer.Add(self.propCombo, 1, wxALL | wxGROW, 4)
121          EVT_COMBOBOX(self, ID_CLASSGEN_PROPCOMBO, self._OnPropTypeSelect)          EVT_CHOICE(self, ID_CLASSGEN_PROPCOMBO, self._OnPropTypeSelect)
122          sizer.Add(psizer, 0, wxALL | wxGROW, 4)          sizer.Add(psizer, 0, wxALL | wxGROW, 4)
123    
124          #############          #############
# Line 167  class ClassGenDialog(wxDialog): Line 161  class ClassGenDialog(wxDialog):
161    
162      def _OnGenerate(self, event):      def _OnGenerate(self, event):
163    
164          index = self.genCombo.GetSelection()          index = self.genChoice.GetSelection()
165    
166          genSel = self.genCombo.GetString(index)          genSel = self.genChoice.GetString(index)
167          genPanel = self.genCombo.GetClientData(index)          genPanel = self.genChoice.GetClientData(index)
168    
169          propPanel = self.propPanel          propPanel = self.propPanel
170    
# Line 486  class GenUniformPanel(wxPanel): Line 480  class GenUniformPanel(wxPanel):
480          return valid          return valid
481    
482      def __CalcStepping(self, min, max, ngroups):      def __CalcStepping(self, min, max, ngroups):
483          step = Str2Num(str((max - min) / float(ngroups)))          step = (max - min) / float(ngroups)
484          if self.fieldType == FIELDTYPE_INT:          if self.fieldType == FIELDTYPE_INT:
485              step = int(step)              step = int(step)
486    
# Line 827  class ClassGenerator: Line 821  class ClassGenerator:
821          clazz = Classification()          clazz = Classification()
822    
823          #step = int((max - min) / float(numGroups))          #step = int((max - min) / float(numGroups))
         step = int(Str2Num(str((max - min + 1) / float(numGroups))))  
824    
825          if numGroups > 0:          if numGroups > 0:
826    
827                step = int((max - min + 1) / float(numGroups))
828              cur_value = min              cur_value = min
829    
830              ramp.SetNumGroups(numGroups)              ramp.SetNumGroups(numGroups)
831    
832              for prop in ramp:              for prop in ramp:
833                  clazz.AppendGroup(                  clazz.AppendGroup(ClassGroupSingleton(cur_value), prop)
                     ClassGroupSingleton(  
                         Str2Num(str(cur_value)),  
                         prop))  
834                  cur_value += step                  cur_value += step
835    
836          return clazz          return clazz
# Line 859  class ClassGenerator: Line 851  class ClassGenerator:
851    
852          ramp.SetNumGroups(numGroups)          ramp.SetNumGroups(numGroups)
853    
854          step = Str2Num(str((max - min) / float(numGroups)))          step = (max - min) / float(numGroups)
855    
856          if intStep:          if intStep:
857              step = int(step)              step = int(step)
# Line 875  class ClassGenerator: Line 867  class ClassGenerator:
867    
868              # this check guards against rounding issues              # this check guards against rounding issues
869              if cur_min != cur_max:              if cur_min != cur_max:
870                  clazz.AppendGroup(                  clazz.AppendGroup(ClassGroupRange(cur_min, cur_max, prop))
                     ClassGroupRange(  
                         Str2Num(str(cur_min)),  
                         Str2Num(str(cur_max)),  
                         prop))  
871    
872              cur_min = cur_max              cur_min = cur_max
873              cur_max += step              cur_max += step

Legend:
Removed from v.677  
changed lines
  Added in v.781

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26