mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Conductor properties : Add two value, function and tension/protocol.
Revamp some widget to edit it. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4172 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
bda6d607b3
commit
1bdb13594b
@ -20,9 +20,9 @@
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "conductor.h"
|
||||
#include "diagram.h"
|
||||
#include "potentialtextsdialog.h"
|
||||
#include "qet.h"
|
||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "potentialselectordialog.h"
|
||||
|
||||
/**
|
||||
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation
|
||||
@ -51,31 +51,6 @@ void ConductorAutoNumerotation::numerate() {
|
||||
else if (conductor_ -> properties().type == ConductorProperties::Multi) numerateNewConductor();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorAutoNumerotation::checkPotential
|
||||
* Check if eah texts of this potential is identical.
|
||||
* If not, ask user how to numerate
|
||||
* @param conductor
|
||||
* A conductor of the potential to check.
|
||||
*/
|
||||
void ConductorAutoNumerotation::checkPotential(Conductor *conductor, QUndoCommand *parent) {
|
||||
//fill list of potential
|
||||
QSet <Conductor *> c_list = conductor->relatedPotentialConductors();
|
||||
c_list << conductor;
|
||||
//fill list of text
|
||||
QStringList strl;
|
||||
foreach (const Conductor *c, c_list) strl<<(c->text());
|
||||
|
||||
//check text list, isn't same in potential, ask user what to do
|
||||
if (!QET::eachStrIsEqual(strl)) {
|
||||
PotentialTextsDialog ptd(conductor, conductor->diagramEditor());
|
||||
if ( ptd.exec() == QDialog::Accepted ) {
|
||||
ConductorAutoNumerotation can(conductor, conductor -> diagram(), parent);
|
||||
can.applyText(ptd.selectedText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorAutoNumerotation::applyText
|
||||
* apply the text @t to @conductor_ and all conductors at the same potential
|
||||
@ -130,9 +105,8 @@ void ConductorAutoNumerotation::numeratePotential()
|
||||
//the texts isn't identicals
|
||||
else
|
||||
{
|
||||
PotentialTextsDialog ptd (conductor_, conductor_ -> diagramEditor());
|
||||
ptd.exec();
|
||||
applyText(ptd.selectedText());
|
||||
PotentialSelectorDialog psd(conductor_, m_parent_undo, conductor_->diagramEditor());
|
||||
psd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ class ConductorAutoNumerotation
|
||||
|
||||
//methods
|
||||
void numerate ();
|
||||
static void checkPotential (Conductor *conductor, QUndoCommand *parent = nullptr);
|
||||
void applyText (QString);
|
||||
|
||||
private:
|
||||
|
@ -241,18 +241,19 @@ ConductorProperties::~ConductorProperties() {
|
||||
* Export conductor propertie, in the XML element 'e'
|
||||
* @param e the xml element
|
||||
*/
|
||||
void ConductorProperties::toXml(QDomElement &e) const {
|
||||
void ConductorProperties::toXml(QDomElement &e) const
|
||||
{
|
||||
e.setAttribute("type", typeToString(type));
|
||||
|
||||
|
||||
if (color != QColor(Qt::black)) {
|
||||
if (color != QColor(Qt::black))
|
||||
e.setAttribute("color", color.name());
|
||||
}
|
||||
|
||||
if (type == Single) {
|
||||
if (type == Single)
|
||||
singleLineProperties.toXml(e);
|
||||
}
|
||||
|
||||
e.setAttribute("num", text);
|
||||
e.setAttribute("function", m_function);
|
||||
e.setAttribute("tension-protocol", m_tension_protocol);
|
||||
e.setAttribute("numsize", text_size);
|
||||
e.setAttribute("displaytext", m_show_text);
|
||||
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
||||
@ -260,9 +261,8 @@ void ConductorProperties::toXml(QDomElement &e) const {
|
||||
e.setAttribute("horizrotatetext", horiz_rotate_text);
|
||||
|
||||
QString conductor_style = writeStyle();
|
||||
if (!conductor_style.isEmpty()) {
|
||||
if (!conductor_style.isEmpty())
|
||||
e.setAttribute("style", conductor_style);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -271,35 +271,36 @@ void ConductorProperties::toXml(QDomElement &e) const {
|
||||
* Import conductor propertie, from the attribute of the xml element 'e'
|
||||
* @param e the xml document
|
||||
*/
|
||||
void ConductorProperties::fromXml(QDomElement &e) {
|
||||
// get conductor color
|
||||
void ConductorProperties::fromXml(QDomElement &e)
|
||||
{
|
||||
// get conductor color
|
||||
QColor xml_color= QColor(e.attribute("color"));
|
||||
if (xml_color.isValid()) {
|
||||
color = xml_color;
|
||||
} else {
|
||||
color = QColor(Qt::black);
|
||||
}
|
||||
color = (xml_color.isValid()? xml_color : QColor(Qt::black));
|
||||
|
||||
// read style of conductor
|
||||
// read style of conductor
|
||||
readStyle(e.attribute("style"));
|
||||
|
||||
if (e.attribute("type") == typeToString(Single)) {
|
||||
// get specific properties for single conductor
|
||||
if (e.attribute("type") == typeToString(Single))
|
||||
{
|
||||
// get specific properties for single conductor
|
||||
singleLineProperties.fromXml(e);
|
||||
type = Single;
|
||||
} else {
|
||||
type = Multi;
|
||||
}
|
||||
// get text field
|
||||
text = e.attribute("num");
|
||||
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
||||
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
||||
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
||||
else
|
||||
type = Multi;
|
||||
|
||||
//Keep retrocompatible with version older than 0,4
|
||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||
text = e.attribute("num");
|
||||
m_function = e.attribute("function");
|
||||
m_tension_protocol = e.attribute("tension-protocol");
|
||||
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
||||
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
||||
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
||||
|
||||
//Keep retrocompatible with version older than 0,4
|
||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||
//@TODO remove this code for qet 0.6 or later
|
||||
if (e.attribute("type") == "simple") m_show_text = false;
|
||||
}
|
||||
|
||||
@ -307,11 +308,14 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
||||
@param settings Parametres a ecrire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
*/
|
||||
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 + "style", writeStyle());
|
||||
settings.setValue(prefix + "type", typeToString(type));
|
||||
settings.setValue(prefix + "text", text);
|
||||
settings.setValue(prefix + "function", m_function);
|
||||
settings.setValue(prefix + "tension-protocol", m_tension_protocol);
|
||||
settings.setValue(prefix + "textsize", QString::number(text_size));
|
||||
settings.setValue(prefix + "displaytext", m_show_text);
|
||||
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
||||
@ -324,30 +328,25 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
||||
@param settings Parametres a lire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
*/
|
||||
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||
// recupere la couleur dans les parametres
|
||||
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix)
|
||||
{
|
||||
QColor settings_color = QColor(settings.value(prefix + "color").toString());
|
||||
if (settings_color.isValid()) {
|
||||
color = settings_color;
|
||||
} else {
|
||||
color = QColor(Qt::black);
|
||||
}
|
||||
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
|
||||
|
||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
||||
if (setting_type == typeToString(Single)) {
|
||||
type = Single;
|
||||
} else {
|
||||
type = Multi;
|
||||
}
|
||||
singleLineProperties.fromSettings(settings, prefix);
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
type = (setting_type == typeToString(Single)? Single : Multi);
|
||||
|
||||
singleLineProperties.fromSettings(settings, prefix);
|
||||
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_tension_protocol = settings.value(prefix + "tension-protocol", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
|
||||
// lit le style du conducteur
|
||||
readStyle(settings.value(prefix + "style").toString());
|
||||
}
|
||||
|
||||
@ -385,6 +384,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const{
|
||||
other.color == color &&\
|
||||
other.style == style &&\
|
||||
other.text == text &&\
|
||||
other.m_function == m_function &&\
|
||||
other.m_tension_protocol == m_tension_protocol &&\
|
||||
other.m_show_text == m_show_text &&\
|
||||
other.text_size == text_size &&\
|
||||
other.verti_rotate_text == verti_rotate_text &&\
|
||||
|
@ -61,56 +61,50 @@ class SingleLineProperties {
|
||||
This class represents the functional properties of a particular conductor,
|
||||
i.e. properties other than path and terminals.
|
||||
*/
|
||||
class ConductorProperties {
|
||||
// constructors, destructor
|
||||
class ConductorProperties
|
||||
{
|
||||
public:
|
||||
ConductorProperties();
|
||||
virtual ~ConductorProperties();
|
||||
ConductorProperties();
|
||||
virtual ~ConductorProperties();
|
||||
|
||||
/**
|
||||
Represents the kind of a particular conductor:
|
||||
* Simple: no symbols, no text input
|
||||
* Single: singleline symbols, no text input
|
||||
* Multi: text input, no symbol
|
||||
*/
|
||||
enum ConductorType { Single, Multi };
|
||||
|
||||
// attributes
|
||||
/// Conductor type
|
||||
ConductorType type;
|
||||
/// Conductor color
|
||||
QColor color;
|
||||
/// Texte displayed for multiline conductors
|
||||
QString text;
|
||||
/// size of text
|
||||
int text_size;
|
||||
/// rotation angle texte
|
||||
double verti_rotate_text;
|
||||
double horiz_rotate_text;
|
||||
bool m_show_text;
|
||||
bool m_one_text_per_folio;
|
||||
/// conducteur style (Qt::SolidLine or Qt::DashLine)
|
||||
Qt::PenStyle style;
|
||||
|
||||
/// properties for singleline conductors
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
// methods
|
||||
void toXml(QDomElement &) const;
|
||||
void fromXml(QDomElement &);
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
static QString typeToString(ConductorType);
|
||||
/**
|
||||
* @brief The ConductorType enum Represents the kind of a particular conductor:
|
||||
* Single: singleline symbols, no text input
|
||||
* Multi: text input, no symbol
|
||||
*/
|
||||
enum ConductorType { Single, Multi };
|
||||
|
||||
static ConductorProperties defaultProperties();
|
||||
|
||||
//Attributes
|
||||
ConductorType type;
|
||||
QColor color;
|
||||
QString text,
|
||||
m_function,
|
||||
m_tension_protocol;
|
||||
int text_size;
|
||||
double verti_rotate_text;
|
||||
double horiz_rotate_text;
|
||||
bool m_show_text;
|
||||
bool m_one_text_per_folio;
|
||||
Qt::PenStyle style;
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
// operators
|
||||
bool operator==(const ConductorProperties &) const;
|
||||
bool operator!=(const ConductorProperties &) const;
|
||||
// methods
|
||||
void toXml(QDomElement &) const;
|
||||
void fromXml(QDomElement &);
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
static QString typeToString(ConductorType);
|
||||
|
||||
static ConductorProperties defaultProperties();
|
||||
|
||||
// operators
|
||||
bool operator==(const ConductorProperties &) const;
|
||||
bool operator!=(const ConductorProperties &) const;
|
||||
|
||||
private:
|
||||
void readStyle(const QString &);
|
||||
QString writeStyle() const;
|
||||
void readStyle(const QString &);
|
||||
QString writeStyle() const;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ConductorProperties)
|
||||
|
@ -35,12 +35,13 @@ bool Conductor::pen_and_brush_initialized = false;
|
||||
QPen Conductor::conductor_pen = QPen();
|
||||
QBrush Conductor::conductor_brush = QBrush();
|
||||
QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param p1 Premiere Borne a laquelle le conducteur est lie
|
||||
@param p2 Seconde Borne a laquelle le conducteur est lie
|
||||
@param parent_diagram QGraphicsScene a laquelle appartient le conducteur
|
||||
*/
|
||||
* @brief Conductor::Conductor
|
||||
* Default constructor.
|
||||
* @param p1 : first terminal of this conductor.
|
||||
* @param p2 : second terminal of this conductor.
|
||||
*/
|
||||
Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
QObject(),
|
||||
QGraphicsPathItem(0),
|
||||
@ -57,7 +58,13 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
segments_squares_scale_(1.0),
|
||||
must_highlight_(Conductor::None)
|
||||
{
|
||||
//set Zvalue at 9 to be upper than the DiagramImageItem and bottom of element(10)
|
||||
//Set the default conductor properties.
|
||||
if (p1->diagram())
|
||||
properties_ = p1->diagram()->defaultConductorProperties;
|
||||
else if (p2->diagram())
|
||||
properties_ = p2->diagram()->defaultConductorProperties;
|
||||
|
||||
//set Zvalue at 9 to be upper than the DiagramImageItem and bottom of element(10)
|
||||
setZValue(9);
|
||||
previous_z_value = zValue();
|
||||
|
||||
@ -67,8 +74,9 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
//m_valid become false if the conductor can't be added to terminal (conductor already exist)
|
||||
m_valid = (!ajout_p1 || !ajout_p2) ? false : true;
|
||||
|
||||
// attributs de dessin par defaut (communs a tous les conducteurs)
|
||||
if (!pen_and_brush_initialized) {
|
||||
//Default attribut for paint a conductor
|
||||
if (!pen_and_brush_initialized)
|
||||
{
|
||||
conductor_pen.setJoinStyle(Qt::MiterJoin);
|
||||
conductor_pen.setCapStyle(Qt::SquareCap);
|
||||
conductor_pen.setColor(Qt::black);
|
||||
@ -79,13 +87,13 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
pen_and_brush_initialized = true;
|
||||
}
|
||||
|
||||
// par defaut, les 4 profils sont des profils nuls = il faut utiliser priv_calculeConductor
|
||||
//By default, the 4 profils are nuls -> we must to use priv_calculeConductor
|
||||
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::BottomLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
||||
|
||||
// calcul du rendu du conducteur
|
||||
//Generate the path of this conductor.
|
||||
generateConductorPath(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptHoverEvents(true);
|
||||
@ -1338,14 +1346,26 @@ void Conductor::setText(const QString &t) {
|
||||
/**
|
||||
* @brief Conductor::setProperties
|
||||
* Set new properties for this conductor
|
||||
* @param p : properties
|
||||
* Also change the common properties for every conductors at the same potential.
|
||||
* (text, function and tension/protocol) other value of properties isn't changed.
|
||||
* @param properties : properties
|
||||
*/
|
||||
void Conductor::setProperties(const ConductorProperties &p) {
|
||||
if (properties_ != p)
|
||||
void Conductor::setProperties(const ConductorProperties &properties)
|
||||
{
|
||||
if (properties_ == properties) return;
|
||||
|
||||
properties_ = properties;
|
||||
|
||||
foreach(Conductor *other_conductor, relatedPotentialConductors())
|
||||
{
|
||||
properties_ = p;
|
||||
readProperties();
|
||||
ConductorProperties other_properties = other_conductor->properties();
|
||||
other_properties.text = properties_.text;
|
||||
other_properties.m_function = properties_.m_function;
|
||||
other_properties.m_tension_protocol = properties_.m_tension_protocol;
|
||||
other_conductor->setProperties(other_properties);
|
||||
}
|
||||
|
||||
readProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,20 +105,20 @@ class Conductor : public QObject, public QGraphicsPathItem
|
||||
bool pathFromXml(const QDomElement &);
|
||||
|
||||
public:
|
||||
const QList<ConductorSegment *> segmentsList() const;
|
||||
void setProperties(const ConductorProperties &);
|
||||
ConductorProperties properties() const;
|
||||
void setProfile(const ConductorProfile &, Qt::Corner);
|
||||
ConductorProfile profile(Qt::Corner) const;
|
||||
void setProfiles(const ConductorProfilesGroup &);
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void readProperties();
|
||||
void calculateTextItemPosition();
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
QSet<Conductor *> relatedPotentialConductors(const bool all_diagram = true, QList <Terminal *> *t_list=0);
|
||||
QETDiagramEditor* diagramEditor() const;
|
||||
void editProperty ();
|
||||
const QList<ConductorSegment *> segmentsList() const;
|
||||
void setProperties(const ConductorProperties &properties);
|
||||
ConductorProperties properties() const;
|
||||
void setProfile(const ConductorProfile &, Qt::Corner);
|
||||
ConductorProfile profile(Qt::Corner) const;
|
||||
void setProfiles(const ConductorProfilesGroup &);
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void readProperties();
|
||||
void calculateTextItemPosition();
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
QSet<Conductor *> relatedPotentialConductors(const bool all_diagram = true, QList <Terminal *> *t_list=0);
|
||||
QETDiagramEditor* diagramEditor() const;
|
||||
void editProperty ();
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
@ -627,7 +627,6 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
new_conductor->setProperties(others_properties);
|
||||
else
|
||||
{
|
||||
new_conductor -> setProperties(diagram() -> defaultConductorProperties);
|
||||
//Autonum it
|
||||
ConductorAutoNumerotation can (new_conductor, diagram(), undo);
|
||||
can.numerate();
|
||||
|
@ -70,31 +70,14 @@ void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor, QWidget *
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
|
||||
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||
|
||||
if (!conductor->relatedPotentialConductors().isEmpty())
|
||||
if (!conductor->relatedPotentialConductors().isEmpty() && cpd.applyAll())
|
||||
{
|
||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
QString old_text = conductor->properties().text;
|
||||
QString new_text = cpd.properties().text;
|
||||
|
||||
foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
|
||||
{
|
||||
//"Apply to all conductors of potential" is checked,
|
||||
//we apply the new properties for every conductors in the same potential.
|
||||
if (cpd.applyAll())
|
||||
{
|
||||
old_value.setValue(potential_conductor->properties());
|
||||
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||
}
|
||||
//The num of conductor isn't affected by "Apply to all conductors of potential"
|
||||
//we always apply it to the potential if he change.
|
||||
else if(old_text != new_text)
|
||||
{
|
||||
old_value.setValue(potential_conductor->properties());
|
||||
ConductorProperties new_properties = potential_conductor->properties();
|
||||
new_properties.text = new_text;
|
||||
new_value.setValue(new_properties);
|
||||
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||
}
|
||||
old_value.setValue(potential_conductor->properties());
|
||||
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,8 @@ ConductorPropertiesWidget::~ConductorPropertiesWidget()
|
||||
* Set the properties
|
||||
* @param properties
|
||||
*/
|
||||
void ConductorPropertiesWidget::setProperties(const ConductorProperties &properties) {
|
||||
void ConductorPropertiesWidget::setProperties(const ConductorProperties &properties)
|
||||
{
|
||||
if (m_properties == properties) return;
|
||||
m_properties = properties;
|
||||
|
||||
@ -74,18 +75,20 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
|
||||
int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style));
|
||||
if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index);
|
||||
|
||||
ui -> m_text_le -> setText (m_properties.text);
|
||||
ui -> m_text_size_sb -> setValue (m_properties.text_size);
|
||||
ui -> m_show_text_cb -> setChecked (m_properties.m_show_text);
|
||||
ui -> m_one_text_per_folio_cb -> setChecked (m_properties.m_one_text_per_folio);
|
||||
ui -> m_earth_cb -> setChecked (m_properties.singleLineProperties.hasGround);
|
||||
ui -> m_neutral_cb -> setChecked (m_properties.singleLineProperties.hasNeutral);
|
||||
ui -> m_pen_cb -> setChecked (m_properties.singleLineProperties.isPen());
|
||||
ui -> m_phase_cb -> setChecked (m_properties.singleLineProperties.phasesCount());
|
||||
ui -> m_phase_slider -> setValue (m_properties.singleLineProperties.phasesCount());
|
||||
ui->m_text_le -> setText (m_properties.text);
|
||||
ui->m_function_le ->setText (m_properties.m_function);
|
||||
ui->m_tension_protocol_le ->setText (m_properties.m_tension_protocol);
|
||||
ui->m_text_size_sb -> setValue (m_properties.text_size);
|
||||
ui->m_show_text_cb -> setChecked (m_properties.m_show_text);
|
||||
ui->m_one_text_per_folio_cb -> setChecked (m_properties.m_one_text_per_folio);
|
||||
ui->m_earth_cb -> setChecked (m_properties.singleLineProperties.hasGround);
|
||||
ui->m_neutral_cb -> setChecked (m_properties.singleLineProperties.hasNeutral);
|
||||
ui->m_pen_cb -> setChecked (m_properties.singleLineProperties.isPen());
|
||||
ui->m_phase_cb -> setChecked (m_properties.singleLineProperties.phasesCount());
|
||||
ui->m_phase_slider -> setValue (m_properties.singleLineProperties.phasesCount());
|
||||
|
||||
m_verti_select -> setValue (m_properties.verti_rotate_text);
|
||||
m_horiz_select -> setValue (m_properties.horiz_rotate_text);
|
||||
m_verti_select -> setValue (m_properties.verti_rotate_text);
|
||||
m_horiz_select -> setValue (m_properties.horiz_rotate_text);
|
||||
|
||||
setConductorType(m_properties.type);
|
||||
updatePreview(false);
|
||||
@ -95,7 +98,8 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
|
||||
* @brief ConductorPropertiesWidget::properties
|
||||
* @return the edited properties
|
||||
*/
|
||||
ConductorProperties ConductorPropertiesWidget::properties() const {
|
||||
ConductorProperties ConductorPropertiesWidget::properties() const
|
||||
{
|
||||
ConductorProperties properties_;
|
||||
if (ui -> m_multiwires_gb -> isChecked()) properties_.type = ConductorProperties::Multi;
|
||||
else if (ui -> m_singlewire_gb -> isChecked()) properties_.type = ConductorProperties::Single;
|
||||
@ -103,6 +107,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const {
|
||||
properties_.color = ui -> m_color_pb->palette().color(QPalette::Button);
|
||||
properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
|
||||
properties_.text = ui -> m_text_le -> text();
|
||||
properties_.m_function = ui -> m_function_le->text();
|
||||
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
|
||||
properties_.text_size = ui -> m_text_size_sb -> value();
|
||||
properties_.m_show_text = ui -> m_show_text_cb -> isChecked();
|
||||
properties_.m_one_text_per_folio = ui -> m_one_text_per_folio_cb -> isChecked();
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>354</width>
|
||||
<height>329</height>
|
||||
<width>504</width>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -33,23 +33,35 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Texte :</string>
|
||||
<string>Taille du texte :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="m_function_le"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="m_text_size_sb">
|
||||
<property name="toolTip">
|
||||
<string>Taille du texte</string>
|
||||
</property>
|
||||
<property name="wrapping">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::UpDownArrows</enum>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
@ -58,14 +70,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="m_tension_protocol_le"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Taille :</string>
|
||||
<string>Tension / Protocole :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Texte :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Fonction :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="m_text_le">
|
||||
<property name="toolTip">
|
||||
<string>Texte</string>
|
||||
@ -75,13 +104,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="m_show_text_cb">
|
||||
<property name="toolTip">
|
||||
<string>Texte visible</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Visible</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
|
224
sources/ui/potentialselectordialog.cpp
Normal file
224
sources/ui/potentialselectordialog.cpp
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
Copyright 2006-2015 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#include "potentialselectordialog.h"
|
||||
#include "ui_potentialselectordialog.h"
|
||||
#include "conductor.h"
|
||||
#include "terminal.h"
|
||||
#include <QRadioButton>
|
||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "diagram.h"
|
||||
#include "element.h"
|
||||
#include "reportelement.h"
|
||||
|
||||
//### PRIVATE CLASS ###//
|
||||
|
||||
/**
|
||||
* @brief The NewConductorPotentialSelector class
|
||||
* Use for get the conductor propertie when two potentials is linked by a conductor
|
||||
*/
|
||||
class NewConductorPotentialSelector : public AbstractPotentialSelector
|
||||
{
|
||||
public:
|
||||
NewConductorPotentialSelector(Conductor *conductor) :
|
||||
m_is_valid(false)
|
||||
{
|
||||
Terminal *terminal_1 = conductor->terminal1;
|
||||
Terminal *terminal_2 = conductor->terminal2;
|
||||
//We temporarily remove the conductor of his two terminals, to get the two existing potential
|
||||
terminal_1->removeConductor(conductor);
|
||||
terminal_2->removeConductor(conductor);
|
||||
|
||||
if (terminal_1->conductors().isEmpty() || terminal_2->conductors().isEmpty()) return;
|
||||
|
||||
m_properties_1 = terminal_1->conductors().first()->properties();
|
||||
m_conductor_number_1 = terminal_1->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
m_properties_2 = terminal_2->conductors().first()->properties();
|
||||
m_conductor_number_2 = terminal_2->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
|
||||
//Re-add conductor to his terminals.
|
||||
terminal_1->addConductor(conductor);
|
||||
terminal_2->addConductor(conductor);
|
||||
m_is_valid = true;
|
||||
}
|
||||
|
||||
bool isValid() const {return m_is_valid;}
|
||||
|
||||
~NewConductorPotentialSelector() {}
|
||||
|
||||
private :
|
||||
bool m_is_valid;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The LinkReportPotentialSelector class
|
||||
* Use for get the conductor propertie when two potentials is linked with a folio report
|
||||
*/
|
||||
class LinkReportPotentialSelector : public AbstractPotentialSelector
|
||||
{
|
||||
public:
|
||||
LinkReportPotentialSelector(Element *report) :
|
||||
m_is_valid(false)
|
||||
{
|
||||
if (report->linkType() & Element::AllReport)
|
||||
{
|
||||
//We temporarily unlink report to get the two existing potential
|
||||
Element *other_report = report->linkedElements().first();
|
||||
report->unlinkAllElements();
|
||||
|
||||
if (report->conductors().isEmpty() || other_report->conductors().isEmpty()) return;
|
||||
|
||||
m_properties_1 = report->conductors().first()->properties();
|
||||
m_conductor_number_1 = report->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
m_properties_2 = other_report->conductors().first()->properties();
|
||||
m_conductor_number_2 = other_report->conductors().first()->relatedPotentialConductors().size() + 1;
|
||||
|
||||
//We relink the report
|
||||
report->linkToElement(other_report);
|
||||
m_is_valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
~LinkReportPotentialSelector() {}
|
||||
|
||||
bool isValid() const {return m_is_valid;}
|
||||
|
||||
private:
|
||||
bool m_is_valid;
|
||||
};
|
||||
|
||||
//### PRIVATE CLASS ###//
|
||||
|
||||
/**
|
||||
* @brief PotentialSelectorDialog::PotentialSelectorDialog
|
||||
* Constructor when we link two potentiels together, with a conductor
|
||||
* @param conductor : the new conductor who connect to existing potential
|
||||
* @param parent_undo : undo parent to use.
|
||||
* @param parent : parent widget.
|
||||
*/
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialSelectorDialog),
|
||||
m_conductor(conductor),
|
||||
m_report(nullptr),
|
||||
m_parent_undo(parent_undo)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_potential_selector = new NewConductorPotentialSelector(conductor);
|
||||
buildWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialSelectorDialog::PotentialSelectorDialog
|
||||
* Constructor when we link two potentiels together, with a folio report.
|
||||
* @param report : one of the report used to link the potentials (report must be linked to another report)
|
||||
* @param parent_undo : undo parent to use
|
||||
* @param parent : paren widget
|
||||
*/
|
||||
PotentialSelectorDialog::PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialSelectorDialog),
|
||||
m_conductor(nullptr),
|
||||
m_report(report),
|
||||
m_parent_undo(parent_undo)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_potential_selector = new LinkReportPotentialSelector(report);
|
||||
buildWidget();
|
||||
}
|
||||
|
||||
PotentialSelectorDialog::~PotentialSelectorDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete m_potential_selector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialSelectorDialog::buildWidget
|
||||
* Build the dialog
|
||||
*/
|
||||
void PotentialSelectorDialog::buildWidget()
|
||||
{
|
||||
QRadioButton *rb1 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_1.text).arg(m_potential_selector->m_conductor_number_1), this);
|
||||
QRadioButton *rb2 = new QRadioButton(tr("Le potentiel avec numero de fil %1 est présent %2 fois").arg(m_potential_selector->m_properties_2.text).arg(m_potential_selector->m_conductor_number_2), this);
|
||||
|
||||
connect(rb1, &QRadioButton::toggled, [this](bool t){if(t) this->m_selected_properties = this->m_potential_selector->m_properties_1;});
|
||||
connect(rb2, &QRadioButton::toggled, [this](bool t){if(t) this->m_selected_properties = this->m_potential_selector->m_properties_2;});
|
||||
|
||||
//Set the radio button of potential with the bigger number of conductors,
|
||||
//at first position, and check it
|
||||
if (m_potential_selector->m_conductor_number_1 >= m_potential_selector->m_conductor_number_2)
|
||||
{
|
||||
ui->verticalLayout->insertWidget(1, rb1);
|
||||
ui->verticalLayout->insertWidget(2, rb2);
|
||||
rb1->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->verticalLayout->insertWidget(1, rb2);
|
||||
ui->verticalLayout->insertWidget(2, rb1);
|
||||
rb2->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialSelectorDialog::on_buttonBox_accepted
|
||||
* Action when user click on OK button
|
||||
*/
|
||||
void PotentialSelectorDialog::on_buttonBox_accepted()
|
||||
{
|
||||
if (!m_potential_selector->isValid()) return;
|
||||
|
||||
if (!m_conductor)
|
||||
m_conductor = m_report->conductors().first();
|
||||
|
||||
ConductorProperties new_properties = m_conductor->properties();
|
||||
new_properties.text = m_selected_properties.text;
|
||||
new_properties.m_function = m_selected_properties.m_function;
|
||||
new_properties.m_tension_protocol = m_selected_properties.m_tension_protocol;
|
||||
|
||||
QVariant old_value, new_value;
|
||||
old_value.setValue(m_conductor->properties());
|
||||
new_value.setValue(new_properties);
|
||||
|
||||
//Set the properties for the new conductor
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
|
||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
|
||||
//Set the new properties for each conductors of the new potential
|
||||
foreach(Conductor *cond, m_conductor->relatedPotentialConductors())
|
||||
{
|
||||
new_properties = cond->properties();
|
||||
new_properties.text = m_selected_properties.text;
|
||||
new_properties.m_function = m_selected_properties.m_function;
|
||||
new_properties.m_tension_protocol = m_selected_properties.m_tension_protocol;
|
||||
old_value.setValue(cond->properties());
|
||||
new_value.setValue(new_properties);
|
||||
new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo);
|
||||
}
|
||||
|
||||
//There is an undo parent, we stop here, the owner of m_parent_undo will push it to an undo stack
|
||||
if (m_parent_undo) return;
|
||||
//There isn't a parent, we push the undo command to diagram undo stack.
|
||||
if (m_conductor->diagram()) m_conductor->diagram()->undoStack().push(undo);
|
||||
//We apply the change without undo command
|
||||
else
|
||||
{
|
||||
delete undo;
|
||||
m_conductor->setProperties(new_properties);
|
||||
}
|
||||
}
|
76
sources/ui/potentialselectordialog.h
Normal file
76
sources/ui/potentialselectordialog.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright 2006-2015 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#ifndef POTENTIALSELECTORDIALOG_H
|
||||
#define POTENTIALSELECTORDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "conductorproperties.h"
|
||||
class Conductor;
|
||||
class QUndoCommand;
|
||||
class Element;
|
||||
|
||||
class AbstractPotentialSelector
|
||||
{
|
||||
public:
|
||||
virtual ~AbstractPotentialSelector() {}
|
||||
virtual bool isValid() const = 0;
|
||||
|
||||
ConductorProperties m_properties_1, m_properties_2;
|
||||
int m_conductor_number_1, m_conductor_number_2;
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class PotentialSelectorDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The PotentialSelectorDialog class
|
||||
* This dialog is used when user try to connect two existing potential together.
|
||||
* The dialog ask to user to make a choice between the properties of the two existing potential,
|
||||
* to apply it for the new potential.
|
||||
*
|
||||
* Each constructor have a QUndoCommand @parent_undo for parameter
|
||||
* If @parent_undo isn't null, when user click on OK button, the dialog will use the parent-undo
|
||||
* as parent of the undo command that describe the changes.
|
||||
* If @parent_undo is null, the created undo-command is push to the undo stack of the parent diagram of a conductor in potential.
|
||||
* else we apply the change without a QUndoCommand.
|
||||
*/
|
||||
class PotentialSelectorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
|
||||
explicit PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
|
||||
~PotentialSelectorDialog();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
void buildWidget();
|
||||
|
||||
private:
|
||||
Ui::PotentialSelectorDialog *ui;
|
||||
Conductor *m_conductor;
|
||||
Element *m_report;
|
||||
QUndoCommand *m_parent_undo;
|
||||
ConductorProperties m_selected_properties;
|
||||
AbstractPotentialSelector *m_potential_selector;
|
||||
};
|
||||
#endif // POTENTIALSELECTORDIALOG_H
|
@ -1,46 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PotentialTextsDialog</class>
|
||||
<widget class="QDialog" name="PotentialTextsDialog">
|
||||
<class>PotentialSelectorDialog</class>
|
||||
<widget class="QDialog" name="PotentialSelectorDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>403</width>
|
||||
<height>94</height>
|
||||
<width>425</width>
|
||||
<height>74</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Textes de potentiel</string>
|
||||
<string>Sélectionner le potentiel éléctrique</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Les textes de ce potentiel électrique ne sont pas identiques.
|
||||
Appliquer un texte à l'ensemble de ces conducteurs.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="m_buttons_layout"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="text">
|
||||
<string>Vous tentez de lier deux potentiels différents ensemble.
|
||||
Veuillez choisir les propriétées à appliquer au nouveau potentiel.</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
@ -59,7 +66,7 @@ Appliquer un texte à l'ensemble de ces conducteurs.</string>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PotentialTextsDialog</receiver>
|
||||
<receiver>PotentialSelectorDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -75,7 +82,7 @@ Appliquer un texte à l'ensemble de ces conducteurs.</string>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PotentialTextsDialog</receiver>
|
||||
<receiver>PotentialSelectorDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2015 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#include "conductor.h"
|
||||
#include "potentialtextsdialog.h"
|
||||
#include "ui_potentialtextsdialog.h"
|
||||
#include <QSignalMapper>
|
||||
#include <QRadioButton>
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::PotentialTextsDialog
|
||||
* Constructor
|
||||
* @param conductor : A Conductor of the potential to check
|
||||
* @param parent : parent widget
|
||||
*/
|
||||
PotentialTextsDialog::PotentialTextsDialog(Conductor *conductor, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PotentialTextsDialog),
|
||||
m_conductor (conductor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
conductorsTextToMap();
|
||||
buildRadioList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::~PotentialTextsDialog
|
||||
* Destructor
|
||||
*/
|
||||
PotentialTextsDialog::~PotentialTextsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::selectedText
|
||||
* @return the selected text
|
||||
*/
|
||||
QString PotentialTextsDialog::selectedText() const {
|
||||
return m_selected_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::buildRadioList
|
||||
* Build the radio list of this dialog, for selected a text
|
||||
*/
|
||||
void PotentialTextsDialog::buildRadioList() {
|
||||
//map the signal for each radio button create in buildRadioList
|
||||
m_signal_mapper = new QSignalMapper(this);
|
||||
connect(m_signal_mapper, SIGNAL(mapped(QString)), this, SLOT(setSelectedText(QString)));
|
||||
|
||||
//create a new radio button for each text of @conductorList
|
||||
for (QMultiMap<int, QString>::ConstIterator it = m_texts.constEnd()-1; it != m_texts.constBegin()-1; --it) {
|
||||
QRadioButton *rb= new QRadioButton(it.value() + tr(" : est présent ") + QString::number(it.key()) + tr(" fois."), this);
|
||||
if (it == m_texts.constEnd()-1) {
|
||||
rb -> setChecked(true);
|
||||
m_selected_text = it.value();
|
||||
}
|
||||
//connect the button to mapper @m_signal_mapper
|
||||
connect(rb, SIGNAL(clicked()), m_signal_mapper, SLOT(map()));
|
||||
m_signal_mapper -> setMapping(rb, it.value());
|
||||
ui -> m_buttons_layout -> addWidget(rb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::conductorsTextToMap
|
||||
* Fill the multimap @m_text with all different text found in the same potentil of @m_conductor
|
||||
* The key "int" of multimap is the number of conductors with the same text.
|
||||
* The value "QString" of multimap is the text.
|
||||
*/
|
||||
void PotentialTextsDialog::conductorsTextToMap() {
|
||||
QStringList textList;
|
||||
textList << m_conductor -> text();
|
||||
foreach(Conductor *c, m_conductor->relatedPotentialConductors()) textList << c -> text();
|
||||
|
||||
while (!textList.size() == 0) {
|
||||
QString t = textList.at(0);
|
||||
int n = textList.count(t);
|
||||
textList.removeAll(t);
|
||||
m_texts.insert(n, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PotentialTextsDialog::setSelectedText
|
||||
* @param text
|
||||
*/
|
||||
void PotentialTextsDialog::setSelectedText(QString text) {
|
||||
m_selected_text = text;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
Copyright 2006-2015 The QElectroTech Team
|
||||
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/>.
|
||||
*/
|
||||
#ifndef POTENTIALTEXTSDIALOG_H
|
||||
#define POTENTIALTEXTSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMultiMap>
|
||||
class Conductor;
|
||||
class QSignalMapper;
|
||||
|
||||
namespace Ui {
|
||||
class PotentialTextsDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The PotentialTextsDialog class
|
||||
* This dialog show all differents conductors texts at the same
|
||||
* potential of @conductor.
|
||||
* The user can select a text in the list.
|
||||
*/
|
||||
class PotentialTextsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PotentialTextsDialog(Conductor *conductor, QWidget *parent = 0);
|
||||
~PotentialTextsDialog();
|
||||
|
||||
QString selectedText () const;
|
||||
|
||||
private:
|
||||
void buildRadioList();
|
||||
void conductorsTextToMap();
|
||||
|
||||
private slots:
|
||||
void setSelectedText (QString text);
|
||||
|
||||
private:
|
||||
Ui::PotentialTextsDialog *ui;
|
||||
Conductor *m_conductor;
|
||||
QSignalMapper *m_signal_mapper;
|
||||
QString m_selected_text;
|
||||
QMultiMap <int, QString> m_texts;
|
||||
};
|
||||
|
||||
#endif // POTENTIALTEXTSDIALOG_H
|
@ -19,6 +19,8 @@
|
||||
#include "element.h"
|
||||
#include "diagram.h"
|
||||
#include "conductorautonumerotation.h"
|
||||
#include "conductor.h"
|
||||
#include "potentialselectordialog.h"
|
||||
|
||||
/**
|
||||
* @brief LinkElementCommand::LinkElementCommand
|
||||
@ -211,7 +213,19 @@ void LinkElementCommand::redo()
|
||||
&& m_element->conductors().size() \
|
||||
&& m_linked_after.size() && m_linked_after.first()->conductors().size())
|
||||
{
|
||||
ConductorAutoNumerotation::checkPotential(m_element->conductors().first(), this);
|
||||
//fill list of potential
|
||||
QSet <Conductor *> c_list = m_element->conductors().first()->relatedPotentialConductors();
|
||||
c_list << m_element->conductors().first();
|
||||
//fill list of text
|
||||
QStringList strl;
|
||||
foreach (const Conductor *c, c_list) strl<<(c->properties().text);
|
||||
|
||||
//check text list, isn't same in potential, ask user what to do
|
||||
if (!QET::eachStrIsEqual(strl))
|
||||
{
|
||||
PotentialSelectorDialog psd(m_element, this);
|
||||
psd.exec();
|
||||
}
|
||||
m_first_redo = false;
|
||||
}
|
||||
QUndoCommand::redo();
|
||||
|
Loading…
x
Reference in New Issue
Block a user