/[thuban]/trunk/thuban/Thuban/UI/classifier.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/UI/classifier.py

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

revision 495 by jonathan, Fri Mar 7 18:22:47 2003 UTC revision 496 by jonathan, Mon Mar 10 10:54:50 2003 UTC
# Line 623  class Classifier(NonModalDialog): Line 623  class Classifier(NonModalDialog):
623              else:              else:
624                  self.fields.SetClientData(i + 1, None)                  self.fields.SetClientData(i + 1, None)
625    
         self.fields.SetSelection(self.__cur_field)  
626    
627          #          #
628          #          #
# Line 707  class Classifier(NonModalDialog): Line 706  class Classifier(NonModalDialog):
706          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)
707          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)
708    
709            self.fields.SetSelection(self.__cur_field)
710            self.__SelectField(self.__cur_field)
711    
712          self.SetAutoLayout(true)          self.SetAutoLayout(true)
713          self.SetSizer(topBox)          self.SetSizer(topBox)
714          topBox.Fit(self)          topBox.Fit(self)
# Line 715  class Classifier(NonModalDialog): Line 717  class Classifier(NonModalDialog):
717    
718      def __BuildClassification(self, fieldIndex):      def __BuildClassification(self, fieldIndex):
719    
720            numRows = self.classGrid.GetNumberRows()
721            assert(numRows > 0) # there should always be a default row
722    
723          clazz = Classification()          clazz = Classification()
724          fieldName = self.fields.GetString(fieldIndex)          if fieldIndex == 0:
725          fieldType = self.layer.GetFieldType(fieldName)              fieldName = None
726                fieldType = None
727            else:
728                fieldName = self.fields.GetString(fieldIndex)
729                fieldType = self.layer.GetFieldType(fieldName)
730    
731          clazz.SetField(fieldName)          clazz.SetField(fieldName)
732          clazz.SetFieldType(fieldType)          clazz.SetFieldType(fieldType)
733    
         numRows = self.classGrid.GetNumberRows()  
   
         assert(numRows > 0) # there should always be a default row  
734    
735          table = self.classGrid.GetTable()          table = self.classGrid.GetTable()
736          clazz.SetDefaultGroup(table.GetClassGroup(0))          clazz.SetDefaultGroup(table.GetClassGroup(0))
# Line 751  class Classifier(NonModalDialog): Line 757  class Classifier(NonModalDialog):
757                                    
758          self.classGrid.CreateTable(clazz, self.layer.ShapeType())          self.classGrid.CreateTable(clazz, self.layer.ShapeType())
759    
760    
761    
762        type2string = {None:             "None",
763                       FIELDTYPE_STRING: "Text",
764                       FIELDTYPE_INT:    "Integer",
765                       FIELDTYPE_DOUBLE: "Decimal"}
766    
767      def __SetFieldTypeText(self, fieldIndex):      def __SetFieldTypeText(self, fieldIndex):
768          fieldName = self.fields.GetString(fieldIndex)          fieldName = self.fields.GetString(fieldIndex)
769          fieldType = self.layer.GetFieldType(fieldName)          fieldType = self.layer.GetFieldType(fieldName)
770    
771          if fieldType is None:          assert(Classifier.type2string.has_key(fieldType))
772              text = "None"  
773          elif fieldType == FIELDTYPE_STRING:          text = Classifier.type2string[fieldType]
             text = "Text"  
         elif fieldType == FIELDTYPE_INT:  
             text = "Integer"  
         elif fieldType == FIELDTYPE_DOUBLE:  
             text = "Decimal" # Rational?  
         else:  
             assert(False)  
             text = "UNKNOWN"  
774    
775          self.fieldTypeText.SetLabel(_("Field Type: %s") % text)          self.fieldTypeText.SetLabel(_("Field Type: %s") % text)
776    
777      def _OnFieldSelect(self, event):      def __SelectField(self, fieldIndex):
778          clazz = self.__BuildClassification(self.__cur_field)          clazz = self.__BuildClassification(fieldIndex)
779          self.fields.SetClientData(self.__cur_field, clazz)          self.fields.SetClientData(fieldIndex, clazz)
780    
781          self.__cur_field = self.fields.GetSelection()          self.__cur_field = self.fields.GetSelection()
782          self.__SetGridTable(self.__cur_field)          self.__SetGridTable(fieldIndex)
783    
784          enabled = self.__cur_field != 0          enabled = fieldIndex != 0
785    
786          for b in self.controlButtons:          for b in self.controlButtons:
787              b.Enable(enabled)              b.Enable(enabled)
788    
789          self.__SetFieldTypeText(self.__cur_field)          self.__SetFieldTypeText(fieldIndex)
790    
791    
792        def _OnFieldSelect(self, event):
793            self.__SelectField(self.__cur_field)
794    
795      def _OnApply(self, event):      def _OnApply(self, event):
796          """Put the data from the table into a new Classification and hand          """Put the data from the table into a new Classification and hand

Legend:
Removed from v.495  
changed lines
  Added in v.496

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26