/** * Initializes the text data of the text label of this dimension. * The text data is created at 0/0 at an angle or 0. Moving the * label to the right position at the right angle is up to the * particular dimension implementation. */ void RDimensionData::initTextData() const { double dimtxt = getDimtxt(); QString label = getMeasurement(); // TODO: fontName property takes precedence textData = RTextData(RVector(0,0), // position RVector(0,0), // alignment point dimtxt, // text height 0.0, RS::VAlignMiddle, RS::HAlignCenter, RS::LeftToRight, RS::Exact, 1.0, label, //fontName, (document==NULL || document->getDimensionFont().isEmpty()) ? "Standard" : document->getDimensionFont(), false, false, 0.0, false // not simple (diameter signs, stacked text, ...) ); textData.setDocument(document); textData.setLayerId(getLayerId()); textData.setBlockId(getBlockId()); textData.setColor(getColor()); textData.setLineweight(getLineweight()); textData.setSelected(isSelected()); textData.setDimensionLabel(true); //qDebug() << "label color: " << textData.getColor(); //qDebug() << "textData: " << textData; dirty = true; }
bool read(int gid) { //logstream(LOG_INFO) << "gid=" << gid << ", idx=" << idx << std::endl; if (gid > idx) { idx = gid; } int bid = getBlockId(idx); if (bid != block_id) { ASSERT_TRUE(closeEdgeFile(0)); block_id = bid; ASSERT_TRUE(openEdgeFile(0)); } int vid, len, eid; bool find = false; std::vector<int>().swap(edges); //logstream(LOG_INFO) << "num_of_edges = " << degree[idx] << ", total_ver_num=" << ver_num << std::endl; while (fin.peek()!=EOF) { //logstream(LOG_INFO) << "begin to read file..." << std::endl; fin.read((char*)(&vid), sizeof(vid)); fin.read((char*)(&len), sizeof(len)); //logstream(LOG_INFO) << "read vid=" << vid << ", current idx=" << idx <<std::endl; if (vid > idx) { //logstream(LOG_INFO) << "judge, read vid=" << vid << ", current idx=" << idx <<std::endl; break; } else if (vid < idx) { for (int i = 0; i < len; i++) { fin.read((char*)(&eid), sizeof(eid)); //logstream(LOG_INFO) << "skip eid=" << eid << std::endl; } // skip no-used edges continue; } else { for (int i = 0; i < len; i++) { fin.read((char*)(&eid), sizeof(eid)); edges.push_back(eid); //logstream(LOG_INFO) << "eid=" << eid << std::endl; } find = true; break; } } if (find) { //logstream(LOG_INFO) << "find" << std::endl; return true; } else { //logstream(LOG_INFO) << "not find" << std::endl; return false; } }
/** * Stream operator for QDebug */ void REntity::print(QDebug dbg) const { dbg.nospace() << "REntity("; RObject::print(dbg); dbg.nospace() << ", type: " << getType() << ", layerId: " << getLayerId() << ", blockId: " << getBlockId() << ", lineweight: " << getLineweight() << ", linetypeId: " << getLinetypeId() << ", color: " << getColor() << ", drawOrder: " << getDrawOrder() << ", selectionStatus: " << isSelected() << ", boundingBoxes: " << getBoundingBoxes() << ")"; }
/** * Stream operator for QDebug */ void REntity::print(QDebug dbg) const { dbg.nospace() << "REntity("; RObject::print(dbg); dbg.nospace() << ", type: " << getType() << ", layerId: " << getLayerId() << ", blockId: " << getBlockId() << ", parentId: " << getParentId() << ", childIds: " << getDocument()->queryChildEntities(getId()) << ", lineweight: " << getLineweight() << ", linetypeId: " << getLinetypeId() << ", linetypeScale: " << getLinetypeScale() << ", color: " << getColor() << ", drawOrder: " << getDrawOrder() << ", selectionStatus: " << isSelected() << ", boundingBoxes: " << getBoundingBoxes() << ")"; }
void Chunk::build() { Batch batch; batch.start(); for (uint8_t x = 0; x < 16 ; x++) { for (uint8_t y = 0; y < 16; y++) { for (uint8_t z = 0; z < 16; z++) { if (getBlockId(x, y, z) == 0) continue; if (getBlockId(x + 1, y, z) != 0 && getBlockId(x, y + 1, z) != 0 && getBlockId(x, y, z + 1) != 0 && getBlockId(x - 1, y, z) != 0 && getBlockId(x, y - 1, z) != 0 && getBlockId(x, y, z - 1) != 0) continue; addCube(batch, x, y, z); } } } mesh_.generateMesh(batch); }
bool RMemoryStorage::saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion, bool keepHandles) { if (object.isNull()) { qWarning() << "RMemoryStorage::saveObject: object is NULL"; return false; } //qDebug() << "saveObject: " << *object; // never allow two layers with identical names, update layer instead: QSharedPointer<RLayer> layer = object.dynamicCast<RLayer>(); if (!layer.isNull()) { RLayer::Id id = getLayerId(layer->getName()); if (id != RLayer::INVALID_ID && id != layer->getId()) { setObjectId(*layer, id); // never unprotect an existing protected layer: QSharedPointer<RLayer> existingLayer = queryLayerDirect(id); if (!existingLayer.isNull()) { if (existingLayer->isProtected()) { layer->setProtected(true); } } } } // never allow two blocks with identical names, update block instead: QSharedPointer<RBlock> block = object.dynamicCast<RBlock> (); if (!block.isNull()) { RBlock::Id id = getBlockId(block->getName()); if (id != RBlock::INVALID_ID && id != block->getId()) { setObjectId(*block, id); } } // never allow two linetypes with identical names, update linetype instead: QSharedPointer<RLinetype> linetype = object.dynamicCast<RLinetype> (); if (!linetype.isNull()) { RLinetype::Id id = getLinetypeId(linetype->getName()); if (id != RLinetype::INVALID_ID && id != linetype->getId()) { setObjectId(*linetype, id); } } // avoid block recursions: if (checkBlockRecursion) { /* QSharedPointer<RBlockReferenceEntity> blockRef = object.dynamicCast<RBlockReferenceEntity> (); if (!blockRef.isNull()) { RBlock::Id id = blockRef->getBlockId(); RBlock::Id refId = blockRef->getReferencedBlockId(); // check if block with 'id' may contain a block reference which refers to // block with 'refid': // 201308: too slow for large, complex drawings: if (checkRecursion(id, refId)) { qCritical("RMemoryStorage::saveObject: recursion found"); return false; } } */ } QSharedPointer<REntity> entity = object.dynamicCast<REntity> (); if (!entity.isNull()) { Q_ASSERT_X(!queryLayerDirect(entity->getLayerId()).isNull(), "RMemoryStrorage::saveObject", "Layer of entity is NULL"); } // assign new object ID to new objects: if (object->getId() == RObject::INVALID_ID) { setObjectId(*object, getNewObjectId()); // only set new handle if handle is not set already: if (!keepHandles || object->getHandle()==RObject::INVALID_HANDLE) { setObjectHandle(*object, getNewObjectHandle()); } // assign draw order to new entities: if (!entity.isNull() && entity->getDrawOrder()==0) { entity->setDrawOrder(getMaxDrawOrder()); setMaxDrawOrder(getMaxDrawOrder()+1); } } // TODO: save original object for rollback: //if (inTransaction) { //transactionObjectMap[object->getId()] = object; //} objectMap[object->getId()] = object; objectHandleMap[object->getHandle()] = object; if (!entity.isNull()) { entityMap[entity->getId()] = entity; blockEntityMap.insert(entity->getBlockId(), entity); setMaxDrawOrder(qMax(entity->getDrawOrder()+1, getMaxDrawOrder())); } if (!layer.isNull()) { layerMap[object->getId()] = layer; } if (!block.isNull()) { blockMap[object->getId()] = block; } if (!linetype.isNull()) { linetypeMap[object->getId()] = linetype; } QSharedPointer<RDocumentVariables> docVars = object.dynamicCast<RDocumentVariables> (); if (!docVars.isNull()) { documentVariables = docVars; } return true; }
bool RMemoryStorage::saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion, bool keepHandles) { if (object.isNull()) { return false; } // never allow two layers with identical names, update layer instead: QSharedPointer<RLayer> layer = object.dynamicCast<RLayer>(); if (!layer.isNull()) { RLayer::Id id = getLayerId(layer->getName()); if (id != RLayer::INVALID_ID) { setObjectId(*layer, id); } } // never allow two blocks with identical names, update block instead: QSharedPointer<RBlock> block = object.dynamicCast<RBlock> (); if (!block.isNull()) { RBlock::Id id = getBlockId(block->getName()); if (id != RBlock::INVALID_ID) { setObjectId(*block, id); } } // avoid block recursions: if (checkBlockRecursion) { /* QSharedPointer<RBlockReferenceEntity> blockRef = object.dynamicCast<RBlockReferenceEntity> (); if (!blockRef.isNull()) { RBlock::Id id = blockRef->getBlockId(); RBlock::Id refId = blockRef->getReferencedBlockId(); // check if block with 'id' may contain a block reference which refers to // block with 'refid': // 201308: too slow for large, complex drawings: if (checkRecursion(id, refId)) { qCritical("RMemoryStorage::saveObject: recursion found"); return false; } } */ } QSharedPointer<REntity> entity = object.dynamicCast<REntity> (); // assign new object ID to new objects: if (object->getId() == RObject::INVALID_ID) { setObjectId(*object, getNewObjectId()); // only set new handle if handle is not set already: if (!keepHandles || object->getHandle()==RObject::INVALID_HANDLE) { setObjectHandle(*object, getNewObjectHandle()); } // assign draw order to new entities: if (!entity.isNull()) { entity->setDrawOrder(getMaxDrawOrder()); setMaxDrawOrder(getMaxDrawOrder()+1); } } // TODO: save original object for rollback: //if (inTransaction) { //transactionObjectMap[object->getId()] = object; //} objectMap[object->getId()] = object; //QSharedPointer<REntity> entity = object.dynamicCast<REntity> (); if (!entity.isNull()) { entityMap[entity->getId()] = entity; blockEntityMap.insert(entity->getBlockId(), entity); //qDebug() << "added " << entity->getId() << " to block " << entity->getBlockId(); setMaxDrawOrder(qMax(entity->getDrawOrder()+1, getMaxDrawOrder())); } if (!layer.isNull()) { layerMap[object->getId()] = layer; } if (!block.isNull()) { blockMap[object->getId()] = block; } return true; }