Commit 1401bb77 authored by Mathieu Westphal's avatar Mathieu Westphal

Correct vtkAbstractContextItem methods signtures to use vtkIdType

vtkAbstractContextItem used to use unsigned int and converted -1 to unsigned int
This fixes it by using vtkIdType instead.
parent 999f47c7
......@@ -70,14 +70,14 @@ int TestContextItemStacking(int ,char * [] )
test5->SetLabel("5");
// Build up our multi-level scene
unsigned int index1 = rootItem->AddItem(test1);
unsigned int index2 = rootItem->AddItem(test2);
unsigned int index3 = rootItem->AddItem(test3);
unsigned int index4 = rootItem->AddItem(test4);
unsigned int index41 = test4->AddItem(test41);
unsigned int index411 = test41->AddItem(test411);
unsigned int index42 = test4->AddItem(test42);
unsigned int index5 = rootItem->AddItem(test5);
vtkIdType index1 = rootItem->AddItem(test1);
vtkIdType index2 = rootItem->AddItem(test2);
vtkIdType index3 = rootItem->AddItem(test3);
vtkIdType index4 = rootItem->AddItem(test4);
vtkIdType index41 = test4->AddItem(test41);
vtkIdType index411 = test41->AddItem(test411);
vtkIdType index42 = test4->AddItem(test42);
vtkIdType index5 = rootItem->AddItem(test5);
view->GetScene()->AddItem(rootItem);
// Check indexes
......
......@@ -315,7 +315,7 @@ void vtkChartXY::Update()
for (int i = 0; i < static_cast<int>(this->ChartPrivate->PlotCorners.size()); ++i)
{
int visible = 0;
for (unsigned int j = 0; j < this->ChartPrivate->PlotCorners[i]->GetNumberOfItems(); ++j)
for (vtkIdType j = 0; j < this->ChartPrivate->PlotCorners[i]->GetNumberOfItems(); ++j)
{
if (vtkPlot::SafeDownCast(this->ChartPrivate->PlotCorners[i]->GetItem(j))->GetVisible())
{
......@@ -573,7 +573,7 @@ void vtkChartXY::RecalculatePlotTransforms()
// their input data when necessary.
vtkRectd shiftScale(
xAxis->GetShift(), yAxis->GetShift(), xAxis->GetScalingFactor(), yAxis->GetScalingFactor());
for (unsigned int j = 0; j < this->ChartPrivate->PlotCorners[i]->GetNumberOfItems(); ++j)
for (vtkIdType j = 0; j < this->ChartPrivate->PlotCorners[i]->GetNumberOfItems(); ++j)
{
vtkPlot* plot = vtkPlot::SafeDownCast(this->ChartPrivate->PlotCorners[i]->GetItem(j));
if (plot)
......
......@@ -57,7 +57,7 @@ void vtkAbstractContextItem::Update()
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::AddItem(vtkAbstractContextItem* item)
vtkIdType vtkAbstractContextItem::AddItem(vtkAbstractContextItem* item)
{
return this->Children->AddItem(item);
}
......@@ -69,15 +69,22 @@ bool vtkAbstractContextItem::RemoveItem(vtkAbstractContextItem* item)
}
//-----------------------------------------------------------------------------
bool vtkAbstractContextItem::RemoveItem(unsigned int index)
bool vtkAbstractContextItem::RemoveItem(vtkIdType index)
{
return this->Children->RemoveItem(index);
if (index >= 0 && index < static_cast<vtkIdType>(this->Children->size()))
{
return this->Children->RemoveItem(index);
}
else
{
return false;
}
}
//-----------------------------------------------------------------------------
vtkAbstractContextItem* vtkAbstractContextItem::GetItem(unsigned int index)
vtkAbstractContextItem* vtkAbstractContextItem::GetItem(vtkIdType index)
{
if (index < this->Children->size())
if (index >= 0 && index < static_cast<vtkIdType>(this->Children->size()))
{
return this->Children->at(index);
}
......@@ -88,21 +95,21 @@ vtkAbstractContextItem* vtkAbstractContextItem::GetItem(unsigned int index)
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::GetItemIndex(vtkAbstractContextItem* item)
vtkIdType vtkAbstractContextItem::GetItemIndex(vtkAbstractContextItem* item)
{
vtkContextScenePrivate::const_iterator it =
std::find(this->Children->begin(), this->Children->end(), item);
if (it == this->Children->end())
{
return static_cast<unsigned int>(-1);
return -1;
}
return it - this->Children->begin();
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::GetNumberOfItems()
vtkIdType vtkAbstractContextItem::GetNumberOfItems()
{
return static_cast<unsigned int>(this->Children->size());
return static_cast<vtkIdType>(this->Children->size());
}
//-----------------------------------------------------------------------------
......@@ -112,24 +119,24 @@ void vtkAbstractContextItem::ClearItems()
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::Raise(unsigned int index)
vtkIdType vtkAbstractContextItem::Raise(vtkIdType index)
{
return this->StackAbove(index, this->GetNumberOfItems() - 1);
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::StackAbove(unsigned int index,
unsigned int under)
vtkIdType vtkAbstractContextItem::StackAbove(vtkIdType index,
vtkIdType under)
{
unsigned int res = index;
if (index == under)
vtkIdType res = index;
if (index == under || index < 0)
{
return res;
}
unsigned int start = 0;
unsigned int middle = 0;
unsigned int end = 0;
if (under == static_cast<unsigned int>(-1))
vtkIdType start = 0;
vtkIdType middle = 0;
vtkIdType end = 0;
if (under == -1)
{
start = 0;
middle = index;
......@@ -157,14 +164,14 @@ unsigned int vtkAbstractContextItem::StackAbove(unsigned int index,
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::Lower(unsigned int index)
vtkIdType vtkAbstractContextItem::Lower(vtkIdType index)
{
return this->StackUnder(index, 0);
}
//-----------------------------------------------------------------------------
unsigned int vtkAbstractContextItem::StackUnder(unsigned int child,
unsigned int above)
vtkIdType vtkAbstractContextItem::StackUnder(vtkIdType child,
vtkIdType above)
{
return this->StackAbove(child, above - 1);
}
......
......@@ -71,7 +71,7 @@ public:
* Add child items to this item. Increments reference count of item.
* \return the index of the child item.
*/
unsigned int AddItem(vtkAbstractContextItem* item);
vtkIdType AddItem(vtkAbstractContextItem* item);
/**
* Remove child item from this item. Decrements reference count of item.
......@@ -85,24 +85,24 @@ public:
* \param index of the item to be removed.
* \return true on success, false otherwise.
*/
bool RemoveItem(unsigned int index);
bool RemoveItem(vtkIdType index);
/**
* Get the item at the specified index.
* \return the item at the specified index (null if index is invalid).
*/
vtkAbstractContextItem* GetItem(unsigned int index);
vtkAbstractContextItem* GetItem(vtkIdType index);
/**
* Get the index of the specified item.
* \return the index of the item (-1 if item is not a valid child).
* Get the index of the specified item in itemIndex.
* \return the item index if found or -1 if not.
*/
unsigned int GetItemIndex(vtkAbstractContextItem* item);
vtkIdType GetItemIndex(vtkAbstractContextItem* item);
/**
* Get the number of child items.
*/
unsigned int GetNumberOfItems();
vtkIdType GetNumberOfItems();
/**
* Remove all child items from this item.
......@@ -114,7 +114,7 @@ public:
* \return The new index of the item
* \sa StackAbove(), Lower(), LowerUnder()
*/
unsigned int Raise(unsigned int index);
vtkIdType Raise(vtkIdType index);
/**
* Raises the \a child above the \a under sibling. If \a under is invalid,
......@@ -122,15 +122,15 @@ public:
* \return The new index of the item
* \sa Raise(), Lower(), StackUnder()
*/
virtual unsigned int StackAbove(unsigned int index,
unsigned int under);
virtual vtkIdType StackAbove(vtkIdType index,
vtkIdType under);
/**
* Lowers the \a child to the bottom of the item's stack.
* \return The new index of the item
* \sa StackUnder(), Raise(), StackAbove()
*/
unsigned int Lower(unsigned int index);
vtkIdType Lower(vtkIdType index);
/**
* Lowers the \a child under the \a above sibling. If \a above is invalid,
......@@ -138,8 +138,8 @@ public:
* \return The new index of the item
* \sa Lower(), Raise(), StackAbove()
*/
virtual unsigned int StackUnder(unsigned int child,
unsigned int above);
virtual vtkIdType StackUnder(vtkIdType child,
vtkIdType above);
/**
* Return true if the supplied x, y coordinate is inside the item.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment