From b4c91af000b58251a41a6e67ad7764825e663c19 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 14 Jan 2012 15:44:05 +0000 Subject: [PATCH 1/4] + use UTF8-encoding of degree symbol git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5408 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Gui/Command.cpp | 12 ++++++------ src/Gui/CommandView.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index db0bf9890..40fdb9557 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -504,26 +504,26 @@ void Command::applyCommandData(Action* action) { action->setText(QCoreApplication::translate( this->className(), sMenuText, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); action->setToolTip(QCoreApplication::translate( this->className(), sToolTipText, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); if (sStatusTip) action->setStatusTip(QCoreApplication::translate( this->className(), sStatusTip, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); else action->setStatusTip(QCoreApplication::translate( this->className(), sToolTipText, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); if (sWhatsThis) action->setWhatsThis(QCoreApplication::translate( this->className(), sWhatsThis, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); else action->setWhatsThis(QCoreApplication::translate( this->className(), sToolTipText, 0, - QCoreApplication::CodecForTr)); + QCoreApplication::UnicodeUTF8)); } const char* Command::keySequenceToAccel(int sk) const diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index c8d70a85f..e8c580ca4 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -1064,9 +1064,9 @@ StdCmdViewRotateLeft::StdCmdViewRotateLeft() { sGroup = QT_TR_NOOP("Standard-View"); sMenuText = QT_TR_NOOP("Rotate Left"); - sToolTipText = QT_TR_NOOP("Rotate the view by 90° counter-clockwise"); + sToolTipText = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise"); sWhatsThis = "Std_ViewXX"; - sStatusTip = QT_TR_NOOP("Rotate the view by 90° counter-clockwise"); + sStatusTip = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise"); sPixmap = "view-rotate-left"; //sAccel = "Shift Left"; eType = Alter3DView; @@ -1088,9 +1088,9 @@ StdCmdViewRotateRight::StdCmdViewRotateRight() { sGroup = QT_TR_NOOP("Standard-View"); sMenuText = QT_TR_NOOP("Rotate Right"); - sToolTipText = QT_TR_NOOP("Rotate the view by 90° clockwise"); + sToolTipText = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 clockwise"); sWhatsThis = "Std_ViewXX"; - sStatusTip = QT_TR_NOOP("Rotate the view by 90° clockwise"); + sStatusTip = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 clockwise"); sPixmap = "view-rotate-right"; //sAccel = "Shift Right"; eType = Alter3DView; From 0496df65383cc6bf0ea17dd8f22d08c4201a5d49 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 16 Jan 2012 14:45:48 +0000 Subject: [PATCH 2/4] + check if re-mapping causes cyclic dependency git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5409 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Sketcher/Gui/Command.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index eeddfb858..6a5a5061d 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -215,6 +215,15 @@ void CmdSketcherMapSketch::activated(int iMsg) qApp->translate(className(),"You have to select a single face as support for a sketch!")); return; } + + std::vector input = part->getOutList(); + if (std::find(input.begin(), input.end(), sel[index]) != input.end()) { + QMessageBox::warning(Gui::getMainWindow(), + qApp->translate(className(),"Cyclic dependency"), + qApp->translate(className(),"You cannot choose a support object depending on the selected sketch!")); + return; + } + // get the selected sub shape (a Face) const Part::TopoShape &shape = part->Shape.getValue(); TopoDS_Shape sh = shape.getSubShape(sub[0].c_str()); From a75fb034073165420f91fd96f8e6eb1df4afef95 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 16 Jan 2012 20:23:26 +0000 Subject: [PATCH 3/4] 0000572: add a method to Part module to read BRep data from string git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5410 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Base/Stream.cpp | 53 +++++++++++++++++++++++++++++ src/Base/Stream.h | 16 +++++++++ src/Mod/Part/App/TopoShape.cpp | 26 ++++++++++++++ src/Mod/Part/App/TopoShape.h | 1 + src/Mod/Part/App/TopoShapePy.xml | 5 +++ src/Mod/Part/App/TopoShapePyImp.cpp | 24 +++++++++++++ 6 files changed, 125 insertions(+) diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index e962be914..009cf7e23 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -40,6 +40,7 @@ #include "Stream.h" #include "Swap.h" #include "FileInfo.h" +#include using namespace Base; @@ -533,6 +534,58 @@ IODeviceIStreambuf::seekpos(std::streambuf::pos_type pos, return seekoff(pos, std::ios_base::beg); } +// --------------------------------------------------------- + +PyStreambuf::PyStreambuf(PyObject* o) : inp(o) +{ + setg (buffer+pbSize, + buffer+pbSize, + buffer+pbSize); +} + +int PyStreambuf::underflow() +{ + if (gptr() < egptr()) { + return *gptr(); + } + + int numPutback; + numPutback = gptr() - eback(); + if (numPutback > pbSize) { + numPutback = pbSize; + } + + memcpy (buffer+(pbSize-numPutback), gptr()-numPutback, numPutback); + + int num=0; + for (int i=0; i(res)[0]; + num++; + buffer[pbSize+i] = c; + if (c == '\n') + break; + } + catch (Py::Exception& e) { + e.clear(); + if (num == 0) + return EOF; + break; + } + } + + setg (buffer+(pbSize-numPutback), + buffer+pbSize, + buffer+pbSize+num); + + return *gptr(); +} + // --------------------------------------------------------- Streambuf::Streambuf(const std::string& data) diff --git a/src/Base/Stream.h b/src/Base/Stream.h index 1836f2116..f083e1e58 100644 --- a/src/Base/Stream.h +++ b/src/Base/Stream.h @@ -35,6 +35,7 @@ class QByteArray; class QIODevice; class QBuffer; +typedef struct _object PyObject; namespace Base { @@ -232,6 +233,21 @@ protected: static const int bufSize = 1024; // size of the data buffer char buffer[bufSize+pbSize]; // data buffer }; + +class BaseExport PyStreambuf : public std::streambuf +{ +public: + PyStreambuf(PyObject* o); + +protected: + int underflow(); + +private: + static const int pbSize = 4; + static const int bufSize = 1024; + char buffer[bufSize+pbSize]; + PyObject* inp; +}; class BaseExport Streambuf : public std::streambuf { diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index c17aa3b1a..86e50b98e 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -609,6 +609,32 @@ void TopoShape::importBrep(const char *FileName) } } +void TopoShape::importBrep(std::istream& str) +{ + try { + // read brep-file + BRep_Builder aBuilder; + TopoDS_Shape aShape; +#if OCC_HEX_VERSION >= 0x060300 + Handle_Message_ProgressIndicator pi = new ProgressIndicator(100); + pi->NewScope(100, "Reading BREP file..."); + pi->Show(); + BRepTools::Read(aShape,str,aBuilder,pi); + pi->EndScope(); +#else + BRepTools::Read(aShape,str,aBuilder); +#endif + this->_Shape = aShape; + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + throw Base::Exception(aFail->GetMessageString()); + } + catch (const std::exception& e) { + throw Base::Exception(e.what()); + } +} + void TopoShape::write(const char *FileName) const { Base::FileInfo File(FileName); diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 389511d05..9f3b17562 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -120,6 +120,7 @@ public: void importIges(const char *FileName); void importStep(const char *FileName); void importBrep(const char *FileName); + void importBrep(std::istream&); void exportIges(const char *FileName) const; void exportStep(const char *FileName) const; void exportBrep(const char *FileName) const; diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index 1a953e2c6..f31f99f56 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -48,6 +48,11 @@ Sub-elements such as vertices, edges or faces are accessible as: Export the content of this shape to an STL mesh file. + + + Import the content to this shape of a string in BREP format. + + Extrude the shape along a direction. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 8982a1792..3aef9eab9 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -311,6 +311,30 @@ PyObject* TopoShapePy::exportBrep(PyObject *args) Py_Return; } +PyObject* TopoShapePy::importBrep(PyObject *args) +{ + PyObject* input; + if (!PyArg_ParseTuple(args, "O", &input)) + //char* input; + //if (!PyArg_ParseTuple(args, "s", &input)) + return NULL; + + try { + // read brep + Base::PyStreambuf buf(input); + std::istream str(0); + str.rdbuf(&buf); + //std::stringstream str(input); + getTopoShapePtr()->importBrep(str); + } + catch (const Base::Exception& e) { + PyErr_SetString(PyExc_Exception,e.what()); + return NULL; + } + + Py_Return; +} + PyObject* TopoShapePy::exportStl(PyObject *args) { char* filename; From f9f668f8fccce10bc6f460c164be96c9ba91f433 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 16 Jan 2012 21:58:58 +0000 Subject: [PATCH 4/4] + fix but that Angle has no effect after creation of revolve feature git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5411 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Part/App/FeatureRevolution.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index b9fb9ddde..dce8533fc 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -49,6 +49,7 @@ short Revolution::mustExecute() const { if (Base.isTouched() || Axis.isTouched() || + Angle.isTouched() || Source.isTouched()) return 1; return 0;