Refactoring.

Merge "if" statement with the enclosing one.
This commit is contained in:
Roman Telezhynskyi 2024-04-29 19:05:19 +03:00
parent 8c83c50991
commit a81f878cd6
92 changed files with 1413 additions and 1948 deletions

View File

@ -408,15 +408,8 @@ auto VPPiece::PathsSuperposition(const QVector<QPointF> &path1, const QVector<QP
const QRectF path2Rect = VLayoutPiece::BoundingRect(path2);
const QPainterPath path2Path = VGObject::PainterPath(path2);
if (path1Rect.intersects(path2Rect) || path2Rect.contains(path1Rect) || path1Rect.contains(path2Rect))
{
if (path1Path.contains(path2Path) || path2Path.contains(path1Path) || path1Path.intersects(path2Path))
{
return true;
}
}
return false;
return (path1Rect.intersects(path2Rect) || path2Rect.contains(path1Rect) || path1Rect.contains(path2Rect)) &&
(path1Path.contains(path2Path) || path2Path.contains(path1Path) || path1Path.intersects(path2Path));
}
//---------------------------------------------------------------------------------------------------------------------
@ -681,18 +674,17 @@ auto VPPiece::StickyPieces(VStickyDistance &match) const -> bool
CastTo(piece->GetMappedExternalContourPoints(), piecePath);
QRectF const pieceBoundingRect = VLayoutPiece::BoundingRect(piecePath);
if (stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) ||
stickyZone.contains(pieceBoundingRect))
if ((stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) ||
stickyZone.contains(pieceBoundingRect)) &&
not VPPiece::PathsSuperposition(path, piecePath))
{
if (not VPPiece::PathsSuperposition(path, piecePath))
QVector<QPointF> const pieceStickyPath = PrepareStickyPath(piecePath);
if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath);
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
{
QVector<QPointF> const pieceStickyPath = PrepareStickyPath(piecePath);
if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath);
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
{
match.m_closestDistance = distance;
match.m_pieceGap = pieceGap;
}
match.m_closestDistance = distance;
match.m_pieceGap = pieceGap;
}
}
}

View File

@ -255,16 +255,13 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (VPPiecePtr const piece = m_piece.toStrongRef(); not piece.isNull())
{
if (VPLayoutPtr const layout = piece->Layout(); not layout.isNull())
if (VPLayoutPtr const layout = piece->Layout();
not layout.isNull() && (layout->LayoutSettings().IsStickyEdges() && m_hasStickyPosition))
{
if (layout->LayoutSettings().IsStickyEdges() && m_hasStickyPosition)
{
auto *command =
new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
layout->UndoStack()->push(command);
auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
layout->UndoStack()->push(command);
SetStickyPoints(QVector<QPointF>());
}
SetStickyPoints(QVector<QPointF>());
}
}
@ -1184,20 +1181,17 @@ void VPGraphicsPiece::PieceZValueChanged(const VPPiecePtr &piece)
//---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) -> QVariant
{
if (scene() != nullptr)
if (scene() != nullptr && change == ItemSelectedHasChanged)
{
if (change == ItemSelectedHasChanged)
VPPiecePtr const piece = m_piece.toStrongRef();
if (not piece.isNull())
{
VPPiecePtr const piece = m_piece.toStrongRef();
if (not piece.isNull())
{
piece->SetSelected(value.toBool());
piece->SetSelected(value.toBool());
VPLayoutPtr const layout = piece->Layout();
if (not layout.isNull())
{
emit layout->PieceSelectionChanged(piece);
}
VPLayoutPtr const layout = piece->Layout();
if (not layout.isNull())
{
emit layout->PieceSelectionChanged(piece);
}
}
}

View File

@ -305,22 +305,19 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
break;
}
if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight)
if ((event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight) && not event->isAutoRepeat())
{
if (not event->isAutoRepeat())
VPLayoutPtr const layout = m_layout.toStrongRef();
if (layout.isNull())
{
VPLayoutPtr const layout = m_layout.toStrongRef();
if (layout.isNull())
{
return;
}
return;
}
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
{
sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false);
sheet->SceneData()->RotationControls()->on_UpdateControls();
sheet->SceneData()->RotationControls()->on_HideHandles(false);
}
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
{
sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false);
sheet->SceneData()->RotationControls()->on_UpdateControls();
sheet->SceneData()->RotationControls()->on_HideHandles(false);
}
}
VMainGraphicsView::keyReleaseEvent(event);
@ -690,32 +687,29 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
}
if (const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
m_hasStickyPosition && not graphicsPieces.isEmpty())
m_hasStickyPosition && not graphicsPieces.isEmpty() && layout->LayoutSettings().IsStickyEdges())
{
if (layout->LayoutSettings().IsStickyEdges())
auto PreparePieces = [layout]()
{
auto PreparePieces = [layout]()
QList<VPPiecePtr> pieces;
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
{
QList<VPPiecePtr> pieces;
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
{
pieces = sheet->GetSelectedPieces();
}
pieces = sheet->GetSelectedPieces();
}
return pieces;
};
return pieces;
};
if (QList<VPPiecePtr> const pieces = PreparePieces(); pieces.size() == 1)
if (QList<VPPiecePtr> const pieces = PreparePieces(); pieces.size() == 1)
{
const VPPiecePtr &p = pieces.constFirst();
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
layout->UndoStack()->push(command);
if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr)
{
const VPPiecePtr &p = pieces.constFirst();
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
layout->UndoStack()->push(command);
if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr)
{
gPiece->SetStickyPoints(QVector<QPointF>());
}
gPiece->SetStickyPoints(QVector<QPointF>());
}
}
}

View File

@ -163,13 +163,10 @@ void VPUndoPiecesMove::undo()
for (const auto &piece : qAsConst(m_pieces))
{
VPPiecePtr const p = piece.toStrongRef();
if (not p.isNull())
if (not p.isNull() && m_oldTransforms.contains(p->GetUniqueID()))
{
if (m_oldTransforms.contains(p->GetUniqueID()))
{
p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
emit layout->PieceTransformationChanged(p);
}
p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
emit layout->PieceTransformationChanged(p);
}
}
}

View File

@ -202,17 +202,14 @@ void VPUndoPiecesRotate::undo()
for (const auto &piece : qAsConst(m_pieces))
{
VPPiecePtr const p = piece.toStrongRef();
if (not p.isNull())
if (not p.isNull() && m_oldTransforms.contains(p->GetUniqueID()))
{
if (m_oldTransforms.contains(p->GetUniqueID()))
p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
if (m_followGrainline || p->IsFollowGrainline())
{
p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
if (m_followGrainline || p->IsFollowGrainline())
{
p->RotateToGrainline(m_origin);
}
emit layout->PieceTransformationChanged(p);
p->RotateToGrainline(m_origin);
}
emit layout->PieceTransformationChanged(p);
}
}
}

View File

@ -109,13 +109,10 @@ void VPUndoPieceZValueMove::undo()
for (const auto &p : pieces)
{
if (not p.isNull())
if (not p.isNull() && m_oldValues.contains(p->GetUniqueID()))
{
if (m_oldValues.contains(p->GetUniqueID()))
{
p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p);
}
p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p);
}
}
}
@ -326,13 +323,10 @@ void VPUndoPiecesZValueMove::undo()
for (const auto &p : pieces)
{
if (not p.isNull())
if (not p.isNull() && m_oldValues.contains(p->GetUniqueID()))
{
if (m_oldValues.contains(p->GetUniqueID()))
{
p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p);
}
p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p);
}
}
}

View File

@ -239,25 +239,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
break;
}
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) &&
VPApplication::VApp()->IsAppInGUIMode() && topWinAllowsPop)
{
if (VPApplication::VApp()->IsAppInGUIMode())
{
if (topWinAllowsPop)
{
messageBox.setText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
messageBox.setText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
#ifndef QT_NO_CURSOR
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
#endif
messageBox.exec();
messageBox.exec();
#ifndef QT_NO_CURSOR
QGuiApplication::restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
#endif
}
}
}
if (QtFatalMsg == type)

View File

@ -216,12 +216,10 @@ void SetPrinterSheetPageSettings(const QSharedPointer<QPrinter> &printer, const
printer->setPageOrientation(sheetOrientation);
printer->setFullPage(sheet->IgnoreMargins());
if (not sheet->IgnoreMargins())
if (not sheet->IgnoreMargins() &&
not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter))
{
if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter))
{
qWarning() << QObject::tr("Cannot set printer margins");
}
qWarning() << QObject::tr("Cannot set printer margins");
}
}
@ -266,12 +264,10 @@ void SetPrinterTiledPageSettings(const QSharedPointer<QPrinter> &printer, const
printer->setPageOrientation(orientation);
printer->setFullPage(layout->LayoutSettings().IgnoreTilesMargins());
if (not layout->LayoutSettings().IgnoreTilesMargins())
if (not layout->LayoutSettings().IgnoreTilesMargins() &&
not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), QPageLayout::Millimeter))
{
if (not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), QPageLayout::Millimeter))
{
qWarning() << QObject::tr("Cannot set printer margins");
}
qWarning() << QObject::tr("Cannot set printer margins");
}
}
@ -488,12 +484,9 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(lock, path);
if (not lock->IsLocked())
if (not lock->IsLocked() && not IgnoreLocking(lock->GetLockError(), path, m_cmd->IsGuiEnabled()))
{
if (not IgnoreLocking(lock->GetLockError(), path, m_cmd->IsGuiEnabled()))
{
return false;
}
return false;
}
try
@ -803,14 +796,11 @@ void VPMainWindow::ShowFullPieceToggled(bool checked)
if (selectedPieces.size() == 1)
{
const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull())
if (not selectedPiece.isNull() && selectedPiece->IsShowFullPiece() != checked)
{
if (selectedPiece->IsShowFullPiece() != checked)
{
selectedPiece->SetShowFullPiece(checked);
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
selectedPiece->SetShowFullPiece(checked);
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
}
@ -822,14 +812,11 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked)
if (selectedPieces.size() == 1)
{
const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull())
if (not selectedPiece.isNull() && selectedPiece->IsShowMirrorLine() != checked)
{
if (selectedPiece->IsShowMirrorLine() != checked)
{
selectedPiece->SetShowMirrorLine(checked);
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
selectedPiece->SetShowMirrorLine(checked);
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
}
@ -841,14 +828,11 @@ void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
if (selectedPieces.size() == 1)
{
const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull())
if (not selectedPiece.isNull() && selectedPiece->IsVerticallyFlipped() != checked)
{
if (selectedPiece->IsVerticallyFlipped() != checked)
{
selectedPiece->FlipVertically();
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
selectedPiece->FlipVertically();
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
}
@ -860,14 +844,11 @@ void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked)
if (selectedPieces.size() == 1)
{
const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull())
if (not selectedPiece.isNull() && selectedPiece->IsHorizontallyFlipped() != checked)
{
if (selectedPiece->IsHorizontallyFlipped() != checked)
{
selectedPiece->FlipHorizontally();
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
selectedPiece->FlipHorizontally();
LayoutWasSaved(false);
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
}
@ -3004,28 +2985,26 @@ auto VPMainWindow::AskLayoutIsInvalid(const QList<VPSheetPtr> &sheets) -> bool
//---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool
{
if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound())
if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound() && not outOfBoundChecked && not piece.isNull() &&
piece->OutOfBound())
{
if (not outOfBoundChecked && not piece.isNull() && piece->OutOfBound())
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
return false;
}
outOfBoundChecked = true; // no need to ask more
return false;
}
outOfBoundChecked = true; // no need to ask more
}
return true;
}
@ -3033,29 +3012,27 @@ auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBou
//---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool
{
if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces())
if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces() && not pieceSuperpositionChecked &&
not piece.isNull() && piece->HasSuperpositionWithPieces())
{
if (not pieceSuperpositionChecked && not piece.isNull() && piece->HasSuperpositionWithPieces())
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue "
"export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue "
"export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
return false;
}
pieceSuperpositionChecked = true; // no need to ask more
return false;
}
pieceSuperpositionChecked = true; // no need to ask more
}
return true;
@ -3064,29 +3041,27 @@ auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pie
//---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckPieceGapePosition(const VPPiecePtr &piece, bool &pieceGapePositionChecked) -> bool
{
if (m_layout->LayoutSettings().GetWarningPieceGapePosition())
if (m_layout->LayoutSettings().GetWarningPieceGapePosition() && not pieceGapePositionChecked &&
not piece.isNull() && piece->HasInvalidPieceGapPosition())
{
if (not pieceGapePositionChecked && not piece.isNull() && piece->HasInvalidPieceGapPosition())
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. One or several pieces are closer than minimally allowed. Do you "
"want to continue export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("The layout is invalid."));
msgBox.setText(tr("The layout is invalid. One or several pieces are closer than minimally allowed. Do you "
"want to continue export?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
const int width = 500;
auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
auto *layout = qobject_cast<QGridLayout *>(msgBox.layout());
SCASSERT(layout != nullptr)
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
if (msgBox.exec() == QMessageBox::No)
{
return false;
}
pieceGapePositionChecked = true; // no need to ask more
return false;
}
pieceGapePositionChecked = true; // no need to ask more
}
return true;
@ -3166,8 +3141,8 @@ auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, co
if (not sheet->IgnoreMargins())
{
QMarginsF const margins = sheet->GetSheetMargins();
if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter))
if (QMarginsF const margins = sheet->GetSheetMargins();
not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter))
{
qWarning() << QObject::tr("Cannot set printer margins");
}

View File

@ -367,31 +367,22 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool
if (m_type == MeasurementsType::Multisize)
{
if (not m_dimensions.empty())
if (not m_dimensions.empty() && not ColumnValid(MultisizeMeasurementsColumns::ShiftA))
{
if (not ColumnValid(MultisizeMeasurementsColumns::ShiftA))
{
ChangeColor(ui->labelShiftA, errorColor);
columnShiftAFlag = false;
}
ChangeColor(ui->labelShiftA, errorColor);
columnShiftAFlag = false;
}
if (m_dimensions.size() > 1)
if (m_dimensions.size() > 1 && not ColumnValid(MultisizeMeasurementsColumns::ShiftB))
{
if (not ColumnValid(MultisizeMeasurementsColumns::ShiftB))
{
ChangeColor(ui->labelShiftB, errorColor);
columnShiftBFlag = false;
}
ChangeColor(ui->labelShiftB, errorColor);
columnShiftBFlag = false;
}
if (m_dimensions.size() > 2)
if (m_dimensions.size() > 2 && not ColumnValid(MultisizeMeasurementsColumns::ShiftC))
{
if (not ColumnValid(MultisizeMeasurementsColumns::ShiftC))
{
ChangeColor(ui->labelShiftC, errorColor);
columnShiftCFlag = false;
}
ChangeColor(ui->labelShiftC, errorColor);
columnShiftCFlag = false;
}
}

View File

@ -405,13 +405,10 @@ void DialogSetupMultisize::CheckDimension(QGroupBox *group, QGroupBox *nameGroup
return;
}
if (nameGroup->isChecked() && lineEdit->text().isEmpty())
if (nameGroup->isChecked() && lineEdit->text().isEmpty() && ui->labelError->text().isEmpty())
{
if (ui->labelError->text().isEmpty())
{
ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
return;
}
ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
return;
}
}
}

View File

@ -275,25 +275,20 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
break;
}
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) &&
not MApplication::VApp()->IsTestMode() && topWinAllowsPop)
{
if (not MApplication::VApp()->IsTestMode())
{
if (topWinAllowsPop)
{
messageBox.setText(VAbstractApplication::ClearMessage(logMsg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
messageBox.setText(VAbstractApplication::ClearMessage(logMsg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
#ifndef QT_NO_CURSOR
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
#endif
messageBox.exec();
messageBox.exec();
#ifndef QT_NO_CURSOR
QGuiApplication::restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
#endif
}
}
}
if (QtFatalMsg == type)
@ -898,13 +893,10 @@ void MApplication::RepopulateMeasurementsDatabase(const QString &path)
//---------------------------------------------------------------------------------------------------------------------
void MApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath)
{
if (oldPath != newPath)
if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr)
{
if (m_knownMeasurementsDatabase != nullptr)
{
RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath);
}
RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath);
}
}

View File

@ -196,12 +196,10 @@ auto TKMMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(m_lock, path);
if (not m_lock->IsLocked())
if (not m_lock->IsLocked() &&
not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
return false;
}
return false;
}
try

View File

@ -433,12 +433,10 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(m_lock, path);
if (not m_lock->IsLocked())
if (not m_lock->IsLocked() &&
not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
return false;
}
return false;
}
try
@ -4097,12 +4095,10 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool
VlpCreateLock(m_lock, path);
if (not m_lock->IsLocked())
if (not m_lock->IsLocked() &&
not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode()))
{
return false;
}
return false;
}
try

View File

@ -287,53 +287,50 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
if (isGuiThread)
{
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
if ((type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) && VApplication::IsGUIMode())
{
if (VApplication::IsGUIMode())
// fixme: trying to make sure there are no save/load dialogs are opened, because error message during
// them will lead to crash
const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) ||
!QApplication::activeModalWidget()->inherits("QFileDialog");
if (topWinAllowsPop && (not isPatternMessage || (type == QtCriticalMsg || type == QtFatalMsg)))
{
// fixme: trying to make sure there are no save/load dialogs are opened, because error message during
// them will lead to crash
const bool topWinAllowsPop = (QApplication::activeModalWidget() == nullptr) ||
!QApplication::activeModalWidget()->inherits("QFileDialog");
if (topWinAllowsPop && (not isPatternMessage || (type == QtCriticalMsg || type == QtFatalMsg)))
QMessageBox messageBox;
switch (type)
{
QMessageBox messageBox;
switch (type)
{
case QtWarningMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning"));
messageBox.setIcon(QMessageBox::Warning);
break;
case QtCriticalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error"));
messageBox.setIcon(QMessageBox::Critical);
break;
case QtFatalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error"));
messageBox.setIcon(QMessageBox::Critical);
break;
case QtInfoMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information"));
messageBox.setIcon(QMessageBox::Information);
break;
case QtDebugMsg:
default:
break;
}
messageBox.setText(VAbstractValApplication::ClearMessage(logMsg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
#ifndef QT_NO_CURSOR
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
#endif
messageBox.exec();
#ifndef QT_NO_CURSOR
QGuiApplication::restoreOverrideCursor();
#endif
case QtWarningMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Warning"));
messageBox.setIcon(QMessageBox::Warning);
break;
case QtCriticalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Critical error"));
messageBox.setIcon(QMessageBox::Critical);
break;
case QtFatalMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Fatal error"));
messageBox.setIcon(QMessageBox::Critical);
break;
case QtInfoMsg:
messageBox.setWindowTitle(QApplication::translate("vNoisyHandler", "Information"));
messageBox.setIcon(QMessageBox::Information);
break;
case QtDebugMsg:
default:
break;
}
messageBox.setText(VAbstractValApplication::ClearMessage(logMsg));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
#ifndef QT_NO_CURSOR
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
#endif
messageBox.exec();
#ifndef QT_NO_CURSOR
QGuiApplication::restoreOverrideCursor();
#endif
}
}
@ -783,13 +780,10 @@ void VApplication::RepopulateMeasurementsDatabase(const QString &path)
//---------------------------------------------------------------------------------------------------------------------
void VApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath)
{
if (oldPath != newPath)
if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr)
{
if (m_knownMeasurementsDatabase != nullptr)
{
RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath);
}
RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath);
}
}

View File

@ -139,13 +139,10 @@ auto VCommandLine::DefaultGenerator() const -> VLayoutGeneratorPtr
}
}
if (IsOptionSet(LONG_OPTION_SHIFTUNITS))
if (IsOptionSet(LONG_OPTION_SHIFTUNITS) && !diag.SelectLayoutUnit(OptionValue(LONG_OPTION_SHIFTUNITS)))
{
if (!diag.SelectLayoutUnit(OptionValue(LONG_OPTION_SHIFTUNITS)))
{
qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n";
const_cast<VCommandLine *>(this)->parser.showHelp(V_EX_USAGE);
}
qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n";
const_cast<VCommandLine *>(this)->parser.showHelp(V_EX_USAGE);
}
if (IsOptionSet(LONG_OPTION_GAPWIDTH))

View File

@ -554,12 +554,9 @@ auto VToolOptionsPropertyBrowser::ComboBoxPalette() const -> QPalette
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item)
{
if (item != nullptr)
if (item != nullptr && not item->isEnabled())
{
if (not item->isEnabled())
{
return;
}
return;
}
if (m_currentItem == item && item != nullptr)

View File

@ -192,14 +192,11 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{
const quint32 id = ui->tableWidget->item(i, PieceColumn::InLayout)->data(Qt::UserRole).toUInt();
if (allDetails->contains(id))
if (allDetails->contains(id) && not(select == allDetails->value(id).IsInLayout()))
{
if (not(select == allDetails->value(id).IsInLayout()))
{
auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece);
VAbstractApplication::VApp()->getUndoStack()->push(togglePrint);
}
auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece);
VAbstractApplication::VApp()->getUndoStack()->push(togglePrint);
}
}
}

View File

@ -358,12 +358,9 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::CheckLayout, this,
[this]()
{
if (pattern->DataPieces()->isEmpty())
if (pattern->DataPieces()->isEmpty() && not ui->actionDraw->isChecked())
{
if (not ui->actionDraw->isChecked())
{
ActionDraw(true);
}
ActionDraw(true);
}
});
connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP);
@ -2334,28 +2331,19 @@ void MainWindow::StoreMultisizeMDimensions()
QList<MeasurementDimension_p> const dimensions = m_m->Dimensions().values();
if (not dimensions.isEmpty())
if (not dimensions.isEmpty() && not m_dimensionALabel.isNull())
{
if (not m_dimensionALabel.isNull())
{
m_dimensionALabel->setText(dimensions.at(0)->Name() + ':'_L1);
}
m_dimensionALabel->setText(dimensions.at(0)->Name() + ':'_L1);
}
if (dimensions.size() > 1)
if (dimensions.size() > 1 && not m_dimensionBLabel.isNull())
{
if (not m_dimensionBLabel.isNull())
{
m_dimensionBLabel->setText(dimensions.at(1)->Name() + ':'_L1);
}
m_dimensionBLabel->setText(dimensions.at(1)->Name() + ':'_L1);
}
if (dimensions.size() > 2)
if (dimensions.size() > 2 && not m_dimensionCLabel.isNull())
{
if (not m_dimensionCLabel.isNull())
{
m_dimensionCLabel->setText(dimensions.at(2)->Name() + ':'_L1);
}
m_dimensionCLabel->setText(dimensions.at(2)->Name() + ':'_L1);
}
StoreMultisizeMDimension(dimensions, 0, m_currentDimensionA);
@ -3909,17 +3897,14 @@ void MainWindow::ActionDetails(bool checked)
ui->actionDetails->setChecked(true);
ui->actionLayout->setChecked(false);
if (not VAbstractValApplication::VApp()->getOpeningPattern())
if (not VAbstractValApplication::VApp()->getOpeningPattern() && pattern->DataPieces()->isEmpty())
{
if (pattern->DataPieces()->isEmpty())
{
QMessageBox::information(this, tr("Detail mode"),
tr("You can't use Detail mode yet. "
"Please, create at least one workpiece."),
QMessageBox::Ok, QMessageBox::Ok);
ActionDraw(true);
return;
}
QMessageBox::information(this, tr("Detail mode"),
tr("You can't use Detail mode yet. "
"Please, create at least one workpiece."),
QMessageBox::Ok, QMessageBox::Ok);
ActionDraw(true);
return;
}
m_detailsWidget->UpdateList();
@ -6782,12 +6767,9 @@ void MainWindow::ExportLayoutAs(bool checked)
auto Uncheck = qScopeGuard([this] { ui->actionLayoutExportAs->setChecked(false); });
if (m_layoutSettings->IsLayoutStale())
if (m_layoutSettings->IsLayoutStale() && VPrintLayout::ContinueIfLayoutStale(this) == QMessageBox::No)
{
if (VPrintLayout::ContinueIfLayoutStale(this) == QMessageBox::No)
{
return;
}
return;
}
try

View File

@ -400,12 +400,10 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool
}
if (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) &&
efficiency >= lGenerator.GetEfficiencyCoefficient())
efficiency >= lGenerator.GetEfficiencyCoefficient() &&
(not lGenerator.IsPreferOneSheetSolution() || lGenerator.PapersCount() == 1))
{
if (not lGenerator.IsPreferOneSheetSolution() || lGenerator.PapersCount() == 1)
{
break;
}
break;
}
if (IsTimeout())

View File

@ -446,13 +446,10 @@ auto VPattern::SPointActiveDraw() -> quint32
if (not domNode.isNull() && domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (not domElement.isNull())
if (not domElement.isNull() && domElement.tagName() == TagPoint &&
domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType)
{
if (domElement.tagName() == TagPoint &&
domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType)
{
return GetParametrId(domElement);
}
return GetParametrId(domElement);
}
}
}
@ -1332,12 +1329,9 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse
if (domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
if (domElement.isNull() == false && domElement.tagName() == TagDetail)
{
if (domElement.tagName() == TagDetail)
{
ParseDetailElement(domElement, parse);
}
ParseDetailElement(domElement, parse);
}
}
domNode = domNode.nextSibling();
@ -2903,25 +2897,22 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do
for (qint32 i = 0; i < num; ++i)
{
const QDomElement element = nodeList.at(i).toElement();
if (element.isNull() == false)
if (element.isNull() == false && element.tagName() == AttrPathPoint)
{
if (element.tagName() == AttrPathPoint)
const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, QStringLiteral("1.0"));
const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0'));
const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, QStringLiteral("1.0"));
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
QLineF line(0, 0, 100, 0);
line.setAngle(angle + 180);
VFSplinePoint const splPoint(p, kAsm1, line.angle(), kAsm2, angle);
points.append(splPoint);
if (parse == Document::FullParse)
{
const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, QStringLiteral("1.0"));
const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0'));
const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, QStringLiteral("1.0"));
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
QLineF line(0, 0, 100, 0);
line.setAngle(angle + 180);
VFSplinePoint const splPoint(p, kAsm1, line.angle(), kAsm2, angle);
points.append(splPoint);
if (parse == Document::FullParse)
{
IncrementReferens(p.getIdTool());
}
IncrementReferens(p.getIdTool());
}
}
}
@ -3069,17 +3060,14 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
for (qint32 i = 0; i < num; ++i)
{
const QDomElement element = nodeList.at(i).toElement();
if (element.isNull() == false)
if (element.isNull() == false && element.tagName() == AttrPathPoint)
{
if (element.tagName() == AttrPathPoint)
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
points.append(p);
if (parse == Document::FullParse)
{
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
points.append(p);
if (parse == Document::FullParse)
{
IncrementReferens(p.getIdTool());
}
IncrementReferens(p.getIdTool());
}
}
}
@ -4187,31 +4175,28 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (not domElement.isNull())
if (const QDomElement domElement = domNode.toElement();
not domElement.isNull() && domElement.tagName() == TagIncrement)
{
if (domElement.tagName() == TagIncrement)
{
const QString name = GetParametrString(domElement, AttrName, QString()).simplified();
const QString desc = GetParametrEmptyString(domElement, AttrDescription);
const IncrementType type =
StringToIncrementType(GetParametrString(domElement, AttrType, strTypeIncrement));
const QString formula = (type == IncrementType::Separator)
? QChar('0')
: GetParametrString(domElement, AttrFormula, QChar('0'));
const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr);
const QString name = GetParametrString(domElement, AttrName, QString()).simplified();
const QString desc = GetParametrEmptyString(domElement, AttrDescription);
const IncrementType type =
StringToIncrementType(GetParametrString(domElement, AttrType, strTypeIncrement));
const QString formula = (type == IncrementType::Separator)
? QChar('0')
: GetParametrString(domElement, AttrFormula, QChar('0'));
const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr);
bool ok = false;
const qreal value = EvalFormula(data, formula, &ok);
bool ok = false;
const qreal value = EvalFormula(data, formula, &ok);
auto *increment = new VIncrement(data, name, type);
increment->SetIndex(static_cast<quint32>(index++));
increment->SetFormula(value, formula, ok);
increment->SetDescription(desc);
increment->SetSpecialUnits(specialUnits);
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
data->AddUniqueVariable(increment);
}
auto *increment = new VIncrement(data, name, type);
increment->SetIndex(static_cast<quint32>(index++));
increment->SetFormula(value, formula, ok);
increment->SetDescription(desc);
increment->SetSpecialUnits(specialUnits);
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
data->AddUniqueVariable(increment);
}
}
domNode = domNode.nextSibling();
@ -4514,13 +4499,10 @@ void VPattern::SetLabelPrefix(const QString &prefix)
{
QDomElement pattern = documentElement();
if (not pattern.isNull())
if (not pattern.isNull() && ConvertToSet<QString>(VApplication::LabelLanguages()).contains(prefix))
{
if (ConvertToSet<QString>(VApplication::LabelLanguages()).contains(prefix))
{
SetAttribute(pattern, AttrLabelPrefix, prefix);
modified = true;
}
SetAttribute(pattern, AttrLabelPrefix, prefix);
modified = true;
}
}

View File

@ -431,45 +431,40 @@ auto FvUpdater::xmlParseFeed() -> bool
const QXmlStreamAttributes attribs = m_xml.attributes();
const auto fervorPlatform = QStringLiteral("fervor:platform");
if (attribs.hasAttribute(fervorPlatform))
if (attribs.hasAttribute(fervorPlatform) &&
CurrentlyRunningOnPlatform(attribs.value(fervorPlatform).toString().trimmed()))
{
if (CurrentlyRunningOnPlatform(attribs.value(fervorPlatform).toString().trimmed()))
xmlEnclosurePlatform = attribs.value(fervorPlatform).toString().trimmed();
const auto attributeUrl = QStringLiteral("url");
if (attribs.hasAttribute(attributeUrl))
{
xmlEnclosurePlatform = attribs.value(fervorPlatform).toString().trimmed();
xmlEnclosureUrl = attribs.value(attributeUrl).toString().trimmed();
}
else
{
xmlEnclosureUrl.clear();
}
const auto attributeUrl = QStringLiteral("url");
if (attribs.hasAttribute(attributeUrl))
const auto fervorVersion = QStringLiteral("fervor:version");
if (attribs.hasAttribute(fervorVersion))
{
const QString candidateVersion = attribs.value(fervorVersion).toString().trimmed();
if (not candidateVersion.isEmpty())
{
xmlEnclosureUrl = attribs.value(attributeUrl).toString().trimmed();
}
else
{
xmlEnclosureUrl.clear();
}
const auto fervorVersion = QStringLiteral("fervor:version");
if (attribs.hasAttribute(fervorVersion))
{
const QString candidateVersion = attribs.value(fervorVersion).toString().trimmed();
if (not candidateVersion.isEmpty())
{
xmlEnclosureVersion = candidateVersion;
}
xmlEnclosureVersion = candidateVersion;
}
}
}
}
}
else if (m_xml.isEndElement())
else if (m_xml.isEndElement() && m_xml.name() == "item"_L1)
{
if (m_xml.name() == "item"_L1)
{
// That's it - we have analyzed a single <item> and we'll stop
// here (because the topmost is the most recent one, and thus
// the newest version.
// That's it - we have analyzed a single <item> and we'll stop
// here (because the topmost is the most recent one, and thus
// the newest version.
return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform);
}
return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform);
}
if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
@ -555,13 +550,10 @@ auto FvUpdater::VersionIsIgnored(const QString &version) -> bool
}
const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion();
if (lastSkippedVersion != 0x0)
if (lastSkippedVersion != 0x0 && decVersion == lastSkippedVersion)
{
if (decVersion == lastSkippedVersion)
{
// Implicitly skipped version - skip
return true;
}
// Implicitly skipped version - skip
return true;
}
if (decVersion > AppVersion())
@ -635,13 +627,10 @@ auto FvUpdater::CurrentlyRunningOnPlatform(const QString &platform) -> bool
//---------------------------------------------------------------------------------------------------------------------
void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMode)
{
if (m_silentAsMuchAsItCouldGet)
if (m_silentAsMuchAsItCouldGet && not showEvenInSilentMode)
{
if (not showEvenInSilentMode)
{
// Don't show errors in the silent mode
return;
}
// Don't show errors in the silent mode
return;
}
QMessageBox dlFailedMsgBox;
@ -653,13 +642,10 @@ void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMod
//---------------------------------------------------------------------------------------------------------------------
void FvUpdater::showInformationDialog(const QString &message, bool showEvenInSilentMode)
{
if (m_silentAsMuchAsItCouldGet)
if (m_silentAsMuchAsItCouldGet && not showEvenInSilentMode)
{
if (not showEvenInSilentMode)
{
// Don't show information dialogs in the silent mode
return;
}
// Don't show information dialogs in the silent mode
return;
}
QMessageBox dlInformationMsgBox;

View File

@ -443,12 +443,9 @@ auto VAbstractPattern::CheckExistNamePP(const QString &name) const -> bool
for (qint32 i = 0; i < elements.count(); i++)
{
const QDomElement elem = elements.at(i).toElement();
if (elem.isNull() == false)
if (elem.isNull() == false && GetParametrString(elem, AttrName) == name)
{
if (GetParametrString(elem, AttrName) == name)
{
return true;
}
return true;
}
}
return false;
@ -498,27 +495,24 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (not domElement.isNull())
if (const QDomElement domElement = domNode.toElement();
not domElement.isNull() && domElement.tagName() == TagGroup)
{
if (domElement.tagName() == TagGroup)
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace);
const QPair<bool, QMap<quint32, quint32>> groupData = ParseItemElement(domElement);
const QMap<quint32, quint32> group = groupData.second;
auto i = group.constBegin();
while (i != group.constEnd())
{
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace);
const QPair<bool, QMap<quint32, quint32>> groupData = ParseItemElement(domElement);
const QMap<quint32, quint32> group = groupData.second;
auto i = group.constBegin();
while (i != group.constEnd())
if (not itemTool.contains(i.key()))
{
if (not itemTool.contains(i.key()))
{
itemTool.insert(i.key(), i.value());
}
const bool previous = itemVisibility.value(i.key(), false);
itemVisibility.insert(i.key(), previous || groupData.first);
++i;
itemTool.insert(i.key(), i.value());
}
const bool previous = itemVisibility.value(i.key(), false);
itemVisibility.insert(i.key(), previous || groupData.first);
++i;
}
}
}
@ -562,13 +556,10 @@ auto VAbstractPattern::GetPPElement(const QString &name) -> QDomElement
for (qint32 i = 0; i < elements.count(); i++)
{
QDomElement const element = elements.at(i).toElement();
if (not element.isNull())
if (QDomElement const element = elements.at(i).toElement();
not element.isNull() && element.attribute(AttrName) == name)
{
if (element.attribute(AttrName) == name)
{
return element;
}
return element;
}
}
}
@ -2623,40 +2614,37 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
{
if (domNode.isElement())
{
const QDomElement group = domNode.toElement();
if (not group.isNull())
if (const QDomElement group = domNode.toElement();
not group.isNull() && group.tagName() == TagGroup)
{
if (group.tagName() == TagGroup)
VGroupData groupData;
const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
groupData.visible = GetParametrBool(group, AttrVisible, trueStr);
groupData.name = GetParametrString(
group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR);
items.resize(0);
const QDomNodeList nodeList = group.childNodes();
const qint32 num = nodeList.size();
items.reserve(num);
for (qint32 i = 0; i < num; ++i)
{
VGroupData groupData;
const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
groupData.visible = GetParametrBool(group, AttrVisible, trueStr);
groupData.name = GetParametrString(
group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR);
items.resize(0);
const QDomNodeList nodeList = group.childNodes();
const qint32 num = nodeList.size();
items.reserve(num);
for (qint32 i = 0; i < num; ++i)
const QDomElement element = nodeList.at(i).toElement();
if (not element.isNull() && element.tagName() == TagGroupItem)
{
const QDomElement element = nodeList.at(i).toElement();
if (not element.isNull() && element.tagName() == TagGroupItem)
{
const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR);
const quint32 object = GetParametrUInt(element, AttrObject, QString::number(tool));
const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR);
const quint32 object = GetParametrUInt(element, AttrObject, QString::number(tool));
items.append(QPair<quint32, quint32>(object, tool));
}
items.append(QPair<quint32, quint32>(object, tool));
}
groupData.items = items;
data.insert(id, groupData);
}
groupData.items = items;
data.insert(id, groupData);
}
}
domNode = domNode.nextSibling();
@ -2703,19 +2691,16 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
{
if (domNode.isElement())
{
const QDomElement group = domNode.toElement();
if (group.isNull() == false)
if (const QDomElement group = domNode.toElement();
group.isNull() == false && group.tagName() == TagGroup)
{
if (group.tagName() == TagGroup)
bool const groupHasItem = GroupHasItem(group, toolId, objectId);
if ((containItem && groupHasItem) || (not containItem && not groupHasItem))
{
bool const groupHasItem = GroupHasItem(group, toolId, objectId);
if ((containItem && groupHasItem) || (not containItem && not groupHasItem))
{
const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0'));
const QString name = GetParametrString(
group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
data.insert(groupId, name);
}
const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0'));
const QString name = GetParametrString(
group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
data.insert(groupId, name);
}
}
}

View File

@ -382,13 +382,9 @@ auto VDomDocument::find(QHash<quint32, QDomElement> &cache, const QDomElement &n
for (qint32 i = 0; i < node.childNodes().length(); ++i)
{
const QDomNode n = node.childNodes().at(i);
if (n.isElement())
if (const QDomNode n = node.childNodes().at(i); n.isElement() && VDomDocument::find(cache, n.toElement(), id))
{
if (VDomDocument::find(cache, n.toElement(), id))
{
return true;
}
return true;
}
}
return false;

View File

@ -643,31 +643,28 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
{
if (domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if (not domElement.isNull())
if (QDomElement domElement = domNode.toElement();
not domElement.isNull() && domElement.tagName() == *strIncrement)
{
if (domElement.tagName() == *strIncrement)
try
{
try
{
const QString name = GetParametrString(domElement, *strName);
names.insert(name);
domElement.setAttribute(*strName, '#'_L1 + name);
const QString name = GetParametrString(domElement, *strName);
names.insert(name);
domElement.setAttribute(*strName, '#'_L1 + name);
const QString base = GetParametrString(domElement, *strBase);
domElement.setAttribute(*strFormula, base);
}
catch (VExceptionEmptyParameter &e)
{
VException excep("Can't get increment.");
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
domElement.removeAttribute(*strId);
domElement.removeAttribute(*strKGrowth);
domElement.removeAttribute(*strKSize);
domElement.removeAttribute(*strBase);
const QString base = GetParametrString(domElement, *strBase);
domElement.setAttribute(*strFormula, base);
}
catch (VExceptionEmptyParameter &e)
{
VException excep("Can't get increment.");
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
domElement.removeAttribute(*strId);
domElement.removeAttribute(*strKGrowth);
domElement.removeAttribute(*strKSize);
domElement.removeAttribute(*strBase);
}
}
domNode = domNode.nextSibling();
@ -1627,13 +1624,10 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0()
QDomNode domNode = modeling.firstChild();
while (not domNode.isNull())
{
QDomElement domElement = domNode.toElement();
if (not domElement.isNull())
if (QDomElement domElement = domNode.toElement();
not domElement.isNull() && domElement.hasAttribute(*strTypeObject))
{
if (domElement.hasAttribute(*strTypeObject))
{
domElement.removeAttribute(*strTypeObject);
}
domElement.removeAttribute(*strTypeObject);
}
domNode = domNode.nextSibling();
}

View File

@ -302,22 +302,19 @@ void DRW_Arc::applyExtrusion()
{
DRW_Circle::applyExtrusion();
if (haveExtrusion)
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if (haveExtrusion && fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
{
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
{
staangle = M_PI - staangle;
endangle = M_PI - endangle;
staangle = M_PI - staangle;
endangle = M_PI - endangle;
double const temp = staangle;
staangle = endangle;
endangle = temp;
}
double const temp = staangle;
staangle = endangle;
endangle = temp;
}
}

View File

@ -677,10 +677,9 @@ void DRW_Header::write(const std::unique_ptr<dxfWriter> &writer, DRW::Version ve
else
writer->writeString(1, "STANDARD");
// verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000)
if (!getInt("$DIMLUNIT", &varInt))
if (!getInt("$DIMLUNIT", &varInt) && !getInt("$DIMUNIT", &varInt))
{
if (!getInt("$DIMUNIT", &varInt))
varInt = 2;
varInt = 2;
}
// verify valid values from 1 to 6
if (varInt < 1 || varInt > 6)

View File

@ -204,13 +204,10 @@ auto dxfRW::writeEntity(DRW_Entity *ent) -> bool
if (version < DRW::AC1012)
{
int varInt = 0;
if (header.getInt("$HANDLING", &varInt))
if (header.getInt("$HANDLING", &varInt) && varInt != 0)
{
if (varInt != 0)
{
ent->handle = static_cast<duint32>(++entCount);
writer->writeString(5, toHexStr(static_cast<int>(ent->handle)));
}
ent->handle = static_cast<duint32>(++entCount);
writer->writeString(5, toHexStr(static_cast<int>(ent->handle)));
}
}
else
@ -410,16 +407,13 @@ auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
transform(name.begin(), name.end(), name.begin(), toupper);
if (!dimstyleStd)
if (!dimstyleStd && name == "STANDARD")
{
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
transform(name.begin(), name.end(), name.begin(), toupper);
if (name == "STANDARD")
{
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
transform(name.begin(), name.end(), name.begin(), toupper);
if (name == "STANDARD")
dimstyleStd = true;
}
dimstyleStd = true;
}
if (version > DRW::AC1009)
{
@ -679,15 +673,12 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeUtf8String(340, toHexStr(txstyHandle));
}
}
if (version > DRW::AC1014)
if (version > DRW::AC1014 && blockMap.count(ent->dimldrblk) > 0)
{
if (blockMap.count(ent->dimldrblk) > 0)
{
int const blkHandle = (*(blockMap.find(ent->dimldrblk))).second;
writer->writeUtf8String(341, toHexStr(blkHandle));
writer->writeInt16(371, ent->dimlwd);
writer->writeInt16(372, ent->dimlwe);
}
int const blkHandle = (*(blockMap.find(ent->dimldrblk))).second;
writer->writeUtf8String(341, toHexStr(blkHandle));
writer->writeInt16(371, ent->dimlwd);
writer->writeInt16(372, ent->dimlwe);
}
return true;
}
@ -2639,12 +2630,9 @@ auto dxfRW::processLType() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !ltype.parseCode(code, reader))
{
if (!ltype.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}
@ -2679,12 +2667,9 @@ auto dxfRW::processLayer() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !layer.parseCode(code, reader))
{
if (!layer.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}
@ -2719,12 +2704,9 @@ auto dxfRW::processDimStyle() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !dimSty.parseCode(code, reader))
{
if (!dimSty.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}
@ -2759,12 +2741,9 @@ auto dxfRW::processTextStyle() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !TxtSty.parseCode(code, reader))
{
if (!TxtSty.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}
@ -2799,12 +2778,9 @@ auto dxfRW::processVports() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !vp.parseCode(code, reader))
{
if (!vp.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}
@ -2839,12 +2815,9 @@ auto dxfRW::processAppId() -> bool
return true; // found ENDTAB terminate
}
}
else if (reading)
else if (reading && !vp.parseCode(code, reader))
{
if (!vp.parseCode(code, reader))
{
return setError(DRW::BAD_CODE_PARSED);
}
return setError(DRW::BAD_CODE_PARSED);
}
}

View File

@ -1047,14 +1047,12 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
{
ExportNotch(passmark.baseLine.p1(), passmark.baseLine.length(), passmark.baseLine.angle());
if (!mirrorLine.isNull() && detail.IsShowFullPiece())
if (!mirrorLine.isNull() && detail.IsShowFullPiece() &&
!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
QLineF const baseLine = matrix.map(passmark.baseLine);
ExportNotch(baseLine.p1(), baseLine.length(), baseLine.angle());
}
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
QLineF const baseLine = matrix.map(passmark.baseLine);
ExportNotch(baseLine.p1(), baseLine.length(), baseLine.angle());
}
}
}
@ -1694,15 +1692,13 @@ void VDxfEngine::ExportASTMNotches(const QSharedPointer<dx_ifaceBlock> &detailBl
ExportPassmark(passmark);
const QLineF mirrorLine = detail.GetMappedSeamMirrorLine();
if (!mirrorLine.isNull() && detail.IsShowFullPiece())
if (!mirrorLine.isNull() && detail.IsShowFullPiece() &&
!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
ExportPassmark(mirroredPassmark);
}
ExportPassmark(mirroredPassmark);
}
}
}
@ -1776,14 +1772,12 @@ auto VDxfEngine::ExportASTMNotch(const VLayoutPassmark &passmark) -> DRW_ASTMNot
notch->angle = passmark.baseLine.angle();
PassmarkLineType type = passmark.type;
if (m_compatibilityMode == DXFApparelCompatibility::RPCADV08 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV09 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV10)
if ((m_compatibilityMode == DXFApparelCompatibility::RPCADV08 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV09 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV10) &&
(type == PassmarkLineType::ExternalVMark || type == PassmarkLineType::InternalVMark))
{
if (type == PassmarkLineType::ExternalVMark || type == PassmarkLineType::InternalVMark)
{
type = PassmarkLineType::CheckMark;
}
type = PassmarkLineType::CheckMark;
}
switch (type)

View File

@ -854,13 +854,10 @@ auto VMeasurements::MeasurementForDimension(IMD type) const -> QString
for (int i = 0; i < list.size(); ++i)
{
const QDomElement domElement = list.at(i).toElement();
if (!domElement.isNull())
if (const QDomElement domElement = list.at(i).toElement();
!domElement.isNull() && domElement.attribute(AttrDimension) == d)
{
if (domElement.attribute(AttrDimension) == d)
{
return domElement.attribute(AttrName);
}
return domElement.attribute(AttrName);
}
}
return {};
@ -1619,13 +1616,10 @@ void VMeasurements::ClearDimension(IMD type)
for (int i = 0; i < list.size(); ++i)
{
QDomElement domElement = list.at(i).toElement();
if (!domElement.isNull())
if (QDomElement domElement = list.at(i).toElement();
!domElement.isNull() && domElement.attribute(AttrDimension) == d)
{
if (domElement.attribute(AttrDimension) == d)
{
domElement.removeAttribute(AttrDimension);
}
domElement.removeAttribute(AttrDimension);
}
}
}

View File

@ -239,13 +239,10 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q
return points;
}
if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0)
if ((m_cusp_limit > 0.0 || m_cusp_limit < 0.0) && da1 > m_cusp_limit)
{
if (da1 > m_cusp_limit)
{
points.append(QPointF(x3, y3));
return points;
}
points.append(QPointF(x3, y3));
return points;
}
}
break;
@ -278,13 +275,10 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q
return points;
}
if (m_cusp_limit > 0.0 || m_cusp_limit < 0.0)
if ((m_cusp_limit > 0.0 || m_cusp_limit < 0.0) && da1 > m_cusp_limit)
{
if (da1 > m_cusp_limit)
{
points.append(QPointF(x2, y2));
return points;
}
points.append(QPointF(x2, y2));
return points;
}
}
break;

View File

@ -528,15 +528,13 @@ void VHPGLEngine::PlotPassmarks(QTextStream &out, const VLayoutPiece &detail)
PlotPassmark(passmark);
const QLineF mirrorLine = detail.GetMappedSeamMirrorLine();
if (!mirrorLine.isNull() && detail.IsShowFullPiece())
if (!mirrorLine.isNull() && detail.IsShowFullPiece() &&
!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
if (!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), mirrorLine.p1(), mirrorLine.p2()))
{
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
PlotPassmark(mirroredPassmark);
}
PlotPassmark(mirroredPassmark);
}
}
}

View File

@ -729,12 +729,9 @@ auto Rollback(QVector<VRawSAPoint> &points, const QLineF &edge) -> bool
points.removeLast();
points = VAbstractPiece::RollbackSeamAllowance(points, edge, &success);
if (not points.isEmpty())
if (not points.isEmpty() && points.constLast().toPoint() != points.constFirst().toPoint())
{
if (points.constLast().toPoint() != points.constFirst().toPoint())
{
points.append(points.constFirst()); // Should be always closed
}
points.append(points.constFirst()); // Should be always closed
}
}
return success;
@ -866,12 +863,9 @@ void RollbackBySecondEdgeRightAngle(QVector<VRawSAPoint> &ekvPoints, const QVect
}
}
if (not ekvPoints.isEmpty())
if (not ekvPoints.isEmpty() && ekvPoints.constLast().toPoint() != ekvPoints.constFirst().toPoint())
{
if (ekvPoints.constLast().toPoint() != ekvPoints.constFirst().toPoint())
{
ekvPoints.append(ekvPoints.constFirst()); // Should be always closed
}
ekvPoints.append(ekvPoints.constFirst()); // Should be always closed
}
}
}

View File

@ -370,14 +370,11 @@ inline auto VAbstractPiece::RemoveDublicates(const QVector<T> &points, bool remo
}
}
if (removeFirstAndLast)
if (removeFirstAndLast && not p.isEmpty() && p.size() > 1)
{
if (not p.isEmpty() && p.size() > 1)
{
// Path can't be closed
// See issue #686
CompareFirstAndLastPoints(p, accuracy);
}
// Path can't be closed
// See issue #686
CompareFirstAndLastPoints(p, accuracy);
}
return p;

View File

@ -1754,16 +1754,13 @@ auto VLayoutPiece::GetItem(bool textAsPaths, bool togetherWithNotches, bool show
mirrorFlag = true;
}
}
else if (not IsSeamAllowanceBuiltIn())
else if (not IsSeamAllowanceBuiltIn() && !d->m_seamAllowanceMirrorLine.isNull())
{
if (!d->m_seamAllowanceMirrorLine.isNull())
{
QPainterPath mirrorPath;
mirrorPath.moveTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p1()));
mirrorPath.lineTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p2()));
mirrorLinePath.addPath(mirrorPath);
mirrorFlag = true;
}
QPainterPath mirrorPath;
mirrorPath.moveTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p1()));
mirrorPath.lineTo(d->m_matrix.map(d->m_seamAllowanceMirrorLine.p2()));
mirrorLinePath.addPath(mirrorPath);
mirrorFlag = true;
}
if (mirrorFlag)

View File

@ -455,15 +455,13 @@ auto VPosition::Crossing(const VLayoutPiece &detail) const -> VPosition::Crossin
for (const auto &position : m_data.positionsCache)
{
if (position.boundingRect.intersects(layoutBoundingRect) ||
position.boundingRect.contains(detailBoundingRect) || detailBoundingRect.contains(position.boundingRect))
if ((position.boundingRect.intersects(layoutBoundingRect) ||
position.boundingRect.contains(detailBoundingRect) ||
detailBoundingRect.contains(position.boundingRect)) &&
(position.layoutAllowancePath.contains(contourPath) || contourPath.contains(position.layoutAllowancePath) ||
position.layoutAllowancePath.intersects(layoutAllowancePath)))
{
if (position.layoutAllowancePath.contains(contourPath) ||
contourPath.contains(position.layoutAllowancePath) ||
position.layoutAllowancePath.intersects(layoutAllowancePath))
{
return CrossingType::Intersection;
}
return CrossingType::Intersection;
}
}

View File

@ -192,12 +192,9 @@ void VPrintLayout::PdfTiledFile(const QString &name)
{
m_isTiled = true;
if (m_isLayoutStale)
if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
return;
}
QPrinter printer;
SetPrinterSettings(&printer, PrintType::PrintPDF, name);
@ -224,12 +221,9 @@ void VPrintLayout::CleanLayout()
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintLayout()
{
if (m_isLayoutStale)
if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
return;
}
// display print dialog and if accepted print
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
@ -269,12 +263,9 @@ void VPrintLayout::PrintLayout()
//---------------------------------------------------------------------------------------------------------------------
void VPrintLayout::PrintPreview()
{
if (m_isLayoutStale)
if (m_isLayoutStale && ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
if (ContinueIfLayoutStale(m_parentWidget) == QMessageBox::No)
{
return;
}
return;
}
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
@ -390,13 +381,10 @@ void VPrintLayout::PrintPages(QPrinter *printer)
{
for (int j = 0; j < numPages; ++j)
{
if (i != 0 || j != 0)
if ((i != 0 || j != 0) && not printer->newPage())
{
if (not printer->newPage())
{
qCritical() << tr("Failed in flushing page to disk, disk full?");
return;
}
qCritical() << tr("Failed in flushing page to disk, disk full?");
return;
}
vsizetype index;
if (printer->pageOrder() == QPrinter::FirstPageFirst)

View File

@ -605,13 +605,10 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
rows = rowCount();
cols = columnCount();
QString data;
if (not dest->isOpen())
if (not dest->isOpen() && not dest->open(QIODevice::WriteOnly | QIODevice::Truncate))
{
if (not dest->open(QIODevice::WriteOnly | QIODevice::Truncate))
{
error = dest->errorString();
return false;
}
error = dest->errorString();
return false;
}
QTextStream stream(dest);

View File

@ -591,14 +591,11 @@ void VAbstractApplication::CheckSystemLocale()
//---------------------------------------------------------------------------------------------------------------------
void VAbstractApplication::SVGFontsPathChanged(const QString &oldPath, const QString &newPath)
{
if (oldPath != newPath)
if (oldPath != newPath && m_svgFontDatabase != nullptr)
{
if (m_svgFontDatabase != nullptr)
{
RestartSVGFontDatabaseWatcher();
m_svgFontDatabase->InvalidatePath(oldPath);
RepopulateFontDatabase(newPath);
}
RestartSVGFontDatabaseWatcher();
m_svgFontDatabase->InvalidatePath(oldPath);
RepopulateFontDatabase(newPath);
}
}

View File

@ -240,27 +240,25 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector<VNodeDetail> &no
for (int i = 0; i < nodes.size(); ++i)
{
const VNodeDetail &node = nodes.at(i);
if (node.getTypeTool() == Tool::NodePoint)
if (node.getTypeTool() == Tool::NodePoint &&
(not qFuzzyIsNull(node.getMx()) || not qFuzzyIsNull(node.getMy())))
{
if (not qFuzzyIsNull(node.getMx()) || not qFuzzyIsNull(node.getMy()))
{
const QPointF previosPoint = path.NodePreviousPoint(data, i);
const QPointF nextPoint = path.NodeNextPoint(data, i);
const QPointF previosPoint = path.NodePreviousPoint(data, i);
const QPointF nextPoint = path.NodeNextPoint(data, i);
const QPointF point = data->GeometricObject<VPointF>(node.getId())->toQPointF();
const QPointF point = data->GeometricObject<VPointF>(node.getId())->toQPointF();
QLineF lineBefore(point, previosPoint);
lineBefore.setAngle(lineBefore.angle() - 90);
lineBefore.setLength(width);
QLineF lineBefore(point, previosPoint);
lineBefore.setAngle(lineBefore.angle() - 90);
lineBefore.setLength(width);
ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy());
ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy());
QLineF lineAfter(point, nextPoint);
lineAfter.setAngle(lineAfter.angle() + 90);
lineAfter.setLength(width);
QLineF lineAfter(point, nextPoint);
lineAfter.setAngle(lineAfter.angle() + 90);
lineAfter.setLength(width);
ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy());
}
ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy());
}
}
}

View File

@ -365,18 +365,15 @@ auto VPiece::PassmarksPath(const VContainer *data) const -> QPainterPath
QPainterPath path;
// seam allowence
if (IsSeamAllowance())
if (IsSeamAllowance() && not passmarks.isEmpty())
{
if (not passmarks.isEmpty())
for (qint32 i = 0; i < passmarks.count(); ++i)
{
for (qint32 i = 0; i < passmarks.count(); ++i)
{
path.moveTo(passmarks.at(i).p1());
path.lineTo(passmarks.at(i).p2());
}
path.setFillRule(Qt::WindingFill);
path.moveTo(passmarks.at(i).p1());
path.lineTo(passmarks.at(i).p2());
}
path.setFillRule(Qt::WindingFill);
}
return path;

View File

@ -221,18 +221,16 @@ template <class T> inline auto VPiece::SeamAllowancePath(const QVector<T> &point
QPainterPath ekv;
// seam allowence
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not points.isEmpty())
{
if (not points.isEmpty())
ekv.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i)
{
ekv.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i)
{
ekv.lineTo(points.at(i));
}
ekv.lineTo(points.at(i));
}
#if !defined(V_NO_ASSERT)
// uncomment for debug
// uncomment for debug
// QFont font;
// font.setPixelSize(1);
// for (qint32 i = 0; i < points.count(); ++i)
@ -248,8 +246,7 @@ template <class T> inline auto VPiece::SeamAllowancePath(const QVector<T> &point
// }
#endif
ekv.setFillRule(Qt::WindingFill);
}
ekv.setFillRule(Qt::WindingFill);
}
return ekv;

View File

@ -156,13 +156,10 @@ auto VPE::VFileEditWidget::eventFilter(QObject *obj, QEvent *ev) -> bool
ev->ignore();
return true;
}
else if (obj == FileLineEdit)
else if (obj == FileLineEdit && ev->type() == QEvent::FocusOut)
{
if (ev->type() == QEvent::FocusOut)
{
setFile(FileLineEdit->text(), true);
// We don't return true here because we still want the line edit to catch the event as well
}
setFile(FileLineEdit->text(), true);
// We don't return true here because we still want the line edit to catch the event as well
}
// forward the signal to the parent class

View File

@ -53,21 +53,18 @@ VPE::VShortcutEditWidget::~VShortcutEditWidget()
auto VPE::VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event) -> bool
{
if (obj == LineEdit)
if (obj == LineEdit && event->type() == QEvent::KeyPress)
{
if (event->type() == QEvent::KeyPress)
auto *keyEvent = static_cast<QKeyEvent *>(event);
int keys = keyEvent->key();
if (keys != Qt::Key_Shift && keys != Qt::Key_Control && keys != Qt::Key_Meta && keys != Qt::Key_AltGr &&
keys != Qt::Key_Alt)
{
auto *keyEvent = static_cast<QKeyEvent *>(event);
int keys = keyEvent->key();
if (keys != Qt::Key_Shift && keys != Qt::Key_Control && keys != Qt::Key_Meta && keys != Qt::Key_AltGr &&
keys != Qt::Key_Alt)
{
keys += keyEvent->modifiers();
setShortcut(QKeySequence(keys), true);
return true;
}
keys += keyEvent->modifiers();
setShortcut(QKeySequence(keys), true);
return true;
}
}

View File

@ -126,13 +126,10 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t
// Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR
if (QGuiApplication::overrideCursor() != nullptr)
if (QGuiApplication::overrideCursor() != nullptr && QGuiApplication::overrideCursor()->shape() == Qt::WaitCursor)
{
if (QGuiApplication::overrideCursor()->shape() == Qt::WaitCursor)
{
restoreCursor = true;
QGuiApplication::restoreOverrideCursor();
}
restoreCursor = true;
QGuiApplication::restoreOverrideCursor();
}
#endif
ui->tableWidget->setColumnCount(2);

View File

@ -369,30 +369,24 @@ void DialogArc::SetRadius(const QString &value)
*/
void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare) // After first choose we ignore all objects
if (not prepare && type == SceneObject::Point &&
SetObject(id, ui->comboBoxBasePoint, QString())) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
if (vis != nullptr)
{
if (SetObject(id, ui->comboBoxBasePoint, QString()))
{
if (vis != nullptr)
{
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
vis->VisualMode(id);
vis->RefreshToolTip();
}
vis->VisualMode(id);
vis->RefreshToolTip();
}
prepare = true;
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -353,30 +353,24 @@ void DialogArcWithLength::ShowDialog(bool click)
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare) // After first choose we ignore all objects
if (not prepare && type == SceneObject::Point &&
SetObject(id, ui->comboBoxCenter, QString())) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
if (vis != nullptr)
{
if (SetObject(id, ui->comboBoxCenter, QString()))
{
if (vis != nullptr)
{
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
vis->VisualMode(id);
vis->RefreshToolTip();
}
vis->VisualMode(id);
vis->RefreshToolTip();
}
prepare = true;
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -213,14 +213,12 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
{
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
{
m_number++;
line->SetPoint2Id(id);
line->RefreshGeometry();
}
m_number++;
line->SetPoint2Id(id);
line->RefreshGeometry();
}
break;
case 2:
@ -439,25 +437,22 @@ void DialogBisector::ChosenThirdPoint(quint32 id)
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id);
if (set.size() == 3)
if (set.size() == 3 && SetObject(id, ui->comboBoxThirdPoint, QString()))
{
if (SetObject(id, ui->comboBoxThirdPoint, QString()))
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetPoint3Id(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetPoint3Id(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
FinishCreating();
}
}
}

View File

@ -122,57 +122,51 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline)
//---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *path = qobject_cast<VisToolCubicBezier *>(vis);
SCASSERT(path != nullptr)
switch (number)
{
auto *path = qobject_cast<VisToolCubicBezier *>(vis);
SCASSERT(path != nullptr)
case 0:
if (SetObject(id, ui->comboBoxP1, tr("Select the second point of curve")))
{
++number;
path->VisualMode(id);
}
break;
case 1:
if (SetObject(id, ui->comboBoxP2, tr("Select the third point of curve")))
{
++number;
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxP1, tr("Select the second point of curve")))
{
++number;
path->VisualMode(id);
}
break;
case 1:
if (SetObject(id, ui->comboBoxP2, tr("Select the third point of curve")))
{
++number;
path->SetPoint2Id(id);
path->RefreshGeometry();
}
break;
case 2:
if (SetObject(id, ui->comboBoxP3, tr("Select the fourth point of curve")))
{
++number;
path->SetPoint2Id(id);
path->RefreshGeometry();
}
break;
case 2:
if (SetObject(id, ui->comboBoxP3, tr("Select the fourth point of curve")))
{
++number;
path->SetPoint3Id(id);
path->RefreshGeometry();
}
break;
case 3:
if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString()))
{
++number;
path->SetPoint3Id(id);
path->RefreshGeometry();
}
break;
case 3:
if (getCurrentObjectId(ui->comboBoxP1) != id)
{
if (SetObject(id, ui->comboBoxP4, QString()))
{
++number;
path->SetPoint4Id(id);
path->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
path->SetPoint4Id(id);
path->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -190,19 +190,17 @@ void DialogCubicBezierPath::ShowDialog(bool click)
}
const auto size = path.CountPoints();
if (size >= 7)
if (size >= 7 && size - VCubicBezierPath::SubSplPointsCount(path.CountSubSpl()) == 0)
{
if (size - VCubicBezierPath::SubSplPointsCount(path.CountSubSpl()) == 0)
{ // Accept only if all subpaths are completed
emit ToolTip(QString());
// Accept only if all subpaths are completed
emit ToolTip(QString());
if (not data->IsUnique(path.name()))
{
path.SetDuplicate(DNumber(path.name()));
}
DialogAccepted();
if (not data->IsUnique(path.name()))
{
path.SetDuplicate(DNumber(path.name()));
}
DialogAccepted();
}
}

View File

@ -261,36 +261,31 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
switch (number)
{
case (0):
if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc ||
type == SceneObject::SplinePath)
if ((type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc ||
type == SceneObject::SplinePath) &&
SetObject(id, ui->comboBoxCurve, tr("Select axis point")))
{
if (SetObject(id, ui->comboBoxCurve, tr("Select axis point")))
{
number++;
line->VisualMode(id);
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
number++;
line->VisualMode(id);
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
break;
case (1):
if (type == SceneObject::Point)
if (type == SceneObject::Point && SetObject(id, ui->comboBoxAxisPoint, QString()))
{
if (SetObject(id, ui->comboBoxAxisPoint, QString()))
line->setAxisPointId(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
line->setAxisPointId(id);
line->RefreshGeometry();
prepare = true;
emit ToolTip(QString());
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
emit ToolTip(QString());
setModal(true);
show();
}
setModal(true);
show();
}
}
break;

View File

@ -172,38 +172,35 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
return;
}
if (type == SceneObject::Arc)
if (type == SceneObject::Arc && SetObject(id, ui->comboBoxArc, QString()))
{
if (SetObject(id, ui->comboBoxArc, QString()))
if (vis != nullptr)
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
prepare = true;
vis->VisualMode(id);
}
prepare = true;
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
if (m_buildStartPoint)
{
SetFormula("0"_L1);
FinishCreating();
return;
}
if (m_buildStartPoint)
{
SetFormula("0"_L1);
FinishCreating();
return;
}
if (m_buildEndPoint)
{
SetFormula(currentLength);
FinishCreating();
return;
}
if (m_buildEndPoint)
{
SetFormula(currentLength);
FinishCreating();
return;
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -175,24 +175,21 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
return;
}
if (type == SceneObject::Spline)
if (type == SceneObject::Spline && SetObject(id, ui->comboBoxSpline, QString()))
{
if (SetObject(id, ui->comboBoxSpline, QString()))
if (vis != nullptr)
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
prepare = true;
vis->VisualMode(id);
}
prepare = true;
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -175,24 +175,21 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
return;
}
if (type == SceneObject::SplinePath)
if (type == SceneObject::SplinePath && SetObject(id, ui->comboBoxSplinePath, QString()))
{
if (SetObject(id, ui->comboBoxSplinePath, QString()))
if (vis != nullptr)
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
prepare = true;
vis->VisualMode(id);
}
prepare = true;
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -206,26 +206,21 @@ void DialogEndLine::FXLength()
*/
void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare) // After first choose we ignore all objects
if (not prepare && type == SceneObject::Point &&
SetObject(id, ui->comboBoxBasePoint, QString())) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
if (vis != nullptr)
{
if (SetObject(id, ui->comboBoxBasePoint, QString()))
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
prepare = true;
vis->VisualMode(id);
}
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
}
}

View File

@ -260,28 +260,25 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector<SourceItem> &value)
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare) // After first choose we ignore all objects
if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
emit ToolTip(tr("Select origin point that is not part of the list of objects"));
return;
}
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select origin point that is not part of the list of objects"));
return;
}
if (SetObject(id, ui->comboBoxOriginPoint, QString()))
{
auto *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr)
operation->SetOriginPointId(id);
operation->RefreshGeometry();
if (SetObject(id, ui->comboBoxOriginPoint, QString()))
{
auto *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr)
operation->SetOriginPointId(id);
operation->RefreshGeometry();
prepare = true;
}
prepare = true;
}
}
}

View File

@ -253,57 +253,49 @@ void DialogFlippingByLine::SetSourceObjects(const QVector<SourceItem> &value)
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare) // After first choose we ignore all objects
if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
switch (number)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
switch (number)
{
case 0:
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
return;
}
case 0:
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
return;
}
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point")))
{
number++;
auto *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetFirstLinePointId(id);
operation->RefreshGeometry();
}
break;
case 1:
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
return;
}
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point")))
{
number++;
auto *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetFirstLinePointId(id);
operation->RefreshGeometry();
}
break;
case 1:
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
return;
}
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id)
{
if (SetObject(id, ui->comboBoxSecondLinePoint, QString()))
{
if (flagError)
{
number = 0;
prepare = true;
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id &&
SetObject(id, ui->comboBoxSecondLinePoint, QString()) && flagError)
{
number = 0;
prepare = true;
auto *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetSecondLinePointId(id);
operation->RefreshGeometry();
}
}
}
break;
default:
break;
}
auto *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetSecondLinePointId(id);
operation->RefreshGeometry();
}
break;
default:
break;
}
}
}

View File

@ -208,14 +208,12 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxBasePoint) != id)
if (getCurrentObjectId(ui->comboBoxBasePoint) != id &&
SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
m_number++;
line->SetLineP1Id(id);
line->RefreshGeometry();
}
m_number++;
line->SetLineP1Id(id);
line->RefreshGeometry();
}
break;
case (2):
@ -225,15 +223,12 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id);
if (set.size() == 3)
if (set.size() == 3 && SetObject(id, ui->comboBoxP2Line, QString()))
{
if (SetObject(id, ui->comboBoxP2Line, QString()))
{
line->SetLineP2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
line->SetLineP2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;

View File

@ -178,39 +178,31 @@ void DialogLine::SaveData()
*/
void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
switch (number)
{
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
number++;
if (vis != nullptr)
{
number++;
if (vis != nullptr)
{
vis->VisualMode(id);
}
vis->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
{
if (flagError)
{
number = 0;
prepare = true;
DialogAccepted();
}
}
}
break;
default:
break;
}
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
SetObject(id, ui->comboBoxSecondPoint, QString()) && flagError)
{
number = 0;
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -108,82 +108,74 @@ DialogLineIntersect::~DialogLineIntersect()
*/
void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
auto *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line")))
{
number++;
line->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP1Line1) != id)
{
if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{
number++;
line->SetLine1P2Id(id);
line->RefreshGeometry();
}
}
break;
case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
{
number++;
line->SetLine2P1Id(id);
line->RefreshGeometry();
}
break;
case 3:
case 0:
if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line")))
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxP1Line1));
set.insert(getCurrentObjectId(ui->comboBoxP2Line1));
set.insert(getCurrentObjectId(ui->comboBoxP1Line2));
set.insert(id);
if (set.size() >= 3)
{
if (SetObject(id, ui->comboBoxP2Line2, QString()))
{
line->SetLine2P2Id(id);
line->RefreshGeometry();
prepare = true;
flagPoint = CheckIntersecion();
CheckState();
if (flagPoint)
{
DialogAccepted();
}
else
{
this->setModal(true);
this->show();
connect(ui->comboBoxP1Line1, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line1, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP1Line2, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line2, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
}
}
}
number++;
line->VisualMode(id);
}
break;
default:
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP1Line1) != id &&
SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{
number++;
line->SetLine1P2Id(id);
line->RefreshGeometry();
}
break;
case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
{
number++;
line->SetLine2P1Id(id);
line->RefreshGeometry();
}
break;
case 3:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxP1Line1));
set.insert(getCurrentObjectId(ui->comboBoxP2Line1));
set.insert(getCurrentObjectId(ui->comboBoxP1Line2));
set.insert(id);
if (set.size() >= 3 && SetObject(id, ui->comboBoxP2Line2, QString()))
{
line->SetLine2P2Id(id);
line->RefreshGeometry();
prepare = true;
flagPoint = CheckIntersecion();
CheckState();
if (flagPoint)
{
DialogAccepted();
}
else
{
this->setModal(true);
this->show();
connect(ui->comboBoxP1Line1, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line1, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP1Line2, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line2, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::PointChanged);
}
}
}
break;
default:
break;
}
}
}

View File

@ -277,65 +277,57 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
auto *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
case (0):
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line")))
{
number++;
line->VisualMode(id);
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id)
{
if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
{
number++;
line->SetPoint2Id(id);
line->RefreshGeometry();
}
}
break;
case (2):
case (0):
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second point of line")))
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxAxisPoint, QString()))
{
line->SetAxisPointId(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
vis->SetMode(Mode::Show);
emit ToolTip(QString());
show();
}
}
}
number++;
line->VisualMode(id);
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
break;
default:
break;
case (1):
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id &&
SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
{
number++;
line->SetPoint2Id(id);
line->RefreshGeometry();
}
break;
case (2):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
set.insert(id);
if (set.size() == 3 && SetObject(id, ui->comboBoxAxisPoint, QString()))
{
line->SetAxisPointId(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
vis->SetMode(Mode::Show);
emit ToolTip(QString());
show();
}
}
}
break;
default:
break;
}
}
}

View File

@ -402,20 +402,16 @@ void DialogMove::ShowDialog(bool click)
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && stage2 && prepare) // After first choose we ignore all objects
if (not stage1 && stage2 && prepare && type == SceneObject::Point &&
QGuiApplication::keyboardModifiers() == Qt::ControlModifier &&
SetObject(id, ui->comboBoxRotationOriginPoint, QString())) // After first choose we ignore all objects
{
if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
{
if (SetObject(id, ui->comboBoxRotationOriginPoint, QString()))
{
auto *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
auto *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetRotationOriginPointId(id);
operation->RefreshGeometry();
optionalRotationOrigin = true;
}
}
operation->SetRotationOriginPointId(id);
operation->RefreshGeometry();
optionalRotationOrigin = true;
}
}

View File

@ -218,23 +218,21 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
SetObject(id, ui->comboBoxSecondPoint, QString()))
{
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
line->SetPoint2Id(id);
line->RefreshGeometry();
prepare = true;
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
line->SetPoint2Id(id);
line->RefreshGeometry();
prepare = true;
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
FinishCreating();
}
}
break;

View File

@ -145,41 +145,33 @@ void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p)
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false &&
(type == SceneObject::Point || type == SceneObject::Arc)) // After first choose we ignore all objects
{
if (type == SceneObject::Point || type == SceneObject::Arc)
{
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr)
auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr)
switch (number)
{
case 0:
if (type == SceneObject::Point)
{
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
{
number++;
point->VisualMode(id);
}
}
break;
case 1:
if (type == SceneObject::Arc)
{
if (SetObject(id, ui->comboBoxArc, QString()))
{
number = 0;
point->SetArcId(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
switch (number)
{
case 0:
if (type == SceneObject::Point && SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
{
number++;
point->VisualMode(id);
}
break;
case 1:
if (type == SceneObject::Arc && SetObject(id, ui->comboBoxArc, QString()))
{
number = 0;
point->SetArcId(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -254,24 +254,22 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxTangentPoint) != id)
if (getCurrentObjectId(ui->comboBoxTangentPoint) != id &&
SetObject(id, ui->comboBoxCircleCenter, QString()))
{
if (SetObject(id, ui->comboBoxCircleCenter, QString()))
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
m_number = 0;
point->SetCenterId(id);
point->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
m_number = 0;
point->SetCenterId(id);
point->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
FinishCreating();
}
}
break;

View File

@ -244,14 +244,12 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc")))
{
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc")))
{
m_number++;
line->SetLineP2Id(id);
line->RefreshGeometry();
}
m_number++;
line->SetLineP2Id(id);
line->RefreshGeometry();
}
break;
case 2:
@ -261,23 +259,19 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id);
if (set.size() == 3)
if (set.size() == 3 && SetObject(id, ui->comboBoxCenter, QString()))
{
if (SetObject(id, ui->comboBoxCenter, QString()))
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetRadiusId(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetRadiusId(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
FinishCreating();
}
}
}

View File

@ -117,38 +117,33 @@ void DialogPointOfIntersection::SetSecondPointId(quint32 value)
*/
void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
auto *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr)
auto *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)")))
{
number++;
line->SetPoint1Id(id);
line->RefreshGeometry();
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
{
line->SetPoint2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)")))
{
number++;
line->SetPoint1Id(id);
line->RefreshGeometry();
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
SetObject(id, ui->comboBoxSecondPoint, QString()))
{
line->SetPoint2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -150,38 +150,32 @@ void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint p)
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Arc) // After first choose we ignore all objects
{
if (type == SceneObject::Arc)
{
auto *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr)
auto *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc")))
{
number++;
point->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxArc1) != id)
{
if (SetObject(id, ui->comboBoxArc2, QString()))
{
number = 0;
point->SetArc2Id(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc")))
{
number++;
point->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxArc1) != id && SetObject(id, ui->comboBoxArc2, QString()))
{
number = 0;
point->SetArc2Id(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -330,20 +330,18 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec
}
break;
case 2:
if (getCurrentObjectId(ui->comboBoxCircle1Center) != id)
if (getCurrentObjectId(ui->comboBoxCircle1Center) != id &&
SetObject(id, ui->comboBoxCircle2Center, QString()))
{
if (SetObject(id, ui->comboBoxCircle2Center, QString()))
{
point->SetCircle2Id(id);
point->RefreshGeometry();
++m_stage;
prepare = true;
point->SetCircle2Id(id);
point->RefreshGeometry();
++m_stage;
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
return;
}
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
return;
}
}
break;

View File

@ -178,39 +178,33 @@ void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP)
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc ||
type == SceneObject::SplinePath)) // After first choose we ignore all objects
{
if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc ||
type == SceneObject::SplinePath)
{
auto *point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
SCASSERT(point != nullptr)
auto *point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
SCASSERT(point != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve")))
{
number++;
point->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxCurve1) != id)
{
if (SetObject(id, ui->comboBoxCurve2, QString()))
{
number = 0;
point->SetCurve2Id(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve")))
{
number++;
point->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxCurve1) != id && SetObject(id, ui->comboBoxCurve2, QString()))
{
number = 0;
point->SetCurve2Id(id);
point->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
default:
break;
}
}
}

View File

@ -321,44 +321,41 @@ void DialogRotation::SetSourceObjects(const QVector<SourceItem> &value)
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare) // After first choose we ignore all objects
if (not stage1 && not prepare && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
{
auto *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
if (sourceObjects.size() > 1)
{
if (sourceObjects.size() > 1)
{
// It's not really logical for a user that a center of rotation no need to select.
// To fix this issue we just silently remove it from the list.
sourceObjects.erase(obj);
operation->SetObjects(SourceToObjects(sourceObjects));
}
else
{
emit ToolTip(tr("This point cannot be origin point. Please, select another origin point"));
return;
}
// It's not really logical for a user that a center of rotation no need to select.
// To fix this issue we just silently remove it from the list.
sourceObjects.erase(obj);
operation->SetObjects(SourceToObjects(sourceObjects));
}
if (SetObject(id, ui->comboBoxOriginPoint, QString()))
else
{
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
operation->SetOriginPointId(id);
operation->RefreshGeometry();
prepare = true;
emit ToolTip(tr("This point cannot be origin point. Please, select another origin point"));
return;
}
}
if (SetObject(id, ui->comboBoxOriginPoint, QString()))
{
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
operation->SetOriginPointId(id);
operation->RefreshGeometry();
prepare = true;
}
}
}

View File

@ -212,14 +212,12 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP3) != id)
if (getCurrentObjectId(ui->comboBoxP3) != id &&
SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
m_number++;
line->SetLineP1Id(id);
line->RefreshGeometry();
}
m_number++;
line->SetLineP1Id(id);
line->RefreshGeometry();
}
break;
case 2:
@ -281,25 +279,22 @@ void DialogShoulderPoint::ChosenThirdPoint(quint32 id)
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id);
if (set.size() == 3)
if (set.size() == 3 && SetObject(id, ui->comboBoxP2Line, QString()))
{
if (SetObject(id, ui->comboBoxP2Line, QString()))
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetLineP2Id(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetLineP2Id(id);
line->RefreshGeometry();
prepare = true;
if (not VAbstractValApplication::VApp()->Settings()->IsInteractiveTools())
{
FinishCreating();
}
FinishCreating();
}
}
}

View File

@ -159,40 +159,34 @@ DialogSpline::~DialogSpline()
*/
void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
{
if (!prepare) // After first choose we ignore all objects
if (!prepare && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr)
switch (number)
{
auto *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve")))
{
++number;
path->VisualMode(id);
}
break;
case 1:
case 0:
if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve")))
{
if (getCurrentObjectId(ui->comboBoxP1) != id)
{
if (SetObject(id, ui->comboBoxP4, QString()))
{
++number;
path->SetPoint4Id(id);
path->RefreshGeometry();
prepare = true;
}
}
break;
++number;
path->VisualMode(id);
}
default:
break;
break;
case 1:
{
if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString()))
{
++number;
path->SetPoint4Id(id);
path->RefreshGeometry();
prepare = true;
}
break;
}
default:
break;
}
}
}

View File

@ -207,12 +207,9 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (i.key() != toolId)
if (i.key() != toolId && IsSpline(i.value()))
{
if (IsSpline(i.value()))
{
PrepareList<VAbstractCurve>(list, i.key());
}
PrepareList<VAbstractCurve>(list, i.key());
}
}
FillList(box, list);
@ -231,12 +228,9 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (i.key() != toolId)
if (i.key() != toolId && IsSplinePath(i.value()))
{
if (IsSplinePath(i.value()))
{
PrepareList<VAbstractCurve>(list, i.key());
}
PrepareList<VAbstractCurve>(list, i.key());
}
}
FillList(box, list);

View File

@ -99,74 +99,63 @@ DialogTriangle::~DialogTriangle()
*/
void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr)
switch (number)
{
auto *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr)
switch (number)
case (0):
if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis")))
{
number++;
line->VisualMode(id);
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxAxisP1) != id &&
SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
{
number++;
line->SetObject2Id(id);
line->RefreshGeometry();
}
break;
case (2):
{
case (0):
if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis")))
{
number++;
line->VisualMode(id);
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxAxisP1) != id)
{
if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
{
number++;
line->SetObject2Id(id);
line->RefreshGeometry();
}
}
break;
case (2):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(id);
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
number++;
line->SetHypotenuseP1Id(id);
line->RefreshGeometry();
}
}
}
break;
case (3):
if (set.size() == 3 && SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(id);
if (set.size() == 4)
{
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
{
line->SetHypotenuseP2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
number++;
line->SetHypotenuseP1Id(id);
line->RefreshGeometry();
}
break;
default:
break;
}
break;
case (3):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(id);
if (set.size() == 4 && SetObject(id, ui->comboBoxSecondPoint, QString()))
{
line->SetHypotenuseP2Id(id);
line->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
default:
break;
}
}
}

View File

@ -217,94 +217,80 @@ void DialogTrueDarts::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
//---------------------------------------------------------------------------------------------------------------------
void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Point) // After first choose we ignore all objects
{
if (type == SceneObject::Point)
auto *points = qobject_cast<VisToolTrueDarts *>(vis);
SCASSERT(points != nullptr)
switch (number)
{
auto *points = qobject_cast<VisToolTrueDarts *>(vis);
SCASSERT(points != nullptr)
switch (number)
case 0:
if (SetObject(id, ui->comboBoxFirstBasePoint, tr("Select the second base point")))
{
number++;
points->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id &&
SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point")))
{
number++;
points->SetBaseLineP2Id(id);
points->RefreshGeometry();
}
break;
case 2:
{
case 0:
if (SetObject(id, ui->comboBoxFirstBasePoint, tr("Select the second base point")))
{
number++;
points->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id)
{
if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point")))
{
number++;
points->SetBaseLineP2Id(id);
points->RefreshGeometry();
}
}
break;
case 2:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(id);
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point")))
{
number++;
points->SetD1PointId(id);
points->RefreshGeometry();
}
}
break;
}
case 3:
if (set.size() == 3 && SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point")))
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
set.insert(id);
if (set.size() == 4)
{
if (SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point")))
{
number++;
points->SetD2PointId(id);
points->RefreshGeometry();
}
}
break;
number++;
points->SetD1PointId(id);
points->RefreshGeometry();
}
case 4:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
set.insert(id);
if (set.size() == 5)
{
if (SetObject(id, ui->comboBoxThirdDartPoint, QString()))
{
points->SetD3PointId(id);
points->RefreshGeometry();
prepare = true;
DialogAccepted();
}
}
break;
}
default:
break;
break;
}
case 3:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
set.insert(id);
if (set.size() == 4 && SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point")))
{
number++;
points->SetD2PointId(id);
points->RefreshGeometry();
}
break;
}
case 4:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
set.insert(id);
if (set.size() == 5 && SetObject(id, ui->comboBoxThirdDartPoint, QString()))
{
points->SetD3PointId(id);
points->RefreshGeometry();
prepare = true;
DialogAccepted();
}
break;
}
default:
break;
}
}
}

View File

@ -133,20 +133,17 @@ auto DialogUnionDetails::CheckDetail(const quint32 &idDetail) const -> bool
*/
void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, vsizetype &index)
{
if (idDetail == NULL_ID)
if (idDetail == NULL_ID && type == SceneObject::Detail)
{
if (type == SceneObject::Detail)
if (CheckDetail(id))
{
if (CheckDetail(id))
{
idDetail = id;
emit ToolTip(tr("Select a first point"));
return;
}
emit ToolTip(tr("Workpiece should have at least two points and three objects"));
idDetail = id;
emit ToolTip(tr("Select a first point"));
return;
}
emit ToolTip(tr("Workpiece should have at least two points and three objects"));
return;
}
if (not CheckObject(id, idDetail))

View File

@ -55,50 +55,44 @@ DialogDuplicateDetail::~DialogDuplicateDetail()
//---------------------------------------------------------------------------------------------------------------------
void DialogDuplicateDetail::ShowDialog(bool click)
{
if (prepare)
if (prepare && click)
{
if (click)
// The check need to ignore first release of mouse button.
// User should have chance to place piece.
if (not m_firstRelease)
{
// The check need to ignore first release of mouse button.
// User should have chance to place piece.
if (not m_firstRelease)
{
m_firstRelease = true;
return;
}
auto *piece = qobject_cast<VisToolDuplicateDetail *>(vis);
SCASSERT(piece != nullptr)
m_mx = piece->Mx();
m_my = piece->My();
emit ToolTip(QString());
DialogAccepted();
m_firstRelease = true;
return;
}
auto *piece = qobject_cast<VisToolDuplicateDetail *>(vis);
SCASSERT(piece != nullptr)
m_mx = piece->Mx();
m_my = piece->My();
emit ToolTip(QString());
DialogAccepted();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false) // After first choose we ignore all objects
if (prepare == false && type == SceneObject::Detail && id > NULL_ID) // After first choose we ignore all objects
{
if (type == SceneObject::Detail && id > NULL_ID)
m_idDetail = id;
auto *tool = qobject_cast<VAbstractTool *>(VAbstractPattern::getTool(m_idDetail));
if (tool)
{
m_idDetail = id;
auto *tool = qobject_cast<VAbstractTool *>(VAbstractPattern::getTool(m_idDetail));
if (tool)
{
vis->SetData(tool->getData()); // Includes currentSeamAllowance variable we need
}
emit ToolTip(tr("Click to place duplicate"));
if (vis != nullptr)
{
vis->VisualMode(id);
}
prepare = true;
vis->SetData(tool->getData()); // Includes currentSeamAllowance variable we need
}
emit ToolTip(tr("Click to place duplicate"));
if (vis != nullptr)
{
vis->VisualMode(id);
}
prepare = true;
}
}

View File

@ -211,23 +211,20 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ShowDialog(bool click)
{
if (not click)
if (not click && CreatePath().CountNodes() > 0)
{
if (CreatePath().CountNodes() > 0)
{
emit ToolTip(QString());
prepare = true;
emit ToolTip(QString());
prepare = true;
if (not m_showMode)
{
auto *visPath = qobject_cast<VisToolPiecePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->SetMode(Mode::Show);
visPath->RefreshGeometry();
}
setModal(true);
show();
if (not m_showMode)
{
auto *visPath = qobject_cast<VisToolPiecePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->SetMode(Mode::Show);
visPath->RefreshGeometry();
}
setModal(true);
show();
}
}

View File

@ -122,22 +122,16 @@ void DialogPin::SetPiecesList(const QVector<quint32> &list)
//---------------------------------------------------------------------------------------------------------------------
void DialogPin::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare)
if (not prepare && type == SceneObject::Point && SetObject(id, ui->comboBoxPoint, QString()))
{
if (type == SceneObject::Point)
if (vis != nullptr)
{
if (SetObject(id, ui->comboBoxPoint, QString()))
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
CheckPoint();
prepare = true;
this->setModal(true);
this->show();
}
vis->VisualMode(id);
}
CheckPoint();
prepare = true;
this->setModal(true);
this->show();
}
}

View File

@ -244,27 +244,21 @@ void DialogPlaceLabel::SetPiecesList(const QVector<quint32> &list)
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
{
if (not prepare)
if (not prepare && type == SceneObject::Point && SetObject(id, ui->comboBoxPoint, QString()))
{
if (type == SceneObject::Point)
if (vis != nullptr)
{
if (SetObject(id, ui->comboBoxPoint, QString()))
{
if (vis != nullptr)
{
vis->VisualMode(id);
}
CheckPoint();
prepare = true;
timerWidth->setSingleShot(formulaTimerTimeout.count());
timerHeight->setSingleShot(formulaTimerTimeout.count());
timerAngle->setSingleShot(formulaTimerTimeout.count());
this->setModal(true);
this->show();
}
vis->VisualMode(id);
}
CheckPoint();
prepare = true;
timerWidth->setSingleShot(formulaTimerTimeout.count());
timerHeight->setSingleShot(formulaTimerTimeout.count());
timerAngle->setSingleShot(formulaTimerTimeout.count());
this->setModal(true);
this->show();
}
}

View File

@ -312,12 +312,10 @@ void VBackgroundImageItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (not Image().Hold())
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
}
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
@ -589,12 +587,9 @@ void VBackgroundImageItem::MakeFresh() const
//---------------------------------------------------------------------------------------------------------------------
void VBackgroundImageItem::DeleteToolWithConfirm(bool ask)
{
if (ask)
if (ask && ConfirmDeletion() == QMessageBox::No)
{
if (ConfirmDeletion() == QMessageBox::No)
{
return;
}
return;
}
emit ActivateControls(QUuid());

View File

@ -388,17 +388,12 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick && IsMovable())
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (IsMovable())
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
oldPosition = event->scenePos();
event->accept();
}
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
oldPosition = event->scenePos();
event->accept();
}
VAbstractSpline::mousePressEvent(event);
}
@ -406,17 +401,12 @@ void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick && IsMovable())
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (IsMovable())
{
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
CurveReleased();
}
}
CurveReleased();
}
VAbstractSpline::mouseReleaseEvent(event);
}

View File

@ -594,18 +594,16 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
//---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
oldPosition = event->scenePos();
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
splIndex = splPath->Segment(oldPosition);
if (IsMovable(splIndex))
{
oldPosition = event->scenePos();
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
splIndex = splPath->Segment(oldPosition);
if (IsMovable(splIndex))
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
}
VAbstractSpline::mousePressEvent(event);
@ -614,15 +612,13 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
oldPosition = event->scenePos();
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
oldPosition = event->scenePos();
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
CurveReleased();
}
CurveReleased();
}
VAbstractSpline::mouseReleaseEvent(event);
}

View File

@ -295,13 +295,11 @@ void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
VToolSinglePoint::mousePressEvent(event);
}
@ -309,12 +307,10 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
}
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
}
VToolSinglePoint::mouseReleaseEvent(event);
}

View File

@ -242,12 +242,9 @@ void VToolSinglePoint::FullUpdateFromFile()
*/
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (selectionType == SelectionType::ByMouseRelease)
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
if (IsSelectedByReleaseEvent(this, event))
{
PointChoosed();
}
PointChoosed();
}
VScenePoint::mouseReleaseEvent(event);
}

View File

@ -965,27 +965,18 @@ void VToolSeamAllowance::ResetChildren(QGraphicsItem *pItem)
const bool selected = isSelected();
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
auto *pVGI = qgraphicsitem_cast<VTextGraphicsItem *>(pItem);
if (pVGI != m_dataLabel)
if (pVGI != m_dataLabel && detail.GetPieceLabelData().IsVisible())
{
if (detail.GetPieceLabelData().IsVisible())
{
m_dataLabel->Reset();
}
m_dataLabel->Reset();
}
if (pVGI != m_patternInfo)
if (pVGI != m_patternInfo && detail.GetPatternLabelData().IsVisible())
{
if (detail.GetPatternLabelData().IsVisible())
{
m_patternInfo->Reset();
}
m_patternInfo->Reset();
}
auto *pGLI = qgraphicsitem_cast<VGrainlineItem *>(pItem);
if (pGLI != m_grainLine)
if (pGLI != m_grainLine && detail.GetGrainlineGeometry().IsVisible())
{
if (detail.GetGrainlineGeometry().IsVisible())
{
m_grainLine->Reset();
}
m_grainLine->Reset();
}
setSelected(selected);
@ -1456,12 +1447,10 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
scene()->clearSelection();
}
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
}
if (selectionType == SelectionType::ByMouseRelease)
@ -1488,13 +1477,10 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
}
if (selectionType == SelectionType::ByMouseRelease)
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
if (IsSelectedByReleaseEvent(this, event))
{
doc->SelectedDetail(m_id);
emit ChoosedTool(m_id, SceneObject::Detail);
}
doc->SelectedDetail(m_id);
emit ChoosedTool(m_id, SceneObject::Detail);
}
QGraphicsPathItem::mouseReleaseEvent(event);
}
@ -2433,12 +2419,9 @@ void VToolSeamAllowance::InitSpecialPoints(const QVector<quint32> &points) const
void VToolSeamAllowance::DeleteToolWithConfirm(bool ask)
{
std::unique_ptr<DeletePiece> delDet(new DeletePiece(doc, m_id, VAbstractTool::data, m_sceneDetails));
if (ask)
if (ask && ConfirmDeletion() == QMessageBox::No)
{
if (ConfirmDeletion() == QMessageBox::No)
{
return;
}
return;
}
VAbstractApplication::VApp()->getUndoStack()->push(delDet.release());

View File

@ -316,16 +316,13 @@ void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
//---------------------------------------------------------------------------------------------------------------------
auto FancyTabBar::event(QEvent *event) -> bool
{
if (event->type() == QEvent::ToolTip)
if (event->type() == QEvent::ToolTip && ValidIndex(m_hoverIndex))
{
if (ValidIndex(m_hoverIndex))
QString const tt = TabToolTip(m_hoverIndex);
if (!tt.isEmpty())
{
QString const tt = TabToolTip(m_hoverIndex);
if (!tt.isEmpty())
{
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
return true;
}
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
return true;
}
}
return QWidget::event(event);

View File

@ -925,14 +925,11 @@ void ColorPickerPopup::showEvent(QShowEvent *)
for (int j = 0; j < grid->rowCount(); ++j)
{
QWidget *w = widgetAt[j][i];
if (w && w->inherits("ColorPickerItem"))
if (w && w->inherits("ColorPickerItem") && static_cast<ColorPickerItem *>(w)->isSelected())
{
if (static_cast<ColorPickerItem *>(w)->isSelected())
{
w->setFocus();
foundSelected = true;
break;
}
w->setFocus();
foundSelected = true;
break;
}
}
}

View File

@ -209,13 +209,11 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick &&
(freeAngle || freeLength))
{
if (freeAngle || freeLength)
{
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
emit Released();
}
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
emit Released();
}
VScenePoint::mouseReleaseEvent(event);
}

View File

@ -290,13 +290,11 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
scene()->clearSelection();
}
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
if (selectionType == SelectionType::ByMouseRelease)
{
@ -315,12 +313,10 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (flags() & QGraphicsItem::ItemIsMovable)
if (flags() & QGraphicsItem::ItemIsMovable && event->button() == Qt::LeftButton &&
event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
}
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
}
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))

View File

@ -162,14 +162,11 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation()
static const auto names = ConvertToSet<QString>(originalNames);
const QString translated = m_trMs->VarToUser(originalName);
if (names.contains(translated))
if (names.contains(translated) && originalName != translated)
{
if (originalName != translated)
{
const QString message = u"Translation repeat original name from other place. "
"Original name:'%1', translated name:'%2'"_s.arg(originalName, translated);
QFAIL(qUtf8Printable(message));
}
const QString message = u"Translation repeat original name from other place. "
"Original name:'%1', translated name:'%2'"_s.arg(originalName, translated);
QFAIL(qUtf8Printable(message));
}
}

View File

@ -324,15 +324,12 @@ void TST_TSLocaleTranslation::TestHTMLTags()
for (const auto &regex : regexes)
{
if (source.contains(regex.first))
if (source.contains(regex.first) &&
(not translation.contains(regex.second) || translation.count(regex.second) != source.count(regex.first)))
{
if (not translation.contains(regex.second) || translation.count(regex.second) != source.count(regex.first))
{
const QString message = u"Tag mismatch. Pattern: '<%1>'. "_s.arg(regex.first.pattern()) +
u"Original name:'%1'"_s.arg(source) +
u", translated name:'%1'"_s.arg(translation);
QFAIL(qUtf8Printable(message));
}
const QString message = u"Tag mismatch. Pattern: '<%1>'. "_s.arg(regex.first.pattern()) +
u"Original name:'%1'"_s.arg(source) + u", translated name:'%1'"_s.arg(translation);
QFAIL(qUtf8Printable(message));
}
}
}