stopper fertig

git-svn-id: http://svn.lsim.tuxzone.org/trunk@21 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
catdog2
2008-11-22 16:45:09 +00:00
parent cabf7af527
commit aa9a70cd8b
4 changed files with 20 additions and 1 deletions

View File

@@ -755,6 +755,7 @@ void SimulScene::startCalculation() {
//Feld Item Listen erzeugen (viel schneller, als jedes mal items(point) durchlaufen)
calcEFieldList.clear();
calcBFieldList.clear();
calcStopperList.clear();
for(int i = 0; i < items().size(); ++i) {
//HomoEFieldItems Abarbeiten
if (qgraphicsitem_cast<HomoEFieldItem*> (items().at(i)) != 0) {
@@ -764,6 +765,10 @@ void SimulScene::startCalculation() {
if (qgraphicsitem_cast<HomoBFieldItem*> (items().at(i)) != 0) {
calcBFieldList << qgraphicsitem_cast<HomoBFieldItem*>(items().at(i));
}
//StopperItems Abarbeiten
if (qgraphicsitem_cast<StopperItem*> (items().at(i)) != 0) {
calcStopperList << qgraphicsitem_cast<StopperItem*>(items().at(i));
}
}
@@ -850,6 +855,17 @@ double SimulScene::getPowerAt(QPointF point, double charge, double speedX, doubl
}
bool SimulScene::stopsHere(const QPointF &p1, const QPointF &p2) {
QPainterPath myPath(p1);
myPath.lineTo(p2);
for (int i = 0; i< calcStopperList.count(); ++i) {
QPainterPath itemPath = calcStopperList.at(i)->mapFromScene(myPath);
if (calcStopperList.at(i)->collidesWithPath(itemPath/*,Qt::IntersectsItemShape*/)) return true;
}
return false;
}
double SimulScene::getMeterPerPx() const {
return meterPerPx;
}