Conductor : formula and text is now two different things.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4799 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-12-06 19:49:18 +00:00
parent c0b5aa7a59
commit 7ab0115c62
16 changed files with 213 additions and 236 deletions

View File

@@ -334,7 +334,6 @@ namespace autonum
//Add location name to path array //Add location name to path array
while((current_location.parent() != current_location) && (current_location.parent().fileName() != "import")) while((current_location.parent() != current_location) && (current_location.parent().fileName() != "import"))
{ {
qDebug() << "i = " << i << " " << current_location.fileName();
i++; i++;
path[i]=current_location.fileName(); path[i]=current_location.fileName();
current_location = current_location.parent(); current_location = current_location.parent();

View File

@@ -191,15 +191,8 @@ void AutoNumberingDockWidget::conductorAutoNumChanged() {
void AutoNumberingDockWidget::on_m_conductor_cb_activated(int) void AutoNumberingDockWidget::on_m_conductor_cb_activated(int)
{ {
QString current_autonum = ui->m_conductor_cb->currentText(); QString current_autonum = ui->m_conductor_cb->currentText();
QString current_formula = m_project->conductorAutoNumFormula(current_autonum);
if (!current_autonum.isEmpty()) {
m_project->setConductorAutoNumCurrentFormula(current_formula, current_autonum);
}
else {
m_project->setConductorAutoNumCurrentFormula("","");
}
m_project->setCurrentConductorAutoNum(current_autonum);
m_project_view->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum); m_project_view->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
m_project_view->currentDiagram()->diagram()->loadCndFolioSeq(); m_project_view->currentDiagram()->diagram()->loadCndFolioSeq();
} }

View File

@@ -23,6 +23,7 @@
#include "qet.h" #include "qet.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "potentialselectordialog.h" #include "potentialselectordialog.h"
#include "assignvariables.h"
/** /**
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation * @brief ConductorAutoNumerotation::ConductorAutoNumerotation
@@ -36,8 +37,8 @@
*/ */
ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagram *diagram, QUndoCommand *parent_undo) : ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagram *diagram, QUndoCommand *parent_undo) :
m_diagram (diagram), m_diagram (diagram),
conductor_ (conductor), m_conductor (conductor),
conductor_list (conductor -> relatedPotentialConductors()), conductor_list (conductor -> relatedPotentialConductors().toList()),
m_parent_undo (parent_undo) m_parent_undo (parent_undo)
{} {}
@@ -46,9 +47,9 @@ ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagr
* execute the automatic numerotation * execute the automatic numerotation
*/ */
void ConductorAutoNumerotation::numerate() { void ConductorAutoNumerotation::numerate() {
if (!conductor_) return; if (!m_conductor) return;
if (conductor_list.size() >= 1 ) numeratePotential(); if (conductor_list.size() >= 1 ) numeratePotential();
else if (conductor_ -> properties().type == ConductorProperties::Multi) numerateNewConductor(); else if (m_conductor -> properties().type == ConductorProperties::Multi) numerateNewConductor();
} }
/** /**
@@ -57,15 +58,15 @@ void ConductorAutoNumerotation::numerate() {
*/ */
void ConductorAutoNumerotation::applyText(QString t) void ConductorAutoNumerotation::applyText(QString t)
{ {
if (!conductor_) return; if (!m_conductor) return;
QVariant old_value, new_value; QVariant old_value, new_value;
ConductorProperties cp = conductor_ -> properties(); ConductorProperties cp = m_conductor -> properties();
old_value.setValue(cp); old_value.setValue(cp);
cp.text = t; cp.text = t;
new_value.setValue(cp); new_value.setValue(cp);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor_, "properties", old_value, new_value, m_parent_undo); QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, m_parent_undo);
undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption")); undo->setText(QObject::tr("Modifier les propriétés d'un conducteur", "undo caption"));
if (!conductor_list.isEmpty()) if (!conductor_list.isEmpty())
@@ -91,35 +92,58 @@ void ConductorAutoNumerotation::applyText(QString t)
*/ */
void ConductorAutoNumerotation::numeratePotential() void ConductorAutoNumerotation::numeratePotential()
{ {
QStringList strl; QStringList text_list;
foreach (const Conductor *cc, conductor_list) strl<<(cc->text()); QStringList formula_list;
foreach (const Conductor *cc, conductor_list)
{
ConductorProperties cp = cc->properties();
text_list << cp.text;
formula_list << cp.m_formula;
}
//the texts is identicals //the texts is identicals
if (QET::eachStrIsEqual(strl)) if (QET::eachStrIsEqual(text_list) && QET::eachStrIsEqual(formula_list))
{ {
ConductorProperties cp = conductor_ -> properties(); ConductorProperties cp = m_conductor -> properties();
cp.text = strl.at(0); cp.text = text_list.first();
conductor_ -> setProperties(cp); cp.m_formula = formula_list.first();
conductor_ -> setText(strl.at(0)); m_conductor->setProperties(cp);
m_conductor->setOthersSequential(conductor_list.first());
m_conductor->setText(text_list.first());
} }
//the texts isn't identicals //the texts isn't identicals
else else
{ {
PotentialSelectorDialog psd(conductor_, m_parent_undo, conductor_->diagramEditor()); PotentialSelectorDialog psd(m_conductor, m_parent_undo, m_conductor->diagramEditor());
psd.exec(); psd.exec();
} }
} }
/** /**
* @brief ConductorAutoNumerotation::numerateNewConductor * @brief ConductorAutoNumerotation::numerateNewConductor
* create and apply a new numerotation to @conductor_ * create and apply a new numerotation to @m_conductor
*/ */
void ConductorAutoNumerotation::numerateNewConductor() { void ConductorAutoNumerotation::numerateNewConductor()
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return; {
if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty())
return;
NumerotationContext context = m_diagram->project()->conductorAutoNum(m_diagram -> conductorsAutonumName()); NumerotationContext context = m_diagram->project()->conductorAutoNum(m_diagram -> conductorsAutonumName());
if (context.isEmpty()) return; if (context.isEmpty())
return;
QString autoNum_name = m_diagram->project()->conductorCurrentAutoNum();
QString formula = autonum::numerotationContextToFormula(context);
ConductorProperties cp = m_conductor -> properties();
cp.m_formula = formula;
m_conductor->setProperties(cp);
autonum::setSequential(formula, m_conductor->rSequenceStruct(), context, m_diagram, autoNum_name);
NumerotationContextCommands ncc (context, m_diagram); NumerotationContextCommands ncc (context, m_diagram);
applyText(m_diagram->project()->conductorAutoNumCurrentFormula()); m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceStruct(), m_diagram));
} }

View File

@@ -18,7 +18,7 @@
#ifndef CONDUCTORAUTONUMEROTATION_H #ifndef CONDUCTORAUTONUMEROTATION_H
#define CONDUCTORAUTONUMEROTATION_H #define CONDUCTORAUTONUMEROTATION_H
#include <QSet> #include <QList>
class Diagram; class Diagram;
class Conductor; class Conductor;
@@ -41,8 +41,8 @@ class ConductorAutoNumerotation
//attributes //attributes
Diagram *m_diagram; Diagram *m_diagram;
Conductor *conductor_; Conductor *m_conductor;
QSet <Conductor *> conductor_list; QList <Conductor *> conductor_list;
QUndoCommand *m_parent_undo; QUndoCommand *m_parent_undo;
}; };

View File

@@ -254,6 +254,7 @@ void ConductorProperties::toXml(QDomElement &e) const
singleLineProperties.toXml(e); singleLineProperties.toXml(e);
e.setAttribute("num", text); e.setAttribute("num", text);
e.setAttribute("formula", m_formula);
e.setAttribute("function", m_function); e.setAttribute("function", m_function);
e.setAttribute("tension-protocol", m_tension_protocol); e.setAttribute("tension-protocol", m_tension_protocol);
e.setAttribute("numsize", QString::number(text_size)); e.setAttribute("numsize", QString::number(text_size));
@@ -293,6 +294,7 @@ void ConductorProperties::fromXml(QDomElement &e)
type = Multi; type = Multi;
text = e.attribute("num"); text = e.attribute("num");
m_formula = e.attribute("formula");
m_function = e.attribute("function"); m_function = e.attribute("function");
m_tension_protocol = e.attribute("tension-protocol"); m_tension_protocol = e.attribute("tension-protocol");
text_size = e.attribute("numsize", QString::number(9)).toInt(); text_size = e.attribute("numsize", QString::number(9)).toInt();
@@ -318,6 +320,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
settings.setValue(prefix + "style", writeStyle()); settings.setValue(prefix + "style", writeStyle());
settings.setValue(prefix + "type", typeToString(type)); settings.setValue(prefix + "type", typeToString(type));
settings.setValue(prefix + "text", text); settings.setValue(prefix + "text", text);
settings.setValue(prefix + "formula", m_formula);
settings.setValue(prefix + "function", m_function); settings.setValue(prefix + "function", m_function);
settings.setValue(prefix + "tension-protocol", m_tension_protocol); settings.setValue(prefix + "tension-protocol", m_tension_protocol);
settings.setValue(prefix + "textsize", QString::number(text_size)); settings.setValue(prefix + "textsize", QString::number(text_size));
@@ -344,6 +347,7 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
singleLineProperties.fromSettings(settings, prefix); singleLineProperties.fromSettings(settings, prefix);
text = settings.value(prefix + "text", "_").toString(); text = settings.value(prefix + "text", "_").toString();
m_formula = settings.value(prefix + "formula", "").toString();
m_function = settings.value(prefix + "function", "").toString(); m_function = settings.value(prefix + "function", "").toString();
m_tension_protocol = settings.value(prefix + "tension-protocol", "").toString(); m_tension_protocol = settings.value(prefix + "tension-protocol", "").toString();
text_size = settings.value(prefix + "textsize", "7").toInt(); text_size = settings.value(prefix + "textsize", "7").toInt();
@@ -391,15 +395,18 @@ ConductorProperties ConductorProperties::defaultProperties()
} }
/** /**
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison * @brief ConductorProperties::operator ==
@return true si les deux ensembles de proprietes sont identiques, false sinon * @param other
*/ * @return true if other == this
bool ConductorProperties::operator==(const ConductorProperties &other) const{ */
bool ConductorProperties::operator==(const ConductorProperties &other) const
{
return( return(
other.type == type &&\ other.type == type &&\
other.color == color &&\ other.color == color &&\
other.style == style &&\ other.style == style &&\
other.text == text &&\ other.text == text &&\
other.m_formula == m_formula &&\
other.m_function == m_function &&\ other.m_function == m_function &&\
other.m_tension_protocol == m_tension_protocol &&\ other.m_tension_protocol == m_tension_protocol &&\
other.m_show_text == m_show_text &&\ other.m_show_text == m_show_text &&\

View File

@@ -80,7 +80,8 @@ class ConductorProperties
QColor color; QColor color;
QString text, QString text,
m_function, m_function,
m_tension_protocol; m_tension_protocol,
m_formula;
int text_size; int text_size;
double cond_size; double cond_size;
double verti_rotate_text; double verti_rotate_text;

View File

@@ -1294,18 +1294,19 @@ void Diagram::loadCndFolioSeq() {
//Conductor //Conductor
QString title = project()->conductorCurrentAutoNum(); QString title = project()->conductorCurrentAutoNum();
NumerotationContext nc = project()->conductorAutoNum(title); NumerotationContext nc = project()->conductorAutoNum(title);
QString formula = autonum::numerotationContextToFormula(nc);
//Unit Folio //Unit Folio
if (m_cnd_unitfolio_max.isEmpty() || !m_cnd_unitfolio_max.contains(title)) { if (m_cnd_unitfolio_max.isEmpty() || !m_cnd_unitfolio_max.contains(title)) {
//Insert Initial Value //Insert Initial Value
if (project()->conductorAutoNumCurrentFormula().contains("%sequf_")) { if (formula.contains("%sequf_")) {
insertFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc); insertFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }
} }
else if (m_cnd_unitfolio_max.contains(title)) { else if (m_cnd_unitfolio_max.contains(title)) {
//Load Folio Current Value //Load Folio Current Value
if (project()->conductorAutoNumCurrentFormula().contains("%sequf_")) { if (formula.contains("%sequf_")) {
loadFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc); loadFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }
@@ -1314,14 +1315,14 @@ void Diagram::loadCndFolioSeq() {
//Ten Folio //Ten Folio
if (m_cnd_tenfolio_max.isEmpty() || !m_cnd_tenfolio_max.contains(title)) { if (m_cnd_tenfolio_max.isEmpty() || !m_cnd_tenfolio_max.contains(title)) {
//Insert Initial Value //Insert Initial Value
if (project()->conductorAutoNumCurrentFormula().contains("%seqtf_")) { if (formula.contains("%seqtf_")) {
insertFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc); insertFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }
} }
else if (m_cnd_tenfolio_max.contains(title)) { else if (m_cnd_tenfolio_max.contains(title)) {
//Load Folio Current Value //Load Folio Current Value
if (project()->conductorAutoNumCurrentFormula().contains("%seqtf_")) { if (formula.contains("%seqtf_")) {
loadFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc); loadFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }
@@ -1330,14 +1331,14 @@ void Diagram::loadCndFolioSeq() {
//Hundred Folio //Hundred Folio
if (m_cnd_hundredfolio_max.isEmpty() || !m_cnd_hundredfolio_max.contains(title)) { if (m_cnd_hundredfolio_max.isEmpty() || !m_cnd_hundredfolio_max.contains(title)) {
//Insert Initial Value //Insert Initial Value
if (project()->conductorAutoNumCurrentFormula().contains("%seqhf_")) { if (formula.contains("%seqhf_")) {
insertFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc); insertFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }
} }
else if (m_cnd_hundredfolio_max.contains(title)) { else if (m_cnd_hundredfolio_max.contains(title)) {
//Load Folio Current Value //Load Folio Current Value
if (project()->conductorAutoNumCurrentFormula().contains("%seqhf_")) { if (formula.contains("%seqhf_")) {
loadFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc); loadFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc);
project()->addConductorAutoNum(title,nc); project()->addConductorAutoNum(title,nc);
} }

View File

@@ -225,14 +225,11 @@ void DiagramEventAddElement::addElement()
QPair <Terminal *, Terminal *> pair = element -> AlignedFreeTerminals().takeFirst(); QPair <Terminal *, Terminal *> pair = element -> AlignedFreeTerminals().takeFirst();
Conductor *conductor = new Conductor(pair.first, pair.second); Conductor *conductor = new Conductor(pair.first, pair.second);
conductor -> setProperties(m_diagram -> defaultConductorProperties);
new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF(), undo_object); new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF(), undo_object);
//Autonum the new conductor, the undo command associated for this, have for parent undo_object //Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, m_diagram, undo_object); ConductorAutoNumerotation can (conductor, m_diagram, undo_object);
can.numerate(); can.numerate();
conductor->setSeq = true;
if (m_diagram->freezeNewConductors() || m_diagram->project()->freezeNewConductors()) { if (m_diagram->freezeNewConductors() || m_diagram->project()->freezeNewConductors()) {
conductor->setFreezeLabel(true); conductor->setFreezeLabel(true);
} }

View File

@@ -181,7 +181,6 @@ void ElementsMover::endMovement()
//Autonum the new conductor, the undo command associated for this, have for parent undo_object //Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, diagram_, undo_object); ConductorAutoNumerotation can (conductor, diagram_, undo_object);
can.numerate(); can.numerate();
conductor->setSeq = true;
} }
}; };
} }

View File

@@ -532,23 +532,23 @@ void ProjectAutoNumConfigPage::removeContextElement()
void ProjectAutoNumConfigPage::saveContext_conductor() { void ProjectAutoNumConfigPage::saveContext_conductor() {
// If the text is the default text "Name of new numerotation" save the edited context // If the text is the default text "Name of new numerotation" save the edited context
// With the the name "No name" // With the the name "No name"
if (m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation")) { if (m_context_cb_conductor-> currentText() == tr("Nom de la nouvelle numérotation"))
{
m_project->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext()); m_project->addConductorAutoNum (tr("Sans nom"), m_saw_conductor -> toNumContext());
project()->addConductorAutoNumFormula (tr("Sans nom"), m_saw_conductor->formula()); //add hash <title, formula> project()->setCurrentConductorAutoNum(tr("Sans nom"));
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(),tr("Sans nom")); //add last added conductor formula to current formula
m_context_cb_conductor-> addItem(tr("Sans nom")); m_context_cb_conductor-> addItem(tr("Sans nom"));
} }
// If the text isn't yet to the autonum of the project, add this new item to the combo box. // If the text isn't yet to the autonum of the project, add this new item to the combo box.
else if ( !m_project -> conductorAutoNum().keys().contains( m_context_cb_conductor->currentText())) { else if ( !m_project -> conductorAutoNum().keys().contains( m_context_cb_conductor->currentText()))
{
project()->addConductorAutoNum(m_context_cb_conductor->currentText(), m_saw_conductor->toNumContext()); project()->addConductorAutoNum(m_context_cb_conductor->currentText(), m_saw_conductor->toNumContext());
project()->addConductorAutoNumFormula (m_context_cb_conductor->currentText(), m_saw_conductor->formula()); //add hash <title, formula> project()->setCurrentConductorAutoNum(m_context_cb_conductor->currentText());
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(),m_context_cb_conductor->currentText()); //add last added conductor formula to current formula
m_context_cb_conductor-> addItem(m_context_cb_conductor->currentText()); m_context_cb_conductor-> addItem(m_context_cb_conductor->currentText());
} }
// Else, the text already exist in the autonum of the project, just update the context // Else, the text already exist in the autonum of the project, just update the context
else { else
project()->addConductorAutoNumFormula (m_context_cb_conductor->currentText(), m_saw_conductor->formula()); //add hash <title, formula> {
project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(), m_context_cb_conductor->currentText()); //add last added conductor formula to current formula project()->setCurrentConductorAutoNum(m_context_cb_conductor->currentText());
m_project->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext()); m_project->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext());
} }
project()->conductorAutoNumAdded(); project()->conductorAutoNumAdded();

View File

@@ -47,8 +47,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
QGraphicsPathItem(0), QGraphicsPathItem(0),
terminal1(p1), terminal1(p1),
terminal2(p2), terminal2(p2),
setSeq(true), m_mouse_over(false),
bMouseOver(false),
m_handler(10), m_handler(10),
text_item(0), text_item(0),
segments(NULL), segments(NULL),
@@ -59,9 +58,9 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
{ {
//Set the default conductor properties. //Set the default conductor properties.
if (p1->diagram()) if (p1->diagram())
properties_ = p1->diagram()->defaultConductorProperties; m_properties = p1->diagram()->defaultConductorProperties;
else if (p2->diagram()) else if (p2->diagram())
properties_ = p2->diagram()->defaultConductorProperties; m_properties = p2->diagram()->defaultConductorProperties;
//set Zvalue at 11 to be upper than the DiagramImageItem and element //set Zvalue at 11 to be upper than the DiagramImageItem and element
setZValue(11); setZValue(11);
@@ -98,7 +97,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
// Add the text field // Add the text field
text_item = new ConductorTextItem(properties_.text, this); text_item = new ConductorTextItem(m_properties.text, this);
connect(text_item, &ConductorTextItem::diagramTextChanged, this, &Conductor::displayedTextChanged); connect(text_item, &ConductorTextItem::diagramTextChanged, this, &Conductor::displayedTextChanged);
} }
@@ -439,7 +438,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
qp -> setRenderHint(QPainter::Antialiasing, false); qp -> setRenderHint(QPainter::Antialiasing, false);
// determine la couleur du conducteur // determine la couleur du conducteur
QColor final_conductor_color(properties_.color); QColor final_conductor_color(m_properties.color);
if (must_highlight_ == Normal) { if (must_highlight_ == Normal) {
final_conductor_color = QColor::fromRgb(69, 137, 255, 255); final_conductor_color = QColor::fromRgb(69, 137, 255, 255);
} else if (must_highlight_ == Alert) { } else if (must_highlight_ == Alert) {
@@ -455,7 +454,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
} }
//Draw the conductor bigger when is hovered //Draw the conductor bigger when is hovered
conductor_pen.setWidthF(bMouseOver? (properties_.cond_size) +4 : (properties_.cond_size)); conductor_pen.setWidthF(m_mouse_over? (m_properties.cond_size) +4 : (m_properties.cond_size));
// affectation du QPen et de la QBrush modifies au QPainter // affectation du QPen et de la QBrush modifies au QPainter
qp -> setBrush(conductor_brush); qp -> setBrush(conductor_brush);
@@ -463,7 +462,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
// modification du QPen generique pour lui affecter la couleur et le style adequats // modification du QPen generique pour lui affecter la couleur et le style adequats
final_conductor_pen.setColor(final_conductor_color); final_conductor_pen.setColor(final_conductor_color);
final_conductor_pen.setStyle(properties_.style); final_conductor_pen.setStyle(m_properties.style);
final_conductor_pen.setJoinStyle(Qt::SvgMiterJoin); // meilleur rendu des pointilles final_conductor_pen.setJoinStyle(Qt::SvgMiterJoin); // meilleur rendu des pointilles
// utilisation d'un trait "cosmetique" en-dessous d'un certain zoom // utilisation d'un trait "cosmetique" en-dessous d'un certain zoom
@@ -475,9 +474,9 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
// dessin du conducteur // dessin du conducteur
qp -> drawPath(path()); qp -> drawPath(path());
if (properties_.type == ConductorProperties::Single) { if (m_properties.type == ConductorProperties::Single) {
qp -> setBrush(final_conductor_color); qp -> setBrush(final_conductor_color);
properties_.singleLineProperties.draw( m_properties.singleLineProperties.draw(
qp, qp,
middleSegment() -> isHorizontal() ? QET::Horizontal : QET::Vertical, middleSegment() -> isHorizontal() ? QET::Horizontal : QET::Vertical,
QRectF(middleSegment() -> middle() - QPointF(12.0, 12.0), QSizeF(24.0, 24.0)) QRectF(middleSegment() -> middle() - QPointF(12.0, 12.0), QSizeF(24.0, 24.0))
@@ -633,7 +632,7 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
*/ */
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event); Q_UNUSED(event);
bMouseOver = true; m_mouse_over = true;
update(); update();
} }
@@ -645,7 +644,7 @@ void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event); Q_UNUSED(event);
update(); update();
bMouseOver = false; m_mouse_over = false;
} }
/** /**
@@ -719,7 +718,7 @@ QRectF Conductor::boundingRect() const
QPainterPath Conductor::shape() const QPainterPath Conductor::shape() const
{ {
QPainterPathStroker pps; QPainterPathStroker pps;
pps.setWidth(bMouseOver? 5 : 1); pps.setWidth(m_mouse_over? 5 : 1);
pps.setJoinStyle(conductor_pen.joinStyle()); pps.setJoinStyle(conductor_pen.joinStyle());
QPainterPath shape_(pps.createStroke(path())); QPainterPath shape_(pps.createStroke(path()));
@@ -850,14 +849,15 @@ bool Conductor::fromXml(QDomElement &e) {
@param Qstring seq to be retrieved @param Qstring seq to be retrieved
@param QStringList list to be inserted values @param QStringList list to be inserted values
*/ */
void Conductor::loadSequential(QDomElement* e, QString seq, QStringList* list) { void Conductor::loadSequential(QDomElement* e, QString seq, QStringList* list)
//Load Sequential Values {
//Load Sequential Values
int i = 0; int i = 0;
while (!e->attribute(seq + QString::number(i+1)).isEmpty()) { while (!e->attribute(seq + QString::number(i+1)).isEmpty())
{
list->append(e->attribute(seq + QString::number(i+1))); list->append(e->attribute(seq + QString::number(i+1)));
i++; i++;
} }
setSeq = false;
} }
/** /**
@@ -922,7 +922,7 @@ QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_
if (m_frozen_label != "") e.setAttribute("frozenlabel", m_frozen_label); if (m_frozen_label != "") e.setAttribute("frozenlabel", m_frozen_label);
// Export the properties and text // Export the properties and text
properties_. toXml(e); m_properties. toXml(e);
text_item -> toXml(e); text_item -> toXml(e);
return(e); return(e);
@@ -1144,7 +1144,7 @@ QPointF Conductor::posForText(Qt::Orientations &flag) {
* If text was moved by user, this function do nothing, except check if text is near conductor. * If text was moved by user, this function do nothing, except check if text is near conductor.
*/ */
void Conductor::calculateTextItemPosition() { void Conductor::calculateTextItemPosition() {
if (!text_item || !diagram() || properties_.type != ConductorProperties::Multi) return; if (!text_item || !diagram() || m_properties.type != ConductorProperties::Multi) return;
if (diagram() -> defaultConductorProperties.m_one_text_per_folio == true && if (diagram() -> defaultConductorProperties.m_one_text_per_folio == true &&
relatedPotentialConductors(false).size() > 0) { relatedPotentialConductors(false).size() > 0) {
@@ -1181,8 +1181,8 @@ void Conductor::calculateTextItemPosition() {
QPointF text_pos = posForText(rotation); QPointF text_pos = posForText(rotation);
if (!text_item -> wasRotateByUser()) { if (!text_item -> wasRotateByUser()) {
rotation == Qt::Vertical ? text_item -> setRotationAngle(properties_.verti_rotate_text): rotation == Qt::Vertical ? text_item -> setRotationAngle(m_properties.verti_rotate_text):
text_item -> setRotationAngle(properties_.horiz_rotate_text); text_item -> setRotationAngle(m_properties.horiz_rotate_text);
} }
//Adjust the position of text if his rotation //Adjust the position of text if his rotation
@@ -1292,23 +1292,24 @@ void Conductor::setOthersSequential(Conductor *other) {
void Conductor::setText(const QString &t) void Conductor::setText(const QString &t)
{ {
text_item->setPlainText(t); text_item->setPlainText(t);
if (setSeq && diagram()) // text_item->setPlainText(t);
{ // if (setSeq && diagram())
QString conductor_currentAutoNum = diagram()->project()->conductorCurrentAutoNum(); // {
NumerotationContext nc = diagram()->project()->conductorAutoNum(conductor_currentAutoNum); // QString conductor_currentAutoNum = diagram()->project()->conductorCurrentAutoNum();
// NumerotationContext nc = diagram()->project()->conductorAutoNum(conductor_currentAutoNum);
autonum::setSequential(text(), m_autoNum_seq, nc, diagram(), conductor_currentAutoNum); // autonum::setSequential(text(), m_autoNum_seq, nc, diagram(), conductor_currentAutoNum);
NumerotationContextCommands ncc (nc); // NumerotationContextCommands ncc (nc);
diagram()->project()->addConductorAutoNum(conductor_currentAutoNum, ncc.next()); // diagram()->project()->addConductorAutoNum(conductor_currentAutoNum, ncc.next());
setSeq = false; // setSeq = false;
} // }
if (diagram()) // if (diagram())
{ // {
QString label = autonum::AssignVariables::formulaToLabel(t, m_autoNum_seq, diagram()); // QString label = autonum::AssignVariables::formulaToLabel(t, m_autoNum_seq, diagram());
text_item -> setPlainText(label); // text_item -> setPlainText(label);
} // }
} }
/** /**
@@ -1329,35 +1330,35 @@ void Conductor::refreshText() {
*/ */
void Conductor::setProperties(const ConductorProperties &properties) void Conductor::setProperties(const ConductorProperties &properties)
{ {
if (properties_ == properties) return; if (m_properties == properties) return;
properties_ = properties; m_properties = properties;
foreach(Conductor *other_conductor, relatedPotentialConductors()) foreach(Conductor *other_conductor, relatedPotentialConductors())
{ {
ConductorProperties other_properties = other_conductor->properties(); ConductorProperties other_properties = other_conductor->properties();
other_properties.text = properties_.text; other_properties.text = m_properties.text;
other_properties.color = properties_.color; other_properties.color = m_properties.color;
other_properties.cond_size = properties_.cond_size; other_properties.cond_size = m_properties.cond_size;
other_properties.m_function = properties_.m_function; other_properties.m_function = m_properties.m_function;
other_properties.m_tension_protocol = properties_.m_tension_protocol; other_properties.m_tension_protocol = m_properties.m_tension_protocol;
other_conductor->setProperties(other_properties); other_conductor->setProperties(other_properties);
} }
setText(properties_.text); setText(m_properties.text);
text_item -> setFontSize(properties_.text_size); text_item -> setFontSize(m_properties.text_size);
if (terminal1 != NULL && terminal1->diagram() != NULL) { if (terminal1 != NULL && terminal1->diagram() != NULL) {
if (terminal1->diagram()->item_paste) if (terminal1->diagram()->item_paste)
m_frozen_label = ""; m_frozen_label = "";
else else
m_frozen_label = properties_.text; m_frozen_label = m_properties.text;
} }
setFreezeLabel(m_freeze_label); setFreezeLabel(m_freeze_label);
if (properties_.type != ConductorProperties::Multi) if (m_properties.type != ConductorProperties::Multi)
text_item -> setVisible(false); text_item -> setVisible(false);
else else
text_item -> setVisible(properties_.m_show_text); text_item -> setVisible(m_properties.m_show_text);
calculateTextItemPosition(); calculateTextItemPosition();
update(); update();
@@ -1368,8 +1369,9 @@ void Conductor::setProperties(const ConductorProperties &properties)
* @brief Conductor::properties * @brief Conductor::properties
* @return the properties of this Conductor * @return the properties of this Conductor
*/ */
ConductorProperties Conductor::properties() const { ConductorProperties Conductor::properties() const
return(properties_); {
return(m_properties);
} }
/** /**
@@ -1394,11 +1396,11 @@ void Conductor::setHighlighted(Conductor::Highlight hl) {
*/ */
void Conductor::displayedTextChanged() void Conductor::displayedTextChanged()
{ {
if ((text_item->toPlainText() == autonum::AssignVariables::formulaToLabel(properties_.text, m_autoNum_seq, diagram())) || !diagram()) return; if ((text_item->toPlainText() == autonum::AssignVariables::formulaToLabel(m_properties.text, m_autoNum_seq, diagram())) || !diagram()) return;
QVariant old_value, new_value; QVariant old_value, new_value;
old_value.setValue(properties_); old_value.setValue(m_properties);
ConductorProperties new_properties(properties_); ConductorProperties new_properties(m_properties);
new_properties.text = text_item -> toPlainText(); new_properties.text = text_item -> toPlainText();
new_value.setValue(new_properties); new_value.setValue(new_properties);
@@ -1767,14 +1769,14 @@ void Conductor::setFreezeLabel(bool freeze) {
if (m_freeze_label) { if (m_freeze_label) {
QString freezelabel = this->text_item->toPlainText(); QString freezelabel = this->text_item->toPlainText();
m_frozen_label = properties_.text; m_frozen_label = m_properties.text;
this->setText(freezelabel); this->setText(freezelabel);
this->properties_.text = freezelabel; this->m_properties.text = freezelabel;
} }
else { else {
if (m_frozen_label.isEmpty()) if (m_frozen_label.isEmpty())
return; return;
this->setText(m_frozen_label); this->setText(m_frozen_label);
properties_.text = m_frozen_label; m_properties.text = m_frozen_label;
} }
} }

View File

@@ -49,7 +49,6 @@ class Conductor : public QObject, public QGraphicsPathItem
signals: signals:
void propertiesChange(); void propertiesChange();
// constructors, destructor
public: public:
Conductor(Terminal *, Terminal *); Conductor(Terminal *, Terminal *);
virtual ~Conductor(); virtual ~Conductor();
@@ -59,44 +58,41 @@ class Conductor : public QObject, public QGraphicsPathItem
private: private:
Conductor(const Conductor &); Conductor(const Conductor &);
// attributes
public: public:
enum { Type = UserType + 1001 }; enum { Type = UserType + 1001 };
enum Highlight { None, Normal, Alert }; enum Highlight { None, Normal, Alert };
/// First terminal the wire is attached to /// First terminal the wire is attached to
Terminal *terminal1; Terminal *terminal1;
/// Second terminal the wire is attached to /// Second terminal the wire is attached to
Terminal *terminal2; Terminal *terminal2;
// methods
public: public:
/** /**
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a * Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a conductor.
Conductor. * @return the QGraphicsItem type
@return the QGraphicsItem type */
*/ virtual int type() const { return Type; }
virtual int type() const { return Type; } Diagram *diagram() const;
Diagram *diagram() const; ConductorTextItem *textItem() const;
ConductorTextItem *textItem() const; void updatePath(const QRectF & = QRectF());
void updatePath(const QRectF & = QRectF());
//This method do nothing, it's only made to be used with Q_PROPERTY //This method do nothing, it's only made to be used with Q_PROPERTY
//It's used to anim the path when is change //It's used to anim the path when is change
void updatePathAnimate(const int = 1) {updatePath();} void updatePathAnimate(const int = 1) {updatePath();}
int fakePath() {return 1;} int fakePath() {return 1;}
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
QRectF boundingRect() const; QRectF boundingRect() const;
virtual QPainterPath shape() const; virtual QPainterPath shape() const;
virtual QPainterPath nearShape() const; virtual QPainterPath nearShape() const;
qreal length() const; qreal length() const;
ConductorSegment *middleSegment(); ConductorSegment *middleSegment();
QPointF posForText(Qt::Orientations &flag); QPointF posForText(Qt::Orientations &flag);
QString text() const; QString text() const;
void setText(const QString &); void setText(const QString &);
void refreshText(); void refreshText();
void setOthersSequential (Conductor *); void setOthersSequential (Conductor *);
public: public:
static bool valideXml (QDomElement &); static bool valideXml (QDomElement &);
@@ -127,12 +123,11 @@ class Conductor : public QObject, public QGraphicsPathItem
autonum::sequenceStruct m_autoNum_seq; autonum::sequenceStruct m_autoNum_seq;
public: public:
bool setSeq;
void setFreezeLabel(bool freeze); void setFreezeLabel(bool freeze);
QString m_frozen_label; QString m_frozen_label;
public slots: public slots:
void displayedTextChanged(); void displayedTextChanged();
protected: protected:
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
@@ -144,57 +139,56 @@ class Conductor : public QObject, public QGraphicsPathItem
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange, const QVariant &); virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
bool bMouseOver;
private: private:
bool m_mouse_over;
QetGraphicsHandlerUtility m_handler; QetGraphicsHandlerUtility m_handler;
/// Functional properties /// Functional properties
ConductorProperties properties_; ConductorProperties m_properties;
/// Text input for non simple, non-singleline conductors /// Text input for non simple, non-singleline conductors
ConductorTextItem *text_item; ConductorTextItem *text_item;
/// Segments composing the conductor /// Segments composing the conductor
ConductorSegment *segments; ConductorSegment *segments;
/// Attributs related to mouse interaction /// Attributs related to mouse interaction
bool moving_segment; bool moving_segment;
int moved_point; int moved_point;
qreal previous_z_value; qreal previous_z_value;
ConductorSegment *moved_segment; ConductorSegment *moved_segment;
QPointF before_mov_text_pos_; QPointF before_mov_text_pos_;
/// Whether the conductor was manually modified by users /// Whether the conductor was manually modified by users
bool modified_path; bool modified_path;
/// Whether the current profile should be saved as soon as possible /// Whether the current profile should be saved as soon as possible
bool has_to_save_profile; bool has_to_save_profile;
/// conductor profile: "photography" of what the conductor is supposed to look /// conductor profile: "photography" of what the conductor is supposed to look
/// like - there is one profile per kind of traject /// like - there is one profile per kind of traject
ConductorProfilesGroup conductor_profiles; ConductorProfilesGroup conductor_profiles;
/// QPen et QBrush objects used to draw conductors /// QPen et QBrush objects used to draw conductors
static QPen conductor_pen; static QPen conductor_pen;
static QBrush conductor_brush; static QBrush conductor_brush;
static bool pen_and_brush_initialized; static bool pen_and_brush_initialized;
/// Define whether and how the conductor should be highlighted /// Define whether and how the conductor should be highlighted
Highlight must_highlight_; Highlight must_highlight_;
bool m_valid; bool m_valid;
bool m_freeze_label = false; bool m_freeze_label = false;
private: private:
void segmentsToPath(); void segmentsToPath();
void saveProfile(bool = true); void saveProfile(bool = true);
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation); void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation); void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const; uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
QList<QPointF> segmentsToPoints() const; QList<QPointF> segmentsToPoints() const;
QList<ConductorBend> bends() const; QList<ConductorBend> bends() const;
QList<QPointF> junctions() const; QList<QPointF> junctions() const;
void pointsToSegments(QList<QPointF>); void pointsToSegments(QList<QPointF>);
Qt::Corner currentPathType() const; Qt::Corner currentPathType() const;
void deleteSegments(); void deleteSegments();
static int getCoeff(const qreal &, const qreal &); static int getCoeff(const qreal &, const qreal &);
static int getSign(const qreal &); static int getSign(const qreal &);
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const; QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0); static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
static Qt::Corner movementType(const QPointF &, const QPointF &); static Qt::Corner movementType(const QPointF &, const QPointF &);
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &); static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
void loadSequential(QDomElement* e, QString seq, QStringList* list); void loadSequential(QDomElement* e, QString seq, QStringList* list);
}; };
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false); Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);

View File

@@ -604,9 +604,9 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
QUndoCommand *undo = new AddItemCommand<Conductor *>(new_conductor, diagram()); QUndoCommand *undo = new AddItemCommand<Conductor *>(new_conductor, diagram());
if (use_properties) { if (use_properties)
{
Conductor *other = conductors_list.toList().first(); Conductor *other = conductors_list.toList().first();
new_conductor->setSeq = false;
new_conductor->setOthersSequential(other); new_conductor->setOthersSequential(other);
new_conductor->setProperties(others_properties); new_conductor->setProperties(others_properties);
} }
@@ -615,11 +615,11 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
//Autonum it //Autonum it
ConductorAutoNumerotation can (new_conductor, diagram(), undo); ConductorAutoNumerotation can (new_conductor, diagram(), undo);
can.numerate(); can.numerate();
new_conductor->setSeq = true;
} }
//Add undo command to the parent diagram //Add undo command to the parent diagram
diagram() -> undoStack().push(undo); diagram() -> undoStack().push(undo);
if (use_properties) { if (use_properties)
{
Conductor *other = conductors_list.toList().first(); Conductor *other = conductors_list.toList().first();
new_conductor->setText(""); new_conductor->setText("");
new_conductor->setText(other->properties().text); new_conductor->setText(other->properties().text);

View File

@@ -418,14 +418,6 @@ QHash <QString, NumerotationContext> QETProject::elementAutoNum() const {
return m_element_autonum; return m_element_autonum;
} }
/**
* @brief QETProject::conductorAutoNumHash
* @return Title and Formula Hash
*/
QHash <QString, QString> QETProject::conductorAutoNumHash() {
return m_conductor_autonum_formula;
}
/** /**
* @brief QETProject::elementAutoNumFormula * @brief QETProject::elementAutoNumFormula
* @param element autonum title * @param element autonum title
@@ -469,18 +461,12 @@ void QETProject::setCurrrentElementAutonum(QString autoNum) {
* @param conductor autonum title * @param conductor autonum title
* @return Formula of element autonum stored in conductor autonum * @return Formula of element autonum stored in conductor autonum
*/ */
QString QETProject::conductorAutoNumFormula (QString key) const { QString QETProject::conductorAutoNumFormula (QString key) const
{
if (m_conductor_autonum.contains(key)) if (m_conductor_autonum.contains(key))
return m_conductor_autonum_formula[key]; return autonum::numerotationContextToFormula(m_conductor_autonum.value(key));
else return ""; else
} return QString();
/**
* @brief QETProject::conductorAutoNumCurrentFormula
* @return current formula being used by project
*/
QString QETProject::conductorAutoNumCurrentFormula() const {
return m_current_conductor_formula;
} }
/** /**
@@ -518,26 +504,6 @@ void QETProject::addConductorAutoNum(QString key, NumerotationContext context) {
m_conductor_autonum.insert(key, context); m_conductor_autonum.insert(key, context);
} }
/**
* @brief QETProject::addConductorAutoNumFormula
* Add the new formula
* @param formula
*/
void QETProject::addConductorAutoNumFormula(QString key, QString formula) {
m_conductor_autonum_formula.insert(key, formula);
}
/**
* @brief QETProject::setConductorAutoNumCurrentFormula
* Add the formula and title to the current formula and current autonum
* @param formula
* @param title
*/
void QETProject::setConductorAutoNumCurrentFormula(QString formula, QString title) {
m_current_conductor_formula = formula;
m_current_conductor_autonum = title;
}
/** /**
* @brief QETProject::addElementAutoNum * @brief QETProject::addElementAutoNum
* Add a new element numerotation context. If key already exist, * Add a new element numerotation context. If key already exist,
@@ -1471,14 +1437,12 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
if (!conds_autonums.isNull()) if (!conds_autonums.isNull())
{ {
m_current_conductor_autonum = conds_autonums.attribute("current_autonum"); m_current_conductor_autonum = conds_autonums.attribute("current_autonum");
m_current_conductor_formula = conds_autonums.attribute("current_formula");
m_freeze_new_conductors = conds_autonums.attribute("freeze_new_conductors") == "true"; m_freeze_new_conductors = conds_autonums.attribute("freeze_new_conductors") == "true";
foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum")) foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum"))
{ {
NumerotationContext nc; NumerotationContext nc;
nc.fromXml(elmt); nc.fromXml(elmt);
m_conductor_autonum.insert(elmt.attribute("title"), nc); m_conductor_autonum.insert(elmt.attribute("title"), nc);
m_conductor_autonum_formula.insert(elmt.attribute("title"),elmt.attribute("formula"));
} }
} }
if (!folio_autonums.isNull()) if (!folio_autonums.isNull())
@@ -1556,7 +1520,6 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
//Export Conductor Autonums //Export Conductor Autonums
QDomElement conductor_autonums = xml_document.createElement("conductors_autonums"); QDomElement conductor_autonums = xml_document.createElement("conductors_autonums");
conductor_autonums.setAttribute("current_autonum", m_current_conductor_autonum); conductor_autonums.setAttribute("current_autonum", m_current_conductor_autonum);
conductor_autonums.setAttribute("current_formula", m_current_conductor_formula);
conductor_autonums.setAttribute("freeze_new_conductors", m_freeze_new_conductors ? "true" : "false"); conductor_autonums.setAttribute("freeze_new_conductors", m_freeze_new_conductors ? "true" : "false");
foreach (QString key, conductorAutoNum().keys()) { foreach (QString key, conductorAutoNum().keys()) {
QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum"); QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum");

View File

@@ -108,11 +108,8 @@ class QETProject : public QObject
QHash <QString, NumerotationContext> conductorAutoNum() const; QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> elementAutoNum() const; QHash <QString, NumerotationContext> elementAutoNum() const;
QHash <QString, QString> conductorAutoNumHash();
QHash <QString, NumerotationContext> folioAutoNum() const; QHash <QString, NumerotationContext> folioAutoNum() const;
void addConductorAutoNum (QString key, NumerotationContext context); void addConductorAutoNum (QString key, NumerotationContext context);
void addConductorAutoNumFormula (QString key, QString formula);
void setConductorAutoNumCurrentFormula (QString formula, QString title);
void addElementAutoNum (QString key, NumerotationContext context); void addElementAutoNum (QString key, NumerotationContext context);
void addFolioAutoNum (QString key, NumerotationContext context); void addFolioAutoNum (QString key, NumerotationContext context);
void removeConductorAutoNum (QString key); void removeConductorAutoNum (QString key);
@@ -123,7 +120,6 @@ class QETProject : public QObject
NumerotationContext elementAutoNum(const QString &key); NumerotationContext elementAutoNum(const QString &key);
QString conductorAutoNumFormula(const QString key) const; //returns Formula QString conductorAutoNumFormula(const QString key) const; //returns Formula
QString conductorAutoNumCurrentFormula() const;
QString conductorCurrentAutoNum() const; QString conductorCurrentAutoNum() const;
void setCurrentConductorAutoNum(QString autoNum); void setCurrentConductorAutoNum(QString autoNum);
@@ -261,8 +257,6 @@ class QETProject : public QObject
QUndoStack *undo_stack_; QUndoStack *undo_stack_;
/// Conductor auto numerotation /// Conductor auto numerotation
QHash <QString, NumerotationContext> m_conductor_autonum;//Title and NumContext hash QHash <QString, NumerotationContext> m_conductor_autonum;//Title and NumContext hash
QHash <QString, QString> m_conductor_autonum_formula;//Title and Formula hash
QString m_current_conductor_formula;
QString m_current_conductor_autonum; QString m_current_conductor_autonum;
/// Folio auto numbering /// Folio auto numbering
QHash <QString, NumerotationContext> m_folio_autonum; QHash <QString, NumerotationContext> m_folio_autonum;

View File

@@ -75,6 +75,7 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style)); int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style));
if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index); if (index != -1) ui -> m_line_style_cb -> setCurrentIndex(index);
ui->m_formula_le -> setText (m_properties.m_formula);
ui->m_text_le -> setText (m_properties.text); ui->m_text_le -> setText (m_properties.text);
ui->m_function_le -> setText (m_properties.m_function); ui->m_function_le -> setText (m_properties.m_function);
ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol); ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol);
@@ -107,6 +108,7 @@ ConductorProperties ConductorPropertiesWidget::properties() const
properties_.color = ui -> m_color_pb->palette().color(QPalette::Button); 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_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
properties_.m_formula = ui->m_formula_le->text();
properties_.text = ui -> m_text_le -> text(); properties_.text = ui -> m_text_le -> text();
properties_.m_function = ui -> m_function_le->text(); properties_.m_function = ui -> m_function_le->text();
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text(); properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
@@ -188,6 +190,7 @@ void ConductorPropertiesWidget::initWidget() {
connect(ui->m_multiwires_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_singlewire_gb->setChecked(!toggle);}); connect(ui->m_multiwires_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_singlewire_gb->setChecked(!toggle);});
connect(ui->m_singlewire_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_multiwires_gb->setChecked(!toggle);}); connect(ui->m_singlewire_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_multiwires_gb->setChecked(!toggle);});
connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());});
ui->m_multiwires_gb->setChecked(true); ui->m_multiwires_gb->setChecked(true);
ui->m_singlewire_gb->setChecked(true); ui->m_singlewire_gb->setChecked(true);
} }