Пример #1
0
//----------------------------------------------------------------------------//
void Editbox::onMouseButtonDown(MouseEventArgs& e)
{
    // base class handling
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton)
    {
        // grab inputs
        if (captureInput())
        {
            // handle mouse down
            clearSelection();
            d_dragging = true;
            d_dragAnchorIdx = getTextIndexFromPosition(e.position);
#ifdef CEGUI_BIDI_SUPPORT
            if (d_bidiVisualMapping->getV2lMapping().size() > d_dragAnchorIdx)
                d_dragAnchorIdx =
                    d_bidiVisualMapping->getV2lMapping()[d_dragAnchorIdx];
#endif
            setCaretIndex(d_dragAnchorIdx);
        }

        ++e.handled;
    }

}
Пример #2
0
bool Game::frameStarted(const Ogre::FrameEvent &fe)
{
	if (window->isClosed())
		return false;
	captureInput();
	return true;
}
Пример #3
0
	void FalagardDragTitle::onMouseButtonDown(MouseEventArgs& e)
	{
		// Base class processing
		Window::onMouseButtonDown(e);

		if (e.button == LeftButton)
		{
			if (d_dragTarget != NULL)
			{
				// we want all mouse inputs from now on
				if (captureInput())
				{
					// initialise the dragging state
					d_dragging = true;
					d_dragPoint = screenToWindow(e.position);

					if (getMetricsMode() == Relative)
					{
						d_dragPoint = relativeToAbsolute(d_dragPoint);
					}
				}
			}
		}

		e.handled = true;
	}
Пример #4
0
	bool BaseManager::HgeFrameFunc()
	{
		captureInput();
		updateFPS();
		drawOneFrame();
		return false;
	}
Пример #5
0
/*************************************************************************
	Handler for mouse button down events
*************************************************************************/
void FrameWindow::onMouseButtonDown(MouseEventArgs& e)
{
	// default processing (this is now essential as it controls event firing).
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		if (isSizingEnabled())
		{
			// get position of mouse as co-ordinates local to this window.
			Point localPos(CoordConverter::screenToWindow(*this, e.position));

			// if the mouse is on the sizing border
			if (getSizingBorderAtPoint(localPos) != SizingNone)
			{
				// ensure all inputs come to us for now
				if (captureInput())
				{
					// setup the 'dragging' state variables
					d_beingSized = true;
					d_dragPoint = localPos;
					e.handled = true;
				}

			}

		}

	}

}
Пример #6
0
	bool BaseManager::frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;

		if (!mGUI)
			return true;

		captureInput();

		return true;
	}
Пример #7
0
/*************************************************************************
    Handler for cursor press events
*************************************************************************/
void TabButton::onCursorPressHold(CursorInputEventArgs& e)
{
    if (e.source == CIS_Middle)
    {
        captureInput ();
        ++e.handled;
        d_dragging = true;

        fireEvent(EventDragged, e, EventNamespace);
    }

	// default handling
    ButtonBase::onCursorPressHold(e);
}
Пример #8
0
	bool BaseManager::frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;

		if (!mGUI)
			return true;

		if( mFastReset )
		{
			mFastReset = false;
			destroyScene();
			_fastReset();
			createScene();
		}

		captureInput();

		//更新控制台内容
		mConsole.updateConsole();
		
		if( mInputFilter )
			mInputFilter->frameStarted( evt );

		if (mInfo)
		{
			static float time = 0;
			time += evt.timeSinceLastFrame;
			if (time > 1&&mInfo->getVisible())
			{
				time -= 1;
				try
				{
					const Ogre::RenderTarget::FrameStats& stats = mWindow->getStatistics();
					mInfo->change("FPS", (int)stats.lastFPS);
					mInfo->change("triangle", stats.triangleCount);
					mInfo->change("batch", stats.batchCount);
					mInfo->change("batch gui", MyGUI::OgreRenderManager::getInstance().getBatchCount());
					mInfo->update();
				}
				catch (...)
				{
					MYGUI_LOG(Warning, "Error get statistics");
				}
			}
		}

		return true;
	}
Пример #9
0
/**
 * mainLoop()
 * runs the game
 */
void Engine::mainLoop()
{
	long dt = 0; // delta time since last frame

	while (!quitting) {
		captureInput();
		runGameEngine(dt);
		tryRender();

		// Sleep 'till next frame, don't waste the CPU
		dt = wait();
	}

	Quit();
}
Пример #10
0
void ButtonBase::onMouseButtonDown(MouseEventArgs& e)
{
    // default processing
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton)
    {
        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            requestRedraw();
        }

        // event was handled by us.
        e.handled = true;
    }
}
Пример #11
0
/*************************************************************************
	Handler for cursor press hold events
*************************************************************************/
void ButtonBase::onCursorPressHold(CursorInputEventArgs& e)
{
	// default processing
    Window::onCursorPressHold(e);

    if (e.source == CIS_Left)
	{
        if (captureInput())
        {
			d_pushed = true;
			updateInternalState(e.position);
			invalidate();
        }

		// event was handled by us.
		++e.handled;
	}
}
Пример #12
0
/*************************************************************************
	Handler for mouse button press events
*************************************************************************/
void Titlebar::onMouseButtonDown(MouseEventArgs& e)
{
	// Base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		if ((d_parent != NULL) && d_dragEnabled)
		{
			// we want all mouse inputs from now on
			if (captureInput())
			{
				// initialise the dragging state
				d_dragging = true;
				d_dragPoint = screenToWindow(e.position);

				if (getMetricsMode() == Relative)
				{
					d_dragPoint = relativeToAbsolute(d_dragPoint);
				}

				// store old constraint area
				d_oldCursorArea = MouseCursor::getSingleton().getConstraintArea();

				// setup new constraint area to be the intersection of the old area and our grand-parent's clipped inner-area
				Rect constrainArea;

				if ((d_parent == NULL) || (d_parent->getParent() == NULL))
				{
					constrainArea = System::getSingleton().getRenderer()->getRect().getIntersection(d_oldCursorArea);
				}
				else 
				{
					constrainArea = d_parent->getParent()->getInnerRect().getIntersection(d_oldCursorArea);
				}

				MouseCursor::getSingleton().setConstraintArea(&constrainArea);
			}

		}

		e.handled = true;
	}
}
Пример #13
0
void FalagardActionButton::onMouseButtonDown(MouseEventArgs& e)
{
    //        FalagardButton::onMouseButtonDown(e);下面就是pushbutton中的部分
    // default processing
    Window::onMouseButtonDown(e);

    if (e.button == LeftButton || e.button == RightButton)
    {
        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            requestRedraw();
        }

        // event was handled by us.
        e.handled = true;
    }
    /////////////////////////////////////////////////////////
    if (e.button == LeftButton && isDraggingEnabled())
    {
        if(!d_dragging)
        {
            // get position of mouse as co-ordinates local to this window.
            Point localPos = (getMetricsMode() == Relative) ?
                             relativeToAbsolute(screenToWindow(e.position)) :
                             screenToWindow(e.position);

            // store drag point for possible sizing or moving operation.
            d_dragPoint = localPos;
            d_leftMouseDown = true;

        }

        e.handled = true;
    }

    if (e.button == RightButton && isDraggingEnabled())
    {
        e.handled = true;
    }
}
Пример #14
0
	bool BaseManager::frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;

		if (!mGUI)
			return true;

		captureInput();

		if (mInfo)
		{
			static float time = 0;
			time += evt.timeSinceLastFrame;
			if (time > 1)
			{
				time -= 1;
				try
				{
					const Ogre::RenderTarget::FrameStats& stats = mWindow->getStatistics();
					mInfo->change("FPS", (int)stats.lastFPS);
					mInfo->change("triangle", stats.triangleCount);
					mInfo->change("batch", stats.batchCount);
					mInfo->change("batch gui", MyGUI::OgreRenderManager::getInstance().getBatchCount());
					mInfo->update();
				}
				catch (...)
				{
					MYGUI_LOG(Warning, "Error get statistics");
				}
			}
		}

		// для дефолтной сцены
		if (mNode)
		{
			mNode->yaw(Ogre::Radian(Ogre::Degree(evt.timeSinceLastFrame * 10)));
		}

		return true;
	}
Пример #15
0
/*************************************************************************
	Handler for mouse button press events
*************************************************************************/
void Titlebar::onMouseButtonDown(MouseEventArgs& e)
{
	// Base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		if ((d_parent != 0) && d_dragEnabled)
		{
			// we want all mouse inputs from now on
			if (captureInput())
			{
				// initialise the dragging state
				d_dragging = true;
				d_dragPoint = CoordConverter::screenToWindow(*this, e.position);

                // store old constraint area
                d_oldCursorArea = getGUIContext().
                    getMouseCursor().getConstraintArea();

				// setup new constraint area to be the intersection of the old area and our grand-parent's clipped inner-area
				Rectf constrainArea;

				if ((d_parent == 0) || (getParent()->getParent() == 0))
				{
                    Rectf screen(Vector2f(0, 0), getRootContainerSize());
					constrainArea = screen.getIntersection(d_oldCursorArea);
				}
				else 
				{
					constrainArea = getParent()->getParent()->getInnerRectClipper().getIntersection(d_oldCursorArea);
				}

                getGUIContext().getMouseCursor().
                    setConstraintArea(&constrainArea);
			}
		}

		++e.handled;
	}
}
Пример #16
0
/*************************************************************************
	Handler for when a mouse button is pushed
*************************************************************************/
void MultiLineEditbox::onMouseButtonDown(MouseEventArgs& e)
{
	// base class handling
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		// grab inputs
		if (captureInput())
		{
			// handle mouse down
			clearSelection();
			d_dragging = true;
			d_dragAnchorIdx = getTextIndexFromPosition(e.position);
			setCaratIndex(d_dragAnchorIdx);
		}

		e.handled = true;
	}

}
Пример #17
0
	void BaseManager::run()
	{
		MSG msg;
		while (true)
		{
			while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			if (mExit)
				break;
			else if (msg.message == WM_QUIT)
				break;

			captureInput();
			drawOneFrame();

			if (GetActiveWindow() != hWnd)
				::Sleep(50);
		}
	}
Пример #18
0
    void DragContainer::onMouseButtonDown(MouseEventArgs& e)
    {
        Window::onMouseButtonDown(e);

        if (e.button == LeftButton)
        {
            // ensure all inputs come to us for now
            if (captureInput())
            {
                // get position of mouse as co-ordinates local to this window.
                Vector2 localPos = CoordConverter::screenToWindow(*this, e.position);

                // store drag point for possible sizing or moving operation.
                d_dragPoint.d_x = cegui_absdim(localPos.d_x);
                d_dragPoint.d_y = cegui_absdim(localPos.d_y);
                d_leftMouseDown = true;
            }

            ++e.handled;
        }

    }
Пример #19
0
/*************************************************************************
    Handler for mouse button pressed events
*************************************************************************/
void MenuItem::onMouseButtonDown(MouseEventArgs& e)
{
    // default processing
    ItemEntry::onMouseButtonDown(e);

    if (e.button == LeftButton)
    {
        d_popupWasClosed = false;

        if (captureInput())
        {
            d_pushed = true;
            updateInternalState(e.position);
            d_popupWasClosed = !togglePopupMenu();
            invalidate();
        }

        // event was handled by us.
        ++e.handled;
    }

}
Пример #20
0
//----------------------------------------------------------------------------//
bool DragContainer::pickUp(const bool force_sticky /*= false*/)
{
    // check if we're already picked up or if dragging is disabled.
    if (d_pickedUp || !d_draggingEnabled)
        return true;

    // see if we need to force sticky mode switch
    if (!d_stickyMode && force_sticky)
        setStickyModeEnabled(true);

    // can only pick up if sticky
    if (d_stickyMode)
    {
        // force immediate release of any current input capture (unless it's us)
        if (d_captureWindow && d_captureWindow != this)
            d_captureWindow->releaseInput();
        // activate ourselves and try to capture input
        activate();
        if (captureInput())
        {
            // set the dragging point to the centre of the container.
            d_dragPoint.d_x = cegui_absdim(d_pixelSize.d_width / 2);
            d_dragPoint.d_y = cegui_absdim(d_pixelSize.d_height / 2);

            // initialise the dragging state
            initialiseDragging();

            // get position of mouse as co-ordinates local to this window.
            const Vector2 localMousePos(CoordConverter::screenToWindow(*this,
                MouseCursor::getSingleton().getPosition()));
            doDragging(localMousePos);

            d_pickedUp = true;
        }
    }

    return d_pickedUp;
}
Пример #21
0
    void DragContainer::onMouseButtonDown(MouseEventArgs& e)
    {
        Window::onMouseButtonDown(e);

        if (e.button == LeftButton)
        {
            // ensure all inputs come to us for now
            if (captureInput())
            {
                // get position of mouse as co-ordinates local to this window.
                Point localPos = (getMetricsMode() == Relative) ? 
                    relativeToAbsolute(screenToWindow(e.position)) :
                    screenToWindow(e.position);

                // store drag point for possible sizing or moving operation.
                d_dragPoint = localPos;
                d_leftMouseDown = true;
            }

            e.handled = true;
        }

    }
Пример #22
0
/*************************************************************************
	Handler for when mouse buttons are pushed
*************************************************************************/
void ListHeaderSegment::onMouseButtonDown(MouseEventArgs& e)
{
	// base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		// ensure all inputs come to us for now
		if (captureInput())
		{
			// get position of mouse as co-ordinates local to this window.
			Point localPos(CoordConverter::screenToWindow(*this, e.position));

			// store drag point for possible sizing or moving operation.
			d_dragPoint = localPos;

			// if the mouse is in the sizing area
			if (d_splitterHover)
			{
				if (isSizingEnabled())
				{
					// setup the 'dragging' state variables
					d_dragSizing = true;
				}

			}
			else
			{
				d_segmentPushed = true;
			}

		}

		++e.handled;
	}

}
Пример #23
0
	void	FalagardCheckButton::onMouseButtonDown(MouseEventArgs& e)
	{
		PushButton::onMouseButtonDown(e);

		if (e.button == LeftButton)
		{
			if (captureInput())
			{
				if( d_nCheckMode == 1 )
				{
					if( d_bIsSelected ) // 如果已经被选中了
						return;
				}
				d_pushed = true;
				d_bIsSelected = !d_bIsSelected;
				updateInternalState(e.position);
				requestRedraw();
				
			}

			// event was handled by us.
			e.handled = true;
		}
	}
Пример #24
0
int main( )
{
    // init input video source
//    cvCaptureFromFile
    
//    cv::VideoCapture captureInput("/Users/andriybas/Downloads/elephant_wild_life.m4v");
//    cv::VideoCapture captureInput("/Users/andriybas/Documents/test.mov");
    cv::VideoCapture captureInput(0);
    
    if (!captureInput.isOpened()) {
        std::cout << "Could not open input source" << std::endl;
        return -1;
    }
    
    double fps = captureInput.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
    
    std::cout << "Frame per seconds : " << fps << std::endl;
    
    cv::namedWindow("window1", CV_WINDOW_AUTOSIZE);
    
    
    int frameCount = 0;

    // loading classifiers
    cv::CascadeClassifier face_classifier(FACE_DETECT_CLASSIFIER_PATH);
    cv::CascadeClassifier profile_face_classifier(PROFILE_FACE_DETECT_CLASSIFIER_PATH);
    cv::CascadeClassifier elephant_classifier(ELEPHANT_DETECT_CLASSIFIER_PATH);
    cv::CascadeClassifier banana_classifier(BANANA_DETECT_CLASSIFIER_PATH);


    // creating detectors
    Detector faceDetector(face_classifier, "face");
    faceDetector.setScaleFactor(2);
    
//    Detector faceProfileDetector(profile_face_classifier, "face_profile");
    
    Detector elephantDetector(elephant_classifier, "elephant");
    elephantDetector.setScaleFactor(3);
    elephantDetector.setMinNeighbours(4);
    
    
    Detector bananaDetector(banana_classifier, "banana");
    bananaDetector.setScaleFactor(2);
    bananaDetector.setMinNeighbours(6);
    
    // init cascade
    DetectCascade detectCascade;
    detectCascade.addDetector(faceDetector);
//    detectCascade.addDetector(faceProfileDetector);
    detectCascade.addDetector(elephantDetector);
    detectCascade.addDetector(bananaDetector);
    
    VideoClassifier videoClassifier;
    
    DetectedResults detectedObjects;
    cv::Mat frame;
    
    long totalTime = 0;
    int detectedFrames = 0;
    
    while(true)
    {
        captureInput >> frame;
        
        if (frameCount < SKIP_COUNT) {
            frameCount++;
        } else {
            frameCount = 0;
            
            
            std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
            
            
            detectedObjects = detectCascade.detect(frame);
            
            
            std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
            auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();
            
//            std::cout << duration << std::endl;
            
            totalTime += duration;
            detectedFrames++;
            
            videoClassifier.addFrame(detectedObjects);
        }
        
        drawDetectedFrames(frame, detectedObjects);
        
        drawTags(frame, detectedObjects);
        
        std::string videoClass = videoClassifier.getVideoClass();
        
        drawClass(frame, videoClass);
        
        imshow("Video classifier", frame );
    
        if (detectedFrames > 100) {
            std::cout << "Average frame detect: " << 1.0 * totalTime / detectedFrames << "\n";
            
            detectedFrames = 0;
            totalTime = 0;
        }
        
        // Press 'c' to escape
//        if(waitKey(1) == 'c') break;
    }
    
    cv::waitKey(0);
    return 0;
}