Commit 162a6773 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell Committed by Kitware Robot
Browse files

Merge topic 'charts_julien'

5640829a ENH: Factorize the code to set a plot to a corner.
a3de986c BUG: Fix memory leak... the Qt mainwindow was not destructed
3f13424c BUG: Fix memory leaks found using dynamic analysis
775065d2 ENH: Mouse buttons are now binary comparable
parents 544562ed 5640829a
......@@ -36,7 +36,7 @@ vtkBlockItem::vtkBlockItem()
{
this->Label = NULL;
this->MouseOver = false;
this->MouseButtonPressed = -1;
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
this->scalarFunction = NULL;
this->Dimensions[0]=0;
this->Dimensions[1]=0;
......@@ -172,7 +172,7 @@ bool vtkBlockItem::MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
//-----------------------------------------------------------------------------
bool vtkBlockItem::MouseButtonReleaseEvent(const vtkContextMouseEvent &)
{
this->MouseButtonPressed = -1;
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
return true;
}
......
......@@ -193,7 +193,7 @@ bool vtkChartPie::MouseEnterEvent(const vtkContextMouseEvent &)
//-----------------------------------------------------------------------------
bool vtkChartPie::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
if (mouse.Button < 0)
if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......
......@@ -593,10 +593,7 @@ void vtkChartXY::SetPlotCorner(vtkPlot *plot, int corner)
<< corner);
return;
}
if (!this->RemovePlotFromCorners(plot))
{
vtkWarningMacro("Error removing plot from corners.");
}
this->RemovePlotFromCorners(plot);
// Grow the plot corners if necessary
if (int(this->ChartPrivate->PlotCorners.size()) <= corner)
{
......@@ -831,12 +828,9 @@ vtkIdType vtkChartXY::AddPlot(vtkPlot * plot)
return -1;
}
plot->Register(this);
// Add the plot to the default corner
plot->SetXAxis(this->ChartPrivate->axes[vtkAxis::BOTTOM]);
plot->SetYAxis(this->ChartPrivate->axes[vtkAxis::LEFT]);
this->ChartPrivate->plots.push_back(plot);
vtkIdType plotIndex = this->ChartPrivate->plots.size() - 1;
this->ChartPrivate->PlotCorners[0]->AddItem(plot);
this->SetPlotCorner(plot, 0);
// Ensure that the bounds are recalculated
this->PlotTransformValid = false;
// Mark the scene as dirty
......@@ -1021,7 +1015,7 @@ bool vtkChartXY::MouseMoveEvent(const vtkContextMouseEvent &mouse)
// Mark the scene as dirty
this->Scene->SetDirty(true);
}
else if (mouse.Button < 0)
else if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......
......@@ -110,7 +110,7 @@ void vtkColorTransferFunctionItem::ComputeTexture()
values,
reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0,0,0)),
VTK_DOUBLE,dimension,1,4);
delete values;
delete [] values;
}
//-----------------------------------------------------------------------------
......
......@@ -131,7 +131,7 @@ void vtkCompositeTransferFunctionItem::ComputeTexture()
ptr+=4;
}
}
delete values;
delete [] values;
}
//-----------------------------------------------------------------------------
......
......@@ -30,9 +30,10 @@ public:
// Description:
// Enumeration of mouse buttons.
enum {
LEFT_BUTTON = 0,
MIDDLE_BUTTON,
RIGHT_BUTTON
NO_BUTTON = 0,
LEFT_BUTTON = 1,
MIDDLE_BUTTON = 2,
RIGHT_BUTTON = 4
};
// Description:
......@@ -60,7 +61,7 @@ public:
vtkVector2i LastScreenPos;
// Description:
// Mouse button that was pressed, using the anonymous enumeration.
// Mouse button that caused the event, using the anonymous enumeration.
int Button;
};
//ETX
......
......@@ -79,26 +79,26 @@ public:
this->Target->MouseMoveEvent(x, y);
break;
case vtkCommand::LeftButtonPressEvent :
this->Target->ButtonPressEvent(0, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::LEFT_BUTTON, x, y);
break;
case vtkCommand::MiddleButtonPressEvent :
this->Target->ButtonPressEvent(1, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::MIDDLE_BUTTON, x, y);
break;
case vtkCommand::RightButtonPressEvent :
this->Target->ButtonPressEvent(2, x, y);
this->Target->ButtonPressEvent(vtkContextMouseEvent::RIGHT_BUTTON, x, y);
break;
case vtkCommand::LeftButtonReleaseEvent :
this->Target->ButtonReleaseEvent(0, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::LEFT_BUTTON, x, y);
break;
case vtkCommand::MiddleButtonReleaseEvent :
this->Target->ButtonReleaseEvent(1, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::MIDDLE_BUTTON, x, y);
break;
case vtkCommand::RightButtonReleaseEvent :
this->Target->ButtonReleaseEvent(2, x, y);
this->Target->ButtonReleaseEvent(vtkContextMouseEvent::RIGHT_BUTTON, x, y);
break;
case vtkCommand::MouseWheelForwardEvent :
// There is a forward and a backward event - not clear on deltas...
this->Target->MouseWheelEvent(1, x, y);
this->Target->MouseWheelEvent(+1, x, y);
break;
case vtkCommand::MouseWheelBackwardEvent :
// There is a forward and a backward event - not clear on deltas...
......@@ -126,8 +126,8 @@ class vtkContextScene::Private
public:
Private()
{
this->itemMousePressCurrent = -1;
this->Event.Button = -1;
this->itemMousePressCurrent = -1;
this->Event.Button = vtkContextMouseEvent::NO_BUTTON;
this->IsDirty = true;
}
~Private()
......@@ -615,7 +615,7 @@ void vtkContextScene::ButtonReleaseEvent(int button, int x, int y)
->MouseButtonReleaseEvent(event);
this->Storage->itemMousePressCurrent = -1;
}
this->Storage->Event.Button = -1;
this->Storage->Event.Button = vtkContextMouseEvent::NO_BUTTON;
}
void vtkContextScene::MouseWheelEvent(int delta, int x, int y)
......
......@@ -551,7 +551,7 @@ void vtkOpenGLContextDevice2D::DrawQuad(float *f, int n)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
this->Storage->Texture->PostRender(this->Renderer);
glDisable(GL_TEXTURE_2D);
delete texCoord;
delete [] texCoord;
}
}
......@@ -580,7 +580,7 @@ void vtkOpenGLContextDevice2D::DrawPolygon(float *f, int n)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
this->Storage->Texture->PostRender(this->Renderer);
glDisable(GL_TEXTURE_2D);
delete texCoord;
delete [] texCoord;
}
}
......
......@@ -45,11 +45,11 @@ int main( int argc, char * argv [] )
{
// Qt initialization
QApplication app(argc, argv);
QMainWindow *mainWindow = new QMainWindow;
mainWindow->setGeometry(0, 0, 1150, 600);
QMainWindow mainWindow;
mainWindow.setGeometry(0, 0, 1150, 600);
// QVTK set up and initialization
QVTKWidget *qvtkWidget = new QVTKWidget(mainWindow);
QVTKWidget *qvtkWidget = new QVTKWidget(&mainWindow);
// Set up my 2D world...
VTK_CREATE(vtkContextView, view); // This contains a chart object
......@@ -107,7 +107,7 @@ int main( int argc, char * argv [] )
line->SetWidth(2.0);
*/
// Now lets try to add a table view
QWidget *widget = new QWidget(mainWindow);
QWidget *widget = new QWidget(&mainWindow);
QHBoxLayout *layout = new QHBoxLayout(widget);
VTK_CREATE(vtkQtTableView, tableView);
tableView->SetSplitMultiComponentColumns(true);
......@@ -116,10 +116,10 @@ int main( int argc, char * argv [] )
layout->addWidget(qvtkWidget, 2);
//layout->addWidget(qtChart, 2);
layout->addWidget(tableView->GetWidget());
mainWindow->setCentralWidget(widget);
mainWindow.setCentralWidget(widget);
// Now show the application and start the event loop
mainWindow->show();
mainWindow.show();
return app.exec();
}
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