/[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 635 by jonathan, Wed Apr 9 15:42:25 2003 UTC revision 781 by jonathan, Tue Apr 29 16:53:38 2003 UTC
# Line 5  Line 5 
5  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
6  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
7    
8    import sys
9    
10  from Thuban import _  from Thuban import _
11    
12  from wxPython.wx import *  from wxPython.wx import *
# Line 19  from Thuban.Model.color import Color Line 21  from Thuban.Model.color import Color
21    
22  import classifier  import classifier
23    
24  from Thuban.common import Str2Num  import resource
25    
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
29  ID_CLASSGEN_PROPCOMBO = 4008  ID_CLASSGEN_PROPCOMBO = 4008
30    
31    USEALL_BMP  = "group_use_all"
32    USE_BMP     = "group_use"
33    USENOT_BMP  = "group_use_not"
34    USENONE_BMP = "group_use_none"
35    
36  GENCOMBOSTR_UNIFORM = _("Uniform Distribution")  GENCOMBOSTR_UNIFORM = _("Uniform Distribution")
37  GENCOMBOSTR_UNIQUE = _("Unique Values")  GENCOMBOSTR_UNIQUE = _("Unique Values")
38    
39  PROPCOMBOSTR_CUSTOM = _("Custom Ramp")  PROPCOMBOSTR_CUSTOM     = _("Custom Ramp")
40  PROPCOMBOSTR_RED    = _("Red Ramp")  PROPCOMBOSTR_GREY       = _("Grey Ramp")
41  PROPCOMBOSTR_GREEN  = _("Green Ramp")  PROPCOMBOSTR_RED        = _("Red Ramp")
42  PROPCOMBOSTR_BLUE   = _("Blue Ramp")  PROPCOMBOSTR_GREEN      = _("Green Ramp")
43    PROPCOMBOSTR_BLUE       = _("Blue Ramp")
44    PROPCOMBOSTR_HOT2COLD   = _("Hot-to-Cold Ramp")
45    
46  class ClassGenDialog(wxDialog):  class ClassGenDialog(wxDialog):
47                                                                                                                                                                    
# Line 70  class ClassGenDialog(wxDialog): Line 79  class ClassGenDialog(wxDialog):
79                    0, wxALL, 4)                    0, wxALL, 4)
80          sizer.Add(wxStaticText(          sizer.Add(wxStaticText(
81              self, -1,              self, -1,
82              _("Field Type: %s") % classifier.Classifier.type2string[self.type]),              _("Data Type: %s") % classifier.Classifier.type2string[self.type]),
83              0, wxALL, 4)              0, wxALL, 4)
84    
85          psizer = wxBoxSizer(wxHORIZONTAL)          psizer = wxBoxSizer(wxHORIZONTAL)
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 90  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, 0, wxGROW | wxALL, 4)              sizer.Add(panel, 1, wxGROW | wxALL, 4)
109              sizer.Show(panel, False)              sizer.Show(panel, False)
110    
111            self.genChoice.SetSelection(0)
112    
113          #############          #############
114    
115          psizer = wxBoxSizer(wxHORIZONTAL)          psizer = wxBoxSizer(wxHORIZONTAL)
116          psizer.Add(wxStaticText(self, -1, _("Color Schemes:")),          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 121  class ClassGenDialog(wxDialog): Line 128  class ClassGenDialog(wxDialog):
128          sizer.Add(panel, 1, wxALL | wxGROW, 4)          sizer.Add(panel, 1, wxALL | wxGROW, 4)
129          sizer.Show(panel, False)          sizer.Show(panel, False)
130    
131            self.propCombo.Append(PROPCOMBOSTR_GREY,  GreyRamp())
132          self.propCombo.Append(PROPCOMBOSTR_RED,   RedRamp())          self.propCombo.Append(PROPCOMBOSTR_RED,   RedRamp())
133          self.propCombo.Append(PROPCOMBOSTR_GREEN, GreenRamp())          self.propCombo.Append(PROPCOMBOSTR_GREEN, GreenRamp())
134          self.propCombo.Append(PROPCOMBOSTR_BLUE,  BlueRamp())          self.propCombo.Append(PROPCOMBOSTR_BLUE,  BlueRamp())
135            self.propCombo.Append(PROPCOMBOSTR_HOT2COLD,  HotToColdRamp())
136          self.propCombo.Append(PROPCOMBOSTR_CUSTOM, panel)          self.propCombo.Append(PROPCOMBOSTR_CUSTOM, panel)
137    
138            self.propCombo.SetSelection(0)
139    
140    
141          #############          #############
# Line 151  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 276  class GenUniformPanel(wxPanel): Line 286  class GenUniformPanel(wxPanel):
286          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
287    
288          sizer.Add(wxStaticText(self, -1, _("Number of Groups:")), 0, wxALL, 4)          sizer.Add(wxStaticText(self, -1, _("Number of Groups:")), 0, wxALL, 4)
289          self.numGroupsCtrl = wxSpinCtrl(self, ID_UNIFORM_NGROUPS, style=wxTE_RIGHT)          self.numGroupsCtrl = wxSpinCtrl(self, ID_UNIFORM_NGROUPS,
290                                            style=wxTE_RIGHT)
291          EVT_TEXT(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)          EVT_TEXT(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)
292          EVT_SPINCTRL(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)          EVT_SPINCTRL(self, ID_UNIFORM_NGROUPS, self._OnNumGroupsChanged)
293          sizer.Add(self.numGroupsCtrl, 1, wxALL, 4)          sizer.Add(self.numGroupsCtrl, 1, wxALL, 4)
# Line 297  class GenUniformPanel(wxPanel): Line 308  class GenUniformPanel(wxPanel):
308          self.numGroupsChanging = False          self.numGroupsChanging = False
309          self.steppingChanging = False          self.steppingChanging = False
310    
311          self.numGroupsCtrl.SetRange(1, 100)          self.numGroupsCtrl.SetRange(1, sys.maxint)
312    
313          self.numGroupsCtrl.SetValue(1)          self.numGroupsCtrl.SetValue(1)
314          self.stepCtrl.SetValue("1")          self.stepCtrl.SetValue("1")
# Line 347  class GenUniformPanel(wxPanel): Line 358  class GenUniformPanel(wxPanel):
358          self.numGroupsCtrl.Enable(on)          self.numGroupsCtrl.Enable(on)
359          self.stepCtrl.Enable(on)          self.stepCtrl.Enable(on)
360    
         if on:  
             self.numGroupsCtrl.SetRange(1, abs(max - min) / 0.001)  
   
361          ngroups = self.GetNumGroups()          ngroups = self.GetNumGroups()
362    
363          if ngroups is not None  \          if ngroups is not None  \
# Line 380  class GenUniformPanel(wxPanel): Line 388  class GenUniformPanel(wxPanel):
388          min = self.GetMin()          min = self.GetMin()
389          max = self.GetMax()          max = self.GetMax()
390    
         if ngroups >= self.numGroupsCtrl.GetMax():  
             self.numGroupsCtrl.SetRange(1, ngroups + 1)  
   
391          if ngroups is not None  \          if ngroups is not None  \
392              and min is not None \              and min is not None \
393              and max is not None \              and max is not None \
# Line 475  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 499  ID_UNIQUE_DONTUSE = 4004 Line 504  ID_UNIQUE_DONTUSE = 4004
504  ID_UNIQUE_USENONE = 4005  ID_UNIQUE_USENONE = 4005
505  ID_UNIQUE_SORTAVAIL = 4006  ID_UNIQUE_SORTAVAIL = 4006
506  ID_UNIQUE_SORTUSE = 4007  ID_UNIQUE_SORTUSE = 4007
507    ID_UNIQUE_REVAVAIL = 4008
508    ID_UNIQUE_REVUSE = 4009
509    
510  class GenUniquePanel(wxPanel):  class GenUniquePanel(wxPanel):
511    
# Line 514  class GenUniquePanel(wxPanel): Line 521  class GenUniquePanel(wxPanel):
521                                      wxVERTICAL)                                      wxVERTICAL)
522    
523    
524            #bsizer = wxBoxSizer(wxVERTICAL)
525            topSizer.Add(wxButton(self, ID_UNIQUE_RETRIEVE,
526                                _("Retrieve From Table")),
527                       0, wxALL | wxALIGN_RIGHT, 4)
528    
529            EVT_BUTTON(self, ID_UNIQUE_RETRIEVE, self._OnRetrieve)
530    
531            #topSizer.Add(bsizer, 0, wxALL, 4)
532    
533          sizer = wxBoxSizer(wxHORIZONTAL)          sizer = wxBoxSizer(wxHORIZONTAL)
534    
535          self.dataList = []          self.dataList = []
# Line 525  class GenUniquePanel(wxPanel): Line 541  class GenUniquePanel(wxPanel):
541          self.list_avail_data = []          self.list_avail_data = []
542          psizer.Add(self.list_avail, 1, wxGROW, 0)          psizer.Add(self.list_avail, 1, wxGROW, 0)
543    
544          psizer.Add(wxButton(self, ID_UNIQUE_SORTAVAIL, _("Sort")))          bsizer = wxBoxSizer(wxHORIZONTAL)
545            bsizer.Add(wxButton(self, ID_UNIQUE_SORTAVAIL, _("Sort")))
546            EVT_BUTTON(self, ID_UNIQUE_SORTAVAIL, self._OnSortList)
547    
548          EVT_BUTTON(self, ID_UNIQUE_SORTAVAIL, self._OnSortAvailList)          bsizer.Add(wxButton(self, ID_UNIQUE_REVAVAIL, _("Reverse")))
549            EVT_BUTTON(self, ID_UNIQUE_REVAVAIL, self._OnReverseList)
550    
551            psizer.Add(bsizer, 0, wxGROW, 0)
552          sizer.Add(psizer, 1, wxGROW, 0)          sizer.Add(psizer, 1, wxGROW, 0)
553    
554                    
555          bsizer = wxBoxSizer(wxVERTICAL)          bsizer = wxBoxSizer(wxVERTICAL)
556          bsizer.Add(wxButton(self, ID_UNIQUE_USEALL, _("Use All")),  
557            bmp = resource.GetBitmapResource(USEALL_BMP, wxBITMAP_TYPE_XPM)
558            bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USEALL, bmp),
559                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
560          bsizer.Add(wxButton(self, ID_UNIQUE_USE, _("Use >>")),          bmp = resource.GetBitmapResource(USE_BMP, wxBITMAP_TYPE_XPM)
561            bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USE, bmp),
562                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
563          bsizer.Add(wxButton(self, ID_UNIQUE_DONTUSE, _("<< Don't Use")),          bmp = resource.GetBitmapResource(USENOT_BMP, wxBITMAP_TYPE_XPM)
564            bsizer.Add(wxBitmapButton(self, ID_UNIQUE_DONTUSE, bmp),
565                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
566          bsizer.Add(wxButton(self, ID_UNIQUE_USENONE, _("Use None")),          bmp = resource.GetBitmapResource(USENONE_BMP, wxBITMAP_TYPE_XPM)
567            bsizer.Add(wxBitmapButton(self, ID_UNIQUE_USENONE, bmp),
568                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
569    
570          EVT_BUTTON(self, ID_UNIQUE_USEALL, self._OnUseAll)          EVT_BUTTON(self, ID_UNIQUE_USEALL, self._OnUseAll)
# Line 556  class GenUniquePanel(wxPanel): Line 581  class GenUniquePanel(wxPanel):
581          self.list_use_data = []          self.list_use_data = []
582          psizer.Add(self.list_use, 1, wxGROW, 0)          psizer.Add(self.list_use, 1, wxGROW, 0)
583    
584          psizer.Add(wxButton(self, ID_UNIQUE_SORTUSE, _("Sort")))          bsizer = wxBoxSizer(wxHORIZONTAL)
585            bsizer.Add(wxButton(self, ID_UNIQUE_SORTUSE, _("Sort")))
586            EVT_BUTTON(self, ID_UNIQUE_SORTUSE, self._OnSortList)
587    
588          EVT_BUTTON(self, ID_UNIQUE_SORTUSE, self._OnSortUseList)          bsizer.Add(wxButton(self, ID_UNIQUE_REVUSE, _("Reverse")))
589            EVT_BUTTON(self, ID_UNIQUE_REVUSE, self._OnReverseList)
590    
591          sizer.Add(psizer, 1, wxGROW, 0)          psizer.Add(bsizer, 0, wxGROW, 0)
   
         bsizer = wxBoxSizer(wxVERTICAL)  
         bsizer.Add(wxButton(self, ID_UNIQUE_RETRIEVE,  
                             _("Retrieve From Table")),  
                    0, wxGROW | wxALL, 4)  
592    
593          EVT_BUTTON(self, ID_UNIQUE_RETRIEVE, self._OnRetrieve)          sizer.Add(psizer, 1, wxGROW, 0)
594    
         sizer.Add(bsizer, 0, wxALL, 4)  
595    
596          topSizer.Add(sizer, 1, wxGROW, 0)          topSizer.Add(sizer, 1, wxGROW, 0)
597    
# Line 590  class GenUniquePanel(wxPanel): Line 612  class GenUniquePanel(wxPanel):
612              list.append(self.dataList[self.list_use.GetItemData(i)])              list.append(self.dataList[self.list_use.GetItemData(i)])
613          return list          return list
614    
615      def _OnSortAvailList(self, event):      def _OnSortList(self, event):
616          self.list_avail.SortItems(lambda i1, i2:          id = event.GetId()
617                                      cmp(self.dataList[i1],  
618                                          self.dataList[i2]))          if id == ID_UNIQUE_SORTUSE:
619                list = self.list_use
620      def _OnSortUseList(self, event):          else:
621          self.list_use.SortItems(lambda i1, i2:              list = self.list_avail
622                                      cmp(self.dataList[i1],  
623                                          self.dataList[i2]))          list.SortItems(lambda i1, i2: cmp(self.dataList[i1],
624                                              self.dataList[i2]))
625    
626        def _OnReverseList(self, event):
627            id = event.GetId()
628    
629            if id == ID_UNIQUE_REVUSE:
630                list = self.list_use
631            else:
632                list = self.list_avail
633    
634            #
635            # always returning 1 reverses the list
636            #
637            list.SortItems(lambda i1, i2: 1)
638    
639      def _OnRetrieve(self, event):      def _OnRetrieve(self, event):
640          self.list_use.DeleteAllItems()          self.list_use.DeleteAllItems()
# Line 621  class GenUniquePanel(wxPanel): Line 657  class GenUniquePanel(wxPanel):
657              self.__MoveListItem(0, self.list_avail, self.list_use)              self.__MoveListItem(0, self.list_avail, self.list_use)
658    
659      def _OnUse(self, event):      def _OnUse(self, event):
         print "_OnUse"  
660          self.__MoveSelectedItems(self.list_avail, self.list_use)          self.__MoveSelectedItems(self.list_avail, self.list_use)
661    
662      def _OnDontUse(self, event):      def _OnDontUse(self, event):
         print "_OnDontUse"  
663          self.__MoveSelectedItems(self.list_use, self.list_avail)          self.__MoveSelectedItems(self.list_use, self.list_avail)
664    
665      def _OnUseNone(self, event):      def _OnUseNone(self, event):
         print "_OnUseNone"  
666    
667          for i in range(self.list_use.GetItemCount()):          for i in range(self.list_use.GetItemCount()):
668              self.__MoveListItem(0, self.list_use, self.list_avail)              self.__MoveListItem(0, self.list_use, self.list_avail)
# Line 695  class CustomRampPanel(wxPanel): Line 728  class CustomRampPanel(wxPanel):
728                        | wxALIGN_CENTER_VERTICAL, \                        | wxALIGN_CENTER_VERTICAL, \
729                     4)                     4)
730    
731            bmp = resource.GetBitmapResource(USE_BMP, wxBITMAP_TYPE_XPM)
732          bsizer = wxBoxSizer(wxVERTICAL)          bsizer = wxBoxSizer(wxVERTICAL)
733          bsizer.Add(wxButton(self, ID_CUSTOMRAMP_COPYSTART, _("Copy >>")),          bsizer.Add(wxBitmapButton(self, ID_CUSTOMRAMP_COPYSTART, bmp),
734                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
735          bsizer.Add(wxButton(self, ID_CUSTOMRAMP_COPYEND, _("<< Copy")),          bmp = resource.GetBitmapResource(USENOT_BMP, wxBITMAP_TYPE_XPM)
736            bsizer.Add(wxBitmapButton(self, ID_CUSTOMRAMP_COPYEND, bmp),
737                     0, wxGROW | wxALL, 4)                     0, wxGROW | wxALL, 4)
738    
739          topSizer.Add(bsizer,          topSizer.Add(bsizer,
# Line 786  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 818  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 834  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
# Line 969  class MonochromaticRamp(CustomRamp): Line 998  class MonochromaticRamp(CustomRamp):
998    
999          CustomRamp.__init__(self, sp, ep)          CustomRamp.__init__(self, sp, ep)
1000    
1001    class GreyRamp(MonochromaticRamp):
1002        def __init__(self):
1003            MonochromaticRamp.__init__(self, Color(1, 1, 1), Color(0, 0, 0))
1004    
1005  class RedRamp(MonochromaticRamp):  class RedRamp(MonochromaticRamp):
1006      def __init__(self):      def __init__(self):
1007          MonochromaticRamp.__init__(self, Color(.2, 0, 0), Color(1, 0, 0))          MonochromaticRamp.__init__(self, Color(1, 1, 1), Color(.8, 0, 0))
1008    
1009  class GreenRamp(MonochromaticRamp):  class GreenRamp(MonochromaticRamp):
1010      def __init__(self):      def __init__(self):
1011          MonochromaticRamp.__init__(self, Color(0, .2, 0), Color(0, 1, 0))          MonochromaticRamp.__init__(self, Color(1, 1, 1), Color(0, .8, 0))
1012    
1013  class BlueRamp(MonochromaticRamp):  class BlueRamp(MonochromaticRamp):
1014      def __init__(self):      def __init__(self):
1015          MonochromaticRamp.__init__(self, Color(0, 0, .2), Color(0, 0, 1))          MonochromaticRamp.__init__(self, Color(1, 1, 1), Color(0, 0, .8))
1016    
1017    class HotToColdRamp:
1018    
1019        def __iter__(self):
1020            return self
1021            
1022        def GetRamp(self):
1023            return self
1024    
1025        def SetNumGroups(self, num):
1026            if num < 0:
1027                return False
1028    
1029            self.num = float(num)
1030            self.index = 0
1031    
1032            return True
1033    
1034        def next(self):
1035            if self.index == self.num:
1036                raise StopIteration
1037    
1038            clr = [1.0, 1.0, 1.0]
1039    
1040            if self.index < (.25 * self.num):
1041                clr[0] = 0
1042                clr[1] = 4 * self.index / self.num
1043            elif self.index < (.5 * self.num):
1044                clr[0] = 0
1045                clr[2] = 1 + 4 * (.25 * self.num - self.index) / self.num
1046            elif self.index < (.75 * self.num):
1047                clr[0] = 4 * (self.index - .5 * self.num) / self.num
1048                clr[2] = 0
1049            else:
1050                clr[1] = 1 + 4 * (.75 * self.num - self.index) / self.num
1051                clr[2] = 0
1052    
1053            self.index += 1
1054    
1055            prop = ClassGroupProperties()
1056            prop.SetLineColor(Color(clr[0], clr[1], clr[2]))
1057            prop.SetFill(Color(clr[0], clr[1], clr[2]))
1058    
1059            return prop
1060    
1061    #class Colors16Ramp:
1062    #
1063        #def __iter__(self):
1064            #return self
1065    #
1066        #def GetRamp(self):
1067            #return self
1068    #
1069        #def SetNumGroups(self, num):
1070            #if num < 0:
1071                #return False
1072    #
1073            #self.index = 0
1074    #
1075            #return True
1076    
1077        

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26