Changeset 344

Show
Ignore:
Timestamp:
Fri Oct 19 16:47:32 2007
Author:
Brian
Message:

Move all shape drawing logic to separate classes.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • scripts/trunk/ORM/Install ORM Tables.py

    r328 r344  
    171 171     Data.AddReportType(rt, ct)  
    172 172  
      173     rt = { 'Name': 'ORM Constraint Connectors', 'TableA': 'ORMConstraintConnector', 'TableB': None, 'Also': None, 'AllOrEach': 'each',  
      174            'SuggestedColumns': ',ID;,ORMNoteID;,TableName;,TableID' }  
      175     ct = [  
      176     { 'Name': 'ID',           'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': False, 'Width': 35  },  
      177     { 'Name': 'ORMConstraintID',    'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      178     { 'Name': 'ORMRoleID',      'Label': None,             'DataType': 'i', 'AccessType': 'd', 'T': 'A', 'Edit': True, 'Width': 55  },  
      179         ]  
      180     Data.AddReportType(rt, ct)  
      181  
    173 182 #       ORMPath  
    174 183 #       - ID  
  • scripts/trunk/ORM/Open ORM Window.py

    r328 r344  
    2083 2083     Data.ReorderReportRows(report_object.ID, rlist)  
    2084 2084  
    2085       return report_object.db.GetObject('ReportRow', newrowid)  
      2085     return report_object.db.GetObject('ReportRow', newrowid)   
    2085 2085  
    2086 2086 #---------------------------------------------------------------------------  
     
    2619 2619  
    2620 2620 # -----------  
      2621 class ORMShape(Data._dbObject):  
      2622     pass  
      2623         # add methods to shape object  
      2624     def Follow(self):  # identify which objects you follow  
      2625         pass  # overriden in subtypes  
      2626     def AddFollower(self, follower_shape):  
      2627         self.followers.append(follower_shape)  
      2628     def RemoveFollower(self, follower_shape):  
      2629         pass  
      2630     def SetTempPos(self, x, y):  
      2631         self._SetInShell('TempX', x)  
      2632         self._SetInShell('TempY', y)  
      2633     def GetPos(self):  
      2634         return self.TempX, self.TempY  
      2635     def CommitPos(self):  # need error check - what if they don't exist  
      2636         self.PosX = self.TempX  
      2637         self.PosY = self.TempY  
      2638 ##            #self.followers.append(follower_shape)  
      2639 ##        shape._SetInShell('followers', [])  
      2640 ##        shape._SetInShell('AddFollower', AddFollower)  
      2641 ##        shape._SetInShell('RemoveFollower', RemoveFollower)  
      2642  
      2643 class ORMBox(ORMShape):  
      2644     def AdjustEnd(self, other_end):  # use separate x & y or a tuple?  
      2645         '''x & y are for the other end of the line'''  
      2646         centerx, centery = self.GetPos()  
      2647         r = self.canvas.pdc.GetIdBounds(self.dcid)  
      2648         x, y = wx.lib.ogl.FindEndForBox(r.GetWidth(), r.GetHeight(), centerx, centery, other_end[0], other_end[1])  
      2649         return int(x), int(y)  
      2650  
      2651 class ORMCircle(ORMShape):  
      2652     def AdjustEnd(self, other_end):  # use separate x & y or a tuple?  
      2653         '''x & y are for the other end of the line'''  
      2654         r = self.canvas.pdc.GetIdBounds(self.dcid)  
      2655         # width == height  
      2656         centerx, centery = self.GetPos()  
      2657         x, y = wx.lib.ogl.FindEndForCircle(r.GetWidth()/2, centerx, centery, other_end[0], other_end[1])  
      2658         return int(x), int(y)  
      2659  
      2660 class ORMConnector(ORMShape):  
      2661     def AdjustEnd(self, other_end):  # use separate x & y or a tuple?  
      2662         '''x & y are for the other end of the line'''  
      2663 #        r = self.canvas.pdc.GetIdBounds(self.dcid)  
      2664 #        x, y = wx.lib.ogl.FindEndForBox(r.GetWidth(), r.GetHeight(), self.PosX, self.PosY, other_end[0], other_end[1])  
      2665 #        return int(x), int(y)  
      2666         return self.GetPos()  
      2667  
      2668 class ORMObjectShape(ORMBox):  
      2669     def Draw(self, dc):  
      2670         orm_object = self.Get('Target')  
      2671         x, y = self.GetPos()  
      2672 ##        x = self.PosX  # treat this as the center of the shape  
      2673 ##        y = self.PosY  
      2674  
      2675         dc.ClearId(self.dcid)  
      2676         dc.SetId(self.dcid)  
      2677  
      2678         # text = orm_object.Text or 'empty note'  
      2679         lines = []  
      2680         word = orm_object.Name or 'default name'  
      2681         if orm_object.Independent:  
      2682             work += "!"  
      2683         if orm_object.Derived:  
      2684             work += orm_object.Derived  
      2685         lines.append(word)  
      2686         word = orm_object.RefMode or ''  
      2687         if word:  
      2688             word = '(' + word + ')'  
      2689         lines.append(word)  
      2690          
      2691         sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
      2692         w = 5  
      2693         h = 0  
      2694         for line_w,line_h in sizes:  
      2695             w = max(w, line_w)  
      2696             h += line_h  
      2697         box_w = w + 8  
      2698         box_h = h + 6  
      2699  
      2700         if orm_object.Type == 'Entity':  
      2701             pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
      2702         else:  
      2703             pen = self.canvas.CachedPen(1, 1, wx.DOT)  
      2704         dc.SetPen(pen)  
      2705 #            dc.SetBrush(self.RandomBrush())  
      2706         dc.SetBrush(self.canvas.CachedBrush('White'))  
      2707         if debug: print 'round rectangle dimensions',x, y, box_w, box_h  
      2708         box_x = x - box_w/2  
      2709         box_y = y - box_h/2  
      2710 #            dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,8)  
      2711         dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,6)  
      2712  
      2713         dc.SetFont(self.canvas.GetFont())  
      2714 #            dc.SetTextForeground(self.RandomColor())  
      2715 #            dc.SetTextBackground(self.RandomColor())  
      2716         dc.SetTextForeground('Black')  
      2717         dc.SetTextBackground('White')  
      2718         dc.DrawText(lines[0], x - sizes[0][0]/2, box_y+3)  # center text in box  
      2719         dc.DrawText(lines[1], x - sizes[1][0]/2, box_y+box_h/2+1)  
      2720  
      2721         r = wx.Rect(box_x,box_y,box_w,box_h)  
      2722         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2723         dc.SetIdBounds(self.dcid,r)  # bounds inclose all of the drawing??  
      2724  
      2725 class ORMFactShape(ORMBox):  
      2726     def Draw(self, dc):  
      2727         orm_object = self.Get('Target')  
      2728         x, y = self.GetPos()  
      2729 ##        x = self.PosX  # treat this as the center of the shape  
      2730 ##        y = self.PosY  
      2731  
      2732         dc.ClearId(self.dcid)  
      2733         dc.SetId(self.dcid)  
      2734  
      2735         role_box_size = 12  
      2736         alignment = self.Orientation or 0  
      2737         # eventually allow any of 4 orientations (90 degree rotations)  
      2738         if alignment == 0:  
      2739             w = (role_box_size) * (orm_object.Nary)  
      2740             h = role_box_size  
      2741         box_w = w + 6  
      2742         box_h = h + 6  
      2743  
      2744         pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
      2745         dc.SetPen(pen)  
      2746         dc.SetBrush(self.canvas.CachedBrush('White'))  
      2747         for i in range(orm_object.Nary):  
      2748             dc.DrawRectangle(x+i*role_box_size,y,role_box_size+1,h)  
      2749  
      2750         r = wx.Rect(x,y,box_w,box_h)  
      2751         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2752         dc.SetIdBounds(self.dcid,r)  
      2753  
      2754 class ORMNoteShape(ORMBox):  
      2755     def Draw(self, dc):  
      2756         orm_object = self.Get('Target')  
      2757         x, y = self.GetPos()  
      2758 ##        x = self.PosX  # treat this as the center of the shape  
      2759 ##        y = self.PosY  
      2760  
      2761         dc.ClearId(self.dcid)  
      2762         dc.SetId(self.dcid)  
      2763  
      2764         text = orm_object.Text or 'empty note'  
      2765         lines = text.splitlines()  
      2766         sizes = [ self.canvas.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
      2767         w = 5  
      2768         h = 0  
      2769         for line_w,line_h in sizes:  
      2770             w = max(w, line_w)  
      2771             h += line_h  
      2772         box_w = w + 6  
      2773         box_h = h + 6  
      2774         box_x = x - box_w/2  
      2775         box_y = y - box_h/2  
      2776  
      2777         pen = self.canvas.CachedPen(1, 1, wx.DOT)  
      2778         dc.SetPen(pen)  
      2779 #            dc.SetBrush(self.RandomBrush())  
      2780         dc.SetBrush(self.canvas.CachedBrush('White'))  
      2781         dc.DrawRectangle(box_x,box_y,box_w,box_h)  
    2621 2782  
      2783         dc.SetFont(self.canvas.GetFont())  
      2784 #            dc.SetTextForeground(self.RandomColor())  
      2785         dc.SetTextForeground('Black')  
      2786         dc.SetTextBackground('White')  
      2787         w = 3; h = 2  
      2788         for i in range(len(lines)):  
      2789             line = lines[i]  
      2790             line_w, line_h = sizes[i]  
      2791             dc.DrawText(line, box_x+w, box_y+h)  
      2792             h += line_h  
      2793  
      2794         r = wx.Rect(box_x,box_y,box_w,box_h)  
      2795         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2796         dc.SetIdBounds(self.dcid,r)  
      2797  
      2798 class ORMConstraintShape(ORMCircle):  
      2799     ''' external constraint?'''  
      2800     def Draw(self, dc):  
      2801         orm_object = self.Get('Target')  
      2802         x, y = self.GetPos()  
      2803 ##        x = self.PosX  # treat this as the center of the shape  
      2804 ##        y = self.PosY  
      2805  
      2806         dc.ClearId(self.dcid)  
      2807         dc.SetId(self.dcid)  
      2808  
      2809         box_w = 20  
      2810         box_h = box_w  
      2811         box_x = x - box_w/2  
      2812         box_y = y - box_h/2  
      2813  
      2814         pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
      2815         dc.SetPen(pen)  
      2816         dc.SetBrush(self.canvas.CachedBrush('White'))  
      2817         dc.DrawCircle(x,y,box_w/2)  
      2818  
      2819 ##        dc.SetFont(self.canvas.GetFont())  
      2820 ##        dc.SetTextForeground('Black')  
      2821 ##        dc.SetTextBackground('White')  
      2822 ##  
      2823 ##        w = 3; h = 2  
      2824 ##        for i in range(len(lines)):  
      2825 ##            line = lines[i]  
      2826 ##            line_w, line_h = sizes[i]  
      2827 ##            dc.DrawText(line, box_x+w, box_y+h)  
      2828 ##            h += line_h  
      2829  
      2830         r = wx.Rect(box_x,box_y,box_w,box_h)  
      2831         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2832         dc.SetIdBounds(self.dcid,r)  
      2833  
      2834 class ORMRoleShape(ORMConnector):  
      2835     def Follow(self):  
      2836         nodea = self.Get('NodeA')  # these objects might not already be in the diagram  
      2837         nodeb = self.Get('NodeB')  
      2838         # if not already in the diagram , then create the nodes  
      2839         print 'nodea type', nodea.__class__  
      2840         if not isinstance(nodea, ORMShape):  
      2841             self.canvas.CreateNode(self.canvas.pdc, nodea)  
      2842         print 'nodeb type', nodeb.__class__  
      2843         if not isinstance(nodeb, ORMShape):  
      2844             self.canvas.CreateNode(self.canvas.pdc, nodeb)  
      2845         nodea.AddFollower(self)  # must be the right subtype to have this method  
      2846         nodeb.AddFollower(self)  
      2847  
      2848     def Draw(self, dc):  
      2849         orm_object = self.Get('Target')  
      2850         x = self.PosX  # treat this as the center of the shape  
      2851         y = self.PosY  
      2852         nodea = self.Get('NodeA')  # these objects might not already be in the diagram  
      2853         nodeb = self.Get('NodeB')  
      2854  
      2855         enda = (nodea.PosX, nodea.PosY)  
      2856         endb = (nodeb.PosX, nodeb.PosY)  
      2857         enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda)  
      2858  
      2859         dc.ClearId(self.dcid)  
      2860         dc.SetId(self.dcid)  
      2861          
      2862         minx = min(enda[0], endb[0])  
      2863         maxx = max(enda[0], endb[0])  
      2864         miny = min(enda[1], endb[1])  
      2865         maxy = max(enda[1], endb[1])  
      2866          
      2867         box_w = maxx - minx + 6  
      2868         box_h = maxy - miny + 6  
      2869  
      2870         pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
      2871         dc.SetPen(pen)  
      2872         dc.DrawLine(enda[0], enda[1], endb[0], endb[1])  
      2873         self.SetTempPos((enda[0]+endb[0]) / 2, (enda[1] + endb[1]) / 2)  
      2874         # need to add logic to draw the role name  
      2875         # need to save the calculated PosX and PosY  
      2876          
      2877         r = wx.Rect(minx,miny,box_w,box_h)  
      2878         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2879         dc.SetIdBounds(self.dcid,r)  
      2880  
      2881 class ORMNoteConnectorShape(ORMConnector):  
      2882     def Follow(self):  
      2883         nodea = self.Get('NodeA')  
      2884         nodeb = self.Get('NodeB')  
      2885         # if not already in the diagram , then create the nodes  
      2886         if not isinstance(nodea, ORMShape):  
      2887             shape.canvas.CreateNode(self.canvas.pdc, nodea)  
      2888         if not isinstance(nodeb, ORMShape):  
      2889             shape.canvas.CreateNode(self.canvas.pdc, nodeb)  
      2890         nodea.AddFollower(self)  # must be the right subtype to have this method  
      2891         nodeb.AddFollower(self)  
      2892  
      2893     def Draw(self, dc):  
      2894         orm_object = self.Get('Target')  
      2895         x = self.PosX  # treat this as the center of the shape  
      2896         y = self.PosY  
      2897         nodea = self.Get('NodeA')  
      2898         nodeb = self.Get('NodeB')  
      2899  
      2900         dc.ClearId(self.dcid)  
      2901         dc.SetId(self.dcid)  
      2902  
      2903         enda = (nodea.PosX, nodea.PosY)  
      2904         endb = (nodeb.PosX, nodeb.PosY)  
      2905         enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda)  
      2906  
      2907         minx = min(enda[0], endb[0])  
      2908         maxx = max(enda[0], endb[0])  
      2909         miny = min(enda[1], endb[1])  
      2910         maxy = max(enda[1], endb[1])  
      2911          
      2912         box_w = maxx - minx + 6  
      2913         box_h = maxy - miny + 6  
      2914  
      2915         pen = self.canvas.CachedPen(1, 1, wx.DOT)  
      2916         dc.SetPen(pen)  
      2917         dc.DrawLine(enda[0], enda[1], endb[0], endb[1])  
      2918         self.SetTempPos((enda[0]+endb[0]) / 2, (enda[1] + endb[1]) / 2)  
      2919  
      2920         r = wx.Rect(minx,miny,box_w,box_h)  
      2921         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2922         dc.SetIdBounds(self.dcid,r)  
      2923  
      2924 class ORMConstraintConnectorShape(ORMConnector):  
      2925     def Follow(self):  
      2926         nodea = self.Get('NodeA')  
      2927         nodeb = self.Get('NodeB')  
      2928         # if not already in the diagram , then create the nodes  
      2929         if not isinstance(nodea, ORMShape):  
      2930             shape.canvas.CreateNode(self.canvas.pdc, nodea)  
      2931         if not isinstance(nodeb, ORMShape):  
      2932             shape.canvas.CreateNode(self.canvas.pdc, nodeb)  
      2933         nodea.AddFollower(self)  # must be the right subtype to have this method  
      2934         nodeb.AddFollower(self)  
      2935  
      2936     def Draw(self, dc):  
      2937         orm_object = self.Get('Target')  
      2938         x = self.PosX  # treat this as the center of the shape  
      2939         y = self.PosY  
      2940         nodea = self.Get('NodeA')  
      2941         nodeb = self.Get('NodeB')  
      2942  
      2943         dc.ClearId(self.dcid)  
      2944         dc.SetId(self.dcid)  
      2945  
      2946         enda = (nodea.PosX, nodea.PosY)  
      2947         endb = (nodeb.PosX, nodeb.PosY)  
      2948         enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda)  
      2949  
      2950         minx = min(enda[0], endb[0])  
      2951         maxx = max(enda[0], endb[0])  
      2952         miny = min(enda[1], endb[1])  
      2953         maxy = max(enda[1], endb[1])  
      2954          
      2955         box_w = maxx - minx + 6  
      2956         box_h = maxy - miny + 6  
      2957  
      2958         pen = self.canvas.CachedPen(1, 1, wx.SOLID)  
      2959         dc.SetPen(pen)  
      2960         dc.DrawLine(enda[0], enda[1], endb[0], endb[1])  
      2961         self.SetTempPos((enda[0]+endb[0]) / 2, (enda[1] + endb[1]) / 2)  
      2962  
      2963         r = wx.Rect(minx,miny,box_w,box_h)  
      2964         r.Inflate(pen.GetWidth(),pen.GetWidth())  
      2965         dc.SetIdBounds(self.dcid,r)  
      2966  
      2967 # -------------  
    2622 2968 class MyCanvas(wx.ScrolledWindow):  
    2623 2969     def __init__(self, parent, id, log, size = wx.DefaultSize, report=None):  
     
    2712 3058         # add some other items  
    2713 3059         menu.Append(self.popupID2, "Fact")  
    2714           menu.Append(self.popupID3, "Constraint - not implemented")  
      3060         menu.Append(self.popupID3, "Constraint")  
    2714 3060         menu.Append(self.popupID4, "Four")  
    2715 3061         menu.Append(self.popupID5, "Undo - not implemented")  
     
    2732 3078         new_shape = self.AddNode('ORMNote', self.popupx, self.popupy)  
    2733 3079         Data.SetUndo('Add Note')  
    2734           id = self.shapexref[new_shape.ID]  
      3080         id = self.shapeid_to_dcid_xref[new_shape.ID]  
    2734 3080         self.RedisplayID(id)  
    2735 3081  
     
    2738 3084         new_shape = self.AddNode('ORMFact', self.popupx, self.popupy)  
    2739 3085         Data.SetUndo('Add Fact')  
    2740           id = self.shapexref[new_shape.ID]  
      3086         id = self.shapeid_to_dcid_xref[new_shape.ID]  
    2740 3086         self.RedisplayID(id)  
    2741 3087  
    2742 3088     def OnPopupThree(self, event):  
    2743           self.log.WriteText("Popup three\n")  
      3089         new_shape = self.AddNode('ORMConstraint', self.popupx, self.popupy)  
      3090         Data.SetUndo('Add Constraint')  
      3091 #        id = self.shapeid_to_dcid_xref[new_shape.ID]  
      3092         self.RedisplayID(new_shape.dcid)  
    2744 3093  
    2745 3094     def OnPopupFour(self, event):  
     
    2796 3145         A shape is a "reportrow" object that represents a shape on the diagram  
    2797 3146         '''  
      3147         if debug: print 'creating node for ', shape  
    2798 3148         id = wx.NewId()  
    2799           dc.SetId(id)  
    2800 3149         # need to remember which dc id belongs to which shape  
    2801           # can't store in object, must be in the graphics window  
    2802           self.shapexref[shape.ID] = id  
    2803           self.idxref[id] = shape  
      3150         # can't store in object, must be in the graphics window -- WRONG!  
      3151         self.shapeid_to_dcid_xref[shape.ID] = id  # convert to 'shape.dcid' instead  
      3152         shape._SetInShell('dcid', id)  
      3153  
      3154         shape._SetInShell('canvas', self)  
      3155         self.dcid_to_shape_xref[id] = shape  
      3156  
      3157 ##        # add methods to shape object  
      3158 ##        def AddFollower(self, follower_shape):  
      3159 ##            self.followers.append(follower_shape)  
      3160 ##        def RemoveFollower(self, follower_shape):  
      3161 ##            pass  
      3162 ##            #self.followers.append(follower_shape)  
      3163 ##        shape._SetInShell('AddFollower', AddFollower)  
      3164 ##        shape._SetInShell('RemoveFollower', RemoveFollower)  
      3165         shape._SetInShell('followers', [])  
    2804 3166  
    2805 3167         orm_object = shape.Get('Target')  
      3168         if debug: print 'node points to object', orm_object  
    2806 3169         x = shape.PosX  # treat this as the center of the shape  
    2807 3170         y = shape.PosY  
     
    2812 3175             print Data.Database[shape.Table][shape.ID]  
    2813 3176             return  
    2814           if orm_object.Table in ('ORMObject'):  
    2815   ##            word = orm_object.Name or 'default name'  
    2816   ##            name_w,name_h = self.GetFullTextExtent(word)[0:2]  # pull out only w and h  
    2817   ##            box_w = name_w + 6  
    2818   ##            box_h = name_h + 6  
    2819    
    2820               # text = orm_object.Text or 'empty note'  
    2821               lines = []  
    2822               word = orm_object.Name or 'default name'  
    2823               if orm_object.Independent:  
    2824                   work += "!"  
    2825               if orm_object.Derived:  
    2826                   work += orm_object.Derived  
    2827               lines.append(word)  
    2828               word = orm_object.RefMode or ''  
    2829               if word:  
    2830                   word = '(' + word + ')'  
    2831               lines.append(word)  
    2832                
    2833               sizes = [ self.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
    2834               w = 5  
    2835               h = 0  
    2836               for line_w,line_h in sizes:  
    2837                   w = max(w, line_w)  
    2838                   h += line_h  
    2839               box_w = w + 8  
    2840               box_h = h + 6  
    2841    
    2842               if orm_object.Type == 'Entity':  
    2843                   pen = self.CachedPen(1, 1, wx.SOLID)  
    2844               else:  
    2845                   pen = self.CachedPen(1, 1, wx.DOT)  
    2846               dc.SetPen(pen)  
    2847   #            dc.SetBrush(self.RandomBrush())  
    2848               dc.SetBrush(self.CachedBrush('White'))  
    2849               if debug: print 'round rectangle dimensions',x, y, box_w, box_h  
    2850               box_x = x - box_w/2  
    2851               box_y = y - box_h/2  
    2852   #            dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,8)  
    2853               dc.DrawRoundedRectangle(box_x,box_y,box_w,box_h,6)  
    2854 3177  
    2855               dc.SetFont(self.GetFont())  
    2856   #            dc.SetTextForeground(self.RandomColor())  
    2857   #            dc.SetTextBackground(self.RandomColor())  
    2858               dc.SetTextForeground('Black')  
    2859               dc.SetTextBackground('White')  
    2860               dc.DrawText(lines[0], x - sizes[0][0]/2, box_y+3)  # center text in box  
    2861               dc.DrawText(lines[1], x - sizes[1][0]/2, box_y+box_h/2+1)  
    2862    
    2863               r = wx.Rect(box_x,box_y,box_w,box_h)  
    2864               r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2865               dc.SetIdBounds(id,r)  
      3178         if debug: print 'orm_object table is', orm_object.Table  
      3179         if orm_object.Table in ('ORMObject'):  
      3180             shape._SetToSubclass(ORMObjectShape)  
      3181             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3182             # shape._SetInShell('Draw', DrawORMObject)  
      3183             print dir(shape)  
      3184             print shape.__class__  
      3185             shape.Draw(dc)  
    2866 3186  
    2867 3187         elif orm_object.Table in ('ORMFact'):  
    2868               role_box_size = 12  
    2869               alignment = shape.Orientation or 0  
    2870               # eventually allow any of 4 orientations (90 degree rotations)  
    2871               if alignment == 0:  
    2872                   w = (role_box_size) * (orm_object.Nary)  
    2873                   h = role_box_size  
    2874               box_w = w + 6  
    2875               box_h = h + 6  
    2876    
    2877               pen = self.CachedPen(1, 1, wx.SOLID)  
    2878               dc.SetPen(pen)  
    2879               dc.SetBrush(self.CachedBrush('White'))  
    2880               for i in range(orm_object.Nary):  
    2881                   dc.DrawRectangle(x+i*role_box_size,y,role_box_size+1,h)  
    2882    
    2883   ##            dc.SetFont(self.GetFont())  
    2884   ###            dc.SetTextForeground(self.RandomColor())  
    2885   ##            dc.SetTextForeground('Black')  
    2886   ##            dc.SetTextBackground('White')  
    2887   ##            w = 3; h = 2  
    2888   ##            for i in range(len(lines)):  
    2889   ##                line = lines[i]  
    2890   ##                line_w, line_h = sizes[i]  
    2891   ##                dc.DrawText(line, x+w, y+h)  
    2892   ##                h += line_h  
    2893    
    2894               r = wx.Rect(x,y,box_w,box_h)  
    2895               r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2896               dc.SetIdBounds(id,r)  
      3188             shape._SetToSubclass(ORMFactShape)  
      3189             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3190             # shape._SetInShell('Draw', DrawORMObject)  
      3191             print dir(shape)  
      3192             print shape.__class__  
      3193             shape.Draw(dc)  
    2897 3194  
    2898 3195         elif orm_object.Table in ('ORMNote'):  
    2899               text = orm_object.Text or 'empty note'  
    2900               lines = text.splitlines()  
    2901               sizes = [ self.GetFullTextExtent(line)[0:2] for line in lines ]  # pull out only w and h  
    2902               w = 5  
    2903               h = 0  
    2904               for line_w,line_h in sizes:  
    2905                   w = max(w, line_w)  
    2906                   h += line_h  
    2907               box_w = w + 6  
    2908               box_h = h + 6  
    2909    
    2910               pen = self.CachedPen(1, 1, wx.DOT)  
    2911               dc.SetPen(pen)  
    2912   #            dc.SetBrush(self.RandomBrush())  
    2913               dc.SetBrush(self.CachedBrush('White'))  
    2914               dc.DrawRectangle(x,y,box_w,box_h)  
    2915    
    2916               dc.SetFont(self.GetFont())  
    2917   #            dc.SetTextForeground(self.RandomColor())  
    2918               dc.SetTextForeground('Black')  
    2919               dc.SetTextBackground('White')  
    2920               w = 3; h = 2  
    2921               for i in range(len(lines)):  
    2922                   line = lines[i]  
    2923                   line_w, line_h = sizes[i]  
    2924                   dc.DrawText(line, x+w, y+h)  
    2925                   h += line_h  
    2926    
    2927               r = wx.Rect(x,y,box_w,box_h)  
    2928               r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2929               dc.SetIdBounds(id,r)  
      3196             shape._SetToSubclass(ORMNoteShape)  
      3197             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3198             # shape._SetInShell('Draw', DrawORMObject)  
      3199             print dir(shape)  
      3200             print shape.__class__  
      3201             shape.Draw(dc)  
    2930 3202              
    2931           elif orm_object.Table in ('ORMRole'):  
    2932               nodea = shape.Get('NodeA')  
    2933               nodeb = shape.Get('NodeB')  
    2934    
    2935               minx = min(nodea.PosX, nodeb.PosX)  
    2936               maxx = max(nodea.PosX, nodeb.PosX)  
    2937               miny = min(nodea.PosY, nodeb.PosY)  
    2938               maxy = max(nodea.PosY, nodeb.PosY)  
      3203         elif orm_object.Table in ('ORMConstraint'):  
      3204             shape._SetToSubclass(ORMConstraintShape)  
      3205             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3206             # shape._SetInShell('Draw', DrawORMObject)  
      3207             print dir(shape)  
      3208             print shape.__class__  
      3209             shape.Draw(dc)  
      3210  
      3211         elif orm_object.Table in ('ORMConstraintConnector'):  
      3212             shape._SetToSubclass(ORMConstraintConnectorShape)  
      3213             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3214             print dir(shape)  
      3215             print shape.__class__  
      3216             shape.Follow()  
      3217             shape.Draw(dc)  
    2939 3218              
    2940               box_w = maxx - minx + 6  
    2941               box_h = maxy - miny + 6  
    2942    
    2943               pen = self.CachedPen(1, 1, wx.SOLID)  
    2944               dc.SetPen(pen)  
    2945               dc.DrawLine(nodea.PosX,nodea.PosY,nodeb.PosX, nodeb.PosY)  
    2946    
    2947               # need to add logic to draw the role name  
    2948    
    2949               r = wx.Rect(minx,miny,box_w,box_h)  
    2950               r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2951               dc.SetIdBounds(id,r)  
      3219         elif orm_object.Table in ('ORMRole'):  
      3220             shape._SetToSubclass(ORMRoleShape)  
      3221             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3222             # shape._SetInShell('Draw', DrawORMObject)  
      3223             print dir(shape)  
      3224             print shape.__class__  
      3225             shape.Follow()  
      3226             shape.Draw(dc)  
    2952 3227              
    2953 3228         elif orm_object.Table in ('ORMNoteConnector'):  
    2954               nodea = shape.Get('NodeA')  
    2955               nodeb = shape.Get('NodeB')  
    2956    
    2957               minx = min(nodea.PosX, nodeb.PosX)  
    2958               maxx = max(nodea.PosX, nodeb.PosX)  
    2959               miny = min(nodea.PosY, nodeb.PosY)  
    2960               maxy = max(nodea.PosY, nodeb.PosY)  
    2961                
    2962               box_w = maxx - minx + 6  
    2963               box_h = maxy - miny + 6  
    2964    
    2965               pen = self.CachedPen(1, 1, wx.DOT)  
    2966               dc.SetPen(pen)  
    2967               dc.DrawLine(nodea.PosX,nodea.PosY,nodeb.PosX, nodeb.PosY)  
    2968    
    2969               r = wx.Rect(minx,miny,box_w,box_h)  
    2970               r.Inflate(pen.GetWidth(),pen.GetWidth())  
    2971               dc.SetIdBounds(id,r)  
      3229             shape._SetToSubclass(ORMNoteConnectorShape)  
      3230             shape.SetTempPos(x,y)  # used to avoid lots of updates while moving  
      3231             # shape._SetInShell('Draw', DrawORMObject)  
      3232             print dir(shape)  
      3233             print shape.__class__  
      3234             shape.Follow()  
      3235             shape.Draw(dc)  
    2972 3236              
    2973 3237         self.objids.append(id)  
     
    2995 3259             new_shape = self.AddConnector('ORMRole', source, target)  
    2996 3260             Data.SetUndo('Add Role Connector')  
    2997           id = self.shapexref[new_shape.ID]  
      3261