#1 fixed und einiges mehr

git-svn-id: http://svn.lsim.tuxzone.org/trunk@10 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
catdog2
2008-11-02 20:34:58 +00:00
parent dc3d1dd8cb
commit 1f68e40c77
17 changed files with 162 additions and 37 deletions

View File

@@ -70,8 +70,8 @@
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
<inlineGet>true</inlineGet>
<inlineSet>true</inlineSet>
<inlineGet>false</inlineGet>
<inlineSet>false</inlineSet>
</creategettersetter>
<splitheadersource>
<enabled>false</enabled>

Binary file not shown.

View File

@@ -1,7 +1,7 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="19" >
<DocsAndViews NumberOfDocuments="23" >
<Doc0 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homoefielditem.cpp" >
<View0 Encoding="" Type="Source" />
</Doc0>
@@ -12,7 +12,7 @@
<View0 Encoding="" Type="Source" />
</Doc2>
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" >
<View0 Encoding="" Type="Source" />
<View0 Encoding="UTF-8" Type="Source" />
</Doc3>
<Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/constants.h" >
<View0 Encoding="" Type="Source" />
@@ -21,7 +21,7 @@
<View0 Encoding="" Type="Source" />
</Doc5>
<Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.cpp" >
<View0 Encoding="" Type="Source" />
<View0 Encoding="" line="171" Type="Source" />
</Doc6>
<Doc7 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.h" >
<View0 Encoding="" Type="Source" />
@@ -48,17 +48,29 @@
<View0 Encoding="" Type="Source" />
</Doc14>
<Doc15 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/expdoublespinbox.cpp" >
<View0 Encoding="" Type="Source" />
<View0 Encoding="" line="110" Type="Source" />
</Doc15>
<Doc16 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/fielditem.h" >
<View0 Encoding="" Type="Source" />
</Doc16>
<Doc17 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/fielditem.cpp" >
<View0 Encoding="" line="48" Type="Source" />
<View0 Encoding="" Type="Source" />
</Doc17>
<Doc18 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.cpp" >
<View0 Encoding="" line="86" Type="Source" />
<View0 Encoding="" Type="Source" />
</Doc18>
<Doc19 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfielditem.h" >
<View0 Encoding="" Type="Source" />
</Doc19>
<Doc20 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.h" >
<View0 Encoding="" Type="Source" />
</Doc20>
<Doc21 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsview.cpp" >
<View0 Encoding="" line="4" Type="Source" />
</Doc21>
<Doc22 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/expdoublespinbox.h" >
<View0 Encoding="" line="49" Type="Source" />
</Doc22>
</DocsAndViews>
<pluginList>
<kdevdebugger>

View File

@@ -28,7 +28,8 @@
ExpDoubleSpinBox::ExpDoubleSpinBox()
: QDoubleSpinBox() {
setPositiveExp(4);
setNegativeExp(3);
setNegativeExp(3);
setDisplayDecimals(decimals());
}
@@ -44,14 +45,14 @@ QString ExpDoubleSpinBox::textFromValue ( double val ) const {
//qDebug() << val;
if((val < pow(10,getPositiveExp()) && val > 1) || (val > -pow(10,getPositiveExp()) && val < -1) || val == 0) {
//return QDoubleSpinBox::textFromValue ( val );
return QString("%L1").arg(val,0,'f',decimals());
return QString("%L1").arg(val,0,'f',getDisplayDecimals());
}
else if ( (val >= pow(10, -getNegativeExp()) && val <= 1 ) || (val <= -pow(10, -getNegativeExp()) && val >= -1 ) ){
//return QDoubleSpinBox::textFromValue ( val );
return QString("%L1").arg(val,0,'f',decimals());
return QString("%L1").arg(val,0,'f',getDisplayDecimals());
}
else {
return QString("%L1").arg(val,0,'e',decimals());
return QString("%L1").arg(val,0,'e',getDisplayDecimals());
}
//return QDoubleSpinBox::textFromValue ( val );
}
@@ -97,3 +98,16 @@ void ExpDoubleSpinBox::stepBy ( int steps ) {
}
int ExpDoubleSpinBox::getDisplayDecimals() const {
return displayDecimals;
}
void ExpDoubleSpinBox::setDisplayDecimals ( int theValue ) {
if (displayDecimals == theValue) return;
//Nicht mehr anzeigen, als die gneauigkeit zulaesst
if (theValue > decimals()) theValue = decimals();
displayDecimals = theValue;
}

View File

@@ -40,21 +40,25 @@ class ExpDoubleSpinBox : public QDoubleSpinBox {
virtual QValidator::State validate ( QString & input, int & pos ) const;
virtual void stepBy ( int steps );
///welche kommastelle soll noch ohne exponentialdarstellungen dargestellt werden
void setNegativeExp (int exponent);
///welche kommastelle soll noch ohne exponentialdarstellungen dargestellt werden
const int getNegativeExp () const;
///ab welchem positiven exponenten soll exponentialdarstellung benutzt werden
void setPositiveExp (int exponent);
///ab welchem positiven exponenten soll exponentialdarstellung benutzt werden
const int getPositiveExp () const;
void setDisplayDecimals ( int theValue );
int getDisplayDecimals() const;
protected:
virtual QDoubleSpinBox::StepEnabled stepEnabled () const;
private:
///welche kommastelle soll noch ohne exponentialdarstellungen dargestellt werden
int negativeExp;
///ab welchem positiven exponenten soll exponentialdarstellung benutzt werden
int positiveExp;
///Wie viele Decimals sollen angezeigt werden (default: displayDecimals=decimals default)
int displayDecimals;
};
#endif

View File

@@ -20,6 +20,7 @@
#include "fielditem.h"
#include "homoefielditem.h"
#include "homobfielditem.h"
#include <QGraphicsSceneWheelEvent>
#include <QDebug>
FieldItem::FieldItem()
@@ -122,6 +123,14 @@ QRectF FieldItem::rect() const {
return getRectF();
}
void FieldItem::wheelEvent(QGraphicsSceneWheelEvent * event) {
if (event->modifiers() == Qt::ShiftModifier) {
setRotation(getRotation()+( (event->delta()/abs(event->delta()))) );
}
else if (event->modifiers() == Qt::ControlModifier) {
setRotation(getRotation()+( (event->delta()/abs(event->delta()))*5 ));
}
}
/*!
\fn FieldItem::getRotation()

View File

@@ -28,6 +28,7 @@
@author Peter Dahlberg <pdahlberg@gmail.com>
*/
class QPointF;
class QGraphicsSceneWheelEvent;
class FieldItem :public QObject, public QGraphicsItem {
Q_OBJECT
public:
@@ -52,10 +53,10 @@ class FieldItem :public QObject, public QGraphicsItem {
\param item Das zu pruefende Item
*/
static bool isFieldItem(QGraphicsItem *item);
int getRotation();
int getRotation();
protected:
virtual void wheelEvent(QGraphicsSceneWheelEvent * event);
QPointF myScenePos;
int myRotation;
QRectF sizeRect;

View File

@@ -128,10 +128,11 @@ double GraphicsEllipseItem::getMasse(double speed) {
void GraphicsEllipseItem::setMasse ( const double& theValue ) {
if (masse == theValue) return;
masse = theValue;
emit masseChanged(theValue);
}
long double GraphicsEllipseItem::getCharge() const {
double GraphicsEllipseItem::getCharge() const {
return charge;
}
@@ -139,6 +140,7 @@ long double GraphicsEllipseItem::getCharge() const {
void GraphicsEllipseItem::setCharge ( const long double& theValue ) {
if (charge == theValue) return;
charge = theValue;
emit chargeChanged(theValue);
}
QWidget * GraphicsEllipseItem::getDockWidget() const
@@ -148,4 +150,27 @@ QWidget * GraphicsEllipseItem::getDockWidget() const
QList<QPointF> * GraphicsEllipseItem::getCurrProbePath() {
return currProbePath;
}
}
double GraphicsEllipseItem::getStartSpeedX() const {
return startSpeedX;
}
void GraphicsEllipseItem::setStartSpeedX ( double theValue ) {
if (startSpeedX == theValue) return;
startSpeedX = theValue;
emit startSpeedXChanged(theValue);
}
double GraphicsEllipseItem::getStartSpeedY() const {
return startSpeedY;
}
void GraphicsEllipseItem::setStartSpeedY ( double theValue ) {
if (startSpeedY == theValue) return;
startSpeedY = theValue;
emit startSpeedYChanged(theValue);
}

View File

@@ -21,18 +21,31 @@
#define GRAPHICSELLIPSEITEM_H
#include <QGraphicsEllipseItem>
#include <QObject>
class ProbeChargeWidget;
/**
@author Peter Dahlberg <pdahlberg@gmail.com>
*/
class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
Q_OBJECT
public:
GraphicsEllipseItem();
QWidget* getDockWidget() const;
~GraphicsEllipseItem();
QList<QPointF> * getCurrProbePath();
double getCharge() const;
double getStartSpeedX() const;
double getStartSpeedY() const;
//! Gibt die Masse zur&uuml;ck
/*!
\param speed alles != 0 relativistisch
*/
double getMasse(double speed);
@@ -53,6 +66,10 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
double charge;
///Zugeordnetes Probe Charge Widget
ProbeChargeWidget* myProbeChargeWidget;
///Startgeschwindigkeit des teilchens in x-Richtung
double startSpeedX;
///Startgeschwindigkeit des teilchens in y-Richtung
double startSpeedY;
public slots:
@@ -64,16 +81,20 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
void setMasse ( const double& theValue );
//! Gibt die Masse zur&uuml;ck
/*!
\param speed alles != 0 relativistisch
*/
double getMasse(double speed);
void setCharge ( const long double& theValue );
void setStartSpeedX ( double theValue );
void setStartSpeedY ( double theValue );
signals:
void startSpeedXChanged(double speed);
void startSpeedYChanged(double speed);
void masseChanged(double masse);
void chargeChanged(double Charge);
long double getCharge() const;
};

View File

@@ -23,6 +23,7 @@
#include <QPainter>
#include <QWidget>
#include <QtDebug>
#include <QGraphicsSceneWheelEvent>
HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
setRectF(sizeRect);
@@ -189,3 +190,13 @@ void HomoBFieldItem::setFluxDensity ( double theValue ) {
fluxDensity = theValue;
emit fluxDensityChanged(theValue);
}
/*!
\fn HomoBFieldItem::wheelEvent ( QGraphicsSceneWheelEvent * event )
*/
void HomoBFieldItem::wheelEvent ( QGraphicsSceneWheelEvent * event )
{
event->ignore();
}

View File

@@ -76,6 +76,8 @@ class HomoBFieldItem : public FieldItem {
protected:
void wheelEvent ( QGraphicsSceneWheelEvent * event );
};
#endif

View File

@@ -37,11 +37,13 @@ void HomoBFieldWidget::createWidget() {
QDoubleSpinBox *heightBox = new QDoubleSpinBox;
heightBox->setRange(HomoBFieldItem::MinimumHeight, 5000);
heightBox->setKeyboardTracking(false);
connect(homoBField ,SIGNAL(heightChanged(double)), heightBox, SLOT(setValue(double)) );
connect(heightBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setRectFHeight(double)) );
QDoubleSpinBox *widthBox = new QDoubleSpinBox;
widthBox->setRange(HomoBFieldItem::MinimumWidth, 5000);
widthBox->setKeyboardTracking(false);
connect(homoBField ,SIGNAL(widthChanged(double)),widthBox, SLOT(setValue(double)) );
connect(widthBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setRectFWidth(double)) );
@@ -52,11 +54,13 @@ void HomoBFieldWidget::createWidget() {
QDoubleSpinBox *posXBox = new QDoubleSpinBox;
posXBox->setRange(-5000, 5000);
posXBox->setKeyboardTracking(false);
connect(homoBField ,SIGNAL(ScenePosXChanged(double)),posXBox, SLOT(setValue(double)) );
connect(posXBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setScenePosX(double)) );
QDoubleSpinBox *posYBox = new QDoubleSpinBox;
posYBox->setRange(-5000, 5000);
posYBox->setKeyboardTracking(false);
connect(homoBField ,SIGNAL(ScenePosYChanged(double)),posYBox, SLOT(setValue(double)) );
connect(posYBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setScenePosY(double)) );
@@ -82,6 +86,9 @@ void HomoBFieldWidget::createWidget() {
ExpDoubleSpinBox* fieldFluxDensityBox = new ExpDoubleSpinBox;
fieldFluxDensityBox->setRange(-1e+200,1e+200);
fieldFluxDensityBox->setDecimals(40);
fieldFluxDensityBox->setDisplayDecimals(2);
fieldFluxDensityBox->setKeyboardTracking(false);
connect(homoBField ,SIGNAL(fluxDensityChanged(double)),fieldFluxDensityBox, SLOT(setValue(double)) );
connect(fieldFluxDensityBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setFluxDensity(double)) );

View File

@@ -44,19 +44,16 @@ HomoEFieldWidget::~HomoEFieldWidget() {
*/
void HomoEFieldWidget::createWidget()
{
QDial *rotationDial = new QDial;
rotationDial->setRange(0,359);
rotationDial->setNotchesVisible(true);
rotationDial->setWrapping(true);
QDoubleSpinBox *heightBox = new QDoubleSpinBox;
heightBox->setRange(HomoEFieldItem::MinimumHeight, 5000);
heightBox->setKeyboardTracking(false);
connect(homoEField ,SIGNAL(heightChanged(double)), heightBox, SLOT(setValue(double)) );
connect(heightBox, SIGNAL(valueChanged(double)),homoEField ,SLOT(setRectFHeight(double)) );
QDoubleSpinBox *widthBox = new QDoubleSpinBox;
widthBox->setRange(HomoEFieldItem::MinimumWidth, 5000);
widthBox->setKeyboardTracking(false);
connect(homoEField ,SIGNAL(widthChanged(double)),widthBox, SLOT(setValue(double)) );
connect(widthBox, SIGNAL(valueChanged(double)),homoEField ,SLOT(setRectFWidth(double)) );
@@ -68,11 +65,13 @@ void HomoEFieldWidget::createWidget()
QDoubleSpinBox *posXBox = new QDoubleSpinBox;
posXBox->setRange(-5000, 5000);
posXBox->setKeyboardTracking(false);
connect(homoEField ,SIGNAL(ScenePosXChanged(double)),posXBox, SLOT(setValue(double)) );
connect(posXBox, SIGNAL(valueChanged(double)),homoEField ,SLOT(setScenePosX(double)) );
QDoubleSpinBox *posYBox = new QDoubleSpinBox;
posYBox->setRange(-5000, 5000);
posYBox->setKeyboardTracking(false);
connect(homoEField ,SIGNAL(ScenePosYChanged(double)),posYBox, SLOT(setValue(double)) );
connect(posYBox, SIGNAL(valueChanged(double)),homoEField ,SLOT(setScenePosY(double)) );
@@ -80,10 +79,10 @@ void HomoEFieldWidget::createWidget()
rotationBox->setRange(0,359);
rotationBox->setSuffix("\260");
rotationBox->setWrapping(true);
connect(rotationDial, SIGNAL(valueChanged(int)),rotationBox ,SIGNAL(valueChanged(int)) );
connect(rotationDial, SIGNAL(valueChanged(int)),rotationBox,SLOT(setValue(int)) );
rotationBox->setKeyboardTracking(false);
connect(rotationBox, SIGNAL(valueChanged(int)),homoEField ,SLOT(setRotation(int)) );
connect(rotationBox, SIGNAL(valueChanged(int)),rotationDial ,SLOT(setValue(int)) );
connect(homoEField, SIGNAL(rotationChanged(int)),rotationBox ,SLOT(setValue(int)) );
QGridLayout* geomGridLayout = new QGridLayout;
@@ -110,11 +109,17 @@ void HomoEFieldWidget::createWidget()
ExpDoubleSpinBox* fieldPowerBox = new ExpDoubleSpinBox;
fieldPowerBox->setRange(-1e+200,1e+200);
fieldPowerBox->setDecimals(35);
fieldPowerBox->setDisplayDecimals(3);
fieldPowerBox->setKeyboardTracking(false);
connect(homoEField ,SIGNAL(fieldPowerChanged(double)),fieldPowerBox, SLOT(setValue(double)) );
connect(fieldPowerBox, SIGNAL(valueChanged(double)),homoEField ,SLOT(setFieldPower(double)) );
ExpDoubleSpinBox* voltageBox = new ExpDoubleSpinBox;
voltageBox->setRange(-1e+200,1e+200);
fieldPowerBox->setDecimals(35);
fieldPowerBox->setDisplayDecimals(3);
voltageBox->setKeyboardTracking(false);
QGridLayout* constGridLayout = new QGridLayout;
//constGridLayout->setSizeConstraint(QLayout::SetFixedSize);

View File

@@ -82,6 +82,10 @@ void lsim::createActions() {
acts.timerStart->setStatusTip (tr ("Timer starten"));
connect (acts.timerStart, SIGNAL (triggered()), simulscene, SLOT (startTimer()));
acts.timerStop = new QAction (tr ("Timer Stop"), this);
acts.timerStop->setStatusTip (tr ("Timer stoppen"));
connect (acts.timerStop, SIGNAL (triggered()), simulscene, SLOT (stopTimer()));
acts.exitAct = new QAction (tr ("Beenden"), this);
acts.exitAct->setStatusTip (tr ("Die Anwendung beenden"));
connect (acts.exitAct, SIGNAL (triggered()), qApp, SLOT (quit()));
@@ -136,6 +140,7 @@ void lsim::createToolBars() {
editToolBar = addToolBar (tr ("Edit"));
editToolBar->addAction(acts.timerStart);
editToolBar->addAction(acts.timerStop);
editToolBar->addSeparator();
editToolBar->addAction(acts.itemEditModeAct);
editToolBar->addAction(acts.insertEFieldItemAct);
@@ -157,8 +162,9 @@ void lsim::createDocks() {
ExpDoubleSpinBox *time_step_box = new ExpDoubleSpinBox;
time_step_box->setRange(-pow(10,33), pow(10,33));
time_step_box->setRange(-pow(10,66), pow(10,66));
time_step_box->setDecimals(30);
time_step_box->setDisplayDecimals(10);
time_step_box->setKeyboardTracking(false);
time_step_box->setValue(simulscene->getTimePerStep());
@@ -167,8 +173,9 @@ void lsim::createDocks() {
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,66), pow(10,66));
meter_per_px_box->setDecimals(30);
meter_per_px_box->setDisplayDecimals(10);
meter_per_px_box->setKeyboardTracking(false);
meter_per_px_box->setValue(simulscene->getMeterPerPx());
connect(meter_per_px_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setMeterPerPx(double)));

View File

@@ -79,6 +79,7 @@ class lsim: public QMainWindow {
QAction *oglEnable;
QAction *oglDisable;
QAction *timerStart;
QAction *timerStop;
QAction *itemEditModeAct;
QAction *insertEFieldItemAct;

View File

@@ -93,6 +93,8 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
}
void SimulScene::startTimer() {
timer->setCurrentTime(0);
ani->clear();
for (int i=0; i<getSteps(); ++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) );
@@ -100,6 +102,9 @@ void SimulScene::startTimer() {
}
timer->start();
}
void SimulScene::stopTimer() {
timer->stop();
}
void SimulScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) {
switch(myMode) {

View File

@@ -60,6 +60,7 @@ class SimulScene : public QGraphicsScene {
public slots:
void setSceneMode(SceneMode mode);
void startTimer();
void stopTimer();
void deleteSelectedFieldItems();
void setTimePerStep(double time);
///starte die Berechnung der teilchenbahn(en)