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 QRectF path2Rect = VLayoutPiece::BoundingRect(path2);
const QPainterPath path2Path = VGObject::PainterPath(path2); const QPainterPath path2Path = VGObject::PainterPath(path2);
if (path1Rect.intersects(path2Rect) || path2Rect.contains(path1Rect) || path1Rect.contains(path2Rect)) return (path1Rect.intersects(path2Rect) || path2Rect.contains(path1Rect) || path1Rect.contains(path2Rect)) &&
{ (path1Path.contains(path2Path) || path2Path.contains(path1Path) || path1Path.intersects(path2Path));
if (path1Path.contains(path2Path) || path2Path.contains(path1Path) || path1Path.intersects(path2Path))
{
return true;
}
}
return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -681,11 +674,11 @@ auto VPPiece::StickyPieces(VStickyDistance &match) const -> bool
CastTo(piece->GetMappedExternalContourPoints(), piecePath); CastTo(piece->GetMappedExternalContourPoints(), piecePath);
QRectF const pieceBoundingRect = VLayoutPiece::BoundingRect(piecePath); QRectF const pieceBoundingRect = VLayoutPiece::BoundingRect(piecePath);
if (stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) || if ((stickyZone.intersects(pieceBoundingRect) || pieceBoundingRect.contains(stickyZone) ||
stickyZone.contains(pieceBoundingRect)) stickyZone.contains(pieceBoundingRect)) &&
{ not VPPiece::PathsSuperposition(path, piecePath))
if (not VPPiece::PathsSuperposition(path, piecePath))
{ {
QVector<QPointF> const pieceStickyPath = PrepareStickyPath(piecePath); QVector<QPointF> const pieceStickyPath = PrepareStickyPath(piecePath);
if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath); if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath);
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length()) match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
@ -695,7 +688,6 @@ auto VPPiece::StickyPieces(VStickyDistance &match) const -> bool
} }
} }
} }
}
return true; return true;
} }

View File

@ -255,18 +255,15 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (VPPiecePtr const piece = m_piece.toStrongRef(); not piece.isNull()) 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);
{
auto *command =
new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
SetStickyPoints(QVector<QPointF>()); SetStickyPoints(QVector<QPointF>());
} }
} }
}
m_allowChangeMerge = false; m_allowChangeMerge = false;
m_hasStickyPosition = false; m_hasStickyPosition = false;
@ -1184,9 +1181,7 @@ void VPGraphicsPiece::PieceZValueChanged(const VPPiecePtr &piece)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &value) -> QVariant 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(); VPPiecePtr const piece = m_piece.toStrongRef();
if (not piece.isNull()) if (not piece.isNull())
@ -1200,7 +1195,6 @@ auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &valu
} }
} }
} }
}
return QGraphicsObject::itemChange(change, value); return QGraphicsObject::itemChange(change, value);
} }

View File

@ -305,9 +305,7 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
break; 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(); VPLayoutPtr const layout = m_layout.toStrongRef();
if (layout.isNull()) if (layout.isNull())
@ -322,7 +320,6 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
sheet->SceneData()->RotationControls()->on_HideHandles(false); sheet->SceneData()->RotationControls()->on_HideHandles(false);
} }
} }
}
VMainGraphicsView::keyReleaseEvent(event); VMainGraphicsView::keyReleaseEvent(event);
} }
@ -690,9 +687,7 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
} }
if (const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces(); 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]()
{ {
@ -718,7 +713,6 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
} }
} }
} }
}
m_allowChangeMerge = false; m_allowChangeMerge = false;
m_hasStickyPosition = false; m_hasStickyPosition = false;

View File

@ -163,16 +163,13 @@ void VPUndoPiecesMove::undo()
for (const auto &piece : qAsConst(m_pieces)) for (const auto &piece : qAsConst(m_pieces))
{ {
VPPiecePtr const p = piece.toStrongRef(); 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())); p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
emit layout->PieceTransformationChanged(p); emit layout->PieceTransformationChanged(p);
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPUndoPiecesMove::redo() void VPUndoPiecesMove::redo()

View File

@ -202,9 +202,7 @@ void VPUndoPiecesRotate::undo()
for (const auto &piece : qAsConst(m_pieces)) for (const auto &piece : qAsConst(m_pieces))
{ {
VPPiecePtr const p = piece.toStrongRef(); 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())); p->SetMatrix(m_oldTransforms.value(p->GetUniqueID()));
if (m_followGrainline || p->IsFollowGrainline()) if (m_followGrainline || p->IsFollowGrainline())
@ -215,7 +213,6 @@ void VPUndoPiecesRotate::undo()
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPUndoPiecesRotate::redo() void VPUndoPiecesRotate::redo()

View File

@ -109,16 +109,13 @@ void VPUndoPieceZValueMove::undo()
for (const auto &p : pieces) 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())); p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p); emit layout->PieceZValueChanged(p);
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPUndoPieceZValueMove::redo() void VPUndoPieceZValueMove::redo()
@ -326,16 +323,13 @@ void VPUndoPiecesZValueMove::undo()
for (const auto &p : pieces) 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())); p->SetZValue(m_oldValues.value(p->GetUniqueID()));
emit layout->PieceZValueChanged(p); emit layout->PieceZValueChanged(p);
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPUndoPiecesZValueMove::redo() void VPUndoPiecesZValueMove::redo()

View File

@ -239,11 +239,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
break; 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.setText(msg);
messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok);
@ -257,8 +254,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
#endif #endif
} }
}
}
if (QtFatalMsg == type) if (QtFatalMsg == type)
{ {

View File

@ -216,14 +216,12 @@ void SetPrinterSheetPageSettings(const QSharedPointer<QPrinter> &printer, const
printer->setPageOrientation(sheetOrientation); printer->setPageOrientation(sheetOrientation);
printer->setFullPage(sheet->IgnoreMargins()); 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");
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void SetPrinterTiledPageSettings(const QSharedPointer<QPrinter> &printer, const VPLayoutPtr &layout, void SetPrinterTiledPageSettings(const QSharedPointer<QPrinter> &printer, const VPLayoutPtr &layout,
@ -266,14 +264,12 @@ void SetPrinterTiledPageSettings(const QSharedPointer<QPrinter> &printer, const
printer->setPageOrientation(orientation); printer->setPageOrientation(orientation);
printer->setFullPage(layout->LayoutSettings().IgnoreTilesMargins()); 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");
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto IsValidFileName(const QString &fileName) -> bool auto IsValidFileName(const QString &fileName) -> bool
@ -488,13 +484,10 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(lock, path); 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 try
{ {
@ -803,9 +796,7 @@ void VPMainWindow::ShowFullPieceToggled(bool checked)
if (selectedPieces.size() == 1) if (selectedPieces.size() == 1)
{ {
const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull()) if (not selectedPiece.isNull() && selectedPiece->IsShowFullPiece() != checked)
{
if (selectedPiece->IsShowFullPiece() != checked)
{ {
selectedPiece->SetShowFullPiece(checked); selectedPiece->SetShowFullPiece(checked);
LayoutWasSaved(false); LayoutWasSaved(false);
@ -813,7 +804,6 @@ void VPMainWindow::ShowFullPieceToggled(bool checked)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::ShowMirrorLineToggled(bool checked) void VPMainWindow::ShowMirrorLineToggled(bool checked)
@ -822,9 +812,7 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked)
if (selectedPieces.size() == 1) if (selectedPieces.size() == 1)
{ {
const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull()) if (not selectedPiece.isNull() && selectedPiece->IsShowMirrorLine() != checked)
{
if (selectedPiece->IsShowMirrorLine() != checked)
{ {
selectedPiece->SetShowMirrorLine(checked); selectedPiece->SetShowMirrorLine(checked);
LayoutWasSaved(false); LayoutWasSaved(false);
@ -832,7 +820,6 @@ void VPMainWindow::ShowMirrorLineToggled(bool checked)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked) void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
@ -841,9 +828,7 @@ void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
if (selectedPieces.size() == 1) if (selectedPieces.size() == 1)
{ {
const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull()) if (not selectedPiece.isNull() && selectedPiece->IsVerticallyFlipped() != checked)
{
if (selectedPiece->IsVerticallyFlipped() != checked)
{ {
selectedPiece->FlipVertically(); selectedPiece->FlipVertically();
LayoutWasSaved(false); LayoutWasSaved(false);
@ -851,7 +836,6 @@ void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked) void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked)
@ -860,9 +844,7 @@ void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked)
if (selectedPieces.size() == 1) if (selectedPieces.size() == 1)
{ {
const VPPiecePtr &selectedPiece = selectedPieces.constFirst(); const VPPiecePtr &selectedPiece = selectedPieces.constFirst();
if (not selectedPiece.isNull()) if (not selectedPiece.isNull() && selectedPiece->IsHorizontallyFlipped() != checked)
{
if (selectedPiece->IsHorizontallyFlipped() != checked)
{ {
selectedPiece->FlipHorizontally(); selectedPiece->FlipHorizontally();
LayoutWasSaved(false); LayoutWasSaved(false);
@ -870,7 +852,6 @@ void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPropertyTabCurrentPiece() void VPMainWindow::InitPropertyTabCurrentPiece()
@ -3004,9 +2985,8 @@ auto VPMainWindow::AskLayoutIsInvalid(const QList<VPSheetPtr> &sheets) -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> 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); QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question); msgBox.setIcon(QMessageBox::Question);
@ -3026,16 +3006,14 @@ auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBou
outOfBoundChecked = true; // no need to ask more outOfBoundChecked = true; // no need to ask more
} }
}
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool 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); QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question); msgBox.setIcon(QMessageBox::Question);
@ -3056,7 +3034,6 @@ auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pie
pieceSuperpositionChecked = true; // no need to ask more pieceSuperpositionChecked = true; // no need to ask more
} }
}
return true; return true;
} }
@ -3064,9 +3041,8 @@ auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pie
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPMainWindow::CheckPieceGapePosition(const VPPiecePtr &piece, bool &pieceGapePositionChecked) -> bool 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); QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Question); msgBox.setIcon(QMessageBox::Question);
@ -3087,7 +3063,6 @@ auto VPMainWindow::CheckPieceGapePosition(const VPPiecePtr &piece, bool &pieceGa
pieceGapePositionChecked = true; // no need to ask more pieceGapePositionChecked = true; // no need to ask more
} }
}
return true; return true;
} }
@ -3166,8 +3141,8 @@ auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, co
if (not sheet->IgnoreMargins()) if (not sheet->IgnoreMargins())
{ {
QMarginsF const margins = sheet->GetSheetMargins(); if (QMarginsF const margins = sheet->GetSheetMargins();
if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) 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");
} }

View File

@ -367,33 +367,24 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool
if (m_type == MeasurementsType::Multisize) 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); ChangeColor(ui->labelShiftA, errorColor);
columnShiftAFlag = false; 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); ChangeColor(ui->labelShiftB, errorColor);
columnShiftBFlag = false; 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); ChangeColor(ui->labelShiftC, errorColor);
columnShiftCFlag = false; columnShiftCFlag = false;
} }
} }
}
ChangeColumnColor(ui->labelFullName, columnFullNameFlag, MultisizeMeasurementsColumns::FullName, ChangeColumnColor(ui->labelFullName, columnFullNameFlag, MultisizeMeasurementsColumns::FullName,
IndividualMeasurementsColumns::FullName); IndividualMeasurementsColumns::FullName);

View File

@ -405,16 +405,13 @@ void DialogSetupMultisize::CheckDimension(QGroupBox *group, QGroupBox *nameGroup
return; 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())); ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
return; return;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::CheckState() void DialogSetupMultisize::CheckState()

View File

@ -275,11 +275,8 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
break; 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.setText(VAbstractApplication::ClearMessage(logMsg));
messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok);
@ -293,8 +290,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
#endif #endif
} }
}
}
if (QtFatalMsg == type) if (QtFatalMsg == type)
{ {
@ -898,15 +893,12 @@ void MApplication::RepopulateMeasurementsDatabase(const QString &path)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath) void MApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath)
{ {
if (oldPath != newPath) if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr)
{
if (m_knownMeasurementsDatabase != nullptr)
{ {
RestartKnownMeasurementsDatabaseWatcher(); RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath); RepopulateMeasurementsDatabase(newPath);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MApplication::SyncKnownMeasurements() void MApplication::SyncKnownMeasurements()

View File

@ -196,13 +196,11 @@ auto TKMMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(m_lock, path); 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 try
{ {

View File

@ -433,13 +433,11 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
VlpCreateLock(m_lock, path); 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 try
{ {
@ -4097,13 +4095,11 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool
VlpCreateLock(m_lock, path); 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 try
{ {

View File

@ -287,9 +287,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
if (isGuiThread) 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 // fixme: trying to make sure there are no save/load dialogs are opened, because error message during
// them will lead to crash // them will lead to crash
@ -335,7 +333,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
#endif #endif
} }
} }
}
if (QtFatalMsg == type) if (QtFatalMsg == type)
{ {
@ -783,15 +780,12 @@ void VApplication::RepopulateMeasurementsDatabase(const QString &path)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath) void VApplication::KnownMeasurementsPathChanged(const QString &oldPath, const QString &newPath)
{ {
if (oldPath != newPath) if (oldPath != newPath && m_knownMeasurementsDatabase != nullptr)
{
if (m_knownMeasurementsDatabase != nullptr)
{ {
RestartKnownMeasurementsDatabaseWatcher(); RestartKnownMeasurementsDatabaseWatcher();
RepopulateMeasurementsDatabase(newPath); RepopulateMeasurementsDatabase(newPath);
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VApplication::IsGUIMode() -> bool auto VApplication::IsGUIMode() -> bool

View File

@ -139,14 +139,11 @@ 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"; qCritical() << translate("VCommandLine", "Unsupported layout units.") << "\n";
const_cast<VCommandLine *>(this)->parser.showHelp(V_EX_USAGE); const_cast<VCommandLine *>(this)->parser.showHelp(V_EX_USAGE);
} }
}
if (IsOptionSet(LONG_OPTION_GAPWIDTH)) if (IsOptionSet(LONG_OPTION_GAPWIDTH))
{ {

View File

@ -554,13 +554,10 @@ auto VToolOptionsPropertyBrowser::ComboBoxPalette() const -> QPalette
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) 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) if (m_currentItem == item && item != nullptr)
{ {

View File

@ -192,9 +192,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
for (int i = 0; i < ui->tableWidget->rowCount(); ++i) for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{ {
const quint32 id = ui->tableWidget->item(i, PieceColumn::InLayout)->data(Qt::UserRole).toUInt(); 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); auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece);
@ -202,7 +200,6 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item) void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item)

View File

@ -358,13 +358,10 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::CheckLayout, this, connect(doc, &VPattern::CheckLayout, this,
[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); connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP);
connect(doc, &VPattern::MadeProgress, this, &MainWindow::ShowProgress); connect(doc, &VPattern::MadeProgress, this, &MainWindow::ShowProgress);
@ -2334,29 +2331,20 @@ void MainWindow::StoreMultisizeMDimensions()
QList<MeasurementDimension_p> const dimensions = m_m->Dimensions().values(); 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); StoreMultisizeMDimension(dimensions, 0, m_currentDimensionA);
StoreMultisizeMDimension(dimensions, 1, m_currentDimensionB); StoreMultisizeMDimension(dimensions, 1, m_currentDimensionB);
@ -3909,9 +3897,7 @@ void MainWindow::ActionDetails(bool checked)
ui->actionDetails->setChecked(true); ui->actionDetails->setChecked(true);
ui->actionLayout->setChecked(false); 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"), QMessageBox::information(this, tr("Detail mode"),
tr("You can't use Detail mode yet. " tr("You can't use Detail mode yet. "
@ -3920,7 +3906,6 @@ void MainWindow::ActionDetails(bool checked)
ActionDraw(true); ActionDraw(true);
return; return;
} }
}
m_detailsWidget->UpdateList(); m_detailsWidget->UpdateList();
@ -6782,13 +6767,10 @@ void MainWindow::ExportLayoutAs(bool checked)
auto Uncheck = qScopeGuard([this] { ui->actionLayoutExportAs->setChecked(false); }); 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 try
{ {

View File

@ -400,13 +400,11 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool
} }
if (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) && 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()) if (IsTimeout())
{ {

View File

@ -446,16 +446,13 @@ auto VPattern::SPointActiveDraw() -> quint32
if (not domNode.isNull() && domNode.isElement()) if (not domNode.isNull() && domNode.isElement())
{ {
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (not domElement.isNull()) if (not domElement.isNull() && domElement.tagName() == TagPoint &&
{
if (domElement.tagName() == TagPoint &&
domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType) domElement.attribute(AttrType, QString()) == VToolBasePoint::ToolType)
{ {
return GetParametrId(domElement); return GetParametrId(domElement);
} }
} }
} }
}
return 0; return 0;
} }
@ -1332,14 +1329,11 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse
if (domNode.isElement()) if (domNode.isElement())
{ {
QDomElement domElement = domNode.toElement(); 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(); domNode = domNode.nextSibling();
} }
@ -2903,9 +2897,7 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do
for (qint32 i = 0; i < num; ++i) for (qint32 i = 0; i < num; ++i)
{ {
const QDomElement element = nodeList.at(i).toElement(); 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 kAsm1 = GetParametrDouble(element, AttrKAsm1, QStringLiteral("1.0"));
const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0')); const qreal angle = GetParametrDouble(element, AttrAngle, QChar('0'));
@ -2924,7 +2916,6 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do
} }
} }
} }
}
auto *path = new VSplinePath(points, kCurve); auto *path = new VSplinePath(points, kCurve);
if (duplicate > 0) if (duplicate > 0)
@ -3069,9 +3060,7 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
for (qint32 i = 0; i < num; ++i) for (qint32 i = 0; i < num; ++i)
{ {
const QDomElement element = nodeList.at(i).toElement(); 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 quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline); const VPointF p = *data->GeometricObject<VPointF>(pSpline);
@ -3082,7 +3071,6 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
} }
} }
} }
}
initData.path = new VCubicBezierPath(points); initData.path = new VCubicBezierPath(points);
if (duplicate > 0) if (duplicate > 0)
@ -4187,10 +4175,8 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars
{ {
if (domNode.isElement()) if (domNode.isElement())
{ {
const QDomElement domElement = domNode.toElement(); if (const QDomElement domElement = domNode.toElement();
if (not domElement.isNull()) not domElement.isNull() && domElement.tagName() == TagIncrement)
{
if (domElement.tagName() == TagIncrement)
{ {
const QString name = GetParametrString(domElement, AttrName, QString()).simplified(); const QString name = GetParametrString(domElement, AttrName, QString()).simplified();
const QString desc = GetParametrEmptyString(domElement, AttrDescription); const QString desc = GetParametrEmptyString(domElement, AttrDescription);
@ -4213,7 +4199,6 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars
data->AddUniqueVariable(increment); data->AddUniqueVariable(increment);
} }
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
@ -4514,15 +4499,12 @@ void VPattern::SetLabelPrefix(const QString &prefix)
{ {
QDomElement pattern = documentElement(); 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); SetAttribute(pattern, AttrLabelPrefix, prefix);
modified = true; modified = true;
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::PrepareForParse(const Document &parse) void VPattern::PrepareForParse(const Document &parse)

View File

@ -431,9 +431,8 @@ auto FvUpdater::xmlParseFeed() -> bool
const QXmlStreamAttributes attribs = m_xml.attributes(); const QXmlStreamAttributes attribs = m_xml.attributes();
const auto fervorPlatform = QStringLiteral("fervor:platform"); 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(); xmlEnclosurePlatform = attribs.value(fervorPlatform).toString().trimmed();
@ -459,10 +458,7 @@ auto FvUpdater::xmlParseFeed() -> bool
} }
} }
} }
} else if (m_xml.isEndElement() && m_xml.name() == "item"_L1)
else if (m_xml.isEndElement())
{
if (m_xml.name() == "item"_L1)
{ {
// That's it - we have analyzed a single <item> and we'll stop // That's it - we have analyzed a single <item> and we'll stop
// here (because the topmost is the most recent one, and thus // here (because the topmost is the most recent one, and thus
@ -470,7 +466,6 @@ auto FvUpdater::xmlParseFeed() -> bool
return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform); return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform);
} }
}
if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
{ {
@ -555,14 +550,11 @@ auto FvUpdater::VersionIsIgnored(const QString &version) -> bool
} }
const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion();
if (lastSkippedVersion != 0x0) if (lastSkippedVersion != 0x0 && decVersion == lastSkippedVersion)
{
if (decVersion == lastSkippedVersion)
{ {
// Implicitly skipped version - skip // Implicitly skipped version - skip
return true; return true;
} }
}
if (decVersion > AppVersion()) if (decVersion > AppVersion())
{ {
@ -635,14 +627,11 @@ auto FvUpdater::CurrentlyRunningOnPlatform(const QString &platform) -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMode) 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 // Don't show errors in the silent mode
return; return;
} }
}
QMessageBox dlFailedMsgBox; QMessageBox dlFailedMsgBox;
dlFailedMsgBox.setIcon(QMessageBox::Critical); dlFailedMsgBox.setIcon(QMessageBox::Critical);
@ -653,14 +642,11 @@ void FvUpdater::showErrorDialog(const QString &message, bool showEvenInSilentMod
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void FvUpdater::showInformationDialog(const QString &message, bool showEvenInSilentMode) 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 // Don't show information dialogs in the silent mode
return; return;
} }
}
QMessageBox dlInformationMsgBox; QMessageBox dlInformationMsgBox;
dlInformationMsgBox.setIcon(QMessageBox::Information); dlInformationMsgBox.setIcon(QMessageBox::Information);

View File

@ -443,14 +443,11 @@ auto VAbstractPattern::CheckExistNamePP(const QString &name) const -> bool
for (qint32 i = 0; i < elements.count(); i++) for (qint32 i = 0; i < elements.count(); i++)
{ {
const QDomElement elem = elements.at(i).toElement(); 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; return false;
} }
@ -498,10 +495,8 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{ {
if (domNode.isElement()) if (domNode.isElement())
{ {
const QDomElement domElement = domNode.toElement(); if (const QDomElement domElement = domNode.toElement();
if (not domElement.isNull()) not domElement.isNull() && domElement.tagName() == TagGroup)
{
if (domElement.tagName() == TagGroup)
{ {
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace); VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace);
@ -521,7 +516,6 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
} }
} }
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
@ -562,16 +556,13 @@ auto VAbstractPattern::GetPPElement(const QString &name) -> QDomElement
for (qint32 i = 0; i < elements.count(); i++) for (qint32 i = 0; i < elements.count(); i++)
{ {
QDomElement const element = elements.at(i).toElement(); if (QDomElement const element = elements.at(i).toElement();
if (not element.isNull()) not element.isNull() && element.attribute(AttrName) == name)
{
if (element.attribute(AttrName) == name)
{ {
return element; return element;
} }
} }
} }
}
return QDomElement(); return QDomElement();
} }
@ -2623,10 +2614,8 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
{ {
if (domNode.isElement()) if (domNode.isElement())
{ {
const QDomElement group = domNode.toElement(); if (const QDomElement group = domNode.toElement();
if (not group.isNull()) not group.isNull() && group.tagName() == TagGroup)
{
if (group.tagName() == TagGroup)
{ {
VGroupData groupData; VGroupData groupData;
const quint32 id = GetParametrUInt(group, AttrId, QChar('0')); const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
@ -2658,7 +2647,6 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
data.insert(id, groupData); data.insert(id, groupData);
} }
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
} }
@ -2703,10 +2691,8 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
{ {
if (domNode.isElement()) if (domNode.isElement())
{ {
const QDomElement group = domNode.toElement(); if (const QDomElement group = domNode.toElement();
if (group.isNull() == false) group.isNull() == false && group.tagName() == TagGroup)
{
if (group.tagName() == TagGroup)
{ {
bool const groupHasItem = GroupHasItem(group, toolId, objectId); bool const groupHasItem = GroupHasItem(group, toolId, objectId);
if ((containItem && groupHasItem) || (not containItem && not groupHasItem)) if ((containItem && groupHasItem) || (not containItem && not groupHasItem))
@ -2718,7 +2704,6 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
} }
} }
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
} }

View File

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

View File

@ -643,10 +643,8 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
{ {
if (domNode.isElement()) if (domNode.isElement())
{ {
QDomElement domElement = domNode.toElement(); if (QDomElement domElement = domNode.toElement();
if (not domElement.isNull()) not domElement.isNull() && domElement.tagName() == *strIncrement)
{
if (domElement.tagName() == *strIncrement)
{ {
try try
{ {
@ -669,7 +667,6 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
domElement.removeAttribute(*strBase); domElement.removeAttribute(*strBase);
} }
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
return names; return names;
@ -1627,14 +1624,11 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0()
QDomNode domNode = modeling.firstChild(); QDomNode domNode = modeling.firstChild();
while (not domNode.isNull()) while (not domNode.isNull())
{ {
QDomElement domElement = domNode.toElement(); if (QDomElement domElement = domNode.toElement();
if (not domElement.isNull()) not domElement.isNull() && domElement.hasAttribute(*strTypeObject))
{
if (domElement.hasAttribute(*strTypeObject))
{ {
domElement.removeAttribute(*strTypeObject); domElement.removeAttribute(*strTypeObject);
} }
}
domNode = domNode.nextSibling(); domNode = domNode.nextSibling();
} }
} }

View File

@ -302,14 +302,12 @@ void DRW_Arc::applyExtrusion()
{ {
DRW_Circle::applyExtrusion(); DRW_Circle::applyExtrusion();
if (haveExtrusion)
{
// If the extrusion vector has a z value less than 0, the angles for the arc // 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. // 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 // 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 // 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. // 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) if (haveExtrusion && fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
{ {
staangle = M_PI - staangle; staangle = M_PI - staangle;
endangle = M_PI - endangle; endangle = M_PI - endangle;
@ -319,7 +317,6 @@ void DRW_Arc::applyExtrusion()
endangle = temp; endangle = temp;
} }
} }
}
auto DRW_Arc::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool auto DRW_Arc::parseCode(int code, const std::unique_ptr<dxfReader> &reader) -> bool
{ {

View File

@ -677,9 +677,8 @@ void DRW_Header::write(const std::unique_ptr<dxfWriter> &writer, DRW::Version ve
else else
writer->writeString(1, "STANDARD"); writer->writeString(1, "STANDARD");
// verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000) // 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 // verify valid values from 1 to 6

View File

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

View File

@ -1047,9 +1047,8 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
{ {
ExportNotch(passmark.baseLine.p1(), passmark.baseLine.length(), passmark.baseLine.angle()); 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); const QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
QLineF const baseLine = matrix.map(passmark.baseLine); QLineF const baseLine = matrix.map(passmark.baseLine);
@ -1058,7 +1057,6 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportAAMAGrainline(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportAAMAGrainline(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
@ -1694,9 +1692,8 @@ void VDxfEngine::ExportASTMNotches(const QSharedPointer<dx_ifaceBlock> &detailBl
ExportPassmark(passmark); ExportPassmark(passmark);
const QLineF mirrorLine = detail.GetMappedSeamMirrorLine(); 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 QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
@ -1705,7 +1702,6 @@ void VDxfEngine::ExportASTMNotches(const QSharedPointer<dx_ifaceBlock> &detailBl
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportASTMMirrorLine(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportASTMMirrorLine(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
@ -1776,15 +1772,13 @@ auto VDxfEngine::ExportASTMNotch(const VLayoutPassmark &passmark) -> DRW_ASTMNot
notch->angle = passmark.baseLine.angle(); notch->angle = passmark.baseLine.angle();
PassmarkLineType type = passmark.type; PassmarkLineType type = passmark.type;
if (m_compatibilityMode == DXFApparelCompatibility::RPCADV08 || if ((m_compatibilityMode == DXFApparelCompatibility::RPCADV08 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV09 || m_compatibilityMode == DXFApparelCompatibility::RPCADV09 ||
m_compatibilityMode == DXFApparelCompatibility::RPCADV10) 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) switch (type)
{ {

View File

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

View File

@ -239,15 +239,12 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q
return points; 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)); points.append(QPointF(x3, y3));
return points; return points;
} }
} }
}
break; break;
} }
case 2: case 2:
@ -278,15 +275,12 @@ auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, q
return points; 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)); points.append(QPointF(x2, y2));
return points; return points;
} }
} }
}
break; break;
} }
case 3: case 3:

View File

@ -528,9 +528,8 @@ void VHPGLEngine::PlotPassmarks(QTextStream &out, const VLayoutPiece &detail)
PlotPassmark(passmark); PlotPassmark(passmark);
const QLineF mirrorLine = detail.GetMappedSeamMirrorLine(); 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 QTransform matrix = VGObject::FlippingMatrix(mirrorLine);
const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false); const VLayoutPassmark mirroredPassmark = VLayoutPiece::MapPassmark(passmark, matrix, false);
@ -539,7 +538,6 @@ void VHPGLEngine::PlotPassmarks(QTextStream &out, const VLayoutPiece &detail)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VHPGLEngine::PlotLabels(QTextStream &out, const VLayoutPiece &detail) void VHPGLEngine::PlotLabels(QTextStream &out, const VLayoutPiece &detail)

View File

@ -729,14 +729,11 @@ auto Rollback(QVector<VRawSAPoint> &points, const QLineF &edge) -> bool
points.removeLast(); points.removeLast();
points = VAbstractPiece::RollbackSeamAllowance(points, edge, &success); 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; return success;
} }
@ -866,15 +863,12 @@ 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
} }
} }
} }
}
} // namespace } // namespace
// Friend functions // Friend functions

View File

@ -370,15 +370,12 @@ 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 // Path can't be closed
// See issue #686 // See issue #686
CompareFirstAndLastPoints(p, accuracy); CompareFirstAndLastPoints(p, accuracy);
} }
}
return p; return p;
} }

View File

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

View File

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

View File

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

View File

@ -605,14 +605,11 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
rows = rowCount(); rows = rowCount();
cols = columnCount(); cols = columnCount();
QString data; 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(); error = dest->errorString();
return false; return false;
} }
}
QTextStream stream(dest); QTextStream stream(dest);
if (codec) if (codec)

View File

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

View File

@ -240,9 +240,8 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector<VNodeDetail> &no
for (int i = 0; i < nodes.size(); ++i) for (int i = 0; i < nodes.size(); ++i)
{ {
const VNodeDetail &node = nodes.at(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 previosPoint = path.NodePreviousPoint(data, i);
const QPointF nextPoint = path.NodeNextPoint(data, i); const QPointF nextPoint = path.NodeNextPoint(data, i);
@ -263,7 +262,6 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector<VNodeDetail> &no
} }
} }
} }
}
if (not closed && path.CountNodes() > 1) if (not closed && path.CountNodes() > 1)
{ {

View File

@ -365,9 +365,7 @@ auto VPiece::PassmarksPath(const VContainer *data) const -> QPainterPath
QPainterPath path; QPainterPath path;
// seam allowence // 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)
{ {
@ -377,7 +375,6 @@ auto VPiece::PassmarksPath(const VContainer *data) const -> QPainterPath
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
} }
}
return path; return path;
} }

View File

@ -221,9 +221,7 @@ template <class T> inline auto VPiece::SeamAllowancePath(const QVector<T> &point
QPainterPath ekv; QPainterPath ekv;
// seam allowence // seam allowence
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not points.isEmpty())
{
if (not points.isEmpty())
{ {
ekv.moveTo(points.at(0)); ekv.moveTo(points.at(0));
for (qint32 i = 1; i < points.count(); ++i) for (qint32 i = 1; i < points.count(); ++i)
@ -250,7 +248,6 @@ template <class T> inline auto VPiece::SeamAllowancePath(const QVector<T> &point
ekv.setFillRule(Qt::WindingFill); ekv.setFillRule(Qt::WindingFill);
} }
}
return ekv; return ekv;
} }

View File

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

View File

@ -53,9 +53,7 @@ VPE::VShortcutEditWidget::~VShortcutEditWidget()
auto VPE::VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event) -> bool 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); auto *keyEvent = static_cast<QKeyEvent *>(event);
@ -69,7 +67,6 @@ auto VPE::VShortcutEditWidget::eventFilter(QObject *obj, QEvent *event) -> bool
return true; return true;
} }
} }
}
return QWidget::eventFilter(obj, event); return QWidget::eventFilter(obj, event);
} }

View File

@ -126,14 +126,11 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 t
// Disable Qt::WaitCursor // Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR #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; restoreCursor = true;
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
} }
}
#endif #endif
ui->tableWidget->setColumnCount(2); ui->tableWidget->setColumnCount(2);
ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers); ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);

View File

@ -369,16 +369,12 @@ void DialogArc::SetRadius(const QString &value)
*/ */
void DialogArc::ChosenObject(quint32 id, const SceneObject &type) 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 (SetObject(id, ui->comboBoxBasePoint, QString()))
{ {
if (vis != nullptr) if (vis != nullptr)
{ {
auto *window = auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
@ -394,8 +390,6 @@ void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::ShowVisualization() void DialogArc::ShowVisualization()

View File

@ -353,16 +353,12 @@ void DialogArcWithLength::ShowDialog(bool click)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type) 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 (SetObject(id, ui->comboBoxCenter, QString()))
{ {
if (vis != nullptr) if (vis != nullptr)
{ {
auto *window = auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
@ -378,8 +374,6 @@ void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::DeployRadiusTextEdit() void DialogArcWithLength::DeployRadiusTextEdit()

View File

@ -213,15 +213,13 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: 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++; m_number++;
line->SetPoint2Id(id); line->SetPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case 2: case 2:
ChosenThirdPoint(id); ChosenThirdPoint(id);
@ -439,9 +437,7 @@ void DialogBisector::ChosenThirdPoint(quint32 id)
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id); 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()); auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
@ -460,7 +456,6 @@ void DialogBisector::ChosenThirdPoint(quint32 id)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::FinishCreating() void DialogBisector::FinishCreating()

View File

@ -122,9 +122,7 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type) 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); auto *path = qobject_cast<VisToolCubicBezier *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
@ -157,9 +155,7 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 3: case 3:
if (getCurrentObjectId(ui->comboBoxP1) != id) if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString()))
{
if (SetObject(id, ui->comboBoxP4, QString()))
{ {
++number; ++number;
@ -168,14 +164,12 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type)
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezier::PointNameChanged() void DialogCubicBezier::PointNameChanged()

View File

@ -190,10 +190,9 @@ void DialogCubicBezierPath::ShowDialog(bool click)
} }
const auto size = path.CountPoints(); 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
{ // Accept only if all subpaths are completed
emit ToolTip(QString()); emit ToolTip(QString());
if (not data->IsUnique(path.name())) if (not data->IsUnique(path.name()))
@ -204,7 +203,6 @@ void DialogCubicBezierPath::ShowDialog(bool click)
DialogAccepted(); DialogAccepted();
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezierPath::ShowVisualization() void DialogCubicBezierPath::ShowVisualization()

View File

@ -261,10 +261,9 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
switch (number) switch (number)
{ {
case (0): case (0):
if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc || if ((type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::ElArc ||
type == SceneObject::SplinePath) type == SceneObject::SplinePath) &&
{ SetObject(id, ui->comboBoxCurve, tr("Select axis point")))
if (SetObject(id, ui->comboBoxCurve, tr("Select axis point")))
{ {
number++; number++;
line->VisualMode(id); line->VisualMode(id);
@ -273,12 +272,9 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip); connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
} }
}
break; break;
case (1): 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->setAxisPointId(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -292,7 +288,6 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
show(); show();
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -172,9 +172,7 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
return; 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)
{ {
@ -206,7 +204,6 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SaveData() void DialogCutArc::SaveData()

View File

@ -175,9 +175,7 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
return; 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)
{ {
@ -195,7 +193,6 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::SaveData() void DialogCutSpline::SaveData()

View File

@ -175,9 +175,7 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
return; 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)
{ {
@ -195,7 +193,6 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SaveData() void DialogCutSplinePath::SaveData()

View File

@ -206,11 +206,8 @@ void DialogEndLine::FXLength()
*/ */
void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) 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 (SetObject(id, ui->comboBoxBasePoint, QString()))
{ {
if (vis != nullptr) if (vis != nullptr)
{ {
@ -227,8 +224,6 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View File

@ -260,9 +260,7 @@ void DialogFlippingByAxis::SetSourceObjects(const QVector<SourceItem> &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type) 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(), auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; }); [id](const SourceItem &sItem) { return sItem.id == id; });
@ -284,7 +282,6 @@ void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SelectedObject(bool selected, quint32 object, quint32 tool) void DialogFlippingByAxis::SelectedObject(bool selected, quint32 object, quint32 tool)

View File

@ -253,9 +253,7 @@ void DialogFlippingByLine::SetSourceObjects(const QVector<SourceItem> &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type) 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(), auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; }); [id](const SourceItem &sItem) { return sItem.id == id; });
@ -284,11 +282,8 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
return; return;
} }
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id) if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id &&
{ SetObject(id, ui->comboBoxSecondLinePoint, QString()) && flagError)
if (SetObject(id, ui->comboBoxSecondLinePoint, QString()))
{
if (flagError)
{ {
number = 0; number = 0;
prepare = true; prepare = true;
@ -298,15 +293,12 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
operation->SetSecondLinePointId(id); operation->SetSecondLinePointId(id);
operation->RefreshGeometry(); operation->RefreshGeometry();
} }
}
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32 tool) void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32 tool)

View File

@ -208,15 +208,13 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case (1): 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++; m_number++;
line->SetLineP1Id(id); line->SetLineP1Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case (2): case (2):
{ {
@ -225,9 +223,7 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxP1Line)); set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id); 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->SetLineP2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -235,7 +231,6 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
DialogAccepted(); DialogAccepted();
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -178,9 +178,7 @@ void DialogLine::SaveData()
*/ */
void DialogLine::ChosenObject(quint32 id, const SceneObject &type) 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)
{ {
@ -195,25 +193,19 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) if (getCurrentObjectId(ui->comboBoxFirstPoint) != id &&
{ SetObject(id, ui->comboBoxSecondPoint, QString()) && flagError)
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
{
if (flagError)
{ {
number = 0; number = 0;
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View File

@ -108,9 +108,7 @@ DialogLineIntersect::~DialogLineIntersect()
*/ */
void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) 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); auto *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
@ -125,15 +123,13 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxP1Line1) != id) if (getCurrentObjectId(ui->comboBoxP1Line1) != id &&
{ SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{ {
number++; number++;
line->SetLine1P2Id(id); line->SetLine1P2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case 2: case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
@ -151,9 +147,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxP1Line2)); set.insert(getCurrentObjectId(ui->comboBoxP1Line2));
set.insert(id); set.insert(id);
if (set.size() >= 3) if (set.size() >= 3 && SetObject(id, ui->comboBoxP2Line2, QString()))
{
if (SetObject(id, ui->comboBoxP2Line2, QString()))
{ {
line->SetLine2P2Id(id); line->SetLine2P2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -179,14 +173,12 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersect::SaveData() void DialogLineIntersect::SaveData()

View File

@ -277,9 +277,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) 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); auto *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
@ -298,15 +296,13 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case (1): case (1):
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id) if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id &&
{ SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
{ {
number++; number++;
line->SetPoint2Id(id); line->SetPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case (2): case (2):
{ {
@ -315,9 +311,7 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint)); set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
set.insert(id); set.insert(id);
if (set.size() == 3) if (set.size() == 3 && SetObject(id, ui->comboBoxAxisPoint, QString()))
{
if (SetObject(id, ui->comboBoxAxisPoint, QString()))
{ {
line->SetAxisPointId(id); line->SetAxisPointId(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -331,14 +325,12 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::EvalAngle() void DialogLineIntersectAxis::EvalAngle()

View File

@ -402,11 +402,9 @@ void DialogMove::ShowDialog(bool click)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMove::ChosenObject(quint32 id, const SceneObject &type) 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 &&
if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier) SetObject(id, ui->comboBoxRotationOriginPoint, QString())) // After first choose we ignore all objects
{
if (SetObject(id, ui->comboBoxRotationOriginPoint, QString()))
{ {
auto *operation = qobject_cast<VisToolMove *>(vis); auto *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
@ -416,8 +414,6 @@ void DialogMove::ChosenObject(quint32 id, const SceneObject &type)
optionalRotationOrigin = true; optionalRotationOrigin = true;
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool) void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)

View File

@ -218,9 +218,8 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: 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->SetPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -236,7 +235,6 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
FinishCreating(); FinishCreating();
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -145,9 +145,8 @@ void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type) 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); auto *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr) SCASSERT(point != nullptr)
@ -155,19 +154,14 @@ void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &t
switch (number) switch (number)
{ {
case 0: case 0:
if (type == SceneObject::Point) if (type == SceneObject::Point && SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
{
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
{ {
number++; number++;
point->VisualMode(id); point->VisualMode(id);
} }
}
break; break;
case 1: case 1:
if (type == SceneObject::Arc) if (type == SceneObject::Arc && SetObject(id, ui->comboBoxArc, QString()))
{
if (SetObject(id, ui->comboBoxArc, QString()))
{ {
number = 0; number = 0;
point->SetArcId(id); point->SetArcId(id);
@ -175,14 +169,12 @@ void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &t
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::ShowVisualization() void DialogPointFromArcAndTangent::ShowVisualization()

View File

@ -254,9 +254,8 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
} }
break; break;
case 1: 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 = auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow()); qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
@ -273,7 +272,6 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
FinishCreating(); FinishCreating();
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -244,15 +244,13 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: 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++; m_number++;
line->SetLineP2Id(id); line->SetLineP2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case 2: case 2:
{ {
@ -261,12 +259,9 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id); 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());
{
auto *window =
qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
@ -280,7 +275,6 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -117,9 +117,7 @@ void DialogPointOfIntersection::SetSecondPointId(quint32 value)
*/ */
void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) 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); auto *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
@ -135,23 +133,20 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
} }
break; break;
case 1: 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->SetPoint2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersection::SaveData() void DialogPointOfIntersection::SaveData()

View File

@ -150,9 +150,7 @@ void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint p)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type) 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); auto *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr) SCASSERT(point != nullptr)
@ -167,9 +165,7 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxArc1) != id) if (getCurrentObjectId(ui->comboBoxArc1) != id && SetObject(id, ui->comboBoxArc2, QString()))
{
if (SetObject(id, ui->comboBoxArc2, QString()))
{ {
number = 0; number = 0;
point->SetArc2Id(id); point->SetArc2Id(id);
@ -177,14 +173,12 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ArcChanged() void DialogPointOfIntersectionArcs::ArcChanged()

View File

@ -330,9 +330,8 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec
} }
break; break;
case 2: 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->SetCircle2Id(id);
point->RefreshGeometry(); point->RefreshGeometry();
@ -345,7 +344,6 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec
return; return;
} }
} }
}
break; break;
default: default:
break; break;

View File

@ -178,10 +178,8 @@ void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject &type) 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); auto *point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
SCASSERT(point != nullptr) SCASSERT(point != nullptr)
@ -196,9 +194,7 @@ void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxCurve1) != id) if (getCurrentObjectId(ui->comboBoxCurve1) != id && SetObject(id, ui->comboBoxCurve2, QString()))
{
if (SetObject(id, ui->comboBoxCurve2, QString()))
{ {
number = 0; number = 0;
point->SetCurve2Id(id); point->SetCurve2Id(id);
@ -206,14 +202,12 @@ void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::ShowVisualization() void DialogPointOfIntersectionCurves::ShowVisualization()

View File

@ -321,9 +321,7 @@ void DialogRotation::SetSourceObjects(const QVector<SourceItem> &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type) 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); auto *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr) SCASSERT(operation != nullptr)
@ -360,7 +358,6 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool) void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)

View File

@ -212,15 +212,13 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: 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++; m_number++;
line->SetLineP1Id(id); line->SetLineP1Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case 2: case 2:
ChosenThirdPoint(id); ChosenThirdPoint(id);
@ -281,9 +279,7 @@ void DialogShoulderPoint::ChosenThirdPoint(quint32 id)
set.insert(getCurrentObjectId(ui->comboBoxP1Line)); set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id); 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()); auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr) SCASSERT(window != nullptr)
@ -302,7 +298,6 @@ void DialogShoulderPoint::ChosenThirdPoint(quint32 id)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::FinishCreating() void DialogShoulderPoint::FinishCreating()

View File

@ -159,9 +159,7 @@ DialogSpline::~DialogSpline()
*/ */
void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) 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); auto *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
@ -177,9 +175,7 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
break; break;
case 1: case 1:
{ {
if (getCurrentObjectId(ui->comboBoxP1) != id) if (getCurrentObjectId(ui->comboBoxP1) != id && SetObject(id, ui->comboBoxP4, QString()))
{
if (SetObject(id, ui->comboBoxP4, QString()))
{ {
++number; ++number;
@ -187,7 +183,6 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
path->RefreshGeometry(); path->RefreshGeometry();
prepare = true; prepare = true;
} }
}
break; break;
} }
default: default:
@ -195,7 +190,6 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSpline::SaveData() void DialogSpline::SaveData()

View File

@ -207,14 +207,11 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const
QMap<QString, quint32> list; QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i) 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); FillList(box, list);
box->setCurrentIndex(-1); // force to select box->setCurrentIndex(-1); // force to select
box->blockSignals(false); box->blockSignals(false);
@ -231,14 +228,11 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
QMap<QString, quint32> list; QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i) 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); FillList(box, list);
box->setCurrentIndex(-1); // force to select box->setCurrentIndex(-1); // force to select
box->blockSignals(false); box->blockSignals(false);

View File

@ -99,9 +99,7 @@ DialogTriangle::~DialogTriangle()
*/ */
void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) 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); auto *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
@ -116,15 +114,13 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case (1): case (1):
if (getCurrentObjectId(ui->comboBoxAxisP1) != id) if (getCurrentObjectId(ui->comboBoxAxisP1) != id &&
{ SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
{ {
number++; number++;
line->SetObject2Id(id); line->SetObject2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
}
break; break;
case (2): case (2):
{ {
@ -133,16 +129,13 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(id); set.insert(id);
if (set.size() == 3) if (set.size() == 3 && SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{ {
number++; number++;
line->SetHypotenuseP1Id(id); line->SetHypotenuseP1Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
} }
}
break; break;
case (3): case (3):
{ {
@ -152,9 +145,7 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(id); set.insert(id);
if (set.size() == 4) if (set.size() == 4 && SetObject(id, ui->comboBoxSecondPoint, QString()))
{
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
{ {
line->SetHypotenuseP2Id(id); line->SetHypotenuseP2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
@ -162,14 +153,12 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
DialogAccepted(); DialogAccepted();
} }
} }
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTriangle::SaveData() void DialogTriangle::SaveData()

View File

@ -217,9 +217,7 @@ void DialogTrueDarts::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) 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); auto *points = qobject_cast<VisToolTrueDarts *>(vis);
SCASSERT(points != nullptr) SCASSERT(points != nullptr)
@ -234,15 +232,13 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id) if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id &&
{ SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point")))
if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point")))
{ {
number++; number++;
points->SetBaseLineP2Id(id); points->SetBaseLineP2Id(id);
points->RefreshGeometry(); points->RefreshGeometry();
} }
}
break; break;
case 2: case 2:
{ {
@ -251,15 +247,12 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint)); set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
set.insert(id); set.insert(id);
if (set.size() == 3) if (set.size() == 3 && SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point")))
{
if (SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point")))
{ {
number++; number++;
points->SetD1PointId(id); points->SetD1PointId(id);
points->RefreshGeometry(); points->RefreshGeometry();
} }
}
break; break;
} }
case 3: case 3:
@ -270,15 +263,12 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint)); set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
set.insert(id); set.insert(id);
if (set.size() == 4) if (set.size() == 4 && SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point")))
{
if (SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point")))
{ {
number++; number++;
points->SetD2PointId(id); points->SetD2PointId(id);
points->RefreshGeometry(); points->RefreshGeometry();
} }
}
break; break;
} }
case 4: case 4:
@ -290,16 +280,13 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint)); set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
set.insert(id); set.insert(id);
if (set.size() == 5) if (set.size() == 5 && SetObject(id, ui->comboBoxThirdDartPoint, QString()))
{
if (SetObject(id, ui->comboBoxThirdDartPoint, QString()))
{ {
points->SetD3PointId(id); points->SetD3PointId(id);
points->RefreshGeometry(); points->RefreshGeometry();
prepare = true; prepare = true;
DialogAccepted(); DialogAccepted();
} }
}
break; break;
} }
default: default:
@ -307,7 +294,6 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTrueDarts::PointNameChanged() void DialogTrueDarts::PointNameChanged()

View File

@ -133,9 +133,7 @@ auto DialogUnionDetails::CheckDetail(const quint32 &idDetail) const -> bool
*/ */
void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, vsizetype &index) 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))
{ {
@ -147,7 +145,6 @@ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &typ
emit ToolTip(tr("Workpiece should have at least two points and three objects")); emit ToolTip(tr("Workpiece should have at least two points and three objects"));
return; return;
} }
}
if (not CheckObject(id, idDetail)) if (not CheckObject(id, idDetail))
{ {

View File

@ -55,9 +55,7 @@ DialogDuplicateDetail::~DialogDuplicateDetail()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDuplicateDetail::ShowDialog(bool click) void DialogDuplicateDetail::ShowDialog(bool click)
{ {
if (prepare) if (prepare && click)
{
if (click)
{ {
// The check need to ignore first release of mouse button. // The check need to ignore first release of mouse button.
// User should have chance to place piece. // User should have chance to place piece.
@ -76,14 +74,11 @@ void DialogDuplicateDetail::ShowDialog(bool click)
DialogAccepted(); DialogAccepted();
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type) 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; m_idDetail = id;
@ -101,4 +96,3 @@ void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type)
prepare = true; prepare = true;
} }
} }
}

View File

@ -211,9 +211,7 @@ void DialogPiecePath::ChosenObject(quint32 id, const SceneObject &type)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ShowDialog(bool click) void DialogPiecePath::ShowDialog(bool click)
{ {
if (not click) if (not click && CreatePath().CountNodes() > 0)
{
if (CreatePath().CountNodes() > 0)
{ {
emit ToolTip(QString()); emit ToolTip(QString());
prepare = true; prepare = true;
@ -229,7 +227,6 @@ void DialogPiecePath::ShowDialog(bool click)
show(); show();
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::CheckState() void DialogPiecePath::CheckState()

View File

@ -122,11 +122,7 @@ void DialogPin::SetPiecesList(const QVector<quint32> &list)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPin::ChosenObject(quint32 id, const SceneObject &type) 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 (SetObject(id, ui->comboBoxPoint, QString()))
{ {
if (vis != nullptr) if (vis != nullptr)
{ {
@ -138,8 +134,6 @@ void DialogPin::ChosenObject(quint32 id, const SceneObject &type)
this->show(); this->show();
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPin::ShowVisualization() void DialogPin::ShowVisualization()

View File

@ -244,11 +244,7 @@ void DialogPlaceLabel::SetPiecesList(const QVector<quint32> &list)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type) 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 (SetObject(id, ui->comboBoxPoint, QString()))
{ {
if (vis != nullptr) if (vis != nullptr)
{ {
@ -265,8 +261,6 @@ void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
this->show(); this->show();
} }
} }
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::ShowVisualization() void DialogPlaceLabel::ShowVisualization()

View File

@ -312,13 +312,11 @@ void VBackgroundImageItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (not Image().Hold()) 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) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{ {
@ -589,13 +587,10 @@ void VBackgroundImageItem::MakeFresh() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VBackgroundImageItem::DeleteToolWithConfirm(bool ask) void VBackgroundImageItem::DeleteToolWithConfirm(bool ask)
{ {
if (ask) if (ask && ConfirmDeletion() == QMessageBox::No)
{
if (ConfirmDeletion() == QMessageBox::No)
{ {
return; return;
} }
}
emit ActivateControls(QUuid()); emit ActivateControls(QUuid());
emit DeleteImage(m_image.Id()); emit DeleteImage(m_image.Id());

View File

@ -388,36 +388,26 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) 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); SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
oldPosition = event->scenePos(); oldPosition = event->scenePos();
event->accept(); event->accept();
} }
}
}
VAbstractSpline::mousePressEvent(event); VAbstractSpline::mousePressEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSpline::mouseReleaseEvent(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); VAbstractSpline::mouseReleaseEvent(event);
} }

View File

@ -594,9 +594,8 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event) 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(); oldPosition = event->scenePos();
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id); const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(m_id);
@ -607,23 +606,20 @@ void VToolSplinePath::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->accept(); event->accept();
} }
} }
}
VAbstractSpline::mousePressEvent(event); VAbstractSpline::mousePressEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::mouseReleaseEvent(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(); oldPosition = event->scenePos();
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
CurveReleased(); CurveReleased();
} }
}
VAbstractSpline::mouseReleaseEvent(event); VAbstractSpline::mouseReleaseEvent(event);
} }

View File

@ -295,27 +295,23 @@ void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *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); SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept(); event->accept();
} }
}
VToolSinglePoint::mousePressEvent(event); VToolSinglePoint::mousePressEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::mouseReleaseEvent(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); VToolSinglePoint::mouseReleaseEvent(event);
} }

View File

@ -242,13 +242,10 @@ void VToolSinglePoint::FullUpdateFromFile()
*/ */
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 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); VScenePoint::mouseReleaseEvent(event);
} }

View File

@ -965,28 +965,19 @@ void VToolSeamAllowance::ResetChildren(QGraphicsItem *pItem)
const bool selected = isSelected(); const bool selected = isSelected();
const VPiece detail = VAbstractTool::data.GetPiece(m_id); const VPiece detail = VAbstractTool::data.GetPiece(m_id);
auto *pVGI = qgraphicsitem_cast<VTextGraphicsItem *>(pItem); 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 && detail.GetPatternLabelData().IsVisible())
if (pVGI != m_patternInfo)
{
if (detail.GetPatternLabelData().IsVisible())
{ {
m_patternInfo->Reset(); m_patternInfo->Reset();
} }
}
auto *pGLI = qgraphicsitem_cast<VGrainlineItem *>(pItem); 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); setSelected(selected);
update(); update();
@ -1456,13 +1447,11 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
scene()->clearSelection(); 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) if (selectionType == SelectionType::ByMouseRelease)
{ {
@ -1488,14 +1477,11 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
} }
if (selectionType == SelectionType::ByMouseRelease) if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
if (IsSelectedByReleaseEvent(this, event))
{ {
doc->SelectedDetail(m_id); doc->SelectedDetail(m_id);
emit ChoosedTool(m_id, SceneObject::Detail); emit ChoosedTool(m_id, SceneObject::Detail);
} }
}
QGraphicsPathItem::mouseReleaseEvent(event); QGraphicsPathItem::mouseReleaseEvent(event);
} }
@ -2433,13 +2419,10 @@ void VToolSeamAllowance::InitSpecialPoints(const QVector<quint32> &points) const
void VToolSeamAllowance::DeleteToolWithConfirm(bool ask) void VToolSeamAllowance::DeleteToolWithConfirm(bool ask)
{ {
std::unique_ptr<DeletePiece> delDet(new DeletePiece(doc, m_id, VAbstractTool::data, m_sceneDetails)); 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()); VAbstractApplication::VApp()->getUndoStack()->push(delDet.release());

View File

@ -316,9 +316,7 @@ void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto FancyTabBar::event(QEvent *event) -> bool 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); QString const tt = TabToolTip(m_hoverIndex);
if (!tt.isEmpty()) if (!tt.isEmpty())
@ -327,7 +325,6 @@ auto FancyTabBar::event(QEvent *event) -> bool
return true; return true;
} }
} }
}
return QWidget::event(event); return QWidget::event(event);
} }

View File

@ -925,9 +925,7 @@ void ColorPickerPopup::showEvent(QShowEvent *)
for (int j = 0; j < grid->rowCount(); ++j) for (int j = 0; j < grid->rowCount(); ++j)
{ {
QWidget *w = widgetAt[j][i]; 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(); w->setFocus();
foundSelected = true; foundSelected = true;
@ -935,7 +933,6 @@ void ColorPickerPopup::showEvent(QShowEvent *)
} }
} }
} }
}
if (!foundSelected) if (!foundSelected)
{ {

View File

@ -209,14 +209,12 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::mouseReleaseEvent(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); SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
emit Released(); emit Released();
} }
}
VScenePoint::mouseReleaseEvent(event); VScenePoint::mouseReleaseEvent(event);
} }

View File

@ -290,14 +290,12 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
scene()->clearSelection(); 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);
event->accept(); event->accept();
} }
}
if (selectionType == SelectionType::ByMouseRelease) if (selectionType == SelectionType::ByMouseRelease)
{ {
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
@ -315,13 +313,11 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mouseReleaseEvent(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)) if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{ {

View File

@ -162,16 +162,13 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation()
static const auto names = ConvertToSet<QString>(originalNames); static const auto names = ConvertToSet<QString>(originalNames);
const QString translated = m_trMs->VarToUser(originalName); 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. " const QString message = u"Translation repeat original name from other place. "
"Original name:'%1', translated name:'%2'"_s.arg(originalName, translated); "Original name:'%1', translated name:'%2'"_s.arg(originalName, translated);
QFAIL(qUtf8Printable(message)); QFAIL(qUtf8Printable(message));
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TST_AbstractRegExp::CallTestForValidCharacters() void TST_AbstractRegExp::CallTestForValidCharacters()

View File

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