letzter commit vor homobfield/erstellung einbindung
git-svn-id: http://svn.lsim.tuxzone.org/trunk@4 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
@@ -80,11 +80,18 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint, double startSpe
|
|||||||
|
|
||||||
for(int i = 1; i< steps;++i) {
|
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) ) );
|
double myMasse = getMasse( sqrt( speedListX->at(i-1)*speedListX->at(i-1) + speedListY->at(i-1)*speedListY->at(i-1) ) );
|
||||||
qDebug()<< myMasse;
|
//qDebug()<< myMasse;
|
||||||
double powerX = myScene->getPowerAt(currProbePath->at(i-1), charge, 'x');
|
double powerX = myScene->getPowerAt(currProbePath->at(i-1), charge, 'x');
|
||||||
double powerY = myScene->getPowerAt(currProbePath->at(i-1), charge, 'y');
|
double powerY = myScene->getPowerAt(currProbePath->at(i-1), charge, 'y');
|
||||||
double deltaDistXconst = speedListX->at(i-1) * (timePerStep/1000.0); //v0*t
|
|
||||||
double deltaDistYconst = speedListY->at(i-1) * (timePerStep/1000.0);
|
double newspeedX = speedListX->at(i-1) + (powerX/myMasse * (timePerStep/1000.0));
|
||||||
|
double newspeedY = speedListY->at(i-1) + (powerY/myMasse * (timePerStep/1000.0));
|
||||||
|
|
||||||
|
//double deltaDistXconst = speedListX->at(i-1) * (timePerStep/1000.0); //v0*t
|
||||||
|
//double deltaDistYconst = speedListY->at(i-1) * (timePerStep/1000.0);
|
||||||
|
|
||||||
|
double deltaDistXconst = (speedListX->at(i-1) + newspeedX)/2.0 * (timePerStep/1000.0); //v0*t
|
||||||
|
double deltaDistYconst = (speedListY->at(i-1) + newspeedY)/2.0 * (timePerStep/1000.0); //mittel zw alt,neu um fehler zu mindern
|
||||||
|
|
||||||
double deltaDistXaccel = 0.5 * (powerX/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0)); // 1/2 * F/m * t*t
|
double deltaDistXaccel = 0.5 * (powerX/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0)); // 1/2 * F/m * t*t
|
||||||
double deltaDistYaccel = 0.5 * (powerY/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0));
|
double deltaDistYaccel = 0.5 * (powerY/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0));
|
||||||
@@ -93,8 +100,8 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint, double startSpe
|
|||||||
double deltaDistY = (deltaDistYconst + deltaDistYaccel);
|
double deltaDistY = (deltaDistYconst + deltaDistYaccel);
|
||||||
|
|
||||||
currProbePath->append(QPointF(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));
|
||||||
speedListX->append(speedListX->at(i-1) + (powerX/myMasse * (timePerStep/1000.0)) );
|
speedListX->append(newspeedX);
|
||||||
speedListY->append(speedListY->at(i-1) + (powerY/myMasse * (timePerStep/1000.0)) );
|
speedListY->append(newspeedY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
107
src/homobfielditem.cpp
Normal file
107
src/homobfielditem.cpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Peter Dahlberg *
|
||||||
|
* pdahlberg@gmail.com *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
#include "homobfielditem.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
|
||||||
|
setFieldLineDistance(10);
|
||||||
|
setFlag(ItemIsMovable);
|
||||||
|
setFlag(ItemIsSelectable);
|
||||||
|
setFlag(ItemIsFocusable);
|
||||||
|
setOuterPenWidth (2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HomoBFieldItem::~HomoBFieldItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRectF HomoBFieldItem::boundingRect() const {
|
||||||
|
return QRectF(sizeRect.x() - outerPenWidth, sizeRect.y() - outerPenWidth,
|
||||||
|
sizeRect.width() + outerPenWidth, sizeRect.height() + outerPenWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF HomoBFieldItem::getRectF() const
|
||||||
|
{
|
||||||
|
return FieldItem::getRectF();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HomoBFieldItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||||
|
Qt::GlobalColor linecolor = Qt::blue;
|
||||||
|
painter->setPen(linecolor);
|
||||||
|
if (isSelected()) painter->setBrush(Qt::Dense6Pattern); //selection deutlich machen
|
||||||
|
painter->drawRect(sizeRect);
|
||||||
|
|
||||||
|
for (int i = 1; i <= floor(sizeRect.width()/(qreal)fieldLineDistance); ++i) {
|
||||||
|
const int top_bottom_space = 10;
|
||||||
|
const int arrow_height = 8; //pfeilhoehe
|
||||||
|
const int arrow_width_half = 3; //Halbe pfeilbreite
|
||||||
|
|
||||||
|
if ((i*fieldLineDistance)+arrow_width_half >= sizeRect.width() -2) break; //rechts ueberstehen verhindern
|
||||||
|
if (sizeRect.height() < top_bottom_space + arrow_height) break;//nur zeichnen, wenn sizeRect hoch genug
|
||||||
|
|
||||||
|
//Feldlinien zeichnen
|
||||||
|
painter->drawLine(
|
||||||
|
sizeRect.x() + (i*fieldLineDistance) ,
|
||||||
|
sizeRect.y() +top_bottom_space ,
|
||||||
|
sizeRect.x() + (i*fieldLineDistance) ,
|
||||||
|
sizeRect.y() + sizeRect.height() - top_bottom_space
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//Pfeile Zeichnen
|
||||||
|
QPointF arrows[3] = {
|
||||||
|
QPointF(sizeRect.x()+(i*fieldLineDistance), sizeRect.y()+sizeRect.height()-top_bottom_space),
|
||||||
|
QPointF(sizeRect.x()+(i*fieldLineDistance)-arrow_width_half,sizeRect.y()+sizeRect.height()-top_bottom_space-arrow_height),
|
||||||
|
QPointF(sizeRect.x()+(i*fieldLineDistance)+arrow_width_half,sizeRect.y()+sizeRect.height()-top_bottom_space-arrow_height),
|
||||||
|
};
|
||||||
|
painter->setBrush(linecolor);
|
||||||
|
painter->drawPolygon(arrows,3);
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
|
//qDebug() << pos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HomoBFieldItem::type() const {
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HomoBFieldItem::getFieldLineDistance() const {
|
||||||
|
return fieldLineDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HomoBFieldItem::setFieldLineDistance ( int theValue ) {
|
||||||
|
if(fieldLineDistance == theValue) return;
|
||||||
|
fieldLineDistance = theValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double HomoBFieldItem::getOuterPenWidth() const {
|
||||||
|
return outerPenWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HomoBFieldItem::setOuterPenWidth ( double theValue ) {
|
||||||
|
outerPenWidth = theValue;
|
||||||
|
}
|
||||||
60
src/homobfielditem.h
Normal file
60
src/homobfielditem.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2008 by Peter Dahlberg *
|
||||||
|
* pdahlberg@gmail.com *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
|
#ifndef HOMOBFIELDITEM_H
|
||||||
|
#define HOMOBFIELDITEM_H
|
||||||
|
|
||||||
|
#include <fielditem.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@author Peter Dahlberg <pdahlberg@gmail.com>
|
||||||
|
*/
|
||||||
|
class HomoBFieldItem : public FieldItem {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum {Type = UserType + 2};
|
||||||
|
enum {MinimumWidth = 20};
|
||||||
|
enum {MinimumHeight = 30};
|
||||||
|
|
||||||
|
HomoBFieldItem(QRectF sizeRect);
|
||||||
|
|
||||||
|
virtual ~HomoBFieldItem();
|
||||||
|
|
||||||
|
virtual QRectF boundingRect() const;
|
||||||
|
virtual QRectF getRectF() const;
|
||||||
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||||
|
int type() const;
|
||||||
|
|
||||||
|
int getFieldLineDistance() const;
|
||||||
|
|
||||||
|
double getOuterPenWidth() const;
|
||||||
|
public slots:
|
||||||
|
void setOuterPenWidth ( double theValue );
|
||||||
|
void setFieldLineDistance ( int theValue );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Abstand der Feldlinien in der Zeichnung
|
||||||
|
int fieldLineDistance;
|
||||||
|
double outerPenWidth;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -33,7 +33,7 @@ HomoEFieldItem::HomoEFieldItem(QRectF sizeRect)
|
|||||||
setFlag(ItemIsMovable);
|
setFlag(ItemIsMovable);
|
||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
setFlag(ItemIsFocusable);
|
setFlag(ItemIsFocusable);
|
||||||
outerPenWidth = 2;
|
setOuterPenWidth (2);
|
||||||
//rotateslot(66);
|
//rotateslot(66);
|
||||||
|
|
||||||
|
|
||||||
@@ -122,3 +122,14 @@ void HomoEFieldItem::setFieldPower (double fieldPower ) {
|
|||||||
this->fieldPower = fieldPower;
|
this->fieldPower = fieldPower;
|
||||||
emit fieldPowerChanged(fieldPower);
|
emit fieldPowerChanged(fieldPower);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double HomoEFieldItem::getOuterPenWidth() const {
|
||||||
|
return outerPenWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HomoEFieldItem::setOuterPenWidth ( double theValue ) {
|
||||||
|
if (outerPenWidth == theValue) return;
|
||||||
|
outerPenWidth = theValue;
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ class HomoEFieldItem : public FieldItem {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setFieldPower (double fieldPower );
|
void setFieldPower (double fieldPower );
|
||||||
|
|
||||||
|
void setOuterPenWidth ( double theValue );
|
||||||
|
double getOuterPenWidth() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fieldPowerChanged(double fieldPower);
|
void fieldPowerChanged(double fieldPower);
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ class HomoEFieldItem : public FieldItem {
|
|||||||
//! Abstand der Feldlinien in der Zeichnung
|
//! Abstand der Feldlinien in der Zeichnung
|
||||||
int fieldLineDistance;
|
int fieldLineDistance;
|
||||||
|
|
||||||
qreal outerPenWidth;
|
double outerPenWidth;
|
||||||
|
|
||||||
HomoEFieldWidget* dockWidget;
|
HomoEFieldWidget* dockWidget;
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void lsim::createDocks() {
|
|||||||
|
|
||||||
ExpDoubleSpinBox *time_step_box = new ExpDoubleSpinBox;
|
ExpDoubleSpinBox *time_step_box = new ExpDoubleSpinBox;
|
||||||
time_step_box->setRange(-pow(10,33), pow(10,33));
|
time_step_box->setRange(-pow(10,33), pow(10,33));
|
||||||
time_step_box->setDecimals(20);
|
time_step_box->setDecimals(30);
|
||||||
time_step_box->setKeyboardTracking(false);
|
time_step_box->setKeyboardTracking(false);
|
||||||
|
|
||||||
time_step_box->setValue(simulscene->getTimePerStep());
|
time_step_box->setValue(simulscene->getTimePerStep());
|
||||||
@@ -161,7 +161,7 @@ void lsim::createDocks() {
|
|||||||
|
|
||||||
ExpDoubleSpinBox *meter_per_px_box = new ExpDoubleSpinBox;
|
ExpDoubleSpinBox *meter_per_px_box = new ExpDoubleSpinBox;
|
||||||
meter_per_px_box->setRange(-pow(10,33), pow(10,33));
|
meter_per_px_box->setRange(-pow(10,33), pow(10,33));
|
||||||
meter_per_px_box->setDecimals(20);
|
meter_per_px_box->setDecimals(30);
|
||||||
meter_per_px_box->setKeyboardTracking(false);
|
meter_per_px_box->setKeyboardTracking(false);
|
||||||
meter_per_px_box->setValue(simulscene->getMeterPerPx());
|
meter_per_px_box->setValue(simulscene->getMeterPerPx());
|
||||||
connect(meter_per_px_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setMeterPerPx(double)));
|
connect(meter_per_px_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setMeterPerPx(double)));
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
|
||||||
//variablen initialisieren
|
//variablen initialisieren
|
||||||
setTimePerStep(0.00001);
|
setTimePerStep(0.00001);
|
||||||
setSteps(200);
|
setSteps(1000);
|
||||||
//setMeterPerPx(1/1000.0);
|
//setMeterPerPx(1/1000.0);
|
||||||
setMeterPerPx(1);
|
setMeterPerPx(1);
|
||||||
currHomoEfieldInsertItem = 0;
|
currHomoEfieldInsertItem = 0;
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ SOURCES += lsim.cpp \
|
|||||||
simulscene.cpp \
|
simulscene.cpp \
|
||||||
expdoublespinbox.cpp \
|
expdoublespinbox.cpp \
|
||||||
homoefieldwidget.cpp \
|
homoefieldwidget.cpp \
|
||||||
probechargewidget.cpp
|
probechargewidget.cpp \
|
||||||
|
homobfielditem.cpp
|
||||||
HEADERS += lsim.h \
|
HEADERS += lsim.h \
|
||||||
graphicsview.h \
|
graphicsview.h \
|
||||||
graphicsellipseitem.h \
|
graphicsellipseitem.h \
|
||||||
@@ -18,7 +19,8 @@ HEADERS += lsim.h \
|
|||||||
lsim_interface.h \
|
lsim_interface.h \
|
||||||
homoefieldwidget.h \
|
homoefieldwidget.h \
|
||||||
constants.h \
|
constants.h \
|
||||||
probechargewidget.h
|
probechargewidget.h \
|
||||||
|
homobfielditem.h
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
CONFIG += warn_on \
|
CONFIG += warn_on \
|
||||||
thread \
|
thread \
|
||||||
|
|||||||
Reference in New Issue
Block a user