Skip to content

Commit 1892130

Browse files
committed
Hotfix
1 parent 2532056 commit 1892130

File tree

1 file changed

+47
-21
lines changed

1 file changed

+47
-21
lines changed

src/ScatterplotPlugin.cpp

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include <vector>
3434
#include <actions/ViewPluginSamplerAction.h>
3535

36+
#define VIEW_SAMPLING_HTML
37+
//#define VIEW_SAMPLING_WIDGET
38+
3639
Q_PLUGIN_METADATA(IID "studio.manivault.ScatterplotPlugin")
3740

3841
using namespace mv;
@@ -232,27 +235,6 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
232235
auto& selectionAction = _settingsAction.getSelectionAction();
233236

234237
getSamplerAction().initialize(this, &selectionAction.getPixelSelectionAction(), &selectionAction.getSamplerPixelSelectionAction());
235-
getSamplerAction().setViewGeneratorFunction([this](const ViewPluginSamplerAction::SampleContext& toolTipContext) -> QString {
236-
QStringList localPointIndices, globalPointIndices;
237-
238-
for (const auto& localPointIndex : toolTipContext["LocalPointIndices"].toList())
239-
localPointIndices << QString::number(localPointIndex.toInt());
240-
241-
for (const auto& globalPointIndex : toolTipContext["GlobalPointIndices"].toList())
242-
globalPointIndices << QString::number(globalPointIndex.toInt());
243-
244-
if (localPointIndices.isEmpty())
245-
return {};
246-
247-
return QString("<table> \
248-
<tr> \
249-
<td><b>Point ID's: </b></td> \
250-
<td>%1</td> \
251-
</tr> \
252-
</table>").arg(globalPointIndices.join(", "));
253-
});
254-
255-
//getSamplerAction().setViewingMode(ViewPluginSamplerAction::ViewingMode::Tooltip);
256238
getSamplerAction().getEnabledAction().setChecked(false);
257239

258240
getLearningCenterAction().addVideos(QStringList({ "Practitioner", "Developer" }));
@@ -299,6 +281,50 @@ void ScatterplotPlugin::init()
299281
_scatterPlotWidget->installEventFilter(this);
300282

301283
getLearningCenterAction().getViewPluginOverlayWidget()->setTargetWidget(_scatterPlotWidget);
284+
285+
#ifdef VIEW_SAMPLING_HTML
286+
getSamplerAction().setHtmlViewGeneratorFunction([this](const ViewPluginSamplerAction::SampleContext& toolTipContext) -> QString {
287+
QStringList localPointIndices, globalPointIndices;
288+
289+
for (const auto& localPointIndex : toolTipContext["LocalPointIndices"].toList())
290+
localPointIndices << QString::number(localPointIndex.toInt());
291+
292+
for (const auto& globalPointIndex : toolTipContext["GlobalPointIndices"].toList())
293+
globalPointIndices << QString::number(globalPointIndex.toInt());
294+
295+
if (localPointIndices.isEmpty())
296+
return {};
297+
298+
return QString("<table> \
299+
<tr> \
300+
<td><b>Point ID's: </b></td> \
301+
<td>%1</td> \
302+
</tr> \
303+
</table>").arg(globalPointIndices.join(", "));
304+
});
305+
#endif
306+
307+
#ifdef VIEW_SAMPLING_WIDGET
308+
auto pointIndicesTableWidget = new QTableWidget(5, 2);
309+
310+
pointIndicesTableWidget->setHorizontalHeaderLabels({ "Local point index", "Global point index" });
311+
312+
getSamplerAction().setWidgetViewGeneratorFunction([this, pointIndicesTableWidget](const ViewPluginSamplerAction::SampleContext& sampleContext) -> QWidget* {
313+
const auto localPointIndices = sampleContext["LocalPointIndices"].toList();
314+
const auto globalPointIndices = sampleContext["GlobalPointIndices"].toList();
315+
316+
pointIndicesTableWidget->setRowCount(localPointIndices.count());
317+
318+
for (int i = 0; i < localPointIndices.count(); ++i) {
319+
pointIndicesTableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(localPointIndices[i].toInt())));
320+
pointIndicesTableWidget->setItem(i, 1, new QTableWidgetItem(QString::number(globalPointIndices[i].toInt())));
321+
}
322+
323+
pointIndicesTableWidget->resizeColumnsToContents();
324+
325+
return pointIndicesTableWidget;
326+
});
327+
#endif
302328
}
303329

304330
void ScatterplotPlugin::loadData(const Datasets& datasets)

0 commit comments

Comments
 (0)