diff --git a/lsim.kdevelop b/lsim.kdevelop index 40b7388..dd1595c 100644 --- a/lsim.kdevelop +++ b/lsim.kdevelop @@ -70,8 +70,8 @@ set m_,_ theValue - true - true + false + false false diff --git a/lsim.kdevelop.pcs b/lsim.kdevelop.pcs index 64a5360..690f6af 100644 Binary files a/lsim.kdevelop.pcs and b/lsim.kdevelop.pcs differ diff --git a/lsim.kdevses b/lsim.kdevses index bc7c8dd..e200843 100644 --- a/lsim.kdevses +++ b/lsim.kdevses @@ -1,7 +1,7 @@ - + @@ -12,7 +12,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -48,17 +48,29 @@ - + - + - + + + + + + + + + + + + + diff --git a/src/expdoublespinbox.cpp b/src/expdoublespinbox.cpp index d08fcd0..20800a1 100644 --- a/src/expdoublespinbox.cpp +++ b/src/expdoublespinbox.cpp @@ -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; +} diff --git a/src/expdoublespinbox.h b/src/expdoublespinbox.h index f698b01..54dc823 100644 --- a/src/expdoublespinbox.h +++ b/src/expdoublespinbox.h @@ -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 diff --git a/src/fielditem.cpp b/src/fielditem.cpp index b5d1a5a..758dd4d 100644 --- a/src/fielditem.cpp +++ b/src/fielditem.cpp @@ -20,6 +20,7 @@ #include "fielditem.h" #include "homoefielditem.h" #include "homobfielditem.h" +#include #include 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() diff --git a/src/fielditem.h b/src/fielditem.h index 260675c..94273fa 100644 --- a/src/fielditem.h +++ b/src/fielditem.h @@ -28,6 +28,7 @@ @author Peter Dahlberg */ 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; diff --git a/src/graphicsellipseitem.cpp b/src/graphicsellipseitem.cpp index c6aca63..6f07ac3 100644 --- a/src/graphicsellipseitem.cpp +++ b/src/graphicsellipseitem.cpp @@ -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 * GraphicsEllipseItem::getCurrProbePath() { return currProbePath; -} \ No newline at end of file +} + +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); +} diff --git a/src/graphicsellipseitem.h b/src/graphicsellipseitem.h index a7bb558..df62f45 100644 --- a/src/graphicsellipseitem.h +++ b/src/graphicsellipseitem.h @@ -21,18 +21,31 @@ #define GRAPHICSELLIPSEITEM_H #include +#include class ProbeChargeWidget; /** @author Peter Dahlberg */ + class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem { + Q_OBJECT public: GraphicsEllipseItem(); QWidget* getDockWidget() const; ~GraphicsEllipseItem(); QList * getCurrProbePath(); + + double getCharge() const; + double getStartSpeedX() const; + double getStartSpeedY() const; + + //! Gibt die Masse zurü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ü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; + + + }; diff --git a/src/homobfielditem.cpp b/src/homobfielditem.cpp index a049e6b..87d11cf 100644 --- a/src/homobfielditem.cpp +++ b/src/homobfielditem.cpp @@ -23,6 +23,7 @@ #include #include #include +#include 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(); +} diff --git a/src/homobfielditem.h b/src/homobfielditem.h index cdcc2aa..e90e728 100644 --- a/src/homobfielditem.h +++ b/src/homobfielditem.h @@ -76,6 +76,8 @@ class HomoBFieldItem : public FieldItem { +protected: + void wheelEvent ( QGraphicsSceneWheelEvent * event ); }; #endif diff --git a/src/homobfieldwidget.cpp b/src/homobfieldwidget.cpp index 766988b..6ada381 100644 --- a/src/homobfieldwidget.cpp +++ b/src/homobfieldwidget.cpp @@ -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)) ); diff --git a/src/homoefieldwidget.cpp b/src/homoefieldwidget.cpp index a821207..2ed1f6e 100644 --- a/src/homoefieldwidget.cpp +++ b/src/homoefieldwidget.cpp @@ -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); diff --git a/src/lsim.cpp b/src/lsim.cpp index c67fdf2..f9b0d31 100644 --- a/src/lsim.cpp +++ b/src/lsim.cpp @@ -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))); diff --git a/src/lsim.h b/src/lsim.h index 4ad65c7..adda2ba 100644 --- a/src/lsim.h +++ b/src/lsim.h @@ -79,6 +79,7 @@ class lsim: public QMainWindow { QAction *oglEnable; QAction *oglDisable; QAction *timerStart; + QAction *timerStop; QAction *itemEditModeAct; QAction *insertEFieldItemAct; diff --git a/src/simulscene.cpp b/src/simulscene.cpp index 9b6bf27..fc33ce9 100644 --- a/src/simulscene.cpp +++ b/src/simulscene.cpp @@ -93,6 +93,8 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { } void SimulScene::startTimer() { + timer->setCurrentTime(0); + ani->clear(); for (int i=0; isetPosAt(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) { diff --git a/src/simulscene.h b/src/simulscene.h index 646bd0f..841d7d0 100644 --- a/src/simulscene.h +++ b/src/simulscene.h @@ -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)