Skip to content

Commit 7473b3c

Browse files
Update view plugin to core version 0.2
1 parent 44158f6 commit 7473b3c

2 files changed

Lines changed: 40 additions & 42 deletions

File tree

ExampleView/src/ExampleViewPlugin.cpp

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,51 @@ void ExampleViewPlugin::init()
2222
{
2323
// Widgets can be freely added to the view plugin via the addWidget() function.
2424
ExampleWidget* exampleWidget = new ExampleWidget();
25-
addWidget(exampleWidget);
26-
}
2725

28-
/**
29-
* Callback which gets triggered when a dataset is added.
30-
* The name of the dataset which was added is given.
31-
* The added dataset can be retrieved through _core->requestSet(name);
32-
* and casting it to the appropriate high-level set.
33-
*/
34-
void ExampleViewPlugin::dataAdded(const QString name)
35-
{
36-
const Points& addedSet = _core->requestData<Points>(name);
37-
}
26+
auto layout = new QVBoxLayout();
3827

39-
/**
40-
* Callback which gets triggered when a dataset changes.
41-
* The name of the dataset which was changed is given.
42-
* The changed dataset can be retrieved through _core->requestSet(name);
43-
* and casting it to the appropriate high-level set.
44-
*/
45-
void ExampleViewPlugin::dataChanged(const QString name)
46-
{
47-
const Points& changedSet = _core->requestData<Points>(name);
48-
}
28+
layout->setMargin(0);
29+
layout->addWidget(exampleWidget, 0, Qt::AlignCenter);
4930

50-
/**
51-
* Callback which gets triggered when a dataset gets removed.
52-
* The name of the dataset which was removed is given.
53-
*/
54-
void ExampleViewPlugin::dataRemoved(const QString name)
55-
{
56-
const Points& removedSet = dynamic_cast<const Points&>(_core->requestData(name));
31+
setLayout(layout);
5732
}
5833

59-
/**
60-
* Callback which gets triggered when any plugin calls notifySelectionChanged().
61-
* The name of the data whose selection was changed is given and the new selection
62-
* can be retrieved through _core->requestSelection(dataName);
63-
*/
64-
void ExampleViewPlugin::selectionChanged(const QString dataName)
34+
void ExampleViewPlugin::onDataEvent(hdps::DataEvent* dataEvent)
6535
{
66-
const hdps::DataSet& selectionSet = _core->requestSelection(dataName);
67-
}
36+
// Event which gets triggered when a dataset is added to the system.
37+
if (dataEvent->getType() == EventType::DataAdded)
38+
{
39+
// Request the point data that has been added for further processing
40+
const Points& addedSet = _core->requestData<Points>(dataEvent->dataSetName);
6841

69-
DataTypes ExampleViewPlugin::supportedDataTypes() const
70-
{
71-
DataTypes supportedTypes;
72-
supportedTypes.append(PointType);
73-
return supportedTypes;
42+
// ...
43+
}
44+
// Event which gets triggered when the data contained in a dataset changes.
45+
if (dataEvent->getType() == EventType::DataChanged)
46+
{
47+
// Request the point data that has changed for further processing
48+
// Datasets can be retrieved through _core->requestData<Type>(name);
49+
const Points& changedSet = _core->requestData<Points>(dataEvent->dataSetName);
50+
51+
// ...
52+
}
53+
// Event which gets triggered when a dataset is removed from the system.
54+
if (dataEvent->getType() == EventType::DataRemoved)
55+
{
56+
// Request the point data that has been removed for further processing
57+
const Points& removedSet = _core->requestData<Points>(dataEvent->dataSetName);
58+
59+
// ...
60+
}
61+
// Event which gets triggered when the selection associated with a dataset changes.
62+
if (dataEvent->getType() == EventType::SelectionChanged)
63+
{
64+
// Request the point data associated with the changed selection, and retrieve the selection from it
65+
const Points& changedDataSet = _core->requestData<Points>(dataEvent->dataSetName);
66+
const hdps::DataSet& selectionSet = changedDataSet.getSelection();
67+
68+
// ...
69+
}
7470
}
7571

7672
// =============================================================================

ExampleView/src/ExampleViewPlugin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class ExampleViewPlugin : public ViewPlugin
3434
~ExampleViewPlugin(void) override;
3535

3636
void init() override;
37+
38+
void onDataEvent(hdps::DataEvent* dataEvent);
3739
};
3840

3941

0 commit comments

Comments
 (0)