//void GLWidget::drawVectors(PivData *pivData, Settings *settings) void GLWidget::drawVectors(PivData *pivData) { Vector3D *vector; qreal _x, _y, _z, _u, _v, _w, angle, speed; int _intLengthX = 500;//settings->intLengthX(); int _intLengthY = 500;//settings->intLengthY(); int _intLengthZ = 500; double scale = 0.2;//settings->vectorScale(); double vectorSub = 5;//settings->vectorSub(); bool hasTail = false;//settings QColor colourFiltered = QColor(0, 155, 0);//settings->vectorColourFiltered(); QColor colourUnfiltered = QColor(0,255,0);// settings->vectorColourUnfiltered(); int i, j, k, vecIndex; // 把vector加到vector3d_list中 if (!vectorGroupCreated) createVectorGroup(pivData->numValid()); vecIndex = 0; for (i = 0; i < xSpan; i++) { for (j = 0; j < ySpan; j++) { for (k = 0; k < zSpan; k++) { //qDebug() << pivData->isValid(i, j, k); if (pivData->isValid(i, j, k)) { vector = vector3d_list.at(vecIndex); // Set the magnitude of the vector _x = pivData->data(i, j, k).x;// + _intLengthX/2.0; _y = pivData->data(i, j, k).y;// + _intLengthY/2.0; _z = pivData->data(i, j, k).z;// + _intLengthZ/2.0; // 还要+个东西 _u = pivData->data(i, j, k).u;// - vectorSub; _v = pivData->data(i, j, k).v;//奇怪 _w = pivData->data(i, j, k).w;//自己加的 speed = sqrt(_u * _u + _v * _v + _w * _w); //speed = 5; // Set the colour of the vector if (pivData->data(i, j, k).filtered) vector->setVector3D(speed, scale, colourFiltered, hasTail); else vector->setVector3D(speed, scale, colourUnfiltered, hasTail); // Set the position of the vector vector->setPos(_x,_y,_z); // Set the orientation of the vector //angle = atan2(_v,_u); vector->setRotation(_u, _v, _w); // Vectors are added and deleted using visibility rather than actually creating/deleting objects vector->setVisible(true); vector->draw(); vecIndex++; } } } } /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0, 0.0, -10.0); glRotatef(xRot / 16.0, 1.0, 0.0, 0.0); glRotatef(yRot / 16.0, 0.0, 1.0, 0.0); glRotatef(zRot / 16.0, 0.0, 0.0, 1.0); for (int i = 0; i < vector3d_list.size(); i++) { Vector3D* temp = vector3d_list.at(i); glTranslatef(0.0, 0.0, -1.0); temp->draw(); }*/ //emit(vectorsDrawn()); }