| 274 | } |
| 275 | |
| 276 | void |
| 277 | NodeGraph::paintEvent(QPaintEvent* e) |
| 278 | { |
| 279 | AppInstancePtr app; |
| 280 | |
| 281 | if ( getGui() ) { |
| 282 | app = getGui()->getApp(); |
| 283 | } |
| 284 | if ( app && app->getProject()->isLoadingProjectInternal() ) { |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | NodeCollectionPtr collection = getGroup(); |
| 289 | NodeGroup* isGroup = dynamic_cast<NodeGroup*>( collection.get() ); |
| 290 | bool isGroupEditable = true; |
| 291 | bool groupEdited = true; |
| 292 | if (isGroup && isGroup->getNode()->isPyPlug()) { |
| 293 | isGroupEditable = isGroup->isSubGraphEditable(); |
| 294 | groupEdited = isGroup->getNode()->hasPyPlugBeenEdited(); |
| 295 | } |
| 296 | |
| 297 | bool drawLockedMode = !isGroupEditable || !groupEdited; |
| 298 | |
| 299 | if (_imp->_refreshOverlays) { |
| 300 | ///The visible portion of the scene, in scene coordinates |
| 301 | QRectF visibleScene = visibleSceneRect(); |
| 302 | QRect visibleWidget = visibleWidgetRect(); |
| 303 | |
| 304 | ///Set the cache size overlay to be in the top left corner of the view |
| 305 | _imp->_cacheSizeText->setPos( visibleScene.topLeft() ); |
| 306 | |
| 307 | double navWidth = NATRON_NAVIGATOR_BASE_WIDTH * width(); |
| 308 | double navHeight = NATRON_NAVIGATOR_BASE_HEIGHT * height(); |
| 309 | QPoint btmRightWidget = visibleWidget.bottomRight(); |
| 310 | QPoint navTopLeftWidget = btmRightWidget - QPoint(navWidth, navHeight ); |
| 311 | QPointF navTopLeftScene = mapToScene(navTopLeftWidget); |
| 312 | |
| 313 | _imp->_navigator->refreshPosition(navTopLeftScene, navWidth, navHeight); |
| 314 | updateNavigator(); |
| 315 | _imp->_refreshOverlays = false; |
| 316 | } |
| 317 | QGraphicsView::paintEvent(e); |
| 318 | |
| 319 | if (drawLockedMode) { |
| 320 | ///Show a semi-opaque foreground indicating the PyPlug has not been edited |
| 321 | QPainter p( viewport() ); |
| 322 | p.setBrush( QColor(120, 120, 120) ); |
| 323 | p.setOpacity(0.7); |
| 324 | p.drawRect( rect() ); |
| 325 | |
| 326 | if (isGroupEditable) { |
| 327 | ///Draw the unlock icon |
| 328 | QPoint pixPos = _imp->getPyPlugUnlockPos(); |
| 329 | int pixW = _imp->unlockIcon.width(); |
| 330 | int pixH = _imp->unlockIcon.height(); |
| 331 | QRect pixRect(pixPos.x(), pixPos.y(), pixW, pixH); |
| 332 | pixRect.adjust(-2, -2, 2, 2); |
| 333 | QRect selRect = pixRect; |
nothing calls this directly
no test coverage detected