keep debuging the seelction highlight

This commit is contained in:
samcake 2017-11-17 18:11:18 -08:00
parent 76cfacef6b
commit e0740b323d
5 changed files with 67 additions and 34 deletions

View file

@ -73,12 +73,11 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis
bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
_selectedItemsListMap.insert(listName, GameplayObjects());
emit selectedItemsListChanged(listName);
onSelectedItemsListChanged(listName);
return true;
}
bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
bool doSetupHandler = false;
auto highlightStyle = _highlightedListMap.find(listName);
if (highlightStyle == _highlightedListMap.end()) {
@ -90,18 +89,14 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c
auto currentList = _selectedItemsListMap.find(listName);
if (currentList == _selectedItemsListMap.end()) {
_selectedItemsListMap.insert(listName, GameplayObjects());
setupHandler(listName);
// doSetupHandler = true;
}
setupHandler(listName);
(*highlightStyle).setBoundToList(true);
}
(*highlightStyle).fromVariantMap(highlightStyleValues);
/* if (doSetupHandler) {
setupHandler(listName);
}*/
auto mainScene = qApp->getMain3DScene();
if (mainScene) {
render::Transaction transaction;
@ -139,7 +134,12 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName)
}
QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {
return QVariantMap();
auto highlightStyle = _highlightedListMap.find(listName);
if (highlightStyle == _highlightedListMap.end()) {
return QVariantMap();
} else {
return (*highlightStyle).toVariantMap();
}
}
render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
@ -156,7 +156,7 @@ template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const
currentList.addToGameplayObjects(idToAdd);
_selectedItemsListMap.insert(listName, currentList);
emit selectedItemsListChanged(listName);
onSelectedItemsListChanged(listName);
return true;
}
template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
@ -165,7 +165,7 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c
currentList.removeFromGameplayObjects(idToRemove);
_selectedItemsListMap.insert(listName, currentList);
emit selectedItemsListChanged(listName);
onSelectedItemsListChanged(listName);
return true;
} else {
return false;
@ -180,34 +180,40 @@ GameplayObjects SelectionScriptingInterface::getList(const QString& listName) {
}
void SelectionScriptingInterface::printList(const QString& listName) {
GameplayObjects currentList = _selectedItemsListMap.value(listName);
if (currentList.getContainsData()) {
auto currentList = _selectedItemsListMap.find(listName);
if (currentList != _selectedItemsListMap.end()) {
if ((*currentList).getContainsData()) {
qDebug() << "Avatar IDs:";
for (auto i : currentList.getAvatarIDs()) {
qDebug() << i << ';';
}
qDebug() << "";
qDebug() << "List named " << listName << ":";
qDebug() << "Avatar IDs:";
for (auto i : (*currentList).getAvatarIDs()) {
qDebug() << i << ';';
}
qDebug() << "";
qDebug() << "Entity IDs:";
for (auto j : currentList.getEntityIDs()) {
qDebug() << j << ';';
}
qDebug() << "";
qDebug() << "Entity IDs:";
for (auto j : (*currentList).getEntityIDs()) {
qDebug() << j << ';';
}
qDebug() << "";
qDebug() << "Overlay IDs:";
for (auto k : currentList.getOverlayIDs()) {
qDebug() << k << ';';
qDebug() << "Overlay IDs:";
for (auto k : (*currentList).getOverlayIDs()) {
qDebug() << k << ';';
}
qDebug() << "";
}
else {
qDebug() << "List named " << listName << " empty";
}
qDebug() << "";
} else {
qDebug() << "List named" << listName << "doesn't exist.";
qDebug() << "List named " << listName << " doesn't exist.";
}
}
bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
if (_selectedItemsListMap.remove(listName)) {
emit selectedItemsListChanged(listName);
onSelectedItemsListChanged(listName);
return true;
} else {
return false;
@ -222,9 +228,17 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) {
(*handler)->initialize(selectionName);
// connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged);
}
void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) {
auto handler = _handlerMap.find(listName);
if (handler != _handlerMap.end()) {
(*handler)->updateSceneFromSelectedList();
}
}
SelectionToSceneHandler::SelectionToSceneHandler() {
}
@ -232,10 +246,8 @@ SelectionToSceneHandler::SelectionToSceneHandler() {
void SelectionToSceneHandler::initialize(const QString& listName) {
_listName = listName;
connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged);
// connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged);
// connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved);
updateSceneFromSelectedList();
}
void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {

View file

@ -138,6 +138,8 @@ public:
render::HighlightStyle getHighlightStyle(const QString& listName) const;
void onSelectedItemsListChanged(const QString& listName);
signals:
void selectedItemsListChanged(const QString& listName);
// void highlightStyleChanged(const QString& listName);

View file

@ -432,6 +432,24 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
outputs.clear();
_sharedParameters->_highlightIds.fill(render::HighlightStage::INVALID_INDEX);
int numLayers = 0;
auto highlightList = highlightStage->getActiveHighlightIds();
for (auto styleId : highlightList) {
auto highlight = highlightStage->getHighlight(styleId);
if (!scene->isSelectionEmpty(highlight._selectionName)) {
auto highlightId = highlightStage->getHighlightIdBySelection(highlight._selectionName);
_sharedParameters->_highlightIds[outputs.size()] = highlightId;
outputs.emplace_back(highlight._selectionName);
numLayers++;
if (numLayers == HighlightSharedParameters::MAX_PASS_COUNT) {
break;
}
}
}
/*
for (auto i = 0; i < HighlightSharedParameters::MAX_PASS_COUNT; i++) {
std::ostringstream stream;
if (i > 0) {
@ -447,7 +465,7 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext
outputs.emplace_back(selectionName);
}
}
}
}*/
}
void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {

View file

@ -51,6 +51,7 @@ namespace render {
HighlightIdList::iterator begin() { return _activeHighlightIds.begin(); }
HighlightIdList::iterator end() { return _activeHighlightIds.end(); }
const HighlightIdList& getActiveHighlightIds() const { return _activeHighlightIds; }
private:

View file

@ -442,7 +442,7 @@ bool Scene::isSelectionEmpty(const Selection::Name& name) const {
std::unique_lock<std::mutex> lock(_selectionsMutex);
auto found = _selections.find(name);
if (found == _selections.end()) {
return false;
return true;
} else {
return (*found).second.isEmpty();
}