Changeset 371
- Timestamp:
- Thu Jan 31 01:51:46 2008
- Files:
-
- scripts/trunk/ORM/Install ORM Tables.py (modified) (diff)
- scripts/trunk/ORM/Open ORM Window.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
scripts/trunk/ORM/Install ORM Tables.py
r354 r371 1 1 # Install ORM Tables 2 # Copyright 2004, 2005, 2006, 2007 by Brian C. Christensen 2 # Copyright 2004, 2005, 2006, 2007, 2008 by Brian C. Christensen 2 2 3 3 # This file is part of GanttPV. … … 22 22 # 070807 - added object and report_object 23 23 # 070907 - more corrections and additions 24 # 080130 - several minor changes 24 25 25 26 # These design notes are intended to explore the problem. They include more than will be … … 86 87 # - ProjectID (Schema) 87 88 # - Nary (1 ..) 88 # - ORMReadingID # prefered reading 89 # - ORMReadingAltID # do I need this???? 89 # - ORMFactReadingID # prefered reading 90 90 # - Derived [None, '*', '+'] 91 91 # - DerivationRule 92 92 93 # in graphic 94 # - Rotation ['h', 'v'] # horizontal, vertical 95 # - Order ['n', 'r'] # roles display in normal or reversed order 96 97 93 98 rt = { 'Name': 'ORM FactTypes', 'TableA': 'ORMFactType', 'TableB': None, 'Also': None, 'AllOrEach': 'each', 94 99 'SuggestedColumns': ',ID;,Name;,Nary;,ORMReadingID;,Derived;,DerivationRule;,DateAdded' } … … 100 105 { 'Name': 'Name', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 101 106 { 'Name': 'Nary', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 102 { 'Name': 'ORMReadingID', 'Label': 'ReadingID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 103 { 'Name': 'ORMReadingAltID','Label': 'ReadingAltID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 75 }, 107 { 'Name': 'ORMFactReadingID', 'Label': 'ReadingID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 104 108 { 'Name': 'Derived', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 50 }, 105 109 { 'Name': 'DerivationRule', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 180 }, … … 113 117 # - ProjectID (Schema) 114 118 # - ORMFactID 119 # - Preference (integer 1 or 2) 115 120 # - Reading (reading text refers to role ids??) 121 # - ORMReadingAltID # do I need this???? 122 123 # in graphic 124 # - Orientation ['l', 'r', 'u', 'd'] # left, right, up, down 116 125 117 rt = { 'Name': 'ORM Readings', 'TableA': 'ORMReading', 'TableB': None, 'Also': None, 'AllOrEach': 'each',126 rt = { 'Name': 'ORM FactReadings', 'TableA': 'ORMFactReading', 'TableB': None, 'Also': None, 'AllOrEach': 'each', 117 126 'SuggestedColumns': ',ID;,ORMFactTypeID;,Reading;,DateAdded' } 118 127 ct = [ … … 121 130 { 'Name': 'Project/Name', 'Label': 'Project\nName', 'DataType': 't', 'AccessType': 'i', 'T': 'A', 'Edit': False, 'Width': 100 }, 122 131 { 'Name': 'ID', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35 }, 123 { 'Name': 'ORMFactTypeID', 'Label': 'ORMFactTypeID','DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 124 { 'Name': 'Reading', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 132 { 'Name': 'ORMFactTypeID', 'Label': 'ORMFactTypeID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 133 { 'Name': 'Preference', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 50 }, 134 { 'Name': 'Reading', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 135 { 'Name': 'ORMFactReadingAltID','Label': 'FactReadingAltID', 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 75 }, 136 { 'Name': 'Unique', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 125 137 { 'Name': 'DateAdded', 'Label': 'Date\nAdded', 'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 80 }, 126 138 ] … … 149 161 { 'Name': 'Mandatory', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 150 162 { 'Name': 'Unique', 'Label': None, 'DataType': 't', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 35 }, 163 { 'Name': 'ORMRoleLabelID', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 164 { 'Name': 'DateAdded', 'Label': 'Date\nAdded', 'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 80 }, 165 ] 166 Data.AddReportType(rt, ct) 167 168 # shouldn't really be needed, but it gives the grapic something to point to 169 rt = { 'Name': 'ORM Role Label', 'TableA': 'ORMRoleLabel', 'TableB': None, 'Also': None, 'AllOrEach': 'each', 170 'SuggestedColumns': ',ID;,ORMRoleID' } 171 ct = [ 172 { 'Name': 'ID', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35 }, 173 { 'Name': 'ORMRoleID', 'Label': None, 'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 100 }, 151 174 { 'Name': 'DateAdded', 'Label': 'Date\nAdded', 'DataType': 'd', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 80 }, 152 175 ] … … 298 321 Data.AddAlias('ORMSubtype', 'ORMObjectType') 299 322 300 Data.Database['ORMReadingAlt'] = Data.Database['ORMReading'] 301 Data.AddAlias('ORMReadingAlt', 'ORMReading') 323 Data.Database['ORMFactReadingAlt'] = Data.Database['ORMFactReading'] 324 Data.AddAlias('ORMFactReadingAlt', 'ORMFactReading') 302 325 303 326 Data.SetUndo("Install ORM Tables") -
scripts/trunk/ORM/Open ORM Window.py
r370 r371 61 61 # import images 62 62 import sys 63 import math # to calculate angles of connectors 63 64 64 65 #--------------------------------------------------------------------------- … … 1255 1256 return report_object.db.GetObject('ReportRow', newrowid) 1256 1257 1258 def AddFollowerToDiagram(report_object, object_type, nodea): 1259 ''' Add report row, add target object, connect to end objects''' 1260 if debug: print 'adding %s to %s' % (object_type, report_object) 1261 project = report_object.Get('Project') 1262 projectid = project.ID 1263 today = Data.TodayString() 1264 1265 # I think that subtype is the only example of linking the same types to each other 1266 1267 model = {'Table': object_type, 'ProjectID': projectid, 'DateAdded': today} 1268 model[nodea.TableName + 'ID'] = nodea.TableID 1269 # if object_type == 'ORMFactReading': 1270 # fact = nodea.Get('Target') 1271 # fact.Nary += 1 1272 # model['Seq'] = fact.Nary 1273 # else: 1274 # model[nodeb.TableName + 'ID'] = nodeb.TableID 1275 object_id = Data.Update(model)['ID'] 1276 if object_type == 'ORMFactReading': 1277 nodea.Get('Target').ORMFactReadingID = object_id # pointer back 1278 elif object_type == 'ORMRoleLabel': # is this really needed 1279 nodea.Get('Target').ORMRoleLabelID = object_id # pointer back 1280 1281 graphic = {'Table': 'ReportRow', 'ProjectID': projectid, 'ReportID': report_object.ID, 1282 'TableName': object_type, 'TableID': object_id, 1283 'NodeAID': nodea.ID, # 'NodeBID': nodeb.ID, # objects pointed to 1284 'PosX': nodea.PosX, 'PosY': nodea.PosY+10, 1285 'DateAdded': today} 1286 newrowid = Data.Update(graphic)['ID'] 1287 1288 rlist = Data.GetRowList(report_object.ID) # insert row at beginning of row list 1289 rlist.append(newrowid) 1290 Data.ReorderReportRows(report_object.ID, rlist) 1291 1292 return report_object.db.GetObject('ReportRow', newrowid) 1293 1257 1294 #--------------------------------------------------------------------------- 1258 1295 # Below here it is OGL … … 1733 1770 "BLACK", 1734 1771 "BLUE", 1772 "WHITE", 1773 "VIOLET", 1735 1774 "BLUE VIOLET", 1736 1775 "BROWN", … … 1746 1785 "RED", 1747 1786 "SKY BLUE", 1748 "VIOLET",1749 1787 "YELLOW", 1750 1788 ] … … 1822 1860 def SetSelected(self): 1823 1861 self._SetInShell('IsSelected', True) 1862 self._SetInShell('CharMode', '') 1824 1863 def ClearSelected(self): 1825 1864 self._SetInShell('IsSelected', False) 1865 1826 1866 def GetSelected(self): 1827 1867 return self.IsSelected … … 1908 1948 nodeb.AddFollower(self) 1909 1949 1950 class ORMFollowText(ORMBox): 1951 def Follow(self): 1952 nodea = self.Get('NodeA') # these objects might not already be in the diagram 1953 # if not already in the diagram , then create the nodes 1954 print 'nodea type', nodea.__class__ 1955 if not isinstance(nodea, ORMShape): 1956 self.canvas.CreateNode(self.canvas.pdc, nodea) 1957 nodea.AddFollower(self) # must be the right subtype to have this method 1958 1910 1959 class ORMObjectTypeShape(ORMBox): 1911 1960 def Draw(self, dc): … … 1926 1975 text = orm_object.Name or 'Default Name' 1927 1976 if orm_object.Independent: 1928 text += "!" 1977 text += " !" 1928 1977 if orm_object.Derived: 1929 text += orm_object.Derived 1978 text += " " + orm_object.Derived 1929 1978 lines = text.splitlines() 1930 1979 word = orm_object.RefMode or '' … … 1949 1998 1950 1999 if orm_object.Type == 'Entity': 1951 pen = self.canvas.CachedPen( 1, 1, wx.SOLID)2000 pen = self.canvas.CachedPen(0, 1, wx.SOLID) 1951 2000 else: 1952 pen = self.canvas.CachedPen( 1, 1, wx.DOT)2001 pen = self.canvas.CachedPen(0, 1, wx.DOT) 1952 2001 dc.SetPen(pen) 1953 2002 # dc.SetBrush(self.RandomBrush()) 1954 2003 if self.GetSelected(): 1955 2004 dc.SetBrush(self.canvas.CachedBrush((210,210,210))) 2005 elif self.canvas.keyboard_nav_dcid == self.dcid: 2006 dc.SetBrush(self.canvas.CachedBrush((255, 102, 204))) # (150,220,220))) 1956 2007 else: 1957 2008 dc.SetBrush(self.canvas.CachedBrush((254,254,254,128))) … … 1983 2034 if debug: print "char", ord(char), "'", char, "'" 1984 2035 orm_object = self.Get('Target') 1985 if orm_object.Name: 1986 if char == '\x08': # this is for windows, cross platform? 1987 orm_object.Name = orm_object.Name[:-1] 1988 elif char == '\r': # this is for windows, cross platform? 1989 orm_object.Name += '\n' 2036 2037 if char == '(': 2038 self._SetInShell('CharMode', 'refmode') 2039 return 2040 elif char == ')': 2041 self._SetInShell('CharMode', '') 2042 return 2043 elif char == '!': 2044 if orm_object.Independent == '!': 2045 orm_object.Independent = '' 1990 2046 else: 1991 orm_object.Name += char 1992 else: 1993 if char in '\r\x08': # this is for windows, cross platform? 1994 pass 2047 orm_object.Independent = '!' 2048 return 2049 elif char in ('+', '*'): 2050 if orm_object.Derived == char: 2051 orm_object.Derived = '' 1995 2052 else: 1996 orm_object.Name = char 2053 orm_object.Derived = char 2054 return 2055 elif char in ('$'): 2056 if orm_object.Type == 'Entity': 2057 orm_object.Type = 'Value' 2058 else: 2059 orm_object.Type = 'Entity' 2060 return 2061 2062 if self.CharMode == '': 2063 if orm_object.Name: 2064 if char == '\x08': # this is for windows, cross platform? 2065 orm_object.Name = orm_object.Name[:-1] 2066 elif char == '\r': # this is for windows, cross platform? 2067 orm_object.Name += '\n' 2068 else: 2069 orm_object.Name += char 2070 else: 2071 if char in '\r\x08': # this is for windows, cross platform? 2072 pass 2073 else: 2074 orm_object.Name = char 2075 elif self.CharMode == 'refmode': 2076 if orm_object.RefMode: 2077 if char == '\x08': # this is for windows, cross platform? 2078 orm_object.RefMode = orm_object.RefMode[:-1] 2079 elif char == '\r': # this is for windows, cross platform? 2080 orm_object.RefMode += '\n' 2081 else: 2082 orm_object.RefMode += char 2083 else: 2084 if char in '\r\x08': # this is for windows, cross platform? 2085 pass 2086 else: 2087 orm_object.RefMode = char 1997 2088 1998 2089 class ORMFactTypeShape(ORMBox): … … 2019 2110 box_h = h + 6 2020 2111 2021 pen = self.canvas.CachedPen( 1, 1, wx.SOLID)2112 pen = self.canvas.CachedPen(0, 1, wx.SOLID) 2021 2112 dc.SetPen(pen) 2022 2113 if self.GetSelected(): 2023 2114 dc.SetBrush(self.canvas.CachedBrush((210,210,210))) 2115 elif self.canvas.keyboard_nav_dcid == self.dcid: 2116 dc.SetBrush(self.canvas.CachedBrush((255, 102, 204))) # (150,220,220))) 2024 2117 else: 2025 2118 dc.SetBrush(self.canvas.CachedBrush((254,254,254))) 2026 2119 # dc.SetBrush(self.canvas.CachedBrush('White')) 2027 2120 for i in range(nary): 2028 dc.DrawRectangle(x+i*role_box_width,y,role_box_width+1,h) 2121 dc.DrawRectangle(x+i*role_box_width,y + 3,role_box_width+1,h) 2028 2121 2029 r = wx.Rect(x,y,box_w,box_h) 2122 role_unique = False 2123 roles = orm_object.GetList('ORMRole') 2124 roles.sort(cmp=lambda x,y: cmp(x.Seq, y.Seq)) 2125 for i in range(len(roles)): 2126 if roles[i].Unique: 2127 role_unique = True 2128 if roles[i].Unique == 'a': 2129 pen = self.canvas.CachedPen(3, 1, wx.SOLID) 2130 else: # 'd' 2131 pen = self.canvas.CachedPen(1, 1, wx.SOLID) 2132 dc.SetPen(pen) 2133 x0 = x+i*role_box_width + 2 2134 y0 = y 2135 x1 = x0 + role_box_width - 3 2136 y1 = y 2137 dc.DrawLine(x0, y0, x1, y1) 2138 2139 if not role_unique and orm_object.Unique: 2140 pen = self.canvas.CachedPen(3, 1, wx.SOLID) 2141 dc.SetPen(pen) 2142 x0 = x+ 1 2143 y0 = y 2144 x1 = x0 + len(roles) * role_box_width - 2 2145 y1 = y 2146 dc.DrawLine(x0, y0, x1, y1) 2147 2148 r = wx.Rect(x,y,box_w,box_h + 3) 2030 2149 r.Inflate(pen.GetWidth(),pen.GetWidth()) 2031 2150 dc.SetIdBounds(self.dcid,r) … … 2040 2159 2041 2160 orm_object = self.Get('Target') 2042 if orm_object.Name: 2161 if char in ('+', '*'): 2162 if orm_object.Derived == char: 2163 orm_object.Derived = '' 2164 else: 2165 orm_object.Derived = char 2166 return 2167 2168 orm_object = orm_object.Get('ORMFactReading') 2169 if orm_object.Reading: 2043 2170 if char == '\x08': # this is for windows, cross platform? 2044 orm_object. Name = orm_object.Name[:-1]2171 orm_object.Reading = orm_object.Reading[:-1] 2044 2171 elif char == '\r': # this is for windows, cross platform? 2045 orm_object. Name+= '\n'2172 orm_object.Reading += '\n' 2045 2172 else: 2046 orm_object. Name+= char2173 orm_object.Reading += char 2046 2173 else: 2047 2174 if char in '\r\x08': # this is for windows, cross platform? 2048 2175 pass 2049 2176 else: 2050 orm_object. Name= char2177 orm_object.Reading = char 2050 2177 2051 2178 2052 class ORM ReadingShape(ORMBox):2179 class ORMFactReadingShape(ORMFollowText): 2052 2179 def Draw(self, dc): 2053 2180 orm_object = self.Get('Target') 2181 # orm_object = self.Get('ORMReading') # make sure this is there 2054 2182 x, y = self.GetPos() 2055 2183 … … 2062 2190 dc.SetId(self.dcid) 2063 2191 2064 text = orm_object. Textor ''2192 text = orm_object.Reading or '' 2064 2192 lines = text.splitlines() 2065 2193 sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ] # pull out only w and h … … 2075 2203 box_y = y - box_h/2 2076 2204 2077 pen = self.canvas.CachedPen(1, 1, wx.DOT) 2205 if text == '': 2206 pen = self.canvas.CachedPen(1, 1, wx.DOT) 2207 else: 2208 pen = self.canvas.CachedPen(2, 1, wx.SOLID) 2078 2209 dc.SetPen(pen) 2079 2210 # dc.SetBrush(self.RandomBrush()) 2080 dc.SetBrush(self.canvas.CachedBrush('White')) 2211 if self.GetSelected(): 2212 dc.SetBrush(self.canvas.CachedBrush((210,210,210))) 2213 else: 2214 dc.SetBrush(self.canvas.CachedBrush((254,254,254))) 2215 # dc.SetBrush(self.canvas.CachedBrush('White')) 2081 2216 dc.DrawRectangle(box_x,box_y,box_w,box_h) 2082 2217 … … 2099 2234 if debug: print "char", ord(char), "'", char, "'" 2100 2235 orm_object = self.Get('Target') 2101 if orm_object. Text:2236 if orm_object.Reading: 2101 2236 if char == '\x08': # this is for windows, cross platform? 2102 orm_object. Text = orm_object.Text[:-1]2237 orm_object.Reading = orm_object.Reading[:-1] 2102 2237 elif char == '\r': # this is for windows, cross platform? 2103 orm_object. Text+= '\n'2238 orm_object.Reading += '\n' 2103 2238 else: 2104 orm_object. Text+= char2239 orm_object.Reading += char 2104 2239 else: 2105 2240 if char in '\r\x08': # this is for windows, cross platform? 2106 2241 pass 2107 2242 else: 2108 orm_object.Text = char 2243 orm_object.Reading = char 2244 2245 2246 class ORMRoleLabelShape(ORMFollowText): 2247 def Draw(self, dc): 2248 orm_object = self.Get('Target') 2249 orm_object = orm_object.Get('ORMRole') # make sure this is there? 2250 x, y = self.GetPos() 2251 2252 dc.ClearId(self.dcid) 2253 dc.SetId(self.dcid) 2254 2255 text = orm_object.Name or '' 2256 lines = text.splitlines() 2257 sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ] # pull out only w and h 2258 w = 5 2259 h = 0 2260 for line_w,line_h in sizes: 2261 w = max(w, line_w) 2262 h += line_h 2263 box_w = w + 6 2264 box_h = h + 6 2265 box_x = x - box_w/2 2266 box_y = y - box_h/2 2109 2267 2268 ### don't draw anything 2269 if text == '': 2270 # pen = self.canvas.CachedPen(1, 1, wx.DOT) 2271 pen = self.canvas.CachedPen(1, 1, wx.SOLID) 2272 else: 2273 pen = self.canvas.CachedPen(2, 1, wx.SOLID) 2274 dc.SetPen(pen) 2275 ### dc.SetBrush(self.RandomBrush()) 2276 ## if self.GetSelected(): 2277 ## dc.SetBrush(self.canvas.CachedBrush((210,210,210))) 2278 ## else: 2279 ## dc.SetBrush(self.canvas.CachedBrush((254,254,254))) 2280 ### dc.SetBrush(self.canvas.CachedBrush('White')) 2281 ## dc.DrawRectangle(box_x,box_y,box_w,box_h) 2282 ## 2283 ## dc.SetFont(self.canvas.GetFont()) 2284 ### dc.SetTextForeground(self.RandomColor()) 2285 ## dc.SetTextForeground('Black') 2286 ## dc.SetTextBackground('White') 2287 ## w = 3; h = 2 2288 ## for i in range(len(lines)): 2289 ## line = lines[i] 2290 ## line_w, line_h = sizes[i] 2291 ## dc.DrawText(line, box_x+w, box_y+h) 2292 ## h += line_h 2293 2294 r = wx.Rect(box_x,box_y,box_w,box_h) 2295 r.Inflate(pen.GetWidth(),pen.GetWidth()) 2296 dc.SetIdBounds(self.dcid,r) 2297 2298 def Char(self, char): 2299 if debug: print "char", ord(char), "'", char, "'" 2300 orm_object = self.Get('Target') 2301 orm_object = orm_object.Get('ORMRole') # make sure this is there? 2302 if orm_object.Name: 2303 if char == '\x08': # this is for windows, cross platform? 2304 orm_object.Name = orm_object.Name[:-1] 2305 elif char == '\r': # this is for windows, cross platform? 2306 orm_object.Name += '\n' 2307 else: 2308 orm_object.Name += char 2309 else: 2310 if char in '\r\x08': # this is for windows, cross platform? 2311 pass 2312 else: 2313 orm_object.Name = char 2110 2314 2111 2315 class ORMNoteShape(ORMBox): … … 2255 2459 orm_object = self.Get('Target') 2256 2460 seq = orm_object.Seq or 1 2257 rolebox_height = 8 # 12 # must match constants in Fact 2461 rolebox_height = 8 + 3 # 12 # must match constants in Fact 2257 2461 rolebox_width = 12 # 12 2258 2462 … … 2299 2503 box_h = maxy - miny + 6 2300 2504 2301 pen = self.canvas.CachedPen( 1, 1, wx.SOLID)2505 pen = self.canvas.CachedPen(0, 1, wx.SOLID) 2301 2505 dc.SetPen(pen) 2302 2506 dc.DrawLine(enda[0], enda[1], endb[0], endb[1]) … … 2307 2511 2308 2512 # place mandatory participation 2309 if 0: # mandatory2513 if orm_object.Mandatory: # mandatory 2309 2513 dot_size = 3 2310 2514 if 1: # one end … … 2313 2517 else: 2314 2518 dot = wx.lib.ogl.GetPointOnLine(endb[0], endb[1], enda[0], enda[1], dot_size) 2315 pen = self.canvas.CachedPen(1, 1, wx.SOLID) 2519 if orm_object.Mandatory == 'a': # 2520 pen = self.canvas.CachedPen(3, 1, wx.SOLID) 2521 dc.SetBrush(self.canvas.CachedBrush('Violet')) 2522 else: # d 2523 pen = self.canvas.CachedPen(1, 1, wx.SOLID) 2524 dc.SetBrush(self.canvas.CachedBrush('Blue')) 2316 2525 dc.SetPen(pen) 2317 dc.SetBrush(self.canvas.CachedBrush('Blue'))2318 2526 dc.DrawCircle(int(dot[0]),int(dot[1]),dot_size) 2319 2527 … … 2322 2530 dc.SetIdBounds(self.dcid,r) 2323 2531 2532 def Char(self, char): 2533 if debug: print "char", ord(char), "'", char, "'" 2534 orm_object = self.Get('Target') 2535 if orm_object.Name: 2536 if char == '\x08': # this is for windows, cross platform? 2537 orm_object.Name = orm_object.Name[:-1] 2538 elif char == '\r': # this is for windows, cross platform? 2539 orm_object.Name += '\n' 2540 else: 2541 orm_object.Name += char 2542 else: 2543 if char in '\r\x08': # this is for windows, cross platform? 2544 pass 2545 else: 2546 orm_object.Name = char 2547 2324 2548 class ORMSubtypeConnectorShape(ORMConnector): 2325 2549 def Draw(self, dc): … … 2450 2674 self.drawing = False 2451 2675 self.selection = {} # keys = selected ids 2676 self.keyboard_nav_dcid = False 2452 2677 2453 2678 font = self.GetFont() … … 2543 2768 menu.Append(self.popupID3, "Note") 2544 2769 menu.Append(self.popupID4, "Constraint") 2545 # menu.Append(self.popupID4, "Four")2770 menu.Append(self.popupID5, "Select All") 2545 2770 # menu.Append(self.popupID5, "Undo - not implemented") 2546 2771 # menu.Append(self.popupID6, "Redo - not implemented") … … 2568 2793 2569 2794 def OnPopupTwo(self, event): 2570 new_shape = self.AddNode('ORMFactType', self.popupx, self.popupy) 2795 new_fact = self.AddNode('ORMFactType', self.popupx, self.popupy) 2796 new_reading = self.AddFollower('ORMFactReading', new_fact) 2571 2797 self.ClearSelection() 2572 self.SelectObject(new_ shape.dcid)2798 self.SelectObject(new_fact.dcid) 2572 2798 Data.SetUndo('Add Fact') 2573 2799 # id = self.shapeid_to_dcid_xref[new_shape.ID] 2574 self.RedisplayID(new_shape.dcid) 2800 self.RedisplayID(new_fact.dcid) 2801 self.RedisplayID(new_reading.dcid) 2575 2802 2576 2803 def OnPopupThree(self, event): … … 2592 2819 2593 2820 def OnPopupFive(self, event): 2594 self. log.WriteText("Popup five\n")2821 self.SelectAll() 2594 2821 2595 2822 def OnPopupSix(self, event): … … 2619 2846 # for clarity. 2620 2847 if not hasattr(self, "popsID1"): 2621 self.popsID1 = wx.NewId() 2622 self.popsID2 = wx.NewId() 2623 self.popsID3 = wx.NewId() 2624 self.popsID4 = wx.NewId() 2625 self.popsID5 = wx.NewId() 2626 self.popsID6 = wx.NewId() 2627 self.popsID7 = wx.NewId() 2628 self.popsID8 = wx.NewId() 2629 self.popsID9 = wx.NewId() 2630 2631 self.Bind(wx.EVT_MENU, self.OnPopsOne, id=self.popsID1) 2632 self.Bind(wx.EVT_MENU, self.OnPopsTwo, id=self.popsID2) 2633 self.Bind(wx.EVT_MENU, self.OnPopsThree, id=self.popsID3) 2634 self.Bind(wx.EVT_MENU, self.OnPopsFour, id=self.popsID4) 2635 self.Bind(wx.EVT_MENU, self.OnPopsFive, id=self.popsID5) 2636 self.Bind(wx.EVT_MENU, self.OnPopsSix, id=self.popsID6) 2637 self.Bind(wx.EVT_MENU, self.OnPopsSeven, id=self.popsID7) 2638 self.Bind(wx.EVT_MENU, self.OnPopsEight, id=self.popsID8) 2639 self.Bind(wx.EVT_MENU, self.OnPopsNine, id=self.popsID9) 2848 self.popsID01 = wx.NewId() 2849 self.popsID02 = wx.NewId() 2850 self.popsID03 = wx.NewId() 2851 self.popsID04 = wx.NewId() 2852 self.popsID05 = wx.NewId() 2853 self.popsID06 = wx.NewId() 2854 self.popsID07 = wx.NewId() 2855 self.popsID08 = wx.NewId() 2856 self.popsID09 = wx.NewId() 2857 self.popsID11 = wx.NewId() 2858 self.popsID12 = wx.NewId() 2859 self.popsID13 = wx.NewId() 2860 self.popsID14 = wx.NewId() 2861 self.popsID15 = wx.NewId() 2862 self.popsID16 = wx.NewId() 2863 2864 self.Bind(wx.EVT_MENU, self.OnPops01, id=self.popsID01) 2865 self.Bind(wx.EVT_MENU, self.OnPops02, id=self.popsID02) 2866 self.Bind(wx.EVT_MENU, self.OnPops03, id=self.popsID03) 2867 self.Bind(wx.EVT_MENU, self.OnPops04, id=self.popsID04) 2868 self.Bind(wx.EVT_MENU, self.OnPops05, id=self.popsID05) 2869 self.Bind(wx.EVT_MENU, self.OnPops06, id=self.popsID06) 2870 self.Bind(wx.EVT_MENU, self.OnPops07, id=self.popsID07) 2871 self.Bind(wx.EVT_MENU, self.OnPops08, id=self.popsID08) 2872 self.Bind(wx.EVT_MENU, self.OnPops09, id=self.popsID09) 2873 self.Bind(wx.EVT_MENU, self.OnPops11, id=self.popsID11) 2874 self.Bind(wx.EVT_MENU, self.OnPops12, id=self.popsID12) 2875 self.Bind(wx.EVT_MENU, self.OnPops13, id=self.popsID13) 2876 self.Bind(wx.EVT_MENU, self.OnPops14, id=self.popsID14) 2877 self.Bind(wx.EVT_MENU, self.OnPops15, id=self.popsID15) 2878 self.Bind(wx.EVT_MENU, self.OnPops16, id=self.popsID16) 2640 2879 2641 2880 # make a menu … … 2651 2890 if l: 2652 2891 shape = self.dcid_to_shape_xref.get(l[0])
