animationsberechnung bei grossen steps beschleunigt, usw.
git-svn-id: http://svn.lsim.tuxzone.org/trunk@13 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
@@ -94,12 +94,16 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
//startpunkt in den Pfad setzen
|
||||
flightPath = QPainterPath(startPoint);
|
||||
|
||||
|
||||
int debugTime = 0;
|
||||
time_t start_time = time(0);
|
||||
for(int i = 1; i< steps;++i) {
|
||||
double myMasse = getMasse( sqrt( speedListX->at(i-1)*speedListX->at(i-1) + speedListY->at(i-1)*speedListY->at(i-1) ) );
|
||||
//qDebug()<< myMasse;
|
||||
time_t timeb = time(0);
|
||||
double powerX = myScene->getPowerAt(currProbePath->at(i-1), charge, speedListX->at(i-1),speedListY->at(i-1), 'x');
|
||||
double powerY = myScene->getPowerAt(currProbePath->at(i-1), charge, speedListX->at(i-1),speedListY->at(i-1), 'y');
|
||||
time_t timea = time(0);
|
||||
debugTime += difftime(timea,timeb);
|
||||
|
||||
double newspeedX = speedListX->at(i-1) + (powerX/myMasse * (timePerStep/1000.0));
|
||||
double newspeedY = speedListY->at(i-1) + (powerY/myMasse * (timePerStep/1000.0));
|
||||
@@ -121,15 +125,17 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
currProbePath->append(newPoint);
|
||||
speedListX->append(newspeedX);
|
||||
speedListY->append(newspeedY);
|
||||
/*if(i%10 == 0)*/ flightPath.lineTo(newPoint);
|
||||
flightPath.lineTo(newPoint);
|
||||
|
||||
}
|
||||
qDebug()<< difftime(time(0),start_time);
|
||||
qDebug()<< debugTime;
|
||||
|
||||
|
||||
qDebug()<< "Probe Path: " <<*currProbePath;
|
||||
qDebug()<< "speed x: "<<*speedListX;
|
||||
qDebug()<< "speed y: "<<*speedListY;
|
||||
qDebug()<<speedListY->at(12);
|
||||
//qDebug()<< "Probe Path: " <<*currProbePath;
|
||||
//qDebug()<< "speed x: "<<*speedListX;
|
||||
//qDebug()<< "speed y: "<<*speedListY;
|
||||
//qDebug()<<speedListY->at(12);
|
||||
//qDebug()<<"power x: "<< (double)myScene->getPowerAt(QPointF(0,0), charge, 'x');
|
||||
//qDebug()<<"power y: " << (double)myScene->getPowerAt(QPointF(0,0), charge, 'y');
|
||||
|
||||
@@ -137,7 +143,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
|
||||
|
||||
double GraphicsEllipseItem::getMasse(double speed) {
|
||||
if(speed == 0) return masse;
|
||||
if(speed < SPEED_OF_LIGHT/10.0) return masse;
|
||||
else {
|
||||
return masse / (sqrt(1- ( (speed/SPEED_OF_LIGHT)*(speed/SPEED_OF_LIGHT))));
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ QRectF HomoBFieldItem::getRectF() const
|
||||
}
|
||||
|
||||
void HomoBFieldItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
Qt::GlobalColor linecolor = Qt::red;
|
||||
//Qt::GlobalColor linecolor = Qt::red;
|
||||
QColor linecolor(92,105,118);
|
||||
painter->setPen(linecolor);
|
||||
if (isSelected()) painter->setBrush(Qt::Dense6Pattern); //selection deutlich machen
|
||||
painter->drawRect(sizeRect);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
//variablen initialisieren
|
||||
setTimePerStep(0.00001);
|
||||
setSteps(1000);
|
||||
setSteps(21234);
|
||||
//setMeterPerPx(1/1000.0);
|
||||
setMeterPerPx(1);
|
||||
|
||||
@@ -52,7 +52,11 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
createResizeRects();
|
||||
|
||||
//path Item Erstellen
|
||||
pathItem1 = addPath(QPainterPath());
|
||||
pathItem1 = addPath(QPainterPath(), QPen(QColor(255,137,11), 1, Qt::SolidLine));
|
||||
pathItem1->setZValue(100);
|
||||
//pathItem1->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
|
||||
setFlightPathVisible();
|
||||
|
||||
|
||||
addLine(0,-298,0,298,QPen(Qt::green, 1, Qt::SolidLine) )->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
@@ -77,7 +81,7 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
ellipse1->setRect(-2,-2,5,5);
|
||||
ellipse1->setPen(Qt::NoPen);
|
||||
ellipse1->setBrush(Qt::red);
|
||||
ellipse1->setZValue(1);
|
||||
ellipse1->setZValue(200);
|
||||
//ellipse1->scale(4,4);
|
||||
ellipse1->setAcceptDrops(true);
|
||||
connect(this,SIGNAL(changed(QList<QRectF>)),ellipse1,SLOT(handleSceneChange(QList<QRectF>)));
|
||||
@@ -98,14 +102,8 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
}
|
||||
|
||||
void SimulScene::startTimer() {
|
||||
|
||||
timer->setCurrentTime(0);
|
||||
ani->clear();
|
||||
int currSteps = ellipse1->getCurrProbePath()->count();
|
||||
for (int i=0; i<currSteps; ++i) {
|
||||
//ani->setPosAt(i/200.0, QPointF(x , 0.5 * ay * pow(( (x/1000) /vx),2) *1000 ));
|
||||
ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) );
|
||||
//qDebug()<< getSteps();
|
||||
}
|
||||
timer->start();
|
||||
}
|
||||
void SimulScene::stopTimer() {
|
||||
@@ -587,8 +585,24 @@ void SimulScene::setTimePerStep(double time) {
|
||||
\fn SimulScene::startCalculation()
|
||||
*/
|
||||
void SimulScene::startCalculation() {
|
||||
pathItem1->setPath(QPainterPath());
|
||||
ellipse1->calculateProbePath(ellipse1->pos());
|
||||
pathItem1->setPath(ellipse1->getFlightPath());
|
||||
|
||||
//animationspfad berechnen
|
||||
time_t anitimeb = time(0);
|
||||
ani->clear();
|
||||
int currSteps = ellipse1->getCurrProbePath()->count();
|
||||
int entry_step = ceil(currSteps/2500.0); //jeder entry_step(te) step wird eingetragen
|
||||
for (int i=0; i<currSteps; ++i) {
|
||||
|
||||
if (i%entry_step == 0 || i==currSteps) {
|
||||
ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) );
|
||||
}
|
||||
//qDebug()<< getSteps();
|
||||
}
|
||||
time_t anitimea = time(0);
|
||||
qDebug()<< "animationszeit" <<difftime(anitimea,anitimeb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class SimulScene : public QGraphicsScene {
|
||||
void setMeterPerPx ( double theValue );
|
||||
double getMeterPerPx() const;
|
||||
void setFlightPathVisible(bool visible = true);
|
||||
|
||||
|
||||
private slots:
|
||||
void displayResizeRects(bool move = false);
|
||||
@@ -86,7 +87,7 @@ class SimulScene : public QGraphicsScene {
|
||||
void flightPathVisibilityChanged(bool visible);
|
||||
private:
|
||||
QTimeLine *timer;
|
||||
|
||||
|
||||
SceneMode myMode;
|
||||
|
||||
///Zeit pro Step in ms
|
||||
|
||||
Reference in New Issue
Block a user