mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 23:54:13 +02:00
Merge remote-tracking branch 'upstream/master' into prefix-button
Conflicts in cmake/qet_compilation_vars.cmake only, where upstream added terminaluuids.cpp/.h next to the qetlabelsfile.cpp/.h this branch adds : both are kept, qetlabelsfile first to stay alphabetical.
This commit is contained in:
@@ -221,12 +221,56 @@ namespace autonum
|
||||
Diagram *diagram,
|
||||
const Element *elmt,
|
||||
const Conductor *cndr)
|
||||
{
|
||||
if (!diagram) {
|
||||
return formula;
|
||||
}
|
||||
|
||||
FormulaContext context;
|
||||
const BorderTitleBlock &border = diagram->border_and_titleblock;
|
||||
context.folio = border.folio();
|
||||
context.folio_index = diagram->folioIndex();
|
||||
context.folio_total = border.folioTotal();
|
||||
context.plant = border.plant();
|
||||
context.locmach = border.locmach();
|
||||
context.title_block_fields = border.additionalFields();
|
||||
context.project_properties = diagram->project()->projectProperties();
|
||||
if (elmt)
|
||||
{
|
||||
context.has_element = true;
|
||||
context.element_position = diagram->convertPosition(elmt->scenePos());
|
||||
context.element_prefix = elmt->getPrefix();
|
||||
}
|
||||
if (cndr)
|
||||
{
|
||||
context.has_conductor = true;
|
||||
context.wire_function = cndr->properties().m_function;
|
||||
context.wire_tension_protocol = cndr->properties().m_tension_protocol;
|
||||
context.wire_color = cndr->properties().m_wire_color;
|
||||
context.wire_section = cndr->properties().m_wire_section;
|
||||
}
|
||||
return formulaToLabel(std::move(formula), seqStruct, context);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief AssignVariables::formulaToLabel
|
||||
Return the formula with its variables assigned from @p context,
|
||||
which describes a folio and the element or conductor the formula
|
||||
belongs to without needing either to be built.
|
||||
@param formula - the formula to work
|
||||
@param seqStruct - struct where is stocked int values
|
||||
(struct is passed as a reference
|
||||
and modified by this static method)
|
||||
@param context - what the variables are read from
|
||||
@return the string with variable assigned.
|
||||
*/
|
||||
QString AssignVariables::formulaToLabel(QString formula,
|
||||
sequentialNumbers &seqStruct,
|
||||
const FormulaContext &context)
|
||||
{
|
||||
AssignVariables av(std::move(formula),
|
||||
seqStruct,
|
||||
diagram,
|
||||
elmt,
|
||||
cndr);
|
||||
context);
|
||||
seqStruct = av.m_seq_struct;
|
||||
return av.m_assigned_label;
|
||||
}
|
||||
@@ -348,76 +392,54 @@ namespace autonum
|
||||
|
||||
AssignVariables::AssignVariables(const QString& formula,
|
||||
const sequentialNumbers& seqStruct,
|
||||
Diagram *diagram,
|
||||
const Element *elmt,
|
||||
const Conductor *cndr):
|
||||
m_diagram(diagram),
|
||||
const FormulaContext &context):
|
||||
m_context(context),
|
||||
m_arg_formula(formula),
|
||||
m_assigned_label(formula),
|
||||
m_seq_struct(seqStruct),
|
||||
m_element(elmt),
|
||||
m_conductor(cndr)
|
||||
m_seq_struct(seqStruct)
|
||||
{
|
||||
if (m_diagram)
|
||||
m_assigned_label.replace("%F", m_context.folio);
|
||||
m_assigned_label.replace("%f",
|
||||
QString::number(m_context.folio_index+1));
|
||||
m_assigned_label.replace("%id",
|
||||
QString::number(m_context.folio_index+1));
|
||||
m_assigned_label.replace("%total",
|
||||
QString::number(m_context.folio_total));
|
||||
m_assigned_label.replace("%M", m_context.plant);
|
||||
m_assigned_label.replace("%LM", m_context.locmach);
|
||||
|
||||
QSettings settings;
|
||||
if (m_context.has_element)
|
||||
{
|
||||
m_assigned_label.replace("%F",
|
||||
m_diagram
|
||||
-> border_and_titleblock
|
||||
.folio());
|
||||
m_assigned_label.replace("%f",
|
||||
QString::number(
|
||||
m_diagram
|
||||
->folioIndex()+1));
|
||||
m_assigned_label.replace("%id",
|
||||
QString::number(
|
||||
m_diagram
|
||||
->folioIndex()+1));
|
||||
m_assigned_label.replace("%total",
|
||||
QString::number(
|
||||
m_diagram
|
||||
->border_and_titleblock
|
||||
.folioTotal()));
|
||||
m_assigned_label.replace("%M",
|
||||
m_diagram
|
||||
-> border_and_titleblock
|
||||
.plant());
|
||||
m_assigned_label.replace("%LM",
|
||||
m_diagram
|
||||
-> border_and_titleblock
|
||||
.locmach());
|
||||
|
||||
QSettings settings;
|
||||
if (m_element)
|
||||
{
|
||||
if (settings.value("border-columns_0", true).toBool()){
|
||||
m_assigned_label.replace("%c", QString::number(m_diagram->convertPosition(m_element->scenePos()).number() - 1));
|
||||
}else{
|
||||
m_assigned_label.replace("%c", QString::number(m_diagram->convertPosition(m_element->scenePos()).number()));
|
||||
}
|
||||
m_assigned_label.replace("%l", m_diagram->convertPosition(m_element->scenePos()).letter());
|
||||
m_assigned_label.replace("%prefix", m_element->getPrefix());
|
||||
if (settings.value("border-columns_0", true).toBool()){
|
||||
m_assigned_label.replace("%c", QString::number(m_context.element_position.number() - 1));
|
||||
}else{
|
||||
m_assigned_label.replace("%c", QString::number(m_context.element_position.number()));
|
||||
}
|
||||
|
||||
if (m_conductor)
|
||||
{
|
||||
m_assigned_label.replace("%wf", cndr->properties().m_function);
|
||||
m_assigned_label.replace("%wv", cndr->properties().m_tension_protocol);
|
||||
m_assigned_label.replace("%wc", cndr->properties().m_wire_color);
|
||||
m_assigned_label.replace("%ws", cndr->properties().m_wire_section);
|
||||
}
|
||||
|
||||
assignTitleBlockVar();
|
||||
assignProjectVar();
|
||||
assignSequence();
|
||||
m_assigned_label.replace("%l", m_context.element_position.letter());
|
||||
m_assigned_label.replace("%prefix", m_context.element_prefix);
|
||||
}
|
||||
|
||||
if (m_context.has_conductor)
|
||||
{
|
||||
m_assigned_label.replace("%wf", m_context.wire_function);
|
||||
m_assigned_label.replace("%wv", m_context.wire_tension_protocol);
|
||||
m_assigned_label.replace("%wc", m_context.wire_color);
|
||||
m_assigned_label.replace("%ws", m_context.wire_section);
|
||||
}
|
||||
|
||||
assignTitleBlockVar();
|
||||
assignProjectVar();
|
||||
assignSequence();
|
||||
}
|
||||
|
||||
void AssignVariables::assignTitleBlockVar()
|
||||
{
|
||||
for (int i = 0; i < m_diagram->border_and_titleblock.additionalFields().count(); i++)
|
||||
DiagramContext fields = m_context.title_block_fields;
|
||||
for (int i = 0; i < fields.count(); i++)
|
||||
{
|
||||
QString folio_variable = m_diagram->border_and_titleblock.additionalFields().keys().at(i);
|
||||
QVariant folio_value = m_diagram->border_and_titleblock.additionalFields().operator [](folio_variable);
|
||||
QString folio_variable = fields.keys().at(i);
|
||||
QVariant folio_value = fields[folio_variable];
|
||||
|
||||
if (m_assigned_label.contains(folio_variable)) {
|
||||
m_assigned_label.replace("%{" + folio_variable + "}", folio_value.toString());
|
||||
@@ -428,10 +450,11 @@ namespace autonum
|
||||
|
||||
void AssignVariables::assignProjectVar()
|
||||
{
|
||||
for (int i = 0; i < m_diagram->project()->projectProperties().count(); i++)
|
||||
DiagramContext properties = m_context.project_properties;
|
||||
for (int i = 0; i < properties.count(); i++)
|
||||
{
|
||||
QString folio_variable = m_diagram->project()->projectProperties().keys().at(i);
|
||||
QVariant folio_value = m_diagram->project()->projectProperties().operator [](folio_variable);
|
||||
QString folio_variable = properties.keys().at(i);
|
||||
QVariant folio_value = properties[folio_variable];
|
||||
|
||||
if (m_assigned_label.contains(folio_variable)) {
|
||||
m_assigned_label.replace("%{" + folio_variable + "}", folio_value.toString());
|
||||
|
||||
Reference in New Issue
Block a user