Commit 6c28b16d authored by Jan Möbius's avatar Jan Möbius

Get rid of a lot of cppcheck warnings

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13232 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 23368e2c
......@@ -155,7 +155,7 @@ QtExaminerViewer::viewMouseEvent(QMouseEvent* _event)
(newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) )
return;
double value_x, value_y;
double value_y;
Vec3d newPoint3D;
bool newPoint_hitSphere = mapToSphere( newPoint2D, newPoint3D );
......@@ -189,6 +189,7 @@ QtExaminerViewer::viewMouseEvent(QMouseEvent* _event)
// move in x,y direction
else if (_event->buttons() & Qt::MidButton)
{
double value_x;
value_x = scene_radius_ * ((newPoint2D.x() - lastPoint2D_.x())) * 2.0 / (double) glWidth();
value_y = scene_radius_ * ((newPoint2D.y() - lastPoint2D_.y())) * 2.0 / (double) glHeight();
translate( Vec3d(value_x * factor , -value_y * factor , 0.0) );
......@@ -262,62 +263,53 @@ QtExaminerViewer::viewMouseEvent(QMouseEvent* _event)
void
QtExaminerViewer::lightMouseEvent(QMouseEvent* _event)
{
switch (_event->type())
{
case QEvent::MouseButtonPress:
{
lastPoint_hitSphere_ = mapToSphere( lastPoint2D_=_event->pos(),
lastPoint3D_ );
switch (_event->type()) {
case QEvent::MouseButtonPress: {
lastPoint_hitSphere_ = mapToSphere(lastPoint2D_ = _event->pos(), lastPoint3D_);
isRotating_ = true;
timer_->stop();
break;
}
case QEvent::MouseMove: {
case QEvent::MouseMove:
{
// rotate lights
if (_event->buttons() & Qt::LeftButton)
{
QPoint newPoint2D = _event->pos();
if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) ||
(newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) )
return;
if (_event->buttons() & Qt::LeftButton) {
QPoint newPoint2D = _event->pos();
if ((newPoint2D.x() < 0) || (newPoint2D.x() > (int) glWidth()) || (newPoint2D.y() < 0)
|| (newPoint2D.y() > (int) glHeight()))
return;
Vec3d newPoint3D;
bool newPoint_hitSphere = mapToSphere( newPoint2D, newPoint3D );
Vec3d newPoint3D;
bool newPoint_hitSphere = mapToSphere(newPoint2D, newPoint3D);
makeCurrent();
makeCurrent();
Vec3d axis(1.0,0.0,0.0);
double angle(0.0);
if (lastPoint_hitSphere_) {
Vec3d axis(1.0, 0.0, 0.0);
double angle(0.0);
if ( lastPoint_hitSphere_ )
{
if ( ( newPoint_hitSphere = mapToSphere( newPoint2D, newPoint3D ) ) )
{
axis = lastPoint3D_ % newPoint3D;
double cos_angle = ( lastPoint3D_ | newPoint3D );
if ( fabs(cos_angle) < 1.0 ) {
angle = acos( cos_angle ) * 180.0 / M_PI;
angle *= 2.0;
}
}
rotate_lights(axis, angle);
}
if ((newPoint_hitSphere = mapToSphere(newPoint2D, newPoint3D))) {
axis = lastPoint3D_ % newPoint3D;
double cos_angle = (lastPoint3D_ | newPoint3D);
if (fabs(cos_angle) < 1.0) {
angle = acos(cos_angle) * 180.0 / M_PI;
angle *= 2.0;
}
}
rotate_lights(axis, angle);
}
lastPoint2D_ = newPoint2D;
lastPoint3D_ = newPoint3D;
lastPoint_hitSphere_ = newPoint_hitSphere;
lastPoint2D_ = newPoint2D;
lastPoint3D_ = newPoint3D;
lastPoint_hitSphere_ = newPoint_hitSphere;
updateGL();
updateGL();
}
break;
}
default: // avoid warning
break;
}
......
......@@ -110,12 +110,8 @@ void
CoordsysNode::
drawCoordsys( GLState& _state) {
const double topRadius = 0.01;
const double arrowLength = 0.03;
const double bodyRadius = 0.004;
const double bodyLength = 0.06;
const int slices = 10;
const int stacks = 10;
const double sphereRadius = 0.01;
......@@ -173,12 +169,8 @@ drawCoordsys( GLState& _state) {
void
CoordsysNode::drawCoordsysPick( GLState& _state) {
const double topRadius = 0.01;
const double arrowLength = 0.03;
const double bodyRadius = 0.004;
const double bodyLength = 0.06;
const int slices = 10;
const int stacks = 10;
const double sphereRadius = 0.01;
// Origin
......
......@@ -96,7 +96,7 @@ void
PointNode::
draw(GLState& /* _state */ , const DrawModes::DrawMode& _drawMode)
{
if (points_.size() == 0)
if (points_.empty())
return;
// points
......
......@@ -1931,15 +1931,8 @@ TranslationManipulatorNode::set_direction(const Vec3d& _directionX, const Vec3d&
localTransformation_.identity();
double angle = 0.0;
const Vec3d cross = _directionX % _directionY;
// std::cerr << "_directionX " << _directionX[0] << " " << _directionX[1] << " " << _directionX[2] << std::endl;
// std::cerr << "_directionY " << _directionY[0] << " " << _directionY[1] << " " << _directionY[2] << std::endl;
// std::cerr << "dirX_ " << dirX_[0] << " " << dirX_[1] << " " << dirX_[2] << std::endl;
// std::cerr << "dirY_ " << dirY_[0] << " " << dirY_[1] << " " << dirY_[2] << std::endl;
// std::cerr << "cross " << cross[0] << " " << cross[1] << " " << cross[2] << std::endl;
localTransformation_(0,0) = _directionX[0];
localTransformation_(1,0) = _directionX[1];
localTransformation_(2,0) = _directionX[2];
......
......@@ -428,7 +428,7 @@ namespace GLSL {
PtrVertexShader vertexShader = 0;
StringList sourceVertex = loadShader(name);
if (sourceVertex.size() != 0) {
if (!sourceVertex.empty() ) {
vertexShader = GLSL::PtrVertexShader(new GLSL::VertexShader());
vertexShader->setSource(sourceVertex);
vertexShader->compile();
......@@ -442,7 +442,7 @@ namespace GLSL {
PtrFragmentShader fragmentShader = 0;
StringList sourceVertex = loadShader(name);
if (sourceVertex.size() != 0) {
if ( !sourceVertex.empty() ) {
fragmentShader = GLSL::PtrFragmentShader(new GLSL::FragmentShader());
fragmentShader->setSource(sourceVertex);
fragmentShader->compile();
......@@ -456,7 +456,7 @@ namespace GLSL {
PtrGeometryShader geometryShader = 0;
StringList sourceVertex = loadShader(name);
if (sourceVertex.size() != 0) {
if (!sourceVertex.empty()) {
geometryShader = GLSL::PtrGeometryShader(new GLSL::GeometryShader());
geometryShader->setSource(sourceVertex);
geometryShader->compile();
......
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