diff options
| author | Bryan Galdrikian <[email protected]> | 2017-08-23 11:24:32 -0700 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-08-23 11:24:32 -0700 |
| commit | f1e539cadfb085cedc32f9773cfb9d14bfcdf138 (patch) | |
| tree | 7ca74e06a4386dd22fd850a8417a31a85d282a30 /tools/ArtistTools/source/BlastPlugin/Window | |
| parent | Updated to CL 22661993: (diff) | |
| download | blast-f1e539cadfb085cedc32f9773cfb9d14bfcdf138.tar.xz blast-f1e539cadfb085cedc32f9773cfb9d14bfcdf138.zip | |
Removing ArtistTools and CurveEditor projects
Diffstat (limited to 'tools/ArtistTools/source/BlastPlugin/Window')
34 files changed, 0 insertions, 8719 deletions
diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp deleted file mode 100644 index ab0ca85..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.cpp +++ /dev/null @@ -1,2678 +0,0 @@ -#include "BlastSceneTree.h" -#include <QtWidgets/QMessageBox> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QMenu> -#include <QtWidgets/QShortcut> -#include <QtCore/QFileInfo> -#include <QtGui/qevent.h> -#include <QtGui/QPainter> -#include <assert.h> -#include "ProjectParams.h" -#include <SimpleScene.h> -#include <BlastController.h> -#include "SelectionToolController.h" -#include "GizmoToolController.h" -#include <SceneController.h> -#include <NvBlastExtPxAsset.h> -#include <NvBlastTkAsset.h> -#include <NvBlastAsset.h> -#include <BlastFamilyModelSimple.h> -#include "GlobalSettings.h" -#include <deque> -#include "ViewerOutput.h" - -static QIcon sCompositeIcon; -static QIcon sAssetIcon; -static QIcon sChunkUUIcon; -static QIcon sChunkSUIcon; -static QIcon sChunkSSIcon; -static QIcon sBondIcon; -static QIcon sProjectileIcon; - -static QPixmap sVisibleIcon = QPixmap(":/AppMainWindow/images/visibilityToggle_visible.png").scaled(QSize(24, 24), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -static QPixmap sInVisibleIcon = QPixmap(":/AppMainWindow/images/visibilityToggle_notVisible.png").scaled(QSize(24, 24), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - -class BlastSceneTreeDataLock -{ -public: - BlastSceneTreeDataLock() - { - BlastSceneTree::ins()->_updateData = false; - } - ~BlastSceneTreeDataLock() - { - BlastSceneTree::ins()->_updateData = true; - } -}; - -#if 0 -bool isChunkVisible(std::vector<BlastFamily*>& fs, uint32_t chunkIndex) -{ - int fsSize = fs.size(); - if (fsSize == 0) - { - return false; - } - - bool visible = false; - for (int i = 0; i < fsSize; i++) - { - if (fs[i]->isChunkVisible(chunkIndex)) - { - visible = true; - break; - } - } - return visible; -} -#endif - -void setChunkVisible(std::vector<BlastFamily*>& fs, uint32_t chunkIndex, bool visible) -{ - int fsSize = fs.size(); - if (fsSize == 0) - { - return; - } - - for (int i = 0; i < fsSize; i++) - { - fs[i]->setChunkVisible(chunkIndex, visible); - } -} - -void setChunkSelected(std::vector<BlastFamily*>& fs, uint32_t chunkIndex, bool selected) -{ - int fsSize = fs.size(); - if (fsSize == 0) - { - return; - } - - for (int i = 0; i < fsSize; i++) - { - BlastFamily* bf = fs[i]; - if(bf) - bf->setChunkSelected(chunkIndex, selected); - } -} - -void BlastNode::traverse(BlastVisitorBase& visitor) -{ - visitor.visit(this); - - for (BlastNode* node : children) - { - if (!visitor.continueTraversing()) - break; - - node->traverse(visitor); - } -} - -void BlastChunkNode::setVisible(bool val) -{ - BPPChunk* pBPPChunk = (BPPChunk*)getData(); - pBPPChunk->visible = val; - - BlastAsset* pBlastAsset = (BlastAsset*)_assetPtr; - - SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager(); - - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap(); - std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator it = AssetFamiliesMap.find(pBlastAsset); - if (it == AssetFamiliesMap.end()) - { - return; - } - - std::vector<BlastFamily*>& fs = it->second; - setChunkVisible(fs, pBPPChunk->ID, val); -} - -void BlastChunkNode::setSelected(bool val) -{ - BPPChunk* pBPPChunk = (BPPChunk*)getData(); - - BlastAsset* pBlastAsset = (BlastAsset*)_assetPtr; - - SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager(); - - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap(); - std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator it = AssetFamiliesMap.find(pBlastAsset); - if (it == AssetFamiliesMap.end()) - { - return; - } - - std::vector<BlastFamily*>& fs = it->second; - setChunkSelected(fs, pBPPChunk->ID, val); -} - -void BlastAssetNode::setSelected(bool val) -{ - BPPAsset* pBPPAsset = (BPPAsset*)getData(); - std::string strAsset = pBPPAsset->name.buf; - - BlastAsset* pBlastAsset = nullptr; - SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = sampleManager.getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap; - for (itAssetDescMap = AssetDescMap.begin(); - itAssetDescMap != AssetDescMap.end(); itAssetDescMap++) - { - AssetList::ModelAsset& model = itAssetDescMap->second; - if (model.name == strAsset) - { - pBlastAsset = itAssetDescMap->first; - break; - } - } - - sampleManager.setCurrentSelectedInstance(pBlastAsset, -1); - - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap(); - std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator itAFM = AssetFamiliesMap.find(pBlastAsset); - if (itAFM == AssetFamiliesMap.end()) - { - return; - } - std::vector<BlastFamily*>& fs = itAFM->second; - for (BlastFamily* pBlastFamily : fs) - { - pBlastFamily->highlightChunks(); - } -} - -bool BlastProjectileNode::getVisible() -{ - return SampleManager::ins()->getSceneController().getProjectileVisible((PhysXSceneActor*)getData()); -} - -void BlastProjectileNode::setVisible(bool val) -{ - SampleManager::ins()->getSceneController().setProjectileVisible((PhysXSceneActor*)getData(), val); -} - -void BlastAssetInstanceNode::setSelected(bool val) -{ - BPPAssetInstance* pBPPAssetInstance = (BPPAssetInstance*)getData(); - if (pBPPAssetInstance == nullptr) - return; - std::string name = pBPPAssetInstance->name.buf; - - std::string strAsset = name.substr(0, name.find_last_of("_")); - BlastAsset* pBlastAsset = nullptr; - SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = sampleManager.getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap; - for (itAssetDescMap = AssetDescMap.begin(); - itAssetDescMap != AssetDescMap.end(); itAssetDescMap++) - { - AssetList::ModelAsset& model = itAssetDescMap->second; - if (model.name == strAsset) - { - pBlastAsset = itAssetDescMap->first; - break; - } - } - - std::string strIndex = name.substr(name.find_last_of("_") + 1); - int nIndex = atoi(strIndex.c_str()); - - sampleManager.setCurrentSelectedInstance(pBlastAsset, nIndex); - - std::vector<BlastFamily*> fs = { SampleManager::ins()->getFamilyByInstance(pBPPAssetInstance) }; - setChunkSelected(fs, 0, val); -} - -BlastTreeData& BlastTreeData::ins() -{ - static BlastTreeData _ins; - return _ins; -} - -bool BlastTreeData::isChild(BlastChunkNode* parent, BlastChunkNode* child) -{ - if (parent == nullptr || child == nullptr) - return false; - - BlastNode* curParent = child->getParent(); - while (eChunk == curParent->getType() && curParent != nullptr) - { - if (curParent == parent) - return true; - curParent = curParent->getParent(); - } - - return false; -} - -std::vector<BlastChunkNode*> BlastTreeData::getTopChunkNodes(std::vector<BlastChunkNode*>& nodes) -{ - std::vector<BlastChunkNode*> result; - - for (size_t i = 0; i < nodes.size(); ++i) - { - bool isCurNodeTop = true; - for (size_t j = 0; j < nodes.size(); ++j) - { - if (i != j && isChild(nodes[j], nodes[i])) - { - isCurNodeTop = false; - break; - } - } - - if (isCurNodeTop) - { - result.push_back(nodes[i]); - } - } - - return result; -} - -int BlastTreeData::getDepth(BlastNode* node) -{ - int depth = -1; // here it's from -1 because it traverse from Blast asset node - while (nullptr != node && (eBond == node->getType() || eChunk == node->getType())) - { - ++depth; - node = node->getParent(); - } - - return depth; -} - -bool BlastTreeData::isRoot(BlastChunkNode* node) -{ - if (node == nullptr || node->getParent() == nullptr) - return false; - - return eAsset == node->getParent()->getType(); -} - -bool BlastTreeData::isLeaf(BlastChunkNode* node) -{ - if (node == nullptr) - return false; - - for (BlastNode* curNode : node->children) - { - if (eChunk == curNode->getType()) - return false; - } - - return true; -} - -void removeChunkNodeSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return; - - BPPChunk* chunk = static_cast<BPPChunk*>(node->getData()); - chunk->support = false; - chunk->staticFlag = false; - - for (BlastNode* curNode : node->children) - { - if (eChunk == curNode->getType()) - { - removeChunkNodeSupport((BlastChunkNode*)curNode); - } - } -} - -void setAncestorSupportFlag(BlastChunkNode* ancestor, BlastChunkNode* startChild) -{ - if (nullptr == ancestor || nullptr == startChild) - return; - - { - BPPChunk* bppChunk = (BPPChunk*)(ancestor->getData()); - bppChunk->support = false; - bppChunk->staticFlag = false; - } - - std::deque<BlastChunkNode*> ancestors; - for (BlastNode* node : ancestor->children) - { - if (eChunk == node->getType()) - { - ancestors.push_back(static_cast<BlastChunkNode*>(node)); - } - } - - while (ancestors.size() > 0) - { - BlastChunkNode* curAncestor = ancestors.front(); - ancestors.pop_front(); - - bool isChild = BlastTreeData::isChild(curAncestor, startChild); - if (isChild) - { - if (curAncestor != startChild) - { - for (BlastNode* node : curAncestor->children) - { - if (eChunk == node->getType()) - { - ancestors.push_back(static_cast<BlastChunkNode*>(node)); - } - } - } - } - else - { - BPPChunk* bppChunk = (BPPChunk*)(curAncestor->getData()); - bppChunk->support = true; - bppChunk->staticFlag = false; - } - } -} - -void BlastTreeData::makeSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return; - - // 1 set flag for current node - BPPChunk* chunk = static_cast<BPPChunk*>(node->getData()); - chunk->staticFlag = false; - chunk->support = true; - - // 2 set flag for ancestors - BlastChunkNode* supportAncestor = ins().getSupportAncestor(node); - if (supportAncestor) - { - setAncestorSupportFlag(supportAncestor, node); - } - - // 3 set flag for children - for (BlastNode* curNode : node->children) - { - if (eChunk == curNode->getType()) - { - removeChunkNodeSupport((BlastChunkNode*)curNode); - } - } -} - -void BlastTreeData::makeStaticSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return; - - // 1 set flag for current node - BPPChunk* chunk = static_cast<BPPChunk*>(node->getData()); - chunk->staticFlag = true; - chunk->support = true; - - // 2 set flag for ancestors - BlastChunkNode* supportAncestor = ins().getSupportAncestor(node); - if (supportAncestor) - { - setAncestorSupportFlag(supportAncestor, node); - } - - // 3 set flag for children - for (BlastNode* curNode : node->children) - { - if (eChunk == curNode->getType()) - { - removeChunkNodeSupport((BlastChunkNode*)curNode); - } - } -} - -void BlastTreeData::removeSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return; - - if (isLeaf(node)) - return; - - BPPChunk* chunk = static_cast<BPPChunk*>(node->getData()); - chunk->support = false; - chunk->staticFlag = false; - - for (BlastNode* curNode : node->children) - { - if (eChunk == curNode->getType()) - { - BPPChunk* curChunk = static_cast<BPPChunk*>(curNode->getData()); - curChunk->support = true; - curChunk->staticFlag = false; - } - } -} - -std::string BlastTreeData::getAssetName(BlastAsset* asset) -{ - std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.find(asset); - - if (itrAssetDesc != assetDescMap.end()) - { - return itrAssetDesc->second.name; - } - - return ""; -} - -BlastAsset* BlastTreeData::getAsset(std::string assetName) -{ - std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.begin(); - for (; itrAssetDesc != assetDescMap.end(); ++itrAssetDesc) - { - if (itrAssetDesc->second.name == assetName) - { - return itrAssetDesc->first; - } - } - - return nullptr; -} - -BlastNode* BlastTreeData::getBlastNodeByProjectData(void* data) -{ - std::map<void*, BlastNode*>::iterator itr = _blastProjectDataToNodeMap.find(data); - if (itr != _blastProjectDataToNodeMap.end()) - return itr->second; - - return nullptr; -} - -struct ChunkSupport -{ - ChunkSupport() - { - m_bSupport = false; - } - - bool m_bSupport; -}; - -struct BondChunkIndices -{ - BondChunkIndices() - { - chunkIndices[0] = -1; - chunkIndices[1] = -1; - } - - void SetIndices(uint32_t chunkIndex0, uint32_t chunkIndex1) - { - if (chunkIndex0 < chunkIndex1) - { - chunkIndices[0] = chunkIndex0; - chunkIndices[1] = chunkIndex1; - } - else - { - chunkIndices[0] = chunkIndex1; - chunkIndices[1] = chunkIndex0; - } - } - - uint32_t chunkIndices[2]; -}; - -BlastAssetNode* BlastTreeData::addAsset(const BlastAsset* asset) -{ - //to do - return nullptr; -} -BlastAssetInstanceNode* BlastTreeData::addAssetInstance(const BlastAsset* asset) -{ - //to do - return nullptr; -} - -void BlastTreeData::remove(const BlastAssetNode* node) -{ - //to do -} - -void BlastTreeData::remove(const BlastAssetInstanceNode* node) -{ - //to do -} - -BlastAssetInstanceNode* BlastTreeData::getAssetInstanceNode(BlastFamily* family) -{ - BPPAssetInstance* instance = SampleManager::ins()->getInstanceByFamily(family); - return getAssetInstanceNode(instance); -} - -BlastAssetInstanceNode* BlastTreeData::getAssetInstanceNode(BPPAssetInstance* instance) -{ - if (nullptr == instance) - return nullptr; - - for (BlastNode* node : _assetInstancesNode->children) - { - if ((BPPAssetInstance*)(node->getData()) == instance) - { - return (BlastAssetInstanceNode*)node; - } - } - - return nullptr; -} - -std::vector<BlastAssetInstanceNode*> BlastTreeData::getAssetInstanceNodes(BlastChunkNode* chunkNode) -{ - std::vector<BlastAssetInstanceNode*> instanceNodes; - - if (nullptr == chunkNode) - return instanceNodes; - - BlastAsset* asset = getAsset(chunkNode); - - if (isRoot(chunkNode)) - { - BPPAssetInstance* instance = (BPPAssetInstance*)(chunkNode->getData()); - - for (BlastNode* instanceNode : _assetInstancesNode->children) - { - BPPAssetInstance* instance = (BPPAssetInstance*)(instanceNode->getData()); - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(instance); - if (&(family->getBlastAsset()) == asset) - instanceNodes.push_back((BlastAssetInstanceNode*)instanceNode); - } - } - - return instanceNodes; -} - -void BlastTreeData::update() -{ - _freeBlastNode(); - - BPPBlast& blast = BlastProject::ins().getParams().blast; - std::vector<BlastAsset*> BlastAssetVec; - { - SampleManager& sampleManager = SimpleScene::Inst()->GetSampleManager(); - - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = sampleManager.getAssetFamiliesMap(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = sampleManager.getAssetDescMap(); - - BlastController& blastController = sampleManager.getBlastController(); - SceneController& sceneController = sampleManager.getSceneController(); - - std::vector<BlastFamilyPtr>& families = blastController.getFamilies(); - int familiesSize = families.size(); - - std::map<BlastAsset*, AssetList::ModelAsset>::iterator it; - for (it = AssetDescMap.begin(); it != AssetDescMap.end(); it++) - { - BlastAssetVec.push_back(it->first); - } - int modelAssetsSize = AssetDescMap.size(); - - } - - BPPAssetArray& assetArray = blast.blastAssets; - - int count = assetArray.arraySizes[0]; - if (BlastAssetVec.size() != count) - { - return; - } - for (int c = 0; c < count; ++c) - { - BPPAsset& asset = assetArray.buf[c]; - BlastAssetNode* assetNode = new BlastAssetNode(asset.name.buf, asset); - _assets.push_back(assetNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&asset, assetNode)); - - // get the firlst level chunks whose parentID is -1 - std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, -1); - - for (size_t i = 0; i < childChunks.size(); ++i) - { - BPPChunk& chunk = *(childChunks[i]); - BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, BlastAssetVec[c]); - assetNode->children.push_back(chunkNode); - chunkNode->setParent(assetNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode)); - _addChunkNode(chunk, asset, chunkNode, BlastAssetVec[c]); - } - } - - _assetInstancesNode = new BlastAssetInstancesNode("BlastAssetInstances"); - _blastProjectDataToNodeMap.insert(std::make_pair(nullptr, _assetInstancesNode)); - BPPAssetInstanceArray& assetInstanceArray = blast.blastAssetInstances; - count = assetInstanceArray.arraySizes[0]; - for (int i = 0; i < count; ++i) - { - BPPAssetInstance& blastAssetInstance = assetInstanceArray.buf[i]; - BlastAssetInstanceNode* blastAssetInstanceNode = new BlastAssetInstanceNode(blastAssetInstance.name.buf, blastAssetInstance); - _assetInstancesNode->children.push_back(blastAssetInstanceNode); - blastAssetInstanceNode->setParent(_assetInstancesNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&blastAssetInstance, blastAssetInstanceNode)); - } - - SceneController& sceneController = SampleManager::ins()->getSceneController(); - std::vector<PhysXSceneActor*> projectiles = sceneController.getPrejectiles(); - for (PhysXSceneActor* projectile : projectiles) - { - BlastProjectileNode* projectileNode = new BlastProjectileNode(sceneController.getProjectileName(projectile), projectile); - _projectiles.push_back(projectileNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&projectile, projectileNode)); - } - - //BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes; - //count = graphicsMeshArray.arraySizes[0]; - //for (int i = 0; i < count; ++i) - //{ - // BPPGraphicsMesh& graphicsMesh = graphicsMeshArray.buf[i]; - // BlastGraphicsMeshNode* graphicsNode = new BlastGraphicsMeshNode(graphicsMesh.name.buf, graphicsMesh); - // _graphicsMeshes.push_back(graphicsNode); - //} -} - -BlastNode* BlastTreeData::getNodeByIndex(uint32_t assetIndex, uint32_t chunkIndex) -{ - BlastNode* pNode = nullptr; - BPPBlast& blast = BlastProject::ins().getParams().blast; - BPPAssetArray& assetArray = blast.blastAssets; - if (assetIndex < assetArray.arraySizes[0]) - { - BPPAsset& asset = assetArray.buf[assetIndex]; - - std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset); - if (chunkIndex < childChunks.size()) - { - BPPChunk& chunk = *(childChunks[chunkIndex]); - pNode = getBlastNodeByProjectData(&chunk); - } - } - return pNode; -} - -void BlastTreeData::update(const BlastAsset* asset) -{ - //to do -} - -BlastChunkNode* findChunkNode(BlastChunkNode* chunkNode, uint32_t chunkIndex) -{ - if (chunkNode == nullptr) - return nullptr; - - if (((BPPChunk*)chunkNode->getData())->ID == chunkIndex) - return chunkNode; - - std::vector<BlastNode*>& children = chunkNode->children; - for (size_t i = 0; i < children.size(); ++i) - { - BlastNode* node = children[i]; - if (node->getType() == eChunk) - { - BlastChunkNode* chunkNode = findChunkNode(static_cast<BlastChunkNode*>(node), chunkIndex); - if (chunkNode) - { - return chunkNode; - } - else - continue; - } - - else - continue; - } - - return nullptr; -} - -BlastAsset* BlastTreeData::getAsset(BlastNode* node) -{ - if (nullptr == node) - return nullptr; - - BlastNode* parent = node->getParent(); - while (nullptr != parent) - { - node = parent; - parent = node->getParent(); - } - - if (eAsset == node->getType()) - { - return getAsset(node->name); - } - - return nullptr; -} - -BlastAssetNode* BlastTreeData::getAssetNode(BlastAsset* asset) -{ - if (nullptr == asset) - return nullptr; - - for (BlastAssetNode* node : _assets) - { - if (node->name == getAssetName(asset)) - return node; - } - - return nullptr; -} - -std::vector<BlastChunkNode*> BlastTreeData::getChunkNodeByBlastChunk(const BlastAsset* asset, const std::vector<uint32_t>& chunkIndexes) -{ - std::vector<BlastChunkNode*> chunkNodes; - if (asset == nullptr || chunkIndexes.size() == 0) - { - return chunkNodes; - } - - BlastAssetNode* assetNode = _getAssetNode(asset); - if (assetNode) - { - std::vector<BlastNode*>& children = assetNode->children; - for (BlastNode* node : children) - { - if (node->getType() == eChunk) - { - for (uint32_t chunkId : chunkIndexes) - { - BlastChunkNode* chunkNode = findChunkNode(static_cast<BlastChunkNode*>(node), chunkId); - if (chunkNode) - { - chunkNodes.push_back(chunkNode); - } - } - } - } - } - - return chunkNodes; -} - -std::vector<BlastNode*> _getNodesByDepth(BlastNode* curNode, uint32_t depth, int32_t curDepth) -{ - std::vector<BlastNode*> res; - if (depth == curDepth && curNode != nullptr) - { - res.push_back(curNode); - } - else if (curNode != nullptr) - { - for (BlastNode* node : curNode->children) - { - std::vector<BlastNode*> nodes = _getNodesByDepth(node, depth, curDepth + 1); - res.insert(res.begin(), nodes.begin(), nodes.end()); - } - } - - return res; -} - -std::vector<BlastChunkNode*> BlastTreeData::getRootChunkNodeByInstance(const BlastAssetInstanceNode* node) -{ - std::vector<BlastChunkNode*> chunks; - if (nullptr != node) - { - const BPPAssetInstance* pBPPAssetInstance = (BPPAssetInstance*)(const_cast<BlastAssetInstanceNode*>(node)->getData()); - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(const_cast<BPPAssetInstance*>(pBPPAssetInstance)); - if (family) - { - const BlastAsset& asset = family->getBlastAsset(); - BlastAssetNode* assetNode = getAssetNode(const_cast<BlastAsset*>(&asset)); - if (assetNode) - { - for (BlastNode* curNode : assetNode->children) - { - if (eChunk == curNode->getType()) - { - chunks.push_back((BlastChunkNode*)curNode); - } - } - } - } - } - return chunks; -} - -std::vector<BlastNode*> BlastTreeData::getNodesByDepth(BlastAssetNode* node, uint32_t depth) -{ - return _getNodesByDepth(node, depth, -1); // here it's from -1 because it traverse from Blast asset node -} - -std::vector<BlastNode*> BlastTreeData::getNodesByDepth(uint32_t depth) -{ - std::vector<BlastNode*> res; - for (BlastAssetNode* node : _assets) - { - std::vector<BlastNode*> nodes = getNodesByDepth(node, depth); - res.insert(res.begin(), nodes.begin(), nodes.end()); - } - return res; -} - -std::vector<BlastNode*> BlastTreeData::getNodesByDepth(std::vector<uint32_t> depths) -{ - std::vector<BlastNode*> res; - for (uint32_t depth : depths) - { - std::vector<BlastNode*> nodes = getNodesByDepth(depth); - res.insert(res.begin(), nodes.begin(), nodes.end()); - } - return res; -} - -std::vector<BlastChunkNode*> _getSupportChunkNodes(BlastNode* curNode) -{ - std::vector<BlastChunkNode*> res; - if (nullptr != curNode && eChunk == curNode->getType() && static_cast<BlastChunkNode*>(curNode)->isSupport()) - { - res.push_back(static_cast<BlastChunkNode*>(curNode)); - } - else if (curNode != nullptr) - { - for (BlastNode* node : curNode->children) - { - std::vector<BlastChunkNode*> nodes = _getSupportChunkNodes(node); - res.insert(res.begin(), nodes.begin(), nodes.end()); - } - } - - return res; -} - -std::vector<BlastChunkNode*> BlastTreeData::getSupportChunkNodes(BlastAssetNode* node) -{ - return _getSupportChunkNodes(node); -} - -std::vector<BlastChunkNode*> BlastTreeData::getSupportChunkNodes() -{ - std::vector<BlastChunkNode*> res; - for (BlastAssetNode* node : _assets) - { - std::vector<BlastChunkNode*> nodes = getSupportChunkNodes(node); - res.insert(res.begin(), nodes.begin(), nodes.end()); - } - return res; -} - -const std::vector<BlastNode*>& _getAllChunkNodes(std::vector<BlastNode*>& res, BlastNode* curNode) -{ - if (nullptr == curNode) - return res; - if (eChunk == curNode->getType()) - { - res.push_back(static_cast<BlastNode*>(curNode)); - } - for (BlastNode* node : curNode->children) - { - _getAllChunkNodes(res, node); - } - - return res; -} - -std::vector<BlastChunkNode*> BlastTreeData::getSiblingChunkNodes(BlastChunkNode* node) -{ - std::vector<BlastChunkNode*> res; - - if (nullptr == node) - return res; - - BlastNode* parent = node->getParent(); - if (nullptr == parent || eChunk != parent->getType()) - { - return res; - } - - BlastChunkNode* chunkNodeParent = static_cast<BlastChunkNode*>(parent); - - for (BlastNode* child : chunkNodeParent->children) - { - if (eChunk == child->getType() && child != node) - res.push_back(static_cast<BlastChunkNode*>(child)); - } - return res; -} - -BlastChunkNode* BlastTreeData::getSupportAncestor(BlastChunkNode* node) -{ - if (nullptr == node) - return nullptr; - - BlastNode* parent = node->getParent(); - while (parent && eChunk == parent->getType()) - { - BlastChunkNode* chunkNodeParent = static_cast<BlastChunkNode*>(parent); - BPPChunk* bppChunk = (BPPChunk*)(chunkNodeParent->getData()); - if (bppChunk->support) - return chunkNodeParent; - parent = chunkNodeParent->getParent(); - } - - return nullptr; -} - -const std::vector<BlastNode*>& BlastTreeData::getAllChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node) -{ - return _getAllChunkNodes(res, node); -} - -const std::vector<BlastNode*>& BlastTreeData::getAllChunkNodes(std::vector<BlastNode*>& res) -{ - for (BlastAssetNode* node : _assets) - { - getAllChunkNodes(res, node); - } - return res; -} - -const std::vector<BlastNode*>& _getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastNode* curNode) -{ - if (nullptr == curNode) - return res; - if (eChunk == curNode->getType()) - { - if (BlastTreeData::isLeaf(dynamic_cast<BlastChunkNode*>(curNode))) - res.push_back(curNode); - } - for (BlastNode* node : curNode->children) - { - _getAllLeavesChunkNodes(res, node); - } - - return res; -} - -const std::vector<BlastNode*>& BlastTreeData::getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node) -{ - return _getAllLeavesChunkNodes(res, node); -} - -const std::vector<BlastNode*>& BlastTreeData::getAllLeavesChunkNodes(std::vector<BlastNode*>& res) -{ - for (BlastAssetNode* node : _assets) - { - getAllLeavesChunkNodes(res, node); - } - return res; -} - -// start from -1 because asset also takes one level. -const std::vector<BlastNode*>& _getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastNode* curNode, int depth, int currDepth = -1) -{ - if (nullptr == curNode) - return res; - if (eChunk == curNode->getType()) - { - if((currDepth == depth) || ((currDepth < depth) && BlastTreeData::isLeaf(dynamic_cast<BlastChunkNode*>(curNode)))) - res.push_back(curNode); - } - if (currDepth < depth) - { - for (BlastNode* node : curNode->children) - { - _getChunkNodesFullCoverage(res, node, depth, currDepth + 1); - } - } - - return res; -} - -const std::vector<BlastNode*>& BlastTreeData::getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastAssetNode* node, int depth) -{ - return _getChunkNodesFullCoverage(res, node, depth); -} - -const std::vector<BlastNode*>& BlastTreeData::getChunkNodesFullCoverage(std::vector<BlastNode*>& res, int depth) -{ - for (BlastAssetNode* node : _assets) - { - getChunkNodesFullCoverage(res, node, depth); - } - return res; -} - -bool isCompleteSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return false; - - if (node->isSupport()) - return true; - - const std::vector<BlastNode*>& children = node->children; - for (BlastNode* curNode : children) - { - if (eChunk == curNode->getType()) - { - BlastChunkNode* chunkNode = (BlastChunkNode*)curNode; - if (0 == chunkNode->children.size()) - { - if (!chunkNode->isSupport()) - return false; - } - - if (!isCompleteSupport(chunkNode)) - return false; - } - } - - return true; -} - -bool BlastTreeData::isCompleteSupportAsset(const BlastAsset* asset) -{ - BlastAssetNode* assetNode = _getAssetNode(asset); - return isCompleteSupportAsset(assetNode); -} - -bool BlastTreeData::isCompleteSupportAsset(const BlastAssetNode* node) -{ - if (node == nullptr) - return false; - - const std::vector<BlastNode*>& children = node->children; - for (BlastNode* curNode : children) - { - if (eChunk == curNode->getType()) - { - BlastChunkNode* chunkNode = (BlastChunkNode*)curNode; - if (!isCompleteSupport(chunkNode)) - return false; - } - } - - return true; -} - -bool BlastTreeData::isOverlapSupportAsset(const BlastAsset* asset) -{ - BlastAssetNode* assetNode = _getAssetNode(asset); - return isOverlapSupportAsset(assetNode); -} - -bool isOverlapSupport(BlastChunkNode* node) -{ - if (node == nullptr) - return false; - - bool isParentSupport = node->isSupport(); - - const std::vector<BlastNode*>& children = node->children; - for (BlastNode* curNode : children) - { - if (eChunk == curNode->getType()) - { - BlastChunkNode* chunkNode = (BlastChunkNode*)curNode; - if (0 == chunkNode->children.size()) - { - if (isParentSupport && chunkNode->isSupport()) - return true; - } - - if (isParentSupport && isOverlapSupport(chunkNode)) - return true; - } - } - - return false; -} - -bool BlastTreeData::isOverlapSupportAsset(const BlastAssetNode* node) -{ - if (node == nullptr) - return false; - - const std::vector<BlastNode*>& children = node->children; - for (BlastNode* curNode : children) - { - if (eChunk == curNode->getType()) - { - BlastChunkNode* chunkNode = (BlastChunkNode*)curNode; - if (isOverlapSupport(chunkNode)) - return true; - } - } - - return false; -} - -void BlastTreeData::traverse(BlastVisitorBase& visitor) -{ - for (BlastAssetNode* assetNode : _assets) - { - if (!visitor.continueTraversing()) - break; - - assetNode->traverse(visitor); - } -} - -BlastTreeData::BlastTreeData() -{ - _assetInstancesNode = new BlastAssetInstancesNode("BlastAssetInstances"); - - _blastProjectDataToNodeMap.clear(); -} - -void BlastTreeData::_addChunkNode(BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr) -{ - if (parentNode == nullptr) - { - return; - } - - std::vector<BPPBond*> bonds = BlastProject::ins().getBondsByChunk(asset, parentData.ID); - for (size_t i = 0; i < bonds.size(); ++i) - { - BPPBond* bond = bonds[i]; - BlastBondNode* bondNode = new BlastBondNode(bond->name.buf, *bond); - parentNode->children.push_back(bondNode); - bondNode->setParent(parentNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)bond, bondNode)); - } - - std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, parentData.ID); - for (size_t i = 0; i < childChunks.size(); ++i) - { - BPPChunk& chunk = *(childChunks[i]); - BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, assetPtr); - parentNode->children.push_back(chunkNode); - chunkNode->setParent(parentNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode)); - _addChunkNode(chunk, asset, chunkNode, assetPtr); - } -} - -void BlastTreeData::_removeChunkNode(BPPAsset& asset) -{ - std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset); - int childChunksSize = childChunks.size(); - for (size_t i = 0; i < childChunksSize; i++) - { - std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(childChunks[i]); - if (it == _blastProjectDataToNodeMap.end()) - { - continue; - } - - BlastNode* node = it->second; - _blastProjectDataToNodeMap.erase(it); - delete node; - } - - std::vector<BPPBond*> childBonds = BlastProject::ins().getChildrenBonds(asset); - int childBondsSize = childBonds.size(); - for (size_t i = 0; i < childBondsSize; i++) - { - std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(childBonds[i]); - if (it == _blastProjectDataToNodeMap.end()) - { - continue; - } - - BlastNode* node = it->second; - _blastProjectDataToNodeMap.erase(it); - delete node; - } -} - -void freeChunkNode(BlastChunkNode* chunkNode) -{ - if (chunkNode == nullptr) - return; - - std::vector<BlastNode*>& children = chunkNode->children; - for (size_t i = 0; i < children.size(); ++i) - { - BlastNode* node = children[i]; - if (node->getType() == eChunk) - freeChunkNode(static_cast<BlastChunkNode*>(node)); - else - { - delete node; - node = nullptr; - } - } - - delete chunkNode; - chunkNode = nullptr; -} - -void BlastTreeData::_freeBlastNode() -{ - if (_assetInstancesNode) - { - size_t count = _assetInstancesNode->children.size(); - for (size_t i = 0; i < count; ++i) - { - delete _assetInstancesNode->children[i]; - } - delete _assetInstancesNode; - _assetInstancesNode = nullptr; - } - - size_t count = _assets.size(); - for (size_t i = 0; i < count; ++i) - { - std::vector<BlastNode*>& children = _assets[i]->children; - for (size_t j = 0; j < children.size(); ++j) - { - freeChunkNode(static_cast<BlastChunkNode*>(children[j])); - } - delete _assets[i]; - } - _assets.clear(); - - count = _projectiles.size(); - for (size_t i = 0; i < count; ++i) - { - delete _projectiles[i]; - } - _projectiles.clear(); - - count = _graphicsMeshes.size(); - for (size_t i = 0; i < count; ++i) - { - delete _graphicsMeshes[i]; - } - _graphicsMeshes.clear(); - - _blastProjectDataToNodeMap.clear(); -} - -BlastAssetNode* BlastTreeData::_getAssetNode(const BlastAsset* asset) -{ - std::map<BlastAsset*, AssetList::ModelAsset>& assetDescMap = SampleManager::ins()->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itrAssetDesc = assetDescMap.find(const_cast<BlastAsset*>(asset)); - - BlastAssetNode* foundAssetNode = nullptr; - for (BlastAssetNode* assetNode : _assets) - { - if (itrAssetDesc->second.name == assetNode->name) - { - foundAssetNode = assetNode; - break; - } - } - - return foundAssetNode; -} - -QRect _getVisualIconArea(const QStyleOptionViewItem &option) -{ - int iconLen = option.rect.height() - 2; - return QRect(option.rect.right() - iconLen, option.rect.top() + 1, iconLen, iconLen); -} - -BlastTreeViewDelegate::BlastTreeViewDelegate(QObject* parent, QStandardItemModel* model) - : QStyledItemDelegate(parent) - , _treeModel(model) -{ - setObjectName("BlastTreeViewDelegate"); -} - -void BlastTreeViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - QStyledItemDelegate::paint(painter, option, index); - - QStandardItem *treeItem = _treeModel->itemFromIndex(index); - BlastSceneTree* tree = BlastSceneTree::ins(); - BlastNode* blastNode = tree->getBlastNodeByItem(treeItem); - PhysXSceneActor* projectileActor = tree->getProjectileActorByItem(treeItem); - - if ((nullptr == blastNode && nullptr == projectileActor)) - return; - - if(nullptr != blastNode && eChunk != blastNode->getType() && eBond != blastNode->getType()) - return; - - if (nullptr != blastNode) - painter->drawPixmap(_getVisualIconArea(option), blastNode->getVisible() ? sVisibleIcon : sInVisibleIcon); - else if (nullptr != projectileActor) - painter->drawPixmap(_getVisualIconArea(option), SampleManager::ins()->getSceneController().getProjectileVisible(projectileActor) ? sVisibleIcon : sInVisibleIcon); -} - -bool BlastTreeViewDelegate::editorEvent(QEvent* evt, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) -{ - if (evt->type() == QEvent::MouseButtonRelease) - { - QMouseEvent* mouseEvt = (QMouseEvent*)evt; - if (_getVisualIconArea(option).contains(mouseEvt->pos())) - { - QStandardItem *treeItem = _treeModel->itemFromIndex(index); - BlastSceneTree* tree = BlastSceneTree::ins(); - BlastNode* blastNode = tree->getBlastNodeByItem(treeItem); - PhysXSceneActor* projectileActor = tree->getProjectileActorByItem(treeItem); - - if ((nullptr == blastNode && nullptr == projectileActor)) - return QStyledItemDelegate::editorEvent(evt, model, option, index); - - if (nullptr != blastNode && eChunk != blastNode->getType() && eBond != blastNode->getType()) - return QStyledItemDelegate::editorEvent(evt, model, option, index); - - if (nullptr != blastNode) - { - blastNode->setVisible(!blastNode->getVisible()); - } - else if (nullptr != projectileActor) - { - SceneController& sceneController = SampleManager::ins()->getSceneController(); - sceneController.setProjectileVisible(projectileActor, !sceneController.getProjectileVisible(projectileActor)); - } - - BlastSceneTree::ins()->update(); - return true; - } - } - return QStyledItemDelegate::editorEvent(evt, model, option, index); -} - -bool BlastTreeViewDelegate::eventFilter(QObject* object, QEvent* event) -{ - return true; -} - -static BlastSceneTree* sBlastSceneTree = nullptr; -BlastSceneTree* BlastSceneTree::ins() -{ - return sBlastSceneTree; -} - -BlastSceneTree::BlastSceneTree(QWidget *parent) - : QDockWidget(parent) -{ - ui.setupUi(this); - _updateData = true; - sBlastSceneTree = this; - - sCompositeIcon = QIcon(":/AppMainWindow/images/AssetComposite.png"); - sAssetIcon = QIcon(":/AppMainWindow/images/Asset.png"); - sChunkUUIcon = QIcon(":/AppMainWindow/images/Chunk_Unsupport_Unstatic.png"); - sChunkSUIcon = QIcon(":/AppMainWindow/images/Chunk_Support_Unstatic.png"); - sChunkSSIcon = QIcon(":/AppMainWindow/images/Chunk_Support_Static.png"); - sBondIcon = QIcon(":/AppMainWindow/images/Bond.png"); - sProjectileIcon = QIcon(":/AppMainWindow/images/Projectile.png"); - - _treeModel = new QStandardItemModel(); - ui.blastSceneTree->setModel(_treeModel); - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(on_blastSceneTree_itemSelectionChanged(const QItemSelection&, const QItemSelection&))); - - BlastTreeViewDelegate* itemDelegate = new BlastTreeViewDelegate(ui.blastSceneTree, _treeModel); - ui.blastSceneTree->setItemDelegate((QAbstractItemDelegate*)itemDelegate); - - ui.blastSceneTree->setStyleSheet("QTreeView::item{height:24px}"); - ui.blastSceneTree->setContextMenuPolicy(Qt::CustomContextMenu); - - _treeContextMenu = new QMenu(this); - _makeSupportAction = new QAction(tr("Make Support"), this); - _treeContextMenu->addAction(_makeSupportAction); - connect(_makeSupportAction, SIGNAL(triggered()), this, SLOT(onMakeSupportMenuItemClicked())); - - _makeStaticSupportAction = new QAction(tr("Make Static Support"), this); - _treeContextMenu->addAction(_makeStaticSupportAction); - connect(_makeStaticSupportAction, SIGNAL(triggered()), this, SLOT(onMakeStaticSupportMenuItemClicked())); - - _removeSupportAction = new QAction(tr("Remove Support"), this); - _treeContextMenu->addAction(_removeSupportAction); - connect(_removeSupportAction, SIGNAL(triggered()), this, SLOT(onRemoveSupportMenuItemClicked())); - - _makeWorldAction = new QAction(tr("Make World"), this); - _treeContextMenu->addAction(_makeWorldAction); - connect(_makeWorldAction, SIGNAL(triggered()), this, SLOT(onMakeWorldMenuItemClicked())); - - _removeWorldAction = new QAction(tr("Remove World"), this); - _treeContextMenu->addAction(_removeWorldAction); - connect(_removeWorldAction, SIGNAL(triggered()), this, SLOT(onRemoveWorldMenuItemClicked())); - - //_bondChunksAction = new QAction(tr("Bond Chunks"), this); - //_treeContextMenu->addAction(_bondChunksAction); - //connect(_bondChunksAction, SIGNAL(triggered()), this, SLOT(onBondChunksMenuItemClicked())); - - - //_bondChunksWithJointsAction = new QAction(tr("Bond Chunks With Joints"), this); - //_treeContextMenu->addAction(_bondChunksWithJointsAction); - //connect(_bondChunksWithJointsAction, SIGNAL(triggered()), this, SLOT(onBondChunksWithJointsMenuItemClicked())); - - //_removeAllBondsAction = new QAction(tr("Remove All Bonds"), this); - //_treeContextMenu->addAction(_removeAllBondsAction); - //connect(_removeAllBondsAction, SIGNAL(triggered()), this, SLOT(onRemoveAllBondsMenuItemClicked())); - - QShortcut* shortCut; - shortCut = new QShortcut(QKeySequence("Alt+C"), this); - connect(shortCut, SIGNAL(activated()), this, SLOT(onCollapseExpandClicked())); - /* - BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode(); - _compositeTreeItem = new QStandardItem(); - _treeModel->appendRow(_compositeTreeItem); - _compositeTreeItem->setText(assetInstancesNode->name.c_str()); - _compositeTreeItem->setIcon(sCompositeIcon); - _treeItemDataMap.insert(_compositeTreeItem, assetInstancesNode); - _treeDataItemMap.insert(assetInstancesNode, _compositeTreeItem); - */ - - m_pNewBlastAsset = nullptr; - m_NewChunkIndexes.clear(); -} - -BlastSceneTree::~BlastSceneTree() -{ - -} - -void BlastSceneTree::updateValues(bool updataData) -{ - if (updataData) - { - BlastTreeData::ins().update(); - } - - std::map<BPPAssetInstance*, std::set<uint32_t>> selectChunks; - - SelectionToolController* m_selectionToolController = &SampleManager::ins()->getSelectionToolController(); - GizmoToolController* m_gizmoToolController = &SampleManager::ins()->getGizmoToolController(); - BlastController* m_blastController = &SampleManager::ins()->getBlastController(); - - if (m_selectionToolController->IsEnabled()) - { - std::set<PxActor*> actors = m_selectionToolController->getTargetActors(); - for (PxActor* actor : actors) - { - BlastFamily* pBlastFamily = m_blastController->getFamilyByPxActor(*actor); - if (pBlastFamily) - { - BPPAssetInstance* assetInstance = SampleManager::ins()->getInstanceByFamily(pBlastFamily); - uint32_t chunkIndex = pBlastFamily->getChunkIndexByPxActor(*actor); - selectChunks[assetInstance].insert(chunkIndex); - } - } - } - else if (m_gizmoToolController->IsEnabled()) - { - PxActor* actor = m_gizmoToolController->getTargetActor(); - - if (actor) - { - BlastFamily* pBlastFamily = m_blastController->getFamilyByPxActor(*actor); - if (pBlastFamily) - { - BPPAssetInstance* assetInstance = SampleManager::ins()->getInstanceByFamily(pBlastFamily); - uint32_t chunkIndex = pBlastFamily->getChunkIndexByPxActor(*actor); - selectChunks[assetInstance].insert(chunkIndex); - } - } - } - - _updateTreeUIs(); - - BlastSceneTreeDataLock lock; - std::set<PxActor*> actors; - for (std::map<BPPAssetInstance*, std::set<uint32_t>>::iterator itr = selectChunks.begin(); itr != selectChunks.end(); ++itr) - { - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(itr->first); - std::set<uint32_t>& chunkIndexes = itr->second; - - if (nullptr != family) - { - for (uint32_t chunkIndex : chunkIndexes) - { - PxActor* actor = nullptr; - family->getPxActorByChunkIndex(chunkIndex, &actor); - - if (actor) - actors.insert(actor); - } - } - } - - if (m_selectionToolController->IsEnabled()) - { - m_selectionToolController->setTargetActors(actors); - } - else if (m_gizmoToolController->IsEnabled()) - { - if (actors.size() > 0) - m_gizmoToolController->setTargetActor(*actors.begin()); - } -} - -void BlastSceneTree::clear() -{ - _treeModel->clear(); - _treeItemDataMap.clear(); - _treeDataItemMap.clear(); - - // notify no selection - std::vector<BlastNode*> nodes; - for (size_t i = 0; i < _observers.size(); ++i) - { - _observers[i]->dataSelected(nodes); - } -} - -void BlastSceneTree::dataSelected(std::vector<BlastNode*> selections) -{ - for (size_t i = 0; i < selections.size(); ++i) - { - selectTreeItem(selections[i]); - } -} - -void BlastSceneTree::addObserver(ISceneObserver* observer) -{ - std::vector<ISceneObserver*>::iterator itr = std::find(_observers.begin(), _observers.end(), observer); - if (itr == _observers.end()) - { - _observers.push_back(observer); - } -} - -void BlastSceneTree::removeObserver(ISceneObserver* observer) -{ - std::vector<ISceneObserver*>::iterator itr = std::find(_observers.begin(), _observers.end(), observer); - _observers.erase(itr); -} - -void BlastSceneTree::updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool visible) -{ - BlastNode* node = BlastTreeData::ins().getNodeByIndex(assetIndex, chunkIndex); - if (node != nullptr && eChunk == node->getType()) - { - static_cast<BlastChunkNode*>(node)->setVisible(visible); - } -} - -void BlastSceneTree::updateChunkItemSelection() -{ - _updateData = false; - - ui.blastSceneTree->clearSelection(); - BlastTreeData& treeData = BlastTreeData::ins(); - std::vector<BlastChunkNode*> chunkNodes; - - std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks(); - std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin(); - for (; itrAssetSelectedChunks != selectedChunks.end(); ++itrAssetSelectedChunks) - { - std::vector<BlastChunkNode*> aseetNodes = treeData.getChunkNodeByBlastChunk(itrAssetSelectedChunks->first, itrAssetSelectedChunks->second); - chunkNodes.insert(chunkNodes.end(), aseetNodes.begin(), aseetNodes.end()); - } - - for (BlastChunkNode* node : chunkNodes) - { - selectTreeItem(node, false); - } - - _updateData = true; -} - -void BlastSceneTree::makeSupport() -{ - std::vector<BlastChunkNode*> selectedChunkNodes; - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - - if (eChunk == itr.value()->getType()) - { - selectedChunkNodes.push_back((BlastChunkNode*)itr.value()); - } - } - - std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes); - std::set<BlastAsset*> assets; - for (BlastChunkNode* chunkNode : topChunkNodes) - { - if (chunkNode->isSupport() && !((BPPChunk*)chunkNode->getData())->staticFlag) - continue; - BlastTreeData::makeSupport(chunkNode); - BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode); - assets.insert(pBlastAsset); - } - - if (0 == assets.size()) - return; - - SampleManager* pSampleManager = SampleManager::ins(); - for (BlastAsset* asset : assets) - { - pSampleManager->refreshAsset(asset); - } - - return; -} - -void BlastSceneTree::makeStaticSupport() -{ - std::vector<BlastChunkNode*> selectedChunkNodes; - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - - if (eChunk == itr.value()->getType()) - { - selectedChunkNodes.push_back((BlastChunkNode*)itr.value()); - } - } - - std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes); - std::set<BlastAsset*> assets; - for (BlastChunkNode* chunkNode : topChunkNodes) - { - if (chunkNode->isSupport() && ((BPPChunk*)chunkNode->getData())->staticFlag) - continue; - BlastTreeData::makeStaticSupport(chunkNode); - BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode); - assets.insert(pBlastAsset); - } - - if (0 == assets.size()) - return; - - SampleManager* pSampleManager = SampleManager::ins(); - for (BlastAsset* asset : assets) - { - pSampleManager->refreshAsset(asset); - } - - return; -} - -void BlastSceneTree::removeSupport() -{ - std::vector<BlastChunkNode*> selectedChunkNodes; - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - - if (eChunk == itr.value()->getType()) - { - selectedChunkNodes.push_back((BlastChunkNode*)itr.value()); - } - } - - std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(selectedChunkNodes); - std::set<BlastAsset*> assets; - for (BlastChunkNode* chunkNode : topChunkNodes) - { - if (!chunkNode->isSupport() || BlastTreeData::isLeaf(chunkNode)) - continue; - BlastTreeData::removeSupport(chunkNode); - BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(chunkNode); - assets.insert(pBlastAsset); - } - - if (0 == assets.size()) - return; - - SampleManager* pSampleManager = SampleManager::ins(); - for (BlastAsset* asset : assets) - { - pSampleManager->refreshAsset(asset); - } - - return; -} - -void BlastSceneTree::makeWorld() -{ - std::vector<BlastBondNode*> selectedBondNodes; - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - - if (eBond == itr.value()->getType()) - { - selectedBondNodes.push_back((BlastBondNode*)itr.value()); - } - } - if (selectedBondNodes.size() == 0) - { - return; - } - - std::vector<BlastBondNode*>::iterator itSBN; - std::map<BlastAsset*, BlastAsset*> UniqueAssets; - for (itSBN = selectedBondNodes.begin(); itSBN != selectedBondNodes.end(); itSBN++) - { - BlastBondNode* node = *itSBN; - - BPPBond* bond = static_cast<BPPBond*>(node->getData()); - bond->toChunk = 0xFFFFFFFF; - - BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(node); - UniqueAssets[pBlastAsset] = pBlastAsset; - } - - - SampleManager* pSampleManager = SampleManager::ins(); - std::map<BlastAsset*, BlastAsset*>::iterator itUA; - for (itUA = UniqueAssets.begin(); itUA != UniqueAssets.end(); itUA++) - { - BlastAsset* pBlastAsset = itUA->second; - pSampleManager->refreshAsset(pBlastAsset); - } -} - -void BlastSceneTree::removeWorld() -{ - std::vector<BlastBondNode*> selectedBondNodes; - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - - if (eBond == itr.value()->getType()) - { - selectedBondNodes.push_back((BlastBondNode*)itr.value()); - } - } - if (selectedBondNodes.size() == 0) - { - return; - } - - std::vector<BlastBondNode*>::iterator itSBN; - std::map<BlastAsset*, BlastAsset*> UniqueAssets; - for (itSBN = selectedBondNodes.begin(); itSBN != selectedBondNodes.end(); itSBN++) - { - BlastBondNode* node = *itSBN; - - BPPBond* bond = static_cast<BPPBond*>(node->getData()); - bond->toChunk = 0xFFFFFFFF - 1; - - BlastAsset* pBlastAsset = BlastTreeData::ins().getAsset(node); - UniqueAssets[pBlastAsset] = pBlastAsset; - } - - - SampleManager* pSampleManager = SampleManager::ins(); - std::map<BlastAsset*, BlastAsset*>::iterator itUA; - for (itUA = UniqueAssets.begin(); itUA != UniqueAssets.end(); itUA++) - { - BlastAsset* pBlastAsset = itUA->second; - pSampleManager->refreshAsset(pBlastAsset); - } -} - -void BlastSceneTree::bondChunks() -{ - -} - -void BlastSceneTree::bondChunksWithJoints() -{ - -} - -void BlastSceneTree::removeAllBonds() -{ - -} - -void BlastSceneTree::setChunkSelected(std::vector<uint32_t> depths, bool selected) -{ - std::vector<BlastNode*> nodes = BlastTreeData::ins().getNodesByDepth(depths); - for (BlastNode* node : nodes) - { - if (eChunk == node->getType()) - { - static_cast<BlastChunkNode*>(node)->setSelected(selected); - selectTreeItem(node); - } - } -} - -void BlastSceneTree::setChunkVisible(std::vector<uint32_t> depths, bool bVisible) -{ - std::vector<BlastNode*> nodes = BlastTreeData::ins().getNodesByDepth(depths); - for (BlastNode* node : nodes) - { - if (eChunk == node->getType()) - { - static_cast<BlastChunkNode*>(node)->setVisible(bVisible); - } - } -} - -void BlastSceneTree::hideAllChunks() -{ - std::vector<BlastNode*> nodes; - BlastTreeData::ins().getAllChunkNodes(nodes); - for (BlastNode* node : nodes) - { - if (eChunk == node->getType()) - { - static_cast<BlastChunkNode*>(node)->setVisible(false); - } - } -} - -void BlastSceneTree::setChunkVisibleFullCoverage(int depth) -{ - std::vector<BlastNode*> nodes; - BlastTreeData::ins().getChunkNodesFullCoverage(nodes, depth); - for (BlastNode* node : nodes) - { - if (eChunk == node->getType()) - { - static_cast<BlastChunkNode*>(node)->setVisible(true); - } - } -} - -void BlastSceneTree::on_btnAsset_clicked() -{ - QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!"); -} - -void BlastSceneTree::on_assetComposite_clicked() -{ - QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!"); -} - -void BlastSceneTree::on_btnChunk_clicked() -{ - QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!"); -} - -void BlastSceneTree::on_btnBond_clicked() -{ - QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!"); -} - -void BlastSceneTree::on_btnProjectile_clicked() -{ - QMessageBox::information(NULL, "Blast Tool", "This feature isn't implemented currently!"); -} - -void BlastSceneTree::on_btnExpandCollapse_clicked() -{ - onCollapseExpandClicked(); -} - -void BlastSceneTree::on_blastSceneTree_customContextMenuRequested(const QPoint &pos) -{ - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - - std::vector<BlastChunkNode*> chunkNodes; - std::vector<BlastBondNode*> bondNodes; - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - if (itr != _treeItemDataMap.end()) - { - if (eChunk == itr.value()->getType()) - { - chunkNodes.push_back((BlastChunkNode*)itr.value()); - } - else if (eBond == itr.value()->getType()) - { - bondNodes.push_back((BlastBondNode*)itr.value()); - } - } - } - - { - std::vector<BlastChunkNode*> topChunkNodes = BlastTreeData::getTopChunkNodes(chunkNodes); - _makeSupportAction->setEnabled(true); - _makeStaticSupportAction->setEnabled(true); - _removeSupportAction->setEnabled(true); - _makeWorldAction->setEnabled(true); - _removeWorldAction->setEnabled(true); - - //select chunk nodes have parent child relation ship, disable all menu items - if (topChunkNodes.size() < chunkNodes.size()) - { - _makeSupportAction->setEnabled(false); - _makeStaticSupportAction->setEnabled(false); - _removeSupportAction->setEnabled(false); - } - else - { - bool allSupported = true, allStaticSupport = true, allUnSupported = true, hasLeaf = false; - - for (BlastChunkNode* chunkNode : chunkNodes) - { - BPPChunk* chunk = (BPPChunk*)(chunkNode->getData()); - if (chunk->support) - { - allUnSupported = false; - } - else - { - allSupported = false; - } - - if (!chunk->staticFlag) - { - allStaticSupport = false; - } - - if (BlastTreeData::isLeaf(chunkNode)) - { - hasLeaf = true; - } - } - - if (allSupported && !allStaticSupport) - { - _makeSupportAction->setEnabled(false); - } - - if (allStaticSupport) - { - _makeStaticSupportAction->setEnabled(false); - } - - if (allUnSupported || hasLeaf) - { - _removeSupportAction->setEnabled(false); - } - } - } - - if (chunkNodes.size() > 0 && bondNodes.size() > 0) - { - _makeSupportAction->setEnabled(false); - _makeStaticSupportAction->setEnabled(false); - _removeSupportAction->setEnabled(false); - _makeWorldAction->setEnabled(false); - _removeWorldAction->setEnabled(false); - } - else if (chunkNodes.size() > 0 && bondNodes.size() == 0) - { - _makeWorldAction->setEnabled(false); - _removeWorldAction->setEnabled(false); - } - else if (chunkNodes.size() == 0 && bondNodes.size() > 0) - { - _makeSupportAction->setEnabled(false); - _makeStaticSupportAction->setEnabled(false); - _removeSupportAction->setEnabled(false); - } - - if (0 < chunkNodes.size() || 0 < bondNodes.size()) - { - _treeContextMenu->exec(QCursor::pos()); - } - -} - -void BlastSceneTree::on_blastSceneTree_itemSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) -{ - if (!_updateData) - return; - - SampleManager::ins()->clearChunksSelected(); - - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); - - std::vector<BlastNode*> nodes; - for (int i = 0; i < selectedIndexes.count(); ++i) - { - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(_treeModel->itemFromIndex(selectedIndexes.at(i))); - if (itr != _treeItemDataMap.end()) - { - nodes.push_back(itr.value()); - - BlastNode* node = itr.value(); - if (eChunk == node->getType()) - { - ((BlastChunkNode*)node)->setSelected(true); - - if (BlastTreeData::isRoot((BlastChunkNode*)node)) - { - std::vector<BlastAssetInstanceNode*> instanceNodes = BlastTreeData::ins().getAssetInstanceNodes((BlastChunkNode*)node); - for (BlastAssetInstanceNode* instanceNode : instanceNodes) - { - selectTreeItem(instanceNode, false); - nodes.push_back(instanceNode); - } - } - } - else if (eAssetInstance == node->getType()) - { - ((BlastAssetInstanceNode*)node)->setSelected(true); - - BlastSceneTreeDataLock lock; - std::vector<BlastChunkNode*> chunkNodes = BlastTreeData::ins().getRootChunkNodeByInstance((BlastAssetInstanceNode*)node); - for (BlastChunkNode* chunkNode : chunkNodes) - { - selectTreeItem(chunkNode, false); - nodes.push_back(chunkNode); - } - } - else if (eAsset == node->getType()) - { - ((BlastAssetNode*)node)->setSelected(true); - } - } - } - - for (size_t i = 0; i < _observers.size(); ++i) - { - _observers[i]->dataSelected(nodes); - } -} - -void BlastSceneTree::onMakeSupportMenuItemClicked() -{ - makeSupport(); -} - -void BlastSceneTree::onMakeStaticSupportMenuItemClicked() -{ - makeStaticSupport(); -} - -void BlastSceneTree::onRemoveSupportMenuItemClicked() -{ - removeSupport(); -} - -void BlastSceneTree::onMakeWorldMenuItemClicked() -{ - makeWorld(); -} - -void BlastSceneTree::onRemoveWorldMenuItemClicked() -{ - removeWorld(); -} - -void BlastSceneTree::onBondChunksMenuItemClicked() -{ - bondChunks(); -} - -void BlastSceneTree::onBondChunksWithJointsMenuItemClicked() -{ - bondChunksWithJoints(); -} - -void BlastSceneTree::onRemoveAllBondsMenuItemClicked() -{ - removeAllBonds(); -} - -void BlastSceneTree::onCollapseExpandClicked() -{ - static bool expand = true; - if (expand) - { - ui.blastSceneTree->collapseAll(); - expand = false; - } - else - { - ui.blastSceneTree->expandAll(); - expand = true; - } -} - -void BlastSceneTree::_updateTreeUIs() -{ -#ifdef _DEBUG - static int gcounter = 0; - static char gbuf[128]; - sprintf(gbuf, "_updateTreeUIs called %d", ++gcounter); - viewer_msg(gbuf); -#endif - //ui.blastSceneTree->setUpdatesEnabled(false); - _treeModel->clear(); - _treeItemDataMap.clear(); - _treeDataItemMap.clear(); - - BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode(); - if (assetInstancesNode != nullptr) - { - QStandardItem* compositeTreeItem = new QStandardItem(); - compositeTreeItem->setText(assetInstancesNode->name.c_str()); - compositeTreeItem->setIcon(sCompositeIcon); - _treeItemDataMap.insert(compositeTreeItem, assetInstancesNode); - _treeDataItemMap.insert(assetInstancesNode, compositeTreeItem); - _treeModel->appendRow(compositeTreeItem); - size_t count = assetInstancesNode->children.size(); - for (size_t i = 0; i < count; ++i) - { - BlastNode* assetInstanceNode = assetInstancesNode->children[i]; - QStandardItem* assetInstanceItem = new QStandardItem(); - compositeTreeItem->appendRow(assetInstanceItem); - assetInstanceItem->setText(assetInstanceNode->name.c_str()); - if (assetInstanceNode->getType() == eAssetInstance) - assetInstanceItem->setIcon(QIcon(":/AppMainWindow/images/Asset.png")); - _treeItemDataMap.insert(assetInstanceItem, assetInstanceNode); - _treeDataItemMap.insert(assetInstanceNode, assetInstanceItem); - } - } - - std::vector<BlastAssetNode*>& assets = BlastTreeData::ins().getAssetNodes(); - size_t count = assets.size(); - for (size_t i = 0; i < count; ++i) - { - BlastAssetNode* assetNode = assets[i]; - - QStandardItem* assetTreeWidgetItem = new QStandardItem(); - _treeModel->appendRow(assetTreeWidgetItem); - assetTreeWidgetItem->setText(assetNode->name.c_str()); - assetTreeWidgetItem->setIcon(sAssetIcon); - _treeItemDataMap.insert(assetTreeWidgetItem, assetNode); - _treeDataItemMap.insert(assetNode, assetTreeWidgetItem); - - _addChunkUI(assetNode, assetTreeWidgetItem); - } - - std::vector<BlastProjectileNode*>& projectiles = BlastTreeData::ins().getProjectileNodes(); - count = projectiles.size(); - for (int i = 0; i < count; ++i) - { - BlastProjectileNode* projectileNode = projectiles[i]; - - QStandardItem* projectileTreeItem = new QStandardItem(); - _treeModel->appendRow(projectileTreeItem); - projectileTreeItem->setText(projectileNode->name.c_str()); - projectileTreeItem->setIcon(sProjectileIcon); - _treeItemDataMap.insert(projectileTreeItem, projectileNode); - _treeDataItemMap.insert(projectileNode, projectileTreeItem); - } - - std::vector<BlastGraphicsMeshNode*>& graphicsMeshes = BlastTreeData::ins().getGraphicsMeshNodes(); - count = graphicsMeshes.size(); - for (int i = 0; i < count; ++i) - { - BlastGraphicsMeshNode* graphicsMesheNode = graphicsMeshes[i]; - - QStandardItem* graphicsMesheTreeWidgetItem = new QStandardItem(); - _treeModel->appendRow(graphicsMesheTreeWidgetItem); - graphicsMesheTreeWidgetItem->setText(graphicsMesheNode->name.c_str()); - _treeItemDataMap.insert(graphicsMesheTreeWidgetItem, graphicsMesheNode); - _treeDataItemMap.insert(graphicsMesheNode, graphicsMesheTreeWidgetItem); - } - - ui.blastSceneTree->expandAll(); - - // notify no selection - //std::vector<BlastNode*> nodes; - //for (size_t i = 0; i < _observers.size(); ++i) - //{ - // _observers[i]->dataSelected(nodes); - //} - - bool autoSelectNewChunks = BlastProject::ins().getParams().fracture.general.autoSelectNewChunks; - if (!autoSelectNewChunks) - { - m_pNewBlastAsset = nullptr; - m_NewChunkIndexes.clear(); - return; - } - - if (m_pNewBlastAsset == nullptr || m_NewChunkIndexes.size() == 0) - { - return; - } - - _updateData = false; - ui.blastSceneTree->clearSelection(); - std::vector<BlastChunkNode*> chunkNodes = - BlastTreeData::ins().getChunkNodeByBlastChunk(m_pNewBlastAsset, m_NewChunkIndexes); - for (BlastChunkNode* node : chunkNodes) - { - node->setVisible(true); - selectTreeItem(node); - } - - m_pNewBlastAsset = nullptr; - m_NewChunkIndexes.clear(); - - _updateData = true; -} - -void BlastSceneTree::_addChunkUI(const BlastNode* parentNode, QStandardItem* parentTreeItem) -{ - if (parentNode != nullptr && parentTreeItem != nullptr) - { - for (size_t i = 0; i < parentNode->children.size(); ++i) - { - BlastNode* node = parentNode->children[i]; - if (node == nullptr) - continue; - - QStandardItem* treeWidgetItem = new QStandardItem(); - parentTreeItem->appendRow(treeWidgetItem); - - if (node->getType() == eChunk) - { - BlastChunkNode* chunkNode = static_cast<BlastChunkNode*>(node); - treeWidgetItem->setText(chunkNode->name.c_str()); - - BPPChunk* chunk = static_cast<BPPChunk*>(chunkNode->getData()); - if (!chunk->support) - { - treeWidgetItem->setIcon(sChunkUUIcon); - } - else if (chunk->support && !chunk->staticFlag) - { - treeWidgetItem->setIcon(sChunkSUIcon); - } - else if (chunk->support && chunk->staticFlag) - { - treeWidgetItem->setIcon(sChunkSSIcon); - } - - _addChunkUI(chunkNode, treeWidgetItem); - } - else if (node->getType() == eBond) - { - BlastBondNode* bond = static_cast<BlastBondNode*>(node); - treeWidgetItem->setIcon(sBondIcon); - treeWidgetItem->setText(bond->name.c_str()); - } - - if (treeWidgetItem == nullptr) - continue; - - _treeItemDataMap.insert(treeWidgetItem, node); - _treeDataItemMap.insert(node, treeWidgetItem); - } - } -} - -void BlastSceneTree::_updateChunkTreeItemAndMenu(BPPChunk* chunk, QStandardItem* chunkItem) -{ - assert(chunk != nullptr); - - _removeSupportAction->setEnabled(true); - _makeSupportAction->setEnabled(true); - _makeStaticSupportAction->setEnabled(true); - - if (!chunk->support && !chunk->staticFlag) - { - _removeSupportAction->setEnabled(false); - chunkItem->setIcon(sChunkUUIcon); - } - else if (chunk->support && !chunk->staticFlag) - { - _makeSupportAction->setEnabled(false); - chunkItem->setIcon(sChunkSUIcon); - } - else if (chunk->support && chunk->staticFlag) - { - _makeStaticSupportAction->setEnabled(false); - chunkItem->setIcon(sChunkSSIcon); - } -} - -void BlastSceneTree::_updateChunkTreeItems() -{ - for (QMap<BlastNode*, QStandardItem*>::iterator itr = _treeDataItemMap.begin(); itr != _treeDataItemMap.end(); ++itr) - { - BlastNode* node = itr.key(); - QStandardItem* treeItem = itr.value(); - if (eChunk == node->getType()) - { - BPPChunk* chunk = static_cast<BPPChunk*>(node->getData()); - if (!chunk->support) - { - treeItem->setIcon(sChunkUUIcon); - } - else if (chunk->support && !chunk->staticFlag) - { - treeItem->setIcon(sChunkSUIcon); - } - else if (chunk->support && chunk->staticFlag) - { - treeItem->setIcon(sChunkSSIcon); - } - } - } -} - -void BlastSceneTree::ApplyAutoSelectNewChunks(BlastAsset* pNewBlastAsset, std::vector<uint32_t>& NewChunkIndexes) -{ - if (pNewBlastAsset == nullptr || NewChunkIndexes.size() == 0) - { - return; - } - - m_pNewBlastAsset = pNewBlastAsset; - m_NewChunkIndexes.clear(); - for (uint32_t nci : NewChunkIndexes) - { - m_NewChunkIndexes.push_back(nci); - } -} - -/* -BlastAssetNode* BlastTreeData::addBlastAsset(BPPAsset& asset) -{ - BlastAsset* pBlastAsset = nullptr; - SampleManager* pSampleManager = SampleManager::ins(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator it; - for (it = AssetDescMap.begin(); it != AssetDescMap.end(); it++) - { - std::string assetname = asset.name.buf; - if (it->second.name == assetname) - { - pBlastAsset = it->first; - } - } - - BlastAssetNode* assetNode = new BlastAssetNode(asset.name.buf, asset); - _assets.push_back(assetNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&asset, assetNode)); - - std::vector<BPPChunk*> childChunks = BlastProject::ins().getChildrenChunks(asset, -1); - int childChunksSize = childChunks.size(); - for (size_t i = 0; i < childChunksSize; ++i) - { - BPPChunk& chunk = *(childChunks[i]); - BlastChunkNode* chunkNode = new BlastChunkNode(chunk.name.buf, chunk, pBlastAsset); - assetNode->children.push_back(chunkNode); - chunkNode->setParent(assetNode); - _blastProjectDataToNodeMap.insert(std::make_pair((void*)&chunk, chunkNode)); - - _addChunkNode(chunk, asset, chunkNode, pBlastAsset); - } - - return assetNode; -} - -void BlastTreeData::removeBlastAsset(BPPAsset& asset) -{ - _removeChunkNode(asset); - - std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(&asset); - if (it == _blastProjectDataToNodeMap.end()) - { - return; - } - - BlastNode* node = it->second; - _blastProjectDataToNodeMap.erase(it); - std::vector<BlastAssetNode*>::iterator itAsset; - for (itAsset = _assets.begin(); itAsset != _assets.end(); itAsset++) - { - if (node == *itAsset) - { - _assets.erase(itAsset); - break; - } - } - - delete node; -} - -BlastAssetInstanceNode* BlastTreeData::addBlastInstance(BPPAssetInstance& instance) -{ - BlastAssetInstanceNode* blastAssetInstanceNode = new BlastAssetInstanceNode(instance.name.buf, instance); - _assetInstancesNode->children.push_back(blastAssetInstanceNode); - blastAssetInstanceNode->setParent(_assetInstancesNode); - void* pointer = (void*)&instance; - _blastProjectDataToNodeMap.insert(std::make_pair(pointer, blastAssetInstanceNode)); - return blastAssetInstanceNode; -} - -void BlastTreeData::removeBlastInstance(BPPAssetInstance& instance) -{ - void* pointer = (void*)&instance; - std::map<void*, BlastNode*>::iterator it = _blastProjectDataToNodeMap.find(pointer); - if (it == _blastProjectDataToNodeMap.end()) - { - return; - } - - BlastNode* node = it->second; - _blastProjectDataToNodeMap.erase(it); - delete node; - - int count = _assetInstancesNode->children.size(); - for (int i = count - 1; i >= 0; --i) - { - BlastNode* pBN = _assetInstancesNode->children[i]; - if (pBN == node) - { - _assetInstancesNode->children.erase(_assetInstancesNode->children.begin() + i); - } - else - { - BlastAssetInstanceNode* blastAssetInstanceNode = dynamic_cast<BlastAssetInstanceNode*>(_assetInstancesNode->children[i]); - if (blastAssetInstanceNode && blastAssetInstanceNode->getData() == &instance) - { - _assetInstancesNode->children.erase(_assetInstancesNode->children.begin() + i); - } - } - } -} - -BlastProjectileNode* BlastTreeData::addProjectile(PhysXSceneActor* projectile) -{ - SceneController& sceneController = SampleManager::ins()->getSceneController(); - BlastProjectileNode* projectileNode = new BlastProjectileNode(sceneController.getProjectileName(projectile), projectile); - _projectiles.push_back(projectileNode); - return projectileNode; -} - -void BlastTreeData::clearProjectile() -{ - std::vector<BlastProjectileNode*>::iterator it; - for (it = _projectiles.begin(); it != _projectiles.end(); it++) - { - delete *it; - } - _projectiles.clear(); -} - -void BlastTreeData::refreshProjectDataToNodeMap(std::map<BPPAsset*, BPPAsset*>& changeMap) -{ - std::map<BPPAsset*, BPPAsset*>::iterator it; - std::map<void*, BlastNode*>::iterator itNode; - for (it = changeMap.begin(); it != changeMap.end(); it++) - { - itNode = _blastProjectDataToNodeMap.find(it->first); - if (itNode == _blastProjectDataToNodeMap.end()) - { - continue; - } - - BlastNode* node = itNode->second; - _blastProjectDataToNodeMap.erase(itNode); - _blastProjectDataToNodeMap[it->second] = node; - } -} - -void BlastTreeData::refreshProjectDataToNodeMap(std::map<BPPAssetInstance*, BPPAssetInstance*>& changeMap) -{ - std::map<BPPAssetInstance*, BPPAssetInstance*>::iterator it; - std::map<void*, BlastNode*>::iterator itNode; - for (it = changeMap.begin(); it != changeMap.end(); it++) - { - itNode = _blastProjectDataToNodeMap.find(it->first); - if (itNode == _blastProjectDataToNodeMap.end()) - { - continue; - } - - BlastNode* node = itNode->second; - _blastProjectDataToNodeMap.erase(itNode); - _blastProjectDataToNodeMap[it->second] = node; - node->setData(it->second); - } -} - -void BlastSceneTree::addBlastAsset(BPPAsset& asset) -{ - BlastAssetNode* assetNode = BlastTreeData::ins().addBlastAsset(asset); - if (assetNode == nullptr) - { - return; - } - - QStandardItem* assetTreeWidgetItem = new QStandardItem(); - _treeModel->appendRow(assetTreeWidgetItem); - assetTreeWidgetItem->setText(assetNode->name.c_str()); - assetTreeWidgetItem->setIcon(sAssetIcon); - _treeItemDataMap.insert(assetTreeWidgetItem, assetNode); - _treeDataItemMap.insert(assetNode, assetTreeWidgetItem); - - _addChunkUI(assetNode, assetTreeWidgetItem); - - ui.blastSceneTree->expandAll(); -} - -void BlastSceneTree::removeBlastAsset(BPPAsset& asset) -{ - BlastNode* node = BlastTreeData::ins().getBlastNodeByProjectData(&asset); - - QMap<BlastNode*, QStandardItem*>::iterator it = _treeDataItemMap.find(node); - if (it != _treeDataItemMap.end()) - { - QStandardItem* item = it.value(); - - if (item != nullptr) - { - _treeModel->removeRow(_treeModel->indexFromItem(item).row()); - ui.blastSceneTree->expandAll(); - } - } - - BlastTreeData::ins().removeBlastAsset(asset); -} - -void BlastSceneTree::addBlastInstance(BPPAssetInstance& instance) -{ - BlastAssetInstanceNode* assetInstanceNode = BlastTreeData::ins().addBlastInstance(instance); - if (assetInstanceNode == nullptr) - { - return; - } - - QStandardItem* assetInstanceItem = new QStandardItem(); - _compositeTreeItem->appendRow(assetInstanceItem); - assetInstanceItem->setText(assetInstanceNode->name.c_str()); - if (assetInstanceNode->getType() == eAssetInstance) - assetInstanceItem->setIcon(sAssetIcon); - _treeItemDataMap.insert(assetInstanceItem, assetInstanceNode); - _treeDataItemMap.insert(assetInstanceNode, assetInstanceItem); - - ui.blastSceneTree->expandAll(); -} - -void BlastSceneTree::removeBlastInstance(BPPAssetInstance& instance) -{ - BlastNode* node = BlastTreeData::ins().getBlastNodeByProjectData(&instance); - - QMap<BlastNode*, QStandardItem*>::iterator it = _treeDataItemMap.find(node); - if (it != _treeDataItemMap.end()) - { - QStandardItem* item = it.value(); - - if (item != nullptr) - { - _compositeTreeItem->removeRow(_treeModel->indexFromItem(_compositeTreeItem).row()); - ui.blastSceneTree->expandAll(); - } - } - - BlastTreeData::ins().removeBlastInstance(instance); -} - -void BlastSceneTree::removeBlastInstances(BPPAsset& asset) -{ - std::vector<BPPAssetInstance*> instances; - BlastProject::ins().getAssetInstances(asset.ID, instances); - - std::vector<BPPAssetInstance*>::iterator it; - for (it = instances.begin(); it != instances.end(); it++) - { - removeBlastInstance(**it); - BlastTreeData::ins().removeBlastInstance(**it); - } -} - -void BlastSceneTree::addProjectile(PhysXSceneActor* projectile) -{ - BlastProjectileNode* projectileNode = BlastTreeData::ins().addProjectile(projectile); - if (projectileNode == nullptr) - { - return; - } - - QStandardItem* projectileTreeItem = new QStandardItem(); - projectileTreeItem->setText(projectileNode->name.c_str()); - projectileTreeItem->setIcon(sProjectileIcon); - _treeModel->appendRow(projectileTreeItem); - _projectileItemActorMap[projectileTreeItem] = projectile;; -} - -void BlastSceneTree::clearProjectile() -{ - QMap<QStandardItem*, PhysXSceneActor*>::iterator it; - for (it =_projectileItemActorMap.begin(); it != _projectileItemActorMap.end(); it++) - { - _treeModel->removeRow(_treeModel->indexFromItem(it.key()).row()); - } - _projectileItemActorMap.clear(); - - BlastTreeData::ins().clearProjectile(); -} -*/ -BlastNode* BlastSceneTree::getBlastNodeByItem(QStandardItem* item) -{ - QMap<QStandardItem*, BlastNode*>::iterator itr = _treeItemDataMap.find(item); - if (itr == _treeItemDataMap.end()) - return nullptr; - - return itr.value(); -} - -PhysXSceneActor* BlastSceneTree::getProjectileActorByItem(QStandardItem* item) -{ - QMap<QStandardItem*, PhysXSceneActor*>::iterator itr = _projectileItemActorMap.find(item); - if (itr == _projectileItemActorMap.end()) - return nullptr; - - return itr.value(); -} - -void BlastSceneTree::selectTreeItem(BlastNode* node, bool updateData) -{ - _updateData = updateData; - QMap<BlastNode*, QStandardItem*>::iterator itr = _treeDataItemMap.find(node); - if (itr != _treeDataItemMap.end()) - { - QItemSelectionModel* selectionModel = ui.blastSceneTree->selectionModel(); - selectionModel->select(_treeModel->indexFromItem(itr.value()), QItemSelectionModel::Select); - } - - _updateData = true; -} - -void BlastSceneTree::selectTreeItem(BlastFamily* family) -{ - BlastAssetInstanceNode* instanceNode = BlastTreeData::ins().getAssetInstanceNode(family); - selectTreeItem(instanceNode, false); -}
\ No newline at end of file diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h b/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h deleted file mode 100644 index 423c2b7..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/BlastSceneTree.h +++ /dev/null @@ -1,389 +0,0 @@ -#ifndef BLASTSCENETREE_H -#define BLASTSCENETREE_H - -#include <QtWidgets/QDockWidget> -#include "ui_BlastSceneTree.h" -#include "ProjectParams.h" -#include <vector> -#include <string> -#include <QtCore/QMap> -#include <QtGui/QStandardItemModel> -#include <QtWidgets/QStyledItemDelegate> - -class QTreeWidgetItem; -class BlastAsset; -class PhysXSceneActor; -class BlastNode; -class BlastFamily; - -enum EBlastNodeType -{ - eBond, - eChunk, - eAsset, - eProjectile, - eGraphicsMesh, - eAssetInstance, - eAssetInstances, -}; - -class BlastVisitorBase -{ -public: - BlastVisitorBase() : _continueTraversing(true) - { - } - - virtual void visit(BlastNode *pNode) { return; } - inline bool continueTraversing(void) const { return _continueTraversing; } - -protected: - bool _continueTraversing; -}; - -class BlastNode -{ -public: - BlastNode(const std::string& inName, void* inData) - : name(inName) - , _data(inData) - , _parent(nullptr) - { - } - - virtual ~BlastNode() - { - } - - inline void* getData() { return _data; } - void setParent(BlastNode* parent) { _parent = parent; } - BlastNode* getParent() { return _parent; } - void traverse(BlastVisitorBase& visitor); - - virtual EBlastNodeType getType() = 0; - virtual bool getVisible() = 0; - virtual void setVisible(bool val) = 0; - - std::string name; - std::vector<BlastNode*> children; - -protected: - inline void setData(void* data) { _data = data; } - -private: - void* _data; - BlastNode* _parent; -}; - -class BlastBondNode : public BlastNode -{ -public: - BlastBondNode(const std::string& inName, BPPBond& inData) - : BlastNode(inName, &inData) - { - } - virtual EBlastNodeType getType() { return eBond; } - virtual bool getVisible() { return ((BPPBond*)getData())->visible; } - virtual void setVisible(bool val) { ((BPPBond*)getData())->visible = val; } - bool isWolrd() { return ((BPPBond*)getData())->toChunk == 0xFFFFFFFF; } - -private: - std::vector<BlastNode*> children; -}; - -class BlastChunkNode : public BlastNode -{ -public: - BlastChunkNode(const std::string& inName, BPPChunk& inData, void* assetPtr) - : BlastNode(inName, &inData) - { - _assetPtr = assetPtr; - } - virtual EBlastNodeType getType() { return eChunk; } - virtual bool getVisible() { return ((BPPChunk*)getData())->visible; } - virtual void setVisible(bool val);// { ((BPPChunk*)getData())->visible = val; } - void setSelected(bool val); - bool isSupport() { return ((BPPChunk*)getData())->support; } - bool isStatic() { return ((BPPChunk*)getData())->staticFlag; } - void* _assetPtr; -}; - -class BlastAssetNode : public BlastNode -{ -public: - BlastAssetNode(const std::string& inName, BPPAsset& inData) - : BlastNode(inName, &inData) - { - } - virtual EBlastNodeType getType() { return eAsset; } - virtual bool getVisible() { return ((BPPAsset*)getData())->visible; } - virtual void setVisible(bool val) { ((BPPAsset*)getData())->visible = val; } - void setSelected(bool val); -}; - -class BlastProjectileNode : public BlastNode -{ -public: - BlastProjectileNode(const std::string& inName, PhysXSceneActor* inData) - : BlastNode(inName, inData) - { - } - virtual EBlastNodeType getType() { return eProjectile; } - virtual bool getVisible(); - virtual void setVisible(bool val); -}; - -class BlastGraphicsMeshNode : public BlastNode -{ -public: - BlastGraphicsMeshNode(const std::string& inName, BPPGraphicsMesh& inData) - : BlastNode(inName, &inData) - { - } - virtual EBlastNodeType getType() { return eGraphicsMesh; } - virtual bool getVisible() { return true; } - virtual void setVisible(bool val) { } -}; - -class BlastAssetInstanceNode : public BlastNode -{ -public: - BlastAssetInstanceNode(const std::string& inName, BPPAssetInstance& inData) - : BlastNode(inName, &inData) - { - } - ~BlastAssetInstanceNode() - { - } - virtual EBlastNodeType getType() { return eAssetInstance; } - virtual bool getVisible() { return ((BPPAssetInstance*)getData())->visible; } - virtual void setVisible(bool val) { ((BPPAssetInstance*)getData())->visible = val; } - void setSelected(bool val); -}; - -class BlastAssetInstancesNode : public BlastNode -{ -public: - BlastAssetInstancesNode(const std::string& inName) - : BlastNode(inName, nullptr) - { - } - virtual EBlastNodeType getType() { return eAssetInstances; } - virtual bool getVisible() { return true; } - virtual void setVisible(bool val) { return; } -}; - -class BlastTreeData -{ -public: - static BlastTreeData& ins(); - static bool isChild(BlastChunkNode* parent, BlastChunkNode* child); - static std::vector<BlastChunkNode*> getTopChunkNodes(std::vector<BlastChunkNode*>& nodes); - static int getDepth(BlastNode* node);// if node is not a chunk or bond, then depth is -1. - static bool isRoot(BlastChunkNode* node); - static bool isLeaf(BlastChunkNode* node); - static void makeSupport(BlastChunkNode* node); - static void makeStaticSupport(BlastChunkNode* node); - static void removeSupport(BlastChunkNode* node); - static std::string getAssetName(BlastAsset* asset); - static BlastAsset* getAsset(std::string assetName); - - BlastNode* getBlastNodeByProjectData(void* blastProjectData); - BlastAssetInstancesNode* getBlastAssetInstancesNode() { return _assetInstancesNode; } - std::vector<BlastAssetNode*>& getAssetNodes() { return _assets; } - BlastAsset* getAsset(BlastNode* node); - BlastAssetNode* getAssetNode(BlastAsset* asset); - std::vector<BlastProjectileNode*>& getProjectileNodes() { return _projectiles; } - std::vector<BlastGraphicsMeshNode*>& getGraphicsMeshNodes() { return _graphicsMeshes; } - std::vector<BlastChunkNode*> getChunkNodeByBlastChunk(const BlastAsset* asset, const std::vector<uint32_t>& chunkIndexes); - std::vector<BlastChunkNode*> getRootChunkNodeByInstance(const BlastAssetInstanceNode* node); - std::vector<BlastNode*> getNodesByDepth(BlastAssetNode* node, uint32_t depth); - std::vector<BlastNode*> getNodesByDepth(uint32_t depth); - std::vector<BlastNode*> getNodesByDepth(std::vector<uint32_t> depths); - BlastNode* getNodeByIndex(uint32_t assetIndex, uint32_t chunkIndex); - std::vector<BlastChunkNode*> getSupportChunkNodes(BlastAssetNode* node); - std::vector<BlastChunkNode*> getSupportChunkNodes(); - std::vector<BlastChunkNode*> getSiblingChunkNodes(BlastChunkNode* node); - BlastChunkNode* getSupportAncestor(BlastChunkNode* node); - const std::vector<BlastNode*>& getAllChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node); - const std::vector<BlastNode*>& getAllChunkNodes(std::vector<BlastNode*>& res); - const std::vector<BlastNode*>& getAllLeavesChunkNodes(std::vector<BlastNode*>& res, BlastAssetNode* node); - const std::vector<BlastNode*>& getAllLeavesChunkNodes(std::vector<BlastNode*>& res); - const std::vector<BlastNode*>& getChunkNodesFullCoverage(std::vector<BlastNode*>& res, BlastAssetNode* node, int depth); - const std::vector<BlastNode*>& getChunkNodesFullCoverage(std::vector<BlastNode*>& res, int depth); - - bool isCompleteSupportAsset(const BlastAsset* asset); - bool isCompleteSupportAsset(const BlastAssetNode* node); - bool isOverlapSupportAsset(const BlastAsset* asset); - bool isOverlapSupportAsset(const BlastAssetNode* node); - - BlastAssetNode* addAsset(const BlastAsset* asset); - BlastAssetInstanceNode* addAssetInstance(const BlastAsset* asset); - void remove(const BlastAssetNode* node); - void remove(const BlastAssetInstanceNode* node); - BlastAssetInstanceNode* getAssetInstanceNode(BlastFamily* family); - BlastAssetInstanceNode* getAssetInstanceNode(BPPAssetInstance* instance); - std::vector<BlastAssetInstanceNode*> getAssetInstanceNodes(BlastChunkNode* chunkNode); - - void update(); - void update(const BlastAsset* asset); - /* - BlastAssetNode* addBlastAsset(BPPAsset& asset); - void removeBlastAsset(BPPAsset& asset); - - BlastAssetInstanceNode* addBlastInstance(BPPAssetInstance& instance); - void removeBlastInstance(BPPAssetInstance& instance); - - BlastProjectileNode* addProjectile(PhysXSceneActor* projectile); - void clearProjectile(); - - void refreshProjectDataToNodeMap(std::map<BPPAsset*, BPPAsset*>& changeMap); - void refreshProjectDataToNodeMap(std::map<BPPAssetInstance*, BPPAssetInstance*>& changeMap); - */ - - void traverse(BlastVisitorBase& visitor); - -private: - BlastTreeData(); - void _addChunkNode(BPPChunk& parentData, BPPAsset& asset, BlastChunkNode* parentNode, void* assetPtr); - void _removeChunkNode(BPPAsset& asset); - void _freeBlastNode(); - BlastAssetNode* _getAssetNode(const BlastAsset* asset); - -private: - BlastAssetInstancesNode* _assetInstancesNode; - std::vector<BlastAssetNode*> _assets; - std::vector<BlastProjectileNode*> _projectiles; - std::vector<BlastGraphicsMeshNode*> _graphicsMeshes; - std::map<void*, BlastNode*> _blastProjectDataToNodeMap; -}; - -class ISceneObserver -{ -public: - virtual void dataSelected(std::vector<BlastNode*> selections) = 0; -}; - -class BlastTreeViewDelegate : QStyledItemDelegate -{ - Q_OBJECT - -public: - BlastTreeViewDelegate(QObject* parent, QStandardItemModel* model); - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; - bool editorEvent(QEvent* evt, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index); - -protected: - bool eventFilter(QObject* object, QEvent* event); - -private: - QStandardItemModel* _treeModel; -}; - -class BlastSceneTreeDataLock; - -class BlastSceneTree : public QDockWidget, public ISceneObserver -{ - Q_OBJECT - - friend class BlastSceneTreeDataLock; -public: - static BlastSceneTree* ins(); - - BlastSceneTree(QWidget *parent = 0); - ~BlastSceneTree(); - - void updateValues(bool updataData = true); - - void clear(); - - virtual void dataSelected(std::vector<BlastNode*> selections); - - void addObserver(ISceneObserver* observer); - void removeObserver(ISceneObserver* observer); - - void updateVisible(uint32_t assetIndex, uint32_t chunkIndex, bool visible); - void updateChunkItemSelection(); - - void makeSupport(); - void makeStaticSupport(); - void removeSupport(); - void makeWorld(); - void removeWorld(); - void bondChunks(); - void bondChunksWithJoints(); - void removeAllBonds(); - - void setChunkSelected(std::vector<uint32_t> depths, bool selected); - void setChunkVisible(std::vector<uint32_t> depths, bool bVisible); - - void setChunkVisibleFullCoverage(int depth); - void hideAllChunks(); - /* - void addBlastAsset(BPPAsset& asset); - void removeBlastAsset(BPPAsset& asset); - - void addBlastInstance(BPPAssetInstance& instance); - void removeBlastInstance(BPPAssetInstance& instance); - void removeBlastInstances(BPPAsset& asset); - - void addProjectile(PhysXSceneActor* projectile); - void clearProjectile(); - */ - BlastNode* getBlastNodeByItem(QStandardItem* item); - PhysXSceneActor* getProjectileActorByItem(QStandardItem* item); - - void selectTreeItem(BlastNode* node, bool updateData = true); - void selectTreeItem(BlastFamily* family); - - void ApplyAutoSelectNewChunks(BlastAsset* pNewBlastAsset, std::vector<uint32_t>& NewChunkIndexes); - -protected slots: - void on_btnAsset_clicked(); - void on_assetComposite_clicked(); - void on_btnChunk_clicked(); - void on_btnBond_clicked(); - void on_btnProjectile_clicked(); - void on_btnExpandCollapse_clicked(); - void on_blastSceneTree_customContextMenuRequested(const QPoint& pos); - void on_blastSceneTree_itemSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void onMakeSupportMenuItemClicked(); - void onMakeStaticSupportMenuItemClicked(); - void onRemoveSupportMenuItemClicked(); - void onMakeWorldMenuItemClicked(); - void onRemoveWorldMenuItemClicked(); - void onBondChunksMenuItemClicked(); - void onBondChunksWithJointsMenuItemClicked(); - void onRemoveAllBondsMenuItemClicked(); - void onCollapseExpandClicked(); - -private: - void _updateTreeUIs(); - void _addChunkUI(const BlastNode* parentNode, QStandardItem* parentTreeItem); - void _updateChunkTreeItemAndMenu(BPPChunk* chunk, QStandardItem* chunkItem); - void _updateChunkTreeItems(); - -private: - Ui::BlastSceneTree ui; - QStandardItemModel* _treeModel; - QMap<QStandardItem*, BlastNode*> _treeItemDataMap; - QMap<BlastNode*, QStandardItem*> _treeDataItemMap; - QMenu* _treeContextMenu; - QAction* _makeSupportAction; - QAction* _makeStaticSupportAction; - QAction* _removeSupportAction; - QAction* _makeWorldAction; - QAction* _removeWorldAction; - QAction* _bondChunksAction; - QAction* _bondChunksWithJointsAction; - QAction* _removeAllBondsAction; - std::vector<ISceneObserver*> _observers; - bool _updateData; -// QStandardItem* _compositeTreeItem; - QMap<QStandardItem*, PhysXSceneActor*> _projectileItemActorMap; - - BlastAsset* m_pNewBlastAsset; - std::vector<uint32_t> m_NewChunkIndexes; -}; - -#endif // BLASTSCENETREE_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp deleted file mode 100644 index 1eed17b..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.cpp +++ /dev/null @@ -1,1077 +0,0 @@ -#include "BlastToolbar.h" - -#include <QtWidgets/QFileDialog> -#include "AppMainWindow.h" -#include "PhysXController.h" -#include "QtUtil.h" - -#include "SampleManager.h" -#include "SceneController.h" -#include "DamageToolController.h" -#include "SelectionToolController.h" -#include "ExplodeToolController.h" -#include "GizmoToolController.h" -#include "BlastController.h" -#include "SourceAssetOpenDlg.h" -#include "BlastPlugin.h" -#include <QtWidgets/QButtonGroup> -#include <QtWidgets/QActionGroup> -#include "Shlwapi.h" -#include "BlastSceneTree.h" -#include "BlastFamily.h" -#include "FileReferencesPanel.h" -#include "GlobalSettings.h" -#include "PxScene.h" -#include "PxRigidDynamic.h" -#include "ViewerOutput.h" - -#include <QtCore/QTimer> -QTimer gDropTimer; -int nExplodedViewState = 0; - -BlastToolbar::BlastToolbar(QWidget* parent) - : QDockWidget(parent) - , m_fullCoverage(false) -{ - // to hide the title bar completely must replace the default widget with a generic one - QWidget* titleWidget = new QWidget(this); - this->setTitleBarWidget(titleWidget); - this->setObjectName(QString::fromUtf8("AppMainToolbar")); - this->setMinimumSize(QSize(0, 50)); - this->setMaximumSize(QSize(16777215, 80)); - - if (this->objectName().isEmpty()) - this->setObjectName(QStringLiteral("AppMainToolbar")); - this->resize(1330, 54); - - QWidget* widget = new QWidget(); - hLayout = new QHBoxLayout(widget); - hLayout->setObjectName(QStringLiteral("hLayout")); - hLayout->setContentsMargins(-1, 3, -1, 3); - - QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - - btnOpenProject = new QPushButton(widget); - setStyledToolTip(btnOpenProject, "Open Project"); - const QFont& font = btnOpenProject->font(); - QFont fontCopy(font); - fontCopy.setPixelSize(9); - - btnOpenProject->setObjectName(QStringLiteral("btnOpenProject")); - sizePolicy1.setHeightForWidth(btnOpenProject->sizePolicy().hasHeightForWidth()); - btnOpenProject->setSizePolicy(sizePolicy1); - btnOpenProject->setMinimumSize(QSize(40, 40)); - btnOpenProject->setMaximumSize(QSize(40, 40)); - btnOpenProject->setText(QApplication::translate("AppMainToolbar", "Open", 0)); - hLayout->addWidget(btnOpenProject); - - btnSaveProject = new QPushButton(widget); - setStyledToolTip(btnSaveProject, "Save Project and assets"); - btnSaveProject->setObjectName(QStringLiteral("btnSaveProject")); - sizePolicy1.setHeightForWidth(btnOpenProject->sizePolicy().hasHeightForWidth()); - btnSaveProject->setSizePolicy(sizePolicy1); - btnSaveProject->setMinimumSize(QSize(40, 40)); - btnSaveProject->setMaximumSize(QSize(40, 40)); - btnSaveProject->setText(QApplication::translate("AppMainToolbar", "Save\nAll", 0)); - hLayout->addWidget(btnSaveProject); - - btnExportAssets = new QPushButton(widget); - setStyledToolTip(btnExportAssets, "Export Blast assets"); - btnExportAssets->setObjectName(QStringLiteral("btnExportAssets")); - sizePolicy1.setHeightForWidth(btnExportAssets->sizePolicy().hasHeightForWidth()); - btnExportAssets->setSizePolicy(sizePolicy1); - btnExportAssets->setMinimumSize(QSize(40, 40)); - btnExportAssets->setMaximumSize(QSize(40, 40)); - btnExportAssets->setText(QApplication::translate("AppMainToolbar", "Export", 0)); - hLayout->addWidget(btnExportAssets); - - vLayoutExport = new QVBoxLayout(); - vLayoutExport->setObjectName(QStringLiteral("vLayoutExport")); - - hLayoutExport = new QHBoxLayout(); - hLayoutExport->setObjectName(QStringLiteral("hLayoutExport")); - - lExportFilepath = new QLabel(widget); - lExportFilepath->setObjectName(QStringLiteral("lExportFilepath")); - lExportFilepath->setText(QApplication::translate("AppMainToolbar", "Export Path", 0)); - hLayoutExport->addWidget(lExportFilepath); - - btnExportFilepath = new QPushButton(widget); - btnExportFilepath->setObjectName(QStringLiteral("btnExportFilepath")); - sizePolicy1.setHeightForWidth(btnExportFilepath->sizePolicy().hasHeightForWidth()); - btnExportFilepath->setSizePolicy(sizePolicy1); - btnExportFilepath->setMinimumSize(QSize(14, 14)); - btnExportFilepath->setMaximumSize(QSize(14, 14)); - btnExportFilepath->setText(QApplication::translate("AppMainToolbar", "", 0)); - btnExportFilepath->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnExportFilepath.png")); - btnExportFilepath->setIconSize(QSize(14, 14)); - hLayoutExport->addWidget(btnExportFilepath); - - vLayoutExport->addLayout(hLayoutExport); - - leExportFilepath = new QLineEdit(widget); - leExportFilepath->setObjectName(QStringLiteral("leExportFilepath")); - sizePolicy1.setHeightForWidth(leExportFilepath->sizePolicy().hasHeightForWidth()); - leExportFilepath->setSizePolicy(sizePolicy1); - leExportFilepath->setMinimumSize(QSize(150, 20)); - leExportFilepath->setMaximumSize(QSize(150, 20)); - leExportFilepath->setText(QApplication::translate("AppMainToolbar", "", 0)); - leExportFilepath->setEnabled(false); // do not allow direct change to make sure the folder exists. - vLayoutExport->addWidget(leExportFilepath); - - hLayout->addLayout(vLayoutExport); - - fSeparate = new QFrame(widget); - fSeparate->setObjectName(QStringLiteral("fSeparate")); - fSeparate->setFrameShape(QFrame::VLine); - fSeparate->setFrameShadow(QFrame::Sunken); - hLayout->addWidget(fSeparate); - - vLayoutDepthCoverage = new QVBoxLayout(); - vLayoutDepthCoverage->setObjectName(QStringLiteral("vLayoutDepthCoverage")); - - hlDepthPreview = new QHBoxLayout(); - hlDepthPreview->setObjectName(QStringLiteral("hlDepthPreview")); - - lbDepthPreview = new QLabel(widget); - lbDepthPreview->setObjectName(QStringLiteral("lbDepthPreview")); - lbDepthPreview->setText(QApplication::translate("AppMainToolbar", "Depth Preview", 0)); - hlDepthPreview->addWidget(lbDepthPreview); - - ssbiDepthPreview = new SlideSpinBoxInt(widget); - ssbiDepthPreview->setObjectName(QStringLiteral("ssbiDepthPreview")); - QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Fixed); - sizePolicy2.setHorizontalStretch(0); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(ssbiDepthPreview->sizePolicy().hasHeightForWidth()); - ssbiDepthPreview->setSizePolicy(sizePolicy2); - ssbiDepthPreview->setMinimumSize(QSize(40, 20)); - ssbiDepthPreview->setMaximumSize(QSize(100, 16777215)); - hlDepthPreview->addWidget(ssbiDepthPreview); - - vLayoutDepthCoverage->addLayout(hlDepthPreview); - - hlExactCoverage = new QHBoxLayout(); - hlExactCoverage->setObjectName(QStringLiteral("hlExactCoverage")); - - lbExactCoverage = new QLabel(widget); - lbExactCoverage->setObjectName(QStringLiteral("lbExactCoverage")); - lbExactCoverage->setText(QApplication::translate("AppMainToolbar", "Full Coverage", 0)); - hlExactCoverage->addWidget(lbExactCoverage); - - cbExactCoverage = new QCheckBox(widget); - cbExactCoverage->setObjectName(QStringLiteral("cbExactCoverage")); - sizePolicy1.setHeightForWidth(cbExactCoverage->sizePolicy().hasHeightForWidth()); - cbExactCoverage->setSizePolicy(sizePolicy1); - cbExactCoverage->setLayoutDirection(Qt::RightToLeft); - hlExactCoverage->addWidget(cbExactCoverage); - - vLayoutDepthCoverage->addLayout(hlExactCoverage); - - hLayout->addLayout(vLayoutDepthCoverage); - - fSeparate = new QFrame(widget); - fSeparate->setObjectName(QStringLiteral("fSeparate")); - fSeparate->setFrameShape(QFrame::VLine); - fSeparate->setFrameShadow(QFrame::Sunken); - hLayout->addWidget(fSeparate); - - QButtonGroup* gizmoGroup = new QButtonGroup(this); - - btnSelectTool = new QPushButton(widget); - setStyledToolTip(btnSelectTool, "Switch to Selection Mode"); - btnSelectTool->setObjectName(QStringLiteral("btnSelectTool")); - sizePolicy1.setHeightForWidth(btnSelectTool->sizePolicy().hasHeightForWidth()); - btnSelectTool->setSizePolicy(sizePolicy1); - btnSelectTool->setMinimumSize(QSize(40, 40)); - btnSelectTool->setMaximumSize(QSize(40, 40)); - btnSelectTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnSelectTool.png")); - btnSelectTool->setIconSize(QSize(36, 36)); - // because we can detect click or draw rect. we do not need menu by now. - //QAction* pointselect_action = new QAction(tr("point select"), this); - //QAction* rectselect_action = new QAction(tr("rect select"), this); - //QAction* drawselect_action = new QAction(tr("draw select"), this); - //pointselect_action->setCheckable(true); - //rectselect_action->setCheckable(true); - //drawselect_action->setCheckable(true); - //QActionGroup* selectGroup = new QActionGroup(this); - //selectGroup->addAction(pointselect_action); - //selectGroup->addAction(rectselect_action); - //selectGroup->addAction(drawselect_action); - //connect(pointselect_action, SIGNAL(triggered()), this, SLOT(on_pointselect_action())); - //connect(rectselect_action, SIGNAL(triggered()), this, SLOT(on_rectselect_action())); - //connect(drawselect_action, SIGNAL(triggered()), this, SLOT(on_drawselect_action())); - //QMenu* menu = new QMenu(btnSelectTool); - //menu->addAction(pointselect_action); - //menu->addAction(rectselect_action); - //menu->addAction(drawselect_action); - //btnSelectTool->setMenu(menu); - hLayout->addWidget(btnSelectTool); - btnSelectTool->setCheckable(true); - gizmoGroup->addButton(btnSelectTool); - - btnExplodedViewTool = new QPushButton(widget); - setStyledToolTip(btnExplodedViewTool, "Exploded View Tool"); - btnExplodedViewTool->setObjectName(QStringLiteral("btnExplodedViewTool")); - sizePolicy1.setHeightForWidth(btnExplodedViewTool->sizePolicy().hasHeightForWidth()); - btnExplodedViewTool->setSizePolicy(sizePolicy1); - btnExplodedViewTool->setMinimumSize(QSize(40, 40)); - btnExplodedViewTool->setMaximumSize(QSize(40, 40)); - btnExplodedViewTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnExplodedViewTool.png")); - btnExplodedViewTool->setIconSize(QSize(36, 36)); - btnExplodedViewTool->setCheckable(true); - hLayout->addWidget(btnExplodedViewTool); - gizmoGroup->addButton(btnExplodedViewTool); - - btnTranslate = new QPushButton(widget); - setStyledToolTip(btnTranslate, "Translate Tool"); - btnTranslate->setObjectName(QStringLiteral("btnTranslate")); - sizePolicy1.setHeightForWidth(btnTranslate->sizePolicy().hasHeightForWidth()); - btnTranslate->setSizePolicy(sizePolicy1); - btnTranslate->setMinimumSize(QSize(40, 40)); - btnTranslate->setMaximumSize(QSize(40, 40)); - btnTranslate->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnTranslate.png")); - btnTranslate->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnTranslate); - btnTranslate->setCheckable(true); - gizmoGroup->addButton(btnTranslate); - - btnRotate = new QPushButton(widget); - setStyledToolTip(btnRotate, "Rotate Tool"); - btnRotate->setObjectName(QStringLiteral("btnRotate")); - sizePolicy1.setHeightForWidth(btnRotate->sizePolicy().hasHeightForWidth()); - btnRotate->setSizePolicy(sizePolicy1); - btnRotate->setMinimumSize(QSize(40, 40)); - btnRotate->setMaximumSize(QSize(40, 40)); - btnRotate->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnRotate.png")); - btnRotate->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnRotate); - btnRotate->setCheckable(true); - gizmoGroup->addButton(btnRotate); - - btnScale = new QPushButton(widget); - setStyledToolTip(btnScale, "Scale Tool"); - btnScale->setObjectName(QStringLiteral("btnScale")); - sizePolicy1.setHeightForWidth(btnScale->sizePolicy().hasHeightForWidth()); - btnScale->setSizePolicy(sizePolicy1); - btnScale->setMinimumSize(QSize(40, 40)); - btnScale->setMaximumSize(QSize(40, 40)); - btnScale->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnScale.png")); - btnScale->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnScale); - btnScale->setCheckable(true); - gizmoGroup->addButton(btnScale); - - btnGizmoWithLocal = new QPushButton(widget); - setStyledToolTip(btnGizmoWithLocal, "Gizmo in Global Mode"); - btnGizmoWithLocal->setObjectName(QStringLiteral("btnGizmoWithLocal")); - sizePolicy1.setHeightForWidth(btnGizmoWithLocal->sizePolicy().hasHeightForWidth()); - btnGizmoWithLocal->setSizePolicy(sizePolicy1); - btnGizmoWithLocal->setMinimumSize(QSize(40, 40)); - btnGizmoWithLocal->setMaximumSize(QSize(40, 40)); - btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithGlobal.png")); - btnGizmoWithLocal->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnGizmoWithLocal); - btnGizmoWithLocal->setCheckable(true); - - //fSeparate = new QFrame(widget); - //fSeparate->setObjectName(QStringLiteral("fSeparate")); - //fSeparate->setFrameShape(QFrame::VLine); - //fSeparate->setFrameShadow(QFrame::Sunken); - //hLayout->addWidget(fSeparate); - - btnPaintbrush = new QPushButton(widget); - setStyledToolTip(btnPaintbrush, "Not Implement"); - btnPaintbrush->setObjectName(QStringLiteral("btnPaintbrush")); - sizePolicy1.setHeightForWidth(btnPaintbrush->sizePolicy().hasHeightForWidth()); - btnPaintbrush->setSizePolicy(sizePolicy1); - btnPaintbrush->setMinimumSize(QSize(40, 40)); - btnPaintbrush->setMaximumSize(QSize(40, 40)); - btnPaintbrush->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnPaintbrush.png")); - btnPaintbrush->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnPaintbrush); - - btnFractureTool = new QPushButton(widget); - setStyledToolTip(btnFractureTool, "Not Implement"); - btnFractureTool->setObjectName(QStringLiteral("btnFractureTool")); - sizePolicy1.setHeightForWidth(btnFractureTool->sizePolicy().hasHeightForWidth()); - btnFractureTool->setSizePolicy(sizePolicy1); - btnFractureTool->setMinimumSize(QSize(40, 40)); - btnFractureTool->setMaximumSize(QSize(40, 40)); - btnFractureTool->setText(QApplication::translate("AppMainToolbar", "Fracture", 0)); - btnFractureTool->setFont(fontCopy); - hLayout->addWidget(btnFractureTool); - - btnJointsTool = new QPushButton(widget); - setStyledToolTip(btnJointsTool, "Not Implement"); - btnJointsTool->setObjectName(QStringLiteral("btnJointsTool")); - sizePolicy1.setHeightForWidth(btnJointsTool->sizePolicy().hasHeightForWidth()); - btnJointsTool->setSizePolicy(sizePolicy1); - btnJointsTool->setMinimumSize(QSize(40, 40)); - btnJointsTool->setMaximumSize(QSize(40, 40)); - btnJointsTool->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnJointsTool.png")); - btnJointsTool->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnJointsTool); - - btnFuseSelectedChunks = new QPushButton(widget); - setStyledToolTip(btnFuseSelectedChunks, "Not Implement"); - btnFuseSelectedChunks->setObjectName(QStringLiteral("btnFuseSelectedChunks")); - sizePolicy1.setHeightForWidth(btnFuseSelectedChunks->sizePolicy().hasHeightForWidth()); - btnFuseSelectedChunks->setSizePolicy(sizePolicy1); - btnFuseSelectedChunks->setMinimumSize(QSize(40, 40)); - btnFuseSelectedChunks->setMaximumSize(QSize(40, 40)); - btnFuseSelectedChunks->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnFuseSelectedChunks.png")); - btnFuseSelectedChunks->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnFuseSelectedChunks); - - fSeparate = new QFrame(widget); - fSeparate->setObjectName(QStringLiteral("fSeparate")); - fSeparate->setFrameShape(QFrame::VLine); - fSeparate->setFrameShadow(QFrame::Sunken); - hLayout->addWidget(fSeparate); - - QButtonGroup* editSimModeGroup = new QButtonGroup(this); - - btnReset = new QPushButton(widget); - setStyledToolTip(btnReset, "Reset Chunks and Switch to Edition Mode"); - btnReset->setObjectName(QStringLiteral("btnReset")); - sizePolicy1.setHeightForWidth(btnReset->sizePolicy().hasHeightForWidth()); - btnReset->setSizePolicy(sizePolicy1); - btnReset->setMinimumSize(QSize(40, 40)); - btnReset->setMaximumSize(QSize(40, 40)); - btnReset->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnReset.png")); - btnReset->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnReset); - btnReset->setCheckable(true); - editSimModeGroup->addButton(btnReset); - - btnSimulatePlay = new QPushButton(widget); - setStyledToolTip(btnSimulatePlay, "Switch to Simulate Mode"); - btnSimulatePlay->setObjectName(QStringLiteral("btnSimulatePlay")); - sizePolicy1.setHeightForWidth(btnSimulatePlay->sizePolicy().hasHeightForWidth()); - btnSimulatePlay->setSizePolicy(sizePolicy1); - btnSimulatePlay->setMinimumSize(QSize(40, 40)); - btnSimulatePlay->setMaximumSize(QSize(40, 40)); - btnSimulatePlay->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnSimulatePlay.png")); - btnSimulatePlay->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnSimulatePlay); - btnSimulatePlay->setCheckable(true); - editSimModeGroup->addButton(btnSimulatePlay); - - btnFrameStepForward = new QPushButton(widget); - setStyledToolTip(btnFrameStepForward, "Switch to StepForward Mode"); - btnFrameStepForward->setObjectName(QStringLiteral("btnFrameStepForward")); - sizePolicy1.setHeightForWidth(btnFrameStepForward->sizePolicy().hasHeightForWidth()); - btnFrameStepForward->setSizePolicy(sizePolicy1); - btnFrameStepForward->setMinimumSize(QSize(40, 40)); - btnFrameStepForward->setMaximumSize(QSize(40, 40)); - btnFrameStepForward->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnFrameStepForward.png")); - btnFrameStepForward->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnFrameStepForward); - btnFrameStepForward->setCheckable(true); - editSimModeGroup->addButton(btnFrameStepForward); - - fSeparate = new QFrame(widget); - fSeparate->setObjectName(QStringLiteral("fSeparate")); - fSeparate->setFrameShape(QFrame::VLine); - fSeparate->setFrameShadow(QFrame::Sunken); - hLayout->addWidget(fSeparate); - - // use btnDamage for Damage function. - btnDamage = new QPushButton(widget); - setStyledToolTip(btnDamage, "Switch on/off Damage Mode"); - btnDamage->setObjectName(QStringLiteral("btnDamage")); - sizePolicy1.setHeightForWidth(btnDamage->sizePolicy().hasHeightForWidth()); - btnDamage->setSizePolicy(sizePolicy1); - btnDamage->setMinimumSize(QSize(40, 40)); - btnDamage->setMaximumSize(QSize(40, 40)); - btnDamage->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnDamage.png")); - btnDamage->setIconSize(QSize(36, 36)); - btnDamage->setCheckable(true); - hLayout->addWidget(btnDamage); - - btnProjectile = new QPushButton(widget); - setStyledToolTip(btnProjectile, "Throw a Box to Chunks"); - btnProjectile->setObjectName(QStringLiteral("btnProjectile")); - sizePolicy1.setHeightForWidth(btnProjectile->sizePolicy().hasHeightForWidth()); - btnProjectile->setSizePolicy(sizePolicy1); - btnProjectile->setMinimumSize(QSize(40, 40)); - btnProjectile->setMaximumSize(QSize(40, 40)); - btnProjectile->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnProjectile.png")); - btnProjectile->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnProjectile); - - btnDropObject = new QPushButton(widget); - setStyledToolTip(btnDropObject, "Drop the object and simulate"); - btnDropObject->setObjectName(QStringLiteral("btnDropObject")); - sizePolicy1.setHeightForWidth(btnDropObject->sizePolicy().hasHeightForWidth()); - btnDropObject->setSizePolicy(sizePolicy1); - btnDropObject->setMinimumSize(QSize(40, 40)); - btnDropObject->setMaximumSize(QSize(40, 40)); - btnDropObject->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnDropObject.png")); - btnDropObject->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnDropObject); - - fSeparate = new QFrame(widget); - fSeparate->setObjectName(QStringLiteral("fSeparate")); - fSeparate->setFrameShape(QFrame::VLine); - fSeparate->setFrameShadow(QFrame::Sunken); - hLayout->addWidget(fSeparate); - - btnPreferences = new QPushButton(widget); - setStyledToolTip(btnPreferences, "Save Blast Asset"); - btnPreferences->setObjectName(QStringLiteral("btnPreferences")); - sizePolicy1.setHeightForWidth(btnPreferences->sizePolicy().hasHeightForWidth()); - btnPreferences->setSizePolicy(sizePolicy1); - btnPreferences->setMinimumSize(QSize(40, 40)); - btnPreferences->setMaximumSize(QSize(40, 40)); - btnPreferences->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnPreferences.png")); - btnPreferences->setIconSize(QSize(36, 36)); - hLayout->addWidget(btnPreferences); - - QSpacerItem *horizontalSpacer; - horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hLayout->addItem(horizontalSpacer); - - this->setWidget(widget); - - connect(&gDropTimer, SIGNAL(timeout()), this, SLOT(on_btnDropObject_clicked())); - connect(btnOpenProject, SIGNAL(clicked()), this, SLOT(on_btnOpenProject_clicked())); - connect(btnSaveProject, SIGNAL(clicked()), this, SLOT(on_btnSaveProject_clicked())); - connect(btnExportAssets, SIGNAL(clicked()), this, SLOT(on_btnExportAssets_clicked())); - connect(btnExportFilepath, SIGNAL(clicked()), this, SLOT(on_btnExportFilepath_clicked())); - connect(ssbiDepthPreview, SIGNAL(valueChanged(int)), this, SLOT(on_ssbiDepthPreview_valueChanged(int))); - connect(cbExactCoverage, SIGNAL(stateChanged(int)), this, SLOT(on_cbExactCoverage_stateChanged(int))); - connect(btnSelectTool, SIGNAL(clicked()), this, SLOT(on_btnSelectTool_clicked())); - connect(btnTranslate, SIGNAL(clicked()), this, SLOT(on_Translate_clicked())); - connect(btnRotate, SIGNAL(clicked()), this, SLOT(on_Rotation_clicked())); - connect(btnScale, SIGNAL(clicked()), this, SLOT(on_Scale_clicked())); - connect(btnGizmoWithLocal, SIGNAL(clicked()), this, SLOT(on_btnGizmoWithLocal_clicked())); - connect(btnPaintbrush, SIGNAL(clicked()), this, SLOT(on_btnPaintbrush_clicked())); - connect(btnFractureTool, SIGNAL(clicked()), this, SLOT(on_btnFractureTool_clicked())); - connect(btnExplodedViewTool, SIGNAL(clicked()), this, SLOT(on_btnExplodedViewTool_clicked())); - connect(btnJointsTool, SIGNAL(clicked()), this, SLOT(on_btnJointsTool_clicked())); - connect(btnFuseSelectedChunks, SIGNAL(clicked()), this, SLOT(on_btnFuseSelectedChunks_clicked())); - connect(btnReset, SIGNAL(clicked()), this, SLOT(on_btnReset_clicked())); - connect(btnSimulatePlay, SIGNAL(clicked()), this, SLOT(on_btnSimulatePlay_clicked())); - connect(btnFrameStepForward, SIGNAL(clicked()), this, SLOT(on_btnFrameStepForward_clicked())); - connect(btnDamage, SIGNAL(clicked()), this, SLOT(on_btnDamage_clicked())); - connect(btnProjectile, SIGNAL(clicked()), this, SLOT(on_btnProjectile_clicked())); - connect(btnDropObject, SIGNAL(clicked()), this, SLOT(on_btnDropObject_clicked())); - connect(btnPreferences, SIGNAL(clicked()), this, SLOT(on_btnPreferences_clicked())); - - QPushButton* unImplementButtons[] = - { - btnPaintbrush, btnFractureTool, btnJointsTool, btnFuseSelectedChunks, btnPreferences - }; - int buttonSize = sizeof(unImplementButtons) / sizeof(QPushButton*); - for (int bs = 0; bs < buttonSize; bs++) - { - unImplementButtons[bs]->setVisible(false); - } -} - -void BlastToolbar::updateValues() -{ - leExportFilepath->setText(GlobalSettings::Inst().m_projectFileDir.c_str()); - btnGizmoWithLocal->setChecked(AppMainWindow::Inst().m_bGizmoWithLocal); - - SampleManager* pSampleManager = SampleManager::ins(); - DamageToolController& damageToolController = pSampleManager->getDamageToolController(); - bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode(); - btnDamage->setChecked(bChecked); -} - -void BlastToolbar::on_btnOpenProject_clicked() -{ - //BlastPlugin::OpenBpxa("", ""); - BlastPlugin::Inst().menu_openProject(); - // show project path in toolbar - updateValues(); -} - -void BlastToolbar::on_btnSaveProject_clicked() -{ - qDebug("%s", __FUNCTION__); - on_btnExportAssets_clicked(); - BlastPlugin::Inst().menu_saveProject(); -} - -void BlastToolbar::on_btnExportAssets_clicked() -{ - qDebug("%s", __FUNCTION__); - FileReferencesPanel* pPanel = BlastPlugin::Inst().GetFileReferencesPanel(); - if (pPanel) - { - BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode(); - if (assetInstancesNode != nullptr) - { - size_t count = assetInstancesNode->children.size(); - for (size_t i = 0; i < count; ++i) - { - BlastAssetInstanceNode* assetInstanceNode = dynamic_cast<BlastAssetInstanceNode*>(assetInstancesNode->children[i]); - if (assetInstanceNode) - { - assetInstanceNode->setSelected(true); - pPanel->on_btnSave_clicked(); - } - } - } - } -} - -void BlastToolbar::on_btnExportFilepath_clicked() -{ - qDebug("%s", __FUNCTION__); - AppMainWindow& window = AppMainWindow::Inst(); - QString lastDir = leExportFilepath->text(); - if (lastDir.length() < 1) - { - lastDir = GlobalSettings::Inst().m_projectFileDir.c_str(); - } - QString pathName = QFileDialog::getExistingDirectory(&window, "Exporting Path", lastDir); - if (!pathName.isEmpty()) - { - GlobalSettings::Inst().m_projectFileDir = pathName.toUtf8().data(); - leExportFilepath->setText(pathName); - } -} - -void BlastToolbar::on_ssbiDepthPreview_valueChanged(int v) -{ - qDebug("%s", __FUNCTION__); - BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins(); - pBlastSceneTree->hideAllChunks(); - if (m_fullCoverage) - { - pBlastSceneTree->setChunkVisibleFullCoverage(v); - } - else - { - std::vector<uint32_t> depths(1, v); - pBlastSceneTree->setChunkVisible(depths, true); - } - // refresh display in scene tree - //pBlastSceneTree->updateValues(false); - SampleManager::ins()->m_bNeedRefreshTree = true; -} - -void BlastToolbar::on_cbExactCoverage_stateChanged(int state) -{ - qDebug("%s", __FUNCTION__); - m_fullCoverage = (state != 0); - //lbExactCoverage->setText(QApplication::translate("AppMainToolbar", (m_fullCoverage? "Full Coverage" : "Exact Coverage"), 0)); - int depth = ssbiDepthPreview->value(); - on_ssbiDepthPreview_valueChanged(depth); -} - -void BlastToolbar::on_btnSelectTool_clicked() -{ - SampleManager* pSampleManager = SampleManager::ins(); - SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController(); - ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController(); - expolodeController.DisableController(); - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - gizmoToolController.showAxisRenderables(false); - - if (gizmoToolController.IsEnabled()) - { - gizmoToolController.DisableController(); - selectionToolController.setTargetActor(gizmoToolController.getTargetActor()); - } - selectionToolController.EnableController(); - -} - -void BlastToolbar::on_pointselect_action() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_rectselect_action() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_drawselect_action() -{ - qDebug("%s", __FUNCTION__); -} - -bool BlastToolbar::on_Translate_clicked() -{ - SampleManager* pSampleManager = SampleManager::ins(); - SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController(); - ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController(); - expolodeController.DisableController(); - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - gizmoToolController.showAxisRenderables(false); - - if (selectionToolController.IsEnabled()) - { - selectionToolController.DisableController(); - gizmoToolController.setTargetActor(selectionToolController.getTargetActor()); - } - gizmoToolController.EnableController(); - gizmoToolController.setGizmoToolMode(GTM_Translate); - - return true; -} - -bool BlastToolbar::on_Rotation_clicked() -{ - SampleManager* pSampleManager = SampleManager::ins(); - SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController(); - ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController(); - expolodeController.DisableController(); - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - gizmoToolController.showAxisRenderables(false); - - if (selectionToolController.IsEnabled()) - { - selectionToolController.DisableController(); - gizmoToolController.setTargetActor(selectionToolController.getTargetActor()); - } - gizmoToolController.EnableController(); - gizmoToolController.setGizmoToolMode(GTM_Rotation); - - return true; -} - -bool BlastToolbar::on_Scale_clicked() -{ - SampleManager* pSampleManager = SampleManager::ins(); - SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController(); - ExplodeToolController& expolodeController = pSampleManager->getExplodeToolController(); - expolodeController.DisableController(); - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - gizmoToolController.showAxisRenderables(false); - - if (selectionToolController.IsEnabled()) - { - selectionToolController.DisableController(); - gizmoToolController.setTargetActor(selectionToolController.getTargetActor()); - } - gizmoToolController.EnableController(); - gizmoToolController.setGizmoToolMode(GTM_Scale); - - return true; -} - -void BlastToolbar::on_btnGizmoWithLocal_clicked() -{ - AppMainWindow& app = AppMainWindow::Inst(); - app.m_bGizmoWithLocal = !app.m_bGizmoWithLocal; - if (app.m_bGizmoWithLocal) - { - btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithLocal.png")); - setStyledToolTip(btnGizmoWithLocal, "Gizmo in Local Mode"); - } - else - { - btnGizmoWithLocal->setIcon(QIcon(":/AppMainWindow/images/Blast_ToolBar_btnGizmoWithGlobal.png")); - setStyledToolTip(btnGizmoWithLocal, "Gizmo in Global Mode"); - } - app.updateUI(); -} - -void BlastToolbar::on_btnPaintbrush_clicked() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_btnFractureTool_clicked() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_btnExplodedViewTool_clicked() -{ -#if (1) - SampleManager* pSampleManager = SampleManager::ins(); - ExplodeToolController& explodeToolController = pSampleManager->getExplodeToolController(); - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - gizmoToolController.showAxisRenderables(false); - - pSampleManager->getSelectionToolController().DisableController(); - - if (gizmoToolController.IsEnabled()) - { - gizmoToolController.DisableController(); - } - explodeToolController.EnableController(); -#endif - -#if (0) - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager->IsSimulating()) - { - return; - } - - BlastAsset* pBlastAsset = nullptr; - int nFamilyIndex = -1; - pSampleManager->getCurrentSelectedInstance(&pBlastAsset, nFamilyIndex); - if (pBlastAsset == nullptr) - { - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - if (AssetDescMap.size() == 1) - { - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itAssetDescMap = AssetDescMap.begin(); - pSampleManager->setCurrentSelectedInstance(itAssetDescMap->first, -1); - pBlastAsset = pSampleManager->getCurBlastAsset(); - viewer_msg("no asset selected, use the only one in current scene."); - } - } - if (pBlastAsset == nullptr) - { - viewer_msg("please select one asset before explode."); - return; - } - - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap(); - std::map<BlastAsset*, std::vector<BlastFamily*>>::iterator itAFM = AssetFamiliesMap.find(pBlastAsset); - if (itAFM == AssetFamiliesMap.end()) - { - return; - } - - std::vector<BlastFamily*> families = itAFM->second; - int familySize = families.size(); - if (familySize == 0) - { - viewer_msg("no instance for current asset."); - return; - } - - if (nFamilyIndex == -1 || nFamilyIndex >= familySize) - { - nFamilyIndex = 0; - viewer_msg("no instance selected, use the first one of current asset."); - } - - BlastFamily* pFamily = families[nFamilyIndex]; - - PxScene& scene = pSampleManager->getPhysXController().getEditPhysXScene(); - const PxU32 actorsCountTotal = scene.getNbActors(PxActorTypeFlag::eRIGID_DYNAMIC); - if (actorsCountTotal == 0) - { - return; - } - - std::vector<PxActor*> actorsTotal(actorsCountTotal); - PxU32 nbActors = scene.getActors(PxActorTypeFlag::eRIGID_DYNAMIC, &actorsTotal[0], actorsCountTotal, 0); - PX_ASSERT(actorsCountTotal == nbActors); - - std::vector<PxActor*> actors; - PxActor* pRootActor = nullptr; - for (int act = 0; act < actorsCountTotal; act++) - { - if (pFamily->find(*actorsTotal[act])) - { - if (pRootActor == nullptr) - { - uint32_t chunkIndex = pFamily->getChunkIndexByPxActor(*actorsTotal[act]); - std::vector<uint32_t> chunkIndexes; - chunkIndexes.push_back(chunkIndex); - std::vector<BlastChunkNode*> chunkNodes = BlastTreeData::ins().getChunkNodeByBlastChunk(pBlastAsset, chunkIndexes); - if (chunkNodes.size() > 0 && BlastTreeData::isRoot(chunkNodes[0])) - { - pRootActor = actorsTotal[act]; - } - else - { - actors.push_back(actorsTotal[act]); - } - } - else - { - actors.push_back(actorsTotal[act]); - } - } - } - - if (pRootActor == nullptr) - { - return; - } - - ++nExplodedViewState; - - BlastController& blastController = pSampleManager->getBlastController(); - - PxVec3 origin = pRootActor->getWorldBounds().getCenter(); - - int actorsCount = actors.size(); - for (int ac = 0; ac < actorsCount; ac++) - { - PxActor* actor = actors[ac]; - PxRigidDynamic* dynamic = actor->is<PxRigidDynamic>(); - PX_ASSERT(dynamic != nullptr); - PxTransform transformOld = dynamic->getGlobalPose(); - PxTransform transformNew = transformOld; - - PxBounds3 bound = actor->getWorldBounds(); - PxVec3 target = bound.getCenter(); - PxVec3 tChange = (target - origin) * 0.5; - if (nExplodedViewState > 5) - { - tChange = (origin - target) / 3; - } - PxVec3 newTarget = target + tChange; - transformNew.p = transformOld.p + tChange; - dynamic->setGlobalPose(transformNew); - blastController.updateActorRenderableTransform(*actor, transformNew, false); - } - if (nExplodedViewState > 9) - nExplodedViewState = 0; - -#endif -} - -void BlastToolbar::on_btnJointsTool_clicked() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_btnFuseSelectedChunks_clicked() -{ - qDebug("%s", __FUNCTION__); -} - -void BlastToolbar::on_btnReset_clicked() -{ - nExplodedViewState = 0; - - SampleManager* pSampleManager = SampleManager::ins(); - bool bStopSimulation = pSampleManager->IsSimulating(); - pSampleManager->resetScene(); - // only show depth 0 if stop from simulation. Otherwise, just show as previous. - if (bStopSimulation) - { - BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins(); - pBlastSceneTree->hideAllChunks(); - std::vector<uint32_t> depths(1, 0); - pBlastSceneTree->setChunkVisible(depths, true); - // refresh display in scene tree - //pBlastSceneTree->updateValues(false); - SampleManager::ins()->m_bNeedRefreshTree = true; - } - updateValues(); -} - -void BlastToolbar::on_btnSimulatePlay_clicked() -{ - qDebug("%s", __FUNCTION__); - - SampleManager* pSampleManager = SampleManager::ins(); - if (!pSampleManager->IsSimulating()) - { - // force to recreate BlastFamilyModelSimple from project data - pSampleManager->resetScene(); - pSampleManager->EnableSimulating(true); - // set right damage mode - DamageToolController& damageToolController = pSampleManager->getDamageToolController(); - bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode(); - if (damageToolController.isDamageMode() && !bChecked) - { - on_btnDamage_clicked(); - } - } - else - { - // pause it or continue - PhysXController& physx = pSampleManager->getPhysXController(); - bool bState = physx.isPaused(); - physx.setPaused(!bState); - } -} - -void BlastToolbar::on_btnFrameStepForward_clicked() -{ - qDebug("%s", __FUNCTION__); - - SampleManager* pSampleManager = SampleManager::ins(); - if (!pSampleManager->IsSimulating()) - { - // force to recreate BlastFamilyModelSimple from project data - pSampleManager->resetScene(); - // set right damage mode - DamageToolController& damageToolController = pSampleManager->getDamageToolController(); - bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode(); - if (damageToolController.isDamageMode() && !bChecked) - { - on_btnDamage_clicked(); - } - } - pSampleManager->EnableSimulating(true); - pSampleManager->EnableStepforward(true); -} - -void BlastToolbar::on_btnDamage_clicked() -{ - qDebug("%s", __FUNCTION__); - SampleManager* pSampleManager = SampleManager::ins(); - DamageToolController& damageToolController = pSampleManager->getDamageToolController(); - if (damageToolController.IsEnabled()) - { - damageToolController.DisableController(); - damageToolController.setDamageMode(false); - btnDamage->setChecked(false); - } - else - { - damageToolController.EnableController(); - damageToolController.setDamageMode(true); - btnDamage->setChecked(true); - } -// pSampleManager->getDamageToolController().setDamageMode(!pSampleManager->getDamageToolController().isDamageMode()); -} - -void BlastToolbar::on_btnProjectile_clicked() -{ - qDebug("%s", __FUNCTION__); - - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager->IsSimulating()) - { - SceneController& sceneController = pSampleManager->getSceneController(); - sceneController.addProjectile(); - } - else - { - viewer_msg("Please use it when simulation runs."); - } -} - -void BlastToolbar::on_btnDropObject_clicked() -{ - qDebug("%s", __FUNCTION__); - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager->IsSimulating()) - { - on_btnReset_clicked(); - // if not use timer, it could go to strange paused state. - gDropTimer.start(10); - return; - } - gDropTimer.stop(); - BlastAssetInstancesNode* assetInstancesNode = BlastTreeData::ins().getBlastAssetInstancesNode(); - if (assetInstancesNode != nullptr) - { - physx::PxVec3 size = pSampleManager->getAssetExtent(); - float fChange = size.magnitude(); - size_t count = assetInstancesNode->children.size(); - // find the min height first - float minHeight = NV_MAX_F32; - for (size_t i = 0; i < count; ++i) - { - BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i]; - BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData(); - if (bppInstance) - { - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance); - if (family) - { - physx::PxTransform t = family->getSettings().transform; - if (GlobalSettings::Inst().m_zup) - { - if (t.p.z < minHeight) - minHeight = t.p.z; - } - else - { - if (t.p.y < minHeight) - minHeight = t.p.y; - } - } - } - } - // make fChange - while ((minHeight + fChange) < 0.0f) - { - fChange += fChange; - } - // change position - for (size_t i = 0; i < count; ++i) - { - BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i]; - BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData(); - if (bppInstance) - { - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance); - if (family) - { - physx::PxTransform t = family->getSettings().transform; - if (GlobalSettings::Inst().m_zup) - { - t.p.z += fChange; - } - else - { - t.p.y += fChange; - } - family->initTransform(t); - } - } - } - // have to reset scene to make the new positions used. - on_btnReset_clicked(); - pSampleManager->EnableSimulating(true); - // restore original position - for (size_t i = 0; i < count; ++i) - { - BlastAssetInstanceNode* assetInstanceNode = (BlastAssetInstanceNode*)assetInstancesNode->children[i]; - BPPAssetInstance* bppInstance = (BPPAssetInstance*)assetInstanceNode->getData(); - if (bppInstance) - { - BlastFamily* family = SampleManager::ins()->getFamilyByInstance(bppInstance); - if (family) - { - physx::PxTransform t = family->getSettings().transform; - if (GlobalSettings::Inst().m_zup) - { - t.p.z -= fChange; - } - else - { - t.p.y -= fChange; - } - family->initTransform(t); - } - } - } - // set right damage mode - DamageToolController& damageToolController = pSampleManager->getDamageToolController(); - bool bChecked = damageToolController.IsEnabled() && damageToolController.IsEnabled() && damageToolController.isDamageMode(); - if (damageToolController.isDamageMode() && !bChecked) - { - on_btnDamage_clicked(); - } - } -} - -void BlastToolbar::on_btnPreferences_clicked() -{ - qDebug("%s", __FUNCTION__); - - SampleManager* pSampleManager = SampleManager::ins(); - BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset(); - pSampleManager->saveAsset(pBlastAsset); -} - -void BlastToolbar::updateCheckIconsStates() -{ - SampleManager* pSampleManager = SampleManager::ins(); - SelectionToolController& selectionToolController = pSampleManager->getSelectionToolController(); - btnSelectTool->setChecked(selectionToolController.IsEnabled()); - - GizmoToolController& gizmoToolController = pSampleManager->getGizmoToolController(); - bool bGizmo = gizmoToolController.IsEnabled(); - GizmoToolMode mode = gizmoToolController.getGizmoToolMode(); - btnTranslate->setChecked(mode == GTM_Translate && bGizmo); - btnRotate->setChecked(mode == GTM_Rotation && bGizmo); - btnScale->setChecked(mode == GTM_Scale && bGizmo); -}
\ No newline at end of file diff --git a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h b/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h deleted file mode 100644 index 24129e8..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/BlastToolBar.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef BlastToolbar_h__ -#define BlastToolbar_h__ - -#include <QtWidgets/QApplication> -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QDockWidget> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QLabel> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QMenu> -#include <QtWidgets/QVBoxLayout> -#include <QtWidgets/QLineEdit> - -#include "SlideSpinBox.h" - -class BlastToolbar : public QDockWidget -{ - Q_OBJECT - -public: - BlastToolbar(QWidget* parent); - - void updateValues(); - -public slots: - void on_btnOpenProject_clicked(); - void on_btnSaveProject_clicked(); - void on_btnExportAssets_clicked(); - - void on_btnExportFilepath_clicked(); - void on_ssbiDepthPreview_valueChanged(int v); - void on_cbExactCoverage_stateChanged(int state); - - void on_btnSelectTool_clicked(); - void on_pointselect_action(); - void on_rectselect_action(); - void on_drawselect_action(); - - bool on_Translate_clicked(); - bool on_Rotation_clicked(); - bool on_Scale_clicked(); - void on_btnGizmoWithLocal_clicked(); - - void on_btnPaintbrush_clicked(); - void on_btnFractureTool_clicked(); - void on_btnExplodedViewTool_clicked(); - void on_btnJointsTool_clicked(); - void on_btnFuseSelectedChunks_clicked(); - - void on_btnReset_clicked(); - void on_btnSimulatePlay_clicked(); - void on_btnFrameStepForward_clicked(); - - void on_btnDamage_clicked(); - void on_btnProjectile_clicked(); - void on_btnDropObject_clicked(); - - void on_btnPreferences_clicked(); - - void updateCheckIconsStates(); - -private: - QHBoxLayout *hLayout; - QFrame *fSeparate; - - QPushButton *btnOpenProject; - QPushButton *btnSaveProject; - QPushButton *btnExportAssets; - - QVBoxLayout *vLayoutExport; - QHBoxLayout *hLayoutExport; - QLabel *lExportFilepath; - QPushButton *btnExportFilepath; - QLineEdit* leExportFilepath; - - QVBoxLayout *vLayoutDepthCoverage; - QHBoxLayout *hlDepthPreview; - QLabel *lbDepthPreview; - SlideSpinBoxInt* ssbiDepthPreview; - QHBoxLayout *hlExactCoverage; - QLabel *lbExactCoverage; - QCheckBox* cbExactCoverage; - - QPushButton *btnSelectTool; - QPushButton *btnTranslate; - QPushButton *btnRotate; - QPushButton *btnScale; - QPushButton *btnGizmoWithLocal; - - QPushButton *btnPaintbrush; - QPushButton *btnFractureTool; - QPushButton *btnExplodedViewTool; - QPushButton *btnJointsTool; - QPushButton *btnFuseSelectedChunks; - - QPushButton *btnReset; - QPushButton *btnSimulatePlay; - QPushButton *btnFrameStepForward; - - QPushButton *btnDamage; - QPushButton *btnProjectile; - QPushButton *btnDropObject; - - QPushButton *btnPreferences; - - bool m_fullCoverage; -}; -#endif // BlastToolbar_h__ diff --git a/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.cpp b/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.cpp deleted file mode 100644 index 4aa2b79..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "CollisionToolsDlg.h" -#include "ui_CollisionToolsDlg.h" - -CollisionToolsDlg::CollisionToolsDlg(QWidget *parent) : - QDialog(parent), - ui(new Ui::CollisionToolsDlg) -{ - ui->setupUi(this); -} - -CollisionToolsDlg::~CollisionToolsDlg() -{ - delete ui; -} - -void CollisionToolsDlg::on_comboBoxApplyFilter_currentIndexChanged(int index) -{ - -} - -void CollisionToolsDlg::on_comboBoxCollisionShape_currentIndexChanged(int index) -{ - -} - -void CollisionToolsDlg::on_spinBoxQuality_valueChanged(int arg1) -{ - -} - -void CollisionToolsDlg::on_spinBoxMaxHulls_valueChanged(int arg1) -{ - -} - -void CollisionToolsDlg::on_spinBoxTrimHulls_valueChanged(int arg1) -{ - -} - -void CollisionToolsDlg::on_comboBoxTargetPlatform_currentIndexChanged(int index) -{ - -} - -void CollisionToolsDlg::on_btnReset_clicked() -{ - -} - -void CollisionToolsDlg::on_btnApply_clicked() -{ - -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.h b/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.h deleted file mode 100644 index d3c8c00..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/CollisionToolsDlg.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef COLLISIONTOOLSDLG_H -#define COLLISIONTOOLSDLG_H - -#include <QtWidgets/QDialog> - -namespace Ui { -class CollisionToolsDlg; -} - -class CollisionToolsDlg : public QDialog -{ - Q_OBJECT - -public: - explicit CollisionToolsDlg(QWidget *parent = 0); - ~CollisionToolsDlg(); - -private slots: - void on_comboBoxApplyFilter_currentIndexChanged(int index); - - void on_comboBoxCollisionShape_currentIndexChanged(int index); - - void on_spinBoxQuality_valueChanged(int arg1); - - void on_spinBoxMaxHulls_valueChanged(int arg1); - - void on_spinBoxTrimHulls_valueChanged(int arg1); - - void on_comboBoxTargetPlatform_currentIndexChanged(int index); - - void on_btnReset_clicked(); - - void on_btnApply_clicked(); - -private: - Ui::CollisionToolsDlg *ui; -}; - -#endif // COLLISIONTOOLSDLG_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp deleted file mode 100644 index 5d82ce5..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include "DefaultDamagePanel.h" -#include "ui_DefaultDamagePanel.h" -#include "ProjectParams.h" -#include "BlastSceneTree.h" -#include <float.h> - -#include "DamageToolController.h" - -DefaultDamagePanel* gDefaultDamagePanel = nullptr; -DefaultDamagePanel* DefaultDamagePanel::ins() -{ - return gDefaultDamagePanel; -} - -QComboBox* DefaultDamagePanel::getDamageProfile() -{ - return ui->comboBoxDamageProfile; -} - -void DefaultDamagePanel::setUpdateData(bool bUpdateData) -{ - _updateData = bUpdateData; -} - -DefaultDamagePanel::DefaultDamagePanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::DefaultDamagePanel), - _updateData(true) -{ - gDefaultDamagePanel = this; - - ui->setupUi(this); - - _updateData = false; - ui->spinBoxDamageAmount->setRange(0.0f, DBL_MAX); - ui->spinBoxExplosiveImpulse->setRange(0.0f, DBL_MAX); - ui->spinBoxDamageRadius->setRange(0.0f, DBL_MAX); - ui->spinBoxStressDamageForce->setRange(0.0f, DBL_MAX); - ui->checkBoxDamageContinuously->setChecked(false); - _updateData = true; -} - -DefaultDamagePanel::~DefaultDamagePanel() -{ - delete ui; -} - -void DefaultDamagePanel::updateValues() -{ - _updateData = false; - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - if (damage.damageStructs.arraySizes[0] > 0) - { - uint32_t damageProfile = damage.damageProfile; - BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile]; - ui->spinBoxDamageAmount->setValue(damage.damageAmount); - ui->spinBoxExplosiveImpulse->setValue(damage.explosiveImpulse); - ui->spinBoxStressDamageForce->setValue(damage.stressDamageForce); - ui->comboBoxDamageProfile->setCurrentIndex(damageProfile); - ui->spinBoxDamageRadius->setValue(damageStruct.damageRadius); - ui->checkBoxDamageContinuously->setChecked(damageStruct.continuously); - } - else - { - ui->spinBoxDamageAmount->setValue(0); - ui->spinBoxExplosiveImpulse->setValue(0); - ui->spinBoxDamageRadius->setValue(0); - ui->spinBoxStressDamageForce->setValue(0); - ui->checkBoxDamageContinuously->setChecked(false); - ui->comboBoxDamageProfile->setCurrentIndex(0); - } - _updateData = true; -} - -void DefaultDamagePanel::dataSelected(std::vector<BlastNode*> selections) -{ - _selectedAssets.clear(); - - for (BlastNode* node: selections) - { - if (eAsset == node->getType()) - { - BPPAsset* asset = static_cast<BPPAsset*>(node->getData()); - _selectedAssets.push_back(asset); - } - } - - updateValues(); -} - -void DefaultDamagePanel::on_spinBoxDamageAmount_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - damage.damageAmount = arg1; - - DamageToolController::ins()->setDamageAmount(arg1); -} - -void DefaultDamagePanel::on_spinBoxExplosiveImpulse_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - damage.explosiveImpulse = arg1; - - DamageToolController::ins()->setExplosiveImpulse(arg1); -} - -void DefaultDamagePanel::on_spinBoxDamageRadius_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - uint32_t damageProfile = damage.damageProfile; - BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile]; - damageStruct.damageRadius = arg1; - - DamageToolController::ins()->setRadius(arg1); -} - -void DefaultDamagePanel::on_spinBoxStressDamageForce_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - damage.stressDamageForce = arg1; - - DamageToolController::ins()->setStressForceFactor(arg1); -} - -void DefaultDamagePanel::on_comboBoxDamageProfile_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - damage.damageProfile = index; - - DamageToolController::ins()->setDamagerIndex(index); - - updateValues(); -} - -void DefaultDamagePanel::on_checkBoxDamageContinuously_stateChanged(int arg1) -{ - if (!_updateData) - return; - - BPPDefaultDamage& damage = BlastProject::ins().getParams().defaultDamage; - uint32_t damageProfile = damage.damageProfile; - BPPDamageStruct& damageStruct = damage.damageStructs.buf[damageProfile]; - damageStruct.continuously = arg1; - - DamageToolController::ins()->setDamageWhilePressed(arg1); -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h b/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h deleted file mode 100644 index 044311e..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/DefaultDamagePanel.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef DEFAULTDAMAGEPANEL_H -#define DEFAULTDAMAGEPANEL_H - -#include <QtWidgets/QWidget> -#include <QtWidgets/QComboBox> -#include "BlastSceneTree.h" - -namespace Ui { -class DefaultDamagePanel; -} - -class DefaultDamagePanel : public QWidget, public ISceneObserver -{ - Q_OBJECT - -public: - explicit DefaultDamagePanel(QWidget *parent = 0); - ~DefaultDamagePanel(); - void updateValues(); - - static DefaultDamagePanel* ins(); - QComboBox* getDamageProfile(); - void setUpdateData(bool bUpdateData); - - virtual void dataSelected(std::vector<BlastNode*> selections); - -private slots: - void on_spinBoxDamageAmount_valueChanged(double arg1); - - void on_spinBoxExplosiveImpulse_valueChanged(double arg1); - - void on_spinBoxDamageRadius_valueChanged(double arg1); - - void on_spinBoxStressDamageForce_valueChanged(double arg1); - - void on_comboBoxDamageProfile_currentIndexChanged(int index); - - void on_checkBoxDamageContinuously_stateChanged(int arg1); - -private: - Ui::DefaultDamagePanel *ui; - bool _updateData; - std::vector<BPPAsset*> _selectedAssets; -}; - -#endif // DEFAULTDAMAGEPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp deleted file mode 100644 index b3b09b4..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include "FileReferencesPanel.h" -#include "ui_FileReferencesPanel.h" -#include "AppMainWindow.h" -#include <QtWidgets/QFileDialog> -#include <QtCore/QFile> -#include <QtCore/QDebug> -#include "GlobalSettings.h" -#include "SampleManager.h" -#include "ViewerOutput.h" - -FileReferencesPanel* gFileReferencesPanel = nullptr; -FileReferencesPanel* FileReferencesPanel::ins() -{ - return gFileReferencesPanel; -} - -FileReferencesPanel::FileReferencesPanel(QWidget *parent) - : QWidget(parent) - , ui(new Ui::FileReferencesPanel) -{ - ui->setupUi(this); - ui->lineEditFBXSourceAsset->setReadOnly(true); - - ui->lineEditFBX->setText("New.fbx"); - ui->lineEditObj->setText("New.obj"); - ui->lineEditLLAsset->setText("Newll.blast"); - ui->lineEditTKAsset->setText("Newtk.blast"); - ui->lineEditBPXA->setText("New.blast"); - bValid = false; - ui->checkBoxFBX->setChecked(false); - ui->checkBoxObj->setChecked(false); - ui->checkBoxLLAsset->setChecked(false); - ui->checkBoxTKAsset->setChecked(false); - ui->checkBoxBPXA->setChecked(false); - bValid = true; - - gFileReferencesPanel = this; - - updateValues(); -} - -FileReferencesPanel::~FileReferencesPanel() -{ - delete ui; -} - -void FileReferencesPanel::updateValues() -{ - AppMainWindow& window = AppMainWindow::Inst(); - BPParams& projectParams = BlastProject::ins().getParams(); - BPPFileReferences& fileReferences = projectParams.blast.fileReferences; - if (fileReferences.fbxSourceAsset.buf != nullptr) - ui->lineEditFBXSourceAsset->setText(fileReferences.fbxSourceAsset.buf); - else - ui->lineEditFBXSourceAsset->setText(""); - - ui->lineEditFBX->setText(""); - ui->lineEditObj->setText(""); - ui->lineEditLLAsset->setText(""); - ui->lineEditTKAsset->setText(""); - ui->lineEditBPXA->setText(""); - bValid = false; - ui->checkBoxFBX->setChecked(false); - ui->checkBoxObj->setChecked(false); - ui->checkBoxTKAsset->setChecked(false); - ui->checkBoxBPXA->setChecked(false); - bValid = true; - - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager == nullptr) - { - return; - } - - BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset(); - if (pBlastAsset == nullptr) - { - return; - } - - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset); - if (itADM == AssetDescMap.end()) - { - return; - } - - AssetList::ModelAsset modelAsset = itADM->second; - if (modelAsset.name.empty()) - { - return; - } - - BPPAssetArray& assetArray = projectParams.blast.blastAssets; - BPPAsset asset; - int aaas = 0; - for (; aaas < assetArray.arraySizes[0]; aaas++) - { - asset = assetArray.buf[aaas]; - std::string assetname = asset.name; - if (assetname == modelAsset.name) - break; - } - if (aaas == assetArray.arraySizes[0]) - { - return; - } - - QFileInfo fileInfo(modelAsset.name.c_str()); - - if (asset.fbx.buf != nullptr) - ui->lineEditFBX->setText(asset.fbx.buf); - else - { - ui->lineEditFBX->setText(fileInfo.baseName() + "_New.fbx"); - } - - if (asset.obj.buf != nullptr) - ui->lineEditObj->setText(asset.obj.buf); - else - { - ui->lineEditObj->setText(fileInfo.baseName() + "_New.obj"); - } - - if (asset.llasset.buf != nullptr) - ui->lineEditLLAsset->setText(asset.llasset.buf); - else - { - ui->lineEditLLAsset->setText(fileInfo.baseName() + "_Newll.blast"); - } - - if (asset.tkasset.buf != nullptr) - ui->lineEditTKAsset->setText(asset.tkasset.buf); - else - { - ui->lineEditTKAsset->setText(fileInfo.baseName() + "_Newtk.blast"); - } - - if (asset.bpxa.buf != nullptr) - ui->lineEditBPXA->setText(asset.bpxa.buf); - else - { - ui->lineEditBPXA->setText(fileInfo.baseName() + "_New.blast"); - } - - bValid = false; - ui->checkBoxFBX->setChecked(asset.exportFBX); - ui->checkBoxEmbedFBXCollision->setChecked(asset.embedFBXCollision); - ui->checkBoxObj->setChecked(asset.exportOBJ); - ui->checkBoxLLAsset->setChecked(asset.exportLLAsset); - ui->checkBoxTKAsset->setChecked(asset.exportTKAsset); - ui->checkBoxBPXA->setChecked(asset.exportBPXA); - bValid = true; -} - -void FileReferencesPanel::on_btnOpenFile_clicked() -{ - AppMainWindow& window = AppMainWindow::Inst(); - GlobalSettings& globalSettings = GlobalSettings::Inst(); - - BPParams& projectParams = BlastProject::ins().getParams(); - BPPFileReferences& fileReferences = projectParams.blast.fileReferences; - const char* fbxSourceAsset = fileReferences.fbxSourceAsset.buf; - QString lastDir = (fbxSourceAsset != nullptr ? fbxSourceAsset : window._lastFilePath); - QString fileName = QFileDialog::getOpenFileName(&window, "Open FBX File", lastDir, "FBX File (*.FBX)"); - - ui->lineEditFBXSourceAsset->setText(fileName); -} - -void FileReferencesPanel::on_btnReload_clicked() -{ - -} - -void FileReferencesPanel::on_btnRemove_clicked() -{ - BPParams& projectParams = BlastProject::ins().getParams(); - BPPFileReferences& fileReferences = projectParams.blast.fileReferences; - if (fileReferences.fbxSourceAsset.buf != nullptr) - { - ui->lineEditFBXSourceAsset->setText(""); - freeString(fileReferences.fbxSourceAsset); - // to do: remove source fbx file - } -} - -void FileReferencesPanel::on_checkBoxFBX_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.exportFBX = ui->checkBoxFBX->isChecked(); -} - -void FileReferencesPanel::on_checkBoxEmbedFBXCollision_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.embedFBXCollision = ui->checkBoxEmbedFBXCollision->isChecked(); -} - -void FileReferencesPanel::on_checkBoxObj_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.exportOBJ = ui->checkBoxObj->isChecked(); -} - -void FileReferencesPanel::on_checkBoxLLAsset_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.exportLLAsset = ui->checkBoxLLAsset->isChecked(); -} - -void FileReferencesPanel::on_checkBoxTKAsset_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.exportTKAsset = ui->checkBoxTKAsset->isChecked(); -} - -void FileReferencesPanel::on_checkBoxBPXA_stateChanged(int arg1) -{ - if (!bValid) - { - return; - } - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - asset.exportBPXA = ui->checkBoxBPXA->isChecked(); - - if (asset.exportBPXA) - { - bValid = false; - ui->checkBoxObj->setChecked(true); - asset.exportOBJ = true; - bValid = true; - } -} - -void FileReferencesPanel::on_btnSave_clicked() -{ - BPParams& projectParams = BlastProject::ins().getParams(); - BPPFileReferences& fileReferences = projectParams.blast.fileReferences; - - copy(fileReferences.fbxSourceAsset, ui->lineEditFBXSourceAsset->text().toUtf8().data()); - - BPPAsset* assetPtr = _getCurrentAsset(); - if (nullptr == assetPtr) - return; - - BPPAsset& asset = *assetPtr; - - copy(asset.fbx, ui->lineEditFBX->text().toUtf8().data()); - asset.exportFBX = ui->checkBoxFBX->isChecked(); - - copy(asset.obj, ui->lineEditObj->text().toUtf8().data()); - asset.exportOBJ = ui->checkBoxObj->isChecked(); - - copy(asset.llasset, ui->lineEditLLAsset->text().toUtf8().data()); - asset.exportLLAsset = ui->checkBoxLLAsset->isChecked(); - - copy(asset.tkasset, ui->lineEditTKAsset->text().toUtf8().data()); - asset.exportTKAsset = ui->checkBoxTKAsset->isChecked(); - - copy(asset.bpxa, ui->lineEditBPXA->text().toUtf8().data()); - asset.exportBPXA = ui->checkBoxBPXA->isChecked(); - - SampleManager::ins()->exportAsset(); -} - -BPPAsset* FileReferencesPanel::_getCurrentAsset() -{ - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager == nullptr) - { - return nullptr; - } - - BlastAsset* pBlastAsset = pSampleManager->getCurBlastAsset(); - if (pBlastAsset == nullptr) - { - return nullptr; - } - - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - std::map<BlastAsset*, AssetList::ModelAsset>::iterator itADM = AssetDescMap.find(pBlastAsset); - if (itADM == AssetDescMap.end()) - { - return nullptr; - } - - AssetList::ModelAsset modelAsset = itADM->second; - if (modelAsset.name.empty()) - { - return nullptr; - } - - BPParams& projectParams = BlastProject::ins().getParams(); - BPPAssetArray& assetArray = projectParams.blast.blastAssets; - int aaas = 0; - for (; aaas < assetArray.arraySizes[0]; aaas++) - { - std::string assetname = assetArray.buf[aaas].name; - if (assetname == modelAsset.name) - break; - } - if (aaas == assetArray.arraySizes[0]) - { - return nullptr; - } - - BPPAsset& asset = assetArray.buf[aaas]; - - return &asset; -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h deleted file mode 100644 index 9accf6a..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FileReferencesPanel.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef FILEREFERENCESPANEL_H -#define FILEREFERENCESPANEL_H - -#include <QtWidgets/QWidget> - -namespace Ui { -class FileReferencesPanel; -} - -#include "ProjectParams.h" - -class FileReferencesPanel : public QWidget -{ - Q_OBJECT - -public: - explicit FileReferencesPanel(QWidget *parent = 0); - ~FileReferencesPanel(); - void updateValues(); - - static FileReferencesPanel* ins(); - -public slots: - void on_btnOpenFile_clicked(); - - void on_btnReload_clicked(); - - void on_btnRemove_clicked(); - - void on_checkBoxFBX_stateChanged(int arg1); - - void on_checkBoxEmbedFBXCollision_stateChanged(int arg1); - - void on_checkBoxObj_stateChanged(int arg1); - - void on_checkBoxLLAsset_stateChanged(int arg1); - - void on_checkBoxTKAsset_stateChanged(int arg1); - - void on_checkBoxBPXA_stateChanged(int arg1); - - void on_btnSave_clicked(); - -private: - BPPAsset* _getCurrentAsset(); - -private: - Ui::FileReferencesPanel *ui; - bool bValid; -}; - -#endif // FILEREFERENCESPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp deleted file mode 100644 index daf4397..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.cpp +++ /dev/null @@ -1,877 +0,0 @@ -#include "FiltersDockWidget.h" -#include "ui_FiltersDockWidget.h" -#include <QtWidgets/QInputDialog> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QMessageBox> -#include "SampleManager.h" -#include "BlastSceneTree.h" -#include "BlastFamily.h" -#include "ViewerOutput.h" - -const QString LISTITEM_NORMAL_STYLESHEET = ":enabled { background: rgb(68,68,68); }"; - -const QString LISTITEM_SELECTED_STYLESHEET = ":enabled { background: rgba(118,185,0, 250); }"; - -const QString LISTITEM_BUTTON_STYLESHEET = ":enabled { border: 0px; }"; - -class FilterOperation -{ -public: - virtual void execute(BlastNode *node) = 0; -}; - -class FilterVisitor : public BlastVisitorBase -{ -public: - FilterVisitor(FilterPreset& filterPreset, FilterOperation& filterOperation) - : resultCount(0) - , _filterPreset(filterPreset) - , _filterOperation(filterOperation) - - { - - } - - virtual void visit(BlastNode *node); - - int resultCount; -private: - bool _canSatisfyFilter(BlastNode *node); - - FilterPreset& _filterPreset; - FilterOperation& _filterOperation; -}; - -void FilterVisitor::visit(BlastNode *node) -{ - if (_canSatisfyFilter(node)) - { - _filterOperation.execute(node); - ++resultCount; - } -} - -bool FilterVisitor::_canSatisfyFilter(BlastNode *node) -{ - EFilterRestriction restrictions = eFilterRestriction_Invalid; - - for (std::vector<EFilterRestriction>::iterator itr = _filterPreset.filters.begin(); itr != _filterPreset.filters.end(); ++itr) - { - restrictions = (EFilterRestriction)(restrictions | (*itr)); - } - - bool matchDepth = false, matchItemType = false; - - // jude whether current node can be filtered by depth restrictions - if (restrictions & eFilterRestriction_DepthAll) - { - matchDepth = true; - } - else - { - int nodeDepth = BlastTreeData::getDepth(node); - int allDepthRestrictions = eFilterRestriction_Depth0 | eFilterRestriction_Depth1 | eFilterRestriction_Depth2 | eFilterRestriction_Depth3 | eFilterRestriction_Depth4 | eFilterRestriction_Depth5; - - if ((restrictions & eFilterRestriction_AllDescendants) && (restrictions & eFilterRestriction_AllParents)) - { - if (restrictions & allDepthRestrictions) - { - matchDepth = true; - } - } - else if ((restrictions & eFilterRestriction_AllDescendants) && !(restrictions & eFilterRestriction_AllParents)) - { - int expectMinDepthRestirction = 5; - if ((restrictions & eFilterRestriction_Depth0)) - { - expectMinDepthRestirction = 0; - } - else if ((restrictions & eFilterRestriction_Depth1)) - { - expectMinDepthRestirction = 1; - } - else if ((restrictions & eFilterRestriction_Depth2)) - { - expectMinDepthRestirction = 2; - } - else if ((restrictions & eFilterRestriction_Depth3)) - { - expectMinDepthRestirction = 3; - } - else if ((restrictions & eFilterRestriction_Depth4)) - { - expectMinDepthRestirction = 4; - } - else if ((restrictions & eFilterRestriction_Depth5)) - { - expectMinDepthRestirction = 5; - } - - if (expectMinDepthRestirction <= nodeDepth) - { - matchDepth = true; - } - } - else if (!(restrictions & eFilterRestriction_AllDescendants) && (restrictions & eFilterRestriction_AllParents)) - { - int expectMaxDepthRestirction = 0; - if ((restrictions & eFilterRestriction_Depth5)) - { - expectMaxDepthRestirction = 5; - } - else if ((restrictions & eFilterRestriction_Depth4)) - { - expectMaxDepthRestirction = 4; - } - else if ((restrictions & eFilterRestriction_Depth3)) - { - expectMaxDepthRestirction = 3; - } - else if ((restrictions & eFilterRestriction_Depth2)) - { - expectMaxDepthRestirction = 2; - } - else if ((restrictions & eFilterRestriction_Depth1)) - { - expectMaxDepthRestirction = 1; - } - else if ((restrictions & eFilterRestriction_Depth0)) - { - expectMaxDepthRestirction = 0; - } - - if (nodeDepth <= expectMaxDepthRestirction) - { - matchDepth = true; - } - } - else if (!(restrictions & eFilterRestriction_AllDescendants) && !(restrictions & eFilterRestriction_AllParents)) - { - EFilterRestriction expectDepthRestriction = (EFilterRestriction)(eFilterRestriction_Depth0 << nodeDepth); - - if (restrictions & expectDepthRestriction) - { - matchDepth = true; - } - } - } - - // jude whether current node can be filtered by item type restrictions - if ((restrictions & eFilterRestriction_ItemTypeAll)) - { - matchItemType = true; - } - else - { - EBlastNodeType nodeType = node->getType(); - if (eChunk == nodeType) - { - BlastChunkNode* chunkNode = (BlastChunkNode*)node; - if (restrictions & eFilterRestriction_Chunk) - { - matchItemType = true; - } - else if (restrictions & eFilterRestriction_SupportChunk) - { - if (chunkNode->isSupport()) - { - matchItemType = true; - } - } - else if (restrictions & eFilterRestriction_StaticSupportChunk) - { - if (chunkNode->isSupport() && chunkNode->isStatic()) - { - matchItemType = true; - } - } - } - else if (eBond == nodeType) - { - BlastBondNode* bondNode = (BlastBondNode*)node; - if (restrictions & eFilterRestriction_Bond) - { - matchItemType = true; - } - else if (restrictions & eFilterRestriction_WorldBond) - { - if (bondNode->isWolrd()) - { - matchItemType = true; - } - } - } - } - - if ((restrictions & eFilterRestriction_EqualTo) && (restrictions & eFilterRestriction_NotEquaTo)) - { - return true; - } - else if (!(restrictions & eFilterRestriction_EqualTo) && !(restrictions & eFilterRestriction_NotEquaTo) - || (restrictions & eFilterRestriction_EqualTo)) - { - if (matchDepth && matchItemType) - return true; - } - else if ((restrictions & eFilterRestriction_NotEquaTo)) - { - if (!(matchDepth && matchItemType)) - return true; - } - - return false; -} - -class FilterSelectOperation : public FilterOperation -{ -public: - virtual void execute(BlastNode *node) - { - if (nullptr != node) - { - BlastSceneTree::ins()->selectTreeItem(node); - } - } -}; - -class FilterVisibilityOperation : public FilterOperation -{ -public: - FilterVisibilityOperation(bool visible) - : _visible(visible) - { - } - - virtual void execute(BlastNode *node) - { - if (nullptr != node) - { - node->setVisible(_visible); - } - } - -private: - bool _visible; -}; - -struct FilterItemInfo -{ -public: - FilterItemInfo(FilterItemWidget* inWidget, const QString& inText) - : itemWidget(inWidget) - , text(inText) - { - } - - FilterItemWidget* itemWidget; - QString text; -}; - -FilterItemWidget::FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, EFilterRestriction restriction) - : QWidget(parent) - , _relatedListWidgetItem(item) - , _filterPreset(filterPreset) - , _restriction(restriction) -{ - QHBoxLayout* layout = new QHBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - _label = new QLabel(this); - - _removeBtn = new QPushButton(this); - _removeBtn->setMaximumSize(20, 20); - _removeBtn->setText("X"); - _removeBtn->setStyleSheet(LISTITEM_BUTTON_STYLESHEET); - - layout->addWidget(_label); - layout->addWidget(_removeBtn); - - this->setLayout(layout); - - QObject::connect(_removeBtn, SIGNAL(clicked()), this, SLOT(onRemoveButtonClicked())); - QObject::connect(this, SIGNAL(RemoveItem(QListWidgetItem*)), parent, SLOT(onListWidgetRemoveBtnClicked(QListWidgetItem*))); - - deSelect(); -} - -void FilterItemWidget::setText(const QString& title) -{ - _label->setText(title); -} - -void FilterItemWidget::select() -{ - _label->setStyleSheet(LISTITEM_SELECTED_STYLESHEET); -} - -void FilterItemWidget::deSelect() -{ - _label->setStyleSheet(LISTITEM_NORMAL_STYLESHEET); -} - -void FilterItemWidget::onRemoveButtonClicked() -{ - emit RemoveItem(_relatedListWidgetItem); -} - -FiltersDockWidget::FiltersDockWidget(QWidget *parent) : - QDockWidget(parent), - ui(new Ui::FiltersDockWidget), - _updateData(true), - _filterUIItems(), - _filterItemWidgets(), - _lastSelectRow(-1) -{ - ui->setupUi(this); - - _restrictionActionMap[eFilterRestriction_AllDescendants] = ui->actionAllDescendants; - _restrictionActionMap[eFilterRestriction_AllParents] = ui->actionAllParents; - _restrictionActionMap[eFilterRestriction_DepthAll] = ui->actionDepthAll; - _restrictionActionMap[eFilterRestriction_Depth0] = ui->actionDepth0; - _restrictionActionMap[eFilterRestriction_Depth1] = ui->actionDepth1; - _restrictionActionMap[eFilterRestriction_Depth2] = ui->actionDepth2; - _restrictionActionMap[eFilterRestriction_Depth3] = ui->actionDepth3; - _restrictionActionMap[eFilterRestriction_Depth4] = ui->actionDepth4; - _restrictionActionMap[eFilterRestriction_Depth5] = ui->actionDepth5; - _restrictionActionMap[eFilterRestriction_ItemTypeAll] = ui->actionItemTypeAll; - _restrictionActionMap[eFilterRestriction_Chunk] = ui->actionChunk; - _restrictionActionMap[eFilterRestriction_SupportChunk] = ui->actionSupportChunk; - _restrictionActionMap[eFilterRestriction_StaticSupportChunk] = ui->actionStaticSupportChunk; - _restrictionActionMap[eFilterRestriction_Bond] = ui->actionBond; - _restrictionActionMap[eFilterRestriction_WorldBond] = ui->actionWorldBond; - _restrictionActionMap[eFilterRestriction_EqualTo] = ui->actionEqualTo; - _restrictionActionMap[eFilterRestriction_NotEquaTo] = ui->actionNotEquaTo; - - _updateFilterItemList(); -} - -FiltersDockWidget::~FiltersDockWidget() -{ - delete ui; -} - -void FiltersDockWidget::updateValues() -{ - _updateData = false; - ui->comboBoxFilterPreset->clear(); - std::vector<FilterPreset>& filterPresets = BlastProject::ins().getFilterPresets(); - QStringList filterNames; - filterNames.append("Default"); - int count = (int)filterPresets.size(); - for (int i = 0; i < count; ++i) - { - filterNames.append(filterPresets[i].name.c_str()); - } - ui->comboBoxFilterPreset->addItems(filterNames); - - BPParams& projectParams = BlastProject::ins().getParams(); - if (nullptr == projectParams.filter.activeFilter.buf - || 0 == strlen(projectParams.filter.activeFilter.buf) - || !(BlastProject::ins().isFilterPresetNameExist(projectParams.filter.activeFilter.buf))) - { - ui->comboBoxFilterPreset->setCurrentIndex(0); - } - else - { - ui->comboBoxFilterPreset->setCurrentText(projectParams.filter.activeFilter.buf); - } - - _updateFilterItemList(); - - if (count > 0) - { - ui->btnModifyFilterPreset->setEnabled(true); - ui->btnRemoveFilterPreset->setEnabled(true); - } - else - { - ui->btnModifyFilterPreset->setEnabled(false); - ui->btnRemoveFilterPreset->setEnabled(false); - } - _updateData = true; -} - -void FiltersDockWidget::on_comboBoxFilterPreset_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - BPParams& projectParams = BlastProject::ins().getParams(); - copy(projectParams.filter.activeFilter, ui->comboBoxFilterPreset->currentText().toUtf8().data()); - - _updateFilterItemList(); -} - -void FiltersDockWidget::on_btnAddFilterPrest_clicked() -{ - bool ok = false; - QString name = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input name for new filter preset:"), - QLineEdit::Normal, - "", - &ok); - bool nameExist = BlastProject::ins().isFilterPresetNameExist(name.toUtf8().data()); - if (ok && !name.isEmpty() && !nameExist) - { - BlastProject::ins().addFilterPreset(name.toUtf8().data()); - updateValues(); - ui->comboBoxFilterPreset->setCurrentIndex(ui->comboBoxFilterPreset->count() - 1); - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && name.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the new filter preset!"); - } -} - -void FiltersDockWidget::on_btnModifyFilterPreset_clicked() -{ - if (ui->comboBoxFilterPreset->currentIndex() < 1) - { - QMessageBox::warning(this, "Blast Tool", "You should select an filter preset!"); - return; - } - - QByteArray tmp = ui->comboBoxFilterPreset->currentText().toUtf8(); - const char* oldName = tmp.data(); - - bool ok = false; - QString newName = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input new name for the selected filter preset:"), - QLineEdit::Normal, - oldName, - &ok); - bool nameExist = BlastProject::ins().isFilterPresetNameExist(newName.toUtf8().data()); - if (ok && !newName.isEmpty() && !nameExist) - { - int index = ui->comboBoxFilterPreset->currentIndex(); - BlastProject::ins().renameFilterPreset(oldName, newName.toUtf8().data()); - updateValues(); - ui->comboBoxFilterPreset->setCurrentIndex(index); - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && newName.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected filter preset!"); - } -} - -void FiltersDockWidget::on_btnRemoveFilterPreset_clicked() -{ - if (ui->comboBoxFilterPreset->currentIndex() < 1) - { - QMessageBox::warning(this, "Blast Tool", "You should select an filter preset!"); - return; - } - - QByteArray tmp = ui->comboBoxFilterPreset->currentText().toUtf8(); - const char* name = tmp.data(); - BlastProject::ins().removeFilterPreset(name); - updateValues(); -} - -void FiltersDockWidget::on_btnSaveFilterPreset_clicked() -{ - BlastProject::ins().saveFilterPreset(); -} - -void FiltersDockWidget::on_actionAllDescendants_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_AllDescendants, checked); -} - -void FiltersDockWidget::on_actionAllParents_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_AllParents, checked); -} - -void FiltersDockWidget::on_actionDepthAll_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_DepthAll, checked); -} - -void FiltersDockWidget::on_actionDepth0_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Depth0, checked); -} - -void FiltersDockWidget::on_actionDepth1_triggered(bool checked) -{ - _addRemoveRestriction(eFilterRestriction_Depth1, checked); -} - -void FiltersDockWidget::on_actionDepth2_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Depth2, checked); -} - -void FiltersDockWidget::on_actionDepth3_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Depth3, checked); -} - -void FiltersDockWidget::on_actionDepth4_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Depth4, checked); -} - -void FiltersDockWidget::on_actionDepth5_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Depth5, checked); -} - -void FiltersDockWidget::on_actionItemTypeAll_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_ItemTypeAll, checked); -} - -void FiltersDockWidget::on_actionChunk_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Chunk, checked); -} - -void FiltersDockWidget::on_actionSupportChunk_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_SupportChunk, checked); -} - -void FiltersDockWidget::on_actionStaticSupportChunk_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_StaticSupportChunk, checked); -} - -void FiltersDockWidget::on_actionBond_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_Bond, checked); -} - -void FiltersDockWidget::on_actionWorldBond_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_WorldBond, checked); -} - -void FiltersDockWidget::on_actionEqualTo_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_EqualTo, checked); -} - -void FiltersDockWidget::on_actionNotEquaTo_triggered(bool checked) -{ - if (!_updateData) - return; - - _addRemoveRestriction(eFilterRestriction_NotEquaTo, checked); -} - -void FiltersDockWidget::on_btnSelect_clicked() -{ - FilterPreset filterPreset("Default"); - FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data()); - if (nullptr == filterPresetPtr) - { - BPPFilter& bppFilter = BlastProject::ins().getParams().filter; - for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i) - { - filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i])); - } - } - else - { - filterPreset = *filterPresetPtr; - } - - // clear old selection - BlastSceneTree::ins()->updateValues(false); - - FilterSelectOperation operation; - FilterVisitor visitor(filterPreset, operation); - BlastTreeData::ins().traverse(visitor); - - if (0 == visitor.resultCount) - { - viewer_msg("No items statify current filters"); - } - //BlastSceneTree::ins()->updateValues(false); - - //std::vector<uint32_t> depths; - //for (FilterItemWidget* itemWidget : _filterItemWidgets) - //{ - // depths.push_back(itemWidget->_restriction); - //} - ////SampleManager::ins()->setChunkSelected(depths, true); - //BlastSceneTree::ins()->setChunkSelected(depths, true); -} - -void FiltersDockWidget::on_btnVisible_clicked() -{ - FilterPreset filterPreset("Default"); - FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data()); - if (nullptr == filterPresetPtr) - { - BPPFilter& bppFilter = BlastProject::ins().getParams().filter; - for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i) - { - filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i])); - } - } - else - { - filterPreset = *filterPresetPtr; - } - - FilterVisibilityOperation operation(true); - FilterVisitor visitor(filterPreset, operation); - BlastTreeData::ins().traverse(visitor); - BlastSceneTree::ins()->updateValues(false); - if (0 == visitor.resultCount) - { - viewer_msg("No items statify current filters"); - } - //std::vector<uint32_t> depths; - //for (FilterItemWidget* itemWidget : _filterItemWidgets) - //{ - // depths.push_back(itemWidget->_restriction); - //} - ////SampleManager::ins()->setChunkVisible(depths, true); - //BlastSceneTree::ins()->setChunkVisible(depths, true); - //// refresh display in scene tree - //BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins(); - //pBlastSceneTree->updateValues(false); -} - -void FiltersDockWidget::on_btnInVisible_clicked() -{ - FilterPreset filterPreset("Default"); - FilterPreset* filterPresetPtr = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data()); - if (nullptr == filterPresetPtr) - { - BPPFilter& bppFilter = BlastProject::ins().getParams().filter; - for (int i = 0; i < bppFilter.filterRestrictions.arraySizes[0]; ++i) - { - filterPreset.filters.push_back(convertStringToFilterRestriction(bppFilter.filterRestrictions.buf[i])); - } - } - else - { - filterPreset = *filterPresetPtr; - } - - FilterVisibilityOperation operation(false); - FilterVisitor visitor(filterPreset, operation); - BlastTreeData::ins().traverse(visitor); - BlastSceneTree::ins()->updateValues(false); - if (0 == visitor.resultCount) - { - viewer_msg("No items statify current filters"); - } - //std::vector<uint32_t> depths; - //for (FilterItemWidget* itemWidget : _filterItemWidgets) - //{ - // depths.push_back(itemWidget->_restriction); - //} - ////SampleManager::ins()->setChunkVisible(depths, false); - //BlastSceneTree::ins()->setChunkVisible(depths, false); - //// refresh display in scene tree - //BlastSceneTree* pBlastSceneTree = BlastSceneTree::ins(); - //pBlastSceneTree->updateValues(false); -} - -void FiltersDockWidget::on_listWidget_currentRowChanged(int index) -{ - if (!_updateData) - return; - - if (-1 != _lastSelectRow && _lastSelectRow < _filterItemWidgets.size()) - static_cast<FilterItemWidget*>(_filterItemWidgets[_lastSelectRow])->deSelect(); - - if (-1 != index && index < _filterItemWidgets.size()) - static_cast<FilterItemWidget*>(_filterItemWidgets[index])->select(); - - _lastSelectRow = index; -} - -void FiltersDockWidget::onListWidgetRemoveBtnClicked(QListWidgetItem* item) -{ - /// remove former ui info - map<QListWidgetItem*, FilterItemInfo*>::iterator toRemoveItem = _filterUIItems.find(item); - if (toRemoveItem != _filterUIItems.end()) - { - FilterItemWidget* itemWidget = toRemoveItem->second->itemWidget; - itemWidget->setParent(nullptr); - - _filterItemWidgets.erase(std::find(_filterItemWidgets.begin(), _filterItemWidgets.end(), toRemoveItem->second->itemWidget)); - - if (0 < ui->comboBoxFilterPreset->currentIndex()) - { - QByteArray filterPreset = itemWidget->_filterPreset.toUtf8(); - BlastProject::ins().removeFilterRestriction(filterPreset.data(), itemWidget->_restriction); - } - else if (0 == ui->comboBoxFilterPreset->currentIndex()) - { - removeItem(BlastProject::ins().getParams().filter.filterRestrictions, convertFilterRestrictionToString(itemWidget->_restriction)); - } - - ui->listWidget->takeItem(ui->listWidget->row(item)); - ui->listWidget->removeItemWidget(item); - delete item; - delete itemWidget; - _filterUIItems.erase(toRemoveItem); - - _updateFilterItemList(); - - } -} - -void FiltersDockWidget::_updateFilterItemList() -{ - _updateData = false; - /// remove former ui info - map<QListWidgetItem*, FilterItemInfo*>::iterator theEnd = _filterUIItems.end(); - for (map<QListWidgetItem*, FilterItemInfo*>::iterator itr = _filterUIItems.begin(); itr != theEnd; ++itr) - { - itr->second->itemWidget->setParent(nullptr); - delete itr->first; - delete itr->second->itemWidget; - delete itr->second; - } - _filterUIItems.clear(); - ui->listWidget->clear(); - _filterItemWidgets.clear(); - - FilterPreset* filterPreset = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data()); - - if (nullptr != filterPreset) - { - for (EFilterRestriction restriction : filterPreset->filters) - { - _addFilterListItem(filterPreset->name.c_str(), restriction); - } - } - else - { - BPParams& projectParams = BlastProject::ins().getParams(); - BPPStringArray& filterRestrictions = projectParams.filter.filterRestrictions; - - for (int i = 0; i < filterRestrictions.arraySizes[0]; ++i) - { - _addFilterListItem("Default", convertStringToFilterRestriction(filterRestrictions.buf[i].buf)); - } - } - - _updateFilterUIs(); - - _updateData = true; -} - -void FiltersDockWidget::_addFilterListItem(const char* filterPresetName, EFilterRestriction restriction) -{ - QListWidgetItem* item = new QListWidgetItem(NULL); - FilterItemWidget* itemWidget = new FilterItemWidget(this, item, filterPresetName, restriction); - - QString depthFilterLabel = convertFilterRestrictionToString(restriction); - _filterUIItems.insert(std::make_pair(item, new FilterItemInfo(itemWidget, depthFilterLabel))); - itemWidget->setText(depthFilterLabel); - _filterItemWidgets.push_back(itemWidget); - - ui->listWidget->addItem(item); - ui->listWidget->setItemWidget(item, itemWidget); -} - -void FiltersDockWidget::_updateFilterUIs() -{ - for (map<EFilterRestriction, QAction*>::iterator itr = _restrictionActionMap.begin(); itr != _restrictionActionMap.end(); ++itr) - itr->second->setChecked(false); - - FilterPreset* filterPreset = BlastProject::ins().getFilterPreset(ui->comboBoxFilterPreset->currentText().toUtf8().data()); - - if (nullptr != filterPreset) - { - for (EFilterRestriction restriction : filterPreset->filters) - { - _restrictionActionMap[restriction]->setChecked(true); - } - } - else - { - BPPStringArray& filterRestrictions = BlastProject::ins().getParams().filter.filterRestrictions; - - for (int i = 0; i < filterRestrictions.arraySizes[0]; ++i) - { - _restrictionActionMap[convertStringToFilterRestriction(filterRestrictions.buf[i].buf)]->setChecked(true); - } - } -} - -void FiltersDockWidget::_addRemoveRestriction(EFilterRestriction restriction, bool add) -{ - if (0 < ui->comboBoxFilterPreset->currentIndex()) - { - QByteArray filterPreset = ui->comboBoxFilterPreset->currentText().toUtf8(); - - if (add) - BlastProject::ins().addFilterRestriction(filterPreset.data(), restriction); - else - BlastProject::ins().removeFilterRestriction(filterPreset.data(), restriction); - } - else if (0 == ui->comboBoxFilterPreset->currentIndex()) - { - BPPFilter& filter = BlastProject::ins().getParams().filter; - if (add) - addItem(filter.filterRestrictions, convertFilterRestrictionToString(restriction)); - else - removeItem(filter.filterRestrictions, convertFilterRestrictionToString(restriction)); - } - _updateFilterItemList(); -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h b/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h deleted file mode 100644 index 43606dc..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FiltersDockWidget.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef FILTERSDOCKWIDGET_H -#define FILTERSDOCKWIDGET_H - -#include <QtWidgets/QDockWidget> -#include <vector> -#include <map> -#include "ProjectParams.h" -using namespace std; - -namespace Ui { -class FiltersDockWidget; -} - -class QLabel; -class QPushButton; -class QListWidgetItem; -class QAction; -struct FilterItemInfo; -class FilterItemWidget; -class FiltersDockWidget; - -class FilterItemWidget : public QWidget -{ - Q_OBJECT -public: - FilterItemWidget(FiltersDockWidget* parent, QListWidgetItem* item, const QString& filterPreset, EFilterRestriction restriction); - ~FilterItemWidget() - { - } - - void setText(const QString& title); - void select(); - void deSelect(); - -signals: - void RemoveItem(QListWidgetItem* item); - -private slots: - void onRemoveButtonClicked(); - -public: - QLabel* _label; - QPushButton* _removeBtn; - QListWidgetItem* _relatedListWidgetItem; - QString _filterPreset; - EFilterRestriction _restriction; -}; - -class FiltersDockWidget : public QDockWidget -{ - Q_OBJECT - -public: - explicit FiltersDockWidget(QWidget *parent = 0); - ~FiltersDockWidget(); - void updateValues(); - -private slots: - void on_comboBoxFilterPreset_currentIndexChanged(int index); - void on_btnAddFilterPrest_clicked(); - void on_btnModifyFilterPreset_clicked(); - void on_btnRemoveFilterPreset_clicked(); - void on_btnSaveFilterPreset_clicked(); - void on_actionAllDescendants_triggered(bool checked); - void on_actionAllParents_triggered(bool checked); - void on_actionDepthAll_triggered(bool checked); - void on_actionDepth0_triggered(bool checked); - void on_actionDepth1_triggered(bool checked); - void on_actionDepth2_triggered(bool checked); - void on_actionDepth3_triggered(bool checked); - void on_actionDepth4_triggered(bool checked); - void on_actionDepth5_triggered(bool checked); - void on_actionItemTypeAll_triggered(bool checked); - void on_actionChunk_triggered(bool checked); - void on_actionSupportChunk_triggered(bool checked); - void on_actionStaticSupportChunk_triggered(bool checked); - void on_actionBond_triggered(bool checked); - void on_actionWorldBond_triggered(bool checked); - void on_actionEqualTo_triggered(bool checked); - void on_actionNotEquaTo_triggered(bool checked); - void on_btnSelect_clicked(); - void on_btnVisible_clicked(); - void on_btnInVisible_clicked(); - void on_listWidget_currentRowChanged(int index); - void onListWidgetRemoveBtnClicked(QListWidgetItem* item); - -private: - void _updateFilterItemList(); - void _addFilterListItem(const char* filterPresetName, EFilterRestriction restriction); - void _updateFilterUIs(); - void _addRemoveRestriction(EFilterRestriction restriction, bool add); - -private: - Ui::FiltersDockWidget *ui; - bool _updateData; - map<QListWidgetItem*, FilterItemInfo*> _filterUIItems; - vector<FilterItemWidget*> _filterItemWidgets; - int _lastSelectRow; - map<EFilterRestriction, QAction*> _restrictionActionMap; -}; - -#endif // FILTERSDOCKWIDGET_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp deleted file mode 100644 index 8a92933..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "FractureGeneralPanel.h" -#include "ui_FractureGeneralPanel.h" -#include "ProjectParams.h" -#include "BlastPlugin.h" -#include <QtWidgets/QInputDialog> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QMessageBox> -#include "FractureVoronoiSettingsPanel.h" -#include "FractureSliceSettingsPanel.h" -#include "FractureVisualizersPanel.h" -#include "ExpandablePanel.h" -#include "SampleManager.h" - -FractureGeneralPanel* pFractureGeneralPanel = nullptr; -FractureGeneralPanel* FractureGeneralPanel::ins() -{ - return pFractureGeneralPanel; -} - -FractureGeneralPanel::FractureGeneralPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::FractureGeneralPanel), - _updateData(true), - _voronoiPanel(nullptr), - _slicePanel(nullptr), - _visualizersPanel(nullptr), - _fractureVoronoiSettingsExpandlePanel(nullptr), - _fractureSliceSettingsExpandlePanel(nullptr) -{ - ui->setupUi(this); - pFractureGeneralPanel = this; - m_bValid = true; - - QStringList types; - types << "Voronoi" << "Slice"; - _updateData = false; - ui->comboBoxFractureType->addItems(types); - ui->comboBoxFractureType->setCurrentIndex(0); - _updateData = true; -} - -FractureGeneralPanel::~FractureGeneralPanel() -{ - delete ui; -} - -void FractureGeneralPanel::updateValues() -{ - _updateData = false; - m_bValid = false; - ui->comboBoxApplyMaterial->clear(); - m_bValid = true; - - QStringList materialNames; - materialNames.append("None"); - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials; - int count = theArray.arraySizes[0]; - for (int i = 0; i < count; ++i) - { - BPPGraphicsMaterial& item = theArray.buf[i]; - materialNames.append(item.name.buf); - } - - m_bValid = false; - ui->comboBoxApplyMaterial->insertItems(0, materialNames); - m_bValid = true; - - BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general; - - std::vector<FracturePreset> presets = BlastProject::ins().getFracturePresets(); - ui->comboBoxFracturePreset->clear(); - QStringList presetNames; - presetNames.append("Default"); - int countPresets = (int)presets.size(); - if (countPresets > 0) - { - for (int i = 0; i < countPresets; ++i) - { - presetNames.append(presets[i].name.c_str()); - } - } - ui->comboBoxFracturePreset->addItems(presetNames); - - if (nullptr == fractureGeneral.fracturePreset.buf - || 0 == strlen(fractureGeneral.fracturePreset.buf) - || !(BlastProject::ins().isFracturePresetNameExist(fractureGeneral.fracturePreset.buf))) - { - ui->comboBoxFracturePreset->setCurrentIndex(0); - } - else - { - ui->comboBoxFracturePreset->setCurrentText(fractureGeneral.fracturePreset.buf); - } - _updateFractureUIs(); - ui->comboBoxApplyMaterial->setCurrentIndex(fractureGeneral.applyMaterial); - - bool checked = BlastProject::ins().getParams().fracture.general.autoSelectNewChunks; - ui->checkBoxAutoSelectNewChunks->setChecked(checked); - _updateData = true; -} - -void FractureGeneralPanel::setFracturePanels(FractureVoronoiSettingsPanel* voronoiPanel, FractureSliceSettingsPanel* slicePanel, FractureVisualizersPanel* visulizersPanel) -{ - _voronoiPanel = voronoiPanel; - _slicePanel = slicePanel; - _visualizersPanel = visulizersPanel; -} - -void FractureGeneralPanel::setFractureExpandablePanels(ExpandablePanel* voronoiPanel, ExpandablePanel* slicePanel) -{ - _fractureVoronoiSettingsExpandlePanel = voronoiPanel; - _fractureSliceSettingsExpandlePanel = slicePanel; -} - -void FractureGeneralPanel::on_comboBoxFracturePreset_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general; - copy(fractureGeneral.fracturePreset, ui->comboBoxFracturePreset->currentText().toStdString().c_str()); - _updateFractureUIs(); -} - - -void FractureGeneralPanel::on_btnAddPreset_clicked() -{ - bool ok = false; - QString name = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input name for new fracture preset:"), - QLineEdit::Normal, - "", - &ok); - bool nameExist = BlastProject::ins().isFracturePresetNameExist(name.toUtf8().data()); - if (ok && !name.isEmpty() && !nameExist) - { - BlastProject::ins().addFracturePreset(name.toUtf8().data(), (FractureType)ui->comboBoxFractureType->currentIndex()); - updateValues(); - ui->comboBoxFracturePreset->setCurrentIndex(ui->comboBoxFracturePreset->count() - 1); - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && name.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the new preset!"); - } -} - -void FractureGeneralPanel::on_btnModifyPreset_clicked() -{ - if (ui->comboBoxFracturePreset->currentIndex() < 1) - { - QMessageBox::warning(this, "Blast Tool", "You should select an fracture preset!"); - return; - } - - QByteArray tmp = ui->comboBoxFracturePreset->currentText().toUtf8(); - const char* oldName = tmp.data(); - - bool ok = false; - QString newName = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input new name for the selected fracture preset:"), - QLineEdit::Normal, - oldName, - &ok); - bool nameExist = BlastProject::ins().isUserPresetNameExist(newName.toUtf8().data()); - if (ok && !newName.isEmpty() && !nameExist) - { - int curIndex = ui->comboBoxFracturePreset->currentIndex() - 1; - if(curIndex >= 0) - { - std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets(); - presets[curIndex].name = newName.toUtf8().data(); - updateValues(); - ui->comboBoxFracturePreset->setCurrentIndex(curIndex + 1); - } - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && newName.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected preset!"); - } -} - -void FractureGeneralPanel::on_btnSavePreset_clicked() -{ - BlastProject::ins().saveFracturePreset(); -} - -void FractureGeneralPanel::on_comboBoxFractureType_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general; - fractureGeneral.fractureType = index; - - FracturePreset* fracturePreset = getCurrentFracturePreset(); - if (fracturePreset != nullptr) - { - fracturePreset->setType((FractureType)index); - } - _showFracturePanel(ui->comboBoxFractureType->currentText()); -} - -void FractureGeneralPanel::on_comboBoxApplyMaterial_currentIndexChanged(int index) -{ - if (!m_bValid) - return; - - if (!_updateData) - return; - - BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general; - fractureGeneral.applyMaterial = index; -} - -void FractureGeneralPanel::on_checkBoxAutoSelectNewChunks_stateChanged(int arg1) -{ - BlastProject::ins().getParams().fracture.general.autoSelectNewChunks = arg1; -} - -FracturePreset* FractureGeneralPanel::getCurrentFracturePreset() -{ - int currentPreset = ui->comboBoxFracturePreset->currentIndex(); - - if (0 < currentPreset) - { - std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets(); - if (presets.size() > 0) - { - return &(presets[currentPreset - 1]); - } - } - - return nullptr; -} - -FracturePreset* FractureGeneralPanel::_getFracturePreset(const char* name) -{ - std::vector<FracturePreset>& presets = BlastProject::ins().getFracturePresets(); - - for (size_t i = 0; i < presets.size(); ++i) - { - if (presets[i].name == name) - return &(presets[i]); - } - - return nullptr; -} - -void FractureGeneralPanel::_updateFractureUIs() -{ - _updateData = false; - - FracturePreset* fracturePreset = getCurrentFracturePreset(); - if (fracturePreset != nullptr) - { - if (eFractureType_Voronoi == fracturePreset->type) - { - ui->comboBoxFractureType->setCurrentIndex(0); - } - else if (eFractureType_Slice == fracturePreset->type) - { - ui->comboBoxFractureType->setCurrentIndex(1); - } - } - else - { - BPPFracture& fracture = BlastProject::ins().getParams().fracture; - ui->comboBoxFractureType->setCurrentIndex(fracture.general.fractureType); - } - - _showFracturePanel(ui->comboBoxFractureType->currentText()); - _visualizersPanel->updateValues(); - _updateData = true; -} - -////////////////////////////////////////////////////////////////////////////// -void FractureGeneralPanel::_showFracturePanel(const QString& fractireType) -{ - _fractureVoronoiSettingsExpandlePanel->hide(); - _fractureSliceSettingsExpandlePanel->hide(); - QString fractireTypeLower = fractireType.toLower(); - if (fractireTypeLower == "voronoi") - { - _voronoiPanel->updateValues(); - _fractureVoronoiSettingsExpandlePanel->show(); - } - else if (fractireTypeLower == "slice") - { - _slicePanel->updateValues(); - _fractureSliceSettingsExpandlePanel->show(); - } -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h deleted file mode 100644 index 1ab9f24..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureGeneralPanel.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef FRACTUREGENERALPANEL_H -#define FRACTUREGENERALPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" - -namespace Ui { -class FractureGeneralPanel; -} - -class FractureVoronoiSettingsPanel; -class FractureSliceSettingsPanel; -class FractureVisualizersPanel; -class ExpandablePanel; - -class FractureGeneralPanel : public QWidget -{ - Q_OBJECT - -public: - static FractureGeneralPanel* ins(); - - explicit FractureGeneralPanel(QWidget *parent = 0); - ~FractureGeneralPanel(); - void updateValues(); - void setFracturePanels(FractureVoronoiSettingsPanel* voronoiPanel, FractureSliceSettingsPanel* slicePanel, FractureVisualizersPanel* visulizersPanel); - void setFractureExpandablePanels(ExpandablePanel* voronoiPanel, ExpandablePanel* slicePanel); - - FracturePreset* getCurrentFracturePreset(); - -private slots: - void on_comboBoxFracturePreset_currentIndexChanged(int index); - - void on_btnAddPreset_clicked(); - - void on_btnModifyPreset_clicked(); - - void on_btnSavePreset_clicked(); - - void on_comboBoxFractureType_currentIndexChanged(int index); - - void on_comboBoxApplyMaterial_currentIndexChanged(int index); - - void on_checkBoxAutoSelectNewChunks_stateChanged(int arg1); - -private: - FracturePreset* _getFracturePreset(const char* name); - void _updateFractureUIs(); - void _showFracturePanel(const QString& fractireType); - -private: - Ui::FractureGeneralPanel *ui; - bool m_bValid; - bool _updateData; - FractureVoronoiSettingsPanel* _voronoiPanel; - FractureSliceSettingsPanel* _slicePanel; - FractureVisualizersPanel* _visualizersPanel; - ExpandablePanel* _fractureVoronoiSettingsExpandlePanel; - ExpandablePanel* _fractureSliceSettingsExpandlePanel; -}; - -#endif // FRACTUREGENERALPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp deleted file mode 100644 index 103c01c..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include "FractureSliceSettingsPanel.h" -#include "ui_FractureSliceSettingsPanel.h" -#include "SimpleScene.h" -#include "SampleManager.h" -#include <QtWidgets/QMessageBox> -#include "FractureGeneralPanel.h" -#include "BlastFamily.h" - -FractureSliceSettingsPanel::FractureSliceSettingsPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::FractureSliceSettingsPanel), - _updateData(true), - _generalPanel(nullptr) -{ - ui->setupUi(this); -} - -FractureSliceSettingsPanel::~FractureSliceSettingsPanel() -{ - delete ui; -} - -void FractureSliceSettingsPanel::updateValues() -{ - _updateData = false; - BPPSlice* slice = _getBPPSlice(); - - ui->spinBoxNumSlicesX->setValue(slice->numSlicesX); - ui->spinBoxNumSlicesY->setValue(slice->numSlicesY); - ui->spinBoxNumSlicesZ->setValue(slice->numSlicesZ); - ui->spinBoxOffsetVariation->setValue(slice->offsetVariation); - ui->spinBoxRotationVariation->setValue(slice->rotationVariation); - ui->spinBoxNoiseAmplitude->setValue(slice->noiseAmplitude); - ui->spinBoxNoiseFrequency->setValue(slice->noiseFrequency); - ui->spinBoxNoiseOctaveNumber->setValue(slice->noiseOctaveNumber); - ui->spinBoxNoiseSeed->setValue(slice->noiseSeed); - ui->spinBoxSurfaceResolution->setValue(slice->surfaceResolution); - _updateData = true; -} - -void FractureSliceSettingsPanel::on_spinBoxNumSlicesX_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->numSlicesX = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNumSlicesY_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->numSlicesY = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNumSlicesZ_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->numSlicesZ = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxOffsetVariation_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->offsetVariation = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxRotationVariation_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->rotationVariation = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNoiseAmplitude_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->noiseAmplitude = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNoiseFrequency_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->noiseFrequency = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNoiseOctaveNumber_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->noiseOctaveNumber = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxNoiseSeed_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->noiseSeed = arg1; -} - -void FractureSliceSettingsPanel::on_spinBoxSurfaceResolution_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPSlice* slice = _getBPPSlice(); - slice->surfaceResolution = arg1; -} - -void FractureSliceSettingsPanel::on_btnApplyFracture_clicked() -{ - BPPSlice* slice = _getBPPSlice(); - SliceFractureExecutor executor; - executor.setBPPSlice(slice); - - SampleManager* pSampleManager = SampleManager::ins(); - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials; - BPPFractureGeneral& fractureGeneral = projectParams.fracture.general; - int32_t nMaterialIndex = fractureGeneral.applyMaterial; - std::string materialName = ""; - RenderMaterial* pRenderMaterial = nullptr; - if (nMaterialIndex > 0) - { - BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1]; - materialName = item.name.buf; - pRenderMaterial = pSampleManager->getRenderMaterial(materialName); - } - - std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks(); - std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin(); - for (; itrAssetSelectedChunks != selectedChunks.end(); itrAssetSelectedChunks++) - { - if (itrAssetSelectedChunks->second.size() == 0) - { - continue; - } - - if (pRenderMaterial != nullptr) - { - BlastAsset* pBlastAsset = itrAssetSelectedChunks->first; - std::vector<BlastFamily*> families = AssetFamiliesMap[pBlastAsset]; - int familySize = families.size(); - for (int fs = 0; fs < familySize; fs++) - { - BlastFamily* pBlastFamily = families[fs]; - pBlastFamily->setMaterial(pRenderMaterial, false); - - AssetList::ModelAsset modelAsset = AssetDescMap[pBlastAsset]; - int assetID = BlastProject::ins().getAssetIDByName(modelAsset.name.c_str()); - BPPAssetInstance* instance = BlastProject::ins().getAssetInstance(assetID, fs); - copy(instance->inMaterial, materialName.c_str()); - } - } - - executor.setSourceAsset(itrAssetSelectedChunks->first); - executor.setTargetChunks(itrAssetSelectedChunks->second); - executor.execute(); - } -} - -BPPSlice* FractureSliceSettingsPanel::_getBPPSlice() -{ - BPPSlice* slice = nullptr; - FracturePreset* preset = _generalPanel->getCurrentFracturePreset(); - if (nullptr != preset) - { - slice = &(preset->fracture.slice); - } - else - { - slice = &(BlastProject::ins().getParams().fracture.slice); - } - return slice; -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h deleted file mode 100644 index 5b68575..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureSliceSettingsPanel.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef FRACTURESLICESETTINGSPANEL_H -#define FRACTURESLICESETTINGSPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" - -namespace Ui { -class FractureSliceSettingsPanel; -} -class FractureGeneralPanel; - -class FractureSliceSettingsPanel : public QWidget -{ - Q_OBJECT - -public: - explicit FractureSliceSettingsPanel(QWidget *parent = 0); - ~FractureSliceSettingsPanel(); - void updateValues(); - void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; } - -private slots: - void on_spinBoxNumSlicesX_valueChanged(int arg1); - void on_spinBoxNumSlicesY_valueChanged(int arg1); - void on_spinBoxNumSlicesZ_valueChanged(int arg1); - - void on_spinBoxOffsetVariation_valueChanged(double arg1); - - void on_spinBoxRotationVariation_valueChanged(double arg1); - - void on_spinBoxNoiseAmplitude_valueChanged(double arg1); - - void on_spinBoxNoiseFrequency_valueChanged(double arg1); - - void on_spinBoxNoiseOctaveNumber_valueChanged(int arg1); - - void on_spinBoxNoiseSeed_valueChanged(int arg1); - - void on_spinBoxSurfaceResolution_valueChanged(int arg1); - - void on_btnApplyFracture_clicked(); - -private: - BPPSlice* _getBPPSlice(); - -private: - Ui::FractureSliceSettingsPanel *ui; - bool _updateData; - FractureGeneralPanel* _generalPanel; -}; - -#endif // FRACTURESLICESETTINGSPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp deleted file mode 100644 index 52d5431..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "FractureVisualizersPanel.h" -#include "ui_FractureVisualizersPanel.h" -#include "ProjectParams.h" -#include "FractureGeneralPanel.h" -#include "SampleManager.h" - -FractureVisualizersPanel::FractureVisualizersPanel(QWidget *parent) : - QWidget(parent), - _updateData(true), - ui(new Ui::FractureVisualizersPanel) -{ - ui->setupUi(this); -} - -FractureVisualizersPanel::~FractureVisualizersPanel() -{ - delete ui; -} - -void FractureVisualizersPanel::updateValues() -{ - _updateData = false; -/* - BPPFractureVisualization* fractureVisualization = _getBPPVisualization(); - - ui->checkBoxFracturePreview->setChecked(fractureVisualization->fracturePreview); - ui->checkBoxDisplayFractureWidget->setChecked(fractureVisualization->displayFractureWidget); -*/ - bool checked = BlastProject::ins().getParams().fracture.general.selectionDepthTest; - ui->checkBoxSelectionDepthTest->setChecked(checked); - _updateData = true; -} -/* -void FractureVisualizersPanel::on_checkBoxFracturePreview_stateChanged(int arg1) -{ - if (!_updateData) - return; - - BPPFractureVisualization* fractureVisualization = _getBPPVisualization(); - fractureVisualization->fracturePreview = (arg1 != 0 ? true : false); -} - -void FractureVisualizersPanel::on_checkBoxDisplayFractureWidget_stateChanged(int arg1) -{ - if (!_updateData) - return; - - BPPFractureVisualization* fractureVisualization = _getBPPVisualization(); - fractureVisualization->displayFractureWidget = (arg1 != 0 ? true : false); -} -*/ -void FractureVisualizersPanel::on_checkBoxSelectionDepthTest_stateChanged(int arg1) -{ - BlastProject::ins().getParams().fracture.general.selectionDepthTest = arg1; - SampleManager* pSampleManager = SampleManager::ins(); - if (nullptr != pSampleManager) - { - SampleManager::ins()->ApplySelectionDepthTest(); - } -} - -BPPFractureVisualization* FractureVisualizersPanel::_getBPPVisualization() -{ - BPPFractureVisualization* visualization = nullptr; - FracturePreset* preset = _generalPanel->getCurrentFracturePreset(); - if (nullptr != preset) - { - visualization = &(preset->visualization); - } - else - { - visualization = &(BlastProject::ins().getParams().fracture.visualization); - } - return visualization; -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h deleted file mode 100644 index 9d944d1..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVisualizersPanel.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef FRACTUREVISUALIZERSPANEL_H -#define FRACTUREVISUALIZERSPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" - -namespace Ui { -class FractureVisualizersPanel; -} -class FractureGeneralPanel; - -class FractureVisualizersPanel : public QWidget -{ - Q_OBJECT - -public: - explicit FractureVisualizersPanel(QWidget *parent = 0); - ~FractureVisualizersPanel(); - void updateValues(); - void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; } - -private slots: -/* - void on_checkBoxFracturePreview_stateChanged(int arg1); - - void on_checkBoxDisplayFractureWidget_stateChanged(int arg1); -*/ - void on_checkBoxSelectionDepthTest_stateChanged(int arg1); - -private: - BPPFractureVisualization* _getBPPVisualization(); -private: - Ui::FractureVisualizersPanel *ui; - bool _updateData; - FractureGeneralPanel* _generalPanel; -}; - -#endif // FRACTUREVISUALIZERSPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp deleted file mode 100644 index 7f18b8d..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "FractureVoronoiSettingsPanel.h" -#include "ui_FractureVoronoiSettingsPanel.h" -#include "ProjectParams.h" -#include <QtWidgets/QInputDialog> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QMessageBox> -#include <QtCore/QFileInfo> -#include "AppMainWindow.h" -#include "SimpleScene.h" -#include "SampleManager.h" -#include "FractureGeneralPanel.h" -#include "BlastFamily.h" - -FractureVoronoiSettingsPanel::FractureVoronoiSettingsPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::FractureVoronoiSettingsPanel), - _updateData(true), - _generalPanel(nullptr) -{ - ui->setupUi(this); - - ui->groupBoxVisualizers->hide(); -} - -FractureVoronoiSettingsPanel::~FractureVoronoiSettingsPanel() -{ - delete ui; -} - -void FractureVoronoiSettingsPanel::updateValues() -{ - _updateData = false; - BPPVoronoi* voronoi = _getBPPVoronoi(); - - ui->comboBoxSiteGeneration->setCurrentIndex(voronoi->siteGeneration); - _showCurrentSiteGenerationUI(); - ui->spinBoxNumberOfSites->setValue(voronoi->numSites); - - ui->spinBoxNumberOfClusters->setValue(voronoi->numberOfClusters); - ui->spinBoxSitesPerCluster->setValue(voronoi->sitesPerCluster); - ui->spinBoxClusterRadius->setValue(voronoi->clusterRadius); - - _updateData = true; -} - -void FractureVoronoiSettingsPanel::on_checkBoxGridPreview_stateChanged(int arg1) -{ - -} - -void FractureVoronoiSettingsPanel::on_checkBoxFracturePreview_stateChanged(int arg1) -{ - -} - -void FractureVoronoiSettingsPanel::on_checkBoxCutterMesh_stateChanged(int arg1) -{ - -} - -void FractureVoronoiSettingsPanel::on_comboBoxSiteGeneration_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - BPPVoronoi* voronoi = _getBPPVoronoi(); - voronoi->siteGeneration = index; - _showCurrentSiteGenerationUI(); -} - -void FractureVoronoiSettingsPanel::on_spinBoxNumberOfSites_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPVoronoi* voronoi = _getBPPVoronoi(); - voronoi->numSites = arg1; -} - -void FractureVoronoiSettingsPanel::on_spinBoxNumberOfClusters_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPVoronoi* voronoi = _getBPPVoronoi(); - voronoi->numberOfClusters = arg1; -} - -void FractureVoronoiSettingsPanel::on_spinBoxSitesPerCluster_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPVoronoi* voronoi = _getBPPVoronoi(); - voronoi->sitesPerCluster = arg1; -} - -void FractureVoronoiSettingsPanel::on_spinBoxClusterRadius_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPVoronoi* voronoi = _getBPPVoronoi(); - voronoi->clusterRadius = arg1; -} - -void FractureVoronoiSettingsPanel::on_btnApplyFracture_clicked() -{ - BPPVoronoi* voronoi = _getBPPVoronoi(); - VoronoiFractureExecutor executor; - executor.setBPPVoronoi(voronoi); - - SampleManager* pSampleManager = SampleManager::ins(); - std::map<BlastAsset*, std::vector<BlastFamily*>>& AssetFamiliesMap = pSampleManager->getAssetFamiliesMap(); - std::map<BlastAsset*, AssetList::ModelAsset>& AssetDescMap = pSampleManager->getAssetDescMap(); - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials; - BPPFractureGeneral& fractureGeneral = projectParams.fracture.general; - int32_t nMaterialIndex = fractureGeneral.applyMaterial; - std::string materialName = ""; - RenderMaterial* pRenderMaterial = nullptr; - if (nMaterialIndex > 0) - { - BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1]; - materialName = item.name.buf; - pRenderMaterial = pSampleManager->getRenderMaterial(materialName); - } - - std::map<BlastAsset*, std::vector<uint32_t>> selectedChunks = SampleManager::ins()->getSelectedChunks(); - std::map<BlastAsset*, std::vector<uint32_t>>::iterator itrAssetSelectedChunks = selectedChunks.begin(); - for (; itrAssetSelectedChunks != selectedChunks.end(); itrAssetSelectedChunks++) - { - if (itrAssetSelectedChunks->second.size() == 0) - { - continue; - } - - if (pRenderMaterial != nullptr) - { - BlastAsset* pBlastAsset = itrAssetSelectedChunks->first; - std::vector<BlastFamily*> families = AssetFamiliesMap[pBlastAsset]; - int familySize = families.size(); - for (int fs = 0; fs < familySize; fs++) - { - BlastFamily* pBlastFamily = families[fs]; - pBlastFamily->setMaterial(pRenderMaterial, false); - - AssetList::ModelAsset modelAsset = AssetDescMap[pBlastAsset]; - int assetID = BlastProject::ins().getAssetIDByName(modelAsset.name.c_str()); - BPPAssetInstance* instance = BlastProject::ins().getAssetInstance(assetID, fs); - copy(instance->inMaterial, materialName.c_str()); - } - } - - executor.setSourceAsset(itrAssetSelectedChunks->first); - executor.setTargetChunks(itrAssetSelectedChunks->second); - executor.execute(); - } -} - -BPPVoronoi* FractureVoronoiSettingsPanel::_getBPPVoronoi() -{ - BPPVoronoi* voronoi = nullptr; - FracturePreset* preset = _generalPanel->getCurrentFracturePreset(); - if (nullptr != preset) - { - voronoi = &(preset->fracture.voronoi); - } - else - { - voronoi = &(BlastProject::ins().getParams().fracture.voronoi); - } - return voronoi; -} - -void FractureVoronoiSettingsPanel::_showCurrentSiteGenerationUI() -{ - ui->widgetUniform->hide(); - ui->widgetClusters->hide(); - BPPVoronoi* voronoi = _getBPPVoronoi(); - switch(voronoi->siteGeneration) - { - case 0: - ui->widgetUniform->show(); - break; - case 1: - ui->widgetClusters->show(); - break; - } -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h deleted file mode 100644 index 0f9b252..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/FractureVoronoiSettingsPanel.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef FRACTUREVORONOISETTINGSPANEL_H -#define FRACTUREVORONOISETTINGSPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" - -namespace Ui { -class FractureVoronoiSettingsPanel; -} -class FractureGeneralPanel; - -class FractureVoronoiSettingsPanel : public QWidget -{ - Q_OBJECT - -public: - explicit FractureVoronoiSettingsPanel(QWidget *parent = 0); - ~FractureVoronoiSettingsPanel(); - void updateValues(); - void setFractureGeneralPanel(FractureGeneralPanel* generalPanel) { _generalPanel = generalPanel; } - -private slots: - void on_checkBoxGridPreview_stateChanged(int arg1); - - void on_checkBoxFracturePreview_stateChanged(int arg1); - - void on_checkBoxCutterMesh_stateChanged(int arg1); - - void on_comboBoxSiteGeneration_currentIndexChanged(int index); - - void on_spinBoxNumberOfSites_valueChanged(int arg1); - - void on_spinBoxNumberOfClusters_valueChanged(int arg1); - - void on_spinBoxSitesPerCluster_valueChanged(int arg1); - - void on_spinBoxClusterRadius_valueChanged(double arg1); - - void on_btnApplyFracture_clicked(); - -private: - BPPVoronoi* _getBPPVoronoi(); - void _showCurrentSiteGenerationUI(); - -private: - Ui::FractureVoronoiSettingsPanel *ui; - bool _updateData; - FractureGeneralPanel* _generalPanel; -}; - -#endif // FRACTUREVORONOISETTINGSPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp deleted file mode 100644 index aa6af69..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.cpp +++ /dev/null @@ -1,315 +0,0 @@ -#include "GeneralPanel.h" -#include "ui_GeneralPanel.h" -#include <QtWidgets/QInputDialog> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QMessageBox> -#include "SampleManager.h" - -GeneralPanel::GeneralPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::GeneralPanel), - _updateData(true) -{ - ui->setupUi(this); -} - -GeneralPanel::~GeneralPanel() -{ - delete ui; -} - -void GeneralPanel::updateValues() -{ - _updateData = false; - ui->comboBoxUserPreset->clear(); - QStringList userPresets; - userPresets.append("Default"); - std::vector<StressSolverUserPreset> presets = BlastProject::ins().getUserPresets(); - int countUserPresets = (int)presets.size(); - if (countUserPresets > 0) - { - for (int i = 0; i < countUserPresets; ++i) - { - userPresets.append(presets[i].name.c_str()); - } - } - ui->comboBoxUserPreset->addItems(userPresets); - - if (_selectedAssets.size() > 0) - { - if (nullptr == _selectedAssets[0]->activeUserPreset.buf - || 0 == strlen(_selectedAssets[0]->activeUserPreset.buf) - || !BlastProject::ins().isUserPresetNameExist(_selectedAssets[0]->activeUserPreset.buf)) - { - ui->comboBoxUserPreset->setCurrentIndex(0); - } - else - { - ui->comboBoxUserPreset->setCurrentText(_selectedAssets[0]->activeUserPreset.buf); - } - - _updateStressSolverUIs(); - } - else - { - ui->comboBoxUserPreset->setCurrentIndex(0); - } - _updateData = true; -} - -void GeneralPanel::dataSelected(std::vector<BlastNode*> selections) -{ - _selectedAssets.clear(); - - for (BlastNode* node : selections) - { - if (eAsset == node->getType()) - { - BPPAsset* asset = static_cast<BPPAsset*>(node->getData()); - _selectedAssets.push_back(asset); - } - } - - updateValues(); -} - -void GeneralPanel::on_comboBoxUserPreset_currentIndexChanged(int index) -{ - if (!_updateData) - return; - - for (size_t i = 0; i < _selectedAssets.size(); ++i) - { - QByteArray tem = ui->comboBoxUserPreset->currentText().toUtf8(); - copy(_selectedAssets[i]->activeUserPreset, tem.data()); - } - _updateStressSolverUIs(); - _updateStressSolverToBlast(); -} - -void GeneralPanel::on_btnAddUserPreset_clicked() -{ - bool ok = false; - QString name = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input name for new User preset:"), - QLineEdit::Normal, - "", - &ok); - bool nameExist = BlastProject::ins().isUserPresetNameExist(name.toUtf8().data()); - if (ok && !name.isEmpty() && !nameExist) - { - BlastProject::ins().addUserPreset(name.toUtf8().data()); - updateValues(); - ui->comboBoxUserPreset->setCurrentIndex(ui->comboBoxUserPreset->count() - 1); - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && name.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the new preset!"); - } -} - -void GeneralPanel::on_btnModifyUserPreset_clicked() -{ - if (ui->comboBoxUserPreset->currentIndex() < 1) - { - QMessageBox::warning(this, "Blast Tool", "You should select an user preset!"); - return; - } - - QByteArray tmp = ui->comboBoxUserPreset->currentText().toUtf8(); - const char* oldName = tmp.data(); - - bool ok = false; - QString newName = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input new name for the selected user preset:"), - QLineEdit::Normal, - oldName, - &ok); - bool nameExist = BlastProject::ins().isUserPresetNameExist(newName.toUtf8().data()); - if (ok && !newName.isEmpty() && !nameExist) - { - int curIndex = ui->comboBoxUserPreset->currentIndex() - 1; - if (curIndex >= 0) - { - std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets(); - presets[curIndex].name = newName.toUtf8().data(); - updateValues(); - ui->comboBoxUserPreset->setCurrentIndex(curIndex + 1); - } - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && newName.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected preset!"); - } -} - -void GeneralPanel::on_btnSaveUserPreset_clicked() -{ - BlastProject::ins().saveUserPreset(); -} - -void GeneralPanel::on_spinBoxMaterialHardness_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - if (stressSolver) - { - stressSolver->hardness = arg1; - } - else - { - for (BPPAsset* asset : _selectedAssets) - { - asset->stressSolver.hardness = arg1; - } - } - - _updateStressSolverToBlast(); -} - -void GeneralPanel::on_spinBoxLinearFactor_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - if (stressSolver) - { - stressSolver->linearFactor = arg1; - } - else - { - for (BPPAsset* asset : _selectedAssets) - { - asset->stressSolver.linearFactor = arg1; - } - } - - _updateStressSolverToBlast(); -} - -void GeneralPanel::on_spinBoxAngularFactor_valueChanged(double arg1) -{ - if (!_updateData) - return; - - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - if (stressSolver) - { - stressSolver->angularFactor = arg1; - } - else - { - for (BPPAsset* asset : _selectedAssets) - { - asset->stressSolver.angularFactor = arg1; - } - } - - _updateStressSolverToBlast(); -} - -void GeneralPanel::on_spinBoxBondIterations_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - if (stressSolver) - { - stressSolver->bondIterationsPerFrame = arg1; - } - else - { - for (BPPAsset* asset : _selectedAssets) - { - asset->stressSolver.bondIterationsPerFrame = arg1; - } - } - - _updateStressSolverToBlast(); -} - -void GeneralPanel::on_spinBoxGraphReductionLevel_valueChanged(int arg1) -{ - if (!_updateData) - return; - - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - if (stressSolver) - { - stressSolver->graphReductionLevel = arg1; - } - else - { - for (BPPAsset* asset : _selectedAssets) - { - asset->stressSolver.graphReductionLevel = arg1; - } - } - - _updateStressSolverToBlast(); -} - -BPPStressSolver* GeneralPanel::_getCurrentUserPresetStressSolver() -{ - int currentUserPreset = ui->comboBoxUserPreset->currentIndex(); - - if (0 < currentUserPreset) - { - std::vector<StressSolverUserPreset>& presets = BlastProject::ins().getUserPresets(); - return &(presets[currentUserPreset - 1].stressSolver); - } - - return nullptr; -} - -void GeneralPanel::_updateStressSolverUIs() -{ - BPPStressSolver noStressSolver; - init(noStressSolver); - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - if (stressSolver == nullptr) - { - if (0 < _selectedAssets.size()) - { - copy(noStressSolver, _selectedAssets[0]->stressSolver); - } - stressSolver = &noStressSolver; - } - - _updateData = false; - ui->spinBoxMaterialHardness->setValue(stressSolver->hardness); - ui->spinBoxLinearFactor->setValue(stressSolver->linearFactor); - ui->spinBoxAngularFactor->setValue(stressSolver->angularFactor); - ui->spinBoxBondIterations->setValue(stressSolver->bondIterationsPerFrame); - ui->spinBoxGraphReductionLevel->setValue(stressSolver->graphReductionLevel); - _updateData = true; -} - -void GeneralPanel::_updateStressSolverToBlast() -{ - BPPStressSolver* stressSolver = _getCurrentUserPresetStressSolver(); - - for (BPPAsset* asset : _selectedAssets) - { - SampleManager::ins()->updateAssetFamilyStressSolver(asset, nullptr != stressSolver? *stressSolver : asset->stressSolver); - } -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h deleted file mode 100644 index 9651185..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/GeneralPanel.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GENERALPANEL_H -#define GENERALPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" -#include "BlastSceneTree.h" - -namespace Ui { -class GeneralPanel; -} - -class GeneralPanel : public QWidget, public ISceneObserver -{ - Q_OBJECT - -public: - explicit GeneralPanel(QWidget *parent = 0); - ~GeneralPanel(); - void updateValues(); - - virtual void dataSelected(std::vector<BlastNode*> selections); - -private slots: - void on_comboBoxUserPreset_currentIndexChanged(int index); - - void on_btnAddUserPreset_clicked(); - - void on_btnModifyUserPreset_clicked(); - - void on_btnSaveUserPreset_clicked(); - - void on_spinBoxMaterialHardness_valueChanged(double arg1); - - void on_spinBoxLinearFactor_valueChanged(double arg1); - - void on_spinBoxAngularFactor_valueChanged(double arg1); - - void on_spinBoxBondIterations_valueChanged(int arg1); - - void on_spinBoxGraphReductionLevel_valueChanged(int arg1); - -private: - BPPStressSolver* _getCurrentUserPresetStressSolver(); - void _updateStressSolverUIs(); - void _updateStressSolverToBlast(); - -private: - Ui::GeneralPanel *ui; - bool _updateData; - std::vector<BPPAsset*> _selectedAssets; -}; - -#endif // GENERALPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp deleted file mode 100644 index 0ecfaf0..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include "MaterialAssignmentsPanel.h" -#include "ui_MaterialAssignmentsPanel.h" -#include "ProjectParams.h" -#include "SampleManager.h" -#include "MaterialLibraryPanel.h" -#include <assert.h> - -MaterialAssignmentsPanel* pMaterialAssignmentsPanel = nullptr; -MaterialAssignmentsPanel* MaterialAssignmentsPanel::ins() -{ - return pMaterialAssignmentsPanel; -} - -MaterialAssignmentsPanel::MaterialAssignmentsPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::MaterialAssignmentsPanel), - _selectedGraphicsMesh(-1) -{ - ui->setupUi(this); - pMaterialAssignmentsPanel = this; - m_bValid = true; -} - -void MaterialAssignmentsPanel::getMaterialNameAndPaths(std::vector<std::string>& materialNames, std::vector<std::string>& materialPaths) -{ - QString m1 = ui->comboBoxMaterialID1->currentText(); - QString m2 = ui->comboBoxMaterialID2->currentText(); - std::string name1 = m1.toUtf8().data(); - std::string name2 = m2.toUtf8().data(); - std::string path1 = ""; - std::string path2 = ""; - - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials; - int count = theArray.arraySizes[0]; - for (int i = 0; i < count; ++i) - { - BPPGraphicsMaterial& item = theArray.buf[i]; - std::string name = item.name.buf; - std::string path = ""; - if (item.diffuseTextureFilePath.buf != nullptr) - { - path = item.diffuseTextureFilePath.buf; - } - if (name1 == name) - { - path1 = path; - } - else if (name2 == name) - { - path2 = path; - } - else if (path1 != "" && path2 != "") - { - break; - } - } - - materialNames[0] = name1; - materialPaths[0] = path1; - - BPPFractureGeneral& fractureGeneral = BlastProject::ins().getParams().fracture.general; - int32_t nMaterialIndex = fractureGeneral.applyMaterial; - assert(theArray.buf != nullptr); - if (nMaterialIndex > 0 && theArray.buf) - { - BPPGraphicsMaterial& item = theArray.buf[nMaterialIndex - 1]; - name2 = item.name.buf; - if (item.diffuseTextureFilePath.buf) - { - path2 = item.diffuseTextureFilePath.buf; - } - } - materialNames[1] = name2; - materialPaths[1] = path2; -} - -MaterialAssignmentsPanel::~MaterialAssignmentsPanel() -{ - delete ui; -} - -void MaterialAssignmentsPanel::updateValues() -{ - m_bValid = false; - ui->comboBoxMaterialID1->clear(); - ui->comboBoxMaterialID2->clear(); - ui->comboBoxMaterialID1->setEnabled(false); - ui->comboBoxMaterialID2->setEnabled(false); - m_bValid = true; - - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager == nullptr) - { - return; - } - - BlastAsset* pBlastAsset = nullptr; - int index = -1; - pSampleManager->getCurrentSelectedInstance(&pBlastAsset, index); - if (pBlastAsset == nullptr || index == -1) - { - return; - } - - ui->comboBoxMaterialID1->setEnabled(true); - ui->comboBoxMaterialID2->setEnabled(true); - - QStringList materialNames; - materialNames.append("None"); - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& theArray = projectParams.graphicsMaterials; - int count = theArray.arraySizes[0]; - for (int i = 0; i < count; ++i) - { - BPPGraphicsMaterial& item = theArray.buf[i]; - materialNames.append(item.name.buf); - } - - m_bValid = false; - ui->comboBoxMaterialID1->insertItems(0, materialNames); - ui->comboBoxMaterialID2->insertItems(0, materialNames); - m_bValid = true; - - std::string strMaterialNames[] = { "", "" }; - bool ex[] = { true, false }; - for (int i = 0; i < 2; i++) - { - pSampleManager->getMaterialForCurrentFamily(strMaterialNames[i], ex[i]); - } - - m_bValid = false; - ui->comboBoxMaterialID1->setCurrentText(strMaterialNames[0].c_str()); - ui->comboBoxMaterialID2->setCurrentText(strMaterialNames[1].c_str()); - m_bValid = true; - - return; - - if (_selectedGraphicsMesh > -1) - { - BPParams& projectParams = BlastProject::ins().getParams(); - BPPBlast& blast = projectParams.blast; - BPPGraphicsMaterialArray& graphicsMaterialsArray = projectParams.graphicsMaterials; - - //BPPMaterialAssignmentsArray& assignment = blast.graphicsMeshes.buf[_selectedGraphicsMesh].materialAssignments; - - //ui->comboBoxMaterialID1->clear(); - //ui->comboBoxMaterialID2->clear(); - //ui->comboBoxMaterialID3->clear(); - //ui->comboBoxMaterialID4->clear(); - - //QStringList materialNames; - //materialNames.append("None"); - //int count = graphicsMaterialsArray.arraySizes[0]; - //for (int i = 0; i < count; ++i) - //{ - // materialNames.append(graphicsMaterialsArray.buf[i].name.buf); - //} - - //ui->comboBoxMaterialID1->insertItems(0, materialNames); - //ui->comboBoxMaterialID2->insertItems(0, materialNames); - //ui->comboBoxMaterialID3->insertItems(0, materialNames); - //ui->comboBoxMaterialID4->insertItems(0, materialNames); - - //ui->comboBoxMaterialID1->setCurrentIndex(assignment.materialIndexes[0] + 1); - //ui->comboBoxMaterialID2->setCurrentIndex(assignment.materialIndexes[1] + 1); - //ui->comboBoxMaterialID3->setCurrentIndex(assignment.materialIndexes[2] + 1); - //ui->comboBoxMaterialID4->setCurrentIndex(assignment.materialIndexes[3] + 1); - } -} - -void MaterialAssignmentsPanel::on_comboBoxMaterialID1_currentIndexChanged(int index) -{ - if (index < 0 || !m_bValid) - return; - - RenderMaterial* pRenderMaterial = nullptr; - - QString currentText = ui->comboBoxMaterialID1->currentText(); - std::string name = currentText.toUtf8().data(); - - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager == nullptr) - { - return; - } - - pSampleManager->setMaterialForCurrentFamily(name, true); - - return; - assignMaterialToMaterialID(0, index - 1); -} - -void MaterialAssignmentsPanel::on_comboBoxMaterialID2_currentIndexChanged(int index) -{ - if (index < 0 || !m_bValid) - return; - - RenderMaterial* pRenderMaterial = nullptr; - - QString currentText = ui->comboBoxMaterialID2->currentText(); - std::string name = currentText.toUtf8().data(); - - SampleManager* pSampleManager = SampleManager::ins(); - if (pSampleManager == nullptr) - { - return; - } - - pSampleManager->setMaterialForCurrentFamily(name, false); - - return; - assignMaterialToMaterialID(1, index - 1); -} - -void MaterialAssignmentsPanel::on_comboBoxMaterialID3_currentIndexChanged(int index) -{ - assignMaterialToMaterialID(2, index - 1); -} - -void MaterialAssignmentsPanel::on_comboBoxMaterialID4_currentIndexChanged(int index) -{ - assignMaterialToMaterialID(3, index - 1); -} - -void MaterialAssignmentsPanel::assignMaterialToMaterialID(int materialID, int materialIndex) -{ - if (materialID < 0 || materialID > 3 || materialIndex < 0) - return; - - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& graphicsMaterialArray = projectParams.graphicsMaterials; - BPPBlast& blast = projectParams.blast; - - if (materialIndex >= graphicsMaterialArray.arraySizes[0]) - return; - - //BPPGraphicsMeshArray& graphicsMeshArray = blast.graphicsMeshes; - - //if (_selectedGraphicsMesh > -1 && _selectedGraphicsMesh < graphicsMeshArray.arraySizes[0]) - //{ - // graphicsMeshArray.buf[_selectedGraphicsMesh].materialAssignments.materialIndexes[materialID] = materialIndex; - //} -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.h deleted file mode 100644 index 782baa8..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialAssignmentsPanel.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MATERIALASSIGNMENTSPANEL_H -#define MATERIALASSIGNMENTSPANEL_H - -#include <QtWidgets/QWidget> - -namespace Ui { -class MaterialAssignmentsPanel; -} - -class MaterialAssignmentsPanel : public QWidget -{ - Q_OBJECT - -public: - explicit MaterialAssignmentsPanel(QWidget *parent = 0); - ~MaterialAssignmentsPanel(); - void updateValues(); - - static MaterialAssignmentsPanel* ins(); - void getMaterialNameAndPaths(std::vector<std::string>& materialNames, std::vector<std::string>& materialPaths); - -private slots: - void on_comboBoxMaterialID1_currentIndexChanged(int index); - - void on_comboBoxMaterialID2_currentIndexChanged(int index); - - void on_comboBoxMaterialID3_currentIndexChanged(int index); - - void on_comboBoxMaterialID4_currentIndexChanged(int index); - -private: - void assignMaterialToMaterialID(int materialID, int materialIndex); - -private: - Ui::MaterialAssignmentsPanel *ui; - int _selectedGraphicsMesh; - bool m_bValid; -}; - -#endif // MATERIALASSIGNMENTSPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp deleted file mode 100644 index f062ad4..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.cpp +++ /dev/null @@ -1,488 +0,0 @@ -#include "MaterialLibraryPanel.h" -#include "ui_MaterialLibraryPanel.h" -#include <QtCore/QFileInfo> -#include <QtWidgets/QInputDialog> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QMessageBox> -#include "QtUtil.h" -#include "AppMainWindow.h" -#include "SampleManager.h" -#include "MaterialAssignmentsPanel.h" -#include "FractureGeneralPanel.h" -#include "ResourceManager.h" -enum ETextureType -{ - eDiffuseTexture, - eSpecularTexture, - eNormalTexture -}; - -void OnTextureButtonClicked(BPPGraphicsMaterial& material, ETextureType t, QPushButton* pButton) -{ - QString texName = AppMainWindow::Inst().OpenTextureFile(); - - QFileInfo fileInfo(texName); - QByteArray ba = fileInfo.absoluteFilePath().toLocal8Bit(); - const char* filePath = (const char*)(ba); - - switch (t) - { - case eDiffuseTexture: - copy(material.diffuseTextureFilePath, filePath); - break; - case eSpecularTexture: - copy(material.specularTextureFilePath, filePath); - break; - case eNormalTexture: - copy(material.normalTextureFilePath, filePath); - break; - } - - if (texName.isEmpty()) - pButton->setIcon(QIcon(":/AppMainWindow/images/TextureEnabled_icon.png")); - else - pButton->setIcon(QIcon(":/AppMainWindow/images/TextureIsUsed_icon.png")); - -} - -void OnTextureReload(BPPGraphicsMaterial& material, ETextureType t, QPushButton* pButton) -{ - QString texName; - switch (t) - { - case eDiffuseTexture: - texName = material.diffuseTextureFilePath.buf; - // to do: reload texture - break; - case eSpecularTexture: - texName = material.specularTextureFilePath.buf; - // to do: reload texture - break; - case eNormalTexture: - texName = material.normalTextureFilePath.buf; - // to do: reload texture - break; - } - - if (texName.isEmpty()) - pButton->setIcon(QIcon(":/AppMainWindow/images/TextureEnabled_icon.png")); - else - pButton->setIcon(QIcon(":/AppMainWindow/images/TextureIsUsed_icon.png")); - -} - -void OnTextureClear(BPPGraphicsMaterial& material, ETextureType t, QPushButton* pButton) -{ - switch (t) - { - case eDiffuseTexture: - freeString(material.diffuseTextureFilePath); - // to do: clear texture - break; - case eSpecularTexture: - freeString(material.specularTextureFilePath); - // to do: clear texture - break; - case eNormalTexture: - freeString(material.normalTextureFilePath); - // to do: clear texture - break; - } - - pButton->setIcon(QIcon(":/AppMainWindow/images/TextureEnabled_icon.png")); - -} - -MaterialLibraryPanel* pMaterialLibraryPanel = nullptr; -MaterialLibraryPanel* MaterialLibraryPanel::ins() -{ - return pMaterialLibraryPanel; -} - -MaterialLibraryPanel::MaterialLibraryPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::MaterialLibraryPanel) -{ - ui->setupUi(this); - - pMaterialLibraryPanel = this; -} - -MaterialLibraryPanel::~MaterialLibraryPanel() -{ - delete ui; -} - -void MaterialLibraryPanel::updateValues() -{ - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& graphicsMaterialArray = projectParams.graphicsMaterials; - - ui->listWidget->clear(); - QStringList materialNames; - int count = graphicsMaterialArray.arraySizes[0]; - for (int i = 0; i < count; ++i) - { - materialNames.append(graphicsMaterialArray.buf[i].name.buf); - } - ui->listWidget->addItems(materialNames); - - if (count > 0) - { - ui->btnModifyMat->setEnabled(true); - ui->btnRemoveMat->setEnabled(true); - } - else - { - ui->btnModifyMat->setEnabled(false); - ui->btnRemoveMat->setEnabled(false); - } - - MaterialAssignmentsPanel::ins()->updateValues(); - FractureGeneralPanel::ins()->updateValues(); -} - -void MaterialLibraryPanel::on_btnAddMat_clicked() -{ - bool ok = false; - QString name = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input name for new graphics material:"), - QLineEdit::Normal, - "", - &ok); - bool nameExist = BlastProject::ins().isGraphicsMaterialNameExist(name.toUtf8().data()); - if (ok && !name.isEmpty() && !nameExist) - { - std::string strName = name.toUtf8().data(); - if (!BlastProject::ins().isGraphicsMaterialNameExist(strName.c_str())) - { - BlastProject::ins().addGraphicsMaterial(strName.c_str()); - updateValues(); - ui->listWidget->setCurrentRow(ui->listWidget->count() - 1); - } - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && name.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the new graphics material!"); - } -} - -void MaterialLibraryPanel::on_btnModifyMat_clicked() -{ - QList<QListWidgetItem*> items = ui->listWidget->selectedItems(); - if (items.size() == 0) - { - SampleManager::ins()->output("please select a material first !"); - return; - } - QByteArray tmp = items.at(0)->text().toUtf8(); - const char* oldName = tmp.data(); - - bool ok = false; - QString newName = QInputDialog::getText(this, - tr("Blast Tool"), - tr("Please input new name for the selected graphics material:"), - QLineEdit::Normal, - oldName, - &ok); - bool nameExist = BlastProject::ins().isGraphicsMaterialNameExist(newName.toUtf8().data()); - if (ok && !newName.isEmpty() && !nameExist) - { - std::string strOldName = oldName; - std::string strNewName = newName.toUtf8().data(); - - SampleManager::ins()->renameRenderMaterial(strOldName, strNewName); - - BlastProject::ins().renameGraphicsMaterial(oldName, newName.toUtf8().data()); - updateValues(); - } - else if (ok && nameExist) - { - QMessageBox::warning(this, "Blast Tool", "The name you input is already exist!"); - } - else if (ok && newName.isEmpty()) - { - QMessageBox::warning(this, "Blast Tool", "You need input a name for the selected graphics material!"); - } -} - -void MaterialLibraryPanel::on_btnRemoveMat_clicked() -{ - QList<QListWidgetItem*> items = ui->listWidget->selectedItems(); - if (items.size() == 0) - { - SampleManager::ins()->output("please select a material first !"); - return; - } - QByteArray tem = items.at(0)->text().toUtf8(); - - std::string strName = tem.data(); - - SampleManager::ins()->removeRenderMaterial(strName); - - BlastProject::ins().removeGraphicsMaterial(strName.c_str()); - updateValues(); - ui->listWidget->setCurrentRow(ui->listWidget->count() - 1); -} - -void MaterialLibraryPanel::on_listWidget_currentRowChanged(int currentRow) -{ - _refreshMaterialValues(currentRow); -} - -void MaterialLibraryPanel::on_btnDiffuseColor_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - atcore_float4* color = (atcore_float4*)&(material->diffuseColor); - pickColor(*color); - setButtonColor(ui->btnDiffuseColor, color->x, color->y, color->z); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - - BlastProject::ins().reloadDiffuseColor(strName.c_str(), color->x, color->y, color->z); - - SampleManager::ins()->reloadRenderMaterial(strName, color->x, color->y, color->z); - } -} - -void MaterialLibraryPanel::on_btnDiffuseColorTex_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureButtonClicked(*material, eDiffuseTexture, ui->btnDiffuseColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->diffuseTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - BlastProject::ins().reloadDiffuseTexture(strName.c_str(), strTexture.c_str()); - - SampleManager::ins()->reloadRenderMaterial(strName, strTexture); - } -} - -void MaterialLibraryPanel::on_btnDiffuseColorTexReload_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureReload(*material, eDiffuseTexture, ui->btnDiffuseColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->diffuseTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - SampleManager::ins()->reloadRenderMaterial(strName, ""); - ResourceManager::ins()->releaseTexture(strTexture.c_str()); - SampleManager::ins()->reloadRenderMaterial(strName, strTexture); - } -} - -void MaterialLibraryPanel::on_btnDiffuseColorTexClear_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureClear(*material, eDiffuseTexture, ui->btnDiffuseColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - - BlastProject::ins().reloadDiffuseTexture(strName.c_str(), ""); - - SampleManager::ins()->reloadRenderMaterial(strName, ""); - } -} - -void MaterialLibraryPanel::on_btnSpecularColor_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - atcore_float4* color = (atcore_float4*)&(material->specularColor); - pickColor(*color); - setButtonColor(ui->btnSpecularColor, color->x, color->y, color->z); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - - BlastProject::ins().reloadSpecularColor(strName.c_str(), color->x, color->y, color->z); - - SampleManager::ins()->reloadRenderMaterial(strName, color->x, color->y, color->z, false); - } -} - -void MaterialLibraryPanel::on_btnSpecularColorTex_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureButtonClicked(*material, eSpecularTexture, ui->btnSpecularColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->specularTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - BlastProject::ins().reloadSpecularTexture(strName.c_str(), strTexture.c_str()); - - SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Specular); - } -} - -void MaterialLibraryPanel::on_btnSpecularColorTexReload_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureReload(*material, eSpecularTexture, ui->btnSpecularColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->specularTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Specular); - ResourceManager::ins()->releaseTexture(strTexture.c_str()); - SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Specular); - } -} - -void MaterialLibraryPanel::on_btnSpecularColorTexClear_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureClear(*material, eSpecularTexture, ui->btnSpecularColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - - BlastProject::ins().reloadSpecularTexture(strName.c_str(), ""); - - SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Specular); - } -} - -void MaterialLibraryPanel::on_spinSpecularShin_valueChanged(double arg1) -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - float specularShininess = (float)arg1; - - material->specularShininess = specularShininess; - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - SampleManager::ins()->reloadRenderMaterial(strName, specularShininess); - } -} - -void MaterialLibraryPanel::on_btnNormalColorTex_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureButtonClicked(*material, eNormalTexture, ui->btnNormalColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->normalTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - BlastProject::ins().reloadNormalTexture(strName.c_str(), strTexture.c_str()); - - SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Normal); - } -} - -void MaterialLibraryPanel::on_btnNormalColorTexReload_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureReload(*material, eNormalTexture, ui->btnNormalColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - QString qTexture = material->normalTextureFilePath.buf; - std::string strTexture = qTexture.toUtf8().data(); - - SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Normal); - ResourceManager::ins()->releaseTexture(strTexture.c_str()); - SampleManager::ins()->reloadRenderMaterial(strName, strTexture, RenderMaterial::TT_Normal); - } -} - -void MaterialLibraryPanel::on_btnNormalColorTexClear_clicked() -{ - BPPGraphicsMaterial* material = _getSelectedMaterial(); - if (material) - { - OnTextureClear(*material, eNormalTexture, ui->btnNormalColorTex); - - QString qName = material->name.buf; - std::string strName = qName.toUtf8().data(); - - BlastProject::ins().reloadNormalTexture(strName.c_str(), ""); - - SampleManager::ins()->reloadRenderMaterial(strName, "", RenderMaterial::TT_Normal); - } -} - -void MaterialLibraryPanel::_refreshMaterialValues(int idx) -{ - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& graphicsMaterialArray = projectParams.graphicsMaterials; - int count = graphicsMaterialArray.arraySizes[0]; - if (idx >= 0 && idx < count) - { - const BPPGraphicsMaterial& material = graphicsMaterialArray.buf[idx]; - - ui->spinSpecularShin->setValue(material.specularShininess); - - const nvidia::NvVec4& diffuseColor = material.diffuseColor; - const nvidia::NvVec4& specularColor = material.specularColor; - setButtonColor(ui->btnDiffuseColor, diffuseColor.x, diffuseColor.y, diffuseColor.z); - setButtonColor(ui->btnSpecularColor, specularColor.x, specularColor.y, specularColor.z); - - updateTextureButton(ui->btnDiffuseColorTex, material.diffuseTextureFilePath.buf); - updateTextureButton(ui->btnSpecularColorTex, material.specularTextureFilePath.buf); - updateTextureButton(ui->btnNormalColorTex, material.normalTextureFilePath.buf); - } - else - { - ui->spinSpecularShin->setValue(0.0f); - - setButtonColor(ui->btnDiffuseColor, 0, 0, 0); - setButtonColor(ui->btnSpecularColor, 0, 0, 0); - updateTextureButton(ui->btnDiffuseColorTex, ""); - updateTextureButton(ui->btnSpecularColorTex, ""); - updateTextureButton(ui->btnNormalColorTex, ""); - } -} - -BPPGraphicsMaterial* MaterialLibraryPanel::_getSelectedMaterial() -{ - BPParams& projectParams = BlastProject::ins().getParams(); - BPPGraphicsMaterialArray& graphicsMaterialArray = projectParams.graphicsMaterials; - - int idx = ui->listWidget->currentRow(); - int count = graphicsMaterialArray.arraySizes[0]; - if (idx < 0 || idx > count) - return nullptr; - - return &(graphicsMaterialArray.buf[idx]); -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h deleted file mode 100644 index 9012294..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/MaterialLibraryPanel.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef MATERIALLIBRARYPANEL_H -#define MATERIALLIBRARYPANEL_H - -#include <QtWidgets/QWidget> -#include "ProjectParams.h" - -class RenderMaterial; - -namespace Ui { -class MaterialLibraryPanel; -} - -class MaterialLibraryPanel : public QWidget -{ - Q_OBJECT - -public: - explicit MaterialLibraryPanel(QWidget *parent = 0); - ~MaterialLibraryPanel(); - void updateValues(); - - static MaterialLibraryPanel* ins(); - -private slots: - void on_btnAddMat_clicked(); - - void on_btnModifyMat_clicked(); - - void on_btnRemoveMat_clicked(); - - void on_listWidget_currentRowChanged(int currentRow); - - void on_btnDiffuseColor_clicked(); - - void on_btnDiffuseColorTex_clicked(); - - void on_btnDiffuseColorTexReload_clicked(); - - void on_btnDiffuseColorTexClear_clicked(); - - void on_btnSpecularColor_clicked(); - - void on_btnSpecularColorTex_clicked(); - - void on_btnSpecularColorTexReload_clicked(); - - void on_btnSpecularColorTexClear_clicked(); - - void on_spinSpecularShin_valueChanged(double arg1); - - void on_btnNormalColorTex_clicked(); - - void on_btnNormalColorTexReload_clicked(); - - void on_btnNormalColorTexClear_clicked(); - -private: - void _refreshMaterialValues(int idx); - BPPGraphicsMaterial* _getSelectedMaterial(); - -private: - Ui::MaterialLibraryPanel *ui; -}; - -#endif // MATERIALLIBRARYPANEL_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.cpp b/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.cpp deleted file mode 100644 index 748002c..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "NoiseToolsDlg.h" -#include "ui_NoiseToolsDlg.h" - -NoiseToolsDlg::NoiseToolsDlg(QWidget *parent) : - QDialog(parent), - ui(new Ui::NoiseToolsDlg) -{ - ui->setupUi(this); -} - -NoiseToolsDlg::~NoiseToolsDlg() -{ - delete ui; -} - -void NoiseToolsDlg::on_comboBoxApplyByMaterial_currentIndexChanged(int index) -{ - -} - -void NoiseToolsDlg::on_spinBoxAmplitude_valueChanged(double arg1) -{ - -} - -void NoiseToolsDlg::on_spinBoxFrequency_valueChanged(double arg1) -{ - -} - -void NoiseToolsDlg::on_spinBoxAmplitude_3_valueChanged(double arg1) -{ - -} - -void NoiseToolsDlg::on_btnApply_clicked() -{ - -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.h b/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.h deleted file mode 100644 index 057dd42..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/NoiseToolsDlg.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef NOISETOOLSDLG_H -#define NOISETOOLSDLG_H - -#include <QtWidgets/QDialog> - -namespace Ui { -class NoiseToolsDlg; -} - -class NoiseToolsDlg : public QDialog -{ - Q_OBJECT - -public: - explicit NoiseToolsDlg(QWidget *parent = 0); - ~NoiseToolsDlg(); - -private slots: - void on_comboBoxApplyByMaterial_currentIndexChanged(int index); - - void on_spinBoxAmplitude_valueChanged(double arg1); - - void on_spinBoxFrequency_valueChanged(double arg1); - - void on_spinBoxAmplitude_3_valueChanged(double arg1); - - void on_btnApply_clicked(); - -private: - Ui::NoiseToolsDlg *ui; -}; - -#endif // NOISETOOLSDLG_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.cpp b/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.cpp deleted file mode 100644 index b2fdd75..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "QtUtil.h" - -#include <QtWidgets/QLabel> -#include "AppMainWindow.h" - -#include "SimpleScene.h" - -////////////////////////////////////////////////////////// -void setStyledToolTip(QPushButton *pButton, const char *tooltip) -{ - char styledString[1024]; - sprintf(styledString, "<span style=\"color:black;\">%s</span>", tooltip); - pButton->setToolTip(styledString); -} - -////////////////////////////////////////////////////////// -QString addStar(QString text, bool add) -{ - QByteArray ba = text.toUtf8(); - - const char* in = ba.data(); - char out[1024]; - - int i = 0; - for (i = 0; i < strlen(in); i++) - { - if (in[i] == '*') - break; - out[i] = in[i]; - } - out[i] = 0; - - QString newtext; - if (add) - newtext = QString((const char*)out) + QString("*"); - else - newtext = QString((const char*)out) ; - return newtext; -} - -////////////////////////////////////////////////////////// -void setFocusColor(QWidget* qWidget, bool sameAsDefault, bool sameForAllAssets) -{ - if (!qWidget) - return; - - QString sameStyle = QString("font: ; color: rgb(150,150,150);") ; - QString differentStyle = QString("font: bold; color: rgb(255,55,55);"); - QString style = (sameForAllAssets) ? sameStyle : differentStyle; - - qWidget->setStyleSheet(style); - - QLabel* label = dynamic_cast<QLabel*>(qWidget); - if (label) - { - QString newtext = addStar(label->text(), !sameAsDefault); - - label->setFrameStyle(0); - label->setText(newtext); - } -} - -////////////////////////////////////////////////////////// -void pickColor(atcore_float4& color) -{ - QColor currentColor; - currentColor.setRgbF(color.x, color.y, color.z); - - QColor newColor = QColorDialog::getColor(currentColor, NV_NULL); - if(newColor.isValid()) - { - qreal r,g,b; - newColor.getRgbF(&r, &g, &b); - - color.x = r; - color.y = g; - color.z = b; - } -} - -////////////////////////////////////////////////////////// -void setButtonColor(QPushButton *button, float r, float g, float b) -{ - QColor specColor; - specColor.setRgbF(r,g,b); - QString specBtnStyle = QString("background-color: rgb(%1,%2,%3);") - .arg(specColor.red()) - .arg(specColor.green()) - .arg(specColor.blue()); - - button->setStyleSheet(specBtnStyle); -} - - -///////////////////////////////////////////////////////////////////////////////////// -void updateColorButton(QPushButton* button, int paramID, QLabel* label) -{ - //atcore_float4 v; - //SimpleScene::Inst()->GetFurCharacter().GetHairParam(paramID, &v); - - //setButtonColor(button, v.x, v.y, v.z); - - //if (label) - // setFocusColor(label, paramID); -} - -///////////////////////////////////////////////////////////////////////////////////// -void setClearButtonIcon(QPushButton *pButton) -{ - pButton->setIcon(QIcon(":/AppMainWindow/images/Remove_icon.png")); -} - -///////////////////////////////////////////////////////////////////////////////////// -void setTextureButtons(QPushButton *pTex, QPushButton *pReload, QPushButton *pClear) -{ - pTex->setIcon(QIcon(":/AppMainWindow/images/TextureEnabled_icon.png")); - pReload->setIcon(QIcon(":/AppMainWindow/images/Refresh_icon.png")); - pClear->setIcon(QIcon(":/AppMainWindow/images/Remove_icon.png")); - - pTex->setIconSize(QSize(12,12)); - pReload->setIconSize(QSize(12,12)); - pClear->setIconSize(QSize(12,12)); -} - -///////////////////////////////////////////////////////////////////////////////////// -void updateTextureButton(QPushButton* pButton, const QString& texturePath) -{ - if (!texturePath.isEmpty()) setStyledToolTip(pButton, texturePath.toUtf8().data()); - - bool isTextureUsed = true; - QIcon notUsedIcon = QIcon(":/AppMainWindow/images/TextureEnabled_icon.png"); - QIcon isUsedIcon = QIcon(":/AppMainWindow/images/TextureIsUsed_icon.png"); - QIcon disabledIcon = QIcon(":/AppMainWindow/images/TextureDisabled_icon.png"); - - pButton->setIcon(!texturePath.isEmpty() ? isUsedIcon : notUsedIcon); -} - -/////////////////////////////////////////////////////////////////////////////////////// -//bool LoadHairTexture(NvHair::TextureType::Enum textureType) -//{ -// QString texName = AppMainWindow::Inst().OpenTextureFile(); -// return SimpleScene::Inst()->GetFurCharacter().LoadHairTexture(textureType, texName.toLocal8Bit()); -//} -// -/////////////////////////////////////////////////////////////////////////////////////// -//bool ReloadHairTexture(NvHair::TextureType::Enum textureType) -//{ -// return SimpleScene::Inst()->GetFurCharacter().ReloadHairTexture(textureType); -//} -// -/////////////////////////////////////////////////////////////////////////////////////// -//bool ClearHairTexture(NvHair::TextureType::Enum textureType) -//{ -// return SimpleScene::Inst()->GetFurCharacter().ClearHairTexture(textureType); -//} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.h b/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.h deleted file mode 100644 index 2372b06..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/QtUtil.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef QtUtil_h__ -#define QtUtil_h__ - -#include <QtCore/QFileInfo> -#include <QtCore/QDir> -#include <QtWidgets/QColorDialog> -#include <QtGui/QPalette> -#include <QtWidgets/QWidget> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QSpinBox> -#include <QtWidgets/QDoubleSpinBox> -#include <QtWidgets/QCheckBox> -#include <QtWidgets/QComboBox> -#include <QtWidgets/QLabel> -#include <QtWidgets/QSlider> -#include "corelib_global.h" - -// utility functions to quickly set and update UI - -void setStyledToolTip(QPushButton *pButton, const char *tooltip); -void pickColor(atcore_float4& color); -void setButtonColor(QPushButton *button, float r, float g, float b); - -void setFocusColor(QWidget* qWidget, bool sameAsDefault, bool sameForAllAssets); - -void updateColorButton(QPushButton* pButton, int paramID, QLabel* label = 0); - -void setTextureButtons(QPushButton *pButton, QPushButton *pReload, QPushButton *pClear); -void updateTextureButton(QPushButton* pButton, const QString& texturePath); - -void setClearButtonIcon(QPushButton *pButton); - -//bool LoadHairTexture(NvHair::TextureType::Enum textureType); -//bool ReloadHairTexture(NvHair::TextureType::Enum textureType); -//bool ClearHairTexture(NvHair::TextureType::Enum textureType); - -#endif diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp deleted file mode 100644 index 9db55c2..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "SourceAssetOpenDlg.h" -#include "ui_SourceAssetOpenDlg.h" -#include <QtWidgets/QFileDialog> -#include "AppMainWindow.h" -#include "GlobalSettings.h" - -SourceAssetOpenDlg::SourceAssetOpenDlg(int usefor, QWidget *parent) : - QDialog(parent), - ui(new Ui::SourceAssetOpenDlg) -{ - ui->setupUi(this); - - m_usefor = usefor; - ui->buttonBox->button(QDialogButtonBox::Ok)->setFixedWidth(100); - ui->buttonBox->button(QDialogButtonBox::Cancel)->setFixedWidth(100); - ui->spinBoxDegree->setMaximum(180); - ui->spinBoxDegree->setMinimum(-180); - - ui->spinBoxXPosition->setRange(-DBL_MAX, DBL_MAX); - ui->spinBoxYPosition->setRange(-DBL_MAX, DBL_MAX); - ui->spinBoxZPosition->setRange(-DBL_MAX, DBL_MAX); - ui->spinBoxXAxis->setRange(-DBL_MAX, DBL_MAX); - ui->spinBoxYAxis->setRange(-DBL_MAX, DBL_MAX); - ui->spinBoxZAxis->setRange(-DBL_MAX, DBL_MAX); - - if (m_usefor == 2) - { - ui->fileLabel->setVisible(false); - ui->lineEditFile->setVisible(false); - ui->btnOpenFile->setVisible(false); - - ui->skinnedLabel->setVisible(false); - ui->checkBoxSkinned->setVisible(false); - - ui->appendLabel->setVisible(false); - ui->checkBoxAppend->setVisible(false); - - ui->preFracturedLabel->setVisible(false); - ui->checkBoxPreFractured->setVisible(false); - } - - GlobalSettings& globalSettings = GlobalSettings::Inst(); - ui->cbSceneUnit->setCurrentIndex(globalSettings.m_sceneUnitIndex); - - if (m_usefor != 0) - { - ui->autoComputeLabel->setVisible(false); - ui->checkBoxAutoCompute->setVisible(false); - } -} - -SourceAssetOpenDlg::~SourceAssetOpenDlg() -{ - delete ui; -} - -void SourceAssetOpenDlg::setDefaultFile(const QString& fn) -{ - ui->lineEditFile->setText(fn); -} - -QString SourceAssetOpenDlg::getFile() -{ - return ui->lineEditFile->text(); -} - -bool SourceAssetOpenDlg::getSkinned() -{ - return ui->checkBoxSkinned->isChecked(); -} - -QVector3D SourceAssetOpenDlg::getPosition() -{ - return QVector3D(ui->spinBoxXPosition->value(), ui->spinBoxYPosition->value(), ui->spinBoxZPosition->value()); -} - -QVector3D SourceAssetOpenDlg::getRotationAxis() -{ - return QVector3D(ui->spinBoxXAxis->value(), ui->spinBoxYAxis->value(), ui->spinBoxZAxis->value()); -} - -double SourceAssetOpenDlg::getRotationDegree() -{ - return ui->spinBoxDegree->value(); -} - -int SourceAssetOpenDlg::sceneUnitIndex() -{ - return ui->cbSceneUnit->currentIndex(); -} - -bool SourceAssetOpenDlg::isAppend() -{ - return ui->checkBoxAppend->isChecked(); -} - -bool SourceAssetOpenDlg::isPreFractured() -{ - return ui->checkBoxPreFractured->isChecked(); -} - -bool SourceAssetOpenDlg::isAutoCompute() -{ - return ui->checkBoxAutoCompute->isChecked(); -} - -void SourceAssetOpenDlg::on_btnOpenFile_clicked() -{ - QString lastDir = AppMainWindow::Inst()._lastFilePath; - QString titleStr = "Open Source Asset File"; - - QString filetype = "Source Asset (*.fbx)"; - if (m_usefor == 1) - { - filetype = "Source Asset (*.blast)"; - } - QString fileName = QFileDialog::getOpenFileName(this, titleStr, lastDir, filetype); - if (!fileName.isEmpty()) - { - QFileInfo fileInfo(fileName); - AppMainWindow::Inst()._lastFilePath = fileInfo.absoluteDir().absolutePath(); - } - - ui->lineEditFile->setText(fileName); -} - -void SourceAssetOpenDlg::on_buttonBox_accepted() -{ - -} - -void SourceAssetOpenDlg::on_buttonBox_rejected() -{ - -} - -void SourceAssetOpenDlg::on_checkBoxPreFractured_stateChanged(int arg1) -{ - if (!ui->checkBoxPreFractured->isChecked()) - { - ui->checkBoxAutoCompute->setChecked(false); - } -} - -void SourceAssetOpenDlg::on_checkBoxAutoCompute_stateChanged(int arg1) -{ - if (ui->checkBoxAutoCompute->isChecked()) - { - ui->checkBoxPreFractured->setChecked(true); - } -}
\ No newline at end of file diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h b/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h deleted file mode 100644 index ed6da9c..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/SourceAssetOpenDlg.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SOURCEASSETOPENDLG_H -#define SOURCEASSETOPENDLG_H - -#include <QtWidgets/QDialog> -#include <QtGui/QVector3D> - -namespace Ui { -class SourceAssetOpenDlg; -} - -class SourceAssetOpenDlg : public QDialog -{ - Q_OBJECT - -public: - explicit SourceAssetOpenDlg(int usefor, QWidget *parent = 0); - ~SourceAssetOpenDlg(); - - void setDefaultFile(const QString& fn); - QString getFile(); - bool getSkinned(); - QVector3D getPosition(); - QVector3D getRotationAxis(); - double getRotationDegree(); - bool isAppend(); - bool isPreFractured(); - bool isAutoCompute(); - int sceneUnitIndex(); - -private slots: - void on_btnOpenFile_clicked(); - - void on_buttonBox_accepted(); - - void on_buttonBox_rejected(); - - void on_checkBoxPreFractured_stateChanged(int arg1); - void on_checkBoxAutoCompute_stateChanged(int arg1); - -private: - Ui::SourceAssetOpenDlg *ui; - /* - m_usefor: - 0 for open fbx file - 1 for open blast file - 2 for add BlastFamily - */ - int m_usefor; -}; - -#endif // SOURCEASSETOPENDLG_H diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp b/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp deleted file mode 100644 index 556da33..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "SupportPanel.h" -#include "ui_SupportPanel.h" - -SupportPanel::SupportPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::SupportPanel) -{ - ui->setupUi(this); - - //ui->labelHealthMask->setEnabled(false); - //ui->comboBoxHealthMask->setEnabled(false); - //ui->btnAddHealthMask->setEnabled(false); - //ui->btnPen->setEnabled(false); - //ui->btnRemove->setEnabled(false); - - _selectedBonds.clear(); -} - -SupportPanel::~SupportPanel() -{ - delete ui; - - _selectedBonds.clear(); -} - -void SupportPanel::updateValues() -{ - if (_selectedBonds.size() > 0) - { - BPPBond* bond = _selectedBonds[0]; - - //ui->comboBoxHealthMask->clear(); - //ui->comboBoxHealthMask->addItem(bond->name.buf); - ui->spinBoxBondStrength->setValue(bond->support.bondStrength); - ui->checkBoxEnableJoint->setChecked(bond->support.enableJoint); - } - else - { - //ui->comboBoxHealthMask->clear(); - //ui->comboBoxHealthMask->addItem("None"); - ui->spinBoxBondStrength->setValue(1.0f); - ui->checkBoxEnableJoint->setChecked(false); - } -} - -void SupportPanel::dataSelected(std::vector<BlastNode*> selections) -{ - _selectedBonds.clear(); - - for (BlastNode* node : selections) - { - if (eBond == node->getType()) - { - BPPBond* bond = static_cast<BPPBond*>(node->getData()); - _selectedBonds.push_back(bond); - } - } - - updateValues(); -} - -void SupportPanel::on_comboBoxHealthMask_currentIndexChanged(int index) -{ - -} - -void SupportPanel::on_btnAddHealthMask_clicked() -{ - -} - -void SupportPanel::on_btnPen_clicked() -{ - -} - -void SupportPanel::on_btnRemove_clicked() -{ - -} - -void SupportPanel::on_spinBoxBondStrength_valueChanged(double arg1) -{ - for (size_t i = 0; i < _selectedBonds.size(); ++i) - { - _selectedBonds[i]->support.bondStrength = arg1; - } -} - -void SupportPanel::on_checkBoxEnableJoint_stateChanged(int arg1) -{ - for (size_t i = 0; i < _selectedBonds.size(); ++i) - { - _selectedBonds[i]->support.enableJoint = arg1; - } -} diff --git a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.h b/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.h deleted file mode 100644 index 0987e46..0000000 --- a/tools/ArtistTools/source/BlastPlugin/Window/SupportPanel.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef SUPPORTPANEL_H -#define SUPPORTPANEL_H - -#include <QtWidgets/QWidget> -#include "BlastSceneTree.h" - -namespace Ui { -class SupportPanel; -} - -class SupportPanel : public QWidget, public ISceneObserver -{ - Q_OBJECT - -public: - explicit SupportPanel(QWidget *parent = 0); - ~SupportPanel(); - void updateValues(); - - virtual void dataSelected(std::vector<BlastNode*> selections); - -private slots: - void on_comboBoxHealthMask_currentIndexChanged(int index); - - void on_btnAddHealthMask_clicked(); - - void on_btnPen_clicked(); - - void on_btnRemove_clicked(); - - void on_spinBoxBondStrength_valueChanged(double arg1); - - void on_checkBoxEnableJoint_stateChanged(int arg1); - -private: - Ui::SupportPanel *ui; - std::vector<BPPBond*> _selectedBonds; -}; - -#endif // SUPPORTPANEL_H |