void RodSoundApp::mouseDown(MouseEvent event)
{
  if (event.isRight()) {
    // Set targetPos to the ControlPoint we just clicked
    if (!r) return;
    Vec2i mouse = event.getPos();
    Vec2i windowSize = getWindowSize();
    Ray ray = cam.generateRay((real)mouse.x/windowSize.x,
                            1.0 - (real)mouse.y/windowSize.y,
                            getWindowAspectRatio());
    real tmin = INFINITY;
    bool any = false;
    for (int i=0; i<r->numCPs(); i++) { // A bit slow, but beats keeping a KD-Tree updated
      Sphere s(EtoC(r->cur().POS(i)), constants::radius * 1.5);
      float t;
      if (s.intersect(ray, &t) && t < tmin) {
        any = true;
        tmin = t;
      }
    }
    if (!any) return;
    targetPos = ray.calcPosition(tmin);
    cam.lookAt(targetPos);
  } else {
    if (!running) return;
    isMouseDown = true;
    mouseDrag(event);
  }
}
Esempio n. 2
0
bool CursorCtrl::handleMousePress( MouseEvent& e ) 
{ 
	if( e.isLeft() && ( e.isNoKey() || e.isAlt() ) ||
		e.isRight() && e.isShift() )
	{
		Allocation a;
		allocation( a );
		ViewAreaMdl* area = d_view->getArea();
		if( d_do[ DimX ] && d_do[ DimY ] && area->getDimCount() == 2 )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, 
				d_view->getDim( DimY ), y, d_mouseVeto );
		}else if( d_do[ DimX ] && area->inUse( DimX ) )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, d_mouseVeto );
		}else if( d_do[ DimY ] && area->inUse( DimY ) )
		{
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimY ), y, d_mouseVeto );
		}
		return d_swallow;	// Der Click soll nicht immer gefressen werden.
	}else
		return false;
}
Esempio n. 3
0
void HW04App::mouseDown( MouseEvent event )
{
    if (event.isRight()) {
        double mouse_x = (event.getX()*1.0)/getWindowWidth();
        double mouse_y = (event.getY()*1.0)/getWindowHeight();
        
        closest = starbucks->getNearest(mouse_x, mouse_y);
    }
}
void AnotherSandboxProjectApp::mouseUp( MouseEvent event )
{
    if (event.isLeft())
    {
        modifyCell(event.getPos(), 1.0f);
    }
    else if (event.isRight())
    {
        modifyCell(event.getPos(), -1.0f);
    }
}
Esempio n. 5
0
/**
* @brief Mouse Click Circle
*
* Every time the mouse is clicked, draw a circle with a random radius and colors
* in that position. Every time the right button is clicked, blur the image.
*/
void CatPictureApp::mouseDown( MouseEvent event )
{
    drawCircle(event.getX(),event.getY(),rand() % 50 + 5,
               new Color8u(rand() % 256, rand() % 256, rand() % 256),
               new Color8u(rand() % 256, rand() % 256, rand() % 256));
    if(event.isRight())
        blur();
    // took out save here since you are already saving in the setup
    // seems like it could cause issues to keep saving to the same file
    // each time the user clicks
    // writeImage("blah.png",*surface);
}
Esempio n. 6
0
void TerrainApp::mouseUp( MouseEvent event )
{
	if( event.isLeft() ){
		mMouseLeftDown = false;
	}
	
	if( event.isRight() ){
		mMouseRightDown = false;
		mMouseRightPos	= getWindowSize() - event.getPos();
	}
	
	mMouseOffset = Vec2f::zero();
}
Esempio n. 7
0
void CatalogApp::mouseDown( MouseEvent event )
{	
	if( event.isRight() ){
//		mArcball.mouseDown( event.getPos() );
		mWasRightButtonLastClicked = true;
	} else {
		mWasRightButtonLastClicked = false;
	}
	mMouseTimePressed	= getElapsedSeconds();
	mMouseDownPos = event.getPos();
	mMousePressed = true;
	mMouseOffset = Vec2f::zero();
}
/**********************************************************************************

Function Name = SecurityProjectDemoApp::mouseDown

Descriptive Name = Used to detect the mouseDown action and open the infected window.

Function =

    This function is used to detect the mouseDown by the user and open up an infected
    window at the position where the mouse down was performed. The function also
    performs additional checks to make sure that only a mousedown event is handled. 

Input =
    
    MouseEvent event - The mouse event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it. 
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::mouseDown ( MouseEvent event )
{
    // Variable Declaration 
    string messageBuffer = "" ;
    ostringstream intToStringConverter ;
    wstring stringTemp ;
    LPCWSTR debugMessage ;

    // Set the mouse positions when mouse button is pressed
    mouseDownMouseX = event.getX () ;
    mouseDownMouseY = event.getY () ;

    // Make sure to only open up the infection window if infection sequence is initialized, 
    // the current event is not already handled and the event is a left or right button click.
    if ( startInitialized && ( event.isLeft() || event.isRight() ) && event.isHandled () == false )
    {
        // ------------------------ Start of Debugging Block -----------------------------

        OutputDebugStringW ( L"\n-------------------- START Detecting a Left/Right mouseDown --------------------\n" ) ;

        // Add all information that is needed into the string stream
        intToStringConverter << "Y--> " << mouseDownMouseY << "\n" << "X--> " << mouseDownMouseX << "\n" ;

        // Fetch the string equivalence of the input (int or any other data type)
        messageBuffer = intToStringConverter.str () ;

        // Convert the messageBuffer string into wstring for later conversion
        stringTemp = wstring ( messageBuffer.begin (), messageBuffer.end () ) ;

        // Convert wstring to LPCWSTR
        debugMessage = stringTemp.c_str () ;

        OutputDebugStringW ( debugMessage ) ;

        OutputDebugStringW ( L"-------------------- DONE Detecting a Left/Right mouseDown --------------------\n" ) ;

        // ------------------------ End of Debugging Block -----------------------------

        // Create the infection window for draw function to open later
        createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                               WINDOW_X_SIZE,
                               WINDOW_Y_SIZE,
                               event.getX (),
                               event.getY ()
                             ) ;

        // Once the single event has been handled mark it as handled to make sure that
        // we avoid handling the same event multiple times.
        event.setHandled( true ) ;
    }
}
void NearestStarbucksApp::mouseDown( MouseEvent event )
{
	if(event.isRight()){
		console() << event.getX() << "," << event.getY() << std::endl;
	}
	if(event.isLeft()){
		nearest_starbucks_ = new Entry();
		nearest_starbucks_->x = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->x; 
		nearest_starbucks_->y = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->y; 
		nearest_starbucks_->identifier = tree->getNearest(1-(getWindowWidth()-event.getX()*1.0000f)/getWindowWidth(),(getWindowHeight()-event.getY()*1.0f)/getWindowHeight()*1.0f)->identifier; 
		console() << "The nearest Starbucks to the clicked point is listed below. " << std::endl; 
		console() << nearest_starbucks_->identifier << std::endl;
	}
}
Esempio n. 10
0
void Level::handleMouseDrag(MouseEvent event)
{
    if (currentMode == 2) {
        int mouseX = event.getX() - getWindowWidth() / 2.0;
        int mouseY = event.getY() - getWindowHeight() / 2.0;
        if (event.isLeft()) {
            setTileAtMousePos(mouseX, mouseY, 0);
        }
        else if (event.isRight()) {
            setTileAtMousePos(mouseX, mouseY, -1);
        }
        return;
    }   
}
Esempio n. 11
0
void Mouse_Event::PullButton(MouseEvent& mouse_event)
{
	if (mouse_event.isLeft())
	{
		mouse_status->press_mouse_button.erase(MouseEvent::LEFT_DOWN);
		mouse_status->pull_mouse_button.insert(MouseEvent::LEFT_DOWN);
	}

	if (mouse_event.isRight())
	{
		mouse_status->press_mouse_button.erase(MouseEvent::RIGHT_DOWN);
		mouse_status->pull_mouse_button.insert(MouseEvent::RIGHT_DOWN);
	}
}
Esempio n. 12
0
void TerrainApp::mouseDown( MouseEvent event )
{
	mMouseDownPos = event.getPos();
	mMouseOffset = Vec2f::zero();
	
	if( event.isLeft() ){
		mMouseLeftDown = true;
	}
	
	if( event.isRight() ){
		mMouseRightDown = true;
		mMouseRightPos	= getWindowSize() - event.getPos();
	}
}
Esempio n. 13
0
void TestbedApp::mouseUp( MouseEvent event )
{
	int x = event.getPos().x;
	int y = event.getPos().y;

	int state = GLUT_NONE;
	if( event.isLeft() ) {
		state = GLUT_UP;
		b2Vec2 p = ConvertScreenToWorld(x, y);
		test->MouseUp(p);
	}
	else if( event.isRight() ) {
		state = GLUT_UP;
		rMouseDown = false;
	}
	previousMouseState = state;
}
Esempio n. 14
0
void mouse(const MouseEvent &e){
  if(e.isRight()){
    selroi[1] = selroi[2];
    selroi[0] = Rect::null;
    step();
  }else if(e.isLeft()){
    if(e.isPressEvent()){
      selroi[0] = Rect(e.getPos(),Size(1,1));
    }else if(e.isDragEvent()){
      selroi[0].width = e.getX() - selroi[0].x;
      selroi[0].height = e.getY() - selroi[0].y;
    }else if(e.isReleaseEvent()){
      selroi[1] = selroi[0].normalized();
      selroi[0] = Rect::null;
    }
    step();
  }
}
Esempio n. 15
0
void InputEvent::mouseUp(MouseEvent event)
{
	if (event.isLeft())
	{
		setPull(MouseEvent::LEFT_DOWN);
		erasePress(MouseEvent::LEFT_DOWN);
	}
	if (event.isRight())
	{
		setPull(MouseEvent::RIGHT_DOWN);
		erasePress(MouseEvent::RIGHT_DOWN);
	}
	if (event.isMiddle())
	{
		setPull(MouseEvent::MIDDLE_DOWN);
		erasePress(MouseEvent::MIDDLE_DOWN);
	}
}
Esempio n. 16
0
void InputEvent::mouseDown(MouseEvent event)
{
	if (event.isLeft())
	{
		setPush(MouseEvent::LEFT_DOWN);
		setPress(MouseEvent::LEFT_DOWN);
	}
	if (event.isRight())
	{
		setPush(MouseEvent::RIGHT_DOWN);
		setPress(MouseEvent::RIGHT_DOWN);
	}
	if (event.isMiddle())
	{
		setPush(MouseEvent::MIDDLE_DOWN);
		setPress(MouseEvent::MIDDLE_DOWN);
	}
}
Esempio n. 17
0
void VoronoiGpuApp::mouseDown( MouseEvent event )
{
	if ( event.isLeft() )
	{
		mPoints.push_back( event.getPos() );
	}
	else if ( event.isRight() )
	{
		vector< Vec2i >::iterator it;

		it = find_if( mPoints.begin(), mPoints.end(),
				closePoint( event.getPos() ) );
		if ( it != mPoints.end() )
		{
			mPoints.erase( it );
		}
	}
	calculateVoronoiTexture();
}
 void cinderFFmpegApp::mouseDown( MouseEvent event )
 {
	if(event.isLeft())
	{
		int selected = calcSelectedPlayer(event.getX(), event.getY()); 
		if(selected < m_Players.size())
			m_iCurrentVideo = selected;
	}
	else if(event.isRight())
	{
		int selected = calcSelectedPlayer(event.getX(), event.getY()); 
		if(selected < m_Players.size())
		{
			m_iCurrentVideo = selected;
			m_Players.erase(m_Players.begin() + selected);		
			m_VideoTextures.erase(m_VideoTextures.begin() + selected);		
			if(m_iCurrentVideo>=m_Players.size())
				m_iCurrentVideo = m_Players.size() - 1;
			if(m_iCurrentVideo<=0)
				m_iCurrentVideo = 0;
		}
	}
 }
Esempio n. 19
0
void TerrainApp::mouseMove( MouseEvent event )
{
	mMousePos = event.getPos();
	if( event.isRight() )
		mMouseRightPos	= getWindowSize() - event.getPos();
}
/**********************************************************************************

Function Name = SecurityProjectDemoApp::mouseMove

Descriptive Name = Used to detect the mouseMove action and open the infected window.

Function =

    This function is used to detect the mouse move by the user and open up an infected
    window at the position where the mouse moved to. The function also
    performs additional checks to make sure that only a mousemove event is handled. 
    There are some glitches in the cinder mouse down and mouse move detection therefore
    require additional checks to make sure that it was a mouse move and not anything else.

Input =
    
    MouseEvent event - The mouse event that is detected for cinder to call the function.

Output =
   
   Creates the infected window and opens it. 
   Prints debug info also.

******************************************************************************/
void SecurityProjectDemoApp::mouseMove ( MouseEvent event )
{
    // Variable Declaration
    int mouseXDifference ;
    int mouseYDifference ;
    string messageBuffer = "" ;
    ostringstream intToStringConverter ;
    wstring stringTemp ;
    LPCWSTR debugMessage ;

    // In the case that the program has just started set the current mouse position as previous
    if ( previousMouseX == NULL && previousMouseY == NULL && startInitialized )
    {
        previousMouseX = event.getX () ;
        previousMouseY = event.getY () ;
    }
    else
    {
        // Calculate the difference between previous mouse location and current mouse location.
        mouseXDifference = abs ( previousMouseX - event.getX () ) ;
        mouseYDifference = abs ( previousMouseY - event.getY () ) ;

        // Only create the infected windows if it is initialized, the event has not already been handled, there is at least a
        // pixel difference of 5 between mouse y coordinates or mouse x coordinates, the event is not left or right click and the
        // mouseDownX and mouseDownY positions are not the same as the mouse move events.
        if ( startInitialized && event.isHandled () == false && ( mouseYDifference > 10 || mouseXDifference > 10 ) && 
             event.isLeft () == false && event.isRight () == false && mouseDownMouseX != event.getX () && mouseDownMouseY != event.getY ()
           )
        {
            // Increase the mouse move counter to show that this function was called to open up a infection window.
            // This counter will be used to allow not to open too many windows too fast or else can not actually
            // see the windows images as they open. Also the program will crash too fast as there will be a lot of
            // mouse movements. 
            mouseMoveCounter++ ;

            // ------------------------ Start of Debugging Block -----------------------------

            OutputDebugStringW ( L"\n-------------------- START Detecting the mouse moving --------------------\n" ) ;

            // Add all information that is needed into the string stream
            intToStringConverter << "Y--> " << mouseYDifference << "\n" << "X--> " << mouseXDifference << "\n" << "Mouse Move Counter--> " << mouseMoveCounter << "\n" ;

            // Fetch the string equivalence of the input (int or any other data type)
            messageBuffer = intToStringConverter.str () ;

            // Convert the messageBuffer string into wstring for later conversion
            stringTemp = wstring ( messageBuffer.begin (), messageBuffer.end () ) ;

            // Convert wstring to LPCWSTR
            debugMessage = stringTemp.c_str () ;

            OutputDebugStringW ( debugMessage ) ;
            
            OutputDebugStringW ( L"-------------------- END Detecting the mouse moving --------------------\n" );

            // ------------------------ End of Debugging Block -----------------------------

            // Only open the infection window if more then 5 mouseMoves are detected.
            if ( mouseMoveCounter > 5 )
            {
                // Create the infection window for draw function to open later
                createInfectedWindow ( loadResource ( RES_SUPPORTEDGESTURES_IMAGE ),
                                       WINDOW_X_SIZE,
                                       WINDOW_Y_SIZE,
                                       event.getX (),
                                       event.getY ()
                                     ) ;

                // Reset the mouseMove counter to 0 once a single window is opened for every 5 mouse moves.
                mouseMoveCounter = 0 ;
            }

            // Once the single event has been handled mark it as handled to make sure that
            // we avoid handling the same event multiple times.
            event.setHandled ( true );

            // Set the current mouse x and y coordinates as previous for later comparisons
            previousMouseX = event.getX ();
            previousMouseY = event.getY ();
        }
    }
}
Esempio n. 21
0
void Level::handleMouseDown(MouseEvent event)
{
    // Hero Reposition, while playing
    if (currentMode == 1) {
        int mouseX = event.getX() - getWindowWidth() / 2.0;
        int mouseY = event.getY() - getWindowHeight() / 2.0;
        if (event.isLeft()) {
            hero.position.set(mouseX + camera.position.x, mouseY + camera.position.y);
        }
        return;
    }
    
    // Hero Startpoint
    if (currentMode == 0) {
        int mouseX = event.getX() - getWindowWidth() / 2.0;
        int mouseY = event.getY() - getWindowHeight() / 2.0;
        if (event.isLeft()) {
            heroStartPosition.set(mouseX + camera.position.x, mouseY + camera.position.y);
        }
        return;
    }
    
    // Tile Edit Mode
    if (currentMode == 2) {
        int mouseX = event.getX() - getWindowWidth() / 2.0;
        int mouseY = event.getY() - getWindowHeight() / 2.0;
        if (event.isLeft()) {
            setTileAtMousePos(mouseX, mouseY, 0);
        }
        else if (event.isRight()) {
            setTileAtMousePos(mouseX, mouseY, -1);
        }
        return;
    }
    
    // Antenna Position Mode
    if (currentMode == 9) {
        int mouseX = event.getX() - getWindowWidth() / 2.0;
        int mouseY = event.getY() - getWindowHeight() / 2.0;
        if (event.isLeft()) {
            antennaPosition.set(mouseX + camera.position.x, mouseY + camera.position.y);
        }
        return;
    }
    
    // Attractor
    if (currentMode == 3) {
        int mouseX = (event.getX() - getWindowWidth() / 2.0) + camera.position.x;
        int mouseY = (event.getY() - getWindowHeight() / 2.0) + camera.position.y;
        
        if (event.isLeft()) {
            Connector* connector = pickConnector(Vec2f(mouseX, mouseY), Connectors);
            if (connector) { // select Attractor
                Attractor* attractor = dynamic_cast<Attractor*>(connector);
                selectedAttractor = attractor;
            }
            else { // add Attractor
                Attractor* attractorToAdd = new Attractor(mouseX, mouseY);
                addConnector(attractorToAdd);
                selectedAttractor = attractorToAdd;
            }
        }
        else if (event.isRight()) { // remove Attractor
            Connector* connector = pickConnector(Vec2f(mouseX, mouseY), Connectors);
            if (!connector) return;
            Attractor* attractor = dynamic_cast<Attractor*>(connector);
            if (attractor) {
                removeConnector(attractor);
            }
        }
        return;
    }
    
    // Detractor
    if (currentMode == 4) {
        int mouseX = (event.getX() - getWindowWidth() / 2.0) + camera.position.x;
        int mouseY = (event.getY() - getWindowHeight() / 2.0) + camera.position.y;
        
        if (event.isLeft()) {
            Connector* connector = pickConnector(Vec2f(mouseX, mouseY), Connectors);
            if (connector) { // select Attractor
                Detractor* detractor = dynamic_cast<Detractor*>(connector);
                selectedDetractor = detractor;
            }
            else { // add Detractor
                Detractor* detractorToAdd = new Detractor(mouseX, mouseY);
                addConnector(detractorToAdd);
                selectedDetractor = detractorToAdd;
            }
        }
        else if (event.isRight()) { // remove Detractor
            Connector* connector = pickConnector(Vec2f(mouseX, mouseY), Connectors);
            if (!connector) return;
            Detractor* detractor = dynamic_cast<Detractor*>(connector);
            if (detractor) {
                removeConnector(detractor);
            }
        }
        return;
    }
    
    
}
void ProcessingApp::mouseDrag( MouseEvent event )
{
    if( mProcessing ){
        mProcessing->call( "void mouseDragged( int x, int y, int button)", event.getX(), event.getY(), event.isLeft() ? 1 : event.isRight() ? 2 : 3 );
    }
}
Esempio n. 23
0
void TestbedApp::mouseDown( MouseEvent event )
{
#if defined( CINDER_GL_ES )
	if( mLeftButton.contains( event.getPos() ) ) {
		--testSelection;
		if (testSelection < 0)
		{
			testSelection = testCount - 1;
		}
		return;
	}
	else if( mRightButton.contains( event.getPos() ) ) {
		++testSelection;
		if (testSelection == testCount)
		{
			testSelection = 0;
		}
		return;
	}
#endif

	int x = event.getPos().x;
	int y = event.getPos().y;
	int button = GLUT_NONE;
	int state = GLUT_NONE;
	int mod = GLUT_NONE;
	if( event.isLeft() ) {
		button = GLUT_LEFT_BUTTON;
		if( event.isLeftDown() ) {
			state = GLUT_DOWN;
		}
	}
	else if( event.isRight() ) {
		button = GLUT_RIGHT_BUTTON;
		if( event.isRightDown() ) {
			state = GLUT_DOWN;
		}
	}

	if (button == GLUT_LEFT_BUTTON)
	{
		b2Vec2 p = ConvertScreenToWorld(x, y);

		switch (fullscreenUI.Mouse(button, state, previousMouseState, p))
		{
		case FullscreenUI::e_SelectionTestPrevious:
			testSelection = std::max(0, testSelection - 1);
			break;
		case FullscreenUI::e_SelectionTestNext:
			if (g_testEntries[testSelection + 1].name) testSelection++;
			break;
		case FullscreenUI::e_SelectionParameterPrevious:
			particleParameter.Decrement();
			break;
		case FullscreenUI::e_SelectionParameterNext:
			particleParameter.Increment();
			break;
		default:
			break;
		}

		if (state == GLUT_DOWN)
		{
			b2Vec2 p = ConvertScreenToWorld(x, y);
			if (mod == GLUT_ACTIVE_SHIFT)
			{
				test->ShiftMouseDown(p);
			}
			else
			{
				test->MouseDown(p);
			}
		}

		/*
		if (state == GLUT_UP)
		{
			test->MouseUp(p);
		}
		*/
	}
	else if (button == GLUT_RIGHT_BUTTON)
	{
		if (state == GLUT_DOWN)
		{
			lastp = ConvertScreenToWorld(x, y);
			rMouseDown = true;
		}

		/*
		if (state == GLUT_UP)
		{
			rMouseDown = false;
		}
		*/
	}
	previousMouseState = state;
}
Esempio n. 24
0
void MultiTouchApp::mouseDown( MouseEvent event )
{
	console() << "Mouse down: " << event.isRight() << " & " << event.isControlDown() << std::endl;	
}
Esempio n. 25
0
 virtual void process(const MouseEvent &e){
   if(gui["rect"].as<bool>() && !e.isRight()){
     DefineRectanglesMouseHandler::process(e);
   }
 }