Exemple #1
0
void copyStencilToColor(GLenum whichColorBuffer)
{
    int		x, y;
    GLint	previousColorBuffer;

    glReadPixels(0, 0, winWidth, winHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
        stencilSave);

    /* I'm sure this could be done much better with OpenGL */
    for(y = 0; y < winHeight; y++)
	for(x = 0; x < winWidth; x++) {
	    int stencilValue;
	    
	    stencilValue = stencilSave[winWidth * y + x];

	    colorSave[(winWidth * y + x) * 3 + 0] = colors[stencilValue % 7][0];
	    colorSave[(winWidth * y + x) * 3 + 1] = colors[stencilValue % 7][1];
	    colorSave[(winWidth * y + x) * 3 + 2] = colors[stencilValue % 7][2];
	}

    pushOrthoView(0, 1, 0, 1, 0, 1);
    glRasterPos3f(0, 0, -.5);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_STENCIL_TEST);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glGetIntegerv(GL_DRAW_BUFFER, &previousColorBuffer);
    glDrawBuffer(whichColorBuffer);
    glDrawPixels(winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, colorSave);
    glDrawBuffer(previousColorBuffer);
    glEnable(GL_DEPTH_TEST);
    popView();
}
/*!
 * \brief AbstractAnimationWindow::clearView
 */
void AbstractAnimationWindow::clearView()
{
  if (mpViewerWidget) {
    mpViewerWidget->getSceneView()->setSceneData(0);
    popView();
    mpViewerWidget->update();
  }
}
Exemple #3
0
void copyDepthToColor(GLenum whichColorBuffer)
{
    int		x, y;
    GLfloat	max, min;
    GLint	previousColorBuffer;

    glReadPixels(0, 0, winWidth, winHeight, GL_DEPTH_COMPONENT, GL_FLOAT,
        depthSave);

    /* I'm sure this could be done much better with OpenGL */
    max = 0;
    min = 1;
    for(y = 0; y < winHeight; y++)
	for(x = 0; x < winWidth; x++) {
	    if(depthSave[winWidth * y + x] < min)
		min = depthSave[winWidth * y + x];
	    if(depthSave[winWidth * y + x] > max && depthSave[winWidth * y + x] < .999)
		max = depthSave[winWidth * y + x];
	}

    for(y = 0; y < winHeight; y++)
	for(x = 0; x < winWidth; x++) {
	    if(depthSave[winWidth * y + x] <= max)
		depthSave[winWidth * y + x] = 1 -  (depthSave[winWidth * y + x] - min) / (max - min);
	    else
		depthSave[winWidth * y + x] = 0;
	}

    pushOrthoView(0, 1, 0, 1, 0, 1);
    glRasterPos3f(0, 0, -.5);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_STENCIL_TEST);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glGetIntegerv(GL_DRAW_BUFFER, &previousColorBuffer);
    glDrawBuffer(whichColorBuffer);
    glDrawPixels(winWidth, winHeight, GL_LUMINANCE , GL_FLOAT, depthSave);
    glDrawBuffer(previousColorBuffer);
    glEnable(GL_DEPTH_TEST);
    popView();
}
/*!
    Function activates view based on viewId parameter. If requested view is
    already open, it is requested to reload. Otherwise view object is created
    and pushed to view stack.
*/
void NmApplication::enterNmUiView(NmUiStartParam *startParam)
{
    NM_FUNCTION;
    
    // Check the validity of start parameter object.
    if (startParam) {
    
        mCurrentMailboxId = startParam->mailboxId();
        
        if (startParam->service() && mMainWindow) {
			// When the message list is started as a service previous views
            // are removed from the stack. Open editors are closed. Also
            // if the view is same than the new one, keep it open (reload the
            // content).
            
		    // Reset the foreground service flag while popping the views.
		    bool previousForegroundService = mForegroundService;
		    mForegroundService = true;
		    
		    // At least one view must remain in the stack.
			while (mViewStack->count( )> 1) {
			    NmUiViewId topId = mViewStack->top()->nmailViewId();
			    if (topId != NmUiViewMessageEditor &&
			        topId != NmUiViewMailboxList &&
			        topId != startParam->viewId()) {
			        prepareForPopView();
			    }
			    else {
			        // Editor or mailbox list in the top. Stop the loop.
			        break;
			    }
			}
			mForegroundService = previousForegroundService;
        }
        
        // Check whether requested view is already active and if so, ask it
        // to reload contents with new start parameter data. Do not reuse the
        // view if started as service to editor view (ShareUI).
        if (mActiveViewId == startParam->viewId() &&
        	(!startParam->service() || mActiveViewId!=NmUiViewMessageEditor)) {
            
            //startParam pointer is tested before usage below
            //coverity[deref_arg]
            mViewStack->top()->reloadViewContents(startParam);
        }
        else {
            switch (startParam->viewId()) {
                case NmUiViewMailboxList:
                {
                    NmMailboxListView *mbListView = new NmMailboxListView(
                    		*this, startParam, *mUiEngine,
                    		*mMbListModel, new HbDocumentLoader(mMainWindow));
                    pushView(mbListView);
                }
                break;
                case NmUiViewMessageList:
                {
                    // Check the topmost view. If it is an editor, save to draft and close it.
                    if (startParam->service() && !mViewStack->isEmpty() && 
                        mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) {
                        QMetaObject::invokeMethod(mViewStack->top(),
                            "safeToDraft", Qt::DirectConnection);
                        popView();
                    }

                    NmMessageListModel *messageListModel =
                        &mUiEngine->messageListModel(startParam->mailboxId(),
                                                     startParam->folderId());
                    NmMessageListView *msgList =
                        new NmMessageListView(*this, startParam, *mUiEngine,
                                              *mMbListModel, messageListModel,
                                              new HbDocumentLoader(mMainWindow));
                    pushView(msgList);
                    
                    // Inform other processes about this event.
                    NmUiEventsNotifier::notifyViewStateChanged(NmUiEventsNotifier::NmViewShownEvent,
                                                               NmUiViewMessageList,
                                                               startParam->mailboxId());
                }
                break;
                case NmUiViewMessageSearchList:
                {
                    // Check the topmost view. If it is an editor, save to draft and close it.
                    if (startParam->service() && !mViewStack->isEmpty() && 
                        mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) {
                        QMetaObject::invokeMethod(mViewStack->top(),
                            "safeToDraft", Qt::DirectConnection);
                        popView();
                    }
                    
                    NmMessageListModel &model =
                        mUiEngine->messageListModelForSearch(startParam->mailboxId());
                    
                    NmMessageSearchListView *searchListView = new NmMessageSearchListView(
                        *this, startParam, *mUiEngine, model,
                        new HbDocumentLoader(mMainWindow));
                    
                    pushView(searchListView);
                }
                break;
                case NmUiViewMessageViewer:
                    pushView(new NmViewerView(*this, startParam, *mUiEngine,
                            mMainWindow, *mAttaManager));
                    break;
                case NmUiViewMessageEditor:
                    // Check the topmost view. If it is an editor, save to draft and close it.
                    if (startParam->service() && !mViewStack->isEmpty() && 
                        mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) {
                        QMetaObject::invokeMethod(mViewStack->top(),
                            "safeToDraft", Qt::DirectConnection);
                        popView();
                    }
                    pushView(new NmEditorView(*this, startParam, *mUiEngine, *mAttaManager));
                    break;
                default:
                    // Reset view stack and exit application.
                    delete startParam;
                    startParam = NULL;
                    resetViewStack();
                    break;
            }
        }
        
        if (startParam && startParam->service()) {
            // Store the view id that was launched as service.
            mServiceViewId = mActiveViewId;
		}
    }
}