Sketcher: BSpline Creation - as single command for one-step undo
This commit is contained in:
parent
bad73abe84
commit
6ad51826d4
|
@ -4405,7 +4405,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
//Gui::Command::commitCommand();
|
||||
|
||||
//static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
|
||||
|
@ -4413,7 +4413,7 @@ public:
|
|||
|
||||
// add auto constraints on pole
|
||||
if (sugConstr[CurrentConstraint].size() > 0) {
|
||||
createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId, Sketcher::mid);
|
||||
createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId, Sketcher::mid, false);
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
|
@ -4450,7 +4450,7 @@ public:
|
|||
// insert circle point for pole, defer internal alignment constraining.
|
||||
try {
|
||||
|
||||
Gui::Command::openCommand("Add Pole circle");
|
||||
//Gui::Command::openCommand("Add Pole circle");
|
||||
|
||||
//Add pole
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)",
|
||||
|
@ -4475,16 +4475,16 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
//Gui::Command::commitCommand();
|
||||
|
||||
//static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
|
||||
// add auto constraints on pole
|
||||
if (sugConstr[CurrentConstraint].size() > 0) {
|
||||
createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId + EditCurve.size()-1, Sketcher::mid);
|
||||
createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId + EditCurve.size()-1, Sketcher::mid, false);
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
//static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
|
||||
if (!IsClosed) {
|
||||
EditCurve.resize(EditCurve.size() + 1); // add one place for a pole
|
||||
|
@ -4523,7 +4523,7 @@ public:
|
|||
|
||||
try {
|
||||
|
||||
Gui::Command::openCommand("Add B-spline curve");
|
||||
//Gui::Command::openCommand("Add B-spline curve");
|
||||
|
||||
//Add arc of parabola
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
|
@ -4623,7 +4623,18 @@ public:
|
|||
}
|
||||
else if(CurrentConstraint == 1) {
|
||||
// if we just have one point and we can not close anything, then cancel this creation but continue according to continuous mode
|
||||
sketchgui->getDocument()->undo(1);
|
||||
//sketchgui->getDocument()->undo(1);
|
||||
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
|
||||
|
||||
if(autoRecompute)
|
||||
Gui::Command::updateActive();
|
||||
else
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
|
||||
if(!continuousMode){
|
||||
DrawSketchHandler::quit();
|
||||
}
|
||||
|
|
|
@ -383,15 +383,18 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
}
|
||||
|
||||
void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint> &autoConstrs,
|
||||
int geoId1, Sketcher::PointPos posId1)
|
||||
int geoId1, Sketcher::PointPos posId1, bool createowncommand /*= true*/)
|
||||
{
|
||||
if (!sketchgui->Autoconstraints.getValue())
|
||||
return; // If Autoconstraints property is not set quit
|
||||
|
||||
if (autoConstrs.size() > 0) {
|
||||
// Open the Command
|
||||
Gui::Command::openCommand("Add auto constraints");
|
||||
|
||||
|
||||
if(createowncommand) {
|
||||
// Open the Command
|
||||
Gui::Command::openCommand("Add auto constraints");
|
||||
}
|
||||
|
||||
// Iterate through constraints
|
||||
std::vector<AutoConstraint>::const_iterator it = autoConstrs.begin();
|
||||
for (; it != autoConstrs.end(); ++it) {
|
||||
|
@ -512,7 +515,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
|
|||
break;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
if(createowncommand) {
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
//Gui::Command::updateActive(); // There is already an recompute in each command creation, this is redundant.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,10 @@ public:
|
|||
int seekAutoConstraint(std::vector<AutoConstraint> &suggestedConstraints,
|
||||
const Base::Vector2d &Pos, const Base::Vector2d &Dir,
|
||||
AutoConstraint::TargetType type = AutoConstraint::VERTEX);
|
||||
// createowncommand indicates whether a separate command shall be create and committed (for example for undo purposes) or not
|
||||
// is not it is the responsibility of the developer to create and commit the command appropriately.
|
||||
void createAutoConstraints(const std::vector<AutoConstraint> &autoConstrs,
|
||||
int geoId, Sketcher::PointPos pointPos=Sketcher::none);
|
||||
int geoId, Sketcher::PointPos pointPos=Sketcher::none, bool createowncommand = true);
|
||||
|
||||
void setPositionText(const Base::Vector2d &Pos, const SbString &text);
|
||||
void setPositionText(const Base::Vector2d &Pos);
|
||||
|
|
Loading…
Reference in New Issue
Block a user