void Genetic_AlgorithmApp::mouseUp(MouseEvent event)
{
    if (event.isLeft())
    {
        m_isBuilder = false;
    }
}
void DavidShaw_RoyalSocApp::mouseDown( MouseEvent event )
{
	if(event.isLeft()) {
		

		x1 = (float(event.getX()));
		y1 = (float(event.getY()));
		Node* cur = sentinel->prev_;
		while(cur!=sentinel) {
			grabFlag = cur->isInside(x1,y1);
			if(grabFlag) {
				grabbedSquare=cur;
			}
			cur = cur->prev_;
		}

	}
	if(grabFlag){ // I'm not sure this works. I've tried it out, but I never get the expected result. - Nick
		grabbedSquare->prev_->next_=grabbedSquare->next_;
		grabbedSquare->next_->prev_=grabbedSquare->prev_; //pulls grabbed square out & connects it's siblings - Nick
		grabbedSquare->next_=sentinel->next_;
		grabbedSquare->next_->prev_=grabbedSquare;
		grabbedSquare->prev_=sentinel;
		sentinel->next_=grabbedSquare; // pulls grabbedsquare to the top. - Nick
	}
}
Beispiel #3
0
void planetsApp::mouseUp(MouseEvent event) {
	if (event.isLeft()) {
		float curTime = getElapsedSeconds();
		if (curTime - lastClickTime <= 0.25 && !doubleClick) {
			doubleClick = true;

			Vec3f start, dir;
			mCam.getPickingRay(event.getPos(), start, dir);
			selected = cont.pickPlanet(start, dir);
			point1 = start;
			dir1 = dir * 1000;

			if (selected) 
				tracking = true;
			else if (!selected && tracking)
				tracking = false;
		}else 
			doubleClick = false;

		lastClickTime = curTime;
	}
	
	if(event.isMiddle() && tracking) {

	}
}
Beispiel #4
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;
}
Beispiel #5
0
bool PointSelectCtrl::handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e ) 
{ 
	if( e.isLeft() && e.isShift() && !e.isAlt() && !e.isCtrl() )
	{
		return installCommand( new _SelectPointCmd( this, d_view ) ); // && d_swallow; 
	}else if( e.isLeft() && e.isNoKey() )
	{
		ViewAreaMdl* mdl = d_view->getViewArea();
		d_view->selectPeak( mdl->toPpm( e.getX(), a.getLeft(), DimX ), 
			mdl->toPpm( e.getY(), a.getTop(), DimY ) );	
		// Nicht immer true zurück, damit Cursor funktioniert.
		notifySelection( d_view, SpinPointView::PairIdLabelSysOrResi );
		return d_swallow;
	}
	// else
		return false;
}
Beispiel #6
0
bool SelectRulerCtr::handleMousePress( MouseEvent& e ) 
{ 
	if( e.isLeft() && e.isShift() && !e.isAlt() && !e.isCtrl() )
	{
		return installCommand( new _SelectRulerCmd( this, d_mdl ), &e ); 
	}else
		return false;
}
Beispiel #7
0
bool PeakSelectCtrl::handleMousePress( MouseEvent& e ) 
{ 
	if( d_eatDrag && e.isLeft() && e.isShift() && !e.isAlt() && !e.isCtrl() )
	{
		return installCommand( new _SelectPeakCmd( this, d_view ), &e ); 
	}else if( e.isLeft() && !e.isAlt() && !e.isCtrl() )
	{
		assert( d_view->getBuf() );
		ViewAreaMdl* mdl = d_view->getBuf()->getViewArea();
		d_view->selectPeak( mdl->toPpm( e.getX(), mdl->getAllocation().getLeft(), DimX ), 
			mdl->toPpm( e.getY(), mdl->getAllocation().getTop(), DimY ), !e.isShift() );	
		// Nicht immer true zurück, damit Cursor funktioniert.
		notifySelection( d_view );
		return d_swallow;
	}
	// else
		return false;
}
Beispiel #8
0
bool SelectZoomCtrl::handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e ) 
{ 
	if( e.isLeft() && e.isCtrl() && e.isShift() && !e.isAlt() )
	{
		return installCommand( new _SelectZoomCmd( this, d_viewer->getViewArea(), 
			d_do[ DimX ], d_do[ DimY ] ) ); 
	}else
		return false;
}
void bakersc3Starbucks::mouseDown( MouseEvent event ){
	clicked = true;
	if(event.isLeft()){
		double x = mousePos.x;
		double y = mousePos.y;
		//panda->getNearest(x, y);
		console() << "clicked!" <<endl;
	}
}
void AnotherSandboxProjectApp::mouseUp( MouseEvent event )
{
    if (event.isLeft())
    {
        modifyCell(event.getPos(), 1.0f);
    }
    else if (event.isRight())
    {
        modifyCell(event.getPos(), -1.0f);
    }
}
Beispiel #11
0
bool ScrollCtrl::handleMousePress(MouseEvent& e ) 
{ 
	if( e.isLeft() && e.isCtrl() && !e.isShift() && !e.isAlt() )
	{
		getViewport()->grab( this );
		d_lastX = e.getX();
		d_lastY = e.getY();
		Viewport::pushCursor( Viewport::CurHand );
		return true;
	}else
		return false;
}
Beispiel #12
0
/**
* Catches 2 mouse clicks and creates a rectangle between them
* only draws a rectangle if first click is the top left point 
* and second is the bottom right point of the rectangle
* @param event A mouse event to allow interaction with the program
**/
void HW1App::mouseDown( MouseEvent event )
{
	// is there a way to make mouseX2, mouse Y2 values changed to mouseX1, mouseY1 if they do not draw anything in makeRectangle()?
	// I had to read through the source code to find out why things were only happening some of the time even when I was clicking below and to the right of my previous click

	//Sets bottom right coordinate of rectangle and draws it
	//Color is currently set to blue
	if(event.isLeft() && mouseMod){
		mouseX2 = event.getX();
		mouseY2 = event.getY();
		makeRectangle(data, mouseX1, mouseY1, mouseX2, mouseY2, blue);
		mouseMod = false;
		return;
	}
	if(event.isLeft()){ //Sets top left coordinate of rectangle/prepares function for next click
		mouseX1 = event.getX();
		mouseY1 = event.getY();
		mouseMod = true;
		return;
	}
}
Beispiel #13
0
void TerrainApp::mouseUp( MouseEvent event )
{
	if( event.isLeft() ){
		mMouseLeftDown = false;
	}
	
	if( event.isRight() ){
		mMouseRightDown = false;
		mMouseRightPos	= getWindowSize() - event.getPos();
	}
	
	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 ) ;
    }
}
Beispiel #15
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;
    }   
}
Beispiel #16
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();
	}
}
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;
	}
}
Beispiel #18
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);
	}
}
void DavidShaw_RoyalSocApp::mouseUp( MouseEvent event ) 
{
	if(event.isLeft()) {

		x2 = (float(event.getX()));
		y2 = (float(event.getY()));
	}

	if(!grabFlag){
		new Node(x1,y1,x2,y2,sentinel); 
	}
	grabFlag = false;
	grabbedSquare = NULL;
}
Beispiel #20
0
void bsplineApp::mouseDown( MouseEvent event )
{
	const float MIN_CLICK_DISTANCE = 6.0f;
	if( event.isLeft() ) { // line
		Vec2f clickPt = Vec2f( event.getPos() );
		int nearestIdx = findNearestPt( clickPt );
		if( ( nearestIdx < 0 ) || ( mPoints[nearestIdx].distance( clickPt ) > MIN_CLICK_DISTANCE ) ) {
			mPoints.push_back( Vec2f( event.getPos() ) );
			mTrackedPoint = -1;
		}
		else
			mTrackedPoint = nearestIdx;
		calcLength();
	}
}
Beispiel #21
0
/* ========================================================
	mouseDown(MouseEvent)
======================================================== */
void GraphyApp::mouseDown(MouseEvent me)
{
	Vec2i pos = me.getPos();

	if (me.isLeft())
	{
		if (panel.checkClick(Vec2f(pos.x, pos.y)))
		{
			panel.setDragging(true);
		}
		else if (panel2.checkClick(Vec2f(pos.x, pos.y)))
		{
			panel2.setDragging(true);
		}
	}
}
Beispiel #22
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;
}
Beispiel #23
0
	bool handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e )
	{
		if( e.isLeft() && d_agent->getCurDim() != -1 )
		{
			d_phi = d_agent->getPhi();
			d_psi = d_agent->getPsi();
			if( e.getX() < ( a.getLeft() + a.getWidth() / 10 ) )
				d_dim = DimY;
			else if( e.getY() < ( a.getTop() + a.getHeight() / 10 ) )
				d_dim = DimX;
			else
				d_dim = DimUndefined;
			v.grab( this );
			return true;
		}else
			return false;
	}
Beispiel #24
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();
  }
}
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);
	}
}
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);
	}
}
Beispiel #27
0
/**
*This function contains the code which allows items to be 
*grouped (contain each other) and considered one item. 
*Releasing an item you are dragging over another item (while
*holding shift) makes the first item the second items child.
*This means that the first item can nolonger be iteracted with
*and that moving or reordering the second item will cause the
*same to happen to the first item. Any number of items can be 
*made children of an item but if you make an item with a child 
*a child that items child will disapear.
*
*This satisfies the "move range of items" requirement, goal F
*and the "ojects can contain objects" requirement, goal I
*/
void homework2App::mouseUp(MouseEvent event){
	if(event.isShiftDown()&&event.isLeft()&&selectedNode_!=NULL){
		ListNode* currentNode = headNode_;

		do{
			if(currentNode->shape_->
				isInside(selectedNode_->shape_->x_,
				selectedNode_->shape_->y_))
			{
				selectedNode_ = selectedNode_->removeNode();
				currentNode->addChild(selectedNode_);
				selectedNode_ = NULL;
				break;
			}
			currentNode = currentNode->next_;
		}while(currentNode!=headNode_);
	}
}
Beispiel #28
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;
		}
	}
 }
/**********************************************************************************

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 ();
        }
    }
}