ein paar kleinere verbesserungen

git-svn-id: http://svn.lsim.tuxzone.org/trunk@28 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
catdog2
2008-12-07 22:11:41 +00:00
parent 80bdc8f262
commit ff93559144
9 changed files with 94 additions and 25 deletions

View File

@@ -161,7 +161,7 @@
<lsim>/mnt/sdb1/c++/lsim</lsim> <lsim>/mnt/sdb1/c++/lsim</lsim>
</cwd> </cwd>
<debugarguments> <debugarguments>
<lsim/> <lsim></lsim>
</debugarguments> </debugarguments>
</run> </run>
<general> <general>

Binary file not shown.

View File

@@ -1,24 +1,24 @@
<?xml version = '1.0' encoding = 'UTF-8'?> <?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession> <!DOCTYPE KDevPrjSession>
<KDevPrjSession> <KDevPrjSession>
<DocsAndViews NumberOfDocuments="11" > <DocsAndViews NumberOfDocuments="15" >
<Doc0 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.h" > <Doc0 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.h" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="139" Type="Source" />
</Doc0> </Doc0>
<Doc1 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" > <Doc1 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/simulscene.cpp" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="110" Type="Source" />
</Doc1> </Doc1>
<Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" > <Doc2 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.h" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="66" Type="Source" />
</Doc2> </Doc2>
<Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" > <Doc3 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/graphicsellipseitem.cpp" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="207" Type="Source" />
</Doc3> </Doc3>
<Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.h" > <Doc4 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.h" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="73" Type="Source" />
</Doc4> </Doc4>
<Doc5 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.cpp" > <Doc5 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/lsim.cpp" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" line="52" Type="Source" />
</Doc5> </Doc5>
<Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/probechargewidget.cpp" > <Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/probechargewidget.cpp" >
<View0 Encoding="" Type="Source" /> <View0 Encoding="" Type="Source" />
@@ -35,6 +35,18 @@
<Doc10 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.h" > <Doc10 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.h" >
<View0 Encoding="" line="25" Type="Source" /> <View0 Encoding="" line="25" Type="Source" />
</Doc10> </Doc10>
<Doc11 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/main.cpp" >
<View0 Encoding="" line="31" Type="Source" />
</Doc11>
<Doc12 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/application.qrc" >
<View0 Encoding="" line="17" Type="Source" />
</Doc12>
<Doc13 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/expdoublespinbox.h" >
<View0 Encoding="" line="44" Type="Source" />
</Doc13>
<Doc14 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/fielditem.cpp" >
<View0 Encoding="" line="122" Type="Source" />
</Doc14>
</DocsAndViews> </DocsAndViews>
<pluginList> <pluginList>
<kdevdebugger> <kdevdebugger>

View File

@@ -102,7 +102,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
currProbePath->append(startPoint); currProbePath->append(startPoint);
speedListX->append(startSpeedX); speedListX->append(startSpeedX);
speedListY->append(startSpeedY); speedListY->append(startSpeedY);
realSimulTime =0; realSimulTime = 0;
//startpunkt in den Pfad setzen //startpunkt in den Pfad setzen
flightPath = QPainterPath(startPoint); flightPath = QPainterPath(startPoint);
@@ -145,7 +145,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
currProbePath->append(newPoint); currProbePath->append(newPoint);
speedListX->append(newspeedX); speedListX->append(newspeedX);
speedListY->append(newspeedY); speedListY->append(newspeedY);
realSimulTime += timePerStep;
if (i%path_entry_step == 0 || i==steps) flightPath.lineTo(newPoint); if (i%path_entry_step == 0 || i==steps) flightPath.lineTo(newPoint);
@@ -252,3 +252,9 @@ void GraphicsEllipseItem::setFlightPath ( const QPainterPath& theValue ) {
if (flightPath==theValue) return; if (flightPath==theValue) return;
flightPath = theValue; flightPath = theValue;
} }
double GraphicsEllipseItem::getRealSimulTime() const {
return realSimulTime;
}

View File

@@ -50,6 +50,7 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
double getMasse(double speed = 0); double getMasse(double speed = 0);
QPainterPath getFlightPath() const; QPainterPath getFlightPath() const;
double getRealSimulTime() const;
protected: protected:
@@ -63,7 +64,7 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
///Liste Der Geschwindigkeitsanteile in y-richtung ///Liste Der Geschwindigkeitsanteile in y-richtung
QList<double> *speedListY; QList<double> *speedListY;
///Gesamtzeilt der der Simulation ///Gesamtzeilt der der Simulation
double *realSimulTime; double realSimulTime;
///Masse der Probeladung in kg ///Masse der Probeladung in kg
double masse; double masse;
///Ladung der Probleadung in As ///Ladung der Probleadung in As

View File

@@ -49,6 +49,7 @@ lsim::lsim() {
createStatusBar(); createStatusBar();
createDocks(); createDocks();
setMode(EditMode); setMode(EditMode);
connect(simulscene, SIGNAL(timeLineDurationChanged(int)),this, SLOT(timeLineDurationChangeWrapperToSec(int)));
} }
void lsim::closeEvent (QCloseEvent *event) { void lsim::closeEvent (QCloseEvent *event) {
@@ -233,17 +234,17 @@ void lsim::createMenus() {
void lsim::createToolBars() { void lsim::createToolBars() {
windowModeBar = new QToolBar(tr("Modus")); windowModeBar = new QToolBar(tr("Modus"));
windowModeBar->setIconSize(QSize(22,22)); windowModeBar->setIconSize(QSize(24,24));
windowModeBar->addAction(acts.editModeAct); windowModeBar->addAction(acts.editModeAct);
windowModeBar->addAction(acts.simulationModeAct); windowModeBar->addAction(acts.simulationModeAct);
timerControlBar = new QToolBar (tr ("Timer")); timerControlBar = new QToolBar (tr ("Timer"));
timerControlBar->setIconSize(QSize(22,22)); timerControlBar->setIconSize(QSize(24,24));
timerControlBar->addAction(acts.timerPause); timerControlBar->addAction(acts.timerPause);
timerControlBar->addAction(acts.timerStop); timerControlBar->addAction(acts.timerStop);
sceneModeBar = new QToolBar (tr ("Edit")); sceneModeBar = new QToolBar (tr ("Edit"));
sceneModeBar->setIconSize(QSize(22,22)); sceneModeBar->setIconSize(QSize(24,24));
sceneModeBar->addAction(acts.itemEditModeAct); sceneModeBar->addAction(acts.itemEditModeAct);
sceneModeBar->addAction(acts.insertEFieldItemAct); sceneModeBar->addAction(acts.insertEFieldItemAct);
sceneModeBar->addAction(acts.insertBFieldItemAct); sceneModeBar->addAction(acts.insertBFieldItemAct);
@@ -251,14 +252,13 @@ void lsim::createToolBars() {
sceneModeBar->addAction(acts.probeChargeItemPlaceAct); sceneModeBar->addAction(acts.probeChargeItemPlaceAct);
upDownBar = new QToolBar(tr("Feldanordnungsreihenfolge")); upDownBar = new QToolBar(tr("Feldanordnungsreihenfolge"));
upDownBar->setIconSize(QSize(20,20)); upDownBar->setIconSize(QSize(21,21));
upDownBar->addAction(acts.moveItemOnBottom); upDownBar->addAction(acts.moveItemOnBottom);
upDownBar->addAction(acts.moveItemDown); upDownBar->addAction(acts.moveItemDown);
upDownBar->addAction(acts.moveItemUp); upDownBar->addAction(acts.moveItemUp);
upDownBar->addAction(acts.moveItemOnTop); upDownBar->addAction(acts.moveItemOnTop);
addToolBar(windowModeBar); addToolBar(windowModeBar);
} }
void lsim::initWindowMode(WindowMode newMode) { void lsim::initWindowMode(WindowMode newMode) {
@@ -395,19 +395,27 @@ void lsim::createDocks() {
connect(simulscene, SIGNAL(flightPathVisibilityChanged(bool)),flight_path_box, SLOT(setChecked(bool))); connect(simulscene, SIGNAL(flightPathVisibilityChanged(bool)),flight_path_box, SLOT(setChecked(bool)));
//timer laenge Box //timer laenge Box
QSpinBox *timer_box = new QSpinBox; QDoubleSpinBox *timer_box = new QDoubleSpinBox;
timer_box->setRange(1.0, 1e+10); timer_box->setRange(1.0, 1e+10);
timer_box->setKeyboardTracking(false); timer_box->setDecimals(3);
timer_box->setValue(simulscene->getTimeLineDuration()); //timer_box->setKeyboardTracking(false);
timer_box->setSuffix(" ms"); timer_box->setValue(simulscene->getTimeLineDuration()/1000.0);
connect(timer_box, SIGNAL(valueChanged(int)),simulscene, SLOT(setTimeLineDuration(int))); timer_box->setSuffix(" s");
connect(timer_box, SIGNAL(valueChanged(double)),this, SLOT(timeLineDurationSetWrapperToMsec(double)));
connect(timer_box, SIGNAL(valueChanged(double)),acts.timerStop, SLOT(trigger()));
//connect(timer_box, SIGNAL(valueChanged(int)),simulscene, SLOT(stopTimer())); //connect(timer_box, SIGNAL(valueChanged(int)),simulscene, SLOT(stopTimer()));
connect(simulscene, SIGNAL(timeLineDurationChanged(int)),timer_box, SLOT(setValue(int))); connect(this, SIGNAL(timeLineDurationChangedSec(double)),timer_box, SLOT(setValue(double)));
//Echte simulationsdauer
QLabel *real_simul_time_shower = new QLabel(tr("keine Daten"));
real_simul_time_shower->setTextInteractionFlags(Qt::TextSelectableByMouse);
connect(simulscene, SIGNAL(realSimulTimeChanged(QString)),real_simul_time_shower, SLOT(setText(QString)));
//description labels //description labels
QLabel *flight_path_label = new QLabel(tr("Flugbahn anzeigen:")); QLabel *flight_path_label = new QLabel(tr("Flugbahn anzeigen:"));
QLabel *timer_label = new QLabel(tr("L\344nge der Animation:")); QLabel *timer_label = new QLabel(tr("L\344nge der Animation:"));
QLabel *real_simul_time_label = new QLabel(tr("\"Reale\" Simulationsdauer:"));
//grid layout //grid layout
QGridLayout *simulOptGridLayout = new QGridLayout; QGridLayout *simulOptGridLayout = new QGridLayout;
@@ -415,6 +423,8 @@ void lsim::createDocks() {
simulOptGridLayout->addWidget(flight_path_box,3,1); simulOptGridLayout->addWidget(flight_path_box,3,1);
simulOptGridLayout->addWidget(timer_label,4,0,Qt::AlignRight); simulOptGridLayout->addWidget(timer_label,4,0,Qt::AlignRight);
simulOptGridLayout->addWidget(timer_box,4,1); simulOptGridLayout->addWidget(timer_box,4,1);
simulOptGridLayout->addWidget(real_simul_time_label,5,0,Qt::AlignRight);
simulOptGridLayout->addWidget(real_simul_time_shower,5,1);
QGroupBox *simulOptGroupBox = new QGroupBox(tr("Allgemeines")); QGroupBox *simulOptGroupBox = new QGroupBox(tr("Allgemeines"));
simulOptGroupBox->setLayout(simulOptGridLayout); simulOptGroupBox->setLayout(simulOptGridLayout);
@@ -456,6 +466,14 @@ void lsim::createDocks() {
} }
void lsim::timeLineDurationChangeWrapperToSec(int length) {
emit timeLineDurationChangedSec((double)length/1000.0);
}
void lsim::timeLineDurationSetWrapperToMsec(double length) {
simulscene->setTimeLineDuration(int(length*1000));
}
void lsim::actModeSwitcher(QAction *action) { void lsim::actModeSwitcher(QAction *action) {
simulscene->setSceneMode((SimulScene::SceneMode)action->data().toInt()); simulscene->setSceneMode((SimulScene::SceneMode)action->data().toInt());
} }
@@ -525,11 +543,13 @@ void lsim::startCalculation() {
if (simulscene->getMeterPerPx() == 0) { if (simulscene->getMeterPerPx() == 0) {
QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Wegl\344nge pro Pixel darf nicht 0 sein!")); QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Wegl\344nge pro Pixel darf nicht 0 sein!"));
setMode(EditMode);
return; return;
} }
if (simulscene->getProbeChargeItem()->getMasse(0) == 0) { if (simulscene->getProbeChargeItem()->getMasse(0) == 0) {
QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Masse der Probeladung darf nicht 0 sein!")); QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Masse der Probeladung darf nicht 0 sein!"));
setMode(EditMode);
return; return;
} }
@@ -542,7 +562,7 @@ void lsim::startCalculation() {
statusBar()->clearMessage(); statusBar()->clearMessage();
} }
void lsim::startTimer() { void lsim::startTimer() {
if( qApp->focusWidget() !=0) qApp->focusWidget()->clearFocus(); clearAnyFocus();
simulscene->startTimer(); simulscene->startTimer();
} }
void lsim::handleDockLocationChange() { void lsim::handleDockLocationChange() {

View File

@@ -70,6 +70,9 @@ class lsim: public QMainWindow {
void clearAnyFocus(); void clearAnyFocus();
void resetAll(); void resetAll();
void timeLineDurationChangeWrapperToSec(int length);
void timeLineDurationSetWrapperToMsec(double length);
private: private:
void createActions(); void createActions();
void createMenus(); void createMenus();
@@ -134,6 +137,7 @@ class lsim: public QMainWindow {
WindowMode myMode; WindowMode myMode;
signals: signals:
void windowModeChanged(WindowMode mode); void windowModeChanged(WindowMode mode);
void timeLineDurationChangedSec(double duration);
}; };
#endif #endif

View File

@@ -39,7 +39,6 @@
#include <QListWidget> #include <QListWidget>
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
fieldListWidget = new QListWidget(); fieldListWidget = new QListWidget();
@@ -109,6 +108,7 @@ void SimulScene::setupVars() {
setSteps(300000); setSteps(300000);
//setMeterPerPx(1/1000.0); //setMeterPerPx(1/1000.0);
setMeterPerPx(0.01); setMeterPerPx(0.01);
setPxPerSec(90.0);
timer->setFrameRange(0,100); timer->setFrameRange(0,100);
timer->setUpdateInterval(30); timer->setUpdateInterval(30);
@@ -810,6 +810,16 @@ void SimulScene::startCalculation() {
ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) ); ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) );
} }
} }
//aenderungen bestimmter Werte bekanntgeben
QString realSimulTimeString(QLocale().toString(ellipse1->getRealSimulTime(),'g'));
realSimulTimeString.append(" s");
emit realSimulTimeChanged(realSimulTimeString);
//brauchbare Animationsdauer bestimmen
setTimeLineDuration(ellipse1->getFlightPath().length()/getPxPerSec() * 1000.0);
} }
@@ -894,6 +904,9 @@ double SimulScene::getMeterPerPx() const {
return meterPerPx; return meterPerPx;
} }
double SimulScene::getPxPerSec() const {
return pxPerSec;
}
void SimulScene::setMeterPerPx ( double theValue ) { void SimulScene::setMeterPerPx ( double theValue ) {
if (theValue == meterPerPx) return; if (theValue == meterPerPx) return;
@@ -901,6 +914,12 @@ void SimulScene::setMeterPerPx ( double theValue ) {
emit meterPerPxChanged(theValue); emit meterPerPxChanged(theValue);
} }
void SimulScene::setPxPerSec ( double theValue ) {
if (theValue == pxPerSec) return;
pxPerSec = theValue;
emit pxPerSecChanged(theValue);
}
/*! /*!
\fn SimulScene::getProbeDockWidget() const \fn SimulScene::getProbeDockWidget() const

View File

@@ -56,6 +56,8 @@ class SimulScene : public QGraphicsScene {
~SimulScene(); ~SimulScene();
double getTimePerStep(); double getTimePerStep();
double getMeterPerPx() const;
double getPxPerSec() const;
int getSteps(); int getSteps();
//! gibt die Wirkende Kraft zur&uuml;ck (in Newton) //! gibt die Wirkende Kraft zur&uuml;ck (in Newton)
@@ -94,7 +96,7 @@ class SimulScene : public QGraphicsScene {
void setSteps(int steps); void setSteps(int steps);
void setMeterPerPx ( double theValue ); void setMeterPerPx ( double theValue );
double getMeterPerPx() const; void setPxPerSec ( double theValue );
void setFlightPathVisible(bool visible = true); void setFlightPathVisible(bool visible = true);
void setTimeLineDuration(int duration); void setTimeLineDuration(int duration);
@@ -118,9 +120,11 @@ class SimulScene : public QGraphicsScene {
void stepsChanged(int steps); void stepsChanged(int steps);
void timePerStepChanged(double timePerStep); void timePerStepChanged(double timePerStep);
void meterPerPxChanged(double meterPerPx); void meterPerPxChanged(double meterPerPx);
void pxPerSecChanged(double pxps);
void flightPathVisibilityChanged(bool visible); void flightPathVisibilityChanged(bool visible);
void timeLineDurationChanged(int duration); void timeLineDurationChanged(int duration);
void timeLineInRunningState(bool yesno = false); void timeLineInRunningState(bool yesno = false);
void realSimulTimeChanged(QString theString);
private: private:
QTimeLine *timer; QTimeLine *timer;
@@ -132,6 +136,9 @@ class SimulScene : public QGraphicsScene {
int steps; int steps;
///ein Pixel entspricht so viel meter ///ein Pixel entspricht so viel meter
double meterPerPx; double meterPerPx;
///Animationsgescheindigkeit in px/s (durchschnittlich)
double pxPerSec;
HomoEFieldItem *currHomoEfieldInsertItem; //Aktuell erstelltes Item HomoEFieldItem *currHomoEfieldInsertItem; //Aktuell erstelltes Item
HomoEFieldItem *currHomoEfieldEditItem; HomoEFieldItem *currHomoEfieldEditItem;