26 #ifndef __vtkChartSelectionHelper_h
27 #define __vtkChartSelectionHelper_h
31 #include "vtkAnnotationLink.h"
32 #include "vtkSelection.h"
33 #include "vtkSelectionNode.h"
35 #include "vtkContextScene.h"
36 #include "vtkContextMouseEvent.h"
54 assert(link != NULL && selectionIds != NULL);
60 vtkSelection *selection = link->GetCurrentSelection();
62 for (
unsigned int i = 0; i < selection->GetNumberOfNodes(); ++i)
64 vtkSelectionNode *tmp = selection->GetNode(i);
67 if (selectionPlot == plot)
77 node->SetContentType(vtkSelectionNode::INDICES);
78 node->SetFieldType(vtkSelectionNode::POINT);
79 node->GetProperties()->Set(vtkSelectionNode::PROP(), plot);
80 node->GetProperties()->Set(vtkSelectionNode::SOURCE(), plot->
GetInput());
82 node->SetSelectionList(selectionIds);
90 node->SetContentType(vtkSelectionNode::INDICES);
91 node->SetFieldType(vtkSelectionNode::POINT);
92 node->SetSelectionList(selectionIds);
93 link->SetCurrentSelection(selection.
GetPointer());
102 std::vector<vtkIdType> output;
113 while (i < size && iOld < oldSize)
115 if (ptrSelection[i] > ptrOldSelection[iOld])
117 output.push_back(ptrOldSelection[iOld++]);
119 else if (ptrSelection[i] == ptrOldSelection[iOld])
124 else if (ptrSelection[i] < ptrOldSelection[iOld])
129 while (iOld < oldSize)
131 output.push_back(ptrOldSelection[iOld++]);
135 for (std::vector<vtkIdType>::iterator it = output.begin();
136 it != output.end(); ++it, ++ptrSelection)
153 std::vector<vtkIdType>::iterator it;
154 it = std::set_union(ptrSelection,
159 int newSize = int(it - output.begin());
162 for (std::vector<vtkIdType>::iterator i = output.begin(); i != it;
175 std::vector<vtkIdType> output;
184 while (i < size && iOld < oldSize)
186 if (ptrSelection[i] > ptrOldSelection[iOld])
188 output.push_back(ptrOldSelection[iOld++]);
190 else if (ptrSelection[i] == ptrOldSelection[iOld])
195 else if (ptrSelection[i] < ptrOldSelection[iOld])
197 output.push_back(ptrSelection[i++]);
202 output.push_back(ptrSelection[i++]);
204 while (iOld < oldSize)
206 output.push_back(ptrOldSelection[iOld++]);
210 for (std::vector<vtkIdType>::iterator it = output.begin();
211 it != output.end(); ++it, ++ptrSelection)
226 if (!plotSelection || !oldSelection)
233 switch(selectionMode)
235 case vtkContextScene::SELECTION_ADDITION:
238 case vtkContextScene::SELECTION_SUBTRACTION:
241 case vtkContextScene::SELECTION_TOGGLE:
244 case vtkContextScene::SELECTION_DEFAULT:
262 if (mouse.GetModifiers() & vtkContextMouseEvent::SHIFT_MODIFIER &&
263 mouse.GetModifiers() & vtkContextMouseEvent::CONTROL_MODIFIER)
265 return vtkContextScene::SELECTION_TOGGLE;
267 else if (mouse.GetModifiers() & vtkContextMouseEvent::SHIFT_MODIFIER)
269 return vtkContextScene::SELECTION_ADDITION;
271 else if (mouse.GetModifiers() & vtkContextMouseEvent::CONTROL_MODIFIER)
273 return vtkContextScene::SELECTION_SUBTRACTION;
275 return selectionMode;
281 #endif // __vtkChartSelectionHelper_h
vtkIdType GetNumberOfTuples()
void MakeSelection(vtkAnnotationLink *link, vtkIdTypeArray *selectionIds, vtkPlot *plot)
void MinusSelection(vtkIdTypeArray *selection, vtkIdTypeArray *oldSelection)
virtual void SetNumberOfTuples(vtkIdType number)=0
dynamic, self-adjusting array of vtkIdType
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
static vtkPlot * SafeDownCast(vtkObjectBase *o)
void BuildSelection(vtkAnnotationLink *link, int selectionMode, vtkIdTypeArray *plotSelection, vtkIdTypeArray *oldSelection, vtkPlot *plot)
Abstract class for 2D plots.
virtual void * GetVoidPointer(vtkIdType id)=0
void ToggleSelection(vtkIdTypeArray *selection, vtkIdTypeArray *oldSelection)
virtual vtkTable * GetInput()
helper functions for making selections in charts.
void AddSelection(vtkIdTypeArray *selection, vtkIdTypeArray *oldSelection)
Allocate and hold a VTK object.
int GetMouseSelectionMode(const vtkContextMouseEvent &mouse, int selectionMode)