Esempio n. 1
0
void ImageLabel::rotate(int deg)
{
  doRotate = !(deg == 0);

  rot_angle = deg;

  applyTransformations();
}
Esempio n. 2
0
void ImageLabel::scale(int w, int h)
{
  doScale = !(w == realpixmap.width() && h == realpixmap.height());

  scale_w = w;
  scale_h = h;

  applyTransformations();
}
Esempio n. 3
0
void Triangle::update()
{
	rotate(0, 0, 0.9);
	translate(0.01, 0, 0);
	applyTransformations();
	_vao.bind();
	_vbo.bind();
	_vbo.data(_geometry.getVectorBufferData());
	_vbo.unbind();
	_vao.unbind();
}
Esempio n. 4
0
void ImageLabel::smoothScale(int w, int h)
{
    doScale = !(w == realpixmap.width() && h == realpixmap.height());

    scale_w = w;
    scale_h = h;

    applyTransformations(true);

//  double widthFactor = ((double)w) / ((double)realpixmap.width());
//  double heightFactor = ((double)h) / ((double)realpixmap.height());

//  pixmap.convertFromImage(realpixmap.convertToImage().smoothScale(w, h));

//  setWidth(pixmap.width());
//  setHeight(pixmap.height());

}
Esempio n. 5
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
	m_ui(new Ui::MainWindow),
	m_materialDock(new MaterialDock(this)),
	m_transformDock(new TransformDock(this)),
	m_meshDock(new MeshDock(this)),
	m_textureDialog(new TextureDialog(this)),
	m_UVEditor(new UVEditor(this)),
	m_settings(new QSettings(this)),
	m_shaderSignalMapper(new QSignalMapper(this)),
	m_actionEnableUserShaders(nullptr),
	m_actionLocateUserShaders(nullptr),
	m_actionReloadUserShaders(nullptr)
{
	m_ui->setupUi(this);

	m_pathImport = m_settings->value(WMIT_SETTINGS_IMPORTVAL, QDir::currentPath()).toString();
	m_pathExport = m_settings->value(WMIT_SETTINGS_EXPORTVAL, QDir::currentPath()).toString();

	m_materialDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_materialDock->hide();

	m_transformDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_transformDock->hide();

	m_meshDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_meshDock->hide();

	m_UVEditor->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_UVEditor->hide();

	addDockWidget(Qt::RightDockWidgetArea, m_materialDock, Qt::Horizontal);
	addDockWidget(Qt::RightDockWidgetArea, m_transformDock, Qt::Horizontal);
	addDockWidget(Qt::RightDockWidgetArea, m_meshDock, Qt::Horizontal);
	addDockWidget(Qt::LeftDockWidgetArea, m_UVEditor, Qt::Horizontal);

	// UI is ready and now we can load window previous state (will do nothing if state wasn't saved).
	// 3DView specifics are loaded later on viewerInitialized event
	resize(QSettings().value("Window/size", size()).toSize());
	move(QSettings().value("Window/position", pos()).toPoint());
	restoreState(QSettings().value("Window/state", QByteArray()).toByteArray());

	m_ui->actionOpen->setIcon(QIcon::fromTheme("document-open", style()->standardIcon(QStyle::SP_DirOpenIcon)));
	m_ui->menuOpenRecent->setIcon(QIcon::fromTheme("document-open-recent"));
	m_ui->actionClearRecentFiles->setIcon(QIcon::fromTheme("edit-clear-list"));
	m_ui->actionSave->setIcon(QIcon::fromTheme("document-save", style()->standardIcon(QStyle::SP_DialogSaveButton)));
	m_ui->actionSaveAs->setIcon(QIcon::fromTheme("document-save-as"));
	m_ui->actionClose->setIcon(QIcon::fromTheme("window-close"));
	m_ui->actionExit->setIcon(QIcon::fromTheme("application-exit", style()->standardIcon(QStyle::SP_DialogCloseButton)));
	m_ui->actionAboutApplication->setIcon(QIcon::fromTheme("help-about"));

	connect(m_ui->centralWidget, SIGNAL(viewerInitialized()), this, SLOT(viewerInitialized()));
	connect(m_ui->menuFile, SIGNAL(aboutToShow()), this, SLOT(updateRecentFilesMenu()));
	connect(m_ui->actionOpen, SIGNAL(triggered()), this, SLOT(actionOpen()));
	connect(m_ui->menuOpenRecent, SIGNAL(triggered(QAction*)), this, SLOT(actionOpenRecent(QAction*)));
	connect(m_ui->actionClearRecentFiles, SIGNAL(triggered()), this, SLOT(actionClearRecentFiles()));
	connect(m_ui->actionClear_Missing_Files, SIGNAL(triggered()), this, SLOT(actionClearMissingFiles()));
	connect(m_ui->actionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
	connect(m_ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
	connect(m_ui->actionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
	connect(m_ui->actionUVEditor, SIGNAL(toggled(bool)), m_UVEditor, SLOT(setVisible(bool)));
	connect(m_ui->actionSetupTextures, SIGNAL(triggered()), this, SLOT(actionSetupTextures()));
	connect(m_ui->actionAppendModel, SIGNAL(triggered()), this, SLOT(actionAppendModel()));
	connect(m_ui->actionImport_Animation, SIGNAL(triggered()), this, SLOT(actionImport_Animation()));
	connect(m_ui->actionImport_Connectors, SIGNAL(triggered()), this, SLOT(actionImport_Connectors()));
	connect(m_ui->actionShowAxes, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setAxisIsDrawn(bool)));
	connect(m_ui->actionShowGrid, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setGridIsDrawn(bool)));
	connect(m_ui->actionShowLightSource, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setDrawLightSource(bool)));
	connect(m_ui->actionLink_Light_Source_To_Camera, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setLinkLightToCamera(bool)));
	connect(m_ui->actionAnimate, SIGNAL(toggled(bool)), m_ui->centralWidget, SLOT(setAnimateState(bool)));
	connect(m_ui->actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt()));
	connect(m_ui->actionSetTeamColor, SIGNAL(triggered()), this, SLOT(actionSetTeamColor()));

	/// Material dock
	m_materialDock->toggleViewAction()->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0) ,m_materialDock->toggleViewAction());

	connect(m_materialDock, SIGNAL(materialChanged(WZMaterial)), this, SLOT(materialChangedFromUI(WZMaterial)));

	/// Transform dock
	m_transformDock->toggleViewAction()->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0) ,m_transformDock->toggleViewAction());

	// transformations
	connect(m_transformDock, SIGNAL(scaleXYZChanged(double)), this, SLOT(scaleXYZChanged(double)));
	connect(m_transformDock, SIGNAL(scaleXChanged(double)), this, SLOT(scaleXChanged(double)));
	connect(m_transformDock, SIGNAL(scaleYChanged(double)), this, SLOT(scaleYChanged(double)));
	connect(m_transformDock, SIGNAL(scaleZChanged(double)), this, SLOT(scaleZChanged(double)));
	connect(m_transformDock, SIGNAL(reverseWindings()), this, SLOT(reverseWindings()));
	connect(m_transformDock, SIGNAL(flipNormals()), this, SLOT(flipNormals()));
	connect(m_transformDock, SIGNAL(applyTransformations()), &m_model, SLOT(applyTransformations()));
	connect(m_transformDock, SIGNAL(changeActiveMesh(int)), &m_model, SLOT(setActiveMesh(int)));
	connect(m_transformDock, SIGNAL(recalculateTB()), &m_model, SLOT(slotRecalculateTB()));
	connect(m_transformDock, SIGNAL(removeMesh()), this, SLOT(removeMesh()));
	connect(m_transformDock, SIGNAL(mirrorAxis(int)), this, SLOT(mirrorAxis(int)));
	connect(m_transformDock, SIGNAL(centerMesh(int)), this, SLOT(centerMesh(int)));
	connect(&m_model, SIGNAL(meshCountChanged(int,QStringList)), m_transformDock, SLOT(setMeshCount(int,QStringList)));

	/// Mesh dock
	m_meshDock->toggleViewAction()->setShortcut(QKeySequence(Qt::Key_M));
	m_ui->menuModel->insertAction(m_ui->menuModel->actions().value(0), m_meshDock->toggleViewAction());

	connect(m_meshDock, SIGNAL(connectorsWereUpdated()), this, SLOT(updateModelRender()));
	connect(&m_model, SIGNAL(meshCountChanged(int,QStringList)), m_meshDock, SLOT(setMeshCount(int,QStringList)));

	/// Reset state
	clear();
}