/*---------------------------------------------------------------------------*\ * interactive networked Virtual Reality system (inVRs) * * * * Copyright (C) 2005-2009 by the Johannes Kepler University, Linz * * * * www.inVRs.org * * * * contact: canthes@inVRs.org, rlander@inVRs.org * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * \*---------------------------------------------------------------------------*/ #include "MainWindow.h" MainWindow::MainWindow() { mEditorLayer = new EditorLayer(); mNewVirtualEnvironmentDialog = new NewVirtualEnvironmentDialog(this); mNewEnvironmentDialog = new NewEnvironmentDialog(this); setCentralWidget(mEditorLayer->getOpenSGWidgetMain()); createDockWindows(); createActions(); createMenus(); createStatusBar(); createConnections(); setWindowIcon(QIcon(":/images/inVRs_logo_300.png")); } // MainWindow MainWindow::~MainWindow() { delete mEditorLayer; } // ~MainWindow void MainWindow::open() { fileName = QFileDialog::getOpenFileName(this, "Open config.xml", ".", "XML Files(*.xml)"); // if a filename was chosen, try to load it: if (! fileName.isEmpty() && ! mEditorLayer->loadConfiguration(qPrintable(fileName))) { QMessageBox::warning(this,"inVrs Editor", QString("The configuration file %1 could not be loaded!").arg(fileName)); } updateStatusBar(); } //open void MainWindow::save(){ mEditorLayer->saveConfiguration(); } // save void MainWindow::about() { QMessageBox::about(this, "About inVRsEditor", "
gwoess@invrs.org");
} // about
void MainWindow::processSelection(QModelIndex current, QModelIndex previous) {
mEditorLayer->processSelection(current);
if(mEditorLayer->isSelectionEntity()){
mEntityProperties->setTranslationX(mEditorLayer->getTranslationX());
mEntityProperties->setTranslationY(mEditorLayer->getTranslationY());
mEntityProperties->setTranslationZ(mEditorLayer->getTranslationZ());
mEntityProperties->setRotationX(mEditorLayer->getRotationX());
mEntityProperties->setRotationY(mEditorLayer->getRotationY());
mEntityProperties->setRotationZ(mEditorLayer->getRotationZ());
mEntityProperties->setRotationA(mEditorLayer->getRotationA());
mEntityProperties->setScaleX(mEditorLayer->getScaleX());
mEntityProperties->setScaleY(mEditorLayer->getScaleY());
mEntityProperties->setScaleZ(mEditorLayer->getScaleZ());
mEntityProperties->setFixed(mEditorLayer->getFixed());
mEntityProperties->updateTableView();
mDockWidgetProperties->setWidget(mEntityProperties);
}else if(mEditorLayer->isSelectionEntityType()){
mEntityTypeProperties->updateModelFilenames(mEditorLayer->getModelFilenames(),
mEditorLayer->getModelFilename());
mEntityTypeProperties->setTranslationX(mEditorLayer->getTranslationX());
mEntityTypeProperties->setTranslationY(mEditorLayer->getTranslationY());
mEntityTypeProperties->setTranslationZ(mEditorLayer->getTranslationZ());
mEntityTypeProperties->setRotationX(mEditorLayer->getRotationX());
mEntityTypeProperties->setRotationY(mEditorLayer->getRotationY());
mEntityTypeProperties->setRotationZ(mEditorLayer->getRotationZ());
mEntityTypeProperties->setRotationA(mEditorLayer->getRotationA());
mEntityTypeProperties->setScaleX(mEditorLayer->getScaleX());
mEntityTypeProperties->setScaleY(mEditorLayer->getScaleY());
mEntityTypeProperties->setScaleZ(mEditorLayer->getScaleZ());
mEntityTypeProperties->setFixed(mEditorLayer->getFixed());
mEntityTypeProperties->setRepCopy(mEditorLayer->getRepCopy());
mEntityTypeProperties->setName(mEditorLayer->getName());
mEntityTypeProperties->setXmlFilename(mEditorLayer->getXmlFilename());
mEntityTypeProperties->updateTableView();
mDockWidgetProperties->setWidget(mEntityTypeProperties);
}else if(mEditorLayer->isSelectionEnvironment()){
mEnvironmentProperties->setPositionX(mEditorLayer->getPositionX());
mEnvironmentProperties->setPositionZ(mEditorLayer->getPositionZ());
mEnvironmentProperties->setXmlFilename(mEditorLayer->getXmlFilename());
mEnvironmentProperties->updateTableView();
mDockWidgetProperties->setWidget(mEnvironmentProperties);
}else{
mDockWidgetProperties->setWidget(mEmptyProperties);
} // else
} // processSelection
void MainWindow::showAllMain(){
mEditorLayer->showAllMain();
} // showAllMain
void MainWindow::showAllPreview(){
mEditorLayer->showAllPreview();
} // showAllPreview
void MainWindow::newEntity(){
if(mEditorLayer->isSelectionEntity() || mEditorLayer->isSelectionEntityType()) {
bool ok = false;
QString item = QInputDialog::getItem(this, "Select Environment", "Select an Environment",
mEditorLayer->getEnvironmentIds(), 0, false, &ok);
if(ok && !item.isEmpty()) {
QModelIndex index = mEditorLayer->newEntity(item);
if(index.isValid()) {
mTreeViewVirtualEnvironment->setCurrentIndex(index);
} // if
} // if
} // if
} // newEntity
void MainWindow::newEntityType(){
bool ok = false;
QString name = QInputDialog::getText(this, "New EntityType", "Name of new EntityType",
QLineEdit::Normal, "", &ok);
if(ok) {
mTreeViewVirtualEnvironment->setCurrentIndex(mEditorLayer->newEntityType(name));
} // if
} // newEntityType
void MainWindow::newEnvironment(int spacingX, int spacingZ, int sizeX, int sizeZ) {
QModelIndex index = mEditorLayer->newEnvironment(spacingX, spacingZ, sizeX, sizeZ);
if(index.isValid()){
mTreeViewVirtualEnvironment->setCurrentIndex(index);
}else{
QMessageBox::warning(this,"inVrs Editor", "Create new Environment failed!");
} // else
} // newEnvironment
void MainWindow::deleteSelection() {
mEditorLayer->deleteSelection();
} // deleteSelection
void MainWindow::createConnections() {
connect(mActionNew, SIGNAL(triggered()), mNewVirtualEnvironmentDialog, SLOT(show()));
connect(mActionOpen, SIGNAL(triggered()), this, SLOT(open()));
connect(mActionSave, SIGNAL(triggered()), this, SLOT(save()));
connect(mActionExit, SIGNAL(triggered()), this, SLOT(close()));
connect(mActionAbout, SIGNAL(triggered()), this, SLOT(about()));
connect(mActionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(mActionShowVirtualEnvironment, SIGNAL(toggled(bool)),
mDockWidgetVirtualEnvironment, SLOT(setVisible(bool)));
connect(mDockWidgetVirtualEnvironment, SIGNAL(visibilityChanged(bool)),
mActionShowVirtualEnvironment, SLOT(setChecked(bool)));
connect(mActionShowProperties, SIGNAL(toggled(bool)),
mDockWidgetProperties, SLOT(setVisible(bool)));
connect(mDockWidgetProperties, SIGNAL(visibilityChanged(bool)),
mActionShowProperties, SLOT(setChecked(bool)));
connect(mActionShowPreview, SIGNAL(toggled(bool)),
mDockWidgetPreview, SLOT(setVisible(bool)));
connect(mDockWidgetPreview, SIGNAL(visibilityChanged(bool)),
mActionShowPreview, SLOT(setChecked(bool)));
connect(mTreeViewVirtualEnvironment->selectionModel(),
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(processSelection(QModelIndex, QModelIndex)));
connect(mEntityProperties, SIGNAL(translationXChanged(double)),
mEditorLayer, SLOT(setTranslationX(double)));
connect(mEntityProperties, SIGNAL(translationYChanged(double)),
mEditorLayer, SLOT(setTranslationY(double)));
connect(mEntityProperties, SIGNAL(translationZChanged(double)),
mEditorLayer, SLOT(setTranslationZ(double)));
connect(mEntityProperties, SIGNAL(rotationXChanged(double)),
mEditorLayer, SLOT(setRotationX(double)));
connect(mEntityProperties, SIGNAL(rotationYChanged(double)),
mEditorLayer, SLOT(setRotationY(double)));
connect(mEntityProperties, SIGNAL(rotationZChanged(double)),
mEditorLayer, SLOT(setRotationZ(double)));
connect(mEntityProperties, SIGNAL(rotationAChanged(double)),
mEditorLayer, SLOT(setRotationA(double)));
connect(mEntityProperties, SIGNAL(scaleXChanged(double)),
mEditorLayer, SLOT(setScaleX(double)));
connect(mEntityProperties, SIGNAL(scaleYChanged(double)),
mEditorLayer, SLOT(setScaleY(double)));
connect(mEntityProperties, SIGNAL(scaleZChanged(double)),
mEditorLayer, SLOT(setScaleZ(double)));
connect(mEntityProperties, SIGNAL(fixedChanged(bool)),
mEditorLayer, SLOT(setFixed(bool)));
connect(mEntityTypeProperties, SIGNAL(translationXChanged(double)),
mEditorLayer, SLOT(setTranslationX(double)));
connect(mEntityTypeProperties, SIGNAL(translationYChanged(double)),
mEditorLayer, SLOT(setTranslationY(double)));
connect(mEntityTypeProperties, SIGNAL(translationZChanged(double)),
mEditorLayer, SLOT(setTranslationZ(double)));
connect(mEntityTypeProperties, SIGNAL(rotationXChanged(double)),
mEditorLayer, SLOT(setRotationX(double)));
connect(mEntityTypeProperties, SIGNAL(rotationYChanged(double)),
mEditorLayer, SLOT(setRotationY(double)));
connect(mEntityTypeProperties, SIGNAL(rotationZChanged(double)),
mEditorLayer, SLOT(setRotationZ(double)));
connect(mEntityTypeProperties, SIGNAL(rotationAChanged(double)),
mEditorLayer, SLOT(setRotationA(double)));
connect(mEntityTypeProperties, SIGNAL(scaleXChanged(double)),
mEditorLayer, SLOT(setScaleX(double)));
connect(mEntityTypeProperties, SIGNAL(scaleYChanged(double)),
mEditorLayer, SLOT(setScaleY(double)));
connect(mEntityTypeProperties, SIGNAL(scaleZChanged(double)),
mEditorLayer, SLOT(setScaleZ(double)));
connect(mEntityTypeProperties, SIGNAL(fixedChanged(bool)),
mEditorLayer, SLOT(setFixed(bool)));
connect(mEntityTypeProperties, SIGNAL(repCopyChanged(bool)),
mEditorLayer, SLOT(setRepCopy(bool)));
connect(mEntityTypeProperties, SIGNAL(modelFilenameChanged(QString)),
mEditorLayer, SLOT(setModelFilename(QString)));
connect(mEntityTypeProperties, SIGNAL(xmlFilenameChanged(QString)),
mEditorLayer, SLOT(setXmlFilename(QString)));
connect(mEntityTypeProperties, SIGNAL(nameChanged(QString)),
mEditorLayer, SLOT(setName(QString)));
connect(mEnvironmentProperties, SIGNAL(positionXChanged(int)),
mEditorLayer, SLOT(setPositionX(int)));
connect(mEnvironmentProperties, SIGNAL(positionZChanged(int)),
mEditorLayer, SLOT(setPositionZ(int)));
connect(mEnvironmentProperties, SIGNAL(xmlFilenameChanged(QString)),
mEditorLayer, SLOT(setXmlFilename(QString)));
connect(mEnvironmentProperties, SIGNAL(entryPointAdded(std::vector