Exemple #1
0
void ViewCanvas::OnMouseDown( wxMouseEvent& e )
{
    if (!m_Focused)
    {
        // focus and eat the event
        SetFocus();
    }
    else
    {
        // if any key is down
        if (e.LeftIsDown() || e.MiddleIsDown() || e.RightIsDown())
        {
            // and we don't already own the mouse
            if (GetCapture() != this)
            {
                // capture it
                CaptureMouse();
            }
        }

        Helium::MouseButtonInput input;
        Helium::ConvertEvent( e, input );
        m_Viewport.MouseDown( input );
        e.Skip( input.GetSkipped() );
    }

    Refresh();
    Update();
}
Exemple #2
0
void Viewport::MouseDown(const Helium::MouseButtonInput& input)
{
	// reset drag mode
	m_DragMode = DragModes::None;

	// are we going to allow entering select drag?
	bool allowSelection = true;

	// if the camera modifier key is down
	if (input.AltIsDown())
	{
		m_Cameras[m_CameraMode].MouseDown( input );

		// camera now owns the drag
		m_DragMode = DragModes::Camera;

		// do NOT allow selection while moving the camera
		allowSelection = false;

		// Save the previous view before it is updated
		UpdateCameraHistory();   
	}
	else if (m_Tool) // else if we have a tool object
	{
		// hit test the tool, and if we intersect or its a tool modifier mouse key
		if (m_Tool->MouseDown( input ) || input.MiddleDown() || input.RightDown())
		{
			// the tool now owns this drag
			m_DragMode = DragModes::Tool;
		}
		else
		{
			// we can still allow selection if it didn't hit he tool
			allowSelection = m_Tool->AllowSelection();
		}
	}

	// if its the left key if we are still looking for a selection
	if ( (input.LeftIsDown() || input.MiddleIsDown()) && m_DragMode == DragModes::None && allowSelection )
	{
		// we are selecting
		m_DragMode = DragModes::Select;

		// reset point trackers
		m_Start = Point (input.GetPosition().x, input.GetPosition().y);
		m_End = Point (input.GetPosition().x, input.GetPosition().y);

		// reset selection frame
		m_SelectionFrame->m_Start = m_Start;
		m_SelectionFrame->m_End = m_End;
		m_SelectionFrame->Update();

		// if we are highlighting
		if ( m_Highlighting )
		{
			// clear the previously highlighted set
			m_ClearHighlight.Raise( ClearHighlightArgs (false) );
		}
	}
}
Exemple #3
0
///////////////////////////////////////////////////////////////////////////////
// Stop tracking mouse movement for moving the camera.
// 
void RenderWindow::OnMouseUp( wxMouseEvent& args )
{
    args.Skip();
    if ( HasCapture() )
    {
        ReleaseMouse();
    }

    Helium::MouseButtonInput input;
    Helium::ConvertEvent( args, input );
    m_Camera.MouseUp( input );
    args.Skip( input.GetSkipped() );
}
Exemple #4
0
void ViewCanvas::OnMouseUp(wxMouseEvent& e)
{
    if (!e.LeftIsDown() && !e.MiddleIsDown() && !e.RightIsDown())
    {
        if (GetCapture() == this)
        {
            ReleaseMouse();
        }
    }

    Helium::MouseButtonInput input;
    Helium::ConvertEvent( e, input );
    m_Viewport.MouseUp( input );
    e.Skip( input.GetSkipped() );

    Refresh();
    Update();
}
Exemple #5
0
///////////////////////////////////////////////////////////////////////////////
// Start tracking mouse movement for moving the camera.
// 
void RenderWindow::OnMouseDown( wxMouseEvent& args )
{
    args.Skip();

    bool modifier = args.ControlDown() || args.MetaDown() || args.ShiftDown() || args.AltDown();
    // Right-click with no modifier keys means to show a context menu
    if ( args.RightDown() && !modifier )
    {
        ShowContextMenu( args.GetPosition() );
    }
    else
    {
        CaptureMouse();

        Helium::MouseButtonInput input;
        Helium::ConvertEvent( args, input );
        m_Camera.MouseDown( input );
        args.Skip( input.GetSkipped() );
    }
}
Exemple #6
0
void Viewport::MouseUp( const Helium::MouseButtonInput& input )
{
	// have we completed a drag?
	bool dragComplete = false;

	switch (m_DragMode)
	{
	case DragModes::None:
		{
			if (!m_Tool && input.RightUp())
			{
				m_End = Point (input.GetPosition().x, input.GetPosition().y);
				m_SelectionFrame->m_End = m_End;
				m_SelectionFrame->Update();

				PickVisitor* pick = NULL;

				SelectionTargetMode targetMode = SelectionTargetModes::Single;

				if (m_SelectionFrame->m_Start.x == m_SelectionFrame->m_End.x && m_SelectionFrame->m_Start.y == m_SelectionFrame->m_End.y)
				{
					pick = new FrustumLinePickVisitor (&m_Cameras[m_CameraMode], m_SelectionFrame->m_Start.x, m_SelectionFrame->m_Start.y);
					targetMode = SelectionTargetModes::Single;
				}
				else 
				{
					Frustum worldSpaceFrustum;
					if ( m_Cameras[m_CameraMode].ViewportToFrustum( (float32_t)m_SelectionFrame->m_Start.x, (float32_t)m_SelectionFrame->m_Start.y, (float32_t)m_SelectionFrame->m_End.x, (float32_t)m_SelectionFrame->m_End.y, worldSpaceFrustum) )
					{
						Point center ( m_SelectionFrame->m_Start + m_SelectionFrame->m_End / 2 );

						Line line;
						m_Cameras[m_CameraMode].ViewportToLine( (float32_t)center.x, (float32_t)center.y, line);

						pick = new FrustumLinePickVisitor(&m_Cameras[m_CameraMode], line, worldSpaceFrustum );
						targetMode = SelectionTargetModes::Multiple;
					}                   
				}

				if ( pick )
				{
					m_Select.Raise( SelectArgs (pick, SelectionModes::Manifest, targetMode) );
					delete pick;
					pick = NULL;
				}

				// our drag is complete now
				dragComplete = true;
			}

			break;
		}

	case DragModes::Select:
		{
			if (input.LeftUp() || input.MiddleUp())
			{
				m_End = Point (input.GetPosition().x, input.GetPosition().y);
				m_SelectionFrame->m_End = m_End;
				m_SelectionFrame->Update();

				PickVisitor* pick = NULL;

				SelectionTargetMode targetMode = SelectionTargetModes::Single;

				if (m_SelectionFrame->m_Start.x == m_SelectionFrame->m_End.x && m_SelectionFrame->m_Start.y == m_SelectionFrame->m_End.y)
				{
					pick = new FrustumLinePickVisitor (&m_Cameras[m_CameraMode], m_SelectionFrame->m_Start.x, m_SelectionFrame->m_Start.y);
					targetMode = SelectionTargetModes::Single;
				}
				else 
				{
					Frustum worldSpaceFrustum;

					if ( m_Cameras[m_CameraMode].ViewportToFrustum( (float32_t)m_SelectionFrame->m_Start.x, (float32_t)m_SelectionFrame->m_Start.y, (float32_t)m_SelectionFrame->m_End.x, (float32_t)m_SelectionFrame->m_End.y, worldSpaceFrustum) )
					{
						Point center ( m_SelectionFrame->m_Start + m_SelectionFrame->m_End / 2 );

						Line line;
						m_Cameras[m_CameraMode].ViewportToLine( (float32_t)center.x, (float32_t)center.y, line);

						pick = new FrustumLinePickVisitor (&m_Cameras[m_CameraMode], line, worldSpaceFrustum); 
						targetMode = SelectionTargetModes::Multiple;
					}
				}

				if ( pick )
				{
					SelectionModes::SelectionMode selectMode;

					if (input.MiddleUp())
					{
						selectMode = SelectionModes::Manifest;
					}
					else
					{
						if ( input.CtrlIsDown() )
						{
							if ( input.ShiftIsDown())
							{
								selectMode = SelectionModes::Add;
							}
							else
							{
								selectMode = SelectionModes::Remove;
							}
						}
						else
						{
							if ( input.ShiftIsDown())
							{
								selectMode = SelectionModes::Toggle;
							}
							else
							{
								selectMode = SelectionModes::Replace;
							}
						}
					}

					m_Select.Raise( SelectArgs (pick, selectMode, targetMode) );
					delete pick;
					pick = NULL;
				}

				// our drag is complete now
				dragComplete = true;
			}

			break;
		}

	case DragModes::Camera:
		{
			if (input.AltIsDown())
			{
				m_Cameras[m_CameraMode].MouseUp( input );
			}

			break;
		}

	default:
		{
			if (m_Tool)
			{
				m_Tool->MouseUp( input );
			}

			break;
		}
	}

	if (dragComplete)
	{
		m_DragMode = DragModes::None;
	}
}