variable zeitschritte: quadratische gleichung abschaetzung
git-svn-id: http://svn.lsim.tuxzone.org/trunk@32 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
Binary file not shown.
58
lsim.kdevses
58
lsim.kdevses
@@ -1,61 +1,31 @@
|
||||
<?xml version = '1.0' encoding = 'UTF-8'?>
|
||||
<!DOCTYPE KDevPrjSession>
|
||||
<KDevPrjSession>
|
||||
<DocsAndViews NumberOfDocuments="18" >
|
||||
<Doc0 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.h" >
|
||||
<View0 Encoding="" line="201" Type="Source" />
|
||||
<DocsAndViews NumberOfDocuments="8" >
|
||||
<Doc0 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" >
|
||||
<View0 Encoding="" line="185" Type="Source" />
|
||||
</Doc0>
|
||||
<Doc1 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" >
|
||||
<View0 Encoding="" line="106" Type="Source" />
|
||||
<View0 Encoding="" line="57" Type="Source" />
|
||||
</Doc1>
|
||||
<Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" >
|
||||
<View0 Encoding="" line="66" Type="Source" />
|
||||
<Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/main.cpp" >
|
||||
<View0 Encoding="" line="0" Type="Source" />
|
||||
</Doc2>
|
||||
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" >
|
||||
<View0 Encoding="" line="207" Type="Source" />
|
||||
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" >
|
||||
<View0 Encoding="" line="81" Type="Source" />
|
||||
</Doc3>
|
||||
<Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.h" >
|
||||
<View0 Encoding="" line="91" Type="Source" />
|
||||
<View0 Encoding="" line="124" Type="Source" />
|
||||
</Doc4>
|
||||
<Doc5 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.cpp" >
|
||||
<View0 Encoding="" line="293" Type="Source" />
|
||||
<View0 Encoding="" line="105" Type="Source" />
|
||||
</Doc5>
|
||||
<Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/probechargewidget.cpp" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
<Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsview.cpp" >
|
||||
<View0 Encoding="" line="105" Type="Source" />
|
||||
</Doc6>
|
||||
<Doc7 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/stopperitem.h" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
<Doc7 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsview.h" >
|
||||
<View0 Encoding="" line="40" Type="Source" />
|
||||
</Doc7>
|
||||
<Doc8 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/stopperitem.cpp" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
</Doc8>
|
||||
<Doc9 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/constants.h" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
</Doc9>
|
||||
<Doc10 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.h" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
</Doc10>
|
||||
<Doc11 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/main.cpp" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
</Doc11>
|
||||
<Doc12 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/application.qrc" >
|
||||
<View0 Encoding="" line="19" Type="Source" />
|
||||
</Doc12>
|
||||
<Doc13 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/expdoublespinbox.h" >
|
||||
<View0 Encoding="" Type="Source" />
|
||||
</Doc13>
|
||||
<Doc14 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/fielditem.cpp" >
|
||||
<View0 Encoding="" line="122" Type="Source" />
|
||||
</Doc14>
|
||||
<Doc15 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsview.h" >
|
||||
<View0 Encoding="" line="42" Type="Source" />
|
||||
</Doc15>
|
||||
<Doc16 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsview.cpp" >
|
||||
<View0 Encoding="" line="101" Type="Source" />
|
||||
</Doc16>
|
||||
<Doc17 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homoefielditem.cpp" >
|
||||
<View0 Encoding="" line="17" Type="Source" />
|
||||
</Doc17>
|
||||
</DocsAndViews>
|
||||
<pluginList>
|
||||
<kdevdebugger>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <cmath>
|
||||
#include "constants.h"
|
||||
#include <iostream>
|
||||
#include <climits>
|
||||
|
||||
GraphicsEllipseItem::GraphicsEllipseItem() {
|
||||
//setFlag(ItemIsMovable);
|
||||
@@ -51,6 +52,8 @@ void GraphicsEllipseItem::setupVars () {
|
||||
setStartSpeedX(0);
|
||||
setStartSpeedY(0);
|
||||
setPos(0,0);
|
||||
setAdaptiveStepLength(0.01);
|
||||
setAdaptiveStepControl(true);
|
||||
}
|
||||
|
||||
void GraphicsEllipseItem::resetProbe() {
|
||||
@@ -120,9 +123,15 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
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');
|
||||
|
||||
if (combinedSpeed != 0) timePerStep = 0.008/(combinedSpeed/meterPerPx);
|
||||
if (timePerStep < (1/10.0 * myScene->getTimePerStep())) timePerStep = 1/10.0 * myScene->getTimePerStep();
|
||||
if (timePerStep > (19.0/10.0 * myScene->getTimePerStep())) timePerStep = 19.0/10.0 * myScene->getTimePerStep();
|
||||
//automatische Zeitschrittanpassung 0.008
|
||||
if (isAdaptiveStepControlEnabled()&&combinedSpeed != 0) timePerStep = getAdaptiveStepLength()/(combinedSpeed/meterPerPx);
|
||||
//if (timePerStep < (1/10.0 * myScene->getTimePerStep())) timePerStep = 1/10.0 * myScene->getTimePerStep();
|
||||
//if (timePerStep > (19.0/10.0 * myScene->getTimePerStep())) timePerStep = 19.0/10.0 * myScene->getTimePerStep();
|
||||
double combinedPower = sqrt(powerX*powerX+powerY*powerY);
|
||||
if (isAdaptiveStepControlEnabled() && combinedPower !=0) {
|
||||
timePerStep = fabs((-combinedSpeed + sqrt(combinedSpeed*combinedSpeed + 2*(combinedPower/myMasse)*getAdaptiveStepLength()*meterPerPx)) / (combinedPower/myMasse));
|
||||
}
|
||||
|
||||
|
||||
//qDebug()<<timePerStep;
|
||||
|
||||
@@ -177,6 +186,10 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
|
||||
QPointF newPoint(currProbePath->at(i-1).x() + deltaDistX/meterPerPx ,currProbePath->at(i-1).y() + deltaDistY/meterPerPx);
|
||||
|
||||
//Scrollbar int Probleme vermeiden
|
||||
if (newPoint.x() + 10 > INT_MAX || newPoint.x() - 10 < INT_MIN) break;
|
||||
if (newPoint.y() + 10 > INT_MAX || newPoint.y() - 10 < INT_MIN) break;
|
||||
|
||||
if (myScene->stopsHere(currProbePath->at(i-1),newPoint)) break;
|
||||
|
||||
currProbePath->append(newPoint);
|
||||
@@ -192,7 +205,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
|
||||
if (i%path_entry_step == 0 || i==currProbePath->count()) flightPath.lineTo(currProbePath->at(i));
|
||||
}
|
||||
|
||||
//qDebug()<< "Probe Path: " <<*currProbePath;
|
||||
qDebug()<< "Probe Path: " <<*currProbePath;
|
||||
//qDebug()<< "speed x: "<<*speedListX;
|
||||
//qDebug()<< "speed y: "<<*speedListY;
|
||||
//qDebug()<<speedListY->at(12);
|
||||
@@ -298,3 +311,27 @@ void GraphicsEllipseItem::setFlightPath ( const QPainterPath& theValue ) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool GraphicsEllipseItem::isAdaptiveStepControlEnabled() const {
|
||||
return adaptiveStepControlEnabled;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsEllipseItem::setAdaptiveStepControl ( bool theValue ) {
|
||||
if (adaptiveStepControlEnabled == theValue) return;
|
||||
adaptiveStepControlEnabled = theValue;
|
||||
emit adaptiveStepControlChanged(theValue);
|
||||
}
|
||||
|
||||
|
||||
double GraphicsEllipseItem::getAdaptiveStepLength() const {
|
||||
return adaptiveStepLength;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsEllipseItem::setAdaptiveStepLength ( double theValue ) {
|
||||
if (adaptiveStepLength == theValue) return;
|
||||
adaptiveStepLength = theValue;
|
||||
emit adaptiveStepLengthChanged(theValue);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
|
||||
QPainterPath getFlightPath() const;
|
||||
double getRealSimulTime() const;
|
||||
bool isAdaptiveStepControlEnabled() const;
|
||||
double getAdaptiveStepLength() const;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -76,6 +78,10 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
double startSpeedX;
|
||||
///Startgeschwindigkeit des teilchens in y-Richtung
|
||||
double startSpeedY;
|
||||
///automatische Zeitschrittanpassung an/aus
|
||||
bool adaptiveStepControlEnabled;
|
||||
///angenaeherte Schrittlaenge in px
|
||||
double adaptiveStepLength;
|
||||
|
||||
QPointF myScenePos;
|
||||
|
||||
@@ -103,6 +109,9 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
|
||||
void setFlightPath ( const QPainterPath& theValue );
|
||||
void resetProbe();
|
||||
void setAdaptiveStepControl ( bool theValue );
|
||||
void setAdaptiveStepLength ( double theValue );
|
||||
|
||||
|
||||
signals:
|
||||
void startSpeedXChanged(double speed);
|
||||
@@ -112,6 +121,8 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
|
||||
void ScenePosChanged(QPointF newpos);
|
||||
void ScenePosXChanged(double newX);
|
||||
void ScenePosYChanged(double newY);
|
||||
void adaptiveStepControlChanged(bool truefalse);
|
||||
void adaptiveStepLengthChanged(double length);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -101,6 +101,12 @@ void GraphicsView::disableOGLViewport() {
|
||||
//setViewport(new QWidget(parentWidget()));
|
||||
}
|
||||
|
||||
void GraphicsView::centerOnProbe() {
|
||||
SimulScene* simulScene = dynamic_cast<SimulScene*> (scene());
|
||||
if (simulScene == 0) return;
|
||||
centerOn(simulScene->getProbeChargeItem());
|
||||
}
|
||||
|
||||
|
||||
GraphicsView::~GraphicsView() {
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class GraphicsView : public QGraphicsView {
|
||||
public slots:
|
||||
void enableOGLViewport();
|
||||
void disableOGLViewport();
|
||||
void centerOnProbe();
|
||||
private:
|
||||
QStatusBar * mainWindowStatusBar;
|
||||
|
||||
|
||||
42
src/lsim.cpp
42
src/lsim.cpp
@@ -102,14 +102,19 @@ void lsim::createActions() {
|
||||
acts.calculate->setStatusTip (tr ("Flugbahn berechnen"));
|
||||
connect (acts.calculate, SIGNAL (triggered()), this, SLOT (startCalculation()));
|
||||
|
||||
acts.resetAct = new QAction (tr ("reset"), this);
|
||||
acts.resetAct->setStatusTip (tr ("reset"));
|
||||
acts.resetAct = new QAction (tr ("Alles Zur\374cksetzen"), this);
|
||||
acts.resetAct->setStatusTip (tr ("Alle Werte Zur\374cksetzen und alle Felder L\366schen"));
|
||||
connect (acts.resetAct, SIGNAL (triggered()), this, SLOT (resetAll()));
|
||||
|
||||
acts.timerStart = new QAction (tr ("Timer Start"), this);
|
||||
acts.timerStart->setStatusTip (tr ("Timer starten"));
|
||||
connect (acts.timerStart, SIGNAL (triggered()), this, SLOT (startTimer()));
|
||||
|
||||
acts.centerOnProbeAct = new QAction (tr ("Ladungstr\344ger Zentrieren"), this);
|
||||
acts.centerOnProbeAct->setStatusTip (tr ("Den Ladungstr\344ger Zentrieren"));
|
||||
acts.centerOnProbeAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||
connect (acts.centerOnProbeAct, SIGNAL (triggered()), gview, SLOT (centerOnProbe()));
|
||||
|
||||
acts.timerStop = new QAction (tr ("Animation stoppen"), this);
|
||||
acts.timerStop->setStatusTip (tr ("Die Animation stoppen und Ladung an den Anfang zur\374cksetzen"));
|
||||
acts.timerStop->setIcon(QIcon(":icons/media-playback-stop.svg"));
|
||||
@@ -243,6 +248,8 @@ void lsim::createMenus() {
|
||||
|
||||
|
||||
viewMenu = menuBar()->addMenu(tr("&Ansicht"));
|
||||
viewMenu->addAction(acts.centerOnProbeAct);
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction(acts.editModeAct);
|
||||
viewMenu->addAction(acts.simulationModeAct);
|
||||
viewMenu->addSeparator();
|
||||
@@ -314,7 +321,7 @@ void lsim::initWindowMode(WindowMode newMode) {
|
||||
fieldItemEditDock->setVisible(true);
|
||||
probeItemDock->setVisible(true);
|
||||
sceneDock->setVisible(true);
|
||||
gview->centerOn(simulscene->getProbeChargeItem());
|
||||
gview->centerOnProbe();
|
||||
|
||||
|
||||
|
||||
@@ -330,7 +337,7 @@ void lsim::initWindowMode(WindowMode newMode) {
|
||||
acts.itemEditModeAct->trigger();
|
||||
simulscene->clearSelection();
|
||||
acts.calculate->trigger();
|
||||
gview->centerOn(simulscene->getProbeChargeItem());
|
||||
gview->centerOnProbe();
|
||||
|
||||
}
|
||||
|
||||
@@ -370,6 +377,24 @@ void lsim::createDocks() {
|
||||
connect(simulscene, SIGNAL(timePerStepChanged(double)),time_step_box, SLOT(setValue( double )));
|
||||
|
||||
|
||||
//automatische Schrittlaengen-box
|
||||
ExpDoubleSpinBox *adaptive_step_length_box = new ExpDoubleSpinBox;
|
||||
adaptive_step_length_box->setRange(pow(10,-100), pow(10,66));
|
||||
adaptive_step_length_box->setDecimals(100);
|
||||
adaptive_step_length_box->setDisplayDecimals(3);
|
||||
adaptive_step_length_box->setSuffix(" px");
|
||||
adaptive_step_length_box->setKeyboardTracking(false);
|
||||
adaptive_step_length_box->setValue(simulscene->getProbeChargeItem()->getAdaptiveStepLength());
|
||||
connect(adaptive_step_length_box, SIGNAL(valueChanged(double)),simulscene->getProbeChargeItem(), SLOT(setAdaptiveStepLength(double)));
|
||||
connect(simulscene->getProbeChargeItem(), SIGNAL(adaptiveStepLengthChanged(double)),adaptive_step_length_box, SLOT(setValue( double )));
|
||||
|
||||
//automatische schrittanpassungsbox
|
||||
QCheckBox *adaptive_time_step_box = new QCheckBox("");
|
||||
adaptive_time_step_box->setChecked(simulscene->getProbeChargeItem()->isAdaptiveStepControlEnabled());
|
||||
connect(adaptive_time_step_box, SIGNAL(toggled(bool)),simulscene->getProbeChargeItem(), SLOT(setAdaptiveStepControl(bool)));
|
||||
connect(simulscene->getProbeChargeItem(), SIGNAL(adaptiveStepControlChanged(bool)),adaptive_time_step_box, SLOT(setChecked(bool)));
|
||||
connect(adaptive_time_step_box, SIGNAL(toggled(bool)),adaptive_step_length_box, SLOT(setEnabled(bool)));
|
||||
|
||||
//meterPerPixel Box
|
||||
ExpDoubleSpinBox *meter_per_px_box = new ExpDoubleSpinBox;
|
||||
meter_per_px_box->setRange(pow(10,-100), pow(10,66));
|
||||
@@ -385,6 +410,7 @@ void lsim::createDocks() {
|
||||
QLabel *time_per_step_label = new QLabel(tr("Zeit pro Schritt:"));
|
||||
QLabel *steps_label = new QLabel(tr("Schritte:"));
|
||||
QLabel *meter_per_pixel_label = new QLabel(tr("Ein Pixel entspricht:"));
|
||||
QLabel *adaptive_time_step_label = new QLabel(tr("Automatische Schrittl\344nge:"));
|
||||
|
||||
//Scene settings Layout
|
||||
QGridLayout *sceneGridLayout = new QGridLayout;
|
||||
@@ -392,8 +418,12 @@ void lsim::createDocks() {
|
||||
sceneGridLayout->addWidget(steps_box,0,1);
|
||||
sceneGridLayout->addWidget(time_per_step_label,1,0,Qt::AlignRight);
|
||||
sceneGridLayout->addWidget(time_step_box,1,1);
|
||||
sceneGridLayout->addWidget(meter_per_pixel_label,2,0,Qt::AlignRight);
|
||||
sceneGridLayout->addWidget(meter_per_px_box,2,1);
|
||||
sceneGridLayout->addWidget(adaptive_time_step_label,2,0,Qt::AlignRight);
|
||||
sceneGridLayout->addWidget(adaptive_time_step_box,2,1);
|
||||
sceneGridLayout->addWidget(adaptive_step_length_box,3,1);
|
||||
sceneGridLayout->addWidget(meter_per_pixel_label,4,0,Qt::AlignRight);
|
||||
sceneGridLayout->addWidget(meter_per_px_box,4,1);
|
||||
|
||||
|
||||
|
||||
QGroupBox *sceneGroupBox = new QGroupBox(tr("Allgemeines"));
|
||||
|
||||
@@ -122,6 +122,7 @@ class lsim: public QMainWindow {
|
||||
|
||||
QAction *resetAct;
|
||||
QAction *fullScreenAct;
|
||||
QAction *centerOnProbeAct;
|
||||
};
|
||||
Actions acts;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user