From 08e6bc0e6a4450882b32d293f25f1277b261914e Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 21 Sep 2012 11:54:35 +0200 Subject: [PATCH 01/17] 0000545: Undo revolve causes crash illegal storage --- src/Mod/Part/Gui/SoBrepShape.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mod/Part/Gui/SoBrepShape.cpp b/src/Mod/Part/Gui/SoBrepShape.cpp index 39658d073..2a9c2c4cb 100644 --- a/src/Mod/Part/Gui/SoBrepShape.cpp +++ b/src/Mod/Part/Gui/SoBrepShape.cpp @@ -1178,6 +1178,12 @@ SoBrepPointSet::SoBrepPointSet() void SoBrepPointSet::GLRender(SoGLRenderAction *action) { + const SoCoordinateElement* coords = SoCoordinateElement::getInstance(action->getState()); + int num = coords->getNum() - this->startIndex.getValue(); + if (num < 0) { + // Fixes: #0000545: Undo revolve causes crash 'illegal storage' + return; + } if (this->selectionIndex.getNum() > 0) renderSelection(action); if (this->highlightIndex.getValue() >= 0) From 065213f9bdd6e867e00ecc34d623728038c18469 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 21 Sep 2012 13:05:37 +0200 Subject: [PATCH 02/17] 0000545: Undo revolve causes crash illegal storage, fix disappearing shape after undo/redo --- src/Mod/Part/Gui/ViewProviderExt.cpp | 1 + src/Mod/PartDesign/Gui/ViewProvider.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index b9ae984c2..10260b9be 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -578,6 +578,7 @@ void ViewProviderPartExt::updateVisual(const TopoDS_Shape& inputShape) faceset ->coordIndex .setNum(0); faceset ->partIndex .setNum(0); lineset ->coordIndex .setNum(0); + nodeset ->startIndex .setValue(0); VisualTouched = false; return; } diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index c0ca541ad..91ec62707 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -58,5 +58,9 @@ void ViewProvider::updateData(const App::Property* prop) strcmp(prop->getName(),"AddShape") == 0) { return; } + if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && + strcmp(prop->getName(),"SubShape") == 0) { + return; + } inherited::updateData(prop); } From a20f4dddffbe590434041373ee125b367ee60e31 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 22 Sep 2012 16:22:26 +0200 Subject: [PATCH 03/17] Fix autotools, fix warning --- src/Mod/Part/Gui/TaskCheckGeometry.cpp | 3 ++ src/Mod/PartDesign/App/Makefile.am | 14 +++++- src/Mod/PartDesign/Gui/Makefile.am | 65 ++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/Mod/Part/Gui/TaskCheckGeometry.cpp b/src/Mod/Part/Gui/TaskCheckGeometry.cpp index bf220e3cc..95afd3795 100644 --- a/src/Mod/Part/Gui/TaskCheckGeometry.cpp +++ b/src/Mod/Part/Gui/TaskCheckGeometry.cpp @@ -521,6 +521,9 @@ QString SetupResultBase::selectionName(ResultEntry *entry, const TopoDS_Shape &s TopExp::MapShapes(parentEntry->shape, TopAbs_VERTEX, shapeMap); stream << "Vertex"; break; + default: + stream << "Unexpected shape type"; + break; } index = shapeMap.FindIndex(shape); diff --git a/src/Mod/PartDesign/App/Makefile.am b/src/Mod/PartDesign/App/Makefile.am index a3b251dec..80f971f49 100644 --- a/src/Mod/PartDesign/App/Makefile.am +++ b/src/Mod/PartDesign/App/Makefile.am @@ -21,18 +21,28 @@ libPartDesign_la_SOURCES=\ FeatureGroove.h \ Body.cpp \ Body.h \ + FeatureLinearPattern.cpp \ + FeatureLinearPattern.h \ + FeatureMirrored.cpp \ + FeatureMirrored.h \ + FeatureMultiTransform.cpp \ + FeatureMultiTransform.h \ + FeaturePolarPattern.cpp \ + FeaturePolarPattern.h \ + FeatureScaled.cpp \ + FeatureScaled.h \ FeatureSketchBased.cpp \ FeatureSketchBased.h \ FeatureRevolution.cpp \ FeatureRevolution.h \ FeatureAdditive.cpp \ FeatureAdditive.h \ - FeaturePatternRectangular.cpp \ - FeaturePatternRectangular.h \ FeatureSubtractive.cpp \ FeatureSubtractive.h \ FeatureHole.cpp \ FeatureHole.h \ + FeatureTransformed.cpp \ + FeatureTransformed.h \ PreCompiled.cpp \ PreCompiled.h diff --git a/src/Mod/PartDesign/Gui/Makefile.am b/src/Mod/PartDesign/Gui/Makefile.am index e3b32574c..4d0ca5034 100644 --- a/src/Mod/PartDesign/Gui/Makefile.am +++ b/src/Mod/PartDesign/Gui/Makefile.am @@ -3,62 +3,103 @@ SUBDIRS=Resources lib_LTLIBRARIES=libPartDesignGui.la PartDesignGui.la BUILT_SOURCES=\ + moc_FeaturePickDialog.cpp \ moc_TaskPadParameters.cpp \ - moc_TaskPatternRectangularParameters.cpp \ moc_TaskPocketParameters.cpp \ moc_TaskChamferParameters.cpp \ moc_TaskFilletParameters.cpp \ moc_TaskGrooveParameters.cpp \ moc_TaskHoleParameters.cpp \ + moc_TaskLinearPatternParameters.cpp \ + moc_TaskMirroredParameters.cpp \ + moc_TaskMultiTransformParameters.cpp \ + moc_TaskPolarPatternParameters.cpp \ moc_TaskRevolutionParameters.cpp \ + moc_TaskScaledParameters.cpp \ + moc_TaskTransformedMessages.cpp \ + moc_TaskTransformedParameters.cpp \ + ui_FeaturePickDialog.h \ ui_TaskGrooveParameters.h \ ui_TaskPadParameters.h \ - ui_TaskPatternRectangularParameters.h \ ui_TaskPocketParameters.h \ ui_TaskChamferParameters.h \ ui_TaskFilletParameters.h \ ui_TaskHoleParameters.h \ - ui_TaskRevolutionParameters.h + ui_TaskLinearPatternParameters.h \ + ui_TaskMirroredParameters.h \ + ui_TaskMultiTransformParameters.h \ + ui_TaskPolarPatternParameters.h \ + ui_TaskRevolutionParameters.h \ + ui_TaskScaledParameters.h \ + ui_TaskTransformedMessages.h libPartDesignGui_la_UI=\ + FeaturePickDialog.ui \ TaskGrooveParameters.ui \ TaskPadParameters.ui \ - TaskPatternRectangularParameters.ui \ TaskPocketParameters.ui \ TaskChamferParameters.ui \ TaskFilletParameters.ui \ TaskHoleParameters.ui \ - TaskRevolutionParameters.ui + TaskLinearPatternParameters.ui \ + TaskMirroredParameters.ui \ + TaskMultiTransformParameters.ui \ + TaskPolarPatternParameters.ui \ + TaskRevolutionParameters.ui \ + TaskScaledParameters.ui \ + TaskTransformedMessages.ui libPartDesignGui_la_SOURCES=\ AppPartDesignGuiPy.cpp \ Command.cpp \ PreCompiled.cpp \ PreCompiled.h \ + FeaturePickDialog.cpp \ + FeaturePickDialog.h \ TaskGrooveParameters.cpp \ TaskGrooveParameters.h \ TaskPadParameters.cpp \ TaskPadParameters.h \ - TaskPatternRectangularParameters.cpp \ - TaskPatternRectangularParameters.h \ TaskPocketParameters.cpp \ TaskPocketParameters.h \ TaskChamferParameters.cpp \ TaskChamferParameters.h \ TaskFilletParameters.cpp \ TaskFilletParameters.h \ + TaskLinearPatternParameters.cpp \ + TaskLinearPatternParameters.h \ + TaskMirroredParameters.cpp \ + TaskMirroredParameters.h \ + TaskMultiTransformParameters.cpp \ + TaskMultiTransformParameters.h \ + TaskPolarPatternParameters.cpp \ + TaskPolarPatternParameters.h \ TaskRevolutionParameters.cpp \ TaskRevolutionParameters.h \ TaskHoleParameters.cpp \ TaskHoleParameters.h \ + TaskScaledParameters.cpp \ + TaskScaledParameters.h \ + TaskTransformedParameters.cpp \ + TaskTransformedParameters.h \ + TaskTransformedMessages.cpp \ + TaskTransformedMessages.h \ ViewProvider.cpp \ ViewProvider.h \ ViewProviderHole.cpp \ ViewProviderHole.h \ + ViewProviderLinearPattern.cpp \ + ViewProviderLinearPattern.h \ + ViewProviderMirrored.cpp \ + ViewProviderMirrored.h \ + ViewProviderMultiTransform.cpp \ + ViewProviderMultiTransform.h \ ViewProviderPad.cpp \ ViewProviderPad.h \ ViewProviderPocket.cpp \ ViewProviderPocket.h \ + ViewProviderPolarPattern.cpp \ + ViewProviderPolarPattern.h \ ViewProviderChamfer.cpp \ ViewProviderChamfer.h \ ViewProviderFillet.cpp \ @@ -67,8 +108,10 @@ libPartDesignGui_la_SOURCES=\ ViewProviderGroove.h \ ViewProviderRevolution.cpp \ ViewProviderRevolution.h \ - ViewProviderPatternRectangular.cpp \ - ViewProviderPatternRectangular.h \ + ViewProviderScaled.cpp \ + ViewProviderScaled.h \ + ViewProviderTransformed.cpp \ + ViewProviderTransformed.h \ Workbench.cpp \ Workbench.h @@ -95,6 +138,10 @@ libPartDesignGui_la_LIBADD = \ -lTKXSBase \ -lTKBRep \ -lTKTopAlgo \ + -lTKG2d \ + -lTKG3d \ + -lTKGeomAlgo \ + -lTKGeomBase \ -lPartDesign #-------------------------------------------------------------------------------------- From 5da80fb08d819592528fc33f1a7b8bc7424e9663 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Sep 2012 10:23:10 +0200 Subject: [PATCH 04/17] 0000843: Wrong Context Menu Entry for Fillet/Chamfer -> Edit Pocket --- src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderFillet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp index bceabe64b..2ad35dc71 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp @@ -51,7 +51,7 @@ ViewProviderChamfer::~ViewProviderChamfer() void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { QAction* act; - act = menu->addAction(QObject::tr("Edit pocket"), receiver, member); + act = menu->addAction(QObject::tr("Edit chamfer"), receiver, member); act->setData(QVariant((int)ViewProvider::Default)); PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp index 0e2b26c06..e5a76b22f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp @@ -51,7 +51,7 @@ ViewProviderFillet::~ViewProviderFillet() void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { QAction* act; - act = menu->addAction(QObject::tr("Edit pocket"), receiver, member); + act = menu->addAction(QObject::tr("Edit fillet"), receiver, member); act->setData(QVariant((int)ViewProvider::Default)); PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member); } From 4ffaecbdbf270c0123f60c6aa51b26e5a918ed4a Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 26 Sep 2012 14:40:12 +0200 Subject: [PATCH 05/17] Extend search path for Coin cmake test --- cMake/FindCoin3D.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cMake/FindCoin3D.cmake b/cMake/FindCoin3D.cmake index 9941e9a98..32fc8150b 100644 --- a/cMake/FindCoin3D.cmake +++ b/cMake/FindCoin3D.cmake @@ -13,6 +13,7 @@ IF (WIN32) FIND_PATH(COIN3D_INCLUDE_DIR Inventor/So.h /usr/include /usr/local/include + PATH_SUFFIXES Coin2 ) FIND_LIBRARY(COIN3D_LIBRARY Coin From 40800adaaa4e8e0d33f5e2045149be52f2f166b1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 26 Sep 2012 18:39:38 +0200 Subject: [PATCH 06/17] Python interface to count selected objects --- src/Gui/Selection.cpp | 24 ++++++++++++++++++++---- src/Gui/Selection.h | 5 +++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index b43b39ec7..feac45c46 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -960,6 +960,11 @@ PyMethodDef SelectionSingleton::Methods[] = { "given the complete selection is cleared."}, {"isSelected", (PyCFunction) SelectionSingleton::sIsSelected, 1, "isSelected(object) -- Check if a given object is selected"}, + {"countObjectsOfType", (PyCFunction) SelectionSingleton::sCountObjectsOfType, 1, + "countObjectsOfType(string, [string]) -- Get the number of selected objects\n" + "The first argument defines the object type e.g. \"Part::Feature\" and the\n" + "second argumeht defines the document name. If no document name is given the\n" + "currently active document is used"}, {"getSelection", (PyCFunction) SelectionSingleton::sGetSelection, 1, "getSelection([string]) -- Return a list of selected objets\n" "Return a list of selected objects for a given document name. If no\n" @@ -974,13 +979,13 @@ PyMethodDef SelectionSingleton::Methods[] = { "addObserver(Object) -- Install an observer\n"}, {"removeObserver", (PyCFunction) SelectionSingleton::sRemSelObserver, 1, "removeObserver(Object) -- Uninstall an observer\n"}, - {"addSelectionGate", (PyCFunction) SelectionSingleton::saddSelectionGate, 1, + {"addSelectionGate", (PyCFunction) SelectionSingleton::sAddSelectionGate, 1, "addSelectionGate(String) -- activate the selection gate.\n" "The selection gate will prohibit all selections which do not match the\n" "the given selection filter string. Examples strings are:\n" "'SELECT Part::Feature SUB Edge',\n" "'SELECT Robot::RobotObject'\n"}, - {"removeSelectionGate", (PyCFunction) SelectionSingleton::sremoveSelectionGate, 1, + {"removeSelectionGate", (PyCFunction) SelectionSingleton::sRemoveSelectionGate, 1, "removeSelectionGate() -- remove the active slection gate\n"}, {NULL, NULL, 0, NULL} /* Sentinel */ }; @@ -1049,6 +1054,17 @@ PyObject *SelectionSingleton::sIsSelected(PyObject * /*self*/, PyObject *args, P return Py_BuildValue("O", (ok ? Py_True : Py_False)); } +PyObject *SelectionSingleton::sCountObjectsOfType(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) +{ + char* objecttype; + char* document=0; + if (!PyArg_ParseTuple(args, "s|s", &objecttype, &document)) + return NULL; + + unsigned int count = Selection().countObjectsOfType(objecttype, document); + return PyInt_FromLong(count); +} + PyObject *SelectionSingleton::sGetSelection(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) { char *documentName=0; @@ -1116,7 +1132,7 @@ PyObject *SelectionSingleton::sRemSelObserver(PyObject * /*self*/, PyObject *arg } PY_CATCH; } -PyObject *SelectionSingleton::saddSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) +PyObject *SelectionSingleton::sAddSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) { char* filter; if (!PyArg_ParseTuple(args, "s",&filter)) @@ -1129,7 +1145,7 @@ PyObject *SelectionSingleton::saddSelectionGate(PyObject * /*self*/, PyObject *a Py_Return; } -PyObject *SelectionSingleton::sremoveSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) +PyObject *SelectionSingleton::sRemoveSelectionGate(PyObject * /*self*/, PyObject *args, PyObject * /*kwd*/) { if (!PyArg_ParseTuple(args, "")) return NULL; // NULL triggers exception diff --git a/src/Gui/Selection.h b/src/Gui/Selection.h index 7ce96b90d..a8e38eb8a 100644 --- a/src/Gui/Selection.h +++ b/src/Gui/Selection.h @@ -306,12 +306,13 @@ protected: static PyObject *sRemoveSelection (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sClearSelection (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sIsSelected (PyObject *self,PyObject *args,PyObject *kwd); + static PyObject *sCountObjectsOfType (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sGetSelection (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sGetSelectionEx (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sAddSelObserver (PyObject *self,PyObject *args,PyObject *kwd); static PyObject *sRemSelObserver (PyObject *self,PyObject *args,PyObject *kwd); - static PyObject *saddSelectionGate (PyObject *self,PyObject *args,PyObject *kwd); - static PyObject *sremoveSelectionGate (PyObject *self,PyObject *args,PyObject *kwd); + static PyObject *sAddSelectionGate (PyObject *self,PyObject *args,PyObject *kwd); + static PyObject *sRemoveSelectionGate (PyObject *self,PyObject *args,PyObject *kwd); protected: /// Construction From 772e4f4ca4d7c8bc0d24d31d24de38e27a31b42c Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Sep 2012 12:47:47 +0200 Subject: [PATCH 07/17] Fix build error in Cam module --- src/Mod/Cam/App/AppCamPy.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Mod/Cam/App/AppCamPy.cpp b/src/Mod/Cam/App/AppCamPy.cpp index 2b2332676..4732881c0 100644 --- a/src/Mod/Cam/App/AppCamPy.cpp +++ b/src/Mod/Cam/App/AppCamPy.cpp @@ -26,6 +26,11 @@ # if defined (_POSIX_C_SOURCE) # undef _POSIX_C_SOURCE # endif // (re-)defined in pyconfig.h +#include + +#ifndef PI +#define PI M_PI +#endif //Basic Stuff #include @@ -93,9 +98,6 @@ #include "SpringbackCorrection.h" - - - using namespace Part; using namespace Mesh; using namespace std; From 765d887943f14c48e45b6ce05bab0cd66c780082 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Sep 2012 13:43:26 +0200 Subject: [PATCH 08/17] Extend data serialization with JSON --- src/App/PropertyPythonObject.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 1b8d14652..455ea65f6 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -94,6 +94,9 @@ std::string PropertyPythonObject::toString() const else if (this->object.hasAttr("__dict__")) { dump = this->object.getAttr("__dict__"); } + else { + dump = this->object; + } Py::Tuple args(1); args.setItem(0, dump); @@ -125,9 +128,12 @@ void PropertyPythonObject::fromString(const std::string& repr) Py::Callable state(this->object.getAttr("__setstate__")); state.apply(args); } - else { + else if (this->object.hasAttr("__dict__")) { this->object.setAttr("__dict__", res); } + else { + this->object = res; + } } catch (Py::Exception&) { Base::PyException e; // extract the Python error text @@ -269,6 +275,9 @@ void PropertyPythonObject::Save (Base::Writer &writer) const << " class=\"" << (std::string)name << "\""; } } + else { + writer.Stream() << " json=\"yes\""; + } } catch (Py::Exception&) { Base::PyException e; // extract the Python error text @@ -333,6 +342,9 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader) load_pickle = true; buffer = std::string(what[2].second, end); } + else if (reader.hasAttribute("json")) { + load_json = true; + } } catch (Py::Exception&) { Base::PyException e; // extract the Python error text From bcddb1e950f6cde94c6f8c48c66f776d571d1b4e Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 28 Sep 2012 12:33:26 +0200 Subject: [PATCH 09/17] Fix bug when painting selection in mesh view provider --- src/Mod/Mesh/Gui/ViewProvider.cpp | 7 +++++-- src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index d92766190..196857b06 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -1562,7 +1562,10 @@ void ViewProviderMesh::setSelection(const std::vector& indices) rMesh.addFacetsToSelection(indices); // Colorize the selection - highlightSelection(); + if (indices.empty()) + unhighlightSelection(); + else + highlightSelection(); } void ViewProviderMesh::addSelection(const std::vector& indices) @@ -1627,7 +1630,7 @@ void ViewProviderMesh::highlightSelection() const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); rMesh.getFacetsFromSelection(selection); if (selection.empty()) { - // If no faces are selected then simply return even without + // If no faces are selected then simply return even // without calling unhighlightSelection() return; } diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp index 4c517cd46..a312e2ccc 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp @@ -160,7 +160,12 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop) } showOpenEdges(OpenEdges.getValue()); - highlightSelection(); + std::vector selection; + mesh->getFacetsFromSelection(selection); + if (selection.empty()) + unhighlightSelection(); + else + highlightSelection(); } } From f403295ca73d39e482a978cc8991a96813d2087f Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 29 Sep 2012 15:50:17 +0200 Subject: [PATCH 10/17] 0000832: Original color STEP model lost in import --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 21 ++++++++++++++++----- src/Mod/Import/Init.py | 2 +- src/Mod/Part/App/ImportStep.cpp | 2 +- src/Mod/Part/Gui/Command.cpp | 16 ++++------------ src/Mod/Part/Init.py | 10 ++++++++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index d98a299d3..be5a70701 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -480,20 +480,24 @@ private: }; /* module functions */ + static PyObject * importer(PyObject *self, PyObject *args) { - const char* Name; - const char* DocName; - if (!PyArg_ParseTuple(args, "ss",&Name,&DocName)) + char* Name; + char* DocName=0; + if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName)) return 0; PY_TRY { //Base::Console().Log("Insert in Part with %s",Name); Base::FileInfo file(Name); - App::Document *pcDoc = App::GetApplication().getDocument(DocName); + App::Document *pcDoc = 0; + if (DocName) { + pcDoc = App::GetApplication().getDocument(DocName); + } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument(DocName); + pcDoc = App::GetApplication().newDocument("Unnamed"); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); @@ -561,6 +565,11 @@ static PyObject * importer(PyObject *self, PyObject *args) Py_Return; } +static PyObject * open(PyObject *self, PyObject *args) +{ + return importer(self, args); +} + static PyObject * exporter(PyObject *self, PyObject *args) { PyObject* object; @@ -946,6 +955,8 @@ static PyObject * ocaf(PyObject *self, PyObject *args) /* registration table */ struct PyMethodDef ImportGui_Import_methods[] = { + {"open" ,open ,METH_VARARGS, + "open(string) -- Open the file and create a new document."}, {"insert" ,importer ,METH_VARARGS, "insert(string,string) -- Insert the file into the given document."}, {"export" ,exporter ,METH_VARARGS, diff --git a/src/Mod/Import/Init.py b/src/Mod/Import/Init.py index 0484cbbb1..889f95b6a 100644 --- a/src/Mod/Import/Init.py +++ b/src/Mod/Import/Init.py @@ -29,5 +29,5 @@ # Append the open handler #FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui") -FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui") +#FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui") #FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui") diff --git a/src/Mod/Part/App/ImportStep.cpp b/src/Mod/Part/App/ImportStep.cpp index fa05530d6..3c48532fa 100644 --- a/src/Mod/Part/App/ImportStep.cpp +++ b/src/Mod/Part/App/ImportStep.cpp @@ -125,7 +125,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name) //Handle_XSControl_TransferReader tr = ws->TransferReader(); std::map hash_col; - ReadColors(aReader.WS(), hash_col); + //ReadColors(aReader.WS(), hash_col); //ReadNames(aReader.WS()); for (Standard_Integer i=1; i<=nbs; i++) { diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 11164ce67..85563a530 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -446,11 +446,9 @@ CmdPartImport::CmdPartImport() void CmdPartImport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)"); - filter << QObject::tr("STEP (*.stp *.step)"); + filter << QObject::tr("STEP AP203 (*.stp *.step)"); filter << QObject::tr("IGES (*.igs *.iges)"); filter << QObject::tr("BREP (*.brp *.brep)"); - filter << QObject::tr("All Files (*.*)"); QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); if (!fn.isEmpty()) { @@ -459,9 +457,7 @@ void CmdPartImport::activated(int iMsg) if (!pDoc) return; // no document openCommand("Import Part"); QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("step") || - ext == QLatin1String("stp") || - ext == QLatin1String("iges") || + if (ext == QLatin1String("iges") || ext == QLatin1String("igs")) { doCommand(Doc, "import ImportGui"); doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName()); @@ -507,20 +503,16 @@ CmdPartExport::CmdPartExport() void CmdPartExport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)"); - filter << QObject::tr("STEP (*.stp *.step)"); + filter << QObject::tr("STEP AP203 (*.stp *.step)"); filter << QObject::tr("IGES (*.igs *.iges)"); filter << QObject::tr("BREP (*.brp *.brep)"); - filter << QObject::tr("All Files (*.*)"); QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); if (!fn.isEmpty()) { App::Document* pDoc = getDocument(); if (!pDoc) return; // no document QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("step") || - ext == QLatin1String("stp") || - ext == QLatin1String("iges") || + if (ext == QLatin1String("iges") || ext == QLatin1String("igs")) { Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui"); } diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index 939723dbf..c50c2d287 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -43,6 +43,12 @@ ParGrp.SetString("WorkBenchName", "Part Design") ParGrp.SetString("WorkBenchModule", "PartWorkbench.py") -FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") -FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +#FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +#FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part") +FreeCAD.addImportType("BREP format (*.brep *.brp)","Part") +FreeCAD.addExportType("BREP format (*.brep *.brp)","Part") +FreeCAD.addImportType("IGES format (*.iges *.igs)","Part") +FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") +FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") +FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") From d8d7fcca3440e3fae6c2265945b7e4d0e859fc26 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 29 Sep 2012 18:23:04 +0200 Subject: [PATCH 11/17] 0000651: FindCoin3D should look in /usr/include/Coin3 for COIN3D_INCLUDE_DIR --- cMake/FindCoin3D.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cMake/FindCoin3D.cmake b/cMake/FindCoin3D.cmake index 32fc8150b..710768740 100644 --- a/cMake/FindCoin3D.cmake +++ b/cMake/FindCoin3D.cmake @@ -13,7 +13,6 @@ IF (WIN32) FIND_PATH(COIN3D_INCLUDE_DIR Inventor/So.h /usr/include /usr/local/include - PATH_SUFFIXES Coin2 ) FIND_LIBRARY(COIN3D_LIBRARY Coin @@ -78,6 +77,7 @@ ELSE (WIN32) FIND_LIBRARY(COIN3D_LIBRARY Coin /usr/lib /usr/local/lib + PATH_SUFFIXES Coin2 Coin3 ) ENDIF(APPLE) From c223f44a97dbdde4e950742679b9a5b86330d175 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 30 Sep 2012 13:50:09 +0200 Subject: [PATCH 12/17] 0000834: Minor preselection color bug --- src/Mod/Part/Gui/SoBrepShape.cpp | 4 +- src/Mod/Part/Gui/SoBrepShape.h | 145 ++++++++++++++++--------------- 2 files changed, 76 insertions(+), 73 deletions(-) diff --git a/src/Mod/Part/Gui/SoBrepShape.cpp b/src/Mod/Part/Gui/SoBrepShape.cpp index 2a9c2c4cb..811710e68 100644 --- a/src/Mod/Part/Gui/SoBrepShape.cpp +++ b/src/Mod/Part/Gui/SoBrepShape.cpp @@ -963,7 +963,7 @@ void SoBrepEdgeSet::renderHighlight(SoGLRenderAction *action) SoLazyElement::setEmissive(state, &this->highlightColor); SoOverrideElement::setEmissiveColorOverride(state, this, TRUE); - SoLazyElement::setDiffuse(state, this,1, &this->highlightColor,&this->colorpacker); + SoLazyElement::setDiffuse(state, this,1, &this->highlightColor,&this->colorpacker1); SoOverrideElement::setDiffuseColorOverride(state, this, TRUE); SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR); @@ -1000,7 +1000,7 @@ void SoBrepEdgeSet::renderSelection(SoGLRenderAction *action) SoLazyElement::setEmissive(state, &this->selectionColor); SoOverrideElement::setEmissiveColorOverride(state, this, TRUE); - SoLazyElement::setDiffuse(state, this,1, &this->selectionColor,&this->colorpacker); + SoLazyElement::setDiffuse(state, this,1, &this->selectionColor,&this->colorpacker2); SoOverrideElement::setDiffuseColorOverride(state, this, TRUE); SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR); diff --git a/src/Mod/Part/Gui/SoBrepShape.h b/src/Mod/Part/Gui/SoBrepShape.h index 4be3b7e8e..d5831032e 100644 --- a/src/Mod/Part/Gui/SoBrepShape.h +++ b/src/Mod/Part/Gui/SoBrepShape.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -56,49 +56,49 @@ protected: virtual ~SoBrepFaceSet() {}; virtual void GLRender(SoGLRenderAction *action); virtual void GLRenderBelowPath(SoGLRenderAction * action); - virtual void doAction(SoAction* action); - virtual SoDetail * createTriangleDetail( - SoRayPickAction * action, - const SoPrimitiveVertex * v1, - const SoPrimitiveVertex * v2, - const SoPrimitiveVertex * v3, + virtual void doAction(SoAction* action); + virtual SoDetail * createTriangleDetail( + SoRayPickAction * action, + const SoPrimitiveVertex * v1, + const SoPrimitiveVertex * v2, + const SoPrimitiveVertex * v3, SoPickedPoint * pp); virtual void generatePrimitives(SoAction * action); private: - enum Binding { - OVERALL = 0, - PER_PART, - PER_PART_INDEXED, - PER_FACE, - PER_FACE_INDEXED, - PER_VERTEX, - PER_VERTEX_INDEXED, - NONE = OVERALL - }; - Binding findMaterialBinding(SoState * const state) const; - Binding findNormalBinding(SoState * const state) const; - void renderShape(const SoGLCoordinateElement * const vertexlist, - const int32_t *vertexindices, - int num_vertexindices, - const int32_t *partindices, - int num_partindices, - const SbVec3f *normals, - const int32_t *normindices, - SoMaterialBundle *const materials, - const int32_t *matindices, - SoTextureCoordinateBundle * const texcoords, - const int32_t *texindices, - const int nbind, - const int mbind, - const int texture); - void renderHighlight(SoGLRenderAction *action); - void renderSelection(SoGLRenderAction *action); - -private: - SbColor selectionColor; - SbColor highlightColor; - SoColorPacker colorpacker; + enum Binding { + OVERALL = 0, + PER_PART, + PER_PART_INDEXED, + PER_FACE, + PER_FACE_INDEXED, + PER_VERTEX, + PER_VERTEX_INDEXED, + NONE = OVERALL + }; + Binding findMaterialBinding(SoState * const state) const; + Binding findNormalBinding(SoState * const state) const; + void renderShape(const SoGLCoordinateElement * const vertexlist, + const int32_t *vertexindices, + int num_vertexindices, + const int32_t *partindices, + int num_partindices, + const SbVec3f *normals, + const int32_t *normindices, + SoMaterialBundle *const materials, + const int32_t *matindices, + SoTextureCoordinateBundle * const texcoords, + const int32_t *texindices, + const int nbind, + const int mbind, + const int texture); + void renderHighlight(SoGLRenderAction *action); + void renderSelection(SoGLRenderAction *action); + +private: + SbColor selectionColor; + SbColor highlightColor; + SoColorPacker colorpacker; }; // --------------------------------------------------------------------- @@ -119,24 +119,27 @@ protected: virtual ~SoBrepEdgeSet() {}; virtual void GLRender(SoGLRenderAction *action); virtual void GLRenderBelowPath(SoGLRenderAction * action); - virtual void doAction(SoAction* action); - virtual SoDetail * createLineSegmentDetail( - SoRayPickAction *action, - const SoPrimitiveVertex *v1, - const SoPrimitiveVertex *v2, - SoPickedPoint *pp); -private: - void renderShape(const SoGLCoordinateElement * const vertexlist, - const int32_t *vertexindices, - int num_vertexindices); - void renderHighlight(SoGLRenderAction *action); - void renderSelection(SoGLRenderAction *action); - -private: - std::vector hl, sl; - SbColor selectionColor; - SbColor highlightColor; - SoColorPacker colorpacker; + virtual void doAction(SoAction* action); + virtual SoDetail * createLineSegmentDetail( + SoRayPickAction *action, + const SoPrimitiveVertex *v1, + const SoPrimitiveVertex *v2, + SoPickedPoint *pp); +private: + void renderShape(const SoGLCoordinateElement * const vertexlist, + const int32_t *vertexindices, + int num_vertexindices); + void renderHighlight(SoGLRenderAction *action); + void renderSelection(SoGLRenderAction *action); + +private: + std::vector hl, sl; + SbColor selectionColor; + SbColor highlightColor; + //#0000834: Minor preselection color bug + //To solve this we need a seprate color packer for highlighting and selection + SoColorPacker colorpacker1; + SoColorPacker colorpacker2; }; // --------------------------------------------------------------------- @@ -157,19 +160,19 @@ protected: virtual ~SoBrepPointSet() {}; virtual void GLRender(SoGLRenderAction *action); virtual void GLRenderBelowPath(SoGLRenderAction * action); - virtual void doAction(SoAction* action); - -private: - void renderShape(const SoGLCoordinateElement * const vertexlist, - const int32_t *vertexindices, - int num_vertexindices); - void renderHighlight(SoGLRenderAction *action); - void renderSelection(SoGLRenderAction *action); - -private: - SbColor selectionColor; - SbColor highlightColor; - SoColorPacker colorpacker; + virtual void doAction(SoAction* action); + +private: + void renderShape(const SoGLCoordinateElement * const vertexlist, + const int32_t *vertexindices, + int num_vertexindices); + void renderHighlight(SoGLRenderAction *action); + void renderSelection(SoGLRenderAction *action); + +private: + SbColor selectionColor; + SbColor highlightColor; + SoColorPacker colorpacker; }; } // namespace PartGui From aa72516fbe192c1f991cf4d838ada2a98838d25b Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 1 Oct 2012 13:16:07 +0200 Subject: [PATCH 13/17] Use variable OCC_OCAF_LIBRARIES for OCAF libs --- cMake/UseLibPack6x.cmake | 11 ++++++-- cMake/UseLibPack7x.cmake | 11 ++++++-- cMake/UseLibPack8x.cmake | 20 +++++++------- cMake/UseLibPackCustom.cmake | 43 +++++++++++++++++++++++++++++-- src/Mod/Import/Gui/CMakeLists.txt | 6 +---- 5 files changed, 70 insertions(+), 21 deletions(-) diff --git a/cMake/UseLibPack6x.cmake b/cMake/UseLibPack6x.cmake index 738404e4c..ef6bc2011 100644 --- a/cMake/UseLibPack6x.cmake +++ b/cMake/UseLibPack6x.cmake @@ -277,6 +277,9 @@ set(ODE_FOUND TRUE) # OCC set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade) +set(OCC_LIBRARY_DIR + ${FREECAD_LIBPACK_DIR}/lib +) set(OCC_LIBRARIES TKFillet TKMesh @@ -302,7 +305,11 @@ set(OCC_LIBRARIES TKHLR TKFeat ) -set(OCC_LIBRARY_DIR - ${FREECAD_LIBPACK_DIR}/lib +set(OCC_OCAF_LIBRARIES + TKCAF + TKXCAF + TKLCAF + TKXDESTEP + TKXDEIGES ) set(OCC_FOUND TRUE) diff --git a/cMake/UseLibPack7x.cmake b/cMake/UseLibPack7x.cmake index b74fc595c..6063ef3b3 100644 --- a/cMake/UseLibPack7x.cmake +++ b/cMake/UseLibPack7x.cmake @@ -283,6 +283,9 @@ set(OPENCV_FOUND TRUE) # OCC set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade) +set(OCC_LIBRARY_DIR + ${FREECAD_LIBPACK_DIR}/lib +) set(OCC_LIBRARIES TKFillet TKMesh @@ -308,8 +311,12 @@ set(OCC_LIBRARIES TKHLR TKFeat ) -set(OCC_LIBRARY_DIR - ${FREECAD_LIBPACK_DIR}/lib +set(OCC_OCAF_LIBRARIES + TKCAF + TKXCAF + TKLCAF + TKXDESTEP + TKXDEIGES ) set(OCC_FOUND TRUE) diff --git a/cMake/UseLibPack8x.cmake b/cMake/UseLibPack8x.cmake index f77a3afcd..ab34a2c5c 100644 --- a/cMake/UseLibPack8x.cmake +++ b/cMake/UseLibPack8x.cmake @@ -283,6 +283,9 @@ set(OPENCV_FOUND TRUE) # OCC set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade) +set(OCC_LIBRARY_DIR + ${FREECAD_LIBPACK_DIR}/lib +) set(OCC_LIBRARIES TKFillet TKMesh @@ -295,14 +298,7 @@ set(OCC_LIBRARIES TKShHealing TKXSBase TKBool - TKXSBase - TKXCAF - TKLCAF - TKCAF - TKSTEP - TKIGES - TKXDESTEP - TKXDEIGES + TKXSBase TKBO TKBRep TKTopAlgo @@ -316,8 +312,12 @@ set(OCC_LIBRARIES TKHLR TKFeat ) -set(OCC_LIBRARY_DIR - ${FREECAD_LIBPACK_DIR}/lib +set(OCC_OCAF_LIBRARIES + TKCAF + TKXCAF + TKLCAF + TKXDESTEP + TKXDEIGES ) set(OCC_FOUND TRUE) diff --git a/cMake/UseLibPackCustom.cmake b/cMake/UseLibPackCustom.cmake index 48fede470..fefcf7ef4 100644 --- a/cMake/UseLibPackCustom.cmake +++ b/cMake/UseLibPackCustom.cmake @@ -305,7 +305,42 @@ set(OPENCV_LIBRARIES cv.lib cvaux.lib cxcore.lib cxts.lib highgui.lib) set(OPENCV_FOUND TRUE) # OCC +#set(OCC_INCLUDE_DIR C:/Projects/LibPack/oce-0.10.0/include/oce) +#set(OCC_LIBRARY_DIR C:/Projects/LibPack/oce-0.10.0/Win64/lib) +#set(OCC_LIBRARIES +# ${OCC_LIBRARY_DIR}/TKFillet.lib +# ${OCC_LIBRARY_DIR}/TKMesh.lib +# ${OCC_LIBRARY_DIR}/TKernel.lib +# ${OCC_LIBRARY_DIR}/TKG2d.lib +# ${OCC_LIBRARY_DIR}/TKG3d.lib +# ${OCC_LIBRARY_DIR}/TKMath.lib +# ${OCC_LIBRARY_DIR}/TKIGES.lib +# ${OCC_LIBRARY_DIR}/TKSTL.lib +# ${OCC_LIBRARY_DIR}/TKShHealing.lib +# ${OCC_LIBRARY_DIR}/TKXSBase.lib +# ${OCC_LIBRARY_DIR}/TKBool.lib +# ${OCC_LIBRARY_DIR}/TKBO.lib +# ${OCC_LIBRARY_DIR}/TKBRep.lib +# ${OCC_LIBRARY_DIR}/TKTopAlgo.lib +# ${OCC_LIBRARY_DIR}/TKGeomAlgo.lib +# ${OCC_LIBRARY_DIR}/TKGeomBase.lib +# ${OCC_LIBRARY_DIR}/TKOffset.lib +# ${OCC_LIBRARY_DIR}/TKPrim.lib +# ${OCC_LIBRARY_DIR}/TKSTEP.lib +# ${OCC_LIBRARY_DIR}/TKSTEPBase.lib +# ${OCC_LIBRARY_DIR}/TKSTEPAttr.lib +# ${OCC_LIBRARY_DIR}/TKHLR.lib +# ${OCC_LIBRARY_DIR}/TKFeat.lib +#) +#set(OCC_OCAF_LIBRARIES +# ${OCC_LIBRARY_DIR}/TKCAF.lib +# ${OCC_LIBRARY_DIR}/TKXCAF.lib +# ${OCC_LIBRARY_DIR}/TKLCAF.lib +# ${OCC_LIBRARY_DIR}/TKXDESTEP.lib +# ${OCC_LIBRARY_DIR}/TKXDEIGES.lib +#) set(OCC_INCLUDE_DIR ${FREECAD_LIBPACK_DIR}/include/OpenCascade-6.3.0) +set(OCC_LIBRARY_DIR ${FREECAD_LIBPACK_DIR}/lib) set(OCC_LIBRARIES TKFillet TKMesh @@ -331,8 +366,12 @@ set(OCC_LIBRARIES TKHLR TKFeat ) -set(OCC_LIBRARY_DIR - ${FREECAD_LIBPACK_DIR}/lib +set(OCC_OCAF_LIBRARIES + TKCAF + TKXCAF + TKLCAF + TKXDESTEP + TKXDEIGES ) set(OCC_FOUND TRUE) diff --git a/src/Mod/Import/Gui/CMakeLists.txt b/src/Mod/Import/Gui/CMakeLists.txt index d5029eca8..ed588fd9c 100644 --- a/src/Mod/Import/Gui/CMakeLists.txt +++ b/src/Mod/Import/Gui/CMakeLists.txt @@ -22,11 +22,7 @@ link_directories(${OCC_LIBRARY_DIR}) set(ImportGui_LIBS FreeCADGui PartGui - TKCAF - TKXCAF - TKLCAF - TKXDESTEP - TKXDEIGES + ${OCC_OCAF_LIBRARIES} ) SET(ImportGui_SRCS From 58da2ebbcc94d0bb203b0ce70069abd77c2b8bab Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 1 Oct 2012 13:58:40 +0200 Subject: [PATCH 14/17] 0000665: Follow up 0000640: This file crashes FreeCAD UI latest Git --- src/Gui/CommandDoc.cpp | 4 ++-- src/Gui/Document.cpp | 4 ++-- src/Gui/MainWindow.cpp | 13 +++++++++++-- src/Gui/ManualAlignment.cpp | 18 +++++++++--------- src/Gui/ProgressBar.cpp | 6 +++--- src/Gui/SoFCSelection.cpp | 4 ++-- src/Gui/Tree.cpp | 2 +- src/Gui/View3DInventorViewer.cpp | 2 +- src/Mod/Web/Gui/BrowserView.cpp | 4 ++-- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 5586fff6f..f285c2ee7 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -615,7 +615,7 @@ StdCmdPrint::StdCmdPrint() void StdCmdPrint::activated(int iMsg) { if (getMainWindow()->activeWindow()) { - getMainWindow()->statusBar()->showMessage(QObject::tr("Printing...")); + getMainWindow()->showMessage(QObject::tr("Printing...")); getMainWindow()->activeWindow()->print(); } } @@ -670,7 +670,7 @@ StdCmdPrintPdf::StdCmdPrintPdf() void StdCmdPrintPdf::activated(int iMsg) { if (getMainWindow()->activeWindow()) { - getMainWindow()->statusBar()->showMessage(QObject::tr("Exporting PDF...")); + getMainWindow()->showMessage(QObject::tr("Exporting PDF...")); getMainWindow()->activeWindow()->printPdf(); } } diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 512f39186..1f629b2ab 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -508,7 +508,7 @@ bool Document::save(void) /// Save the document under a new file name bool Document::saveAs(void) { - getMainWindow()->statusBar()->showMessage(QObject::tr("Save document under new filename...")); + getMainWindow()->showMessage(QObject::tr("Save document under new filename...")); QString exe = qApp->applicationName(); QString fn = QFileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe), @@ -554,7 +554,7 @@ bool Document::saveAs(void) return true; } else { - getMainWindow()->statusBar()->showMessage(QObject::tr("Saving aborted"), 2000); + getMainWindow()->showMessage(QObject::tr("Saving aborted"), 2000); return false; } } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index cccdf146b..e1cc361a1 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -734,7 +734,7 @@ void MainWindow::addWindow(MDIView* view) #endif #endif connect(view, SIGNAL(message(const QString&, int)), - statusBar(), SLOT(showMessage(const QString&, int))); + this, SLOT(showMessage(const QString&, int))); connect(this, SIGNAL(windowStateChanged(MDIView*)), view, SLOT(windowStateChanged(MDIView*))); @@ -799,7 +799,7 @@ void MainWindow::removeWindow(Gui::MDIView* view) { // free all connections disconnect(view, SIGNAL(message(const QString&, int)), - statusBar(), SLOT(message(const QString&, int ))); + this, SLOT(showMessage(const QString&, int ))); disconnect(this, SIGNAL(windowStateChanged(MDIView*)), view, SLOT(windowStateChanged(MDIView*))); view->removeEventFilter(this); @@ -1552,7 +1552,16 @@ void MainWindow::showMessage (const QString& message, int timeout) { QFontMetrics fm(statusBar()->font()); QString msg = fm.elidedText(message, Qt::ElideMiddle, this->width()/2); +#if QT_VERSION != 0x040801 this->statusBar()->showMessage(msg, timeout); +#else + //#0000665: There is a crash under Ubuntu 12.04 (Qt 4.8.1) + QMetaObject::invokeMethod(statusBar(), "showMessage", + Qt::QueuedConnection, + QGenericReturnArgument(), + Q_ARG(QString,msg), + Q_ARG(int, timeout)); +#endif } // ------------------------------------------------------------- diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index d220922fa..0256a0279 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -778,7 +778,7 @@ void ManualAlignment::continueAlignment() grp.addToViewer(myViewer->getViewer(0)); grp.setAlignable(true); - Gui::getMainWindow()->statusBar()->showMessage(tr("Please pick points in the left and right view")); + Gui::getMainWindow()->showMessage(tr("Please pick points in the left and right view")); myViewer->getViewer(0)->setEditingCursor(QCursor(Qt::PointingHandCursor)); myViewer->getViewer(1)->setEditingCursor(QCursor(Qt::PointingHandCursor)); @@ -838,7 +838,7 @@ void ManualAlignment::finish() closeViewer(); reset(); - Gui::getMainWindow()->statusBar()->showMessage(tr("The alignment has finished")); + Gui::getMainWindow()->showMessage(tr("The alignment has finished")); // If an event receiver has been defined send the manual alignment finished event to it emitFinished(); @@ -856,7 +856,7 @@ void ManualAlignment::cancel() myTransform = Base::Placement(); reset(); - Gui::getMainWindow()->statusBar()->showMessage(tr("The alignment has been canceled")); + Gui::getMainWindow()->showMessage(tr("The alignment has been canceled")); // If an event receiver has been defined send the manual alignment cancelled event to it emitCanceled(); @@ -888,7 +888,7 @@ void ManualAlignment::align() myAlignModel.activeGroup().removeFromViewer(myViewer->getViewer(0)); myAlignModel.activeGroup().setAlignable(false); std::vector pViews = myAlignModel.activeGroup().getViews(); - Gui::getMainWindow()->statusBar()->showMessage(tr("Try to align group of views")); + Gui::getMainWindow()->showMessage(tr("Try to align group of views")); // Compute alignment bool ok = computeAlignment(myAlignModel.activeGroup().getPoints(), myFixedGroup.getPoints()); @@ -928,17 +928,17 @@ void ManualAlignment::showInstructions() { // Now we can start the actual alignment if (myAlignModel.activeGroup().countPoints() < myPickPoints) { - Gui::getMainWindow()->statusBar()->showMessage( + Gui::getMainWindow()->showMessage( tr("Too few points picked in the left view." " At least %1 points are needed.").arg(myPickPoints)); } else if (myFixedGroup.countPoints() < myPickPoints) { - Gui::getMainWindow()->statusBar()->showMessage( + Gui::getMainWindow()->showMessage( tr("Too few points picked in the right view." " At least %1 points are needed.").arg(myPickPoints)); } else if (myAlignModel.activeGroup().countPoints() != myFixedGroup.countPoints()) { - Gui::getMainWindow()->statusBar()->showMessage( + Gui::getMainWindow()->showMessage( tr("Different number of points picked in left and right view. " "On the left view %1 points are picked, " "on the right view %2 points are picked.") @@ -1146,13 +1146,13 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n) self->applyPickedProbe(that, point); const SbVec3f& vec = point->getPoint(); - Gui::getMainWindow()->statusBar()->showMessage( + Gui::getMainWindow()->showMessage( tr("Point picked at (%1,%2,%3)") .arg(vec[0]).arg(vec[1]).arg(vec[2])); } } else { - Gui::getMainWindow()->statusBar()->showMessage( + Gui::getMainWindow()->showMessage( tr("No point was picked")); } } diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index 129860a4a..5fd5be65b 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -252,7 +252,7 @@ void Sequencer::showRemainingTime() Q_ARG(QString,status)); } else { - getMainWindow()->statusBar()->showMessage(status); + getMainWindow()->showMessage(status); } } } @@ -285,7 +285,7 @@ void Sequencer::resetData() d->waitCursor = 0; d->bar->leaveControlEvents(); getMainWindow()->setPaneText(1, QString()); - getMainWindow()->statusBar()->showMessage(QString()); + getMainWindow()->showMessage(QString()); } SequencerBase::resetData(); @@ -313,7 +313,7 @@ void Sequencer::setText (const char* pszTxt) Q_ARG(QString,d->text)); } else { - getMainWindow()->statusBar()->showMessage(d->text); + getMainWindow()->showMessage(d->text); } } diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index c34b52b08..f3362d4c2 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -568,7 +568,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) ,pp->getPoint()[1] ,pp->getPoint()[2]); - getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000); + getMainWindow()->showMessage(QString::fromAscii(buf),3000); } } } @@ -602,7 +602,7 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) ,pp->getPoint()[1] ,pp->getPoint()[2]); - getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000); + getMainWindow()->showMessage(QString::fromAscii(buf),3000); } } diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 48d27f325..bca4d8e2b 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -1201,7 +1201,7 @@ void DocumentObjectItem::displayStatusInfo() QString info = QString::fromAscii(Obj->getStatusString()); if ( Obj->mustExecute() == 1 ) info += QString::fromAscii(" (but must be executed)"); - getMainWindow()->statusBar()->showMessage( info ); + getMainWindow()->showMessage( info ); } diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 7c61cfc01..47f3b9991 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2081,7 +2081,7 @@ SoPath * View3DInventorViewer::pickFilterCB(void *viewer, const SoPickedPoint * ,pp->getPoint()[1] ,pp->getPoint()[2]); - getMainWindow()->statusBar()->showMessage(QString::fromAscii(buf),3000); + getMainWindow()->showMessage(QString::fromAscii(buf),3000); } return pp->getPath(); } diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 04739a351..5e53f872d 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -232,7 +232,7 @@ void BrowserView::onLoadStarted() QProgressBar* bar = Gui::Sequencer::instance()->getProgressBar(); bar->setRange(0, 100); bar->show(); - Gui::getMainWindow()->statusBar()->showMessage(tr("Loading %1...").arg(view->url().toString())); + Gui::getMainWindow()->showMessage(tr("Loading %1...").arg(view->url().toString())); isLoading = true; } @@ -248,7 +248,7 @@ void BrowserView::onLoadFinished(bool ok) QProgressBar* bar = Sequencer::instance()->getProgressBar(); bar->setValue(100); bar->hide(); - getMainWindow()->statusBar()->showMessage(QString()); + getMainWindow()->showMessage(QString()); } isLoading = false; } From 95de7d19cfa9ed13360772832ef88e70757df9d9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 1 Oct 2012 16:38:43 +0200 Subject: [PATCH 15/17] Replace Python std output only for GUI application and not for CLI --- src/Base/Interpreter.cpp | 11 ++++++++--- src/Base/Interpreter.h | 1 + src/Gui/Application.cpp | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 427e439dc..b9676bb9b 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -343,15 +343,20 @@ const char* InterpreterSingleton::init(int argc,char *argv[]) Py_Initialize(); PySys_SetArgv(argc, argv); PythonStdOutput::init_type(); - PythonStdOutput* out = new PythonStdOutput(); - PySys_SetObject("stdout", out); - PySys_SetObject("stderr", out); this->_global = PyEval_SaveThread(); } return Py_GetPath(); } +void InterpreterSingleton::replaceStdOutput() +{ + PyGILStateLocker locker; + PythonStdOutput* out = new PythonStdOutput(); + PySys_SetObject("stdout", out); + PySys_SetObject("stderr", out); +} + int InterpreterSingleton::cleanup(void (*func)(void)) { return Py_AtExit( func ); diff --git a/src/Base/Interpreter.h b/src/Base/Interpreter.h index 9f32d68d3..a055e8aa2 100644 --- a/src/Base/Interpreter.h +++ b/src/Base/Interpreter.h @@ -193,6 +193,7 @@ public: /// init the interpreter and returns the module search path const char* init(int argc,char *argv[]); int runCommandLine(const char *prompt); + void replaceStdOutput(); static InterpreterSingleton &Instance(void); static void Destruct(void); //@} diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 53dec5681..b969ffb98 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1403,6 +1403,7 @@ static void init_resources() void Application::initApplication(void) { try { + Base::Interpreter().replaceStdOutput(); initTypes(); new Base::ScriptProducer( "FreeCADGuiInit", FreeCADGuiInit ); init_resources(); From a5d9ee4be915a9308578d5e4fa075419dff2ed63 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 1 Oct 2012 18:45:48 +0200 Subject: [PATCH 16/17] Use STEP AP203 for 64-bit due to a bug in OCC --- src/Mod/Part/Gui/Command.cpp | 30 ++++++++++++++++-------------- src/Mod/Part/Init.py | 11 +++++++++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 85563a530..a7e9b8154 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -446,19 +446,20 @@ CmdPartImport::CmdPartImport() void CmdPartImport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("STEP AP203 (*.stp *.step)"); - filter << QObject::tr("IGES (*.igs *.iges)"); - filter << QObject::tr("BREP (*.brp *.brep)"); + filter << QString::fromAscii("STEP AP203 (*.stp *.step)"); + filter << QString::fromAscii("STEP AP214 (*.stp *.step)"); + filter << QString::fromAscii("IGES (*.igs *.iges)"); + filter << QString::fromAscii("BREP (*.brp *.brep)"); - QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); + QString select; + QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select); if (!fn.isEmpty()) { Gui::WaitCursor wc; App::Document* pDoc = getDocument(); if (!pDoc) return; // no document openCommand("Import Part"); - QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("iges") || - ext == QLatin1String("igs")) { + if (select == filter[1] || + select == filter[2]) { doCommand(Doc, "import ImportGui"); doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName()); } @@ -503,17 +504,18 @@ CmdPartExport::CmdPartExport() void CmdPartExport::activated(int iMsg) { QStringList filter; - filter << QObject::tr("STEP AP203 (*.stp *.step)"); - filter << QObject::tr("IGES (*.igs *.iges)"); - filter << QObject::tr("BREP (*.brp *.brep)"); + filter << QString::fromAscii("STEP AP203 (*.stp *.step)"); + filter << QString::fromAscii("STEP AP214 (*.stp *.step)"); + filter << QString::fromAscii("IGES (*.igs *.iges)"); + filter << QString::fromAscii("BREP (*.brp *.brep)"); - QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;"))); + QString select; + QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select); if (!fn.isEmpty()) { App::Document* pDoc = getDocument(); if (!pDoc) return; // no document - QString ext = QFileInfo(fn).suffix().toLower(); - if (ext == QLatin1String("iges") || - ext == QLatin1String("igs")) { + if (select == filter[1] || + select == filter[2]) { Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui"); } else { diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index c50c2d287..fcd75f94c 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -49,6 +49,13 @@ FreeCAD.addImportType("BREP format (*.brep *.brp)","Part") FreeCAD.addExportType("BREP format (*.brep *.brp)","Part") FreeCAD.addImportType("IGES format (*.iges *.igs)","Part") FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") -FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") -FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") + +# There is a bug in OCC 6.5.3 (and older which leads to a crash) +import platform +if platform.architecture()[0]=='64bit': + FreeCAD.addImportType("STEP AP203 format (*.step *.stp)","Part") + FreeCAD.addExportType("STEP AP203 format (*.step *.stp)","Part") +else: + FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") + FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") From 9316de659dab422959e56481f3115ac3d77126a0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Oct 2012 13:01:16 +0200 Subject: [PATCH 17/17] Use STEP AP203 for 64-bit due to a bug in OCC --- src/Mod/Part/App/AppPart.cpp | 11 +++++++++++ src/Mod/Part/Init.py | 15 ++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index c52c467cf..6bcc48860 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -92,6 +92,17 @@ void PartExport initPart() str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE; App::Application::Config()["OCC_VERSION"] = str.str(); + // see Init.py +#if defined (_OCC64) +#if OCC_VERSION_HEX < 0x060503 + App::GetApplication().addImportType("STEP AP203 format (*.step *.stp)","Part"); + App::GetApplication().addExportType("STEP AP203 format (*.step *.stp)","Part"); +#else + App::GetApplication().addImportType("STEP AP214 format (*.step *.stp)","ImportGui"); + App::GetApplication().addExportType("STEP AP214 format (*.step *.stp)","ImportGui"); +#endif +#endif + PyObject* partModule = Py_InitModule3("Part", Part_methods, module_part_doc); /* mod name, table ptr */ Base::Console().Log("Loading Part module... done\n"); diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index fcd75f94c..33a81998e 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -50,12 +50,13 @@ FreeCAD.addExportType("BREP format (*.brep *.brp)","Part") FreeCAD.addImportType("IGES format (*.iges *.igs)","Part") FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") -# There is a bug in OCC 6.5.3 (and older which leads to a crash) +# There is a bug in OCC 6.5.0 64-bit and older which leads to a crash +# The registration of the STEP filetype for 64-bit is handled in initPart() import platform -if platform.architecture()[0]=='64bit': - FreeCAD.addImportType("STEP AP203 format (*.step *.stp)","Part") - FreeCAD.addExportType("STEP AP203 format (*.step *.stp)","Part") -else: - FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") - FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") +if platform.architecture()[0]=='32bit': + FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") + FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") +#else: +# FreeCAD.addImportType("STEP AP203 format (*.step *.stp)","Part") +# FreeCAD.addExportType("STEP AP203 format (*.step *.stp)","Part")