diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 519fa9b6a..ab64d336f 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -224,7 +224,9 @@ ConductorProperties::ConductorProperties() : verti_rotate_text(270), horiz_rotate_text(0), style(Qt::SolidLine), - m_show_text(true) + m_show_text(true), + m_one_text_per_folio(false), + m_no_one_text_per_folio(false) { } @@ -254,6 +256,8 @@ void ConductorProperties::toXml(QDomElement &e) const { e.setAttribute("num", text); e.setAttribute("numsize", text_size); e.setAttribute("displaytext", m_show_text); + e.setAttribute("onetextperfolio", m_one_text_per_folio); + e.setAttribute("noonetextperfolio", m_no_one_text_per_folio); e.setAttribute("vertirotatetext", verti_rotate_text); e.setAttribute("horizrotatetext", horiz_rotate_text); @@ -292,6 +296,8 @@ void ConductorProperties::fromXml(QDomElement &e) { 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(); + m_no_one_text_per_folio = e.attribute("noonetextperfolio", QString::number(0)).toInt(); verti_rotate_text = e.attribute("vertirotatetext").toDouble(); horiz_rotate_text = e.attribute("horizrotatetext").toDouble(); @@ -311,6 +317,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) settings.setValue(prefix + "text", text); settings.setValue(prefix + "textsize", QString::number(text_size)); settings.setValue(prefix + "displaytext", m_show_text); + settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio); settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text)); settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text)); singleLineProperties.toSettings(settings, prefix); @@ -339,6 +346,7 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi 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(); @@ -371,7 +379,9 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const{ other.text_size == text_size &&\ other.verti_rotate_text == verti_rotate_text &&\ other.horiz_rotate_text == horiz_rotate_text &&\ - other.singleLineProperties == singleLineProperties + other.singleLineProperties == singleLineProperties &&\ + other.m_one_text_per_folio == m_one_text_per_folio &&\ + other.m_no_one_text_per_folio == m_no_one_text_per_folio ); } diff --git a/sources/conductorproperties.h b/sources/conductorproperties.h index 74256c71d..33d1b6e96 100644 --- a/sources/conductorproperties.h +++ b/sources/conductorproperties.h @@ -85,6 +85,8 @@ class ConductorProperties { double verti_rotate_text; double horiz_rotate_text; bool m_show_text; + bool m_one_text_per_folio; + bool m_no_one_text_per_folio; /// conducteur style (Qt::SolidLine or Qt::DashLine) Qt::PenStyle style; diff --git a/sources/configpages.cpp b/sources/configpages.cpp index 236f5800c..6d36fd1f8 100644 --- a/sources/configpages.cpp +++ b/sources/configpages.cpp @@ -47,6 +47,7 @@ NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) : ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true); // default conductor properties cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties()); + cpw -> setHiddenNoOneTextPerFolio(true); // default propertie of report label rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties()); // default properties of xref diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index b0f3aeffa..880917ab8 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1188,7 +1188,35 @@ QPointF Conductor::posForText(Qt::Orientations &flag) { * If text was moved by user, this function do nothing, except check if text is near conductor. */ void Conductor::calculateTextItemPosition() { - if (!text_item) return; + if (!text_item || !diagram()) return; + + if (diagram() -> defaultConductorProperties.m_one_text_per_folio == true) { + QSet conductor_list = relatedPotentialConductors(false); + Conductor *longuest_conductor = this; + + //Search the longuest conductor + foreach (Conductor *c, conductor_list) { + if (c -> length() > longuest_conductor -> length()) { + longuest_conductor = c; + } + } + + //The longuest conductor isn't this conductor + //we call calculateTextItemPosition of the longuest conductor + if(longuest_conductor != this) { + longuest_conductor -> calculateTextItemPosition(); + return; + } + + //At this point this conductor is the longuest conductor + //we hide all text of conductor_list + foreach (Conductor *c, conductor_list) { + c -> textItem() -> setVisible(false); + } + } + + //Make sure text item is visible + text_item -> setVisible(true); //position if (text_item -> wasMovedByUser()) { @@ -1405,10 +1433,12 @@ QSet Conductor::relatedConductors() const { * @brief Conductor::relatedPotentialConductors * Return all conductors at the same potential of this conductor, this conductor isn't * part of the returned QSet. + * @param all_diagram : if true search in all diagram of the project, + * false search only in the parent diagram of this conductor * @param t_list, a list of terminal already cheched for the serach of potential. * @return a QSet of conductor at the same potential. */ -QSet Conductor::relatedPotentialConductors(QList *t_list) { +QSet Conductor::relatedPotentialConductors(const bool all_diagram, QList *t_list) { bool declar_t_list = false; if (t_list == 0) { declar_t_list = true; @@ -1426,7 +1456,7 @@ QSet Conductor::relatedPotentialConductors(QList *t_li QList other_conductors_list_t = terminal -> conductors(); //get terminal share the same potential of @terminal, of parent element - Terminal *t1_bis = relatedPotentialTerminal(terminal); + Terminal *t1_bis = relatedPotentialTerminal(terminal, all_diagram); if (t1_bis && !t_list->contains(t1_bis)) { t_list -> append(t1_bis); other_conductors_list_t += t1_bis->conductors(); @@ -1435,7 +1465,7 @@ QSet Conductor::relatedPotentialConductors(QList *t_li other_conductors_list_t.removeAll(this); // Research the conductors connected to conductors already found foreach (Conductor *c, other_conductors_list_t) { - other_conductors += c -> relatedPotentialConductors(t_list); + other_conductors += c -> relatedPotentialConductors(all_diagram, t_list); } other_conductors += other_conductors_list_t.toSet(); } @@ -1454,11 +1484,13 @@ QSet Conductor::relatedPotentialConductors(QList *t_li * For folio report, return the terminal of linked other report. * For Terminal element, return the other terminal of terminal element. * @param t terminal to start search + * @param all_diagram :if true return all related terminal, + * false return only terminal in the same diagram of @t * @return */ -Terminal * Conductor::relatedPotentialTerminal (Terminal *t) { +Terminal * Conductor::relatedPotentialTerminal (Terminal *t, const bool all_diagram) { // If terminal parent element is a folio report. - if (t->parentElement()->linkType() & Element::AllReport) { + if (all_diagram && t->parentElement()->linkType() & Element::AllReport) { QList elmt_list = t->parentElement()->linkedElements(); if (!elmt_list.isEmpty()) { return (elmt_list.first()->terminals().first()); diff --git a/sources/qetgraphicsitem/conductor.h b/sources/qetgraphicsitem/conductor.h index b1ca05298..ddb3b7e9a 100644 --- a/sources/qetgraphicsitem/conductor.h +++ b/sources/qetgraphicsitem/conductor.h @@ -107,7 +107,7 @@ class Conductor : public QObject, public QGraphicsPathItem { virtual Highlight highlight() const; virtual void setHighlighted(Highlight); void autoText(); - QSet relatedPotentialConductors(QList *t_list=0); + QSet relatedPotentialConductors(const bool all_diagram = true, QList *t_list=0); QETDiagramEditor* diagramEditor() const; void editProperty (); @@ -181,6 +181,6 @@ class Conductor : public QObject, public QGraphicsPathItem { static qreal conductor_bound(qreal, qreal, bool); static Qt::Corner movementType(const QPointF &, const QPointF &); static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &); - Terminal * relatedPotentialTerminal (Terminal *); + Terminal * relatedPotentialTerminal (Terminal *, const bool all_diagram = true); }; #endif diff --git a/sources/ui/conductorpropertiesdialog.cpp b/sources/ui/conductorpropertiesdialog.cpp index c95d388a8..b25e7b507 100644 --- a/sources/ui/conductorpropertiesdialog.cpp +++ b/sources/ui/conductorpropertiesdialog.cpp @@ -36,6 +36,7 @@ ConductorPropertiesDialog::ConductorPropertiesDialog(Conductor *conductor, QWidg { ui->setupUi(this); m_cpw = new ConductorPropertiesWidget(conductor->properties()); + m_cpw -> setHiddenOneTextPerFolio(true); ui -> main_layout -> insertWidget(1, m_cpw); } diff --git a/sources/ui/conductorpropertieswidget.cpp b/sources/ui/conductorpropertieswidget.cpp index 3be38f19c..f2c6da671 100644 --- a/sources/ui/conductorpropertieswidget.cpp +++ b/sources/ui/conductorpropertieswidget.cpp @@ -70,16 +70,20 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert setColorButton(m_properties.color); int index = ui -> m_line_style_cb->findData(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_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); + + 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_no_one_text_per_folio_cb -> setChecked (m_properties.m_no_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); setConductorType(m_properties.type); updatePreview(false); @@ -93,16 +97,20 @@ ConductorProperties ConductorPropertiesWidget::properties() const { ConductorProperties properties_; if (ui -> m_multi_rb -> isChecked()) properties_.type = ConductorProperties::Multi; else if (ui -> m_single_rb -> isChecked()) properties_.type = ConductorProperties::Single; - properties_.color = ui->m_color_pb->palette().color(QPalette::Button); - properties_.style = static_cast(ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).toInt()); - properties_.text = ui -> m_text_le -> text(); - properties_.text_size = ui -> m_text_size_sb -> value(); - properties_.m_show_text = ui -> m_show_text_cb -> isChecked(); - properties_.verti_rotate_text = m_verti_select -> value(); - properties_.horiz_rotate_text = m_horiz_select -> value(); - properties_.singleLineProperties.hasGround = ui -> m_earth_cb -> isChecked(); + + properties_.color = ui->m_color_pb->palette().color(QPalette::Button); + properties_.style = static_cast(ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).toInt()); + properties_.text = ui -> m_text_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(); + properties_.m_no_one_text_per_folio = ui -> m_no_one_text_per_folio_cb -> isChecked(); + properties_.verti_rotate_text = m_verti_select -> value(); + properties_.horiz_rotate_text = m_horiz_select -> value(); + + properties_.singleLineProperties.hasGround = ui -> m_earth_cb -> isChecked(); properties_.singleLineProperties.hasNeutral = ui -> m_neutral_cb -> isChecked(); - properties_.singleLineProperties.is_pen = ui -> m_pen_cb -> isChecked(); + properties_.singleLineProperties.is_pen = ui -> m_pen_cb -> isChecked(); properties_.singleLineProperties.setPhasesCount(ui -> m_phase_cb -> isChecked() ? ui -> m_phase_sb -> value() : 0); return properties_; @@ -116,10 +124,30 @@ void ConductorPropertiesWidget::setReadOnly(const bool &ro) { this->setDisabled(ro); } +/** + * @brief ConductorPropertiesWidget::addAutonumWidget + * @param widget + */ void ConductorPropertiesWidget::addAutonumWidget(QWidget *widget) { ui->m_autonum_layout->addWidget(widget); } +/** + * @brief ConductorPropertiesWidget::setHiddenOneTextPerFolio + * @param hide + */ +void ConductorPropertiesWidget::setHiddenOneTextPerFolio(const bool &hide) { + ui -> m_one_text_per_folio_cb -> setHidden(hide); +} + +/** + * @brief ConductorPropertiesWidget::setHiddenNoOneTextPerFolio + * @param hide + */ +void ConductorPropertiesWidget::setHiddenNoOneTextPerFolio(const bool &hide) { + ui -> m_no_one_text_per_folio_cb -> setHidden(hide); +} + /** * @brief ConductorPropertiesWidget::initWidget */ diff --git a/sources/ui/conductorpropertieswidget.h b/sources/ui/conductorpropertieswidget.h index a66f2eafd..c5e355219 100644 --- a/sources/ui/conductorpropertieswidget.h +++ b/sources/ui/conductorpropertieswidget.h @@ -41,6 +41,8 @@ class ConductorPropertiesWidget : public QWidget void setReadOnly(const bool &ro); void addAutonumWidget (QWidget *widget); + void setHiddenOneTextPerFolio (const bool &hide); + void setHiddenNoOneTextPerFolio (const bool &hide); private: void initWidget(); diff --git a/sources/ui/conductorpropertieswidget.ui b/sources/ui/conductorpropertieswidget.ui index 9563fb929..fc05ac515 100644 --- a/sources/ui/conductorpropertieswidget.ui +++ b/sources/ui/conductorpropertieswidget.ui @@ -6,8 +6,8 @@ 0 0 - 430 - 407 + 570 + 453 @@ -94,7 +94,22 @@ - + + + + + Afficher un seul texte par potentiel présent sur un folio. (expérimental) + + + + + + + Ne pas subir l'option : afficher un seul texte par potentiel présent sur un folio. (Inactifl) + + + + diff --git a/sources/ui/diagrampropertiesdialog.cpp b/sources/ui/diagrampropertiesdialog.cpp index 3275e5f60..395c965d0 100644 --- a/sources/ui/diagrampropertiesdialog.cpp +++ b/sources/ui/diagrampropertiesdialog.cpp @@ -64,6 +64,7 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare //Conductor widget ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(conductors, this); + cpw -> setHiddenNoOneTextPerFolio(true); cpw -> setReadOnly(diagram_is_read_only); //Conductor autonum