Exemplo n.º 1
0
MStatus CMayaManager::BindViewerToPanel (const char* strView)
{
    //HRESULT hr= S_OK;
    HWND renderwnd= NULL;
    MDagPath MayaCamera;

    if(strView == NULL)
        strView= "";

    StringCchCopyA(m_ViewerBinding, MAX_PATH, strView);

    if(strView && (strView[0] != '\0'))
    {
        if(0 == lstrcmpiA(strView, "floating"))
        {
            g_Viewer.BindToWindow(NULL, true);
        }
        else
        {
            M3dView ourView;
            M3dView::get3dView(0,ourView);

            for(UINT iView= 0; iView < M3dView::numberOf3dViews(); iView++)
            {
                M3dView::get3dView(iView, ourView);
                ourView.getCamera(MayaCamera);
                MayaCamera.pop();
                if(MayaCamera.partialPathName() == MString(strView))
                {
                    renderwnd= (HWND)ourView.window();
                    g_Viewer.BindToWindow(ourView.window(), true);
                    break;
                }
            }
        }
    }

//e_Exit:

    return MS::kSuccess;
}
Exemplo n.º 2
0
MStatus marqueeContext::doRelease( MEvent & event )
//
// Selects objects within the marquee box.
{

	MSelectionList			incomingList, marqueeList;

	// Clear the marquee when you release the mouse button

#ifdef USE_SOFTWARE_OVERLAYS

	GLboolean depthTest[1];
	GLboolean colorLogicOp[1];
	GLboolean lineStipple[1];

	event.getPosition( last_x, last_y );

	// Save the state of these 3 attribtes and restore them later.
	glGetBooleanv (GL_DEPTH_TEST, depthTest);
	glGetBooleanv (GL_COLOR_LOGIC_OP, colorLogicOp);
	glGetBooleanv (GL_LINE_STIPPLE, lineStipple);

	// Turn Line stippling on.
	glLineStipple( 1, 0x5555 );
	glLineWidth( 1.0 );
	glEnable( GL_LINE_STIPPLE );

	// Disable GL_DEPTH_TEST
	glDisable (GL_DEPTH_TEST);

	// Enable XOR mode.
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp (GL_INVERT);

	// Save the current Matrix onto the stack
	glMatrixMode (GL_MODELVIEW);
	glPushMatrix();

	// Setup the Orthographic projection Matrix.
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
    gluOrtho2D(
    			0.0, (GLdouble) view.portWidth(),
    			0.0, (GLdouble) view.portHeight()
    );
    glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
    glTranslatef(0.375, 0.375, 0.0);

	// Set the draw color
	glIndexi (2);

	// Redraw the marquee so that it will be cleared from the screen
	// when the mouse is released.
	glBegin( GL_LINE_LOOP );
		glVertex2i( start_x, start_y );
		glVertex2i( p_last_x, start_y );
		glVertex2i( p_last_x, p_last_y );
		glVertex2i( start_x, p_last_y );
	glEnd();
		

#ifndef _WIN32
    glXSwapBuffers( view.display(), view.window() );
#else
	SwapBuffers( view.deviceContext() );
#endif

	// Restore saved Matrix from stack
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();

	glDisable(GL_COLOR_LOGIC_OP);
	
	// Restore the previous state of these attributes
	if (colorLogicOp[0])
		glEnable (GL_COLOR_LOGIC_OP);
	else
		glDisable (GL_COLOR_LOGIC_OP);

	if (depthTest[0])
		glEnable (GL_DEPTH_TEST);
	else
		glDisable (GL_DEPTH_TEST);

	if (lineStipple[0])
		glEnable( GL_LINE_STIPPLE );
	else
		glDisable( GL_LINE_STIPPLE );

#else
	// If HW overlays enabled, then clear the overlay plane
	// such that the marquee is no longer drawn on screen.
	view.clearOverlayPlane();
	view.endOverlayDrawing();
#endif

	view.endGL();

	// Get the end position of the marquee
	event.getPosition( last_x, last_y );

	// Save the state of the current selections.  The "selectFromSceen"
	// below will alter the active list, and we have to be able to put
	// it back.
	MGlobal::getActiveSelectionList(incomingList);

	// If we have a zero dimension box, just do a point pick
	//
	if ( abs(start_x - last_x) < 2 && abs(start_y - last_y) < 2 ) {
		MGlobal::selectFromScreen( start_x, start_y, MGlobal::kReplaceList );
	} else {
		// Select all the objects or components within the marquee.
		MGlobal::selectFromScreen( start_x, start_y, last_x, last_y,
								   MGlobal::kReplaceList );
	}

	// Get the list of selected items
	MGlobal::getActiveSelectionList(marqueeList);

	// Restore the active selection list to what it was before
	// the "selectFromScreen"
	MGlobal::setActiveSelectionList(incomingList, MGlobal::kReplaceList);

	// Update the selection list as indicated by the modifier keys.
	MGlobal::selectCommand(marqueeList, listAdjustment);
	return MS::kSuccess;		
}
Exemplo n.º 3
0
MStatus marqueeContext::doDrag( MEvent & event )
//
// Drag out the marquee (using OpenGL)
//
{
	
	event.getPosition( last_x, last_y );


#ifdef USE_SOFTWARE_OVERLAYS

	GLboolean depthTest[1];
	GLboolean colorLogicOp[1];
	GLboolean lineStipple[1];

	// Save the state of these 3 attribtes and restore them later.
	glGetBooleanv (GL_DEPTH_TEST, depthTest);
	glGetBooleanv (GL_COLOR_LOGIC_OP, colorLogicOp);
	glGetBooleanv (GL_LINE_STIPPLE, lineStipple);
#endif

	// Turn Line stippling on.
	glLineStipple( 1, 0x5555 );
	glLineWidth( 1.0 );
	glEnable( GL_LINE_STIPPLE );

	// Save the state of the matrix on stack
	glMatrixMode (GL_MODELVIEW);
	glPushMatrix();

	// Setup the Orthographic projection Matrix.
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
    gluOrtho2D(
    			0.0, (GLdouble) view.portWidth(),
    			0.0, (GLdouble) view.portHeight()
    );
    glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
    glTranslatef(0.375, 0.375, 0.0);

	// Set the draw color
	glIndexi (2);

	// If we are using software overlays then we need to draw the marquee
	// in XOR mode

#ifdef USE_SOFTWARE_OVERLAYS
	
	glDisable (GL_DEPTH_TEST);

	// Enable XOR mode.
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp (GL_XOR);

	// We erase the previously drawn rubber band on the screen by 
	// redrawing it in XOR OpenGL mode.

	if (fsDrawn)
	{
		
		glBegin( GL_LINE_LOOP );
			glVertex2i( start_x, start_y );
			glVertex2i( p_last_x, start_y );
			glVertex2i( p_last_x, p_last_y );
			glVertex2i( start_x, p_last_y );
		glEnd();
		
	}

	fsDrawn = true;
#else
	// If HW overlays enabled then we will clear the overlay plane 
	// so that the previously drawn marquee does not appear on the screen
	// anymore
	view.clearOverlayPlane();

#endif

	// Draw the rectangular marquee
	//
	glBegin( GL_LINE_LOOP );
		glVertex2i( start_x, start_y );
		glVertex2i( last_x, start_y );
		glVertex2i( last_x, last_y );
		glVertex2i( start_x, last_y );
	glEnd();

#ifdef _WIN32
	SwapBuffers( view.deviceContext() );
#elif defined (OSMac_)
	::aglSwapBuffers(view.display()); 
#else
	glXSwapBuffers( view.display(), view.window() );
#endif

	// Restore the state of the matrix from stack
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();


#ifdef USE_SOFTWARE_OVERLAYS
	// Store the current x and y coordinates such that in the next iteration
	// we can erase this marquee by redrawing it in XOR mode.
	p_last_x = last_x;
	p_last_y = last_y;

	// Restore the previous state of these attributes
	if (colorLogicOp[0])
		glEnable (GL_COLOR_LOGIC_OP);
	else
		glDisable (GL_COLOR_LOGIC_OP);

	if (depthTest[0])
		glEnable (GL_DEPTH_TEST);
	else
		glDisable (GL_DEPTH_TEST);

	if (lineStipple[0])
		glEnable( GL_LINE_STIPPLE );
	else
		glDisable( GL_LINE_STIPPLE );
#endif

	return MS::kSuccess;		

}