Changeset 1074
- Timestamp:
- 11/17/06 02:35:40 (2 years ago)
- Files:
-
- gaphor/branches/new-canvas/ChangeLog (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/UML/diagram.py (modified) (2 diffs)
- gaphor/branches/new-canvas/gaphor/UML/element.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/UML/elementfactory.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/classifier.py (modified) (3 diffs)
- gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py (modified) (4 diffs)
- gaphor/branches/new-canvas/gaphor/diagram/diagramline.py (modified) (4 diffs)
- gaphor/branches/new-canvas/gaphor/storage.py (modified) (9 diffs)
- gaphor/branches/new-canvas/gaphor/tests/test_storage.py (modified) (4 diffs)
- gaphor/branches/new-canvas/setup.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/new-canvas/ChangeLog
r1057 r1074 1 2006-11-14 arjan <arjan at yirdis dot nl> 2 3 * setup.py: incremented version to 0.9.0 4 1 5 2006-10-30 arjan <arjan at yirdis dot nl> 2 6 gaphor/branches/new-canvas/gaphor/UML/diagram.py
r1068 r1074 35 35 def update_now(self): 36 36 if self._block_updates: 37 log.debug('Update blocked for canvas %s' % self)37 #log.debug('Update blocked for canvas %s' % self) 38 38 return 39 39 super(DiagramCanvas, self).update_now() … … 48 48 49 49 def postload(self): 50 self.block_updates = False50 pass #self.block_updates = False 51 51 52 52 def select(self, expression=lambda e: True): gaphor/branches/new-canvas/gaphor/UML/element.py
r1066 r1074 78 78 79 79 def postload(self): 80 """Fix up the odds and ends. 80 """ 81 Fix up the odds and ends. 81 82 """ 82 83 for name in dir(type(self)): gaphor/branches/new-canvas/gaphor/UML/elementfactory.py
r1057 r1074 147 147 # First flush all diagrams: 148 148 for value in list(self.select(lambda e: isinstance(e, Diagram))): 149 # Make sure no updates happen while destroying the canvas 150 value.canvas.block_updates = True 149 151 value.unlink() 150 152 gaphor/branches/new-canvas/gaphor/diagram/classifier.py
r1073 r1074 258 258 s_w, s_h = text_extents(cr, self.stereotype) 259 259 n_w, n_h = text_extents(cr, self.subject.name) 260 260 261 f_w, f_h = 0, 0 261 262 if self.subject.namespace: … … 273 274 self.min_width = max(self.min_width, w) 274 275 self.min_height += h 276 275 277 super(ClassifierItem, self).pre_update(context) 276 278 … … 304 306 305 307 def draw_compartment(self, context): 306 if not self.subject: return308 #if not self.subject: return 307 309 cr = context.cairo 308 310 cr.rectangle(0, 0, self.width, self.height) gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py
r1071 r1074 185 185 186 186 def _subject_disconnect_helper(self, element, callback_prefix, prop_list): 187 """Disconnect a previously connected signal handler. 187 """ 188 Disconnect a previously connected signal handler. 188 189 189 190 See: DiagramItem.on_subject_notify() … … 209 210 210 211 def _on_subject_notify_helper(self, element, pspec, callback_name, prop_list, old): 211 """This signal handler handles signals that are not direct properties 212 """ 213 This signal handler handles signals that are not direct properties 212 214 of self.subject (e.g. 'subject.lowerValue.value'). This way the 213 215 presentation class is not bothered with the details of keeping track … … 232 234 233 235 def on_subject_notify(self, pspec, notifiers=()): 234 """A new subject is set on this model element. 236 """ 237 A new subject is set on this model element. 235 238 notifiers is an optional tuple of elements that also need a 236 239 callback function. Callbacks have the signature … … 240 243 of a property of subject (e.g. 'lowerValue.value'). 241 244 """ 242 #log.info(' DiagramItem.on_subject_notify: %s' % self.__subject_notifier_ids)245 #log.info('Setting subject from %s to %s' % (self.__the_subject, self.subject)) 243 246 # First, split all notifiers on '.' 244 247 callback_prefix = 'on_subject_notify_' gaphor/branches/new-canvas/gaphor/diagram/diagramline.py
r1044 r1074 8 8 from gaphas.util import text_extents 9 9 from diagramitem import DiagramItem 10 #from gaphor.diagram import LineItemMeta 10 from interfaces import IConnect 11 11 12 12 13 class LineItem(gaphas.Line, DiagramItem): … … 76 77 ) 77 78 78 def do_set_property (self, pspec, value):79 pass80 81 def do_get_property(self, pspec):82 pass83 84 79 def save (self, save_func): 85 80 LineItem.save(self, save_func) 86 for prop in ('affine', 'color', 'orthogonal', 'horizontal'): 87 save_func(prop, self.get_property(prop)) 81 save_func('matrix', tuple(self.matrix)) 82 for prop in ('orthogonal', 'horizontal'): 83 save_func(prop, getattr(self, prop)) 88 84 points = [ ] 89 for h in self.handles: 90 pos = h.get_pos_i () 91 points.append (pos) 85 for h in self.handles(): 86 points.append(tuple(map(float, h.pos))) 92 87 save_func('points', points) 93 c = self.handles [0].connected_to88 c = self.handles()[0].connected_to 94 89 if c: 95 90 save_func('head-connection', c, reference=True) 96 c = self.handles [-1].connected_to91 c = self.handles()[-1].connected_to 97 92 if c: 98 93 save_func('tail-connection', c, reference=True) … … 101 96 if name == 'points': 102 97 points = eval(value) 103 self.set_property('head_pos', points[0]) 104 self.set_property('tail_pos', points[1]) 105 for p in points[2:]: 106 self.set_property ('add_point', p) 98 for x in xrange(len(points) - 2): 99 self.split_segment(0) 100 #self.set_property('head_pos', points[0]) 101 #self.set_property('tail_pos', points[1]) 102 for i, p in enumerate(points): 103 self.handles()[i].pos = p 107 104 elif name in ('head_connection', 'head-connection'): 108 105 self._load_head_connection = value … … 113 110 114 111 def postload(self): 112 # Ohoh, need the IConnect adapters here 113 from zope import component 115 114 if hasattr(self, '_load_head_connection'): 116 self._load_head_connection.connect_handle(self.handles[0]) 115 adapter = component.queryMultiAdapter((self._load_head_connection, self), IConnect) 116 #self._load_head_connection.connect_handle(self.handles[0]) 117 h = self.handles()[0] 118 119 x, y = self.canvas.get_matrix_i2w(self, calculate=True).transform_point(h.x, h.y) 120 x, y = self.canvas.get_matrix_w2i(self._load_head_connection, calculate=True).transform_point(x, y) 121 adapter.connect(self.handles()[0], x, y) 117 122 del self._load_head_connection 118 123 if hasattr(self, '_load_tail_connection'): 119 self._load_tail_connection.connect_handle(self.handles[-1]) 124 #self._load_tail_connection.connect_handle(self.handles[-1]) 125 adapter = component.queryMultiAdapter((self._load_tail_connection, self), IConnect) 126 h = self.handles()[0] 127 128 x, y = self.canvas.get_matrix_i2w(self, calculate=True).transform_point(h.x, h.y) 129 x, y = self.canvas.get_matrix_w2i(self._load_tail_connection, calculate=True).transform_point(x, y) 130 adapter.connect(self.handles()[0], x, y) 120 131 del self._load_tail_connection 121 132 LineItem.postload(self) gaphor/branches/new-canvas/gaphor/storage.py
r1068 r1074 176 176 version_0_6_2(elements, factory, gaphor_version) 177 177 version_0_7_2(elements, factory, gaphor_version) 178 version_0_9_0(elements, factory, gaphor_version) 178 179 179 180 #log.debug("Still have %d elements" % len(elements)) … … 210 211 for item in elem.canvas.canvasitems: 211 212 assert item in elements.values(), 'Item %s (%s) is a canvas item, but it is not in the parsed objects table' % (item, item.id) 212 #item.element.set_property('parent', elem.element.canvas.root)213 213 elem.element.canvas.add(item.element) 214 214 … … 217 217 for item in elem.canvasitems: 218 218 assert item in elements.values(), 'Item %s (%s) is a canvas item, but it is not in the parsed objects table' % (item, item.id) 219 #item.element.set_property('parent', elem.element)220 219 elem.element.canvas.add(item.element, parent=elem.element) 221 220 … … 256 255 version_0_5_2(elements, factory, gaphor_version) 257 256 version_0_7_1(elements, factory, gaphor_version) 257 258 258 # Before version 0.7.2 there was only decision node (no merge nodes). 259 259 # This node could have many incoming and outgoing flows (edges). … … 272 272 yield update_status_queue() 273 273 elem.element.postload() 274 275 # Unlock canvas's for updates 276 for id, elem in elements.items(): 277 if elem.canvas: 278 elem.element.canvas.block_updates = False 274 279 275 280 factory.notify_model() … … 327 332 except Exception, e: 328 333 log.info('file %s could not be loaded' % filename, e) 329 import traceback330 traceback.print_exc()331 334 raise 332 335 333 336 337 def version_0_9_0(elements, factory, gaphor_version): 338 """ 339 Before 0.9.0, we used DiaCanvas2 as diagram widget in the GUI. As of 0.9.0 340 Gaphas was introduced. Some properties of <item /> elements have changed, 341 renamed or been removed at all. 342 343 This function is called before the actual elements are constructed. 344 """ 345 if tuple(map(int, gaphor_version.split('.'))) < (0, 9, 0): 346 for elem in elements.values(): 347 try: 348 if type(elem) is parser.canvasitem: 349 # Rename affine to matrix 350 if elem.values.get('affine'): 351 elem.values['matrix'] = elem.values['affine'] 352 del elem.values['affine'] 353 # No more 'color' attribute: 354 if elem.values.get('color'): 355 del elem.values['color'] 356 357 except Exception, e: 358 log.error('Error while updating taggedValues', e) 359 334 360 def version_0_7_2(elements, factory, gaphor_version): 335 """Before 0.7.2, only Property and Parameter elements had taggedValues. 361 """ 362 Before 0.7.2, only Property and Parameter elements had taggedValues. 336 363 Since 0.7.2 all NamedElements are able to have taggedValues. However, 337 364 the multiplicity of taggedValue has changed from 0..1 to *, so all elements … … 362 389 363 390 def version_0_7_1(elements, factory, gaphor_version): 364 """Before version 0.7.1, there were two states for association 391 """ 392 Before version 0.7.1, there were two states for association 365 393 navigability (in terms of UML 2.0): unknown and navigable. 366 394 In case of unknown navigability Property.owningAssociation was set. … … 397 425 398 426 def version_0_6_2(elements, factory, gaphor_version): 399 """Before 0.6.2 an Interface could be represented by a ClassItem and 427 """ 428 Before 0.6.2 an Interface could be represented by a ClassItem and 400 429 a InterfaceItem. Now only InterfaceItems are used. 401 430 """ … … 416 445 417 446 def version_0_5_2(elements, factory, gaphor_version): 418 """Before version 0.5.2, the wrong memberEnd of the association was 447 """ 448 Before version 0.5.2, the wrong memberEnd of the association was 419 449 holding the aggregation information. 420 450 """ gaphor/branches/new-canvas/gaphor/tests/test_storage.py
r1068 r1074 63 63 64 64 def test_load_uml(self): 65 """Test loading of a freshly saved model. 65 """ 66 Test loading of a freshly saved model. 66 67 """ 67 68 filename = '%s.gaphor' % __module__ … … 88 89 89 90 90 def test_load_uml(self): 91 """Test loading of a freshly saved model. 91 def test_load_uml_2(self): 92 """ 93 Test loading of a freshly saved model. 92 94 """ 93 95 filename = '%s.gaphor' % __module__ … … 118 120 assert len(UML.lselect(lambda e: e.isKindOf(UML.Interface))) == 1 119 121 122 c = UML.lselect(lambda e: e.isKindOf(UML.Class))[0] 123 assert c.presentation 124 assert c.presentation[0].subject is c 125 #assert c.presentation[0].subject.name.startwith('Class') 126 120 127 iface = UML.lselect(lambda e: e.isKindOf(UML.Interface))[0] 121 128 assert iface.name == 'Circus' … … 129 136 d1 = d.canvas.select(lambda e: isinstance(e, items.ClassItem))[0] 130 137 assert d1 138 #print d1, d1.subject 139 140 141 def test_load_uml_relationships(self): 142 """ 143 Test loading of a freshly saved model with relationship objects. 144 """ 145 filename = '%s.gaphor' % __module__ 146 147 UML.create(UML.Package) 148 diagram = UML.create(UML.Diagram) 149 diagram.create(items.CommentItem, subject=UML.create(UML.Comment)) 150 c1 = diagram.create(items.ClassItem, subject=UML.create(UML.Class)) 151 diagram.create(items.AssociationItem) 152 153 fd = open(filename, 'w') 154 storage.save(XMLWriter(fd)) 155 fd.close() 156 157 UML.flush() 158 assert not list(UML.select()) 159 160 storage.load(filename) 161 162 assert len(UML.lselect()) == 4 163 assert len(UML.lselect(lambda e: e.isKindOf(UML.Package))) == 1 164 assert len(UML.lselect(lambda e: e.isKindOf(UML.Diagram))) == 1 165 d = UML.lselect(lambda e: e.isKindOf(UML.Diagram))[0] 166 assert len(UML.lselect(lambda e: e.isKindOf(UML.Comment))) == 1 167 assert len(UML.lselect(lambda e: e.isKindOf(UML.Class))) == 1 168 assert len(UML.lselect(lambda e: e.isKindOf(UML.Association))) == 0 169 170 # Check load/save of other canvas items. 171 assert len(d.canvas.get_all_items()) == 3 172 #for item in d.canvas.get_all_items(): 173 # assert item.subject, 'No subject for %s' % item 174 d1 = d.canvas.select(lambda e: isinstance(e, items.ClassItem))[0] 175 assert d1 131 176 print d1, d1.subject 132 177 gaphor/branches/new-canvas/setup.py
r1059 r1074 3 3 # setup.py for Gaphor 4 4 # 5 # vim:sw=4:et6 """Gaphor7 5 """ 6 Gaphor 7 """ 8 8 9 9 MAJOR_VERSION = 0 10 MINOR_VERSION = 811 MICRO_VERSION = 110 MINOR_VERSION = 9 11 MICRO_VERSION = 0 12 12 13 13 VERSION = '%d.%d.%d' % ( MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION ) … … 484 484 ) 485 485 ) 486 487 # vim:sw=4:et
