Probeladungsplatzierung hinzugefuegt, kleine verbesserungen

git-svn-id: http://svn.lsim.tuxzone.org/trunk@16 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
catdog2
2008-11-15 13:55:29 +00:00
parent 3dc80bdeb0
commit 12fd597883
9 changed files with 84 additions and 26 deletions

View File

@@ -48,6 +48,7 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) {
currHomoEfieldEditItem = 0;
currHomoBfieldInsertItem = 0;
currHomoBfieldEditItem = 0;
ChargePlacementInProgress = false;
createResizeRects();
@@ -124,6 +125,11 @@ void SimulScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) {
addItem(currHomoBfieldInsertItem);
QApplication::setOverrideCursor(QCursor(Qt::SizeFDiagCursor));
break;
case ProbeChargeItemPlace:
if (mouseEvent->button() != Qt::LeftButton) break; //benutze nur linke maustaste
ChargePlacementInProgress = true;
ellipse1->setPos(mouseEvent->scenePos());
break;
default:
if (itemAt(mouseEvent->scenePos())->data(0) == ResizeRectItem && mouseEvent->button()==Qt::LeftButton) {
pressedResizeItem = itemAt(mouseEvent->scenePos());
@@ -206,6 +212,11 @@ void SimulScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) {
//if(mouseEvent->scenePos() != mouseEvent->lastScenePos()) displayResizeRects(true);
}
else if (ChargePlacementInProgress) {
if (myMode == ProbeChargeItemPlace) {
ellipse1->setPos(mouseEvent->scenePos());
}
}
else {
QGraphicsScene::mouseMoveEvent(mouseEvent);
if (mouseEvent->buttons() == Qt::LeftButton)
@@ -295,6 +306,10 @@ void SimulScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) {
update();
QApplication::restoreOverrideCursor();
}
else if (ChargePlacementInProgress) {
ChargePlacementInProgress = false;
setSceneMode(FieldItemEdit);
}
pressedResizeItem = 0;
currHomoEfieldInsertItem = 0;
currHomoBfieldInsertItem = 0;
@@ -585,6 +600,10 @@ void SimulScene::setTimePerStep(double time) {
\fn SimulScene::startCalculation()
*/
void SimulScene::startCalculation() {
//evtl laufenden timer stoppen
stopTimer();
//leeren Pfad setezen
pathItem1->setPath(QPainterPath());
//Feld Item Listen erzeugen (viel schneller, als jedes mal items(point) durchlaufen)
@@ -611,7 +630,6 @@ void SimulScene::startCalculation() {
int currSteps = ellipse1->getCurrProbePath()->count();
int entry_step = ceil(currSteps/2500.0); //jeder entry_step(te) step wird eingetragen
for (int i=0; i<currSteps; ++i) {
if (i%entry_step == 0 || i==currSteps) {
ani->setPosAt(i/(double)currSteps, ellipse1->getCurrProbePath()->at(i) );
}
@@ -705,9 +723,9 @@ double SimulScene::getPowerAt(QPointF point, double charge, double speedX, doubl
double PowerRadAngle; //Winkel des Lorentzkraftvektors zur x-Achse im Bogenmass
if (myHomoBFieldItem->getIsDirectionIntoPlane()) {
PowerRadAngle = speedRadAngle + PI/2.0;
} else {
PowerRadAngle = speedRadAngle - PI/2.0;
} else {
PowerRadAngle = speedRadAngle + PI/2.0;
}
//qDebug()<< PowerRadAngle;