Wed, 08 May 2013 14:57:48 +0300
Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
104 | 3 | * Copyright (C) 2013 Santeri Piippo |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
18 | |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QAbstractButton> |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <qboxlayout.h> |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "zz_setContentsDialog.h" |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
22 | #include "file.h" |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "gui.h" |
90
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
24 | #include "history.h" |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | // ============================================================================= |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
27 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | // ============================================================================= |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
29 | SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) { |
161 | 30 | setWindowTitle (APPNAME ": Set Contents"); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
32 | lb_contents = new QLabel ("Set contents:", parent); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
34 | le_contents = new QLineEdit (parent); |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
35 | le_contents->setText (obj->getContents ().chars()); |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
36 | le_contents->setWhatsThis ("The LDraw code of this object. The code written " |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | "here is expected to be valid LDraw code, invalid code here results " |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | "the object being turned into an error object. Please do refer to the " |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | "<a href=\"http://www.ldraw.org/article/218.html\">official file format " |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | "standard</a> for further information."); |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
41 | le_contents->setMinimumWidth (384); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
43 | if (obj->getType() == LDObject::Gibberish) { |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
44 | lb_error = new QLabel; |
161 | 45 | lb_error->setText (fmt ("<span style=\"color: #900\">%s</span>", |
61
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
46 | static_cast<LDGibberish*> (obj)->zReason.chars())); |
82
e61c50fdb8cc
Touched up the error icon, show the error icon in the set contents dialog if the contents are gibberish.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
61
diff
changeset
|
47 | |
158
499286fcbf37
Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
48 | QPixmap qErrorPixmap = getIcon ("error").scaledToHeight (16); |
82
e61c50fdb8cc
Touched up the error icon, show the error icon in the set contents dialog if the contents are gibberish.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
61
diff
changeset
|
49 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
50 | lb_errorIcon = new QLabel; |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
51 | lb_errorIcon->setPixmap (qErrorPixmap); |
61
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
52 | } |
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
53 | |
39
110669124caf
Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
54 | IMPLEMENT_DIALOG_BUTTONS |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | QVBoxLayout* layout = new QVBoxLayout; |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
57 | layout->addWidget (lb_contents); |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
58 | layout->addWidget (le_contents); |
61
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
59 | |
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
60 | QHBoxLayout* layout2 = new QHBoxLayout; |
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
61 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
161
diff
changeset
|
62 | if (obj->getType() == LDObject::Gibberish) { |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
63 | layout2->addWidget (lb_errorIcon); |
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
64 | layout2->addWidget (lb_error); |
82
e61c50fdb8cc
Touched up the error icon, show the error icon in the set contents dialog if the contents are gibberish.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
61
diff
changeset
|
65 | } |
61
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
66 | |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
67 | layout2->addWidget (bbx_buttons); |
61
109b07334fa0
If editing contents of a gibberish object, show the reason for the gibberishness in the dialog. Clamp the bounding box scale to at least 1.0 so that polygons are visible in new files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
68 | layout->addLayout (layout2); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | setLayout (layout); |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
70 | |
161 | 71 | setWindowTitle (APPNAME ": Set Contents"); |
158
499286fcbf37
Compile the icon resources to a QRC file, so that they are embedded in the application
Santeri Piippo <crimsondusk64@gmail.com>
parents:
135
diff
changeset
|
72 | setWindowIcon (getIcon ("set-contents")); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | } |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | // ============================================================================= |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
76 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | // ============================================================================= |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
78 | void SetContentsDialog::slot_handleButtons (QAbstractButton* qButton) { |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | qButton = qButton; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | } |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | // ============================================================================= |
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
83 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | // ============================================================================= |
90
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
85 | void SetContentsDialog::staticDialog (LDObject* obj) { |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | if (!obj) |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | return; |
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | |
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
|
89 | SetContentsDialog dlg (obj, g_win); |
90
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
90 | if (dlg.exec () == false) |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
91 | return; |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
92 | |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
93 | LDObject* oldobj = obj; |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
94 | |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
95 | // Reinterpret it from the text of the input field |
135
c243df39913e
Cleanup and some restructuring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
125
diff
changeset
|
96 | obj = parseLine (dlg.le_contents->text ().toStdString ().c_str ()); |
90
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
97 | |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
98 | // Mark down the history now before we perform the replacement (which |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
99 | // destroys the old object) |
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
|
100 | History::addEntry (new EditHistory ({(ulong) oldobj->getIndex (g_curfile)}, |
117
7eb7a43a511b
Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
101 | {oldobj->clone ()}, {obj->clone ()})); |
90
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
102 | |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
103 | oldobj->replace (obj); |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
104 | |
03f718ed5b33
Added history handling for set contents
Santeri Piippo <crimsondusk64@gmail.com>
parents:
82
diff
changeset
|
105 | // Rebuild stuff after this |
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
|
106 | g_win->refresh (); |
15
a78ccb3976b6
oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |