TechDraw: add transactions to multiple commands (#22795)
* TechDraw: add transactions to multiple commands * Feed each 'Create Dimension' option to the translation macro * Call fixSceneDependencies when re-adding dimensions so that it shows up at the right place
This commit is contained in:
@@ -2086,11 +2086,20 @@ bool CmdTechDrawHorizontalExtentDimension::isActive()
|
||||
|
||||
void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
{
|
||||
const char* commandString = nullptr;
|
||||
if (dimType == "DistanceX") {
|
||||
commandString = QT_TRANSLATE_NOOP("Command", "Create Dimension DistanceX");
|
||||
} else if (dimType == "DistanceY") {
|
||||
commandString = QT_TRANSLATE_NOOP("Command", "Create Dimension DistanceY");
|
||||
}
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", commandString));
|
||||
|
||||
bool result = _checkDrawViewPart(cmd);
|
||||
if (!result) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect selection"),
|
||||
QObject::tr("No view of a part in selection."));
|
||||
Gui::Command::abortCommand();
|
||||
return;
|
||||
}
|
||||
ReferenceVector references2d;
|
||||
@@ -2106,6 +2115,7 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect selection"),
|
||||
QObject::tr("Selection contains both 2D and 3D geometry"));
|
||||
Gui::Command::abortCommand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2129,8 +2139,9 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
references2d, acceptableGeometry, minimumCounts, acceptableDimensionGeometrys);
|
||||
if (geometryRefs2d == DimensionGeometry::isInvalid) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect selection"),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Cannot make 2D extent dimension from selection"));
|
||||
Gui::Command::abortCommand();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2146,6 +2157,7 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Cannot make 3D extent dimension from selection"));
|
||||
Gui::Command::abortCommand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2156,6 +2168,7 @@ void execExtent(Gui::Command* cmd, const std::string& dimType)
|
||||
else {
|
||||
DrawDimHelper::makeExtentDim3d(partFeat, dimType, references3d);
|
||||
}
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "ZVALUE.h"
|
||||
#include "TaskDimension.h"
|
||||
#include "QGIViewDimension.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "ViewProviderDimension.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -189,6 +190,15 @@ void ViewProviderDimension::updateData(const App::Property* prop)
|
||||
return;
|
||||
}
|
||||
|
||||
// This properties is changed when creating then on redo (or undo deletion)
|
||||
// so does Reference3d, but using || would call fixSceneDependencies() twice
|
||||
if (prop == &(getViewObject()->References2D)) {
|
||||
// Ensure the QGraphicsItems hierarchy matches the DocumentObject's
|
||||
if (ViewProviderPage* vpp = getViewProviderPage()) {
|
||||
vpp->fixSceneDependencies();
|
||||
}
|
||||
}
|
||||
|
||||
//Skip QGIView X, Y processing - do not call ViewProviderDrawingView
|
||||
Gui::ViewProviderDocumentObject::updateData(prop); //NOLINT
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ class CommandAxoLengthDimension:
|
||||
|
||||
def Activated(self):
|
||||
"""Run the following code when the command is activated (button press)."""
|
||||
|
||||
App.setActiveTransaction("Create axonometric length dimension")
|
||||
vertexes = []
|
||||
edges = []
|
||||
if Utils.getSelEdges(2):
|
||||
@@ -110,6 +112,7 @@ class CommandAxoLengthDimension:
|
||||
distanceDim.recompute()
|
||||
view.requestPaint()
|
||||
Gui.Selection.clearSelection()
|
||||
App.closeActiveTransaction()
|
||||
|
||||
def IsActive(self):
|
||||
"""Return True when the command should be active or False when it should be disabled (greyed)."""
|
||||
|
||||
@@ -46,6 +46,8 @@ class TaskAddOffsetVertex():
|
||||
self.view = view
|
||||
self.vertex = vertex
|
||||
|
||||
App.setActiveTransaction("Add offset vertex")
|
||||
|
||||
def accept(self):
|
||||
'''slot: OK pressed'''
|
||||
point = self.vertex.Point # this is unscaled and inverted, but is also rotated.
|
||||
@@ -59,6 +61,8 @@ class TaskAddOffsetVertex():
|
||||
# uninverted relative value.
|
||||
self.view.makeCosmeticVertex(point+offset)
|
||||
Gui.Control.closeDialog()
|
||||
App.closeActiveTransaction()
|
||||
|
||||
def reject(self):
|
||||
App.closeActiveTransaction(True)
|
||||
return True
|
||||
|
||||
@@ -428,6 +428,8 @@ class TaskFillTemplateFields:
|
||||
QtCore.QMetaObject.connectSlotsByName(self.dialog)
|
||||
self.dialog.show()
|
||||
self.dialog.exec_()
|
||||
|
||||
App.setActiveTransaction("Fill template fields")
|
||||
else:
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgTitle = QtCore.QT_TRANSLATE_NOOP(
|
||||
@@ -526,6 +528,9 @@ class TaskFillTemplateFields:
|
||||
self.page.Template.EditableTexts = self.texts
|
||||
self.close()
|
||||
|
||||
App.closeActiveTransaction()
|
||||
|
||||
def close(self):
|
||||
self.dialog.hide()
|
||||
App.closeActiveTransaction(True)
|
||||
return True
|
||||
|
||||
@@ -94,6 +94,8 @@ class TaskHoleShaftFit:
|
||||
self.form.rbHoleBase.clicked.connect(partial(self.on_HoleShaftChanged, True))
|
||||
self.form.rbShaftBase.clicked.connect(partial(self.on_HoleShaftChanged, False))
|
||||
self.form.cbField.currentIndexChanged.connect(self.on_FieldChanged)
|
||||
|
||||
App.setActiveTransaction("Add hole or shaft fit")
|
||||
|
||||
def setHoleFields(self):
|
||||
"""set hole fields in the combo box"""
|
||||
@@ -168,8 +170,10 @@ class TaskHoleShaftFit:
|
||||
else:
|
||||
dim.FormatSpecUnderTolerance = "( %-0.6w)"
|
||||
Gui.Control.closeDialog()
|
||||
App.closeActiveTransaction()
|
||||
|
||||
def reject(self):
|
||||
App.closeActiveTransaction(True)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -57,8 +57,11 @@ class TaskMoveView:
|
||||
|
||||
self.dialogOpen = False
|
||||
|
||||
App.setActiveTransaction("Move view")
|
||||
|
||||
def accept(self):
|
||||
# print ("Accept")
|
||||
App.closeActiveTransaction()
|
||||
view = App.ActiveDocument.getObject(self.viewName)
|
||||
fromPage = App.ActiveDocument.getObject(self.fromPageName)
|
||||
toPage = App.ActiveDocument.getObject(self.toPageName)
|
||||
@@ -67,6 +70,7 @@ class TaskMoveView:
|
||||
|
||||
def reject(self):
|
||||
# print ("Reject")
|
||||
App.closeActiveTransaction(True)
|
||||
return True
|
||||
|
||||
def pickView(self):
|
||||
|
||||
@@ -57,16 +57,21 @@ class TaskShareView:
|
||||
|
||||
self.dialogOpen = False
|
||||
|
||||
App.setActiveTransaction("Share view")
|
||||
|
||||
def accept(self):
|
||||
# print ("Accept")
|
||||
view = App.ActiveDocument.getObject(self.viewName)
|
||||
fromPage = App.ActiveDocument.getObject(self.fromPageName)
|
||||
toPage = App.ActiveDocument.getObject(self.toPageName)
|
||||
TDToolsMovers.moveView(view, fromPage, toPage, True)
|
||||
|
||||
App.closeActiveTransaction()
|
||||
return True
|
||||
|
||||
def reject(self):
|
||||
# print ("Reject")
|
||||
App.closeActiveTransaction(True)
|
||||
return True
|
||||
|
||||
def pickView(self):
|
||||
|
||||
Reference in New Issue
Block a user