Esempio n. 1
0
void SeqScreen::mousePressEvent(QMouseEvent *event)
{
    mouseX = event->x();
    mouseY = event->y();
    emit mousePressed(((double)mouseX - SEQSCR_HMARG) /
                            (w - 2 * SEQSCR_HMARG),
                1. - ((double)mouseY - SEQSCR_VMARG) /
                (h - 2 * SEQSCR_VMARG), event->buttons());
}
Esempio n. 2
0
void AccessibilityInspector::inspectWindow(QWindow *window)
{
    qDebug() << "AccessibilityInspector::inspectWindow()" << window;

    optionsWidget = new OptionsWidget();

    accessibilityScene = new MouseInterceptingGraphicsScene();

    accessibilityView = new QGraphicsView();
    accessibilityView->setScene(accessibilityScene);
    accessibilityView->resize(640, 480);
    accessibilityView->scale(1.3, 1.3);

    accessibilityTreeScene = new QGraphicsScene();

    accessibilityTreeView = new QGraphicsView();
    accessibilityTreeView->setScene(accessibilityTreeScene);
    accessibilityTreeView->resize(640, 480);

    sceneManager = new AccessibilitySceneManager();
    QObject::connect(optionsWidget, SIGNAL(optionsChanged()), sceneManager, SLOT(updateAccessibilitySceneItemFlags()));
    QObject::connect(optionsWidget, SIGNAL(refreshClicked()), sceneManager, SLOT(populateAccessibilityScene()));
    QObject::connect(optionsWidget, SIGNAL(refreshClicked()), sceneManager, SLOT(populateAccessibilityTreeScene()));
    QObject::connect(optionsWidget, SIGNAL(scaleChanged(int)), sceneManager, SLOT(changeScale(int)));

    sceneManager->setOptionsWidget(optionsWidget);
    sceneManager->setRootWindow(window);
    sceneManager->setScene(accessibilityScene);
    sceneManager->setView(accessibilityView);
    sceneManager->setTreeScene(accessibilityTreeScene);
    sceneManager->setTreeView(accessibilityTreeView);

    screenReader = new ScreenReader;
    QObject::connect(accessibilityScene, SIGNAL(mousePressed(QPoint)), screenReader, SLOT(touchPoint(QPoint)));
    QObject::connect(accessibilityScene, SIGNAL(mouseDobleClicked()), screenReader, SLOT(activate()));
    QObject::connect(screenReader, SIGNAL(selected(QObject*)), sceneManager, SLOT(setSelected(QObject*)));
    screenReader->setRootObject(window);
    screenReader->setOptionsWidget(optionsWidget);

    previousUpdateHandler = QAccessible::installUpdateHandler(accessibilityUpdateHandler);

    QTimer::singleShot(100, sceneManager, SLOT(populateAccessibilityScene()));
    QTimer::singleShot(100, sceneManager, SLOT(populateAccessibilityTreeScene()));

    QSettings settings;
    accessibilityView->restoreGeometry(settings.value("accessiblityGeometry").toByteArray());
    accessibilityView->setObjectName(QLatin1String("accessibilityInspectorView"));
    accessibilityView->show();


    accessibilityTreeView->restoreGeometry(settings.value("treeGeometry").toByteArray());
    accessibilityTreeView->setObjectName(QLatin1String("accessibilityInspectorTreeView"));
    accessibilityTreeView->show();
    optionsWidget->restoreGeometry(settings.value("optionsGeometry").toByteArray());
    optionsWidget->setObjectName(QLatin1String("accessibilityInspectorOptions"));
    optionsWidget->show();
}
void QITreeView::mousePressEvent(QMouseEvent *pEvent)
{
    /* Reject event initially: */
    pEvent->setAccepted(false);
    /* Notify listeners about event allowing them to handle it: */
    emit mousePressed(pEvent);
    /* Call to base-class only if event was not yet accepted: */
    if (!pEvent->isAccepted())
        QTreeView::mousePressEvent(pEvent);
}
void SelectionWidget::mousePressEvent(QMouseEvent *e)
{
    if (e->button()==Qt::LeftButton)
    {
        selectionStarted=true;
        selectionRect.setTopLeft(e->pos());
        selectionRect.setBottomRight(e->pos());
        emit mousePressed();
    }
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
void QGLImageGpuWidget::mousePressEvent(QMouseEvent *event)
{
  button_ = event->button();

  // Save current Position
  mouse_x_old_ = floor(event->x()/zoom_);
  mouse_y_old_ = floor(event->y()/zoom_);

  if (event->button() == Qt::LeftButton)
  {
    //    printf("QGLWidget: mouse pressed %d/%d\n", event->x(), event->y());
    emit mousePressed(mouse_x_old_, mouse_y_old_);
    emit mousePressed(mouse_x_old_, mouse_y_old_, event->globalX(), event->globalY());
  }
  else if (button_ == Qt::MidButton)
  {
    old_cursor_ = this->cursor();
    this->setCursor(Qt::ClosedHandCursor);
  }
}
bool TribotsTools::ScrollImageWidget::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: mousePressed((QMouseEvent*)static_QUType_ptr.get(_o+1)); break;
    case 1: mouseMoved((QMouseEvent*)static_QUType_ptr.get(_o+1)); break;
    case 2: keyPressed((QKeyEvent*)static_QUType_ptr.get(_o+1)); break;
    default:
	return QScrollView::qt_emit(_id,_o);
    }
    return TRUE;
}
Esempio n. 7
0
void CamLabel::mouseMoveEvent(QMouseEvent *ev)
{
    if(ev->buttons() & Qt::LeftButton)
        emit mousePressed(ev->x(), ev->y());
    else if(ev->buttons() & Qt::RightButton)
    {
        emit mouseRightPressed(ev->x()-prevx, ev->y()-prevy);
        prevx = ev->x();
        prevy = ev->y();
    }
    emit mouseOnlyMove(ev->x(), ev->y());
}
Esempio n. 8
0
void SimpleSimulator::processEvents()
{
    SDL_Event event;

    while( SDL_PollEvent( &event ) ) {

        switch( event.type ) {
		case SDL_KEYDOWN:
			if( event.key.keysym.sym == SDLK_ESCAPE ){
				running = false;
				SDL_Quit();
			} else if( event.key.keysym.sym == SDLK_F1 ){
				fullscreen=!fullscreen;
				initWindow();
			} else if( event.key.keysym.sym == SDLK_f ){
				fullupdate=!tuioServer->fullUpdateEnabled();
				if (fullupdate) tuioServer->enableFullUpdate();
				else tuioServer->disableFullUpdate();
			} else if( event.key.keysym.sym == SDLK_p ){
				periodic=!tuioServer->periodicMessagesEnabled();
				if (periodic) tuioServer->enablePeriodicMessages();
				else tuioServer->disablePeriodicMessages();
			} else if( event.key.keysym.sym == SDLK_v ){
				verbose = !verbose;
				tuioServer->setVerbose(verbose);
			} else if( event.key.keysym.sym == SDLK_h ){
				help = !help;
			} else if( event.key.keysym.sym == SDLK_r ){
				tuioServer->resetTuioCursors();
				stickyCursorList.clear();
				jointCursorList.clear();
				activeCursorList.clear();
			}
			break;

		case SDL_MOUSEMOTION:
			if (event.button.button == SDL_BUTTON_LEFT) mouseDragged((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_MOUSEBUTTONDOWN:
			if (event.button.button == SDL_BUTTON_LEFT) mousePressed((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_MOUSEBUTTONUP:
			if (event.button.button == SDL_BUTTON_LEFT) mouseReleased((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_QUIT:
			running = false;
			SDL_ShowCursor(true);
			SDL_Quit();
			break;
        }
    }
}
Esempio n. 9
0
void LfoScreen::mousePressEvent(QMouseEvent *event)
{
    mouseX = event->x();
    mouseY = event->y();
    bool cl = false;

    mouseX = clip(mouseX, LFOSCR_HMARG, xMax, &cl);
    mouseY = clip(mouseY, LFOSCR_VMARG + 1, h - LFOSCR_VMARG, &cl);

    emit mousePressed(((double)mouseX - LFOSCR_HMARG) /
                            ((double)xMax - LFOSCR_HMARG + .2),
                1. - ((double)mouseY - LFOSCR_VMARG) /
                (h - 2 * LFOSCR_VMARG), event->buttons());
}
Esempio n. 10
0
//------------------ other methods -----------------------------------
void GlutMouseListener::update( int info, int x, int y )
{
    switch ( info & GlutMouseSource::MOUSE_ACTION_MASK )
    {
        case GlutMouseSource::MOUSE_BUTTON_DOWN:
            mousePressed( info & GlutMouseSource::MOUSE_BUTTON_MASK, x, y );
            break;
        case GlutMouseSource::MOUSE_BUTTON_UP:
            mouseReleased( info & GlutMouseSource::MOUSE_BUTTON_MASK, x, y );
            break;
        case GlutMouseSource::MOUSE_MOTION:
            mouseMoved(x, y);
            break;
    }
}
Esempio n. 11
0
void ofxUISuperCanvas::onMousePressed(ofMouseEventArgs& data)
{
    if(rect->inside(data.x, data.y) && canvasTitle->isHit(data.x, data.y))
    {
        bTitleLabelHit = true;
        hitPoint.set(data.x - rect->getX(), data.y - rect->getY());
        
        if((ofGetElapsedTimef() - lastHitTime) < deltaTime)
        {
            toggleMinified();
            return;
        }
        lastHitTime = ofGetElapsedTimef();
    }
    mousePressed(data.x, data.y, data.button);
}
Esempio n. 12
0
void GLWidget::mousePressEvent(QMouseEvent *event)
{
    // reset last mouse position
    if(event->type() & QEvent::MouseButtonPress &&
        event->button() & Qt::LeftButton)
    {
        qDebug() << "Mouse pressed" << event->pos();

        // route event
        emit mousePressed(event);
    }
    else if(event->type() & QEvent::MouseButtonRelease)
    {
        lastMousePos.setX(0);
        lastMousePos.setY(0);
    }
}
Esempio n. 13
0
squareToolDock::squareToolDock(QWidget* parent)
  : constWidthDock(parent), detailDock_(NULL) {

  dockLayout_ = new QVBoxLayout(this);
  setLayout(dockLayout_);

  toolLayout_ = new QGridLayout();

  // toolLayout_ uses smaller icons by default
  // apparently every button has to be set individually...
  const int iconDimension = style()->pixelMetric(QStyle::PM_ToolBarIconSize);
  const QSize iconSize(iconDimension, iconDimension);
  constructTools(iconSize);

  toolColorLabel_ = new mousePressLabel(this);
  toolColorLabel_->setFixedSize(swatchSize());
  toolColorLabel_->setFrameStyle(QFrame::Panel | QFrame::Raised);
  toolColorLabel_->setLineWidth(3);
  toolColorLabel_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
  toolColorLabel_->setAlignment(Qt::AlignCenter);
  QPixmap qpm = QPixmap(swatchSize());
  qpm.fill(Qt::black);
  toolColorLabel_->setPixmap(qpm);
  toolColorLabel_->setEnabled(false);
  connect(toolColorLabel_, SIGNAL(mousePressed()),
          this, SLOT(processToolLabelMousePressed()));

  toolLabelLayout_ = new QHBoxLayout();
  dockLayout_->addLayout(toolLabelLayout_);
  toolLabelLayout_->addWidget(toolColorLabel_);

  dockLayout_->addLayout(toolLayout_);

  flossTypeBox_ = new QComboBox(this);
  connect(flossTypeBox_, SIGNAL(currentIndexChanged(int )),
          this, SLOT(processFlossTypeBoxChange(int )));
  const QList<flossType> types = flossType::flossTypes();
  for (int i = 0, size = types.size(); i < size; ++i) {
    flossTypeBox_->addItem(types[i].text(),
                           QVariant::fromValue(types[i]));
  }
  dockLayout_->addWidget(flossTypeBox_);

  setMinimumSize(sizeHint());
  setMaximumSize(sizeHint());
}
Esempio n. 14
0
void View::doMousePressed(u16 x, u16 y, MouseButton b)
{
  if (!curButton)
  {
    for (const auto bt : buttons)
    {
      if (bt && bt->isActive() && bt->isInside(x,y) && b == BUTTON_LEFT)
      {
        bt->press();
        curButton = bt;
        return;
      }
    }
  }
  
  mousePressed(x,y,b);
}
Esempio n. 15
0
	void GenericSkin::mouseMultiDragged(int x, int y) {
		if(mPressedKey) return;

		if( x>=screenRect.x && x<screenRect.x+screenRect.w &&
			y>=screenRect.y && y<screenRect.y+screenRect.h) {
				if(!mTouchedInside) {
					mousePressed(x, y);
					return;
				}

				int xPosition = x - screenRect.x;
				int yPosition = y - screenRect.y;

				// Calculates the delta movement from the mouse
				// and adds the same distance to the mirrored touch event
				mLastKnownMousePosition[1].first +=
							( mLastKnownMousePosition[0].first - xPosition);
				mLastKnownMousePosition[1].second +=
							( mLastKnownMousePosition[0].second - yPosition);

				mListener->onMoSyncPointerDrag(x-screenRect.x,
												y-screenRect.y, 0);

				mListener->onMoSyncPointerDrag(
											mLastKnownMousePosition[1].first,
											mLastKnownMousePosition[1].second,
											1);

				mLastKnownMousePosition[0].first = xPosition;
				mLastKnownMousePosition[0].second = yPosition;

				return;
		} else {
			if(mTouchedInside) {
				if(x<screenRect.x) x = screenRect.x;
				if(y<screenRect.y) y = screenRect.y;
				if(x>=screenRect.x+screenRect.w)
					x = screenRect.x+screenRect.w-1;
				if(y>=screenRect.y+screenRect.h)
					y = screenRect.y+screenRect.h-1;
				mouseReleased(x, y);
				return;
			}
		}
	}
/*
	QCameraTreeItemEditor
*/
QCameraTreeItemEditor::QCameraTreeItemEditor( Camera* camera, QWidget* parent )
	: QComponentEditorWidget(parent),
	  mCamera(camera),
	  mCaptureSettingsCombo(NULL),
	  mButton(NULL),
	  mImageWidget(NULL)
{
	QHBoxLayout* layout = new QHBoxLayout();
	layout->setMargin(0);
	setLayout(layout);

	mButton = new QPushButton( this );
	layout->addWidget( mButton );
	bool ret = connect( mButton, SIGNAL( clicked(bool) ), this, SLOT( onButtonClicked(bool) ) );
	assert(ret);
	mButton->setText( mCamera->isCapturing()?"Stop":"Start" );
	mButton->setFixedSize( 40, 18 );

	mCaptureSettingsCombo = new QComboBox( this );
	layout->addWidget( mCaptureSettingsCombo );
	mCaptureSettingsCombo->setFixedSize( 200, 18 );
	const CaptureSettingsList& settingsList = camera->getSupportedCaptureSettings();
	for ( std::size_t i=0; i<settingsList.size(); ++i )
	{
		const CaptureSettings& settings = settingsList[i];
		unsigned int w = settings.getImageFormat().getWidth();
		unsigned int h = settings.getImageFormat().getHeight();
		const char* encoding = settings.getImageFormat().getEncodingName();
		float fps = settings.getFrameRate();
		QString text = QString("#%1 %2x%3 %4 %5fps").arg(i).arg(w).arg(h).arg(QString(encoding)).arg(fps, 0,'f',1);
		mCaptureSettingsCombo->addItem( text );
	}	
	
	mImageWidget = new QImageWidget( this );
	mImageWidget->setFrameShape( QFrame::Box );
	mImageWidget->setFixedSize( 24, 18 );
	mImageWidget->scaleImage(true);
	layout->addWidget( mImageWidget );

	ret = connect( mImageWidget, SIGNAL(mousePressed()), SLOT(onImageWidgetClicked()) );
	assert(ret);

	layout->addSpacerItem( new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum) );
}
Esempio n. 17
0
  void GraphicsView::mousePressEvent(QMouseEvent *event)
  {
#ifdef Q_OS_MAC
    Qt::MouseButtons buttons = (event->modifiers() == Qt::ControlModifier &&
      event->buttons() == Qt::LeftButton) ? 
      Qt::MiddleButton : event->buttons();
    emit pressedMouseButtons(event->x(), event->y(), buttons);
#else
    emit pressedMouseButtons(event->x(), event->y(), event->buttons());
#endif
    if (event_listening_timer_.isActive())
    {
      event_listening_timer_.stop();
      sendEvent(mousePressed(event->x(), event->y(), event->buttons(), 
        event->modifiers()));
    }
    // Handle the mouse press event as usual.
    QGraphicsView::mousePressEvent(event);
  }
Esempio n. 18
0
		void CInputEventsTranslator::deactivateMouseButtonTranslation()
		{

			Messages::MessageType mousePressed("MOUSE_PRESSED");
			Messages::MessageType mouseReleased("MOUSE_RELEASED");
			Messages::MessageType updateMouse("UPDATE_MOUSE");

			CMessageModule* messageModule = CMessageModule::getInstancePtr();
			Messages::Messenger* messageManager = messageModule->getMessageManager();

			try
			{
				/**
				 * Continuous mouse messages
				 */
				messageManager->delListener ( mouseButtonEventsTranslator, mousePressed );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonEventsTranslator listener removed for MOUSE_PRESSED" );

				messageManager->delListener ( mouseButtonEventsTranslator, mouseReleased );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonEventsTranslator listener removed for MOUSE_RELEASED" );

				messageManager->delListener ( mouseButtonEventsTrigger, updateMouse );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonEventsTrigger listener removed" );

				/**
				 * State based mouse messages
				 */
				messageManager->delListener ( mouseButtonStateTranslator, mousePressed );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonStateTranslator listener removed for MOUSE_PRESSED" );

				messageManager->delListener ( mouseButtonStateTranslator, mouseReleased );
				Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonStateTranslator listener removed for MOUSE_RELEASED" );
			}
			catch(...)
			{
				throw;
			}

			CTimeModule* timeModule = CTimeModule::getInstancePtr();
			shared_ptr<CMessage>  message (new CMessage(updateMouse, m_periodData ));
			timeModule->delPeriodicEvent(0, message, boost::any_cast<unsigned long int> (*m_periodData) );

		}
Esempio n. 19
0
void MapWidget::mapChanged(QImage map) {
	lock_.lock();
	if (map_ == NULL) {
		Parameters* parameters = Parameters::getInstance();

		graphicsView_ = new MapGraphicsView(frame);

		graphicsView_->keyPressed = boost::function<void (QKeyEvent*)>(boost::bind(&MapWidget::handleKeyPressEvent,this,_1));
		graphicsView_->keyReleased = boost::function<void (QKeyEvent*)>(boost::bind(&MapWidget::handleKeyReleaseEvent,this,_1));

		graphicsView_->setCacheMode(QGraphicsView::CacheNone);
		graphicsView_->setAlignment(Qt::AlignCenter);
		graphicsView_->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
		graphicsView_->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );

		frameGridLayout->addWidget(graphicsView_, 0, 0, 1, 1);

		graphicsView_->scale(1, -1);
		graphicsView_->scale(1 / parameters->mapResolution(),
							 1 / parameters->mapResolution());

		scene_ = new QGraphicsScene(graphicsView_);
		graphicsView_->setScene(scene_);

		map_ = new MapGraphicsItem(QPixmap::fromImage(map), parameters->mapOrigin(), 0, scene_);
		graphicsView_->centerOn(map_);

		connect(map_, SIGNAL(mousePressed(QPointF , Qt::MouseButton)), this, SLOT(onMapPressedSlot(QPointF , Qt::MouseButton)));

		map_size_ = map.width() * parameters->mapResolution();

		square_image_ = QImage(map.width(), map.height(), QImage::Format_RGB888);

		tf_listener_thread_ = boost::thread(&MapWidget::tfListenerProcess, this);
	} else {
		map_->setPixmap(QPixmap::fromImage(map));
	}


	lock_.unlock();
}
Esempio n. 20
0
StatusWidget::StatusWidget( QWidget *parent ) :
        QWidget(parent),
        replyAction(0),
        gotohomepageAction(0),
        gototwitterpageAction(0),
        deleteAction(0),
        statusState( StatusModel::STATE_DISABLED ),
        statusData(0),
        m_ui(new Ui::StatusWidget)
{
    m_ui->setupUi( this );
    m_ui->favoriteReplyButton->hide();
    m_ui->infoButton->hide();
    m_ui->replyDeleteButton->hide();

    m_ui->favoriteReplyButton->setToolTip( tr( "Add to Favorites" ) );

    QFont timeStampFont = m_ui->timeStamp->font();
#ifdef Q_WS_MAC
    timeStampFont.setPointSize( timeStampFont.pointSize() - 2 );
#else
    timeStampFont.setPointSize( timeStampFont.pointSize() - 1 );
#endif
    m_ui->timeStamp->setFont( timeStampFont );

    connect( m_ui->replyDeleteButton, SIGNAL(clicked()), this, SLOT(handleReplyDeleteButton()));
    connect( m_ui->userStatus, SIGNAL(mousePressed()), this, SLOT(focusRequest()) );
    connect( this, SIGNAL(selectMe(StatusWidget*)), StatusModel::instance(), SLOT(selectStatus(StatusWidget*)) );

    applyTheme();
    m_ui->userName->setText( "" );
    m_ui->userStatus->setHtml( "" );
    m_ui->timeStamp->setText( "" );

    resize( currentWidth, height() );
    adjustSize();
    createMenu();
    m_ui->userStatus->setMenu( menu );
}
bool AsemanMouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *e)
{
    QMouseEvent *mevent = static_cast<QMouseEvent*>(e);
    switch(static_cast<int>(e->type()))
    {
    case QEvent::MouseMove:
    {
        QPointF newP = mapFromItem(item, mevent->pos());
        bool xChanged = (newP.x() != p->point.x());
        bool yChanged = (newP.y() != p->point.y());
        p->point = newP;
        if(xChanged) Q_EMIT mouseXChanged();
        if(yChanged) Q_EMIT mouseYChanged();
        Q_EMIT mousePositionChanged();
        break;
    }
    case QEvent::MouseButtonPress:
        p->point = mapFromItem(item, mevent->pos());
        Q_EMIT mousePressed();
        break;
    case QEvent::MouseButtonRelease:
        p->point = mapFromItem(item, mevent->pos());
        Q_EMIT mouseReleased();
        break;

    default:
        p->ignoreEvent = false;
        break;
    }

    if(p->ignoreEvent)
    {
        p->ignoreEvent = false;
        return true;
    }
    else
        return QQuickItem::childMouseEventFilter(item, e);
}
Esempio n. 22
0
bool MyScene::event(QEvent* event)
{
    switch(event->type())
    {
        case QEvent::Leave:
            emit mouseLeft();
            break;
        case QEvent::GraphicsSceneMouseMove:
            x = (int)(static_cast<QGraphicsSceneMouseEvent*>(event)->scenePos().x());
            y = (int)(static_cast<QGraphicsSceneMouseEvent*>(event)->scenePos().y());
            emit mouseMoved();
            break;
        case QEvent::GraphicsSceneMousePress:
            emit mousePressed();;
            break;
        case QEvent::GraphicsSceneMouseRelease:
            emit mouseReleased();
            break;
        default:
            return false;
    }
    return false;
}
Esempio n. 23
0
	void GenericSkin::mouseDragged(int x, int y) {
		if(mPressedKey) return;

		if( x>=screenRect.x && x<screenRect.x+screenRect.w &&
			y>=screenRect.y && y<screenRect.y+screenRect.h) {
				if(!mTouchedInside) {
					mousePressed(x, y);
					return;
				}

				mListener->onMoSyncPointerDrag(x-screenRect.x, y-screenRect.y, 0);
				return;
		} else {
			if(mTouchedInside) {
				if(x<screenRect.x) x = screenRect.x;
				if(y<screenRect.y) y = screenRect.y;
				if(x>=screenRect.x+screenRect.w) x = screenRect.x+screenRect.w-1;
				if(y>=screenRect.y+screenRect.h) y = screenRect.y+screenRect.h-1;
				mouseReleased(x, y);
				return;
			}
		}
	}
Esempio n. 24
0
void SimpleSimulator::processEvents()
{
    SDL_Event event;

    while( SDL_PollEvent( &event ) ) {

        switch( event.type ) {
		case SDL_KEYDOWN:
			if( event.key.keysym.sym == SDLK_ESCAPE ){
				running = false;
				SDL_ShowCursor(true);
				SDL_Quit();
			} else if( event.key.keysym.sym == SDLK_F1 ){
				toggleFullscreen();
			} else if( event.key.keysym.sym == SDLK_v ){
				verbose = !verbose;	
				tuioServer->setVerbose(verbose);
			} 
			break;
				
		case SDL_MOUSEMOTION:
			if (event.button.button & SDL_BUTTON(1)) mouseDragged((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_MOUSEBUTTONDOWN:
			if (event.button.button & SDL_BUTTON(1)) mousePressed((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_MOUSEBUTTONUP:
			if (event.button.button & SDL_BUTTON(1)) mouseReleased((float)event.button.x/width, (float)event.button.y/height);
			break;
		case SDL_QUIT:
			running = false;
			SDL_ShowCursor(true);
			SDL_Quit();
			break;
        }
    }
}
Esempio n. 25
0
rosterListView::rosterListView(QWidget* parent):QListView(parent), m_chat("Chat", this),
m_profile("View Profile", this), m_removeContact("Remove", this)
{
    bool check = connect(this, SIGNAL(pressed(QModelIndex)), this,
                         SLOT(mousePressed(QModelIndex)));
    Q_ASSERT(check);
    check = connect(this, SIGNAL(doubleClicked(QModelIndex)), this,
                         SLOT(doubleClicked(QModelIndex)));
    Q_ASSERT(check);
    check = connect(this, SIGNAL(clicked(QModelIndex)), this,
                         SLOT(clicked(QModelIndex)));
    Q_ASSERT(check);
    check = connect(&m_chat, SIGNAL(triggered()), this,
                         SLOT(showChatDialog_helper()));
    Q_ASSERT(check);

    check = connect(&m_profile, SIGNAL(triggered()), this,
                         SLOT(showProfile_helper()));
    Q_ASSERT(check);

    check = connect(&m_removeContact, SIGNAL(triggered()), this,
                         SLOT(removeContact_helper()));
    Q_ASSERT(check);
}
Esempio n. 26
0
//-----------------------------------------------------------------------------------------
TestTransformation::TestTransformation()
    : m_bPressed(false)
    , m_bTouch(false)
    , m_StartPan(-1, -1)
    , m_LastPan(-1, -1)
{
    // On cr�e une camera
    CCamera* pCamera = m_pSceneManager->createCamera();

    m_vNewEyePosition = QVector3D(8., 8., 4.);
    pCamera->setEyePosition(m_vNewEyePosition);
    pCamera->setCenter(QVector3D(0., 0., 0.));

    qDebug() << "Create View";
    m_pView = createWidget3D(pCamera);
    m_pView->setAttribute(Qt::WA_AcceptTouchEvents);
    qDebug() << "End create View";

    // On cr�e un noeud afin d'y placer une lumi�re
    CSceneNode* pRootNode = getSceneManager()->getRootNode();

    // On cr�e une lumi�re diffuse bleue
    CLight* pLight = getSceneManager()->createLight();
    pLight->setDiffuseColor(1.0, 1.0, 1.0);
    pLight->setAmbientColor(1.0, 1.0, 1.0);
    pLight->setDirection(QVector3D(-1, 0, 0));
    pLight->setSpecularColor(1.0f, 1.0f, 1.0f);

    // On l'associe au noeud
    pRootNode->addItem(pLight);

    // SkyBox
    CSkyBox* pSkyBoxMesh = CMeshManager::getInstance().createCustomMesh<CSkyBox>("CSkyBox", "SkyBoxMesh");

    CMeshInstance* pSkyBox = getSceneManager()->createMeshInstance(pSkyBoxMesh, "SkyBox");
    pSkyBox->setSelectable(false);
    CSceneNode* pSkyBoxNode = pRootNode->createChild("SkyBoxNode");
    pSkyBoxNode->scale(400.);
    pSkyBoxNode->addItem(pSkyBox);


    CMaterial* pSkyBoxMat = CMaterialManager::getInstance().createMaterial("SkyBoxMaterial");
    pSkyBox->setMaterialName(pSkyBoxMat->getName());

    QStringList fileNames;
    fileNames << "://Resources/xpos.png" << "://Resources/xneg.png" << "://Resources/ypos.png"
              << "://Resources/yneg.png" << "://Resources/zpos.png" << "://Resources/zneg.png";

    ATexture* pSkyBoxTexture = CTextureManager::getInstance().createTextureCube("SkyBoxTexCube", fileNames);
    pSkyBoxMat->addTexture(pSkyBoxTexture, eDiffuse);

#ifdef EMBEDDED_TARGET
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skyboxES.vertex.glsl",
                "",
                "://Resources/skyboxES.fragment.glsl");
#else
    CShader* pShader = CShaderManager::getInstance().createShader(
                "SkyBoxShader",
                "://Resources/skybox.vertex.glsl",
                "",
                "://Resources/skybox.fragment.glsl");
#endif

    pSkyBoxMat->getRenderPass(0)->setShaderName(pShader->getName());
    pSkyBoxMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));

    // Particules
    CBillboard* pBillboard = getSceneManager()->createBillboard();
    QVector<QVector3D> pos;
    for (int i = 0; i < 1000; ++i)
        pos << QVector3D(
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.),
                   Math::randDouble(-200., +200.));
    pBillboard->addPositions(pos);

    CMaterial* pBillboardMat = CMaterialManager::getInstance().createMaterial("BillboardMaterial");
    pBillboardMat->getRenderPass(0)->renderStates().setFaceCulling(CFaceCulling(false));
    CBlending blending;
    blending.setEnabled(true);
    blending.setBlendEquation(eAdd, eAdd);

    blending.setBlendSeparateFunction(Source::eSourceAlpha, Destination::eOneMinusSourceAlpha, Source::eOne, Destination::eZero);
    pBillboardMat->getRenderPass(0)->renderStates().setBlending(blending);

    ATexture* pBillboardTexture = CTextureManager::getInstance().createTexture2D("BillBoardTex", "://Resources/particle.png");
    pBillboardMat->addTexture(pBillboardTexture, eDiffuse);

    CShader* pBillboardShader = CShaderManager::getInstance().createShader("BillboardShader",
        "://Resources/billboard.vertex.glsl",
        "://Resources/billboard.geometry.glsl",
        "://Resources/billboard.fragment.glsl");

    pBillboardMat->getRenderPass(0)->setShaderName(pBillboardShader->getName());
    pBillboard->setMaterialName(pBillboardMat->getName());
    pBillboardShader->setUniformValue("halfSize", 1.);

    CSceneNode* pBillboardNode = pRootNode->createChild("BillboardNode");
    pBillboardNode->addItem(pBillboard);

    // Orbites
    CPolyLine* pPolyLine = CMeshManager::getInstance().createCustomMesh<CPolyLine>("CPolyLine", "CPolyLine");

    QList<QVector3D> pts;

    for (int i = 0; i <= 360; ++i)
    {
        pts << QVector3D(cos(Math::degToRad((real)i)), 0., sin(Math::degToRad((real)i)));
    }

    pPolyLine->addPoints(pts);

    CSphereMesh* pSphereMesh = CMeshManager::getInstance().createCustomMesh<CSphereMesh>("CSphereMesh", "SphereMesh");

    CMeshInstance* pSun = getSceneManager()->createMeshInstance(pSphereMesh, "Sun");
    CMaterial* pSunMat = CMaterialManager::getInstance().createMaterial("SunMat");
    pSunMat->setAmbientColor(1., 1., 1.);

    CTexture2D* pSunTexture = CTextureManager::getInstance().createTexture2D("SunTex", ":/Resources/sun.png");
    pSunMat->addTexture(pSunTexture, eDiffuse);
    pSun->setMaterialName(pSunMat->getName());

    CMeshInstance* pEarth = getSceneManager()->createMeshInstance(pSphereMesh, "Earth");
    CMaterial* pEarthMat = CMaterialManager::getInstance().createMaterial("EarthMat");

    CTexture2D* pEarthTexture = CTextureManager::getInstance().createTexture2D("EarthTex", ":/Resources/earth.png");
    pEarthMat->addTexture(pEarthTexture, eDiffuse);

    pEarthMat->setAmbientColor(0.1, 0.1, 0.1);
    pEarthMat->setDiffuseColor(1.0, 1.0, 1.0);
    pEarthMat->setShininessFactor(10);
    pEarth->setMaterialName(pEarthMat->getName());

    CMeshInstance* pJupiter = getSceneManager()->createMeshInstance(pSphereMesh, "Jupiter");
    CMaterial* pJupiterMat = CMaterialManager::getInstance().createMaterial("JupiterMat");
    pJupiterMat->setAmbientColor(0.4, 0.4, 0.4);

    CTexture2D* pJupiterTexture = CTextureManager::getInstance().createTexture2D("JupiterTex", ":/Resources/jupiter.png");
    pJupiterMat->addTexture(pJupiterTexture, eDiffuse);
    pJupiter->setMaterialName(pJupiterMat->getName());

    CMeshInstance* pMoon = getSceneManager()->createMeshInstance(pSphereMesh, "Moon");
    CMaterial* pMoonMat = CMaterialManager::getInstance().createMaterial("MoonMat");
    CTexture2D* pMoonTexture = CTextureManager::getInstance().createTexture2D("MoonTex", ":/Resources/moon.png");
    pMoonMat->addTexture(pMoonTexture, eDiffuse);
    pMoon->setMaterialName(pMoonMat->getName());

    CCoordinateSystem* pCoordinateSystemMesh = CMeshManager::getInstance().createCustomMesh<CCoordinateSystem>("CCoordinateSystem", "CCoordinateSystem");
    CMeshInstance* pCoordinateSystem = getSceneManager()->createMeshInstance(pCoordinateSystemMesh, "CoordinateSystem");
    pRootNode->addItem(pCoordinateSystem);
    pRootNode->addItem(pSkyBox);

    m_pSolarSystemNode = pRootNode->createChild(QVector3D(0., 0., 0.));

    m_pSunNode = m_pSolarSystemNode->createChild(QVector3D(0., 0., 0.));
    m_pSunNode->scale(4.0);
    m_pSunNode->addItem(pSun);

    m_pSunToEarthNode = m_pSolarSystemNode->createChild();
    m_pSunToJupiterNode = m_pSolarSystemNode->createChild();

    CMeshInstance* pSunToEarthPLine = getSceneManager()->createMeshInstance(pPolyLine, "SunToEarth");
    pSunToEarthPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pSunToEarthNode->addItem(pSunToEarthPLine);
    m_pSunToEarthNode->scale(10.0);
    m_pEarthNode = m_pSolarSystemNode->createChild(QVector3D(10.0, 0., 0.));
    m_pEarthNode->scale(1.0);
    m_pEarthNode->addItem(pEarth);

    CMeshInstance* pSunToJupiterPLine = getSceneManager()->createMeshInstance(pPolyLine, "SunToJupiter");
    pSunToJupiterPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pSunToJupiterNode->addItem(pSunToJupiterPLine);
    m_pSunToJupiterNode->scale(20);
    m_pJupiterNode = m_pSolarSystemNode->createChild(QVector3D(20.0, 0., 0.));
    m_pJupiterNode->scale(4.0);
    m_pJupiterNode->addItem(pJupiter);

    m_pEarthToMoonNode = m_pEarthNode->createChild();
    CMeshInstance* pEarthToMoonPLine = getSceneManager()->createMeshInstance(pPolyLine, "EarthToMoon");
    pEarthToMoonPLine->setMaterialName(CMaterialManager::getInstance().getMaterialNameByColor(Color::eWhite));
    m_pEarthToMoonNode->addItem(pEarthToMoonPLine);
    m_pEarthToMoonNode->scale(2.0);
    m_pEarthToMoonNode->rotate(QVector3D(1.0, 0.0, 0.0), 30);
    m_pMoonNode = m_pEarthToMoonNode->createChild(QVector3D(1.0, 0.0, 0.));
    m_pMoonNode->scale(0.2);
    m_pMoonNode->addItem(pMoon);

    QTimer* pTimer = new QTimer(this);
    connect(pTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
    pTimer->start(5);


    connect(m_pView, SIGNAL(mouseMoved()),				this, SLOT(onMouseMoved()));
    connect(m_pView, SIGNAL(mouseReleased()),			this, SLOT(onMouseReleased()));
    connect(m_pView, SIGNAL(mousePressed()),			this, SLOT(onMousePressed()));
    connect(m_pView, SIGNAL(touchScaleStarted()),       this, SLOT(onTouchScaleStarted()));
    connect(m_pView, SIGNAL(touchScaleChanged(real)),	this, SLOT(onTouchScaleChanged(real)));
    connect(m_pView, SIGNAL(touchScaleEnded()),         this, SLOT(onTouchScaleEnded()));

    //m_pView->setGeometry(QRect(1920, 100, 400, 300));

    m_GlobalTime.start();
}
Esempio n. 27
0
void IrrWidget::mousePressEvent(QMouseEvent *event)
{
  if (verboseOutput)
    qDebug() << "mousePressEvent from widget";
  emit mousePressed(event->pos(),event->button());
}
Esempio n. 28
0
void GdvCanvas3D::mousePressEvent(QMouseEvent* e)
{
    emit mousePressed(e->pos().x(), e->pos().y());
}
Esempio n. 29
0
void MockUInput::pressMouse(Button button)
{
    Q_EMIT mousePressed(button);
}
Esempio n. 30
0
MainWindow::MainWindow( QWidget * parent)
	: QMainWindow(parent)
{
    setupUi(this);

    version = "2015-08-28";

    inimage = false;
    x1drag = false;
    x2drag = false;
    y1drag = false;
    y2drag = false;

    image = QImage();
    pixmap = scene.addPixmap(QPixmap());
    pixmap->setZValue(0);

    QPen pen;
    pen.setColor(QColor(255,255,0));
    pen.setStyle(Qt::DashLine);
    // limit lines
    x1line = scene.addLine(QLineF(), pen);
    x1line->setZValue(1);
    x2line = scene.addLine(QLineF(), pen);
    x2line->setZValue(1);
    y1line = scene.addLine(QLineF(), pen);
    y1line->setZValue(1);
    y2line = scene.addLine(QLineF(), pen);
    y2line->setZValue(1);

    pen.setColor(QColor(255,0,0));
    pen.setStyle(Qt::SolidLine);
    // projections, beam profile, centroid
    xprojection = scene.addPath(QPainterPath(), pen);
    xprojection->setZValue(2);
    yprojection = scene.addPath(QPainterPath(), pen);
    yprojection->setZValue(2);
    ellipse = scene.addEllipse(0,0,0,0, pen);
    ellipse->setZValue(2);
    centerAline = scene.addLine(QLineF(), pen);
    centerAline->setZValue(2);
    centerBline = scene.addLine(QLineF(), pen);
    centerBline->setZValue(2);

    QObject::connect(&scene, SIGNAL(mouseMoved()), this, SLOT(mouseMovedOnScene()));
    QObject::connect(&scene, SIGNAL(mousePressed()), this, SLOT(mousePressedOnScene()));
    QObject::connect(&scene, SIGNAL(mouseReleased()), this, SLOT(mouseReleasedOnScene()));
    QObject::connect(&scene, SIGNAL(mouseLeft()), this, SLOT(mouseLeftScene()));

    graphicsView->setScene(&scene);
    graphicsView->setContextMenuPolicy(Qt::CustomContextMenu);

    X1SpinBox->setRange(0, MAX_HEIGHT-1);
    X2SpinBox->setRange(0, MAX_HEIGHT-1);
    Y1SpinBox->setRange(0, MAX_WIDTH-1);
    Y2SpinBox->setRange(0, MAX_WIDTH-1);

    scaleLabel->setScaledContents(true);

    AllocateMemory();

    dataloaded = false;
    refloaded = false;
    RestoreSession();

    LoadRef(reffile);
    LoadData(datafile);

    // Scale image
    scale = QImage(20, 256, QImage::Format_Indexed8);
    SetColorTable();
    for(int i=0; i<20; i++)
	for(int j=0; j<=255; j++)
	    scale.setPixel(i, j, 255-j);
    scaleLabel->setPixmap(QPixmap::fromImage(scale));

    graphicsView->scale(pow(2,zoom/2), pow(2,zoom/2));

    InitializeShortcuts();
    UpdateVisibility();
}