Exemple #1
0
View::View(QGraphicsScene *scene) :
        QGraphicsView(scene), m_timer(this) ,m_delay(30){

    qDebug()<<"in View now";

    QPixmap bgPix(":/images/koskipuisto_pieni.jpg");
    m_pix = bgPix;

    setupWindow();

    int h = height();
    int y = qAbs(m_imageHeight-h)/2;
    setSceneRect(0, y, width(), h);


    m_sensors.append(InputController::QACCELEROMETER);
    m_sensors.append(InputController::QORIENTATIONSENSOR);
    m_sensors.append(InputController::QMAGNETOMETER);
    m_sensors.append(InputController::QROTATIONSENSOR);
    m_sensors.append(InputController::QTAPSENSOR);
    m_sensors.append(InputController::QCOMPASS);
    m_sensors.append(InputController::QKEYS);


    m_menu = new QMenu(this);
    createActions();
    handleAction(NULL,InputController::QACCELEROMETER);

    m_timer.setSingleShot(false);
    m_timer.start(m_delay);

    connect(&m_timer, SIGNAL(timeout()), this, SLOT(update()));
    connect(this,SIGNAL(sceneRectChanged(QRectF)), this, SLOT(checkSensors(QRectF)));

}
void QGraphicsSceneIndexPrivate::init()
{
    if (!scene)
        return;

    QObject::connect(scene, SIGNAL(sceneRectChanged(QRectF)),
                     q_func(), SLOT(updateSceneRect(QRectF)));
}
Exemple #3
0
Tagaro::Scene::Private::Private(Tagaro::Sprite* backgroundSprite, Tagaro::Scene* parent)
	: Tagaro::SpriteClient(backgroundSprite)
	, m_parent(parent)
	, m_mainView(0)
	, m_renderSize() //constructed with invalid size (as documented)
	, m_adjustingSceneRect(false)
	, m_currentOverlay(0)
{
	connect(parent, SIGNAL(sceneRectChanged(QRectF)), parent, SLOT(_k_updateSceneRect(QRectF)));
}
Exemple #4
0
Ruudukko::Ruudukko(QGraphicsScene *sceene) :
    QGraphicsObject()
{
    // Huolehditaan riittävästä ruudusta
    sceene->addRect(-0.0, -50.0, 200, 100, Qt::NoPen, Qt::NoBrush);

    setZValue(-125);
    sceene->addItem(this);
    koko_ = scene()->sceneRect();
    connect( scene(), SIGNAL(sceneRectChanged(QRectF)), this, SLOT(kokoMuuttunut(QRectF)));
}
void MiniViewContainer::setView(QGraphicsView * view)
{
	QGraphicsView * oldView = m_miniView->view();
	if (oldView == view) return;

	if (oldView != NULL) {
		disconnect(oldView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
		disconnect(oldView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
		disconnect(oldView->scene(), SIGNAL(sceneRectChanged(QRectF)), this, SLOT(updateFrame()));
		disconnect(oldView, SIGNAL(resizeSignal()), this, SLOT(updateFrame()));
		disconnect(m_frame, SIGNAL(scrollChangeSignal(double, double)), oldView, SLOT(navigatorScrollChange(double, double)));
	}
Exemple #6
0
void MiniMap::setCurrentScene()
{
	mEditorView = mWindow->getCurrentTab();
	if (mEditorView == NULL) {
		return;
	}

	EditorViewScene *editorViewScene = static_cast<EditorViewScene *>(mEditorView->scene());
	if (editorViewScene->mainWindow() != NULL) {
		setScene(editorViewScene);
		// can affect zoom - need to change it if we make another desision about it
		connect(editorViewScene, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(showScene()));
	}
}
void ModelOverviewWidget::show(ModelWidget *model)
{
	if(this->model)
	{
		disconnect(this->model, nullptr, this, nullptr);
		disconnect(this->model->viewport, nullptr,  this, nullptr);
		disconnect(this->model->scene, nullptr,  this, nullptr);
	}

	this->model=model;

	if(this->model)
	{
		connect(this->model, SIGNAL(s_objectCreated(void)), this, SLOT(updateOverview(void)));
		connect(this->model, SIGNAL(s_objectRemoved(void)), this, SLOT(updateOverview(void)));
		connect(this->model, SIGNAL(s_objectsMoved(void)), this, SLOT(updateOverview(void)));
		connect(this->model, SIGNAL(s_objectModified(void)), this, SLOT(updateOverview(void)));
		connect(this->model, SIGNAL(s_zoomModified(float)), this, SLOT(updateZoomFactor(float)));

		connect(this->model, SIGNAL(s_modelResized(void)), this, SLOT(resizeOverview(void)));
		connect(this->model, SIGNAL(s_modelResized(void)), this, SLOT(resizeWindowFrame(void)));
		connect(this->model, SIGNAL(s_modelResized(void)), this, SLOT(updateOverview(void)));

		connect(this->model->viewport->horizontalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(resizeWindowFrame(void)));
		connect(this->model->viewport->verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(resizeWindowFrame(void)));

		connect(this->model->scene, SIGNAL(selectionChanged(void)), this, SLOT(updateOverview(void)));
		connect(this->model->scene, SIGNAL(sceneRectChanged(QRectF)),this, SLOT(resizeOverview(void)));
		connect(this->model->scene, SIGNAL(sceneRectChanged(QRectF)),this, SLOT(updateOverview(void)));

		this->resizeOverview();
		this->resizeWindowFrame();
		this->updateOverview(true);

		this->move(this->model->geometry().right() - this->width(),
							 this->model->geometry().bottom() - this->height());
	}
Exemple #8
0
void SCgView::updateSceneRect(const QRectF& rect)
{
    if(!isSceneRectControlled && !sceneRect().contains(rect))
        isSceneRectControlled = true;

    if(isSceneRectControlled)
    {
        QPointF topLeft = mapToScene(0,0);
        QPointF bottomRight = mapToScene(viewport()->width(), viewport()->height());
        QRectF vis(topLeft, bottomRight);
        QRectF result = rect.adjusted(-100, -100, 100, 100).united(vis).united(sceneRect());
        setSceneRect(result);

        emit sceneRectChanged(result);
    }
}
Exemple #9
0
BoardView::BoardView(QGraphicsScene* scene, QWidget* parent)
	: QGraphicsView(scene, parent),
	  m_initialized(false),
	  m_resizeTimer(new QTimer(this))
{
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setRenderHint(QPainter::Antialiasing);
	setMouseTracking(true);

	m_resizeTimer->setSingleShot(true);
	m_resizeTimer->setInterval(300);

	connect(m_resizeTimer, SIGNAL(timeout()),
		this, SLOT(fitToRect()));
	connect(scene, SIGNAL(sceneRectChanged(QRectF)),
		this, SLOT(fitToRect()));
}
GraphicStoryView::GraphicStoryView(GraphicStoryScene * _currentScene,QGraphicsView * parent)
	:QGraphicsView(parent)
{
	this->setMouseTracking(true);
	this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
	this->setAcceptDrops(true);
	this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
	this->current_scene=_currentScene;
	connect(this->current_scene,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(updateSceneRect(QRectF)));
	//connect(this->current_scene,SIGNAL(itemInserted(StoryItem*)),this,SLOT(add_story(StoryItem*)));
	this->setScene(this->current_scene);
	//this->setSceneRect(-150,-150,1200,1200);
	connect(this,SIGNAL(story_split_added(QString,StoryBase*)),this->current_scene,SLOT(add_split_story(QString, StoryBase*)));
	connect(this,SIGNAL(story_root_added(QString,StoryBase*)),this->current_scene,SLOT(add_root_story(QString,StoryBase*)));
	//connect(this,SIGNAL(event_added(Event*,int)),this->current_scene,SLOT(add_event(Event*,int)));
	connect(this,SIGNAL(obsPoint_added(ObservationPoint*, int)),this->current_scene,SLOT(add_Obs_point(ObservationPoint*,int)));
	this->setRenderHints(QPainter::Antialiasing);
	this->init=true;

}
Exemple #11
0
void CanvasView::setScene(QGraphicsScene *scene)
{
    if (scene == canvas())
    {
        return;
    }

    if (canvas())
    {
        disconnect(canvas(), 0, this, 0);
    }
    QGraphicsView::setScene(scene);

    if (canvas())
    {
        connect(canvas(), SIGNAL(sceneRectChanged(QRectF)),
                this, SLOT(adjustSceneRect(QRectF)));
        connect(canvas(), SIGNAL(debugOverlayEnabled(bool)),
                this, SLOT(debugOverlayEnabled(bool)));
        connect(canvas(), SIGNAL(editModeChanged(int)),
                this, SLOT(editModeChanged(int)));
    }
}
Exemple #12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	ui->setupUi(this);
#if !MAINWINDOW_ENABLE_UNDO
	delete ui->actionUndo;
#endif
	ui->optionsWidget->setVisible(ui->optionsCheckBox->isChecked());
	setWindowTitle(APP_NAME);

	playerSelector = new PlayerSelector(&tileFactory, this);

	for (int i = 1; i <= MAX_PLAYERS; ++i)
	{
		QLabel * numberLabel = new QLabel(QString::number(i));
		ui->ngPlayerLayout->addWidget(numberLabel, i, 0);

		QComboBox * colorBox = new QComboBox();
		for (uint j = 0; j < colors.size(); ++j)
		{
			colorBox->addItem(colorNames[j]);

			QPixmap px(32, 32);
			QPainter painter(&px);
			painter.fillRect(px.rect(), colors[j]);
			painter.drawRect(0, 0, px.width() - 1, px.height() - 1);
			colorBox->setItemIcon(j, QIcon(px));
		}
		colorBox->setCurrentIndex(i-1);
		ui->ngPlayerLayout->addWidget(colorBox, i, 1);
		connect(colorBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorBoxChanged(int)));

		QComboBox * typeBox = new QComboBox();
		typeBox->addItems(QStringList{tr("", "player selection: no player"), tr("Player"), tr("Computer")});
		ui->ngPlayerLayout->addWidget(typeBox, i, 2);
		connect(typeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(typeBoxChanged(int)));

		QLineEdit * nameEdit = new QLineEdit();
		ui->ngPlayerLayout->addWidget(nameEdit, i, 3);

		ngPlayerEdits[i-1] = NgPlayerEdit{colorBox, typeBox, nameEdit};
	}

	auto actionGroup = new QActionGroup(this);
	actionGroup->addAction(ui->actionRandom_Tiles);
	actionGroup->addAction(ui->actionChoose_Tiles);

	boardUi = new BoardGraphicsScene(&tileFactory, &imgFactory, ui->boardView);
	game = new Game(this, true);
	game->addView(this);
	gameThread = new GameThread(game, this);

	boardUi->setGame(game);
	ui->boardView->setScene(boardUi);

	connect(boardUi, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(recenter(QRectF)));
	connect(this, SIGNAL(gameEvent(QString)), this, SLOT(displayGameEvent(QString)));
	connect(this, SIGNAL(gameEventPop()), this, SLOT(displayGameEventPop()));

	readSettings();

	game->addWatchingPlayer(this);
}
	if (oldView == view) return;

	if (oldView != NULL) {
		disconnect(oldView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
		disconnect(oldView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
		disconnect(oldView->scene(), SIGNAL(sceneRectChanged(QRectF)), this, SLOT(updateFrame()));
		disconnect(oldView, SIGNAL(resizeSignal()), this, SLOT(updateFrame()));
		disconnect(m_frame, SIGNAL(scrollChangeSignal(double, double)), oldView, SLOT(navigatorScrollChange(double, double)));
	}

	m_miniView->setView(view);
	updateFrame();

	bool succeeded = connect(view->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
	succeeded = connect(view->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateFrame()));
	succeeded = connect(view->scene(), SIGNAL(sceneRectChanged(QRectF)), this, SLOT(updateFrame()));
	succeeded = connect(view, SIGNAL(resizeSignal()), this, SLOT(updateFrame()));
	succeeded = connect(m_frame, SIGNAL(scrollChangeSignal(double, double)), view, SLOT(navigatorScrollChange(double, double)));

	forceResize();
}

void MiniViewContainer::forceResize() {
	// force a resize on a view change because otherwise some size or sceneRect isn't updated and the navigator is off
	m_miniView->resize(this->size() / 2.0);
	m_miniView->resize(this->size());
}

void MiniViewContainer::resizeEvent ( QResizeEvent * event )
{
	QWidget::resizeEvent(event);
void CurvesView::addCurve(CurveItem * curve){
    curve->setScene(this);
    update();
    connect(this, SIGNAL(scaleChanged(QPointF)), curve, SLOT(counterSceneScale(QPointF)));
    connect(this, SIGNAL(sceneRectChanged(QRectF)), curve, SLOT(updatePath()));
}