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

@@ -129,6 +129,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) {
speedListY->append(newspeedY);
if (i%path_entry_step == 0 || i==steps) flightPath.lineTo(newPoint);
if (myScene->stopsHere(currProbePath->at(i-1),newPoint)) break;
}
qDebug()<< difftime(time(0),start_time);

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;
}

View File

@@ -67,6 +67,7 @@ class SimulScene : public QGraphicsScene {
\param xy r&uuml;ckgabe in x oder y-Richtung
*/
double getPowerAt(QPointF point, double charge, double speedX, double speedY, char xy);
bool stopsHere(const QPointF &p1,const QPointF &p2);
QWidget* getProbeDockWidget() const;
@@ -171,6 +172,7 @@ class SimulScene : public QGraphicsScene {
QList<HomoEFieldItem*> calcEFieldList;
QList<HomoBFieldItem*> calcBFieldList;
QList<StopperItem*> calcStopperList;
static const qreal FieldDefaultZValue = 10.0; //default z-value fuer Felder
static const qreal FieldZStep = 1e-10; //schritt, um den der z-index erhoeht wird

View File

@@ -29,7 +29,7 @@
StopperItem::StopperItem(QPointF start, QPointF end): FieldItem() {
setLine(QLineF(start,end));
stopperWidget = new StopperWidget(0,0,this);
setOuterPenWidth (2);
setOuterPenWidth (0);
setFlag(ItemIsMovable);
setFlag(ItemIsSelectable);
setFlag(ItemIsFocusable);