/** * Called when this view gets the focus. Highlights the view to show to the user * that events go to this view. */ void RGraphicsViewQt::focusInEvent(QFocusEvent* event) { if (getDocumentInterface()!=NULL) { RGraphicsViewQt* other = dynamic_cast<RGraphicsViewQt*>( getDocumentInterface()->getLastKnownViewWithFocus() ); if (other!=NULL) { other->removeFocus(); } getDocumentInterface()->setLastKnownViewWithFocus(this); if (focusFrameWidget!=NULL) { QPalette p = focusFrameWidget->palette(); #ifdef Q_OS_MAC QColor light("#adc2d9"); QColor dark("#adc2d9"); #else QColor light("#2d2d92"); QColor dark("#2d2d92"); #endif p.setColor(QPalette::Light, light); p.setColor(QPalette::Dark, dark); focusFrameWidget->setPalette(p); } RMainWindow* mainWindow = RMainWindow::getMainWindow(); if (mainWindow!=NULL) { mainWindow->notifyViewFocusListeners(this); } } QWidget::focusInEvent(event); }
/** * Finds the entity that is the closest to the given screen * coordinate (in pixels). * * \param range Maximum distance in pixels. * * \return The closest entity or NULL. */ REntity::Id RGraphicsView::getClosestEntity(const RVector& screenPosition, int range, int strictRange, bool includeLockedLayers, bool selectedOnly) { RVector modelPosition = mapFromView(screenPosition); double modelRange = mapDistanceFromView(range); double modelStrictRange = mapDistanceFromView(strictRange); if (getDocumentInterface() == NULL) { return REntity::INVALID_ID; } return getDocumentInterface()->getClosestEntity(modelPosition, modelRange, modelStrictRange, includeLockedLayers, selectedOnly); }
void RMainWindow::notifyListeners(bool withNull) { RDocument* document = NULL; RDocumentInterface* di = NULL; RGraphicsView* view = NULL; if (!withNull) { document = getDocument(); di = getDocumentInterface(); if (di!=NULL) { view = di->getLastKnownViewWithFocus(); } } notifyFocusListeners(di); notifyViewFocusListeners(view); notifyCoordinateListeners(di); notifySnapListeners(di); notifyTransactionListeners(document); notifyPropertyListeners(document); notifySelectionListeners(di); notifyLayerListeners(di); notifyPenListeners(di); notifyBlockListeners(di); notifyViewListeners(di); }
/** * Repaints the view. If the view has been invalidated before, * the view is redrawn from scratch. Otherwise, only a cached * buffer is drawn (very fast). * * \see invalidate */ void RGraphicsViewQt::paintEvent(QPaintEvent* e) { // enable timer for performance monitoring: //RDebug::startTimer(); RDocumentInterface* di = getDocumentInterface(); if (di!=NULL && di->isSuspended()) { QPainter wPainter(this); //wPainter.drawImage(0, 0, graphicsBuffer); wPainter.drawImage(getRect(), graphicsBuffer); //QPixmap pm; //pm.convertFromImage(graphicsBuffer); //wPainter.drawPixmap(this->rect(), pm); wPainter.end(); return; } updateImage(); // event is NULL for fake paint events (testing): if (e!=NULL) { QPainter wPainter(this); //wPainter.drawImage(0, 0, graphicsBufferWithPreview); wPainter.drawImage(getRect(), graphicsBufferWithPreview); //QPixmap pm; //pm.convertFromImage(graphicsBufferWithPreview); //wPainter.drawPixmap(this->rect(), pm); wPainter.end(); } //RDebug::stopTimer("paintEvent"); }
RGraphicsViewQt* RMdiChildQt::getLastKnownViewWithFocus() { RDocumentInterface* di = getDocumentInterface(); if (di==NULL) { return NULL; } return dynamic_cast<RGraphicsViewQt*>(di->getLastKnownViewWithFocus()); }
/** * Called immediately after the user has activated a new UCS to be used as current UCS. */ void RMainWindow::ucsSetEvent(const QString& ucsName) { RDocumentInterface* documentInterface = getDocumentInterface(); if (documentInterface == NULL) { return; } documentInterface->ucsSetEvent(ucsName); }
void RMainWindow::propertyChangeEvent(RPropertyEvent& event) { RDocumentInterface* documentInterface = getDocumentInterface(); if (documentInterface == NULL) { return; } documentInterface->propertyChangeEvent(event); }