Merge branch 'refs/heads/master' into review-CL-Bundler
Conflicts: src/3rdParty/salomesmesh/CMakeLists.txt
This commit is contained in:
@@ -1330,6 +1330,44 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
ExternalGeo.push_back(line);
|
||||
}
|
||||
}
|
||||
else if (curve.GetType() == GeomAbs_Circle) {
|
||||
gp_Dir vec1 = sketchPlane.Axis().Direction();
|
||||
gp_Dir vec2 = curve.Circle().Axis().Direction();
|
||||
if (vec1.IsParallel(vec2, Precision::Confusion())) {
|
||||
gp_Circ circle = curve.Circle();
|
||||
gp_Pnt cnt = circle.Location();
|
||||
gp_Pnt beg = curve.Value(curve.FirstParameter());
|
||||
gp_Pnt end = curve.Value(curve.LastParameter());
|
||||
|
||||
GeomAPI_ProjectPointOnSurf proj(cnt,gPlane);
|
||||
cnt = proj.NearestPoint();
|
||||
circle.SetLocation(cnt);
|
||||
cnt.Transform(mov);
|
||||
circle.Transform(mov);
|
||||
|
||||
if (beg.SquareDistance(end) < Precision::Confusion()) {
|
||||
Part::GeomCircle* gCircle = new Part::GeomCircle();
|
||||
gCircle->setRadius(circle.Radius());
|
||||
gCircle->setCenter(Base::Vector3d(cnt.X(),cnt.Y(),cnt.Z()));
|
||||
|
||||
gCircle->Construction = true;
|
||||
ExternalGeo.push_back(gCircle);
|
||||
}
|
||||
else {
|
||||
Part::GeomArcOfCircle* gArc = new Part::GeomArcOfCircle();
|
||||
Handle_Geom_Curve hCircle = new Geom_Circle(circle);
|
||||
Handle_Geom_TrimmedCurve tCurve = new Geom_TrimmedCurve(hCircle, curve.FirstParameter(),
|
||||
curve.LastParameter());
|
||||
gArc->setHandle(tCurve);
|
||||
gArc->Construction = true;
|
||||
ExternalGeo.push_back(gArc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// creates an ellipse
|
||||
throw Base::Exception("Not yet supported geometry for external geometry");
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
BRepOffsetAPI_NormalProjection mkProj(aProjFace);
|
||||
|
||||
@@ -3009,32 +3009,20 @@ public:
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
EditCurve[0].fX,EditCurve[0].fY,EditCurve[34].fX,EditCurve[34].fY);
|
||||
//// add the tnagent constraints
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve,firstCurve+2);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) "
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,1,%i,1)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve,firstCurve+3);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve+1,firstCurve+2);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve+1,firstCurve+3);
|
||||
// add the four coincidents to ty them together
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,1,%i,1)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve,firstCurve+3);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve,firstCurve+2);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) "
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve+2,firstCurve+1);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,2)) "
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,2)) "
|
||||
,sketchgui->getObject()->getNameInDocument()
|
||||
,firstCurve+3,firstCurve+1);
|
||||
|
||||
//// add the either horizontal or vertical constraints
|
||||
if(fabs(lx)>fabs(ly))
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) "
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <boost/bind.hpp>
|
||||
#endif
|
||||
|
||||
#include "TaskDlgEditSketch.h"
|
||||
@@ -46,16 +47,33 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
|
||||
Elements = new TaskSketcherElements(sketchView);
|
||||
General = new TaskSketcherGeneral(sketchView);
|
||||
Messages = new TaskSketcherMessages(sketchView);
|
||||
|
||||
|
||||
Content.push_back(Messages);
|
||||
Content.push_back(General);
|
||||
Content.push_back(Constraints);
|
||||
Content.push_back(Elements);
|
||||
|
||||
App::Document* document = sketchView->getObject()->getDocument();
|
||||
connectUndoDocument =
|
||||
document->signalUndo.connect(boost::bind(&TaskDlgEditSketch::slotUndoDocument, this, _1));
|
||||
connectRedoDocument =
|
||||
document->signalRedo.connect(boost::bind(&TaskDlgEditSketch::slotRedoDocument, this, _1));
|
||||
}
|
||||
|
||||
TaskDlgEditSketch::~TaskDlgEditSketch()
|
||||
{
|
||||
connectUndoDocument.disconnect();
|
||||
connectRedoDocument.disconnect();
|
||||
}
|
||||
|
||||
void TaskDlgEditSketch::slotUndoDocument(const App::Document& doc)
|
||||
{
|
||||
const_cast<App::Document&>(doc).recomputeFeature(sketchView->getObject());
|
||||
}
|
||||
|
||||
void TaskDlgEditSketch::slotRedoDocument(const App::Document& doc)
|
||||
{
|
||||
const_cast<App::Document&>(doc).recomputeFeature(sketchView->getObject());
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include "TaskSketcherElements.h"
|
||||
#include "TaskSketcherGeneral.h"
|
||||
#include "TaskSketcherMessages.h"
|
||||
#include <boost/signals.hpp>
|
||||
|
||||
typedef boost::signals::connection Connection;
|
||||
|
||||
namespace SketcherGui {
|
||||
|
||||
@@ -65,11 +68,17 @@ public:
|
||||
{ return QDialogButtonBox::Close|QDialogButtonBox::Help; }
|
||||
|
||||
protected:
|
||||
ViewProviderSketch *sketchView;
|
||||
void slotUndoDocument(const App::Document&);
|
||||
void slotRedoDocument(const App::Document&);
|
||||
|
||||
protected:
|
||||
ViewProviderSketch *sketchView;
|
||||
TaskSketcherConstrains *Constraints;
|
||||
TaskSketcherElements *Elements;
|
||||
TaskSketcherElements *Elements;
|
||||
TaskSketcherGeneral *General;
|
||||
TaskSketcherMessages *Messages;
|
||||
Connection connectUndoDocument;
|
||||
Connection connectRedoDocument;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ void SketcherGeneralWidget::saveSettings()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher/General");
|
||||
hGrp->SetBool("ShowGrid", ui->checkBoxShowGrid->isChecked());
|
||||
|
||||
ui->gridSize->pushToHistory();
|
||||
|
||||
ui->gridSize->pushToHistory();
|
||||
|
||||
hGrp->SetBool("GridSnap", ui->checkBoxGridSnap->isChecked());
|
||||
hGrp->SetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked());
|
||||
@@ -78,14 +78,12 @@ void SketcherGeneralWidget::loadSettings()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher/General");
|
||||
ui->checkBoxShowGrid->setChecked(hGrp->GetBool("ShowGrid", true));
|
||||
ui->gridSize->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketchGridSize"));
|
||||
//ui->gridSize->setToLastUsedValue();
|
||||
ui->gridSize->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketchGridSize"));
|
||||
//ui->gridSize->setToLastUsedValue();
|
||||
ui->checkBoxGridSnap->setChecked(hGrp->GetBool("GridSnap", ui->checkBoxGridSnap->isChecked()));
|
||||
ui->checkBoxAutoconstraints->setChecked(hGrp->GetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SketcherGeneralWidget::toggleGridView(bool on)
|
||||
{
|
||||
ui->label->setEnabled(on);
|
||||
@@ -101,7 +99,7 @@ void SketcherGeneralWidget::setGridSize(double val)
|
||||
|
||||
void SketcherGeneralWidget::setInitGridSize(double val)
|
||||
{
|
||||
ui->gridSize->setValue(Base::Quantity(val,Base::Unit::Length));
|
||||
ui->gridSize->setValue(Base::Quantity(val,Base::Unit::Length));
|
||||
}
|
||||
|
||||
void SketcherGeneralWidget::toggleGridSnap(int state)
|
||||
@@ -150,7 +148,7 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
widget->loadSettings();
|
||||
widget->setInitGridSize(sketchView->GridSize.getValue() );
|
||||
widget->setInitGridSize(sketchView->GridSize.getValue() );
|
||||
}
|
||||
|
||||
TaskSketcherGeneral::~TaskSketcherGeneral()
|
||||
@@ -182,7 +180,7 @@ void TaskSketcherGeneral::toggleAutoconstraints(int state)
|
||||
|
||||
/// @cond DOXERR
|
||||
void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
|
||||
Gui::SelectionSingleton::MessageType Reason)
|
||||
Gui::SelectionSingleton::MessageType Reason)
|
||||
{
|
||||
//if (Reason.Type == SelectionChanges::AddSelection ||
|
||||
// Reason.Type == SelectionChanges::RmvSelection ||
|
||||
|
||||
@@ -694,14 +694,15 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
int GeoId;
|
||||
Sketcher::PointPos PosId;
|
||||
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
|
||||
Gui::Command::openCommand("Drag Point");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)"
|
||||
,getObject()->getNameInDocument()
|
||||
,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0
|
||||
);
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::updateActive();
|
||||
|
||||
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
|
||||
Gui::Command::openCommand("Drag Point");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)"
|
||||
,getObject()->getNameInDocument()
|
||||
,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0
|
||||
);
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
setPreselectPoint(edit->DragPoint);
|
||||
edit->DragPoint = -1;
|
||||
//updateColor();
|
||||
@@ -987,10 +988,12 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
||||
int GeoId;
|
||||
Sketcher::PointPos PosId;
|
||||
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
|
||||
edit->ActSketch.initMove(GeoId, PosId, false);
|
||||
relative = false;
|
||||
xInit = 0;
|
||||
yInit = 0;
|
||||
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
|
||||
edit->ActSketch.initMove(GeoId, PosId, false);
|
||||
relative = false;
|
||||
xInit = 0;
|
||||
yInit = 0;
|
||||
}
|
||||
} else {
|
||||
Mode = STATUS_NONE;
|
||||
}
|
||||
@@ -1044,13 +1047,15 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
||||
Sketcher::PointPos PosId;
|
||||
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
|
||||
Base::Vector3d vec(x-xInit,y-yInit,0);
|
||||
if (edit->ActSketch.movePoint(GeoId, PosId, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
draw(true);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||
} else {
|
||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||
//Base::Console().Log("Error solving:%d\n",ret);
|
||||
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
|
||||
if (edit->ActSketch.movePoint(GeoId, PosId, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
draw(true);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime));
|
||||
} else {
|
||||
signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime));
|
||||
//Base::Console().Log("Error solving:%d\n",ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user