From 769528e86e10938351ef1f5fc7d9f58ffa20f5df Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 11 Jun 2012 18:25:56 +0200 Subject: [PATCH 01/27] Set number if decimals in property editor according to user settings --- src/Gui/propertyeditor/PropertyItem.cpp | 20 ++++++++++---------- src/Mod/Drawing/App/FeatureViewPart.cpp | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index eab7c4c20..52b5733ec 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -544,7 +544,7 @@ PropertyFloatItem::PropertyFloatItem() QVariant PropertyFloatItem::toString(const QVariant& prop) const { double value = prop.toDouble(); - QString data = QLocale::system().toString(value, 'f', 2); + QString data = QLocale::system().toString(value, 'f', decimals()); const std::vector& props = getPropertyData(); if (!props.empty()) { if (props.front()->getTypeId().isDerivedFrom(App::PropertyDistance::getClassTypeId())) { @@ -698,7 +698,7 @@ PropertyFloatConstraintItem::PropertyFloatConstraintItem() QVariant PropertyFloatConstraintItem::toString(const QVariant& prop) const { double value = prop.toDouble(); - QString data = QLocale::system().toString(value, 'f', 2); + QString data = QLocale::system().toString(value, 'f', decimals()); return QVariant(data); } @@ -791,7 +791,7 @@ QVariant PropertyAngleItem::toString(const QVariant& prop) const { double value = prop.toDouble(); QString data = QString::fromUtf8("%1 \xc2\xb0") - .arg(QLocale::system().toString(value, 'f', 2)); + .arg(QLocale::system().toString(value, 'f', decimals())); return QVariant(data); } @@ -1246,13 +1246,13 @@ QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const QString data = QString::fromAscii("Axis: (%1 %2 %3)\n" "Angle: %4\n" "Move: (%5 %6 %7)") - .arg(QLocale::system().toString(dir.x,'f',2)) - .arg(QLocale::system().toString(dir.y,'f',2)) - .arg(QLocale::system().toString(dir.z,'f',2)) - .arg(QLocale::system().toString(angle,'f',2)) - .arg(QLocale::system().toString(pos.x,'f',2)) - .arg(QLocale::system().toString(pos.y,'f',2)) - .arg(QLocale::system().toString(pos.z,'f',2)); + .arg(QLocale::system().toString(dir.x,'f',decimals())) + .arg(QLocale::system().toString(dir.y,'f',decimals())) + .arg(QLocale::system().toString(dir.z,'f',decimals())) + .arg(QLocale::system().toString(angle,'f',decimals())) + .arg(QLocale::system().toString(pos.x,'f',decimals())) + .arg(QLocale::system().toString(pos.y,'f',decimals())) + .arg(QLocale::system().toString(pos.z,'f',decimals())); return QVariant(data); } diff --git a/src/Mod/Drawing/App/FeatureViewPart.cpp b/src/Mod/Drawing/App/FeatureViewPart.cpp index f4f755338..0eee19f3a 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.cpp +++ b/src/Mod/Drawing/App/FeatureViewPart.cpp @@ -82,7 +82,7 @@ FeatureViewPart::FeatureViewPart(void) ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Shape to view"); ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines"); ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines"); - ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the resulting lines"); + ADD_PROPERTY_TYPE(LineWidth,(0.35f),vgroup,App::Prop_None,"The thickness of the resulting lines"); } FeatureViewPart::~FeatureViewPart() From 2efc4915a1579af49fefca98f1d4ae2119520c0a Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 11 Jun 2012 14:31:27 -0300 Subject: [PATCH 02/27] 0000715: Draft snap --- src/Mod/Draft/DraftGui.py | 58 ++++++++++++++++++++++++++++---------- src/Mod/Draft/DraftSnap.py | 29 ++++++++++++++----- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index d68a981a7..d97a7d474 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -137,7 +137,7 @@ class DraftLineEdit(QtGui.QLineEdit): self.emit(QtCore.SIGNAL("up()")) elif event.key() == QtCore.Qt.Key_Down: self.emit(QtCore.SIGNAL("down()")) - elif (event.key() == QtCore.Qt.Key_Z) and QtCore.Qt.ControlModifier: + elif (event.key() == QtCore.Qt.Key_Z) and (int(event.modifiers()) == QtCore.Qt.ControlModifier): self.emit(QtCore.SIGNAL("undo()")) else: QtGui.QLineEdit.keyPressEvent(self, event) @@ -184,6 +184,7 @@ class DraftToolBar: self.crossedViews = [] self.isTaskOn = False self.fillmode = Draft.getParam("fillmode") + self.mask = None if self.taskmode: # add only a dummy widget, since widgets are created on demand @@ -593,6 +594,7 @@ class DraftToolBar: self.cancel = None self.sourceCmd = None self.pointcallback = None + self.mask = None if self.taskmode: self.isTaskOn = False self.baseWidget = QtGui.QWidget() @@ -882,15 +884,16 @@ class DraftToolBar: last = self.sourceCmd.node[0] else: last = self.sourceCmd.node[-1] - numx = last.x + numx - numy = last.y + numy - numz = last.z + numz + print "last:",last + v = FreeCAD.Vector(numx,numy,numz) + print "orig:",v if FreeCAD.DraftWorkingPlane: v = FreeCAD.Vector(numx,numy,numz) - v = FreeCAD.DraftWorkingPlane.getGlobalCoords(v) - numx = v.x - numy = v.y - numz = v.z + v = FreeCAD.DraftWorkingPlane.getGlobalRot(v) + print "rotated:",v + numx = last.x + v.x + numy = last.y + v.y + numz = last.z + v.z self.sourceCmd.numericInput(numx,numy,numz) def finish(self): @@ -963,6 +966,12 @@ class DraftToolBar: self.toggleradius(1) elif txt.endsWith("]"): self.toggleradius(-1) + elif txt.endsWith("x"): + self.constrain("x") + elif txt.endsWith("y"): + self.constrain("y") + elif txt.endsWith("z"): + self.constrain("z") elif txt.endsWith("c"): if self.closeButton.isVisible(): self.closeLine() @@ -1025,29 +1034,38 @@ class DraftToolBar: dp = point if self.relativeMode and (last != None): if plane: - dp = plane.getLocalCoords(FreeCAD.Vector(point.x-last.x, point.y-last.y, point.z-last.z)) + dp = plane.getLocalRot(FreeCAD.Vector(point.x-last.x, point.y-last.y, point.z-last.z)) else: dp = FreeCAD.Vector(point.x-last.x, point.y-last.y, point.z-last.z) # set widgets - self.xValue.setText("%.2f" % dp.x) - self.yValue.setText("%.2f" % dp.y) - self.zValue.setText("%.2f" % dp.z) + if self.mask in ['y','z']: + self.xValue.setText("0.00") + else: + self.xValue.setText("%.2f" % dp.x) + if self.mask in ['x','z']: + self.yValue.setText("0.00") + else: + self.yValue.setText("%.2f" % dp.y) + if self.mask in ['x','y']: + self.zValue.setText("0.00") + else: + self.zValue.setText("%.2f" % dp.z) # set masks - if mask == "x": + if (mask == "x") or (self.mask == "x"): self.xValue.setEnabled(True) self.yValue.setEnabled(False) self.zValue.setEnabled(False) self.xValue.setFocus() self.xValue.selectAll() - elif mask == "y": + elif (mask == "y") or (self.mask == "y"): self.xValue.setEnabled(False) self.yValue.setEnabled(True) self.zValue.setEnabled(False) self.yValue.setFocus() self.yValue.selectAll() - elif mask == "z": + elif (mask == "z") or (self.mask == "z"): self.xValue.setEnabled(False) self.yValue.setEnabled(False) self.zValue.setEnabled(True) @@ -1168,6 +1186,16 @@ class DraftToolBar: Draft.setParam("snapRange",par+val) FreeCADGui.Snapper.showradius() + def constrain(self,val): + if self.mask == val: + self.mask = None + if hasattr(FreeCADGui,"Snapper"): + FreeCADGui.Snapper.mask = None + else: + self.mask = val + if hasattr(FreeCADGui,"Snapper"): + FreeCADGui.Snapper.mask = val + #--------------------------------------------------------------------------- # TaskView operations #--------------------------------------------------------------------------- diff --git a/src/Mod/Draft/DraftSnap.py b/src/Mod/Draft/DraftSnap.py index c4bacf77a..b906c7188 100644 --- a/src/Mod/Draft/DraftSnap.py +++ b/src/Mod/Draft/DraftSnap.py @@ -60,6 +60,7 @@ class Snapper: self.constraintAxis = None self.basepoint = None self.affinity = None + self.mask = None self.cursorMode = None if Draft.getParam("maxSnap"): self.maxEdges = Draft.getParam("maxSnapEdges") @@ -126,7 +127,7 @@ class Snapper: def cstr(point): "constrains if needed" - if constrain: + if constrain or self.mask: fpt = self.constrain(point,lastpoint) else: self.unconstrain() @@ -211,7 +212,9 @@ class Snapper: else: # first stick to the snapped object - point = self.snapToVertex(self.snapInfo)[0] + s = self.snapToVertex(self.snapInfo) + if s: + point = s[0] # active snapping comp = self.snapInfo['Component'] @@ -278,7 +281,7 @@ class Snapper: self.lastObj[1] = obj.Name if not snaps: - return point + return cstr(point) # calculating the nearest snap point shortest = 1000000000000000000 @@ -395,7 +398,7 @@ class Snapper: def snapToPolar(self,point,last): "snaps to polar lines from the given point" - if self.isEnabled('ortho'): + if self.isEnabled('ortho') and (not self.mask): if last: vecs = [] if hasattr(FreeCAD,"DraftWorkingPlane"): @@ -535,9 +538,11 @@ class Snapper: "returns a perpendicular X extension snap location" if self.isEnabled("extension") and self.isEnabled("perpendicular"): if last and self.extLine: - tmpEdge = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape() - np = self.getPerpendicular(tmpEdge,last) - return [np,'perpendicular',np] + if self.extLine.p1() != self.extLine.p2(): + tmpEdge = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape() + np = self.getPerpendicular(tmpEdge,last) + return [np,'perpendicular',np] + return None def snapToElines(self,e1,e2): "returns a snap location at the infinite intersection of the given edges" @@ -668,6 +673,7 @@ class Snapper: self.setCursor() if Draft.getParam("hideSnapBar"): self.toolbar.hide() + self.mask = None def constrain(self,point,basepoint=None,axis=None): '''constrain(point,basepoint=None,axis=None: Returns a @@ -696,6 +702,8 @@ class Snapper: delta = point.sub(self.basepoint) # setting constraint axis + if self.mask: + self.affinity = self.mask if not self.affinity: self.affinity = FreeCAD.DraftWorkingPlane.getClosestAxis(delta) if isinstance(axis,FreeCAD.Vector): @@ -920,6 +928,13 @@ class Snapper: if FreeCADGui.ActiveDocument: self.setTrackers() + def setGrid(self): + "sets the grid, if visible" + if self.grid and (not self.forceGridOff): + if self.grid.Visible: + self.grid.set() + self.setTrackers() + def setTrackers(self): v = Draft.get3DView() if v in self.trackers[0]: From 231786f5792ffa2ac32b38d00ca444b6f92fa92f Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 11 Jun 2012 14:56:38 -0300 Subject: [PATCH 03/27] 0000737: Draft selection --- src/Mod/Draft/DraftGui.py | 4 +-- src/Mod/Draft/DraftTools.py | 55 +++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index d97a7d474..1e84dbce8 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -697,7 +697,7 @@ class DraftToolBar: if not self.taskmode: self.labelx.setText(translate("draft", "Pick Object")) self.labelx.show() - self.makeDumbTask() + self.makeDumbTask() def editUi(self): self.taskUi(translate("draft", "Edit")) @@ -769,7 +769,7 @@ class DraftToolBar: def __init__(self): pass def getStandardButtons(self): - return 0 + return int(QtGui.QDialogButtonBox.Cancel) panel = TaskPanel() FreeCADGui.Control.showDialog(panel) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 040736927..9f3b6fde0 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -111,15 +111,15 @@ def selectObject(arg): if (arg["Key"] == "ESCAPE"): FreeCAD.activeDraftCommand.finish() # TODO : this part raises a coin3D warning about scene traversal, to be fixed. - if (arg["Type"] == "SoMouseButtonEvent"): - if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): - cursor = arg["Position"] - snapped = Draft.get3DView().getObjectInfo((cursor[0],cursor[1])) - if snapped: - obj = FreeCAD.ActiveDocument.getObject(snapped['Object']) - FreeCADGui.Selection.addSelection(obj) - FreeCAD.activeDraftCommand.component=snapped['Component'] - FreeCAD.activeDraftCommand.proceed() + elif (arg["Type"] == "SoMouseButtonEvent"): + if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): + cursor = arg["Position"] + snapped = Draft.get3DView().getObjectInfo((cursor[0],cursor[1])) + if snapped: + obj = FreeCAD.ActiveDocument.getObject(snapped['Object']) + FreeCADGui.Selection.addSelection(obj) + FreeCAD.activeDraftCommand.component=snapped['Component'] + FreeCAD.activeDraftCommand.proceed() def getPoint(target,args,mobile=False,sym=False,workingplane=True): ''' @@ -1726,12 +1726,6 @@ class Modifier(DraftTool): def __init__(self): DraftTool.__init__(self) - def IsActive(self): - if Draft.getSelection(): - return True - else: - return False - class Move(Modifier): "The Draft_Move FreeCAD command definition" @@ -1771,9 +1765,11 @@ class Move(Modifier): self.ui.cross(True) def finish(self,closed=False,cont=False): - if self.ui: + if self.ghost: self.ghost.finalize() + if self.linetrack: self.linetrack.finalize() + if self.constraintrack: self.constraintrack.finalize() Modifier.finish(self) if cont and self.ui: @@ -1941,11 +1937,15 @@ class Rotate(Modifier): def finish(self,closed=False,cont=False): "finishes the arc" Modifier.finish(self) - if self.ui: + if self.linetrack: self.linetrack.finalize() + if self.constraintrack: self.constraintrack.finalize() + if self.arctrack: self.arctrack.finalize() + if self.ghost: self.ghost.finalize() + if self.doc: self.doc.recompute() if cont and self.ui: if self.ui.continueMode: @@ -2248,10 +2248,13 @@ class Offset(Modifier): self.finish() def finish(self,closed=False): - if self.ui and self.running: - self.linetrack.finalize() - self.constraintrack.finalize() - self.ghost.finalize() + if self.running: + if self.linetrack: + self.linetrack.finalize() + if self.constraintrack: + self.constraintrack.finalize() + if self.ghost: + self.ghost.finalize() Modifier.finish(self) def numericRadius(self,rad): @@ -2924,8 +2927,10 @@ class Trimex(Modifier): Modifier.finish(self) self.force = None if self.ui: - self.linetrack.finalize() - self.constraintrack.finalize() + if self.linetrack: + self.linetrack.finalize() + if self.constraintrack: + self.constraintrack.finalize() if self.ghost: for g in self.ghost: g.finalize() @@ -2980,9 +2985,11 @@ class Scale(Modifier): def finish(self,closed=False,cont=False): Modifier.finish(self) - if self.ui: + if self.ghost: self.ghost.finalize() + if self.linetrack: self.linetrack.finalize() + if self.constraintrack: self.constraintrack.finalize() if cont and self.ui: if self.ui.continueMode: From 104f9d522589b1f8e713b75d31c54e8b3193c21e Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 11 Jun 2012 21:19:49 +0200 Subject: [PATCH 04/27] Fix build errors with autotools, fix a couple of grave bugs --- src/Mod/Drawing/App/FeaturePage.cpp | 11 +++++++---- src/Mod/Part/App/PartFeature.h | 25 +++++++++++++------------ src/Mod/Part/Gui/Makefile.am | 5 +++++ src/Mod/PartDesign/App/Makefile.am | 2 ++ src/Mod/PartDesign/Gui/Makefile.am | 6 ++++++ 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/Mod/Drawing/App/FeaturePage.cpp b/src/Mod/Drawing/App/FeaturePage.cpp index c1730ebc4..0af2e7f4d 100644 --- a/src/Mod/Drawing/App/FeaturePage.cpp +++ b/src/Mod/Drawing/App/FeaturePage.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "FeaturePage.h" #include "FeatureView.h" @@ -86,10 +87,11 @@ void FeaturePage::onChanged(const App::Property* prop) App::DocumentObjectExecReturn *FeaturePage::execute(void) { - if(Template.getValue() == "") + std::string temp = Template.getValue(); + if (temp.empty()) return App::DocumentObject::StdReturn; - Base::FileInfo fi(Template.getValue()); + Base::FileInfo fi(temp); if (!fi.isReadable()) { // if there is a old absolute template file set use a redirect fi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName()); @@ -186,8 +188,9 @@ std::vector FeaturePage::getEditableTextsFromTemplate(void) const { std::vector eds; - if (Template.getValue() != "") { - Base::FileInfo tfi(Template.getValue()); + std::string temp = Template.getValue(); + if (!temp.empty()) { + Base::FileInfo tfi(temp); if (!tfi.isReadable()) { // if there is a old absolute template file set use a redirect tfi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + tfi.fileName()); diff --git a/src/Mod/Part/App/PartFeature.h b/src/Mod/Part/App/PartFeature.h index 9bb4bd49a..5c08151bc 100644 --- a/src/Mod/Part/App/PartFeature.h +++ b/src/Mod/Part/App/PartFeature.h @@ -71,21 +71,21 @@ public: virtual std::vector getPySubObjects(const std::vector&) const; /** - /* Find the origin of a reference, e.g. the vertex or edge in a sketch that - /* produced a face - */ + * Find the origin of a reference, e.g. the vertex or edge in a sketch that + * produced a face + */ const TopoDS_Shape findOriginOf(const TopoDS_Shape& reference); protected: void onChanged(const App::Property* prop); TopLoc_Location getLocation() const; /** - /* Build a history of changes - /* MakeShape: The operation that created the changes, e.g. BRepAlgoAPI_Common - /* type: The type of object we are interested in, e.g. TopAbs_FACE - /* newS: The new shape that was created by the operation - /* oldS: The original shape prior to the operation - */ + * Build a history of changes + * MakeShape: The operation that created the changes, e.g. BRepAlgoAPI_Common + * type: The type of object we are interested in, e.g. TopAbs_FACE + * newS: The new shape that was created by the operation + * oldS: The original shape prior to the operation + */ ShapeHistory buildHistory(BRepBuilderAPI_MakeShape&, TopAbs_ShapeEnum type, const TopoDS_Shape& newS, const TopoDS_Shape& oldS); ShapeHistory joinHistory(const ShapeHistory&, const ShapeHistory&); @@ -121,9 +121,9 @@ public: // Utility methods /** -/* Find all faces cut by a line through the centre of gravity of a given face -/* Useful for the "up to face" options to pocket or pad -*/ + * Find all faces cut by a line through the centre of gravity of a given face + * Useful for the "up to face" options to pocket or pad + */ struct cutFaces { TopoDS_Face face; double distsq; @@ -137,3 +137,4 @@ std::vector findAllFacesCutBy(const TopoDS_Shape& shape, #endif // PART_FEATURE_H + diff --git a/src/Mod/Part/Gui/Makefile.am b/src/Mod/Part/Gui/Makefile.am index 15a2a094a..f214d928d 100644 --- a/src/Mod/Part/Gui/Makefile.am +++ b/src/Mod/Part/Gui/Makefile.am @@ -19,6 +19,7 @@ BUILT_SOURCES=\ ui_TaskFaceColors.h \ ui_TaskShapeBuilder.h \ ui_TaskLoft.h \ + ui_TaskSweep.h \ moc_CrossSections.cpp \ moc_DlgBooleanOperation.cpp \ moc_DlgExtrusion.cpp \ @@ -35,6 +36,7 @@ BUILT_SOURCES=\ moc_TaskFaceColors.cpp \ moc_TaskShapeBuilder.cpp \ moc_TaskLoft.cpp \ + moc_TaskSweep.cpp \ qrc_Part.cpp libPartGui_la_SOURCES=\ @@ -73,6 +75,8 @@ libPartGui_la_SOURCES=\ TaskShapeBuilder.h \ TaskLoft.cpp \ TaskLoft.h \ + TaskSweep.cpp \ + TaskSweep.h \ PreCompiled.cpp \ PreCompiled.h \ SoBrepShape.cpp \ @@ -230,6 +234,7 @@ EXTRA_DIST = \ TaskFaceColors.ui \ TaskShapeBuilder.ui \ TaskLoft.ui \ + TaskSweep.ui \ Resources/Part.qrc \ Resources/translations/Part_af.qm \ Resources/translations/Part_af.ts \ diff --git a/src/Mod/PartDesign/App/Makefile.am b/src/Mod/PartDesign/App/Makefile.am index 54d59e3bd..a3b251dec 100644 --- a/src/Mod/PartDesign/App/Makefile.am +++ b/src/Mod/PartDesign/App/Makefile.am @@ -17,6 +17,8 @@ libPartDesign_la_SOURCES=\ FeatureChamfer.h \ FeatureDressUp.cpp \ FeatureDressUp.h \ + FeatureGroove.cpp \ + FeatureGroove.h \ Body.cpp \ Body.h \ FeatureSketchBased.cpp \ diff --git a/src/Mod/PartDesign/Gui/Makefile.am b/src/Mod/PartDesign/Gui/Makefile.am index f7bbf7054..9977ac0c1 100644 --- a/src/Mod/PartDesign/Gui/Makefile.am +++ b/src/Mod/PartDesign/Gui/Makefile.am @@ -8,8 +8,10 @@ BUILT_SOURCES=\ moc_TaskPocketParameters.cpp \ moc_TaskChamferParameters.cpp \ moc_TaskFilletParameters.cpp \ + moc_TaskGrooveParameters.cpp \ moc_TaskHoleParameters.cpp \ moc_TaskRevolutionParameters.cpp \ + ui_TaskGrooveParameters.h \ ui_TaskPadParameters.h \ ui_TaskPatternRectangularParameters.h \ ui_TaskPocketParameters.h \ @@ -32,6 +34,8 @@ libPartDesignGui_la_SOURCES=\ Command.cpp \ PreCompiled.cpp \ PreCompiled.h \ + TaskGrooveParameters.cpp \ + TaskGrooveParameters.h \ TaskPadParameters.cpp \ TaskPadParameters.h \ TaskPatternRectangularParameters.cpp \ @@ -58,6 +62,8 @@ libPartDesignGui_la_SOURCES=\ ViewProviderChamfer.h \ ViewProviderFillet.cpp \ ViewProviderFillet.h \ + ViewProviderGroove.cpp \ + ViewProviderGroove.h \ ViewProviderRevolution.cpp \ ViewProviderRevolution.h \ ViewProviderPatternRectangular.cpp \ From 041dd32a006fe1b9b1b77a85e39fc54df3915f54 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 11 Jun 2012 17:14:40 -0300 Subject: [PATCH 05/27] 0000742: Draft grid --- src/Mod/Draft/DraftSnap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/DraftSnap.py b/src/Mod/Draft/DraftSnap.py index b906c7188..55a4d7a23 100644 --- a/src/Mod/Draft/DraftSnap.py +++ b/src/Mod/Draft/DraftSnap.py @@ -956,7 +956,7 @@ class Snapper: self.trackers[2].append(self.tracker) self.trackers[3].append(self.extLine) self.trackers[4].append(self.radiusTracker) - if not self.forceGridOff: + if self.grid and (not self.forceGridOff): self.grid.set() if not hasattr(FreeCADGui,"Snapper"): From 291dbfa0548209f130daeff3dc1a7ec8c4ae0fa1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 11 Jun 2012 23:06:09 +0200 Subject: [PATCH 06/27] Fix issues in autotools --- configure.ac | 6 +++--- src/Gui/Icons/Makefile.am | 1 + src/Mod/Drawing/Gui/Makefile.am | 1 + src/Mod/PartDesign/Gui/Makefile.am | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 6883a2f39..05010ef14 100644 --- a/configure.ac +++ b/configure.ac @@ -1082,10 +1082,10 @@ AC_MSG_NOTICE([ RTTI enabled (forced): true Compiler warnings enabled: $fc_set_warn installation prefix: $prefix - eneble-assembly: $fc_set_assembly - eneble-cam: $fc_set_cam + enable-assembly: $fc_set_assembly + enable-cam: $fc_set_cam enable-sandbox: $fc_set_sandbox - eneble-template: $fc_set_template + enable-template: $fc_set_template Now, run 'make' to build FreeCAD. ************************************************************************** diff --git a/src/Gui/Icons/Makefile.am b/src/Gui/Icons/Makefile.am index 9be01aa6c..66c1c3548 100644 --- a/src/Gui/Icons/Makefile.am +++ b/src/Gui/Icons/Makefile.am @@ -56,6 +56,7 @@ EXTRA_DIST = \ edit-copy.svg \ edit-cut.svg \ edit-delete.svg \ + edit-edit.svg \ edit-paste.svg \ edit-select-all.svg \ edit-select-box.svg \ diff --git a/src/Mod/Drawing/Gui/Makefile.am b/src/Mod/Drawing/Gui/Makefile.am index 3cca838d3..84253f31f 100644 --- a/src/Mod/Drawing/Gui/Makefile.am +++ b/src/Mod/Drawing/Gui/Makefile.am @@ -91,5 +91,6 @@ libdir = $(prefix)/Mod/Drawing CLEANFILES = $(BUILT_SOURCES) EXTRA_DIST = \ + $(ibDrawingGui_la_UI) CMakeLists.txt diff --git a/src/Mod/PartDesign/Gui/Makefile.am b/src/Mod/PartDesign/Gui/Makefile.am index 9977ac0c1..e3b32574c 100644 --- a/src/Mod/PartDesign/Gui/Makefile.am +++ b/src/Mod/PartDesign/Gui/Makefile.am @@ -21,6 +21,7 @@ BUILT_SOURCES=\ ui_TaskRevolutionParameters.h libPartDesignGui_la_UI=\ + TaskGrooveParameters.ui \ TaskPadParameters.ui \ TaskPatternRectangularParameters.ui \ TaskPocketParameters.ui \ From a2710d2e15718eb58a82b96caaf61649ff050ec4 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 11 Jun 2012 19:16:02 -0300 Subject: [PATCH 07/27] Draft: Made the grid unpickable --- src/Mod/Draft/DraftTrackers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Mod/Draft/DraftTrackers.py b/src/Mod/Draft/DraftTrackers.py index c36d03152..c655c62bd 100644 --- a/src/Mod/Draft/DraftTrackers.py +++ b/src/Mod/Draft/DraftTrackers.py @@ -468,6 +468,8 @@ class PlaneTracker(Tracker): p1 = Draft.get3DView().getPoint((100,100)) p2 = Draft.get3DView().getPoint((110,100)) bl = (p2.sub(p1)).Length * (Draft.getParam("snapRange")/2) + pick = coin.SoPickStyle() + pick.style.setValue(coin.SoPickStyle.UNPICKABLE) self.trans = coin.SoTransform() self.trans.translation.setValue([0,0,0]) m1 = coin.SoMaterial() @@ -486,6 +488,7 @@ class PlaneTracker(Tracker): l = coin.SoLineSet() l.numVertices.setValues([3,3,3]) s = coin.SoSeparator() + s.addChild(pick) s.addChild(self.trans) s.addChild(m1) s.addChild(c1) @@ -542,6 +545,9 @@ class gridTracker(Tracker): self.mainlines = Draft.getParam("gridEvery") self.numlines = 100 col = [0.2,0.2,0.3] + + pick = coin.SoPickStyle() + pick.style.setValue(coin.SoPickStyle.UNPICKABLE) self.trans = coin.SoTransform() self.trans.translation.setValue([0,0,0]) @@ -595,6 +601,7 @@ class gridTracker(Tracker): lines3 = coin.SoLineSet() lines3.numVertices.setValues(aidx) s = coin.SoSeparator() + s.addChild(pick) s.addChild(self.trans) s.addChild(mat1) s.addChild(self.coords1) From 178010bb39e679f0d09be2a231b6b387bad1150b Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Jun 2012 01:00:17 +0200 Subject: [PATCH 08/27] Fix build errors with autotools --- src/Mod/Drawing/Gui/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Drawing/Gui/Makefile.am b/src/Mod/Drawing/Gui/Makefile.am index 84253f31f..a434c80f0 100644 --- a/src/Mod/Drawing/Gui/Makefile.am +++ b/src/Mod/Drawing/Gui/Makefile.am @@ -91,6 +91,6 @@ libdir = $(prefix)/Mod/Drawing CLEANFILES = $(BUILT_SOURCES) EXTRA_DIST = \ - $(ibDrawingGui_la_UI) + $(libDrawingGui_la_UI) \ CMakeLists.txt From ad6ae5e2bcd1ddd49bc21d28b22d05da6d33e920 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Jun 2012 10:10:21 +0200 Subject: [PATCH 09/27] Fix Makefile --- src/Mod/Drawing/Gui/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Drawing/Gui/Makefile.am b/src/Mod/Drawing/Gui/Makefile.am index 84253f31f..a434c80f0 100644 --- a/src/Mod/Drawing/Gui/Makefile.am +++ b/src/Mod/Drawing/Gui/Makefile.am @@ -91,6 +91,6 @@ libdir = $(prefix)/Mod/Drawing CLEANFILES = $(BUILT_SOURCES) EXTRA_DIST = \ - $(ibDrawingGui_la_UI) + $(libDrawingGui_la_UI) \ CMakeLists.txt From 6621c00c10bcebb9a56108b23373a23685ad54a9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Jun 2012 10:52:49 +0200 Subject: [PATCH 10/27] Add sweep and loft to toolbar --- src/Mod/Part/Gui/Command.cpp | 4 ++-- src/Mod/Part/Gui/Workbench.cpp | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 444f5b1e0..60d199d9c 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -948,7 +948,7 @@ CmdPartLoft::CmdPartLoft() sAppModule = "Part"; sGroup = QT_TR_NOOP("Part"); sMenuText = QT_TR_NOOP("Loft..."); - sToolTipText = QT_TR_NOOP("Advanced utility to lofts"); + sToolTipText = QT_TR_NOOP("Utility to loft"); sWhatsThis = sToolTipText; sStatusTip = sToolTipText; sPixmap = "Part_Loft"; @@ -974,7 +974,7 @@ CmdPartSweep::CmdPartSweep() sAppModule = "Part"; sGroup = QT_TR_NOOP("Part"); sMenuText = QT_TR_NOOP("Sweep..."); - sToolTipText = QT_TR_NOOP("Advanced utility to sweep"); + sToolTipText = QT_TR_NOOP("Utility to sweep"); sWhatsThis = sToolTipText; sStatusTip = sToolTipText; sPixmap = "Part_Sweep"; diff --git a/src/Mod/Part/Gui/Workbench.cpp b/src/Mod/Part/Gui/Workbench.cpp index 9997750b2..d6b6b113a 100644 --- a/src/Mod/Part/Gui/Workbench.cpp +++ b/src/Mod/Part/Gui/Workbench.cpp @@ -67,18 +67,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const root->insertItem(item, part); part->setCommand("&Part"); *part << "Part_Import" << "Part_Export" << "Separator"; - *part << prim << "Part_Primitives" << "Separator" << "Part_ShapeFromMesh" - << "Part_MakeSolid" << "Part_ReverseShape" << "Part_SimpleCopy" - << "Part_RefineShape" << "Separator" + *part << prim << "Part_Primitives" << "Part_Builder" << "Separator" + << "Part_ShapeFromMesh" << "Part_MakeSolid" << "Part_ReverseShape" + << "Part_SimpleCopy" << "Part_RefineShape" << "Separator" << "Part_Boolean" << "Part_CrossSections" << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer" - << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep" - << "Part_Builder"; - - //Gui::MenuItem* partSimple = new Gui::MenuItem; - //root->insertItem(item, partSimple); - //partSimple->setCommand("&Simple"); - //*partSimple << "Part_SimpleCylinder"; + << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep"; return root; } @@ -89,15 +83,18 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* solids = new Gui::ToolBarItem(root); solids->setCommand("Solids"); - *solids << "Part_Box" << "Part_Cylinder" << "Part_Sphere" << "Part_Cone" << "Part_Torus" << "Part_Primitives"; + *solids << "Part_Box" << "Part_Cylinder" << "Part_Sphere" << "Part_Cone" + << "Part_Torus" << "Part_Primitives" << "Part_Builder"; Gui::ToolBarItem* tool = new Gui::ToolBarItem(root); tool->setCommand("Part tools"); - *tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" << "Part_Chamfer" << "Part_RuledSurface"; + *tool << "Part_Extrude" << "Part_Revolve" << "Part_Mirror" << "Part_Fillet" + << "Part_Chamfer" << "Part_RuledSurface" << "Part_Loft" << "Part_Sweep"; Gui::ToolBarItem* boolop = new Gui::ToolBarItem(root); boolop->setCommand("Boolean"); - *boolop << "Part_Boolean" << "Part_Cut" << "Part_Fuse" << "Part_Common" << "Part_Section"; + *boolop << "Part_Boolean" << "Part_Cut" << "Part_Fuse" << "Part_Common" + << "Part_Section" << "Part_CrossSections"; return root; } From 9170bfe0451cea8dd63650995af2db4575b3ad4d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Jun 2012 19:03:29 +0200 Subject: [PATCH 11/27] Export object dependencies to graphviz file --- src/App/Document.cpp | 25 ++++++++++ src/App/Document.h | 1 + src/App/DocumentPy.xml | 5 ++ src/App/DocumentPyImp.cpp | 19 ++++++++ src/Gui/CommandDoc.cpp | 76 ++++++++++++++++++++++++++++++ src/Gui/Workbench.cpp | 5 +- src/Mod/Complete/Gui/Workbench.cpp | 3 +- 7 files changed, 131 insertions(+), 3 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 61d1b7921..cba2e757b 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -847,6 +847,31 @@ unsigned int Document::getMemSize (void) const return size; } +void Document::exportGraphviz(std::ostream& out) +{ + std::vector names; + names.reserve(d->objectMap.size()); + DependencyList DepList; + std::map VertexObjectList; + + // Filling up the adjacency List + for (std::map::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) { + // add the object as Vertex and remember the index + VertexObjectList[It->second] = add_vertex(DepList); + names.push_back(It->second->Label.getValue()); + } + // add the edges + for (std::map::const_iterator It = d->objectMap.begin(); It != d->objectMap.end();++It) { + std::vector OutList = It->second->getOutList(); + for (std::vector::const_iterator It2=OutList.begin();It2!=OutList.end();++It2) { + if (*It2) + add_edge(VertexObjectList[It->second],VertexObjectList[*It2],DepList); + } + } + + boost::write_graphviz(out, DepList, boost::make_label_writer(&(names[0]))); +} + // Save the document under the name it has been opened bool Document::save (void) { diff --git a/src/App/Document.h b/src/App/Document.h index 38b247a20..9b705e8c9 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -114,6 +114,7 @@ public: /// Restore the document from the file in Property Path void restore (void); void exportObjects(const std::vector&, std::ostream&); + void exportGraphviz(std::ostream&); std::vector importObjects(std::istream&); /// Opens the document from its file name //void open (void); diff --git a/src/App/DocumentPy.xml b/src/App/DocumentPy.xml index 3897af801..4a996e111 100644 --- a/src/App/DocumentPy.xml +++ b/src/App/DocumentPy.xml @@ -23,6 +23,11 @@ Restore the document from disc + + + Export the dependencies of the objects as graph + + Open a new Undo/Redo transaction. diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 64b04d8b9..4b5d805d4 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -92,6 +92,25 @@ PyObject* DocumentPy::restore(PyObject * args) Py_Return; } +PyObject* DocumentPy::exportGraphviz(PyObject * args) +{ + char* fn=0; + if (!PyArg_ParseTuple(args, "|s",&fn)) // convert args: Python->C + return NULL; // NULL triggers exception + if (fn) { + Base::FileInfo fi(fn); + Base::ofstream str(fi); + getDocumentPtr()->exportGraphviz(str); + str.close(); + Py_Return; + } + else { + std::stringstream str; + getDocumentPtr()->exportGraphviz(str); + return PyString_FromString(str.str().c_str()); + } +} + PyObject* DocumentPy::addObject(PyObject *args) { char *sType,*sName=0; diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index a445f68c1..a83d5ea5e 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -24,12 +24,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include +# include # include # include +# include +# include #endif #include #include +#include #include #include #include @@ -311,6 +315,77 @@ bool StdCmdMergeProjects::isActive(void) return this->hasActiveDocument(); } +//=========================================================================== +// Std_ExportGraphviz +//=========================================================================== + +DEF_STD_CMD_A(StdCmdExportGraphviz); + +StdCmdExportGraphviz::StdCmdExportGraphviz() + : Command("Std_ExportGraphviz") +{ + // seting the + sGroup = QT_TR_NOOP("Tools"); + sMenuText = QT_TR_NOOP("Dependency graph..."); + sToolTipText = QT_TR_NOOP("Show the dependency graph of the objects in the active document"); + sStatusTip = QT_TR_NOOP("Show the dependency graph of the objects in the active document"); + sWhatsThis = "Std_ExportGraphviz"; + eType = 0; +} + +void StdCmdExportGraphviz::activated(int iMsg) +{ + App::Document* doc = App::GetApplication().getActiveDocument(); + Base::FileInfo fi(Base::FileInfo::getTempFileName()); + Base::ofstream str(fi); + doc->exportGraphviz(str); + str.close(); + + Base::FileInfo out(Base::FileInfo::getTempFileName()); + QProcess proc; + QEventLoop loop; + QObject::connect(&proc, SIGNAL(finished(int, QProcess::ExitStatus)), + &loop, SLOT(quit())); + QStringList args; + args << QLatin1String("-Tpng") << QString::fromUtf8(fi.filePath().c_str()) + << QLatin1String("-o") << QString::fromUtf8(out.filePath().c_str()); + QString exe = QLatin1String("dot"); + QStringList env = QProcess::systemEnvironment(); + proc.setEnvironment(env); + proc.start(exe, args); + if (proc.state() == QProcess::Running) { + loop.exec(); + fi.deleteFile(); + } + else { + QMessageBox::warning(getMainWindow(), + qApp->translate("Std_ExportGraphviz","Graphviz not found"), + qApp->translate("Std_ExportGraphviz","Graphviz couldn't be found on your system")); + fi.deleteFile(); + return; + } + + if (out.exists()) { + QPixmap px(QString::fromUtf8(out.filePath().c_str()), "PNG"); + out.deleteFile(); + QLabel* label = new QLabel(0); + label->setAttribute(Qt::WA_DeleteOnClose); + label->setPixmap(px); + label->resize(px.size()); + label->show(); + } + else { + QMessageBox::warning(getMainWindow(), + qApp->translate("Std_ExportGraphviz","Graphviz failed"), + qApp->translate("Std_ExportGraphviz","Graphviz failed to create an image file")); + } +} + +bool StdCmdExportGraphviz::isActive(void) +{ + return (getActiveGuiDocument() ? true : false); +} + //=========================================================================== // Std_New //=========================================================================== @@ -1126,6 +1201,7 @@ void CreateDocCommands(void) rcCmdMgr.addCommand(new StdCmdImport()); rcCmdMgr.addCommand(new StdCmdExport()); rcCmdMgr.addCommand(new StdCmdMergeProjects()); + rcCmdMgr.addCommand(new StdCmdExportGraphviz()); rcCmdMgr.addCommand(new StdCmdSave()); rcCmdMgr.addCommand(new StdCmdSaveAs()); diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 26ca5d698..f055c2443 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -490,8 +490,9 @@ MenuItem* StdWorkbench::setupMenuBar() const MenuItem* tool = new MenuItem( menuBar ); tool->setCommand("&Tools"); *tool << "Std_DlgParameter" << "Separator" - << "Std_ViewScreenShot" << "Std_SceneInspector" << "Std_DemoMode" - << "Separator" << "Std_DlgCustomize"; + << "Std_ViewScreenShot" << "Std_SceneInspector" + << "Std_ExportGraphviz" << "Std_ProjectUtil" + << "Std_DemoMode" << "Separator" << "Std_DlgCustomize"; // Macro MenuItem* macro = new MenuItem( menuBar ); diff --git a/src/Mod/Complete/Gui/Workbench.cpp b/src/Mod/Complete/Gui/Workbench.cpp index 9b0b0fcf0..707e32131 100644 --- a/src/Mod/Complete/Gui/Workbench.cpp +++ b/src/Mod/Complete/Gui/Workbench.cpp @@ -183,7 +183,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Std_DlgMacroRecord" << "Std_MacroStopRecord" << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect" << "Separator" << "Std_ViewScreenShot" << "Std_SceneInspector" - << "Std_ProjectUtil" << "Std_DemoMode" << "Separator" << "Std_DlgCustomize"; + << "Std_ExportGraphviz" << "Std_ProjectUtil" + << "Std_DemoMode" << "Separator" << "Std_DlgCustomize"; // Mesh **************************************************************************************************** Gui::MenuItem* mesh = new Gui::MenuItem( menuBar ); From 28b663c9144ac8c54fa3b35e7772e2f80058ef04 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 12 Jun 2012 17:02:55 -0300 Subject: [PATCH 12/27] Arch: Fixes in structure and roof --- src/Mod/Arch/ArchRoof.py | 82 +++++++++++++++--------------- src/Mod/Arch/ArchStructure.py | 95 ++++++++++++++++++----------------- 2 files changed, 90 insertions(+), 87 deletions(-) diff --git a/src/Mod/Arch/ArchRoof.py b/src/Mod/Arch/ArchRoof.py index e85581e60..2ac0c7604 100644 --- a/src/Mod/Arch/ArchRoof.py +++ b/src/Mod/Arch/ArchRoof.py @@ -70,20 +70,15 @@ class _CommandRoof: FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() - elif obj.isDerivedFrom("Part::Feature"): - if len(obj.Shape.Faces) == 1: - FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Roof"))) - FreeCADGui.doCommand("import Arch") - FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+",1)") - FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() - elif obj.isDerivedFrom("Part::Feature"): - if len(obj.Shape.Faces) == 1: + return + if obj.isDerivedFrom("Part::Feature"): + if obj.Shape.Wires: FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Roof"))) FreeCADGui.doCommand("import Arch") - FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+",1)") + FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() + return else: FreeCAD.Console.PrintMessage(str(translate("Arch","Unable to create a roof"))) else: @@ -110,37 +105,42 @@ class _Roof(ArchComponent.Component): import Part, math, DraftGeomUtils pl = obj.Placement - if obj.Base and obj.Face and obj.Angle: - if len(obj.Base.Shape.Faces) >= obj.Face: - f = obj.Base.Shape.Faces[obj.Face-1] - if len(f.Wires) == 1: - if f.Wires[0].isClosed(): - c = round(math.tan(math.radians(obj.Angle)),Draft.precision()) - norm = f.normalAt(0,0) - d = f.BoundBox.DiagonalLength - edges = DraftGeomUtils.sortEdges(f.Edges) - l = len(edges) - edges.append(edges[0]) - shps = [] - for i in range(l): - v = DraftGeomUtils.vec(DraftGeomUtils.angleBisection(edges[i],edges[i+1])) - v.normalize() - bis = v.getAngle(DraftGeomUtils.vec(edges[i])) - delta = 1/math.cos(bis) - v.multiply(delta) - n = (FreeCAD.Vector(norm)).multiply(c) - dv = v.add(n) - dv.normalize() - dv.scale(d,d,d) - shps.append(f.extrude(dv)) - c = shps.pop() - for s in shps: - c = c.common(s) - c = c.removeSplitter() - if not c.isNull(): - obj.Shape = c - if not DraftGeomUtils.isNull(pl): - obj.Placement = pl + if obj.Base and obj.Angle: + w = None + if obj.Base.isDerivedFrom("Part::Feature"): + if (obj.Base.Shape.Faces and obj.Face): + w = obj.Base.Shape.Faces[obj.Face-1].Wires[0] + elif obj.Base.Shape.Wires: + w = obj.Base.Shape.Wires[0] + if w: + if w.isClosed(): + f = Part.Face(w) + norm = f.normalAt(0,0) + c = round(math.tan(math.radians(obj.Angle)),Draft.precision()) + d = f.BoundBox.DiagonalLength + edges = DraftGeomUtils.sortEdges(f.Edges) + l = len(edges) + edges.append(edges[0]) + shps = [] + for i in range(l): + v = DraftGeomUtils.vec(DraftGeomUtils.angleBisection(edges[i],edges[i+1])) + v.normalize() + bis = v.getAngle(DraftGeomUtils.vec(edges[i])) + delta = 1/math.cos(bis) + v.multiply(delta) + n = (FreeCAD.Vector(norm)).multiply(c) + dv = v.add(n) + dv.normalize() + dv.scale(d,d,d) + shps.append(f.extrude(dv)) + c = shps.pop() + for s in shps: + c = c.common(s) + c = c.removeSplitter() + if not c.isNull(): + obj.Shape = c + if not DraftGeomUtils.isNull(pl): + obj.Placement = pl class _ViewProviderRoof(ArchComponent.ViewProviderComponent): "A View Provider for the Roof object" diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 1a9f51c07..e30c14106 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -30,7 +30,7 @@ __title__="FreeCAD Structure" __author__ = "Yorik van Havre" __url__ = "http://free-cad.sourceforge.net" -def makeStructure(baseobj=None,length=None,width=None,height=None,name=str(translate("Arch","Structure"))): +def makeStructure(baseobj=None,length=1,width=1,height=1,name=str(translate("Arch","Structure"))): '''makeStructure([obj],[length],[width],[heigth],[swap]): creates a structure element based on the given profile object and the given extrusion height. If no base object is given, you can also specify @@ -38,16 +38,12 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=str(trans obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name) _Structure(obj) _ViewProviderStructure(obj.ViewObject) - if baseobj: obj.Base = baseobj - if length: obj.Length = length - if width: obj.Width = width - if height: obj.Height = height - if obj.Base: + if baseobj: + obj.Base = baseobj obj.Base.ViewObject.hide() - else: - if (not obj.Width) and (not obj.Length): - obj.Width = 1 - obj.Height = 1 + obj.Width = width + obj.Height = height + obj.Length = length p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") c = p.GetUnsigned("StructureColor") r = float((c>>24)&0xFF)/255.0 @@ -116,43 +112,45 @@ class _Structure(ArchComponent.Component): def createGeometry(self,obj): import Part, DraftGeomUtils + # getting default values - height = normal = None - if obj.Length: - length = obj.Length - else: - length = 1 - width = 1 + height = width = length = 1 + if hasattr(obj,"Length"): + if obj.Length: + length = obj.Length if hasattr(obj,"Width"): if obj.Width: width = obj.Width - if obj.Height: - height = obj.Height - else: - for p in obj.InList: - if Draft.getType(p) == "Floor": - height = p.Height - if not height: height = 1 - if obj.Normal == Vector(0,0,0): - normal = Vector(0,0,1) - else: - normal = Vector(obj.Normal) + if hasattr(obj,"Height"): + if obj.Height: + height = obj.Height - # creating shape + # creating base shape pl = obj.Placement - norm = normal.multiply(height) base = None if obj.Base: if obj.Base.isDerivedFrom("Part::Feature"): + if obj.Normal == Vector(0,0,0): + p = FreeCAD.Placement(obj.Base.Placement) + normal = p.Rotation.multVec(Vector(0,0,1)) + else: + normal = Vector(obj.Normal) + normal = normal.multiply(height) base = obj.Base.Shape.copy() if base.Solids: pass elif base.Faces: base = base.extrude(normal) - elif (len(base.Wires) == 1) and base.Wires[0].isClosed(): - base = Part.Face(base.Wires[0]) - base = base.extrude(normal) + elif (len(base.Wires) == 1): + if base.Wires[0].isClosed(): + base = Part.Face(base.Wires[0]) + base = base.extrude(normal) else: + if obj.Normal == Vector(0,0,0): + normal = Vector(0,0,1) + else: + normal = Vector(obj.Normal) + normal = normal.multiply(height) l2 = length/2 or 0.5 w2 = width/2 or 0.5 v1 = Vector(-l2,-w2,0) @@ -162,17 +160,20 @@ class _Structure(ArchComponent.Component): base = Part.makePolygon([v1,v2,v3,v4,v1]) base = Part.Face(base) base = base.extrude(normal) - for app in obj.Additions: - if hasattr(app,"Shape"): - if not app.Shape.isNull(): - base = base.fuse(app.Shape) - app.ViewObject.hide() # to be removed - for hole in obj.Subtractions: - if hasattr(hole,"Shape"): - if not hole.Shape.isNull(): - base = base.cut(hole.Shape) - hole.ViewObject.hide() # to be removed + if base: + # applying adds and subs + if not base.isNull(): + for app in obj.Additions: + if hasattr(app,"Shape"): + if not app.Shape.isNull(): + base = base.fuse(app.Shape) + app.ViewObject.hide() # to be removed + for hole in obj.Subtractions: + if hasattr(hole,"Shape"): + if not hole.Shape.isNull(): + base = base.cut(hole.Shape) + hole.ViewObject.hide() # to be removed pts = self.getAxisPoints(obj) if pts: fsh = [] @@ -182,10 +183,12 @@ class _Structure(ArchComponent.Component): fsh.append(sh) obj.Shape = Part.makeCompound(fsh) else: - if not base.isNull(): - base = base.removeSplitter() - obj.Shape = base - if not DraftGeomUtils.isNull(pl): obj.Placement = pl + if base: + if not base.isNull(): + base = base.removeSplitter() + obj.Shape = base + if not DraftGeomUtils.isNull(pl): + obj.Placement = pl class _ViewProviderStructure(ArchComponent.ViewProviderComponent): "A View Provider for the Structure object" From 5691866433686a55f7eea222fde5c3b9853adea8 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 12 Jun 2012 22:06:35 -0300 Subject: [PATCH 13/27] Arch: Fixes in windows --- src/Mod/Arch/ArchWall.py | 24 +++++++++++++++++------- src/Mod/Arch/ArchWindow.py | 6 +++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index e8236af3f..4983d77e7 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -271,7 +271,7 @@ class _Wall(ArchComponent.Component): if prop in ["Base","Height","Width","Align","Additions","Subtractions"]: self.createGeometry(obj) - def getSubVolume(self,base,width,delta=None): + def getSubVolume(self,base,width,plac=None): "returns a subvolume from a base object" import Part max_length = 0 @@ -288,8 +288,8 @@ class _Wall(ArchComponent.Component): v2 = DraftVecUtils.neg(v1) v2 = DraftVecUtils.scale(v1,-2) f = f.extrude(v2) - if delta: - f.translate(delta) + if plac: + f.Placement = plac return f return None @@ -384,12 +384,22 @@ class _Wall(ArchComponent.Component): if base: for app in obj.Additions: - if hasattr(app,"Shape"): + if Draft.getType(app) == "Window": + # window + if app.Base and obj.Width: + f = self.getSubVolume(app.Base,width) + if f: + base = base.cut(f) + elif Draft.isClone(app,"Window"): + if app.Objects[0].Base and width: + f = self.getSubVolume(app.Objects[0].Base,width,app.Placement) + if f: + base = base.cut(f) + elif app.isDerivedFrom("Part::Feature"): if app.Shape: if not app.Shape.isNull(): base = base.fuse(app.Shape) app.ViewObject.hide() #to be removed - for hole in obj.Subtractions: if Draft.getType(hole) == "Window": # window @@ -399,10 +409,10 @@ class _Wall(ArchComponent.Component): base = base.cut(f) elif Draft.isClone(hole,"Window"): if hole.Objects[0].Base and width: - f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement.Base) + f = self.getSubVolume(hole.Objects[0].Base,width,hole.Placement) if f: base = base.cut(f) - elif hasattr(hole,"Shape"): + elif hole.isDerivedFrom("Part::Feature"): if hole.Shape: if not hole.Shape.isNull(): base = base.cut(hole.Shape) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index ad9d49369..9c540e7be 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -107,9 +107,9 @@ class _CommandWindow: s = obj.Support w = FreeCAD.ActiveDocument.Objects[-1] # last created object FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+w.Name+",host=FreeCAD.ActiveDocument."+s.Name+")") - elif Draft.isClone(w,"Window"): - if w.Objects[0].Inlist: - FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+w.Name+",host=FreeCAD.ActiveDocument."+w.Objects[0].Inlist[0].Name+")") + elif Draft.isClone(obj,"Window"): + if obj.Objects[0].Inlist: + FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+obj.Name+",host=FreeCAD.ActiveDocument."+obj.Objects[0].Inlist[0].Name+")") FreeCAD.ActiveDocument.commitTransaction() class _Window(ArchComponent.Component): From be4500046c9576470fc6ec536487c9d2ad954059 Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Tue, 12 Jun 2012 16:54:07 +0200 Subject: [PATCH 14/27] Matrix4D::analyse function it returns a textual description of the transformation --- src/Base/Matrix.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++ src/Base/Matrix.h | 2 + 2 files changed, 97 insertions(+) diff --git a/src/Base/Matrix.cpp b/src/Base/Matrix.cpp index 4ea986415..ba936e13f 100644 --- a/src/Base/Matrix.cpp +++ b/src/Base/Matrix.cpp @@ -691,3 +691,98 @@ void Matrix4D::fromString(const std::string &str) input >> dMtrx4D[i][j]; } } + +// Analyse the a transformation Matrix and describe the transformation +std::string Matrix4D::analyse(void) const +{ + const double eps=1.0e-06; + bool hastranslation = (dMtrx4D[0][3] != 0.0 || + dMtrx4D[1][3] != 0.0 || dMtrx4D[2][3] != 0.0); + const Base::Matrix4D unityMatrix = Base::Matrix4D(); + std::string text; + if (*this == unityMatrix) + { + text = "Unity Matrix"; + } + else + { + if (dMtrx4D[3][0] != 0.0 || dMtrx4D[3][1] != 0.0 || + dMtrx4D[3][2] != 0.0 || dMtrx4D[3][3] != 1.0) + { + text = "Projection"; + } + else //translation and affine + { + if (dMtrx4D[0][1] == 0.0 && dMtrx4D[0][2] == 0.0 && + dMtrx4D[1][0] == 0.0 && dMtrx4D[1][2] == 0.0 && + dMtrx4D[2][0] == 0.0 && dMtrx4D[2][1] == 0.0) //scaling + { + std::ostringstream stringStream; + stringStream << "Scale [" << dMtrx4D[0][0] << ", " << + dMtrx4D[1][1] << ", " << dMtrx4D[2][2] << "]"; + text = stringStream.str(); + } + else + { + Base::Matrix4D sub; + sub[0][0] = dMtrx4D[0][0]; sub[0][1] = dMtrx4D[0][1]; + sub[0][2] = dMtrx4D[0][2]; sub[1][0] = dMtrx4D[1][0]; + sub[1][1] = dMtrx4D[1][1]; sub[1][2] = dMtrx4D[1][2]; + sub[2][0] = dMtrx4D[2][0]; sub[2][1] = dMtrx4D[2][1]; + sub[2][2] = dMtrx4D[2][2]; + + Base::Matrix4D trp = sub; + trp.transpose(); + trp = trp * sub; + bool ortho = true; + for (int i=0; i<4 && ortho; i++) { + for (int j=0; j<4 && ortho; j++) { + if (i != j) { + if (fabs(trp[i][j]) > eps) { + ortho = false; + break; + } + } + } + } + + double determinant = sub.determinant(); + if (ortho) + { + if (fabs(determinant-1.0) Date: Tue, 12 Jun 2012 16:55:20 +0200 Subject: [PATCH 15/27] Add PropertyMatrixItem --- src/App/PropertyGeo.h | 3 + src/Gui/SoFCDB.cpp | 1 + src/Gui/propertyeditor/PropertyItem.cpp | 352 ++++++++++++++++++++++++ src/Gui/propertyeditor/PropertyItem.h | 88 ++++++ 4 files changed, 444 insertions(+) diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index 280deedea..f8f839b47 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -185,6 +185,9 @@ public: /** This method returns a string representation of the property */ const Base::Matrix4D &getValue(void) const; + const char* getEditorName(void) const { + return "Gui::PropertyEditor::PropertyMatrixItem"; + } virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index ddf074ca1..5769248c4 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -111,6 +111,7 @@ void Gui::SoFCDB::init() PropertyBoolItem ::init(); PropertyVectorItem ::init(); PropertyDoubleVectorItem ::init(); + PropertyMatrixItem ::init(); PropertyPlacementItem ::init(); PropertyEnumItem ::init(); PropertyStringListItem ::init(); diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 52b5733ec..ef772af2b 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1050,6 +1050,358 @@ void PropertyDoubleVectorItem::setZ(double z) setData(QVariant::fromValue(Base::Vector3d(x(), y(), z))); } +// --------------------------------------------------------------- + +TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyMatrixItem, Gui::PropertyEditor::PropertyItem); + +PropertyMatrixItem::PropertyMatrixItem() +{ + const int decimals=16; + m_a11 = static_cast(PropertyFloatItem::create()); + m_a11->setParent(this); + m_a11->setPropertyName(QLatin1String("A11")); + m_a11->setDecimals(decimals); + this->appendChild(m_a11); + m_a12 = static_cast(PropertyFloatItem::create()); + m_a12->setParent(this); + m_a12->setPropertyName(QLatin1String("A12")); + m_a12->setDecimals(decimals); + this->appendChild(m_a12); + m_a13 = static_cast(PropertyFloatItem::create()); + m_a13->setParent(this); + m_a13->setPropertyName(QLatin1String("A13")); + m_a13->setDecimals(decimals); + this->appendChild(m_a13); + m_a14 = static_cast(PropertyFloatItem::create()); + m_a14->setParent(this); + m_a14->setPropertyName(QLatin1String("A14")); + m_a14->setDecimals(decimals); + this->appendChild(m_a14); + m_a21 = static_cast(PropertyFloatItem::create()); + m_a21->setParent(this); + m_a21->setPropertyName(QLatin1String("A21")); + m_a21->setDecimals(decimals); + this->appendChild(m_a21); + m_a22 = static_cast(PropertyFloatItem::create()); + m_a22->setParent(this); + m_a22->setPropertyName(QLatin1String("A22")); + m_a22->setDecimals(decimals); + this->appendChild(m_a22); + m_a23 = static_cast(PropertyFloatItem::create()); + m_a23->setParent(this); + m_a23->setPropertyName(QLatin1String("A23")); + m_a23->setDecimals(decimals); + this->appendChild(m_a23); + m_a24 = static_cast(PropertyFloatItem::create()); + m_a24->setParent(this); + m_a24->setPropertyName(QLatin1String("A24")); + m_a24->setDecimals(decimals); + this->appendChild(m_a24); + m_a31 = static_cast(PropertyFloatItem::create()); + m_a31->setParent(this); + m_a31->setPropertyName(QLatin1String("A31")); + m_a31->setDecimals(decimals); + this->appendChild(m_a31); + m_a32 = static_cast(PropertyFloatItem::create()); + m_a32->setParent(this); + m_a32->setPropertyName(QLatin1String("A32")); + m_a32->setDecimals(decimals); + this->appendChild(m_a32); + m_a33 = static_cast(PropertyFloatItem::create()); + m_a33->setParent(this); + m_a33->setPropertyName(QLatin1String("A33")); + m_a33->setDecimals(decimals); + this->appendChild(m_a33); + m_a34 = static_cast(PropertyFloatItem::create()); + m_a34->setParent(this); + m_a34->setPropertyName(QLatin1String("A34")); + m_a34->setDecimals(decimals); + this->appendChild(m_a34); + m_a41 = static_cast(PropertyFloatItem::create()); + m_a41->setParent(this); + m_a41->setPropertyName(QLatin1String("A41")); + m_a41->setDecimals(decimals); + this->appendChild(m_a41); + m_a42 = static_cast(PropertyFloatItem::create()); + m_a42->setParent(this); + m_a42->setPropertyName(QLatin1String("A42")); + m_a42->setDecimals(decimals); + this->appendChild(m_a42); + m_a43 = static_cast(PropertyFloatItem::create()); + m_a43->setParent(this); + m_a43->setPropertyName(QLatin1String("A43")); + m_a43->setDecimals(decimals); + this->appendChild(m_a43); + m_a44 = static_cast(PropertyFloatItem::create()); + m_a44->setParent(this); + m_a44->setPropertyName(QLatin1String("A44")); + m_a44->setDecimals(decimals); + this->appendChild(m_a44); +} + +QVariant PropertyMatrixItem::toString(const QVariant& prop) const +{ + const Base::Matrix4D& value = prop.value(); + QString text = QString::fromAscii("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") + .arg(QLocale::system().toString(value[0][0], 'f', 2)) //(unsigned short usNdx) + .arg(QLocale::system().toString(value[0][1], 'f', 2)) + .arg(QLocale::system().toString(value[0][2], 'f', 2)) + .arg(QLocale::system().toString(value[0][3], 'f', 2)) + .arg(QLocale::system().toString(value[1][0], 'f', 2)) + .arg(QLocale::system().toString(value[1][1], 'f', 2)) + .arg(QLocale::system().toString(value[1][2], 'f', 2)) + .arg(QLocale::system().toString(value[1][3], 'f', 2)) + .arg(QLocale::system().toString(value[2][0], 'f', 2)) + .arg(QLocale::system().toString(value[2][1], 'f', 2)) + .arg(QLocale::system().toString(value[2][2], 'f', 2)) + .arg(QLocale::system().toString(value[2][3], 'f', 2)) + .arg(QLocale::system().toString(value[3][0], 'f', 2)) + .arg(QLocale::system().toString(value[3][1], 'f', 2)) + .arg(QLocale::system().toString(value[3][2], 'f', 2)) + .arg(QLocale::system().toString(value[3][3], 'f', 2)); + return QVariant(text); +} + +QVariant PropertyMatrixItem::value(const App::Property* prop) const +{ + assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId())); + + const Base::Matrix4D& value = static_cast(prop)->getValue(); + return QVariant::fromValue(value); +} + +QVariant PropertyMatrixItem::toolTip(const App::Property* prop) const +{ + assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId())); + + const Base::Matrix4D& value = static_cast(prop)->getValue(); + return QVariant(QString::fromStdString(value.analyse())); +} + +void PropertyMatrixItem::setValue(const QVariant& value) +{ + if (!value.canConvert()) + return; + const Base::Matrix4D& val = value.value(); + const int decimals=16; + QString data = QString::fromAscii("FreeCAD.Matrix(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)") + .arg(val[0][0],0, 'f', decimals) + .arg(val[0][1],0, 'f', decimals) + .arg(val[0][2],0, 'f', decimals) + .arg(val[0][3],0, 'f', decimals) + .arg(val[1][0],0, 'f', decimals) + .arg(val[1][1],0, 'f', decimals) + .arg(val[1][2],0, 'f', decimals) + .arg(val[1][3],0, 'f', decimals) + .arg(val[2][0],0, 'f', decimals) + .arg(val[2][1],0, 'f', decimals) + .arg(val[2][2],0, 'f', decimals) + .arg(val[2][3],0, 'f', decimals) + .arg(val[3][0],0, 'f', decimals) + .arg(val[3][1],0, 'f', decimals) + .arg(val[3][2],0, 'f', decimals) + .arg(val[3][3],0, 'f', decimals); + setPropertyValue(data); +} + +QWidget* PropertyMatrixItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const +{ + QLineEdit *le = new QLineEdit(parent); + le->setFrame(false); + le->setReadOnly(true); + return le; +} + +void PropertyMatrixItem::setEditorData(QWidget *editor, const QVariant& data) const +{ + QLineEdit* le = qobject_cast(editor); + const Base::Matrix4D& value = data.value(); + QString text = QString::fromAscii("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") + .arg(QLocale::system().toString(value[0][0], 'f', 2)) //(unsigned short usNdx) + .arg(QLocale::system().toString(value[0][1], 'f', 2)) + .arg(QLocale::system().toString(value[0][2], 'f', 2)) + .arg(QLocale::system().toString(value[0][3], 'f', 2)) + .arg(QLocale::system().toString(value[1][0], 'f', 2)) + .arg(QLocale::system().toString(value[1][1], 'f', 2)) + .arg(QLocale::system().toString(value[1][2], 'f', 2)) + .arg(QLocale::system().toString(value[1][3], 'f', 2)) + .arg(QLocale::system().toString(value[2][0], 'f', 2)) + .arg(QLocale::system().toString(value[2][1], 'f', 2)) + .arg(QLocale::system().toString(value[2][2], 'f', 2)) + .arg(QLocale::system().toString(value[2][3], 'f', 2)) + .arg(QLocale::system().toString(value[3][0], 'f', 2)) + .arg(QLocale::system().toString(value[3][1], 'f', 2)) + .arg(QLocale::system().toString(value[3][2], 'f', 2)) + .arg(QLocale::system().toString(value[3][3], 'f', 2)); + le->setText(text); +} + +QVariant PropertyMatrixItem::editorData(QWidget *editor) const +{ + QLineEdit *le = qobject_cast(editor); + return QVariant(le->text()); +} + +double PropertyMatrixItem::getA11() const +{ + return data(1,Qt::EditRole).value()[0][0]; +} + +void PropertyMatrixItem::setA11(double A11) +{ + setData(QVariant::fromValue(Base::Matrix4D(A11,getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA12() const +{ + return data(1,Qt::EditRole).value()[0][1]; +} + +void PropertyMatrixItem::setA12(double A12) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),A12,getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA13() const +{ + return data(1,Qt::EditRole).value()[0][2]; +} + +void PropertyMatrixItem::setA13(double A13) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),A13,getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA14() const +{ + return data(1,Qt::EditRole).value()[0][3]; +} + +void PropertyMatrixItem::setA14(double A14) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),A14,getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA21() const +{ + return data(1,Qt::EditRole).value()[1][0]; +} + +void PropertyMatrixItem::setA21(double A21) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),A21,getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA22() const +{ + return data(1,Qt::EditRole).value()[1][1]; +} + +void PropertyMatrixItem::setA22(double A22) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),A22,getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA23() const +{ + return data(1,Qt::EditRole).value()[1][2]; +} + +void PropertyMatrixItem::setA23(double A23) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),A23,getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA24() const +{ + return data(1,Qt::EditRole).value()[1][3]; +} + +void PropertyMatrixItem::setA24(double A24) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),A24,getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA31() const +{ + return data(1,Qt::EditRole).value()[2][0]; +} + +void PropertyMatrixItem::setA31(double A31) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),A31,getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA32() const +{ + return data(1,Qt::EditRole).value()[2][1]; +} + +void PropertyMatrixItem::setA32(double A32) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),A32,getA33(),getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA33() const +{ + return data(1,Qt::EditRole).value()[2][2]; +} + +void PropertyMatrixItem::setA33(double A33) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),A33,getA34(),getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA34() const +{ + return data(1,Qt::EditRole).value()[2][3]; +} + +void PropertyMatrixItem::setA34(double A34) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),A34,getA41(),getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA41() const +{ + return data(1,Qt::EditRole).value()[3][0]; +} + +void PropertyMatrixItem::setA41(double A41) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),A41,getA42(),getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA42() const +{ + return data(1,Qt::EditRole).value()[3][1]; +} + +void PropertyMatrixItem::setA42(double A42) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),A42,getA43(),getA44() ))); +} + +double PropertyMatrixItem::getA43() const +{ + return data(1,Qt::EditRole).value()[3][2]; +} + +void PropertyMatrixItem::setA43(double A43) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),A43,getA44() ))); +} + +double PropertyMatrixItem::getA44() const +{ + return data(1,Qt::EditRole).value()[3][3]; +} + +void PropertyMatrixItem::setA44(double A44) +{ + setData(QVariant::fromValue(Base::Matrix4D(getA11(),getA12(),getA13(),getA14(),getA21(),getA22(),getA23(),getA24(),getA31(),getA32(),getA33(),getA34(),getA41(),getA42(),getA43(),A44 ))); +} + // -------------------------------------------------------------------- PlacementEditor::PlacementEditor(const QString& name, QWidget * parent) diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index bc247966f..e9990136d 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,7 @@ Q_DECLARE_METATYPE(Base::Vector3f) Q_DECLARE_METATYPE(Base::Vector3d) +Q_DECLARE_METATYPE(Base::Matrix4D) Q_DECLARE_METATYPE(Base::Placement) namespace Gui { @@ -366,6 +368,92 @@ private: PropertyFloatItem* m_z; }; +class GuiExport PropertyMatrixItem: public PropertyItem +{ + Q_OBJECT + Q_PROPERTY(double A11 READ getA11 WRITE setA11 DESIGNABLE true USER true) + Q_PROPERTY(double A12 READ getA12 WRITE setA12 DESIGNABLE true USER true) + Q_PROPERTY(double A13 READ getA13 WRITE setA13 DESIGNABLE true USER true) + Q_PROPERTY(double A14 READ getA14 WRITE setA14 DESIGNABLE true USER true) + Q_PROPERTY(double A21 READ getA21 WRITE setA21 DESIGNABLE true USER true) + Q_PROPERTY(double A22 READ getA22 WRITE setA22 DESIGNABLE true USER true) + Q_PROPERTY(double A23 READ getA23 WRITE setA23 DESIGNABLE true USER true) + Q_PROPERTY(double A24 READ getA24 WRITE setA24 DESIGNABLE true USER true) + Q_PROPERTY(double A31 READ getA31 WRITE setA31 DESIGNABLE true USER true) + Q_PROPERTY(double A32 READ getA32 WRITE setA32 DESIGNABLE true USER true) + Q_PROPERTY(double A33 READ getA33 WRITE setA33 DESIGNABLE true USER true) + Q_PROPERTY(double A34 READ getA34 WRITE setA34 DESIGNABLE true USER true) + Q_PROPERTY(double A41 READ getA41 WRITE setA41 DESIGNABLE true USER true) + Q_PROPERTY(double A42 READ getA42 WRITE setA42 DESIGNABLE true USER true) + Q_PROPERTY(double A43 READ getA43 WRITE setA43 DESIGNABLE true USER true) + Q_PROPERTY(double A44 READ getA44 WRITE setA44 DESIGNABLE true USER true) + TYPESYSTEM_HEADER(); + + virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const; + virtual void setEditorData(QWidget *editor, const QVariant& data) const; + virtual QVariant editorData(QWidget *editor) const; + + double getA11() const; + void setA11(double A11); + double getA12() const; + void setA12(double A12); + double getA13() const; + void setA13(double A13); + double getA14() const; + void setA14(double A14); + double getA21() const; + void setA21(double A21); + double getA22() const; + void setA22(double A22); + double getA23() const; + void setA23(double A23); + double getA24() const; + void setA24(double A24); + double getA31() const; + void setA31(double A31); + double getA32() const; + void setA32(double A32); + double getA33() const; + void setA33(double A33); + double getA34() const; + void setA34(double A34); + double getA41() const; + void setA41(double A41); + double getA42() const; + void setA42(double A42); + double getA43() const; + void setA43(double A43); + double getA44() const; + void setA44(double A44); + +protected: + virtual QVariant toString(const QVariant&) const; + virtual QVariant value(const App::Property*) const; + virtual void setValue(const QVariant&); + +protected: + PropertyMatrixItem(); + virtual QVariant toolTip(const App::Property*) const; + +private: + PropertyFloatItem* m_a11; + PropertyFloatItem* m_a12; + PropertyFloatItem* m_a13; + PropertyFloatItem* m_a14; + PropertyFloatItem* m_a21; + PropertyFloatItem* m_a22; + PropertyFloatItem* m_a23; + PropertyFloatItem* m_a24; + PropertyFloatItem* m_a31; + PropertyFloatItem* m_a32; + PropertyFloatItem* m_a33; + PropertyFloatItem* m_a34; + PropertyFloatItem* m_a41; + PropertyFloatItem* m_a42; + PropertyFloatItem* m_a43; + PropertyFloatItem* m_a44; +}; + class PlacementEditor : public Gui::LabelButton { Q_OBJECT From 11620c4f4191f01716f09a5eb15d8e757b95df22 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Jun 2012 11:02:24 +0200 Subject: [PATCH 16/27] Expose Matrix4D::analyse to python --- src/Base/MatrixPy.xml | 8 ++++++++ src/Base/MatrixPyImp.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Base/MatrixPy.xml b/src/Base/MatrixPy.xml index 23b5b15e4..2ab7326b2 100644 --- a/src/Base/MatrixPy.xml +++ b/src/Base/MatrixPy.xml @@ -125,6 +125,14 @@ Get the sub-matrix. The parameter must be in the range [1,4]. + + + +analyze() -> string +Analyzes the type of transformation. + + + The matrix elements diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index a5408bb18..b7d594f54 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -474,6 +474,18 @@ PyObject* MatrixPy::transpose(PyObject * args) PY_CATCH; } +PyObject* MatrixPy::analyze(PyObject * args) +{ + if (!PyArg_ParseTuple(args, "")) + return NULL; + + PY_TRY { + std::string type = getMatrixPtr()->analyse(); + return PyString_FromString(type.c_str()); + } + PY_CATCH; +} + Py::Float MatrixPy::getA11(void) const { double val = (*this->getMatrixPtr())[0][0]; From 3259a16c298cb5a7b0bfb3ec4bfaad585133ec5a Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Jun 2012 12:52:17 +0200 Subject: [PATCH 17/27] Improve grapgviz integration --- src/Gui/CommandDoc.cpp | 99 ++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 33 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index a83d5ea5e..ae1be98eb 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -25,6 +25,8 @@ #ifndef _PreComp_ # include # include +# include +# include # include # include # include @@ -319,6 +321,28 @@ bool StdCmdMergeProjects::isActive(void) // Std_ExportGraphviz //=========================================================================== +namespace Gui { +class ImageView : public MDIView +{ +public: + ImageView(const QPixmap& p, QWidget* parent=0) : MDIView(0, parent) + { + scene = new QGraphicsScene(); + scene->addPixmap(p); + view = new QGraphicsView(scene, this); + view->show(); + setCentralWidget(view); + } + ~ImageView() + { + delete scene; + delete view; + } + QGraphicsScene* scene; + QGraphicsView* view; +}; +} + DEF_STD_CMD_A(StdCmdExportGraphviz); StdCmdExportGraphviz::StdCmdExportGraphviz() @@ -336,48 +360,57 @@ StdCmdExportGraphviz::StdCmdExportGraphviz() void StdCmdExportGraphviz::activated(int iMsg) { App::Document* doc = App::GetApplication().getActiveDocument(); - Base::FileInfo fi(Base::FileInfo::getTempFileName()); - Base::ofstream str(fi); + std::stringstream str; doc->exportGraphviz(str); - str.close(); - Base::FileInfo out(Base::FileInfo::getTempFileName()); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Paths"); QProcess proc; - QEventLoop loop; - QObject::connect(&proc, SIGNAL(finished(int, QProcess::ExitStatus)), - &loop, SLOT(quit())); QStringList args; - args << QLatin1String("-Tpng") << QString::fromUtf8(fi.filePath().c_str()) - << QLatin1String("-o") << QString::fromUtf8(out.filePath().c_str()); - QString exe = QLatin1String("dot"); - QStringList env = QProcess::systemEnvironment(); - proc.setEnvironment(env); - proc.start(exe, args); - if (proc.state() == QProcess::Running) { - loop.exec(); - fi.deleteFile(); - } - else { - QMessageBox::warning(getMainWindow(), - qApp->translate("Std_ExportGraphviz","Graphviz not found"), - qApp->translate("Std_ExportGraphviz","Graphviz couldn't be found on your system")); - fi.deleteFile(); - return; + args << QLatin1String("-Tpng"); + QString path = QString::fromUtf8(hGrp->GetASCII("Graphviz").c_str()); + bool pathChanged = false; + QString exe = QString::fromAscii("\"%1/dot\"").arg(path); + proc.setEnvironment(QProcess::systemEnvironment()); + do { + proc.start(exe, args); + if (!proc.waitForStarted()) { + int ret = QMessageBox::warning(getMainWindow(), + qApp->translate("Std_ExportGraphviz","Graphviz not found"), + qApp->translate("Std_ExportGraphviz","Graphviz couldn't be found on your system.\n" + "Do you want to specify its installation path if it's already installed?"), + QMessageBox::Yes, QMessageBox::No); + if (ret == QMessageBox::No) + return; + path = QFileDialog::getExistingDirectory(Gui::getMainWindow(), + qApp->translate("Std_ExportGraphviz","Graphviz installation path")); + if (path.isEmpty()) + return; + pathChanged = true; + exe = QString::fromAscii("\"%1/dot\"").arg(path); + } + else { + if (pathChanged) + hGrp->SetASCII("Graphviz", (const char*)path.toUtf8()); + break; + } } + while(true); - if (out.exists()) { - QPixmap px(QString::fromUtf8(out.filePath().c_str()), "PNG"); - out.deleteFile(); - QLabel* label = new QLabel(0); - label->setAttribute(Qt::WA_DeleteOnClose); - label->setPixmap(px); - label->resize(px.size()); - label->show(); + proc.write(str.str().c_str(), str.str().size()); + proc.closeWriteChannel(); + if (!proc.waitForFinished()) + return; + + QPixmap px; + if (px.loadFromData(proc.readAll(), "PNG")) { + Gui::ImageView* view = new Gui::ImageView(px); + view->setWindowTitle(qApp->translate("Std_ExportGraphviz","Dependency graph")); + getMainWindow()->addWindow(view); } else { QMessageBox::warning(getMainWindow(), - qApp->translate("Std_ExportGraphviz","Graphviz failed"), - qApp->translate("Std_ExportGraphviz","Graphviz failed to create an image file")); + qApp->translate("Std_ExportGraphviz","Graphviz failed"), + qApp->translate("Std_ExportGraphviz","Graphviz failed to create an image file")); } } From de4e9a1d115fc2ca7dea3291d968cc724e38645e Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Jun 2012 14:07:47 +0200 Subject: [PATCH 18/27] Support sample buffers --- src/Gui/CommandDoc.cpp | 2 ++ src/Gui/View3DInventor.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index ae1be98eb..c7ea796cb 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -26,6 +26,8 @@ # include # include # include +# include +# include # include # include # include diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 8d354c937..e1f035a4a 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -32,6 +32,8 @@ # include # include # include +# include +# include # include # include # include @@ -299,6 +301,29 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M else if (strcmp(Reason,"UseAntialiasing") == 0) { _viewer->getGLRenderAction()->setSmoothing(rGrp.GetBool("UseAntialiasing",false)); } + else if (strcmp(Reason,"SampleBuffers") == 0) { +#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5) + _viewer->setSampleBuffers(rGrp.GetInt("SampleBuffers",4)); +#else + // http://stackoverflow.com/questions/4207506/where-is-gl-multisample-defined + //int sb = rGrp.GetInt("SampleBuffers",4); + //QGLWidget* gl = static_cast(_viewer->getGLWidget()); + //QGLFormat fmt = gl->format(); + //if (sb > 0) { + // fmt.setSampleBuffers(true); + // fmt.setSamples(sb); + // gl->setFormat(fmt); + // gl->makeCurrent(); + // //glEnable(GL_MULTISAMPLE); + //} + //else { + // fmt.setSampleBuffers(false); + // gl->setFormat(fmt); + // gl->makeCurrent(); + // //glDisable(GL_MULTISAMPLE); + //} +#endif + } else if (strcmp(Reason,"ShowFPS") == 0) { _viewer->setEnabledFPSCounter(rGrp.GetBool("ShowFPS",false)); } From b4aff85333b62ca6381b50cf3b3f828191ef16c0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Jun 2012 18:49:10 +0200 Subject: [PATCH 19/27] Fix critical warnings --- src/Base/BoundBoxPyImp.cpp | 2 +- src/Gui/CommandView.cpp | 5 +- src/Mod/Drawing/App/ProjectionAlgos.cpp | 14 +- src/Mod/Drawing/Gui/TaskOrthoViews.cpp | 31 +- src/Mod/Fem/App/FemMesh.cpp | 2 +- src/Mod/Import/Gui/AppImportGuiPy.cpp | 2 +- src/Mod/Mesh/App/Core/Algorithm.cpp | 27 +- src/Mod/Mesh/App/Core/Curvature.cpp | 2 +- src/Mod/Mesh/App/Core/MeshIO.cpp | 2 +- src/Mod/Mesh/App/Core/Trim.cpp | 2 +- src/Mod/Part/App/ImportIges.cpp | 2 +- src/Mod/Part/App/TopoShape.cpp | 4 +- src/Mod/Part/Gui/Command.cpp | 3 + src/Mod/Part/Gui/DlgPrimitives.cpp | 295 +++++++++--------- src/Mod/PartDesign/App/FeaturePocket.cpp | 2 +- src/Mod/PartDesign/Gui/TaskPadParameters.cpp | 2 +- .../PartDesign/Gui/TaskPocketParameters.cpp | 2 +- src/Mod/Sketcher/App/ConstraintPyImp.cpp | 2 +- src/Mod/Web/Gui/BrowserView.cpp | 2 +- 19 files changed, 204 insertions(+), 199 deletions(-) diff --git a/src/Base/BoundBoxPyImp.cpp b/src/Base/BoundBoxPyImp.cpp index 63dc76378..8a6d4e132 100644 --- a/src/Base/BoundBoxPyImp.cpp +++ b/src/Base/BoundBoxPyImp.cpp @@ -192,7 +192,6 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject *args) *(static_cast(object2)->getVectorPtr()), point, epsilon); // IsInBox() doesn't handle border points correctly - BoundBoxPy::PointerType bb = getBoundBoxPtr(); if (ok) { return new VectorPy(point); } @@ -209,6 +208,7 @@ PyObject* BoundBoxPy::move(PyObject *args) { double x,y,z; PyObject *object; + Base::Vector3d vec; if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) { diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 33da94c7c..4399325dd 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -452,6 +452,7 @@ void StdCmdFreezeViews::languageChange() } } + //=========================================================================== // Std_ToggleClipPlane //=========================================================================== @@ -522,8 +523,8 @@ Gui::Action * StdCmdDrawStyle::createAction(void) pcAction->setDropDownMenu(true); applyCommandData(pcAction); - QAction* a0 = pcAction->addAction(QString()); - QAction* a1 = pcAction->addAction(QString()); + pcAction->addAction(QString()); + pcAction->addAction(QString()); _pcAction = pcAction; languageChange(); return pcAction; diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index a5f844619..b37c6cb48 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -263,7 +263,7 @@ std::string ProjectionAlgos::getDXF(SvgExtractionType type, float scale) << "ENTITIES" << endl; if (!H.IsNull() && (type & WithHidden)) { - float width = 0.15f/scale; + //float width = 0.15f/scale; BRepMesh::Mesh(H,0.1); result //<< "" << endl; } if (!HO.IsNull() && (type & WithHidden)) { - float width = 0.15f/scale; + //float width = 0.15f/scale; BRepMesh::Mesh(HO,0.1); result //<< "" << endl; } if (!VO.IsNull()) { - float width = 0.35f/scale; + //float width = 0.35f/scale; BRepMesh::Mesh(VO,0.1); result //<< "" << endl; } if (!V.IsNull()) { - float width = 0.35f/scale; - + //float width = 0.35f/scale; BRepMesh::Mesh(V,0.1); result //<< "" << endl; } if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) { - - float width = 0.15f/scale; + //float width = 0.15f/scale; BRepMesh::Mesh(H1,0.1); result //<< " #include #include -#include +#include #include #include @@ -301,7 +301,7 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent) App::Document* doc = App::GetApplication().getActiveDocument(); std::vector pages = doc->getObjectsOfType(Drawing::FeaturePage::getClassTypeId()); - std::string PageName = pages.front()->getNameInDocument(); + std::string PageName = pages.front()->getNameInDocument(); const char * page = PageName.c_str(); App::DocumentObject * this_page = doc->getObject(page); @@ -409,7 +409,7 @@ TaskOrthoViews::TaskOrthoViews(QWidget *parent) data[1] = &x_pos; data[2] = &y_pos; data[3] = &horiz; - data[4] = | + data[4] = | // Command::doCommand(Command::Doc,"#%d", map1[2][2][1]); @@ -636,24 +636,24 @@ void TaskOrthoViews::compute() void TaskOrthoViews::validate_cbs() { - for (int i=0; i < 5; i++) - for (int j=0; j < 5; j++) - if ((abs(i-2) + abs(j-2)) < 3) //if i,j combination corresponds to valid check box, then proceed with: + for (int i=0; i < 5; i++) { + for (int j=0; j < 5; j++) { + if ((abs(i-2) + abs(j-2)) < 3) { //if i,j combination corresponds to valid check box, then proceed with: if (view_count == 0) { c_boxes[i][j]->setEnabled(false); c_boxes[i][j]->setChecked(false); } - else if (!c_boxes[i][j]->isChecked()) //only questions boxes 'enableability' if it's not checked - if (view_count == 4) + else if (!c_boxes[i][j]->isChecked()) { //only questions boxes 'enableability' if it's not checked + if (view_count == 4) { c_boxes[i][j]->setEnabled(false); //if there are four checked boxes then all others are disabled - else - { - if ((abs(i-2) + abs(j-2)) == 1) //only true for boxes immediately up/down/left/right of centre + } + else { + if ((abs(i-2) + abs(j-2)) == 1) { //only true for boxes immediately up/down/left/right of centre c_boxes[i][j]->setEnabled(c_boxes[2][2]->isChecked()); //which are enabled if centre box is checked - else - { + } + else { int di = ((i-2) < 0) - ((i-2) > 0); //which direction is towards centre? int dj = ((j-2) < 0) - ((j-2) > 0); @@ -668,9 +668,12 @@ void TaskOrthoViews::validate_cbs() c_boxes[i][j]->setEnabled(false); } } + } + } + } + } } - void TaskOrthoViews::cb_toggled(bool toggle) { QString name = sender()->objectName().right(2); diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index 440b5cb01..a3c98e586 100644 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -99,7 +99,7 @@ FemMesh &FemMesh::operator=(const FemMesh& mesh) void FemMesh::copyMeshData(const FemMesh& mesh) { - const SMDS_MeshInfo& info = mesh.myMesh->GetMeshDS()->GetMeshInfo(); + //const SMDS_MeshInfo& info = mesh.myMesh->GetMeshDS()->GetMeshInfo(); //int numPoly = info.NbPolygons(); //int numVolu = info.NbVolumes(); //int numTetr = info.NbTetras(); diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 8edbcada5..d98a299d3 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -26,8 +26,8 @@ # define WNT // avoid conflict with GUID #endif #ifndef _PreComp_ -# include # include +# include # include # include # include diff --git a/src/Mod/Mesh/App/Core/Algorithm.cpp b/src/Mod/Mesh/App/Core/Algorithm.cpp index 281fba7f7..f72bba760 100644 --- a/src/Mod/Mesh/App/Core/Algorithm.cpp +++ b/src/Mod/Mesh/App/Core/Algorithm.cpp @@ -641,8 +641,8 @@ bool MeshAlgorithm::FillupHole(const std::vector& boundary, bool ready = false; for (MeshFacetArray::_TConstIterator it = _rclMesh._aclFacetArray.begin(); it != _rclMesh._aclFacetArray.end(); ++it) { for (int i=0; i<3; i++) { - if ((it->_aulPoints[i] == refPoint0) && (it->_aulPoints[(i+1)%3] == refPoint1) || - (it->_aulPoints[i] == refPoint1) && (it->_aulPoints[(i+1)%3] == refPoint0)) { + if (((it->_aulPoints[i] == refPoint0) && (it->_aulPoints[(i+1)%3] == refPoint1)) || + ((it->_aulPoints[i] == refPoint1) && (it->_aulPoints[(i+1)%3] == refPoint0))) { rFace = *it; rTriangle = _rclMesh.GetFacet(*it); ready = true; @@ -1527,6 +1527,7 @@ bool MeshAlgorithm::ConnectLines (std::list_aulPoints[0]]; - const MeshPoint &p1 = rPoints[pF->_aulPoints[1]]; - const MeshPoint &p2 = rPoints[pF->_aulPoints[2]]; - float l2p01 = Base::DistanceP2(p0,p1); - float l2p12 = Base::DistanceP2(p1,p2); - float l2p20 = Base::DistanceP2(p2,p0); - - Base::Vector3f facenormal = _rclMesh.GetFacet(*pF).GetNormal(); - _norm[pF->_aulPoints[0]] += facenormal * (1.0f / (l2p01 * l2p20)); - _norm[pF->_aulPoints[1]] += facenormal * (1.0f / (l2p12 * l2p01)); - _norm[pF->_aulPoints[2]] += facenormal * (1.0f / (l2p20 * l2p12)); + const MeshPoint &p0 = rPoints[pF->_aulPoints[0]]; + const MeshPoint &p1 = rPoints[pF->_aulPoints[1]]; + const MeshPoint &p2 = rPoints[pF->_aulPoints[2]]; + float l2p01 = Base::DistanceP2(p0,p1); + float l2p12 = Base::DistanceP2(p1,p2); + float l2p20 = Base::DistanceP2(p2,p0); + + Base::Vector3f facenormal = _rclMesh.GetFacet(*pF).GetNormal(); + _norm[pF->_aulPoints[0]] += facenormal * (1.0f / (l2p01 * l2p20)); + _norm[pF->_aulPoints[1]] += facenormal * (1.0f / (l2p12 * l2p01)); + _norm[pF->_aulPoints[2]] += facenormal * (1.0f / (l2p20 * l2p12)); } for (std::vector::iterator it = _norm.begin(); it != _norm.end(); ++it) it->Normalize(); diff --git a/src/Mod/Mesh/App/Core/Curvature.cpp b/src/Mod/Mesh/App/Core/Curvature.cpp index d0371da4b..93a0234e4 100644 --- a/src/Mod/Mesh/App/Core/Curvature.cpp +++ b/src/Mod/Mesh/App/Core/Curvature.cpp @@ -151,7 +151,7 @@ private: // -------------------------------------------------------- FacetCurvature::FacetCurvature(const MeshKernel& kernel, const MeshRefPointToFacets& search, float r, unsigned long pt) - : myKernel(kernel), mySearch(search), myRadius(r), myMinPoints(pt) + : myKernel(kernel), mySearch(search), myMinPoints(pt), myRadius(r) { } diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index 4003e019c..7d7024771 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -544,7 +544,6 @@ bool MeshInput::LoadOFF (std::istream &rstrIn) if (!buf) return false; - bool readvertices=false; std::getline(rstrIn, line); boost::algorithm::to_lower(line); if (line.find("off") == std::string::npos) @@ -2315,6 +2314,7 @@ bool MeshVRML::Save (std::ostream &rstrOut, const std::vector &raclC MeshFacetIterator pFIter(_rclMesh); pFIter.Transform(this->_transform); i = 0, k = _rclMesh.CountFacets(); + for (pFIter.Init(); pFIter.More(); pFIter.Next()) { MeshFacet clFacet = pFIter.GetIndices(); rstrOut << " " diff --git a/src/Mod/Mesh/App/Core/Trim.cpp b/src/Mod/Mesh/App/Core/Trim.cpp index 7d94592a8..27a64c156 100644 --- a/src/Mod/Mesh/App/Core/Trim.cpp +++ b/src/Mod/Mesh/App/Core/Trim.cpp @@ -32,7 +32,7 @@ using namespace MeshCore; MeshTrimming::MeshTrimming(MeshKernel &rclM, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly) - : myMesh(rclM), myProj(pclProj), myPoly(rclPoly), myInner(true) + : myMesh(rclM), myInner(true), myProj(pclProj), myPoly(rclPoly) { } diff --git a/src/Mod/Part/App/ImportIges.cpp b/src/Mod/Part/App/ImportIges.cpp index 98cb5393f..e8030ee22 100644 --- a/src/Mod/Part/App/ImportIges.cpp +++ b/src/Mod/Part/App/ImportIges.cpp @@ -95,7 +95,7 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName) // make model aReader.ClearShapes(); - Standard_Integer nbRootsForTransfer = aReader.NbRootsForTransfer(); + //Standard_Integer nbRootsForTransfer = aReader.NbRootsForTransfer(); aReader.TransferRoots(); pi->EndScope(); diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 9bf487074..f40916e5b 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1403,7 +1403,7 @@ TopoDS_Shape TopoShape::makeTube(double radius, double tol, int cont, int maxdeg { // http://opencascade.blogspot.com/2009/11/surface-modeling-part3.html Standard_Real theTol = tol; - Standard_Boolean theIsPolynomial = Standard_True; + //Standard_Boolean theIsPolynomial = Standard_True; Standard_Boolean myIsElem = Standard_True; GeomAbs_Shape theContinuity = GeomAbs_Shape(cont); Standard_Integer theMaxDegree = maxdegree; @@ -1445,7 +1445,7 @@ TopoDS_Shape TopoShape::makeTube(double radius, double tol, int cont, int maxdeg mkSweep.Build (aSec, GeomFill_Location, theContinuity, theMaxDegree, theMaxSegment); if (mkSweep.IsDone()) { Handle_Geom_Surface mySurface = mkSweep.Surface(); - Standard_Real myError = mkSweep.ErrorOnSurface(); + //Standard_Real myError = mkSweep.ErrorOnSurface(); Standard_Real u1,u2,v1,v2; mySurface->Bounds(u1,u2,v1,v2); diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index 60d199d9c..edd0c41e6 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -664,6 +664,7 @@ DEF_STD_CMD_A(CmdPartReverseShape); CmdPartReverseShape::CmdPartReverseShape() :Command("Part_ReverseShape") { + sAppModule = "Part"; sGroup = QT_TR_NOOP("Part"); sMenuText = QT_TR_NOOP("Reverse shapes"); @@ -1008,6 +1009,7 @@ CmdShapeInfo::CmdShapeInfo() void CmdShapeInfo::activated(int iMsg) { +#if 0 static const char * const part_pipette[]={ "32 32 17 1", "# c #000000", @@ -1062,6 +1064,7 @@ void CmdShapeInfo::activated(int iMsg) Gui::Document* doc = Gui::Application::Instance->activeDocument(); Gui::View3DInventor* view = static_cast(doc->getActiveView()); +#endif //if (view) { // Gui::View3DInventorViewer* viewer = view->getViewer(); // viewer->setEditing(true); diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index 3665dd196..3e4628646 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include "DlgPrimitives.h" @@ -55,43 +55,43 @@ using namespace PartGui; namespace PartGui { - -const char* gce_ErrorStatusText(gce_ErrorType et) -{ - switch (et) - { - case gce_Done: - return "Construction was successful"; - case gce_ConfusedPoints: - return "Two points are coincident"; - case gce_NegativeRadius: - return "Radius value is negative"; - case gce_ColinearPoints: - return "Three points are collinear"; - case gce_IntersectionError: - return "Intersection cannot be computed"; - case gce_NullAxis: - return "Axis is undefined"; - case gce_NullAngle: - return "Angle value is invalid (usually null)"; - case gce_NullRadius: - return "Radius is null"; - case gce_InvertAxis: - return "Axis value is invalid"; - case gce_BadAngle: - return "Angle value is invalid"; - case gce_InvertRadius: - return "Radius value is incorrect (usually with respect to another radius)"; - case gce_NullFocusLength: - return "Focal distance is null"; - case gce_NullVector: - return "Vector is null"; - case gce_BadEquation: - return "Coefficients are incorrect (applies to the equation of a geometric object)"; - default: - return "Creation of geometry failed"; - } -} + +const char* gce_ErrorStatusText(gce_ErrorType et) +{ + switch (et) + { + case gce_Done: + return "Construction was successful"; + case gce_ConfusedPoints: + return "Two points are coincident"; + case gce_NegativeRadius: + return "Radius value is negative"; + case gce_ColinearPoints: + return "Three points are collinear"; + case gce_IntersectionError: + return "Intersection cannot be computed"; + case gce_NullAxis: + return "Axis is undefined"; + case gce_NullAngle: + return "Angle value is invalid (usually null)"; + case gce_NullRadius: + return "Radius is null"; + case gce_InvertAxis: + return "Axis value is invalid"; + case gce_BadAngle: + return "Angle value is invalid"; + case gce_InvertRadius: + return "Radius value is incorrect (usually with respect to another radius)"; + case gce_NullFocusLength: + return "Focal distance is null"; + case gce_NullVector: + return "Vector is null"; + case gce_BadEquation: + return "Coefficients are incorrect (applies to the equation of a geometric object)"; + default: + return "Creation of geometry failed"; + } +} void Picker::createPrimitive(QWidget* widget, const QString& descr, Gui::Document* doc) { @@ -113,17 +113,17 @@ void Picker::createPrimitive(QWidget* widget, const QString& descr, Gui::Documen QString Picker::toPlacement(const gp_Ax2& axis) const { - gp_Dir dir = axis.Direction(); - gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); - gp_Ax3 ax3(pnt, dir, axis.XDirection()); - - gp_Trsf Trf; - Trf.SetTransformation(ax3); - Trf.Invert(); - - gp_XYZ theAxis(0,0,1); - Standard_Real theAngle = 0.0; - Trf.GetRotation(theAxis,theAngle); + gp_Dir dir = axis.Direction(); + gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); + gp_Ax3 ax3(pnt, dir, axis.XDirection()); + + gp_Trsf Trf; + Trf.SetTransformation(ax3); + Trf.Invert(); + + gp_XYZ theAxis(0,0,1); + Standard_Real theAngle = 0.0; + Trf.GetRotation(theAxis,theAngle); Base::Rotation rot(Base::convertTo(theAxis), theAngle); gp_Pnt loc = axis.Location(); @@ -153,10 +153,10 @@ public: QString command(App::Document* doc) const { GC_MakeArcOfCircle arc(points[0], points[1], points[2]); - if (!arc.IsDone()) - throw Base::Exception(gce_ErrorStatusText(arc.Status())); - Handle_Geom_TrimmedCurve trim = arc.Value(); - Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); + if (!arc.IsDone()) + throw Base::Exception(gce_ErrorStatusText(arc.Status())); + Handle_Geom_TrimmedCurve trim = arc.Value(); + Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve()); QString name = QString::fromAscii(doc->getUniqueObjectName("Circle").c_str()); return QString::fromAscii( @@ -270,7 +270,6 @@ DlgPrimitives::~DlgPrimitives() void DlgPrimitives::pickCallback(void * ud, SoEventCallback * n) { const SoMouseButtonEvent * mbe = static_cast(n->getEvent()); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->setHandled(); @@ -569,18 +568,18 @@ void DlgPrimitives::createPrimitive(const QString& placement) .arg(ui.comboBox1->currentText()), QString::fromLatin1(e.what())); } } - -// ---------------------------------------------- - -/* TRANSLATOR PartGui::Location */ - -Location::Location(QWidget* parent) -{ - ui.setupUi(this); -} - -Location::~Location() -{ + +// ---------------------------------------------- + +/* TRANSLATOR PartGui::Location */ + +Location::Location(QWidget* parent) +{ + ui.setupUi(this); +} + +Location::~Location() +{ // no need to delete child widgets, Qt does it all for us if (!this->activeView.isNull()) { Gui::View3DInventorViewer* viewer = static_cast @@ -589,7 +588,7 @@ Location::~Location() viewer->setRedirectToSceneGraph(false); viewer->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), pickCallback,this); } -} +} void Location::on_viewPositionButton_clicked() { @@ -643,46 +642,46 @@ void Location::pickCallback(void * ud, SoEventCallback * n) QString Location::toPlacement() const { Base::Vector3f d = ui.loc->getDirection(); - gp_Dir dir = gp_Dir(d.x,d.y,d.z); - gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); - gp_Ax3 ax3; - - double cosNX = dir.Dot(gp::DX()); - double cosNY = dir.Dot(gp::DY()); - double cosNZ = dir.Dot(gp::DZ()); - std::vector cosXYZ; - cosXYZ.push_back(fabs(cosNX)); - cosXYZ.push_back(fabs(cosNY)); - cosXYZ.push_back(fabs(cosNZ)); - - int pos = std::max_element(cosXYZ.begin(), cosXYZ.end()) - cosXYZ.begin(); - - // +X/-X - if (pos == 0) { - if (cosNX > 0) - ax3 = gp_Ax3(pnt, dir, gp_Dir(0,1,0)); - else - ax3 = gp_Ax3(pnt, dir, gp_Dir(0,-1,0)); - } - // +Y/-Y - else if (pos == 1) { - if (cosNY > 0) - ax3 = gp_Ax3(pnt, dir, gp_Dir(0,0,1)); - else - ax3 = gp_Ax3(pnt, dir, gp_Dir(0,0,-1)); - } - // +Z/-Z - else { - ax3 = gp_Ax3(pnt, dir, gp_Dir(1,0,0)); - } - - gp_Trsf Trf; - Trf.SetTransformation(ax3); - Trf.Invert(); - - gp_XYZ theAxis(0,0,1); - Standard_Real theAngle = 0.0; - Trf.GetRotation(theAxis,theAngle); + gp_Dir dir = gp_Dir(d.x,d.y,d.z); + gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); + gp_Ax3 ax3; + + double cosNX = dir.Dot(gp::DX()); + double cosNY = dir.Dot(gp::DY()); + double cosNZ = dir.Dot(gp::DZ()); + std::vector cosXYZ; + cosXYZ.push_back(fabs(cosNX)); + cosXYZ.push_back(fabs(cosNY)); + cosXYZ.push_back(fabs(cosNZ)); + + int pos = std::max_element(cosXYZ.begin(), cosXYZ.end()) - cosXYZ.begin(); + + // +X/-X + if (pos == 0) { + if (cosNX > 0) + ax3 = gp_Ax3(pnt, dir, gp_Dir(0,1,0)); + else + ax3 = gp_Ax3(pnt, dir, gp_Dir(0,-1,0)); + } + // +Y/-Y + else if (pos == 1) { + if (cosNY > 0) + ax3 = gp_Ax3(pnt, dir, gp_Dir(0,0,1)); + else + ax3 = gp_Ax3(pnt, dir, gp_Dir(0,0,-1)); + } + // +Z/-Z + else { + ax3 = gp_Ax3(pnt, dir, gp_Dir(1,0,0)); + } + + gp_Trsf Trf; + Trf.SetTransformation(ax3); + Trf.Invert(); + + gp_XYZ theAxis(0,0,1); + Standard_Real theAngle = 0.0; + Trf.GetRotation(theAxis,theAngle); Base::Rotation rot(Base::convertTo(theAxis), theAngle); Base::Vector3f loc = ui.loc->getPosition(); @@ -696,52 +695,52 @@ QString Location::toPlacement() const .arg(rot[2],0,'f',2) .arg(rot[3],0,'f',2); } - -// ---------------------------------------------- - -/* TRANSLATOR PartGui::TaskPrimitives */ - -TaskPrimitives::TaskPrimitives() -{ - Gui::TaskView::TaskBox* taskbox; - widget = new DlgPrimitives(); - taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(),true, 0); - taskbox->groupLayout()->addWidget(widget); - Content.push_back(taskbox); - - location = new Location(); - taskbox = new Gui::TaskView::TaskBox(QPixmap(), location->windowTitle(),true, 0); - taskbox->groupLayout()->addWidget(location); - taskbox->hideGroupBox(); - Content.push_back(taskbox); -} - -TaskPrimitives::~TaskPrimitives() -{ - // automatically deleted in the sub-class -} - -QDialogButtonBox::StandardButtons TaskPrimitives::getStandardButtons() const -{ - return QDialogButtonBox::Close| - QDialogButtonBox::Ok; -} + +// ---------------------------------------------- + +/* TRANSLATOR PartGui::TaskPrimitives */ + +TaskPrimitives::TaskPrimitives() +{ + Gui::TaskView::TaskBox* taskbox; + widget = new DlgPrimitives(); + taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(),true, 0); + taskbox->groupLayout()->addWidget(widget); + Content.push_back(taskbox); + + location = new Location(); + taskbox = new Gui::TaskView::TaskBox(QPixmap(), location->windowTitle(),true, 0); + taskbox->groupLayout()->addWidget(location); + taskbox->hideGroupBox(); + Content.push_back(taskbox); +} + +TaskPrimitives::~TaskPrimitives() +{ + // automatically deleted in the sub-class +} + +QDialogButtonBox::StandardButtons TaskPrimitives::getStandardButtons() const +{ + return QDialogButtonBox::Close| + QDialogButtonBox::Ok; +} void TaskPrimitives::modifyStandardButtons(QDialogButtonBox* box) { QPushButton* btn = box->button(QDialogButtonBox::Ok); btn->setText(QApplication::translate("PartGui::DlgPrimitives", "&Create")); } - -bool TaskPrimitives::accept() -{ - widget->createPrimitive(location->toPlacement()); - return false; -} - -bool TaskPrimitives::reject() -{ - return true; -} + +bool TaskPrimitives::accept() +{ + widget->createPrimitive(location->toPlacement()); + return false; +} + +bool TaskPrimitives::reject() +{ + return true; +} #include "moc_DlgPrimitives.cpp" diff --git a/src/Mod/PartDesign/App/FeaturePocket.cpp b/src/Mod/PartDesign/App/FeaturePocket.cpp index a0ef1cdd4..beec62191 100644 --- a/src/Mod/PartDesign/App/FeaturePocket.cpp +++ b/src/Mod/PartDesign/App/FeaturePocket.cpp @@ -178,7 +178,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void) it_near = it; upToFace = (std::string(Type.getValueAsString()) == "UpToLast" ? it_far->face : it_near->face); } else { - if (FaceName.getValue() == "") + if (FaceName.isEmpty()) return new App::DocumentObjectExecReturn("Cannot extrude up to face: No face selected"); // Get active object, this is the object that the user referenced when he clicked on the face! diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index d7c37b7b3..c28e35f5a 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -92,7 +92,7 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent) // According to bug #0000521 the reversed option // shouldn't be de-activated if the pad has a support face ui->checkBoxReversed->setChecked(reversed); - ui->lineFaceName->setText(upToFace == "" ? tr("No face selected") : tr(upToFace)); + ui->lineFaceName->setText(pcPad->FaceName.isEmpty() ? tr("No face selected") : tr(upToFace)); ui->changeMode->clear(); ui->changeMode->insertItem(0, tr("Dimension")); ui->changeMode->insertItem(1, tr("To last")); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 2122bafd1..cfa9f7155 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -86,7 +86,7 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge ui->lineFaceName->setEnabled(false); } else if (index == 4) { // Only this option requires to select a face ui->doubleSpinBox->setEnabled(false); - ui->lineFaceName->setText(upToFace == "" ? tr("No face selected") : tr(upToFace)); + ui->lineFaceName->setText(pcPocket->FaceName.isEmpty() ? tr("No face selected") : tr(upToFace)); } else { // Neither value nor face required ui->doubleSpinBox->setEnabled(false); ui->lineFaceName->setEnabled(false); diff --git a/src/Mod/Sketcher/App/ConstraintPyImp.cpp b/src/Mod/Sketcher/App/ConstraintPyImp.cpp index 7dad2b759..3a9ee1782 100644 --- a/src/Mod/Sketcher/App/ConstraintPyImp.cpp +++ b/src/Mod/Sketcher/App/ConstraintPyImp.cpp @@ -51,7 +51,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) int SecondIndex= Constraint::GeoUndef; int SecondPos = none; int ThirdIndex = Constraint::GeoUndef; - int ThirdPos = none; + //int ThirdPos = none; double Value = 0; // Note: In Python 2.x PyArg_ParseTuple prints a warning if a float is given but an integer is expected. // This means we must use a PyObject and check afterwards if it's a float or integer. diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 7410edc1d..81c02dd8b 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -182,7 +182,7 @@ bool BrowserView::chckHostAllowed(const QString& host) void BrowserView::onDownloadRequested(const QNetworkRequest & request) { Dialog::DownloadDialog dlg (request.url(),this); - int result = dlg.exec(); + dlg.exec(); } void BrowserView::load(const char* URL) From 02bbb1f12d554ed9d424eb04a70c3ec95544a4c2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Jun 2012 19:39:37 +0200 Subject: [PATCH 20/27] Fix issue with non-starting executable --- src/Gui/CommandDoc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index c7ea796cb..3d728e394 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -369,9 +369,17 @@ void StdCmdExportGraphviz::activated(int iMsg) QProcess proc; QStringList args; args << QLatin1String("-Tpng"); +#ifdef FC_OS_LINUX + QString path = QString::fromUtf8(hGrp->GetASCII("Graphviz", "/usr/bin").c_str()); +#else QString path = QString::fromUtf8(hGrp->GetASCII("Graphviz").c_str()); +#endif bool pathChanged = false; +#ifdef FC_OS_WIN32 QString exe = QString::fromAscii("\"%1/dot\"").arg(path); +#else + QString exe = QString::fromAscii("%1/dot").arg(path); +#endif proc.setEnvironment(QProcess::systemEnvironment()); do { proc.start(exe, args); @@ -388,7 +396,11 @@ void StdCmdExportGraphviz::activated(int iMsg) if (path.isEmpty()) return; pathChanged = true; +#ifdef FC_OS_WIN32 exe = QString::fromAscii("\"%1/dot\"").arg(path); +#else + exe = QString::fromAscii("%1/dot").arg(path); +#endif } else { if (pathChanged) From f6cf5227ed98979dda9abd7d8b0b80a5f6413d97 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 13:01:07 +0200 Subject: [PATCH 21/27] 0000749: PI was not declared in this scope - compile error --- src/Mod/Drawing/App/PreCompiled.h | 1 - src/Mod/Fem/App/AppFemPy.cpp | 17 +++++++++-------- src/Mod/Part/App/FeatureRevolution.cpp | 4 ++-- src/Mod/Part/App/PrimitiveFeature.cpp | 16 ++++++++-------- src/Mod/Part/App/TopoShape.cpp | 16 ++++++++++------ src/Mod/Part/Gui/DlgSettingsGeneral.ui | 2 +- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/Mod/Drawing/App/PreCompiled.h b/src/Mod/Drawing/App/PreCompiled.h index 2bffecf1d..bb3d325c9 100644 --- a/src/Mod/Drawing/App/PreCompiled.h +++ b/src/Mod/Drawing/App/PreCompiled.h @@ -104,7 +104,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index 551e07eb6..838a5aeab 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -28,6 +28,7 @@ #endif #include +#include #include #include #include @@ -498,12 +499,12 @@ static PyObject * minBoundingBox(PyObject *self, PyObject *args) //Do a Monte Carlo approach and start from the Principal Axis System //and rotate +/- 60° around each axis in a first iteration - double angle_range_min_x=-PI/3.0,angle_range_max_x=PI/3.0, - angle_range_min_y=-PI/3.0,angle_range_max_y=PI/3.0, - angle_range_min_z=-PI/3.0,angle_range_max_z=PI/3.0; + double angle_range_min_x=-M_PI/3.0,angle_range_max_x=M_PI/3.0, + angle_range_min_y=-M_PI/3.0,angle_range_max_y=M_PI/3.0, + angle_range_min_z=-M_PI/3.0,angle_range_max_z=M_PI/3.0; //We rotate until we are 0.1° sure to be in the right position - for (step_size = (2.0*PI/it_steps);step_size>(2.0*PI/3600.0);step_size=(2.0*PI/it_steps)) + for (step_size = (2.0*M_PI/it_steps);step_size>(2.0*M_PI/3600.0);step_size=(2.0*M_PI/it_steps)) { for(alpha_x=angle_range_min_x;alpha_x(2.0*PI/360.0);step_size=(2.0*PI/it_steps)) + for (step_size = (2.0*M_PI/it_steps);step_size>(2.0*M_PI/360.0);step_size=(2.0*M_PI/it_steps)) { for(alpha_x=angle_range_min_x;alpha_x using namespace Part; @@ -72,7 +72,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void) try { // Now, let's get the TopoDS_Shape TopoDS_Shape revolve = base->Shape.getShape().revolve(gp_Ax1(pnt, dir), - Angle.getValue()/180.0f*Standard_PI); + Angle.getValue()/180.0f*M_PI); if (revolve.IsNull()) return new App::DocumentObjectExecReturn("Resulting shape is null"); this->Shape.setValue(revolve); diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 5673ddd42..c2e818a52 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -333,9 +333,9 @@ App::DocumentObjectExecReturn *Sphere::execute(void) return new App::DocumentObjectExecReturn("Radius of sphere too small"); try { BRepPrimAPI_MakeSphere mkSphere(Radius.getValue(), - Angle1.getValue()/180.0f*Standard_PI, - Angle2.getValue()/180.0f*Standard_PI, - Angle3.getValue()/180.0f*Standard_PI); + Angle1.getValue()/180.0f*M_PI, + Angle2.getValue()/180.0f*M_PI, + Angle3.getValue()/180.0f*M_PI); TopoDS_Shape ResultShape = mkSphere.Shape(); this->Shape.setValue(ResultShape); } @@ -391,9 +391,9 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void) gp_Ax2 ax2(pnt,dir); BRepPrimAPI_MakeSphere mkSphere(ax2, Radius2.getValue(), - Angle1.getValue()/180.0f*Standard_PI, - Angle2.getValue()/180.0f*Standard_PI, - Angle3.getValue()/180.0f*Standard_PI); + Angle1.getValue()/180.0f*M_PI, + Angle2.getValue()/180.0f*M_PI, + Angle3.getValue()/180.0f*M_PI); Standard_Real scale = Radius1.getValue()/Radius2.getValue(); gp_Dir xDir = ax2.XDirection(); gp_Dir yDir = ax2.YDirection(); @@ -450,7 +450,7 @@ App::DocumentObjectExecReturn *Cylinder::execute(void) try { BRepPrimAPI_MakeCylinder mkCylr(Radius.getValue(), Height.getValue(), - Angle.getValue()/180.0f*Standard_PI); + Angle.getValue()/180.0f*M_PI); TopoDS_Shape ResultShape = mkCylr.Shape(); this->Shape.setValue(ResultShape); } @@ -499,7 +499,7 @@ App::DocumentObjectExecReturn *Cone::execute(void) BRepPrimAPI_MakeCone mkCone(Radius1.getValue(), Radius2.getValue(), Height.getValue(), - Angle.getValue()/180.0f*Standard_PI); + Angle.getValue()/180.0f*M_PI); TopoDS_Shape ResultShape = mkCone.Shape(); this->Shape.setValue(ResultShape); } diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index f40916e5b..a42a3ec08 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1432,7 +1432,7 @@ TopoDS_Shape TopoShape::makeTube(double radius, double tol, int cont, int maxdeg //circular profile Handle(Geom_Circle) aCirc = new Geom_Circle (gp::XOY(), radius); - aCirc->Rotate (gp::OZ(), Standard_PI/2.); + aCirc->Rotate (gp::OZ(), M_PI/2.); //perpendicular section Handle(Law_Function) myEvol = ::CreateBsFunction (myPath->FirstParameter(), myPath->LastParameter(), radius); @@ -1540,18 +1540,18 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, } gp_Pnt2d aPnt(0, 0); - gp_Dir2d aDir(2. * PI, pitch); + gp_Dir2d aDir(2. * M_PI, pitch); if (leftHanded) { //aPnt.SetCoord(0.0, height); //aDir.SetCoord(2.0 * PI, -pitch); - aPnt.SetCoord(2. * PI, 0.0); - aDir.SetCoord(-2. * PI, pitch); + aPnt.SetCoord(2. * M_PI, 0.0); + aDir.SetCoord(-2. * M_PI, pitch); } gp_Ax2d aAx2d(aPnt, aDir); Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d); gp_Pnt2d beg = line->Value(0); - gp_Pnt2d end = line->Value(sqrt(4.0*PI*PI+pitch*pitch)*(height/pitch)); + gp_Pnt2d end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*(height/pitch)); Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end); TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf); @@ -1944,7 +1944,11 @@ void TopoShape::getFaces(std::vector &aPoints, Standard_Real x3, y3, z3; Handle_StlMesh_Mesh aMesh = new StlMesh_Mesh(); - StlTransfer::BuildIncrementalMesh(this->_Shape, accuracy, aMesh); + StlTransfer::BuildIncrementalMesh(this->_Shape, accuracy, +#if OCC_VERSION_HEX >= 0x060503 + Standard_True, +#endif + aMesh); StlMesh_MeshExplorer xp(aMesh); for (Standard_Integer nbd=1;nbd<=aMesh->NbDomains();nbd++) { for (xp.InitTriangle (nbd); xp.MoreTriangle (); xp.NextTriangle ()) { diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.ui b/src/Mod/Part/Gui/DlgSettingsGeneral.ui index 4ea3f5222..535d0f1d3 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.ui +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.ui @@ -71,7 +71,7 @@ - Boolean operation + Model refinement From 6c9f670dcb57866aac075ebd0e14bb9a310fa3e9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 13:42:40 +0200 Subject: [PATCH 22/27] 0000749: PI was not declared in this scope - compile error --- src/Mod/Import/Gui/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Import/Gui/CMakeLists.txt b/src/Mod/Import/Gui/CMakeLists.txt index 7cd962a92..d5029eca8 100644 --- a/src/Mod/Import/Gui/CMakeLists.txt +++ b/src/Mod/Import/Gui/CMakeLists.txt @@ -22,6 +22,7 @@ link_directories(${OCC_LIBRARY_DIR}) set(ImportGui_LIBS FreeCADGui PartGui + TKCAF TKXCAF TKLCAF TKXDESTEP From a60cd565699a77de344919de898a2e033cf075c5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 14:03:46 +0200 Subject: [PATCH 23/27] Extend filter list for release script --- src/WindowsInstaller/BuildInstaller.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WindowsInstaller/BuildInstaller.bat b/src/WindowsInstaller/BuildInstaller.bat index d779137f6..f84c4de89 100644 --- a/src/WindowsInstaller/BuildInstaller.bat +++ b/src/WindowsInstaller/BuildInstaller.bat @@ -24,7 +24,7 @@ SET /P M=Reebuild and press enter rem making of the bin zip file -"c:\Program Files\7-Zip\7z.exe" a -t7z FreeCAD.7z "-xr!*.idb" "-xr!*.pdb" "-xr!*.ilk" "-xr!*.rule" "-xr!*.svn-base" "-xr!*.pyc" "-xr!*.stamp" "-xr!*.cmake" "-xr!*.svn*" "-xr!*.vcproj" "-xr!*.am" ..\..\bin ..\..\Mod ..\..\Doc ..\..\data +"c:\Program Files\7-Zip\7z.exe" a -t7z FreeCAD.7z "-xr!*.idb" "-xr!*.pdb" "-xr!*.ilk" "-xr!*.rule" "-xr!*.svn-base" "-xr!*.pyc" "-xr!*.stamp" "-xr!*.cmake" "-xr!*.svn*" "-xr!*.vcproj" "-xr!*.am" "-xr!CMakeFiles" "-xr!*.dir" ..\..\bin ..\..\Mod ..\..\Doc ..\..\data call CopyRelease.bat From 4fcc518eb807504476a975705b00a05d032ee7c1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 14:39:06 +0200 Subject: [PATCH 24/27] Use lsb_release to show used distribution --- src/Gui/Splashscreen.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index fbfaca519..7a40dc7be 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -26,6 +26,7 @@ # include # include # include +# include # include # include # include @@ -241,6 +242,18 @@ static QString getPlatform() #elif defined (Q_OS_MAC) return QString::fromAscii("Mac OS X"); #elif defined (Q_OS_LINUX) + QString exe(QLatin1String("lsb_release")); + QStringList args; + args << QLatin1String("-ds"); + QProcess proc; + proc.setEnvironment(QProcess::systemEnvironment()); + proc.start(exe, args); + if (proc.waitForStarted() && proc.waitForFinished()) { + QByteArray info = proc.readAll(); + info.replace('\n',""); + return QString::fromAscii((const char*)info); + } + return QString::fromAscii("Linux"); #elif defined (Q_OS_UNIX) return QString::fromAscii("UNIX"); @@ -326,6 +339,7 @@ void AboutDialog::on_copyButton_clicked() QString major = QString::fromAscii(config["BuildVersionMajor"].c_str()); QString minor = QString::fromAscii(config["BuildVersionMinor"].c_str()); QString build = QString::fromAscii(config["BuildRevision"].c_str()); + str << "Platform: " << getPlatform() << " (" << QSysInfo::WordSize << "-bit)" << endl; str << "Version: " << major << "." << minor << "." << build << endl; it = config.find("BuildRevisionBranch"); if (it != config.end()) From f7b200c20499b3ea30fe0e60b338de5d9ccb4728 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 15:03:21 +0200 Subject: [PATCH 25/27] Copy version numbers of libraries in About dialog --- src/Gui/Splashscreen.cpp | 11 +++++++++++ src/Mod/Part/App/AppPart.cpp | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 7a40dc7be..d127e13bb 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -30,6 +30,9 @@ # include # include # include +# include +# include +# include #endif #include "Splashscreen.h" @@ -347,6 +350,14 @@ void AboutDialog::on_copyButton_clicked() it = config.find("BuildRevisionHash"); if (it != config.end()) str << "Hash: " << it->second.c_str() << endl; + // report also the version numbers of the most important libraries in FreeCAD + str << "Python version: " << PY_VERSION << endl; + str << "Qt version: " << QT_VERSION_STR << endl; + str << "Coin version: " << COIN_VERSION << endl; + str << "SoQt version: " << SOQT_VERSION << endl; + it = config.find("OCC_VERSION"); + if (it != config.end()) + str << "OCC version: " << it->second.c_str() << endl; QClipboard* cb = QApplication::clipboard(); cb->setText(data); diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 4980b0be1..4e521342c 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -13,6 +13,7 @@ #ifndef _PreComp_ # include # include +# include #endif #include @@ -86,6 +87,10 @@ PyDoc_STRVAR(module_part_doc, extern "C" { void PartExport initPart() { + std::stringstream str; + str << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE; + App::Application::Config()["OCC_VERSION"] = str.str(); + PyObject* partModule = Py_InitModule3("Part", Part_methods, module_part_doc); /* mod name, table ptr */ Base::Console().Log("Loading Part module... done\n"); From 1912ba66cc7ca381bfc1bd6cdd28bd094e099e05 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 14 Jun 2012 15:04:52 +0200 Subject: [PATCH 26/27] Fix path to merge module in FreeCAD.wxs --- src/WindowsInstaller/FreeCAD.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WindowsInstaller/FreeCAD.wxs b/src/WindowsInstaller/FreeCAD.wxs index a9c15ed40..ee21354a8 100644 --- a/src/WindowsInstaller/FreeCAD.wxs +++ b/src/WindowsInstaller/FreeCAD.wxs @@ -78,7 +78,7 @@ - + From 21add8911d082d9b3044507cff4e0c240f243461 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 15 Jun 2012 13:04:07 +0200 Subject: [PATCH 27/27] First draft of makeThread --- src/Mod/Part/App/AppPartPy.cpp | 21 ++++++++++++ src/Mod/Part/App/TopoShape.cpp | 63 ++++++++++++++++++++++++++++++++++ src/Mod/Part/App/TopoShape.h | 2 ++ src/Mod/Part/MakeBottle.py | 8 +++-- 4 files changed, 92 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 2132042df..342c59069 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -785,6 +785,24 @@ static PyObject * makeHelix(PyObject *self, PyObject *args) } } +static PyObject * makeThread(PyObject *self, PyObject *args) +{ + double pitch, height, depth, radius; + if (!PyArg_ParseTuple(args, "dddd", &pitch, &height, &depth, &radius)) + return 0; + + try { + TopoShape helix; + TopoDS_Shape wire = helix.makeThread(pitch, height, depth, radius); + return new TopoShapeWirePy(new TopoShape(wire)); + } + catch (Standard_Failure) { + Handle_Standard_Failure e = Standard_Failure::Caught(); + PyErr_SetString(PyExc_Exception, e->GetMessageString()); + return 0; + } +} + static PyObject * makeLine(PyObject *self, PyObject *args) { PyObject *obj1, *obj2; @@ -1475,6 +1493,9 @@ struct PyMethodDef Part_methods[] = { "By default a cylindrical surface is used to create the helix. If the fourth parameter is set\n" "(the apex given in degree) a conical surface is used instead"}, + {"makeThread" ,makeThread,METH_VARARGS, + "makeThread(pitch,depth,height,radius) -- Make a thread with a given pitch, depth, height and radius"}, + {"makeRevolution" ,makeRevolution,METH_VARARGS, "makeRevolution(Curve,[vmin,vmax,angle,pnt,dir]) -- Make a revolved shape\n" "by rotating the curve or a portion of it around an axis given by (pnt,dir).\n" diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index a42a3ec08..8ebac8242 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -105,6 +105,7 @@ # include # include # include +# include # include # include # include @@ -1560,6 +1561,68 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, return wire; } +TopoDS_Shape TopoShape::makeThread(Standard_Real pitch, + Standard_Real depth, + Standard_Real height, + Standard_Real radius) const +{ + if (pitch < Precision::Confusion()) + Standard_Failure::Raise("Pitch of thread too small"); + + if (depth < Precision::Confusion()) + Standard_Failure::Raise("Depth of thread too small"); + + if (height < Precision::Confusion()) + Standard_Failure::Raise("Height of thread too small"); + + if (radius < Precision::Confusion()) + Standard_Failure::Raise("Radius of thread too small"); + + //Threading : Create Surfaces + gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ()); + Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(cylAx2 , radius); + Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(cylAx2 , radius+depth); + + //Threading : Define 2D Curves + gp_Pnt2d aPnt(2. * M_PI , height / 2.); + gp_Dir2d aDir(2. * M_PI , height / 4.); + gp_Ax2d aAx2d(aPnt , aDir); + + Standard_Real aMajor = 2. * M_PI; + Standard_Real aMinor = pitch; + + Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor); + Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(aAx2d , aMajor , aMinor / 4); + + Handle(Geom2d_TrimmedCurve) aArc1 = new Geom2d_TrimmedCurve(anEllipse1 , 0 , M_PI); + Handle(Geom2d_TrimmedCurve) aArc2 = new Geom2d_TrimmedCurve(anEllipse2 , 0 , M_PI); + + gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0); + gp_Pnt2d anEllipsePnt2 = anEllipse1->Value(M_PI); + + Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment(anEllipsePnt1 , anEllipsePnt2); + + //Threading : Build Edges and Wires + TopoDS_Edge aEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(aArc1 , aCyl1); + TopoDS_Edge aEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment , aCyl1); + TopoDS_Edge aEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(aArc2 , aCyl2); + TopoDS_Edge aEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment , aCyl2); + + TopoDS_Wire threadingWire1 = BRepBuilderAPI_MakeWire(aEdge1OnSurf1 , aEdge2OnSurf1); + TopoDS_Wire threadingWire2 = BRepBuilderAPI_MakeWire(aEdge1OnSurf2 , aEdge2OnSurf2); + + BRepLib::BuildCurves3d(threadingWire1); + BRepLib::BuildCurves3d(threadingWire2); + + BRepOffsetAPI_ThruSections aTool(Standard_True); + + aTool.AddWire(threadingWire1); + aTool.AddWire(threadingWire2); + aTool.CheckCompatibility(Standard_False); + + return aTool.Shape(); +} + TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, Standard_Boolean isRuled) const diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 1d16b9e07..aaf521e05 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -163,6 +163,8 @@ public: TopoDS_Shape makeTube(double radius, double tol, int cont, int maxdeg, int maxsegm) const; TopoDS_Shape makeHelix(Standard_Real pitch, Standard_Real height, Standard_Real radius, Standard_Real angle=0, Standard_Boolean left=Standard_False) const; + TopoDS_Shape makeThread(Standard_Real pitch, Standard_Real depth, + Standard_Real height, Standard_Real radius) const; TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, Standard_Boolean isRuled) const; TopoDS_Shape makeOffset(double offset, double tol, diff --git a/src/Mod/Part/MakeBottle.py b/src/Mod/Part/MakeBottle.py index 65fb20971..1f4c2babf 100644 --- a/src/Mod/Part/MakeBottle.py +++ b/src/Mod/Part/MakeBottle.py @@ -47,7 +47,8 @@ def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0): aTrsf=Base.Matrix() aTrsf.rotateZ(math.pi) # rotate around the z-axis - aMirroredWire=aWire.transformGeometry(aTrsf) + aMirroredWire=aWire.copy() + aMirroredWire.transformShape(aTrsf) myWireProfile=Part.Wire([aWire,aMirroredWire]) myFaceProfile=Part.Face(myWireProfile) @@ -80,8 +81,11 @@ def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0): # This doesn't work for any reason myBody = myBody.makeThickness([faceToRemove],-myThickness/50 , 1.e-3) + myThreading = Part.makeThread(myNeckHeight/10, myNeckRadius*0.06, myHeight/10, myNeckRadius*0.99) + myThreading.translate(Base.Vector(0,0,myHeight)) + myCompound = Part.Compound([myBody, myThreading]) - return myBody + return myCompound def makeBoreHole(): # create a document if needed