/[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 783 by jonathan, Tue Apr 29 17:29:32 2003 UTC revision 835 by bh, Tue May 6 15:52:41 2003 UTC
# Line 62  class ClassGrid(wxGrid): Line 62  class ClassGrid(wxGrid):
62                   use for display.                   use for display.
63          """          """
64    
65          wxGrid.__init__(self, parent, ID_CLASS_TABLE)          wxGrid.__init__(self, parent, ID_CLASS_TABLE, style = 0)
66    
67          self.classifier = classifier          self.classifier = classifier
68    
# Line 650  class ClassTable(wxPyGridTableBase): Line 650  class ClassTable(wxPyGridTableBase):
650              self.__NotifyRowChanges(old_len, self.GetNumberRows())              self.__NotifyRowChanges(old_len, self.GetNumberRows())
651    
652    
 ID_PROPERTY_OK = 4001  
653  ID_PROPERTY_REVERT = 4002  ID_PROPERTY_REVERT = 4002
654  ID_PROPERTY_ADD = 4003  ID_PROPERTY_ADD = 4003
655  ID_PROPERTY_GENCLASS = 4004  ID_PROPERTY_GENCLASS = 4004
# Line 659  ID_PROPERTY_MOVEUP = 4006 Line 658  ID_PROPERTY_MOVEUP = 4006
658  ID_PROPERTY_MOVEDOWN = 4007  ID_PROPERTY_MOVEDOWN = 4007
659  ID_PROPERTY_TRY = 4008  ID_PROPERTY_TRY = 4008
660  ID_PROPERTY_EDITSYM = 4009  ID_PROPERTY_EDITSYM = 4009
 ID_PROPERTY_CLOSE = 4010  
661  ID_PROPERTY_SELECT = 4011  ID_PROPERTY_SELECT = 4011
662  ID_PROPERTY_TITLE = 4012  ID_PROPERTY_TITLE = 4012
663  ID_PROPERTY_FIELDTEXT = 4013  ID_PROPERTY_FIELDTEXT = 4013
# Line 695  class Classifier(NonModalDialog): Line 693  class Classifier(NonModalDialog):
693    
694          self.genDlg = None          self.genDlg = None
695    
696          topBox = wxBoxSizer(wxVERTICAL)          ############################
697            # Create the controls
698          panel = wxPanel(self, -1, size=(100, 100))          #
   
         panelBox = wxBoxSizer(wxVERTICAL)  
   
         sizer = wxBoxSizer(wxHORIZONTAL)  
         sizer.Add(wxStaticText(panel, -1, _("Title: ")),  
             0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 4)  
         sizer.Add(wxTextCtrl(panel, ID_PROPERTY_TITLE, layer.Title()),  
                   1, wxGROW | wxALL, 4)  
         EVT_TEXT(self, ID_PROPERTY_TITLE, self._OnTitleChanged)  
   
         panelBox.Add(sizer, 0, wxGROW, 4)  
   
         panelBox.Add(wxStaticText(panel, -1,  
                                 _("Type: %s") % layer.ShapeType()),  
             0, wxALIGN_LEFT | wxALL, 4)  
   
   
         #####################  
   
         #panelBox = wxBoxSizer(wxVERTICAL)  
         classBox = wxStaticBoxSizer(  
                     wxStaticBox(panel, -1, _("Classification")), wxVERTICAL)  
699    
700            panel = wxPanel(self, -1)
701    
702            text_title = wxTextCtrl(panel, ID_PROPERTY_TITLE, layer.Title())
703          #          #
704          # make field choice box          # make field choice box
705          #          #
706          self.fields = wxChoice(panel, ID_PROPERTY_SELECT,)          self.fields = wxChoice(panel, ID_PROPERTY_SELECT,)
         #self.fields = wxComboBox(panel, ID_PROPERTY_SELECT, "",  
         #                             style = wxCB_READONLY)  
707    
708          self.num_cols = layer.table.field_count()          self.num_cols = layer.table.NumColumns()
709          # just assume the first field in case one hasn't been          # just assume the first field in case one hasn't been
710          # specified in the file.          # specified in the file.
711          self.__cur_field = 0          self.__cur_field = 0
# Line 742  class Classifier(NonModalDialog): Line 718  class Classifier(NonModalDialog):
718              self.fields.SetClientData(0, None)              self.fields.SetClientData(0, None)
719    
720          for i in range(self.num_cols):          for i in range(self.num_cols):
721              type, name, len, decc = layer.table.field_info(i)              name = layer.table.Column(i).name
722              self.fields.Append(name)              self.fields.Append(name)
723    
724              if name == field:              if name == field:
# Line 753  class Classifier(NonModalDialog): Line 729  class Classifier(NonModalDialog):
729                  self.fields.SetClientData(i + 1, None)                  self.fields.SetClientData(i + 1, None)
730    
731    
732          ###########          self.fieldTypeText = wxStaticText(panel, -1, "")
733    
734            button_gen = wxButton(panel, ID_PROPERTY_GENCLASS, _("Generate Class"))
735    
736          sizer = wxBoxSizer(wxHORIZONTAL)          button_add = wxButton(panel, ID_PROPERTY_ADD, _("Add"))
737          sizer.Add(wxStaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")),          button_moveup = wxButton(panel, ID_PROPERTY_MOVEUP, _("Move Up"))
738              0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4)          button_movedown = wxButton(panel, ID_PROPERTY_MOVEDOWN, _("Move Down"))
739          sizer.Add(self.fields, 1, wxGROW | wxALL, 4)          button_edit = wxButton(panel, ID_PROPERTY_EDITSYM, _("Edit Symbol"))
740          EVT_CHOICE(self, ID_PROPERTY_SELECT, self._OnFieldSelect)          button_remove = wxButton(panel, ID_PROPERTY_REMOVE, _("Remove"))
         #EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self._OnFieldSelect)  
741    
         classBox.Add(sizer, 0, wxGROW, 4)  
742    
743          self.fieldTypeText = wxStaticText(panel, -1, "")          button_try = wxButton(panel, ID_PROPERTY_TRY, _("Try"))
744          classBox.Add(self.fieldTypeText, 0,          button_revert = wxButton(panel, ID_PROPERTY_REVERT, _("Revert"))
745                       wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4)          button_ok = wxButton(panel, wxID_OK, _("OK"))
746            button_ok.SetDefault()
747            button_close = wxButton(panel, wxID_CANCEL, _("Close"))
748    
749            self.classGrid = ClassGrid(panel, self)
750    
751          #          # calling __SelectField after creating the classGrid fills in the
752          # Control Box          # grid with the correct information
753          #          self.fields.SetSelection(self.__cur_field)
754          controlBox = wxBoxSizer(wxHORIZONTAL)          self.__SelectField(self.__cur_field, group = group)
   
755    
756          ###########          ############################
757            # Layout the controls
758          #          #
         # Control buttons:  
         #  
         controlButtonBox = wxBoxSizer(wxVERTICAL)  
759    
760          button = wxButton(panel, ID_PROPERTY_GENCLASS, _("Generate Class"))          topBox = wxBoxSizer(wxVERTICAL)
761          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          panelBox = wxBoxSizer(wxVERTICAL)
762    
763          button = wxButton(panel, ID_PROPERTY_ADD, _("Add"))          sizer = wxBoxSizer(wxHORIZONTAL)
764          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)          sizer.Add(wxStaticText(panel, -1, _("Title: ")),
765                0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 4)
766            sizer.Add(text_title, 1, wxGROW, 0)
767    
768          button = wxButton(panel, ID_PROPERTY_MOVEUP, _("Move Up"))          panelBox.Add(sizer, 0, wxGROW, 4)
         controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)  
769    
770          button = wxButton(panel, ID_PROPERTY_MOVEDOWN, _("Move Down"))          panelBox.Add(wxStaticText(panel, -1,
771          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)                                  _("Type: %s") % layer.ShapeType()),
772                0, wxALIGN_LEFT | wxALL, 4)
773    
774          button = wxButton(panel, ID_PROPERTY_EDITSYM, _("Edit Symbol"))          classBox = wxStaticBoxSizer(
775          controlButtonBox.Add(button, 0, wxGROW | wxALL, 4)                      wxStaticBox(panel, -1, _("Classification")), wxVERTICAL)
776    
         controlButtonBox.Add(60, 20, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)  
777    
778          button = wxButton(panel, ID_PROPERTY_REMOVE, _("Remove"))          sizer = wxBoxSizer(wxHORIZONTAL)
779          controlButtonBox.Add(button, 0, wxGROW | wxALL | wxALIGN_BOTTOM, 4)          sizer.Add(wxStaticText(panel, ID_PROPERTY_FIELDTEXT, _("Field: ")),
780                0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 4)
781            sizer.Add(self.fields, 1, wxGROW | wxALL, 4)
782    
783            classBox.Add(sizer, 0, wxGROW, 4)
784    
785          ###########          classBox.Add(self.fieldTypeText, 0,
786          #                       wxGROW | wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE, 4)
         # Classification data table  
         #  
787    
788          self.classGrid = ClassGrid(panel, self)          controlBox = wxBoxSizer(wxHORIZONTAL)
789            controlButtonBox = wxBoxSizer(wxVERTICAL)
790    
791          # calling __SelectField after creating the classGrid fills in the          controlButtonBox.Add(button_gen, 0, wxGROW|wxALL, 4)
792          # grid with the correct information          controlButtonBox.Add(button_add, 0, wxGROW|wxALL, 4)
793          self.fields.SetSelection(self.__cur_field)          controlButtonBox.Add(button_moveup, 0, wxGROW|wxALL, 4)
794          self.__SelectField(self.__cur_field, group = group)          controlButtonBox.Add(button_movedown, 0, wxGROW|wxALL, 4)
795            controlButtonBox.Add(button_edit, 0, wxGROW|wxALL, 4)
796            controlButtonBox.Add(60, 20, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4)
797            controlButtonBox.Add(button_remove, 0, wxGROW|wxALL|wxALIGN_BOTTOM, 4)
798    
799          controlBox.Add(self.classGrid, 1, wxGROW, 0)          controlBox.Add(self.classGrid, 1, wxGROW, 0)
800          controlBox.Add(controlButtonBox, 0, wxGROW, 10)          controlBox.Add(controlButtonBox, 0, wxGROW, 10)
# Line 821  class Classifier(NonModalDialog): Line 802  class Classifier(NonModalDialog):
802          classBox.Add(controlBox, 1, wxGROW, 10)          classBox.Add(controlBox, 1, wxGROW, 10)
803          panelBox.Add(classBox, 1, wxGROW, 0)          panelBox.Add(classBox, 1, wxGROW, 0)
804    
         EVT_BUTTON(self, ID_PROPERTY_ADD, self._OnAdd)  
         EVT_BUTTON(self, ID_PROPERTY_EDITSYM, self._OnEditSymbol)  
         EVT_BUTTON(self, ID_PROPERTY_REMOVE, self._OnRemove)  
         EVT_BUTTON(self, ID_PROPERTY_GENCLASS, self._OnGenClass)  
         EVT_BUTTON(self, ID_PROPERTY_MOVEUP, self._OnMoveUp)  
         EVT_BUTTON(self, ID_PROPERTY_MOVEDOWN, self._OnMoveDown)  
   
         ###########  
805    
806            buttonBox = wxBoxSizer(wxHORIZONTAL)
807            buttonBox.Add(button_try, 0, wxALL, 4)
808            buttonBox.Add(60, 20, 0, wxALL, 4)
809            buttonBox.Add(button_revert, 0, wxALL, 4)
810            buttonBox.Add(60, 20, 0, wxALL, 4)
811            buttonBox.Add(button_ok, 0, wxALL, 4)
812            buttonBox.Add(60, 20, 0, wxALL, 4)
813            buttonBox.Add(button_close, 0, wxALL, 4)
814            panelBox.Add(buttonBox, 0,
815                wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0)
816    
817          panel.SetAutoLayout(True)          panel.SetAutoLayout(True)
818          panel.SetSizer(panelBox)          panel.SetSizer(panelBox)
819            panelBox.Fit(panel)
820          panelBox.SetSizeHints(panel)          panelBox.SetSizeHints(panel)
821    
822          topBox.Add(panel, 1, wxGROW | wxALL, 4)          topBox.Add(panel, 1, wxGROW | wxALL, 4)
823    
824          ###########          self.SetAutoLayout(True)
825            self.SetSizer(topBox)
826            topBox.Fit(self)
827            topBox.SetSizeHints(self)
828            self.Layout()
829    
830          buttonBox = wxBoxSizer(wxHORIZONTAL)          ###########
         buttonBox.Add(wxButton(self, ID_PROPERTY_TRY, _("Try")),  
                       0, wxALL, 4)  
         buttonBox.Add(60, 20, 0, wxALL, 4)  
         buttonBox.Add(wxButton(self, ID_PROPERTY_REVERT, _("Revert")),  
                       0, wxALL, 4)  
         buttonBox.Add(60, 20, 0, wxALL, 4)  
         buttonBox.Add(wxButton(self, ID_PROPERTY_OK, _("OK")),  
                       0, wxALL, 4)  
         buttonBox.Add(60, 20, 0, wxALL, 4)  
         buttonBox.Add(wxButton(self, ID_PROPERTY_CLOSE, _("Close")),  
                       0, wxALL, 4)  
         topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 0)  
831    
832          EVT_BUTTON(self, ID_PROPERTY_OK, self._OnOK)          EVT_CHOICE(self, ID_PROPERTY_SELECT, self._OnFieldSelect)
833            EVT_TEXT(self, ID_PROPERTY_TITLE, self._OnTitleChanged)
834            EVT_BUTTON(self, wxID_OK, self._OnOK)
835          EVT_BUTTON(self, ID_PROPERTY_TRY, self._OnTry)          EVT_BUTTON(self, ID_PROPERTY_TRY, self._OnTry)
836          EVT_BUTTON(self, ID_PROPERTY_CLOSE, self._OnCloseBtn)          EVT_BUTTON(self, wxID_CANCEL, self._OnCloseBtn)
837          EVT_BUTTON(self, ID_PROPERTY_REVERT, self._OnRevert)          EVT_BUTTON(self, ID_PROPERTY_REVERT, self._OnRevert)
838    
839          ###########          EVT_BUTTON(self, ID_PROPERTY_ADD, self._OnAdd)
840            EVT_BUTTON(self, ID_PROPERTY_EDITSYM, self._OnEditSymbol)
841          topBox.SetSizeHints(self)          EVT_BUTTON(self, ID_PROPERTY_REMOVE, self._OnRemove)
842          self.SetAutoLayout(True)          EVT_BUTTON(self, ID_PROPERTY_GENCLASS, self._OnGenClass)
843          self.SetSizer(topBox)          EVT_BUTTON(self, ID_PROPERTY_MOVEUP, self._OnMoveUp)
844            EVT_BUTTON(self, ID_PROPERTY_MOVEDOWN, self._OnMoveDown)
845    
         #self.Fit()  
846          ######################          ######################
847    
848            self.fields.SetFocus()
849          self.haveApplied = False          self.haveApplied = False
850    
851      def EditSymbol(self, row):      def EditSymbol(self, row):
# Line 1002  class Classifier(NonModalDialog): Line 981  class Classifier(NonModalDialog):
981          self._OnTry(event)          self._OnTry(event)
982          self.Close()          self.Close()
983    
984        def OnClose(self, event):
985            NonModalDialog.OnClose(self, event)
986    
987      def _OnCloseBtn(self, event):      def _OnCloseBtn(self, event):
988          """Close is similar to Cancel except that any changes that were          """Close is similar to Cancel except that any changes that were
989          made and applied remain applied, but the currently displayed          made and applied remain applied, but the currently displayed
# Line 1079  class Classifier(NonModalDialog): Line 1061  class Classifier(NonModalDialog):
1061      def __EnableButtons(self, case, enable):      def __EnableButtons(self, case, enable):
1062    
1063          if case == EB_LAYER_TITLE:            if case == EB_LAYER_TITLE:  
1064              list = (ID_PROPERTY_OK,              list = (wxID_OK,
1065                      ID_PROPERTY_CLOSE)                      wxID_CANCEL)
1066    
1067          elif case == EB_SELECT_FIELD:          elif case == EB_SELECT_FIELD:
1068              list = (ID_PROPERTY_GENCLASS,              list = (ID_PROPERTY_GENCLASS,
# Line 1099  class Classifier(NonModalDialog): Line 1081  class Classifier(NonModalDialog):
1081          for id in list:          for id in list:
1082              self.FindWindowById(id).Enable(enable)              self.FindWindowById(id).Enable(enable)
1083    
 ID_SELPROP_OK = 4001  
 ID_SELPROP_CANCEL = 4002  
1084  ID_SELPROP_SPINCTRL = 4002  ID_SELPROP_SPINCTRL = 4002
1085  ID_SELPROP_PREVIEW = 4003  ID_SELPROP_PREVIEW = 4003
1086  ID_SELPROP_STROKECLR = 4004  ID_SELPROP_STROKECLR = 4004
# Line 1139  class SelectPropertiesDialog(wxDialog): Line 1119  class SelectPropertiesDialog(wxDialog):
1119          ctrlBox = wxBoxSizer(wxVERTICAL)          ctrlBox = wxBoxSizer(wxVERTICAL)
1120    
1121          lineColorBox = wxBoxSizer(wxHORIZONTAL)          lineColorBox = wxBoxSizer(wxHORIZONTAL)
1122          lineColorBox.Add(          button = wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color"))
1123              wxButton(self, ID_SELPROP_STROKECLR, _("Change Line Color")),          button.SetFocus()
1124              1, wxALL | wxGROW, 4)          lineColorBox.Add(button, 1, wxALL | wxGROW, 4)
1125          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)          EVT_BUTTON(self, ID_SELPROP_STROKECLR, self._OnChangeLineColor)
1126    
1127          lineColorBox.Add(          lineColorBox.Add(
# Line 1187  class SelectPropertiesDialog(wxDialog): Line 1167  class SelectPropertiesDialog(wxDialog):
1167          # Control buttons:          # Control buttons:
1168          #          #
1169          buttonBox = wxBoxSizer(wxHORIZONTAL)          buttonBox = wxBoxSizer(wxHORIZONTAL)
1170          buttonBox.Add(wxButton(self, ID_SELPROP_OK, _("OK")),          button_ok = wxButton(self, wxID_OK, _("OK"))
1171                        0, wxALL, 4)          button_ok.SetDefault()
1172          buttonBox.Add(wxButton(self, ID_SELPROP_CANCEL, _("Cancel")),          buttonBox.Add(button_ok, 0, wxALL, 4)
1173            buttonBox.Add(wxButton(self, wxID_CANCEL, _("Cancel")),
1174                        0, wxALL, 4)                        0, wxALL, 4)
1175          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)          topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 10)
1176                                                                                                                                                                    
1177          EVT_BUTTON(self, ID_SELPROP_OK, self._OnOK)          #EVT_BUTTON(self, wxID_OK, self._OnOK)
1178          EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)          #EVT_BUTTON(self, ID_SELPROP_CANCEL, self._OnCancel)
1179                                                                                                                                                                    
1180          self.SetAutoLayout(True)          self.SetAutoLayout(True)
1181          self.SetSizer(topBox)          self.SetSizer(topBox)
1182          topBox.Fit(self)          topBox.Fit(self)
1183          topBox.SetSizeHints(self)          topBox.SetSizeHints(self)
1184    
1185      def _OnOK(self, event):      def OnOK(self, event):
1186          self.EndModal(wxID_OK)          self.EndModal(wxID_OK)
1187    
1188      def _OnCancel(self, event):      def OnCancel(self, event):
1189          self.EndModal(wxID_CANCEL)          self.EndModal(wxID_CANCEL)
1190    
1191      def _OnSpin(self, event):      def _OnSpin(self, event):

Legend:
Removed from v.783  
changed lines
  Added in v.835

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26