improve undo/redo handling
This commit is contained in:
@@ -148,11 +148,11 @@ void ShapeValidator::checkAndAdd(const Part::TopoShape &ts, const char *subName,
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Surface::SurfaceFeature, Part::Feature)
|
||||
PROPERTY_SOURCE(Surface::SurfaceFeature, Part::Spline)
|
||||
|
||||
const char* SurfaceFeature::FillTypeEnums[] = {"Stretched", "Coons", "Curved", NULL};
|
||||
|
||||
SurfaceFeature::SurfaceFeature(): Feature()
|
||||
SurfaceFeature::SurfaceFeature(): Spline()
|
||||
{
|
||||
ADD_PROPERTY(FillType, ((long)0));
|
||||
ADD_PROPERTY(BoundaryList, (0, "Dummy"));
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/FeaturePartSpline.h>
|
||||
|
||||
namespace Surface
|
||||
{
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class SurfaceFeature : public Part::Feature
|
||||
class SurfaceFeature : public Part::Spline
|
||||
{
|
||||
PROPERTY_HEADER(Surface::SurfaceFeature);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <GeomFill_FillingStyle.hxx>
|
||||
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
@@ -133,6 +132,7 @@ SurfaceFilling::SurfaceFilling(ViewProviderSurfaceFeature* vp, Surface::SurfaceF
|
||||
ui->setupUi(this);
|
||||
selectionMode = None;
|
||||
this->vp = vp;
|
||||
checkCommand = true;
|
||||
setEditedObject(obj);
|
||||
|
||||
// Create context menu
|
||||
@@ -208,21 +208,22 @@ void SurfaceFilling::changeEvent(QEvent *e)
|
||||
|
||||
void SurfaceFilling::open()
|
||||
{
|
||||
if (!Gui::Command::hasPendingCommand()) {
|
||||
if (checkCommand && !Gui::Command::hasPendingCommand()) {
|
||||
std::string Msg("Edit ");
|
||||
Msg += editedObject->Label.getValue();
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
checkCommand = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceFilling::slotUndoDocument(const Gui::Document&)
|
||||
{
|
||||
//Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
void SurfaceFilling::slotRedoDocument(const Gui::Document&)
|
||||
{
|
||||
//Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
bool SurfaceFilling::accept()
|
||||
@@ -271,33 +272,25 @@ bool SurfaceFilling::reject()
|
||||
|
||||
void SurfaceFilling::on_fillType_stretch_clicked()
|
||||
{
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
if (curtype != GeomFill_StretchStyle) {
|
||||
editedObject->FillType.setValue(static_cast<long>(GeomFill_StretchStyle));
|
||||
editedObject->recomputeFeature();
|
||||
if (!editedObject->isValid()) {
|
||||
Base::Console().Error("Surface filling: %s", editedObject->getStatusString());
|
||||
}
|
||||
}
|
||||
changeFillType(GeomFill_StretchStyle);
|
||||
}
|
||||
|
||||
void SurfaceFilling::on_fillType_coons_clicked()
|
||||
{
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
if (curtype != GeomFill_CoonsStyle) {
|
||||
editedObject->FillType.setValue(static_cast<long>(GeomFill_CoonsStyle));
|
||||
editedObject->recomputeFeature();
|
||||
if (!editedObject->isValid()) {
|
||||
Base::Console().Error("Surface filling: %s", editedObject->getStatusString());
|
||||
}
|
||||
}
|
||||
changeFillType(GeomFill_CoonsStyle);
|
||||
}
|
||||
|
||||
void SurfaceFilling::on_fillType_curved_clicked()
|
||||
{
|
||||
changeFillType(GeomFill_CurvedStyle);
|
||||
}
|
||||
|
||||
void SurfaceFilling::changeFillType(GeomFill_FillingStyle fillType)
|
||||
{
|
||||
GeomFill_FillingStyle curtype = static_cast<GeomFill_FillingStyle>(editedObject->FillType.getValue());
|
||||
if (curtype != GeomFill_CurvedStyle) {
|
||||
editedObject->FillType.setValue(static_cast<long>(GeomFill_CurvedStyle));
|
||||
if (curtype != fillType) {
|
||||
open();
|
||||
editedObject->FillType.setValue(static_cast<long>(fillType));
|
||||
editedObject->recomputeFeature();
|
||||
if (!editedObject->isValid()) {
|
||||
Base::Console().Error("Surface filling: %s", editedObject->getStatusString());
|
||||
@@ -323,6 +316,7 @@ void SurfaceFilling::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
return;
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
open();
|
||||
if (selectionMode == Append) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
ui->listWidget->addItem(item);
|
||||
@@ -384,6 +378,7 @@ void SurfaceFilling::onDeleteEdge()
|
||||
int row = ui->listWidget->currentRow();
|
||||
QListWidgetItem* item = ui->listWidget->item(row);
|
||||
if (item) {
|
||||
open();
|
||||
QList<QVariant> data;
|
||||
data = item->data(Qt::UserRole).toList();
|
||||
ui->listWidget->takeItem(row);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <Base/BoundBox.h>
|
||||
#include <Mod/Part/Gui/ViewProviderSpline.h>
|
||||
#include <Mod/Surface/App/FeatureSurface.h>
|
||||
#include <GeomFill_FillingStyle.hxx>
|
||||
|
||||
namespace SurfaceGui
|
||||
{
|
||||
@@ -75,6 +76,7 @@ protected:
|
||||
enum SelectionMode { None, Append, Remove };
|
||||
SelectionMode selectionMode;
|
||||
Surface::SurfaceFeature* editedObject;
|
||||
bool checkCommand;
|
||||
|
||||
private:
|
||||
Ui_SurfaceFilling* ui;
|
||||
@@ -96,6 +98,7 @@ protected:
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
void changeFillType(GeomFill_FillingStyle);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_fillType_stretch_clicked();
|
||||
|
||||
Reference in New Issue
Block a user