Exemple #1
0
 bool eventFilter(QObject *watched, QEvent *event) {
     if (event->type() == QEvent::MouseButtonDblClick ||
             event->type() == QEvent::MouseButtonPress ||
             event->type() == QEvent::MouseButtonRelease) {
         auto ev = static_cast<QMouseEvent*>(event);
         if (ev->button() == Qt::RightButton) {
             auto buttons = ev->buttons();
             if (buttons & Qt::RightButton) {
                 buttons ^= Qt::RightButton;
                 buttons |= Qt::LeftButton;
             }
             QMouseEvent lev{ev->type(),
                             ev->localPos(),
                             ev->windowPos(),
                             ev->screenPos(),
                             Qt::LeftButton,
                             buttons,
                             ev->modifiers(),
                             ev->source()};
             Q_ASSERT(! (lev.buttons() & Qt::RightButton));
             QCoreApplication::sendEvent(watched, &lev);
             return true;
         }
     }
     return QObject::eventFilter(watched, event);
 }
/******************************************************************************
* Renders the image in a rectangle given in viewport coordinates.
******************************************************************************/
void DefaultImagePrimitive::renderViewport(SceneRenderer* renderer, const Point2& pos, const Vector2& size)
{
	QSize imageSize = renderer->outputSize();
	Point2 windowPos((pos.x() + 1.0f) * imageSize.width() / 2, (-(pos.y() + size.y()) + 1.0) * imageSize.height() / 2);
	Vector2 windowSize(size.x() * imageSize.width() / 2, size.y() * imageSize.height() / 2);
	renderWindow(renderer, windowPos, windowSize);
}
void ServerWidget::show() {
	if (isVisible()) {
		raise();
	} else {
		/* Center the dialog */
		QDesktopWidget *desktop = QApplication::desktop();
		QRect geo = desktop->screenGeometry();
		QPoint windowPos(
			geo.left() + (geo.width() - width()) / 2,
			geo.top() + (geo.height() - height())/2
		);
		move(windowPos);
		QMainWindow::show();
	}
}
void MScenePrivate::touchPointMirrorMousePosToPointStartPos(QTouchEvent::TouchPoint &point, const QGraphicsSceneMouseEvent *event)
{
    Q_Q(MScene);

    if (q->views().size() > 0) {
        QPointF windowPos(q->views().at(0)->pos());
        QSize resolution = MDeviceProfile::instance()->resolution();
        QPointF centerPoint(resolution.width() / 2, resolution.height() / 2);

        QPointF mirrorPoint = centerPoint + (centerPoint - event->screenPos() + windowPos);

        point.setStartPos(mirrorPoint);
        point.setStartScenePos(mirrorPoint);
        point.setStartScreenPos(mirrorPoint + windowPos);
    }
}
Exemple #5
0
void InputService::handleMouseEvent(const Event &event)
{
	// only left clicks for now
	if (event.rawInputClick.button != sf::Mouse::Left || !event.rawInputClick.pressed)
		return;

	// only control if not currently controlling
	if (hasPlayerEntity())
		return;

	sf::Vector2i windowPos(event.rawInputClick.x, event.rawInputClick.y);

	auto clicked(getClickedEntity(windowPos, 0));
	if (clicked.is_initialized())
		setPlayerEntity(clicked.get()->id);

}
OutputWindow::OutputWindow()
	: QGraphicsView(new QGraphicsScene())
	, m_url("")
	, m_pollDviz(false)
	, m_updateTime(1000)
	, m_isDataPoll(false)
	, m_slideId(-1)
	, m_slideName("")
	//, m_startStopButton(0)
        , m_countValue(0)
        , m_drw(0)
        , m_blinkCount(0)
{
	// Setup graphics view
	setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform );
	setCacheMode(QGraphicsView::CacheBackground);
	setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
	setOptimizationFlags(QGraphicsView::DontSavePainterState);
	setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
	setTransformationAnchor(AnchorUnderMouse);
	setResizeAnchor(AnchorViewCenter);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		
	// Add pixmap item for background
	QPixmap bluePixmap(32,23);
	bluePixmap.fill(Qt::blue);
	m_pixmap = scene()->addPixmap(bluePixmap);
	
	// Background behind text
	m_counterBgRect = scene()->addRect(0,0,100,60,QPen(), Qt::black);
	m_counterBgRect->setZValue(99);
	// Add text (for use with clock)
	QFont font("Monospace", 50, 600);
	m_counterText = new QGraphicsSimpleTextItem("0");
	m_counterText->setFont(font);
	m_counterText->setPen(QPen(Qt::black));
	m_counterText->setBrush(Qt::white);
	m_counterText->setPos(0, -13);
	m_counterText->setZValue(100);
	scene()->addItem(m_counterText);
	
	
	// Background behind text
	m_overlayBgRect = scene()->addRect(0,300,100,60,QPen(), Qt::black);
	m_overlayBgRect->setZValue(99);
	// Add text (for use with clock)
	//QFont font("Monospace", 50, 600);
	m_overlayText = new QGraphicsSimpleTextItem("Hello, World!");
	m_overlayText->setFont(font);
	m_overlayText->setPen(QPen(Qt::black));
	m_overlayText->setBrush(Qt::white);
	m_overlayText->setPos(0, 300-13);
	m_overlayText->setZValue(100);
	scene()->addItem(m_overlayText);
	
	m_blinkOverlay = false;
	connect(&m_blinkOverlayTimer, SIGNAL(timeout()), this, SLOT(blinkOverlaySlot()));
	
	GET_CONFIG();
	
	QPoint windowPos(1024,0);
	QPoint windowSize(1024,768);

	//QPoint windowPos(10,10);
	//QPoint windowSize = QPoint(640,480);
	QString windowGeomString = config.value("geom","1024,0,1024,768").toString();
	if(!windowGeomString.isEmpty())
	{
		QStringList list = windowGeomString.split(",");
		windowPos  = QPoint(list[0].toInt(), list[1].toInt());
		windowSize = QPoint(list[2].toInt(), list[3].toInt());
	}
	
	setWindowGeom(QRect(windowPos.x(),windowPos.y(),windowSize.x(),windowSize.y()));
	
	
	bool frameless = config.value("frameless","true").toString() == "true";
	if(frameless)
		setWindowFlags(Qt::FramelessWindowHint);// | Qt::ToolTip);

	connect(&m_pollDvizTimer, SIGNAL(timeout()), this, SLOT(initDvizPoll()));
	//connect(&m_pollImageTimer, SIGNAL(timeout()), this, SLOT(initImagePoll()));
	
	setUpdateTime(m_updateTime);
	
        //setUrl("http://10.10.9.90:8081/image");
        //setUrl("");
	//setPollDviz(true);
	
	setInputSource(config.value("source","dviz://192.168.0.10:8081/image").toString());
	
// 	m_startStopButton = new QPushButton("Start Counter");
// 	connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(toggleCounter()));
 	connect(&m_counterTimer, SIGNAL(timeout()), this, SLOT(counterTick()));
 	m_counterTimer.setInterval(1000);
// 	
// 	m_startStopButton->show();

	//toggleCounter();
	setCounterActive(false);
		
	
	setBlinkOverlay(config.value("blink-overlay","false").toString() == "true", config.value("blink-speed", 333).toInt());
	//setOverlayVisible(config.value("overlay-visible", "true").toString() == "true");
	setCounterVisible(config.value("counter-visible", "true").toString() == "true");
	
	setCounterAlignment((Qt::Alignment)config.value("counter-alignment", (int)(Qt::AlignLeft | Qt::AlignTop)).toInt());
	setOverlayAlignment((Qt::Alignment)config.value("overlay-alignment", (int)(Qt::AlignCenter | Qt::AlignBottom)).toInt());
	
	setOverlayText(config.value("overlay-text").toString());
}
/******************************************************************************
* Renders the text string at the given location given in normalized
* viewport coordinates ([-1,+1] range).
******************************************************************************/
void DefaultTextPrimitive::renderViewport(SceneRenderer* renderer, const Point2& pos, int alignment)
{
	QSize imageSize = renderer->outputSize();
	Point2 windowPos((pos.x() + 1.0f) * imageSize.width() / 2, (-pos.y() + 1.0f) * imageSize.height() / 2);
	renderWindow(renderer, windowPos, alignment);
}
Exemple #8
0
//--------------------------------------------------------------
bool ofApp::imGui()
{
	static const int kGuiMargin = 10;

	bool bMouseOverGui = false;
	m_gui.begin();
	{
		ofVec2f windowPos(kGuiMargin, kGuiMargin);
		ofVec2f windowSize = ofVec2f(0);

		ImGui::SetNextWindowPos(windowPos, ImGuiSetCond_Appearing);
		ImGui::SetNextWindowSize(ofVec2f(380, 94), ImGuiSetCond_Appearing);
		if (ImGui::Begin("App", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) 
		{
			ImGui::Text("%.1f FPS (%.3f ms/frame)", ofGetFrameRate(), 1000.0f / ImGui::GetIO().Framerate);

			if (ImGui::CollapsingHeader("World", nullptr, true, true))
			{
				ImGui::SliderFloat("Scale", &m_scale, 1.0f, 2048.0f);
			}

			if (ImGui::CollapsingHeader("Playback", nullptr, true, true))
			{
				if (ImGui::Checkbox("Sync Timeline", &m_bSyncPlayback))
				{
					if (m_bSyncPlayback)
					{
						m_timeline.stop();
						m_timeline.setCurrentFrame(0);
						m_timeline.setFrameRate(m_sequenceRamses.getFrameRate());
						m_timeline.setDurationInFrames(m_sequenceRamses.getTotalFrames());
					}
				}

				if (ImGui::Checkbox("Export", &m_bExportFrames))
				{
					if (m_bExportFrames)
					{
						std::string folderName = ofSystemTextBoxDialog("Save to folder", ofGetTimestampString("%Y%m%d-%H%M%S"));
						if (folderName.length())
						{
							m_exportPath = ofToDataPath("exports/" + folderName + "/");

							m_timeline.setCurrentFrame(0);
							m_timeline.setFrameBased(true);
							m_timeline.play();
						}
					}
					else
					{
						m_timeline.stop();
						m_timeline.setFrameBased(false);
					}
				}
			}

			windowSize = ImGui::GetWindowSize();
			ImGui::End();
		}

		ofRectangle windowBounds(windowPos, windowSize.x, windowSize.y);
		bMouseOverGui = windowBounds.inside(ofGetMouseX(), ofGetMouseY());

		windowPos.y += windowSize.y + kGuiMargin;
		bMouseOverGui |= m_sequenceRamses.imGui(windowPos, windowSize);
	}
	m_gui.end();

	return bMouseOverGui;
}