Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -83,38 +83,56 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c · 82 unmodified lines | ||
| 83 | 83 | auto highlightStyle = _highlightedListMap.find(listName); |
| 84 | 84 | if (highlightStyle == _highlightedListMap.end()) { |
| 85 | 85 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); |
| 86 | − doSetupHandler = true; | |
| 86 | + | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | if (!(*highlightStyle).isBoundToList()) { |
| 90 | − GameplayObjects currentList = _selectedItemsListMap.value(listName); | |
| 91 | − if (!currentList.getContainsData()) { | |
| 92 | − _selectedItemsListMap.insert(listName, currentList); | |
| 93 | − doSetupHandler = true; | |
| 90 | + auto currentList = _selectedItemsListMap.find(listName); | |
| 91 | + if (currentList == _selectedItemsListMap.end()) { | |
| 92 | + _selectedItemsListMap.insert(listName, GameplayObjects()); | |
| 93 | + setupHandler(listName); | |
| 94 | + // doSetupHandler = true; | |
| 94 | 95 | } |
| 95 | 96 | (*highlightStyle).setBoundToList(true); |
| 96 | 97 | } |
| 97 | 98 | |
| 98 | 99 | (*highlightStyle).fromVariantMap(highlightStyleValues); |
| 99 | 100 | |
| 100 | − if (doSetupHandler) { | |
| 101 | +/* if (doSetupHandler) { | |
| 101 | 102 | setupHandler(listName); |
| 103 | + }*/ | |
| 104 | + | |
| 105 | + auto mainScene = qApp->getMain3DScene(); | |
| 106 | + if (mainScene) { | |
| 107 | + render::Transaction transaction; | |
| 108 | + transaction.resetSelectionHighlight(listName.toStdString(), (*highlightStyle).getStyle()); | |
| 109 | + mainScene->enqueueTransaction(transaction); | |
| 110 | + } | |
| 111 | + else { | |
| 112 | + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; | |
| 102 | 113 | } |
| 103 | 114 | |
| 104 | − emit highlightStyleChanged(listName); | |
| 105 | 115 | return true; |
| 106 | 116 | } |
| 107 | 117 | |
| 108 | 118 | bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { |
| 109 | 119 | auto highlightStyle = _highlightedListMap.find(listName); |
| 110 | 120 | if (highlightStyle != _highlightedListMap.end()) { |
| 111 | − if ((*highlightStyle).isBoundToList()) { | |
| 112 | − GameplayObjects currentList = _selectedItemsListMap.value(listName); | |
| 113 | − if (currentList.getContainsData()) { | |
| 114 | − } | |
| 121 | + // if ((*highlightStyle).isBoundToList()) { | |
| 115 | 122 | _highlightedListMap.erase(highlightStyle); |
| 116 | − emit selectedItemsListChanged(listName); | |
| 117 | − } | |
| 123 | + | |
| 124 | + auto mainScene = qApp->getMain3DScene(); | |
| 125 | + if (mainScene) { | |
| 126 | + render::Transaction transaction; | |
| 127 | + transaction.removeHighlightFromSelection(listName.toStdString()); | |
| 128 | + mainScene->enqueueTransaction(transaction); | |
| 129 | + } | |
| 130 | + else { | |
| 131 | + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; | |
| 132 | + } | |
| 133 | + // emit highlightStyleRemoved(listName); | |
| 134 | + | |
| 135 | + // } | |
| 118 | 136 | } |
| 119 | 137 | |
| 120 | 138 | return true; |
| @@ -126,7 +144,7 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li · 5 unmodified lines | ||
| 126 | 144 | |
| 127 | 145 | render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { |
| 128 | 146 | auto highlightStyle = _highlightedListMap.find(listName); |
| 129 | − if (highlightStyle != _highlightedListMap.end()) { | |
| 147 | + if (highlightStyle == _highlightedListMap.end()) { | |
| 130 | 148 | return render::HighlightStyle(); |
| 131 | 149 | } else { |
| 132 | 150 | return (*highlightStyle).getStyle(); |
| @@ -196,14 +214,6 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { · 63 unmodified lines | ||
| 196 | 214 | } |
| 197 | 215 | } |
| 198 | 216 | |
| 199 | −void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { | |
| 200 | − emit selectedItemsListChanged(listName); | |
| 201 | −} | |
| 202 | − | |
| 203 | −void SelectionScriptingInterface::onHighlightStyleChanged(const QString& listName) { | |
| 204 | − emit onHighlightStyleChanged(listName); | |
| 205 | −} | |
| 206 | − | |
| 207 | 217 | void SelectionScriptingInterface::setupHandler(const QString& selectionName) { |
| 208 | 218 | auto handler = _handlerMap.find(selectionName); |
| 209 | 219 | if (handler == _handlerMap.end()) { |
| @@ -223,14 +233,9 @@ void SelectionToSceneHandler::initialize(const QString& listName) { · 13 unmodified lines | ||
| 223 | 233 | _listName = listName; |
| 224 | 234 | |
| 225 | 235 | connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); |
| 226 | − connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); | |
| 236 | + // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); | |
| 237 | + // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved); | |
| 227 | 238 | |
| 228 | − auto mainScene = qApp->getMain3DScene(); | |
| 229 | − if (mainScene) { | |
| 230 | − render::Transaction transaction; | |
| 231 | − transaction.resetSelectionHighlight(listName.toStdString(), DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName)); | |
| 232 | − mainScene->enqueueTransaction(transaction); | |
| 233 | − } | |
| 234 | 239 | } |
| 235 | 240 | |
| 236 | 241 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { |
| @@ -284,25 +289,36 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 47 unmodified lines | ||
| 284 | 289 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; |
| 285 | 290 | } |
| 286 | 291 | } |
| 287 | − | |
| 292 | +/* | |
| 288 | 293 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { |
| 289 | 294 | if (listName == _listName) { |
| 290 | 295 | auto mainScene = qApp->getMain3DScene(); |
| 291 | 296 | if (mainScene) { |
| 292 | 297 | auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); |
| 293 | 298 | render::Transaction transaction; |
| 294 | − render::ItemIDs finalList; | |
| 295 | − | |
| 296 | 299 | transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); |
| 297 | − | |
| 298 | 300 | mainScene->enqueueTransaction(transaction); |
| 299 | 301 | } |
| 300 | 302 | else { |
| 301 | − qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | |
| 303 | + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; | |
| 302 | 304 | } |
| 303 | 305 | } |
| 304 | 306 | } |
| 305 | 307 | |
| 308 | +void SelectionToSceneHandler::highlightStyleRemoved(const QString& listName) { | |
| 309 | + if (listName == _listName) { | |
| 310 | + auto mainScene = qApp->getMain3DScene(); | |
| 311 | + if (mainScene) { | |
| 312 | + render::Transaction transaction; | |
| 313 | + transaction.removeHighlightFromSelection(listName.toStdString()); | |
| 314 | + mainScene->enqueueTransaction(transaction); | |
| 315 | + } | |
| 316 | + else { | |
| 317 | + qWarning() << "SelectionToSceneHandler::highlightStyleRemoved(), Unexpected null scene, possibly during application shutdown"; | |
| 318 | + } | |
| 319 | + } | |
| 320 | +} | |
| 321 | +*/ | |
| 306 | 322 | bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { |
| 307 | 323 | auto outlineColor = properties["outlineColor"]; |
| 308 | 324 | if (outlineColor.isValid()) { |