当前位置: 首页>>代码示例>>C++>>正文


C++ Director::performManualPan方法代码示例

本文整理汇总了C++中Director::performManualPan方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::performManualPan方法的具体用法?C++ Director::performManualPan怎么用?C++ Director::performManualPan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Director的用法示例。


在下文中一共展示了Director::performManualPan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	//ActuatorController ac("/dev/tty.usbserial-A9S3VTXD");
	//ac.init();

	sf::Clock clock;
	

	sf::RenderWindow window(sf::VideoMode(640,480), "test");
	bool isAdding = false;
	bool area_selected = false;

	Director director;
	std::vector<cv::Vec2d> pointsList;
	std::vector<cv::Vec2d> area_points;
	std::vector<cv::Vec2d> selected_points;
	std::vector<ActuatorMoveOrder> ordersList;
	while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
        	sf::Time time1 = clock.getElapsedTime();
            director.update();
            if (event.type == sf::Event::MouseButtonPressed) {
            	if(isAdding) {
            		//When in adding mode, add position of where mouse clicked to a vector.
            		cv::Vec2d point = cv::Vec2d(-150+300.0*((double)event.mouseButton.x)/640.0, -90.0+180*((double)event.mouseButton.y)/480.0);
            		std::cout << point[0] << ',' << point[1] << std::endl;
            		pointsList.push_back(point);

            		cv::Vec2d mouse_pos = {(double)event.mouseButton.x, (double)event.mouseButton.y};
            		selected_points.push_back(mouse_pos); 
            	}
            	else {
            		//When not in adding mode, send order to manualPan function to move actuator.
            		cv::Vec2d point = cv::Vec2d(-150+300.0*((double)event.mouseButton.x)/640.0, -90.0+180*((double)event.mouseButton.y)/480.0);
            		std::cout << point[0] << ',' << point[1] << std::endl;
            		ActuatorMoveOrder order;
            		order.posDeg = point;
            		order.duration = 2;
            		director.performManualPan(order);
            		std::cout << time1.asSeconds() << std::endl;

            	}
            }
            else if (event.type == sf::Event::KeyPressed) {
            	if (event.key.code == sf::Keyboard::Escape) {
			    	window.close();
		    	}
		    	else if(event.key.code == sf::Keyboard::A) {
		    		// When A is pressed, window is in adding mode
		    		isAdding = true;
		    	}
		    	else if(event.key.code == sf::Keyboard::S) {
		    		//Draw box, Scan region
		    		director.performRegionScan(pointsList);
		    		area_points = director.getSelectedRegion();
		    		pointsList.clear();
		    		isAdding = false;
		    		area_selected = true;		   
		    	}
		    	else if(event.key.code == sf::Keyboard::D) {
		    		//FullScan
		    		ordersList = director.performFullScan();

		    	}
		    	else if(event.key.code == sf::Keyboard::C) {
		    		//Empty everything and stop
		    		area_points.clear();
		    		selected_points.clear();
		    		ordersList.clear();
		    		isAdding = false;
		    		area_selected = false;
		    		director.haltMovement();
		    	}

            }
            else if (event.type == sf::Event::Closed) {
                window.close();
            }
        }
        window.clear();

        //Acuator Position
        cv::Vec2d pos;
		pos = director.getCurrentPositionAC();
		//std::cout << pos << std::endl;
		auto actPos = sf::Vector2f((pos[0]+150.0)/300.0*640.0, (pos[1]+90.0)/180.0*480.0);
		sf::CircleShape actuator;
		actuator.setRadius(2);
		actuator.setFillColor(sf::Color::Green);		
		actuator.setPosition(actPos);
		window.draw(actuator);


		sf::Vector2f prevPos;
		//Actuator move path - create lines
		for(int j = 0; j < ordersList.size(); j++) {
//.........这里部分代码省略.........
开发者ID:Chris112,项目名称:sep,代码行数:101,代码来源:main.cpp


注:本文中的Director::performManualPan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。