mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Conductor: add option one text per potential in the same diagram (work in progress)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3341 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 *> 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 *> 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 *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_list) {
|
||||
QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram, QList <Terminal *> *t_list) {
|
||||
bool declar_t_list = false;
|
||||
if (t_list == 0) {
|
||||
declar_t_list = true;
|
||||
@@ -1426,7 +1456,7 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_li
|
||||
QList <Conductor *> 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 *> Conductor::relatedPotentialConductors(QList <Terminal *> *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 *> Conductor::relatedPotentialConductors(QList <Terminal *> *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 <Element *> elmt_list = t->parentElement()->linkedElements();
|
||||
if (!elmt_list.isEmpty()) {
|
||||
return (elmt_list.first()->terminals().first());
|
||||
|
||||
@@ -107,7 +107,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
virtual Highlight highlight() const;
|
||||
virtual void setHighlighted(Highlight);
|
||||
void autoText();
|
||||
QSet<Conductor *> relatedPotentialConductors(QList <Terminal *> *t_list=0);
|
||||
QSet<Conductor *> relatedPotentialConductors(const bool all_diagram = true, QList <Terminal *> *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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,14 +70,18 @@ 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_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);
|
||||
|
||||
@@ -93,13 +97,17 @@ 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<Qt::PenStyle>(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();
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>430</width>
|
||||
<height>407</height>
|
||||
<width>570</width>
|
||||
<height>453</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -94,7 +94,22 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="m_autonum_layout"/>
|
||||
<layout class="QVBoxLayout" name="m_autonum_layout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_one_text_per_folio_cb">
|
||||
<property name="text">
|
||||
<string>Afficher un seul texte par potentiel présent sur un folio. (expérimental)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_no_one_text_per_folio_cb">
|
||||
<property name="text">
|
||||
<string>Ne pas subir l'option : afficher un seul texte par potentiel présent sur un folio. (Inactifl)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user