void Logger::init(QTreeWidget* o, QCheckBox* w, QPlainTextEdit* d) { m_cmlog.clear(); m_cmtxt.clear(); if (m_treeOut) m_treeOut->disconnect(this); if (m_textOut) m_textOut->disconnect(this); if (m_chkWrite) m_chkWrite->disconnect(this); m_treeOut = o; m_textOut = d; m_chkWrite = w; if (m_treeOut && m_textOut && m_chkWrite) { QList<QKeySequence> ks; ks << QKeySequence(Qt::CTRL + Qt::Key_D); QAction* copy = new QAction(tr("Copy"), this); copy->setShortcuts(QKeySequence::Copy); connect(copy, SIGNAL(triggered()), this, SLOT(copy())); QAction* clear = new QAction(tr("Clear"), this); clear->setShortcuts(ks); connect(clear, SIGNAL(triggered()), this, SIGNAL(clearLog())); QAction* all = new QAction(tr("Select All"), this); all->setShortcuts(QKeySequence::SelectAll); connect(all, SIGNAL(triggered()), m_textOut, SLOT(selectAll())); m_cmlog.addAction(copy); m_cmlog.addSeparator(); m_cmlog.addAction(clear); m_cmtxt.addAction(copy); m_cmtxt.addSeparator(); m_cmtxt.addAction(all); QPalette pal = m_textOut->palette(); pal.setBrush(QPalette::Base, m_treeOut->palette().brush(QPalette::Window)); m_textOut->setPalette(pal); m_treeOut->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_treeOut, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ctxmenu(const QPoint&))); connect(m_treeOut, SIGNAL(itemSelectionChanged()), this, SLOT(syncOutput())); m_textOut->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_textOut, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ctxmenu(const QPoint&))); }
/** * GLRender, updates and checks handles if necessary. * If node id has changed (ie, if anything in the node has changed) * an update is performed, otherwise it binds the stored handles to units. */ void SoXipBindTextures::GLRender(SoGLRenderAction* action) { if (attachmentHandles.getNum() > 16) { SoDebugError::post("SoXipBindTextures", "cant process more than 16 handles"); return; } bool dbgPrint = false; if (mNodeId != getNodeId()) { mNodeId = getNodeId(); // Check if any handles have changed bool handlesChanged = false; for (int i = 0; i < attachmentHandles.getNum(); i++) { if (mTexHandles[i] != attachmentHandles[i]) { handlesChanged = true; } } // If something has changed we process if (mNumTextures != attachmentHandles.getNum() || handlesChanged) { mNumTextures = attachmentHandles.getNum(); assignTextures(action); dbgPrint = true; } } bindTextures(action); syncOutput(); #ifdef a_DEBUG if (dbgPrint) { dbgPrint = false; // Debug printout FboSetup * fbo = SoXipFboElement::getActive(action->getState(), this); int col = fbo->numColorAttachments; int dep = fbo->numDepthAttachments; SoDebugError::postInfo("SoXipBindTextures", "(fbo %d %d %d) binding %d %d %d on %d %d %d", fbo->fboHandle, col, dep, mTexHandles[0], mTexHandles[1], mTexHandles[2], mTexUnits[0], mTexUnits[1], mTexUnits[2]); } #endif }
/** * Sets up the buffers, saves the state and pushes the effected attributes. * Allocates buffer if need be and performs most functionallity. */ void SoXipFboAttachColor3D::GLRender(SoGLRenderAction* action) { FboSetup * fbo = SoXipFboElement::getActive(action->getState(), this); if (!fbo->isOpen) return; if (*fbo != mFboIn || fbo->isDirty) { if (fbo->numColorAttachments != 0) SoDebugError::postInfo("SoXipFboAttachColor3D", "Replacing existing color attachments, please set 0 attachments in Fbo node"); mFboIn = *fbo; mFboIn.isDirty = false; mNeedsUpdate = true; //SoDebugError::postInfo("SoXipFboAttachColor3D", "mFboIn != fbo"); } if (mNodeId != getNodeId()) { mNodeId = getNodeId(); mFboIn = *fbo; mNeedsUpdate = true; //SoDebugError::postInfo("SoXipFboAttachColor3D", "mNodeId != nodeId"); } if (mNeedsUpdate) { //if (mIsAllocated) // deallocate(); checkMaxNumAttachments(); // Update setup according to fields mNumAttachments = multiplicity.getValue(); mFboOut = mFboIn; mFboOut.colorStorage = GL_TEXTURE_3D; mFboOut.numColorAttachments = mNumAttachments; mFboOut.width = sizeX.getValue(); mFboOut.height = sizeY.getValue(); mFboOut.depth = sizeZ.getValue(); mFboOut.colorFormat = format.getValue(); mFboOut.internalColorFormat = internalFormat.getValue(); mFboOut.colorWrap = wrap.getValue(); mFboOut.colorFilter = filter.getValue(); // Reserve a unit for setting up the fbo textures GLuint unit = SoXipMultiTextureElement::getFreeUnit(action->getState()); SoXipMultiTextureElement::setUnit(action->getState(), unit); SoXipMultiTextureElement::bindTexture(action->getState(), mFboOut.colorStorage, 0); allocate(); syncOutput(); mFboOut.isDirty = true; mNeedsUpdate = false; } else mFboOut.isDirty = false; // Update settings mFboOut.numColorAttachments = mNumAttachments; for (int i = 0; i < mNumAttachments; i++) mFboOut.colorHandles[i] = mHandles[i]; mFboOut.hasModColors = true; // Upload to element SoXipFboElement::set(action->getState(), this, mFboOut); }