History

Working on the selection highlight js interface

samcake committed 8 years ago

Commit 771c64f1 parent 93208914 files · +59 −12Browse files

Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

interface/src/scripting/SelectionScriptingInterface.cpp+45−12
@@ -78,21 +78,24 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName · 77 unmodified lines
78}78}
79 79
80bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {80bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
81 auto highlightStyle = _highlightedListMap.value(listName);81 auto highlightStyle = _highlightedListMap.find(listName);
82 if (!highlightStyle.isBoundToList()) {82 if (highlightStyle == _highlightedListMap.end()) {
83 highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle());
84 }
85
86 if (!(*highlightStyle).isBoundToList()) {
83 GameplayObjects currentList = _selectedItemsListMap.value(listName);87 GameplayObjects currentList = _selectedItemsListMap.value(listName);
84 if (!currentList.getContainsData()) {88 if (!currentList.getContainsData()) {
85 _selectedItemsListMap.insert(listName, currentList);89 _selectedItemsListMap.insert(listName, currentList);
90 highlightStyleChanged(listName);
86 }91 }
92 (*highlightStyle).setBoundToList(true);
87 }93 }
88 94
89 highlightStyle.fromVariantMap(highlightStyleValues);95 (*highlightStyle).fromVariantMap(highlightStyleValues);
90 highlightStyle.setBoundToList(true);
91
92 _highlightedListMap.insert(listName, highlightStyle);
93 96
94 97
95 emit selectedItemsListChanged(listName);98 emit highlightStyleChanged(listName);
96 return true;99 return true;
97}100}
98 101
@@ -104,6 +107,7 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) · 5 unmodified lines
104 if (currentList.getContainsData()) {107 if (currentList.getContainsData()) {
105 }108 }
106 _highlightedListMap.erase(highlightStyle);109 _highlightedListMap.erase(highlightStyle);
110 emit selectedItemsListChanged(listName);
107 }111 }
108 }112 }
109 113
@@ -114,6 +118,15 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li · 4 unmodified lines
114 return QVariantMap();118 return QVariantMap();
115}119}
116 120
121render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
122 auto highlightStyle = _highlightedListMap.find(listName);
123 if (highlightStyle != _highlightedListMap.end()) {
124 return render::HighlightStyle();
125 } else {
126 return (*highlightStyle).getStyle();
127 }
128}
129
117template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {130template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {
118 GameplayObjects currentList = _selectedItemsListMap.value(listName);131 GameplayObjects currentList = _selectedItemsListMap.value(listName);
119 currentList.addToGameplayObjects(idToAdd);132 currentList.addToGameplayObjects(idToAdd);
@@ -237,6 +250,21 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 117 unmodified lines
237 }250 }
238}251}
239 252
253void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) {
254 auto mainScene = qApp->getMain3DScene();
255 if (mainScene) {
256 auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName);
257 render::Transaction transaction;
258 render::ItemIDs finalList;
259
260 transaction.resetSelectionHighlight(listName.toStdString(), thisStyle);
261
262 mainScene->enqueueTransaction(transaction);
263 }
264 else {
265 qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown";
266 }
267}
240 268
241bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) {269bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) {
242 auto outlineColor = properties["outlineColor"];270 auto outlineColor = properties["outlineColor"];
@@ -261,10 +289,6 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { · 18 unmodified lines
261 _style.outlineIntensity = outlineIntensity.toFloat();289 _style.outlineIntensity = outlineIntensity.toFloat();
262 }290 }
263 291
264 auto isFilled = properties["isFilled"];
265 if (isFilled.isValid()) {
266 _style.isFilled = isFilled.toBool();
267 }
268 auto unoccludedFillOpacity = properties["unoccludedFillOpacity"];292 auto unoccludedFillOpacity = properties["unoccludedFillOpacity"];
269 if (unoccludedFillOpacity.isValid()) {293 if (unoccludedFillOpacity.isValid()) {
270 _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat();294 _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat();
@@ -277,5 +301,14 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { · 6 unmodified lines
277 return true;301 return true;
278}302}
279QVariantMap SelectionHighlightStyle::toVariantMap() const {303QVariantMap SelectionHighlightStyle::toVariantMap() const {
280 return QVariantMap();304 QVariantMap properties;
305
306 properties["outlineColor"] = xColorToVariant(xColorFromGlm(_style.color));
307 properties["outlineWidth"] = _style.outlineWidth;
308 properties["isOutlineSmooth"] = _style.isOutlineSmooth;
309 properties["outlineIntensity"] = _style.outlineIntensity;
310 properties["unoccludedFillOpacity"] = _style.unoccludedFillOpacity;
311 properties["occludedFillOpacity"] = _style.occludedFillOpacity;
312
313 return properties;
281}314}