initial commit of code tree
git-svn-id: http://svn.lsim.tuxzone.org/trunk@2 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
125
src/simulscene.h
Normal file
125
src/simulscene.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/***************************************************************************
|
||||
* 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;
|
||||
class QGraphicsRectItem;
|
||||
class QGraphicsItemGroup;
|
||||
class GraphicsEllipseItem;
|
||||
|
||||
/**
|
||||
@author Peter Dahlberg <pdahlberg@gmail.com>
|
||||
*/
|
||||
class SimulScene : public QGraphicsScene {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SceneMode {HomoEFieldItemInsert, FieldItemEdit };
|
||||
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
|
||||
\param xy x oder y-Richtung
|
||||
*/
|
||||
long double getPowerAt(QPointF point, long double charge, char xy);
|
||||
QWidget* getProbeDockWidget() const;
|
||||
|
||||
public slots:
|
||||
void setSceneMode(SceneMode mode);
|
||||
void startTimer();
|
||||
void deleteSelectedFieldItems();
|
||||
void setTimePerStep(double time);
|
||||
///starte die Berechnung der teilchenbahn(en)
|
||||
void startCalculation();
|
||||
void setSteps(int steps);
|
||||
|
||||
void setMeterPerPx ( double theValue );
|
||||
|
||||
|
||||
double getMeterPerPx() const;
|
||||
|
||||
private slots:
|
||||
void displayResizeRects(bool move = false);
|
||||
///does the same as displayResizeRects(true)
|
||||
void moveResizeRects();
|
||||
signals:
|
||||
void sceneModeChanged(int mode);
|
||||
void stepsChanged(int steps);
|
||||
void timePerStepChanged(double timePerStep);
|
||||
private:
|
||||
QTimeLine *timer;
|
||||
|
||||
SceneMode myMode;
|
||||
|
||||
///Zeit pro Step in ms
|
||||
double timePerStep;
|
||||
///anzahl der Steps
|
||||
int steps;
|
||||
///ein Pixel entspricht so viel meter
|
||||
double meterPerPx;
|
||||
HomoEFieldItem *currHomoEfieldInsertItem; //Aktuell erstelltes Item
|
||||
HomoEFieldItem *currHomoEfieldEditItem;
|
||||
QGraphicsItem *pressedResizeItem;
|
||||
|
||||
GraphicsEllipseItem *ellipse1;
|
||||
|
||||
|
||||
//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
|
||||
);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
void keyPressEvent ( QKeyEvent * keyEvent );
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user