Changeset 424

Show
Ignore:
Timestamp:
Thu Jun 5 17:29:34 2008
Author:
Alexander
Message:

workaround for bug in GetPixel? on MacOSX; moved rolebox connector logic into the fact shape; replaced ctrl-click with cmd-click on Mac; grid gets its column label size from Data.Option

Files:

Legend:

Unmodified
Added
Removed
Modified
  • ganttpv/trunk/ORM.py

    r421 r424  
    59 59 # 080604 - Added Role entries to Fact Type popup menu  
    60 60 # 080605 - Will add and connect Role and Subtype constraints  
      61 # 080605 - Alex - workaround for bug in GetPixel on MacOSX; moved rolebox connector logic into the fact shape; replaced ctrl-click with cmd-click on Mac  
    61 62  
    62 63 import wx  
     
    88 89 # import images  
    89 90  
      91  
      92  
      93 # workaround for a bug in wx.DC.GetPixel on MacOSX  
      94  
      95 if Data.platform == "mac":  
      96     def GetPixel(self, x, y):  
      97         x, y = self.LogicalToDeviceX(x), self.LogicalToDeviceY(y)  
      98         bitmap = self.GetAsBitmap(wx.Rect(x, y, 1, 1))  
      99         image = wx.ImageFromBitmap(bitmap)  
      100         rgba = image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0), image.GetAlpha(0, 0)  
      101         return wx.Colour(*rgba)  
      102  
      103     wx.DC.GetPixel = GetPixel  
      104  
      105     def FindObjects(self, x, y, hitradius=1, bgcolor=wx.WHITE):  
      106         bitmap = wx.EmptyBitmap(1, 1)  
      107         memdc = wx.MemoryDC(bitmap)  
      108         memdc.SetDeviceOrigin(-x, -y)  
      109         result = []  
      110         for id in self.FindObjectsByBBox(x, y):  
      111             memdc.SetBackground(wx.Brush(bgcolor))  
      112             memdc.Clear()  
      113             self.DrawIdToDC(id, memdc)  
      114             if memdc.GetPixel(x, y) != bgcolor:  
      115                 result.append(id)  
      116         return result  
      117    
      118     wx.PseudoDC.FindObjects = FindObjects  
      119  
      120  
      121  
      122 # implement "any" function for lesser versions of python  
      123 try:  
      124     any  
      125 except NameError:  
      126     def any(iterable):  
      127         for element in iterable:  
      128             if element:  
      129                 return True  
      130         return False  
      131  
      132  
      133  
    90 134 # ---------------- Main.opj replacement -----------  
    91 135 def opj(path):  
     
    2126 2170  
    2127 2171 class ORMFactTypeShape(ORMBox):  
      2172     def AdjustEnd(self, other_end, seq=None):  
      2173         nary = self.Get('Target').Nary  
      2174         if not seq:  
      2175             seq = (nary + 1) / 2.0  
      2176  
      2177         ax, ay = self.GetPos()  
      2178         bx, by = other_end  
      2179         midway = ay + role_box_height / 2  
      2180         rightend = ax + role_box_width * seq  
      2181  
      2182         if seq == 1 and bx < ax and abs(bx - ax) > abs(by - midway):  
      2183             ay = midway  
      2184         elif seq == nary and ax < bx and abs(bx - rightend) > abs(by - midway):  
      2185             ax = rightend  
      2186             ay = midway  
      2187         else:  
      2188             ax += role_box_width * seq - role_box_width / 2  
      2189             if by > midway:  
      2190                 ay += role_box_width  
      2191         return ax, ay  
      2192  
    2128 2193     def Draw(self, dc):  
    2129 2194         orm_object = self.Get('Target')  
     
    2648 2713  
    2649 2714 class ORMRoleConnectorShape(ORMConnector):  
    2650       def GetFactEnd(self):  # move to fact object??  
    2651           orm_object = self.Get('Target')  
    2652           if not orm_object: return self.GetPos()  # object probably undone  
    2653           seq = orm_object.Seq or 1  
    2654           rolebox_height = 8 + 3 #  12  # must match constants in Fact  
    2655           rolebox_width = 12 #  12  
    2656    
    2657           fact = self.Get('NodeA')  
    2658           ax, ay = fact.GetPos()  
    2659           midway = ay + rolebox_height / 2  
    2660           rightend = ax + rolebox_width * seq  
    2661           nary = fact.Get('Target').Nary  
    2662    
    2663           entity = self.Get('NodeB')  
    2664           bx, by = entity.GetPos()  
    2665    
    2666           if seq == 1 and bx < ax and abs(bx - ax) > abs(by - midway):  
    2667               ay = midway  
    2668           elif seq == nary and ax < bx and abs(bx - rightend) > abs(by - midway):  
    2669               ax = rightend  
    2670               ay = midway  
    2671           else:  
    2672               ax += rolebox_width * seq - rolebox_width / 2  
    2673               if by > midway:  
    2674                   ay += rolebox_height  
    2675           return ax, ay  
    2676    
    2677 2715     def Draw(self, dc):  
    2678 2716         orm_object = self.Get('Target')  
     
    2685 2723         dc.SetId(self.dcid)  
    2686 2724          
    2687           enda = self.GetFactEnd()  
    2688   #        endb = nodeb.GetPos()  
      2725         seq = orm_object.Seq or 1  
      2726         endb = nodeb.GetPos()  
      2727         enda = nodea.AdjustEnd(endb, seq)  
    2689 2728         endb = nodeb.AdjustEnd(enda)  
    2690 2729  
     
    2833 2872  
    2834 2873         enda = nodea.GetPos()  
    2835           endb = nodeb.GetPos()  
    2836           enda, endb = nodea.AdjustEnd(endb), nodeb.AdjustEnd(enda)  
      2874         endb = nodeb.AdjustEnd(enda, seq=0)  
      2875         enda = nodea.AdjustEnd(endb)  
    2837 2876  
    2838 2877         minx = min(enda[0], endb[0])  
     
    4060 4099                     if self.demo.draw_mode or event.ShiftDown():  # "demo" is a poor name, this is where the window global data is  
    4061 4100                         self.SelectObject(self.dragid)  
    4062                       elif event.ControlDown():  
      4101                     elif event.CmdDown():  
    4062 4101                         self.ToggleObjectSelect(self.dragid)  
    4063 4102                     else:  
     
    4078 4117                     self.SelectObject(self.dragid)  
    4079 4118                 else:  # control down and normal  
    4080                       if not event.ControlDown():  
      4119                     if not event.CmdDown():  
    4080 4119                         self.ClearSelection()  
    4081 4120                     self.selection_rectangle_origin_x = x  
     
    4106 4145                     if self.demo.draw_mode or event.ShiftDown():  
    4107 4146                         pass  # open object  
    4108                       elif event.ControlDown():  
      4147                     elif event.CmdDown():  
    4108 4147                         if debug: print "control double click on object"  
    4109 4148                         self.AddDependentsToSelection(self.dragid)  
     
    4129 4168             if self.demo.draw_mode or event.ShiftDown():  # "demo" is a poor name, this is where the window global data is  
    4130 4169                 pass  
    4131               elif event.ControlDown() or self.dragid == -1:  # control down and (normal not drag)  
      4170             elif event.CmdDown() or self.dragid == -1:  # control down and (normal not drag)  
    4131 4170                 if self.selection_rectangle:  
    4132 4171                     x,y = self.ConvertEventCoords(event)  
     
    4218 4257 ##                        self.dragid = id  # remember start of draf  
    4219 4258 ##                        self.lastpos = (event.GetX(),event.GetY())  
    4220                   elif event.ControlDown():  
      4259                 elif event.CmdDown():  
    4220 4259                     if self.selection_rectangle:  
    4221 4260                         x,y = self.ConvertEventCoords(event)  
  • ganttpv/trunk/GanttReport.py

    r403 r424  
    95 95 # 080516 - Brian - added actual and baseline plan bars  
    96 96 # 080517 - Alex - sorted the insert column list  
      97 # 080605 - Alex - grid gets its column label size from Data.Option  
    97 98  
    98 99 import wx, wx.grid  
     
    562 563         self.DisableDragGridSize()  
    563 564         self.SetRowLabelSize(40)  
    564           self.SetRowLabelSize(32)  
      565         self.SetColLabelSize(Data.Option.get("GridColumnLabelSize", 32))  
    564 565         self.SetDefaultRowSize(22)  # (22, True) would resize existing rows  
    565 566         self.SetDefaultColSize(40)  # (40, True) would resize existing columns