zz_newPartDialog.cpp

Mon, 06 May 2013 03:32:00 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 06 May 2013 03:32:00 +0300
changeset 166
72ec7b60da54
parent 161
c9fba92c4e35
permissions
-rw-r--r--

add missing license headers from new files

76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <qgridlayout.h>
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "zz_newPartDialog.h"
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "file.h"
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 // -------------------------------------
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 enum {
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 LICENSE_CCAL,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 LICENSE_NonCA,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 LICENSE_None
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 };
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 // -------------------------------------
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 enum {
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 BFCBOX_CCW,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 BFCBOX_CW,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 BFCBOX_None,
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 };
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 // =============================================================================
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 // =============================================================================
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
41 lb_brickIcon = new QLabel;
158
499286fcbf37 Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents: 157
diff changeset
42 lb_brickIcon->setPixmap (getIcon ("brick"));
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
44 lb_name = new QLabel ("Name:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
45 le_name = new QLineEdit;
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
46 le_name->setMinimumWidth (320);
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
48 lb_author = new QLabel ("Author:");
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
49 le_author = new QLineEdit;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
51 rb_license = new RadioBox ("License", {
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 "CCAL Redistributable",
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 "Non-redistributable",
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
54 "Don't append a license",
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
55 }, LICENSE_CCAL);
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
57 rb_BFC = new RadioBox ("BFC Winding", {
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 "CCW",
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 "CW",
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 "No winding"
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
61 }, BFCBOX_CCW);
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
62
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
63 QHBoxLayout* boxes = new QHBoxLayout;
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
64 boxes->addWidget (rb_license);
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
65 boxes->addWidget (rb_BFC);
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 IMPLEMENT_DIALOG_BUTTONS
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 QGridLayout* layout = new QGridLayout;
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
70 layout->addWidget (lb_brickIcon, 0, 0);
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
71 layout->addWidget (lb_name, 0, 1);
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
72 layout->addWidget (le_name, 0, 2);
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
73 layout->addWidget (lb_author, 1, 1);
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
74 layout->addWidget (le_author, 1, 2);
136
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
75 layout->addLayout (boxes, 2, 1, 1, 2);
13db97be14cb Converted combo boxes in add object and new part dialogs to radio buttons. Added a convenience widget which makes it easier for me to add groups of radio buttons. My first widget.. :')
Santeri Piippo <crimsondusk64@gmail.com>
parents: 135
diff changeset
76 layout->addWidget (bbx_buttons, 3, 2);
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 setLayout (layout);
158
499286fcbf37 Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents: 157
diff changeset
79 setWindowIcon (getIcon ("brick"));
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
80 setWindowTitle (APPNAME ": New Part");
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 }
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 // =============================================================================
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 // =============================================================================
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 void NewPartDialog::StaticDialog () {
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
87 NewPartDialog dlg (g_win);
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 if (dlg.exec ()) {
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 newFile ();
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 short idx;
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
92 str zAuthor = dlg.le_author->text ();
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
93 vector<LDObject*>& objs = g_curfile->m_objs;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
95 idx = dlg.rb_BFC->value ();
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
96 const LDBFC::Type eBFCType =
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
97 (idx == BFCBOX_CCW) ? LDBFC::CertifyCCW :
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
98 (idx == BFCBOX_CW) ? LDBFC::CertifyCW :
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
99 LDBFC::NoCertify;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100
157
635da3135bd4 Un-templated ButtonBox and renamed to RadioBox. Much better this way.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 136
diff changeset
101 idx = dlg.rb_license->value ();
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 const char* sLicense =
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 (idx == LICENSE_CCAL) ? "Redistributable under CCAL version 2.0 : see CAreadme.txt" :
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 (idx == LICENSE_NonCA) ? "Not redistributable : see NonCAreadme.txt" :
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
105 null;
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106
135
c243df39913e Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
107 objs.push_back (new LDComment (dlg.le_name->text ()));
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 objs.push_back (new LDComment ("Name: <untitled>.dat"));
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
109 objs.push_back (new LDComment (fmt ("Author: %s", zAuthor.chars())));
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
110 objs.push_back (new LDComment (fmt ("!LDRAW_ORG Unofficial_Part")));
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
112 if (sLicense != null)
161
c9fba92c4e35 Further tweaking
Santeri Piippo <crimsondusk64@gmail.com>
parents: 160
diff changeset
113 objs.push_back (new LDComment (fmt ("!LICENSE %s", sLicense)));
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 objs.push_back (new LDEmpty);
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 objs.push_back (new LDBFC (eBFCType));
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 objs.push_back (new LDEmpty);
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118
160
edcb03f3ef75 Mass renaming and cleanup. GLRenderer's and ForgeWindow's members made private. Names of common identifiers shortened, moved logVA to ForgeWindow since it's a GUI-related function (though logf remains under main.cpp for ubiquitous usage)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 158
diff changeset
119 g_win->refresh ();
76
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 }
42284126072a Added a New Part dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 }

mercurial