Refactoring. Delete global variables.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-19 20:27:11 +02:00
parent f641894abd
commit fa06c04cd2
59 changed files with 626 additions and 504 deletions

View file

@ -1,11 +1,11 @@
SOURCES += \
src/container/vincrementtablerow.cpp \
src/container/vcontainer.cpp \
src/container/calculator.cpp \
src/container/vmeasurement.cpp
src/container/vmeasurement.cpp \
src/container/vincrement.cpp
HEADERS += \
src/container/vincrementtablerow.h \
src/container/vcontainer.h \
src/container/calculator.h \
src/container/vmeasurement.h
src/container/vmeasurement.h \
src/container/vincrement.h

View file

@ -30,12 +30,13 @@
#include <QDebug>
#include <QtAlgorithms>
#include "../widgets/vapplication.h"
quint32 VContainer::_id = 0;
VContainer::VContainer()
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
measurements(QHash<QString, VMeasurement>()), incrementTable(QHash<QString, VIncrementTableRow>()),
measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
{
@ -49,7 +50,7 @@ VContainer &VContainer::operator =(const VContainer &data)
VContainer::VContainer(const VContainer &data)
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
measurements(QHash<QString, VMeasurement>()), incrementTable(QHash<QString, VIncrementTableRow>()),
measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
{
@ -104,7 +105,7 @@ void VContainer::setData(const VContainer &data)
}
}
measurements = *data.DataMeasurements();
incrementTable = *data.DataIncrementTable();
increments = *data.DataIncrements();
lengthLines = *data.DataLengthLines();
lineAngles = *data.DataLineAngles();
lengthSplines = *data.DataLengthSplines();
@ -149,10 +150,10 @@ const VMeasurement VContainer::GetMeasurement(const QString &name) const
return GetVariable(measurements, name);
}
const VIncrementTableRow VContainer::GetIncrementTableRow(const QString& name) const
const VIncrement VContainer::GetIncrement(const QString& name) const
{
Q_ASSERT(name.isEmpty()==false);
return GetVariable(incrementTable, name);
return GetVariable(increments, name);
}
qreal VContainer::GetLine(const QString &name) const
@ -196,9 +197,9 @@ quint32 VContainer::AddDetail(VDetail detail)
return id;
}
void VContainer::AddIncrementTableRow(const QString &name, VIncrementTableRow row)
void VContainer::AddIncrement(const QString &name, VIncrement incr)
{
incrementTable[name] = row;
increments[name] = incr;
}
quint32 VContainer::getNextId()
@ -239,7 +240,7 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
void VContainer::AddLengthArc(const quint32 &id)
{
const VArc * arc = GeometricObject<const VArc *>(id);
lengthArcs[arc->name()] = fromPixel(arc->GetLength());
lengthArcs[arc->name()] = qApp->fromPixel(arc->GetLength());
}
void VContainer::AddLineAngle(const QString &name, const qreal &value)
@ -251,7 +252,7 @@ void VContainer::AddLineAngle(const QString &name, const qreal &value)
qreal VContainer::GetValueStandardTableRow(const QString& name) const
{
const VMeasurement m = GetMeasurement(name);
if (patternType == Pattern::Individual)
if (qApp->patternType() == Pattern::Individual)
{
return m.GetValue();
}
@ -263,18 +264,22 @@ qreal VContainer::GetValueStandardTableRow(const QString& name) const
qreal VContainer::GetValueIncrementTableRow(const QString& name) const
{
const VIncrementTableRow row = GetIncrementTableRow(name);
const qreal k_size = ( size() - 50.0 ) / 2.0;
const qreal k_growth = ( height() - 176.0 ) / 6.0;
const qreal value = row.getBase() + k_size * row.getKsize() + k_growth * row.getKgrowth();
return value;
const VIncrement icr = GetIncrement(name);
if (qApp->patternType() == Pattern::Individual)
{
return icr.GetValue();
}
else
{
return icr.GetValue(size(), height());
}
}
void VContainer::Clear()
{
_id = 0;
measurements.clear();
incrementTable.clear();
increments.clear();
lengthLines.clear();
lengthArcs.clear();
lineAngles.clear();
@ -326,7 +331,7 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const
*ok = true;
return GetValueStandardTableRow(name);
}
if (incrementTable.contains(name))
if (increments.contains(name))
{
*ok = true;
return GetValueIncrementTableRow(name);
@ -360,7 +365,7 @@ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPoint
QString nameLine = GetNameLine(firstPointId, secondPointId);
const VPointF *first = GeometricObject<const VPointF *>(firstPointId);
const VPointF *second = GeometricObject<const VPointF *>(secondPointId);
AddLengthLine(nameLine, fromPixel(QLineF(first->toQPointF(), second->toQPointF()).length()));
AddLengthLine(nameLine, qApp->fromPixel(QLineF(first->toQPointF(), second->toQPointF()).length()));
nameLine = GetNameLineAngle(firstPointId, secondPointId);
AddLineAngle(nameLine, QLineF(first->toQPointF(), second->toQPointF()).angle());
}

View file

@ -30,7 +30,7 @@
#define VCONTAINER_H
#include "vmeasurement.h"
#include "vincrementtablerow.h"
#include "vincrement.h"
#include "../geometry/varc.h"
#include "../geometry/vsplinepath.h"
#include "../geometry/vdetail.h"
@ -113,11 +113,11 @@ public:
*/
const VMeasurement GetMeasurement(const QString& name) const;
/**
* @brief GetIncrementTableRow return increment table row by name
* @brief GetIncrement return increment table row by name
* @param name name of increment table row
* @return row of increment table
* @return increment
*/
const VIncrementTableRow GetIncrementTableRow(const QString& name) const;
const VIncrement GetIncrement(const QString& name) const;
/**
* @brief GetLine return length of line by name
* @param name name of line
@ -172,11 +172,11 @@ public:
*/
void AddMeasurement(const QString& name, const VMeasurement &m);
/**
* @brief AddIncrementTableRow add new row of increment table
* @brief AddIncrement add new row of increment table
* @param name name of new row of increment table
* @param row new row of increment table
*/
void AddIncrementTableRow(const QString& name, VIncrementTableRow row);
void AddIncrement(const QString& name, VIncrement incr);
/**
* @brief AddLengthLine add length of line to container
* @param name name of line
@ -242,11 +242,11 @@ public:
*/
void UpdateMeasurement(const QString& name, VMeasurement m);
/**
* @brief UpdateIncrementTableRow update increment table row by name
* @brief UpdateIncrement update increment table row by name
* @param name name of row
* @param row row
*/
void UpdateIncrementTableRow(const QString& name, VIncrementTableRow row);
void UpdateIncrement(const QString& name, VIncrement incr);
/**
* @brief GetValueStandardTableRow return value of measurement by name
* @param name name of measurement
@ -347,10 +347,10 @@ public:
*/
const QHash<QString, VMeasurement> *DataMeasurements() const;
/**
* @brief data container with dataIncrementTable return container of increment table
* @brief data container with dataIncrements return container of increment table
* @return pointer on container of increment table
*/
const QHash<QString, VIncrementTableRow> *DataIncrementTable() const;
const QHash<QString, VIncrement> *DataIncrements() const;
/**
* @brief data container with dataLengthLines return container of lines lengths
* @return pointer on container of lines lengths
@ -399,9 +399,9 @@ private:
*/
QHash<QString, VMeasurement> measurements;
/**
* @brief incrementTable
* @brief increments
*/
QHash<QString, VIncrementTableRow> incrementTable;
QHash<QString, VIncrement> increments;
/**
* @brief lengthLines container of lines lengths
*/
@ -468,14 +468,14 @@ inline void VContainer::UpdateMeasurement(const QString &name, VMeasurement m)
measurements[name] = m;
}
inline void VContainer::UpdateIncrementTableRow(const QString &name, VIncrementTableRow row)
inline void VContainer::UpdateIncrement(const QString &name, VIncrement incr)
{
incrementTable[name] = row;
increments[name] = incr;
}
inline void VContainer::ClearIncrementTable()
{
incrementTable.clear();
increments.clear();
}
inline void VContainer::ClearLengthLines()
@ -545,12 +545,12 @@ inline QString VContainer::HeightName() const
inline bool VContainer::IncrementTableContains(const QString &name)
{
return incrementTable.contains(name);
return increments.contains(name);
}
inline void VContainer::RemoveIncrementTableRow(const QString &name)
{
incrementTable.remove(name);
increments.remove(name);
}
inline const QHash<quint32, VGObject *> *VContainer::DataGObjects() const
@ -563,9 +563,9 @@ inline const QHash<QString, VMeasurement> *VContainer::DataMeasurements() const
return &measurements;
}
inline const QHash<QString, VIncrementTableRow> *VContainer::DataIncrementTable() const
inline const QHash<QString, VIncrement> *VContainer::DataIncrements() const
{
return &incrementTable;
return &increments;
}
inline const QHash<QString, qreal> *VContainer::DataLengthLines() const

View file

@ -26,10 +26,22 @@
**
*************************************************************************/
#include "vincrementtablerow.h"
#include "vincrement.h"
VIncrementTableRow::VIncrementTableRow()
:id(0), base(0), ksize(0), kgrowth(0), description(QString()){}
VIncrement::VIncrement()
:id(0), base(0), ksize(50.0), kheight(176.0), description(QString()){}
VIncrementTableRow::VIncrementTableRow(quint32 id, qreal base, qreal ksize, qreal kgrowth, QString description)
:id(id), base(base), ksize(ksize), kgrowth(kgrowth), description(description){}
VIncrement::VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QString description)
:id(id), base(base), ksize(ksize), kheight(kheight), description(description){}
qreal VIncrement::GetValue() const
{
return base;
}
qreal VIncrement::GetValue(const qreal &size, const qreal &height) const
{
const qreal k_size = ( size - 50.0 ) / 2.0;
const qreal k_height = ( height - 176.0 ) / 6.0;
return base + k_size * ksize + k_height * kheight;
}

View file

@ -32,15 +32,15 @@
#include <QString>
/**
* @brief The VIncrementTableRow class keep data row of increment table
* @brief The VIncrement class keep data row of increment table
*/
class VIncrementTableRow
class VIncrement
{
public:
/**
* @brief VIncrementTableRow create enpty row
*/
VIncrementTableRow();
VIncrement();
/**
* @brief VIncrementTableRow create row
* @param id id
@ -49,8 +49,7 @@ public:
* @param kgrowth increment in growths
* @param description description of increment
*/
VIncrementTableRow(quint32 id, qreal base, qreal ksize, qreal kgrowth,
QString description = QString());
VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QString description = QString());
/**
* @brief getId return id of row
* @return id
@ -82,15 +81,15 @@ public:
*/
void setKsize(const qreal &value);
/**
* @brief getKgrowth return increment in growths
* @brief getKheight return increment in growths
* @return increment
*/
qreal getKgrowth() const;
qreal getKheight() const;
/**
* @brief setKgrowth set increment in growths
* @brief setKheight set increment in growths
* @param value value of increment
*/
void setKgrowth(const qreal &value);
void setKheight(const qreal &value);
/**
* @brief getDescription return description
* @return description
@ -101,6 +100,8 @@ public:
* @param value description
*/
void setDescription(const QString &value);
qreal GetValue() const;
qreal GetValue(const qreal &size, const qreal &height) const;
private:
/**
* @brief id identificator
@ -117,59 +118,59 @@ private:
/**
* @brief kgrowth increment in growths
*/
qreal kgrowth;
qreal kheight;
/**
* @brief description description of increment
*/
QString description;
};
inline quint32 VIncrementTableRow::getId() const
inline quint32 VIncrement::getId() const
{
return id;
}
inline void VIncrementTableRow::setId(const quint32 &value)
inline void VIncrement::setId(const quint32 &value)
{
id = value;
}
inline qreal VIncrementTableRow::getBase() const
inline qreal VIncrement::getBase() const
{
return base;
}
inline void VIncrementTableRow::setBase(const qreal &value)
inline void VIncrement::setBase(const qreal &value)
{
base = value;
}
inline qreal VIncrementTableRow::getKsize() const
inline qreal VIncrement::getKsize() const
{
return ksize;
}
inline void VIncrementTableRow::setKsize(const qreal &value)
inline void VIncrement::setKsize(const qreal &value)
{
ksize = value;
}
inline qreal VIncrementTableRow::getKgrowth() const
inline qreal VIncrement::getKheight() const
{
return kgrowth;
return kheight;
}
inline void VIncrementTableRow::setKgrowth(const qreal &value)
inline void VIncrement::setKheight(const qreal &value)
{
kgrowth = value;
kheight = value;
}
inline QString VIncrementTableRow::getDescription() const
inline QString VIncrement::getDescription() const
{
return description;
}
inline void VIncrementTableRow::setDescription(const QString &value)
inline void VIncrement::setDescription(const QString &value)
{
description = value;
}

View file

@ -49,6 +49,6 @@ qreal VMeasurement::GetValue() const
qreal VMeasurement::GetValue(const qreal &size, const qreal &height) const
{
const qreal k_size = ( size - 50.0 ) / 2.0;
const qreal k_growth = ( height - 176.0 ) / 6.0;
return base + k_size * ksize + k_growth * kheight;
const qreal k_height = ( height - 176.0 ) / 6.0;
return base + k_size * ksize + k_height * kheight;
}

View file

@ -45,13 +45,40 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);
if (qApp->patternType() == Pattern::Standard)
{
ui->labelBirthDate->setVisible(false);
ui->lineEditBirthDate->setVisible(false);
ui->labelFamilyName->setVisible(false);
ui->lineEditFamilyName->setVisible(false);
ui->labelGivenName->setVisible(false);
ui->lineEditGivenName->setVisible(false);
ui->labelSex->setVisible(false);
ui->lineEditSex->setVisible(false);
}
else
{
ui->tableWidgetMeasurements->setColumnHidden( 1, true );
ui->tableWidgetMeasurements->setColumnHidden( 3, true );
ui->tableWidgetMeasurements->setColumnHidden( 4, true );
ui->tableWidgetIncrement->setColumnHidden( 1, true );
ui->tableWidgetIncrement->setColumnHidden( 3, true );
ui->tableWidgetIncrement->setColumnHidden( 4, true );
ui->tableWidgetMeasurements->setItemDelegateForColumn(0, textDelegate);
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementsChanged);
}
FillMeasurements();
FillIncrementTable();
FillIncrements();
FillLengthLines();
FillLengthSplines();
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::cellChanged);
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
connect(ui->toolButtonRemove, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonRemove);
@ -67,54 +94,61 @@ void DialogIncrements::FillMeasurements()
const QHash<QString, VMeasurement> *table = data->DataMeasurements();
qint32 currentRow = -1;
QHashIterator<QString, VMeasurement> i(*table);
ui->tableWidgetStandard->setRowCount ( table->size() );
ui->tableWidgetMeasurements->setRowCount ( table->size() );
while (i.hasNext())
{
i.next();
VMeasurement cell = i.value();
VMeasurement m = i.value();
currentRow++;
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold));
ui->tableWidgetStandard->setItem(currentRow, 0, item);
item->setToolTip(m.GetDescription());
ui->tableWidgetMeasurements->setItem(currentRow, 0, item);
item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(i.key())));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 1, item);
if (qApp->patternType() == Pattern::Standard)
{
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(i.key())));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);
}
item = new QTableWidgetItem(QString().setNum(cell.GetBase()));
item = new QTableWidgetItem(QString().setNum(m.GetBase()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 2, item);
ui->tableWidgetMeasurements->setItem(currentRow, 2, item);
item = new QTableWidgetItem(QString().setNum(cell.GetKsize()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 3, item);
if (qApp->patternType() == Pattern::Standard)
{
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m.GetKsize()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetMeasurements->setItem(currentRow, 3, item);
item = new QTableWidgetItem(QString().setNum(cell.GetKheight()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 4, item);
item = new QTableWidgetItem(QString().setNum(m.GetKheight()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetMeasurements->setItem(currentRow, 4, item);
}
item = new QTableWidgetItem(cell.GetDescription());
item = new QTableWidgetItem(m.GetNumber());
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 5, item);
ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
}
ui->tableWidgetStandard->resizeColumnsToContents();
ui->tableWidgetStandard->resizeRowsToContents();
ui->tableWidgetStandard->verticalHeader()->setDefaultSectionSize(20);
ui->tableWidgetMeasurements->resizeColumnsToContents();
ui->tableWidgetMeasurements->resizeRowsToContents();
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
}
void DialogIncrements::FillIncrementTable()
void DialogIncrements::FillIncrements()
{
const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable();
QHashIterator<QString, VIncrementTableRow> i(*incrementTable);
const QHash<QString, VIncrement> *increments = data->DataIncrements();
QHashIterator<QString, VIncrement> i(*increments);
QMap<quint32, QString> map;
//Sorting QHash by id
while (i.hasNext())
{
i.next();
VIncrementTableRow cell = i.value();
map.insert(cell.getId(), i.key());
VIncrement incr = i.value();
map.insert(incr.getId(), i.key());
}
qint32 currentRow = -1;
@ -122,37 +156,43 @@ void DialogIncrements::FillIncrementTable()
while (iMap.hasNext())
{
iMap.next();
VIncrementTableRow cell = incrementTable->value(iMap.value());
VIncrement incr = increments->value(iMap.value());
currentRow++;
ui->tableWidgetIncrement->setRowCount ( incrementTable->size() );
ui->tableWidgetIncrement->setRowCount ( increments->size() );
QTableWidgetItem *item = new QTableWidgetItem(iMap.value());
item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold));
item->setData(Qt::UserRole, cell.getId());
item->setData(Qt::UserRole, incr.getId());
ui->tableWidgetIncrement->setItem(currentRow, 0, item);
item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value())));
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
if (qApp->patternType() == Pattern::Standard)
{
item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value())));
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
}
item = new QTableWidgetItem(QString().setNum(cell.getBase()));
item = new QTableWidgetItem(QString().setNum(incr.getBase()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 2, item);
item = new QTableWidgetItem(QString().setNum(cell.getKsize()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
if (qApp->patternType() == Pattern::Standard)
{
item = new QTableWidgetItem(QString().setNum(incr.getKsize()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
item = new QTableWidgetItem(QString().setNum(cell.getKgrowth()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
item = new QTableWidgetItem(QString().setNum(incr.getKheight()));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
}
item = new QTableWidgetItem(cell.getDescription());
item = new QTableWidgetItem(incr.getDescription());
item->setTextAlignment(Qt::AlignLeft);
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
}
@ -273,13 +313,13 @@ void DialogIncrements::FillLengthArcs()
void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
ui->tableWidgetStandard->clearContents();
ui->tableWidgetMeasurements->clearContents();
FillMeasurements();
ui->tableWidgetIncrement->clearContents();
FillIncrementTable();
FillIncrements();
ui->tableWidgetLines->clearContents();
FillLengthLines();
@ -291,14 +331,14 @@ void DialogIncrements::FullUpdateFromFile()
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
}
void DialogIncrements::clickedToolButtonAdd()
{
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
qint32 currentRow = ui->tableWidgetIncrement->rowCount();
ui->tableWidgetIncrement->insertRow( currentRow );
@ -315,8 +355,8 @@ void DialogIncrements::clickedToolButtonAdd()
qreal ksize = 0;
qreal kgrowth = 0;
QString description = QString(tr("Description"));
VIncrementTableRow incrementRow = VIncrementTableRow(id, base, ksize, kgrowth, description);
data->AddIncrementTableRow(name, incrementRow);
VIncrement incr = VIncrement(id, base, ksize, kgrowth, description);
data->AddIncrement(name, incr);
AddIncrementToFile(id, name, base, ksize, kgrowth, description);
@ -353,14 +393,14 @@ void DialogIncrements::clickedToolButtonAdd()
ui->toolButtonRemove->setEnabled(true);
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
emit haveLiteChange();
}
void DialogIncrements::clickedToolButtonRemove()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
QTableWidgetItem *item = ui->tableWidgetIncrement->currentItem();
qint32 row = item->row();
QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0);
@ -378,7 +418,7 @@ void DialogIncrements::clickedToolButtonRemove()
ui->toolButtonRemove->setEnabled(false);
}
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::cellChanged);
&DialogIncrements::IncrementChanged);
emit haveLiteChange();
}
@ -415,7 +455,7 @@ void DialogIncrements::AddIncrementToFile(quint32 id, QString name, qreal base,
list.at(0).appendChild(element);
}
void DialogIncrements::cellChanged ( qint32 row, qint32 column )
void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
{
QTableWidgetItem *item = nullptr;
QTableWidgetItem *itemName = nullptr;
@ -493,9 +533,9 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column )
if (domElement.isElement())
{
domElement.setAttribute("description", item->text());
VIncrementTableRow incr = data->GetIncrementTableRow(itemName->text());
VIncrement incr = data->GetIncrement(itemName->text());
incr.setDescription(item->text());
data->UpdateIncrementTableRow(itemName->text(), incr);
data->UpdateIncrement(itemName->text(), incr);
ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents();
ui->tableWidgetIncrement->setCurrentCell( row, 0 );
@ -507,6 +547,11 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column )
}
}
void DialogIncrements::MeasurementsChanged(qint32 row, qint32 column)
{
}
void DialogIncrements::closeEvent(QCloseEvent *event)
{
emit DialogClosed(QDialog::Accepted);

View file

@ -66,7 +66,8 @@ public slots:
* @param row number of row
* @param column number of column
*/
void cellChanged ( qint32 row, qint32 column );
void IncrementChanged ( qint32 row, qint32 column );
void MeasurementsChanged ( qint32 row, qint32 column );
/**
* @brief FullUpdateFromFile update information in tables form file
*/
@ -111,7 +112,7 @@ private:
/**
* @brief FillIncrementTable fill data for increment table
*/
void FillIncrementTable();
void FillIncrements();
/**
* @brief FillLengthLines fill data for table of lines lengths
*/

View file

@ -61,7 +61,9 @@
<string>...</string>
</property>
<property name="icon">
<iconset theme="document-open"/>
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
</widget>
</item>
@ -70,21 +72,21 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelFamilyName">
<property name="text">
<string>Family name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="lineEditFamilyName"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="labelGivenName">
<property name="minimumSize">
<size>
<width>84</width>
@ -97,14 +99,14 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
<widget class="QLineEdit" name="lineEditGivenName"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="labelBirthDate">
<property name="minimumSize">
<size>
<width>84</width>
@ -117,14 +119,14 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3"/>
<widget class="QLineEdit" name="lineEditBirthDate"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="labelSex">
<property name="minimumSize">
<size>
<width>84</width>
@ -137,12 +139,12 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_4"/>
<widget class="QLineEdit" name="lineEditSex"/>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="tableWidgetStandard">
<widget class="QTableWidget" name="tableWidgetMeasurements">
<property name="enabled">
<bool>true</bool>
</property>
@ -448,7 +450,7 @@
</layout>
</widget>
<tabstops>
<tabstop>tableWidgetStandard</tabstop>
<tabstop>tableWidgetMeasurements</tabstop>
<tabstop>tableWidgetIncrement</tabstop>
<tabstop>toolButtonAdd</tabstop>
<tabstop>toolButtonRemove</tabstop>

View file

@ -33,6 +33,7 @@
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
#include "../../widgets/vapplication.h"
DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName,
QWidget *parent) :
@ -112,7 +113,7 @@ void DialogIndividualMeasurements::DialogAccepted()
try
{
m.setContent(&file);
patternUnit = m.Unit();
qApp->setPatternUnit( m.Unit());
}
catch(VException &e)
{
@ -196,18 +197,9 @@ void DialogIndividualMeasurements::CheckState()
void DialogIndividualMeasurements::LoadIndividualTables()
{
#ifdef Q_OS_WIN
const QString pathToTables = QString("/tables/individual");
#else
#ifdef QT_DEBUG
const QString pathToTables = QString("/tables/individual");
#else
const QString pathToTables = QString("/usr/share/valentina/tables/individual");
#endif
#endif
QStringList filters;
filters << "*.vit";
QDir tablesDir(pathToTables);
QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters);
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);

View file

@ -30,6 +30,7 @@
#include "ui_dialogstandardmeasurements.h"
#include <QDir>
#include "../../xml/vstandardmeasurements.h"
#include "../../widgets/vapplication.h"
DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName,
QWidget *parent) :
@ -94,7 +95,7 @@ void DialogStandardMeasurements::DialogAccepted()
try
{
m.setContent(&file);
patternUnit = m.Unit();
qApp->setPatternUnit(m.Unit());
}
catch(VException &e)
{
@ -148,18 +149,9 @@ void DialogStandardMeasurements::CheckState()
void DialogStandardMeasurements::LoadStandardTables()
{
#ifdef Q_OS_WIN
const QString pathToTables = QString("/tables/standard");
#else
#ifdef QT_DEBUG
const QString pathToTables = QString("/tables/standard");
#else
const QString pathToTables = QString("/usr/share/valentina/tables/standard");
#endif
#endif
QStringList filters;
filters << "*.vst";
QDir tablesDir(pathToTables);
QDir tablesDir(qApp->pathToTables());
tablesDir.setNameFilters(filters);
const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files);

View file

@ -28,6 +28,7 @@
#include "pages.h"
#include "../../options.h"
#include "../../widgets/vapplication.h"
ConfigurationPage::ConfigurationPage(QWidget *parent):
QWidget(parent), autoSaveCheck(0), autoTime(0), langCombo(0), osOptionCheck(0), langChanged(false)
@ -115,7 +116,7 @@ QGroupBox *ConfigurationPage::LangGroup()
QString checkedLocale = settings.value("configuration/locale", defaultLocale).toString();
QString m_langPath = QApplication::applicationDirPath();
m_langPath.append(translationsPath);
m_langPath.append(qApp->translationsPath());
QDir dir(m_langPath);
QStringList fileNames = dir.entryList(QStringList("valentina_*.qm"));

View file

@ -150,8 +150,8 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N
this, &DialogDetail::BiasXChanged);
disconnect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
ui.spinBoxBiasX->setValue(static_cast<qint32>(fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(fromPixel(node.getMy())));
ui.spinBoxBiasX->setValue(static_cast<qint32>(qApp->fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(qApp->fromPixel(node.getMy())));
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
@ -184,7 +184,7 @@ void DialogDetail::BiasXChanged(qreal d)
QListWidgetItem *item = ui.listWidget->item( row );
Q_CHECK_PTR(item);
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
node.setMx(toPixel(d));
node.setMx(qApp->toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
@ -194,7 +194,7 @@ void DialogDetail::BiasYChanged(qreal d)
QListWidgetItem *item = ui.listWidget->item( row );
Q_CHECK_PTR(item);
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
node.setMy(toPixel(d));
node.setMy(qApp->toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
@ -218,8 +218,8 @@ void DialogDetail::ObjectChanged(int row)
}
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
ui.spinBoxBiasX->setValue(static_cast<qint32>(fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(fromPixel(node.getMy())));
ui.spinBoxBiasX->setValue(static_cast<qint32>(qApp->fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(qApp->fromPixel(node.getMy())));
}
void DialogDetail::DeleteItem()

View file

@ -67,7 +67,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare
connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged);
if (patternType == Pattern::Standard)
if (qApp->patternType() == Pattern::Standard)
{
SizeHeight();
connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight);

View file

@ -36,8 +36,8 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent)
point(QPointF())
{
ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0, fromPixel(SceneSize));
ui->doubleSpinBoxY->setRange(0, fromPixel(SceneSize));
ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize));
ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize));
labelEditNamePoint = ui->labelEditName;
InitOkCansel(ui);
@ -51,20 +51,20 @@ void DialogSinglePoint::mousePress(const QPointF &scenePos)
{
if (isInitialized == false)
{
ui->doubleSpinBoxX->setValue(fromPixel(scenePos.x()));
ui->doubleSpinBoxY->setValue(fromPixel(scenePos.y()));
ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x()));
ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y()));
this->show();
}
else
{
ui->doubleSpinBoxX->setValue(fromPixel(scenePos.x()));
ui->doubleSpinBoxY->setValue(fromPixel(scenePos.y()));
ui->doubleSpinBoxX->setValue(qApp->fromPixel(scenePos.x()));
ui->doubleSpinBoxY->setValue(qApp->fromPixel(scenePos.y()));
}
}
void DialogSinglePoint::DialogAccepted()
{
point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
point = QPointF(qApp->toPixel(ui->doubleSpinBoxX->value()), qApp->toPixel(ui->doubleSpinBoxY->value()));
name = ui->lineEditName->text();
emit DialogClosed(QDialog::Accepted);
}
@ -75,8 +75,8 @@ void DialogSinglePoint::setData(const QString &name, const QPointF &point)
this->point = point;
isInitialized = true;
ui->lineEditName->setText(name);
ui->doubleSpinBoxX->setValue(fromPixel(point.x()));
ui->doubleSpinBoxY->setValue(fromPixel(point.y()));
ui->doubleSpinBoxX->setValue(qApp->fromPixel(point.x()));
ui->doubleSpinBoxY->setValue(qApp->fromPixel(point.y()));
}
DialogSinglePoint::~DialogSinglePoint()

View file

@ -566,7 +566,7 @@ void DialogTool::LengthCurves()
void DialogTool::Increments()
{
ShowVariable(data->DataIncrementTable());
ShowVariable(data->DataIncrements());
}
void DialogTool::PutHere()
@ -624,9 +624,9 @@ void DialogTool::ValChenged(int row)
}
if (radioButtonIncrements->isChecked())
{
VIncrementTableRow itable = data->GetIncrementTableRow(item->text());
VIncrement incr = data->GetIncrement(item->text());
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
.arg(itable.getDescription());
.arg(incr.getDescription());
labelDescription->setText(desc);
return;
}
@ -672,7 +672,7 @@ void DialogTool::UpdateList()
}
if (radioButtonIncrements->isChecked())
{
ShowVariable(data->DataIncrementTable());
ShowVariable(data->DataIncrements());
}
if (radioButtonLengthLine->isChecked())
{

View file

@ -37,6 +37,7 @@
#include <QRadioButton>
#include <QDialogButtonBox>
#include "../../container/vcontainer.h"
#include "../../widgets/vapplication.h"
namespace ComboMode
{
@ -428,7 +429,7 @@ protected:
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
if (patternType == Pattern::Standard)
if (qApp->patternType() == Pattern::Standard)
{
SizeHeight();
connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight);

View file

@ -27,6 +27,7 @@
*************************************************************************/
#include "vequidistant.h"
#include "../widgets/vapplication.h"
QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer *data) const
{
@ -145,11 +146,11 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer
QPainterPath ekv;
if (detail.getClosed() == true)
{
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth()));
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, qApp->toPixel(detail.getWidth()));
}
else
{
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth()));
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, qApp->toPixel(detail.getWidth()));
}
path.addPath(ekv);
path.setFillRule(Qt::WindingFill);
@ -385,7 +386,7 @@ QVector<QPointF> VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2
case (QLineF::UnboundedIntersection):
{
QLineF line( line1.p2(), CrosPoint );
if (line.length() > width + toPixel(8))
if (line.length() > width + qApp->toPixel(8))
{
QLineF lineL = QLineF(bigLine1.p2(), CrosPoint);
lineL.setLength(width);

View file

@ -31,20 +31,6 @@
#include <QTextCodec>
#include <QtCore>
#include "tablewindow.h"
#include "options.h"
Valentina::Units patternUnit = Valentina::Cm;// Default pattern unit.
Pattern::Measurements patternType = Pattern::Individual;// Default pattern type.
#ifdef Q_OS_WIN
const QString translationsPath = QString("/translations");
#else
#ifdef QT_DEBUG
const QString translationsPath = QString("/translations");
#else
const QString translationsPath = QString("/usr/share/valentina/translations");
#endif
#endif
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
@ -98,12 +84,12 @@ int main(int argc, char *argv[])
QTranslator appTranslator;
#ifdef Q_OS_WIN
appTranslator.load("valentina_" + checkedLocale, "."+translationsPath);
appTranslator.load("valentina_" + checkedLocale, "."+qApp->translationsPath());
#else
#ifdef QT_DEBUG
appTranslator.load("valentina_" + checkedLocale, "."+translationsPath);
appTranslator.load("valentina_" + checkedLocale, "."+qApp->translationsPath());
#else
appTranslator.load("valentina_" + checkedLocale, translationsPath);
appTranslator.load("valentina_" + checkedLocale, qApp->translationsPath());
#endif
#endif
app.installTranslator(&appTranslator);

View file

@ -120,7 +120,7 @@ void MainWindow::ActionNewDraw()
measurements.exec();
if (measurements.type() == Measurements::Standard)
{
patternType == Pattern::Standard;
qApp->setPatternType(Pattern::Standard);
DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this);
if (stMeasurements.exec() == QDialog::Accepted)
{
@ -134,7 +134,7 @@ void MainWindow::ActionNewDraw()
}
else
{
patternType == Pattern::Individual;
qApp->setPatternType(Pattern::Individual);
DialogIndividualMeasurements indMeasurements(pattern, patternPieceName, this);
if (indMeasurements.exec() == QDialog::Accepted)
{
@ -167,7 +167,7 @@ void MainWindow::ActionNewDraw()
pattern->ClearGObjects();
//Create single point
const quint32 id = pattern->AddGObject(new VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5,
const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10), "А", 5,
10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui);
sceneDraw->addItem(spoint);
@ -626,8 +626,8 @@ void MainWindow::currentDrawChanged( int index )
void MainWindow::mouseMove(const QPointF &scenePos)
{
QString string = QString("%1, %2")
.arg(static_cast<qint32>(fromPixel(scenePos.x())))
.arg(static_cast<qint32>(fromPixel(scenePos.y())));
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.x())))
.arg(static_cast<qint32>(qApp->fromPixel(scenePos.y())));
mouseCoordinate->setText(string);
}

View file

@ -101,8 +101,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Sources )
Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Draws )
Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Units )
extern Valentina::Units patternUnit;
namespace Pattern
{
/**
@ -111,51 +109,7 @@ namespace Pattern
enum Measurement { Standard, Individual };
Q_DECLARE_FLAGS(Measurements, Measurement)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Pattern::Measurements )
extern Pattern::Measurements patternType;
#define PrintDPI 96.0
inline double toPixel(double unit)
{
double result = 0;
switch (patternUnit)
{
case Valentina::Mm:
result = (unit / 25.4) * PrintDPI;
break;
case Valentina::Cm:
result = ((unit * 10.0) / 25.4) * PrintDPI;
break;
case Valentina::In:
result = unit * PrintDPI;
break;
default:
break;
}
return result;
}
inline double fromPixel(double pix)
{
double result = 0;
switch (patternUnit)
{
case Valentina::Mm:
result = (pix / PrintDPI) * 25.4;
break;
case Valentina::Cm:
result = ((pix / PrintDPI) * 25.4) / 10.0;
break;
case Valentina::In:
result = pix / PrintDPI;
break;
default:
break;
}
return result;
}
Q_DECLARE_OPERATORS_FOR_FLAGS( Pattern::Measurements )
#define widthMainLine 1.2 //mm
#define widthHairLine widthMainLine/3

View file

@ -47,7 +47,6 @@ were in use. */
#include <QtXml>
#include <QtWidgets>
#include <QtSvg/QtSvg>
#include "options.h"
#endif
#endif // STABLE_H

View file

@ -31,7 +31,7 @@
#include "widgets/vtablegraphicsview.h"
#include <QtSvg>
#include <QPrinter>
#include "options.h"
#include "widgets/vapplication.h"
TableWindow::TableWindow(QWidget *parent)
:QMainWindow(parent), numberDetal(nullptr), colission(nullptr), ui(new Ui::TableWindow),
@ -45,8 +45,8 @@ TableWindow::TableWindow(QWidget *parent)
ui->statusBar->addWidget(numberDetal);
ui->statusBar->addWidget(colission);
outItems = collidingItems = false;
//sceneRect = QRectF(0, 0, toPixel(203), toPixel(287));
sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171));
//sceneRect = QRectF(0, 0, qApp->toPixel(203), qApp->toPixel(287));
sceneRect = QRectF(0, 0, qApp->toPixel(823), qApp->toPixel(1171));
tableScene = new QGraphicsScene(sceneRect);
QBrush brush;
brush.setStyle( Qt::SolidPattern );
@ -81,7 +81,7 @@ void TableWindow::AddPaper()
shadowPaper->setBrush(QBrush(Qt::black));
tableScene->addItem(shadowPaper);
paper = new QGraphicsRectItem(QRectF(x1, y1, x2, y2));
paper->setPen(QPen(Qt::black, toPixel(widthMainLine)));
paper->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
paper->setBrush(QBrush(Qt::white));
tableScene->addItem(paper);
qDebug()<<paper->rect().size().toSize();
@ -168,7 +168,7 @@ void TableWindow::StopTable()
delete listOutItems;
listDetails.clear();
//sceneRect = QRectF(0, 0, 230*resol/25.9, 327*resol/25.9);
sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171));
sceneRect = QRectF(0, 0, qApp->toPixel(823), qApp->toPixel(1171));
emit closed();
}
@ -216,6 +216,7 @@ void TableWindow::saveScene()
tableScene->setBackgroundBrush( *brush );
tableScene->clearSelection(); // Selections would also render to the file, so need delete them
shadowPaper->setVisible(false);
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
QFileInfo fi( name );
QStringList suffix;
suffix << "svg" << "png" << "pdf" << "eps" << "ps";
@ -226,30 +227,23 @@ void TableWindow::saveScene()
SvgFile(name);
paper->setVisible(true);
break;
case 1: //png
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
case 1: //png
PngFile(name);
paper->setPen(QPen(Qt::black, toPixel(widthMainLine)));
break;
case 2: //pdf
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PdfFile(name);
paper->setPen(QPen(Qt::black, toPixel(widthMainLine)));
PdfFile(name);
break;
case 3: //eps
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
EpsFile(name);
paper->setPen(QPen(Qt::black, toPixel(widthMainLine)));
break;
case 4: //ps
paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen));
PsFile(name);
paper->setPen(QPen(Qt::black, toPixel(widthMainLine)));
break;
default:
qWarning() << "Bad file suffix"<<Q_FUNC_INFO;
break;
}
paper->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
brush->setColor( QColor( Qt::gray ) );
brush->setStyle( Qt::SolidPattern );
tableScene->setBackgroundBrush( *brush );
@ -323,7 +317,7 @@ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(i) );
Q_CHECK_PTR(bitem);
bitem->setPen(QPen(Qt::black, toPixel(widthMainLine)));
bitem->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
listCollidingItems.removeAt(i);
}
}
@ -332,7 +326,7 @@ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( listCollidingItems.at(0) );
Q_CHECK_PTR(bitem);
bitem->setPen(QPen(Qt::black, toPixel(widthMainLine)));
bitem->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
listCollidingItems.clear();
collidingItems = true;
}
@ -378,13 +372,13 @@ void TableWindow::GetNextDetail()
void TableWindow::AddLength()
{
QRectF rect = tableScene->sceneRect();
rect.setHeight(rect.height()+toPixel(279));
rect.setHeight(rect.height()+qApp->toPixel(279));
tableScene->setSceneRect(rect);
rect = shadowPaper->rect();
rect.setHeight(rect.height()+toPixel(279));
rect.setHeight(rect.height()+qApp->toPixel(279));
shadowPaper->setRect(rect);
rect = paper->rect();
rect.setHeight(rect.height()+toPixel(279));
rect.setHeight(rect.height()+qApp->toPixel(279));
paper->setRect(rect);
ui->actionRemove->setEnabled(true);
emit LengthChanged();
@ -395,13 +389,13 @@ void TableWindow::RemoveLength()
if (sceneRect.height() <= tableScene->sceneRect().height() - 100)
{
QRectF rect = tableScene->sceneRect();
rect.setHeight(rect.height()-toPixel(279));
rect.setHeight(rect.height()-qApp->toPixel(279));
tableScene->setSceneRect(rect);
rect = shadowPaper->rect();
rect.setHeight(rect.height()-toPixel(279));
rect.setHeight(rect.height()-qApp->toPixel(279));
shadowPaper->setRect(rect);
rect = paper->rect();
rect.setHeight(rect.height()-toPixel(279));
rect.setHeight(rect.height()-qApp->toPixel(279));
paper->setRect(rect);
if (fabs(sceneRect.height() - tableScene->sceneRect().height()) < 0.01)
{
@ -437,12 +431,12 @@ void TableWindow::SvgFile(const QString &name) const
generator.setViewBox(paper->rect());
generator.setTitle("Valentina pattern");
generator.setDescription(description);
generator.setResolution(PrintDPI);
generator.setResolution(static_cast<int>(qApp->PrintDPI));
QPainter painter;
painter.begin(&generator);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, toPixel(widthHairLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(widthHairLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
tableScene->render(&painter);
painter.end();
@ -459,7 +453,7 @@ void TableWindow::PngFile(const QString &name) const
QPainter painter(&image);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
tableScene->render(&painter);
image.save(name);
@ -473,8 +467,8 @@ void TableWindow::PdfFile(const QString &name) const
QRectF r = paper->rect();
qreal x=0, y=0, w=0, h=0;
r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents
printer.setResolution(PrintDPI);
printer.setPaperSize ( QSizeF(fromPixel(w), fromPixel(h)), QPrinter::Millimeter );
printer.setResolution(static_cast<int>(qApp->PrintDPI));
printer.setPaperSize ( QSizeF(qApp->fromPixel(w), qApp->fromPixel(h)), QPrinter::Millimeter );
QPainter painter;
if (painter.begin( &printer ) == false)
{ // failed to open file
@ -483,7 +477,7 @@ void TableWindow::PdfFile(const QString &name) const
}
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
tableScene->render(&painter);
painter.end();

View file

@ -54,7 +54,7 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName)
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
emit setEnabledPoint(selectable);
@ -75,13 +75,13 @@ void VAbstractSpline::SetFactor(qreal factor)
void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor));
}
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
}
QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)

View file

@ -196,7 +196,7 @@ protected:
{
currentColor = color;
}
item->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
item->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
}
}
private:

View file

@ -87,8 +87,8 @@ void VToolAlongLine::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -104,8 +104,8 @@ void VToolAlongLine::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -172,7 +172,7 @@ void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const Q
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
line.setLength(toPixel(result));
line.setLength(qApp->toPixel(result));
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
{

View file

@ -42,7 +42,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina:
path.addPath(arc->GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
@ -93,7 +93,7 @@ void VToolArc::Create(const quint32 _id, const quint32 &center, const QString &r
qreal result = cal.eval(radius, &errorMsg);
if (errorMsg.isEmpty())
{
calcRadius = toPixel(result);
calcRadius = qApp->toPixel(result);
}
errorMsg.clear();
@ -155,7 +155,7 @@ void VToolArc::ChangedActivDraw(const QString &newName)
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName);
@ -218,14 +218,14 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor));
}
//cppcheck-suppress unusedFunction
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
}
void VToolArc::RemoveReferens()
@ -278,7 +278,7 @@ void VToolArc::SaveDialog(QDomElement &domElement)
void VToolArc::RefreshGeometry()
{
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
QPainterPath path;
path.addPath(arc->GetPath());

View file

@ -115,7 +115,7 @@ void VToolBisector::Create(const quint32 _id, const QString &formula, const quin
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
thirdPoint->toQPointF(), toPixel(result));
thirdPoint->toQPointF(), qApp->toPixel(result));
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
{
@ -185,8 +185,8 @@ void VToolBisector::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -203,8 +203,8 @@ void VToolBisector::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);

View file

@ -98,7 +98,7 @@ void VToolCutArc::Create(const quint32 _id, const QString &pointName, const QStr
{
VArc arc1;
VArc arc2;
QPointF point = arc->CutArc(toPixel(result), arc1, arc2);
QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2);
quint32 id = _id;
quint32 arc1id = 0;
@ -185,8 +185,8 @@ void VToolCutArc::ChangedActivDraw(const QString &newName)
secondArc->setFlag(QGraphicsItem::ItemIsSelectable, false);
secondArc->setAcceptHoverEvents(false);
}
firstArc->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
secondArc->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
firstArc->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
secondArc->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
VToolPoint::ChangedActivDraw(newName);
}
@ -208,8 +208,8 @@ void VToolCutArc::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, arcId);
@ -224,8 +224,8 @@ void VToolCutArc::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, arcId);
}

View file

@ -98,7 +98,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName,
if (errorMsg.isEmpty())
{
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
quint32 id = _id;
quint32 spl1id = 0;
@ -110,11 +110,11 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName,
VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve());
spl1id = data->AddGObject(spline1);
data->AddLengthSpline(spline1->name(), fromPixel(spline1->GetLength()));
data->AddLengthSpline(spline1->name(), qApp->fromPixel(spline1->GetLength()));
VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve());
spl2id = data->AddGObject(spline2);
data->AddLengthSpline(spline2->name(), fromPixel(spline2->GetLength()));
data->AddLengthSpline(spline2->name(), qApp->fromPixel(spline2->GetLength()));
}
else
{
@ -126,11 +126,11 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName,
VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve());
data->UpdateGObject(spl1id, spline1);
data->AddLengthSpline(spline1->name(), fromPixel(spline1->GetLength()));
data->AddLengthSpline(spline1->name(), qApp->fromPixel(spline1->GetLength()));
VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve());
data->UpdateGObject(spl2id, spline2);
data->AddLengthSpline(spline2->name(), fromPixel(spline2->GetLength()));
data->AddLengthSpline(spline2->name(), qApp->fromPixel(spline2->GetLength()));
if (parse != Document::FullParse)
{
@ -204,8 +204,8 @@ void VToolCutSpline::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, splineId);
@ -220,8 +220,8 @@ void VToolCutSpline::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, splineId);
}

View file

@ -102,7 +102,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
const QPointF point = splPath->CutSplinePath(toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
if (typeCreation == Valentina::FromGui)
{
@ -159,10 +159,10 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con
splPath2->setMaxCountPoints(splPath->CountPoint());
splPath1id = data->AddGObject(splPath1);
data->AddLengthSpline(splPath1->name(), fromPixel(splPath1->GetLength()));
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
splPath2id = data->AddGObject(splPath2);
data->AddLengthSpline(splPath2->name(), fromPixel(splPath2->GetLength()));
data->AddLengthSpline(splPath2->name(), qApp->fromPixel(splPath2->GetLength()));
}
else
{
@ -200,10 +200,10 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con
splPath2->setMaxCountPoints(splPath->CountPoint());
data->UpdateGObject(splPath1id, splPath1);
data->AddLengthSpline(splPath1->name(), fromPixel(splPath1->GetLength()));
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
data->UpdateGObject(splPath2id, splPath2);
data->AddLengthSpline(splPath2->name(), fromPixel(splPath2->GetLength()));
data->AddLengthSpline(splPath2->name(), qApp->fromPixel(splPath2->GetLength()));
if (parse != Document::FullParse)
{
@ -278,8 +278,8 @@ void VToolCutSplinePath::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, splinePathId);
@ -294,8 +294,8 @@ void VToolCutSplinePath::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, splinePathId);
}

View file

@ -89,7 +89,7 @@ void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QSt
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
line.setLength(toPixel(result));
line.setLength(qApp->toPixel(result));
line.setAngle(angle);
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
@ -151,8 +151,8 @@ void VToolEndLine::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -169,8 +169,8 @@ void VToolEndLine::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrAngle, angle);

View file

@ -157,8 +157,8 @@ void VToolHeight::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
@ -176,8 +176,8 @@ void VToolHeight::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
doc->SetAttribute(domElement, AttrP1Line, p1LineId);

View file

@ -45,7 +45,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor, LineStyle()));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor, LineStyle()));
if (typeCreation == Valentina::FromGui)
{
@ -142,7 +142,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle()));
this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName);
}
@ -177,13 +177,13 @@ void VToolLine::RefreshDataInFile()
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor, LineStyle()));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor, LineStyle()));
}
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle()));
}
void VToolLine::RemoveReferens()
@ -245,5 +245,5 @@ void VToolLine::RefreshGeometry()
const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint);
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle()));
}

View file

@ -168,8 +168,8 @@ void VToolLineIntersect::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
@ -186,8 +186,8 @@ void VToolLineIntersect::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
doc->SetAttribute(domElement, AttrP1Line2, p1Line2);

View file

@ -39,7 +39,7 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
QPointF point2 = data->GeometricObject<const VPointF *>(id)->toQPointF();
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
mainLine->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor, LineStyle()));
mainLine->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor, LineStyle()));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
@ -53,13 +53,13 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
{
currentColor = Qt::gray;
}
mainLine->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
mainLine->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle()));
VToolPoint::ChangedActivDraw(newName);
}
void VToolLinePoint::RefreshGeometry()
{
mainLine->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
mainLine->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor, LineStyle()));
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();

View file

@ -92,7 +92,7 @@ void VToolNormal::Create(const quint32 _id, const QString &formula, const quint3
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
toPixel(result), angle);
qApp->toPixel(result), angle);
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
{
@ -171,8 +171,8 @@ void VToolNormal::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -190,8 +190,8 @@ void VToolNormal::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrAngle, angle);

View file

@ -31,7 +31,7 @@
const QString VToolPoint::TagName = QStringLiteral("point");
VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0)
QGraphicsEllipseItem(parent), radius(qApp->toPixel(2)), namePoint(0), lineName(0)
{
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu);
@ -62,8 +62,8 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, fromPixel(mx));
doc->SetAttribute(domElement, AttrMy, fromPixel(my));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(mx));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(my));
emit toolhaveChange();
}
}
@ -81,7 +81,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
namePoint->setFlag(QGraphicsItem::ItemIsMovable, selectable);
@ -89,7 +89,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName)
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, selectable);
namePoint->setBrush(QBrush(currentColor));
namePoint->setAcceptHoverEvents(selectable);
lineName->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
lineName->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
VDrawTool::ChangedActivDraw(newName);
}
@ -121,18 +121,18 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/factor));
}
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
}
void VToolPoint::RefreshPointGeometry(const VPointF &point)
{
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
@ -158,13 +158,13 @@ void VToolPoint::RefreshLine()
lineName->setLine(QLineF(p1, pRec - scenePos()));
if (currentColor == Qt::gray)
{
lineName->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
lineName->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
}
else
{
lineName->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor));
lineName->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor));
}
if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4))
if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4))
{
lineName->setVisible(false);
}

View file

@ -117,7 +117,7 @@ void VToolPointOfContact::Create(const quint32 _id, const QString &radius, const
qreal result = cal.eval(radius, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP->toQPointF(),
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(),
firstP->toQPointF(), secondP->toQPointF());
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
@ -191,8 +191,8 @@ void VToolPointOfContact::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrRadius, arcRadius);
doc->SetAttribute(domElement, AttrCenter, center);
@ -209,8 +209,8 @@ void VToolPointOfContact::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrRadius, arcRadius);
doc->SetAttribute(domElement, AttrCenter, center);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);

View file

@ -141,8 +141,8 @@ void VToolPointOfIntersection::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
@ -157,8 +157,8 @@ void VToolPointOfIntersection::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}

View file

@ -120,7 +120,7 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const
if (errorMsg.isEmpty())
{
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
shoulderPoint->toQPointF(), toPixel(result));
shoulderPoint->toQPointF(), qApp->toPixel(result));
quint32 id = _id;
if (typeCreation == Valentina::FromGui)
{
@ -193,8 +193,8 @@ void VToolShoulderPoint::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
@ -212,8 +212,8 @@ void VToolShoulderPoint::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrName, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrName, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrName, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrP1Line, basePointId);

View file

@ -69,10 +69,10 @@ void VToolSinglePoint::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrX, fromPixel(point->x()));
doc->SetAttribute(domElement, AttrY, fromPixel(point->y()));
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x()));
doc->SetAttribute(domElement, AttrY, qApp->fromPixel(point->y()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
AddToCalculation(domElement);
}
@ -84,10 +84,10 @@ void VToolSinglePoint::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(point->x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(point->y())));
doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(point->mx())));
doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(point->my())));
doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(point->x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(point->y())));
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(point->mx())));
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(point->my())));
}
}
@ -113,8 +113,8 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(newPos.x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(newPos.y())));
doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(newPos.x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(newPos.y())));
QList<QGraphicsView*> list = this->scene()->views();
VAbstractTool::NewSceneRect(this->scene(), list[0]);
@ -143,14 +143,14 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement)
QPointF p = dialogTool->getPoint();
QString name = dialogTool->getName();
doc->SetAttribute(domElement, AttrName, name);
doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(p.x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(p.y())));
doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(p.x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y())));
}
void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color)
{
namePoint->setBrush(color);
lineName->setPen(QPen(color, toPixel(widthHairLine)/factor));
lineName->setPen(QPen(color, qApp->toPixel(widthHairLine)/factor));
}
void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )

View file

@ -40,7 +40,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale
path.addPath(spl->GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
@ -115,12 +115,12 @@ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4
if (typeCreation == Valentina::FromGui)
{
id = data->AddGObject(spline);
data->AddLengthSpline(spline->name(), fromPixel(spline->GetLength()));
data->AddLengthSpline(spline->name(), qApp->fromPixel(spline->GetLength()));
}
else
{
data->UpdateGObject(id, spline);
data->AddLengthSpline(spline->name(), fromPixel(spline->GetLength()));
data->AddLengthSpline(spline->name(), qApp->fromPixel(spline->GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
@ -256,7 +256,7 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
QPainterPath path;
path.addPath(spl->GetPath());

View file

@ -39,7 +39,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
path.addPath(splPath->GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
@ -102,12 +102,12 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics
if (typeCreation == Valentina::FromGui)
{
id = data->AddGObject(path);
data->AddLengthSpline(path->name(), fromPixel(path->GetLength()));
data->AddLengthSpline(path->name(), qApp->fromPixel(path->GetLength()));
}
else
{
data->UpdateGObject(id, path);
data->AddLengthSpline(path->name(), fromPixel(path->GetLength()));
data->AddLengthSpline(path->name(), qApp->fromPixel(path->GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
@ -284,7 +284,7 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement)
void VToolSplinePath::RefreshGeometry()
{
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/factor));
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
QPainterPath path;
path.addPath(splPath->GetPath());

View file

@ -197,8 +197,8 @@ void VToolTriangle::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrAxisP1, axisP1Id);
doc->SetAttribute(domElement, AttrAxisP2, axisP2Id);
@ -215,8 +215,8 @@ void VToolTriangle::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrAxisP1, axisP1Id);
doc->SetAttribute(domElement, AttrAxisP2, axisP2Id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);

View file

@ -29,6 +29,7 @@
#include "vnodearc.h"
#include <QtWidgets>
#include "../../widgets/vapplication.h"
const QString VNodeArc::TagName = QStringLiteral("arc");
const QString VNodeArc::ToolType = QStringLiteral("modeling");
@ -38,7 +39,7 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, toPixel(widthHairLine)));
this->setPen(QPen(baseColor, qApp->toPixel(widthHairLine)));
if (typeCreation == Valentina::FromGui)
{
@ -128,13 +129,13 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)));
}
void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)));
}
void VNodeArc::RefreshGeometry()

View file

@ -29,6 +29,7 @@
#include "vnodepoint.h"
#include <QtWidgets>
#include "../../widgets/vapplication.h"
const QString VNodePoint::TagName = QStringLiteral("point");
const QString VNodePoint::ToolType = QStringLiteral("modeling");
@ -36,14 +37,14 @@ const QString VNodePoint::ToolType = QStringLiteral("modeling");
VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint,
const Valentina::Sources &typeCreation, const quint32 &idTool, QObject *qoParent,
QGraphicsItem *parent)
:VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(toPixel(1.5)),
:VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(qApp->toPixel(1.5)),
namePoint(nullptr), lineName(nullptr)
{
namePoint = new VGraphicsSimpleTextItem(this);
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VNodePoint::NameChangePosition);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
@ -107,8 +108,8 @@ void VNodePoint::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
if (idTool != 0)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
@ -124,8 +125,8 @@ void VNodePoint::RefreshDataInFile()
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(point->my()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
if (idTool != 0)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
@ -145,13 +146,13 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)));
}
void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)));
}
@ -171,8 +172,8 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(mx)));
doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(my)));
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my)));
emit toolhaveChange();
}
}
@ -200,7 +201,7 @@ void VNodePoint::RefreshLine()
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - scenePos()));
if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4))
if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4))
{
lineName->setVisible(false);
}

View file

@ -29,6 +29,7 @@
#include "vnodespline.h"
#include <QtWidgets>
#include "../../widgets/vapplication.h"
const QString VNodeSpline::TagName = QStringLiteral("spline");
const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline");
@ -39,7 +40,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, toPixel(widthHairLine)));
this->setPen(QPen(baseColor, qApp->toPixel(widthHairLine)));
if (typeCreation == Valentina::FromGui)
{
@ -132,13 +133,13 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)));
}
void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)));
}
void VNodeSpline::RefreshGeometry()

View file

@ -29,6 +29,7 @@
#include "vnodesplinepath.h"
#include <QtWidgets>
#include "../../widgets/vapplication.h"
const QString VNodeSplinePath::TagName = QStringLiteral("spline");
const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
@ -39,7 +40,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, toPixel(widthHairLine)));
this->setPen(QPen(baseColor, qApp->toPixel(widthHairLine)));
if (typeCreation == Valentina::FromGui)
{
@ -135,13 +136,13 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)));
}
void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)));
}
void VNodeSplinePath::RefreshGeometry()

View file

@ -230,8 +230,8 @@ void VToolDetail::AddToFile()
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, AttrName, detail.getName());
doc->SetAttribute(domElement, AttrMx, fromPixel(detail.getMx()));
doc->SetAttribute(domElement, AttrMy, fromPixel(detail.getMy()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy()));
doc->SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance());
doc->SetAttribute(domElement, AttrClosed, detail.getClosed());
doc->SetAttribute(domElement, AttrWidth, detail.getWidth());
@ -277,8 +277,8 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(newPos.x())));
doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(newPos.y())));
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(newPos.x())));
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(newPos.y())));
QList<QGraphicsView*> list = this->scene()->views();
VAbstractTool::NewSceneRect(this->scene(), list[0]);
@ -370,8 +370,8 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node)
QDomElement nod = doc->createElement(TagNode);
doc->SetAttribute(nod, AttrIdObject, node.getId());
doc->SetAttribute(nod, AttrMx, fromPixel(node.getMx()));
doc->SetAttribute(nod, AttrMy, fromPixel(node.getMy()));
doc->SetAttribute(nod, AttrMx, qApp->fromPixel(node.getMx()));
doc->SetAttribute(nod, AttrMy, qApp->fromPixel(node.getMy()));
if (node.getTypeNode() == NodeDetail::Contour)
{
doc->SetAttribute(nod, AttrNodeType, NodeTypeContour);

View file

@ -579,8 +579,8 @@ QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomE
if (element.tagName() == VToolUnionDetails::TagNode)
{
quint32 id = doc->GetParametrUInt(element, VToolDetail::AttrIdObject, "0");
qreal mx = toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
qreal my = toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
qreal mx = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
qreal my = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
Valentina::Tools tool;
NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
QString t = doc->GetParametrString(element, "type", "NodePoint");
@ -657,8 +657,8 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node
QDomElement nod = doc->createElement(TagNode);
doc->SetAttribute(nod, AttrIdObject, node.getId());
doc->SetAttribute(nod, AttrMx, fromPixel(node.getMx()));
doc->SetAttribute(nod, AttrMy, fromPixel(node.getMy()));
doc->SetAttribute(nod, AttrMx, qApp->fromPixel(node.getMx()));
doc->SetAttribute(nod, AttrMy, qApp->fromPixel(node.getMy()));
if (node.getTypeNode() == NodeDetail::Contour)
{
doc->SetAttribute(nod, AttrNodeType, NodeTypeContour);

View file

@ -36,12 +36,20 @@
#include <QMessageBox>
#include <QDebug>
const qreal VApplication::PrintDPI = 96.0;
// reimplemented from QApplication so we can throw exceptions in slots
VApplication::VApplication(int &argc, char **argv)
: QApplication(argc, argv), _patternUnit(Valentina::Cm), _patternType(Pattern::Individual)
{
}
bool VApplication::notify(QObject *receiver, QEvent *event)
{
try
{
return QApplication::notify(receiver, event);
return QApplication::notify(receiver, event);
}
catch (const VExceptionObjectError &e)
{
@ -79,3 +87,83 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
}
return false;
}
double VApplication::toPixel(double unit) const
{
double result = 0;
switch (_patternUnit)
{
case Valentina::Mm:
result = (unit / 25.4) * PrintDPI;
break;
case Valentina::Cm:
result = ((unit * 10.0) / 25.4) * PrintDPI;
break;
case Valentina::In:
result = unit * PrintDPI;
break;
default:
break;
}
return result;
}
double VApplication::fromPixel(double pix) const
{
double result = 0;
switch (_patternUnit)
{
case Valentina::Mm:
result = (pix / PrintDPI) * 25.4;
break;
case Valentina::Cm:
result = ((pix / PrintDPI) * 25.4) / 10.0;
break;
case Valentina::In:
result = pix / PrintDPI;
break;
default:
break;
}
return result;
}
QString VApplication::pathToTables() const
{
if (_patternType == Pattern::Individual)
{
#ifdef Q_OS_WIN
return QStringLiteral("/tables/individual");
#else
#ifdef QT_DEBUG
return QStringLiteral("/tables/individual");
#else
return QStringLiteral("/usr/share/valentina/tables/individual");
#endif
#endif
}
else
{
#ifdef Q_OS_WIN
return QStringLiteral("/tables/standard");
#else
#ifdef QT_DEBUG
return QStringLiteral("/tables/standard");
#else
return QStringLiteral("/usr/share/valentina/tables/standard");
#endif
#endif
}
}
QString VApplication::translationsPath() const
{
#ifdef Q_OS_WIN
return QStringLiteral("/translations");
#else
#ifdef QT_DEBUG
return QStringLiteral("/translations");
#else
return QStringLiteral("/usr/share/valentina/translations");
#endif
#endif
}

View file

@ -30,6 +30,14 @@
#define VAPPLICATION_H
#include <QApplication>
#include "../options.h"
class VApplication;
#if defined(qApp)
#undef qApp
#endif
#define qApp (static_cast<VApplication*>(QCoreApplication::instance()))
/**
* @brief The VApplication class reimplamentation QApplication class.
@ -43,7 +51,7 @@ public:
* @param argc number arguments.
* @param argv command line.
*/
VApplication(int &argc, char ** argv): QApplication(argc, argv){}
VApplication(int &argc, char ** argv);
virtual ~VApplication() {}
/**
* @brief notify Reimplemented from QApplication::notify().
@ -52,6 +60,39 @@ public:
* @return value that is returned from the receiver's event handler.
*/
virtual bool notify(QObject * receiver, QEvent * event);
Valentina::Units patternUnit() const;
void setPatternUnit(const Valentina::Units &patternUnit);
Pattern::Measurements patternType() const;
void setPatternType(const Pattern::Measurements &patternType);
double toPixel(double unit) const;
double fromPixel(double pix) const;
static const qreal PrintDPI;
QString translationsPath() const;
QString pathToTables() const;
private:
Valentina::Units _patternUnit;
Pattern::Measurements _patternType;
};
inline Valentina::Units VApplication::patternUnit() const
{
return _patternUnit;
}
inline void VApplication::setPatternUnit(const Valentina::Units &patternUnit)
{
_patternUnit = patternUnit;
}
inline Pattern::Measurements VApplication::patternType() const
{
return _patternType;
}
inline void VApplication::setPatternType(const Pattern::Measurements &patternType)
{
_patternType = patternType;
}
#endif // VAPPLICATION_H

View file

@ -30,18 +30,19 @@
#include "../tools/vabstracttool.h"
#include <QPen>
#include "../widgets/vapplication.h"
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint,
QGraphicsItem *parent)
:QGraphicsEllipseItem(parent), radius(toPixel(1.5)), controlLine(nullptr), indexSpline(indexSpline),
:QGraphicsEllipseItem(parent), radius(qApp->toPixel(1.5)), controlLine(nullptr), indexSpline(indexSpline),
position(position)
{
//create circle
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -52,20 +53,20 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint:
QPointF p1, p2;
VAbstractTool::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this);
controlLine->setPen(QPen(Qt::red, toPixel(widthHairLine)));
controlLine->setPen(QPen(Qt::red, qApp->toPixel(widthHairLine)));
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(Qt::black, toPixel(widthMainLine)));
this->setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
}
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(Qt::black, toPixel(widthHairLine)));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
}
QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
@ -94,14 +95,14 @@ void VControlPointSpline::setEnabledPoint(bool enable)
{
if (enable == true)
{
this->setPen(QPen(Qt::black, toPixel(widthHairLine)));
this->setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setAcceptHoverEvents(true);
}
else
{
this->setPen(QPen(Qt::gray, toPixel(widthHairLine)));
this->setPen(QPen(Qt::gray, qApp->toPixel(widthHairLine)));
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setFlag(QGraphicsItem::ItemIsMovable, false);
this->setAcceptHoverEvents(false);

View file

@ -27,10 +27,10 @@
*************************************************************************/
#include "vitem.h"
#include "../options.h"
#include <QGraphicsScene>
#include <QDebug>
#include "../widgets/vapplication.h"
VItem::VItem (const QPainterPath & path, int numInList, QGraphicsItem * parent )
:QGraphicsPathItem ( path, parent ), numInOutList(numInList), paper(nullptr)
@ -63,19 +63,19 @@ void VItem::checkItemChange()
QRectF myrect = sceneBoundingRect();
if ( rect.contains( myrect )==true )
{
setPen(QPen(Qt::black, toPixel(widthMainLine)));
setPen(QPen(Qt::black, qApp->toPixel(widthMainLine)));
emit itemOut( numInOutList, false );
}
else
{
setPen(QPen(Qt::red, toPixel(widthMainLine)));
setPen(QPen(Qt::red, qApp->toPixel(widthMainLine)));
emit itemOut( numInOutList, true );
}
QList<QGraphicsItem *> list = QGraphicsItem::collidingItems ();
if ( list.size() - 2 > 0 )
{
list.append( this );
setPen(QPen(Qt::red, toPixel(widthMainLine)));
setPen(QPen(Qt::red, qApp->toPixel(widthMainLine)));
emit itemColliding( list, 1 );//Detail intersect with other details.
}
else

View file

@ -27,17 +27,18 @@
*************************************************************************/
#include "vsimplearc.h"
#include "../widgets/vapplication.h"
VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
if (factor == nullptr)
{
setPen(QPen(Qt::black, toPixel(widthHairLine)));
setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
}
else
{
setPen(QPen(Qt::black, toPixel(widthHairLine)/ *factor));
setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/ *factor));
}
setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptHoverEvents(true);
@ -57,11 +58,11 @@ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if (factor == nullptr)
{
this->setPen(QPen(*currentColor, toPixel(widthMainLine)));
this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)));
}
else
{
this->setPen(QPen(*currentColor, toPixel(widthMainLine)/ *factor));
this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)/ *factor));
}
}
@ -70,10 +71,10 @@ void VSimpleArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if (factor == nullptr)
{
this->setPen(QPen(*currentColor, toPixel(widthHairLine)));
this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)));
}
else
{
this->setPen(QPen(*currentColor, toPixel(widthHairLine)/ *factor));
this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor));
}
}

View file

@ -27,18 +27,18 @@
*************************************************************************/
#include "vsimplespline.h"
#include "../options.h"
#include "../widgets/vapplication.h"
VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
if (factor == nullptr)
{
setPen(QPen(Qt::black, toPixel(widthHairLine)));
setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)));
}
else
{
setPen(QPen(Qt::black, toPixel(widthHairLine)/ *factor));
setPen(QPen(Qt::black, qApp->toPixel(widthHairLine)/ *factor));
}
setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptHoverEvents(true);
@ -48,7 +48,7 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag)
{
setFlag(QGraphicsItem::ItemIsSelectable, flag);
setAcceptHoverEvents(flag);
setPen(QPen(*currentColor, toPixel(widthHairLine)/ *factor));
setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor));
}
void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@ -65,11 +65,11 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if (factor == nullptr)
{
this->setPen(QPen(*currentColor, toPixel(widthMainLine)));
this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)));
}
else
{
this->setPen(QPen(*currentColor, toPixel(widthMainLine)/ *factor));
this->setPen(QPen(*currentColor, qApp->toPixel(widthMainLine)/ *factor));
}
}
@ -78,10 +78,10 @@ void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if (factor == nullptr)
{
this->setPen(QPen(*currentColor, toPixel(widthHairLine)));
this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)));
}
else
{
this->setPen(QPen(*currentColor, toPixel(widthHairLine)/ *factor));
this->setPen(QPen(*currentColor, qApp->toPixel(widthHairLine)/ *factor));
}
}

View file

@ -27,6 +27,7 @@
*************************************************************************/
#include "vsimplesplinepath.h"
#include "../widgets/vapplication.h"
VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor)
:VAbstractTool(doc, data, id), factor(factor)
@ -45,11 +46,11 @@ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthMainLine)/ *factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthMainLine)/ *factor));
}
void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, toPixel(widthHairLine)/ *factor));
this->setPen(QPen(currentColor, qApp->toPixel(widthHairLine)/ *factor));
}

View file

@ -84,8 +84,8 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
patternElement.appendChild(createElement(TagNotes));
QDomElement measurements = createElement(TagMeasurements);
SetAttribute(measurements, "unit", patternUnit);
SetAttribute(measurements, "type", patternType);
SetAttribute(measurements, "unit", qApp->patternUnit());
SetAttribute(measurements, "type", qApp->patternType());
SetAttribute(measurements, "path", tablePath);
patternElement.appendChild(measurements);
@ -547,8 +547,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
VDetail detail;
const quint32 id = GetParametrId(domElement);
detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
detail.setMx(qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
detail.setMy(qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1"));
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1"));
@ -563,8 +563,8 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
if (element.tagName() == VToolDetail::TagNode)
{
const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, "0");
const qreal mx = toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
const qreal my = toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
const qreal my = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
const NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
const QString t = GetParametrString(element, AttrType, "NodePoint");
@ -650,10 +650,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A");
const qreal x = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
const qreal y = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
VDrawTool::AddRecord(id, Valentina::SinglePointTool, this);
@ -685,8 +685,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
@ -708,8 +708,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
@ -731,8 +731,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
@ -755,8 +755,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
@ -779,8 +779,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
@ -803,8 +803,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
@ -825,8 +825,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
@ -849,8 +849,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
Valentina::Modeling));
VNodePoint::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool);
@ -867,8 +867,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
@ -890,8 +890,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
@ -912,8 +912,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
@ -932,8 +932,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
@ -951,8 +951,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
@ -971,8 +971,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
{
const quint32 id = GetParametrId(domElement);
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
const qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
@ -1246,7 +1246,7 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
const qreal kgrowth = GetParametrDouble(domElement, IncrementKgrowth, "0");
const QString desc = GetParametrString(domElement, IncrementDescription, "Description");
data->UpdateId(id);
data->AddIncrementTableRow(name, VIncrementTableRow(id, base, ksize, kgrowth, desc));
data->AddIncrement(name, VIncrement(id, base, ksize, kgrowth, desc));
}
}
}