Tue, 01 Jan 2019 22:30:10 +0200
commit work done on mdi
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
804
diff
changeset
|
20 | #include <functional> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QMainWindow> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QAction> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QListWidget> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QRadioButton> |
963
c1526d1877d7
More through removal of the vertex object
Teemu Piippo <crimsondusk64@gmail.com>
parents:
962
diff
changeset
|
25 | #include <QTreeWidget> |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
26 | #include <QMetaMethod> |
1147
a26568aa3cce
Renamed ldObject.cpp → linetypes/modelobject.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1124
diff
changeset
|
27 | #include "linetypes/modelobject.h" |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
794
diff
changeset
|
28 | #include "colors.h" |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
29 | #include "glShared.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
31 | class QMdiSubWindow; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | class QToolButton; |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1097
diff
changeset
|
33 | class Canvas; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
34 | class Toolset; |
1018
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
35 | class PrimitiveManager; |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
36 | class Grid; |
1159
6ad8cdcd88d9
print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1157
diff
changeset
|
37 | class DocumentManager; |
6ad8cdcd88d9
print() is no longer a global function but is tied to HierarchyElement.
Teemu Piippo <teemu@hecknology.net>
parents:
1157
diff
changeset
|
38 | class LDDocument; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | |
794 | 40 | // LDForge's main GUI class. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | class MainWindow : public QMainWindow |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | { |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
804
diff
changeset
|
43 | Q_OBJECT |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
794 | 45 | public: |
1322
d8935cdb24c0
renamed sink() to singleton()
Teemu Piippo <teemu@hecknology.net>
parents:
1291
diff
changeset
|
46 | explicit MainWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = 0); |
857
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
47 | ~MainWindow(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
1353 | 49 | void applyToActions(function<void(QAction*)> function); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
50 | void changeDocument (LDDocument* f); |
1256
3fea6bc1519b
removed LDDocument::clearSelection and replaced it with a MainWindow implementation
Santeri Piippo
parents:
1251
diff
changeset
|
51 | void clearSelection(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
52 | void createBlankDocument(); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
53 | Canvas* createCameraForDocument(LDDocument* document, gl::CameraType cameraType); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
54 | LDDocument* currentDocument(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
55 | void currentDocumentClosed(); |
1257 | 56 | QItemSelectionModel* currentSelectionModel(); |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
988
diff
changeset
|
57 | QKeySequence defaultShortcut (QAction* act); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
58 | void deleteByColor (LDColor color); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
59 | int deleteSelection(); |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
988
diff
changeset
|
60 | DocumentManager* documents() { return m_documents; } |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
61 | void doFullRefresh(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
62 | void endAction(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
63 | class ExtProgramToolset* externalPrograms(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
64 | LDColor getUniformSelectedColor(); |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1097
diff
changeset
|
65 | Canvas* getRendererForDocument(LDDocument* document); |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
66 | Grid* grid(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
67 | void loadShortcuts(); |
1090
ed73c4f48ca4
The current document pointer may no longer be null.
Teemu Piippo <teemu@hecknology.net>
parents:
1073
diff
changeset
|
68 | void openDocumentForEditing(LDDocument* document); |
1018
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
69 | PrimitiveManager* primitives(); |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
1097
diff
changeset
|
70 | Canvas* renderer(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
71 | void refresh(); |
1257 | 72 | void replaceSelection(const QItemSelection& selection); |
1417
ed39bfca7a67
refactored the segments/divisions editor in MainWindow to a new widget
Teemu Piippo <teemu@hecknology.net>
parents:
1382
diff
changeset
|
73 | CircularSection circleToolSection() const; |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
74 | bool save (LDDocument* doc, bool saveAs); |
1257 | 75 | void select(const QModelIndex& objectIndex); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
76 | Canvas* selectCameraForDocument(LDDocument* document, gl::CameraType cameraType); |
1250 | 77 | QModelIndexList selectedIndexes() const; |
78 | QSet<LDObject*> selectedObjects() const; | |
1031
55c0d3beea0d
removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1024
diff
changeset
|
79 | void spawnContextMenu (const QPoint& position); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
80 | int suggestInsertPoint(); |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
81 | Q_SLOT void updateActions(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
82 | void updateColorToolbar(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
83 | void updateDocumentList(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
84 | void updateDocumentListItem (LDDocument* doc); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
85 | void updateEditModeActions(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
86 | void updateGridToolBar(); |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
87 | void updateRecentFilesMenu(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | |
1157
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
89 | static QPixmap getIcon(QString iconName); |
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1156
diff
changeset
|
90 | |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
91 | signals: |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
92 | void gridChanged(); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
93 | |
794 | 94 | public slots: |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
95 | void actionTriggered(); |
798
88d4973cfe1a
- added close buttons to tabs
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
96 | void closeTab (int tabindex); |
983
05ba93066194
Refactor edit history
Teemu Piippo <crimsondusk64@gmail.com>
parents:
981
diff
changeset
|
97 | void historyTraversed(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
98 | void tabSelected(); |
1097
9a9e6ce0c5dc
Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents:
1090
diff
changeset
|
99 | void documentClosed(LDDocument* document); |
1291
9c570a30c98a
Added basic header editing
Teemu Piippo <teemu@hecknology.net>
parents:
1283
diff
changeset
|
100 | void updateTitle(); |
1428
ece049033adc
fixed a crash when trying to open a document for the 3rd time after closing it 2 times
Teemu Piippo <teemu@hecknology.net>
parents:
1419
diff
changeset
|
101 | void newDocument (LDDocument* document, bool cache = false); |
1432
4cc687851fbb
Refactored the color toolbar editing into a new model/view system
Teemu Piippo <teemu@hecknology.net>
parents:
1428
diff
changeset
|
102 | void settingsChanged(); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
103 | void canvasClosed(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
794 | 105 | protected: |
1335
5530161fcd47
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
Teemu Piippo <teemu@hecknology.net>
parents:
1328
diff
changeset
|
106 | void closeEvent (QCloseEvent* event); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | |
794 | 108 | private: |
1124
bd151d5c42e6
Moved definition of MainWindow::ToolInfo into mainwindow.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1113
diff
changeset
|
109 | struct ToolInfo; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
110 | |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
111 | QMap<LDDocument*, QStack<Canvas*>> m_renderers; |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
112 | QMap<LDDocument*, QItemSelectionModel*> m_selectionModels; |
1018
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
113 | PrimitiveManager* m_primitives; |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1018
diff
changeset
|
114 | Grid* m_grid; |
1419
f7c53002a990
replaced uses of QList with QVector
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
115 | QVector<QToolButton*> m_colorButtons; |
f7c53002a990
replaced uses of QList with QVector
Teemu Piippo <teemu@hecknology.net>
parents:
1417
diff
changeset
|
116 | QVector<QAction*> m_recentFiles; |
965
d1b0aa40db91
MainWindow: "ui->" -> "ui."
Teemu Piippo <crimsondusk64@gmail.com>
parents:
964
diff
changeset
|
117 | class Ui_MainWindow& ui; |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
118 | QTabBar* m_tabs; |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
119 | bool m_updatingTabs; |
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
120 | QVector<Toolset*> m_toolsets; |
969
b1742ee91d5b
Split actions.cpp and actionsEdit.cpp into toolsets.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
121 | QMap<QAction*, ToolInfo> m_toolmap; |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
969
diff
changeset
|
122 | class ExtProgramToolset* m_externalPrograms; |
997
1b49f34e533d
Commit work done on document manager. Happy 3rd birthday LDForge!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
988
diff
changeset
|
123 | DocumentManager* m_documents; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
974
diff
changeset
|
124 | LDDocument* m_currentDocument; |
998 | 125 | QMap<QAction*, QKeySequence> m_defaultShortcuts; |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
126 | QMap<Canvas*, QMdiSubWindow*> m_subWindows; |
1339
1f342d5abc85
Added support for 8-primitives
Teemu Piippo <teemu@hecknology.net>
parents:
1335
diff
changeset
|
127 | int previousDivisions = MediumResolution; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
794 | 129 | private slots: |
1018
49358df9495b
Transformed primitive management into a new class PrimitiveManager that is a member of MainWindow
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
130 | void finishInitialization(); |
981
5d5d84ab2c48
Refactor MainWindow's API
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
131 | void recentFileClicked(); |
1437
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
132 | void canvasActivated(QMdiSubWindow* window); |
1a77c6156db7
commit work done on mdi
Teemu Piippo <teemu@hecknology.net>
parents:
1435
diff
changeset
|
133 | void mainModelLoaded(LDDocument* document); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | }; |