2008-10-08 22:11:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2008 by Peter Dahlberg *
|
|
|
|
|
* pdahlberg@gmail.com *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#ifndef SIMULSCENE_H
|
|
|
|
|
#define SIMULSCENE_H
|
|
|
|
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
|
|
|
|
class QTimeLine;
|
|
|
|
|
class HomoEFieldItem;
|
2008-10-14 19:31:02 +00:00
|
|
|
class HomoBFieldItem;
|
2008-10-08 22:11:27 +00:00
|
|
|
class QGraphicsRectItem;
|
|
|
|
|
class QGraphicsItemGroup;
|
|
|
|
|
class GraphicsEllipseItem;
|
2008-10-11 23:16:51 +00:00
|
|
|
class QGraphicsItemAnimation;
|
2008-11-11 20:31:04 +00:00
|
|
|
class QGraphicsPathItem;
|
|
|
|
|
class QPainterPath;
|
2008-10-08 22:11:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@author Peter Dahlberg <pdahlberg@gmail.com>
|
|
|
|
|
*/
|
|
|
|
|
class SimulScene : public QGraphicsScene {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2008-10-14 19:31:02 +00:00
|
|
|
enum SceneMode {HomoEFieldItemInsert, FieldItemEdit, HomoBFieldItemInsert };
|
2008-10-08 22:11:27 +00:00
|
|
|
enum ItemType {ResizeRectItem};
|
|
|
|
|
SimulScene ( QObject* parent = 0);
|
|
|
|
|
qreal getHighestZIndexVisible(); //hoechsten z-index der sichtbaren items ausgeben
|
|
|
|
|
|
|
|
|
|
~SimulScene();
|
|
|
|
|
double getTimePerStep();
|
|
|
|
|
int getSteps();
|
|
|
|
|
|
|
|
|
|
//! gibt die Wirkende Kraft zurück (in Newton)
|
|
|
|
|
/*!
|
|
|
|
|
\param point der Punkt der abgeprüft werden soll
|
|
|
|
|
\param charge Die Ladung, auf die die Kraft ausgeübt wird
|
2008-10-18 16:03:06 +00:00
|
|
|
\param speedX Aktuelle Geschwindigkeit in x-Richtung
|
|
|
|
|
\param speedY Aktuelle Geschwindigkeit in y-Richtung
|
|
|
|
|
\param xy rückgabe in x oder y-Richtung
|
2008-10-08 22:11:27 +00:00
|
|
|
*/
|
2008-10-18 16:03:06 +00:00
|
|
|
double getPowerAt(QPointF point, double charge, double speedX, double speedY, char xy);
|
|
|
|
|
|
|
|
|
|
QWidget* getProbeDockWidget() const;
|
2008-11-13 22:10:20 +00:00
|
|
|
|
|
|
|
|
bool isFlightPathVisible();
|
|
|
|
|
int getTimeLineDuration();
|
2008-10-08 22:11:27 +00:00
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void setSceneMode(SceneMode mode);
|
|
|
|
|
void startTimer();
|
2008-11-02 20:34:58 +00:00
|
|
|
void stopTimer();
|
2008-10-08 22:11:27 +00:00
|
|
|
void deleteSelectedFieldItems();
|
|
|
|
|
void setTimePerStep(double time);
|
|
|
|
|
///starte die Berechnung der teilchenbahn(en)
|
|
|
|
|
void startCalculation();
|
|
|
|
|
void setSteps(int steps);
|
|
|
|
|
|
2008-10-14 19:31:02 +00:00
|
|
|
void setMeterPerPx ( double theValue );
|
|
|
|
|
double getMeterPerPx() const;
|
2008-11-11 20:31:04 +00:00
|
|
|
void setFlightPathVisible(bool visible = true);
|
2008-11-13 22:10:20 +00:00
|
|
|
void setTimeLineDuration(int duration);
|
|
|
|
|
|
2008-11-12 21:50:47 +00:00
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void displayResizeRects(bool move = false);
|
|
|
|
|
///does the same as displayResizeRects(true)
|
|
|
|
|
void moveResizeRects();
|
2008-11-11 20:31:04 +00:00
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
signals:
|
|
|
|
|
void sceneModeChanged(int mode);
|
|
|
|
|
void stepsChanged(int steps);
|
|
|
|
|
void timePerStepChanged(double timePerStep);
|
2008-10-11 23:16:51 +00:00
|
|
|
void meterPerPxChanged(double meterPerPx);
|
2008-11-11 20:31:04 +00:00
|
|
|
void flightPathVisibilityChanged(bool visible);
|
2008-11-13 22:10:20 +00:00
|
|
|
void timeLineDurationChanged(int duration);
|
2008-10-08 22:11:27 +00:00
|
|
|
private:
|
|
|
|
|
QTimeLine *timer;
|
2008-11-12 21:50:47 +00:00
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
SceneMode myMode;
|
|
|
|
|
|
|
|
|
|
///Zeit pro Step in ms
|
|
|
|
|
double timePerStep;
|
|
|
|
|
///anzahl der Steps
|
|
|
|
|
int steps;
|
|
|
|
|
///ein Pixel entspricht so viel meter
|
|
|
|
|
double meterPerPx;
|
2008-10-14 19:31:02 +00:00
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
HomoEFieldItem *currHomoEfieldInsertItem; //Aktuell erstelltes Item
|
|
|
|
|
HomoEFieldItem *currHomoEfieldEditItem;
|
2008-10-14 19:31:02 +00:00
|
|
|
|
|
|
|
|
HomoBFieldItem *currHomoBfieldInsertItem; //Aktuell erstelltes Item
|
|
|
|
|
HomoBFieldItem *currHomoBfieldEditItem;
|
|
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
QGraphicsItem *pressedResizeItem;
|
|
|
|
|
|
|
|
|
|
GraphicsEllipseItem *ellipse1;
|
2008-10-11 23:16:51 +00:00
|
|
|
QGraphicsItemAnimation *ani;
|
2008-11-11 20:31:04 +00:00
|
|
|
|
|
|
|
|
QGraphicsPathItem *pathItem1;
|
2008-10-08 22:11:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//rechtecke zur groesenaenderung
|
|
|
|
|
struct resizeRects {
|
|
|
|
|
QGraphicsRectItem *leftTopResizeItem;
|
|
|
|
|
QGraphicsRectItem *leftResizeItem;
|
|
|
|
|
QGraphicsRectItem *leftBottomResizeItem;
|
|
|
|
|
QGraphicsRectItem *bottomResizeItem;
|
|
|
|
|
QGraphicsRectItem *rightBottomResizeItem;
|
|
|
|
|
QGraphicsRectItem *rightRezizeItem;
|
|
|
|
|
QGraphicsRectItem *rightTopResizeItem;
|
|
|
|
|
QGraphicsRectItem *topResizeItem;
|
|
|
|
|
};
|
|
|
|
|
resizeRects reRects;
|
|
|
|
|
void createResizeRects();
|
|
|
|
|
|
|
|
|
|
void calculateItemResize(
|
|
|
|
|
QGraphicsSceneMouseEvent *mouseEvent,
|
|
|
|
|
QGraphicsRectItem *pressedRectItem,
|
|
|
|
|
QRectF &currRect,
|
|
|
|
|
QPointF &newPos,
|
|
|
|
|
qreal minWidth,
|
|
|
|
|
qreal minHeight
|
|
|
|
|
);
|
|
|
|
|
|
2008-11-13 15:17:17 +00:00
|
|
|
QList<HomoEFieldItem*> calcEFieldList;
|
|
|
|
|
QList<HomoBFieldItem*> calcBFieldList;
|
|
|
|
|
|
|
|
|
|
|
2008-10-08 22:11:27 +00:00
|
|
|
protected:
|
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
|
|
|
void keyPressEvent ( QKeyEvent * keyEvent );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|