48 #include "ui_mainwindow.h"
49 #include "../vgeometry/vspline.h"
50 #include "../ifc/exception/vexceptionobjecterror.h"
51 #include "../ifc/exception/vexceptionconversionerror.h"
52 #include "../ifc/exception/vexceptionemptyparameter.h"
53 #include "../ifc/exception/vexceptionwrongid.h"
54 #include "../ifc/exception/vexceptionundo.h"
57 #include "../vmisc/customevents.h"
58 #include "../vmisc/vsettings.h"
59 #include "../vmisc/def.h"
60 #include "../vmisc/qxtcsvmodel.h"
61 #include "../vmisc/dialogs/dialogexporttocsv.h"
65 #include "../ifc/xml/vpatternconverter.h"
66 #include "../vmisc/logging.h"
67 #include "../vformat/vmeasurements.h"
68 #include "../ifc/xml/vvstconverter.h"
69 #include "../ifc/xml/vvitconverter.h"
70 #include "../vwidgets/vwidgetpopup.h"
71 #include "../vwidgets/vmaingraphicsscene.h"
72 #include "../vwidgets/mouse_coordinates.h"
73 #include "../vtools/tools/drawTools/drawtools.h"
74 #include "../vtools/dialogs/tooldialogs.h"
81 #include "../vtools/undocommands/addgroup.h"
82 #include "../vtools/undocommands/label/showpointname.h"
83 #include "../vpatterndb/vpiecepath.h"
84 #include "../qmuparser/qmuparsererror.h"
85 #include "../vtools/dialogs/support/editlabeltemplate_dialog.h"
87 #include <QInputDialog>
89 #include <QMessageBox>
92 #include <QFileDialog>
93 #include <QSourceLocation>
100 #include <QDesktopWidget>
101 #include <QDesktopServices>
104 #include <QFileSystemWatcher>
106 #include <QFontComboBox>
107 #include <QTextCodec>
108 #include <QDoubleSpinBox>
110 #if defined(Q_OS_MAC)
116 QT_WARNING_DISABLE_CLANG(
"-Wmissing-prototypes")
117 QT_WARNING_DISABLE_INTEL(1418)
119 Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow")
127 const QString
strCtrl = QStringLiteral("Ctrl");
137 , watcher(new QFileSystemWatcher(this))
138 , currentTool(
Tool::Arrow)
139 , lastUsedTool(
Tool::Arrow)
140 , draftScene(
nullptr)
141 , pieceScene(
nullptr)
142 , mouseCoordinates(
nullptr)
143 , infoToolButton(
nullptr)
145 , isInitialized(false)
147 , mChangesAsked(true)
148 , patternReadOnly(false)
149 , dialogTable(
nullptr)
151 , historyDialog(
nullptr)
152 , fontComboBox(
nullptr)
153 , fontSizeComboBox(
nullptr)
154 , draftBlockComboBox(
nullptr)
155 , draftBlockLabel(
nullptr)
156 , mode(
Draw::Calculation)
157 , currentBlockIndex(0)
158 , currentToolBoxIndex(0)
159 , isToolOptionsDockVisible(true)
160 , isGroupsDockVisible(true)
161 , isLayoutsDockVisible(false)
162 , isToolboxDockVisible(true)
165 , separatorAct(
nullptr)
166 , leftGoToStage(
nullptr)
167 , rightGoToStage(
nullptr)
168 , autoSaveTimer(
nullptr)
170 , gradationHeights(
nullptr)
171 , gradationSizes(
nullptr)
172 , gradationHeightsLabel(
nullptr)
173 , gradationSizesLabel(
nullptr)
174 , toolProperties(
nullptr)
175 , groupsWidget(
nullptr)
176 , patternPiecesWidget(
nullptr)
178 , zoomScaleSpinBox(
nullptr)
179 , m_penToolBar(
nullptr)
180 , m_penReset(
nullptr)
181 , m_zoomToPointComboBox(
nullptr)
183 for (
int i = 0; i < MaxRecentFiles; ++i)
185 recentFileActs[i] =
nullptr;
190 doc =
new VPattern(pattern, &mode, draftScene, pieceScene);
197 if (pattern->DataPieces()->count() == 0)
199 if(not ui->showDraftMode->isChecked())
207 this->updateZoomToPointComboBox(draftPointNamesList());
209 qApp->setCurrentDocument(doc);
210 qApp->setCurrentData(pattern);
215 initPointNameToolBar();
220 helpLabel =
new QLabel(QObject::tr(
"Create new pattern piece to start working."));
221 ui->statusBar->addWidget(helpLabel);
229 ui->draft_ToolBox->setCurrentIndex(0);
232 initToolBarVisibility();
240 connect(
qApp, &QApplication::focusChanged,
this, [
this](QWidget *old, QWidget *now)
242 if (old ==
nullptr && isAncestorOf(now) ==
true)
244 static bool asking =
false;
245 if (not asking && mChanges && not mChangesAsked)
248 mChangesAsked =
true;
249 const auto answer = QMessageBox::question(
this, tr(
"Measurements"),
250 tr(
"Measurements were changed. Do you want to sync measurements now?"),
251 QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
252 if (answer == QMessageBox::Yes)
265 #if defined(Q_OS_MAC)
267 ui->draft_ToolBar->setIconSize(QSize(24, 24));
268 ui->mode_ToolBar->setIconSize(QSize(24, 24));
269 ui->edit_Toolbar->setIconSize(QSize(24, 24));
270 ui->zoom_ToolBar->setIconSize(QSize(24, 24));
272 setUnifiedTitleAndToolBarOnMac(
true);
275 QMenu *menu =
new QMenu(
this);
277 QAction *newPattern_Action = menu->addAction(tr(
"New pattern"));
278 newPattern_Action->setMenuRole(QAction::NoRole);
279 connect(newPattern_Action, &QAction::triggered,
this, &
MainWindow::New);
281 QAction *openPattern_Action = menu->addAction(tr(
"Open pattern"));
282 openPattern_Action->setMenuRole(QAction::NoRole);
285 QAction *openSeamlyMe_Action = menu->addAction(tr(
"Create/Edit measurements"));
286 openSeamlyMe_Action->setMenuRole(QAction::NoRole);
287 connect(openSeamlyMe_Action, &QAction::triggered,
this, &MainWindow::CreateMeasurements);
289 QAction *appPreferences_Action = menu->addAction(tr(
"Preferences"));
290 appPreferences_Action->setMenuRole(QAction::NoRole);
293 menu->setAsDockMenu();
302 qCDebug(vMainWindow,
"Error creating draft block with the name %s.", qUtf8Printable(blockName));
318 ui->view->itemClicked(
nullptr);
321 VPointF *point =
new VPointF(startPosition.x(), startPosition.y(), label, 5, 10);
324 ui->view->itemClicked(spoint);
342 ui->view->zoom100Percent();
344 ui->newDraft_Action->setEnabled(
true);
352 const qreal originX = 30.0;
353 const qreal originY = 40.0;
354 const qreal margin = 40.0;
358 if (rect.width() <= rect.height())
360 return QPointF(rect.width()+margin, originY);
364 return QPointF(originX, rect.height()+margin);
369 return QPointF(originX, originY);
421 QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
422 policy.setHorizontalStretch(12);
423 ui->view->setSizePolicy(policy);
424 qApp->setSceneView(
ui->view);
441 measurements->setXMLContent(path);
445 VException e(tr(
"Measurement file has unknown format."));
452 measurements->setXMLContent(converter.
Convert());
457 measurements->setXMLContent(converter.
Convert());
460 if (not measurements->IsDefinedKnownNamesValid())
462 VException e(tr(
"Measurement file contains invalid known measurement(s)."));
472 qCCritical(vMainWindow,
"%s\n\n%s", qUtf8Printable(tr(
"Wrong units.")),
473 qUtf8Printable(tr(
"Application doesn't support multisize table with inches.")));
474 measurements->clear();
485 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"File error.")),
487 measurements->clear();
502 if (measurements->isNull())
509 qWarning()<<tr(
"Gradation doesn't support inches");
515 qApp->setPatternType(measurements->Type());
518 measurements->ReadMeasurements();
522 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"File error.")),
534 *measurements->GetData()->GetPatternUnit()));
536 *measurements->GetData()->GetPatternUnit()));
554 if (measurements->isNull())
559 if (
qApp->patternType() != measurements->Type())
561 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"Measurement files types have not match.")));
572 measurements->ReadMeasurements();
576 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"File error.")),
604 auto tempMeasurements = measurements->
ListAll();
606 const QSet<QString> match = QSet<QString>(docMeasurements.begin(), docMeasurements.end()).
607 subtract(QSet<QString>(tempMeasurements.begin(), tempMeasurements.end()));
608 if (not match.isEmpty())
611 for (
int i = 0; i < list.size(); ++i)
613 list[i] =
qApp->TrVars()->MToUser(list.at(i));
616 VException e(tr(
"Measurement file doesn't include all the required measurements."));
617 e.
AddMoreInformation(tr(
"Please provide additional measurements: %1").arg(QStringList(list).join(
", ")));
631 template <
typename Dialog,
typename Func>
633 Func closeDialogSlot)
640 auto cursorResource = cursor;
641 if (
qApp->devicePixelRatio() >= 2)
644 auto cursorHidpiResource = QString(cursor).replace(
".png",
"@2x.png");
645 if (QFileInfo(cursorResource).exists())
647 cursorResource = cursorHidpiResource;
650 QPixmap pixmap(cursorResource);
651 QCursor cur(pixmap, 2, 2);
652 ui->view->viewport()->setCursor(cur);
654 ui->view->setShowToolOptions(
false);
660 dialogTool->setWindowTitle(
"Point - Intersect Arc and Axis");
681 ui->view->itemClicked(
nullptr);
685 if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender()))
687 tButton->setChecked(
true);
693 template <
typename Dialog,
typename Func,
typename Func2>
704 Func closeDialogSlot, Func2 applyDialogSlot)
708 SetToolButton<Dialog>(checked, t, cursor, toolTip, closeDialogSlot);
714 if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender()))
716 tButton->setChecked(
true);
725 template <
typename DrawTool>
729 if (result == QDialog::Accepted)
734 QGraphicsItem *tool =
dynamic_cast<QGraphicsItem *
>(DrawTool::Create(
dialogTool, scene,
doc,
pattern));
736 ui->view->itemClicked(tool);
746 template <
typename DrawTool>
750 if (result == QDialog::Accepted)
752 ApplyDialog<DrawTool>(scene);
755 DrawTool *vtool = qobject_cast<DrawTool *>(
dialogTool->GetAssociatedTool());
756 if (
dialogTool->GetAssociatedTool() !=
nullptr)
759 vtool->DialogLinkDestroy();
763 ui->view->itemClicked(vtool);
779 template <
typename DrawTool>
785 if (
dialogTool->GetAssociatedTool() ==
nullptr)
793 DrawTool * vtool = qobject_cast<DrawTool *>(
dialogTool->GetAssociatedTool());
795 vtool->FullUpdateFromGuiApply();
800 template <
typename DrawTool>
803 ClosedDialogWithApply<DrawTool>(result,
draftScene);
807 template <
typename DrawTool>
814 template <
typename DrawTool>
817 ClosedDialogWithApply<DrawTool>(result,
pieceScene);
820 ui->anchorPoint_ToolButton->setEnabled(
true);
821 ui->internalPath_ToolButton->setEnabled(
true);
822 ui->insertNodes_ToolButton->setEnabled(
true);
823 ui->anchorPoint_Action->setEnabled(
true);
824 ui->internalPath_Action->setEnabled(
true);
825 ui->insertNodes_Action->setEnabled(
true);
830 template <
typename DrawTool>
842 SetToolButtonWithApply<DialogAlongLine>
846 ":/cursor/midpoint_cursor.png",
847 tr(
"<b>Tool::Point - Midpoint on Line</b>: Select first point"),
848 &MainWindow::ClosedDrawDialogWithApply<VToolAlongLine>,
849 &MainWindow::ApplyDrawDialog<VToolAlongLine>
861 SetToolButtonWithApply<DialogEndLine>
865 ":/cursor/endline_cursor.png",
866 tr(
"<b>Tool::Point - Length and Angle</b>: Select point"),
867 &MainWindow::ClosedDrawDialogWithApply<VToolEndLine>,
868 &MainWindow::ApplyDrawDialog<VToolEndLine>
880 SetToolButtonWithApply<DialogAlongLine>
884 ":/cursor/alongline_cursor.png",
885 tr(
"<b>Tool::Point - On Line:</b> Select first point"),
886 &MainWindow::ClosedDrawDialogWithApply<VToolAlongLine>,
887 &MainWindow::ApplyDrawDialog<VToolAlongLine>
899 SetToolButtonWithApply<DialogNormal>
903 ":/cursor/normal_cursor.png",
904 tr(
"<b>Tool::Point - On Perpendicular:</b> Select first point of line"),
905 &MainWindow::ClosedDrawDialogWithApply<VToolNormal>,
906 &MainWindow::ApplyDrawDialog<VToolNormal>
918 SetToolButtonWithApply<DialogBisector>
922 ":/cursor/bisector_cursor.png",
923 tr(
"<b>Tool::Point - On Bisector:</b> Select first point of angle"),
924 &MainWindow::ClosedDrawDialogWithApply<VToolBisector>,
925 &MainWindow::ApplyDrawDialog<VToolBisector>
937 SetToolButtonWithApply<DialogShoulderPoint>
941 ":/cursor/shoulder_cursor.png",
942 tr(
"<b>Tool::Point - Length to Line:</b> Select point"),
943 &MainWindow::ClosedDrawDialogWithApply<VToolShoulderPoint>,
944 &MainWindow::ApplyDrawDialog<VToolShoulderPoint>
956 SetToolButtonWithApply<DialogPointOfContact>
959 ":/cursor/pointcontact_cursor.png",
960 tr(
"<b>Tool::Point - Intersect Arc and Line:</b> Select first point of line"),
961 &MainWindow::ClosedDrawDialogWithApply<VToolPointOfContact>,
962 &MainWindow::ApplyDrawDialog<VToolPointOfContact>
974 SetToolButtonWithApply<DialogTriangle>
978 ":/cursor/triangle_cursor.png",
979 tr(
"<b>Tool::Point - Intersect Axis and Triangle:</b> Select first point of axis"),
980 &MainWindow::ClosedDrawDialogWithApply<VToolTriangle>,
981 &MainWindow::ApplyDrawDialog<VToolTriangle>
993 SetToolButtonWithApply<PointIntersectXYDialog>
997 ":/cursor/pointofintersect_cursor.png",
998 tr(
"<b>Tool::Point - Intersect XY</b> Select point for X value (vertical)"),
999 &MainWindow::ClosedDrawDialogWithApply<PointIntersectXYTool>,
1000 &MainWindow::ApplyDrawDialog<PointIntersectXYTool>
1012 SetToolButtonWithApply<DialogHeight>
1016 ":/cursor/height_cursor.png",
1017 tr(
"<b>Tool::Point - Intersect Line and Perpendicular:</b> Select base point"),
1018 &MainWindow::ClosedDrawDialogWithApply<VToolHeight>,
1019 &MainWindow::ApplyDrawDialog<VToolHeight>
1027 SetToolButtonWithApply<DialogLineIntersectAxis>
1031 ":/cursor/line_intersect_axis_cursor.png",
1032 tr(
"<b>Tool::Point - Intersect Line and Axis:</b> Select first point of line"),
1033 &MainWindow::ClosedDrawDialogWithApply<VToolLineIntersectAxis>,
1034 &MainWindow::ApplyDrawDialog<VToolLineIntersectAxis>
1047 SetToolButtonWithApply<DialogLine>
1051 ":/cursor/line_cursor.png",
1052 tr(
"<b>Tool::Line:</b>:Select first point"),
1053 &MainWindow::ClosedDrawDialogWithApply<VToolLine>,
1054 &MainWindow::ApplyDrawDialog<VToolLine>
1066 SetToolButtonWithApply<DialogLineIntersect>
1070 ":/cursor/intersect_cursor.png",
1071 tr(
"<b>Tool::Point - Intersect Lines:</b> Select first point of first line"),
1072 &MainWindow::ClosedDrawDialogWithApply<VToolLineIntersect>,
1073 &MainWindow::ApplyDrawDialog<VToolLineIntersect>
1086 SetToolButtonWithApply<DialogSpline>
1090 ":/cursor/spline_cursor.png",
1091 tr(
"<b>Tool::Curve - Interactive:</b> Select start point of curve"),
1092 &MainWindow::ClosedDrawDialogWithApply<VToolSpline>,
1093 &MainWindow::ApplyDrawDialog<VToolSpline>
1105 SetToolButtonWithApply<DialogSplinePath>
1109 ":/cursor/splinepath_cursor.png",
1110 tr(
"<b>Tool::Spline - Interactive:</b> Select start point of spline"),
1111 &MainWindow::ClosedDrawDialogWithApply<VToolSplinePath>,
1112 &MainWindow::ApplyDrawDialog<VToolSplinePath>
1120 SetToolButtonWithApply<DialogCubicBezier>
1124 ":/cursor/cubic_bezier_cursor.png",
1125 tr(
"<b>Tool::Curve - Fixed:</b> Select first point of curve"),
1126 &MainWindow::ClosedDrawDialogWithApply<VToolCubicBezier>,
1127 &MainWindow::ApplyDrawDialog<VToolCubicBezier>
1135 SetToolButtonWithApply<DialogCubicBezierPath>
1139 ":/cursor/cubic_bezier_path_cursor.png",
1140 tr(
"<b>Tool::Spline - Fixed:</b> Select first point of spline"),
1141 &MainWindow::ClosedDrawDialogWithApply<VToolCubicBezierPath>,
1142 &MainWindow::ApplyDrawDialog<VToolCubicBezierPath>
1154 SetToolButtonWithApply<DialogCutSpline>
1158 ":/cursor/spline_cut_point_cursor.png",
1159 tr(
"<b>Tool::Point - On Curve:</b> Select first point of curve"),
1160 &MainWindow::ClosedDrawDialogWithApply<VToolCutSpline>,
1161 &MainWindow::ApplyDrawDialog<VToolCutSpline>
1173 SetToolButtonWithApply<DialogCutSplinePath>
1177 ":/cursor/splinepath_cut_point_cursor.png",
1178 tr(
"<b>Tool::Point - On Spline:</b> Select spline"),
1179 &MainWindow::ClosedDrawDialogWithApply<VToolCutSplinePath>,
1180 &MainWindow::ApplyDrawDialog<VToolCutSplinePath>
1188 SetToolButtonWithApply<DialogPointOfIntersectionCurves>
1192 "://cursor/intersection_curves_cursor.png",
1193 tr(
"<b>Tool::Point - Intersect Curves:</b> Select first curve"),
1194 &MainWindow::ClosedDrawDialogWithApply<VToolPointOfIntersectionCurves>,
1195 &MainWindow::ApplyDrawDialog<VToolPointOfIntersectionCurves>
1203 SetToolButtonWithApply<DialogCurveIntersectAxis>
1207 ":/cursor/curve_intersect_axis_cursor.png",
1208 tr(
"<b>Tool::Point - Intersect Curve and Axis:</b> Select curve"),
1209 &MainWindow::ClosedDrawDialogWithApply<VToolCurveIntersectAxis>,
1210 &MainWindow::ApplyDrawDialog<VToolCurveIntersectAxis>
1223 SetToolButtonWithApply<DialogArc>
1227 ":/cursor/arc_cursor.png",
1228 tr(
"<b>Tool::Arc - Radius and Angles:</b> Select point of center of arc"),
1229 &MainWindow::ClosedDrawDialogWithApply<VToolArc>,
1230 &MainWindow::ApplyDrawDialog<VToolArc>
1242 SetToolButtonWithApply<DialogCutArc>
1246 ":/cursor/arc_cut_cursor.png",
1247 tr(
"<b>Tool::Point - On Arc:</b> Select arc"),
1248 &MainWindow::ClosedDrawDialogWithApply<VToolCutArc>,
1249 &MainWindow::ApplyDrawDialog<VToolCutArc>
1258 SetToolButtonWithApply<DialogCurveIntersectAxis>
1262 ":/cursor/arc_intersect_axis_cursor.png",
1263 tr(
"<b>Tool::Point - Intersect Arc and Axis:</b> Select arc"),
1264 &MainWindow::ClosedDrawDialogWithApply<VToolCurveIntersectAxis>,
1265 &MainWindow::ApplyDrawDialog<VToolCurveIntersectAxis>
1273 SetToolButtonWithApply<DialogPointOfIntersectionArcs>
1277 "://cursor/point_of_intersection_arcs.png",
1278 tr(
"<b>Tool::Point - Intersect Arcs:</b> Select first an arc"),
1279 &MainWindow::ClosedDrawDialogWithApply<VToolPointOfIntersectionArcs>,
1280 &MainWindow::ApplyDrawDialog<VToolPointOfIntersectionArcs>
1288 SetToolButtonWithApply<IntersectCirclesDialog>
1292 "://cursor/point_of_intersection_circles.png",
1293 tr(
"<b>Tool::Point - Intersect Circles:</b> Select first circle center"),
1294 &MainWindow::ClosedDrawDialogWithApply<IntersectCirclesTool>,
1295 &MainWindow::ApplyDrawDialog<IntersectCirclesTool>
1305 SetToolButtonWithApply<IntersectCircleTangentDialog>
1309 "://cursor/point_from_circle_and_tangent_cursor.png",
1310 tr(
"<b>Tool::Point - Intersect Circle and Tangent:</b> Select point on tangent"),
1311 &MainWindow::ClosedDrawDialogWithApply<IntersectCircleTangentTool>,
1312 &MainWindow::ApplyDrawDialog<IntersectCircleTangentTool>
1320 SetToolButtonWithApply<DialogPointFromArcAndTangent>
1324 "://cursor/point_from_arc_and_tangent_cursor.png",
1325 tr(
"<b>Tool::Point - Intersect Arc and Tangent:</b> Select point on tangent"),
1326 &MainWindow::ClosedDrawDialogWithApply<VToolPointFromArcAndTangent>,
1327 &MainWindow::ApplyDrawDialog<VToolPointFromArcAndTangent>
1335 SetToolButtonWithApply<DialogArcWithLength>
1339 "://cursor/arc_with_length_cursor.png",
1340 tr(
"<b>Tool::Arc - Radius and Length:</b> Select point of the center of the arc"),
1341 &MainWindow::ClosedDrawDialogWithApply<VToolArcWithLength>,
1342 &MainWindow::ApplyDrawDialog<VToolArcWithLength>
1355 SetToolButtonWithApply<DialogEllipticalArc>
1359 ":/cursor/el_arc_cursor.png",
1360 tr(
"<b>Tool::Arc - Elliptical:</b> Select point of center of elliptical arc"),
1361 &MainWindow::ClosedDrawDialogWithApply<VToolEllipticalArc>,
1362 &MainWindow::ApplyDrawDialog<VToolEllipticalArc>
1371 const QString tooltip = tr(
"<b>Tool::Operations - Create Group:</b> Select one or more objects -"
1372 " Hold <b>%1</b> for multiple selection, "
1373 "Press <b>ENTER</b> to finish group creation ")
1375 strCtrl.toUtf8().constData()));
1376 SetToolButton<AddToGroupDialog>
1380 ":/cursor/group_cursor.png",
1390 if (result == QDialog::Accepted)
1395 QString gName = dialog->getName();
1400 QMessageBox::information(
this, tr(
"Add Group Objects"), tr(
"Group is Locked. Unlock to add objects"),
1401 QMessageBox::Ok, QMessageBox::Ok);
1411 const QString tooltip = tr(
"<b>Tool::Operations - Rotation:</b> Select one or more objects -"
1412 " Hold <b>%1</b> for multiple selection, "
1413 "Press <b>ENTER</b> to confirm selection")
1415 strCtrl.toUtf8().constData()));
1416 SetToolButtonWithApply<DialogRotation>
1420 ":/cursor/rotation_cursor.png",
1422 &MainWindow::ClosedDrawDialogWithApply<VToolRotation>,
1423 &MainWindow::ApplyDrawDialog<VToolRotation>
1431 const QString tooltip = tr(
"<b>Tool::Operations - Mirror by Line:</b> Select one or more objects -"
1432 " Hold <b>%1</b> for multiple selection, "
1433 "Press <b>ENTER</b> to confirm selection")
1435 strCtrl.toUtf8().constData()));
1436 SetToolButtonWithApply<DialogMirrorByLine>
1440 ":/cursor/mirror_by_line_cursor.png",
1441 tooltip, &MainWindow::ClosedDrawDialogWithApply<VToolMirrorByLine>,
1442 &MainWindow::ApplyDrawDialog<VToolMirrorByLine>
1450 const QString tooltip = tr(
"<b>Tool::Operations - Mirror by Axis:</b> Select one or more objects -"
1451 " Hold <b>%1</b> for multiple selection, "
1452 "Press <b>ENTER</b> to confirm selection")
1454 strCtrl.toUtf8().constData()));
1455 SetToolButtonWithApply<DialogMirrorByAxis>
1459 ":/cursor/mirror_by_axis_cursor.png",
1461 &MainWindow::ClosedDrawDialogWithApply<VToolMirrorByAxis>,
1462 &MainWindow::ApplyDrawDialog<VToolMirrorByAxis>
1470 const QString tooltip = tr(
"<b>Tool::Operations - Move:</b> Select one or more objects -"
1471 " Hold <b>%1</b> for multiple selection, "
1472 "Press <b>ENTER</b> to confirm selection")
1474 strCtrl.toUtf8().constData()));
1475 SetToolButtonWithApply<DialogMove>
1479 ":/cursor/move_cursor.png",
1481 &MainWindow::ClosedDrawDialogWithApply<VToolMove>,
1482 &MainWindow::ApplyDrawDialog<VToolMove>
1490 SetToolButtonWithApply<DialogTrueDarts>
1494 "://cursor/true_darts_cursor.png",
1495 tr(
"<b>Tool::Operations - TrueDarts:</b> Select the first base line point"),
1496 &MainWindow::ClosedDrawDialogWithApply<VToolTrueDarts>,
1497 &MainWindow::ApplyDrawDialog<VToolTrueDarts>
1509 SetToolButtonWithApply<PatternPieceDialog>
1513 ":/cursor/new_piece_cursor.png",
1514 tr(
"<b>Tool::Piece - Add New Pattern Piece:</b> Select main path of objects clockwise."),
1515 &MainWindow::ClosedPiecesDialogWithApply<PatternPieceTool>,
1516 &MainWindow::applyPiecesDialog<PatternPieceTool>
1524 SetToolButton<AnchorPointDialog>
1528 ":/cursor/anchor_point_cursor.png",
1529 tr(
"<b>Tool::Piece - Add Anchor Point:</b> Select anchor point"),
1537 if (result == QDialog::Accepted)
1549 SetToolButton<DialogInternalPath>
1553 ":/cursor/path_cursor.png",
1554 tr(
"<b>Tool::Piece - Internal Path:</b> Select path objects, use <b>SHIFT</b> to reverse curve direction"),
1563 if (result == QDialog::Accepted)
1575 const QString tooltip = tr(
"<b>Tool::Piece - Insert Nodes:</b> Select one or more objects -"
1576 " Hold <b>%1</b> for multiple selection, "
1577 "Press <b>ENTER</b> to confirm selection")
1579 strCtrl.toUtf8().constData()));
1580 SetToolButton<InsertNodesDialog>
1584 "://cursor/insert_nodes_cursor.png",
1594 if (result == QDialog::Accepted)
1612 SetToolButton<UnionDialog>
1616 ":/cursor/union_cursor.png",
1617 tr(
"<b>Tool::Details - Union:</b> Select pattern piece"),
1629 ClosedDialog<UnionTool>(result);
1699 qCDebug(vMainWindow,
"Add Selected items to Group.");
1709 QMainWindow::showEvent( event );
1710 if ( event->spontaneous() )
1729 if (event->type() == QEvent::LanguageChange)
1732 ui->retranslateUi(
this);
1735 helpLabel->setText(QObject::tr(
"Changes applied."));
1741 QMainWindow::changeEvent(event);
1751 qCDebug(vMainWindow,
"Closing main window");
1757 QApplication::closeAllWindows();
1761 qCDebug(vMainWindow,
"Closing canceled.");
1771 qApp->getUndoStack()->undo();
1782 ui->listWidget->clear();
1790 for (
int i=1; i<=
scenes.size(); ++i)
1792 QListWidgetItem *item =
new QListWidgetItem(
ScenePreview(i-1), QString::number(i));
1793 ui->listWidget->addItem(item);
1796 if (not
scenes.isEmpty())
1798 ui->listWidget->setCurrentRow(0);
1823 for (i = increments.constBegin(); i != increments.constEnd(); ++i)
1826 map.insert(incr->getIndex(), i.key());
1829 qint32 currentRow = -1;
1830 QMapIterator<quint32, QString> iMap(map);
1831 while (iMap.hasNext())
1838 csv.
setText(currentRow, 0, incr->GetName());
1839 csv.
setText(currentRow, 1,
qApp->LocaleToString(*incr->GetValue()));
1844 formula =
qApp->TrVars()->FormulaToUser(incr->GetFormula(),
qApp->Settings()->GetOsSeparator());
1849 formula = incr->GetFormula();
1852 csv.
setText(currentRow, 2, formula);
1860 QString file = tr(
"untitled");
1861 if(!
qApp->getFilePath().isEmpty())
1863 QString filePath =
qApp->getFilePath();
1864 file = QFileInfo(filePath).baseName();
1872 const QString filter = tr(
"Individual measurements") + QLatin1String(
" (*.vit);;") + tr(
"Multisize measurements") +
1873 QLatin1String(
" (*.vst)");
1875 const QString path =
qApp->Seamly2DSettings()->GetPathIndividualMeasurements();
1877 bool usedNotExistedDir =
false;
1878 QDir directory(path);
1879 if (not directory.exists())
1881 usedNotExistedDir = directory.mkpath(
".");
1884 const QString mPath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), path, filter,
nullptr,
1885 QFileDialog::DontUseNativeDialog);
1887 if (not mPath.isEmpty())
1895 ui->unloadMeasurements_Action->setEnabled(
true);
1899 ui->editCurrent_Action->setEnabled(
true);
1900 helpLabel->setText(tr(
"Measurements loaded"));
1907 if (usedNotExistedDir)
1909 QDir directory(path);
1910 directory.rmpath(
".");
1917 const QString filter = tr(
"Multisize measurements") + QLatin1String(
" (*.vst);;") + tr(
"Individual measurements") +
1918 QLatin1String(
"(*.vit)");
1920 QString path =
qApp->Seamly2DSettings()->GetPathMultisizeMeasurements();
1922 const QString mPath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), path, filter,
nullptr,
1923 QFileDialog::DontUseNativeDialog);
1925 if (not mPath.isEmpty())
1944 ui->unloadMeasurements_Action->setEnabled(
true);
1948 ui->editCurrent_Action->setEnabled(
true);
1949 helpLabel->setText(tr(
"Measurements loaded"));
1975 ui->unloadMeasurements_Action->setDisabled(
true);
1990 ui->editCurrent_Action->setEnabled(
false);
1991 ui->unloadMeasurements_Action->setDisabled(
true);
1992 helpLabel->setText(tr(
"Measurements unloaded"));
1998 qCWarning(vMainWindow,
"%s",
1999 qUtf8Printable(tr(
"Couldn't unload measurements. Some of them are used in the pattern.")));
2010 QStringList arguments;
2013 arguments = QStringList()
2024 arguments = QStringList() << absoluteMPath
2034 const QString seamlyme =
qApp->SeamlyMeFilePath();
2035 const QString workingDirectory = QFileInfo(seamlyme).absoluteDir().absolutePath();
2036 QProcess::startDetached(seamlyme, arguments, workingDirectory);
2040 ui->editCurrent_Action->setEnabled(
false);
2048 QFileInfo checkFile(path);
2049 if (checkFile.exists())
2056 for(
int i=0; i<=1000; i=i+10)
2058 if (checkFile.exists())
2066 std::this_thread::sleep_for(std::chrono::milliseconds(10));
2072 ui->syncMeasurements_Action->setEnabled(
mChanges);
2083 if (not
watcher->files().contains(path))
2087 const QString msg = tr(
"Measurements have been synced");
2088 qCDebug(vMainWindow,
"%s", qUtf8Printable(msg));
2095 ui->syncMeasurements_Action->setEnabled(
mChanges);
2099 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"Couldn't sync measurements.")));
2105 #if defined(Q_OS_MAC)
2106 void MainWindow::OpenAt(QAction *where)
2108 const QString path =
qApp->getFilePath().left(
qApp->getFilePath().indexOf(where->text())) + where->text();
2109 if (path ==
qApp->getFilePath())
2114 process.start(QStringLiteral(
"/usr/bin/open"), QStringList() << path, QIODevice::ReadOnly);
2115 process.waitForFinished();
2161 connect(
gradationHeights.data(),
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
2170 connect(
gradationSizes.data(),
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
2186 QComboBox *comboBox =
new QComboBox(
this);
2187 comboBox->addItems(list);
2188 ui->statusBar->addPermanentWidget(label);
2189 ui->statusBar->addPermanentWidget(comboBox);
2198 leftGoToStage->setPixmap(QPixmap(
"://icon/24x24/fast_forward_left_to_right_arrow.png"));
2202 rightGoToStage->setPixmap(QPixmap(
"://icon/24x24/left_to_right_arrow.png"));
2213 fontComboBox->setCurrentFont(
qApp->Seamly2DSettings()->getPointNameFont());
2214 ui->pointName_ToolBar->insertWidget(
ui->showPointNames_Action,
fontComboBox);
2215 fontComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
2218 connect(
fontComboBox,
static_cast<void (QFontComboBox::*)(
const QFont &)
>(&QFontComboBox::currentFontChanged),
2219 this, [
this](QFont font)
2221 qApp->Seamly2DSettings()->setPointNameFont(font);
2258 if (index < 0 || index > 28)
2264 connect(
fontSizeComboBox, &QComboBox::currentTextChanged,
this, [
this](QString text)
2266 qApp->Seamly2DSettings()->setPointNameSize(text.toInt());
2287 connect(
draftBlockComboBox,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
2290 connect(
ui->renameDraft_Action, &QAction::triggered,
this, [
this]()
2292 const QString activeDraftBlock = doc->getActiveDraftBlockName();
2293 const QString draftBlockName = createDraftBlockName(activeDraftBlock);
2294 if (draftBlockName.isEmpty())
2299 qApp->getUndoStack()->push(draftBlock);
2312 zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn));
2313 zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier));
2314 ui->zoomIn_Action->setShortcuts(zoomInShortcuts);
2318 zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut));
2319 zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier));
2320 ui->zoomOut_Action->setShortcuts(zoomOutShortcuts);
2324 zoom100PercentShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0));
2325 zoom100PercentShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier));
2326 ui->zoom100Percent_Action->setShortcuts(zoom100PercentShortcuts);
2330 zoomToFitShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal));
2331 ui->zoomToFit_Action->setShortcuts(zoomToFitShortcuts);
2335 zoomToSelectedShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Right));
2336 ui->zoomToSelected_Action->setShortcuts(zoomToSelectedShortcuts);
2340 zoomToPreviousShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Left));
2341 ui->zoomToPrevious_Action->setShortcuts(zoomToPreviousShortcuts);
2345 zoomToAreaShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_A));
2346 ui->zoomToArea_Action->setShortcuts(zoomToAreaShortcuts);
2353 zoomToPointShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::AltModifier + Qt::Key_P));
2354 ui->zoomToPoint_Action->setShortcuts(zoomToPointShortcuts);
2379 connect(
zoomScaleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
2380 this,[
this](
double d){
ui->view->zoomByScale(d/100.0);});
2387 connect(
ui->tools_ToolBox_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2389 ui->tools_ToolBox_ToolBar->setVisible(visible);
2390 qApp->Settings()->setShowToolsToolBar(visible);
2392 connect(
ui->points_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2394 ui->points_ToolBar->setVisible(visible);
2395 qApp->Settings()->setShowPointToolBar(visible);
2397 connect(
ui->lines_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2399 ui->lines_ToolBar->setVisible(visible);
2400 qApp->Settings()->setShowLineToolBar(visible);
2402 connect(
ui->curves_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2404 ui->curves_ToolBar->setVisible(visible);
2405 qApp->Settings()->setShowCurveToolBar(visible);
2407 connect(
ui->arcs_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2409 ui->arcs_ToolBar->setVisible(visible);
2410 qApp->Settings()->setShowArcToolBar(visible);
2412 connect(
ui->operations_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2414 ui->operations_ToolBar->setVisible(visible);
2415 qApp->Settings()->setShowOpsToolBar(visible);
2417 connect(
ui->pieces_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2419 ui->pieces_ToolBar->setVisible(visible);
2420 qApp->Settings()->setShowPieceToolBar(visible);
2422 connect(
ui->details_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2424 ui->details_ToolBar->setVisible(visible);
2425 qApp->Settings()->setShowDetailsToolBar(visible);
2427 connect(
ui->layout_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
2429 ui->layout_ToolBar->setVisible(visible);
2430 qApp->Settings()->setShowLayoutToolBar(visible);
2445 m_penToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
2476 toolbar->blockSignals(
true);
2477 toolbar->setVisible(visible);
2478 toolbar->blockSignals(
false);
2486 qCDebug(vMainWindow,
"Value %f\n", (qreal(qFloor(scale*1000)/10.0)));
2498 QGraphicsItem *item =
qApp->getCurrentScene()->focusItem();
2500 if ((item !=
nullptr) && (item->type() == QGraphicsItem::UserType +
static_cast<int>(
Tool::Piece)))
2503 rect = item->boundingRect();
2504 rect.translate(item->scenePos());
2505 ui->view->zoomToRect(rect);
2525 ui->view->zoomToAreaEnabled(checked);
2527 if (
ui->zoomToArea_Action->isChecked())
2529 ui->zoomPan_Action->setChecked(
false);
2536 ui->view->zoomPanEnabled(checked);
2539 ui->zoomToArea_Action->setChecked(
false);
2552 QString pointName = QInputDialog::getItem(
this, tr(
"Zoom to Point"), tr(
"Point:"), pointNames, 0,
true, &ok,
2553 Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
2554 if (!ok || pointName.isEmpty())
return;
2569 for (i = objects->constBegin(); i != objects->constEnd(); ++i)
2572 const quint32 objectId =
object->getIdObject();
2573 const QString objectName =
object->name();
2575 if (objectName == pointName)
2578 ui->view->zoom100Percent();
2591 tool->setPointNameVisiblity(toolId,
true);
2616 connect(
ui->pointAtDistanceAngle_ToolButton, &QToolButton::clicked,
2643 connect(
ui->pointOfIntersectionArcs_ToolButton, &QToolButton::clicked,
2645 connect(
ui->pointOfIntersectionCircles_ToolButton, &QToolButton::clicked,
2647 connect(
ui->pointOfIntersectionCurves_ToolButton, &QToolButton::clicked,
2649 connect(
ui->pointFromCircleAndTangent_ToolButton, &QToolButton::clicked,
2651 connect(
ui->pointFromArcAndTangent_ToolButton, &QToolButton::clicked,
2671 qCDebug(vMainWindow,
"Points Menu selected. \n");
2675 QAction *action_PointAtDA = menu.addAction(QIcon(
":/toolicon/32x32/segment.png"), tr(
"Length and Angle") +
"\tL, A");
2676 QAction *action_PointAlongLine = menu.addAction(QIcon(
":/toolicon/32x32/along_line.png"), tr(
"On Line") +
"\tO, L");
2677 QAction *action_Midpoint = menu.addAction(QIcon(
":/toolicon/32x32/midpoint.png"), tr(
"Midpoint") +
"\tShift+O, Shift+L");
2678 QAction *action_AlongPerpendicular = menu.addAction(QIcon(
":/toolicon/32x32/normal.png"), tr(
"On Perpendicular") +
"\tO, P");
2679 QAction *action_Bisector = menu.addAction(QIcon(
":/toolicon/32x32/bisector.png"), tr(
"On Bisector") +
"\tO, B");
2680 QAction *action_Shoulder = menu.addAction(QIcon(
":/toolicon/32x32/shoulder.png"), tr(
"Length to Line") +
"\tP, S");
2681 QAction *action_PointOfContact = menu.addAction(QIcon(
":/toolicon/32x32/point_of_contact.png"), tr(
"Intersect Arc and Line") +
"\tA, L");
2682 QAction *action_Triangle = menu.addAction(QIcon(
":/toolicon/32x32/triangle.png"), tr(
"Intersect Axis and Triangle") +
"\tX, T");
2683 QAction *action_PointIntersectXY = menu.addAction(QIcon(
":/toolicon/32x32/point_intersectxy_icon.png"), tr(
"Intersect XY") +
"\tX, Y");
2684 QAction *action_PerpendicularPoint = menu.addAction(QIcon(
":/toolicon/32x32/height.png"), tr(
"Intersect Line and Perpendicular") +
"\tL, P");
2685 QAction *action_PointIntersectAxis = menu.addAction(QIcon(
":/toolicon/32x32/line_intersect_axis.png"), tr(
"Intersect Line and Axis") +
"\tL, X");
2687 QAction *selectedAction = menu.exec(QCursor::pos());
2689 if(selectedAction ==
nullptr)
2693 else if (selectedAction == action_Midpoint)
2695 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2696 ui->midpoint_ToolButton->setChecked(
true);
2699 else if (selectedAction == action_PointAtDA)
2701 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2702 ui->pointAtDistanceAngle_ToolButton->setChecked(
true);
2705 else if (selectedAction == action_PointAlongLine)
2707 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2708 ui->alongLine_ToolButton->setChecked(
true);
2711 else if (selectedAction == action_AlongPerpendicular)
2713 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2714 ui->normal_ToolButton->setChecked(
true);
2717 else if (selectedAction == action_Bisector)
2719 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2720 ui->bisector_ToolButton->setChecked(
true);
2723 else if (selectedAction == action_Shoulder)
2725 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2726 ui->shoulderPoint_ToolButton->setChecked(
true);
2729 else if (selectedAction == action_PointOfContact)
2731 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2732 ui->pointOfContact_ToolButton->setChecked(
true);
2735 else if (selectedAction == action_Triangle)
2737 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2738 ui->triangle_ToolButton->setChecked(
true);
2741 else if (selectedAction == action_PointIntersectXY)
2743 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2744 ui->pointIntersectXY_ToolButton->setChecked(
true);
2747 else if (selectedAction == action_PerpendicularPoint)
2749 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2750 ui->height_ToolButton->setChecked(
true);
2753 else if (selectedAction == action_PointIntersectAxis)
2755 ui->draft_ToolBox->setCurrentWidget(
ui->points_Page);
2756 ui->lineIntersectAxis_ToolButton->setChecked(
true);
2763 qCDebug(vMainWindow,
"Lines Menu selected. \n");
2766 QAction *action_Line = menu.addAction(QIcon(
":/toolicon/32x32/line.png"), tr(
"Line") +
"\tAlt+L");
2767 QAction *action_LineIntersect = menu.addAction(QIcon(
":/toolicon/32x32/intersect.png"), tr(
"Intersect Lines") +
"\tI, L");
2769 QAction *selectedAction = menu.exec(QCursor::pos());
2771 if(selectedAction ==
nullptr)
2775 else if (selectedAction == action_Line)
2777 ui->draft_ToolBox->setCurrentWidget(
ui->lines_Page);
2778 ui->line_ToolButton->setChecked(
true);
2781 else if (selectedAction == action_LineIntersect)
2783 ui->draft_ToolBox->setCurrentWidget(
ui->lines_Page);
2784 ui->lineIntersect_ToolButton->setChecked(
true);
2791 qCDebug(vMainWindow,
"Arcs Menu selected. \n");
2794 QAction *action_Arc = menu.addAction(QIcon(
":/toolicon/32x32/arc.png"), tr(
"Radius and Angles") +
"\tAlt+A");
2795 QAction *action_PointAlongArc = menu.addAction(QIcon(
":/toolicon/32x32/arc_cut.png"), tr(
"Point on Arc") +
"\tO, A");
2796 QAction *action_ArcIntersectAxis = menu.addAction(QIcon(
":/toolicon/32x32/arc_intersect_axis.png"), tr(
"Intersect Arc and Axis") +
"\tA, X");
2797 QAction *action_ArcIntersectArc = menu.addAction(QIcon(
":/toolicon/32x32/point_of_intersection_arcs.png"), tr(
"Intersect Arcs") +
"\tI, A");
2798 QAction *action_CircleIntersect = menu.addAction(QIcon(
":/toolicon/32x32/point_of_intersection_circles.png"), tr(
"Intersect Circles") +
"\tShift+I, Shift+C");
2799 QAction *action_CircleTangent = menu.addAction(QIcon(
":/toolicon/32x32/point_from_circle_and_tangent.png"), tr(
"Intersect Circle and Tangent") +
"\tC, T");
2800 QAction *action_ArcTangent = menu.addAction(QIcon(
":/toolicon/32x32/point_from_arc_and_tangent.png"), tr(
"Intersect Arc and Tangent") +
"\tA, T");
2801 QAction *action_ArcWithLength = menu.addAction(QIcon(
":/toolicon/32x32/arc_with_length.png"), tr(
"Radius and Length") +
"\tAlt+Shift+A");
2802 QAction *action_EllipticalArc = menu.addAction(QIcon(
":/toolicon/32x32/el_arc.png"), tr(
"Elliptical") +
"\tAlt+E");
2804 QAction *selectedAction = menu.exec(QCursor::pos());
2806 if(selectedAction ==
nullptr)
2810 else if (selectedAction == action_Arc)
2812 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2813 ui->arc_ToolButton->setChecked(
true);
2816 else if (selectedAction == action_PointAlongArc)
2818 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2819 ui->pointAlongArc_ToolButton->setChecked(
true);
2822 else if (selectedAction == action_ArcIntersectAxis)
2824 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2825 ui->arcIntersectAxis_ToolButton->setChecked(
true);
2828 else if (selectedAction == action_ArcIntersectArc)
2830 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2831 ui->pointOfIntersectionArcs_ToolButton->setChecked(
true);
2834 else if (selectedAction == action_CircleIntersect)
2836 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2837 ui->pointOfIntersectionCircles_ToolButton->setChecked(
true);
2840 else if (selectedAction == action_CircleTangent)
2842 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2843 ui->pointFromCircleAndTangent_ToolButton->setChecked(
true);
2846 else if (selectedAction == action_ArcTangent)
2848 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2849 ui->pointFromArcAndTangent_ToolButton->setChecked(
true);
2852 else if (selectedAction == action_ArcWithLength)
2854 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2855 ui->arcWithLength_ToolButton->setChecked(
true);
2858 else if (selectedAction == action_EllipticalArc)
2860 ui->draft_ToolBox->setCurrentWidget(
ui->arcs_Page);
2861 ui->ellipticalArc_ToolButton->setChecked(
true);
2868 qCDebug(vMainWindow,
"Curves Menu selected. \n");
2871 QAction *action_Curve = menu.addAction(QIcon(
":/toolicon/32x32/spline.png"), tr(
"Curve - Interactive") +
"\tAlt+C");
2872 QAction *action_Spline = menu.addAction(QIcon(
":/toolicon/32x32/splinePath.png"), tr(
"Spline - Interactive") +
"\tAlt+S");
2873 QAction *action_CurveWithCPs = menu.addAction(QIcon(
":/toolicon/32x32/cubic_bezier.png"), tr(
"Curve - Fixed") +
"\tAlt+Shift+C");
2874 QAction *action_SplineWithCPs = menu.addAction(QIcon(
":/toolicon/32x32/cubic_bezier_path.png"), tr(
"Spline - Fixed") +
"\tAlt+Shift+S");
2875 QAction *action_PointAlongCurve = menu.addAction(QIcon(
":/toolicon/32x32/spline_cut_point.png"), tr(
"Point on Curve") +
"\tO, C");
2876 QAction *action_PointAlongSpline = menu.addAction(QIcon(
":/toolicon/32x32/splinePath_cut_point.png"), tr(
"Point on Spline") +
"\tO, S");
2877 QAction *action_CurveIntersectCurve = menu.addAction(QIcon(
":/toolicon/32x32/intersection_curves.png"), tr(
"Intersect Curves") +
"\tI, C");
2878 QAction *action_CurveIntersectAxis = menu.addAction(QIcon(
":/toolicon/32x32/curve_intersect_axis.png"), tr(
"Intersect Curve & Axis") +
"\tC, X");
2880 QAction *selectedAction = menu.exec(QCursor::pos());
2882 if(selectedAction ==
nullptr)
2886 else if (selectedAction == action_Curve)
2888 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2889 ui->curve_ToolButton->setChecked(
true);
2892 else if (selectedAction == action_Spline)
2894 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2895 ui->spline_ToolButton->setChecked(
true);
2898 else if (selectedAction == action_PointAlongCurve)
2900 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2901 ui->pointAlongCurve_ToolButton->setChecked(
true);
2904 else if (selectedAction == action_PointAlongSpline)
2906 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2907 ui->pointAlongSpline_ToolButton->setChecked(
true);
2910 else if (selectedAction == action_CurveWithCPs)
2912 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2913 ui->curveWithCPs_ToolButton->setChecked(
true);
2916 else if (selectedAction == action_SplineWithCPs)
2918 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2919 ui->splineWithCPs_ToolButton->setChecked(
true);
2922 else if (selectedAction == action_CurveIntersectCurve)
2924 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2925 ui->pointOfIntersectionCurves_ToolButton->setChecked(
true);
2928 else if (selectedAction == action_CurveIntersectAxis)
2930 ui->draft_ToolBox->setCurrentWidget(
ui->curves_Page);
2931 ui->curveIntersectAxis_ToolButton->setChecked(
true);
2938 qCDebug(vMainWindow,
"Circles Menu selected. \n");
2944 qCDebug(vMainWindow,
"Operations Menu selected. \n");
2947 QAction *action_Group = menu.addAction(QIcon(
":/toolicon/32x32/group.png"), tr(
"Add Objects to Group") +
"\tG");
2948 QAction *action_Rotate = menu.addAction(QIcon(
":/toolicon/32x32/rotation.png"), tr(
"Rotate") +
"\tR");
2949 QAction *action_MirrorByLine = menu.addAction(QIcon(
":/toolicon/32x32/mirror_by_line.png"), tr(
"Mirror by Line") +
"\tM, L");
2950 QAction *action_MirrorByAxis = menu.addAction(QIcon(
":/toolicon/32x32/mirror_by_axis.png"), tr(
"Mirror by Axis") +
"\tM, A");
2951 QAction *action_Move = menu.addAction(QIcon(
":/toolicon/32x32/move.png"), tr(
"Move") +
"\tAlt+M");
2952 QAction *action_TrueDarts = menu.addAction(QIcon(
":/toolicon/32x32/true_darts.png"), tr(
"True Darts") +
"\tT, D");
2953 QAction *action_ExportDraftBlocks = menu.addAction(QIcon(
":/toolicon/32x32/export.png"), tr(
"Export Draft Blocks") +
"\tE, D");
2955 QAction *selectedAction = menu.exec(QCursor::pos());
2957 if(selectedAction ==
nullptr)
2961 else if (selectedAction == action_Group)
2963 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2964 ui->group_ToolButton->setChecked(
true);
2967 else if (selectedAction == action_Rotate)
2969 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2970 ui->rotation_ToolButton->setChecked(
true);
2973 else if (selectedAction == action_MirrorByLine)
2975 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2976 ui->mirrorByLine_ToolButton->setChecked(
true);
2979 else if (selectedAction == action_MirrorByAxis)
2981 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2982 ui->mirrorByAxis_ToolButton->setChecked(
true);
2985 else if (selectedAction == action_Move)
2987 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2988 ui->move_ToolButton->setChecked(
true);
2991 else if (selectedAction == action_TrueDarts)
2993 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
2994 ui->trueDarts_ToolButton->setChecked(
true);
2997 else if (selectedAction == action_ExportDraftBlocks)
2999 ui->draft_ToolBox->setCurrentWidget(
ui->operations_Page);
3008 QAction *action_Piece = menu.addAction(QIcon(
":/toolicon/32x32/new_detail.png"), tr(
"New Pattern Piece") +
"\tN, P");
3009 QAction *action_AnchorPoint = menu.addAction(QIcon(
":/toolicon/32x32/anchor_point.png"), tr(
"Add AnchorPoint") +
"\tA, P");
3010 QAction *action_InternalPath = menu.addAction(QIcon(
":/toolicon/32x32/path.png"), tr(
"Create Internal Path") +
"\tI, N");
3011 QAction *action_InsertNodes = menu.addAction(QIcon(
":/toolicon/32x32/insert_nodes_icon.png"), tr(
"Insert Nodes in Path") +
"\tI, P");
3017 QAction *selectedAction = menu.exec(QCursor::pos());
3019 if(selectedAction ==
nullptr)
3023 else if (selectedAction == action_Piece)
3025 ui->draft_ToolBox->setCurrentWidget(
ui->piece_Page);
3026 ui->addPatternPiece_ToolButton->setChecked(
true);
3029 else if (selectedAction == action_AnchorPoint)
3031 ui->draft_ToolBox->setCurrentWidget(
ui->piece_Page);
3032 ui->anchorPoint_ToolButton->setChecked(
true);
3035 else if (selectedAction == action_InternalPath)
3037 ui->draft_ToolBox->setCurrentWidget(
ui->piece_Page);
3038 ui->internalPath_ToolButton->setChecked(
true);
3041 else if (selectedAction == action_InsertNodes)
3043 ui->draft_ToolBox->setCurrentWidget(
ui->piece_Page);
3044 ui->insertNodes_ToolButton->setChecked(
true);
3051 qCDebug(vMainWindow,
"PatternPieces Menu selected. \n");
3054 QAction *action_Union = menu.addAction(QIcon(
":/toolicon/32x32/union.png"), tr(
"Union Tool") +
"\tU");
3055 QAction *action_ExportPieces = menu.addAction(QIcon(
":/toolicon/32x32/export.png"), tr(
"Export Pattern Pieces") +
"\tE, P");
3056 QAction *selectedAction = menu.exec(QCursor::pos());
3058 if(selectedAction ==
nullptr)
3062 else if (selectedAction == action_Union)
3064 ui->piece_ToolBox->setCurrentWidget(
ui->details_Page);
3065 ui->unitePieces_ToolButton->setChecked(
true);
3068 else if (selectedAction == action_ExportPieces)
3070 ui->piece_ToolBox->setCurrentWidget(
ui->details_Page);
3077 qCDebug(vMainWindow,
"Layout Menu selected. \n");
3082 QAction *action_NewLayout = menu.addAction(QIcon(
":/toolicon/32x32/layout_settings.png"), tr(
"New Print Layout") +
"\tN, L");
3083 QAction *action_ExportLayout = menu.addAction(QIcon(
":/toolicon/32x32/export.png"), tr(
"Export Layout") +
"\tE, L");
3085 QAction *selectedAction = menu.exec(QCursor::pos());
3087 if(selectedAction ==
nullptr)
3091 else if (selectedAction == action_NewLayout)
3093 ui->layout_ToolBox->setCurrentWidget(
ui->layout_Page);
3094 ui->layoutSettings_ToolButton->setChecked(
true);
3097 else if (selectedAction == action_ExportLayout)
3099 ui->layout_ToolBox->setCurrentWidget(
ui->layout_Page);
3119 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
3128 qCDebug(vMainWindow,
"Canceling tool.");
3130 qCDebug(vMainWindow,
"Dialog closed.");
3132 currentScene->setFocus(Qt::OtherFocusReason);
3133 currentScene->clearSelection();
3134 ui->view->itemClicked(
nullptr);
3136 ui->zoomPan_Action->setChecked(
false);
3137 ui->view->zoomPanEnabled(
false);
3139 ui->zoomToArea_Action->setChecked(
false);
3140 ui->view->zoomToAreaEnabled(
false);
3142 switch ( currentTool )
3145 ui->arrowPointer_ToolButton->setChecked(
false);
3146 ui->arrow_Action->setChecked(
false);
3147 helpLabel->setText(
"");
3150 undoAction->setEnabled(
false);
3151 redoAction->setEnabled(
false);
3170 ui->pointAtDistanceAngle_ToolButton->setChecked(
false);
3173 ui->line_ToolButton->setChecked(
false);
3176 ui->alongLine_ToolButton->setChecked(
false);
3179 ui->midpoint_ToolButton->setChecked(
false);
3182 ui->shoulderPoint_ToolButton->setChecked(
false);
3185 ui->normal_ToolButton->setChecked(
false);
3188 ui->bisector_ToolButton->setChecked(
false);
3191 ui->lineIntersect_ToolButton->setChecked(
false);
3194 ui->curve_ToolButton->setChecked(
false);
3197 ui->curveWithCPs_ToolButton->setChecked(
false);
3200 ui->arc_ToolButton->setChecked(
false);
3203 ui->arcWithLength_ToolButton->setChecked(
false);
3206 ui->spline_ToolButton->setChecked(
false);
3209 ui->splineWithCPs_ToolButton->setChecked(
false);
3212 ui->pointOfContact_ToolButton->setChecked(
false);
3215 ui->addPatternPiece_ToolButton->setChecked(
false);
3218 ui->internalPath_ToolButton->setChecked(
false);
3221 ui->height_ToolButton->setChecked(
false);
3224 ui->triangle_ToolButton->setChecked(
false);
3227 ui->pointIntersectXY_ToolButton->setChecked(
false);
3230 ui->pointAlongCurve_ToolButton->setChecked(
false);
3233 ui->pointAlongSpline_ToolButton->setChecked(
false);
3236 ui->unitePieces_ToolButton->setChecked(
false);
3239 ui->pointAlongArc_ToolButton->setChecked(
false);
3242 ui->lineIntersectAxis_ToolButton->setChecked(
false);
3245 ui->curveIntersectAxis_ToolButton->setChecked(
false);
3248 ui->arcIntersectAxis_ToolButton->setChecked(
false);
3251 ui->pointOfIntersectionArcs_ToolButton->setChecked(
false);
3254 ui->pointOfIntersectionCircles_ToolButton->setChecked(
false);
3257 ui->pointOfIntersectionCurves_ToolButton->setChecked(
false);
3260 ui->pointFromCircleAndTangent_ToolButton->setChecked(
false);
3263 ui->pointFromArcAndTangent_ToolButton->setChecked(
false);
3266 ui->trueDarts_ToolButton->setChecked(
false);
3269 ui->group_ToolButton->setChecked(
false);
3272 ui->rotation_ToolButton->setChecked(
false);
3275 ui->mirrorByLine_ToolButton->setChecked(
false);
3278 ui->mirrorByAxis_ToolButton->setChecked(
false);
3281 ui->move_ToolButton->setChecked(
false);
3284 ui->ellipticalArc_ToolButton->setChecked(
false);
3287 ui->anchorPoint_ToolButton->setChecked(
false);
3290 ui->insertNodes_ToolButton->setChecked(
false);
3295 undoAction->setEnabled(
qApp->getUndoStack()->canUndo());
3296 redoAction->setEnabled(
qApp->getUndoStack()->canRedo());
3309 qCDebug(vMainWindow,
"Arrow tool.");
3311 ui->arrowPointer_ToolButton->setChecked(
true);
3312 ui->arrow_Action->setChecked(
true);
3342 ui->view->allowRubberBand(
true);
3344 ui->view->viewport()->unsetCursor();
3346 ui->view->setShowToolOptions(
true);
3347 qCDebug(vMainWindow,
"Enabled arrow tool.");
3351 ui->view->viewport()->setCursor(QCursor(Qt::ArrowCursor));
3352 ui->arrowPointer_ToolButton->setChecked(
true);
3353 ui->arrow_Action->setChecked(
true);
3364 switch (event->key())
3366 case Qt::Key_Escape:
3369 case Qt::Key_Return:
3374 if (
qApp->Seamly2DSettings()->isPanActiveSpaceKey())
3376 ui->zoomPan_Action->setChecked(
true);
3382 QMainWindow::keyPressEvent (event);
3392 switch (event->key())
3395 if (
qApp->Seamly2DSettings()->isPanActiveSpaceKey())
3397 ui->zoomPan_Action->setChecked(
false);
3402 QMainWindow::keyReleaseEvent(event);
3419 QScrollBar *horScrollBar =
ui->view->horizontalScrollBar();
3421 QScrollBar *verScrollBar =
ui->view->verticalScrollBar();
3439 QScrollBar *horScrollBar =
ui->view->horizontalScrollBar();
3441 QScrollBar *verScrollBar =
ui->view->verticalScrollBar();
3454 ui->toolbox_StackedWidget->setCurrentIndex(0);
3455 qCDebug(vMainWindow,
"Show draft scene");
3458 leftGoToStage->setPixmap(QPixmap(
"://icon/24x24/fast_forward_left_to_right_arrow.png"));
3459 rightGoToStage->setPixmap(QPixmap(
"://icon/24x24/left_to_right_arrow.png"));
3461 ui->showDraftMode->setChecked(
true);
3462 ui->pieceMode_Action->setChecked(
false);
3463 ui->layoutMode_Action->setChecked(
false);
3486 ui->useToolColor_Action->setChecked(
qApp->Settings()->getUseToolColor());
3498 ui->groups_DockWidget->setWindowTitle(tr(
"Group Manager"));
3502 ui->showDraftMode->setChecked(
true);
3515 ui->toolbox_StackedWidget->setCurrentIndex(1);
3525 leftGoToStage->setPixmap(QPixmap(
"://icon/24x24/right_to_left_arrow.png"));
3526 rightGoToStage->setPixmap(QPixmap(
"://icon/24x24/left_to_right_arrow.png"));
3528 ui->showDraftMode->setChecked(
false);
3529 ui->pieceMode_Action->setChecked(
true);
3530 ui->layoutMode_Action->setChecked(
false);
3532 if(not
qApp->getOpeningPattern())
3536 QMessageBox::information(
this, tr(
"Piece mode"), tr(
"You can't use Piece mode yet. "
3537 "Please, create at least one pattern piece."),
3538 QMessageBox::Ok, QMessageBox::Ok);
3546 qCDebug(vMainWindow,
"Show piece scene");
3550 ui->view->itemClicked(
nullptr);
3566 ui->piece_ToolBox->setCurrentIndex(
ui->piece_ToolBox->indexOf(
ui->details_Page));
3576 ui->groups_DockWidget->setWindowTitle(tr(
"Pattern Pieces"));
3582 ui->pieceMode_Action->setChecked(
true);
3595 ui->toolbox_StackedWidget->setCurrentIndex(2);
3605 leftGoToStage->setPixmap(QPixmap(
"://icon/24x24/right_to_left_arrow.png"));
3606 rightGoToStage->setPixmap(QPixmap(
"://icon/24x24/fast_forward_right_to_left_arrow.png"));
3608 ui->showDraftMode->setChecked(
false);
3609 ui->pieceMode_Action->setChecked(
false);
3610 ui->layoutMode_Action->setChecked(
true);
3613 if(not
qApp->getOpeningPattern())
3616 if (allPieces->count() == 0)
3618 QMessageBox::information(
this, tr(
"Layout mode"), tr(
"You can't use Layout mode yet. "
3619 "Please, create at least one pattern piece."),
3620 QMessageBox::Ok, QMessageBox::Ok);
3627 while (i != allPieces->constEnd())
3629 if (i.value().isInLayout())
3631 pieces.insert(i.key(), i.value());
3638 QMessageBox::information(
this, tr(
"Layout mode"), tr(
"You can't use Layout mode yet. Please, "
3639 "include at least one pattern piece in layout."),
3640 QMessageBox::Ok, QMessageBox::Ok);
3649 qCDebug(vMainWindow,
"Show layout scene");
3660 QMessageBox::warning(
this, tr(
"Layout mode"),
3661 tr(
"You can't use Layout mode yet.") + QLatin1String(
" \n") + e.
ErrorMessage(),
3662 QMessageBox::Ok, QMessageBox::Ok);
3668 ui->view->itemClicked(
nullptr);
3678 ui->layout_ToolBox->setCurrentIndex(
ui->layout_ToolBox->indexOf(
ui->layout_Page));
3694 ui->layoutSettings_ToolButton->click();
3701 ui->layoutMode_Action->setChecked(
true);
3714 QMessageBox messageBox(
this);
3715 messageBox.setIcon(QMessageBox::Warning);
3716 messageBox.setText(tr(
"Can not save file."));
3717 messageBox.setInformativeText(tr(
"Pattern is read only."));
3718 messageBox.setDefaultButton(QMessageBox::Ok);
3719 messageBox.setStandardButtons(QMessageBox::Ok);
3723 QString filters(tr(
"Pattern files") + QLatin1String(
"(*.val)"));
3724 QString filePath =
qApp->getFilePath();
3727 if (filePath.isEmpty())
3729 dir =
qApp->Seamly2DSettings()->GetPathPattern();
3730 fileName = QLatin1String(
"pattern");
3734 dir = QFileInfo(filePath).path();
3735 fileName = QFileInfo(filePath).baseName();
3738 bool usedNotExistedDir =
false;
3739 QDir directory(dir);
3740 if (!directory.exists())
3742 usedNotExistedDir = directory.mkpath(
".");
3745 fileName = QFileDialog::getSaveFileName(
this, tr(
"Save as"),
3746 dir + QLatin1String(
"/") + fileName + QLatin1String(
".val"),
3747 filters,
nullptr, QFileDialog::DontUseNativeDialog);
3749 auto RemoveTempDir = [usedNotExistedDir, dir]()
3751 if (usedNotExistedDir)
3753 QDir directory(dir);
3754 directory.rmpath(
".");
3758 if (fileName.isEmpty())
3764 QFileInfo fileInfo(fileName);
3765 if (fileInfo.suffix().isEmpty() && fileInfo.suffix() != QLatin1String(
"val"))
3767 fileName += QLatin1String(
".val");
3770 if (fileInfo.exists() && fileName != filePath)
3777 qCWarning(vMainWindow,
"%s",
3778 qUtf8Printable(tr(
"Failed to lock. File with this name is opened in another window.")));
3788 if (result ==
false)
3790 QMessageBox messageBox(
this);
3791 messageBox.setIcon(QMessageBox::Warning);
3792 messageBox.setInformativeText(tr(
"Could not save file"));
3793 messageBox.setDefaultButton(QMessageBox::Ok);
3794 messageBox.setDetailedText(error);
3795 messageBox.setStandardButtons(QMessageBox::Ok);
3809 if (fileName != filePath)
3812 if (!
lock->IsLocked())
3814 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"Failed to lock. This file already opened in another window. "
3815 "Expect collisions when running 2 copies of the program.")));
3834 QMessageBox messageBox(
this);
3835 messageBox.setIcon(QMessageBox::Warning);
3836 messageBox.setText(tr(
"Can not save file."));
3837 messageBox.setInformativeText(tr(
"Pattern is read only."));
3838 messageBox.setDefaultButton(QMessageBox::Ok);
3839 messageBox.setStandardButtons(QMessageBox::Ok);
3843 if (
qApp->getFilePath().isEmpty())
3856 qt_ntfs_permission_lookup++;
3858 const bool isFileWritable = QFileInfo(
qApp->getFilePath()).isWritable();
3860 if (!isFileWritable)
3862 QMessageBox messageBox(
this);
3863 messageBox.setIcon(QMessageBox::Question);
3864 messageBox.setText(tr(
"The document has no write permissions."));
3865 messageBox.setInformativeText(
"Do you want to change the permissions?");
3866 messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
3867 messageBox.setDefaultButton(QMessageBox::Yes);
3869 if (messageBox.exec() == QMessageBox::Yes)
3871 bool changed = QFile::setPermissions(
qApp->getFilePath(),
3872 QFileInfo(
qApp->getFilePath()).permissions() | QFileDevice::WriteUser);
3874 qt_ntfs_permission_lookup--;
3879 QMessageBox messageBox(
this);
3880 messageBox.setIcon(QMessageBox::Warning);
3881 messageBox.setText(tr(
"Cannot set permissions for %1 to writable.").arg(
qApp->getFilePath()));
3882 messageBox.setInformativeText(tr(
"Could not save the file."));
3883 messageBox.setDefaultButton(QMessageBox::Ok);
3884 messageBox.setStandardButtons(QMessageBox::Ok);
3905 QMessageBox messageBox(
this);
3906 messageBox.setIcon(QMessageBox::Warning);
3907 messageBox.setText(tr(
"Could not save the file"));
3908 messageBox.setDefaultButton(QMessageBox::Ok);
3909 messageBox.setDetailedText(error);
3910 messageBox.setStandardButtons(QMessageBox::Ok);
3923 qCDebug(vMainWindow,
"Opening new file.");
3924 const QString filter(tr(
"Pattern files (*.val)"));
3926 const QStringList files =
qApp->Seamly2DSettings()->GetRecentFileList();
3928 if (files.isEmpty())
3930 dir = QDir::homePath();
3935 dir = QFileInfo(files.first()).absolutePath();
3937 qCDebug(vMainWindow,
"Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
3938 const QString filePath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), dir, filter,
nullptr,
3939 QFileDialog::DontUseNativeDialog);
3940 if (filePath.isEmpty())
3953 qCDebug(vMainWindow,
"Resetting main window.");
3955 qCDebug(vMainWindow,
"Unlocked pattern file.");
3957 qCDebug(vMainWindow,
"Returned to Draft mode.");
3960 qCDebug(vMainWindow,
"Clearing pattern.");
3961 if (not
qApp->getFilePath().isEmpty() && not
doc->
MPath().isEmpty())
3966 qCDebug(vMainWindow,
"Clearing scenes.");
3971 ui->showDraftMode->setEnabled(
false);
3972 ui->pieceMode_Action->setEnabled(
false);
3973 ui->layoutMode_Action->setEnabled(
false);
3974 ui->newDraft_Action->setEnabled(
false);
3975 ui->renameDraft_Action->setEnabled(
false);
3976 ui->save_Action->setEnabled(
false);
3977 ui->saveAs_Action->setEnabled(
false);
3978 ui->patternPreferences_Action->setEnabled(
false);
3982 ui->zoomIn_Action->setEnabled(
false);
3983 ui->zoomOut_Action->setEnabled(
false);
3984 ui->zoomToFit_Action->setEnabled(
false);
3985 ui->zoomToSelected_Action->setEnabled(
false);
3986 ui->zoom100Percent_Action->setEnabled(
false);
3987 ui->zoomToPrevious_Action->setEnabled(
false);
3988 ui->zoomToArea_Action->setEnabled(
false);
3989 ui->zoomPan_Action->setEnabled(
false);
3990 ui->zoomToPoint_Action->setEnabled(
false);
3993 ui->groups_DockWidget->setEnabled(
false);
3996 ui->history_Action->setEnabled(
false);
3997 ui->table_Action->setEnabled(
false);
3999 ui->lastTool_Action->setEnabled(
false);
4000 ui->increaseSize_Action->setEnabled(
false);
4001 ui->decreaseSize_Action->setEnabled(
false);
4002 ui->useToolColor_Action->setEnabled(
false);
4003 ui->showPointNames_Action->setEnabled(
false);
4004 ui->toggleWireframe_Action->setEnabled(
false);
4005 ui->toggleControlPoints_Action->setEnabled(
false);
4006 ui->toggleAxisOrigin_Action->setEnabled(
false);
4007 ui->toggleSeamAllowances_Action->setEnabled(
false);
4008 ui->toggleGrainLines_Action->setEnabled(
false);
4009 ui->toggleLabels_Action->setEnabled(
false);
4014 ui->loadIndividual_Action->setEnabled(
false);
4015 ui->loadMultisize_Action->setEnabled(
false);
4016 ui->unloadMeasurements_Action->setEnabled(
false);
4017 ui->editCurrent_Action->setEnabled(
false);
4023 #ifndef QT_NO_CURSOR
4024 QGuiApplication::restoreOverrideCursor();
4028 qApp->getUndoStack()->clear();
4039 QStringList restoreFiles =
qApp->Seamly2DSettings()->GetRestoreFileList();
4040 restoreFiles.removeAll(
qApp->getFilePath());
4041 qApp->Seamly2DSettings()->SetRestoreFileList(restoreFiles);
4045 if (autofile.exists())
4049 qCDebug(vMainWindow,
"File %s closed correct.", qUtf8Printable(
qApp->getFilePath()));
4055 qCDebug(vMainWindow,
"Full parsing file");
4068 QApplication::postEvent(
this,
new UndoEvent());
4073 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error parsing file.")),
4084 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error can't convert value.")),
4095 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error empty parameter.")),
4106 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error wrong id.")),
4117 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error parsing file.")),
4126 catch (
const std::bad_alloc &)
4128 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"Error parsing file (std::bad_alloc).")));
4137 QString patternPiece;
4146 draftBlockNames.sort();
4162 ui->patternPreferences_Action->setEnabled(
true);
4190 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Bad id.")),
4201 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Error empty parameter.")),
4217 if (enabled ==
false)
4220 qApp->getUndoStack()->clear();
4227 ui->statusBar->setEnabled(enabled);
4228 #ifndef QT_NO_CURSOR
4229 QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
4243 const bool designStage = (draftStage || pieceStage);
4247 ui->arrow_Action->setEnabled(enable && designStage);
4250 ui->save_Action->setEnabled(isWindowModified() && enable && not
patternReadOnly);
4251 ui->saveAs_Action->setEnabled(enable);
4252 ui->patternPreferences_Action->setEnabled(enable && designStage);
4255 undoAction->setEnabled(enable && designStage &&
qApp->getUndoStack()->canUndo());
4256 redoAction->setEnabled(enable && designStage &&
qApp->getUndoStack()->canRedo());
4259 ui->showDraftMode->setEnabled(enable);
4260 ui->pieceMode_Action->setEnabled(enable);
4261 ui->layoutMode_Action->setEnabled(enable);
4263 ui->zoomIn_Action->setEnabled(enable);
4264 ui->zoomOut_Action->setEnabled(enable);
4265 ui->zoomToFit_Action->setEnabled(enable);
4266 ui->zoomToSelected_Action->setEnabled(enable);
4267 ui->zoom100Percent_Action->setEnabled(enable);
4268 ui->zoomToPrevious_Action->setEnabled(enable);
4269 ui->zoomToArea_Action->setEnabled(enable);
4270 ui->zoomPan_Action->setEnabled(enable);
4271 ui->zoomToPoint_Action->setEnabled(enable && draftStage);
4274 ui->increaseSize_Action->setEnabled(enable);
4275 ui->decreaseSize_Action->setEnabled(enable);
4276 ui->useToolColor_Action->setEnabled(enable && draftStage);
4277 ui->showPointNames_Action->setEnabled(enable);
4278 ui->toggleWireframe_Action->setEnabled(enable);
4279 ui->toggleControlPoints_Action->setEnabled(enable && draftStage);
4280 ui->toggleAxisOrigin_Action->setEnabled(enable);
4281 ui->toggleSeamAllowances_Action->setEnabled(enable && pieceStage);
4282 ui->toggleGrainLines_Action->setEnabled(enable && pieceStage);
4283 ui->toggleLabels_Action->setEnabled(enable && pieceStage);
4290 ui->newDraft_Action->setEnabled(enable && draftStage);
4291 ui->renameDraft_Action->setEnabled(enable && draftStage);
4294 ui->loadIndividual_Action->setEnabled(enable && designStage);
4295 ui->loadMultisize_Action->setEnabled(enable && designStage);
4296 ui->unloadMeasurements_Action->setEnabled(enable && designStage);
4297 ui->table_Action->setEnabled(enable && draftStage);
4300 ui->history_Action->setEnabled(enable && draftStage);
4303 ui->calculator_Action->setEnabled(enable);
4304 ui->decimalChart_Action->setEnabled(enable);
4307 ui->shortcuts_Action->setEnabled(enable);
4310 ui->groups_DockWidget->setEnabled(enable && designStage);
4311 ui->toolProperties_DockWidget->setEnabled(enable && draftStage);
4312 ui->layoutPages_DockWidget->setEnabled(enable && layoutStage);
4319 ui->view->setEnabled(enable);
4381 qCDebug(vMainWindow,
"New Draft Block.");
4383 qCDebug(vMainWindow,
"Generated Draft Block name: %s", qUtf8Printable(draftBlockName));
4385 qCDebug(vMainWindow,
"First Draft Block");
4387 if (newPattern.exec() == QDialog::Accepted)
4389 draftBlockName = newPattern.
name();
4391 qCDebug(vMainWindow,
"Draft Block name: %s", qUtf8Printable(draftBlockName));
4395 qCDebug(vMainWindow,
"Creating new Draft Block was canceled.");
4426 setWindowModified(state);
4427 not
patternReadOnly ?
ui->save_Action->setEnabled(state):
ui->save_Action->setEnabled(
false);
4449 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"Couldn't update measurements.")));
4451 const qint32 index =
gradationSizes->findText(QString().setNum(size));
4458 qCDebug(vMainWindow,
"Couldn't restore size value.");
4479 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"Couldn't update measurements.")));
4488 qCDebug(vMainWindow,
"Couldn't restore height value.");
4540 bool draftTools =
false;
4541 bool pieceTools =
false;
4542 bool layoutTools =
false;
4547 draftTools = enable;
4550 pieceTools = enable;
4553 layoutTools = enable;
4564 ui->pointAtDistanceAngle_ToolButton->setEnabled(draftTools);
4565 ui->alongLine_ToolButton->setEnabled(draftTools);
4566 ui->normal_ToolButton->setEnabled(draftTools);
4567 ui->bisector_ToolButton->setEnabled(draftTools);
4568 ui->shoulderPoint_ToolButton->setEnabled(draftTools);
4569 ui->pointOfContact_ToolButton->setEnabled(draftTools);
4570 ui->triangle_ToolButton->setEnabled(draftTools);
4571 ui->pointIntersectXY_ToolButton->setEnabled(draftTools);
4572 ui->height_ToolButton->setEnabled(draftTools);
4573 ui->lineIntersectAxis_ToolButton->setEnabled(draftTools);
4574 ui->midpoint_ToolButton->setEnabled(draftTools);
4577 ui->line_ToolButton->setEnabled(draftTools);
4578 ui->lineIntersect_ToolButton->setEnabled(draftTools);
4581 ui->curve_ToolButton->setEnabled(draftTools);
4582 ui->spline_ToolButton->setEnabled(draftTools);
4583 ui->curveWithCPs_ToolButton->setEnabled(draftTools);
4584 ui->splineWithCPs_ToolButton->setEnabled(draftTools);
4585 ui->pointAlongCurve_ToolButton->setEnabled(draftTools);
4586 ui->pointAlongSpline_ToolButton->setEnabled(draftTools);
4587 ui->pointOfIntersectionCurves_ToolButton->setEnabled(draftTools);
4588 ui->curveIntersectAxis_ToolButton->setEnabled(draftTools);
4591 ui->arc_ToolButton->setEnabled(draftTools);
4592 ui->pointAlongArc_ToolButton->setEnabled(draftTools);
4593 ui->arcIntersectAxis_ToolButton->setEnabled(draftTools);
4594 ui->pointOfIntersectionArcs_ToolButton->setEnabled(draftTools);
4595 ui->pointOfIntersectionCircles_ToolButton->setEnabled(draftTools);
4596 ui->pointFromCircleAndTangent_ToolButton->setEnabled(draftTools);
4597 ui->pointFromArcAndTangent_ToolButton->setEnabled(draftTools);
4598 ui->arcWithLength_ToolButton->setEnabled(draftTools);
4599 ui->ellipticalArc_ToolButton->setEnabled(draftTools);
4602 ui->group_ToolButton->setEnabled(draftTools);
4603 ui->rotation_ToolButton->setEnabled(draftTools);
4604 ui->mirrorByLine_ToolButton->setEnabled(draftTools);
4605 ui->mirrorByAxis_ToolButton->setEnabled(draftTools);
4606 ui->move_ToolButton->setEnabled(draftTools);
4607 ui->trueDarts_ToolButton->setEnabled(draftTools);
4608 ui->exportDraftBlocks_ToolButton->setEnabled(draftTools);
4611 ui->addPatternPiece_ToolButton->setEnabled(draftTools);
4613 ui->internalPath_ToolButton->setEnabled(draftTools & (
pattern->
DataPieces()->size() > 0));
4617 ui->unitePieces_ToolButton->setEnabled(pieceTools);
4618 ui->exportPiecesAs_ToolButton->setEnabled(pieceTools);
4621 ui->layoutSettings_ToolButton->setEnabled(layoutTools);
4624 ui->arrow_Action->setEnabled(enable);
4625 ui->points_Action->setEnabled(draftTools);
4626 ui->lines_Action->setEnabled(draftTools);
4627 ui->arcs_Action->setEnabled(draftTools);
4628 ui->curves_Action->setEnabled(draftTools);
4629 ui->modifications_Action->setEnabled(draftTools);
4630 ui->pieces_Action->setEnabled(draftTools);
4631 ui->details_Action->setEnabled(pieceTools);
4632 ui->layout_Action->setEnabled(layoutTools);
4636 ui->midpoint_Action->setEnabled(draftTools);
4637 ui->pointAtDistanceAngle_Action->setEnabled(draftTools);
4638 ui->pointAlongLine_Action->setEnabled(draftTools);
4639 ui->pointAlongPerpendicular_Action->setEnabled(draftTools);
4640 ui->bisector_Action->setEnabled(draftTools);
4641 ui->pointOnShoulder_Action->setEnabled(draftTools);
4642 ui->pointOfContact_Action->setEnabled(draftTools);
4643 ui->triangle_Action->setEnabled(draftTools);
4644 ui->pointIntersectXY_Action->setEnabled(draftTools);
4645 ui->perpendicularPoint_Action->setEnabled(draftTools);
4646 ui->pointIntersectAxis_Action->setEnabled(draftTools);
4649 ui->lineTool_Action->setEnabled(draftTools);
4650 ui->lineIntersect_Action->setEnabled(draftTools);
4653 ui->curve_Action->setEnabled(draftTools);
4654 ui->spline_Action->setEnabled(draftTools);
4655 ui->curveWithCPs_Action->setEnabled(draftTools);
4656 ui->splineWithCPs_Action->setEnabled(draftTools);
4657 ui->pointAlongCurve_Action->setEnabled(draftTools);
4658 ui->pointAlongSpline_Action->setEnabled(draftTools);
4659 ui->curveIntersectCurve_Action->setEnabled(draftTools);
4660 ui->splineIntersectAxis_Action->setEnabled(draftTools);
4663 ui->arcTool_Action->setEnabled(draftTools);
4664 ui->pointAlongArc_Action->setEnabled(draftTools);
4665 ui->arcIntersectAxis_Action->setEnabled(draftTools);
4666 ui->arcIntersectArc_Action->setEnabled(draftTools);
4667 ui->circleIntersect_Action->setEnabled(draftTools);
4668 ui->circleTangent_Action->setEnabled(draftTools);
4669 ui->arcTangent_Action->setEnabled(draftTools);;
4670 ui->arcWithLength_Action->setEnabled(draftTools);
4671 ui->ellipticalArc_Action->setEnabled(draftTools);
4674 ui->group_Action->setEnabled(draftTools);
4675 ui->rotation_Action->setEnabled(draftTools);
4676 ui->mirrorByLine_Action->setEnabled(draftTools);
4677 ui->mirrorByAxis_Action->setEnabled(draftTools);
4678 ui->move_Action->setEnabled(draftTools);
4679 ui->trueDarts_Action->setEnabled(draftTools);
4680 ui->exportDraftBlocks_Action->setEnabled(draftTools);
4683 ui->addPiece_Action->setEnabled(draftTools);
4689 ui->union_Action->setEnabled(pieceTools);
4690 ui->exportPieces_Action->setEnabled(pieceTools);
4693 ui->newPrintLayout_Action->setEnabled(layoutTools);
4694 ui->exportLayout_Action->setEnabled(layoutTools);
4695 ui->lastTool_Action->setEnabled(draftTools);
4697 ui->arrowPointer_ToolButton->setEnabled(draftTools || pieceTools);
4698 ui->arrowPointer_ToolButton->setChecked(draftTools || pieceTools);
4699 ui->arrow_Action->setChecked(draftTools || pieceTools);
4705 const bool enabled = not
scenes.isEmpty();
4707 ui->exportLayout_ToolButton->setEnabled(enabled);
4708 ui->exportAs_Action->setEnabled(enabled);
4709 ui->printPreview_Action->setEnabled(enabled);
4710 ui->printPreviewTiled_Action->setEnabled(enabled);
4711 ui->print_Action->setEnabled(enabled);
4712 ui->printTiled_Action->setEnabled(enabled);
4721 QScrollBar *horScrollBar =
ui->view->horizontalScrollBar();
4722 horScrollBar->setValue(horScrollBar->minimum());
4723 QScrollBar *verScrollBar =
ui->view->verticalScrollBar();
4724 verScrollBar->setValue(verScrollBar->minimum());
4735 qCDebug(vMainWindow,
"Saving pattern file %s.", qUtf8Printable(fileName));
4736 QFileInfo tempInfo(fileName);
4739 if (not mPath.isEmpty() &&
qApp->getFilePath() != fileName)
4747 if (tempInfo.suffix() != QLatin1String(
"autosave"))
4751 qCDebug(vMainWindow,
"File %s saved.", qUtf8Printable(fileName));
4759 qCDebug(vMainWindow,
"Could not save file %s. %s.", qUtf8Printable(fileName), qUtf8Printable(error));
4774 qCDebug(vMainWindow,
"Autosaving pattern.");
4776 if (
qApp->getFilePath().isEmpty() ==
false && this->isWindowModified() ==
true)
4792 qCDebug(vMainWindow,
"Set current name to \"%s\"", qUtf8Printable(fileName));
4793 qApp->setFilePath(fileName);
4796 qApp->getUndoStack()->setClean();
4800 qCDebug(vMainWindow,
"Updating recent file list.");
4803 files.removeAll(fileName);
4804 files.prepend(fileName);
4813 qCDebug(vMainWindow,
"Updating restore file list.");
4815 restoreFiles.removeAll(fileName);
4816 restoreFiles.prepend(fileName);
4829 qCDebug(vMainWindow,
"Reading settings.");
4837 ui->view->setRenderHint(QPainter::Antialiasing, graphOutputValue);
4838 ui->view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue);
4875 QScopedPointer<QMessageBox> messageBox(
new QMessageBox(tr(
"Unsaved changes"),
4876 tr(
"The pattern has been modified.\n"
4877 "Do you want to save your changes?"),
4878 QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
4879 QMessageBox::Cancel,
this, Qt::Sheet));
4881 messageBox->setDefaultButton(QMessageBox::Yes);
4882 messageBox->setEscapeButton(QMessageBox::Cancel);
4884 messageBox->setButtonText(QMessageBox::Yes,
4886 messageBox->setButtonText(QMessageBox::No, tr(
"Don't Save"));
4888 messageBox->setWindowModality(Qt::ApplicationModal);
4889 const auto ret =
static_cast<QMessageBox::StandardButton
>(messageBox->exec());
4893 case QMessageBox::Yes:
4902 case QMessageBox::No:
4904 case QMessageBox::Cancel:
4916 qCDebug(vMainWindow,
"Updating recent file actions.");
4917 const QStringList files =
qApp->Seamly2DSettings()->GetRecentFileList();
4918 const int numRecentFiles = qMin(files.size(),
static_cast<int>(
MaxRecentFiles));
4920 for (
int i = 0; i < numRecentFiles; ++i)
4922 QString text = QString(
"&%1. %2").arg(i + 1).arg(
strippedName(files.at(i)));
4950 undoShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Z));
4951 undoShortcuts.append(QKeySequence(Qt::AltModifier + Qt::Key_Backspace));
4953 undoAction =
qApp->getUndoStack()->createUndoAction(
this, tr(
"&Undo"));
4955 undoAction->setIcon(QIcon::fromTheme(
"edit-undo"));
4961 redoShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Y));
4962 redoShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_Z));
4963 redoShortcuts.append(QKeySequence(Qt::AltModifier + Qt::ShiftModifier + Qt::Key_Backspace));
4965 redoAction =
qApp->getUndoStack()->createRedoAction(
this, tr(
"&Redo"));
4967 redoAction->setIcon(QIcon::fromTheme(
"edit-redo"));
4982 QMenu *menu =
new QMenu(
"Toolbars");
4983 ui->view_Menu->addMenu(menu);
4985 menu->addAction(
ui->file_ToolBar->toggleViewAction());
4986 connect(
ui->file_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
4988 ui->file_ToolBar->setVisible(visible);
4990 menu->addAction(
ui->edit_Toolbar->toggleViewAction());
4991 connect(
ui->edit_Toolbar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
4993 ui->edit_Toolbar->setVisible(visible);
4995 menu->addAction(
ui->view_ToolBar->toggleViewAction());
4996 connect(
ui->view_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
4998 ui->view_ToolBar->setVisible(visible);
5001 menu->addAction(
ui->mode_ToolBar->toggleViewAction());
5002 connect(
ui->mode_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
5004 ui->mode_ToolBar->setVisible(visible);
5006 menu->addAction(
ui->draft_ToolBar->toggleViewAction());
5007 connect(
ui->draft_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
5009 ui->draft_ToolBar->setVisible(visible);
5012 menu->addAction(
ui->zoom_ToolBar->toggleViewAction());
5013 connect(
ui->zoom_ToolBar, &QToolBar::visibilityChanged,
this, [
this](
bool visible)
5015 ui->zoom_ToolBar->setVisible(visible);
5017 menu->addAction(
ui->tools_ToolBox_ToolBar->toggleViewAction());
5018 menu->addAction(
ui->points_ToolBar->toggleViewAction());
5019 menu->addAction(
ui->lines_ToolBar->toggleViewAction());
5020 menu->addAction(
ui->curves_ToolBar->toggleViewAction());
5021 menu->addAction(
ui->arcs_ToolBar->toggleViewAction());
5022 menu->addAction(
ui->operations_ToolBar->toggleViewAction());
5023 menu->addAction(
ui->pieces_ToolBar->toggleViewAction());
5024 menu->addAction(
ui->details_ToolBar->toggleViewAction());
5025 menu->addAction(
ui->layout_ToolBar->toggleViewAction());
5026 menu->addAction(
ui->pointName_ToolBar->toggleViewAction());
5031 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
5037 if (currentTool == lastUsedTool)
5042 switch ( lastUsedTool )
5045 ui->arrowPointer_ToolButton->setChecked(
true);
5046 ui->arrow_Action->setChecked(
true);
5047 handleArrowTool(
true);
5065 ui->pointAtDistanceAngle_ToolButton->setChecked(
true);
5066 handlePointAtDistanceAngleTool(
true);
5069 ui->line_ToolButton->setChecked(
true);
5070 handleLineTool(
true);
5073 ui->alongLine_ToolButton->setChecked(
true);
5074 handleAlongLineTool(
true);
5077 ui->midpoint_ToolButton->setChecked(
true);
5078 handleMidpointTool(
true);
5081 ui->shoulderPoint_ToolButton->setChecked(
true);
5082 handleShoulderPointTool(
true);
5085 ui->normal_ToolButton->setChecked(
true);
5086 handleNormalTool(
true);
5089 ui->bisector_ToolButton->setChecked(
true);
5090 handleBisectorTool(
true);
5093 ui->lineIntersect_ToolButton->setChecked(
true);
5094 handleLineIntersectTool(
true);
5097 ui->curve_ToolButton->setChecked(
true);
5098 handleCurveTool(
true);
5101 ui->curveWithCPs_ToolButton->setChecked(
true);
5102 handleCurveWithControlPointsTool(
true);
5105 ui->arc_ToolButton->setChecked(
true);
5106 handleArcTool(
true);
5109 ui->spline_ToolButton->setChecked(
true);
5110 handleSplineTool(
true);
5113 ui->splineWithCPs_ToolButton->setChecked(
true);
5114 handleSplineWithControlPointsTool(
true);
5117 ui->pointOfContact_ToolButton->setChecked(
true);
5118 handlePointOfContactTool(
true);
5121 ui->addPatternPiece_ToolButton->setChecked(
true);
5122 handlePatternPieceTool(
true);
5125 ui->internalPath_ToolButton->setChecked(
true);
5126 handleInternalPathTool(
true);
5129 ui->height_ToolButton->setChecked(
true);
5130 handleHeightTool(
true);
5133 ui->triangle_ToolButton->setChecked(
true);
5134 handleTriangleTool(
true);
5137 ui->pointIntersectXY_ToolButton->setChecked(
true);
5138 handlePointIntersectXYTool(
true);
5141 ui->pointOfIntersectionArcs_ToolButton->setChecked(
true);
5142 handlePointOfIntersectionArcsTool(
true);
5145 ui->pointAlongCurve_ToolButton->setChecked(
true);
5146 handlePointAlongCurveTool(
true);
5149 ui->pointAlongSpline_ToolButton->setChecked(
true);
5150 handlePointAlongSplineTool(
true);
5153 ui->unitePieces_ToolButton->setChecked(
true);
5154 handleUnionTool(
true);
5157 ui->pointAlongArc_ToolButton->setChecked(
true);
5158 handlePointAlongArcTool(
true);
5161 ui->lineIntersectAxis_ToolButton->setChecked(
true);
5162 handleLineIntersectAxisTool(
true);
5165 ui->curveIntersectAxis_ToolButton->setChecked(
true);
5166 handleCurveIntersectAxisTool(
true);
5169 ui->arcIntersectAxis_ToolButton->setChecked(
true);
5170 handleArcIntersectAxisTool(
true);
5173 ui->pointOfIntersectionCircles_ToolButton->setChecked(
true);
5174 handlePointOfIntersectionCirclesTool(
true);
5177 ui->pointOfIntersectionCurves_ToolButton->setChecked(
true);
5178 handleCurveIntersectCurveTool(
true);
5181 ui->pointFromCircleAndTangent_ToolButton->setChecked(
true);
5182 handlePointFromCircleAndTangentTool(
true);
5185 ui->pointFromArcAndTangent_ToolButton->setChecked(
true);
5186 handlePointFromArcAndTangentTool(
true);
5189 ui->arcWithLength_ToolButton->setChecked(
true);
5190 handleArcWithLengthTool(
true);
5193 ui->trueDarts_ToolButton->setChecked(
true);
5194 handleTrueDartTool(
true);
5197 ui->group_ToolButton->setChecked(
true);
5198 handleGroupTool(
true);
5201 ui->rotation_ToolButton->setChecked(
true);
5202 handleRotationTool(
true);
5205 ui->mirrorByLine_ToolButton->setChecked(
true);
5206 handleMirrorByLineTool(
true);
5209 ui->mirrorByAxis_ToolButton->setChecked(
true);
5210 handleMirrorByAxisTool(
true);
5213 ui->move_ToolButton->setChecked(
true);
5214 handleMoveTool(
true);
5217 ui->ellipticalArc_ToolButton->setChecked(
true);
5218 handleEllipticalArcTool(
true);
5221 ui->anchorPoint_ToolButton->setChecked(
true);
5222 handleAnchorPointTool(
true);
5225 ui->insertNodes_ToolButton->setChecked(
true);
5226 handleInsertNodesTool(
true);
5239 connect(
ui->toolProperties_DockWidget, &QDockWidget::visibilityChanged,
this, [
this](
bool visible)
5241 isToolOptionsDockVisible = visible;
5246 connect(
ui->groups_DockWidget, &QDockWidget::visibilityChanged,
this, [
this](
bool visible)
5248 isGroupsDockVisible = visible;
5253 connect(
ui->layoutPages_DockWidget, &QDockWidget::visibilityChanged,
this, [
this](
bool visible)
5255 isLayoutsDockVisible = visible;
5260 connect(
ui->toolbox_DockWidget, &QDockWidget::visibilityChanged,
this, [
this](
bool visible)
5262 isToolboxDockVisible = visible;
5269 setTabPosition(Qt::RightDockWidgetArea, QTabWidget::West);
5270 setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East);
5272 qCDebug(vMainWindow,
"Initialize Tool Options Property editor.");
5278 qCDebug(vMainWindow,
"Initialize Groups manager.");
5290 ui->toolbox_StackedWidget->setCurrentIndex(0);
5296 if (this->isWindowModified() ||
qApp->getFilePath().isEmpty() ==
false)
5314 connect(
ui->closePattern_Action, &QAction::triggered,
this, [
this]()
5318 FileClosedCorrect();
5330 connect(ui->patternPreferences_Action, &QAction::triggered,
this, [
this]()
5332 DialogPatternProperties proper(doc, pattern, this);
5333 connect(&proper, &DialogPatternProperties::UpdateGradation, this, [this]()
5335 UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit()));
5336 UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit()));
5340 ui->patternPreferences_Action->setEnabled(
false);
5343 for (
int i = 0; i < MaxRecentFiles; ++i)
5345 QAction *action =
new QAction(
this);
5346 action->setVisible(
false);
5347 recentFileActs[i] = action;
5348 connect(recentFileActs[i], &QAction::triggered,
this, [
this]()
5350 if (QAction *action = qobject_cast<QAction*>(sender()))
5352 const QString filePath = action->data().toString();
5353 if (not filePath.isEmpty())
5355 LoadPattern(filePath);
5361 connect(ui->documentInfo_Action, &QAction::triggered,
this, [
this]()
5363 ShowInfoDialog *infoDialog = new ShowInfoDialog(doc, this);
5364 infoDialog->setAttribute(Qt::WA_DeleteOnClose, true);
5365 infoDialog->adjustSize();
5369 connect(ui->exit_Action, &QAction::triggered,
this, &MainWindow::close);
5372 connect(ui->labelTemplateEditor_Action, &QAction::triggered,
this, [
this]()
5374 EditLabelTemplateDialog editor(doc);
5383 connect(ui->toggleWireframe_Action, &QAction::triggered,
this, [
this](
bool checked)
5385 qApp->Seamly2DSettings()->setWireframe(checked);
5386 ui->view->itemClicked(nullptr);
5390 connect(ui->toggleControlPoints_Action, &QAction::triggered,
this, [
this](
bool checked)
5392 qApp->Seamly2DSettings()->setShowControlPoints(checked);
5393 ui->view->itemClicked(nullptr);
5394 draftScene->enablePiecesMode(checked);
5397 connect(ui->toggleAxisOrigin_Action, &QAction::triggered,
this, [
this](
bool checked)
5399 qApp->Seamly2DSettings()->setShowAxisOrigin(checked);
5400 draftScene->setOriginsVisible(checked);
5401 pieceScene->setOriginsVisible(checked);
5404 connect(ui->toggleSeamAllowances_Action, &QAction::triggered,
this, [
this](
bool checked)
5406 qApp->Seamly2DSettings()->setShowSeamAllowances(checked);
5407 ui->view->itemClicked(nullptr);
5408 refreshSeamAllowances();
5411 connect(ui->toggleGrainLines_Action, &QAction::triggered,
this, [
this](
bool checked)
5413 qApp->Seamly2DSettings()->setShowGrainlines(checked);
5414 ui->view->itemClicked(nullptr);
5415 refreshGrainLines();
5418 connect(ui->toggleLabels_Action, &QAction::triggered,
this, [
this](
bool checked)
5420 qApp->Seamly2DSettings()->setShowLabels(checked);
5421 ui->view->itemClicked(nullptr);
5430 connect(ui->increaseSize_Action, &QAction::triggered,
this, [
this]()
5432 int index = qMin(fontSizeComboBox->currentIndex() + 1, fontSizeComboBox->count()-1);
5433 fontSizeComboBox->setCurrentIndex(index);
5434 qApp->Seamly2DSettings()->setPointNameSize(fontSizeComboBox->currentText().toInt());
5438 connect(ui->decreaseSize_Action, &QAction::triggered,
this, [
this]()
5440 const int index = qMax(fontSizeComboBox->currentIndex() - 1, 0);
5441 fontSizeComboBox->setCurrentIndex(index);
5442 qApp->Seamly2DSettings()->setPointNameSize(fontSizeComboBox->currentText().toInt());
5446 connect(ui->showPointNames_Action, &QAction::triggered,
this, [
this](
bool checked)
5448 qApp->Seamly2DSettings()->setHidePointNames(checked);
5452 connect(ui->useToolColor_Action, &QAction::triggered,
this, [
this](
bool checked)
5454 qApp->Seamly2DSettings()->setUseToolColor(checked);
5459 connect(ui->newDraft_Action, &QAction::triggered,
this, [
this]()
5461 qCDebug(vMainWindow,
"New Draft Block.");
5462 QString draftBlockName = tr(
"Draft Block %1").arg(draftBlockComboBox->count()+1);
5463 qCDebug(vMainWindow,
"Generated Draft Block name: %s", qUtf8Printable(draftBlockName));
5465 qCDebug(vMainWindow,
"Draft Block count %d", draftBlockComboBox->count());
5466 draftBlockName = createDraftBlockName(draftBlockName);
5467 qCDebug(vMainWindow,
"Draft Block name: %s", qUtf8Printable(draftBlockName));
5468 if (draftBlockName.isEmpty())
5470 qCDebug(vMainWindow,
"Draft Block name is empty.");
5474 addDraftBlock(draftBlockName);
5478 connect(ui->midpoint_Action, &QAction::triggered,
this, [
this]
5480 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5481 ui->midpoint_ToolButton->setChecked(true);
5482 handleMidpointTool(true);
5484 connect(ui->pointAtDistanceAngle_Action, &QAction::triggered,
this, [
this]
5486 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5487 ui->pointAtDistanceAngle_ToolButton->setChecked(true);
5488 handlePointAtDistanceAngleTool(true);
5490 connect(ui->pointAlongLine_Action, &QAction::triggered,
this, [
this]
5492 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5493 ui->alongLine_ToolButton->setChecked(true);
5494 handleAlongLineTool(true);
5496 connect(ui->pointAlongPerpendicular_Action, &QAction::triggered,
this, [
this]
5498 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5499 ui->normal_ToolButton->setChecked(true);
5500 handleNormalTool(true);
5502 connect(ui->bisector_Action, &QAction::triggered,
this, [
this]
5504 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5505 ui->bisector_ToolButton->setChecked(true);
5506 handleBisectorTool(true);
5508 connect(ui->pointOnShoulder_Action, &QAction::triggered,
this, [
this]
5510 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5511 ui->shoulderPoint_ToolButton->setChecked(true);
5512 handleShoulderPointTool(true);
5514 connect(ui->pointOfContact_Action, &QAction::triggered,
this, [
this]
5516 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5517 ui->pointOfContact_ToolButton->setChecked(true);
5518 handlePointOfContactTool(true);
5520 connect(ui->triangle_Action, &QAction::triggered,
this, [
this]
5522 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5523 ui->triangle_ToolButton->setChecked(true);
5524 handleTriangleTool(true);
5526 connect(ui->pointIntersectXY_Action, &QAction::triggered,
this, [
this]
5528 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5529 ui->pointIntersectXY_ToolButton->setChecked(true);
5530 handlePointIntersectXYTool(true);
5532 connect(ui->perpendicularPoint_Action, &QAction::triggered,
this, [
this]
5534 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5535 ui->height_ToolButton->setChecked(true);
5536 handleHeightTool(true);
5538 connect(ui->pointIntersectAxis_Action, &QAction::triggered,
this, [
this]
5540 ui->draft_ToolBox->setCurrentWidget(ui->points_Page);
5541 ui->lineIntersectAxis_ToolButton->setChecked(true);
5542 handleLineIntersectAxisTool(true);
5546 connect(ui->lineTool_Action, &QAction::triggered,
this, [
this]
5549 ui->draft_ToolBox->setCurrentWidget(ui->lines_Page);
5550 ui->line_ToolButton->setChecked(true);
5551 handleLineTool(true);
5553 connect(ui->lineIntersect_Action, &QAction::triggered,
this, [
this]
5555 ui->draft_ToolBox->setCurrentWidget(ui->lines_Page);
5556 ui->lineIntersect_ToolButton->setChecked(true);
5557 handleLineIntersectTool(true);
5561 connect(ui->curve_Action, &QAction::triggered,
this, [
this]
5563 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5564 ui->curve_ToolButton->setChecked(true);
5565 handleCurveTool(true);
5567 connect(ui->spline_Action, &QAction::triggered,
this, [
this]
5569 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5570 ui->spline_ToolButton->setChecked(true);
5571 handleSplineTool(true);
5573 connect(ui->curveWithCPs_Action, &QAction::triggered,
this, [
this]
5575 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5576 ui->curveWithCPs_ToolButton->setChecked(true);
5577 handleCurveWithControlPointsTool(true);
5579 connect(ui->splineWithCPs_Action, &QAction::triggered,
this, [
this]
5581 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5582 ui->splineWithCPs_ToolButton->setChecked(true);
5583 handleSplineWithControlPointsTool(true);
5585 connect(ui->pointAlongCurve_Action, &QAction::triggered,
this, [
this]
5587 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5588 ui->pointAlongCurve_ToolButton->setChecked(true);
5589 handlePointAlongCurveTool(true);
5591 connect(ui->pointAlongSpline_Action, &QAction::triggered,
this, [
this]
5593 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5594 ui->pointAlongSpline_ToolButton->setChecked(true);
5595 handlePointAlongSplineTool(true);
5597 connect(ui->curveIntersectCurve_Action, &QAction::triggered,
this, [
this]
5599 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5600 ui->pointOfIntersectionCurves_ToolButton->setChecked(true);
5601 handleCurveIntersectCurveTool(true);
5603 connect(ui->splineIntersectAxis_Action, &QAction::triggered,
this, [
this]
5605 ui->draft_ToolBox->setCurrentWidget(ui->curves_Page);
5606 ui->curveIntersectAxis_ToolButton->setChecked(true);
5607 handleCurveIntersectAxisTool(true);
5611 connect(ui->arcTool_Action, &QAction::triggered,
this, [
this]
5613 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5614 ui->arc_ToolButton->setChecked(true);
5615 handleArcTool(true);
5618 connect(ui->pointAlongArc_Action, &QAction::triggered,
this, [
this]
5620 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5621 ui->pointAlongArc_ToolButton->setChecked(true);
5622 handlePointAlongArcTool(true);
5625 connect(ui->arcIntersectAxis_Action, &QAction::triggered,
this, [
this]
5627 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5628 ui->arcIntersectAxis_ToolButton->setChecked(true);
5629 handleArcIntersectAxisTool(true);
5632 connect(ui->arcIntersectArc_Action, &QAction::triggered,
this, [
this]
5634 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5635 ui->pointOfIntersectionArcs_ToolButton->setChecked(true);
5636 handlePointOfIntersectionArcsTool(true);
5639 connect(ui->circleIntersect_Action, &QAction::triggered,
this, [
this]
5641 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5642 ui->pointOfIntersectionCircles_ToolButton->setChecked(true);
5643 handlePointOfIntersectionCirclesTool(true);
5646 connect(ui->circleTangent_Action, &QAction::triggered,
this, [
this]
5648 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5649 ui->pointFromCircleAndTangent_ToolButton->setChecked(true);
5650 handlePointFromCircleAndTangentTool(true);
5653 connect(ui->arcTangent_Action, &QAction::triggered,
this, [
this]
5655 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5656 ui->pointFromArcAndTangent_ToolButton->setChecked(true);
5657 handlePointFromArcAndTangentTool(true);
5660 connect(ui->arcWithLength_Action, &QAction::triggered,
this, [
this]
5662 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5663 ui->arcWithLength_ToolButton->setChecked(true);
5664 handleArcWithLengthTool(true);
5667 connect(ui->ellipticalArc_Action, &QAction::triggered,
this, [
this]
5669 ui->draft_ToolBox->setCurrentWidget(ui->arcs_Page);
5670 ui->ellipticalArc_ToolButton->setChecked(true);
5671 handleEllipticalArcTool(true);
5675 connect(ui->group_Action, &QAction::triggered,
this, [
this]
5677 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5678 ui->group_ToolButton->setChecked(true);
5679 handleGroupTool(true);
5682 connect(ui->rotation_Action, &QAction::triggered,
this, [
this]
5684 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5685 ui->rotation_ToolButton->setChecked(true);
5686 handleRotationTool(true);
5689 connect(ui->mirrorByLine_Action, &QAction::triggered,
this, [
this]
5691 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5692 ui->mirrorByLine_ToolButton->setChecked(true);
5693 handleMirrorByLineTool(true); });
5694 connect(ui->mirrorByAxis_Action, &QAction::triggered,
this, [
this]
5696 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5697 ui->mirrorByAxis_ToolButton->setChecked(true);
5698 handleMirrorByAxisTool(true);
5701 connect(ui->move_Action, &QAction::triggered,
this, [
this]
5703 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5704 ui->move_ToolButton->setChecked(true);
5705 handleMoveTool(true);
5708 connect(ui->trueDarts_Action, &QAction::triggered,
this, [
this]
5710 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5711 ui->trueDarts_ToolButton->setChecked(true);
5712 handleTrueDartTool(true);
5715 connect(ui->exportDraftBlocks_Action, &QAction::triggered,
this, [
this]
5717 ui->draft_ToolBox->setCurrentWidget(ui->operations_Page);
5718 exportDraftBlocksAs();
5722 connect(ui->union_Action, &QAction::triggered,
this, [
this]
5724 ui->piece_ToolBox->setCurrentWidget(ui->details_Page);
5725 ui->unitePieces_ToolButton->setChecked(true);
5726 handleUnionTool(true);
5729 connect(ui->exportPieces_Action, &QAction::triggered,
this, [
this]
5731 ui->piece_ToolBox->setCurrentWidget(ui->details_Page);
5736 connect(ui->addPiece_Action, &QAction::triggered,
this, [
this]
5738 ui->draft_ToolBox->setCurrentWidget(ui->piece_Page);
5739 ui->addPatternPiece_ToolButton->setChecked(true);
5740 handlePatternPieceTool(true);
5742 connect(ui->anchorPoint_Action, &QAction::triggered,
this, [
this]
5744 ui->draft_ToolBox->setCurrentWidget(ui->piece_Page);
5745 ui->anchorPoint_ToolButton->setChecked(true);
5746 handleAnchorPointTool(true);
5748 connect(ui->internalPath_Action, &QAction::triggered,
this, [
this]
5750 ui->draft_ToolBox->setCurrentWidget(ui->piece_Page);
5751 ui->internalPath_ToolButton->setChecked(true);
5752 handleInternalPathTool(true);
5754 connect(ui->insertNodes_Action, &QAction::triggered,
this, [
this]
5756 ui->draft_ToolBox->setCurrentWidget(ui->piece_Page);
5757 ui->insertNodes_ToolButton->setChecked(true);
5758 handleInsertNodesTool(true);
5762 connect(ui->newPrintLayout_Action, &QAction::triggered,
this, [
this]
5764 ui->layout_ToolBox->setCurrentWidget(ui->layout_Page);
5765 ui->layoutSettings_ToolButton->setChecked(true);
5766 handleNewLayout(true);
5769 connect(ui->exportLayout_Action, &QAction::triggered,
this, [
this]
5771 ui->layout_ToolBox->setCurrentWidget(ui->layout_Page);
5778 connect(ui->openSeamlyMe_Action, &QAction::triggered,
this, [
this]()
5780 const QString seamlyme = qApp->SeamlyMeFilePath();
5781 const QString workingDirectory = QFileInfo(seamlyme).absoluteDir().absolutePath();
5783 QStringList arguments;
5786 arguments.append(QLatin1String(
"--") + LONG_OPTION_NO_HDPI_SCALING);
5789 QProcess::startDetached(seamlyme, arguments, workingDirectory);
5797 connect(ui->table_Action, &QAction::triggered,
this, [
this](
bool checked)
5801 dialogTable = new DialogVariables(pattern, doc, this);
5802 connect(dialogTable.data(), &DialogVariables::updateProperties, toolProperties,
5803 &VToolOptionsPropertyBrowser::refreshOptions);
5804 connect(dialogTable.data(), &DialogVariables::DialogClosed, this, [this]()
5806 ui->table_Action->setChecked(false);
5807 if (dialogTable != nullptr)
5812 dialogTable->show();
5816 ui->table_Action->setChecked(true);
5817 dialogTable->activateWindow();
5823 connect(ui->history_Action, &QAction::triggered,
this, [
this](
bool checked)
5827 historyDialog = new HistoryDialog(pattern, doc, this);
5828 connect(this, &MainWindow::RefreshHistory, historyDialog.data(), &HistoryDialog::updateHistory);
5829 connect(historyDialog.data(), &HistoryDialog::DialogClosed, this, [this]()
5831 ui->history_Action->setChecked(false);
5832 if (historyDialog != nullptr)
5834 delete historyDialog;
5837 historyDialog->show();
5841 ui->history_Action->setChecked(true);
5842 historyDialog->activateWindow();
5847 connect(ui->calculator_Action, &QAction::triggered,
this, [
this]()
5849 CalculatorDialog *calcDialog = new CalculatorDialog(this);
5850 calcDialog->setAttribute(Qt::WA_DeleteOnClose, true);
5851 calcDialog->setWindowTitle(tr(
"Calculator"));
5852 calcDialog->adjustSize();
5856 connect(ui->decimalChart_Action, &QAction::triggered,
this, [
this]()
5858 DecimalChartDialog *decimalchartDialog = new DecimalChartDialog(this);
5859 decimalchartDialog->setAttribute(Qt::WA_DeleteOnClose, true);
5860 decimalchartDialog->show();
5864 connect(ui->shortcuts_Action, &QAction::triggered,
this, [
this]()
5866 ShortcutsDialog *shortcutsDialog = new ShortcutsDialog(this);
5867 shortcutsDialog->setAttribute(Qt::WA_DeleteOnClose, true);
5868 shortcutsDialog->show();
5870 connect(ui->wiki_Action, &QAction::triggered,
this, []()
5872 qCDebug(vMainWindow,
"Showing online help");
5873 QDesktopServices::openUrl(QUrl(QStringLiteral(
"https://wiki.seamly.net/wiki/Main_Page")));
5876 connect(ui->forum_Action, &QAction::triggered,
this, []()
5878 qCDebug(vMainWindow,
"Opening forum");
5879 QDesktopServices::openUrl(QUrl(QStringLiteral(
"https://forum.seamly.net/")));
5882 connect(ui->reportBug_Action, &QAction::triggered,
this, []()
5884 qCDebug(vMainWindow,
"Reporting bug");
5885 QDesktopServices::openUrl(QUrl(QStringLiteral(
5886 "https://github.com/FashionFreedom/Seamly2D/issues/new?&labels=bug&template=bug_report.md&title=BUG%3A")));
5889 connect(ui->aboutQt_Action, &QAction::triggered,
this, [
this]()
5891 QMessageBox::aboutQt(this, tr(
"About Qt"));
5894 connect(ui->aboutSeamly2D_Action, &QAction::triggered,
this, [
this]()
5896 DialogAboutApp *aboutDialog = new DialogAboutApp(this);
5897 aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
5898 aboutDialog->show();
5925 if (
qApp->Seamly2DSettings()->GetAutosaveState())
5927 const qint32 autoTime =
qApp->Seamly2DSettings()->getAutosaveInterval();
5929 qCDebug(vMainWindow,
"Autosaving every %d minutes.", autoTime);
5937 QInputDialog *dialog =
new QInputDialog(
this);
5938 dialog->setInputMode( QInputDialog::TextInput );
5939 dialog->setLabelText(tr(
"Name:"));
5940 dialog->setTextEchoMode(QLineEdit::Normal);
5941 dialog->setWindowTitle(tr(
"Draft block."));
5942 dialog->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint
5943 & ~Qt::WindowMaximizeButtonHint
5944 & ~Qt::WindowMinimizeButtonHint);
5945 dialog->resize(300, 100);
5946 dialog->setTextValue(text);
5947 QString draftBlockName;
5950 const bool result = dialog->exec();
5951 draftBlockName = dialog->textValue();
5952 if (result ==
false || draftBlockName.isEmpty())
5962 QMessageBox messageBox;
5963 messageBox.setWindowTitle(tr(
"Name Exists"));
5964 messageBox.setIcon(QMessageBox::Warning);
5965 messageBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel);
5966 messageBox.setDefaultButton(QMessageBox::Retry);
5967 messageBox.setText(tr(
"The action can't be completed because the Draft Block name already exists."));
5968 int boxResult = messageBox.exec();
5972 case QMessageBox::Retry:
5974 case QMessageBox::Cancel:
5981 return draftBlockName;
6001 qCDebug(vMainWindow,
"Loading new file %s.", qUtf8Printable(fileName));
6009 if (fileName.isEmpty())
6011 qCDebug(vMainWindow,
"New loaded filename is empty.");
6027 const QString seamlyme =
qApp->SeamlyMeFilePath();
6028 const QString workingDirectory = QFileInfo(seamlyme).absoluteDir().absolutePath();
6030 QStringList arguments = QStringList() << fileName;
6036 QProcess::startDetached(seamlyme, arguments, workingDirectory);
6043 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"File error.")),
6053 qCDebug(vMainWindow,
"Locking file");
6056 if (
lock->IsLocked())
6058 qCDebug(vMainWindow,
"Pattern file %s was locked.", qUtf8Printable(fileName));
6072 qApp->setOpeningPattern();
6079 if (!customMeasureFile.isEmpty())
6086 if (not path.isEmpty())
6090 if (newPath.isEmpty())
6092 qApp->setOpeningPattern();
6094 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"The measurements file '%1' could not be found.")
6105 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"The measurements file '%1' could not be found.")
6107 qApp->setOpeningPattern();
6117 ui->unloadMeasurements_Action->setEnabled(
true);
6119 ui->editCurrent_Action->setEnabled(
true);
6130 qCCritical(vMainWindow,
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"File error.")),
6132 qApp->setOpeningPattern();
6149 qCDebug(vMainWindow,
"File loaded.");
6157 qApp->setOpeningPattern();
6162 qApp->setOpeningPattern();
6170 QStringList restoreFiles;
6172 QStringList files =
qApp->Seamly2DSettings()->GetRestoreFileList();
6173 if (files.size() > 0)
6175 for (
int i = 0; i < files.size(); ++i)
6181 restoreFiles.append(files.at(i));
6186 for (
int i = 0; i < restoreFiles.size(); ++i)
6188 files.removeAll(restoreFiles.at(i));
6192 QStringList filtered;
6193 for (
int i = 0; i < files.size(); ++i)
6195 if (QFileInfo(files.at(i)).exists())
6197 filtered.append(files.at(i));
6201 qApp->Seamly2DSettings()->SetRestoreFileList(filtered);
6203 return restoreFiles;
6215 fontComboBox->setCurrentFont(
qApp->Seamly2DSettings()->getPointNameFont());
6231 if (index < 0 || index >=
scenes.size())
6237 ui->view->setScene(
scenes.at(index));
6240 ui->view->fitInView(
ui->view->scene()->sceneRect(), Qt::KeepAspectRatio);
6247 static QPointer<DialogPreferences> guard;
6250 QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
6253 QScopedPointer<DialogPreferences> dialog(preferences);
6254 guard = preferences;
6271 QGuiApplication::restoreOverrideCursor();
6273 if (guard->exec() == QDialog::Accepted)
6281 #if defined(Q_OS_MAC)
6282 void MainWindow::CreateMeasurements()
6284 const QString seamlyme =
qApp->SeamlyMeFilePath();
6285 const QString workingDirectory = QFileInfo(seamlyme).absoluteDir().absolutePath();
6287 QStringList arguments;
6293 QProcess::startDetached(seamlyme, arguments, workingDirectory);
6300 ui->exportLayout_ToolButton->setChecked(
true);
6306 ui->exportLayout_ToolButton->setChecked(
false);
6315 if (dialog.exec() == QDialog::Rejected)
6317 ui->exportLayout_ToolButton->setChecked(
false);
6325 ui->exportLayout_ToolButton->setChecked(
false);
6326 qCritical(
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Export error.")),
6330 ui->exportLayout_ToolButton->setChecked(
false);
6336 ui->arrowPointer_ToolButton->setChecked(
false);
6337 ui->arrow_Action->setChecked(
false);
6338 ui->exportPiecesAs_ToolButton->setChecked(
true);
6343 while (i != allPieces->constEnd())
6345 if (i.value().isInLayout())
6347 piecesInLayout.insert(i.key(), i.value());
6352 if (piecesInLayout.count() == 0)
6354 QMessageBox::information(
this, tr(
"Layout mode"), tr(
"You don't have any pieces to export. Please, "
6355 "include at least one piece in layout."),
6356 QMessageBox::Ok, QMessageBox::Ok);
6367 QMessageBox::warning(
this, tr(
"Export pieces"),
6368 tr(
"Can't export pieces.") + QLatin1String(
" \n") + e.
ErrorMessage(),
6369 QMessageBox::Ok, QMessageBox::Ok);
6376 dialog.setWindowTitle(
"Export Pattern Pieces");
6378 if (dialog.exec() == QDialog::Rejected)
6380 ui->exportPiecesAs_ToolButton->setChecked(
false);
6388 ui->exportPiecesAs_ToolButton->setChecked(
false);
6389 qCritical(
"%s\n\n%s\n\n%s", qUtf8Printable(tr(
"Export error.")),
6394 ui->arrowPointer_ToolButton->setChecked(
true);
6395 ui->arrow_Action->setChecked(
true);
6396 ui->exportPiecesAs_ToolButton->setChecked(
false);
6403 ui->arrowPointer_ToolButton->setChecked(
false);
6404 ui->arrow_Action->setChecked(
false);
6405 ui->exportDraftBlocks_ToolButton->setChecked(
true);
6408 int vScrollBar =
ui->view->verticalScrollBar()->value();
6409 int hScrollBar =
ui->view->horizontalScrollBar()->value();
6410 QTransform viewTransform =
ui->view->transform();
6413 ui->view->zoomToFit();
6414 ui->view->repaint();
6415 ui->view->zoom100Percent();
6419 for (
auto *item : items)
6421 item->setEnabled(
true);
6423 ui->view->repaint();
6429 dialog.setWindowTitle(
"Export Draft Blocks");
6431 if (dialog.exec() == QDialog::Accepted)
6433 const QString filename = QString(
"%1/%2%3")
6441 QGraphicsRectItem *paper =
new QGraphicsRectItem(rect);
6442 QMarginsF
margins = QMarginsF(0, 0, 0, 0);
6531 ui->view->setTransform(viewTransform);
6535 ui->view->verticalScrollBar()->setValue(vScrollBar);
6536 ui->view->horizontalScrollBar()->setValue(hScrollBar);
6539 ui->arrowPointer_ToolButton->setChecked(
true);
6540 ui->arrow_Action->setChecked(
true);
6541 ui->exportDraftBlocks_ToolButton->setChecked(
false);
6548 if (files.size() > 0)
6550 qCDebug(vMainWindow,
"Reopen files after crash.");
6552 QStringList restoreFiles;
6553 for (
int i = 0; i < files.size(); ++i)
6558 restoreFiles.append(files.at(i));
6562 if (restoreFiles.size() > 0)
6564 QMessageBox::StandardButton reply;
6565 const QString mes = tr(
"Seamly2D didn't shut down correctly. Do you want reopen files (%1) you had open?")
6566 .arg(restoreFiles.size());
6567 reply = QMessageBox::question(
this, tr(
"Reopen files."), mes, QMessageBox::Yes|QMessageBox::No,
6569 if (reply == QMessageBox::Yes)
6571 qCDebug(vMainWindow,
"User said Yes.");
6573 for (
int i = 0; i < restoreFiles.size(); ++i)
6581 args.removeAll(restoreFiles.at(i));
6585 qCDebug(vMainWindow,
"Could not copy %s%s to %s %s",
6586 qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(
autosavePrefix),
6587 qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(error));
6603 QFileInfo table(path);
6604 if (table.exists() ==
false)
6612 const QString text = tr(
"The measurements file <br/><br/> <b>%1</b> <br/><br/> could not be found. Do you "
6613 "want to update the file location?").arg(path);
6614 QMessageBox::StandardButton res = QMessageBox::question(
this, tr(
"Loading measurements file"), text,
6615 QMessageBox::Yes | QMessageBox::No,
6617 if (res == QMessageBox::No)
6624 if (table.suffix() == QLatin1String(
"vst"))
6628 else if (table.suffix() == QLatin1String(
"vit"))
6640 const QString filter = tr(
"Multisize measurements") + QLatin1String(
" (*.vst)");
6642 QString path =
qApp->Seamly2DSettings()->GetPathMultisizeMeasurements();
6644 mPath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), path, filter,
nullptr,
6645 QFileDialog::DontUseNativeDialog);
6649 const QString filter = tr(
"Individual measurements") + QLatin1String(
" (*.vit)");
6651 const QString path =
qApp->Seamly2DSettings()->GetPathIndividualMeasurements();
6653 bool usedNotExistedDir =
false;
6654 QDir directory(path);
6655 if (not directory.exists())
6657 usedNotExistedDir = directory.mkpath(
".");
6660 mPath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), path, filter,
nullptr,
6661 QFileDialog::DontUseNativeDialog);
6663 if (usedNotExistedDir)
6665 QDir directory(path);
6666 directory.rmpath(
".");
6671 const QString filter = tr(
"Individual measurements") + QLatin1String(
" (*.vit);;") +
6672 tr(
"Multisize measurements") + QLatin1String(
" (*.vst)");
6674 const QString path =
qApp->Seamly2DSettings()->GetPathIndividualMeasurements();
6677 bool usedNotExistedDir =
false;
6678 QDir directory(path);
6679 if (not directory.exists())
6681 usedNotExistedDir = directory.mkpath(
".");
6684 mPath = QFileDialog::getOpenFileName(
this, tr(
"Open file"), path, filter,
nullptr,
6685 QFileDialog::DontUseNativeDialog);
6687 if (usedNotExistedDir)
6689 QDir directory(path);
6690 directory.rmpath(
".");
6694 if (mPath.isEmpty())
6703 measurements->setXMLContent(mPath);
6705 patternType = measurements->Type();
6709 VException e(tr(
"Measurement file has unknown format."));
6716 measurements->setXMLContent(converter.
Convert());
6721 measurements->setXMLContent(converter.
Convert());
6724 if (not measurements->IsDefinedKnownNamesValid())
6726 VException e(tr(
"Measurement file contains invalid known measurement(s)."));
6732 qApp->setPatternType(patternType);
6785 ui->view->zoomToFit();
6787 if (not
ui->showDraftMode->isChecked())
6799 ui->view->zoomToFit();
6802 if (not
ui->showDraftMode->isChecked())
6812 if(not
qApp->getOpeningPattern())
6814 if (
pieces->count() == 0)
6816 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"You can't export empty scene.")));
6823 const bool exportOnlyPieces = expParams->exportOnlyPieces();
6824 if (exportOnlyPieces)
6838 qCCritical(vMainWindow,
"%s\n\n%s", qUtf8Printable(tr(
"Export error.")), qUtf8Printable(e.
ErrorMessage()));
6845 auto settings = expParams->DefaultGenerator();
6846 settings->SetTestAsPaths(expParams->isTextAsPaths());
6861 qCCritical(vMainWindow,
"%s\n\n%s", qUtf8Printable(tr(
"Export error.")), qUtf8Printable(e.
ErrorMessage()));
6880 if (this->isWindowModified() || not
qApp->getFilePath().isEmpty())
6885 const qint32 index =
gradationSizes->findText(QString().setNum(size));
6892 qCCritical(vMainWindow,
"%s",
6893 qUtf8Printable(tr(
"Not supported size value '%1' for this pattern file.").arg(text)));
6899 qCCritical(vMainWindow,
"%s",
6900 qUtf8Printable(tr(
"Couldn't set size. Need a file with multisize measurements.")));
6906 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"Couldn't set size. File wasn't opened.")));
6912 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
6923 if (this->isWindowModified() || not
qApp->getFilePath().isEmpty())
6935 qCCritical(vMainWindow,
"%s",
6936 qUtf8Printable(tr(
"Not supported height value '%1' for this pattern file.").arg(text)));
6942 qCCritical(vMainWindow,
"%s",
6943 qUtf8Printable(tr(
"Couldn't set height. Need a file with multisize measurements.")));
6949 qCCritical(vMainWindow,
"%s", qUtf8Printable(tr(
"Couldn't set height. File wasn't opened.")));
6955 qCWarning(vMainWindow,
"%s", qUtf8Printable(tr(
"The method %1 does nothing in GUI mode").arg(Q_FUNC_INFO)));
6965 auto args = cmd->OptInputFileNames();
6975 if (args.size() != 1)
6977 qCritical() << tr(
"Please, provide one input file.");
6983 for (
int i=0, sz = args.size(); i < sz; ++i)
6985 const bool loaded =
LoadPattern(args.at(
static_cast<int>(i)), cmd->OptMeasurePath());
6992 bool hSetted =
true;
6993 bool sSetted =
true;
6994 if (loaded && (cmd->IsTestModeEnabled() || cmd->IsExportEnabled()))
6996 if (cmd->IsSetGradationSize())
6998 sSetted =
SetSize(cmd->OptGradationSize());
7001 if (cmd->IsSetGradationHeight())
7003 hSetted =
SetHeight(cmd->OptGradationHeight());
7007 if (not cmd->IsTestModeEnabled())
7009 if (cmd->IsExportEnabled())
7011 if (loaded && hSetted && sSetted)
7035 QString shownName = tr(
"untitled.val");
7036 if(not
qApp->getFilePath().isEmpty())
7038 shownName =
qApp->getFilePath();
7040 shownName += QLatin1String(
"[*]");
7053 QString shownName(
" - [");
7058 shownName += QLatin1String(
"*");
7061 shownName += QLatin1String(
"]");
7069 bool isFileWritable =
true;
7070 if (!
qApp->getFilePath().isEmpty())
7073 qt_ntfs_permission_lookup++;
7075 isFileWritable = QFileInfo(
qApp->getFilePath()).isWritable();
7077 qt_ntfs_permission_lookup--;
7090 setWindowFilePath(
qApp->getFilePath());
7092 #if defined(Q_OS_MAC)
7093 static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() +
7094 QLatin1String(
"/../Resources/Seamly2D.icns"));
7096 if (!
qApp->getFilePath().isEmpty())
7098 if (!isWindowModified())
7104 static QIcon darkIcon;
7106 if (darkIcon.isNull())
7108 darkIcon = QIcon(
darkenPixmap(fileIcon.pixmap(16, 16)));
7113 setWindowIcon(icon);
7132 ui->toggleWireframe_Action->setChecked(
qApp->Settings()->isWireframe());
7133 ui->toggleControlPoints_Action->setChecked(
qApp->Settings()->getShowControlPoints());
7134 ui->toggleAxisOrigin_Action->setChecked(
qApp->Settings()->getShowAxisOrigin());
7135 ui->toggleGrainLines_Action->setChecked(
qApp->Settings()->showGrainlines());
7136 ui->toggleSeamAllowances_Action->setChecked(
qApp->Settings()->showSeamAllowances());
7137 ui->toggleLabels_Action->setChecked(
qApp->Settings()->showLabels());
7143 zoomPanShortcuts =
ui->zoomPan_Action->shortcuts();
7144 zoomPanShortcuts.removeAll(QKeySequence(Qt::Key_Space));
7145 if (!
qApp->Seamly2DSettings()->isPanActiveSpaceKey())
7147 zoomPanShortcuts.append(QKeySequence(Qt::Key_Space));
7149 ui->zoomPan_Action->setShortcuts(zoomPanShortcuts);
7155 QMessageBox::StandardButton answer = QMessageBox::Abort;
7160 case QLockFile::LockFailedError:
7161 answer = QMessageBox::warning(
this, tr(
"Locking file"),
7162 tr(
"This file already opened in another window. Ignore if you want "
7163 "to continue (not recommended, can cause a data corruption)."),
7164 QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
7166 case QLockFile::PermissionError:
7167 answer = QMessageBox::question(
this, tr(
"Locking file"),
7168 tr(
"The lock file could not be created, for lack of permissions. "
7169 "Ignore if you want to continue (not recommended, can cause "
7170 "a data corruption)."),
7171 QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
7173 case QLockFile::UnknownError:
7174 answer = QMessageBox::question(
this, tr(
"Locking file"),
7175 tr(
"Unknown error happened, for instance a full partition prevented "
7176 "writing out the lock file. Ignore if you want to continue (not "
7177 "recommended, can cause a data corruption)."),
7178 QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
7181 answer = QMessageBox::Abort;
7186 if (answer == QMessageBox::Abort)
7188 qCDebug(vMainWindow,
"Failed to lock %s", qUtf8Printable(path));
7189 qCDebug(vMainWindow,
"Error type: %d", error);
7195 case QLockFile::LockFailedError:
7196 qCCritical(vMainWindow,
"%s",
7197 qUtf8Printable(tr(
"This file already opened in another window.")));
7199 case QLockFile::PermissionError:
7200 qCCritical(vMainWindow,
"%s",
7201 qUtf8Printable(tr(
"The lock file could not be created, for lack of permissions.")));
7203 case QLockFile::UnknownError:
7204 qCCritical(vMainWindow,
"%s",
7205 qUtf8Printable(tr(
"Unknown error happened, for instance a full partition prevented "
7206 "writing out the lock file.")));
7225 QStringList pointNames;
7230 if (item.value()->getType() ==
GOType::Point && !pointNames.contains(item.value()->name()))
7231 pointNames << item.value()->name();
7234 pointNames.removeDuplicates();
7271 ui->view->allowRubberBand(
false);
7311 ui->view->allowRubberBand(
false);
7337 ui->view->allowRubberBand(
false);
7363 ui->view->allowRubberBand(
false);
7389 ui->view->allowRubberBand(
false);
7415 ui->view->allowRubberBand(
false);
7441 ui->view->allowRubberBand(
false);
7467 ui->view->allowRubberBand(
true);
7496 ui->view->allowRubberBand(
false);
void setDestinationPath(const QString &cmdDestinationPath)
LayoutExportFormat format() const
static QString exportFormatSuffix(LayoutExportFormat format)
void setTextAsPaths(bool textAsPaths)
void setBinaryDXFFormat(bool binary)
void selectFormat(LayoutExportFormat format)
The MainWindow class main windows.
void handlePointFromArcAndTangentTool(bool checked)
void handlePointOfIntersectionArcsTool(bool checked)
void selectPieceTool() const
void updateToolBarVisibility()
void EnableLabelSelection(bool enable) const
void EnableElArcSelection(bool enable) const
void ReopenFilesAfterCrash(QStringList &args)
QSharedPointer< VMeasurements > OpenMeasurementFile(const QString &path)
void ToolSelectSplinePath() const
void handleAlongLineTool(bool checked)
handleAlongLineTool handler for point along Line tools.
void ToolSelectPointArc() const
void initToolBarVisibility()
void enablePieceSelection(bool enable) const
void zoomScaleChanged(qreal scale)
void zoomFirstShow()
zoomFirstShow Fit scene size to best size for first show
QPointer< QComboBox > gradationSizes
void EnableElArcHover(bool enable) const
QPointer< MouseCoordinates > mouseCoordinates
mouseCoordinates pointer to label who show mouse coordinate.
void handleTriangleTool(bool checked)
handleTriangleTool handler Point - Intersect Axis and Triangle.
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle after close window.
void EnableNodeLabelHover(bool enable) const
void handleUnionTool(bool checked)
handleUnionTool handler for Union tool.
QPointer< HistoryDialog > historyDialog
void changeDraftBlock(int index, bool zoomBestFit=true)
bool UpdateMeasurements(const QString &path, int size, int height)
void updateZoomToPointComboBox(QStringList namesList)
updateZoomToPointComboBox updates the list of points included in the toolbar combobox.
virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE
ShowTool highlight tool.Tip show tools tooltip.
void showDraftMode(bool checked)
showDraftMode show draw scene.
void handleArcWithLengthTool(bool checked)
void EnableSplinePathHover(bool enable) const
QLabel * helpLabel
helpLabel help show tooltip.
void ClosedDrawDialogWithApply(int result)
bool isInitialized
isInitialized true after first show window.
void setToolBarVisibility(QToolBar *toolbar, bool visible)
QPointF draftBlockStartPosition() const
void UnloadMeasurements()
bool SetHeight(const QString &text)
void addSelectedItemsToGroup()
void initPenToolBar()
initPenToolBar enable default color, line wight & type toolbar.
void AutoSavePattern()
AutoSavePattern start safe saving.
bool Save()
Save save pattern file.
void ClosedDialogInternalPath(int result)
void EnableLineSelection(bool enable) const
void handleTrueDartTool(bool checked)
void handleShoulderPointTool(bool checked)
handleShoulderPointTool handler for shoulderPoint tool.
virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
keyPressEvent handle key press events.
virtual void customEvent(QEvent *event) Q_DECL_OVERRIDE
Ui::MainWindow * ui
ui keeps information about user interface
bool SavePattern(const QString &fileName, QString &error)
SavePattern save pattern file.
void EnablePointSelection(bool enable) const
void setCurrentFile(const QString &fileName)
setCurrentFile the function is called to reset the state of a few variables when a file is loaded or ...
void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot, Func2 applyDialogSlot)
SetToolButtonWithApply set tool and show dialog.
void ToolSelectPoint() const
QComboBox * fontSizeComboBox
void zoomPan(bool checked)
void addDraftBlock(const QString &blockName)
QAction * recentFileActs[MaxRecentFiles]
void handleInternalPathTool(bool checked)
VMainGraphicsScene * draftScene
draftScene draft block scene.
void ToolSelectCurve() const
void handleCurveIntersectCurveTool(bool checked)
void handlePointAtDistanceAngleTool(bool checked)
handlePointAtDistanceAngleTool handler for handlePointAtDistanceAngle tool.
void handleSplineWithControlPointsTool(bool checked)
QFontComboBox * fontComboBox
void UpdateHeightsList(const QStringList &list)
void ReadSettings()
ReadSettings read setting for app.
void EnablePointHover(bool enable) const
void New()
NewPattern create new empty pattern.
void enablePieceHover(bool enable) const
void showZoomToPointDialog()
zoomToPoint show dialog for choosing a point and update the graphics view to focus on it.
QPointer< QLabel > gradationSizesLabel
void EnableItemMove(bool move)
void handleMirrorByLineTool(bool checked)
void handleRotationTool(bool checked)
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
void ClosedInsertNodesDialog(int result)
void WriteSettings()
WriteSettings save setting for app.
void ChangedHeight(int index)
ChangedGrowth change new height value.
void EnableLineHover(bool enable) const
QString createDraftBlockName(const QString &text)
void ClosedDialogAnchorPoint(int result)
bool SaveAs()
SaveAs save as pattern file.
VToolOptionsPropertyBrowser * toolProperties
bool isLayoutsDockVisible
void handleLineIntersectTool(bool checked)
handleLineIntersectTool handler for lineIntersect tool.
virtual void CleanLayout() Q_DECL_OVERRIDE
void ClosedEditGroupDialog(int result)
void handleNewLayout(bool checked)
handleNewLayout handler for New Layout tool.
void handleCurveWithControlPointsTool(bool checked)
void handleEllipticalArcTool(bool checked)
handleEllipticalArcTool handler for EllipticalArc tool.
void MouseMove(const QPointF &scenePos)
mouseMove save mouse position and show user.
void handleSplineTool(bool checked)
handleSplineTool handler for spline tool.
void Open()
Open ask user select pattern file.
void exportDraftBlocksAs()
void zoomToPoint(const QString &pointName)
zoomToPoint show dialog for choosing a point and update the graphics view to focus on it.
void SetLayoutModeActions()
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
showEvent handle after show window.
void ToolSelectOperationObjects() const
void ClosedDialogWithApply(int result, VMainGraphicsScene *scene)
ClosedDialogWithApply handle close dialog that has apply button.
Tool lastUsedTool
tool last used tool
void showLayoutMode(bool checked)
showLayoutMode show layout scene.
PenToolBar * m_penToolBar
for selecting the current pen
virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE
keyReleaseEvent handle key press events.
PiecesWidget * patternPiecesWidget
void deleteGroupFromList()
GroupsWidget * groupsWidget
void RestoreCurrentScene()
RestoreCurrentScene restore scene options after change.
void handleGroupTool(bool checked)
void EnableSplineSelection(bool enable) const
void handleArrowTool(bool checked)
handleArrowTool enable arrow tool.
void handleNormalTool(bool checked)
handleNormalTool handler point on perpendicular tool.
virtual ~MainWindow() Q_DECL_OVERRIDE
void handleArcTool(bool checked)
handleArcTool handler for arc tool.
void handleArcIntersectAxisTool(bool checked)
void zoomToArea(bool checked)
QFileSystemWatcher * watcher
virtual void exportToCSVData(const QString &fileName, const DialogExportToCSV &dialog) Q_DECL_FINAL
QComboBox * m_zoomToPointComboBox
void ItemsSelection(SelectionType type) const
bool LoadMeasurements(const QString &path)
void MeasurementsChanged(const QString &path)
void EnableSplinePathSelection(bool enable) const
void handleBisectorTool(bool checked)
handleBisectorTool handler for bisector tool.
bool SetSize(const QString &text)
bool IgnoreLocking(int error, const QString &path)
bool isToolboxDockVisible
bool OpenNewSeamly2D(const QString &fileName=QString()) const
void ToolSelectPointByRelease() const
void EnableArcSelection(bool enable) const
void handleLineTool(bool checked)
handleLineTool handler for line tool.
void ChangedSize(int index)
ChangedSize change new size value.
bool LoadPattern(const QString &fileName, const QString &customMeasureFile=QString())
LoadPattern open pattern file.
void selectAllDraftObjectsTool() const
Tool currentTool
tool current tool
VMainGraphicsScene * pieceScene
pieceScene pattern piece scene.
void handleLineIntersectAxisTool(bool checked)
void EnableNodeLabelSelection(bool enable) const
void SaveCurrentScene()
SaveCurrentScene save scene options before set another.
void setEnableTools(bool enable)
setEnableTools enable button.
void handleMoveTool(bool checked)
QString CheckPathToMeasurements(const QString &patternPath, const QString &path)
void ToolSelectPointByPress() const
void handlePointOfIntersectionCirclesTool(bool checked)
void handleMirrorByAxisTool(bool checked)
void handlePointOfContactTool(bool checked)
handlePointOfContactTool handler for pointOfContact tool.
void PatternChangesWereSaved(bool saved)
haveChange enable action save if we have unsaved change.
void handleMidpointTool(bool checked)
void EndVisualization(bool click=false)
EndVisualization try show dialog after and working with tool visualization.
QPointer< QComboBox > gradationHeights
QStringList GetUnlokedRestoreFileList() const
void handlePointAlongArcTool(bool checked)
handlePointAlongArcTool handler for PointAlongArc tool.
void initStatusBar()
initStatusBar initialize horizontal bar for presenting status information
void ToolSelectGroupObjects() const
void showLayoutPages(int index)
QString GetPatternFileName()
void SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot)
SetToolButton set tool and show dialog.
void closeUnionDialog(int result)
closeUnionDialog actions after closing Union tool dialog.
void EnableSplineHover(bool enable) const
void initDraftToolBar()
initDraftToolBar enable draw toolbar.
virtual void updateGroups() Q_DECL_OVERRIDE
triggers the update of the groups
void ToolSelectArc() const
void handlePointAlongCurveTool(bool checked)
handlePointAlongCurveTool handler for point along curve tool.
void showPieceMode(bool checked)
showPieceMode show Piece scene.
QDoubleSpinBox * zoomScaleSpinBox
void handlePatternPiecesMenu()
void Clear()
Clear reset to default window.
QComboBox * SetGradationList(QLabel *label, const QStringList &list)
void GlobalchangeDraftBlock(const QString &patternPiece)
qint32 currentBlockIndex
mode stores current draw mode.
std::shared_ptr< VLockGuard< char > > lock
void handlePointAlongSplineTool(bool checked)
handlePointAlongSplineTool handler for point along spline tool.
void ToolSelectSpline() const
bool MaybeSave()
MaybeSave The function is called to save pending changes.
void UpdateSizesList(const QStringList &list)
void handlePatternPieceTool(bool checked)
handlePatternPieceTool handler for pattern piece tool.
bool mChanges
mChanges true if measurement file was changed.
qint32 currentToolBoxIndex
currentBlockIndex current selected draft block.
void SetEnableWidgets(bool enable)
SetEnableWidgets enable action button.
virtual void zoomToSelected() Q_DECL_OVERRIDE
void EnableArcHover(bool enable) const
void ApplyDialog(VMainGraphicsScene *scene)
ApplyDialog handle apply in dialog.
void EnableNodePointSelection(bool enable) const
QString GetMeasurementFileName()
void handleAnchorPointTool(bool checked)
void handleOperationsMenu()
void handleCurveIntersectAxisTool(bool checked)
void UpdateRecentFileActions()
QPointer< QToolButton > infoToolButton
void MinimumScrollBar()
MinimumScrollBar set scroll bar to minimum.
void handlePointFromCircleAndTangentTool(bool checked)
QComboBox * draftBlockComboBox
QLabel * draftBlockLabel
draftBlockComboBox stores names of draft blocks.
void ClosedDialog(int result)
ClosedDialog handle close dialog.
void DoExport(const VCommandLinePtr &expParams)
void EnableNodePointHover(bool enable) const
QSharedPointer< DialogTool > dialogTool
virtual void PrepareSceneList() Q_DECL_OVERRIDE
void CancelTool()
CancelTool cancel tool.
void handleHeightTool(bool checked)
handleHeightTool handler tool height.
void EnableLabelHover(bool enable) const
QPointer< QLabel > gradationHeightsLabel
void ClosedPiecesDialogWithApply(int result)
void initPointNameToolBar()
initPointNameToolBar enable Point Name toolbar.
void handleCurveTool(bool checked)
handleCurveTool handler for curve tool.
QStringList draftPointNamesList()
draftPointNamesList gets the list of points in draft mode.
void handlePointIntersectXYTool(bool checked)
handlePointIntersectXYTool handler for pointOfIntersection tool.
bool isToolOptionsDockVisible
currentToolBoxIndex current set of tools.
void handleInsertNodesTool(bool checked)
void SetEnabledGUI(bool enabled)
void CheckRequiredMeasurements(const VMeasurements *m)
QGraphicsScene * tempSceneLayout
currentScene pointer to current scene.
void exportPPM(const QString &name, QGraphicsScene *scene) const
exportPPM save layout to gif file.
void exportSVG(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene) const
exportSVG save layout to svg file.
VContainer * pattern
pattern container with data (points, arcs, splines, spline paths, variables)
void ExportData(const QVector< VLayoutPiece > &pieceList, const ExportLayoutDialog &dialog)
void refreshLabels()
refreshLabels call to recalculate piece labels. For example after changing a font.
void exportTIF(const QString &name, QGraphicsScene *scene) const
exportTIF save layout to tif file.
void exportJPG(const QString &name, QGraphicsScene *scene) const
exportJPG save layout to jpg file.
void exportEPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportEPS( save layout to eps file.
QList< QList< QGraphicsItem * > > pieces
QList< QGraphicsItem * > shadows
static QVector< VLayoutPiece > preparePiecesForLayout(const QHash< quint32, VPiece > &pieces)
QList< QGraphicsItem * > papers
doc dom document container
QAction * actionDockWidgetGroups
int ContinueIfLayoutStale()
QIcon ScenePreview(int i) const
void PrintPreviewOrigin()
void exportBMP(const QString &name, QGraphicsScene *scene) const
exportBMP save layout to bmp file.
void exportPNG(const QString &name, QGraphicsScene *scene) const
exportPNG save layout to png file.
void exportPDF(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportPDF save layout to pdf file.
QVector< VLayoutPiece > pieceList
void SetSizeHeightForIndividualM() const
void exportPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportPS save layout to ps file.
QAction * actionDockWidgetToolOptions
bool LayoutSettings(VLayoutGenerator &lGenerator)
QAction * actionDockWidgetToolbox
void toolLayoutSettings(QToolButton *tButton, bool checked)
QList< QGraphicsScene * > scenes
QAction * actionDockWidgetLayouts
VPattern * doc
pattern container with data (points, arcs, splines, spline paths, variables)
QGraphicsScene * currentScene
The QxtCsvModel class provides a QAbstractTableModel for CSV Files.
void setText(int row, int column, const QString &value)
Sets the content of the cell at row row and column column to value.
bool insertColumn(int col, const QModelIndex &parent=QModelIndex())
\reimp
void setHeaderText(int column, const QString &value)
Sets the content of the header for column column to value.
bool insertRow(int row, const QModelIndex &parent=QModelIndex())
\reimp
void toCSV(QIODevice *file, bool withHeader=false, QChar separator=',', QTextCodec *codec=nullptr) const
Outputs the content of the model as a CSV file to the device dest using codec.
int GetCurrentFormatVarsion() const
QString GetVersionStr() const
int m_curFileFormatVersion
QString m_curFileFormatVersionStr
void exportToCSV(QString &file)
void ToolBarStyle(QToolBar *bar)
bool ContinueFormatRewrite(const QString ¤tFormatVersion, const QString &maxFormatVersion)
void FullUpdateFromFile()
FullUpdateFromFile update tool data form file.
void UpdateInLayoutList(quint32 id)
void SetModified(bool modified)
QStringList getPatternPieces() const
void SetPatternWasChanged(bool changed)
bool appendDraftBlock(const QString &name)
appendDraftBlock add new draft block.
void patternChanged(bool saved)
patternChanged emit if we have unsaved change.
QDomElement addGroupItems(const QString &name, const QMap< quint32, quint32 > &groupData)
void UpdatePatternLabel()
QMap< GHeights, bool > GetGradationHeights() const
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
void setDefaultPen(Pen pen)
void SetEnabledGUI(bool enabled)
QStringList ListMeasurements() const
QMap< GSizes, bool > GetGradationSizes() const
void showPiece(quint32 id)
QString getActiveDraftBlockName() const
getActiveDraftBlockName return current draft block name.
QMap< quint32, QString > getGroupsContainingItem(quint32 toolId, quint32 objectId, bool containsItem)
Returns the groups that contain or do not contain the item identified by the toolid and the objectid.
quint32 getCursor() const
void setCurrentDraftBlock(const QString &patterPiece)
void changeActiveDraftBlock(const QString &name, const Document &parse=Document::FullParse)
changeActiveDraftBlock set new active draft block name.
void SetMPath(const QString &path)
static void NewSeamly2D(const QString &fileName=QString())
NewSeamly2D start Seamly2D in new process, send path to pattern file in argument.
static QString GetDefPathMultisizeMeasurements()
static QString PrepareMultisizeTables(const QString ¤tPath)
void SetRecentFileList(const QStringList &value)
QByteArray GetGeometry() const
void SetToolbarsState(const QByteArray &value)
QByteArray GetToolbarsState() const
QStringList GetRecentFileList() const
void SetRestoreFileList(const QStringList &value)
void SetWindowState(const QByteArray &value)
QByteArray GetWindowState() const
QStringList GetRestoreFileList() const
void SetGeometry(const QByteArray &value)
static qreal height()
height return height
static void SetSize(qreal size)
SetSize set value of size.
const QHash< quint32, VPiece > * DataPieces() const
void ClearVariables(const VarType &type=VarType::Unknown)
void Clear()
Clear clear data in container. Id will be 0.
void ClearGObjects()
ClearObject points, splines, arcs, spline paths will be cleared.
static qreal size()
size return size
const QMap< QString, QSharedPointer< VIncrement > > variablesData() const
const QHash< quint32, QSharedPointer< VGObject > > * DataGObjects() const
data container with datagObjects return container of gObjects
const Unit * GetPatternUnit() const
static void SetHeight(qreal height)
SetGrowth set value of growth.
static bool SafeCopy(const QString &source, const QString &destination, QString &error)
The VExceptionBadId class for exception bad id.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
The VExceptionConversionError class for exception of conversion error.
The VExceptionEmptyParameter class for exception empty parameter.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
virtual QString DetailedInformation() const Q_DECL_OVERRIDE
DetailedInformation return detailed information about error.
The VExceptionObjectError class for exception object error.
The VExceptionWrongId class for exception wrong id.
The VException class parent for all exception. Could be use for abstract exception.
virtual QString ErrorMessage() const
ErrorMessage return main error message.
void AddMoreInformation(const QString &info)
AddMoreInformation add more information for error.
virtual QString DetailedInformation() const
DetailedInformation return detailed information about error.
quint32 getIdObject() const
getIdObject return parent id.
quint32 getIdTool() const
The VMainGraphicsScene class main scene.
void SetDisableTools(bool disable, const QString &draftBlockName)
QTransform transform() const
transform return view transformation.
void EnableItemMove(bool move)
QRectF visibleItemsBoundingRect() const
void setOriginsVisible(bool visible)
void ToggleArcHover(bool enabled)
void mouseMove(const QPointF &scenePos)
mouseMove send new mouse position.
void ToggleSplinePathSelection(bool enabled)
void TogglePointHover(bool enabled)
void ToggleElArcHover(bool enabled)
void ToggleElArcSelection(bool enabled)
void togglePieceSelection(bool enabled)
void ToggleNodePointSelection(bool enabled)
void ToggleNodeLabelHover(bool enabled)
void ToggleNodePointHover(bool enabled)
void SelectedObject(bool selected, quint32 object, quint32 tool)
qint32 getHorScrollBar() const
getHorScrollBar return scene horizontal scrollbar.
void ToggleSplinePathHover(bool enabled)
void ToggleNodeLabelSelection(bool enabled)
void setVerScrollBar(const qint32 &value)
setVerScrollBar set scene vertical scrollbar.
void ChosenObject(quint32 id, SceneObject type)
ChosenObject send option choosed object.
void ToggleSplineHover(bool enabled)
void setHorScrollBar(const qint32 &value)
setHorScrollBar set scene horizontal scrollbar.
void ToggleLabelSelection(bool enabled)
void ToggleSplineSelection(bool enabled)
void togglePieceHover(bool enabled)
void ToggleArcSelection(bool enabled)
void ToggleLabelHover(bool enabled)
void HighlightItem(quint32 id)
void setCurrentTransform(const QTransform &transform)
setCurrentTransform set view transformation.
void swapTransforms()
swapTransforms.
void enablePiecesMode(bool mode)
void ItemsSelection(const SelectionType &type)
void ToggleLineSelection(bool enabled)
void TogglePointSelection(bool enabled)
qint32 getVerScrollBar() const
getVerScrollBar return scene vertical scrollbar.
void ToggleLineHover(bool enabled)
void itemClicked(QGraphicsItem *item)
void signalZoomScaleChanged(qreal scale)
void mouseRelease()
mouseRelease help catch mouse release event.
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QGraphicsItem *item=nullptr)
NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
void resetScrollAnimations()
static QStringList ListSizes(QMap< GSizes, bool > sizes, Unit patternUnit)
static QStringList ListHeights(QMap< GHeights, bool > heights, Unit patternUnit)
QStringList ListAll() const
void SetSize(qreal *size)
void SetHeight(qreal *height)
MeasurementsType Type() const
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE
static const QString PatternMaxVerStr
static Q_DECL_CONSTEXPR const int PatternMaxVer
The VPattern class working with pattern file.
int GetDefCustomSize() const
QVector< quint32 > getActivePatternPieces() const
QRectF ActiveDrawBoundingRect() const
int GetDefCustomHeight() const
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName=QString()) const Q_DECL_OVERRIDE
GenerateLabel create name for draft block basepoint.
virtual void setXMLContent(const QString &fileName) Q_DECL_OVERRIDE
virtual bool SaveDocument(const QString &fileName, QString &error) Q_DECL_OVERRIDE
virtual void LiteParseTree(const Document &parse) Q_DECL_OVERRIDE
LiteParseTree lite parse file.
void Parse(const Document &parse)
Parse parse file.
void setCurrentData()
setCurrentData set current data set.
The VPointF class keep data of point.
QPointF toQPointF() const
bool GetGraphicalOutput() const
Error class of the parser.
const QEvent::Type UNDO_EVENT
QPixmap darkenPixmap(const QPixmap &pixmap)
const QString LONG_OPTION_NO_HDPI_SCALING
QString strippedName(const QString &fullFileName)
strippedName the function call around curFile to exclude the path to the file.
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath)
qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
@ PointOfIntersectionCurves
@ PointOfIntersectionCircles
@ PointFromCircleAndTangent
@ PointOfIntersectionArcs
QT_WARNING_PUSH QT_WARNING_POP const QString autosavePrefix
const QString strQShortcut
#define VER_INTERNALNAME_STR
#define translate(context, source)
std::shared_ptr< VCommandLine > VCommandLinePtr
QT_WARNING_PUSH void VlpCreateLock(std::shared_ptr< VLockGuard< Guarded >> &r, const QString &lockName, int stale=0, int timeout=0)
static const auto V_EX_DATAERR
static const auto V_EX_OK
static const auto V_EX_NOINPUT