Skip to content

Commit

Permalink
askTransformDialog, mainwindow: Hopefully fix redo/undo/repeat in the…
Browse files Browse the repository at this point in the history
… roto-translate tool after the changes in be41797. Fix the 3D view not refreshing on Ctrl + R.

Boy, this was a huge pain to get working for so little code. :)
  • Loading branch information
Swyter committed May 15, 2024
1 parent 1a1f204 commit 482077f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions askTransformDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ class AskTransformDialog : public QDialog {
public slots:
int exec();
void reset();
void update();

private:
Ui::AskTransformDialog *ui;
double sensitivityOne, sensitivityAll;
private slots:
void update();

void updateSensitivity();
void onAlignmentLX(bool);
void onAlignmentLY(bool);
Expand Down
16 changes: 11 additions & 5 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ MainWindow::MainWindow(QWidget *parent):QMainWindow(parent),inidata(brfdata)
askTransformDialog->matrix = glWidget->extraMatrix;
askTransformDialog->setApplyToAllLoc( &( glWidget->applyExtraMatrixToAll ) );
connect(askTransformDialog,SIGNAL(changed()),glWidget,SLOT(update()));
connect(askTransformDialog, SIGNAL(accepted()), this, SLOT(onTransformDone())); /* swy: split the transform() into two, so that the askTransformDialog is no longer a modal that doesn't let us move the camera, we apply the consequences on transformDone(), adding a ton of complexity to the undo/redo and repeat action functionality, oh boy */
connect(askTransformDialog, SIGNAL(rejected()), this, SLOT(onTransformDone()));

askUvTransformDialog = new AskUvTransformDialog(this);
connect(askUvTransformDialog,SIGNAL(changed()),this,SLOT(meshUvTransformDoIt()));
Expand Down Expand Up @@ -2603,8 +2605,7 @@ void MainWindow::transform(){
lastUsedI = list[0].row();
lastUsedTab = selector->currentTabName();
*/
if (!executingRepeatedCommand) d->reset();
executingRepeatedCommand = false;
if (!executingRepeatedCommand) d->reset(); else d->update(); /* swy: reset all the controls to zero when opening it normally; just refresh the 3D view from the pre-filled repeated input values if not */

d->setBoundingBox(bboxAll.min.V(), bboxAll.max.V());

Expand All @@ -2622,8 +2623,7 @@ void MainWindow::transform(){
and move the camera while rescaling/translating via the AskTransformDialog GUI */
disableWhileInToolMode(true);

QObject::connect(d, SIGNAL(accepted()), this, SLOT(onTransformDone()));
QObject::connect(d, SIGNAL(rejected()), this, SLOT(onTransformDone()));


d->setWindowFlags(Qt::Tool);
d->show();
Expand Down Expand Up @@ -2653,10 +2653,16 @@ void MainWindow::onTransformDone(){
for (int j=start; j<list.size(); j++)
brfdata.body[list[j].row()].Transform(d->matrix);

setModified();
setModified(); /* swy: this comes with the repeatable = true default parameter, that sets the setNextActionAsRepeatable = true */
if (!executingRepeatedCommand) /* swy: FIXME: look into this; because I'm getting a headache with the Ctrl+R repeat command and undo/redo step logic and splitting the action into two unrelated functions :) */
undoHistoryAddAction(selector->transformAct); /* swy: this is a way of manually triggering a fake QAction that will save the changes at that point with the right name */

onActionTriggered(selector->transformAct); /* swy: this works in conjunction with setNextActionAsRepeatable set to true to mark the current action as repeatable, enables the Ctrl + R and the menu entry under Tools > Repeat, go figure */
}
glWidget->clearExtraMatrix();
updateGl();

executingRepeatedCommand = false;
}


Expand Down

0 comments on commit 482077f

Please sign in to comment.