src/dialogs/generateprimitivedialog.cpp

Thu, 09 Feb 2017 19:59:27 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 09 Feb 2017 19:59:27 +0200
changeset 1111
471572db2fe1
parent 1072
9ce9496427f2
child 1147
a26568aa3cce
permissions
-rw-r--r--

Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.

1020
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
1 /*
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1053
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
1020
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
4 *
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
5 * This program is free software: you can redistribute it and/or modify
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
6 * it under the terms of the GNU General Public License as published by
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
8 * (at your option) any later version.
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
9 *
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
10 * This program is distributed in the hope that it will be useful,
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
13 * GNU General Public License for more details.
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
14 *
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
15 * You should have received a copy of the GNU General Public License
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
17 */
815a040d4039 Reformatted primitives.cpp
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1019
diff changeset
18
1019
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "../ldObject.h"
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "generateprimitivedialog.h"
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "ui_generateprimitivedialog.h"
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 GeneratePrimitiveDialog::GeneratePrimitiveDialog (QWidget* parent, Qt::WindowFlags f) :
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 QDialog (parent, f),
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 ui(*new Ui_GeneratePrimitiveDialog)
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 {
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 ui.setupUi (this);
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 connect (ui.highResolution, &QCheckBox::toggled, this, &GeneratePrimitiveDialog::highResolutionToggled);
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 }
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 GeneratePrimitiveDialog::~GeneratePrimitiveDialog()
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 {
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 delete &ui;
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 }
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 void GeneratePrimitiveDialog::highResolutionToggled (bool on)
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 {
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 ui.segments->setMaximum (on ? HighResolution : LowResolution);
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // If the current value is 16 and we switch to hi-res, default the
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // spinbox to 48. (should we scale this?)
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 if (on and ui.segments->value() == LowResolution)
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 ui.segments->setValue(HighResolution);
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 }
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
1053
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
49 PrimitiveModel GeneratePrimitiveDialog::primitiveModel() const
1019
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 {
1053
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
51 PrimitiveModel result;
1019
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 result.type =
1053
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
53 ui.typeCircle->isChecked() ? PrimitiveModel::Circle :
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
54 ui.typeCylinder->isChecked() ? PrimitiveModel::Cylinder :
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
55 ui.typeDisc->isChecked() ? PrimitiveModel::Disc :
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
56 ui.typeDiscNegative->isChecked() ? PrimitiveModel::DiscNegative :
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
57 ui.typeRing->isChecked() ? PrimitiveModel::Ring :
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
58 PrimitiveModel::Cone;
1019
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 result.divisions = ui.highResolution->isChecked() ? HighResolution : LowResolution;
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 result.segments = ui.segments->value();
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 result.ringNumber = ui.ringNumber->value();
a2e4286adb0d Split PrimitivePrompt into its new source files, renamed it to GeneratePrimitivePrompt
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 return result;
1053
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1020
diff changeset
63 }

mercurial