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
7878 }
7979
8080 bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
81− auto highlightStyle = _highlightedListMap.value(listName);
82− if (!highlightStyle.isBoundToList()) {
81+ auto highlightStyle = _highlightedListMap.find(listName);
82+ if (highlightStyle == _highlightedListMap.end()) {
83+ highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle());
84+ }
85+
86+ if (!(*highlightStyle).isBoundToList()) {
8387 GameplayObjects currentList = _selectedItemsListMap.value(listName);
8488 if (!currentList.getContainsData()) {
8589 _selectedItemsListMap.insert(listName, currentList);
90+ highlightStyleChanged(listName);
8691 }
92+ (*highlightStyle).setBoundToList(true);
8793 }
8894
89− highlightStyle.fromVariantMap(highlightStyleValues);
90− highlightStyle.setBoundToList(true);
91−
92− _highlightedListMap.insert(listName, highlightStyle);
95+ (*highlightStyle).fromVariantMap(highlightStyleValues);
9396
9497
95− emit selectedItemsListChanged(listName);
98+ emit highlightStyleChanged(listName);
9699 return true;
97100 }
98101
@@ -104,6 +107,7 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) · 5 unmodified lines
104107 if (currentList.getContainsData()) {
105108 }
106109 _highlightedListMap.erase(highlightStyle);
110+ emit selectedItemsListChanged(listName);
107111 }
108112 }
109113
@@ -114,6 +118,15 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li · 4 unmodified lines
114118 return QVariantMap();
115119 }
116120
121+render::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+
117130 template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {
118131 GameplayObjects currentList = _selectedItemsListMap.value(listName);
119132 currentList.addToGameplayObjects(idToAdd);
@@ -237,6 +250,21 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 117 unmodified lines
237250 }
238251 }
239252
253+void 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+}
240268
241269 bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) {
242270 auto outlineColor = properties["outlineColor"];
@@ -261,10 +289,6 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { · 18 unmodified lines
261289 _style.outlineIntensity = outlineIntensity.toFloat();
262290 }
263291
264− auto isFilled = properties["isFilled"];
265− if (isFilled.isValid()) {
266− _style.isFilled = isFilled.toBool();
267− }
268292 auto unoccludedFillOpacity = properties["unoccludedFillOpacity"];
269293 if (unoccludedFillOpacity.isValid()) {
270294 _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat();
@@ -277,5 +301,14 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { · 6 unmodified lines
277301 return true;
278302 }
279303 QVariantMap 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;
281314 }