mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Improve code style, Wrap code for better readability
This commit is contained in:
@@ -46,7 +46,8 @@ namespace autonum
|
|||||||
|
|
||||||
sequentialNumbers::~sequentialNumbers() {}
|
sequentialNumbers::~sequentialNumbers() {}
|
||||||
|
|
||||||
sequentialNumbers &sequentialNumbers::operator=(const sequentialNumbers &other)
|
sequentialNumbers &sequentialNumbers::operator=(
|
||||||
|
const sequentialNumbers &other)
|
||||||
{
|
{
|
||||||
if (&other == this || other == *this)
|
if (&other == this || other == *this)
|
||||||
return (*this);
|
return (*this);
|
||||||
@@ -90,22 +91,41 @@ namespace autonum
|
|||||||
@return A QDomElement, if this sequential have no value,
|
@return A QDomElement, if this sequential have no value,
|
||||||
the returned QDomELement is empty
|
the returned QDomELement is empty
|
||||||
*/
|
*/
|
||||||
QDomElement sequentialNumbers::toXml(QDomDocument &document, const QString& tag_name) const
|
QDomElement sequentialNumbers::toXml(QDomDocument &document,
|
||||||
|
const QString& tag_name) const
|
||||||
{
|
{
|
||||||
QDomElement element = document.createElement(tag_name);
|
QDomElement element = document.createElement(tag_name);
|
||||||
|
|
||||||
if (!unit.isEmpty())
|
if (!unit.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "unit", unit.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"unit",
|
||||||
|
unit.join(";")));
|
||||||
if (!unit_folio.isEmpty())
|
if (!unit_folio.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "unitFolio", unit_folio.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"unitFolio",
|
||||||
|
unit_folio.join(";")));
|
||||||
if(!ten.isEmpty())
|
if(!ten.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "ten", ten.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"ten",
|
||||||
|
ten.join(";")));
|
||||||
if(!ten_folio.isEmpty())
|
if(!ten_folio.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "tenFolio", ten_folio.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"tenFolio",
|
||||||
|
ten_folio.join(";")));
|
||||||
if(!hundred.isEmpty())
|
if(!hundred.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "hundred", hundred.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"hundred",
|
||||||
|
hundred.join(";")));
|
||||||
if(!hundred_folio.isEmpty())
|
if(!hundred_folio.isEmpty())
|
||||||
element.appendChild(QETXML::textToDomElement(document, "hundredFolio", hundred_folio.join(";")));
|
element.appendChild(QETXML::textToDomElement(
|
||||||
|
document,
|
||||||
|
"hundredFolio",
|
||||||
|
hundred_folio.join(";")));
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@@ -164,9 +184,15 @@ namespace autonum
|
|||||||
@param elmt - parent element (if any) of the formula
|
@param elmt - parent element (if any) of the formula
|
||||||
@return the string with variable assigned.
|
@return the string with variable assigned.
|
||||||
*/
|
*/
|
||||||
QString AssignVariables::formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt)
|
QString AssignVariables::formulaToLabel(QString formula,
|
||||||
|
sequentialNumbers &seqStruct,
|
||||||
|
Diagram *diagram,
|
||||||
|
const Element *elmt)
|
||||||
{
|
{
|
||||||
AssignVariables av(std::move(formula), seqStruct, diagram, elmt);
|
AssignVariables av(std::move(formula),
|
||||||
|
seqStruct,
|
||||||
|
diagram,
|
||||||
|
elmt);
|
||||||
seqStruct = av.m_seq_struct;
|
seqStruct = av.m_seq_struct;
|
||||||
return av.m_assigned_label;
|
return av.m_assigned_label;
|
||||||
}
|
}
|
||||||
@@ -174,12 +200,13 @@ namespace autonum
|
|||||||
/**
|
/**
|
||||||
@brief AssignVariables::replaceVariable
|
@brief AssignVariables::replaceVariable
|
||||||
Replace the variables in @formula in form %{my-var}
|
Replace the variables in @formula in form %{my-var}
|
||||||
to the corresponding value stored in @dc
|
to the corresponding value stored in dc
|
||||||
@param formula
|
@param formula
|
||||||
@param dc
|
@param dc
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QString AssignVariables::replaceVariable(const QString &formula, const DiagramContext &dc)
|
QString AssignVariables::replaceVariable(const QString &formula,
|
||||||
|
const DiagramContext &dc)
|
||||||
{
|
{
|
||||||
QString str = formula;
|
QString str = formula;
|
||||||
str.replace("%{label}", dc.value("label").toString());
|
str.replace("%{label}", dc.value("label").toString());
|
||||||
@@ -188,13 +215,15 @@ namespace autonum
|
|||||||
str.replace("%{description}", dc.value("description").toString());
|
str.replace("%{description}", dc.value("description").toString());
|
||||||
str.replace("%{designation}", dc.value("designation").toString());
|
str.replace("%{designation}", dc.value("designation").toString());
|
||||||
str.replace("%{manufacturer}", dc.value("manufacturer").toString());
|
str.replace("%{manufacturer}", dc.value("manufacturer").toString());
|
||||||
str.replace("%{manufacturer_reference}", dc.value("manufacturer_reference").toString());
|
str.replace("%{manufacturer_reference}",
|
||||||
|
dc.value("manufacturer_reference").toString());
|
||||||
str.replace("%{supplier}", dc.value("supplier").toString());
|
str.replace("%{supplier}", dc.value("supplier").toString());
|
||||||
str.replace("%{quantity}", dc.value("quantity").toString());
|
str.replace("%{quantity}", dc.value("quantity").toString());
|
||||||
str.replace("%{unity}", dc.value("unity").toString());
|
str.replace("%{unity}", dc.value("unity").toString());
|
||||||
str.replace("%{auxiliary1}", dc.value("auxiliary1").toString());
|
str.replace("%{auxiliary1}", dc.value("auxiliary1").toString());
|
||||||
str.replace("%{auxiliary2}", dc.value("auxiliary2").toString());
|
str.replace("%{auxiliary2}", dc.value("auxiliary2").toString());
|
||||||
str.replace("%{machine_manufacturer_reference}", dc.value("machine_manufacturer_reference").toString());
|
str.replace("%{machine_manufacturer_reference}",
|
||||||
|
dc.value("machine_manufacturer_reference").toString());
|
||||||
str.replace("%{location}", dc.value("location").toString());
|
str.replace("%{location}", dc.value("location").toString());
|
||||||
str.replace("%{function}", dc.value("function").toString());
|
str.replace("%{function}", dc.value("function").toString());
|
||||||
str.replace("%{void}", QString());
|
str.replace("%{void}", QString());
|
||||||
@@ -203,7 +232,10 @@ namespace autonum
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AssignVariables::AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt):
|
AssignVariables::AssignVariables(const QString& formula,
|
||||||
|
const sequentialNumbers& seqStruct,
|
||||||
|
Diagram *diagram,
|
||||||
|
const Element *elmt):
|
||||||
m_diagram(diagram),
|
m_diagram(diagram),
|
||||||
m_arg_formula(formula),
|
m_arg_formula(formula),
|
||||||
m_assigned_label(formula),
|
m_assigned_label(formula),
|
||||||
@@ -213,14 +245,33 @@ namespace autonum
|
|||||||
{
|
{
|
||||||
if (m_diagram)
|
if (m_diagram)
|
||||||
{
|
{
|
||||||
m_assigned_label.replace("%F", m_diagram -> border_and_titleblock.folio());
|
m_assigned_label.replace("%F",
|
||||||
m_assigned_label.replace("%f", QString::number(m_diagram->folioIndex()+1));
|
m_diagram
|
||||||
m_assigned_label.replace("%id", QString::number(m_diagram->folioIndex()+1));
|
-> border_and_titleblock
|
||||||
m_assigned_label.replace("%total", QString::number(m_diagram->border_and_titleblock.folioTotal()));
|
.folio());
|
||||||
m_assigned_label.replace("%M", m_diagram -> border_and_titleblock.plant());
|
m_assigned_label.replace("%f",
|
||||||
m_assigned_label.replace("%LM", m_diagram -> border_and_titleblock.locmach());
|
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;
|
QSettings settings;
|
||||||
if (m_element)
|
if (m_element)
|
||||||
{
|
{
|
||||||
if (settings.value("border-columns_0", true).toBool()){
|
if (settings.value("border-columns_0", true).toBool()){
|
||||||
|
|||||||
@@ -25,37 +25,37 @@ class QStackedWidget;
|
|||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
/**
|
/**
|
||||||
This class represents the configuration dialog for QElectroTech.
|
This class represents the configuration dialog for QElectroTech.
|
||||||
It displays "configuration pages", each page having to provide an icon and
|
It displays "configuration pages",
|
||||||
a title.
|
each page having to provide an icon and a title.
|
||||||
*/
|
*/
|
||||||
class ConfigDialog : public QDialog {
|
class ConfigDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ConfigDialog(QWidget * = nullptr);
|
ConfigDialog(QWidget * = nullptr);
|
||||||
~ConfigDialog() override;
|
~ConfigDialog() override;
|
||||||
private:
|
private:
|
||||||
ConfigDialog(const ConfigDialog &);
|
ConfigDialog(const ConfigDialog &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QList<ConfigPage *> pages;
|
QList<ConfigPage *> pages;
|
||||||
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public slots:
|
public slots:
|
||||||
void applyConf();
|
void applyConf();
|
||||||
void addPage(ConfigPage *);
|
void addPage(ConfigPage *);
|
||||||
void setCurrentPage(const int index);
|
void setCurrentPage(const int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildPagesList();
|
void buildPagesList();
|
||||||
void addPageToList(ConfigPage *);
|
void addPageToList(ConfigPage *);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QListWidget *pages_list;
|
QListWidget *pages_list;
|
||||||
QStackedWidget *pages_widget;
|
QStackedWidget *pages_widget;
|
||||||
QDialogButtonBox *buttons;
|
QDialogButtonBox *buttons;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,38 +24,93 @@
|
|||||||
|
|
||||||
/* This class exports the project to DXF Format */
|
/* This class exports the project to DXF Format */
|
||||||
class Createdxf
|
class Createdxf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Createdxf();
|
Createdxf();
|
||||||
~Createdxf();
|
~Createdxf();
|
||||||
static void dxfBegin (const QString&);
|
static void dxfBegin (const QString&);
|
||||||
static void dxfEnd(const QString&);
|
static void dxfEnd(const QString&);
|
||||||
// you can add more functions to create more drawings.
|
// you can add more functions to create more drawings.
|
||||||
static void drawCircle(const QString&,double,double,double,int);
|
static void drawCircle(const QString&,
|
||||||
static void drawArc(const QString&,double x,double y,double rad,double startAngle,double endAngle,int color);
|
double,
|
||||||
static void drawDonut(QString,double,double,double,int);
|
double,
|
||||||
|
double,
|
||||||
|
int);
|
||||||
|
static void drawArc(const QString&,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double rad,
|
||||||
|
double startAngle,
|
||||||
|
double endAngle,
|
||||||
|
int color);
|
||||||
|
static void drawDonut(QString,double,double,double,int);
|
||||||
|
|
||||||
static void drawArcEllipse (const QString &file_path, qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal spanAngle, qreal hotspot_x, qreal hotspot_y, qreal rotation_angle, const int &colorcode);
|
static void drawArcEllipse (const QString &file_path,
|
||||||
|
qreal x,
|
||||||
|
qreal y,
|
||||||
|
qreal w,
|
||||||
|
qreal h,
|
||||||
|
qreal startAngle,
|
||||||
|
qreal spanAngle,
|
||||||
|
qreal hotspot_x,
|
||||||
|
qreal hotspot_y,
|
||||||
|
qreal rotation_angle,
|
||||||
|
const int &colorcode);
|
||||||
|
|
||||||
static void drawEllipse (const QString &filepath, const QRectF &rect, const int &colorcode);
|
static void drawEllipse (const QString &filepath,
|
||||||
|
const QRectF &rect,
|
||||||
|
const int &colorcode);
|
||||||
|
|
||||||
static void drawRectangle(const QString &filepath,double,double,double,double,const int &colorcode);
|
static void drawRectangle(const QString &filepath,
|
||||||
static void drawRectangle(const QString &filepath, const QRectF &rect, const int &colorcode);
|
double,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
const int &colorcode);
|
||||||
|
static void drawRectangle(const QString &filepath,
|
||||||
|
const QRectF &rect,
|
||||||
|
const int &colorcode);
|
||||||
|
|
||||||
static void drawLine(const QString &filapath,double,double,double,double, const int &clorcode);
|
static void drawLine(const QString &filapath,
|
||||||
static void drawLine(const QString &filepath, const QLineF &line,const int &colorcode);
|
double,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
const int &clorcode);
|
||||||
|
static void drawLine(const QString &filepath,
|
||||||
|
const QLineF &line,
|
||||||
|
const int &colorcode);
|
||||||
|
|
||||||
static void drawText(const QString&,const QString&,double,double,double,double,int);
|
static void drawText(const QString&,
|
||||||
static void drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, int colour, bool leftAlign = false, float scale = 0);
|
const QString&,
|
||||||
|
double,double,
|
||||||
|
double,
|
||||||
|
double,
|
||||||
|
int);
|
||||||
|
static void drawTextAligned(const QString& fileName,
|
||||||
|
const QString& text,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double height,
|
||||||
|
double rotation,
|
||||||
|
double oblique,
|
||||||
|
int hAlign,
|
||||||
|
int vAlign,
|
||||||
|
double xAlign,
|
||||||
|
int colour,
|
||||||
|
bool leftAlign = false,
|
||||||
|
float scale = 0);
|
||||||
|
|
||||||
|
|
||||||
static int getcolorCode (const long red, const long green, const long blue);
|
static int getcolorCode (const long red,
|
||||||
static long RGBcodeTable[];
|
const long green,
|
||||||
|
const long blue);
|
||||||
|
static long RGBcodeTable[];
|
||||||
|
|
||||||
static const double sheetWidth;
|
static const double sheetWidth;
|
||||||
static const double sheetHeight;
|
static const double sheetHeight;
|
||||||
static double xScale;
|
static double xScale;
|
||||||
static double yScale;
|
static double yScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CREATEDXF_H
|
#endif // CREATEDXF_H
|
||||||
|
|||||||
Reference in New Issue
Block a user