`draw` is in charge of actually making the OpenGL calls to draw whetever the primitive represent on the viewport. The base class provides the minimum loop needed *before* doing any drawing in order to be compatible with the callback system. That means this m
(self, view, renderer)
| 220 | self.isDirty = False |
| 221 | |
| 222 | def draw(self, view, renderer): |
| 223 | """ |
| 224 | `draw` is in charge of actually making the OpenGL calls to draw |
| 225 | whetever the primitive represent on the viewport. |
| 226 | |
| 227 | The base class provides the minimum loop needed *before* doing any |
| 228 | drawing in order to be compatible with the callback system. That means |
| 229 | this method is intended to be *EXTENDED* (i.e. always call super |
| 230 | on subclasses... unless you know what you're doing). |
| 231 | """ |
| 232 | logger.debug('Drawing: {}'.format(self)) |
| 233 | |
| 234 | # Update transform according to `parent`. |
| 235 | if self.parent: |
| 236 | fn = om2.MFnTransform(self.parent) |
| 237 | self.transform = fn.transformation() |
| 238 | self.isDirty = True |
| 239 | |
| 240 | # Run pre-update callbacks (i.e. registered as `CALLBACK_PREUPDATE`). |
| 241 | toRemove = [] |
| 242 | for each in self._preCallbacks: |
| 243 | if each(self): |
| 244 | self.isDirty = True |
| 245 | else: |
| 246 | toRemove.append(each) |
| 247 | for x in toRemove: |
| 248 | self.unregisterCallback(x) |
| 249 | |
| 250 | # Run `update` method if it's needed. |
| 251 | if self.isDirty: |
| 252 | self.update() |
| 253 | |
| 254 | # Run post-update callbacks (i.e. registered as `CALLBACK_POSTUPDATE`). |
| 255 | toRemove = [] |
| 256 | for each in self._postCallbacks: |
| 257 | if not each(self): |
| 258 | toRemove.append(each) |
| 259 | for x in toRemove: |
| 260 | self.unregisterCallback(x) |
| 261 | |
| 262 | |
| 263 | # === Curve Primitive === |