mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-25 00:39:58 +01:00
Il est desormais possible de poser des conducteurs en pointilles.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@773 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -467,8 +467,10 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
qp -> setBrush(conductor_brush);
|
qp -> setBrush(conductor_brush);
|
||||||
QPen final_conductor_pen = conductor_pen;
|
QPen final_conductor_pen = conductor_pen;
|
||||||
|
|
||||||
// modification du QPen generique pour lui affecter la couleur adequate
|
// modification du QPen generique pour lui affecter la couleur et le style adequats
|
||||||
final_conductor_pen.setColor(final_conductor_color);
|
final_conductor_pen.setColor(final_conductor_color);
|
||||||
|
final_conductor_pen.setStyle(properties_.style);
|
||||||
|
final_conductor_pen.setJoinStyle(Qt::SvgMiterJoin); // meilleur rendu des pointilles
|
||||||
|
|
||||||
// utilisation d'un trait "cosmetique" en-dessous d'un certain zoom
|
// utilisation d'un trait "cosmetique" en-dessous d'un certain zoom
|
||||||
if (options && options -> levelOfDetail < 1.0) {
|
if (options && options -> levelOfDetail < 1.0) {
|
||||||
@@ -518,8 +520,9 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
// dessine les eventuelles jonctions
|
// dessine les eventuelles jonctions
|
||||||
QList<QPointF> junctions_list = junctions();
|
QList<QPointF> junctions_list = junctions();
|
||||||
if (!junctions_list.isEmpty()) {
|
if (!junctions_list.isEmpty()) {
|
||||||
QBrush junction_brush(Qt::SolidPattern);
|
final_conductor_pen.setStyle(Qt::SolidLine);
|
||||||
junction_brush.setColor(final_conductor_color);
|
QBrush junction_brush(final_conductor_color, Qt::SolidPattern);
|
||||||
|
qp -> setPen(final_conductor_pen);
|
||||||
qp -> setBrush(junction_brush);
|
qp -> setBrush(junction_brush);
|
||||||
qp -> setRenderHint(QPainter::Antialiasing, true);
|
qp -> setRenderHint(QPainter::Antialiasing, true);
|
||||||
foreach(QPointF point, junctions_list) {
|
foreach(QPointF point, junctions_list) {
|
||||||
|
|||||||
@@ -187,7 +187,8 @@ void SingleLineProperties::fromXml(QDomElement &e) {
|
|||||||
ConductorProperties::ConductorProperties() :
|
ConductorProperties::ConductorProperties() :
|
||||||
type(Multi),
|
type(Multi),
|
||||||
color(Qt::black),
|
color(Qt::black),
|
||||||
text("_")
|
text("_"),
|
||||||
|
style(Qt::SolidLine)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +215,11 @@ void ConductorProperties::toXml(QDomElement &e) const {
|
|||||||
} else if (type == Multi) {
|
} else if (type == Multi) {
|
||||||
e.setAttribute("num", text);
|
e.setAttribute("num", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString conductor_style = writeStyle();
|
||||||
|
if (!conductor_style.isEmpty()) {
|
||||||
|
e.setAttribute("style", conductor_style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,6 +236,9 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
|||||||
color = QColor(Qt::black);
|
color = QColor(Qt::black);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lit le style du conducteur
|
||||||
|
readStyle(e.attribute("style"));
|
||||||
|
|
||||||
if (e.attribute("type") == typeToString(Single)) {
|
if (e.attribute("type") == typeToString(Single)) {
|
||||||
// recupere les parametres specifiques a un conducteur unifilaire
|
// recupere les parametres specifiques a un conducteur unifilaire
|
||||||
singleLineProperties.fromXml(e);
|
singleLineProperties.fromXml(e);
|
||||||
@@ -249,6 +258,7 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
|||||||
*/
|
*/
|
||||||
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
||||||
settings.setValue(prefix + "color", color.name());
|
settings.setValue(prefix + "color", color.name());
|
||||||
|
settings.setValue(prefix + "style", writeStyle());
|
||||||
settings.setValue(prefix + "type", typeToString(type));
|
settings.setValue(prefix + "type", typeToString(type));
|
||||||
settings.setValue(prefix + "text", text);
|
settings.setValue(prefix + "text", text);
|
||||||
singleLineProperties.toSettings(settings, prefix);
|
singleLineProperties.toSettings(settings, prefix);
|
||||||
@@ -277,6 +287,9 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
}
|
}
|
||||||
singleLineProperties.fromSettings(settings, prefix);
|
singleLineProperties.fromSettings(settings, prefix);
|
||||||
text = settings.value(prefix + "text", "_").toString();
|
text = settings.value(prefix + "text", "_").toString();
|
||||||
|
|
||||||
|
// lit le style du conducteur
|
||||||
|
readStyle(settings.value(prefix + "style").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,6 +312,7 @@ int ConductorProperties::operator==(const ConductorProperties &other) {
|
|||||||
return(
|
return(
|
||||||
other.type == type &&\
|
other.type == type &&\
|
||||||
other.color == color &&\
|
other.color == color &&\
|
||||||
|
other.color == style &&\
|
||||||
other.text == text &&\
|
other.text == text &&\
|
||||||
other.singleLineProperties == singleLineProperties
|
other.singleLineProperties == singleLineProperties
|
||||||
);
|
);
|
||||||
@@ -312,11 +326,49 @@ int ConductorProperties::operator!=(const ConductorProperties &other) {
|
|||||||
return(
|
return(
|
||||||
other.type != type ||\
|
other.type != type ||\
|
||||||
other.color != color ||\
|
other.color != color ||\
|
||||||
|
other.color != style ||\
|
||||||
other.text != text ||\
|
other.text != text ||\
|
||||||
other.singleLineProperties != singleLineProperties
|
other.singleLineProperties != singleLineProperties
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Applique les styles passes en parametre dans cet objet
|
||||||
|
@param style_string Chaine decrivant le style du conducteur
|
||||||
|
*/
|
||||||
|
void ConductorProperties::readStyle(const QString &style_string) {
|
||||||
|
style = Qt::SolidLine; // style par defaut
|
||||||
|
|
||||||
|
if (style_string.isEmpty()) return;
|
||||||
|
|
||||||
|
// recupere la liste des couples style / valeur
|
||||||
|
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
||||||
|
|
||||||
|
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
|
||||||
|
foreach (QString style_str, styles) {
|
||||||
|
if (rx.exactMatch(style_str)) {
|
||||||
|
QString style_name = rx.cap(1);
|
||||||
|
QString style_value = rx.cap(2);
|
||||||
|
if (style_name == "line-style") {
|
||||||
|
if (style_value == "dashed") style = Qt::DashLine;
|
||||||
|
else if (style_value == "normal") style = Qt::SolidLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Exporte le style du conducteur sous forme d'une chaine de caracteres
|
||||||
|
@return une chaine de caracteres decrivant le style du conducteur
|
||||||
|
*/
|
||||||
|
QString ConductorProperties::writeStyle() const {
|
||||||
|
if (style == Qt::DashLine) {
|
||||||
|
return("line-style: dashed;");
|
||||||
|
} else {
|
||||||
|
return(QString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
||||||
@return true si les deux ensembles de proprietes sont identiques, false sinon
|
@return true si les deux ensembles de proprietes sont identiques, false sinon
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class ConductorProperties {
|
|||||||
QColor color;
|
QColor color;
|
||||||
/// texte affiche si le conducteur est multifilaire
|
/// texte affiche si le conducteur est multifilaire
|
||||||
QString text;
|
QString text;
|
||||||
|
/// style du conducteur (Qt::SolidLine ou Qt::DashLine)
|
||||||
|
Qt::PenStyle style;
|
||||||
|
|
||||||
/// proprietes si le conducteur est unifilaire
|
/// proprietes si le conducteur est unifilaire
|
||||||
SingleLineProperties singleLineProperties;
|
SingleLineProperties singleLineProperties;
|
||||||
@@ -89,5 +91,9 @@ class ConductorProperties {
|
|||||||
// operateurs
|
// operateurs
|
||||||
int operator==(const ConductorProperties &);
|
int operator==(const ConductorProperties &);
|
||||||
int operator!=(const ConductorProperties &);
|
int operator!=(const ConductorProperties &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void readStyle(const QString &);
|
||||||
|
QString writeStyle() const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -102,10 +102,13 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
QHBoxLayout *color_layout = new QHBoxLayout();
|
QHBoxLayout *color_layout = new QHBoxLayout();
|
||||||
QLabel *text1 = new QLabel(tr("Couleur :"));
|
QLabel *text1 = new QLabel(tr("Couleur :"));
|
||||||
color_button = new QPushButton("");
|
color_button = new QPushButton("");
|
||||||
|
dashed_checkbox = new QCheckBox(tr("Trait en pointill\351s"));
|
||||||
|
|
||||||
color_layout -> addWidget(text1);
|
color_layout -> addWidget(text1);
|
||||||
color_layout -> addWidget(color_button);
|
color_layout -> addWidget(color_button);
|
||||||
|
|
||||||
setColorButton(properties_.color);
|
setColorButton(properties_.color);
|
||||||
|
dashed_checkbox -> setChecked(properties_.style == Qt::DashLine);
|
||||||
|
|
||||||
groupbox_layout -> addWidget(simple);
|
groupbox_layout -> addWidget(simple);
|
||||||
groupbox_layout -> addWidget(multiline);
|
groupbox_layout -> addWidget(multiline);
|
||||||
@@ -114,6 +117,7 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
groupbox_layout -> addLayout(singleline_layout1);
|
groupbox_layout -> addLayout(singleline_layout1);
|
||||||
|
|
||||||
groupbox2_layout -> addLayout(color_layout);
|
groupbox2_layout -> addLayout(color_layout);
|
||||||
|
groupbox2_layout -> addWidget(dashed_checkbox);
|
||||||
|
|
||||||
radio_buttons = new QButtonGroup(this);
|
radio_buttons = new QButtonGroup(this);
|
||||||
radio_buttons -> addButton(simple, ConductorProperties::Simple);
|
radio_buttons -> addButton(simple, ConductorProperties::Simple);
|
||||||
@@ -134,6 +138,7 @@ void ConductorPropertiesWidget::buildConnections() {
|
|||||||
connect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
connect(phase_slider, SIGNAL(valueChanged(int)), this, SLOT(updateConfig()));
|
||||||
connect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
connect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
||||||
connect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
connect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
||||||
|
connect(dashed_checkbox, SIGNAL(toggled(bool)), this, SLOT(updateConfig()));
|
||||||
connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +182,7 @@ void ConductorPropertiesWidget::destroyConnections() {
|
|||||||
disconnect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
disconnect(radio_buttons, SIGNAL(buttonClicked(int)), this, SLOT(updateConfig()));
|
||||||
disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
disconnect(text_field, SIGNAL(textChanged(const QString &)), this, SLOT(updateConfig()));
|
||||||
disconnect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
disconnect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor()));
|
||||||
|
disconnect(dashed_checkbox, SIGNAL(toggled(bool)), this, SLOT(updateConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -187,6 +193,7 @@ ConductorPropertiesWidget::~ConductorPropertiesWidget() {
|
|||||||
void ConductorPropertiesWidget::updateConfig() {
|
void ConductorPropertiesWidget::updateConfig() {
|
||||||
properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId());
|
properties_.type = static_cast<ConductorProperties::ConductorType>(radio_buttons -> checkedId());
|
||||||
properties_.color = colorButton();
|
properties_.color = colorButton();
|
||||||
|
properties_.style = dashed_checkbox -> isChecked() ? Qt::DashLine : Qt::SolidLine;
|
||||||
properties_.text = text_field -> text();
|
properties_.text = text_field -> text();
|
||||||
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
|
properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked();
|
||||||
properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked();
|
properties_.singleLineProperties.hasNeutral = neutral_checkbox -> isChecked();
|
||||||
@@ -201,6 +208,7 @@ void ConductorPropertiesWidget::updateDisplay() {
|
|||||||
|
|
||||||
setConductorType(properties_.type);
|
setConductorType(properties_.type);
|
||||||
setColorButton(properties_.color);
|
setColorButton(properties_.color);
|
||||||
|
dashed_checkbox -> setChecked(properties_.style == Qt::DashLine);
|
||||||
text_field -> setText(properties_.text);
|
text_field -> setText(properties_.text);
|
||||||
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
|
ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround);
|
||||||
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
|
neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral);
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class ConductorPropertiesWidget : public QWidget {
|
|||||||
QCheckBox *neutral_checkbox;
|
QCheckBox *neutral_checkbox;
|
||||||
QLabel *preview;
|
QLabel *preview;
|
||||||
QPushButton *color_button;
|
QPushButton *color_button;
|
||||||
|
QCheckBox *dashed_checkbox;
|
||||||
|
|
||||||
ConductorProperties properties_;
|
ConductorProperties properties_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user