/[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 485 by jonathan, Fri Mar 7 18:20:31 2003 UTC revision 498 by jonathan, Mon Mar 10 11:03:22 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 651  class Classifier(NonModalDialog): Line 650  class Classifier(NonModalDialog):
650    
651          self.classGrid = ClassGrid(self)          self.classGrid = ClassGrid(self)
652          self.__SetGridTable(self.__cur_field)          self.__SetGridTable(self.__cur_field)
         print self.classGrid.GetSizeTuple()  
653    
654          controlBox.Add(self.classGrid, 1, wxGROW, 0)          controlBox.Add(self.classGrid, 1, wxGROW, 0)
655    
# Line 708  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 716  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 752  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, newIndex, oldIndex = -1):
         clazz = self.__BuildClassification(self.__cur_field)  
         self.fields.SetClientData(self.__cur_field, clazz)  
778    
779          self.__cur_field = self.fields.GetSelection()          assert(oldIndex >= -1)
780          self.__SetGridTable(self.__cur_field)  
781            if oldIndex != -1:
782                clazz = self.__BuildClassification(oldIndex)
783                self.fields.SetClientData(oldIndex, clazz)
784    
785          enabled = self.__cur_field != 0          self.__SetGridTable(newIndex)
786    
787            enabled = newIndex != 0
788    
789          for b in self.controlButtons:          for b in self.controlButtons:
790              b.Enable(enabled)              b.Enable(enabled)
791    
792          self.__SetFieldTypeText(self.__cur_field)          self.__SetFieldTypeText(newIndex)
793    
794    
795        def _OnFieldSelect(self, event):
796            index = self.fields.GetSelection()
797            self.__SelectField(index, self.__cur_field)
798            self.__cur_field = index
799    
800      def _OnApply(self, event):      def _OnApply(self, event):
801          """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.485  
changed lines
  Added in v.498

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26