|
33 | 33 | #include <vector> |
34 | 34 | #include <actions/ViewPluginSamplerAction.h> |
35 | 35 |
|
| 36 | +#define VIEW_SAMPLING_HTML |
| 37 | +//#define VIEW_SAMPLING_WIDGET |
| 38 | + |
36 | 39 | Q_PLUGIN_METADATA(IID "studio.manivault.ScatterplotPlugin") |
37 | 40 |
|
38 | 41 | using namespace mv; |
@@ -232,27 +235,6 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) : |
232 | 235 | auto& selectionAction = _settingsAction.getSelectionAction(); |
233 | 236 |
|
234 | 237 | 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); |
256 | 238 | getSamplerAction().getEnabledAction().setChecked(false); |
257 | 239 |
|
258 | 240 | getLearningCenterAction().addVideos(QStringList({ "Practitioner", "Developer" })); |
@@ -299,6 +281,50 @@ void ScatterplotPlugin::init() |
299 | 281 | _scatterPlotWidget->installEventFilter(this); |
300 | 282 |
|
301 | 283 | 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 |
302 | 328 | } |
303 | 329 |
|
304 | 330 | void ScatterplotPlugin::loadData(const Datasets& datasets) |
|
0 commit comments