mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-03 18:44:13 +02:00
6f7e537db3
Reported by @scorpio810 on #632 with a screenshot: a "Chiffre 1" followed by
a "Cyclique (modulo) 8" numbers elements 0..7 and then jumps straight to 9,
never showing 8, and never producing the 0-7 / 10-17 / 20-27 pattern the
feature exists for.
The cause is that the wrap-and-carry feature shipped without its rendering
half. Commit 68c2603 added the arithmetic and the editor UI across seven
files, none of them assignvariables.*, so there is no %seqw_ variable, no
wrap list in sequentialNumbers, no branch in setSequential(), and no branch
in numerotationContextToFormula(). A cyclic part therefore contributes
nothing to the generated formula and cannot be referenced from one -- it is
invisible.
Invisible but not inert: it still advances and still carries. So the digit
in front of it receives +1 from the carry on top of its own increment, and
the only digit the label does show jumps by two. That is the missing 8.
Add the missing half:
- sequentialNumbers gains a wrap list, handled in the copy constructor,
assignment, comparison, clear(), toXml() and fromXml();
- setSequential() collects wrap parts when the label uses %seqw_;
- assignSequence() substitutes %seqw_N and counts wrap in its bound, so a
context whose only counter is cyclic still resolves;
- numerotationContextToFormula() emits %seqw_N, so adding a Cyclique part
in the editor now puts a token in the formula instead of nothing.
Old projects are unaffected: <wrap> is simply absent from files written
before this, which fromXml() reads as an empty list, and such files have no
cyclic parts to reference in the first place. An older QET reading a newer
file ignores the unknown child.
Measured on the exact configuration from the report, unit + wrap(mod 8):
formula generated %sequ_1%seqw_1 (was %sequ_1 -- wrap contributed none)
carry digit increment 1 00 11 22 33 44 55 66 77 90 101 112 ...
carry digit increment 0 00 01 02 03 04 05 06 07 10 11 ... 17 20 21
The second line is the requested pattern. The first shows what is left once
the rendering is fixed but the carry digit still increments itself as well
as receiving the carry -- worth a UI decision, noted on the PR.
96 lines
3.2 KiB
C++
96 lines
3.2 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef ASSIGNVARIABLES_H
|
|
#define ASSIGNVARIABLES_H
|
|
#include "../diagramcontext.h"
|
|
#include "numerotationcontext.h"
|
|
|
|
#include <QPointF>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
class Conductor;
|
|
class Diagram;
|
|
class Element;
|
|
class ElementsLocation;
|
|
|
|
namespace autonum
|
|
{
|
|
class sequentialNumbers
|
|
{
|
|
public:
|
|
sequentialNumbers();
|
|
sequentialNumbers(const sequentialNumbers &other);
|
|
~sequentialNumbers();
|
|
|
|
sequentialNumbers &operator= (const sequentialNumbers &other);
|
|
bool operator== (const sequentialNumbers &other) const;
|
|
bool operator!= (const sequentialNumbers &other) const;
|
|
|
|
QDomElement toXml(QDomDocument &document, const QString& tag_name = QString("sequentialNumbers")) const;
|
|
void fromXml(const QDomElement &element);
|
|
void clear();
|
|
|
|
QStringList unit;
|
|
/// Values of the cyclic (modulo) parts, referenced by %seqw_N.
|
|
QStringList wrap;
|
|
QStringList unit_folio;
|
|
QStringList ten;
|
|
QStringList ten_folio;
|
|
QStringList hundred;
|
|
QStringList hundred_folio;
|
|
QStringList alpha;
|
|
};
|
|
|
|
/**
|
|
@brief The AssignVariables class
|
|
This class assign variable of a formula string.
|
|
Return the final string used to be displayed from a formula string.
|
|
*/
|
|
class AssignVariables
|
|
{
|
|
public:
|
|
static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr, const Conductor *cndr = nullptr);
|
|
static QString replaceVariable (const QString &formula, const DiagramContext &dc);
|
|
static QString genericXref (const Element *element);
|
|
|
|
private:
|
|
AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt = nullptr, const Conductor *cndr = nullptr);
|
|
void assignTitleBlockVar();
|
|
void assignProjectVar();
|
|
void assignSequence();
|
|
|
|
Diagram *m_diagram = nullptr;
|
|
QString m_arg_formula;
|
|
QString m_assigned_label;
|
|
sequentialNumbers m_seq_struct;
|
|
const Element *m_element = nullptr;
|
|
const Conductor *m_conductor = nullptr;
|
|
};
|
|
|
|
void setSequentialToList(QStringList &list, NumerotationContext &nc, const QString& type);
|
|
void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, const QString& autoNumName);
|
|
void setSequential(const QString& label, autonum::sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, const QString& hashKey);
|
|
QString numerotationContextToFormula(const NumerotationContext &nc);
|
|
QString elementPrefixForLocation(const ElementsLocation &location);
|
|
}
|
|
|
|
Q_DECLARE_METATYPE(autonum::sequentialNumbers)
|
|
|
|
#endif // ASSIGNVARIABLES_H
|