Changeset 349
- Timestamp:
- Mon Oct 22 19:36:29 2007
- Files:
-
- scripts/trunk/ORM/Open ORM Window.py (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
scripts/trunk/ORM/Open ORM Window.py
r347 r349 2035 2035 model['Type'] = 'Entity' 2036 2036 elif object_type == 'ORMFact': 2037 model['Nary'] = 2# number of roles2037 model['Nary'] = 0 # number of roles 2037 2037 object_id = Data.Update(model)['ID'] 2038 2038 … … 2061 2061 2062 2062 # I think that subtype is the only example of linking the same types to each other 2063 2064 fact = nodea.Get('Target') 2065 fact.Nary += 1 2066 2063 2067 model = {'Table': object_type, 'ProjectID': projectid, 'DateAdded': today} 2064 2068 model[nodea.TableName + 'ID'] = nodea.TableID 2069 model['Seq'] = fact.Nary 2065 2070 if object_type == 'ORMSubtypeArrow': # what should this be called? 2066 2071 model['ORMSubtypeID'] = nodeb.TableID … … 2759 2764 # eventually allow any of 4 orientations (90 degree rotations) 2760 2765 if alignment == 0: 2761 w = (role_box_size) * (orm_object.Nary) 2766 w = (role_box_size) * (orm_object.Nary or 1) 2761 2766 h = role_box_size 2762 2767 box_w = w + 6 … … 2767 2772 dc.SetPen(pen) 2768 2773 dc.SetBrush(self.canvas.CachedBrush('White')) 2769 for i in range(orm_object.Nary): 2774 for i in range(orm_object.Nary or 1): 2769 2774 dc.DrawRectangle(x+i*role_box_size,y,role_box_size+1,h) 2770 2775 … … 2855 2860 2856 2861 class ORMRoleShape(ORMConnector): 2862 def GetFactEnd(self): 2863 orm_object = self.Get('Target') 2864 seq = orm_object.Seq or 1 2865 rolebox_size = 12 2866 2867 fact = self.Get('NodeA') 2868 ax, ay = fact.GetPos() 2869 midway = ay + rolebox_size / 2 2870 rightend = ax + rolebox_size * seq 2871 nary = fact.Get('Target').Nary 2872 2873 object = self.Get('NodeB') 2874 bx, by = object.GetPos() 2875 2876 if seq == 1 and bx < ax and abs(bx - ax) > abs(by - midway): 2877 ay = midway 2878 elif seq == nary and ax < bx and abs(bx - rightend) > abs(by - midway): 2879 ax = rightend 2880 ay = midway 2881 else: 2882 ax += rolebox_size * seq - rolebox_size / 2 2883 if by > midway: 2884 ay += rolebox_size 2885 return ax, ay 2886 2857 2887 def Draw(self, dc): 2858 2888 orm_object = self.Get('Target') 2859 x = self.PosX # treat this as the center of the shape 2860 y = self.PosY 2889 x, y = self.GetPos() 2861 2890 nodea = self.Get('NodeA') # these objects might not already be in the diagram 2862 2891 nodeb = self.Get('NodeB') 2863 2892 2864 enda = (nodea.PosX, nodea.PosY) 2865 endb = (nodeb.PosX, nodeb.PosY) 2866 enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda) 2893 enda = self.GetFactEnd() 2894 endb = nodeb.GetPos() 2895 endb = nodeb.AdjustEnd(enda) 2867 2896 2868 2897 dc.ClearId(self.dcid) … … 2903 2932 def Draw(self, dc): 2904 2933 orm_object = self.Get('Target') 2905 x = self.PosX # treat this as the center of the shape 2906 y = self.PosY 2934 x, y = self.GetPos() # treat this as the center of the shape 2907 2935 nodea = self.Get('NodeA') # these objects might not already be in the diagram 2908 2936 nodeb = self.Get('NodeB') 2909 2937 2910 enda = (nodea.PosX, nodea.PosY) 2911 endb = (nodeb.PosX, nodeb.PosY) 2912 enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda) 2938 enda = self.GetFactEnd() 2939 endb = nodeb.GetPos() 2940 endb = nodeb.AdjustEnd(enda) 2913 2941 2914 2942 dc.ClearId(self.dcid) … … 2946 2974 def Draw(self, dc): 2947 2975 orm_object = self.Get('Target') 2948 x = self.PosX # treat this as the center of the shape 2949 y = self.PosY 2976 x, y = self.GetPos() 2950 2977 nodea = self.Get('NodeA') 2951 2978 nodeb = self.Get('NodeB') … … 2978 3005 def Draw(self, dc): 2979 3006 orm_object = self.Get('Target') 2980 x = self.PosX # treat this as the center of the shape 2981 y = self.PosY 3007 x, y = self.GetPos() 2982 3008 nodea = self.Get('NodeA') 2983 3009 nodeb = self.Get('NodeB') … … 3025 3051 3026 3052 font = self.GetFont() 3027 font.SetPointSize(7) 3028 font.SetFaceName('Tahoma') # on mac use 'Geneva' ?? 3053 if Data.platform == "mac": 3054 font.SetFaceName('Geneva') 3055 else: 3056 font.SetPointSize(7) 3057 font.SetFaceName('Tahoma') 3029 3058 # font.SetFamily(wx.wxSWISS) 3030 3059 self.SetFont(font) … … 3187 3216 dc.BeginDrawing() 3188 3217 self.CreateNode(dc, shape) 3218 source.Draw(dc) 3219 target.Draw(dc) 3189 3220 dc.EndDrawing() 3190 3221 return shape
