// ==> finishedRendering(param) // Called when a POV-Ray Renderer finished (it uses the params to see which area is finished) // It emmits a signal that the rendering is partly completed //-------------------------------------------------------------------- void RenderManager::finishedRendering(PovRayRendererInformation params) { moveToThread(cthread); std::cout << "Finished rendering " << params.outputFile.toStdString().c_str() << std::endl; if (_isFirstRenderedImage) { this->outputImage = new QImage(params.outputFile); _isFirstRenderedImage = false; } else { QPainter painter(outputImage); QImage image(params.outputFile); if (image.isNull()) { return; } QRect target(params.startColumn-1, params.startRow-1, params.endColumn-params.startColumn+1, params.endRow-params.startRow+1); QRect source = target; painter.drawImage(target, image, source); } this->outputImage->save(_outputFileName); updateProgress(); emit finishedRendering(_isSnapShot); }
void KoReportItemWeb::loadFinished(bool) { kDebug () << m_rendering; if (m_rendering) { OROPicture * pic = new OROPicture(); m_webPage->setViewportSize(m_size.toScene().toSize()); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); QPainter p(pic->picture()); m_webPage->mainFrame()->render(&p); QPointF pos = m_pos.toScene(); QSizeF size = m_size.toScene(); pos += m_targetOffset; pic->setPosition(pos); pic->setSize(size); if (m_targetPage) m_targetPage->addPrimitive(pic, false, true); OROPicture *p2 = dynamic_cast<OROPicture*>(pic->clone()); p2->setPosition(m_pos.toPoint()); if (m_targetSection) m_targetSection->addPrimitive(p2); m_rendering = false; emit(finishedRendering()); } }
// ==> createRenderers() // create a vector of PovRayRenderers (based on the number of processors to be used) //-------------------------------------------------------------------- void RenderManager::createRenderers() { IniManager::getSingletonPtr()->setInputFileName(_inputFileName); IniManager::getSingletonPtr()->setOutputFileType(_outputFileType); IniManager::getSingletonPtr()->setQuality(_quality); IniManager::getSingletonPtr()->setAnitalias(_antialias); IniManager::getSingletonPtr()->setWidth(_width); IniManager::getSingletonPtr()->setHeight(_height); if (_renderers.size() > 0) { for (int i=0; i<_renderers.size(); i++) { delete _renderers[i]; } } _renderers.clear(); _renderersProgress.clear(); int stroke = ceil(float(_width)/float(_nProcess)); _progress = 0; int startRow = 1; int endRow = _height; for (int i=0; i<_nProcess; i++) { int startColumn = i*stroke+1; int endColumn = startColumn + stroke-1; //IniManager::getSingletonPtr()->setInputFileName("combined.pov"); //IniManager::getSingletonPtr()->setOutputFileName("../temp/temp" + QString::number(i) + ".png"); //IniManager::getSingletonPtr()->createIniFile("mcnpx" + QString::number(i) + ".ini", startColumn, endColumn, startRow, endRow); IniManager::getSingletonPtr()->setOutputFileName(QString::fromStdString(Config::getSingleton().TEMP) + "temp" + QString::number(i) + ".png"); IniManager::getSingletonPtr()->createIniFile(QString::fromStdString(Config::getSingleton().TEMP) + "mcnpx" + QString::number(i) + ".ini", startColumn, endColumn, startRow, endRow); PovRayRenderer* renderer = new PovRayRenderer(_inputFileName, QString::fromStdString(Config::getSingleton().TEMP) + "mcnpx" + QString::number(i) + ".ini"); renderer->setInfo(PovRayRendererInformation(QString::fromStdString(Config::getSingleton().TEMP) + "temp" + QString::number(i) + ".png", i, startColumn, endColumn, startRow, endRow)); connect(renderer, SIGNAL(finishedRendering(PovRayRendererInformation)), this, SLOT(finishedRendering(PovRayRendererInformation))); connect(renderer, SIGNAL(rendererCallOutput(QString, PovRayRendererInformation, bool)), this, SLOT(rendererCallOutput(QString, PovRayRendererInformation, bool))); this->_renderers.push_back(renderer); this->_renderersProgress.push_back(0); } }
void KoReportASyncItemManager::addItem(KoReportASyncItemBase* item, OROPage* page, OROSection* section, QPointF offset, QVariant data, KRScriptHandler* script) { RenderData *rdata = new RenderData(); rdata->item = item; rdata->page = page; rdata->section = section; rdata->offset = offset; rdata->data = data; rdata->script = script; m_renderList.enqueue(rdata); //Just connect the first instance if (!m_itemList.contains(item)) { m_itemList.append(item); connect(item, SIGNAL(finishedRendering()), this, SLOT(itemFinished())); } //kDebug() << m_renderList.count(); }