2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2010-01-03 16:25:37 +00:00
|
|
|
Copyright 2006-2010 Xavier Guerrin
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech 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.
|
|
|
|
|
|
|
|
QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
#include "styleeditor.h"
|
|
|
|
#include "customelementgraphicpart.h"
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Constructeur
|
|
|
|
@param editor L'editeur d'element concerne
|
|
|
|
@param p La partie a editer
|
|
|
|
@param parent le Widget parent
|
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p, QWidget *parent) : ElementItemEditor(editor, parent), part(p) {
|
2007-06-30 17:41:07 +00:00
|
|
|
// couleur
|
|
|
|
color = new QButtonGroup(this);
|
2009-04-03 19:30:25 +00:00
|
|
|
color -> addButton(black_color = new QRadioButton(tr("Noir", "element part color")), CustomElementGraphicPart::BlackColor);
|
|
|
|
color -> addButton(white_color = new QRadioButton(tr("Blanc", "element part color")), CustomElementGraphicPart::WhiteColor);
|
2007-06-30 17:41:07 +00:00
|
|
|
|
|
|
|
// style
|
|
|
|
style = new QButtonGroup(this);
|
2009-04-03 19:30:25 +00:00
|
|
|
style -> addButton(normal_style = new QRadioButton(tr("Normal", "element part line style")), CustomElementGraphicPart::NormalStyle);
|
|
|
|
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351", "element part line style")), CustomElementGraphicPart::DashedStyle);
|
2007-06-30 17:41:07 +00:00
|
|
|
style -> button(part -> lineStyle()) -> setChecked(true);
|
|
|
|
|
|
|
|
// epaisseur
|
|
|
|
weight = new QButtonGroup(this);
|
2009-04-03 19:30:25 +00:00
|
|
|
weight -> addButton(none_weight = new QRadioButton(tr("Nulle", "element part weight")), CustomElementGraphicPart::NoneWeight);
|
|
|
|
weight -> addButton(thin_weight = new QRadioButton(tr("Fine", "element part weight")), CustomElementGraphicPart::ThinWeight);
|
|
|
|
weight -> addButton(normal_weight = new QRadioButton(tr("Normale", "element part weight")), CustomElementGraphicPart::NormalWeight);
|
2007-06-30 17:41:07 +00:00
|
|
|
|
|
|
|
// remplissage
|
|
|
|
filling = new QButtonGroup(this);
|
2009-04-03 19:30:25 +00:00
|
|
|
filling -> addButton(no_filling = new QRadioButton(tr("Aucun", "element part filling")), CustomElementGraphicPart::NoneFilling );
|
|
|
|
filling -> addButton(black_filling = new QRadioButton(tr("Noir", "element part filling")), CustomElementGraphicPart::BlackFilling);
|
|
|
|
filling -> addButton(white_filling = new QRadioButton(tr("Blanc", "element part filling")), CustomElementGraphicPart::WhiteFilling);
|
2007-06-30 17:41:07 +00:00
|
|
|
|
|
|
|
// antialiasing
|
|
|
|
antialiasing = new QCheckBox(tr("Antialiasing"));
|
|
|
|
|
|
|
|
updateForm();
|
|
|
|
|
|
|
|
main_layout = new QVBoxLayout();
|
|
|
|
main_layout -> addWidget(antialiasing);
|
|
|
|
|
|
|
|
main_layout -> addWidget(new QLabel("<u>" + tr("Trait :") + "</u> "));
|
|
|
|
|
|
|
|
QHBoxLayout *color_layout = new QHBoxLayout();
|
|
|
|
color_layout -> addWidget(new QLabel(tr("Couleur : ")));
|
|
|
|
color_layout -> addWidget(black_color);
|
|
|
|
color_layout -> addWidget(white_color);
|
|
|
|
color_layout -> addStretch();
|
|
|
|
main_layout -> addItem(color_layout);
|
|
|
|
|
|
|
|
QHBoxLayout *style_layout = new QHBoxLayout();
|
|
|
|
style_layout -> addWidget(new QLabel(tr("Style : ")));
|
|
|
|
style_layout -> addWidget(normal_style);
|
|
|
|
style_layout -> addWidget(dashed_style);
|
|
|
|
style_layout -> addStretch();
|
|
|
|
main_layout -> addItem(style_layout);
|
|
|
|
|
|
|
|
QHBoxLayout *weight_layout = new QHBoxLayout();
|
|
|
|
weight_layout -> addWidget(new QLabel(tr("\311paisseur : ")));
|
|
|
|
weight_layout -> addWidget(none_weight);
|
|
|
|
weight_layout -> addWidget(thin_weight);
|
|
|
|
weight_layout -> addWidget(normal_weight);
|
|
|
|
weight_layout -> addStretch();
|
|
|
|
main_layout -> addItem(weight_layout);
|
|
|
|
|
|
|
|
main_layout -> addWidget(new QLabel("<u>" + tr("Remplissage :") + "</u> "));
|
|
|
|
|
|
|
|
QHBoxLayout *filling_layout = new QHBoxLayout();
|
|
|
|
filling_layout -> addWidget(no_filling);
|
|
|
|
filling_layout -> addWidget(black_filling);
|
|
|
|
filling_layout -> addWidget(white_filling);
|
|
|
|
filling_layout -> addStretch();
|
|
|
|
main_layout -> addItem(filling_layout);
|
|
|
|
|
|
|
|
main_layout -> addStretch();
|
|
|
|
|
|
|
|
setLayout(main_layout);
|
|
|
|
}
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Destructeur
|
2007-06-30 17:41:07 +00:00
|
|
|
StyleEditor::~StyleEditor() {
|
|
|
|
}
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Met a jour le style de la partie a partir des donnees du formulaire
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
void StyleEditor::updatePart() {
|
|
|
|
// applique l'antialiasing
|
|
|
|
part -> setAntialiased(antialiasing -> isChecked());
|
|
|
|
|
|
|
|
// applique la couleur
|
|
|
|
part -> setColor(static_cast<CEGP::Color>(color -> checkedId()));
|
|
|
|
|
|
|
|
// applique le style
|
|
|
|
part -> setLineStyle(static_cast<CEGP::LineStyle>(style -> checkedId()));
|
|
|
|
|
|
|
|
// applique l'epaisseur
|
|
|
|
part -> setLineWeight(static_cast<CEGP::LineWeight>(weight -> checkedId()));
|
|
|
|
|
|
|
|
// applique le remplissage
|
|
|
|
part -> setFilling(static_cast<CEGP::Filling>(filling -> checkedId()));
|
|
|
|
}
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Met a jour l'antialiasing et cree un objet d'annulation
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::updatePartAntialiasing() { addChangePartCommand("style antialiasing", part, "antialias", antialiasing -> isChecked()); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Met a jour la couleur du trait et cree un objet d'annulation
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::updatePartColor() { addChangePartCommand("style couleur", part, "color", color -> checkedId()); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Met a jour le style du trait et cree un objet d'annulation
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::updatePartLineStyle() { addChangePartCommand("style ligne", part, "line-style", style -> checkedId()); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Met a jour l'epaisseur du trait et cree un objet d'annulation
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::updatePartLineWeight() { addChangePartCommand("style epaisseur", part, "line-weight", weight -> checkedId()); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// Met a jour la couleur de fond et cree un objet d'annulation
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::updatePartFilling() { addChangePartCommand("style remplissage", part, "filling", filling -> checkedId()); }
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Met a jour le formulaire d'edition
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
void StyleEditor::updateForm() {
|
2007-08-25 03:43:05 +00:00
|
|
|
activeConnections(false);
|
|
|
|
// lit l'antialiasing
|
2007-06-30 17:41:07 +00:00
|
|
|
antialiasing -> setChecked(part -> antialiased());
|
|
|
|
|
|
|
|
// lit la couleur
|
|
|
|
color -> button(part -> color()) -> setChecked(true);
|
|
|
|
|
|
|
|
// lit le style
|
|
|
|
style -> button(part -> lineStyle()) -> setChecked(true);
|
|
|
|
|
|
|
|
// lit l'epaisseur
|
|
|
|
weight -> button(part -> lineWeight()) -> setChecked(true);
|
|
|
|
|
|
|
|
// lit le remplissage
|
|
|
|
filling -> button(part -> filling()) -> setChecked(true);
|
2007-08-25 03:43:05 +00:00
|
|
|
activeConnections(true);
|
2007-06-30 17:41:07 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Ajoute un widget en bas de l'editeur de style
|
|
|
|
@param w Widget a inserer
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
void StyleEditor::appendWidget(QWidget *w) {
|
|
|
|
main_layout -> insertWidget(7, w);
|
|
|
|
}
|
2007-08-25 03:43:05 +00:00
|
|
|
|
2007-12-05 21:16:01 +00:00
|
|
|
/**
|
|
|
|
Active ou desactive les connexionx signaux/slots entre les widgets internes.
|
|
|
|
@param active true pour activer les connexions, false pour les desactiver
|
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
void StyleEditor::activeConnections(bool active) {
|
|
|
|
if (active) {
|
|
|
|
connect(color, SIGNAL(buttonClicked(int)), this, SLOT(updatePartColor()));
|
|
|
|
connect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
|
|
|
|
connect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
|
|
|
|
connect(filling, SIGNAL(buttonClicked(int)), this, SLOT(updatePartFilling()));
|
|
|
|
connect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
|
|
|
} else {
|
|
|
|
disconnect(color, SIGNAL(buttonClicked(int)), this, SLOT(updatePartColor()));
|
|
|
|
disconnect(style, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineStyle()));
|
|
|
|
disconnect(weight, SIGNAL(buttonClicked(int)), this, SLOT(updatePartLineWeight()));
|
|
|
|
disconnect(filling, SIGNAL(buttonClicked(int)), this, SLOT(updatePartFilling()));
|
|
|
|
disconnect(antialiasing, SIGNAL(stateChanged(int)), this, SLOT(updatePartAntialiasing()));
|
|
|
|
}
|
|
|
|
}
|