MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / execComm

Method execComm

plugins/align/align.cpp:36–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void LC_Align::execComm(Document_Interface *doc,
37 QWidget *parent, QString cmd)
38{
39 Q_UNUSED(parent);
40
41 /* First load the settings */
42 QSettings settings(QSettings::IniFormat, QSettings::UserScope,
43 "LibreCAD", "align_plugin");
44 bool keep_orig = settings.value("keep_original", false).toBool();
45 bool base_first = settings.value("base_first", false).toBool();
46 bool acting = true;
47
48 if (cmd.length() > 6) { // cheapo settings dialog, could be improved
49 QCheckBox* cbkeep = new QCheckBox(tr("Keep original objects"));
50 QCheckBox* cbbase = new QCheckBox(tr("Specify base points first"));
51 cbkeep->setChecked(keep_orig);
52 cbbase->setChecked(base_first);
53 QMessageBox setdlg;
54 setdlg.setWindowTitle(tr("Align Settings"));
55 setdlg.addButton(cbkeep, QMessageBox::ActionRole);
56 setdlg.addButton(cbbase, QMessageBox::ActionRole);
57 setdlg.setText(tr("Click on options to set/unset,\n"
58 "Ok to accept and start alignment."));
59 setdlg.setDetailedText(
60 tr("If 'Keep original objects' is checked,\n"
61 "Align will copy rather than move the selected objects.\n\n"
62 "If 'Specify base points first' is checked,\n"
63 "Align will prompt for the alignment points in the order\n"
64 "first base, second base, first target, second target.")
65 );
66 QPushButton* okpushbtn = setdlg.addButton(QMessageBox::Ok);
67 QAbstractButton* okbtn = (QAbstractButton*)okpushbtn;
68 while (acting) {
69 setdlg.exec();
70 keep_orig = cbkeep->isChecked();
71 base_first = cbbase->isChecked();
72 if (setdlg.clickedButton() == okbtn) acting = false;
73 }
74 settings.setValue("keep_original", keep_orig);
75 settings.setValue("base_first", base_first);
76 }
77 QPointF base1, base2, target1, target2;
78 QList<Plug_Entity *> obj;
79 bool yes = doc->getSelect(&obj);
80 if (!yes || obj.isEmpty()) return;
81 yes = doc->getPoint(&base1, QString(tr("first base point:")));
82 while (yes) {
83 if (base_first)
84 yes = doc->getPoint(&base2, QString(tr("second base point:")));
85 if (!yes) break;
86 yes = doc->getPoint(&target1, QString(tr("first target point:")), &base1);
87 if (!yes) break;
88 if (!base_first)
89 yes = doc->getPoint(&base2, QString(tr("second base point:")));
90 if (!yes) break;
91 yes = doc->getPoint(&target2, QString(tr("second target point:")), &base2);
92 break;
93 }

Callers

nothing calls this directly

Calls 9

addButtonMethod · 0.80
getSelectMethod · 0.80
isEmptyMethod · 0.80
QStringClass · 0.50
setTextMethod · 0.45
getPointMethod · 0.45
sizeMethod · 0.45
moveRotateMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected