diff --git a/src/graphicsellipseitem.cpp b/src/graphicsellipseitem.cpp index 91ddbe2..7559cd2 100644 --- a/src/graphicsellipseitem.cpp +++ b/src/graphicsellipseitem.cpp @@ -93,6 +93,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) { //startpunkt in den Pfad setzen flightPath = QPainterPath(startPoint); + int path_entry_step = ceil(steps/5000.0); //jeder entry_step(te) step wird eingetragen int debugTime = 0; time_t start_time = time(0); @@ -125,7 +126,8 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) { currProbePath->append(newPoint); speedListX->append(newspeedX); speedListY->append(newspeedY); - flightPath.lineTo(newPoint); + + if (i%path_entry_step == 0 || i==steps) flightPath.lineTo(newPoint); } qDebug()<< difftime(time(0),start_time); diff --git a/src/homobfielditem.cpp b/src/homobfielditem.cpp index d87a082..7ea652f 100644 --- a/src/homobfielditem.cpp +++ b/src/homobfielditem.cpp @@ -34,7 +34,7 @@ HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() { setOuterPenWidth (2); dockWidget = new HomoBFieldWidget(0,0,this); setIsDirectionIntoPlane(true); - setFluxDensity(233); + setFluxDensity(2e-5); } diff --git a/src/homoefielditem.cpp b/src/homoefielditem.cpp index 4ce07a1..c5f33dd 100644 --- a/src/homoefielditem.cpp +++ b/src/homoefielditem.cpp @@ -28,7 +28,7 @@ HomoEFieldItem::HomoEFieldItem(QRectF sizeRect) : FieldItem() { setRectF(sizeRect); dockWidget = new HomoEFieldWidget(0,0,this); - setFieldPower(2.8e+3); + setFieldPower(10); setFieldLineDistance(10); setFlag(ItemIsMovable); setFlag(ItemIsSelectable); diff --git a/src/lsim.cpp b/src/lsim.cpp index 308fc44..b7a0fb2 100644 --- a/src/lsim.cpp +++ b/src/lsim.cpp @@ -27,10 +27,12 @@ #include #include #include +#include #include #include #include #include +#include #include "expdoublespinbox.h" #include "homoefieldwidget.h" @@ -78,6 +80,10 @@ void lsim::createActions() { acts.oglDisable->setStatusTip (tr ("OGL aus")); connect (acts.oglDisable, SIGNAL (triggered()), gview, SLOT (disableOGLViewport())); + acts.calculate = new QAction (tr ("Berechnen"), this); + acts.calculate->setStatusTip (tr ("Flugbahn berechnen")); + connect (acts.calculate, SIGNAL (triggered()), simulscene, SLOT (startCalculation())); + acts.timerStart = new QAction (tr ("Timer Start"), this); acts.timerStart->setStatusTip (tr ("Timer starten")); connect (acts.timerStart, SIGNAL (triggered()), simulscene, SLOT (startTimer())); @@ -117,14 +123,16 @@ void lsim::createActions() { } void lsim::createMenus() { - fileMenu = menuBar()->addMenu("Datei"); - fileMenu->addAction(acts.oglEnable); - fileMenu->addAction(acts.oglDisable); - fileMenu->addSeparator(); + fileMenu = menuBar()->addMenu(tr("Datei")); + fileMenu->addAction(acts.exitAct); - menuBar()->addMenu("Bearbeiten"); - menuBar()->addMenu("Ansicht"); - menuBar()->addMenu("Einstellungen"); + menuBar()->addMenu(tr("Bearbeiten")); + + viewMenu = menuBar()->addMenu(tr("Ansicht")); + viewMenu->addAction(acts.oglDisable); + viewMenu->addAction(acts.oglEnable); + + menuBar()->addMenu(tr("Einstellungen")); helpMenu = menuBar()->addMenu (tr ("&Help")); @@ -135,20 +143,21 @@ void lsim::createMenus() { void lsim::createToolBars() { fileToolBar = addToolBar (tr ("File")); - fileToolBar->addAction(acts.oglEnable); - fileToolBar->addAction(acts.oglDisable); + fileToolBar->addAction(acts.calculate); + fileToolBar->addSeparator(); + fileToolBar->addAction(acts.timerStart); + fileToolBar->addAction(acts.timerStop); + editToolBar = addToolBar (tr ("Edit")); - editToolBar->addAction(acts.timerStart); - editToolBar->addAction(acts.timerStop); - editToolBar->addSeparator(); + editToolBar->addAction(acts.itemEditModeAct); editToolBar->addAction(acts.insertEFieldItemAct); editToolBar->addAction(acts.insertBFieldItemAct); } void lsim::createStatusBar() { - statusBar()->showMessage (tr ("Ready")); + statusBar()->showMessage (tr ("Willkommen zu lsim")); } void lsim::createScene() { @@ -157,48 +166,91 @@ void lsim::createScene() { } void lsim::createDocks() { - QPushButton *button1 = new QPushButton("Loeschen"); - QPushButton *button2 = new QPushButton("calculate"); + //steps box + QSpinBox *steps_box = new QSpinBox; + steps_box->setRange(1, 2e+6); + steps_box->setKeyboardTracking(false); + steps_box->setValue(simulscene->getSteps()); + connect(steps_box, SIGNAL(valueChanged(int)),simulscene, SLOT(setSteps(int))); + connect(simulscene, SIGNAL(stepsChanged(int)),steps_box, SLOT(setValue(int))); + //time Per step Box ExpDoubleSpinBox *time_step_box = new ExpDoubleSpinBox; - time_step_box->setRange(-pow(10,66), pow(10,66)); - time_step_box->setDecimals(30); - time_step_box->setDisplayDecimals(10); + time_step_box->setRange(-pow(10,-100), pow(10,66)); + time_step_box->setDecimals(100); + time_step_box->setDisplayDecimals(3); time_step_box->setKeyboardTracking(false); - + time_step_box->setSuffix(" ms"); time_step_box->setValue(simulscene->getTimePerStep()); connect(time_step_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setTimePerStep(double))); connect(simulscene, SIGNAL(timePerStepChanged(double)),time_step_box, SLOT(setValue( double ))); - + + //meterPerPixel Box ExpDoubleSpinBox *meter_per_px_box = new ExpDoubleSpinBox; - 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->setRange(pow(10,-100), pow(10,66)); + meter_per_px_box->setDecimals(100); + meter_per_px_box->setDisplayDecimals(3); + meter_per_px_box->setSuffix(" m"); 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))); connect(simulscene, SIGNAL(meterPerPxChanged(double)),meter_per_px_box, SLOT(setValue( double ))); - QSlider *slider1 = new QSlider(); - slider1->setMinimum(0); - slider1->setMaximum(360); + //FlugbahnAnzeigeBox + QCheckBox *flight_path_box = new QCheckBox(""); + flight_path_box->setChecked(simulscene->isFlightPathVisible()); + connect(flight_path_box, SIGNAL(toggled(bool)),simulscene, SLOT(setFlightPathVisible(bool))); + connect(simulscene, SIGNAL(flightPathVisibilityChanged(bool)),flight_path_box, SLOT(setChecked(bool))); - connect (button1, SIGNAL(clicked()) , simulscene, SLOT(deleteSelectedFieldItems())); - connect (button2, SIGNAL(clicked()) , simulscene, SLOT(startCalculation())); + //timer laenge Box + QSpinBox *timer_box = new QSpinBox; + timer_box->setRange(1, 1e+10); + timer_box->setKeyboardTracking(false); + timer_box->setValue(simulscene->getTimeLineDuration()); + timer_box->setSuffix(" ms"); + connect(timer_box, SIGNAL(valueChanged(int)),simulscene, SLOT(setTimeLineDuration(int))); + connect(simulscene, SIGNAL(timeLineDurationChanged(int)),timer_box, SLOT(setValue(int))); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(button1); - layout->addWidget(button2); - layout->addWidget(slider1); - layout->addWidget(time_step_box); - layout->addWidget(meter_per_px_box); - QWidget *widget2 = new QWidget; - widget2->setLayout(layout); + + //description labels + 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 *flight_path_label = new QLabel(tr("Flugbahn anzeigen:")); + QLabel *timer_label = new QLabel(tr("L\344nge der Animation:")); + + //Scene settings Layout + QGridLayout *sceneGridLayout = new QGridLayout; + sceneGridLayout->addWidget(steps_label,0,0,Qt::AlignRight); + 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(flight_path_label,3,0,Qt::AlignRight); + sceneGridLayout->addWidget(flight_path_box,3,1); + sceneGridLayout->addWidget(timer_label,4,0,Qt::AlignRight); + sceneGridLayout->addWidget(timer_box,4,1); + + QGroupBox *sceneGroupBox = new QGroupBox(tr("Allgemeines")); + sceneGroupBox->setLayout(sceneGridLayout); + + QVBoxLayout *allgVBoxLayout = new QVBoxLayout(); + allgVBoxLayout->addWidget(sceneGroupBox); + allgVBoxLayout->addStretch(); + + QWidget *allgWidget = new QWidget; + allgWidget->setLayout(allgVBoxLayout); - //HomoEFieldWidget *eFieldOpt = new HomoEFieldWidget(0,0,qgraphicsitem_cast(simulscene->items().first())); - //HomoEFieldItem *homoitem = new HomoEFieldItem(QRectF(44,44,99,99)); + sceneDock = new QDockWidget(tr("Allgemeines"), this); + sceneDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + sceneDock->setWidget((allgWidget)); + addDockWidget(Qt::LeftDockWidgetArea, sceneDock); + + //************************************************************************** + fieldItemEditDock = new QDockWidget(tr("Feldeinstellungen"), this); fieldItemEditDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); @@ -207,11 +259,6 @@ void lsim::createDocks() { connect (simulscene, SIGNAL(selectionChanged ()) , this, SLOT(updateDockFieldWidget())); updateDockFieldWidget(); - dock_2 = new QDockWidget(tr("Ein Testdock 2"), this); - dock_2->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - dock_2->setWidget((widget2)); - addDockWidget(Qt::LeftDockWidgetArea, dock_2); - probeItemDock = new QDockWidget(tr("Probleladung"), this); probeItemDock->setWidget(simulscene->getProbeDockWidget()); @@ -219,8 +266,8 @@ void lsim::createDocks() { - tabifyDockWidget(dock_2,fieldItemEditDock); - tabifyDockWidget(fieldItemEditDock, probeItemDock); + tabifyDockWidget(probeItemDock,fieldItemEditDock); + tabifyDockWidget(fieldItemEditDock, sceneDock); setDockOptions(QMainWindow::VerticalTabs); } @@ -254,6 +301,7 @@ void lsim::setSceneMode(int mode) { */ } + lsim::~lsim() { } diff --git a/src/lsim.h b/src/lsim.h index adda2ba..d074dc5 100644 --- a/src/lsim.h +++ b/src/lsim.h @@ -68,6 +68,7 @@ class lsim: public QMainWindow { QMenu *fileMenu; QMenu *editMenu; QMenu *helpMenu; + QMenu *viewMenu; QToolBar *fileToolBar; QToolBar *editToolBar; @@ -78,6 +79,7 @@ class lsim: public QMainWindow { QAction *aboutQtAct; QAction *oglEnable; QAction *oglDisable; + QAction *calculate; QAction *timerStart; QAction *timerStop; @@ -93,7 +95,7 @@ class lsim: public QMainWindow { QDockWidget *fieldItemEditDock; QDockWidget *probeItemDock; - QDockWidget *dock_2; + QDockWidget *sceneDock; SimulScene *simulscene; }; diff --git a/src/simulscene.cpp b/src/simulscene.cpp index 7b76e52..0517191 100644 --- a/src/simulscene.cpp +++ b/src/simulscene.cpp @@ -39,10 +39,10 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { //variablen initialisieren - setTimePerStep(0.00001); - setSteps(210000); + setTimePerStep(1e-7); + setSteps(300000); //setMeterPerPx(1/1000.0); - setMeterPerPx(1); + setMeterPerPx(0.01); currHomoEfieldInsertItem = 0; currHomoEfieldEditItem = 0; @@ -587,7 +587,7 @@ void SimulScene::setTimePerStep(double time) { void SimulScene::startCalculation() { pathItem1->setPath(QPainterPath()); - //Feld Item Listen erzeugen + //Feld Item Listen erzeugen (viel schneller, als jedes mal items(point) durchlaufen) calcEFieldList.clear(); calcBFieldList.clear(); for(int i = 0; i < items().size(); ++i) { @@ -607,7 +607,6 @@ void SimulScene::startCalculation() { pathItem1->setPath(ellipse1->getFlightPath()); //animationspfad berechnen - time_t anitimeb = time(0); ani->clear(); int currSteps = ellipse1->getCurrProbePath()->count(); int entry_step = ceil(currSteps/2500.0); //jeder entry_step(te) step wird eingetragen @@ -616,10 +615,7 @@ void SimulScene::startCalculation() { if (i%entry_step == 0 || i==currSteps) { ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) ); } - //qDebug()<< getSteps(); } - time_t anitimea = time(0); - qDebug()<< "animationszeit" <isVisible() == visible) return; pathItem1->setVisible(visible); emit flightPathVisibilityChanged(visible); +} + +bool SimulScene::isFlightPathVisible() { + return pathItem1->isVisible(); +} + +void SimulScene::setTimeLineDuration(int duration) { + if(timer->duration() == duration) return; + timer->setDuration(duration); + emit timeLineDurationChanged(duration); +} + +int SimulScene::getTimeLineDuration() { + return timer->duration(); } \ No newline at end of file diff --git a/src/simulscene.h b/src/simulscene.h index 9232be2..a888f44 100644 --- a/src/simulscene.h +++ b/src/simulscene.h @@ -58,6 +58,9 @@ class SimulScene : public QGraphicsScene { double getPowerAt(QPointF point, double charge, double speedX, double speedY, char xy); QWidget* getProbeDockWidget() const; + + bool isFlightPathVisible(); + int getTimeLineDuration(); public slots: void setSceneMode(SceneMode mode); @@ -72,6 +75,8 @@ class SimulScene : public QGraphicsScene { void setMeterPerPx ( double theValue ); double getMeterPerPx() const; void setFlightPathVisible(bool visible = true); + void setTimeLineDuration(int duration); + private slots: @@ -85,6 +90,7 @@ class SimulScene : public QGraphicsScene { void timePerStepChanged(double timePerStep); void meterPerPxChanged(double meterPerPx); void flightPathVisibilityChanged(bool visible); + void timeLineDurationChanged(int duration); private: QTimeLine *timer;