src/edithistory.cpp

Wed, 25 May 2022 20:36:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 20:36:34 +0300
changeset 199
6988973515d2
parent 153
2f79053c2e9a
permissions
-rw-r--r--

Fix pick() picking from weird places on the screen with high DPI scaling

glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account

136
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
1 /*
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
2 * LDForge: LDraw parts authoring CAD
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
4 *
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
5 * This program is free software: you can redistribute it and/or modify
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
6 * it under the terms of the GNU General Public License as published by
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
8 * (at your option) any later version.
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
9 *
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
10 * This program is distributed in the hope that it will be useful,
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
13 * GNU General Public License for more details.
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
14 *
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
15 * You should have received a copy of the GNU General Public License
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
17 */
e8444e0d7f1a Work on edit history
Teemu Piippo <teemu@hecknology.net>
parents: 133
diff changeset
18
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #include "edithistory.h"
153
2f79053c2e9a Renamed modeleditcontext.cpp -> modeleditor.cpp
Teemu Piippo <teemu@hecknology.net>
parents: 152
diff changeset
20 #include "modeleditor.h"
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 EditHistory::EditHistory()
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
27 void InsertHistoryEntry::undo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 editContext.remove(this->position);
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
32 void InsertHistoryEntry::redo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
37 void DeleteHistoryEntry::undo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 static_cast<InsertHistoryEntry*>(this)->redo(editContext);
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
42 void DeleteHistoryEntry::redo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
43 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
44 static_cast<InsertHistoryEntry*>(this)->undo(editContext);
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
47 void EditHistoryEntry::undo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
50 }
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
51
152
03f8e6d42e13 Major refactoring
Teemu Piippo <teemu@hecknology.net>
parents: 136
diff changeset
52 void EditHistoryEntry::redo(ModelEditor &editContext)
133
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53 {
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
54
e39326ee48dc Begin work on edit history
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
55 }

mercurial