gui.cpp

Tue, 19 Mar 2013 15:29:42 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 19 Mar 2013 15:29:42 +0200
changeset 30
31ff9aabd506
parent 29
55406ce7446e
child 32
5d22b7ecf110
permissions
-rw-r--r--

Licensed LDForge GPL3, added some more icons

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
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
3 * Copyright (C) 2013 Santeri `arezey` Piippo
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
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QtGui>
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "common.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 "gldraw.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "gui.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
24 #include "file.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
26 #include "zz_setContentsDialog.h"
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
27 #include "zz_configDialog.h"
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
28
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
29 ForgeWindow::ForgeWindow () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 R = new renderer;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 qObjList = new QTreeWidget;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 qObjList->setHeaderHidden (true);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 qObjList->setMaximumWidth (256);
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
35 qObjList->setSelectionMode (QTreeWidget::MultiSelection);
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
36 connect (qObjList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ()));
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 qMessageLog = new QTextEdit;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 qMessageLog->setReadOnly (true);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 qMessageLog->setMaximumHeight (96);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 QWidget* w = new QWidget;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 QGridLayout* layout = new QGridLayout;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 layout->setColumnMinimumWidth (0, 192);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 layout->setColumnStretch (0, 1);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 layout->addWidget (R, 0, 0);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 layout->addWidget (qObjList, 0, 1);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 layout->addWidget (qMessageLog, 1, 0, 1, 2);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 w->setLayout (layout);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 setCentralWidget (w);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 createMenuActions ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 createMenus ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 createToolbars ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
22
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
56 slot_selectionChanged ();
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
57
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
58 setWindowIcon (QIcon ("icons/ldforge.png"));
7
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
59 setTitle ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 setMinimumSize (320, 200);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 resize (800, 600);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 #define MAKE_ACTION(OBJECT, DISPLAYNAME, IMAGENAME, DESCR) \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 qAct_##OBJECT = new QAction (QIcon ("./icons/" IMAGENAME ".png"), tr (DISPLAYNAME), this); \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 qAct_##OBJECT->setStatusTip (tr (DESCR)); \
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 connect (qAct_##OBJECT, SIGNAL (triggered ()), this, SLOT (slot_##OBJECT ()));
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
69 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
71 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
72 void ForgeWindow::createMenuActions () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 // Long menu names go here so my cool action definition table doesn't get out of proportions
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
74 char const* sNewCdLineText = "New Conditional Line",
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 *sNewQuadText = "New Quadrilateral",
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 *sAboutText = "About " APPNAME_DISPLAY;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 MAKE_ACTION (new, "&New", "file-new", "Create a new part model.")
5
727e02d6b87a rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
79 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.")
727e02d6b87a rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
80 MAKE_ACTION (save, "&Save", "file-save", "Save the part model.")
727e02d6b87a rename file-specific icons to file-*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
81 MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part to a specific file.")
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 MAKE_ACTION (exit, "&Exit", "exit", "Close " APPNAME_DISPLAY ".")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
88 MAKE_ACTION (inline, "Inline", "inline", "Inline selected subfiles.")
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
89 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.")
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
90 MAKE_ACTION (setContents, "Set Contents", "set-contents", "Set the raw code of this object.")
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
91
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 MAKE_ACTION (newLine, "New Line", "add-line", "Creates a new line.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 MAKE_ACTION (newTriangle, "New Triangle", "add-triangle", "Creates a new triangle.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 MAKE_ACTION (newQuad, sNewQuadText, "add-quad", "Creates a new quadrilateral.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 MAKE_ACTION (newCondLine, sNewCdLineText, "add-condline", "Creates a new conditional line.");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 MAKE_ACTION (newComment, "New Comment", "add-comment", "Creates a new comment.");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 MAKE_ACTION (newVector, "New Vector", "add-vector", "Creates a new vector.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 MAKE_ACTION (newVertex, "New Vertex", "add-vertex", "Creates a new vertex.")
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
101 MAKE_ACTION (settings, "Settings", "settings", "Edit the settings of " APPNAME_DISPLAY ".")
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
102
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
103 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME_DISPLAY " help manual.")
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
104 MAKE_ACTION (about, sAboutText, "ldforge", "Shows information about " APPNAME_DISPLAY ".")
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
105 MAKE_ACTION (aboutQt, "About Qt", "aboutQt", "Shows information about Qt.")
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
106
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 // Keyboard shortcuts
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 qAct_new->setShortcut (Qt::CTRL | Qt::Key_N);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 qAct_open->setShortcut (Qt::CTRL | Qt::Key_O);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 qAct_save->setShortcut (Qt::CTRL | Qt::Key_S);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 qAct_saveAs->setShortcut (Qt::CTRL | Qt::SHIFT | Qt::Key_S);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 qAct_cut->setShortcut (Qt::CTRL | Qt::Key_X);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 qAct_copy->setShortcut (Qt::CTRL | Qt::Key_C);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 qAct_paste->setShortcut (Qt::CTRL | Qt::Key_V);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 // things not implemented yet
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 QAction* qaDisabledActions[] = {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 qAct_newSubfile,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 qAct_newTriangle,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 qAct_newQuad,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 qAct_newCondLine,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 qAct_newComment,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 qAct_newVector,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 qAct_newVertex,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 qAct_cut,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 qAct_copy,
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 qAct_paste,
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
129 qAct_about,
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
130 qAct_inline,
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
131 qAct_help,
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 };
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 for (ushort i = 0; i < sizeof qaDisabledActions / sizeof *qaDisabledActions; ++i)
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 qaDisabledActions[i]->setEnabled (false);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
138 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
140 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
141 void ForgeWindow::createMenus () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 // File menu
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 qFileMenu = menuBar ()->addMenu (tr ("&File"));
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 qFileMenu->addAction (qAct_new); // New
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 qFileMenu->addAction (qAct_open); // Open
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 qFileMenu->addAction (qAct_save); // Save
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 qFileMenu->addAction (qAct_saveAs); // Save As
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 qFileMenu->addSeparator (); // -------
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
149 qFileMenu->addAction (qAct_settings); // Settings
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
150 qFileMenu->addSeparator (); // -------
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 qFileMenu->addAction (qAct_exit); // Exit
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 // Edit menu
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 qInsertMenu = menuBar ()->addMenu (tr ("&Insert"));
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
155 qInsertMenu->addAction (qAct_newSubfile); // New Subfile
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
156 qInsertMenu->addAction (qAct_newLine); // New Line
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157 qInsertMenu->addAction (qAct_newTriangle); // New Triangle
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 qInsertMenu->addAction (qAct_newQuad); // New Quad
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159 qInsertMenu->addAction (qAct_newCondLine); // New Conditional Line
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 qInsertMenu->addAction (qAct_newComment); // New Comment
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 qInsertMenu->addAction (qAct_newVector); // New Vector
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 qInsertMenu->addAction (qAct_newVertex); // New Vertex
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 qEditMenu = menuBar ()->addMenu (tr ("&Edit"));
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 qEditMenu->addAction (qAct_cut); // Cut
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 qEditMenu->addAction (qAct_copy); // Copy
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 qEditMenu->addAction (qAct_paste); // Paste
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
168 qEditMenu->addSeparator (); // -----
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
169 qEditMenu->addAction (qAct_inline); // Inline
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
170 qEditMenu->addAction (qAct_splitQuads); // Split Quads
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
171 qEditMenu->addAction (qAct_setContents); // Set Contents
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 // Help menu
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 qHelpMenu = menuBar ()->addMenu (tr ("&Help"));
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
175 qHelpMenu->addAction (qAct_help); // Help
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
176 qHelpMenu->addSeparator (); // -----
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 qHelpMenu->addAction (qAct_about); // About
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 qHelpMenu->addAction (qAct_aboutQt); // About Qt
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
181 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
183 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
184 void ForgeWindow::createToolbars () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 qFileToolBar = new QToolBar ("File");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 qFileToolBar->addAction (qAct_new);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 qFileToolBar->addAction (qAct_open);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 qFileToolBar->addAction (qAct_save);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189 qFileToolBar->addAction (qAct_saveAs);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190 addToolBar (qFileToolBar);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 qInsertToolBar = new QToolBar ("Insert");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 qInsertToolBar->addAction (qAct_newSubfile);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 qInsertToolBar->addAction (qAct_newLine);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 qInsertToolBar->addAction (qAct_newTriangle);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 qInsertToolBar->addAction (qAct_newQuad);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 qInsertToolBar->addAction (qAct_newCondLine);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 qInsertToolBar->addAction (qAct_newComment);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 qInsertToolBar->addAction (qAct_newVector);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 qInsertToolBar->addAction (qAct_newVertex);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 addToolBar (qInsertToolBar);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 qEditToolBar = new QToolBar ("Edit");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
204 qEditToolBar->addAction (qAct_cut);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 qEditToolBar->addAction (qAct_copy);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 qEditToolBar->addAction (qAct_paste);
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
207 qEditToolBar->addAction (qAct_inline);
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
208 qEditToolBar->addAction (qAct_splitQuads);
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
209 qEditToolBar->addAction (qAct_setContents);
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
210 addToolBar (qEditToolBar);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
211 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
212
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
213 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
215 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
216 void ForgeWindow::setTitle () {
7
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
217 str zTitle = APPNAME_DISPLAY " v" VERSION_STRING;
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
218
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
219 // Append our current file if we have one
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
220 if (g_CurrentFile) {
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
221 zTitle.appendformat (": %s", basename (g_CurrentFile->zFileName.chars()));
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
222
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
223 if (g_CurrentFile->objects.size() > 0 &&
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
224 g_CurrentFile->objects[0]->getType() == OBJ_Comment)
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
225 {
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
226 // Append title
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
227 LDComment* comm = static_cast<LDComment*> (g_CurrentFile->objects[0]);
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
228 zTitle.appendformat (":%s", comm->zText.chars());
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
229 }
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
230 }
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
231
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
232 setWindowTitle (zTitle.chars());
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
233 }
098e3c4949c6 Set window title dynamically based on filename
Santeri Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
234
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
235 void ForgeWindow::slot_new () {
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
236 newFile ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
237 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
238
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
239 void ForgeWindow::slot_open () {
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
240 str zName;
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
241 zName += QFileDialog::getOpenFileName (this, "Open File",
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
242 "", "LDraw files (*.dat *.ldr)");
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
244 if (~zName)
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
245 openMainFile (zName);
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
247
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
248 void ForgeWindow::slot_save () {
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
249 g_CurrentFile->save ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
251
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
252 void ForgeWindow::slot_saveAs () {
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
253 str zName;
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
254 zName += QFileDialog::getSaveFileName (this, "Save As",
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
255 "", "LDraw files (*.dat *.ldr)");
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
256
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
257 if (~zName && g_CurrentFile->save (zName))
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
258 g_CurrentFile->zFileName = zName;
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
259 }
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
260
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
261 void ForgeWindow::slot_settings () {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
262 ConfigDialog::staticDialog (this);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
263 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
264
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
265 void ForgeWindow::slot_exit () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 exit (0);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
269 void ForgeWindow::slot_newSubfile () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
273 void ForgeWindow::slot_newLine () {
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
274 LDLine* line = new LDLine;
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
275 const ulong ulSpot = getInsertionPoint ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
277 memset (line->vaCoords, 0, sizeof line->vaCoords);
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
278 line->dColor = 24;
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
279
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
280 g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulSpot, line);
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
281
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
282 buildObjList ();
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
283 R->hardRefresh ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
284 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
286 void ForgeWindow::slot_newTriangle () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
288 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
289
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
290 void ForgeWindow::slot_newQuad () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
292 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
293
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
294 void ForgeWindow::slot_newCondLine () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
298 void ForgeWindow::slot_newComment () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
299
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
300 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
301
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
302 void ForgeWindow::slot_help () {
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
303
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
304 }
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
305
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
306 void ForgeWindow::slot_about () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
307
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
308 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
309
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
310 void ForgeWindow::slot_aboutQt () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 QMessageBox::aboutQt (this);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
314 void ForgeWindow::slot_cut () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
318 void ForgeWindow::slot_copy () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
322 void ForgeWindow::slot_paste () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
323
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
324 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
326 void ForgeWindow::slot_newVector () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
327
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
330 void ForgeWindow::slot_newVertex () {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
331
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
333
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
334 void ForgeWindow::slot_inline () {
24
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
335
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
336 }
d2d4d0154338 added dummy action for future inlining command. Also GCC says that deleting instances of classes with virtual members but no virtual destructors is bad.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
337
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
338 void ForgeWindow::slot_splitQuads () {
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
339 if (qObjList->selectedItems().size() == 0)
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
340 return;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
341
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
342 QList<QTreeWidgetItem*> const qaItems = qObjList->selectedItems();
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
343
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
344 for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) {
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
345 LDObject* obj = g_CurrentFile->objects[i];
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
346
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
347 // Don't even consider non-quads
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
348 if (obj->getType() != OBJ_Quad)
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
349 continue;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
350
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
351 bool bIsSelected = false;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
352
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
353 for (long j = 0; j < qaItems.size(); ++j) {
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
354 if (qaItems[j] == obj->qObjListEntry) {
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
355 bIsSelected = true;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
356 break;
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
357 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
358 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
359
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
360 if (!bIsSelected)
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
361 continue; // Was not selected
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
362
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
363 static_cast<LDQuad*> (obj)->splitToTriangles ();
22
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
364 i++;// Skip past the second triangle
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
365 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
366
22
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
367 printf ("build obj list\n");
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
368 buildObjList ();
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
369
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
370 printf ("refresh teh renderer\n");
21
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
371 R->hardRefresh ();
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
372 }
9aebaaafa5da Added split-quads-to-triangles function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
373
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
374 void ForgeWindow::slot_setContents () {
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
375 if (qObjList->selectedItems().size() != 1)
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
376 return;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
377
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
378 ulong ulIndex;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
379 LDObject* obj = nullptr;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
380
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
381 QTreeWidgetItem* item = qObjList->selectedItems()[0];
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
382 for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex) {
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
383 obj = g_CurrentFile->objects[ulIndex];
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
384
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
385 if (obj->qObjListEntry == item)
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
386 break;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
387 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
388
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
389 if (ulIndex >= g_CurrentFile->objects.size())
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
390 return;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
391
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
392 SetContentsDialog::staticDialog (obj, this);
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
393 }
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
395 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
396 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
397 // =============================================================================
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398 static QIcon IconForObjectType (LDObject* obj) {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 switch (obj->getType ()) {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 case OBJ_Empty:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 return QIcon ("icons/empty.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 case OBJ_Line:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404 return QIcon ("icons/line.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
406 case OBJ_Quad:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407 return QIcon ("icons/quad.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 case OBJ_Subfile:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 return QIcon ("icons/subfile.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 case OBJ_Triangle:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
413 return QIcon ("icons/triangle.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
414
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415 case OBJ_CondLine:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 return QIcon ("icons/condline.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
417
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418 case OBJ_Comment:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 return QIcon ("icons/comment.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 case OBJ_Vector:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 return QIcon ("icons/vector.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 case OBJ_Vertex:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 return QIcon ("icons/vertex.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 case OBJ_Gibberish:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428 case OBJ_Unidentified:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 return QIcon ("icons/error.png");
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 return QIcon ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
435 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
436 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
437 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
438 void ForgeWindow::buildObjList () {
3
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
439 if (!g_CurrentFile)
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
440 return;
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
441
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 QList<QTreeWidgetItem*> qaItems;
3
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
443
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
444 qObjList->clear ();
2b78cf8634c3 don't crash if g_CurrentFile is null
Santeri Piippo <crimsondusk64@gmail.com>
parents: 0
diff changeset
445
22
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
446 for (ulong i = 0; i < g_CurrentFile->objects.size(); ++i) {
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
447 LDObject* obj = g_CurrentFile->objects[i];
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449 str zText;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 switch (obj->getType ()) {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451 case OBJ_Comment:
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
452 zText = static_cast<LDComment*> (obj)->zText.chars();
10
5b0579997e9b remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
453
5b0579997e9b remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
454 // Remove leading whitespace
5b0579997e9b remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
455 while (~zText && zText[0] == ' ')
5b0579997e9b remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
456 zText -= -1;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
459 case OBJ_Empty:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460 break; // leave it empty
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
462 case OBJ_Line:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463 case OBJ_CondLine:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464 {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 LDLine* line = static_cast<LDLine*> (obj);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466 zText.format ("%s, %s",
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
467 line->vaCoords[0].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
468 line->vaCoords[1].getStringRep (true).chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 case OBJ_Triangle:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
474 LDTriangle* triangle = static_cast<LDTriangle*> (obj);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475 zText.format ("%s, %s, %s",
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
476 triangle->vaCoords[0].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
477 triangle->vaCoords[1].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
478 triangle->vaCoords[2].getStringRep (true).chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
479 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
481
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 case OBJ_Quad:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 LDQuad* quad = static_cast<LDQuad*> (obj);
10
5b0579997e9b remove leading whitespace from comments when drawing them in the list
Santeri Piippo <crimsondusk64@gmail.com>
parents: 7
diff changeset
485 zText.format ("%s, %s, %s, %s",
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
486 quad->vaCoords[0].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
487 quad->vaCoords[1].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
488 quad->vaCoords[2].getStringRep (true).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
489 quad->vaCoords[3].getStringRep (true).chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
490 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
491 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
492
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
493 case OBJ_Gibberish:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
494 zText.format ("ERROR: %s",
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
495 static_cast<LDGibberish*> (obj)->zContents.chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
496 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
497
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
498 case OBJ_Vector:
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
499 zText.format ("%s", static_cast<LDVector*> (obj)->vPos.getStringRep(true).chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
500 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
501
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
502 case OBJ_Vertex:
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 17
diff changeset
503 zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep(true).chars());
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
504 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
505
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
506 default:
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
507 zText = g_saObjTypeNames[obj->getType ()];
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
508 break;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
509 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
510
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
511 QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr),
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
512 QStringList (zText.chars()), 0);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
513 item->setIcon (0, IconForObjectType (obj));
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
514
11
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
515 // Color gibberish red
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
516 if (obj->getType() == OBJ_Gibberish) {
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
517 item->setBackgroundColor (0, "#AA0000");
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
518 item->setForeground (0, QColor ("#FFAA00"));
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
519 }
323390a03294 Color gibberish red. Check for line code length for gibberish (must be 1 to be valid)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
520
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
521 obj->qObjListEntry = item;
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
522
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
523 qaItems.append (item);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
524 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
525
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
526 qObjList->insertTopLevelItems (0, qaItems);
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
527 }
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
528
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
529 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
530 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
531 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
532 void ForgeWindow::slot_selectionChanged () {
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
533 // If the selection isn't 1 exact, disable setting contents
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
534 qAct_setContents->setEnabled (qObjList->selectedItems().size() == 1);
22
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
535
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
536 // If we have no selection, disable splitting quads
335e430a6b4f So much for that pointer class, caused more problems than it solved. For instance splitting a second quad after a first one had been split would trigger a peculiar crash...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
537 qAct_splitQuads->setEnabled (qObjList->selectedItems().size() > 0);
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
538 }
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
539
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
540 // =============================================================================
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
541 // ulong getInsertionPoint ()
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
542 //
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
543 // Returns the index of where a new item should be placed at.
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
544 // =============================================================================
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 24
diff changeset
545 ulong ForgeWindow::getInsertionPoint () {
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
546 ulong ulIndex;
14
6d9d8efae2f8 this thing got its own reinterpret_cast now. :P Added SetContents action for altering an object by contents and reinterpreting it.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 11
diff changeset
547
17
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
548 if (qObjList->selectedItems().size() == 1) {
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
549 // If we have a selection, put the item after it.
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
550 for (ulIndex = 0; ulIndex < g_CurrentFile->objects.size(); ++ulIndex)
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
551 if (g_CurrentFile->objects[ulIndex]->qObjListEntry == qObjList->selectedItems()[0])
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
552 break;
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
553
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
554 if (ulIndex >= g_CurrentFile->objects.size())
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
555 return ulIndex + 1;
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
556 }
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
557
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
558 // Otherwise place the object at the end.
5606eebd0b90 Allow addition of dummy lines..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 14
diff changeset
559 return g_CurrentFile->objects.size();
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
560 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
561
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
562 void ForgeWindow::refresh () {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
563 buildObjList ();
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
564 R->hardRefresh ();
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
565 }

mercurial