12 #include <vtkIdTypeArray.h>
13 #include <vtkPolyData.h>
20 : m_vtkArray(nullptr), m_fieldAssociation(CELLS) {}
24 : m_vtkArray(nullptr),
29 vtkIdType numTuples =
vtkArray->GetNumberOfTuples();
47 : m_vtkArray(nullptr), m_fieldAssociation(association) {
50 m_vtkArray->SetNumberOfTuples(
ids.size());
51 for (
int i = 0; i <
ids.size(); ++i) {
52 m_vtkArray->SetValue(i,
ids[i]);
59 : m_vtkArray(nullptr),
60 m_fieldAssociation(other.m_fieldAssociation),
61 m_actorInfos(other.m_actorInfos) {
62 if (other.m_vtkArray) {
65 vtkIdType numTuples = other.m_vtkArray->GetNumberOfTuples();
72 m_vtkArray->DeepCopy(other.m_vtkArray);
84 m_fieldAssociation = other.m_fieldAssociation;
85 m_actorInfos = other.m_actorInfos;
87 if (other.m_vtkArray) {
90 vtkIdType numTuples = other.m_vtkArray->GetNumberOfTuples();
93 m_vtkArray->DeepCopy(other.m_vtkArray);
102 m_vtkArray =
nullptr;
115 return !m_vtkArray || m_vtkArray->GetNumberOfTuples() == 0;
120 return m_vtkArray ? m_vtkArray->GetNumberOfTuples() : 0;
127 vtkIdType numTuples = m_vtkArray->GetNumberOfTuples();
128 result.reserve(numTuples);
129 for (vtkIdType i = 0; i < numTuples; ++i) {
130 result.append(m_vtkArray->GetValue(i));
138 m_vtkArray =
nullptr;
139 m_actorInfos.clear();
144 return (m_fieldAssociation ==
CELLS) ?
"cells" :
"points";
149 m_actorInfos.append(info);
152 std::sort(m_actorInfos.begin(), m_actorInfos.end(),
154 return a.zValue < b.zValue;
160 vtkPolyData* polyData,
162 m_actorInfos.clear();
169 m_actorInfos.append(info);
174 if (index >= 0 && index < m_actorInfos.size()) {
175 return m_actorInfos[index];
182 return m_actorInfos.isEmpty() ? nullptr : m_actorInfos[0].actor;
187 return m_actorInfos.isEmpty() ? nullptr : m_actorInfos[0].polyData;
Encapsulates selection data without exposing VTK types.
~cvSelectionData()
Destructor.
cvSelectionData()
Construct empty selection data.
vtkSmartPointer< vtkIdTypeArray > vtkArray() const
Get the underlying VTK array (for internal use only)
QString fieldTypeString() const
Get human-readable field type string.
void addActorInfo(const cvActorSelectionInfo &info)
Actor/Representation information (ParaView-style)
FieldAssociation
Field association for selection.
@ CELLS
Selection applies to cells.
bool isEmpty() const
Check if selection is empty.
void clearActorInfo()
Clear actor information.
QVector< qint64 > ids() const
Get selected IDs as a vector (copy)
cvSelectionData & operator=(const cvSelectionData &other)
Assignment operator.
int count() const
Get number of selected items.
cvActorSelectionInfo actorInfo(int index=0) const
Get actor info at index.
void clear()
Clear the selection.
vtkPolyData * primaryPolyData() const
Get the primary (front-most) polyData.
vtkActor * primaryActor() const
Get the primary (front-most) actor.
void setActorInfo(vtkActor *actor, vtkPolyData *polyData, double zValue=1.0)
Set actor information (single actor case)
Information about a selected actor/representation.
double zValue
Z-buffer depth value (for front-to-back ordering)
vtkPolyData * polyData
The associated polyData (weak pointer)
vtkActor * actor
The selected actor (weak pointer)