HomoBFieldItem wird richtig als B-Feld gezeichnet
git-svn-id: http://svn.lsim.tuxzone.org/trunk@6 4bec179b-ab65-46ed-a5f8-55b8b5c735d0
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
|
HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
|
||||||
setRectF(sizeRect);
|
setRectF(sizeRect);
|
||||||
@@ -29,6 +30,7 @@ HomoBFieldItem::HomoBFieldItem(QRectF sizeRect): FieldItem() {
|
|||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
setFlag(ItemIsFocusable);
|
setFlag(ItemIsFocusable);
|
||||||
setOuterPenWidth (2);
|
setOuterPenWidth (2);
|
||||||
|
setIsDirectionIntoPlane(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +55,55 @@ void HomoBFieldItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* op
|
|||||||
if (isSelected()) painter->setBrush(Qt::Dense6Pattern); //selection deutlich machen
|
if (isSelected()) painter->setBrush(Qt::Dense6Pattern); //selection deutlich machen
|
||||||
painter->drawRect(sizeRect);
|
painter->drawRect(sizeRect);
|
||||||
|
|
||||||
for (int i = 1; i <= floor(sizeRect.width()/(qreal)fieldLineDistance); ++i) {
|
const int x_arrow_width = 8; //laenge und breite des Pfeils
|
||||||
|
const int circle_arrow_width = 12; //laenge u. breite des kreispfeiles
|
||||||
|
|
||||||
|
int arrow_width;
|
||||||
|
if (getIsDirectionIntoPlane()) arrow_width = x_arrow_width;
|
||||||
|
else arrow_width = circle_arrow_width; //arrow width an das jeweilige anpassen
|
||||||
|
for (int y = 1; y <= floor(sizeRect.height()/(qreal)(getFieldLineDistance()+arrow_width)); ++y ) {
|
||||||
|
//unten ueberstehen verhindern
|
||||||
|
if (-abs(sizeRect.y()) + y*getFieldLineDistance() + y*arrow_width >= sizeRect.height()-4 ) break;
|
||||||
|
for (int x = 1; x <= floor(sizeRect.width()/(qreal)(getFieldLineDistance()+arrow_width)); ++x ) {
|
||||||
|
//rechts ueberstehen verhindern
|
||||||
|
if (-abs(sizeRect.x()) + x*getFieldLineDistance() + x*arrow_width >= sizeRect.width()-4 ) break;
|
||||||
|
if (getIsDirectionIntoPlane()) {
|
||||||
|
painter->drawLine(
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + (x-1)*arrow_width,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + (y-1)*arrow_width,
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + arrow_width + (x-1)*arrow_width,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + arrow_width + (y-1)*arrow_width
|
||||||
|
);
|
||||||
|
painter->drawLine(
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + arrow_width + (x-1)*arrow_width,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + (y-1)*arrow_width,
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + (x-1)*arrow_width,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + arrow_width + (y-1)*arrow_width
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
painter->drawEllipse(
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + (x-1)*arrow_width,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + (y-1)*arrow_width,
|
||||||
|
arrow_width,
|
||||||
|
arrow_width
|
||||||
|
);
|
||||||
|
painter->setBrush(linecolor);
|
||||||
|
painter->drawEllipse(
|
||||||
|
QPoint(
|
||||||
|
sizeRect.x() + x*getFieldLineDistance() + (x-1)*arrow_width + arrow_width/2.0,
|
||||||
|
sizeRect.y() + y*getFieldLineDistance() + (y-1)*arrow_width + arrow_width/2.0
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*for (int i = 1; i <= floor(sizeRect.width()/(qreal)fieldLineDistance); ++i) {
|
||||||
const int top_bottom_space = 10;
|
const int top_bottom_space = 10;
|
||||||
const int arrow_height = 8; //pfeilhoehe
|
const int arrow_height = 8; //pfeilhoehe
|
||||||
const int arrow_width_half = 3; //Halbe pfeilbreite
|
const int arrow_width_half = 3; //Halbe pfeilbreite
|
||||||
@@ -81,7 +131,7 @@ void HomoBFieldItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* op
|
|||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
//qDebug() << pos();
|
//qDebug() << pos();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int HomoBFieldItem::type() const {
|
int HomoBFieldItem::type() const {
|
||||||
@@ -111,3 +161,15 @@ void HomoBFieldItem::setOuterPenWidth ( double theValue ) {
|
|||||||
QWidget* HomoBFieldItem::getDockWidget() const {
|
QWidget* HomoBFieldItem::getDockWidget() const {
|
||||||
return new QWidget();
|
return new QWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool HomoBFieldItem::getIsDirectionIntoPlane() const {
|
||||||
|
return isDirectionIntoPlane;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HomoBFieldItem::setIsDirectionIntoPlane ( bool theValue ) {
|
||||||
|
if(isDirectionIntoPlane == theValue) return;
|
||||||
|
isDirectionIntoPlane = theValue;
|
||||||
|
emit directionChanged(theValue);
|
||||||
|
}
|
||||||
|
|||||||
@@ -46,17 +46,23 @@ class HomoBFieldItem : public FieldItem {
|
|||||||
QWidget* getDockWidget() const;
|
QWidget* getDockWidget() const;
|
||||||
|
|
||||||
double getOuterPenWidth() const;
|
double getOuterPenWidth() const;
|
||||||
|
bool getIsDirectionIntoPlane() const;
|
||||||
public slots:
|
public slots:
|
||||||
void setOuterPenWidth ( double theValue );
|
void setOuterPenWidth ( double theValue );
|
||||||
void setFieldLineDistance ( int theValue );
|
void setFieldLineDistance ( int theValue );
|
||||||
|
void setIsDirectionIntoPlane ( bool theValue );
|
||||||
|
signals:
|
||||||
|
void directionChanged(bool theValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Abstand der Feldlinien in der Zeichnung
|
//! Abstand der Feldlinien in der Zeichnung
|
||||||
int fieldLineDistance;
|
int fieldLineDistance;
|
||||||
|
|
||||||
double outerPenWidth;
|
double outerPenWidth;
|
||||||
|
|
||||||
|
//! Gibt an, ob das Feld in die Ebene Zeigt oder heraus (true == in die Ebene)
|
||||||
|
bool isDirectionIntoPlane;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ HEADERS += lsim.h \
|
|||||||
homoefielditem.h \
|
homoefielditem.h \
|
||||||
simulscene.h \
|
simulscene.h \
|
||||||
expdoublespinbox.h \
|
expdoublespinbox.h \
|
||||||
lsim_interface.h \
|
|
||||||
homoefieldwidget.h \
|
homoefieldwidget.h \
|
||||||
constants.h \
|
constants.h \
|
||||||
probechargewidget.h \
|
probechargewidget.h \
|
||||||
|
|||||||
Reference in New Issue
Block a user