Skip to content

Commit

Permalink
re #8418 cppcheck style
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed Nov 11, 2013
1 parent 4b9632e commit 3416502
Show file tree
Hide file tree
Showing 29 changed files with 138 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void PanelsSurface::addObjCompAssemblies(ComponentID bankId)
{
return;
}
int ndetectors = 0;

QList<ComponentID> objCompAssemblies;
// normal to the plane, undefined at first
Mantid::Kernel::V3D normal(0,0,0);
Expand Down Expand Up @@ -401,7 +401,6 @@ void PanelsSurface::addObjCompAssemblies(ComponentID bankId)
return;
}
}
ndetectors += objCompAssembly->nelements();
objCompAssemblies << objCompAssembly->getComponentID();
}
if ( !objCompAssemblies.isEmpty() )
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/MantidMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ bool MantidMatrixModel::checkMontorCache(int row) const
}
m_monCache.insert(row, isMon);
}
catch (std::exception e)
catch (std::exception& e)
{
m_monCache.insert(row,false);
isMon = false;
Expand Down
7 changes: 3 additions & 4 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,12 +1152,11 @@ Table* MantidUI::createDetectorTable(const QString & wsName, const Mantid::API::
if(calcQ)
{

double efixed(0.0), usignTheta(0.0);
try
{
// Get unsigned theta and efixed value
efixed = ws->getEFixed(det);
usignTheta = ws->detectorTwoTheta(det)/2.0;
double efixed = ws->getEFixed(det);
double usignTheta = ws->detectorTwoTheta(det)/2.0;

double q = Mantid::Kernel::UnitConversion::run(usignTheta, efixed);
colValues << QVariant(q);
Expand Down Expand Up @@ -1578,10 +1577,10 @@ void MantidUI::copyWorkspacestoVector(const QList<QTreeWidgetItem*> &selectedIt
bool MantidUI::hasUB(const QString& wsName)
{
const std::string algName("HasUB");
const int version = -1;
Mantid::API::IAlgorithm_sptr alg;
try
{
const int version = -1;
alg = Mantid::API::AlgorithmManager::Instance().create(algName);
} catch (...)
{
Expand Down
5 changes: 2 additions & 3 deletions Code/Mantid/MantidPlot/src/MatrixModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,14 @@ bool MatrixModel::calculate(int startRow, int endRow, int startCol, int endCol)
double dy = d_matrix->dy();
double x_start = d_matrix->xStart();
double y_start = d_matrix->yStart();
double r = 0.0, c = 0.0;
for(int row = startRow; row <= endRow; row++){
r = row + 1.0;
double r = row + 1.0;
script->setDouble(r, "i");
script->setDouble(r, "row");
script->setDouble(y_start + row*dy, "y");
int aux = row*d_cols + startCol;
for(int col = startCol; col <= endCol; col++){
c = col + 1.0;
double c = col + 1.0;
script->setDouble(c, "j");
script->setDouble(c, "col");
script->setDouble(x_start + col*dx, "x");
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/MultiLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ void MultiLayer::setLayersNumber(int n)

// check whether the active Graph.has been deleted
if(graphsList.indexOf(active_graph) == -1)
active_graph=(Graph*) graphsList.last();
active_graph=static_cast<Graph*>( graphsList.last());
for (int j=0;j<static_cast<int>(graphsList.count());j++){
Graph *gr=static_cast<Graph *>(graphsList.at(j));
if (gr == active_graph){
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/MultiPeakFitTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void MultiPeakFitTool::finalize()

d_graph->plotWidget()->replot();
if (d_graph->activeTool() && d_graph->activeTool()->rtti() == PlotToolInterface::Rtti_RangeSelector){
((RangeSelectorTool *)d_graph->activeTool())->setEnabled();
(static_cast<RangeSelectorTool *>(d_graph->activeTool()))->setEnabled();
} else
d_graph->plotWidget()->canvas()->unsetCursor();
delete this;
Expand Down
30 changes: 15 additions & 15 deletions Code/Mantid/MantidPlot/src/Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void Plot::drawItems (QPainter *painter, const QRect &rect,
if (!axisEnabled(i))
continue;

const ScaleDraw *sd = (const ScaleDraw *) axisScaleDraw (i);
const ScaleDraw *sd = static_cast<const ScaleDraw *>(axisScaleDraw (i));
int majorTicksType = sd->majorTicksStyle();
int minorTicksType = sd->minorTicksStyle();

Expand Down Expand Up @@ -388,7 +388,7 @@ void Plot::drawInwardTicks(QPainter *painter, const QRect &rect,

void Plot::drawBreak(QPainter *painter, const QRect &rect, const QwtScaleMap &map, int axis) const
{
const ScaleEngine *sc_engine = (const ScaleEngine *)axisScaleEngine(axis);
const ScaleEngine *sc_engine = static_cast<const ScaleEngine *>(axisScaleEngine(axis));
/*const QwtScaleEngine *qwtsc_engine=axisScaleEngine(axis);
const ScaleEngine *sc_engine =dynamic_cast<const ScaleEngine*>(qwtsc_engine);
if(sc_engine!=NULL)
Expand Down Expand Up @@ -479,7 +479,7 @@ QwtPlotCurve* Plot::curve(int index)
{
QwtPlotItem *it = d_curves.value(index);
if (it && it->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
return (QwtPlotCurve*)it;
return static_cast<QwtPlotCurve*>(it);
else
return 0;
}
Expand Down Expand Up @@ -508,7 +508,7 @@ int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)

if(item->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
{
PlotCurve *c = (PlotCurve *)item;
PlotCurve *c = static_cast<PlotCurve *>(item);
DataCurve *dc = dynamic_cast<DataCurve *>(item);
if (dc)
{
Expand Down Expand Up @@ -552,7 +552,7 @@ int Plot::insertMarker(QwtPlotMarker *m)
marker_key++;
if (!d_markers.contains(marker_key))
d_markers.insert (marker_key, m);
m->setRenderHint(QwtPlotItem::RenderAntialiased, ((Graph *)parent())->antialiasing());
m->setRenderHint(QwtPlotItem::RenderAntialiased, (static_cast<Graph *>(parent()))->antialiasing());
m->attach(((QwtPlot *)this));
return marker_key;
}
Expand All @@ -563,9 +563,9 @@ int Plot::insertCurve(QwtPlotItem *c)
if (!d_curves.contains(curve_key))
d_curves.insert (curve_key, c);
if (c->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
((QwtPlotCurve *)c)->setPaintAttribute(QwtPlotCurve::PaintFiltered);
(static_cast<QwtPlotCurve *>(c))->setPaintAttribute(QwtPlotCurve::PaintFiltered);

c->setRenderHint(QwtPlotItem::RenderAntialiased, ((Graph *)parent())->antialiasing());
c->setRenderHint(QwtPlotItem::RenderAntialiased, (static_cast<Graph *>(parent()))->antialiasing());
c->attach(this);
return curve_key;
}
Expand All @@ -578,7 +578,7 @@ void Plot::removeCurve(int index)

if (c->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
{
Spectrogram *sp = (Spectrogram *)c;
Spectrogram *sp = static_cast<Spectrogram *>(c);
QwtScaleWidget *colorAxis = axisWidget(sp->colorScaleAxis());
if (colorAxis)
colorAxis->setColorBarEnabled(false);
Expand All @@ -603,7 +603,7 @@ QList<int> Plot::getMajorTicksType()
{
if (axisEnabled(axis))
{
ScaleDraw *sd = (ScaleDraw *) axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>(axisScaleDraw (axis));
majorTicksType << sd->majorTicksStyle();
}
else
Expand All @@ -614,7 +614,7 @@ QList<int> Plot::getMajorTicksType()

void Plot::setMajorTicksType(int axis, int type)
{
ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>(axisScaleDraw (axis));
if (sd)
sd->setMajorTicksStyle ((ScaleDraw::TicksStyle)type);
}
Expand All @@ -626,7 +626,7 @@ QList<int> Plot::getMinorTicksType()
{
if (axisEnabled(axis))
{
ScaleDraw *sd = (ScaleDraw *) axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>( axisScaleDraw (axis));
minorTicksType << sd->minorTicksStyle();
}
else
Expand All @@ -637,15 +637,15 @@ QList<int> Plot::getMinorTicksType()

void Plot::setMinorTicksType(int axis, int type)
{
ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>(axisScaleDraw (axis));
if (sd)
sd->setMinorTicksStyle((ScaleDraw::TicksStyle)type);
}

int Plot::axisLabelFormat(int axis)
{
if (axisValid(axis)){
ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>(axisScaleDraw (axis));
return sd->labelNumericFormat();
}
return 0;
Expand All @@ -655,7 +655,7 @@ int Plot::axisLabelPrecision(int axis)
{
if (axisValid(axis))
{
ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
ScaleDraw *sd = static_cast<ScaleDraw *>(axisScaleDraw (axis));
return sd->labelNumericPrecision();
}

Expand All @@ -672,7 +672,7 @@ int Plot::axisLabelPrecision(int axis)
void Plot::axisLabelFormat(int axis, char &f, int &prec) const
{
if (axisValid(axis)){
const ScaleDraw *sd = (const ScaleDraw *)axisScaleDraw (axis);
const ScaleDraw *sd = static_cast<const ScaleDraw *>(axisScaleDraw (axis));
sd->labelFormat(f, prec);
} else {//for a bad call we return the default values
f = 'g';
Expand Down
20 changes: 10 additions & 10 deletions Code/Mantid/MantidPlot/src/Plot3DDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ void Plot3DDialog::accept()

void Plot3DDialog::changeZoom(int)
{
if (generalDialog->currentPage() != (QWidget*)general)
if (generalDialog->currentPage() != static_cast<QWidget*>(general))
return;

QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Expand All @@ -714,7 +714,7 @@ void Plot3DDialog::changeZoom(int)

void Plot3DDialog::changeTransparency(int val)
{
if (generalDialog->currentPage() != (QWidget*)colors)
if (generalDialog->currentPage() != static_cast<QWidget*>(colors))
return;

d_plot->changeTransparency(val*0.01);
Expand All @@ -726,14 +726,14 @@ bool Plot3DDialog::updatePlot()
if (!d_plot)
return false;

ApplicationWindow *app = (ApplicationWindow *)this->parent();
ApplicationWindow *app = static_cast<ApplicationWindow *>(this->parent());
if (!app)
return false;

if (generalDialog->currentPage()==(QWidget*)bars){
if (generalDialog->currentPage()==static_cast<QWidget*>(bars)){
d_plot->setBarRadius(boxBarsRad->text().toDouble());
d_plot->setBarStyle();
} else if (generalDialog->currentPage() == (QWidget*)points){
} else if (generalDialog->currentPage() == static_cast<QWidget*>(points)){
if (boxPointStyle->currentIndex() == 0) {
d_plot->setDotOptions(boxSize->text().toDouble(), boxSmooth->isChecked());
d_plot->setDotStyle();
Expand All @@ -747,9 +747,9 @@ bool Plot3DDialog::updatePlot()
}

app->custom3DActions(d_plot);
} else if (generalDialog->currentPage()==(QWidget*)title){
} else if (generalDialog->currentPage()==static_cast<QWidget*>(title)){
d_plot->setTitle(boxTitle->text().remove("\n"), btnTitleColor->color(), titleFont);
} else if (generalDialog->currentPage()==(QWidget*)colors){
} else if (generalDialog->currentPage()==static_cast<QWidget*>(colors)){
d_plot->changeTransparency(boxTransparency->value()*0.01);
d_plot->setDataColors(btnFromColor->color(), btnToColor->color());
d_plot->setMeshColor(btnMesh->color());
Expand All @@ -758,15 +758,15 @@ bool Plot3DDialog::updatePlot()
d_plot->setLabelsColor(btnLabels->color());
d_plot->setBackgroundColor(btnBackground->color());
d_plot->setGridColor(btnGrid->color());
} else if (generalDialog->currentPage()==(QWidget*)general){
} else if (generalDialog->currentPage()==static_cast<QWidget*>(general)){
d_plot->showColorLegend(boxLegend->isChecked());
d_plot->setResolution(boxResolution->value());
d_plot->setMeshLineWidth(boxMeshLineWidth->value());
d_plot->setLabelsDistance(boxDistance->value());
d_plot->setNumbersFont(numbersFont);
d_plot->setZoom(zoom*boxZoom->value()*0.01);
d_plot->setScale(xScale*boxXScale->value()*0.01, yScale*boxYScale->value()*0.01, zScale*boxZScale->value()*0.01);
} else if (generalDialog->currentPage()==(QWidget*)scale){
} else if (generalDialog->currentPage()==static_cast<QWidget*>(scale)){
int axis = axesList->currentRow();
QString from=boxFrom->text().lower();
QString to=boxTo->text().lower();
Expand Down Expand Up @@ -804,7 +804,7 @@ bool Plot3DDialog::updatePlot()

d_plot->updateScale(axis, scaleOptions(axis, start, end, boxMajors->text(), boxMinors->text()));
//d_plot->setScale(xsc,ysc,zsc*0.1);
} else if (generalDialog->currentPage()==(QWidget*)axes){
} else if (generalDialog->currentPage()==static_cast<QWidget*>(axes)){
int axis = axesList2->currentRow();
labels[axis] = boxLabel->text();

Expand Down
24 changes: 12 additions & 12 deletions Code/Mantid/MantidPlot/src/PlotCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ PlotCurve::PlotCurve(const PlotCurve& c) : QObject(), QwtPlotCurve(c.title().tex

QString PlotCurve::saveCurveLayout()
{
Plot *plot = (Plot *)this->plot();
Graph *g = (Graph *)plot->parent();
Plot *plot = static_cast<Plot *>(this->plot());
Graph *g = static_cast<Graph *>(plot->parent();

int index = g->curveIndex((QwtPlotCurve *)this);
int index = g->curveIndex(static_cast<QwtPlotCurve *>(this));
int style = g->curveType(index);
QString s = "<Style>" + QString::number(style) + "</Style>\n";

Expand Down Expand Up @@ -270,8 +270,8 @@ void PlotCurve::drawSideLines(QPainter *p, const QwtScaleMap &xMap, const QwtSca

void PlotCurve::computeWaterfallOffsets()
{
Plot *plot = (Plot *)this->plot();
Graph *g = (Graph *)plot->parent();
Plot *plot = static_cast<Plot *>(this->plot());
Graph *g = static_cast<Graph *>(plot->parent());

// reset the offsets
d_x_offset = 0.0;
Expand Down Expand Up @@ -423,8 +423,8 @@ bool DataCurve::updateData(Table *t, const QString& colName)

void DataCurve::loadData()
{
Plot *plot = (Plot *)this->plot();
Graph *g = (Graph *)plot->parent();
Plot *plot = static_cast<Plot *>(this->plot());
Graph *g = static_cast<Graph *>(plot->parent());
if (!g)
return;

Expand Down Expand Up @@ -536,7 +536,7 @@ void DataCurve::loadData()
int axis = QwtPlot::xBottom;
if (d_type == Graph::HorizontalBars)
axis = QwtPlot::yLeft;
ScaleDraw *old_sd = (ScaleDraw *)plot->axisScaleDraw(axis);
ScaleDraw *old_sd = static_cast<ScaleDraw *>(plot->axisScaleDraw(axis));
ScaleDraw *sd = new ScaleDraw(plot, old_sd);
if (xColType == Table::Date)
sd->setDateTimeOrigin(date0);
Expand All @@ -550,7 +550,7 @@ void DataCurve::loadData()
}

if (!d_labels_list.isEmpty()){
((Graph*)plot->parent())->updatePlot();
(static_cast<Graph*>(*plot->parent()))->updatePlot();
loadLabels();
}
}
Expand Down Expand Up @@ -587,7 +587,7 @@ void DataCurve::clearErrorBars()

void DataCurve::remove()
{
Graph *g = (Graph *)plot()->parent();
Graph *g = static_cast<Graph *>(plot()->parent());
if (!g)
return;

Expand Down Expand Up @@ -985,7 +985,7 @@ void DataCurve::setLabelsSelected(bool on)
}
if (on)
{
Graph *g = (Graph *) plot()->parent();
Graph *g = static_cast<Graph *>(plot()->parent());
g->selectTitle(false);
g->deselectMarker();
g->notifyFontChange(d_labels_font);
Expand Down Expand Up @@ -1025,7 +1025,7 @@ void DataCurve::moveLabels(const QPoint& pos)
updateLabelsPosition();
d_plot->replot();

((Graph *) d_plot->parent())->notifyChanges();
(static_cast<Graph *>(d_plot->parent()))->notifyChanges();

d_click_pos_x = d_plot->invTransform(xAxis(), pos.x());
d_click_pos_y = d_plot->invTransform(yAxis(), pos.y());
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/MantidPlot/src/PlotWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool PlotWizard::noCurves()

void PlotWizard::plot3DRibbon(const QStringList& lst)
{
ApplicationWindow *app = (ApplicationWindow *)this->parent();
ApplicationWindow *app = static_cast<ApplicationWindow *>(this->parent());
if (!app)
return;

Expand Down Expand Up @@ -360,7 +360,7 @@ void PlotWizard::plot3DRibbon(const QStringList& lst)

void PlotWizard::plot3D(const QStringList& lst)
{
ApplicationWindow *app = (ApplicationWindow *)this->parent();
ApplicationWindow *app = static_cast<ApplicationWindow *>(this->parent());
if (!app)
return;

Expand Down

0 comments on commit 3416502

Please sign in to comment.