bool OgreDetourTileCache::buildTile(const int tx, const int ty, InputGeom *inputGeom) { if (tx < 0 || tx >= m_tw) return false; if (ty < 0 || ty >= m_th) return false; //TODO maybe I want to keep these values up to date /* m_cacheLayerCount = 0; m_cacheCompressedSize = 0; m_cacheRawSize = 0; */ TileCacheData tiles[MAX_LAYERS]; memset(tiles, 0, sizeof(tiles)); int ntiles = rasterizeTileLayers(inputGeom, tx, ty, m_cfg, tiles, MAX_LAYERS); // This is where the tile is built dtStatus status; // I don't know exactly why this can still be multiple tiles (??) for (int i = 0; i < ntiles; ++i) { TileCacheData* tile = &tiles[i]; dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)tile->data; // Important: if a tile already exists at this position, first remove the old one or it will not be updated! removeTile( m_tileCache->getTileRef(m_tileCache->getTileAt(header->tx, header->ty,header->tlayer)) ); status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); // Add compressed tiles to tileCache if (dtStatusFailed(status)) { dtFree(tile->data); tile->data = 0; continue; // TODO maybe return false here? } // TODO this has to be recalculated differently when rebuilding a tile /* m_cacheLayerCount++; m_cacheCompressedSize += tile->dataSize; m_cacheRawSize += calcLayerBufferSize(m_tcparams.width, m_tcparams.height); */ } //TODO add a deferred command for this? // Build navmesh tile from cached tile m_tileCache->buildNavMeshTilesAt(tx,ty, m_recast->m_navMesh); // This immediately builds the tile, without the need of a dtTileCache::update() //TODO update this value? //m_cacheBuildMemUsage = m_talloc->high; // TODO extract debug drawing to a separate class drawDetail(tx, ty); return true; }
void OgreDetourTileCache::drawNavMesh() { for (int y = 0; y < m_th; ++y) { for (int x = 0; x < m_tw; ++x) { drawDetail(x, y); } } }
/** Renders the report as a page collection - the caller * is responsible for de-allocating the returned * collection * * copyright : (C) 2002-2008 InfoSiAL S.L. * email : [email protected] * */ MPageCollection * MReportEngine::renderReport( int initRow, int initCol ) { cancelRender = false; csvData_ = ""; p->setStyleName( styleName_ ); // Create the page collection MPageCollection *pages = new MPageCollection; // Initialize the basic page data currHeight = pageHeight - ( bottomMargin + pFooter->getHeight() ); currPage = 0; currDate = QDate::currentDate(); // Initialize the grand total array grandTotal->clear(); for ( int i = 0; i < rFooter->getCalcFieldCount(); i++ ) grandTotal->append( new QMemArray < double > ); // Create the first page startPage( pages ); unsigned int rowCount = records.length(); if ( rowCount <= 1 ) rowCount = 2; uint nRecord = 0; // Draw the details drawDetail( pages, 0, nRecord, initRow, initCol ); // Finish the last page of the report endPage( pages ); // Destroy the page painter p->painter()->end(); // Set the page collection attributes pages->setPageDimensions( QSize( pageWidth, pageHeight ) ); pages->setPageSize( pageSize ); pages->setPageOrientation( pageOrientation ); pages->setPrintToPos( printToPos ); // Send final status emit signalRenderStatus( rowCount / 2 ); return pages; }
void Sample_TempObstacles::renderCachedTile(const int tx, const int ty, const int type) { DebugDrawGL dd; if (m_tileCache) drawDetail(&dd,m_tileCache,tx,ty,type); }
//copyright : (C) 2002-2004 InfoSiAL S.L. //email : [email protected] void MReportEngine::drawDetail(MPageCollection *pages, int level, uint &currRecord, const int initRow, const int initCol) { currRecord_ = currRecord; QString detailValue; int nextLevel; int detailHeight = 0; MReportSection *detail = findDetail(level); MReportSection *footer; if (detail) detailHeight = detail->getHeight(); if (!canDrawDetailHeader(level, currRecord, currY)) { if (level > 0) drawAddOnFooter(pages, (level - 1), gDTFooters[(level - 1)], gDTSFooters[(level - 1)]); newPage(pages, level); // Sólo dibujamos el detail header si no hemos dibujado ya el addOnHeader if (!findAddOnHeader(level)) drawDetailHeader(pages, level); } else { drawDetailHeader(pages, level); } if (!detail) { drawDetailFooter(pages, level); return; } gDTFooters[level]->clear(); gDTSFooters[level]->clear(); int currLevel; int chkRow = 0; int loops = 0; if (initCol != 0) currX = leftMargin + (detail->getWidth() * (initCol - 1)); if (initRow != 0) currY = topMargin + (detail->getHeight() * (initRow - 1)); currLevel = level; do { QDomNode record = records.item(currRecord); if (record.nodeType() == QDomNode::ElementNode) { if (currLevel == level) { if ((chkRow = (currRecord / 2) % 20) == 0) emit signalRenderStatus(currRecord / 2); if (cancelRender) { MLabelObject lblCancel; lblCancel.setFont("Arial", 20, MLabelObject::Bold, false); lblCancel.setText(tr("INFORME INCOMPLETO\nCANCELADO POR EL USUARIO")); lblCancel.setGeometry(20, pageHeight / 2, 450, 70); lblCancel.setHorizontalAlignment(MLabelObject::Center); lblCancel.setVerticalAlignment(MLabelObject::Middle); lblCancel.draw(p); return; } QDomNamedNodeMap fields = record.attributes(); reserveSizeForCalcFields(&fields, level); detail->setPageNumber(currPage); detail->setReportDate(currDate); if (!canDrawDetail(level, currRecord, currY)) { if (loops) { drawAddOnFooter(pages, level, gDTFooters[level], gDTSFooters[level]); } else { if (level > 0) { drawAddOnFooter(pages, (level - 1), gDTFooters[(level - 1)], gDTSFooters[(level - 1)]); } } newPage(pages, level); } QDomNode record = records.item(currRecord); QDomNode *ptrRecord = &record; setFieldValues(&fields, level, detail, ptrRecord); if (detail->mustBeDrawed(ptrRecord)) { detail->setCalcFieldData(0, 0, ptrRecord, fillRecords_); int sectionHeight = detail->getHeight(); detail->draw(p, currX, currY, sectionHeight); detailHeight = sectionHeight; currX += detail->getWidth(); if (currX >= (pageWidth - rightMargin - leftMargin)) { currX = leftMargin; currY += sectionHeight; } MReportSection *rS = findDetail(level + 1); if (!rS) { for (uint i = 0; i <= level; i++) { rS = findDetailHeader(i); if (rS) csvData_ += rS->csvData(); rS = findDetail(i); if (rS) csvData_ += rS->csvData(); } csvData_ += "\n"; } } ++currRecord; } else { drawDetail(pages, currLevel, currRecord); } if (currRecord < records.count()) { record = records.item(currRecord); QDomNamedNodeMap fields = record.attributes(); detailValue = fields.namedItem("level").nodeValue(); currLevel = detailValue.toInt(); } if (cancelRender) { MLabelObject lblCancel; lblCancel.setFont("Arial", 20, MLabelObject::Bold, false); lblCancel.setText(tr("INFORME INCOMPLETO\nCANCELADO POR EL USUARIO")); lblCancel.setGeometry(20, pageHeight / 2, 450, 70); lblCancel.setHorizontalAlignment(MLabelObject::Center); lblCancel.setVerticalAlignment(MLabelObject::Middle); lblCancel.draw(p); return; } } loops++; } while (level <= currLevel && currRecord < records.count()); drawDetailFooter(pages, level, gDTFooters[level], gDTSFooters[level]); footer = findDetailFooter(level); if (footer && currRecord < records.count()) if (footer->newPage()) newPage(pages); }
/** Renders the report as a page collection - the caller * is responsible for de-allocating the returned * collection * * copyright : (C) 2002-2008 InfoSiAL S.L. * email : [email protected] * */ MPageCollection *MReportEngine::renderReport(int initRow, int initCol, MPageCollection *pages, uint flags) { fillRecords_ = flags & MReportEngine::FillRecords; bool pageBreak = flags & MReportEngine::PageBreak; bool append = flags & MReportEngine::Append; cancelRender = false; currRecord_ = 0; csvData_ = QString::null; p->setStyleName(styleName_); // Create the page collection QPicture *currentPage = 0; QPicture *currentPageCopy = 0; bool lastPageFound = false; if (pages == 0) { pages = new MPageCollection(this); currPage = 0; } else { if (append && !pageBreak) { currX = leftMargin ; lastPageFound = true; currentPage = pages->getLastPage(); p->painter()->end(); currentPageCopy = new QPicture(*currentPage); p->painter()->begin(currentPage); currentPageCopy->play(p->painter()); delete currentPageCopy; } } // Initialize the basic page data currHeight = pageHeight - (bottomMargin + pFooter->getHeight()); currDate = QDate::currentDate(); // Initialize the grand total array clearGrantTotals(); for (int i = 0; i < rFooter->getCalcFieldCount(); i++) grandTotal->append(new QMemArray<double>); // Create the first page if (!lastPageFound) startPage(pages); unsigned int rowCount = records.length(); if (rowCount <= 1) rowCount = 2; uint nRecord = 0; // Draw the details drawDetail(pages, 0, nRecord, initRow, initCol); // Finish the last page of the report endPage(pages); // Destroy the page painter p->painter()->end(); // Set the page collection attributes pages->setPageDimensions(QSize(pageWidth, pageHeight)); pages->setPageSize(pageSize); pages->setPageOrientation(pageOrientation); pages->setPrintToPos(printToPos); fillRecords_ = false; // Send final status emit signalRenderStatus(rowCount / 2); return pages; }