From cabf7af52727fd3270ec5eae88797d07378ef2dd Mon Sep 17 00:00:00 2001 From: catdog2 Date: Fri, 21 Nov 2008 23:56:10 +0000 Subject: [PATCH] StopperItem fertig, wird aber noch nicht in berechnung einbezogen git-svn-id: http://svn.lsim.tuxzone.org/trunk@20 4bec179b-ab65-46ed-a5f8-55b8b5c735d0 --- lsim.kdevelop.pcs | Bin 118403 -> 135948 bytes lsim.kdevses | 42 +++++-------- src/fielditem.cpp | 2 + src/graphicsellipseitem.cpp | 15 ++--- src/homobfielditem.cpp | 11 ++++ src/homobfielditem.h | 2 + src/homoefielditem.cpp | 11 ++++ src/homoefielditem.h | 5 +- src/lsim.cpp | 35 +++++++++-- src/lsim.h | 1 + src/probechargewidget.cpp | 5 +- src/simulscene.cpp | 116 +++++++++++++++++++++++++++++++++++- src/simulscene.h | 11 +++- src/src.pro | 8 ++- src/stopperitem.cpp | 81 +++++++++++++++++++++++++ src/stopperitem.h | 61 +++++++++++++++++++ src/stopperwidget.cpp | 105 ++++++++++++++++++++++++++++++++ src/stopperwidget.h | 57 ++++++++++++++++++ 18 files changed, 519 insertions(+), 49 deletions(-) create mode 100644 src/stopperitem.cpp create mode 100644 src/stopperitem.h create mode 100644 src/stopperwidget.cpp create mode 100644 src/stopperwidget.h diff --git a/lsim.kdevelop.pcs b/lsim.kdevelop.pcs index a70360a491ee7e6975d9859448b3ca19260835ba..29f2656245a0f84404c35b03fa4ae957b676d0d4 100644 GIT binary patch delta 13006 zcmbU{30PIt)@R+za1Zxh2ASsz0xF0gh@zl^AaD@@XH=9?#Y8{`HB!N$%sJWV&IZG5 zFil0TiKZr*nU$sX8eX&3YqCLjfB$Q;=fBoI=U%|9-un;VVc)aYu-9ID4STP1RzKpn z@kw1igo7jBcmj#BAn%~E!3HPP9#WDt3QK- z6Lsd0Q#T~(Rd4RL5aL<$0e@Xq!hlpsx|qYZo|uZ@i!&tYt&dpA#fj{BaL|171uqGO zBv#zz$MWnP978USl)zy)B4@I^|8>!2{VU^y1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R2Qh*8C zuW?h|$lq0MN3)D-nU<*~MH$t*s+p}6BZWF!OxD>aOZEezR9}`#+T&s>FMW7SrD<;J zU@9@G&x(n>mbZ8!HJX^j!k_YjS!knKtrJ!J>CK~x;@nlMsNm1GJSym(JD+wwf4cLS zPp^BZ%S8!)%FA0qJ=>~VJZ0M`CCgdL=tlo*t3CncSah^2#e1p+qL86-vqD<$sjk(G dC%qF!iS5)yl(q~^E< - + - + - + - - - - - - - + + + + + + + - - + + - - + + - - - - - - - - - - - - @@ -53,7 +41,7 @@ - + diff --git a/src/fielditem.cpp b/src/fielditem.cpp index c71b07c..1235a62 100644 --- a/src/fielditem.cpp +++ b/src/fielditem.cpp @@ -20,6 +20,7 @@ #include "fielditem.h" #include "homoefielditem.h" #include "homobfielditem.h" +#include "stopperitem.h" #include "simulscene.h" #include #include @@ -47,6 +48,7 @@ bool FieldItem::isFieldItem(QGraphicsItem *item) { // ---- Definiert die FieldItem typen fieldItemTypes << HomoEFieldItem::Type; fieldItemTypes << HomoBFieldItem::Type; + fieldItemTypes << StopperItem::Type; // ---- for (int i=0; itype() == fieldItemTypes.at(i)) { diff --git a/src/graphicsellipseitem.cpp b/src/graphicsellipseitem.cpp index 156bd98..2d448ac 100644 --- a/src/graphicsellipseitem.cpp +++ b/src/graphicsellipseitem.cpp @@ -28,6 +28,7 @@ #include "probechargewidget.h" #include #include "constants.h" +#include GraphicsEllipseItem::GraphicsEllipseItem() { //setFlag(ItemIsMovable); @@ -106,17 +107,17 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) { time_t timea = time(0); debugTime += difftime(timea,timeb); - double newspeedX = speedListX->at(i-1) + (powerX/myMasse * (timePerStep/1000.0)); - double newspeedY = speedListY->at(i-1) + (powerY/myMasse * (timePerStep/1000.0)); + double newspeedX = speedListX->at(i-1) + (powerX/myMasse * timePerStep); + double newspeedY = speedListY->at(i-1) + (powerY/myMasse * timePerStep); //double deltaDistXconst = speedListX->at(i-1) * (timePerStep/1000.0); //v0*t //double deltaDistYconst = speedListY->at(i-1) * (timePerStep/1000.0); - double deltaDistXconst = (speedListX->at(i-1) + newspeedX)/2.0 * (timePerStep/1000.0); //v0*t - double deltaDistYconst = (speedListY->at(i-1) + newspeedY)/2.0 * (timePerStep/1000.0); //mittel zw alt,neu um fehler zu mindern + double deltaDistXconst = (speedListX->at(i-1) + newspeedX)/2.0 * timePerStep; //v0*t + double deltaDistYconst = (speedListY->at(i-1) + newspeedY)/2.0 * timePerStep; //mittel zw alt,neu um fehler zu mindern - double deltaDistXaccel = 0.5 * (powerX/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0)); // 1/2 * F/m * t*t - double deltaDistYaccel = 0.5 * (powerY/myMasse * (timePerStep/1000.0) * (timePerStep/1000.0)); + double deltaDistXaccel = 0.5 * (powerX/myMasse * timePerStep * timePerStep); // 1/2 * F/m * t*t + double deltaDistYaccel = 0.5 * (powerY/myMasse * timePerStep * timePerStep); double deltaDistX = (deltaDistXconst + deltaDistXaccel); double deltaDistY = (deltaDistYconst + deltaDistYaccel); @@ -131,7 +132,7 @@ void GraphicsEllipseItem::calculateProbePath(QPointF startPoint) { } qDebug()<< difftime(time(0),start_time); - qDebug()<< debugTime; + std::cout<< debugTime<ignore(); } + +bool HomoBFieldItem::contains(const QPointF point) { + mapFromScene (point); + return ( + (point.x() <= boundingRect().width()) && + (point.y() <= boundingRect().height()) && + (point.y() >=0) && + (point.x() >=0) + ); + +} diff --git a/src/homobfielditem.h b/src/homobfielditem.h index e90e728..fc14c07 100644 --- a/src/homobfielditem.h +++ b/src/homobfielditem.h @@ -41,6 +41,8 @@ class HomoBFieldItem : public FieldItem { virtual QRectF boundingRect() const; virtual QRectF getRectF() const; virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); + virtual bool contains(const QPointF point); + int type() const; int getFieldLineDistance() const; diff --git a/src/homoefielditem.cpp b/src/homoefielditem.cpp index 7bc69b3..e0e51ff 100644 --- a/src/homoefielditem.cpp +++ b/src/homoefielditem.cpp @@ -136,3 +136,14 @@ void HomoEFieldItem::setOuterPenWidth ( double theValue ) { if (outerPenWidth == theValue) return; outerPenWidth = theValue; } + +bool HomoEFieldItem::contains(const QPointF point) { + mapFromScene (point); + return ( + (point.x() <= boundingRect().width()) && + (point.y() <= boundingRect().height()) && + (point.y() >=0) && + (point.x() >=0) + ); + +} \ No newline at end of file diff --git a/src/homoefielditem.h b/src/homoefielditem.h index f4ef301..8c0efa6 100644 --- a/src/homoefielditem.h +++ b/src/homoefielditem.h @@ -50,14 +50,17 @@ class HomoEFieldItem : public FieldItem { \param pixel der Abstand */ virtual void setFieldLineDistance(int pixel); + virtual bool contains(const QPointF point); double getFieldPower() const; + double getOuterPenWidth() const; + public slots: void setFieldPower (double fieldPower ); void setOuterPenWidth ( double theValue ); - double getOuterPenWidth() const; + signals: void fieldPowerChanged(double fieldPower); diff --git a/src/lsim.cpp b/src/lsim.cpp index 13efcf9..c1829b1 100644 --- a/src/lsim.cpp +++ b/src/lsim.cpp @@ -141,6 +141,12 @@ void lsim::createActions() { acts.insertBFieldItemAct->setCheckable(true); acts.insertBFieldItemAct->setData(QVariant(SimulScene::HomoBFieldItemInsert)); + acts.insertStopperItemAct = new QAction (tr ("Stopper"), this); + acts.insertStopperItemAct->setStatusTip (tr ("Stopteil Einfuegen")); + acts.insertStopperItemAct->setCheckable(true); + acts.insertStopperItemAct->setData(QVariant(SimulScene::StopperItemInsert)); + + acts.probeChargeItemPlaceAct = new QAction (tr ("Ladung setzen"), this); acts.probeChargeItemPlaceAct->setStatusTip (tr ("Probeladung neu platzieren")); acts.probeChargeItemPlaceAct->setCheckable(true); @@ -150,6 +156,7 @@ void lsim::createActions() { modeChangeActGroup->addAction(acts.itemEditModeAct); modeChangeActGroup->addAction(acts.insertEFieldItemAct); modeChangeActGroup->addAction(acts.insertBFieldItemAct); + modeChangeActGroup->addAction(acts.insertStopperItemAct); modeChangeActGroup->addAction(acts.probeChargeItemPlaceAct); connect (modeChangeActGroup, SIGNAL (triggered(QAction*)), this, SLOT (actModeSwitcher(QAction*))); connect (simulscene, SIGNAL(sceneModeChanged(int)) , this, SLOT(setSceneMode(int))); @@ -187,6 +194,7 @@ void lsim::createToolBars() { editToolBar->addAction(acts.itemEditModeAct); editToolBar->addAction(acts.insertEFieldItemAct); editToolBar->addAction(acts.insertBFieldItemAct); + editToolBar->addAction(acts.insertStopperItemAct); editToolBar->addAction(acts.probeChargeItemPlaceAct); upDownToolBar=addToolBar(tr("updown")); @@ -210,7 +218,7 @@ void lsim::createDocks() { //steps box QSpinBox *steps_box = new QSpinBox; - steps_box->setRange(1, 2e+6); + steps_box->setRange(1, 5e+6); steps_box->setKeyboardTracking(false); steps_box->setValue(simulscene->getSteps()); connect(steps_box, SIGNAL(valueChanged(int)),simulscene, SLOT(setSteps(int))); @@ -222,7 +230,7 @@ void lsim::createDocks() { time_step_box->setDecimals(100); time_step_box->setDisplayDecimals(3); time_step_box->setKeyboardTracking(false); - time_step_box->setSuffix(" ms"); + time_step_box->setSuffix(" s"); time_step_box->setValue(simulscene->getTimePerStep()); connect(time_step_box, SIGNAL(valueChanged(double)),simulscene, SLOT(setTimePerStep(double))); connect(simulscene, SIGNAL(timePerStepChanged(double)),time_step_box, SLOT(setValue( double ))); @@ -339,8 +347,8 @@ void lsim::setSceneMode(int mode) { default: gview->unsetCursor(); - } -*/ + }*/ + } @@ -358,7 +366,7 @@ void lsim::updateDockFieldWidget() { QLabel* currLabel = new QLabel(tr("Bitte ein Feld ausw\344hlen")); currLabel->setWordWrap(true); currLabel->setAlignment(Qt::AlignCenter); - QWidget *currDockWidget =simulscene->getFieldListWidget(); + QWidget *currDockWidget =currLabel;//simulscene->getFieldListWidget(); if(simulscene->selectedItems().count() == 1) { QGraphicsItem *currItem = simulscene->selectedItems().first(); if (FieldItem::isFieldItem(currItem)) { @@ -372,7 +380,24 @@ void lsim::updateDockFieldWidget() { void lsim::startCalculation() { if( qApp->focusWidget() !=0) qApp->focusWidget()->clearFocus(); + + if (simulscene->getMeterPerPx() == 0) { + QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Wegl\344nge pro Pixel darf nicht 0 sein!")); + return; + } + + if (simulscene->getProbeChargeItem()->getMasse(0) == 0) { + QMessageBox::critical (this,tr("B\366ser Fehler!"),tr("Die Masse der Probeladung darf nicht 0 sein!")); + return; + } + + statusBar()->showMessage(tr("Berechne Flugbahn. Bitte Warten ...")); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + simulscene->startCalculation(); + + QApplication::restoreOverrideCursor(); + statusBar()->clearMessage(); } void lsim::startTimer() { if( qApp->focusWidget() !=0) qApp->focusWidget()->clearFocus(); diff --git a/src/lsim.h b/src/lsim.h index de30d3a..912805a 100644 --- a/src/lsim.h +++ b/src/lsim.h @@ -96,6 +96,7 @@ class lsim: public QMainWindow { QAction *itemEditModeAct; QAction *insertEFieldItemAct; QAction *insertBFieldItemAct; + QAction *insertStopperItemAct; QAction *probeChargeItemPlaceAct; }; Actions acts; diff --git a/src/probechargewidget.cpp b/src/probechargewidget.cpp index 400a90d..69699cf 100644 --- a/src/probechargewidget.cpp +++ b/src/probechargewidget.cpp @@ -25,6 +25,7 @@ #include #include #include +#include ProbeChargeWidget::ProbeChargeWidget ( QWidget* parent, Qt::WindowFlags f, GraphicsEllipseItem* ellipse ) : QWidget (parent, f ) { ellipseItem = ellipse; @@ -47,7 +48,7 @@ void ProbeChargeWidget::createWidget() ExpDoubleSpinBox *startSpeedYBox = new ExpDoubleSpinBox; startSpeedYBox->setDecimals(50); startSpeedYBox->setDisplayDecimals(3); - startSpeedYBox->setRange(-3e+8, 3e+8); + startSpeedYBox->setRange(-(SPEED_OF_LIGHT-pow(10,-100)), SPEED_OF_LIGHT-pow(10,-100)); startSpeedYBox->setSuffix(" m/s"); startSpeedYBox->setKeyboardTracking(false); connect(startSpeedYBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setStartSpeedY(double)) ); @@ -56,7 +57,7 @@ void ProbeChargeWidget::createWidget() ExpDoubleSpinBox *startSpeedXBox = new ExpDoubleSpinBox; startSpeedXBox->setDecimals(50); startSpeedXBox->setDisplayDecimals(3); - startSpeedXBox->setRange(-3e+8, 3e+8); + startSpeedXBox->setRange(-(SPEED_OF_LIGHT-pow(10,-100)), SPEED_OF_LIGHT-pow(10,-100)); startSpeedXBox->setSuffix(" m/s"); startSpeedXBox->setKeyboardTracking(false); connect(startSpeedXBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setStartSpeedX(double)) ); diff --git a/src/simulscene.cpp b/src/simulscene.cpp index 455c20a..fb7672e 100644 --- a/src/simulscene.cpp +++ b/src/simulscene.cpp @@ -26,6 +26,7 @@ #include "graphicsellipseitem.h" #include "homoefielditem.h" #include "homobfielditem.h" +#include "stopperitem.h" #include #include #include @@ -40,7 +41,7 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { //variablen initialisieren - setTimePerStep(1e-7); + setTimePerStep(1e-10); setSteps(300000); //setMeterPerPx(1/1000.0); setMeterPerPx(0.01); @@ -51,6 +52,8 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { currHomoEfieldEditItem = 0; currHomoBfieldInsertItem = 0; currHomoBfieldEditItem = 0; + currStopperInsertItem = 0; + currStopperEditItem = 0; ChargePlacementInProgress = false; createResizeRects(); @@ -61,7 +64,6 @@ SimulScene::SimulScene ( QObject* parent ) : QGraphicsScene ( parent ) { //pathItem1->setCacheMode(QGraphicsItem::DeviceCoordinateCache); setFlightPathVisible(); - addLine(0,-298,0,298,QPen(Qt::green, 1, Qt::SolidLine) )->setCacheMode(QGraphicsItem::DeviceCoordinateCache); addLine(-398,0,398,0,QPen(Qt::green, 1, Qt::SolidLine) )->setCacheMode(QGraphicsItem::DeviceCoordinateCache); @@ -124,6 +126,13 @@ void SimulScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { addItem(currHomoEfieldInsertItem); QApplication::setOverrideCursor(QCursor(Qt::SizeFDiagCursor)); break; + case StopperItemInsert: + if (mouseEvent->button() != Qt::LeftButton) break; //benutze nur linke maustaste + currStopperInsertItem = new StopperItem(mouseEvent->scenePos() ,mouseEvent->scenePos()); + currStopperInsertItem->setZValue(getHighestZIndexFieldItems() + FieldZStep); //zValue setzen + addItem(currStopperInsertItem); + QApplication::setOverrideCursor(QCursor(Qt::SizeHorCursor)); + break; case HomoBFieldItemInsert: if (mouseEvent->button() != Qt::LeftButton) break; //benutze nur linke maustaste currHomoBfieldInsertItem = new HomoBFieldItem(QRectF(mouseEvent->scenePos(),mouseEvent->scenePos())); @@ -148,6 +157,10 @@ void SimulScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) { currHomoBfieldEditItem = qgraphicsitem_cast(selectedItems().first()); QApplication::setOverrideCursor(pressedResizeItem->cursor()); } + else if (selectedItems().first()->type() == StopperItem::Type) { + currStopperEditItem = qgraphicsitem_cast(selectedItems().first()); + QApplication::setOverrideCursor(pressedResizeItem->cursor()); + } } else { @@ -172,6 +185,17 @@ void SimulScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { } } + if (currStopperInsertItem != 0) { + if (myMode == StopperItemInsert) { + QPointF point(currStopperInsertItem->getRectF().x(), currStopperInsertItem->getRectF().y()); + update(currStopperInsertItem->getRectF()); + if(point.x() <= mouseEvent->scenePos().x() && point.y() <= mouseEvent->scenePos().y()) { + currStopperInsertItem->setLine(QLineF(point, QPointF(mouseEvent->scenePos().x(),point.y() ))); + + } + + } + } else if (currHomoBfieldInsertItem != 0) { if (myMode == HomoBFieldItemInsert) { QPointF point(currHomoBfieldInsertItem->getRectF().x(), currHomoBfieldInsertItem->getRectF().y()); @@ -218,6 +242,47 @@ void SimulScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) { //resize rechtecke mitverschieben --> macht jetzt schon das Widget //if(mouseEvent->scenePos() != mouseEvent->lastScenePos()) displayResizeRects(true); + } + else if (currStopperEditItem != 0 ) { + + QGraphicsRectItem *pressedRectItem = qgraphicsitem_cast(pressedResizeItem); + QRectF currRect = currStopperEditItem->getRectF(); + QPointF pos = currStopperEditItem->pos(); + + //calculateItemResize(mouseEvent,pressedRectItem,currRect,newPos,StopperItem::MinimumWidth,StopperItem::Height); + qreal mouseDistanceX = mouseEvent->scenePos().x() - mouseEvent->lastScenePos().x(); + + + //aenderungen uebernehmen + if ( + pressedResizeItem == reRects.rightRezizeItem || + pressedResizeItem == reRects.rightTopResizeItem || + pressedResizeItem == reRects.rightBottomResizeItem + ) { + QPointF newPos = QPointF(pos.x()+currRect.width()+mouseDistanceX , pos.y()); + if (newPos.x() - pos.x() >= StopperItem::MinimumWidth) { + currRect.adjust(0,0, (mouseDistanceX),0); + currStopperEditItem->setRectF(currRect); + + //currStopperEditItem->setLine(QLineF(pos, newPos )); + } + } else if ( + pressedResizeItem == reRects.leftResizeItem || + pressedResizeItem == reRects.leftTopResizeItem || + pressedResizeItem == reRects.leftBottomResizeItem + ) { + if ( pos.x() - pos.x()+currRect.width()-mouseDistanceX >= StopperItem::MinimumWidth) { + currRect.adjust(0,0,-mouseDistanceX,0); + currStopperEditItem->setPos(pos.x()+mouseDistanceX,pos.y()); + currStopperEditItem->setRectF(currRect); + + //currStopperEditItem->setLine(QLineF(pos, newPos )); + } + + } + //resize rechtecke mitverschieben --> macht jetzt schon das Widget + //if(mouseEvent->scenePos() != mouseEvent->lastScenePos()) displayResizeRects(true); + } else if (ChargePlacementInProgress) { if (myMode == ProbeChargeItemPlace) { @@ -304,6 +369,41 @@ void SimulScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { } update(); //moegliche darstellungsprobleme beseitigen QApplication::restoreOverrideCursor(); + } + else if (currStopperInsertItem != 0 && myMode == StopperItemInsert) { + if (currStopperInsertItem->getRectF().width() < StopperItem::MinimumWidth) { + //removeItem(currHomoEfieldInsertItem); //segmention fault in kombination mit delete? + delete currStopperInsertItem; //zu kleines feld loeschen + } else { + //setze Startpunkt des rechtecks auf 0,0, damit pos() richtig funktioniert + currStopperInsertItem->setVisible(false); //ausblenden, damit sich nix verschiebt + QRectF rect (currStopperInsertItem->getRectF()); + QPointF posPoint(rect.x(),rect.y()); + rect.setWidth(rect.width() - rect.x()); + rect.setHeight(rect.height() - rect.y()); + rect.setX(0); + rect.setY(0); + currStopperInsertItem->setRectF(rect); + currStopperInsertItem->setPos(posPoint); + currStopperInsertItem->setVisible(true); //und wieder einblenden + + + setSceneMode(FieldItemEdit); + //das neue item auswaehlen + clearSelection(); + currStopperInsertItem->setSelected(true); + + //die resize items aus und einblenden bei rotation + connect( currStopperInsertItem, SIGNAL(rotationChanged()), this, SLOT(displayResizeRects())); + //bei groesenanderung und verschieben resizerects mitverschieben + connect( currStopperInsertItem, SIGNAL(heightChanged(double)), this, SLOT(moveResizeRects())); + connect( currStopperInsertItem, SIGNAL(widthChanged(double)), this, SLOT(moveResizeRects())); + connect( currStopperInsertItem, SIGNAL(ScenePosChanged(QPointF)), this, SLOT(moveResizeRects())); + //item ueber sceneChange informieren + connect(this,SIGNAL(changed(QList)),currStopperInsertItem,SLOT(handleSceneChange(QList))); + } + update(); //moegliche darstellungsprobleme beseitigen + QApplication::restoreOverrideCursor(); } else if (currHomoEfieldEditItem != 0) { update(); @@ -313,6 +413,10 @@ void SimulScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { update(); QApplication::restoreOverrideCursor(); } + else if (currStopperEditItem != 0) { + update(); + QApplication::restoreOverrideCursor(); + } else if (ChargePlacementInProgress) { ChargePlacementInProgress = false; setSceneMode(FieldItemEdit); @@ -322,6 +426,8 @@ void SimulScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) { currHomoBfieldInsertItem = 0; currHomoEfieldEditItem = 0; currHomoBfieldEditItem = 0; + currStopperInsertItem = 0; + currStopperEditItem = 0; QGraphicsScene::mouseReleaseEvent(mouseEvent); } @@ -916,4 +1022,8 @@ void SimulScene::moveSelectedFieldItemOnTop() { void SimulScene::moveSelectedFieldItemOnBottom() { if (selectedItems().isEmpty()) return; moveFieldItemOnBottom(selectedItems().first()); -} \ No newline at end of file +} + +GraphicsEllipseItem* SimulScene::getProbeChargeItem() { + return ellipse1; +} diff --git a/src/simulscene.h b/src/simulscene.h index cf8061e..5472899 100644 --- a/src/simulscene.h +++ b/src/simulscene.h @@ -21,18 +21,19 @@ #define SIMULSCENE_H #include +#include class QTimeLine; class HomoEFieldItem; class HomoBFieldItem; class QGraphicsRectItem; class QGraphicsItemGroup; -class GraphicsEllipseItem; class QGraphicsItemAnimation; class QGraphicsPathItem; class QPainterPath; class QListWidget; class FieldItem; +class StopperItem; /** @author Peter Dahlberg @@ -44,6 +45,7 @@ class SimulScene : public QGraphicsScene { HomoEFieldItemInsert, FieldItemEdit, HomoBFieldItemInsert, + StopperItemInsert, ProbeChargeItemPlace }; enum ItemType {ResizeRectItem}; @@ -74,6 +76,8 @@ class SimulScene : public QGraphicsScene { QList getItemsInZOrder(); QList getFieldItemsInZOrder(); + GraphicsEllipseItem* getProbeChargeItem(); + public slots: void setSceneMode(SceneMode mode); void startTimer(); @@ -115,7 +119,7 @@ class SimulScene : public QGraphicsScene { SceneMode myMode; - ///Zeit pro Step in ms + ///Zeit pro Step in sekunden double timePerStep; ///anzahl der Steps int steps; @@ -128,6 +132,9 @@ class SimulScene : public QGraphicsScene { HomoBFieldItem *currHomoBfieldInsertItem; //Aktuell erstelltes Item HomoBFieldItem *currHomoBfieldEditItem; + StopperItem *currStopperInsertItem; //Aktuell erstelltes Item + StopperItem *currStopperEditItem; + bool ChargePlacementInProgress; //ladung wird gerade platziert QGraphicsItem *pressedResizeItem; diff --git a/src/src.pro b/src/src.pro index 0dda31e..a506314 100644 --- a/src/src.pro +++ b/src/src.pro @@ -9,7 +9,9 @@ SOURCES += lsim.cpp \ homoefieldwidget.cpp \ probechargewidget.cpp \ homobfielditem.cpp \ - homobfieldwidget.cpp + homobfieldwidget.cpp \ + stopperitem.cpp \ + stopperwidget.cpp HEADERS += lsim.h \ graphicsview.h \ graphicsellipseitem.h \ @@ -21,7 +23,9 @@ HEADERS += lsim.h \ constants.h \ probechargewidget.h \ homobfielditem.h \ - homobfieldwidget.h + homobfieldwidget.h \ + stopperitem.h \ + stopperwidget.h TEMPLATE = app CONFIG += warn_on \ thread \ diff --git a/src/stopperitem.cpp b/src/stopperitem.cpp new file mode 100644 index 0000000..347c7c1 --- /dev/null +++ b/src/stopperitem.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#include "stopperitem.h" +#include +#include +#include +#include +#include +#include "stopperwidget.h" + + +StopperItem::StopperItem(QPointF start, QPointF end): FieldItem() { + setLine(QLineF(start,end)); + stopperWidget = new StopperWidget(0,0,this); + setOuterPenWidth (2); + setFlag(ItemIsMovable); + setFlag(ItemIsSelectable); + setFlag(ItemIsFocusable); +} + + +StopperItem::~StopperItem() { + +} + +QRectF StopperItem::boundingRect() const { + return QRectF(sizeRect.x() - outerPenWidth, sizeRect.y() - outerPenWidth, + sizeRect.width() + outerPenWidth, sizeRect.height() + outerPenWidth); +} + +void StopperItem::setOuterPenWidth ( double theValue ) { + outerPenWidth = theValue; +} + + +double StopperItem::getOuterPenWidth() const { + return outerPenWidth; +} + +void StopperItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + QColor linecolor(172,214,255); + painter->setPen(linecolor); + if (isSelected()) { + painter->setBrush(Qt::Dense6Pattern); //selection deutlich machen + painter->drawRect(sizeRect); + } + + linecolor.setAlpha(188); + painter->setBrush(QBrush(linecolor)); + + painter->drawRect(sizeRect); +} + +int StopperItem::type() const { + return Type; +} + +QWidget* StopperItem::getDockWidget() const { + return stopperWidget; +} + +void StopperItem::setLine(QLineF line) { + setRectF(QRectF(line.p1(), QPointF(line.p2().x(),line.p2().y()+Height))); +} \ No newline at end of file diff --git a/src/stopperitem.h b/src/stopperitem.h new file mode 100644 index 0000000..8b288a3 --- /dev/null +++ b/src/stopperitem.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * 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 STOPPERITEM_H +#define STOPPERITEM_H + +#include + +/** + @author Peter Dahlberg +*/ +class QWidget; +class QPainter; +class QLineF; +class StopperWidget; +class StopperItem : public FieldItem +{ +Q_OBJECT +public: + enum {Type = UserType + 3}; + enum {MinimumWidth = 20}; + enum {Height = 10}; + StopperItem(QPointF start, QPointF end); + virtual QRectF boundingRect() const; + virtual void paint ( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + int type() const; + ///pointer auf das zugehoerige einstellungs Widget + QWidget* getDockWidget() const; + void setLine (QLineF line); + + ~StopperItem(); + + double getOuterPenWidth() const; + +public slots: + void setOuterPenWidth ( double theValue ); + + +private: + double outerPenWidth; + StopperWidget *stopperWidget; + +}; + +#endif diff --git a/src/stopperwidget.cpp b/src/stopperwidget.cpp new file mode 100644 index 0000000..f1ade1b --- /dev/null +++ b/src/stopperwidget.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#include "stopperwidget.h" +#include "stopperitem.h" +#include "expdoublespinbox.h" +#include +#include +#include +#include +#include +#include + +StopperWidget::StopperWidget(QWidget* parent, Qt::WindowFlags f, StopperItem* stopperI): QWidget() { + stopperItem = stopperI; + createWidget(); +} + + +StopperWidget::~StopperWidget() { +} + + + +void StopperWidget::createWidget() +{ + + QDoubleSpinBox *widthBox = new QDoubleSpinBox; + widthBox->setRange(StopperItem::MinimumWidth, 5000); + widthBox->setKeyboardTracking(false); + connect(stopperItem ,SIGNAL(widthChanged(double)),widthBox, SLOT(setValue(double)) ); + connect(widthBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setRectFWidth(double)) ); + + QLabel* xLabel = new QLabel(tr("x:")); + QLabel* yLabel = new QLabel(tr("y:")); + QLabel* widthLabel = new QLabel(tr("Breite:")); + QLabel* rotationLabel = new QLabel(tr("Rotation:")); + + QDoubleSpinBox *posXBox = new QDoubleSpinBox; + posXBox->setRange(-5000, 5000); + posXBox->setKeyboardTracking(false); + connect(stopperItem ,SIGNAL(ScenePosXChanged(double)),posXBox, SLOT(setValue(double)) ); + connect(posXBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setScenePosX(double)) ); + + QDoubleSpinBox *posYBox = new QDoubleSpinBox; + posYBox->setRange(-5000, 5000); + posYBox->setKeyboardTracking(false); + connect(stopperItem ,SIGNAL(ScenePosYChanged(double)),posYBox, SLOT(setValue(double)) ); + connect(posYBox, SIGNAL(valueChanged(double)),stopperItem ,SLOT(setScenePosY(double)) ); + + QSpinBox* rotationBox = new QSpinBox; + rotationBox->setRange(0,359); + rotationBox->setSuffix("\260"); + rotationBox->setWrapping(true); + rotationBox->setKeyboardTracking(false); + + connect(rotationBox, SIGNAL(valueChanged(int)),stopperItem ,SLOT(setRotation(int)) ); + connect(stopperItem, SIGNAL(rotationChanged(int)),rotationBox ,SLOT(setValue(int)) ); + + + QGridLayout* geomGridLayout = new QGridLayout; + //geomGridLayout->setSizeConstraint(QLayout::SetFixedSize); + + geomGridLayout->addWidget(rotationBox,0,1); + geomGridLayout->addWidget(posYBox,2,1); + geomGridLayout->addWidget(posXBox,1,1); + geomGridLayout->addWidget(xLabel,1,0,Qt::AlignRight); + geomGridLayout->addWidget(yLabel,2,0,Qt::AlignRight); + geomGridLayout->addWidget(widthLabel,3,0,Qt::AlignRight); + geomGridLayout->addWidget(rotationLabel,0,0,Qt::AlignRight); + geomGridLayout->addWidget(widthBox,3,1); + //geomGridLayout->addWidget(rotationDial, 1,0,2,2); + + QGroupBox* geometryBox = new QGroupBox(tr("Geometrie")); + geometryBox->setLayout(geomGridLayout); + + + + + QVBoxLayout * mainLayout = new QVBoxLayout(this); + mainLayout -> addWidget(geometryBox); + mainLayout -> addStretch(); + + QWidget::setTabOrder (rotationBox, posXBox); + QWidget::setTabOrder (posXBox, posYBox); + QWidget::setTabOrder (posYBox, widthBox); + + this -> setLayout(mainLayout); +} diff --git a/src/stopperwidget.h b/src/stopperwidget.h new file mode 100644 index 0000000..0a91065 --- /dev/null +++ b/src/stopperwidget.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * 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 STOPPERWIDGET_H +#define STOPPERWIDGET_H + +#include + +//! Dock Widget fuer die Eigenschaften von StopperItem +/** + auf diesem Widget befinden sich Steuerelemente, mit denen man + die Eigenschaften von einem StopperItem manipulieren kann. + + @author Peter Dahlberg +*/ + +class StopperItem; +class StopperWidget : public QWidget { + Q_OBJECT +public: + //! Erzeugt ein neues StopperWidget + /*! + \param parent Parent Widget, see Qt Documentaion + \param f Window Flags, see Qt Documentaion + \param eField StopperItem, zu dem das StopperWidget zugeordnet werden soll + */ + StopperWidget(QWidget* parent, Qt::WindowFlags f, StopperItem* stopperI); + + virtual ~StopperWidget(); + private: + //!enthält einen Zeiger auf das zugeordnete StopperItem + StopperItem* stopperItem; + //! Erstellt die Steuerelemente + /*! + Wird von Konstruktor aufgerufen, um die Steuerelemente zu erzeugen + */ + void createWidget(); + +}; + +#endif