Replaced Qmap on to Qhash. Better performance.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-04 14:32:42 +03:00
parent 91ce892ab0
commit 233e1f7cbc
16 changed files with 136 additions and 128 deletions

View File

@ -26,15 +26,15 @@
qint64 VContainer::_id = 0; qint64 VContainer::_id = 0;
VContainer::VContainer():base(QMap<QString, qint32>()), points(QMap<qint64, VPointF>()), VContainer::VContainer():base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
modelingPoints(QMap<qint64, VPointF>()), modelingPoints(QHash<qint64, VPointF>()),
standartTable(QMap<QString, VStandartTableCell>()), incrementTable(QMap<QString, VIncrementTableRow>()), standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QMap<QString, qreal>()), lineAngles(QMap<QString, qreal>()), splines(QMap<qint64, VSpline>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
modelingSplines(QMap<qint64, VSpline>()), modelingSplines(QHash<qint64, VSpline>()),
lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), modelingArcs(QMap<qint64, VArc>()), lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()),
lengthArcs(QMap<QString, qreal>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QMap<qint64, VSplinePath>()), modelingSplinePaths(QMap<qint64, VSplinePath>()), splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()),
details(QMap<qint64, VDetail>()){ details(QHash<qint64, VDetail>()){
SetSize(500); SetSize(500);
SetGrowth(1760); SetGrowth(1760);
CreateManTableIGroup (); CreateManTableIGroup ();
@ -45,15 +45,15 @@ VContainer &VContainer::operator =(const VContainer &data){
return *this; return *this;
} }
VContainer::VContainer(const VContainer &data):base(QMap<QString, qint32>()), points(QMap<qint64, VPointF>()), VContainer::VContainer(const VContainer &data):base(QHash<QString, qint32>()), points(QHash<qint64, VPointF>()),
modelingPoints(QMap<qint64, VPointF>()), modelingPoints(QHash<qint64, VPointF>()),
standartTable(QMap<QString, VStandartTableCell>()), incrementTable(QMap<QString, VIncrementTableRow>()), standartTable(QHash<QString, VStandartTableCell>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QMap<QString, qreal>()), lineAngles(QMap<QString, qreal>()), splines(QMap<qint64, VSpline>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), splines(QHash<qint64, VSpline>()),
modelingSplines(QMap<qint64, VSpline>()), modelingSplines(QHash<qint64, VSpline>()),
lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), modelingArcs(QMap<qint64, VArc>()), lengthSplines(QHash<QString, qreal>()), arcs(QHash<qint64, VArc>()), modelingArcs(QHash<qint64, VArc>()),
lengthArcs(QMap<QString, qreal>()), lengthArcs(QHash<QString, qreal>()),
splinePaths(QMap<qint64, VSplinePath>()), modelingSplinePaths(QMap<qint64, VSplinePath>()), splinePaths(QHash<qint64, VSplinePath>()), modelingSplinePaths(QHash<qint64, VSplinePath>()),
details(QMap<qint64, VDetail>()){ details(QHash<qint64, VDetail>()){
setData(data); setData(data);
} }
@ -77,7 +77,7 @@ void VContainer::setData(const VContainer &data){
} }
template <typename key, typename val> template <typename key, typename val>
val VContainer::GetObject(const QMap<key,val> &obj, key id){ val VContainer::GetObject(const QHash<key, val> &obj, key id){
if(obj.contains(id)){ if(obj.contains(id)){
return obj.value(id); return obj.value(id);
} else { } else {
@ -85,7 +85,6 @@ val VContainer::GetObject(const QMap<key,val> &obj, key id){
} }
} }
VPointF VContainer::GetPoint(qint64 id) const{ VPointF VContainer::GetPoint(qint64 id) const{
return GetObject(points, id); return GetObject(points, id);
} }
@ -377,7 +376,7 @@ QVector<QPointF> VContainer::CheckLoops(const QVector<QPointF> &points) const{
} }
void VContainer::PrepareDetails(QVector<VItem *> &list) const{ void VContainer::PrepareDetails(QVector<VItem *> &list) const{
QMapIterator<qint64, VDetail> iDetail(details); QHashIterator<qint64, VDetail> iDetail(details);
while (iDetail.hasNext()) { while (iDetail.hasNext()) {
iDetail.next(); iDetail.next();
list.append(new VItem(ContourPath(iDetail.key()), list.size())); list.append(new VItem(ContourPath(iDetail.key()), list.size()));
@ -389,7 +388,7 @@ void VContainer::RemoveIncrementTableRow(const QString& name){
} }
template <typename val> template <typename val>
void VContainer::UpdateObject(QMap<qint64, val> &obj, const qint64 &id, const val& point){ void VContainer::UpdateObject(QHash<qint64, val> &obj, const qint64 &id, const val& point){
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
obj[id] = point; obj[id] = point;
UpdateId(id); UpdateId(id);
@ -567,67 +566,67 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const{
return 0; return 0;
} }
const QMap<qint64, VPointF> *VContainer::DataPoints() const{ const QHash<qint64, VPointF> *VContainer::DataPoints() const{
return &points; return &points;
} }
const QMap<qint64, VPointF> *VContainer::DataModelingPoints() const{ const QHash<qint64, VPointF> *VContainer::DataModelingPoints() const{
return &modelingPoints; return &modelingPoints;
} }
const QMap<qint64, VSpline> *VContainer::DataSplines() const{ const QHash<qint64, VSpline> *VContainer::DataSplines() const{
return &splines; return &splines;
} }
const QMap<qint64, VSpline> *VContainer::DataModelingSplines() const{ const QHash<qint64, VSpline> *VContainer::DataModelingSplines() const{
return &modelingSplines; return &modelingSplines;
} }
const QMap<qint64, VArc> *VContainer::DataArcs() const{ const QHash<qint64, VArc> *VContainer::DataArcs() const{
return &arcs; return &arcs;
} }
const QMap<qint64, VArc> *VContainer::DataModelingArcs() const{ const QHash<qint64, VArc> *VContainer::DataModelingArcs() const{
return &modelingArcs; return &modelingArcs;
} }
const QMap<QString, qint32> *VContainer::DataBase() const{ const QHash<QString, qint32> *VContainer::DataBase() const{
return &base; return &base;
} }
const QMap<QString, VStandartTableCell> *VContainer::DataStandartTable() const{ const QHash<QString, VStandartTableCell> *VContainer::DataStandartTable() const{
return &standartTable; return &standartTable;
} }
const QMap<QString, VIncrementTableRow> *VContainer::DataIncrementTable() const{ const QHash<QString, VIncrementTableRow> *VContainer::DataIncrementTable() const{
return &incrementTable; return &incrementTable;
} }
const QMap<QString, qreal> *VContainer::DataLengthLines() const{ const QHash<QString, qreal> *VContainer::DataLengthLines() const{
return &lengthLines; return &lengthLines;
} }
const QMap<QString, qreal> *VContainer::DataLengthSplines() const{ const QHash<QString, qreal> *VContainer::DataLengthSplines() const{
return &lengthSplines; return &lengthSplines;
} }
const QMap<QString, qreal> *VContainer::DataLengthArcs() const{ const QHash<QString, qreal> *VContainer::DataLengthArcs() const{
return &lengthArcs; return &lengthArcs;
} }
const QMap<QString, qreal> *VContainer::DataLineAngles() const{ const QHash<QString, qreal> *VContainer::DataLineAngles() const{
return &lineAngles; return &lineAngles;
} }
const QMap<qint64, VSplinePath> *VContainer::DataSplinePaths() const{ const QHash<qint64, VSplinePath> *VContainer::DataSplinePaths() const{
return &splinePaths; return &splinePaths;
} }
const QMap<qint64, VSplinePath> *VContainer::DataModelingSplinePaths() const{ const QHash<qint64, VSplinePath> *VContainer::DataModelingSplinePaths() const{
return &modelingSplinePaths; return &modelingSplinePaths;
} }
const QMap<qint64, VDetail> *VContainer::DataDetails() const{ const QHash<qint64, VDetail> *VContainer::DataDetails() const{
return &details; return &details;
} }
@ -648,7 +647,7 @@ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId
} }
template <typename key, typename val> template <typename key, typename val>
qint64 VContainer::AddObject(QMap<key, val> &obj, const val& value){ qint64 VContainer::AddObject(QHash<key, val> &obj, const val& value){
qint64 id = getNextId(); qint64 id = getNextId();
obj[id] = value; obj[id] = value;
return id; return id;

View File

@ -122,22 +122,22 @@ public:
bool IncrementTableContains(const QString& name); bool IncrementTableContains(const QString& name);
static qint64 getNextId(); static qint64 getNextId();
void RemoveIncrementTableRow(const QString& name); void RemoveIncrementTableRow(const QString& name);
const QMap<qint64, VPointF> *DataPoints() const; const QHash<qint64, VPointF> *DataPoints() const;
const QMap<qint64, VPointF> *DataModelingPoints() const; const QHash<qint64, VPointF> *DataModelingPoints() const;
const QMap<qint64, VSpline> *DataSplines() const; const QHash<qint64, VSpline> *DataSplines() const;
const QMap<qint64, VSpline> *DataModelingSplines() const; const QHash<qint64, VSpline> *DataModelingSplines() const;
const QMap<qint64, VArc> *DataArcs() const; const QHash<qint64, VArc> *DataArcs() const;
const QMap<qint64, VArc> *DataModelingArcs() const; const QHash<qint64, VArc> *DataModelingArcs() const;
const QMap<QString, qint32> *DataBase() const; const QHash<QString, qint32> *DataBase() const;
const QMap<QString, VStandartTableCell> *DataStandartTable() const; const QHash<QString, VStandartTableCell> *DataStandartTable() const;
const QMap<QString, VIncrementTableRow> *DataIncrementTable() const; const QHash<QString, VIncrementTableRow> *DataIncrementTable() const;
const QMap<QString, qreal> *DataLengthLines() const; const QHash<QString, qreal> *DataLengthLines() const;
const QMap<QString, qreal> *DataLengthSplines() const; const QHash<QString, qreal> *DataLengthSplines() const;
const QMap<QString, qreal> *DataLengthArcs() const; const QHash<QString, qreal> *DataLengthArcs() const;
const QMap<QString, qreal> *DataLineAngles() const; const QHash<QString, qreal> *DataLineAngles() const;
const QMap<qint64, VSplinePath> *DataSplinePaths() const; const QHash<qint64, VSplinePath> *DataSplinePaths() const;
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const; const QHash<qint64, VSplinePath> *DataModelingSplinePaths() const;
const QMap<qint64, VDetail> *DataDetails() const; const QHash<qint64, VDetail> *DataDetails() const;
static void UpdateId(qint64 newId); static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const; QPainterPath ContourPath(qint64 idDetail) const;
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv, QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
@ -149,26 +149,26 @@ public:
void PrepareDetails(QVector<VItem*> & list)const; void PrepareDetails(QVector<VItem*> & list)const;
private: private:
static qint64 _id; static qint64 _id;
QMap<QString, qint32> base; QHash<QString, qint32> base;
QMap<qint64, VPointF> points; QHash<qint64, VPointF> points;
QMap<qint64, VPointF> modelingPoints; QHash<qint64, VPointF> modelingPoints;
QMap<QString, VStandartTableCell> standartTable; QHash<QString, VStandartTableCell> standartTable;
QMap<QString, VIncrementTableRow> incrementTable; QHash<QString, VIncrementTableRow> incrementTable;
QMap<QString, qreal> lengthLines; QHash<QString, qreal> lengthLines;
QMap<QString, qreal> lineAngles; QHash<QString, qreal> lineAngles;
QMap<qint64, VSpline> splines; QHash<qint64, VSpline> splines;
QMap<qint64, VSpline> modelingSplines; QHash<qint64, VSpline> modelingSplines;
QMap<QString, qreal> lengthSplines; QHash<QString, qreal> lengthSplines;
QMap<qint64, VArc> arcs; QHash<qint64, VArc> arcs;
QMap<qint64, VArc> modelingArcs; QHash<qint64, VArc> modelingArcs;
QMap<QString, qreal> lengthArcs; QHash<QString, qreal> lengthArcs;
QMap<qint64, VSplinePath> splinePaths; QHash<qint64, VSplinePath> splinePaths;
QMap<qint64, VSplinePath> modelingSplinePaths; QHash<qint64, VSplinePath> modelingSplinePaths;
QMap<qint64, VDetail> details; QHash<qint64, VDetail> details;
template <typename key, typename val> static val GetObject(const QMap<key,val> &obj, key id); template <typename key, typename val> static val GetObject(const QHash<key,val> &obj, key id);
template <typename val> static void UpdateObject(QMap<qint64, val> &obj, const qint64 &id, template <typename val> static void UpdateObject(QHash<qint64, val> &obj, const qint64 &id,
const val& point); const val& point);
template <typename key, typename val> static qint64 AddObject(QMap<key, val> &obj, const val& value); template <typename key, typename val> static qint64 AddObject(QHash<key, val> &obj, const val& value);
void CreateManTableIGroup (); void CreateManTableIGroup ();
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const; QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const; qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const;

View File

@ -209,8 +209,8 @@ void DialogArc::ShowLineArcs(){
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ui->listWidget->clear(); ui->listWidget->clear();
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
const QMap<QString, qreal> *lineArcsTable = data->DataLineAngles(); const QHash<QString, qreal> *lineArcsTable = data->DataLineAngles();
QMapIterator<QString, qreal> i(*lineArcsTable); QHashIterator<QString, qreal> i(*lineArcsTable);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
QListWidgetItem *item = new QListWidgetItem(i.key()); QListWidgetItem *item = new QListWidgetItem(i.key());

View File

@ -55,9 +55,9 @@ DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget
} }
void DialogIncrements::FillStandartTable(){ void DialogIncrements::FillStandartTable(){
const QMap<QString, VStandartTableCell> *standartTable = data->DataStandartTable(); const QHash<QString, VStandartTableCell> *standartTable = data->DataStandartTable();
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, VStandartTableCell> i(*standartTable); QHashIterator<QString, VStandartTableCell> i(*standartTable);
ui->tableWidgetStandart->setRowCount ( standartTable->size() ); ui->tableWidgetStandart->setRowCount ( standartTable->size() );
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
@ -95,22 +95,31 @@ void DialogIncrements::FillStandartTable(){
} }
void DialogIncrements::FillIncrementTable(){ void DialogIncrements::FillIncrementTable(){
const QMap<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable(); const QHash<QString, VIncrementTableRow> *incrementTable = data->DataIncrementTable();
qint32 currentRow = -1; QHashIterator<QString, VIncrementTableRow> i(*incrementTable);
QMapIterator<QString, VIncrementTableRow> i(*incrementTable); QMap<qint64, QString> map;
//Sorting QHash by id
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
VIncrementTableRow cell = i.value(); VIncrementTableRow cell = i.value();
map.insert(cell.getId(), i.key());
}
qint32 currentRow = -1;
QMapIterator<qint64, QString> iMap(map);
while (iMap.hasNext()) {
iMap.next();
VIncrementTableRow cell = incrementTable->value(iMap.value());
currentRow++; currentRow++;
ui->tableWidgetIncrement->setRowCount ( incrementTable->size() ); ui->tableWidgetIncrement->setRowCount ( incrementTable->size() );
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); QTableWidgetItem *item = new QTableWidgetItem(iMap.value());
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
item->setData(Qt::UserRole, cell.getId()); item->setData(Qt::UserRole, cell.getId());
ui->tableWidgetIncrement->setItem(currentRow, 0, item); ui->tableWidgetIncrement->setItem(currentRow, 0, item);
item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(i.key()))); item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value())));
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags(); Qt::ItemFlags flags = item->flags();
@ -143,9 +152,9 @@ void DialogIncrements::FillIncrementTable(){
} }
void DialogIncrements::FillLengthLines(){ void DialogIncrements::FillLengthLines(){
const QMap<QString, qreal> *linesTable = data->DataLengthLines(); const QHash<QString, qreal> *linesTable = data->DataLengthLines();
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(*linesTable); QHashIterator<QString, qreal> i(*linesTable);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
@ -167,9 +176,9 @@ void DialogIncrements::FillLengthLines(){
} }
void DialogIncrements::FillLengthSplines(){ void DialogIncrements::FillLengthSplines(){
const QMap<QString, qreal> *splinesTable = data->DataLengthSplines(); const QHash<QString, qreal> *splinesTable = data->DataLengthSplines();
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(*splinesTable); QHashIterator<QString, qreal> i(*splinesTable);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();
@ -191,9 +200,9 @@ void DialogIncrements::FillLengthSplines(){
} }
void DialogIncrements::FillLengthArcs(){ void DialogIncrements::FillLengthArcs(){
const QMap<QString, qreal> *arcsTable = data->DataLengthArcs(); const QHash<QString, qreal> *arcsTable = data->DataLengthArcs();
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<QString, qreal> i(*arcsTable); QHashIterator<QString, qreal> i(*arcsTable);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
qreal length = i.value(); qreal length = i.value();

View File

@ -58,8 +58,8 @@ void DialogTool::showEvent(QShowEvent *event){
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
box->clear(); box->clear();
if(mode == Draw::Calculation){ if(mode == Draw::Calculation){
const QMap<qint64, VPointF> *points = data->DataPoints(); const QHash<qint64, VPointF> *points = data->DataPoints();
QMapIterator<qint64, VPointF> i(*points); QHashIterator<qint64, VPointF> i(*points);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
if(i.key() != id){ if(i.key() != id){
@ -373,12 +373,12 @@ bool DialogTool::CheckObject(const qint64 &id){
} }
template <class key, class val> template <class key, class val>
void DialogTool::ShowVariable(const QMap<key, val> *var){ void DialogTool::ShowVariable(const QHash<key, val> *var){
Q_CHECK_PTR(listWidget); Q_CHECK_PTR(listWidget);
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
listWidget->clear(); listWidget->clear();
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
QMapIterator<key, val> i(*var); QHashIterator<key, val> i(*var);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
QListWidgetItem *item = new QListWidgetItem(i.key()); QListWidgetItem *item = new QListWidgetItem(i.key());

View File

@ -92,7 +92,7 @@ protected:
void FillComboBoxTypeLine(QComboBox *box) const; void FillComboBoxTypeLine(QComboBox *box) const;
virtual void CheckState(); virtual void CheckState();
QString GetTypeLine(const QComboBox *box)const; QString GetTypeLine(const QComboBox *box)const;
template <class key, class val> void ShowVariable(const QMap<key, val> *var); template <class key, class val> void ShowVariable(const QHash<key, val> *var);
void SetupTypeLine(QComboBox *box, const QString &value); void SetupTypeLine(QComboBox *box, const QString &value);
void ChangeCurrentText(QComboBox *box, const QString &value); void ChangeCurrentText(QComboBox *box, const QString &value);
void ChangeCurrentData(QComboBox *box, const qint64 &value) const; void ChangeCurrentData(QComboBox *box, const qint64 &value) const;

View File

@ -26,7 +26,7 @@ VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius
center(0), points(0), mode(Draw::Calculation), idObject(0){ center(0), points(0), mode(Draw::Calculation), idObject(0){
} }
VArc::VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc::VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject) qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Draws mode, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(points), mode(mode), idObject(idObject){ center(center), points(points), mode(mode), idObject(idObject){
@ -108,7 +108,7 @@ QPointF VArc::GetP2 () const{
return centerP2.p2(); return centerP2.p2();
} }
const QMap<qint64, VPointF> *VArc::GetDataPoints() const{ const QHash<qint64, VPointF> *VArc::GetDataPoints() const{
return points; return points;
} }

View File

@ -40,7 +40,7 @@ public:
* @param f1 початковий кут в градусах. * @param f1 початковий кут в градусах.
* @param f2 кінцевий кут в градусах. * @param f2 кінцевий кут в градусах.
*/ */
VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius, VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2 , QString formulaF2, qreal f1, QString formulaF1, qreal f2 , QString formulaF2,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VArc(const VArc &arc); VArc(const VArc &arc);
@ -84,7 +84,7 @@ public:
* @return точку кінця дуги. * @return точку кінця дуги.
*/ */
QPointF GetP2 () const; QPointF GetP2 () const;
const QMap<qint64, VPointF> *GetDataPoints() const; const QHash<qint64, VPointF> *GetDataPoints() const;
/** /**
* @brief GetPath будує шлях по даній дузі. * @brief GetPath будує шлях по даній дузі.
* @return повертає шлях. * @return повертає шлях.
@ -119,7 +119,7 @@ private:
* @brief center центральна точка дуги. * @brief center центральна точка дуги.
*/ */
qint64 center; qint64 center;
const QMap<qint64, VPointF> *points; const QHash<qint64, VPointF> *points;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
}; };

View File

@ -32,14 +32,14 @@ VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2
mode(spline.getMode()), idObject(spline.getIdObject()){ mode(spline.getMode()), idObject(spline.getIdObject()){
} }
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()), qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()),
p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points),
mode(mode), idObject(idObject){ mode(mode), idObject(idObject){
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve ); ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
} }
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4, VSpline::VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), qreal kCurve, Draw::Draws mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0),
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){ angle2(0), kAsm1(1), kAsm2(1), kCurve(1), points(points), mode(mode), idObject(idObject){
ModifiSpl ( p1, p2, p3, p4, kCurve); ModifiSpl ( p1, p2, p3, p4, kCurve);
@ -190,7 +190,7 @@ qreal VSpline::GetKcurve() const{
return kCurve; return kCurve;
} }
const QMap<qint64, VPointF> *VSpline::GetDataPoints() const{ const QHash<qint64, VPointF> *VSpline::GetDataPoints() const{
return points; return points;
} }

View File

@ -26,7 +26,7 @@
#include <QPainterPath> #include <QPainterPath>
#include <QVector> #include <QVector>
#include <QMap> #include <QHash>
#include "container/vpointf.h" #include "container/vpointf.h"
/** /**
@ -50,7 +50,7 @@ public:
* @param kAsm1 коефіцієнт довжини першої напрямної. * @param kAsm1 коефіцієнт довжини першої напрямної.
* @param kAsm2 коефіцієнт довжини другої напрямної. * @param kAsm2 коефіцієнт довжини другої напрямної.
*/ */
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
/** /**
@ -60,7 +60,7 @@ public:
* @param p3 друга контролююча точка сплайну. * @param p3 друга контролююча точка сплайну.
* @param p4 кінцева точка сплайну. * @param p4 кінцева точка сплайну.
*/ */
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, VSpline (const QHash<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3,
qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 p4, qreal kCurve, Draw::Draws mode = Draw::Calculation,
qint64 idObject = 0); qint64 idObject = 0);
/** /**
@ -136,7 +136,7 @@ public:
qreal GetKasm1() const; qreal GetKasm1() const;
qreal GetKasm2() const; qreal GetKasm2() const;
qreal GetKcurve() const; qreal GetKcurve() const;
const QMap<qint64, VPointF> *GetDataPoints() const; const QHash<qint64, VPointF> *GetDataPoints() const;
/** /**
* @brief CrossingSplLine перевіряє перетин сплайну з лінією. * @brief CrossingSplLine перевіряє перетин сплайну з лінією.
* @param line лінія з якою перевіряється перетин. * @param line лінія з якою перевіряється перетин.
@ -224,7 +224,7 @@ private:
qreal kAsm1; qreal kAsm1;
qreal kAsm2; qreal kAsm2;
qreal kCurve; qreal kCurve;
const QMap<qint64, VPointF> *points; const QHash<qint64, VPointF> *points;
Draw::Draws mode; Draw::Draws mode;
qint64 idObject; qint64 idObject;
/** /**

View File

@ -26,7 +26,7 @@ VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw:
idObject(0){ idObject(0){
} }
VSplinePath::VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector<VSplinePoint>()), VSplinePath::VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve, Draw::Draws mode, qint64 idObject): path(QVector<VSplinePoint>()),
kCurve(kCurve), mode(mode), points(points), idObject(idObject){ kCurve(kCurve), mode(mode), points(points), idObject(idObject){
} }
@ -108,7 +108,7 @@ qreal VSplinePath::GetLength() const{
return length; return length;
} }
const QMap<qint64, VPointF> *VSplinePath::GetDataPoints() const{ const QHash<qint64, VPointF> *VSplinePath::GetDataPoints() const{
return points; return points;
} }

View File

@ -45,7 +45,7 @@ public:
/** /**
* @brief VSplinePath конструктор по замовчуванню. * @brief VSplinePath конструктор по замовчуванню.
*/ */
VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve = 1, VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0); Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const VSplinePath& splPath); VSplinePath(const VSplinePath& splPath);
/** /**
@ -60,7 +60,7 @@ public:
QVector<QPointF> GetPathPoints() const; QVector<QPointF> GetPathPoints() const;
QVector<VSplinePoint> GetSplinePath() const; QVector<VSplinePoint> GetSplinePath() const;
qreal GetLength() const; qreal GetLength() const;
const QMap<qint64, VPointF> *GetDataPoints() const; const QHash<qint64, VPointF> *GetDataPoints() const;
void UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point); void UpdatePoint(qint32 indexSpline, SplinePoint::Position pos, VSplinePoint point);
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const; VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const;
/** /**
@ -85,7 +85,7 @@ protected:
QVector<VSplinePoint> path; QVector<VSplinePoint> path;
qreal kCurve; qreal kCurve;
Draw::Draws mode; Draw::Draws mode;
const QMap<qint64, VPointF> *points; const QHash<qint64, VPointF> *points;
qint64 idObject; qint64 idObject;
}; };

View File

@ -150,7 +150,7 @@ void MainWindow::ActionNewDraw(){
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
sceneDraw->addItem(spoint); sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, spoint); tools->insert(id, spoint);
VDrawTool::AddRecord(id, Tool::SinglePointTool, doc); VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);
SetEnableTool(true); SetEnableTool(true);
@ -214,7 +214,7 @@ void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &curso
template <typename T> template <typename T>
void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
const qint64 &idDetail){ const qint64 &idDetail){
QMap<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail)); VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
Q_CHECK_PTR(det); Q_CHECK_PTR(det);
det->AddTool(tool, id, typeTool); det->AddTool(tool, id, typeTool);

View File

@ -30,7 +30,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()), :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()),
sceneDetails(scene){ sceneDetails(scene){
VDetail detail = data->GetDetail(id); VDetail detail = data->GetDetail(id);
QMap<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
Q_CHECK_PTR(tools); Q_CHECK_PTR(tools);
for(qint32 i = 0; i< detail.CountNode(); ++i){ for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){ switch(detail[i].getTypeTool()){
@ -248,7 +248,7 @@ void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScen
scene->addItem(detail); scene->addItem(detail);
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, detail); tools->insert(id, detail);
} }
} }

View File

@ -36,22 +36,22 @@
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(), VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(),
map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0), tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
comboBoxDraws(comboBoxDraws), mode(mode){ comboBoxDraws(comboBoxDraws), mode(mode){
} }
VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode) : Draw::Draws *mode) :
QDomDocument(name), map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data), QDomDocument(name), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0), tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
comboBoxDraws(comboBoxDraws), mode(mode){ comboBoxDraws(comboBoxDraws), mode(mode){
} }
VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws, VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode) : Draw::Draws *mode) :
QDomDocument(doctype), map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data), QDomDocument(doctype), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0), tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
comboBoxDraws(comboBoxDraws), mode(mode){ comboBoxDraws(comboBoxDraws), mode(mode){
} }
@ -296,7 +296,7 @@ void VDomDocument::Parse(Document::Documents parse, VMainGraphicsScene *sceneDra
} }
} }
QMap<qint64, VDataTool *> *VDomDocument::getTools(){ QHash<qint64, VDataTool *> *VDomDocument::getTools(){
return &tools; return &tools;
} }
@ -1035,7 +1035,7 @@ void VDomDocument::setCurrentData(){
} }
void VDomDocument::GarbageCollector(){ void VDomDocument::GarbageCollector(){
QMapIterator<qint64, VDataTool*> t(tools); QHashIterator<qint64, VDataTool*> t(tools);
while (t.hasNext()) { while (t.hasNext()) {
t.next(); t.next();
VDataTool *tool = t.value(); VDataTool *tool = t.value();

View File

@ -23,7 +23,7 @@
#define VDOMDOCUMENT_H #define VDOMDOCUMENT_H
#include <QDomDocument> #include <QDomDocument>
#include <QMap> #include <QHash>
#include <QComboBox> #include <QComboBox>
#include "widgets/vmaingraphicsscene.h" #include "widgets/vmaingraphicsscene.h"
#include "tools/vdatatool.h" #include "tools/vdatatool.h"
@ -58,7 +58,7 @@ public:
bool appendDraw(const QString& name); bool appendDraw(const QString& name);
void SetNameDraw(const QString& name); void SetNameDraw(const QString& name);
void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail); void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail);
QMap<qint64, VDataTool*>* getTools(); QHash<qint64, VDataTool*>* getTools();
QVector<VToolRecord> *getHistory(); QVector<VToolRecord> *getHistory();
qint64 getCursor() const; qint64 getCursor() const;
void setCursor(const qint64 &value); void setCursor(const qint64 &value);
@ -81,10 +81,10 @@ public slots:
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
private: private:
Q_DISABLE_COPY(VDomDocument) Q_DISABLE_COPY(VDomDocument)
QMap<QString, QDomElement> map; QHash<QString, QDomElement> map;
QString nameActivDraw; QString nameActivDraw;
VContainer *data; VContainer *data;
QMap<qint64, VDataTool*> tools; QHash<qint64, VDataTool*> tools;
QVector<VToolRecord> history; QVector<VToolRecord> history;
qint64 cursor; qint64 cursor;
QComboBox *comboBoxDraws; QComboBox *comboBoxDraws;