aboutsummaryrefslogtreecommitdiff
path: root/tools/ArtistTools/source/CoreLib/Window
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /tools/ArtistTools/source/CoreLib/Window
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'tools/ArtistTools/source/CoreLib/Window')
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/AppMainWindow.cpp161
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/AppMainWindow.h15
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/D3DWidget.cpp29
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/DisplayPreferencesPanel.cpp33
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.cpp13
-rw-r--r--tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.h2
6 files changed, 217 insertions, 36 deletions
diff --git a/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.cpp b/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.cpp
index 3a85d8b..31a5dc5 100644
--- a/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.cpp
+++ b/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.cpp
@@ -151,6 +151,8 @@ AppMainWindow::AppMainWindow(QWidget *parent, Qt::WindowFlags flags)
,_bookmarkActionGroup(0)
,_actionAddBookmark(0)
,_actionEditBookmarks(0)
+ , _recentMenu(NV_NULL)
+ , _recentFileRecordFile("RecentFiles", "File")
{
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@@ -178,6 +180,8 @@ AppMainWindow::AppMainWindow(QWidget *parent, Qt::WindowFlags flags)
_progressDialog.close(); // prevent show one empty progress dialog when it runs.
m_bGizmoWithLocal = false;
+ m_bGizmoWithDepthTest = false;
+ m_bShowPlane = false;
}
void AppMainWindow::InitUI()
@@ -279,6 +283,8 @@ void AppMainWindow::InitMenuItems()
if (_connectionMode != 1)
{
+ connect(ui.menuBar, SIGNAL(triggered(QAction*)), this, SLOT(menu_item_triggered(QAction*)));
+
act = new QAction("Clear scene", this);
act->setShortcut(QKeySequence::New);
connect(act, SIGNAL(triggered()), this, SLOT(menu_clearScene()));
@@ -292,6 +298,15 @@ void AppMainWindow::InitMenuItems()
fileMenu->addSeparator();
+ act = new QAction("Recents", this);
+ fileMenu->addAction(act);
+ _recentMenu = new QMenu("Recents", this);
+ act->setMenu(_recentMenu);
+
+ fileMenu->addSeparator();
+
+ _loadRecentFile();
+
#ifndef NV_ARTISTTOOLS
fileMenu->addSeparator();
act = new QAction("Open project file", this);
@@ -559,6 +574,7 @@ void AppMainWindow::InitMainTab()
panel->AddContent(_displayMeshesPanel);
ui.displayScrollAreaLayout->insertWidget(idx++, panel);
panel->SetTitle("Display Meshes");
+ panel->setVisible(false);
}
if (_connectionMode != 1)
@@ -792,9 +808,10 @@ bool AppMainWindow::openProject(QString fileName)
return false;
}
-void AppMainWindow::processDragAndDrop(QString fname)
+void AppMainWindow::processDragAndDrop(const QStringList& fileNames)
{
- openProject(fname);
+ CoreLib::Inst()->SimpleScene_OpenFilesByDrop(fileNames);
+ updateUI();
}
void AppMainWindow::removeBookmark(const QString& name)
@@ -861,6 +878,33 @@ void AppMainWindow::ShowCurveEditor(int paramId)
}
#endif
+void AppMainWindow::menu_item_triggered(QAction* action)
+{
+ qDebug("%s", __FUNCTION__);
+#ifdef NV_ARTISTTOOLS
+
+ bool clickRecent = false;
+ for (int i = 0; i < _recentFileActions.count(); ++i)
+ {
+ if (_recentFileActions.at(i) == action)
+ {
+ clickRecent = true;
+ break;
+ }
+ }
+
+ if (clickRecent)
+ {
+ QStringList recentFile;
+ recentFile.push_back(action->text());
+ CoreLib::Inst()->SimpleScene_OpenFilesByDrop(recentFile);
+ return;
+ }
+
+ CoreLib::Inst()->menu_item_triggered(action);
+#endif // NV_ARTISTTOOLS
+}
+
void AppMainWindow::menu_clearScene()
{
SimpleScene::Inst()->Clear();
@@ -905,7 +949,9 @@ bool AppMainWindow::menu_openfbx()
*/
// dir and file will get in blast open asset dialog
- return SimpleScene::Inst()->LoadSceneFromFbx("", "");
+ bool res = SimpleScene::Inst()->LoadSceneFromFbx("", "");
+ updateUI();
+ return res;
}
void AppMainWindow::menu_addBookmark()
@@ -1146,7 +1192,8 @@ char AppMainWindow::TestMouseScheme( Qt::KeyboardModifiers modifiers, Qt::MouseB
if (op != 0)
return op;
- if (modifiers == Qt::KeyboardModifier(Qt::ControlModifier))
+ bool isKeyL = (GetAsyncKeyState('L') && 0x8000);
+ if (isKeyL) //if(modifiers == Qt::KeyboardModifier(Qt::ControlModifier)) // ctrl is used by Selection Tool
{
if (buttons == Qt::MouseButton(Qt::LeftButton))
return 'L';
@@ -1174,16 +1221,114 @@ char AppMainWindow::TestDragCamera( Qt::KeyboardModifiers modifiers, Qt::MouseBu
if(scheme == MAYA_SCHEME)
{
auto itr = _mayaScheme.find(input);
- if(itr != _mayaScheme.end()) return itr.value();
+ if(itr != _mayaScheme.end())
+ return itr.value();
}
else
{
auto itr = _maxScheme.find(input);
- if(itr != _maxScheme.end()) return itr.value();
+ if(itr != _maxScheme.end())
+ return itr.value();
}
return 0;
}
+void AppMainWindow::addRecentFile(const QString filePath)
+{
+ if (filePath.isEmpty())
+ return;
+
+ if (_recentFileRecordFile.getItems().count() > 0 && _recentFileRecordFile.getItems().first() == filePath)
+ return;
+
+ if (_recentFileActions.count() == 8)
+ {
+ QAction* act = _recentFileActions.last();
+ _recentMenu->removeAction(act);
+
+ _recentFileRecordFile.getItems().pop_back();
+ _recentFileActions.pop_back();
+ }
+
+ if (_recentFileRecordFile.isItemExist(filePath))
+ {
+ _resetRecentFile(filePath);
+ return;
+ }
+
+ QAction* act = new QAction(filePath, _recentMenu);
+ if (_recentFileActions.count() > 0)
+ _recentMenu->insertAction(_recentFileActions.first(), act);
+ else
+ _recentMenu->addAction(act);
+
+ _recentFileActions.push_front(act);
+
+ _recentFileRecordFile.getItems().push_front(filePath);
+
+ _saveRecentFile();
+}
+
+void AppMainWindow::_resetRecentFile(const QString filePath)
+{
+ if (filePath.isEmpty())
+ return;
+
+ if (_recentFileRecordFile.getItems().count() > 0 && _recentFileRecordFile.getItems().first() == filePath)
+ return;
+
+ if (!_recentFileRecordFile.isItemExist(filePath))
+ return;
+
+ QList<QAction*> actions;
+ for (int i = 0; i < _recentFileActions.count(); ++i)
+ {
+ QAction* act = _recentFileActions.at(i);
+ if (act->text() == filePath)
+ actions.push_front(act);
+ else
+ actions.push_back(act);
+ }
+
+ _recentMenu->addActions(actions);
+ _recentFileActions = actions;
+
+ QList<QString> filesTMP;
+ QList<QString>& filesCurrent = _recentFileRecordFile.getItems();
+ for (int i = 0; i < filesCurrent.count(); ++i)
+ {
+ QString item = filesCurrent.at(i);
+ if (item == filePath)
+ filesTMP.push_front(item);
+ else
+ filesTMP.push_back(item);
+ }
+ filesCurrent.clear();
+ filesCurrent = filesTMP;
+
+ _saveRecentFile();
+}
+
+void AppMainWindow::_loadRecentFile()
+{
+ QString recentFileRecordFile = QCoreApplication::applicationDirPath() + "/RecentFiles.rfs";
+ _recentFileRecordFile.load(recentFileRecordFile);
+
+ QList<QString> recentFiles = _recentFileRecordFile.getItems();
+ _recentFileRecordFile.getItems().clear();
+
+ for (int i = recentFiles.count() - 1; i >= 0; --i)
+ {
+ addRecentFile(recentFiles.at(i));
+ }
+}
+
+void AppMainWindow::_saveRecentFile()
+{
+ QString recentFileRecordFile = QCoreApplication::applicationDirPath() + "/RecentFiles.rfs";
+ _recentFileRecordFile.save(recentFileRecordFile);
+}
+
QString AppMainWindow::OpenTextureFile(QString title)
{
QString lastDir = _lastFilePath;
@@ -1268,7 +1413,7 @@ void AppMainWindow::updateMainToolbar()
bool AppMainWindow::menu_openProject()
{
QString lastDir = _lastFilePath;
- QString fileName = QFileDialog::getOpenFileName(this, "Open Hair Project File", lastDir, "Hair Project File (*.furproj)");
+ QString fileName = QFileDialog::getOpenFileName(this, "Open Project File", lastDir, "Project File (*.blastProj)");
return openProject(fileName);
}
@@ -1318,7 +1463,7 @@ bool AppMainWindow::menu_saveProjectAs()
char message[1024];
QString lastDir = _lastFilePath;
- QString fileName = QFileDialog::getSaveFileName(this, "Save Hair Project File", lastDir, "Hair Project File (*.furproj)");
+ QString fileName = QFileDialog::getSaveFileName(this, "Save Project File", lastDir, "Project File (*.blastProj)");
if (!fileName.isEmpty())
{
QFileInfo fileInfo(fileName);
diff --git a/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.h b/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.h
index 4183fc2..823c14f 100644
--- a/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.h
+++ b/tools/ArtistTools/source/CoreLib/Window/AppMainWindow.h
@@ -6,6 +6,7 @@
#include "ui_AppMainWindow.h"
#include "UIGlobal.h"
+#include "XMLHelper.h"
class StyleMaterialPanel;
class AssetControlPanel;
@@ -72,7 +73,7 @@ public:
CORELIB_EXPORT void quit();
CORELIB_EXPORT void updateMainToolbar();
- CORELIB_EXPORT void processDragAndDrop(QString fname);
+ CORELIB_EXPORT void processDragAndDrop(const QStringList& fileNames);
CORELIB_EXPORT bool openProject(QString fileName);
CORELIB_EXPORT static void setConnectionMode(int);
@@ -96,6 +97,7 @@ signals:
void aboutToQuit();
public slots:
+ CORELIB_EXPORT void menu_item_triggered(QAction* action);
CORELIB_EXPORT void menu_clearScene();
CORELIB_EXPORT bool menu_openfbx();
CORELIB_EXPORT void menu_addBookmark();
@@ -125,9 +127,14 @@ signals:
CORELIB_EXPORT void onReloadColorAttributeTexture(nvidia::CurveEditor::ColorAttribute* attribute, bool reloadColorTex, int selectedCtrlPntIndex);
#endif
+ CORELIB_EXPORT void addRecentFile(const QString filePath);
private:
char TestDragCamera(Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons);
+ void _resetRecentFile(const QString filePath);
+ void _loadRecentFile();
+ void _saveRecentFile();
+
public:
void InitMenuItems();
void InitToolbar();
@@ -140,6 +147,10 @@ public:
Ui::AppMainWindowClass ui;
D3DWidget* _d3dWidget;
+ QMenu* _recentMenu;
+ QList<QAction*> _recentFileActions;
+ SingleItemKindFile _recentFileRecordFile;
+
QMenu* _bookmarksMenu;
DisplayMeshesPanel* _displayMeshesPanel;
@@ -203,6 +214,8 @@ private:
#endif // NV_ARTISTTOOLS
bool m_bGizmoWithLocal;
+ bool m_bGizmoWithDepthTest;
+ bool m_bShowPlane;
};
#endif // APPMAINWINDOW_H
diff --git a/tools/ArtistTools/source/CoreLib/Window/D3DWidget.cpp b/tools/ArtistTools/source/CoreLib/Window/D3DWidget.cpp
index 69be706..73aabfc 100644
--- a/tools/ArtistTools/source/CoreLib/Window/D3DWidget.cpp
+++ b/tools/ArtistTools/source/CoreLib/Window/D3DWidget.cpp
@@ -58,21 +58,18 @@ void D3DWidget::dropEvent(QDropEvent *e)
return;
QList<QUrl> urlList = data->urls();
- QString text;
+ QStringList fileNames;
for (int i = 0; i < urlList.size() && i < 32; ++i) {
- QString url = urlList.at(i).toLocalFile();
- text += url;
+ fileNames.append(urlList.at(i).toLocalFile());
}
e->acceptProposedAction();
- AppMainWindow::Inst().processDragAndDrop(text);
+ AppMainWindow::Inst().processDragAndDrop(fileNames);
}
void D3DWidget::paintEvent( QPaintEvent* e )
{
- CoreLib::Inst()->D3DWidget_paintEvent(e);
-
SimpleScene::Inst()->Draw();
}
@@ -98,40 +95,42 @@ void D3DWidget::resizeEvent( QResizeEvent* e )
void D3DWidget::mouseMoveEvent( QMouseEvent* e )
{
- CoreLib::Inst()->D3DWidget_mouseMoveEvent(e);
-
atcore_float2 pos = gfsdk_makeFloat2(e->x(), e->y());
SimpleScene::Inst()->onMouseMove(pos);
Q_ASSERT(_appWindow != NV_NULL);
char mode = _appWindow->TestMouseScheme(e->modifiers(), e->buttons());
-
+ CoreLib::Inst()->D3DWidget_mouseMoveEvent(e);
+ if (!e->isAccepted())
+ {
+ return;
+ }
if(mode == 0) return;
SimpleScene::Inst()->Drag(mode);
}
void D3DWidget::wheelEvent(QWheelEvent* e)
{
- CoreLib::Inst()->D3DWidget_wheelEvent(e);
-
SimpleScene::Inst()->onMouseWheel(e->delta());
SimpleScene::Inst()->WheelZoom();
+
+ CoreLib::Inst()->D3DWidget_wheelEvent(e);
}
void D3DWidget::mousePressEvent( QMouseEvent* e )
{
- CoreLib::Inst()->D3DWidget_mousePressEvent(e);
-
atcore_float2 pos = gfsdk_makeFloat2(e->x(), e->y());
SimpleScene::Inst()->onMouseDown(pos);
+
+ CoreLib::Inst()->D3DWidget_mousePressEvent(e);
}
void D3DWidget::mouseReleaseEvent( QMouseEvent* e )
{
- CoreLib::Inst()->D3DWidget_mouseReleaseEvent(e);
-
atcore_float2 pos = gfsdk_makeFloat2(e->x(), e->y());
SimpleScene::Inst()->onMouseUp(pos);
+
+ CoreLib::Inst()->D3DWidget_mouseReleaseEvent(e);
}
void D3DWidget::keyPressEvent( QKeyEvent* e )
diff --git a/tools/ArtistTools/source/CoreLib/Window/DisplayPreferencesPanel.cpp b/tools/ArtistTools/source/CoreLib/Window/DisplayPreferencesPanel.cpp
index fe4b808..3f010fb 100644
--- a/tools/ArtistTools/source/CoreLib/Window/DisplayPreferencesPanel.cpp
+++ b/tools/ArtistTools/source/CoreLib/Window/DisplayPreferencesPanel.cpp
@@ -397,7 +397,7 @@ void DisplayPreferencesPanel::on_btnPlaylistAddProj_clicked()
{
lastPath = PlaylistsLoader::mediaPath;
}
- QString fileNameInput = QFileDialog::getOpenFileName(this, "Open Hair Project File", lastPath, "Hair Project File (*.furproj)");
+ QString fileNameInput = QFileDialog::getOpenFileName(this, "Open Project File", lastPath, "Project File (*.blastProj)");
if (!QFile::exists(fileNameInput))
return;
std::string tmp = fileNameInput.toUtf8().data();
@@ -561,6 +561,7 @@ void PlaylistsLoader::ReleasePlaylistParamsContext()
void PlaylistsLoader::loadPlaylistsFromMediaPath()
{
+ std::string t1 = projectPath.toUtf8().data();
if (projectPath.isEmpty())
{
QString appDir = qApp->applicationDirPath();
@@ -579,7 +580,12 @@ void PlaylistsLoader::loadPlaylistsFromMediaPath()
projectPath = dirTmp.absolutePath();
}
}
- if (!projectPath.isEmpty())
+ if (projectPath.isEmpty())
+ {
+ projectPath = qApp->applicationDirPath();
+ mediaPath = projectPath;
+ }
+ else
{
if (dirTmp.cd(".."))
{
@@ -688,30 +694,30 @@ bool PlaylistsLoader::saveProjectsInPlaylist(int idx, QList<QString>& projects)
objects[numObjects++] = params;
NvParameterized::Interface* iface = static_cast<NvParameterized::Interface*>(params);
+ std::vector<std::string> strArray;
+ std::vector<const char*> strOutput;
+
if (1)
{
nvidia::parameterized::PlaylistParams* params = static_cast<nvidia::parameterized::PlaylistParams*>(iface);
nvidia::parameterized::PlaylistParamsNS::ParametersStruct& targetDesc = params->parameters();
NvParameterized::Handle handle(iface);
- if (iface->getParameterHandle("furprojFilePaths", handle) == NvParameterized::ERROR_NONE)
+ if (iface->getParameterHandle("blastProjFilePaths", handle) == NvParameterized::ERROR_NONE)
{
int num = projects.size();
-
- std::vector<std::string> strArray;
- const char** strOutput = new const char*[num];
+ strArray.resize(num);
+ strOutput.resize(num);
for (int i = 0; i < num; i++)
{
std::string proj = projects[i].toUtf8().data();
- strArray.push_back(proj);
+ strArray[i] = proj;
strOutput[i] = strArray[i].c_str();
}
handle.resizeArray(num);
- handle.setParamStringArray(strOutput, num);
-
- delete[] strOutput;
+ handle.setParamStringArray(&strOutput[0], num);
}
}
@@ -762,6 +768,8 @@ QString PlaylistsLoader::convertToAbsoluteFilePath(QString& filePath)
QString PlaylistsLoader::convertToSaveingFilePath(QString& filePath)
{
+ std::string t1 = mediaPath.toUtf8().data();
+ std::string t2 = projectPath.toUtf8().data();
QString fname;
bool bCanBeRelativePath = false;
bool bAbsPath = (filePath.indexOf(':') >= 0);
@@ -771,7 +779,7 @@ QString PlaylistsLoader::convertToSaveingFilePath(QString& filePath)
{
QFileInfo fi(filePath);
int pos = fi.absoluteFilePath().indexOf(mediaPath, Qt::CaseInsensitive);
- if (pos >= 0)
+ if (pos >= 0 && mediaPath.length())
{
// convert to relative path
fname = filePath.right(filePath.size() - (pos + mediaPath.size() + 1));
@@ -800,6 +808,7 @@ QString PlaylistsLoader::convertToSaveingFilePath(QString& filePath)
{
fname = filePath;
}
+ std::string tmp3 = fname.toUtf8().data();
QFileInfo fi(mediaPath + "/" + fname);
std::string tmp = fi.absoluteFilePath().toUtf8().data();
if (!QFile::exists(fi.absoluteFilePath()))
@@ -853,7 +862,7 @@ int PlaylistsLoader::getProjectsInPlaylist(int idx, QList<QString>& projects)
nvidia::parameterized::PlaylistParams* params = static_cast<nvidia::parameterized::PlaylistParams*>(iface);
nvidia::parameterized::PlaylistParamsNS::ParametersStruct& srcDesc = params->parameters();
NvParameterized::Handle handle(iface);
- if (iface->getParameterHandle("furprojFilePaths", handle) == NvParameterized::ERROR_NONE)
+ if (iface->getParameterHandle("blastProjFilePaths", handle) == NvParameterized::ERROR_NONE)
{
int arraySize;
handle.getArraySize(arraySize);
diff --git a/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.cpp b/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.cpp
index b118b6b..7c0e382 100644
--- a/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.cpp
+++ b/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.cpp
@@ -76,6 +76,17 @@ void DisplayScenePanel::on_btnSkinningDQ_stateChanged(int state)
void DisplayScenePanel::on_checkBoxGizmoWithLocal_stateChanged(int state)
{
AppMainWindow::Inst().m_bGizmoWithLocal = state;
+ CoreLib::Inst()->AppMainWindow_updateMainToolbar();
+}
+
+void DisplayScenePanel::on_checkBoxGizmoWithDepthTest_stateChanged(int state)
+{
+ AppMainWindow::Inst().m_bGizmoWithDepthTest = state;
+}
+
+void DisplayScenePanel::on_checkBoxShowPlane_stateChanged(int state)
+{
+ AppMainWindow::Inst().m_bShowPlane = state;
}
void DisplayScenePanel::updateValues()
@@ -90,4 +101,6 @@ void DisplayScenePanel::updateValues()
ui.btnUseLighting->setChecked(globalSettings.m_useLighting);
ui.btnShowGraphicsMesh->setChecked( globalSettings.m_showGraphicsMesh);
ui.btnShowSkinnedOnly->setChecked( globalSettings.m_showSkinnedMeshOnly);
+ ui.checkBoxGizmoWithLocal->setChecked(AppMainWindow::Inst().m_bGizmoWithLocal);
+ ui.checkBoxGizmoWithDepthTest->setChecked(AppMainWindow::Inst().m_bGizmoWithDepthTest);
}
diff --git a/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.h b/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.h
index 6614eca..cd277b6 100644
--- a/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.h
+++ b/tools/ArtistTools/source/CoreLib/Window/DisplayScenePanel.h
@@ -30,6 +30,8 @@ public:
CORELIB_EXPORT void on_btnShowSkinnedOnly_stateChanged(int state);
CORELIB_EXPORT void on_btnSkinningDQ_stateChanged(int state);
CORELIB_EXPORT void on_checkBoxGizmoWithLocal_stateChanged(int state);
+ CORELIB_EXPORT void on_checkBoxGizmoWithDepthTest_stateChanged(int state);
+ CORELIB_EXPORT void on_checkBoxShowPlane_stateChanged(int state);
private: