From fc903d93dfd545a0a11be9187f8641f6e719a2d9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 15 Nov 2014 14:31:24 +0100 Subject: [PATCH 01/18] + support adding circles as external geometry not lying on the sketch plane --- src/Mod/Sketcher/App/SketchObject.cpp | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 75f76414a..059cdfb44 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1330,6 +1330,44 @@ void SketchObject::rebuildExternalGeometry(void) ExternalGeo.push_back(line); } } + else if (curve.GetType() == GeomAbs_Circle) { + gp_Dir vec1 = sketchPlane.Axis().Direction(); + gp_Dir vec2 = curve.Circle().Axis().Direction(); + if (vec1.IsParallel(vec2, Precision::Confusion())) { + gp_Circ circle = curve.Circle(); + gp_Pnt cnt = circle.Location(); + gp_Pnt beg = curve.Value(curve.FirstParameter()); + gp_Pnt end = curve.Value(curve.LastParameter()); + + GeomAPI_ProjectPointOnSurf proj(cnt,gPlane); + cnt = proj.NearestPoint(); + circle.SetLocation(cnt); + cnt.Transform(mov); + circle.Transform(mov); + + if (beg.SquareDistance(end) < Precision::Confusion()) { + Part::GeomCircle* gCircle = new Part::GeomCircle(); + gCircle->setRadius(circle.Radius()); + gCircle->setCenter(Base::Vector3d(cnt.X(),cnt.Y(),cnt.Z())); + + gCircle->Construction = true; + ExternalGeo.push_back(gCircle); + } + else { + Part::GeomArcOfCircle* gArc = new Part::GeomArcOfCircle(); + Handle_Geom_Curve hCircle = new Geom_Circle(circle); + Handle_Geom_TrimmedCurve tCurve = new Geom_TrimmedCurve(hCircle, curve.FirstParameter(), + curve.LastParameter()); + gArc->setHandle(tCurve); + gArc->Construction = true; + ExternalGeo.push_back(gArc); + } + } + else { + // creates an ellipse + throw Base::Exception("Not yet supported geometry for external geometry"); + } + } else { try { BRepOffsetAPI_NormalProjection mkProj(aProjFace); From a622d14c2d0bdfee6a6de1d09980880094c64978 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 15 Nov 2014 18:48:58 +0100 Subject: [PATCH 02/18] + port to CMake 3.0 --- CMakeLists.txt | 12 ++++++++---- src/Mod/PartDesign/CMakeLists.txt | 2 +- src/Mod/Plot/CMakeLists.txt | 2 +- src/Mod/Ship/CMakeLists.txt | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 075f95562..fa753325b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,14 @@ set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) +if(COMMAND cmake_policy) + cmake_policy(SET CMP0003 NEW) + # added in cmake 3.0 + if(POLICY CMP0050) + cmake_policy(SET CMP0050 OLD) + endif(POLICY CMP0050) +endif(COMMAND cmake_policy) + # include local modules include(AddFileDependencies) include(cMake/FreeCadMacros.cmake) @@ -17,10 +25,6 @@ include(cMake/FreeCadMacros.cmake) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake") -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) - #if(CMAKE_CFG_INTDIR STREQUAL .) # No Debug/Release output paths set(DEBUG_MAIN_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) diff --git a/src/Mod/PartDesign/CMakeLists.txt b/src/Mod/PartDesign/CMakeLists.txt index 44b920041..d9ac48c08 100644 --- a/src/Mod/PartDesign/CMakeLists.txt +++ b/src/Mod/PartDesign/CMakeLists.txt @@ -63,7 +63,7 @@ ADD_CUSTOM_TARGET(WizardShaft ALL SET(all_files ${all_wizardshaft_files}) -fc_copy_sources(Mod/PartDesign "${CMAKE_BINARY_DIR}/Mod/PartDesign" ${all_files}) +fc_copy_sources(WizardShaft "${CMAKE_BINARY_DIR}/Mod/PartDesign" ${all_files}) INSTALL( FILES diff --git a/src/Mod/Plot/CMakeLists.txt b/src/Mod/Plot/CMakeLists.txt index 29b6acdbd..f7faa1a2e 100644 --- a/src/Mod/Plot/CMakeLists.txt +++ b/src/Mod/Plot/CMakeLists.txt @@ -53,7 +53,7 @@ ADD_CUSTOM_TARGET(Plot ALL SOURCES ${all_files} ) -fc_copy_sources(Mod/Plot "${CMAKE_BINARY_DIR}/Mod/Plot" ${all_files}) +fc_copy_sources(Plot "${CMAKE_BINARY_DIR}/Mod/Plot" ${all_files}) INSTALL( FILES diff --git a/src/Mod/Ship/CMakeLists.txt b/src/Mod/Ship/CMakeLists.txt index 420bb1178..bd282f535 100644 --- a/src/Mod/Ship/CMakeLists.txt +++ b/src/Mod/Ship/CMakeLists.txt @@ -69,7 +69,7 @@ ADD_CUSTOM_TARGET(Ship ALL SOURCES ${all_files} ) -fc_copy_sources(Mod/Ship "${CMAKE_BINARY_DIR}/Mod/Ship" ${all_files}) +fc_copy_sources(Ship "${CMAKE_BINARY_DIR}/Mod/Ship" ${all_files}) INSTALL( FILES From 4e2cbaf04523bddd66cf6f50fbff209dbbf6f36e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 15 Nov 2014 22:45:56 +0100 Subject: [PATCH 03/18] + fix saving problem with file names containing an apostrophe --- src/Gui/Document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 6db42bad4..015c79239 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -582,7 +582,7 @@ bool Document::saveAs(void) // save as new file name Gui::WaitCursor wc; - Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs('%s')" + Command::doCommand(Command::Doc,"App.getDocument(\"%s\").saveAs(\"%s\")" , DocName, (const char*)fn.toUtf8()); setModified(false); From 7a307cdab36b2b28ff899984ae4c23c117a700ea Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 16 Nov 2014 19:11:31 +0100 Subject: [PATCH 04/18] + fix crash when dragging a point adter undoing the deletion of a line --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 43 ++++++++++++--------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 4f266b396..a7d0f7156 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -694,14 +694,15 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe int GeoId; Sketcher::PointPos PosId; getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId); - Gui::Command::openCommand("Drag Point"); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)" - ,getObject()->getNameInDocument() - ,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0 - ); - Gui::Command::commitCommand(); - Gui::Command::updateActive(); - + if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) { + Gui::Command::openCommand("Drag Point"); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)" + ,getObject()->getNameInDocument() + ,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0 + ); + Gui::Command::commitCommand(); + Gui::Command::updateActive(); + } setPreselectPoint(edit->DragPoint); edit->DragPoint = -1; //updateColor(); @@ -987,10 +988,12 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor int GeoId; Sketcher::PointPos PosId; getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId); - edit->ActSketch.initMove(GeoId, PosId, false); - relative = false; - xInit = 0; - yInit = 0; + if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) { + edit->ActSketch.initMove(GeoId, PosId, false); + relative = false; + xInit = 0; + yInit = 0; + } } else { Mode = STATUS_NONE; } @@ -1044,13 +1047,15 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor Sketcher::PointPos PosId; getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId); Base::Vector3d vec(x-xInit,y-yInit,0); - if (edit->ActSketch.movePoint(GeoId, PosId, vec, relative) == 0) { - setPositionText(Base::Vector2D(x,y)); - draw(true); - signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime)); - } else { - signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime)); - //Base::Console().Log("Error solving:%d\n",ret); + if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) { + if (edit->ActSketch.movePoint(GeoId, PosId, vec, relative) == 0) { + setPositionText(Base::Vector2D(x,y)); + draw(true); + signalSolved(QString::fromLatin1("Solved in %1 sec").arg(edit->ActSketch.SolveTime)); + } else { + signalSolved(QString::fromLatin1("Unsolved (%1 sec)").arg(edit->ActSketch.SolveTime)); + //Base::Console().Log("Error solving:%d\n",ret); + } } } return true; From 2ead6f9bcf5ac46e4cb27550eb7bc60b209c3ea6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 16 Nov 2014 19:12:34 +0100 Subject: [PATCH 05/18] + whitespace improvement --- src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp index eba78b4ba..d9b266dfb 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp @@ -66,8 +66,8 @@ void SketcherGeneralWidget::saveSettings() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher/General"); hGrp->SetBool("ShowGrid", ui->checkBoxShowGrid->isChecked()); - - ui->gridSize->pushToHistory(); + + ui->gridSize->pushToHistory(); hGrp->SetBool("GridSnap", ui->checkBoxGridSnap->isChecked()); hGrp->SetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked()); @@ -78,14 +78,12 @@ void SketcherGeneralWidget::loadSettings() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Sketcher/General"); ui->checkBoxShowGrid->setChecked(hGrp->GetBool("ShowGrid", true)); - ui->gridSize->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketchGridSize")); - //ui->gridSize->setToLastUsedValue(); + ui->gridSize->setParamGrpPath(QByteArray("User parameter:BaseApp/History/SketchGridSize")); + //ui->gridSize->setToLastUsedValue(); ui->checkBoxGridSnap->setChecked(hGrp->GetBool("GridSnap", ui->checkBoxGridSnap->isChecked())); ui->checkBoxAutoconstraints->setChecked(hGrp->GetBool("AutoConstraints", ui->checkBoxAutoconstraints->isChecked())); } - - void SketcherGeneralWidget::toggleGridView(bool on) { ui->label->setEnabled(on); @@ -101,7 +99,7 @@ void SketcherGeneralWidget::setGridSize(double val) void SketcherGeneralWidget::setInitGridSize(double val) { - ui->gridSize->setValue(Base::Quantity(val,Base::Unit::Length)); + ui->gridSize->setValue(Base::Quantity(val,Base::Unit::Length)); } void SketcherGeneralWidget::toggleGridSnap(int state) @@ -150,7 +148,7 @@ TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView) Gui::Selection().Attach(this); widget->loadSettings(); - widget->setInitGridSize(sketchView->GridSize.getValue() ); + widget->setInitGridSize(sketchView->GridSize.getValue() ); } TaskSketcherGeneral::~TaskSketcherGeneral() @@ -182,7 +180,7 @@ void TaskSketcherGeneral::toggleAutoconstraints(int state) /// @cond DOXERR void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller, - Gui::SelectionSingleton::MessageType Reason) + Gui::SelectionSingleton::MessageType Reason) { //if (Reason.Type == SelectionChanges::AddSelection || // Reason.Type == SelectionChanges::RmvSelection || From 62de0655d75d9d2e35fa7e7fbb87d27fc96a4b2c Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 16 Nov 2014 19:13:06 +0100 Subject: [PATCH 06/18] + fix inconsistency problem after undo/redo --- src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp | 20 +++++++++++++++++++- src/Mod/Sketcher/Gui/TaskDlgEditSketch.h | 13 +++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp index cd0a003b7..d7d9850e9 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include #endif #include "TaskDlgEditSketch.h" @@ -46,16 +47,33 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView) Elements = new TaskSketcherElements(sketchView); General = new TaskSketcherGeneral(sketchView); Messages = new TaskSketcherMessages(sketchView); - + Content.push_back(Messages); Content.push_back(General); Content.push_back(Constraints); Content.push_back(Elements); + + App::Document* document = sketchView->getObject()->getDocument(); + connectUndoDocument = + document->signalUndo.connect(boost::bind(&TaskDlgEditSketch::slotUndoDocument, this, _1)); + connectRedoDocument = + document->signalRedo.connect(boost::bind(&TaskDlgEditSketch::slotRedoDocument, this, _1)); } TaskDlgEditSketch::~TaskDlgEditSketch() { + connectUndoDocument.disconnect(); + connectRedoDocument.disconnect(); +} +void TaskDlgEditSketch::slotUndoDocument(const App::Document& doc) +{ + const_cast(doc).recomputeFeature(sketchView->getObject()); +} + +void TaskDlgEditSketch::slotRedoDocument(const App::Document& doc) +{ + const_cast(doc).recomputeFeature(sketchView->getObject()); } //==== calls from the TaskView =============================================================== diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h index b1ec85303..445b84994 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.h @@ -31,6 +31,9 @@ #include "TaskSketcherElements.h" #include "TaskSketcherGeneral.h" #include "TaskSketcherMessages.h" +#include + +typedef boost::signals::connection Connection; namespace SketcherGui { @@ -65,11 +68,17 @@ public: { return QDialogButtonBox::Close|QDialogButtonBox::Help; } protected: - ViewProviderSketch *sketchView; + void slotUndoDocument(const App::Document&); + void slotRedoDocument(const App::Document&); + +protected: + ViewProviderSketch *sketchView; TaskSketcherConstrains *Constraints; - TaskSketcherElements *Elements; + TaskSketcherElements *Elements; TaskSketcherGeneral *General; TaskSketcherMessages *Messages; + Connection connectUndoDocument; + Connection connectRedoDocument; }; From 86a1757c2049e9e028525297636a2b1fdfce6006 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Sun, 16 Nov 2014 23:45:13 +0400 Subject: [PATCH 07/18] Sketcher: Slot: proper tangent constraints Endpoint-to-endpoint tangency is applied now instead of tangency+coincident. Fixes issue #0001828 ( http://freecadweb.org/tracker/view.php?id=0001828 ) --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 24 ++++++----------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index db7e1c9c3..82cb3de2a 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -3009,32 +3009,20 @@ public: Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))", sketchgui->getObject()->getNameInDocument(), EditCurve[0].fX,EditCurve[0].fY,EditCurve[34].fX,EditCurve[34].fY); - //// add the tnagent constraints - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) " - ,sketchgui->getObject()->getNameInDocument() - ,firstCurve,firstCurve+2); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) " + + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,1,%i,1)) " ,sketchgui->getObject()->getNameInDocument() ,firstCurve,firstCurve+3); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) " - ,sketchgui->getObject()->getNameInDocument() - ,firstCurve+1,firstCurve+2); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,%i)) " - ,sketchgui->getObject()->getNameInDocument() - ,firstCurve+1,firstCurve+3); - // add the four coincidents to ty them together - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,1,%i,1)) " - ,sketchgui->getObject()->getNameInDocument() - ,firstCurve,firstCurve+3); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) " + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) " ,sketchgui->getObject()->getNameInDocument() ,firstCurve,firstCurve+2); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,1)) " + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,1)) " ,sketchgui->getObject()->getNameInDocument() ,firstCurve+2,firstCurve+1); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%i,2,%i,2)) " + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Tangent',%i,2,%i,2)) " ,sketchgui->getObject()->getNameInDocument() ,firstCurve+3,firstCurve+1); + //// add the either horizontal or vertical constraints if(fabs(lx)>fabs(ly)) Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Horizontal',%i)) " From e070a717a51789d976f7a0bee48596570d35cf5e Mon Sep 17 00:00:00 2001 From: wood galaxy Date: Mon, 17 Nov 2014 15:44:11 +0100 Subject: [PATCH 08/18] improvement to Cut Plane Move cut plane on itw own. Add ArchCutPlan to CmakeList Add task panel Add choice between side of the face --- src/Mod/Arch/Arch.py | 5 +- src/Mod/Arch/ArchCommands.py | 31 ----------- src/Mod/Arch/ArchCutPlane.py | 99 ++++++++++++++++++++++++++++++++++++ src/Mod/Arch/CMakeLists.txt | 1 + 4 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 src/Mod/Arch/ArchCutPlane.py diff --git a/src/Mod/Arch/Arch.py b/src/Mod/Arch/Arch.py index 1a915f125..778834366 100644 --- a/src/Mod/Arch/Arch.py +++ b/src/Mod/Arch/Arch.py @@ -1,7 +1,7 @@ #*************************************************************************** #* * -#* Copyright (c) 2011 * -#* Yorik van Havre * +#* Copyright (c) 2011 * +#* Yorik van Havre * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * @@ -46,3 +46,4 @@ from ArchRebar import * from ArchFrame import * from ArchPanel import * from ArchEquipment import * +from ArchCutPlane import * diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 4d894ec6c..f7b889ba1 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -393,16 +393,6 @@ def getCutVolume(cutplane,shapes): invcutvolume = cutface.extrude(cutnormal) return cutface,cutvolume,invcutvolume -def cutComponent(cutPlane, archObject): - """cut object from a plan""" - cutVolume = getCutVolume(cutPlane, archObject.Object.Shape) - cutVolume = cutVolume[2] - if cutVolume: - obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume") - obj.Shape = cutVolume - # add substraction component to Arch object - return removeComponents(obj,archObject.Object) - def getShapeFromMesh(mesh,fast=True,tolerance=0.001,flat=False,cut=True): import Part, MeshPart, DraftGeomUtils if mesh.isSolid() and (mesh.countComponents() == 1) and fast: @@ -942,26 +932,6 @@ class _CommandRemove: FreeCAD.ActiveDocument.recompute() -class _CommandCutPlane: - "the Arch CutPlane command definition" - def GetResources(self): - return {'Pixmap' : 'Arch_CutPlane', - 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut object"), - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut the object with plane")} - - def IsActive(self): - return len(FreeCADGui.Selection.getSelection()) > 1 - - def Activated(self): - face = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] - archObject = FreeCADGui.Selection.getSelectionEx()[0] - FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting"))) - FreeCADGui.addModule("Arch") - FreeCADGui.doCommand("Arch.cutComponent(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0],FreeCADGui.Selection.getSelectionEx()[0])") - FreeCAD.ActiveDocument.commitTransaction() - FreeCAD.ActiveDocument.recompute() - - class _CommandSplitMesh: "the Arch SplitMesh command definition" def GetResources(self): @@ -1148,7 +1118,6 @@ class _ToggleIfcBrepFlag: if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Add',_CommandAdd()) FreeCADGui.addCommand('Arch_Remove',_CommandRemove()) - FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane()) FreeCADGui.addCommand('Arch_SplitMesh',_CommandSplitMesh()) FreeCADGui.addCommand('Arch_MeshToShape',_CommandMeshToShape()) FreeCADGui.addCommand('Arch_SelectNonSolidMeshes',_CommandSelectNonSolidMeshes()) diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py new file mode 100644 index 000000000..92389ef27 --- /dev/null +++ b/src/Mod/Arch/ArchCutPlane.py @@ -0,0 +1,99 @@ +#*************************************************************************** +#* * +#* Copyright (c) 2014 * +#* Jonathan Wiedemann * +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU Lesser General Public License (LGPL) * +#* as published by the Free Software Foundation; either version 2 of * +#* the License, or (at your option) any later version. * +#* for detail see the LICENCE text file. * +#* * +#* This program is distributed in the hope that it will be useful, * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +#* GNU Library General Public License for more details. * +#* * +#* You should have received a copy of the GNU Library General Public * +#* License along with this program; if not, write to the Free Software * +#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +#* USA * +#* * +#*************************************************************************** + +import FreeCAD,ArchCommands +from FreeCAD import Vector +if FreeCAD.GuiUp: + import FreeCADGui + from PySide import QtCore, QtGui + from DraftTools import translate +else: + def translate(ctxt,txt): + return txt + +__title__="FreeCAD CutPlane" +__author__ = "Jonathan Wiedemann" +__url__ = "http://www.freecadweb.org" + +# Couper +def cutComponentwithPlane(archObject, cutPlane, sideFace): + """cut object from a plan define by a face, Behind = 0 , front = 1""" + cutVolume = ArchCommands.getCutVolume(cutPlane, archObject.Object.Shape) + if sideFace == 0: + cutVolume = cutVolume[2] + else: + cutVolume = cutVolume[1] + if cutVolume: + obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume") + obj.Shape = cutVolume + # add substraction component to Arch object + return ArchCommands.removeComponents(obj,archObject.Object) + +class _CommandCutPlane: + "the Arch CutPlane command definition" + def GetResources(self): + return {'Pixmap' : 'Arch_CutPlane', + 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut object"), + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut the object with plane")} + + def IsActive(self): + return len(FreeCADGui.Selection.getSelection()) > 1 + + def Activated(self): + panel=_CutPlaneTaskPanel() + FreeCADGui.Control.showDialog(panel) + +class _CutPlaneTaskPanel: + def __init__(self): + self.title = QtGui.QLabel('Cut Plane options') + self.infoText = QtGui.QLabel('Wich side') + self.grid = QtGui.QGridLayout() + self.grid.addWidget(self.title, 1, 0) + self.grid.addWidget(self.infoText, 2, 0) + self.combobox = QtGui.QComboBox() + items = ["Behind","Front"] + self.combobox.addItems(items) + self.combobox.setCurrentIndex(items.index("Behind")) + self.grid.addWidget(self.combobox, 2, 1) + groupBox = QtGui.QGroupBox() + groupBox.setLayout(self.grid) + self.form = groupBox + + def accept(self): + val = self.combobox.currentIndex() + FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting"))) + FreeCADGui.addModule("Arch") + FreeCADGui.doCommand("Arch.cutComponentwithPlane(FreeCADGui.Selection.getSelectionEx()[0],FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0],"+ str(val) +")") + FreeCAD.ActiveDocument.commitTransaction() + FreeCAD.ActiveDocument.recompute() + return True + + def reject(self): + FreeCAD.Console.PrintMessage("Cancel Cut Plane\n") + return True + + def getStandardButtons(self): + return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) + +if FreeCAD.GuiUp: + FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane()) diff --git a/src/Mod/Arch/CMakeLists.txt b/src/Mod/Arch/CMakeLists.txt index 6ea0af2e6..9d27dc1aa 100644 --- a/src/Mod/Arch/CMakeLists.txt +++ b/src/Mod/Arch/CMakeLists.txt @@ -28,6 +28,7 @@ SET(Arch_SRCS ArchFrame.py ArchPanel.py ArchEquipment.py + ArchCutPlane.py ) SOURCE_GROUP("" FILES ${Arch_SRCS}) From 3d03e208d9ab392c802913fd96f6e3ee2c5cb8f8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Nov 2014 20:36:22 +0100 Subject: [PATCH 09/18] + fixes #0001829: DlgPrimitives replaces non ASCII charaters in objects Labels by ? --- src/Mod/Part/Gui/DlgPrimitives.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index fb1eb4547..ceaaded93 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -645,7 +645,7 @@ void DlgPrimitives::createPrimitive(const QString& placement) // Execute the Python block QString prim = tr("Create %1").arg(ui.comboBox1->currentText()); Gui::Application::Instance->activeDocument()->openCommand(prim.toUtf8()); - Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toAscii()); + Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toUtf8()); Gui::Application::Instance->activeDocument()->commitCommand(); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); Gui::Command::doCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")"); From 3904d0a8ee63b67979e9e71e61e423cfe331926a Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 17 Nov 2014 21:11:28 +0100 Subject: [PATCH 10/18] + fixes #0001830: Gui.export() cannot handle long filenames --- src/Gui/ApplicationPy.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index f1a70c13e..ad2d5945c 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -242,7 +242,7 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args,PyObject * /*kw QString fileName = QString::fromUtf8(Utf8Name.c_str()); QFileInfo fi; fi.setFile(fileName); - QString ext = fi.completeSuffix().toLower(); + QString ext = fi.suffix().toLower(); QList views = getMainWindow()->findChildren(); for (QList::Iterator it = views.begin(); it != views.end(); ++it) { if ((*it)->fileName() == fileName) { @@ -286,6 +286,9 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args,PyObject * /*kw edit->resize(400, 300); getMainWindow()->addWindow( edit ); } + else { + Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData()); + } } PY_CATCH; Py_Return; @@ -304,7 +307,7 @@ PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args,PyObject * /* QString fileName = QString::fromUtf8(Utf8Name.c_str()); QFileInfo fi; fi.setFile(fileName); - QString ext = fi.completeSuffix().toLower(); + QString ext = fi.suffix().toLower(); if (ext == QLatin1String("iv")) { App::Document *doc = 0; if (DocName) @@ -348,6 +351,9 @@ PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args,PyObject * /* edit->resize(400, 300); getMainWindow()->addWindow( edit ); } + else { + Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData()); + } } PY_CATCH; Py_Return; @@ -379,7 +385,7 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /* QString fileName = QString::fromUtf8(Utf8Name.c_str()); QFileInfo fi; fi.setFile(fileName); - QString ext = fi.completeSuffix().toLower(); + QString ext = fi.suffix().toLower(); if (ext == QLatin1String("iv") || ext == QLatin1String("wrl") || ext == QLatin1String("vrml") || ext == QLatin1String("wrz") || ext == QLatin1String("svg") || ext == QLatin1String("idtf")) { @@ -411,6 +417,9 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /* } } } + else { + Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData()); + } } } PY_CATCH; From 7a201f9b7490e27d8bf04ac8b1dd1518061dfc36 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Mon, 17 Nov 2014 17:03:41 -0500 Subject: [PATCH 11/18] Work around for Mantis issue 0954 on Helix Primitive To be removed after OCC helix bug corrected. --- src/Mod/Part/App/PrimitiveFeature.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 2928c041c..5e357fe72 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -771,10 +771,14 @@ App::DocumentObjectExecReturn *Helix::execute(void) Standard_Boolean myLocalCS = LocalCoord.getValue() ? Standard_True : Standard_False; Standard_Boolean myStyle = Style.getValue() ? Standard_True : Standard_False; TopoShape helix; - if (myHeight / myPitch > 50.0) - this->Shape.setValue(helix.makeLongHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS)); - else - this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS, myStyle)); + // work around for OCC bug #23314 (FC #0954) + // the exact conditions for failure are unknown. building the helix 1 turn at a time + // seems to always work. + this->Shape.setValue(helix.makeLongHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS)); +// if (myHeight / myPitch > 50.0) +// this->Shape.setValue(helix.makeLongHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS)); +// else +// this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS, myStyle)); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); From b11acfd165f33ec24b911a1445353af73ae6f113 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 19 Nov 2014 11:18:18 +0100 Subject: [PATCH 12/18] + handle unicode strings in class PythonWrapper --- src/Gui/WidgetFactory.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index d1cf605d7..56eaa9b75 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -134,6 +134,15 @@ PythonWrapper::PythonWrapper() bool PythonWrapper::toCString(const Py::Object& pyobject, std::string& str) { + if (PyUnicode_Check(pyobject.ptr())) { + PyObject* unicode = PyUnicode_AsUTF8String(pyobject.ptr()); + str = PyString_AsString(unicode); + Py_DECREF(unicode); + return true; + } + else if (PyString_Check(pyobject.ptr())) { + str = PyString_AsString(pyobject.ptr()); + } #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) if (Shiboken::String::check(pyobject.ptr())) { const char* s = Shiboken::String::toCString(pyobject.ptr()); From be7f583aa08abbb591b777aa8b3b6019208668b0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 19 Nov 2014 15:32:35 +0100 Subject: [PATCH 13/18] + fix issues on 64-bit Linux/MacOSX systems --- src/Mod/Mesh/App/Core/MeshIO.cpp | 4 ++-- src/Mod/Mesh/App/Core/MeshKernel.cpp | 22 +++++++++++++++++++--- src/Mod/Mesh/Gui/ViewProvider.cpp | 2 +- src/Mod/MeshPart/App/CurveProjector.cpp | 4 ++-- src/Mod/ReverseEngineering/Gui/Command.cpp | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index 75f12c4af..d054ae261 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -312,7 +312,7 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn) bool ok = true; for (int i=0;i<3;i++) { if (it->_aulPoints[i] >= ct) { - Base::Console().Warning("Face index %ld out of range\n", it->_aulPoints[i]); + Base::Console().Warning("Face index %lu out of range\n", it->_aulPoints[i]); ok = false; } } @@ -435,7 +435,7 @@ bool MeshInput::LoadOFF (std::istream &rstrIn) bool ok = true; for (int i=0;i<3;i++) { if (it->_aulPoints[i] >= ct) { - Base::Console().Warning("Face index %ld out of range\n", it->_aulPoints[i]); + Base::Console().Warning("Face index %lu out of range\n", it->_aulPoints[i]); ok = false; } } diff --git a/src/Mod/Mesh/App/Core/MeshKernel.cpp b/src/Mod/Mesh/App/Core/MeshKernel.cpp index fb4ce96b3..fc53e1f23 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.cpp +++ b/src/Mod/Mesh/App/Core/MeshKernel.cpp @@ -809,6 +809,7 @@ void MeshKernel::Read (std::istream &rclIn) str >> magic >> version; swap_magic = magic; Base::SwapEndian(swap_magic); swap_version = version; Base::SwapEndian(swap_version); + uint32_t open_edge = 0xffffffff; // value to mark an open edge // is it the new or old format? bool new_format = false; @@ -846,10 +847,25 @@ void MeshKernel::Read (std::istream &rclIn) it->_aulPoints[1] = v2; it->_aulPoints[2] = v3; + // On systems where an 'unsigned long' is a 64-bit value + // the empty neighbour must be explicitly set to 'ULONG_MAX' + // because in algorithms this value is always used to check + // for open edges. str >> v1 >> v2 >> v3; - it->_aulNeighbours[0] = v1; - it->_aulNeighbours[1] = v2; - it->_aulNeighbours[2] = v3; + if (v1 < open_edge) + it->_aulNeighbours[0] = v1; + else + it->_aulNeighbours[0] = ULONG_MAX; + + if (v2 < open_edge) + it->_aulNeighbours[1] = v2; + else + it->_aulNeighbours[1] = ULONG_MAX; + + if (v3 < open_edge) + it->_aulNeighbours[2] = v3; + else + it->_aulNeighbours[2] = ULONG_MAX; } str >> _clBoundBox.MinX >> _clBoundBox.MaxX; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 18d220af3..f1d372508 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -1385,7 +1385,7 @@ void ViewProviderMesh::faceInfo(unsigned long uFacet) if (uFacet < facets.size()) { MeshCore::MeshFacet face = facets[uFacet]; MeshCore::MeshGeomFacet tria = rKernel.GetFacet(face); - Base::Console().Message("Mesh: %s Facet %ld: Points: <%ld, %ld, %ld>, Neighbours: <%ld, %ld, %ld>\n" + Base::Console().Message("Mesh: %s Facet %lu: Points: <%lu, %lu, %lu>, Neighbours: <%lu, %lu, %lu>\n" "Triangle: <[%.6f, %.6f, %.6f], [%.6f, %.6f, %.6f], [%.6f, %.6f, %.6f]>\n", fea->getNameInDocument(), uFacet, face._aulPoints[0], face._aulPoints[1], face._aulPoints[2], face._aulNeighbours[0], face._aulNeighbours[1], face._aulNeighbours[2], diff --git a/src/Mod/MeshPart/App/CurveProjector.cpp b/src/Mod/MeshPart/App/CurveProjector.cpp index 38fb3ba20..3e9f3e4b9 100644 --- a/src/Mod/MeshPart/App/CurveProjector.cpp +++ b/src/Mod/MeshPart/App/CurveProjector.cpp @@ -184,7 +184,7 @@ void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge, // more the one intersection (@ToDo) }else if(Alg.NbPoints() > 1){ PointOnEdge[i] = Base::Vector3f(FLOAT_MAX,0,0); - Base::Console().Log("MeshAlgos::projectCurve(): More then one intersection in Facet %ld, Edge %d\n",uCurFacetIdx,i); + Base::Console().Log("MeshAlgos::projectCurve(): More then one intersection in Facet %lu, Edge %d\n",uCurFacetIdx,i); } } } @@ -202,7 +202,7 @@ void CurveProjectorShape::projectCurve( const TopoDS_Edge& aEdge, cResultPoint = cSplitPoint; GoOn = true; }else{ - Base::Console().Log("MeshAlgos::projectCurve(): Posibel reentry in Facet %ld\n", uCurFacetIdx); + Base::Console().Log("MeshAlgos::projectCurve(): Possible reentry in Facet %lu\n", uCurFacetIdx); } if( uCurFacetIdx == uStartFacetIdx ) diff --git a/src/Mod/ReverseEngineering/Gui/Command.cpp b/src/Mod/ReverseEngineering/Gui/Command.cpp index 7c5a0813d..1df871e11 100644 --- a/src/Mod/ReverseEngineering/Gui/Command.cpp +++ b/src/Mod/ReverseEngineering/Gui/Command.cpp @@ -170,7 +170,7 @@ void CmdApproxPlane::activated(int iMsg) double q0, q1, q2, q3; pm.getRotation().getValue(q0, q1, q2, q3); - Base::Console().Log("RMS value for plane fit with %ld points: %.4f\n", aData.size(), sigma); + Base::Console().Log("RMS value for plane fit with %lu points: %.4f\n", aData.size(), sigma); Base::Console().Log(" Plane base(%.4f, %.4f, %.4f)\n", base.x, base.y, base.z); Base::Console().Log(" Plane normal(%.4f, %.4f, %.4f)\n", norm.x, norm.y, norm.z); From 6bdf0b4b762115862c9720166c4de365eb6a71bd Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 19 Nov 2014 22:56:29 +0100 Subject: [PATCH 14/18] + minor fix --- src/Gui/WidgetFactory.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 56eaa9b75..a82ab2eaf 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -142,6 +142,7 @@ bool PythonWrapper::toCString(const Py::Object& pyobject, std::string& str) } else if (PyString_Check(pyobject.ptr())) { str = PyString_AsString(pyobject.ptr()); + return true; } #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) if (Shiboken::String::check(pyobject.ptr())) { From d354e21ce532b7d285ca0417810efd383e92f299 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 20 Nov 2014 16:30:10 +0100 Subject: [PATCH 15/18] + prepare for netgen 5.x support --- src/3rdParty/salomesmesh/CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/3rdParty/salomesmesh/CMakeLists.txt b/src/3rdParty/salomesmesh/CMakeLists.txt index d3f2de90d..26a07eb46 100644 --- a/src/3rdParty/salomesmesh/CMakeLists.txt +++ b/src/3rdParty/salomesmesh/CMakeLists.txt @@ -9,13 +9,6 @@ SET(SMESH_VERSION_TWEAK 2) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) include_directories( - ${CMAKE_BINARY_DIR}/src - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR} - ${Boost_INCLUDE_DIRS} - ${OCC_INCLUDE_DIR} - ${NGLIB_INCLUDE_DIR} - ${NETGEN_INCLUDE_DIRS} src/SMDS src/Driver src/DriverUNV @@ -23,6 +16,14 @@ include_directories( src/DriverSTL src/StdMeshers inc + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR} + ${Boost_INCLUDE_DIRS} + ${OCC_INCLUDE_DIR} + ${NGLIB_INCLUDE_DIR} + ${NETGEN_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR} ) link_directories(${OCC_LIBRARY_DIR}) From 5f261fb6361b3727bc99cbd98be4c9d20c53a398 Mon Sep 17 00:00:00 2001 From: wood galaxy Date: Tue, 18 Nov 2014 23:43:53 +0100 Subject: [PATCH 16/18] make compatible with Part typed object tool make a Part Cut object when object are not Arch typed. the cutVolume is now Red and 75 transparence --- src/Mod/Arch/ArchCutPlane.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py index 92389ef27..6381150ab 100644 --- a/src/Mod/Arch/ArchCutPlane.py +++ b/src/Mod/Arch/ArchCutPlane.py @@ -46,8 +46,16 @@ def cutComponentwithPlane(archObject, cutPlane, sideFace): if cutVolume: obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume") obj.Shape = cutVolume + obj.ViewObject.ShapeColor = (1.00,0.00,0.00) + obj.ViewObject.Transparency = 75 # add substraction component to Arch object - return ArchCommands.removeComponents(obj,archObject.Object) + if "Additions" in archObject.Object.PropertiesList: + return ArchCommands.removeComponents(obj,archObject.Object) + else: + cutObj = FreeCAD.ActiveDocument.addObject("Part::Cut", "CutPlane") + cutObj.Base = archObject.Object + cutObj.Tool = obj + return cutObj class _CommandCutPlane: "the Arch CutPlane command definition" From af89ebc80319cc38812426114a88884e2cedb689 Mon Sep 17 00:00:00 2001 From: wood galaxy Date: Wed, 19 Nov 2014 00:57:50 +0100 Subject: [PATCH 17/18] add preview CutVolume in Arch CutPlane --- src/Mod/Arch/ArchCutPlane.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py index 6381150ab..62033b797 100644 --- a/src/Mod/Arch/ArchCutPlane.py +++ b/src/Mod/Arch/ArchCutPlane.py @@ -86,8 +86,16 @@ class _CutPlaneTaskPanel: groupBox = QtGui.QGroupBox() groupBox.setLayout(self.grid) self.form = groupBox + # Connecter la combobox a la fonction preveiwCutVolume + QtCore.QObject.connect(self.combobox,QtCore.SIGNAL("currentIndexChanged(int)"),self.previewCutVolume) + # Ajouter un objet PreveiwCutVolume vide + self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") + # Afficher la preview CutVolume en fonction du choix par defaut de la combobox + self.previewCutVolume(self.combobox.currentIndex()) def accept(self): + # Suppression objet PreviewCutVolume + FreeCAD.ActiveDocument.removeObject(self.obj.Name) val = self.combobox.currentIndex() FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting"))) FreeCADGui.addModule("Arch") @@ -97,11 +105,27 @@ class _CutPlaneTaskPanel: return True def reject(self): + # Suppression objet PreviewCutVolume + FreeCAD.ActiveDocument.removeObject(self.obj.Name) FreeCAD.Console.PrintMessage("Cancel Cut Plane\n") return True def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) + def previewCutVolume(self, i): + cutVolume = ArchCommands.getCutVolume(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0], FreeCADGui.Selection.getSelectionEx()[0].Object.Shape) + FreeCAD.ActiveDocument.removeObject(self.obj.Name) + self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") + #self.obj.Shape = cutVolume + self.obj.ViewObject.ShapeColor = (1.00,0.00,0.00) + self.obj.ViewObject.Transparency = 75 + if i == 1: + cutVolume = cutVolume[1] + else: + cutVolume = cutVolume[2] + if cutVolume: + self.obj.Shape = cutVolume + if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane()) From c5f2e9e56b0850d2be65bc679d83d619c5893fbe Mon Sep 17 00:00:00 2001 From: wood galaxy Date: Fri, 21 Nov 2014 04:30:38 +0100 Subject: [PATCH 18/18] Add PointOnObject constraints to 2-pane window --- src/Mod/Arch/ArchWindow.py | 236 +++++++++++++++++++------------------ 1 file changed, 121 insertions(+), 115 deletions(-) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index d57f9839f..7b490ca2f 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -1,7 +1,7 @@ #*************************************************************************** #* * -#* Copyright (c) 2011 * -#* Yorik van Havre * +#* Copyright (c) 2011 * +#* Yorik van Havre * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * @@ -38,7 +38,7 @@ __url__ = "http://www.freecadweb.org" # presets WindowPartTypes = ["Frame","Solid panel","Glass panel"] AllowedHosts = ["Wall","Structure","Roof"] -WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", +WindowPresets = ["Fixed", "Open 1-pane", "Open 2-pane", "Sash 2-pane", "Sliding 2-pane", "Simple door", "Glass door"] Roles = ["Window","Door"] @@ -88,9 +88,9 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None """makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,[placement]): makes a window object based on the given data. windowtype must be one of the names defined in Arch.WindowPresets""" - + def makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2): - + import Part,Sketcher width = float(width) height = float(height) @@ -106,7 +106,7 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None # glass size divider gla = 10 s = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Sketch') - + def addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8): "adds two rectangles to the given sketch" idx = s.GeometryCount @@ -114,27 +114,27 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None s.addGeometry(Part.Line(p2,p3)) s.addGeometry(Part.Line(p3,p4)) s.addGeometry(Part.Line(p4,p1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx,2,idx+1,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+1,2,idx+2,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+2,2,idx+3,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+3,2,idx,1)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+2)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx,2,idx+1,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+1,2,idx+2,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+2,2,idx+3,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+3,2,idx,1)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+2)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+1)) s.addConstraint(Sketcher.Constraint('Vertical',idx+3)) s.addGeometry(Part.Line(p5,p6)) s.addGeometry(Part.Line(p6,p7)) s.addGeometry(Part.Line(p7,p8)) s.addGeometry(Part.Line(p8,p5)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+4,2,idx+5,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+5,2,idx+6,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+6,2,idx+7,1)) - s.addConstraint(Sketcher.Constraint('Coincident',idx+7,2,idx+4,1)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+4)) - s.addConstraint(Sketcher.Constraint('Horizontal',idx+6)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+5)) - s.addConstraint(Sketcher.Constraint('Vertical',idx+7)) - + s.addConstraint(Sketcher.Constraint('Coincident',idx+4,2,idx+5,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+5,2,idx+6,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+6,2,idx+7,1)) + s.addConstraint(Sketcher.Constraint('Coincident',idx+7,2,idx+4,1)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+4)) + s.addConstraint(Sketcher.Constraint('Horizontal',idx+6)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+5)) + s.addConstraint(Sketcher.Constraint('Vertical',idx+7)) + def outerFrame(s,width,height,h1,w1,o1): p1 = Vector(0,0,0) p2 = Vector(width,0,0) @@ -147,13 +147,13 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 - s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,h1)) s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) return ["OuterFrame","Frame","Wire0,Wire1",str(w1),str(o1)] - + def doorFrame(s,width,height,h1,w1,o1): p1 = Vector(0,0,0) p2 = Vector(width,0,0) @@ -166,17 +166,17 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) s.addConstraint(Sketcher.Constraint('DistanceY',1,height)) #16 s.addConstraint(Sketcher.Constraint('DistanceX',0,width)) #17 - s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceY',6,2,2,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',2,2,6,2,h1)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,2,0,2,h1)) s.addConstraint(Sketcher.Constraint('DistanceY',0,2,4,2,0.0)) s.addConstraint(Sketcher.Constraint('Coincident',0,1,-1,1)) return ["OuterFrame","Frame","Wire0,Wire1",str(w1),str(o1)] - + if windowtype == "Fixed": wp = outerFrame(s,width,height,h1,w1,o1) wp.extend(["Glass","Glass panel","Wire1",str(w1/gla),str(w1/2)]) - + elif windowtype == "Open 1-pane": wp = outerFrame(s,width,height,h1,w1,o1) p1 = Vector(h1+tol,h1+tol,0) @@ -188,23 +188,23 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None p7 = Vector(width-(h1+h2),height-(h1+h2),0) p8 = Vector(h1+h2,height-(h1+h2),0) addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) wp.extend(["InnerFrame","Frame","Wire2,Wire3",str(w2),str(o1+o2)]) wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o1+o2+w2/2)]) - + elif windowtype == "Open 2-pane": wp = outerFrame(s,width,height,h1,w1,o1) p1 = Vector(h1+tol,h1+tol,0) p2 = Vector((width/2)-tol,h1+tol,0) p3 = Vector((width/2)-tol,height-(h1+tol),0) - p4 = Vector(h1+tol,height-(h1+tol),0) + p4 = Vector(h1+tol,height-(h1+tol),0) p5 = Vector(h1+h2,h1+h2,0) p6 = Vector((width/2)-h2,h1+h2,0) p7 = Vector((width/2)-h2,height-(h1+h2),0) @@ -219,25 +219,27 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None p7 = Vector(width-(h1+h2),height-(h1+h2),0) p8 = Vector((width/2)+h2,height-(h1+h2),0) addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('Equal',22,14)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('Equal',22,14)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) + s.addConstraint(Sketcher.Constraint('PointOnObject',20,1,12)) wp.extend(["LeftFrame","Frame","Wire2,Wire3",str(w2),str(o1+o2)]) wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o1+o2+w2/2)]) wp.extend(["RightFrame","Frame","Wire4,Wire5",str(w2),str(o1+o2)]) wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o1+o2+w2/2)]) - + elif windowtype == "Sash 2-pane": wp = outerFrame(s,width,height,h1,w1,o1) p1 = Vector(h1+tol,h1+tol,0) @@ -258,25 +260,27 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None p7 = Vector(width-(h1+h2),height-(h1+h2),0) p8 = Vector(h1+h2,height-(h1+h2),0) addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',16,2,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,2,14,2,-h2)) - s.addConstraint(Sketcher.Constraint('Equal',23,15)) - s.addConstraint(Sketcher.Constraint('DistanceX',12,1,20,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',13,2,20,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',16,2,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,2,14,2,-h2)) + s.addConstraint(Sketcher.Constraint('Equal',23,15)) + s.addConstraint(Sketcher.Constraint('DistanceX',12,1,20,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',13,2,20,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceY',10,1,16,1,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',9,2,17)) + s.addConstraint(Sketcher.Constraint('PointOnObject',16,1,11)) wp.extend(["LowerFrame","Frame","Wire2,Wire3",str(w2),str(o1+o2+w2)]) wp.extend(["LowerGlass","Glass panel","Wire3",str(w2/gla),str(o1+o2+w2+w2/2)]) wp.extend(["UpperFrame","Frame","Wire4,Wire5",str(w2),str(o1+o2)]) wp.extend(["UpperGlass","Glass panel","Wire5",str(w2/gla),str(o1+o2+w2/2)]) - + elif windowtype == "Sliding 2-pane": wp = outerFrame(s,width,height,h1,w1,o1) p1 = Vector(h1+tol,h1+tol,0) @@ -297,29 +301,31 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None p7 = Vector(width-(h1+h2),height-(h1+h2),0) p8 = Vector((width/2)+h2,height-(h1+h2),0) addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('Equal',22,14)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',21,2,17,2,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',16,1,20,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('Equal',22,14)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,2,16,1,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceY',10,1,18,2,0.0)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceY',6,1,18,1,-tol)) s.addConstraint(Sketcher.Constraint('DistanceX',9,1,19,2,tol)) + s.addConstraint(Sketcher.Constraint('PointOnObject',13,2,22)) + s.addConstraint(Sketcher.Constraint('PointOnObject',12,2,20)) wp.extend(["LeftFrame","Frame","Wire2,Wire3",str(w2),str(o1+o2)]) wp.extend(["LeftGlass","Glass panel","Wire3",str(w2/gla),str(o1+o2+w2/2)]) wp.extend(["RightFrame","Frame","Wire4,Wire5",str(w2),str(o1+o2+w2)]) wp.extend(["RightGlass","Glass panel","Wire5",str(w2/gla),str(o1+o2+w2+w2/2)]) - + elif windowtype == "Simple door": wp = doorFrame(s,width,height,h1,w1,o1) wp.extend(["Door","Solid panel","Wire1",str(w2),str(o1+o2)]) - + elif windowtype == "Glass door": wp = doorFrame(s,width,height,h1,w1,o1) p1 = Vector(h1+tol,h1+tol,0) @@ -331,19 +337,19 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None p7 = Vector(width-(h1+h2),height-(h1+h2),0) p8 = Vector(h1+h2,height-(h1+h2),0) addFrame(s,p1,p2,p3,p4,p5,p6,p7,p8) - s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h3)) - s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) - s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',8,1,12,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',8,1,12,1,h3)) + s.addConstraint(Sketcher.Constraint('DistanceX',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceY',14,1,10,1,h2)) + s.addConstraint(Sketcher.Constraint('DistanceX',4,1,8,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',4,1,8,1,tol)) - s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) + s.addConstraint(Sketcher.Constraint('DistanceX',10,1,6,1,tol)) s.addConstraint(Sketcher.Constraint('DistanceY',10,1,6,1,tol)) wp.extend(["InnerFrame","Frame","Wire2,Wire3",str(w2),str(o1+o2)]) wp.extend(["InnerGlass","Glass panel","Wire3",str(w2/gla),str(o1+o2+w2/2)]) - + return (s,wp) - + if windowtype in WindowPresets: default = makeSketch(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2) FreeCAD.ActiveDocument.recompute() @@ -357,7 +363,7 @@ def makeWindowPreset(windowtype,width,height,h1,h2,h3,w1,w2,o1,o2,placement=None obj.Role = "Door" FreeCAD.ActiveDocument.recompute() return obj - + print "Arch: Unknown window type" @@ -391,7 +397,7 @@ class _CommandWindow: self.DECIMALS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2) import DraftGui self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS,'Length') - + # auto mode if sel and FreeCADGui.Selection.getSelectionEx(): obj = sel[0] @@ -415,7 +421,7 @@ class _CommandWindow: host = obj.Support[0] else: host = obj.Support - obj.Support = None # remove + obj.Support = None # remove elif Draft.isClone(obj,"Window"): if obj.Objects[0].Inlist: host = obj.Objects[0].Inlist[0] @@ -511,7 +517,7 @@ class _CommandWindow: ui = FreeCADGui.UiLoader() w.setWindowTitle(translate("Arch","Window options")) grid = QtGui.QGridLayout(w) - + # sill height labels = QtGui.QLabel(translate("Arch","Sill height")) values = ui.createWidget("Gui::InputField") @@ -527,7 +533,7 @@ class _CommandWindow: grid.addWidget(labelp,1,0,1,1) grid.addWidget(valuep,1,1,1,1) QtCore.QObject.connect(valuep,QtCore.SIGNAL("currentIndexChanged(int)"),self.setPreset) - + # image display self.im = QtSvg.QSvgWidget(":/ui/ParametersWindowFixed.svg") self.im.setMaximumWidth(200) @@ -556,10 +562,10 @@ class _CommandWindow: setArchWindowParamFunction('"""+param+"""',d)""") QtCore.QObject.connect(getattr(self,"val"+param),QtCore.SIGNAL("valueChanged(double)"),valueChanged) return w - + def setSill(self,d): self.Sill = d - + def setParams(self,param,d): setattr(self,param,d) self.tracker.length(self.Width) @@ -635,7 +641,7 @@ class _Window(ArchComponent.Component): # because of load order, but it doesn't harm... pass FreeCAD.ActiveDocument.recompute() - + def execute(self,obj): import Part, DraftGeomUtils @@ -690,13 +696,13 @@ class _Window(ArchComponent.Component): base.Placement = base.Placement.multiply(pl) else: print "Arch: Bad formatting of window parts definitions" - + base = self.processSubShapes(obj,base) self.applyShape(obj,base,pl) def getSubVolume(self,obj,plac=None): "returns a subvolume for cutting in a base object" - + # check if we have a custom subvolume if hasattr(obj,"Subvolume"): if obj.Subvolume: @@ -728,10 +734,10 @@ class _Window(ArchComponent.Component): b = base.Shape.BoundBox width = max(b.XLength,b.YLength,b.ZLength) if not width: - width = 1.1112 # some weird value to have little chance to overlap with an existing face + width = 1.1112 # some weird value to have little chance to overlap with an existing face if not base: return None - + # finding biggest wire in the base shape max_length = 0 f = None @@ -768,13 +774,13 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): def getIcon(self): import Arch_rc return ":/icons/Arch_Window_Tree.svg" - + def updateData(self,obj,prop): if (prop in ["WindowParts","Shape"]): if obj.Shape: if not obj.Shape.isNull(): self.colorize(obj) - + def onChanged(self,vobj,prop): if (prop == "DiffuseColor") and vobj.Object: if len(vobj.DiffuseColor) < 2: @@ -793,7 +799,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): taskd.update() FreeCADGui.Control.showDialog(taskd) return True - + def unsetEdit(self,vobj,mode): vobj.DisplayMode = self.sets[0] vobj.Transparency = self.sets[1] @@ -801,7 +807,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent): self.Object.Base.ViewObject.hide() FreeCADGui.Control.closeDialog() return - + def colorize(self,obj): "setting different part colors" solids = obj.Shape.copy().Solids @@ -846,13 +852,13 @@ class _ArchWindowTaskPanel: self.wiretree = QtGui.QTreeWidget(self.form) self.grid.addWidget(self.wiretree, 2, 0, 1, 3) self.wiretree.setColumnCount(1) - self.wiretree.setSelectionMode(QtGui.QAbstractItemView.MultiSelection) + self.wiretree.setSelectionMode(QtGui.QAbstractItemView.MultiSelection) self.comptree = QtGui.QTreeWidget(self.form) self.grid.addWidget(self.comptree, 2, 4, 1, 3) - self.comptree.setColumnCount(1) - - # buttons + self.comptree.setColumnCount(1) + + # buttons self.addButton = QtGui.QPushButton(self.form) self.addButton.setObjectName("addButton") self.addButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg")) @@ -865,7 +871,7 @@ class _ArchWindowTaskPanel: self.grid.addWidget(self.editButton, 3, 2, 1, 3) self.editButton.setMaximumSize(QtCore.QSize(60,40)) self.editButton.setEnabled(False) - + self.delButton = QtGui.QPushButton(self.form) self.delButton.setObjectName("delButton") self.delButton.setIcon(QtGui.QIcon(":/icons/Arch_Remove.svg")) @@ -886,7 +892,7 @@ class _ArchWindowTaskPanel: self.field2 = QtGui.QComboBox(self.form) self.field3 = QtGui.QLineEdit(self.form) self.field4 = ui.createWidget("Gui::InputField") - self.field5 = ui.createWidget("Gui::InputField") + self.field5 = ui.createWidget("Gui::InputField") self.createButton = QtGui.QPushButton(self.form) self.createButton.setObjectName("createButton") self.createButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg")) @@ -898,7 +904,7 @@ class _ArchWindowTaskPanel: self.grid.addWidget(self.new3, 9, 0, 1, 1) self.grid.addWidget(self.field3, 9, 2, 1, 5) self.grid.addWidget(self.new4, 10, 0, 1, 1) - self.grid.addWidget(self.field4, 10, 2, 1, 5) + self.grid.addWidget(self.field4, 10, 2, 1, 5) self.grid.addWidget(self.new5, 11, 0, 1, 1) self.grid.addWidget(self.field5, 11, 2, 1, 5) self.grid.addWidget(self.createButton, 12, 0, 1, 7) @@ -917,7 +923,7 @@ class _ArchWindowTaskPanel: self.field4.setVisible(False) self.field5.setVisible(False) self.createButton.setVisible(False) - + QtCore.QObject.connect(self.addButton, QtCore.SIGNAL("clicked()"), self.addElement) QtCore.QObject.connect(self.delButton, QtCore.SIGNAL("clicked()"), self.removeElement) QtCore.QObject.connect(self.editButton, QtCore.SIGNAL("clicked()"), self.editElement) @@ -940,7 +946,7 @@ class _ArchWindowTaskPanel: def check(self,wid,col): self.editButton.setEnabled(True) self.delButton.setEnabled(True) - + def select(self,wid,col): FreeCADGui.Selection.clearSelection() ws = '' @@ -956,7 +962,7 @@ class _ArchWindowTaskPanel: if e.hashCode() == self.obj.Base.Shape.Edges[i].hashCode(): FreeCADGui.Selection.addSelection(self.obj.Base,"Edge"+str(i+1)) self.field3.setText(ws) - + def getIcon(self,obj): if hasattr(obj.ViewObject,"Proxy"): return QtGui.QIcon(obj.ViewObject.Proxy.getIcon()) @@ -1075,7 +1081,7 @@ class _ArchWindowTaskPanel: except (ValueError,TypeError): ok = False ar.append(t) - + if ok: if self.obj: parts = self.obj.WindowParts @@ -1089,7 +1095,7 @@ class _ArchWindowTaskPanel: self.update() else: FreeCAD.Console.PrintWarning(translate("Arch", "Unable to create component\n")) - + self.newtitle.setVisible(False) self.new1.setVisible(False) self.new2.setVisible(False) @@ -1103,12 +1109,12 @@ class _ArchWindowTaskPanel: self.field5.setVisible(False) self.createButton.setVisible(False) self.addButton.setEnabled(True) - + def reject(self): FreeCAD.ActiveDocument.recompute() FreeCADGui.ActiveDocument.resetEdit() return True - + def retranslateUi(self, TaskPanel): TaskPanel.setWindowTitle(QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)) self.delButton.setText(QtGui.QApplication.translate("Arch", "Remove", None, QtGui.QApplication.UnicodeUTF8)) @@ -1127,5 +1133,5 @@ class _ArchWindowTaskPanel: for i in range(len(WindowPartTypes)): self.field2.setItemText(i, QtGui.QApplication.translate("Arch", WindowPartTypes[i], None, QtGui.QApplication.UnicodeUTF8)) -if FreeCAD.GuiUp: +if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Window',_CommandWindow())