/** * The default implementation calls the \ref REntity::exportEntity() function * of the entity. * This method may use the \c currentEntity stack to access the * entity that is currently being exported. * Exporters can choose to reimplement this function to export an entity * in a target platform specific manner (e.g. to optimize things for * a specific platform). */ void RExporter::exportCurrentEntity(bool preview, bool forceSelected) { REntity* entity = getEntity(); if (entity==NULL) { return; } // if this exporter exports a visual // representation of the drawing (scene, view, print)... if (isVisualExporter()) { // ... only export entities on visible layers: if (currentLayer!=NULL && currentLayer->isFrozen()) { return; } // ... only export entities in visible blocks: RBlockReferenceEntity* blockRef = dynamic_cast<RBlockReferenceEntity*>(entity); if (blockRef!=NULL) { RBlock::Id blockId = blockRef->getReferencedBlockId(); if (blockId!=RBlock::INVALID_ID) { QSharedPointer<RBlock> block = document->queryBlockDirect(blockId); if (!block.isNull() && block->isFrozen()) { return; } } } } setEntityAttributes(forceSelected); //bool sblt = getScreenBasedLinetypes(); if ((forceSelected || entity->isSelected()) && RSettings::getUseSecondarySelectionColor()) { // first part of two color selection: //setScreenBasedLinetypes(true); twoColorSelectedMode = true; } entity->exportEntity(*this, preview, forceSelected); // selected? export again with second color and pattern: if (visualExporter) { if ((forceSelected || entity->isSelected()) && RSettings::getUseSecondarySelectionColor() && entity->getType()!=RS::EntityBlockRef && entity->getType()!=RS::EntityText && entity->getType()!=RS::EntityAttribute && entity->getType()!=RS::EntityAttributeDefinition) { RColor secondarySelectionColor = RSettings::getColor("GraphicsViewColors/SecondarySelectionColor", RColor(Qt::white)); setColor(secondarySelectionColor); //setStyle(Qt::CustomDashLine); setDashPattern(QVector<qreal>() << 2 << 3); entity->exportEntity(*this, preview, forceSelected); } } twoColorSelectedMode = false; //setScreenBasedLinetypes(sblt); }
void RGraphicsSceneQt::highlightEntity(REntity& entity) { beginPreview(); // get painter paths for closest entity: QList<RPainterPath> painterPaths = getPainterPaths(entity.getId()); for (int i = 0; i < painterPaths.size(); ++i) { painterPaths[i].setSelected(entity.isSelected()); painterPaths[i].setHighlighted(true); } addToPreview(painterPaths); endPreview(); }
void RExporter::setEntityAttributes(bool forceSelected) { REntity* currentEntity = getEntity(); if (currentEntity == NULL) { return; } if (forceSelected || currentEntity->isSelected()) { setColor(RSettings::getSelectionColor()); } else { setColor(currentEntity->getColor(true, blockRefStack)); } setLineweight(currentEntity->getLineweight(true, blockRefStack)); setLinetypeId(currentEntity->getLinetypeId(true, blockRefStack)); setStyle(Qt::SolidLine); setBrushStyle(Qt::SolidPattern); }
/** * Starts a new painter path to export geometry into. * \return True if a path has been created, false if there is already a * valid path. */ bool RGraphicsSceneQt::beginPath() { if (!exportToPreview) { Q_ASSERT(getEntity() != NULL); } if (currentPainterPath.isValid()) { return false; } currentPainterPath = RPainterPath(); currentPainterPath.setZLevel(0); if (screenBasedLinetypes && currentPen.style()==Qt::SolidLine) { QVector<qreal> pat = currentLinetypePattern.getScreenBasedLinetype(); if (!pat.isEmpty()) { currentPen.setDashPattern(pat); } } REntity* entity = getEntity(); if (draftMode || screenBasedLinetypes || twoColorSelectedMode) { QPen localPen = currentPen; if (twoColorSelectedMode) { // fixed width for selected entities in two color selected mode: localPen.setCosmetic(true); localPen.setWidth(3); } else { if (draftMode) { localPen.setWidth(0); } else { // screen based line weights: localPen.setCosmetic(true); // magic number 4.25 to scale approximately, so 1mm width is 1mm on screen: localPen.setWidth(currentPen.widthF()*4.25); } } currentPainterPath.setPen(localPen); } else { if (entity!=NULL && entity->getCustomProperty("QCAD", "ScreenWeight", false)==true) { QPen localPen = currentPen; localPen.setCosmetic(true); localPen.setWidthF(entity->getLineweight()/10); currentPainterPath.setPen(localPen); } else { currentPainterPath.setPen(currentPen); } } currentPainterPath.setBrush(QBrush(Qt::NoBrush)); currentPainterPath.setPixelSizeHint(pixelSizeHint); if (!exportToPreview) { if (entity!=NULL && entity->isSelected()) { currentPainterPath.setSelected(true); } } else { if (entity!=NULL && entity->getCustomProperty("QCADCAM", "simulation", false)==true) { currentPainterPath.setHighlighted(true); } } return true; }