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>
</cwd>
<debugarguments>
<lsim/>
<lsim></lsim>
</debugarguments>
</run>
<general>

Binary file not shown.

View File

@@ -1,24 +1,24 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="11" >
<DocsAndViews NumberOfDocuments="15" >
<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>
<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>
<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>
<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>
<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>
<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>
<Doc6 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/probechargewidget.cpp" >
<View0 Encoding="" Type="Source" />
@@ -35,6 +35,18 @@
<Doc10 NumberOfViews="1" URL="file:///mnt/sdb1/c%2B%2B/lsim/src/homobfieldwidget.h" >
<View0 Encoding="" line="25" Type="Source" />
</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>
<pluginList>
<kdevdebugger>

View File

@@ -145,7 +145,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
currProbePath->append(newPoint);
speedListX->append(newspeedX);
speedListY->append(newspeedY);
realSimulTime += timePerStep;
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;
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);
QPainterPath getFlightPath() const;
double getRealSimulTime() const;
protected:
@@ -63,7 +64,7 @@ class GraphicsEllipseItem : public QObject , public QGraphicsEllipseItem {
///Liste Der Geschwindigkeitsanteile in y-richtung
QList<double> *speedListY;
///Gesamtzeilt der der Simulation
double *realSimulTime;
double realSimulTime;
///Masse der Probeladung in kg
double masse;
///Ladung der Probleadung in As

View File

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

View File

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

View File

@@ -39,7 +39,6 @@
#include <QListWidget>
SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
fieldListWidget = new QListWidget();
@@ -109,6 +108,7 @@ void SimulScene::setupVars() {
setSteps(300000);
//setMeterPerPx(1/1000.0);
setMeterPerPx(0.01);
setPxPerSec(90.0);
timer->setFrameRange(0,100);
timer->setUpdateInterval(30);
@@ -810,6 +810,16 @@ void SimulScene::startCalculation() {
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;
}
double SimulScene::getPxPerSec() const {
return pxPerSec;
}
void SimulScene::setMeterPerPx ( double theValue ) {
if (theValue == meterPerPx) return;
@@ -901,6 +914,12 @@ void SimulScene::setMeterPerPx ( double theValue ) {
emit meterPerPxChanged(theValue);
}
void SimulScene::setPxPerSec ( double theValue ) {
if (theValue == pxPerSec) return;
pxPerSec = theValue;
emit pxPerSecChanged(theValue);
}
/*!
\fn SimulScene::getProbeDockWidget() const

View File

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