/[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 498 by jonathan, Mon Mar 10 11:03:22 2003 UTC revision 511 by jonathan, Tue Mar 11 16:27:52 2003 UTC
# Line 70  class ClassGrid(wxGrid): Line 70  class ClassGrid(wxGrid):
70    
71          #wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160))          #wxGrid.__init__(self, parent, ID_CLASS_TABLE, size = (340, 160))
72          wxGrid.__init__(self, parent, ID_CLASS_TABLE)          wxGrid.__init__(self, parent, ID_CLASS_TABLE)
73          #self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), true)          #self.SetTable(ClassTable(fieldData, layer.ShapeType(), self), True)
74    
75          EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick)          EVT_GRID_CELL_LEFT_DCLICK(self, self._OnCellDClick)
76          EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange)          EVT_GRID_RANGE_SELECT(self, self._OnSelectedRange)
# Line 85  class ClassGrid(wxGrid): Line 85  class ClassGrid(wxGrid):
85          self.shapeType = shapeType          self.shapeType = shapeType
86          table = self.GetTable()          table = self.GetTable()
87          if table is None:          if table is None:
88              self.SetTable(ClassTable(clazz, self.shapeType, self), true)              w = self.GetDefaultColSize() * 3 + self.GetDefaultRowLabelSize()
89                h = self.GetDefaultRowSize() * 4 + self.GetDefaultColLabelSize()
90                self.SetDimensions(-1, -1, w, h)
91                self.SetSizeHints(w, h, -1, -1)
92                self.SetTable(ClassTable(clazz, self.shapeType, self), True)
93          else:          else:
94              table.Reset(clazz, self.shapeType)              table.Reset(clazz, self.shapeType)
95    
# Line 279  class ClassTable(wxPyGridTableBase): Line 283  class ClassTable(wxPyGridTableBase):
283    
284          self.__NotifyRowChanges(old_len, len(self.tdata))          self.__NotifyRowChanges(old_len, len(self.tdata))
285    
         view = self.GetView()  
         w = view.GetDefaultColSize() * 3 + view.GetDefaultRowLabelSize()  
         h = view.GetDefaultRowSize() * 4 + view.GetDefaultColLabelSize()  
         view.SetDimensions(-1, -1, w, h)  
         view.SetSizeHints(w, h, -1, -1)  
286                            
287          self.GetView().EndBatch()          self.GetView().EndBatch()
288    
# Line 297  class ClassTable(wxPyGridTableBase): Line 296  class ClassTable(wxPyGridTableBase):
296                          wxGRIDTABLE_NOTIFY_ROWS_APPENDED,                          wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
297                          newRows - curRows)    # how many                          newRows - curRows)    # how many
298              self.GetView().ProcessTableMessage(msg)              self.GetView().ProcessTableMessage(msg)
299                self.GetView().FitInside()
300          elif newRows < curRows:          elif newRows < curRows:
301              msg = wxGridTableMessage(self,              msg = wxGridTableMessage(self,
302                          wxGRIDTABLE_NOTIFY_ROWS_DELETED,                          wxGRIDTABLE_NOTIFY_ROWS_DELETED,
303                          curRows - newRows,    # position                          curRows - newRows,    # position
304                          curRows - newRows)    # how many                          curRows - newRows)    # how many
305              self.GetView().ProcessTableMessage(msg)              self.GetView().ProcessTableMessage(msg)
306                self.GetView().FitInside()
307    
308      def __SetRow(self, row, group):      def __SetRow(self, row, group):
309          """Set a row's data to that of the group.          """Set a row's data to that of the group.
# Line 584  class Classifier(NonModalDialog): Line 585  class Classifier(NonModalDialog):
585          NonModalDialog.__init__(self, parent, interactor, name,          NonModalDialog.__init__(self, parent, interactor, name,
586                                  _("Classifier: %s") % layer.Title())                                  _("Classifier: %s") % layer.Title())
587    
588            panel = wxPanel(self, -1, size=(100, 100))
589    
590          self.layer = layer          self.layer = layer
591    
592          self.originalClass = self.layer.GetClassification()          self.originalClass = self.layer.GetClassification()
# Line 591  class Classifier(NonModalDialog): Line 594  class Classifier(NonModalDialog):
594          fieldType = self.originalClass.GetFieldType()          fieldType = self.originalClass.GetFieldType()
595    
596          topBox = wxBoxSizer(wxVERTICAL)          topBox = wxBoxSizer(wxVERTICAL)
597            panelBox = wxBoxSizer(wxVERTICAL)
598    
599          #topBox.Add(wxStaticText(self, -1, _("Layer: %s") % layer.Title()),          #panelBox.Add(wxStaticText(panel, -1, _("Layer: %s") % layer.Title()),
600              #0, wxALIGN_LEFT | wxALL, 4)              #0, wxALIGN_LEFT | wxALL, 4)
601          topBox.Add(wxStaticText(self, -1,          panelBox.Add(wxStaticText(panel, -1,
602                                  _("Layer Type: %s") % layer.ShapeType()),                                  _("Layer Type: %s") % layer.ShapeType()),
603              0, wxALIGN_LEFT | wxALL, 4)              0, wxALIGN_LEFT | wxALL, 4)
604    
# Line 602  class Classifier(NonModalDialog): Line 606  class Classifier(NonModalDialog):
606          #          #
607          # make field combo box          # make field combo box
608          #          #
609          self.fields = wxComboBox(self, ID_PROPERTY_SELECT, "",          self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "",
610                                       style = wxCB_READONLY)                                       style = wxCB_READONLY)
611    
612          self.num_cols = layer.table.field_count()          self.num_cols = layer.table.field_count()
# Line 624  class Classifier(NonModalDialog): Line 628  class Classifier(NonModalDialog):
628                  self.fields.SetClientData(i + 1, None)                  self.fields.SetClientData(i + 1, None)
629    
630    
631          #          ###########
         #  
         #  
   
         self.fieldTypeText = wxStaticText(self, -1, "")  
         self.__SetFieldTypeText(self.__cur_field)  
632    
633          topBox.Add(self.fieldTypeText, 0, wxALIGN_LEFT | wxALL, 4)          self.fieldTypeText = wxStaticText(panel, -1, "")
634          #self.fieldTypeText.SetLabel("asdfadsfs")          panelBox.Add(self.fieldTypeText, 0, wxGROW | wxALIGN_LEFT | wxALL, 4)
635    
636          propertyBox = wxBoxSizer(wxHORIZONTAL)          propertyBox = wxBoxSizer(wxHORIZONTAL)
637          propertyBox.Add(wxStaticText(self, -1, _("Field: ")),          propertyBox.Add(wxStaticText(panel, -1, _("Field: ")),
638              0, wxALIGN_CENTER | wxALL, 4)              0, wxALIGN_LEFT | wxALL, 4)
639          propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4)          propertyBox.Add(self.fields, 1, wxGROW|wxALL, 4)
640          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect)          EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect)
641    
642          topBox.Add(propertyBox, 0, wxGROW, 4)          panelBox.Add(propertyBox, 0, wxGROW, 4)
643    
644            ###########
645          #          #
646          # Classification data table          # Classification data table
647          #          #
648    
649          controlBox = wxBoxSizer(wxHORIZONTAL)          controlBox = wxBoxSizer(wxHORIZONTAL)
650    
651          self.classGrid = ClassGrid(self)          self.classGrid = ClassGrid(panel)
652          self.__SetGridTable(self.__cur_field)          self.__SetGridTable(self.__cur_field)
653    
654          controlBox.Add(self.classGrid, 1, wxGROW, 0)          controlBox.Add(self.classGrid, 1, wxGROW, 0)
655    
656          controlButtonBox = wxBoxSizer(wxVERTICAL)          ###########
   
657          #          #
658          # Control buttons:          # Control buttons:
659          #          #
660          self.controlButtons = []          self.controlButtons = []
661    
662          button = wxButton(self, ID_CLASSIFY_ADD, _("Add"))          controlButtonBox = wxBoxSizer(wxVERTICAL)
663    
664            button = wxButton(panel, ID_CLASSIFY_ADD, _("Add"))
665          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
666          self.controlButtons.append(button)          self.controlButtons.append(button)
667    
668          #button = wxButton(self, ID_CLASSIFY_GENRANGE, _("Generate Ranges"))          #button = wxButton(panel, ID_CLASSIFY_GENRANGE, _("Generate Ranges"))
669          #controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          #controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
670          #self.controlButtons.append(button)          #self.controlButtons.append(button)
671    
672          button = wxButton(self, ID_CLASSIFY_MOVEUP, _("Move Up"))          button = wxButton(panel, ID_CLASSIFY_MOVEUP, _("Move Up"))
673          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
674          self.controlButtons.append(button)          self.controlButtons.append(button)
675    
676          button = wxButton(self, ID_CLASSIFY_MOVEDOWN, _("Move Down"))          button = wxButton(panel, ID_CLASSIFY_MOVEDOWN, _("Move Down"))
677          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)
678          self.controlButtons.append(button)          self.controlButtons.append(button)
679    
680          controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)          controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)
681    
682          button = wxButton(self, ID_CLASSIFY_REMOVE, _("Remove"))          button = wxButton(panel, ID_CLASSIFY_REMOVE, _("Remove"))
683          controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)          controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)
684          self.controlButtons.append(button)          self.controlButtons.append(button)
685    
686          controlBox.Add(controlButtonBox, 0, wxGROW, 10)          controlBox.Add(controlButtonBox, 0, wxGROW, 10)
687          topBox.Add(controlBox, 1, wxGROW, 10)          panelBox.Add(controlBox, 1, wxGROW, 10)
688    
689          EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd)          EVT_BUTTON(self, ID_CLASSIFY_ADD, self._OnAdd)
690          EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove)          EVT_BUTTON(self, ID_CLASSIFY_REMOVE, self._OnRemove)
# Line 691  class Classifier(NonModalDialog): Line 692  class Classifier(NonModalDialog):
692          EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp)          EVT_BUTTON(self, ID_CLASSIFY_MOVEUP, self._OnMoveUp)
693          EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown)          EVT_BUTTON(self, ID_CLASSIFY_MOVEDOWN, self._OnMoveDown)
694    
695            ###########
696    
697          buttonBox = wxBoxSizer(wxHORIZONTAL)          buttonBox = wxBoxSizer(wxHORIZONTAL)
698          buttonBox.Add(wxButton(self, ID_CLASSIFY_OK, _("OK")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_OK, _("OK")),
699                        0, wxALL, 4)                        0, wxALL, 4)
700          buttonBox.Add(60, 20, 0, wxALL, 4)          buttonBox.Add(60, 20, 0, wxALL, 4)
701          buttonBox.Add(wxButton(self, ID_CLASSIFY_APPLY, _("Apply")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_APPLY, _("Apply")),
702                        0, wxALL, 4)                        0, wxALL, 4)
703          buttonBox.Add(60, 20, 0, wxALL, 4)          buttonBox.Add(60, 20, 0, wxALL, 4)
704          buttonBox.Add(wxButton(self, ID_CLASSIFY_CANCEL, _("Cancel")),          buttonBox.Add(wxButton(panel, ID_CLASSIFY_CANCEL, _("Cancel")),
705                        0, wxALL, 4)                        0, wxALL, 4)
706          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)          panelBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0)
707    
708          EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK)          EVT_BUTTON(self, ID_CLASSIFY_OK, self._OnOK)
709          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)          EVT_BUTTON(self, ID_CLASSIFY_APPLY, self._OnApply)
710          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)          EVT_BUTTON(self, ID_CLASSIFY_CANCEL, self._OnCancel)
711    
712            ###########
713    
714          self.fields.SetSelection(self.__cur_field)          self.fields.SetSelection(self.__cur_field)
715          self.__SelectField(self.__cur_field)          self.__SelectField(self.__cur_field)
716    
717          self.SetAutoLayout(true)          panel.SetAutoLayout(True)
718            panel.SetSizer(panelBox)
719            panelBox.SetSizeHints(panel)
720    
721            topBox.Add(panel, 1, wxGROW, 0)
722            panelBox.SetSizeHints(self)
723            self.SetAutoLayout(True)
724          self.SetSizer(topBox)          self.SetSizer(topBox)
         topBox.Fit(self)  
         topBox.SetSizeHints(self)  
   
725    
726      def __BuildClassification(self, fieldIndex):      def __BuildClassification(self, fieldIndex):
727    
# Line 759  class Classifier(NonModalDialog): Line 767  class Classifier(NonModalDialog):
767    
768    
769    
770      type2string = {None:             "None",      type2string = {None:             _("None"),
771                     FIELDTYPE_STRING: "Text",                     FIELDTYPE_STRING: _("Text"),
772                     FIELDTYPE_INT:    "Integer",                     FIELDTYPE_INT:    _("Integer"),
773                     FIELDTYPE_DOUBLE: "Decimal"}                     FIELDTYPE_DOUBLE: _("Decimal")}
774    
775      def __SetFieldTypeText(self, fieldIndex):      def __SetFieldTypeText(self, fieldIndex):
776          fieldName = self.fields.GetString(fieldIndex)          fieldName = self.fields.GetString(fieldIndex)
# Line 873  class SelectPropertiesDialog(wxDialog): Line 881  class SelectPropertiesDialog(wxDialog):
881    
882      def __init__(self, parent, prop, shapeType):      def __init__(self, parent, prop, shapeType):
883          wxDialog.__init__(self, parent, -1, _("Select Properties"),          wxDialog.__init__(self, parent, -1, _("Select Properties"),
884                            style = wxRESIZE_BORDER)                            style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
885    
886          self.prop = ClassGroupProperties(prop)          self.prop = ClassGroupProperties(prop)
887    
# Line 896  class SelectPropertiesDialog(wxDialog): Line 904  class SelectPropertiesDialog(wxDialog):
904    
905          lineColorBox = wxBoxSizer(wxHORIZONTAL)          lineColorBox = wxBoxSizer(wxHORIZONTAL)
906          lineColorBox.Add(          lineColorBox.Add(
907              wxButton(self, ID_SELPROP_STROKECLR, "Change Line Color"),              wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")),
908              1, wxALL | wxGROW, 4)              1, wxALL | wxGROW, 4)
909          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)
910    
911          lineColorBox.Add(          lineColorBox.Add(
912              wxButton(self, ID_SELPROP_STROKECLRTRANS, "Transparent"),              wxButton(self, ID_SELPROP_STROKECLRTRANS, _("Transparent")),
913              1, wxALL | wxGROW, 4)              1, wxALL | wxGROW, 4)
914          EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS,          EVT_BUTTON(self, ID_SELPROP_STROKECLRTRANS,
915                     self._OnChangeLineColorTrans)                     self._OnChangeLineColorTrans)
# Line 912  class SelectPropertiesDialog(wxDialog): Line 920  class SelectPropertiesDialog(wxDialog):
920          if shapeType != SHAPETYPE_ARC:          if shapeType != SHAPETYPE_ARC:
921              fillColorBox = wxBoxSizer(wxHORIZONTAL)              fillColorBox = wxBoxSizer(wxHORIZONTAL)
922              fillColorBox.Add(              fillColorBox.Add(
923                  wxButton(self, ID_SELPROP_FILLCLR, "Change Fill Color"),                  wxButton(self, ID_SELPROP_FILLCLR, _("Change Fill Color")),
924                  1, wxALL | wxGROW, 4)                  1, wxALL | wxGROW, 4)
925              EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor)              EVT_BUTTON(self, ID_SELPROP_FILLCLR, self._OnChangeFillColor)
926              fillColorBox.Add(              fillColorBox.Add(
927                  wxButton(self, ID_SELPROP_FILLCLRTRANS, "Transparent"),                  wxButton(self, ID_SELPROP_FILLCLRTRANS, _("Transparent")),
928                  1, wxALL | wxGROW, 4)                  1, wxALL | wxGROW, 4)
929              EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS,              EVT_BUTTON(self, ID_SELPROP_FILLCLRTRANS,
930                         self._OnChangeFillColorTrans)                         self._OnChangeFillColorTrans)
# Line 952  class SelectPropertiesDialog(wxDialog): Line 960  class SelectPropertiesDialog(wxDialog):
960          EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK)          EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK)
961          EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)          EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)
962                                                                                                                                                                    
963          self.SetAutoLayout(true)          self.SetAutoLayout(True)
964          self.SetSizer(topBox)          self.SetSizer(topBox)
965          topBox.Fit(self)          topBox.Fit(self)
966          topBox.SetSizeHints(self)          topBox.SetSizeHints(self)

Legend:
Removed from v.498  
changed lines
  Added in v.511

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26