Ejemplo n.º 1
0
void Preview::mouseMoveEvent( QMouseEvent* e )
{
	e;
	QCursor c = cursor();
	QPoint mapFromGlobal = this->mapFromGlobal( c.pos() );
	if ( GetAsyncKeyState( VK_LBUTTON ) < 0 && mapFromGlobal.x() >= 0 && mapFromGlobal.x() <= width() &&
		 mapFromGlobal.y() >= 0 && mapFromGlobal.y() <= height() && MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
	{
		if ( !MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( true );
		glm::vec2 oldPos = MouseInput::globalMouseInput.oldMousePosition;
		MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
		
		c.setPos( QPoint( oldPos.x , oldPos.y ) );
		c.setShape( Qt::BlankCursor );
	}
	else if ( MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
	{
		c.setShape( Qt::ArrowCursor );
		if ( MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( false );
		MouseInput::globalMouseInput.oldMousePosition = glm::vec2( c.pos().x() , c.pos().y() );
		MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
	}
	clearFocus();
	setCursor( c );
	setFocus();
}
Ejemplo n.º 2
0
void GLWidget::updateCursor()
{
    QCursor cursor = this->cursor();
    cursor.setShape(Qt::ArrowCursor);
    if(leftMouseButtonMode == ROTATE)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    else if(leftMouseButtonMode == PANNING)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    QWidget::setCursor(cursor);
}
void OpenGLWindow::ShowCursor()
{
	cursorClip = false;
	QCursor c = cursor();
	c.setShape(Qt::ArrowCursor);
	setCursor(c);
}
Ejemplo n.º 4
0
void CircuitsWidget::wireSlot(int, Component *c) {
	QCursor cr;
	cr.setShape(Qt::CrossCursor);
	setCursor(cr);
	connectingComponent = true;
	componentOnConnection = c;
}
Ejemplo n.º 5
0
void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, QgsFeatureId id )
{
  mRubberSelectId->reset();

  Qt::CursorShape shapeCurrent = cursor().shape();

  QCursor c;
  c.setShape( Qt::WaitCursor );
  setCursor( c );

  mRubberSelectId->addFeature( lyr, id );
  mRubberSelectId->show();

  c.setShape( shapeCurrent );
  setCursor( c );
} // void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, int id )
void OpenGLWindow::HideCursor()
{
	skipClipFrame = true;
	cursorClip = true;
	QCursor c = cursor();
	c.setShape(Qt::BlankCursor);
	setCursor(c);
}
Ejemplo n.º 7
0
void VisualizationWidget::on_zoomToolButton_toggled( bool checked )
{
	if (checked)
	{
		vtkSmartPointer<vtkInteractorStyleRubberBandZoom> interactorStyle =
		        vtkSmartPointer<vtkInteractorStyleRubberBandZoom>::New();
		vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(interactorStyle);
		QCursor cursor;
		cursor.setShape(Qt::CrossCursor);
		vtkWidget->setCursor(cursor);
	}
	else
	{
		vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(_interactorStyle);
		QCursor cursor;
		cursor.setShape(Qt::ArrowCursor);
		vtkWidget->setCursor(cursor);
	}
}
void GL_insert_ball_layer_2::keyPressEvent(QKeyEvent *e) {
	switch (e->key()) {
		case Qt::Key_Control:
//			widget->cursor()->setShape(Qt::CrossCursor);
			QCursor c = widget->get_default_cursor();
			c.setShape(Qt::CrossCursor);
			widget->setCursor(c);
			break;
	}
}
Ejemplo n.º 9
0
void GL_navigate_layer_2::mouseReleaseEvent(QMouseEvent *e) {
	switch (s) {
		case PAN:
			s = NONE;
			break;
		case ZOOM:
			s = NONE;
			break;
		case ZOOM_RECT:
			rubber_band->hide();
			delete rubber_band;
			rubber_band = 0;
			widget->repaintGL();

			if((e->x() != first_x) && (e->y() != first_y)) {
				double x, y, xfirst2, yfirst2;
				x = widget->x_real(e->x());
				y = widget->y_real(e->y());
				xfirst2 = widget->x_real(first_x);
				yfirst2 = widget->y_real(first_y);

				double	xmin, xmax, ymin, ymax;
				if(x < xfirst2) {xmin = x; xmax = xfirst2;}
				else {xmin = xfirst2; xmax = x;};
				if(y < yfirst2) {ymin = y; ymax = yfirst2;}
				else {ymin = yfirst2; ymax = y;};

				if (is_alt(e)) widget->set_window(xmin, xmax, ymin, ymax);
				else smooth_zoom(xmin, xmax, ymin, ymax);
			} else if (widget->has_boundingbox()) {
				// jump to bounding box
				double x_min = widget->get_bounding_xmin();
				double x_max = widget->get_bounding_xmax();
				double y_min = widget->get_bounding_ymin();
				double y_max = widget->get_bounding_ymax();
				if (x_min != x_max && y_min != y_max)	{
					double margin_percent= BOUNDING_BOX_MARGIN_PERCENT;
					double x_margin = (x_max - x_min) * margin_percent;
					double y_margin = (y_max - y_min) * margin_percent;
					x_min -= x_margin;	x_max += x_margin;
					y_min -= y_margin;	y_max += y_margin;
					if (is_alt(e)) widget->set_window(x_min, x_max, y_min, y_max);
					else smooth_zoom(x_min, x_max, y_min, y_max);
				}
			}
			s = NONE;
			break;
	}
	if (is_pure(e) || is_alt(e) || is_shift(e)) widget->setCursor(QCursor( QPixmap( (const char**)hand_xpm)));
	else {
			QCursor c = widget->get_default_cursor();
			c.setShape(Qt::CrossCursor);
			widget->setCursor(c);
	}
}
Ejemplo n.º 10
0
void CSceneGraph::setPickingType(PICKING_TYPE_ID itype)
{
	m_nPickingType = itype;		//0: polyobj, 1: face, 2: line
	QCursor cursor;
	switch(m_nPickingType){
	case CSceneGraph::PICK_OBJECT:
		cursor.setShape(Qt::PointingHandCursor);
		break;
	case CSceneGraph::PICK_FACE:
		cursor.setShape(Qt::SizeAllCursor);
		break;
	case CSceneGraph::PICK_LINE:
		cursor.setShape(Qt::CrossCursor);
		break;
	default:
		cursor.setShape(Qt::ArrowCursor);
		break;
	}
	emit pickingCursorChanged(&cursor);
}
Ejemplo n.º 11
0
void GLWidget::mousePressEvent(QMouseEvent *event)
{
    lastPos = event->pos();
    QCursor cursor = this->cursor();
    if(leftMouseButtonMode == ROTATE)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    if(leftMouseButtonMode == PANNING)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    if(event->buttons() & Qt::RightButton)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    else if(event->buttons() & Qt::MidButton)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    QWidget::setCursor(cursor);
}
Ejemplo n.º 12
0
void OpenGLWindow::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        QCursor c = cursor();
        c.setShape(Qt::OpenHandCursor);
        setCursor(c);

        leftButton = false;

    }

    event->accept();
}
Ejemplo n.º 13
0
void Preview::initializeGL()
{
	CommonGraphicsCommands::initializeGlobalGraphics();
	GameObjectManager::globalGameObjectManager.initialize();
	std::string err;
	ShaderInfo* shader = GraphicsShaderManager::globalShaderManager.createShaderInfo( FileReader( "assets/shaders/VertexShader.glsl" ).c_str() , FileReader( "assets/shaders/FragmentShader.glsl" ).c_str() , &err );
	std::cout << err.c_str() << std::endl;

	renderable = GraphicsRenderingManager::globalRenderingManager.addRenderable();
	renderable->geometryInfo = 0;
	renderable->shaderInfo = shader;
	renderable->culling = CT_BACK;
	renderable->depthTestEnabled = true;
	renderable->sharedUniforms = &GraphicsSharedUniformManager::globalSharedUniformManager;
	renderable->initialize( 10 , 1 );

	colorTexture = GraphicsTextureManager::globalTextureManager.addTexture( 0 , 0 , 0 , 0 );
	renderable->addTexture( colorTexture );

	GameObject* previewModel = GameObjectManager::globalGameObjectManager.addGameObject();
	previewModel->addComponent( renderable );
	
	animation = new AnimationRenderingInfo;
	previewModel->addComponent( animation );

	Camera* camera = GraphicsCameraManager::globalCameraManager.addCamera();
	camera->direction = glm::normalize( glm::vec3( -1 , 0 , -1 ) );
	camera->initializeRenderManagers();
	camera->nearestObject = 0.01f;
	camera->addRenderList( &GraphicsRenderingManager::globalRenderingManager );
	fpsInput = new FirstPersonCameraInput;
	fpsInput->moveSensitivity = 1;
	fpsInput->rotationSensitivity = 0.1f;
	GameObject* cameraMan = GameObjectManager::globalGameObjectManager.addGameObject();
	cameraMan->translate = glm::vec3( 6 , 5 , 15 );
	cameraMan->addComponent( camera );
	cameraMan->addComponent( fpsInput );

	MouseInput::globalMouseInput.updateOldMousePosition = false;

	setMouseTracking( true );
	QCursor c = cursor();
	c.setPos( mapToGlobal( QPoint( width() / 2 , height() / 2 ) ) );
	c.setShape( Qt::BlankCursor );
	setCursor( c );
	MouseInput::globalMouseInput.updateMousePosition( glm::vec2( width() / 2 , height() / 2 ) );
	timer = new QTimer();
	connect( timer , SIGNAL( timeout() ) , this , SLOT( update() ) );
	timer->start( 0 );
}
Ejemplo n.º 14
0
void OpenGLWindow::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        QCursor c = cursor();
        c.setShape(Qt::DragMoveCursor);
        setCursor(c);

        leftButton = true;
        currentMousePos.x = event->x();
        currentMousePos.y = event->y();
    }

    event->accept();
}
Ejemplo n.º 15
0
void GameView::mousePressEvent(QMouseEvent*)
{
	if (m_editor->isGameMode())
	{
		setFocus();
		setMouseTracking(true);
		grabMouse();
		grabKeyboard();
		QCursor c = cursor();
		c.setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
		c.setShape(Qt::BlankCursor);
		setCursor(c);
		m_editor->getEngine().getInputSystem().enable(true);
		m_isInputHandling = true;
	}
}
Ejemplo n.º 16
0
  /*!
   * \author Ingemar Axelsson
   *
   * \brief The class constructor
   */
  CellCursor::CellCursor(QWidget *parent)
    : Cell(parent),
    clickedOn_( false )
  {
    setHeight(3);
    QWidget *content = new CursorWidget(this);

    setMainWidget(content);
    hideTreeView(true);
    // PORT >> setBackgroundMode(Qt::PaletteBase);
    setBackgroundRole( QPalette::Base );
    setBackgroundColor(QColor(100,100,100));

    // 2006-04-27 AF, set cursor shape for cell cursor
    QCursor mousecursor = cursor();
    mousecursor.setShape( Qt::SizeHorCursor );
    setCursor( mousecursor );
  }
Ejemplo n.º 17
0
void GameView::mouseMoveEvent(QMouseEvent* event)
{
	if (!m_isInputHandling)
	{
		return;
	}

	int half_width = width() / 2;
	int half_height = height() / 2;
	if (event->x() != half_width || event->y() != half_height)
	{
		auto& input_system = m_editor->getEngine().getInputSystem();
		input_system.injectMouseXMove(event->x() - half_width);
		input_system.injectMouseYMove(event->y() - half_height);
		QCursor c = cursor();
		c.setPos(mapToGlobal(QPoint(half_width, half_height)));
		c.setShape(Qt::BlankCursor);
		setCursor(c);
	}
}
Ejemplo n.º 18
0
GNSSView::GNSSView(QStringList & args)
{
	fullScreen=true;
	
	for (int i=1;i<args.size();i++){ // skip the first
		if (args.at(i) == "--nofullscreen")
			fullScreen=false;
		else if (args.at(i) == "--help"){
			std::cout << "gnssview " << std::endl;
			std::cout << "Usage: gnssview [options]" << std::endl;
			std::cout << std::endl;
			std::cout << "--help         print this help" << std::endl;
			std::cout << "--license      print this help" << std::endl;
			std::cout << "--nofullscreen run in a window" << std::endl;
			std::cout << "--version      display version" << std::endl;
			
			exit(EXIT_SUCCESS);
		}
		else if (args.at(i) == "--license"){
			std::cout << " gnssview - a program for displaying GNSS satellite paths" << std::endl;
			std::cout <<  std::endl;
			std::cout << " The MIT License (MIT)" << std::endl;
			std::cout <<  std::endl;
			std::cout << " Copyright (c)  2014  Michael J. Wouters" << std::endl;
			std::cout <<  std::endl; 
			std::cout << " Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl;
			std::cout << " of this software and associated documentation files (the \"Software\"), to deal" << std::endl;
			std::cout << " in the Software without restriction, including without limitation the rights" << std::endl;
			std::cout << " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl;
			std::cout << " copies of the Software, and to permit persons to whom the Software is" << std::endl;
			std::cout << " furnished to do so, subject to the following conditions:" << std::endl;
			std::cout << std::endl; 
			std::cout << " The above copyright notice and this permission notice shall be included in" << std::endl;
			std::cout << " all copies or substantial portions of the Software." << std::endl;
			std::cout << std::endl;
			std::cout << " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl;
			std::cout << " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl;
			std::cout << " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl;
			std::cout << " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl;
			std::cout << " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl;
			std::cout << " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN" << std::endl;
			std::cout << " THE SOFTWARE." << std::endl;
			
			exit(EXIT_SUCCESS);
		}
		else if (args.at(i) == "--version"){
			std::cout << "gnssview " << VERSION_INFO << std::endl;
			std::cout << std::endl;
			std::cout << "This ain't no stinkin' Perl script!" << std::endl;
			
			exit(EXIT_SUCCESS);
		}
		else{
			std::cout << "gnssview: Unknown option '"<< args.at(i).toStdString() << "'" << std::endl;
			std::cout << "gnssview: Use --help to get a list of available command line options"<< std::endl;
			
			exit(EXIT_SUCCESS);
		}
	}
	
	setWindowTitle(tr("gnssview"));
	setMinimumSize(QSize(1920,1080));
	if (fullScreen)
		setWindowState(windowState() ^ Qt::WindowFullScreen);
	
	setMouseTracking(true); // so that mouse movements wake up the display
	QCursor curs;
	curs.setShape(Qt::BlankCursor);
	setCursor(curs);
	cursor().setPos(0,0);
	
	QTime on(7,0,0);
	QTime off(19,0,0);
	
	powerManager=new PowerManager(on,off);
	powerManager->enable(false);
	
	latitude=-33.87;
	longitude=151.21;
	address="";
	port=-1;
	
	// Note: readConfig needs 'view'
	QVBoxLayout * vb = new QVBoxLayout(this);
	vb->setContentsMargins(0,0,0,0);
	view = new GNSSViewWidget(NULL,&birds);
	vb->addWidget(view);
	
	QString config = app->locateResource("gnssview.xml");
	
	if (!config.isNull())
		readConfig(config);
	
	view->setLocation(latitude,longitude);
	
	createActions();
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this,SIGNAL(customContextMenuRequested ( const QPoint & )),this,SLOT(createContextMenu(const QPoint &)));

	udpSocket = new QUdpSocket(this);
  udpSocket->bind(port,QUdpSocket::ShareAddress);
	
	// Start of flimflummery
	// Newer versions of Qt support this but for the moment we'll do it the Unix way 
	int socketfd = udpSocket->socketDescriptor();
	if (socketfd != -1){
		ip_mreq mreq;
		memset(&mreq,0,sizeof(ip_mreq));
		mreq.imr_multiaddr.s_addr = inet_addr(address.toStdString().c_str()); // group addr
		mreq.imr_interface.s_addr = htons(INADDR_ANY); // use default

		//Make this a member of the Multicast Group
		if(setsockopt(socketfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq,sizeof(mreq)) < 0){
			qDebug("Failed to add to multicast group");
		}
		
		// set TTL (Time To Live)
		unsigned int ttl = 38; // restricted to 38 hops
		if (setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&ttl, sizeof(ttl) ) < 0){
			qDebug("Failed to set TTL");
		}
	}
	else{
		qDebug() << "Bad socket fd!";
	}
	// End of flimflummery
	
  connect(udpSocket, SIGNAL(readyRead()),this, SLOT(readPendingDatagrams()));
				 
	updateTimer = new QTimer(this);
	connect(updateTimer,SIGNAL(timeout()),this,SLOT(updateView()));
	
	QDateTime now = QDateTime::currentDateTime();
	updateTimer->start(1000-now.time().msec()); 
	
}
Ejemplo n.º 19
0
void GLDisplay::setCursorShape(Qt::CursorShape cursorShape){
	QCursor cursor = this->cursor();
	cursor.setShape(cursorShape);
	this->setCursor(cursor);
}
Ejemplo n.º 20
0
void CircuitsWidget::mouseReleaseEvent(QMouseEvent *event) {
	setFocus();
	if(connectingComponent){
		// resetting cursor
		QCursor c;
		c.setShape(Qt::ArrowCursor);
		setCursor(c);
		// checking click on components
		QPoint click = event->pos();
		for(int it = 0; it < componentList.size(); it++){
			QRect r = componentList[it]->rect();
			r.setX(componentList[it]->x());
			r.setY(componentList[it]->y());
			r.setWidth(componentList[it]->width());
			r.setHeight(componentList[it]->height());
			bool c1 = r.contains(click); // the mouserelease is on a component
			bool c2 = !(componentOnConnection == componentList[it]); // not the same component
			bool c3 = (componentOnConnection->outComponentList.indexOf(componentList[it])==-1); // not already connected
			bool c4 = componentOnConnection->getComponentType() != 2; // the left component is not a collector
			bool c5 = componentList[it]->getComponentType() != 3; // the right component is not a variable
            // if the right component is a collector it must be unconnected
            bool c6;
            if(componentList[it]->getComponentType() == 2)
                c6 = componentList[it]->inComponentList.isEmpty();
            else
                c6 = true;  
            // if the right component is a NOT port it must be unconnected
            bool c7;
            if(componentList[it]->getComponentType() == 6)
                c7 = componentList[it]->inComponentList.isEmpty();
            else
                c7 = true;
            // if the right component is a divider, it must be unconnected
            bool c8;
            if(componentList[it]->getComponentType() == 7)
                c8 = componentList[it]->inComponentList.isEmpty();
            else
                c8 = true;
			if(c1 && c2 && c3 && c4 && c5 && c6 && c7 && c8){
				// creating and set new wire
				Wire *w = new Wire(componentOnConnection, componentList[it]);
				wireList.append(w);
				// setting connections
				componentOnConnection->outComponentList.append(componentList[it]);
				componentList[it]->inComponentList.append(componentOnConnection);
				// value injection
				int ctype = componentList[it]->getComponentType();
				switch(ctype){
                    case(8):{
                        // muler
                        int tmp = componentList[it]->getValue();
                        componentList[it]->setValue(tmp * componentOnConnection->getValue());
                        break;
                    }
                    case(7):{
                        // diver
                        Diver* d = (Diver*) componentList[it].data(); // pay attenction
                        int r = componentOnConnection->getValue() / d->getDivider();
                        componentList[it]->setValue(r);
                        break;
                    }
                    case(6):{
                        //noter
                        if(componentOnConnection->getValue() != 0)
                            componentList[it]->setValue(0);
                        else
                            componentList[it]->setValue(1);
                        break;
                    }
                    case(5):{
                        //orer
                        bool tmp = componentList[it]->getValue();
                        componentList[it]->setValue(tmp || componentOnConnection->getValue());
                        break;
                    }
                    case(4):{
                        //ander
                        bool tmp = componentList[it]->getValue();
                        componentList[it]->setValue(tmp && componentOnConnection->getValue());
                        break;
                    }
					case(3):{
						//variabile
						printf("WARNING: This component shouldn't have any incoming component\n");
						break;
					}
					case(2):{
						// collector
						componentList[it]->setValue(componentOnConnection->getValue());
						break;
					}
					case(1):{
						//adder
						int tmp = componentList[it]->getValue();
						componentList[it]->setValue(tmp + componentOnConnection->getValue());
						break;
					}
					default:{
						printf("FATAL ERROR: invalid component type\n");
						exit(1);
					}
				}
				repaint();
			}
		}
		connectingComponent = false;
		componentOnConnection = NULL;
	}
}