Pfandanzeige
git-svn-id: http://svn.lsim.tuxzone.org/trunk@12 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include <QDrag>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QMimeData>
|
||||
#include <QPainterPath>
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QDebug>
|
||||
#include "simulscene.h"
|
||||
#include "probechargewidget.h"
|
||||
@@ -40,7 +42,7 @@ GraphicsEllipseItem::GraphicsEllipseItem() {
|
||||
currProbePath = new QList<QPointF>;
|
||||
speedListX = new QList<double>;
|
||||
speedListY = new QList<double>;
|
||||
|
||||
|
||||
}
|
||||
void GraphicsEllipseItem::timerEvent ( QTimerEvent * event ) {
|
||||
static double vx;
|
||||
@@ -89,6 +91,9 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
speedListX->append(startSpeedX);
|
||||
speedListY->append(startSpeedY);
|
||||
|
||||
//startpunkt in den Pfad setzen
|
||||
flightPath = QPainterPath(startPoint);
|
||||
|
||||
|
||||
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) ) );
|
||||
@@ -110,10 +115,13 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
|
||||
double deltaDistX = (deltaDistXconst + deltaDistXaccel);
|
||||
double deltaDistY = (deltaDistYconst + deltaDistYaccel);
|
||||
|
||||
QPointF newPoint(currProbePath->at(i-1).x() + deltaDistX/meterPerPx ,currProbePath->at(i-1).y() + deltaDistY/meterPerPx);
|
||||
|
||||
currProbePath->append(QPointF(currProbePath->at(i-1).x() + deltaDistX/meterPerPx ,currProbePath->at(i-1).y() + deltaDistY/meterPerPx));
|
||||
currProbePath->append(newPoint);
|
||||
speedListX->append(newspeedX);
|
||||
speedListY->append(newspeedY);
|
||||
/*if(i%10 == 0)*/ flightPath.lineTo(newPoint);
|
||||
|
||||
}
|
||||
|
||||
@@ -204,3 +212,14 @@ void GraphicsEllipseItem::setScenePosX(double newPosX)
|
||||
{
|
||||
moveBy(newPosX - scenePos().x(),0 );
|
||||
}
|
||||
|
||||
|
||||
QPainterPath GraphicsEllipseItem::getFlightPath() const {
|
||||
return flightPath;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsEllipseItem::setFlightPath ( const QPainterPath& theValue ) {
|
||||
if (flightPath==theValue) return;
|
||||
flightPath = theValue;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include <QObject>
|
||||
class ProbeChargeWidget;
|
||||
class QPainterPath;
|
||||
class QGraphicsPathItem;
|
||||
|
||||
/**
|
||||
@author Peter Dahlberg <pdahlberg@gmail.com>
|
||||
@@ -47,7 +49,7 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
*/
|
||||
double getMasse(double speed);
|
||||
|
||||
|
||||
QPainterPath getFlightPath() const;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -73,6 +75,8 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
|
||||
QPointF myScenePos;
|
||||
|
||||
///Pfad der Flugbahn
|
||||
QPainterPath flightPath;
|
||||
|
||||
public slots:
|
||||
//! Berechnet die Bewegung der Probeladung
|
||||
@@ -90,6 +94,9 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
void setScenePosY(double newPosY);
|
||||
void setScenePosX(double newPosX);
|
||||
void handleSceneChange(const QList<QRectF> & /*region*/);
|
||||
|
||||
void setFlightPath ( const QPainterPath& theValue );
|
||||
|
||||
signals:
|
||||
void startSpeedXChanged(double speed);
|
||||
void startSpeedYChanged(double speed);
|
||||
|
||||
@@ -85,7 +85,7 @@ void HomoBFieldWidget::createWidget() {
|
||||
QLabel* fieldFluxDensityLabel = new QLabel(tr("Flussdichte(B):"));
|
||||
|
||||
ExpDoubleSpinBox* fieldFluxDensityBox = new ExpDoubleSpinBox;
|
||||
fieldFluxDensityBox->setRange(-1e+200,1e+200);
|
||||
fieldFluxDensityBox->setRange(0,1e+200);
|
||||
fieldFluxDensityBox->setDecimals(40);
|
||||
fieldFluxDensityBox->setDisplayDecimals(3);
|
||||
fieldFluxDensityBox->setKeyboardTracking(false);
|
||||
|
||||
@@ -108,7 +108,7 @@ void HomoEFieldWidget::createWidget()
|
||||
QLabel* voltageLabel = new QLabel(tr("Spannung:"));
|
||||
|
||||
ExpDoubleSpinBox* fieldPowerBox = new ExpDoubleSpinBox;
|
||||
fieldPowerBox->setRange(-1e+200,1e+200);
|
||||
fieldPowerBox->setRange(0,1e+200);
|
||||
fieldPowerBox->setDecimals(35);
|
||||
fieldPowerBox->setDisplayDecimals(3);
|
||||
fieldPowerBox->setKeyboardTracking(false);
|
||||
|
||||
@@ -112,7 +112,7 @@ void ProbeChargeWidget::createWidget()
|
||||
|
||||
|
||||
ExpDoubleSpinBox* masseBox = new ExpDoubleSpinBox;
|
||||
masseBox->setRange(-1e+200,1e+200);
|
||||
masseBox->setRange(0,1e+200);
|
||||
masseBox->setDecimals(50);
|
||||
masseBox->setDisplayDecimals(3);
|
||||
masseBox->setKeyboardTracking(false);
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QKeyEvent>
|
||||
#include <QGraphicsItemGroup>
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QGraphicsPathItem>
|
||||
|
||||
|
||||
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
@@ -49,6 +50,10 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
currHomoBfieldEditItem = 0;
|
||||
|
||||
createResizeRects();
|
||||
|
||||
//path Item Erstellen
|
||||
pathItem1 = addPath(QPainterPath());
|
||||
|
||||
|
||||
addLine(0,-298,0,298,QPen(Qt::green, 1, Qt::SolidLine) )->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
addLine(-398,0,398,0,QPen(Qt::green, 1, Qt::SolidLine) )->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
|
||||
@@ -90,15 +95,15 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||
ani->setItem(ellipse1);
|
||||
ani->setTimeLine(timer);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SimulScene::startTimer() {
|
||||
timer->setCurrentTime(0);
|
||||
ani->clear();
|
||||
for (int i=0; i<getSteps(); ++i) {
|
||||
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)getSteps(), ellipse1->getCurrProbePath()->at(i) );
|
||||
ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) );
|
||||
//qDebug()<< getSteps();
|
||||
}
|
||||
timer->start();
|
||||
@@ -582,7 +587,8 @@ void SimulScene::setTimePerStep(double time) {
|
||||
\fn SimulScene::startCalculation()
|
||||
*/
|
||||
void SimulScene::startCalculation() {
|
||||
ellipse1->calculateProbePath(ellipse1->pos());
|
||||
ellipse1->calculateProbePath(ellipse1->pos());
|
||||
pathItem1->setPath(ellipse1->getFlightPath());
|
||||
}
|
||||
|
||||
|
||||
@@ -667,3 +673,8 @@ void SimulScene::setMeterPerPx ( double theValue ) {
|
||||
QWidget* SimulScene::getProbeDockWidget() const {
|
||||
return ellipse1->getDockWidget();
|
||||
}
|
||||
|
||||
void SimulScene::setFlightPathVisible(bool visible) {
|
||||
pathItem1->setVisible(visible);
|
||||
emit flightPathVisibilityChanged(visible);
|
||||
}
|
||||
@@ -29,6 +29,8 @@ class QGraphicsRectItem;
|
||||
class QGraphicsItemGroup;
|
||||
class GraphicsEllipseItem;
|
||||
class QGraphicsItemAnimation;
|
||||
class QGraphicsPathItem;
|
||||
class QPainterPath;
|
||||
|
||||
/**
|
||||
@author Peter Dahlberg <pdahlberg@gmail.com>
|
||||
@@ -69,16 +71,19 @@ class SimulScene : public QGraphicsScene {
|
||||
|
||||
void setMeterPerPx ( double theValue );
|
||||
double getMeterPerPx() const;
|
||||
void setFlightPathVisible(bool visible = true);
|
||||
|
||||
private slots:
|
||||
void displayResizeRects(bool move = false);
|
||||
///does the same as displayResizeRects(true)
|
||||
void moveResizeRects();
|
||||
|
||||
signals:
|
||||
void sceneModeChanged(int mode);
|
||||
void stepsChanged(int steps);
|
||||
void timePerStepChanged(double timePerStep);
|
||||
void meterPerPxChanged(double meterPerPx);
|
||||
void flightPathVisibilityChanged(bool visible);
|
||||
private:
|
||||
QTimeLine *timer;
|
||||
|
||||
@@ -101,6 +106,8 @@ class SimulScene : public QGraphicsScene {
|
||||
|
||||
GraphicsEllipseItem *ellipse1;
|
||||
QGraphicsItemAnimation *ani;
|
||||
|
||||
QGraphicsPathItem *pathItem1;
|
||||
|
||||
|
||||
//rechtecke zur groesenaenderung
|
||||
|
||||
Reference in New Issue
Block a user