Sketcher: new Feature: Group creation of Sketcher geometry and other improvements and bug fixes

===============================================================================================

Group creation:
- complex geometries (consisting of several geometry elements and constraints) have been rewritten to use python list (one command call for all geometries and constraints)
- Ellipse ExposeInternalGeo as group creation of geometries and constraints

To construction mode creation:
- addGeometry python and SketchObject functions modified to take an additional optional parameter "construction" to create the geometry/geometries directly as construction.
  In addition to the shorter form, this helps generate less amount of onChange propagation and Redraws.
- all the geometry creation commands in CommandCreateGeo.cpp have been rewritten to use the new construction argument. This includes modifying the regular polygon script to
take a new optional parameter to create geometry as construction in addGeometry.
- special care is taken in group creation not make construction points
- Show/hide internal geometry implemented with this option.

To solving:
- the solve previously included after every geometry addition (when in no Update, e.i. no Recompute mode) has been removed and each Gui::Command calls either an UpdateActive
for recompute or a Solve in no Update mode. This is behaviour is less intrusive and uniform with group creation.

Bug fixes and redrawing reduction:
- Fixes the CheckId exception problem. The solution also helps further remove redraws during creation of complex geometry (e.g. Slot)
- Fixes touching the sketch by only opening it.
- Code clean up.
This commit is contained in:
Abdullah Tahiri
2015-06-12 17:01:47 +02:00
committed by wmayer
parent 61bd2d41ac
commit ec5f3b2b98
7 changed files with 236 additions and 319 deletions

View File

@@ -64,9 +64,19 @@ PyObject* SketchObjectPy::solve(PyObject *args)
PyObject* SketchObjectPy::addGeometry(PyObject *args)
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O", &pcObj))
return 0;
PyObject *pcObj;
PyObject* construction; // this is an optional argument default false
bool isConstruction;
if (!PyArg_ParseTuple(args, "OO!", &pcObj, &PyBool_Type, &construction)) {
PyErr_Clear();
if (!PyArg_ParseTuple(args, "O", &pcObj))
return 0;
else
isConstruction=false;
}
else {
isConstruction = PyObject_IsTrue(construction) ? true : false;
}
if (PyObject_TypeCheck(pcObj, &(Part::GeometryPy::Type))) {
Part::Geometry *geo = static_cast<Part::GeometryPy*>(pcObj)->getGeometryPtr();
@@ -80,13 +90,13 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
// create the definition struct for that geom
Part::GeomArcOfCircle aoc;
aoc.setHandle(trim);
ret = this->getSketchObjectPtr()->addGeometry(&aoc);
ret = this->getSketchObjectPtr()->addGeometry(&aoc,isConstruction);
}
else if (!ellipse.IsNull()) {
// create the definition struct for that geom
Part::GeomArcOfEllipse aoe;
aoe.setHandle(trim);
ret = this->getSketchObjectPtr()->addGeometry(&aoe);
ret = this->getSketchObjectPtr()->addGeometry(&aoe,isConstruction);
}
else {
std::stringstream str;
@@ -101,7 +111,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() ||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
ret = this->getSketchObjectPtr()->addGeometry(geo);
ret = this->getSketchObjectPtr()->addGeometry(geo,isConstruction);
}
else {
std::stringstream str;
@@ -163,7 +173,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject *args)
}
}
int ret = this->getSketchObjectPtr()->addGeometry(geoList) + 1;
int ret = this->getSketchObjectPtr()->addGeometry(geoList,isConstruction) + 1;
std::size_t numGeo = geoList.size();
Py::Tuple tuple(numGeo);
for (std::size_t i=0; i<numGeo; ++i) {