/*************************************************************************** * 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 "probechargewidget.h" #include "graphicsellipseitem.h" #include "expdoublespinbox.h" #include #include #include #include #include ProbeChargeWidget::ProbeChargeWidget ( QWidget* parent, Qt::WindowFlags f, GraphicsEllipseItem* ellipse ) : QWidget (parent, f ) { ellipseItem = ellipse; createWidget(); } ProbeChargeWidget::~ProbeChargeWidget() { } void ProbeChargeWidget::createWidget() { QDial *rotationDial = new QDial; rotationDial->setRange(0,359); rotationDial->setNotchesVisible(true); rotationDial->setWrapping(true); ExpDoubleSpinBox *startSpeedYBox = new ExpDoubleSpinBox; startSpeedYBox->setDecimals(50); startSpeedYBox->setDisplayDecimals(3); startSpeedYBox->setRange(-3e+8, 3e+8); startSpeedYBox->setKeyboardTracking(false); connect(startSpeedYBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setStartSpeedY(double)) ); connect(ellipseItem, SIGNAL(startSpeedYChanged(double)), startSpeedYBox, SLOT(setValue(double)) ); ExpDoubleSpinBox *startSpeedXBox = new ExpDoubleSpinBox; startSpeedXBox->setDecimals(50); startSpeedXBox->setDisplayDecimals(3); startSpeedXBox->setRange(-3e+8, 3e+8); startSpeedXBox->setKeyboardTracking(false); connect(startSpeedXBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setStartSpeedX(double)) ); connect(ellipseItem, SIGNAL(startSpeedXChanged(double)), startSpeedXBox, SLOT(setValue(double)) ); QLabel* xLabel = new QLabel(tr("x:")); QLabel* yLabel = new QLabel(tr("y:")); QLabel* startSpeedYLabel = new QLabel(tr("Startgeschwindigkeit y:")); QLabel* startSpeedXLabel = new QLabel(tr("Startgeschwindigkeit x:")); QDoubleSpinBox *posXBox = new QDoubleSpinBox; posXBox->setRange(-5000, 5000); posXBox->setKeyboardTracking(false); connect(posXBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setScenePosX(double)) ); connect(ellipseItem, SIGNAL(ScenePosXChanged(double)), posXBox, SLOT(setValue(double)) ); QDoubleSpinBox *posYBox = new QDoubleSpinBox; posYBox->setRange(-5000, 5000); posYBox->setKeyboardTracking(false); connect(posYBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setScenePosY(double)) ); connect(ellipseItem, SIGNAL(ScenePosYChanged(double)), posYBox, SLOT(setValue(double)) ); QGridLayout* geomGridLayout = new QGridLayout; //geomGridLayout->setSizeConstraint(QLayout::SetFixedSize); geomGridLayout->addWidget(startSpeedYBox,4,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(startSpeedYLabel,4,0,Qt::AlignRight); geomGridLayout->addWidget(startSpeedXLabel,3,0,Qt::AlignRight); geomGridLayout->addWidget(startSpeedXBox,3,1); //geomGridLayout->addWidget(rotationDial, 1,0,2,2); QGroupBox* geometryBox = new QGroupBox(tr("Geometrie")); geometryBox->setLayout(geomGridLayout); QLabel* chargeLabel = new QLabel(tr("Ladung:")); QLabel* masseLabel = new QLabel(tr("Masse:")); ExpDoubleSpinBox* chargeBox = new ExpDoubleSpinBox; chargeBox->setRange(-1e+200,1e+200); chargeBox->setDecimals(50); chargeBox->setDisplayDecimals(3); chargeBox->setKeyboardTracking(false); chargeBox->setSuffix(" As"); connect(chargeBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setCharge(double)) ); connect(ellipseItem, SIGNAL(chargeChanged(double)), chargeBox, SLOT(setValue(double)) ); ExpDoubleSpinBox* masseBox = new ExpDoubleSpinBox; masseBox->setRange(-1e+200,1e+200); masseBox->setDecimals(50); masseBox->setDisplayDecimals(3); masseBox->setKeyboardTracking(false); masseBox->setSuffix(" kg"); connect(masseBox, SIGNAL(valueChanged(double)), ellipseItem, SLOT(setMasse(double)) ); connect(ellipseItem, SIGNAL(masseChanged(double)), masseBox, SLOT(setValue(double)) ); QGridLayout* constGridLayout = new QGridLayout; //constGridLayout->setSizeConstraint(QLayout::SetFixedSize); constGridLayout->addWidget(chargeBox,0,1); constGridLayout->addWidget(masseBox,1,1); constGridLayout->addWidget(chargeLabel,0,0,Qt::AlignRight); constGridLayout->addWidget(masseLabel,1,0,Qt::AlignRight); QGroupBox* fieldConstantsBox = new QGroupBox(tr("Konstanten")); fieldConstantsBox->setLayout(constGridLayout); QVBoxLayout * mainLayout = new QVBoxLayout(this); mainLayout -> addWidget(geometryBox); mainLayout -> addWidget(fieldConstantsBox); mainLayout -> addStretch(); QWidget::setTabOrder (posXBox, posYBox); QWidget::setTabOrder (posYBox, startSpeedYBox); QWidget::setTabOrder (startSpeedYBox, startSpeedXBox); this -> setLayout(mainLayout); }