HomoBFieldWidget soweit erstmal fertig

git-svn-id: http://svn.lsim.tuxzone.org/trunk@8 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
catdog2
2008-10-15 20:23:41 +00:00
parent eab7792a79
commit 4c6bb8e3f6
6 changed files with 598 additions and 56 deletions

View File

@@ -31,8 +31,9 @@ HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
setFlag(ItemIsSelectable);
setFlag(ItemIsFocusable);
setOuterPenWidth (2);
setIsDirectionIntoPlane(true);
dockWidget = new HomoBFieldWidget(0,0,this);
setIsDirectionIntoPlane(true);
setFluxDensity(233);
}
@@ -172,6 +173,19 @@ bool HomoBFieldItem::getIsDirectionIntoPlane() const {
void HomoBFieldItem::setIsDirectionIntoPlane ( bool theValue ) {
if(isDirectionIntoPlane == theValue) return;
prepareGeometryChange();
isDirectionIntoPlane = theValue;
emit directionChanged(theValue);
}
double HomoBFieldItem::getFluxDensity() const {
return fluxDensity;
}
void HomoBFieldItem::setFluxDensity ( double theValue ) {
if(fluxDensity == theValue) return;
fluxDensity = theValue;
emit fluxDensityChanged(theValue);
}

View File

@@ -48,12 +48,17 @@ class HomoBFieldItem : public FieldItem {
double getOuterPenWidth() const;
bool getIsDirectionIntoPlane() const;
double getFluxDensity() const;
public slots:
void setOuterPenWidth ( double theValue );
void setFieldLineDistance ( int theValue );
void setIsDirectionIntoPlane ( bool theValue );
void setFluxDensity ( double theValue );
signals:
void directionChanged(bool theValue);
void fluxDensityChanged(double theValue);
private:
//! Abstand der Feldlinien in der Zeichnung
@@ -61,10 +66,15 @@ class HomoBFieldItem : public FieldItem {
double outerPenWidth;
//! Gibt an, ob das Feld in die Ebene Zeigt oder heraus (true == in die Ebene)
//! Gibt an, ob das Feld in die Ebene Zeigt oder heraus (true == in die Ebene hinein)
bool isDirectionIntoPlane;
HomoBFieldWidget* dockWidget;
///! Enthät die Magnetische Flussdichte B in Tesla
double fluxDensity;
};

View File

@@ -25,7 +25,8 @@
#include <QDial>
#include <QGroupBox>
#include <QLabel>
#include <QRadioButton>
#include <QButtonGroup>
HomoBFieldWidget::HomoBFieldWidget(QWidget* parent, Qt::WindowFlags f, HomoBFieldItem* bField):QWidget(parent, f) {
homoBField = bField;
@@ -33,11 +34,6 @@ HomoBFieldWidget::HomoBFieldWidget(QWidget* parent, Qt::WindowFlags f, HomoBFiel
}
void HomoBFieldWidget::createWidget() {
QDial *rotationDial = new QDial;
rotationDial->setRange(0,359);
rotationDial->setNotchesVisible(true);
rotationDial->setWrapping(true);
QDoubleSpinBox *heightBox = new QDoubleSpinBox;
heightBox->setRange(HomoBFieldItem::MinimumHeight, 5000);
@@ -53,7 +49,6 @@ void HomoBFieldWidget::createWidget() {
QLabel* yLabel = new QLabel(tr("y:"));
QLabel* widthLabel = new QLabel(tr("Breite(l):"));
QLabel* heightLabel = new QLabel(tr("H\366he(d):"));
QLabel* rotationLabel = new QLabel(tr("Rotation:"));
QDoubleSpinBox *posXBox = new QDoubleSpinBox;
posXBox->setRange(-5000, 5000);
@@ -65,60 +60,68 @@ void HomoBFieldWidget::createWidget() {
connect(homoBField ,SIGNAL(ScenePosYChanged(double)),posYBox, SLOT(setValue(double)) );
connect(posYBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setScenePosY(double)) );
QSpinBox* rotationBox = new QSpinBox;
rotationBox->setRange(0,359);
rotationBox->setSuffix("\260");
rotationBox->setWrapping(true);
//connect(rotationDial, SIGNAL(valueChanged(int)),rotationBox ,SIGNAL(valueChanged(int)) );
//connect(rotationDial, SIGNAL(valueChanged(int)),rotationBox,SLOT(setValue(int)) );
//connect(rotationBox, SIGNAL(valueChanged(int)),homoEField ,SLOT(setRotation(int)) );
//connect(rotationBox, SIGNAL(valueChanged(int)),rotationDial ,SLOT(setValue(int)) );
QGridLayout* geomGridLayout = new QGridLayout;
//geomGridLayout->setSizeConstraint(QLayout::SetFixedSize);
geomGridLayout->addWidget(heightBox,3,1);
geomGridLayout->addWidget(posYBox,1,1);
geomGridLayout->addWidget(posXBox,0,1);
geomGridLayout->addWidget(xLabel,0,0,Qt::AlignRight);
geomGridLayout->addWidget(yLabel,1,0,Qt::AlignRight);
geomGridLayout->addWidget(heightLabel,3,0,Qt::AlignRight);
geomGridLayout->addWidget(widthLabel,2,0,Qt::AlignRight);
geomGridLayout->addWidget(widthBox,2,1);
geomGridLayout->addWidget(heightBox,4,1);
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(heightLabel,4,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);
QLabel* fieldPowerLabel = new QLabel(tr("Feldst\344rke:"));
QLabel* voltageLabel = new QLabel(tr("Spannung:"));
ExpDoubleSpinBox* fieldPowerBox = new ExpDoubleSpinBox;
fieldPowerBox->setRange(-1e+200,1e+200);
connect(homoBField ,SIGNAL(fieldPowerChanged(double)),fieldPowerBox, SLOT(setValue(double)) );
connect(fieldPowerBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setFieldPower(double)) );
QLabel* fieldFluxDensityLabel = new QLabel(tr("Flussdichte(B):"));
ExpDoubleSpinBox* fieldFluxDensityBox = new ExpDoubleSpinBox;
fieldFluxDensityBox->setRange(-1e+200,1e+200);
connect(homoBField ,SIGNAL(fluxDensityChanged(double)),fieldFluxDensityBox, SLOT(setValue(double)) );
connect(fieldFluxDensityBox, SIGNAL(valueChanged(double)),homoBField ,SLOT(setFluxDensity(double)) );
QGridLayout* constGridLayout = new QGridLayout;
//constGridLayout->setSizeConstraint(QLayout::SetFixedSize);
constGridLayout->addWidget(fieldPowerBox,0,1);
constGridLayout->addWidget(fieldPowerLabel,0,0,Qt::AlignRight);
constGridLayout->addWidget(fieldFluxDensityBox,0,1);
constGridLayout->addWidget(fieldFluxDensityLabel,0,0,Qt::AlignRight);
QGroupBox* fieldConstantsBox = new QGroupBox(tr("Feldkonstanten"));
fieldConstantsBox->setLayout(constGridLayout);
QRadioButton* intoPlaneButton = new QRadioButton(tr("in die Ebene hinein"));
QRadioButton* outOfPlaneButton = new QRadioButton(tr("aus der Ebene heraus"));
connect(homoBField ,SIGNAL(directionChanged(bool)),intoPlaneButton, SLOT(setChecked(bool)) );
connect(intoPlaneButton, SIGNAL(toggled(bool)),homoBField ,SLOT(setIsDirectionIntoPlane(bool)) );
QButtonGroup* directionGroup = new QButtonGroup();
directionGroup->addButton(intoPlaneButton);
directionGroup->addButton(outOfPlaneButton);
QGridLayout* directionGridLayout = new QGridLayout;
directionGridLayout->addWidget(intoPlaneButton,0,0);
directionGridLayout->addWidget(outOfPlaneButton,1,0);
QGroupBox* fieldDirectionBox = new QGroupBox(tr("Feldrichtung"));
fieldDirectionBox->setLayout(directionGridLayout);
QVBoxLayout * mainLayout = new QVBoxLayout(this);
mainLayout -> addWidget(geometryBox);
mainLayout -> addWidget(fieldDirectionBox);
mainLayout -> addWidget(fieldConstantsBox);
mainLayout -> addStretch();
QWidget::setTabOrder (rotationBox, posXBox);
QWidget::setTabOrder (posXBox, posYBox);
QWidget::setTabOrder (posYBox, widthBox);
QWidget::setTabOrder (widthBox, heightBox);

View File

@@ -38,7 +38,7 @@ class HomoBFieldWidget : public QWidget
/*!
\param parent Parent Widget, see Qt Documentaion
\param f Window Flags, see Qt Documentaion
\param eField HomoBFieldItem, zu dem das HomoBFieldWidget zugeordnet werden soll
\param bField HomoBFieldItem, zu dem das HomoBFieldWidget zugeordnet werden soll
*/
HomoBFieldWidget(QWidget* parent, Qt::WindowFlags f, HomoBFieldItem* bField);

View File

@@ -105,7 +105,7 @@ void HomoEFieldWidget::createWidget()
geometryBox->setLayout(geomGridLayout);
QLabel* fieldPowerLabel = new QLabel(tr("Feldst\344rke:"));
QLabel* fieldPowerLabel = new QLabel(tr("Feldst\344rke(E):"));
QLabel* voltageLabel = new QLabel(tr("Spannung:"));
ExpDoubleSpinBox* fieldPowerBox = new ExpDoubleSpinBox;