[qet] qet/qet: [4799] Conductor : formula and text is now two different things. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4799
Author: blacksun
Date: 2016-12-06 20:49:18 +0100 (Tue, 06 Dec 2016)
Log Message:
-----------
Conductor : formula and text is now two different things.
Modified Paths:
--------------
trunk/sources/autoNum/assignvariables.cpp
trunk/sources/autoNum/ui/autonumberingdockwidget.cpp
trunk/sources/conductorautonumerotation.cpp
trunk/sources/conductorautonumerotation.h
trunk/sources/conductorproperties.cpp
trunk/sources/conductorproperties.h
trunk/sources/diagram.cpp
trunk/sources/diagramevent/diagrameventaddelement.cpp
trunk/sources/elementsmover.cpp
trunk/sources/projectconfigpages.cpp
trunk/sources/qetgraphicsitem/conductor.cpp
trunk/sources/qetgraphicsitem/conductor.h
trunk/sources/qetgraphicsitem/terminal.cpp
trunk/sources/qetproject.cpp
trunk/sources/qetproject.h
trunk/sources/ui/conductorpropertieswidget.cpp
Modified: trunk/sources/autoNum/assignvariables.cpp
===================================================================
--- trunk/sources/autoNum/assignvariables.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/autoNum/assignvariables.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -334,7 +334,6 @@
//Add location name to path array
while((current_location.parent() != current_location) && (current_location.parent().fileName() != "import"))
{
- qDebug() << "i = " << i << " " << current_location.fileName();
i++;
path[i]=current_location.fileName();
current_location = current_location.parent();
Modified: trunk/sources/autoNum/ui/autonumberingdockwidget.cpp
===================================================================
--- trunk/sources/autoNum/ui/autonumberingdockwidget.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/autoNum/ui/autonumberingdockwidget.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -191,15 +191,8 @@
void AutoNumberingDockWidget::on_m_conductor_cb_activated(int)
{
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()->loadCndFolioSeq();
}
Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/conductorautonumerotation.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -23,6 +23,7 @@
#include "qet.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "potentialselectordialog.h"
+#include "assignvariables.h"
/**
* @brief ConductorAutoNumerotation::ConductorAutoNumerotation
@@ -36,8 +37,8 @@
*/
ConductorAutoNumerotation::ConductorAutoNumerotation(Conductor *conductor, Diagram *diagram, QUndoCommand *parent_undo) :
m_diagram (diagram),
- conductor_ (conductor),
- conductor_list (conductor -> relatedPotentialConductors()),
+ m_conductor (conductor),
+ conductor_list (conductor -> relatedPotentialConductors().toList()),
m_parent_undo (parent_undo)
{}
@@ -46,9 +47,9 @@
* execute the automatic numerotation
*/
void ConductorAutoNumerotation::numerate() {
- if (!conductor_) return;
+ if (!m_conductor) return;
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::applyText(QString t)
{
- if (!conductor_) return;
+ if (!m_conductor) return;
QVariant old_value, new_value;
- ConductorProperties cp = conductor_ -> properties();
+ ConductorProperties cp = m_conductor -> properties();
old_value.setValue(cp);
cp.text = t;
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"));
if (!conductor_list.isEmpty())
@@ -91,21 +92,30 @@
*/
void ConductorAutoNumerotation::numeratePotential()
{
- QStringList strl;
- foreach (const Conductor *cc, conductor_list) strl<<(cc->text());
+ QStringList text_list;
+ 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
- if (QET::eachStrIsEqual(strl))
+ if (QET::eachStrIsEqual(text_list) && QET::eachStrIsEqual(formula_list))
{
- ConductorProperties cp = conductor_ -> properties();
- cp.text = strl.at(0);
- conductor_ -> setProperties(cp);
- conductor_ -> setText(strl.at(0));
+ ConductorProperties cp = m_conductor -> properties();
+ cp.text = text_list.first();
+ cp.m_formula = formula_list.first();
+ m_conductor->setProperties(cp);
+ m_conductor->setOthersSequential(conductor_list.first());
+ m_conductor->setText(text_list.first());
}
//the texts isn't identicals
else
{
- PotentialSelectorDialog psd(conductor_, m_parent_undo, conductor_->diagramEditor());
+ PotentialSelectorDialog psd(m_conductor, m_parent_undo, m_conductor->diagramEditor());
psd.exec();
}
}
@@ -112,14 +122,28 @@
/**
* @brief ConductorAutoNumerotation::numerateNewConductor
- * create and apply a new numerotation to @conductor_
+ * create and apply a new numerotation to @m_conductor
*/
-void ConductorAutoNumerotation::numerateNewConductor() {
- if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
+void ConductorAutoNumerotation::numerateNewConductor()
+{
+ if (!m_conductor || m_diagram->conductorsAutonumName().isEmpty())
+ return;
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);
- applyText(m_diagram->project()->conductorAutoNumCurrentFormula());
+ m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
+
+ applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceStruct(), m_diagram));
}
Modified: trunk/sources/conductorautonumerotation.h
===================================================================
--- trunk/sources/conductorautonumerotation.h 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/conductorautonumerotation.h 2016-12-06 19:49:18 UTC (rev 4799)
@@ -18,7 +18,7 @@
#ifndef CONDUCTORAUTONUMEROTATION_H
#define CONDUCTORAUTONUMEROTATION_H
-#include <QSet>
+#include <QList>
class Diagram;
class Conductor;
@@ -41,8 +41,8 @@
//attributes
Diagram *m_diagram;
- Conductor *conductor_;
- QSet <Conductor *> conductor_list;
+ Conductor *m_conductor;
+ QList <Conductor *> conductor_list;
QUndoCommand *m_parent_undo;
};
Modified: trunk/sources/conductorproperties.cpp
===================================================================
--- trunk/sources/conductorproperties.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/conductorproperties.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -254,6 +254,7 @@
singleLineProperties.toXml(e);
e.setAttribute("num", text);
+ e.setAttribute("formula", m_formula);
e.setAttribute("function", m_function);
e.setAttribute("tension-protocol", m_tension_protocol);
e.setAttribute("numsize", QString::number(text_size));
@@ -293,6 +294,7 @@
type = Multi;
text = e.attribute("num");
+ m_formula = e.attribute("formula");
m_function = e.attribute("function");
m_tension_protocol = e.attribute("tension-protocol");
text_size = e.attribute("numsize", QString::number(9)).toInt();
@@ -318,6 +320,7 @@
settings.setValue(prefix + "style", writeStyle());
settings.setValue(prefix + "type", typeToString(type));
settings.setValue(prefix + "text", text);
+ settings.setValue(prefix + "formula", m_formula);
settings.setValue(prefix + "function", m_function);
settings.setValue(prefix + "tension-protocol", m_tension_protocol);
settings.setValue(prefix + "textsize", QString::number(text_size));
@@ -344,6 +347,7 @@
singleLineProperties.fromSettings(settings, prefix);
text = settings.value(prefix + "text", "_").toString();
+ m_formula = settings.value(prefix + "formula", "").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();
@@ -391,15 +395,18 @@
}
/**
- @param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
- @return true si les deux ensembles de proprietes sont identiques, false sinon
-*/
-bool ConductorProperties::operator==(const ConductorProperties &other) const{
+ * @brief ConductorProperties::operator ==
+ * @param other
+ * @return true if other == this
+ */
+bool ConductorProperties::operator==(const ConductorProperties &other) const
+{
return(
other.type == type &&\
other.color == color &&\
other.style == style &&\
other.text == text &&\
+ other.m_formula == m_formula &&\
other.m_function == m_function &&\
other.m_tension_protocol == m_tension_protocol &&\
other.m_show_text == m_show_text &&\
Modified: trunk/sources/conductorproperties.h
===================================================================
--- trunk/sources/conductorproperties.h 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/conductorproperties.h 2016-12-06 19:49:18 UTC (rev 4799)
@@ -80,7 +80,8 @@
QColor color;
QString text,
m_function,
- m_tension_protocol;
+ m_tension_protocol,
+ m_formula;
int text_size;
double cond_size;
double verti_rotate_text;
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/diagram.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -1294,11 +1294,12 @@
//Conductor
QString title = project()->conductorCurrentAutoNum();
NumerotationContext nc = project()->conductorAutoNum(title);
+ QString formula = autonum::numerotationContextToFormula(nc);
//Unit Folio
if (m_cnd_unitfolio_max.isEmpty() || !m_cnd_unitfolio_max.contains(title)) {
//Insert Initial Value
- if (project()->conductorAutoNumCurrentFormula().contains("%sequf_")) {
+ if (formula.contains("%sequf_")) {
insertFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1305,7 +1306,7 @@
}
else if (m_cnd_unitfolio_max.contains(title)) {
//Load Folio Current Value
- if (project()->conductorAutoNumCurrentFormula().contains("%sequf_")) {
+ if (formula.contains("%sequf_")) {
loadFolioSeqHash(&m_cnd_unitfolio_max,title,"unitfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1314,7 +1315,7 @@
//Ten Folio
if (m_cnd_tenfolio_max.isEmpty() || !m_cnd_tenfolio_max.contains(title)) {
//Insert Initial Value
- if (project()->conductorAutoNumCurrentFormula().contains("%seqtf_")) {
+ if (formula.contains("%seqtf_")) {
insertFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1321,7 +1322,7 @@
}
else if (m_cnd_tenfolio_max.contains(title)) {
//Load Folio Current Value
- if (project()->conductorAutoNumCurrentFormula().contains("%seqtf_")) {
+ if (formula.contains("%seqtf_")) {
loadFolioSeqHash(&m_cnd_tenfolio_max,title,"tenfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1330,7 +1331,7 @@
//Hundred Folio
if (m_cnd_hundredfolio_max.isEmpty() || !m_cnd_hundredfolio_max.contains(title)) {
//Insert Initial Value
- if (project()->conductorAutoNumCurrentFormula().contains("%seqhf_")) {
+ if (formula.contains("%seqhf_")) {
insertFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1337,7 +1338,7 @@
}
else if (m_cnd_hundredfolio_max.contains(title)) {
//Load Folio Current Value
- if (project()->conductorAutoNumCurrentFormula().contains("%seqhf_")) {
+ if (formula.contains("%seqhf_")) {
loadFolioSeqHash(&m_cnd_hundredfolio_max,title,"hundredfolio",&nc);
project()->addConductorAutoNum(title,nc);
}
Modified: trunk/sources/diagramevent/diagrameventaddelement.cpp
===================================================================
--- trunk/sources/diagramevent/diagrameventaddelement.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/diagramevent/diagrameventaddelement.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -225,14 +225,11 @@
QPair <Terminal *, Terminal *> pair = element -> AlignedFreeTerminals().takeFirst();
Conductor *conductor = new Conductor(pair.first, pair.second);
- conductor -> setProperties(m_diagram -> defaultConductorProperties);
-
new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF(), undo_object);
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, m_diagram, undo_object);
can.numerate();
- conductor->setSeq = true;
if (m_diagram->freezeNewConductors() || m_diagram->project()->freezeNewConductors()) {
conductor->setFreezeLabel(true);
}
Modified: trunk/sources/elementsmover.cpp
===================================================================
--- trunk/sources/elementsmover.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/elementsmover.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -181,7 +181,6 @@
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, diagram_, undo_object);
can.numerate();
- conductor->setSeq = true;
}
};
}
Modified: trunk/sources/projectconfigpages.cpp
===================================================================
--- trunk/sources/projectconfigpages.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/projectconfigpages.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -532,23 +532,23 @@
void ProjectAutoNumConfigPage::saveContext_conductor() {
// If the text is the default text "Name of new numerotation" save the edited context
// 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());
- project()->addConductorAutoNumFormula (tr("Sans nom"), m_saw_conductor->formula()); //add hash <title, formula>
- project()->setConductorAutoNumCurrentFormula (m_saw_conductor->formula(),tr("Sans nom")); //add last added conductor formula to current formula
+ project()->setCurrentConductorAutoNum(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.
- 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()->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_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 {
- 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
+ else
+ {
+ project()->setCurrentConductorAutoNum(m_context_cb_conductor->currentText());
m_project->addConductorAutoNum (m_context_cb_conductor-> currentText(), m_saw_conductor -> toNumContext());
}
project()->conductorAutoNumAdded();
Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/qetgraphicsitem/conductor.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -47,8 +47,7 @@
QGraphicsPathItem(0),
terminal1(p1),
terminal2(p2),
- setSeq(true),
- bMouseOver(false),
+ m_mouse_over(false),
m_handler(10),
text_item(0),
segments(NULL),
@@ -59,9 +58,9 @@
{
//Set the default conductor properties.
if (p1->diagram())
- properties_ = p1->diagram()->defaultConductorProperties;
+ m_properties = p1->diagram()->defaultConductorProperties;
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
setZValue(11);
@@ -98,7 +97,7 @@
setAcceptHoverEvents(true);
// 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);
}
@@ -439,7 +438,7 @@
qp -> setRenderHint(QPainter::Antialiasing, false);
// determine la couleur du conducteur
- QColor final_conductor_color(properties_.color);
+ QColor final_conductor_color(m_properties.color);
if (must_highlight_ == Normal) {
final_conductor_color = QColor::fromRgb(69, 137, 255, 255);
} else if (must_highlight_ == Alert) {
@@ -455,7 +454,7 @@
}
//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
qp -> setBrush(conductor_brush);
@@ -463,7 +462,7 @@
// modification du QPen generique pour lui affecter la couleur et le style adequats
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
// utilisation d'un trait "cosmetique" en-dessous d'un certain zoom
@@ -475,9 +474,9 @@
// dessin du conducteur
qp -> drawPath(path());
- if (properties_.type == ConductorProperties::Single) {
+ if (m_properties.type == ConductorProperties::Single) {
qp -> setBrush(final_conductor_color);
- properties_.singleLineProperties.draw(
+ m_properties.singleLineProperties.draw(
qp,
middleSegment() -> isHorizontal() ? QET::Horizontal : QET::Vertical,
QRectF(middleSegment() -> middle() - QPointF(12.0, 12.0), QSizeF(24.0, 24.0))
@@ -633,7 +632,7 @@
*/
void Conductor::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event);
- bMouseOver = true;
+ m_mouse_over = true;
update();
}
@@ -645,7 +644,7 @@
void Conductor::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
Q_UNUSED(event);
update();
- bMouseOver = false;
+ m_mouse_over = false;
}
/**
@@ -719,7 +718,7 @@
QPainterPath Conductor::shape() const
{
QPainterPathStroker pps;
- pps.setWidth(bMouseOver? 5 : 1);
+ pps.setWidth(m_mouse_over? 5 : 1);
pps.setJoinStyle(conductor_pen.joinStyle());
QPainterPath shape_(pps.createStroke(path()));
@@ -850,14 +849,15 @@
@param Qstring seq to be retrieved
@param QStringList list to be inserted values
*/
-void Conductor::loadSequential(QDomElement* e, QString seq, QStringList* list) {
- //Load Sequential Values
+void Conductor::loadSequential(QDomElement* e, QString seq, QStringList* list)
+{
+ //Load Sequential Values
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)));
i++;
}
- setSeq = false;
}
/**
@@ -922,7 +922,7 @@
if (m_frozen_label != "") e.setAttribute("frozenlabel", m_frozen_label);
// Export the properties and text
- properties_. toXml(e);
+ m_properties. toXml(e);
text_item -> toXml(e);
return(e);
@@ -1144,7 +1144,7 @@
* If text was moved by user, this function do nothing, except check if text is near conductor.
*/
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 &&
relatedPotentialConductors(false).size() > 0) {
@@ -1181,8 +1181,8 @@
QPointF text_pos = posForText(rotation);
if (!text_item -> wasRotateByUser()) {
- rotation == Qt::Vertical ? text_item -> setRotationAngle(properties_.verti_rotate_text):
- text_item -> setRotationAngle(properties_.horiz_rotate_text);
+ rotation == Qt::Vertical ? text_item -> setRotationAngle(m_properties.verti_rotate_text):
+ text_item -> setRotationAngle(m_properties.horiz_rotate_text);
}
//Adjust the position of text if his rotation
@@ -1292,23 +1292,24 @@
void Conductor::setText(const QString &t)
{
text_item->setPlainText(t);
- if (setSeq && diagram())
- {
- QString conductor_currentAutoNum = diagram()->project()->conductorCurrentAutoNum();
- NumerotationContext nc = diagram()->project()->conductorAutoNum(conductor_currentAutoNum);
+// text_item->setPlainText(t);
+// if (setSeq && diagram())
+// {
+// 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);
- diagram()->project()->addConductorAutoNum(conductor_currentAutoNum, ncc.next());
+// NumerotationContextCommands ncc (nc);
+// diagram()->project()->addConductorAutoNum(conductor_currentAutoNum, ncc.next());
- setSeq = false;
- }
- if (diagram())
- {
- QString label = autonum::AssignVariables::formulaToLabel(t, m_autoNum_seq, diagram());
- text_item -> setPlainText(label);
- }
+// setSeq = false;
+// }
+// if (diagram())
+// {
+// QString label = autonum::AssignVariables::formulaToLabel(t, m_autoNum_seq, diagram());
+// text_item -> setPlainText(label);
+// }
}
/**
@@ -1329,35 +1330,35 @@
*/
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())
{
ConductorProperties other_properties = other_conductor->properties();
- other_properties.text = properties_.text;
- other_properties.color = properties_.color;
- other_properties.cond_size = properties_.cond_size;
- other_properties.m_function = properties_.m_function;
- other_properties.m_tension_protocol = properties_.m_tension_protocol;
+ other_properties.text = m_properties.text;
+ other_properties.color = m_properties.color;
+ other_properties.cond_size = m_properties.cond_size;
+ other_properties.m_function = m_properties.m_function;
+ other_properties.m_tension_protocol = m_properties.m_tension_protocol;
other_conductor->setProperties(other_properties);
}
- setText(properties_.text);
- text_item -> setFontSize(properties_.text_size);
+ setText(m_properties.text);
+ text_item -> setFontSize(m_properties.text_size);
if (terminal1 != NULL && terminal1->diagram() != NULL) {
if (terminal1->diagram()->item_paste)
m_frozen_label = "";
else
- m_frozen_label = properties_.text;
+ m_frozen_label = m_properties.text;
}
setFreezeLabel(m_freeze_label);
- if (properties_.type != ConductorProperties::Multi)
+ if (m_properties.type != ConductorProperties::Multi)
text_item -> setVisible(false);
else
- text_item -> setVisible(properties_.m_show_text);
+ text_item -> setVisible(m_properties.m_show_text);
calculateTextItemPosition();
update();
@@ -1368,8 +1369,9 @@
* @brief Conductor::properties
* @return the properties of this Conductor
*/
-ConductorProperties Conductor::properties() const {
- return(properties_);
+ConductorProperties Conductor::properties() const
+{
+ return(m_properties);
}
/**
@@ -1394,11 +1396,11 @@
*/
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;
- old_value.setValue(properties_);
- ConductorProperties new_properties(properties_);
+ old_value.setValue(m_properties);
+ ConductorProperties new_properties(m_properties);
new_properties.text = text_item -> toPlainText();
new_value.setValue(new_properties);
@@ -1767,14 +1769,14 @@
if (m_freeze_label) {
QString freezelabel = this->text_item->toPlainText();
- m_frozen_label = properties_.text;
+ m_frozen_label = m_properties.text;
this->setText(freezelabel);
- this->properties_.text = freezelabel;
+ this->m_properties.text = freezelabel;
}
else {
if (m_frozen_label.isEmpty())
return;
this->setText(m_frozen_label);
- properties_.text = m_frozen_label;
+ m_properties.text = m_frozen_label;
}
}
Modified: trunk/sources/qetgraphicsitem/conductor.h
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.h 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/qetgraphicsitem/conductor.h 2016-12-06 19:49:18 UTC (rev 4799)
@@ -49,7 +49,6 @@
signals:
void propertiesChange();
- // constructors, destructor
public:
Conductor(Terminal *, Terminal *);
virtual ~Conductor();
@@ -59,44 +58,41 @@
private:
Conductor(const Conductor &);
- // attributes
public:
- enum { Type = UserType + 1001 };
- enum Highlight { None, Normal, Alert };
+ enum { Type = UserType + 1001 };
+ enum Highlight { None, Normal, Alert };
+
+ /// First terminal the wire is attached to
+ Terminal *terminal1;
+ /// Second terminal the wire is attached to
+ Terminal *terminal2;
- /// First terminal the wire is attached to
- Terminal *terminal1;
- /// Second terminal the wire is attached to
- Terminal *terminal2;
-
- // methods
public:
- /**
- Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
- Conductor.
- @return the QGraphicsItem type
- */
- virtual int type() const { return Type; }
- Diagram *diagram() const;
- ConductorTextItem *textItem() const;
- void updatePath(const QRectF & = QRectF());
+ /**
+ * Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a conductor.
+ * @return the QGraphicsItem type
+ */
+ virtual int type() const { return Type; }
+ Diagram *diagram() const;
+ ConductorTextItem *textItem() const;
+ void updatePath(const QRectF & = QRectF());
- //This method do nothing, it's only made to be used with Q_PROPERTY
- //It's used to anim the path when is change
- void updatePathAnimate(const int = 1) {updatePath();}
- int fakePath() {return 1;}
+ //This method do nothing, it's only made to be used with Q_PROPERTY
+ //It's used to anim the path when is change
+ void updatePathAnimate(const int = 1) {updatePath();}
+ int fakePath() {return 1;}
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
- QRectF boundingRect() const;
- virtual QPainterPath shape() const;
- virtual QPainterPath nearShape() const;
- qreal length() const;
- ConductorSegment *middleSegment();
- QPointF posForText(Qt::Orientations &flag);
- QString text() const;
- void setText(const QString &);
- void refreshText();
- void setOthersSequential (Conductor *);
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ QRectF boundingRect() const;
+ virtual QPainterPath shape() const;
+ virtual QPainterPath nearShape() const;
+ qreal length() const;
+ ConductorSegment *middleSegment();
+ QPointF posForText(Qt::Orientations &flag);
+ QString text() const;
+ void setText(const QString &);
+ void refreshText();
+ void setOthersSequential (Conductor *);
public:
static bool valideXml (QDomElement &);
@@ -127,12 +123,11 @@
autonum::sequenceStruct m_autoNum_seq;
public:
- bool setSeq;
void setFreezeLabel(bool freeze);
QString m_frozen_label;
public slots:
- void displayedTextChanged();
+ void displayedTextChanged();
protected:
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
@@ -143,58 +138,57 @@
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
-
- bool bMouseOver;
private:
+ bool m_mouse_over;
QetGraphicsHandlerUtility m_handler;
/// Functional properties
- ConductorProperties properties_;
+ ConductorProperties m_properties;
/// Text input for non simple, non-singleline conductors
- ConductorTextItem *text_item;
+ ConductorTextItem *text_item;
/// Segments composing the conductor
- ConductorSegment *segments;
+ ConductorSegment *segments;
/// Attributs related to mouse interaction
- bool moving_segment;
- int moved_point;
- qreal previous_z_value;
- ConductorSegment *moved_segment;
- QPointF before_mov_text_pos_;
+ bool moving_segment;
+ int moved_point;
+ qreal previous_z_value;
+ ConductorSegment *moved_segment;
+ QPointF before_mov_text_pos_;
/// 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
- bool has_to_save_profile;
+ bool has_to_save_profile;
/// conductor profile: "photography" of what the conductor is supposed to look
/// like - there is one profile per kind of traject
- ConductorProfilesGroup conductor_profiles;
+ ConductorProfilesGroup conductor_profiles;
/// QPen et QBrush objects used to draw conductors
- static QPen conductor_pen;
- static QBrush conductor_brush;
- static bool pen_and_brush_initialized;
+ static QPen conductor_pen;
+ static QBrush conductor_brush;
+ static bool pen_and_brush_initialized;
/// Define whether and how the conductor should be highlighted
- Highlight must_highlight_;
- bool m_valid;
- bool m_freeze_label = false;
+ Highlight must_highlight_;
+ bool m_valid;
+ bool m_freeze_label = false;
private:
- void segmentsToPath();
- void saveProfile(bool = true);
- void generateConductorPath(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;
- QList<QPointF> segmentsToPoints() const;
- QList<ConductorBend> bends() const;
- QList<QPointF> junctions() const;
- void pointsToSegments(QList<QPointF>);
- Qt::Corner currentPathType() const;
- void deleteSegments();
- static int getCoeff(const qreal &, const qreal &);
- static int getSign(const qreal &);
- 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 Qt::Corner movementType(const QPointF &, const QPointF &);
- static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
- void loadSequential(QDomElement* e, QString seq, QStringList* list);
+ void segmentsToPath();
+ void saveProfile(bool = true);
+ void generateConductorPath(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;
+ QList<QPointF> segmentsToPoints() const;
+ QList<ConductorBend> bends() const;
+ QList<QPointF> junctions() const;
+ void pointsToSegments(QList<QPointF>);
+ Qt::Corner currentPathType() const;
+ void deleteSegments();
+ static int getCoeff(const qreal &, const qreal &);
+ static int getSign(const qreal &);
+ 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 Qt::Corner movementType(const QPointF &, const QPointF &);
+ static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
+ void loadSequential(QDomElement* e, QString seq, QStringList* list);
};
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);
Modified: trunk/sources/qetgraphicsitem/terminal.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/terminal.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/qetgraphicsitem/terminal.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -604,9 +604,9 @@
QUndoCommand *undo = new AddItemCommand<Conductor *>(new_conductor, diagram());
- if (use_properties) {
+ if (use_properties)
+ {
Conductor *other = conductors_list.toList().first();
- new_conductor->setSeq = false;
new_conductor->setOthersSequential(other);
new_conductor->setProperties(others_properties);
}
@@ -615,11 +615,11 @@
//Autonum it
ConductorAutoNumerotation can (new_conductor, diagram(), undo);
can.numerate();
- new_conductor->setSeq = true;
}
//Add undo command to the parent diagram
diagram() -> undoStack().push(undo);
- if (use_properties) {
+ if (use_properties)
+ {
Conductor *other = conductors_list.toList().first();
new_conductor->setText("");
new_conductor->setText(other->properties().text);
Modified: trunk/sources/qetproject.cpp
===================================================================
--- trunk/sources/qetproject.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/qetproject.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -419,14 +419,6 @@
}
/**
- * @brief QETProject::conductorAutoNumHash
- * @return Title and Formula Hash
- */
-QHash <QString, QString> QETProject::conductorAutoNumHash() {
- return m_conductor_autonum_formula;
-}
-
-/**
* @brief QETProject::elementAutoNumFormula
* @param element autonum title
* @return Formula of element autonum stored in element autonum
@@ -469,21 +461,15 @@
* @param conductor autonum title
* @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))
- return m_conductor_autonum_formula[key];
- else return "";
+ return autonum::numerotationContextToFormula(m_conductor_autonum.value(key));
+ else
+ return QString();
}
/**
- * @brief QETProject::conductorAutoNumCurrentFormula
- * @return current formula being used by project
- */
-QString QETProject::conductorAutoNumCurrentFormula() const {
- return m_current_conductor_formula;
-}
-
-/**
* @brief QETProject::conductorCurrentAutoNum
* @return current conductor autonum title
*/
@@ -519,26 +505,6 @@
}
/**
- * @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
* Add a new element numerotation context. If key already exist,
* replace old context by the new context
@@ -1471,7 +1437,6 @@
if (!conds_autonums.isNull())
{
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";
foreach (QDomElement elmt, QET::findInDomElement(conds_autonums, "conductor_autonum"))
{
@@ -1478,7 +1443,6 @@
NumerotationContext nc;
nc.fromXml(elmt);
m_conductor_autonum.insert(elmt.attribute("title"), nc);
- m_conductor_autonum_formula.insert(elmt.attribute("title"),elmt.attribute("formula"));
}
}
if (!folio_autonums.isNull())
@@ -1556,7 +1520,6 @@
//Export Conductor Autonums
QDomElement conductor_autonums = xml_document.createElement("conductors_autonums");
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");
foreach (QString key, conductorAutoNum().keys()) {
QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum");
Modified: trunk/sources/qetproject.h
===================================================================
--- trunk/sources/qetproject.h 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/qetproject.h 2016-12-06 19:49:18 UTC (rev 4799)
@@ -108,11 +108,8 @@
QHash <QString, NumerotationContext> conductorAutoNum() const;
QHash <QString, NumerotationContext> elementAutoNum() const;
- QHash <QString, QString> conductorAutoNumHash();
QHash <QString, NumerotationContext> folioAutoNum() const;
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 addFolioAutoNum (QString key, NumerotationContext context);
void removeConductorAutoNum (QString key);
@@ -123,7 +120,6 @@
NumerotationContext elementAutoNum(const QString &key);
QString conductorAutoNumFormula(const QString key) const; //returns Formula
- QString conductorAutoNumCurrentFormula() const;
QString conductorCurrentAutoNum() const;
void setCurrentConductorAutoNum(QString autoNum);
@@ -261,8 +257,6 @@
QUndoStack *undo_stack_;
/// Conductor auto numerotation
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;
/// Folio auto numbering
QHash <QString, NumerotationContext> m_folio_autonum;
Modified: trunk/sources/ui/conductorpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/conductorpropertieswidget.cpp 2016-12-04 03:50:12 UTC (rev 4798)
+++ trunk/sources/ui/conductorpropertieswidget.cpp 2016-12-06 19:49:18 UTC (rev 4799)
@@ -75,6 +75,7 @@
int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style));
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_function_le -> setText (m_properties.m_function);
ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol);
@@ -107,6 +108,7 @@
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_.m_formula = ui->m_formula_le->text();
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();
@@ -188,6 +190,7 @@
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_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());});
ui->m_multiwires_gb->setChecked(true);
ui->m_singlewire_gb->setChecked(true);
}