Merge branch 'master' of git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
b6ad772ade
|
@ -38,6 +38,7 @@
|
|||
#include "Body.h"
|
||||
#include "FeatureDressUp.h"
|
||||
#include "FeatureChamfer.h"
|
||||
#include "FeatureDraft.h"
|
||||
#include "FeatureFace.h"
|
||||
#include "FeatureSubtractive.h"
|
||||
#include "FeatureAdditive.h"
|
||||
|
@ -96,6 +97,7 @@ void PartDesignExport initPartDesign()
|
|||
PartDesign::Groove ::init();
|
||||
PartDesign::Chamfer ::init();
|
||||
PartDesign::Face ::init();
|
||||
PartDesign::Draft ::init();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
|
|
@ -51,6 +51,8 @@ SET(FeaturesDressUp_SRCS
|
|||
FeatureFillet.h
|
||||
FeatureChamfer.cpp
|
||||
FeatureChamfer.h
|
||||
FeatureDraft.cpp
|
||||
FeatureDraft.h
|
||||
)
|
||||
SOURCE_GROUP("DressUpFeatures" FILES ${FeaturesDressUp_SRCS})
|
||||
|
||||
|
|
295
src/Mod/PartDesign/App/FeatureDraft.cpp
Normal file
295
src/Mod/PartDesign/App/FeatureDraft.cpp
Normal file
|
@ -0,0 +1,295 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRepOffsetAPI_DraftAngle.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <gp_Ax1.hxx>
|
||||
//# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <gp_Pln.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <GeomAbs_SurfaceType.hxx>
|
||||
# include <GeomAPI_IntSS.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
# include <Geom_Curve.hxx>
|
||||
# include <Geom_Line.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "FeatureDraft.h"
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
|
||||
PROPERTY_SOURCE(PartDesign::Draft, PartDesign::DressUp)
|
||||
|
||||
const App::PropertyFloatConstraint::Constraints floatAngle = {0.0f,89.99f,0.1f};
|
||||
|
||||
Draft::Draft()
|
||||
{
|
||||
ADD_PROPERTY(Angle,(1.5f));
|
||||
Angle.setConstraints(&floatAngle);
|
||||
ADD_PROPERTY_TYPE(NeutralPlane,(0),"Draft",(App::PropertyType)(App::Prop_None),"NeutralPlane");
|
||||
ADD_PROPERTY_TYPE(PullDirection,(0),"Draft",(App::PropertyType)(App::Prop_None),"PullDirection");
|
||||
ADD_PROPERTY(Reversed,(0));
|
||||
}
|
||||
|
||||
short Draft::mustExecute() const
|
||||
{
|
||||
if (Placement.isTouched() ||
|
||||
Angle.isTouched() ||
|
||||
NeutralPlane.isTouched() ||
|
||||
PullDirection.isTouched() ||
|
||||
Reversed.isTouched())
|
||||
return 1;
|
||||
return DressUp::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Draft::execute(void)
|
||||
{
|
||||
// Get parameters
|
||||
// Base shape
|
||||
App::DocumentObject* link = Base.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No object linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
|
||||
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
if (TopShape._Shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Cannot draft invalid shape");
|
||||
|
||||
// Faces where draft should be applied
|
||||
// Note: Cannot be const reference currently because of BRepOffsetAPI_DraftAngle::Remove() bug, see below
|
||||
std::vector<std::string> SubVals = Base.getSubValuesStartsWith("Face");
|
||||
if (SubVals.size() == 0)
|
||||
return new App::DocumentObjectExecReturn("No faces specified");
|
||||
|
||||
// Draft angle
|
||||
float angle = Angle.getValue() / 180.0 * M_PI;
|
||||
|
||||
// Pull direction
|
||||
gp_Dir pullDirection;
|
||||
App::DocumentObject* refDirection = PullDirection.getValue();
|
||||
if (refDirection != NULL) {
|
||||
if (!refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::Exception("Pull direction reference must be an edge of a feature");
|
||||
std::vector<std::string> subStrings = PullDirection.getSubValues();
|
||||
if (subStrings.empty() || subStrings[0].empty())
|
||||
throw Base::Exception("No pull direction reference specified");
|
||||
|
||||
Part::Feature* refFeature = static_cast<Part::Feature*>(refDirection);
|
||||
Part::TopoShape refShape = refFeature->Shape.getShape();
|
||||
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
|
||||
|
||||
if (ref.ShapeType() == TopAbs_EDGE) {
|
||||
TopoDS_Edge refEdge = TopoDS::Edge(ref);
|
||||
if (refEdge.IsNull())
|
||||
throw Base::Exception("Failed to extract pull direction reference edge");
|
||||
BRepAdaptor_Curve adapt(refEdge);
|
||||
if (adapt.GetType() != GeomAbs_Line)
|
||||
throw Base::Exception("Pull direction reference edge must be linear");
|
||||
|
||||
pullDirection = adapt.Line().Direction();
|
||||
} else {
|
||||
throw Base::Exception("Pull direction reference must be an edge");
|
||||
}
|
||||
|
||||
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
||||
pullDirection.Transform(invObjLoc.Transformation());
|
||||
}
|
||||
|
||||
// Neutral plane
|
||||
gp_Pln neutralPlane;
|
||||
App::DocumentObject* refPlane = NeutralPlane.getValue();
|
||||
if (refPlane == NULL) {
|
||||
// Try to guess a neutral plane from the first selected face
|
||||
// Get edges of first selected face
|
||||
TopoDS_Shape face = TopShape.getSubShape(SubVals[0].c_str());
|
||||
TopTools_IndexedMapOfShape mapOfEdges;
|
||||
TopExp::MapShapes(face, TopAbs_EDGE, mapOfEdges);
|
||||
bool found;
|
||||
|
||||
for (int i = 1; i <= mapOfEdges.Extent(); i++) {
|
||||
// Note: What happens if mapOfEdges(i) is the degenerated edge of a cone?
|
||||
// But in that case the draft is not possible anyway!
|
||||
BRepAdaptor_Curve c(TopoDS::Edge(mapOfEdges(i)));
|
||||
gp_Pnt p1 = c.Value(c.FirstParameter());
|
||||
gp_Pnt p2 = c.Value(c.LastParameter());
|
||||
|
||||
if (c.IsClosed()) {
|
||||
// Edge is a circle or a circular arc (other types are not allowed for drafting)
|
||||
neutralPlane = gp_Pln(p1, c.Circle().Axis().Direction());
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
// Edge is linear
|
||||
// Find midpoint of edge and create auxiliary plane through midpoint normal to edge
|
||||
gp_Pnt pm = c.Value((c.FirstParameter() + c.LastParameter()) / 2.0);
|
||||
Handle_Geom_Plane aux = new Geom_Plane(pm, gp_Dir(p2.X() - p1.X(), p2.Y() - p1.Y(), p2.Z() - p1.Z()));
|
||||
// Intersect plane with face. Is there no easier way?
|
||||
BRepAdaptor_Surface adapt(TopoDS::Face(face), Standard_False);
|
||||
Handle_Geom_Surface sf = adapt.Surface().Surface();
|
||||
GeomAPI_IntSS intersector(aux, sf, Precision::Confusion());
|
||||
if (!intersector.IsDone())
|
||||
continue;
|
||||
Handle_Geom_Curve icurve = intersector.Line(1);
|
||||
if (!icurve->IsKind(STANDARD_TYPE(Geom_Line)))
|
||||
continue;
|
||||
// TODO: How to extract the line from icurve without creating an edge first?
|
||||
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(icurve);
|
||||
BRepAdaptor_Curve c(edge);
|
||||
neutralPlane = gp_Pln(pm, c.Line().Direction());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
throw Base::Exception("No neutral plane specified and none can be guessed");
|
||||
} else {
|
||||
if (!refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::Exception("Neutral plane reference must be face of a feature");
|
||||
std::vector<std::string> subStrings = NeutralPlane.getSubValues();
|
||||
if (subStrings.empty() || subStrings[0].empty())
|
||||
throw Base::Exception("No neutral plane reference specified");
|
||||
|
||||
Part::Feature* refFeature = static_cast<Part::Feature*>(refPlane);
|
||||
Part::TopoShape refShape = refFeature->Shape.getShape();
|
||||
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
|
||||
|
||||
if (ref.ShapeType() == TopAbs_FACE) {
|
||||
TopoDS_Face refFace = TopoDS::Face(ref);
|
||||
if (refFace.IsNull())
|
||||
throw Base::Exception("Failed to extract neutral plane reference face");
|
||||
BRepAdaptor_Surface adapt(refFace);
|
||||
if (adapt.GetType() != GeomAbs_Plane)
|
||||
throw Base::Exception("Neutral plane reference face must be planar");
|
||||
|
||||
neutralPlane = adapt.Plane();
|
||||
} else if (ref.ShapeType() == TopAbs_EDGE) {
|
||||
if (refDirection != NULL) {
|
||||
// Create neutral plane through edge normal to pull direction
|
||||
TopoDS_Edge refEdge = TopoDS::Edge(ref);
|
||||
if (refEdge.IsNull())
|
||||
throw Base::Exception("Failed to extract neutral plane reference edge");
|
||||
BRepAdaptor_Curve c(refEdge);
|
||||
if (!c.GetType() == GeomAbs_Line)
|
||||
throw Base::Exception("Neutral plane reference edge must be linear");
|
||||
double a = c.Line().Angle(gp_Lin(c.Value(c.FirstParameter()), pullDirection));
|
||||
if (std::fabs(a - M_PI_2) > Precision::Confusion())
|
||||
throw Base::Exception("Neutral plane reference edge must be normal to pull direction");
|
||||
neutralPlane = gp_Pln(c.Value(c.FirstParameter()), pullDirection);
|
||||
} else {
|
||||
throw Base::Exception("Neutral plane reference can only be an edge if pull direction is defined");
|
||||
}
|
||||
} else {
|
||||
throw Base::Exception("Neutral plane reference must be a face");
|
||||
}
|
||||
|
||||
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
||||
neutralPlane.Transform(invObjLoc.Transformation());
|
||||
}
|
||||
|
||||
if (refDirection == NULL) {
|
||||
// Choose pull direction normal to neutral plane
|
||||
pullDirection = neutralPlane.Axis().Direction();
|
||||
}
|
||||
|
||||
// Reversed pull direction
|
||||
bool reversed = Reversed.getValue();
|
||||
if (reversed)
|
||||
angle *= -1.0;
|
||||
|
||||
this->positionByBase();
|
||||
// create an untransformed copy of the base shape
|
||||
Part::TopoShape baseShape(TopShape);
|
||||
baseShape.setTransform(Base::Matrix4D());
|
||||
try {
|
||||
BRepOffsetAPI_DraftAngle mkDraft;
|
||||
// Note:
|
||||
// LocOpe_SplitDrafts can split a face with a wire and apply draft to both parts
|
||||
// Not clear though whether the face must have free boundaries
|
||||
// LocOpe_DPrism can create a stand-alone draft prism. The sketch can only have a single
|
||||
// wire, though.
|
||||
// BRepFeat_MakeDPrism requires a support for the operation but will probably support multiple
|
||||
// wires in the sketch
|
||||
|
||||
bool success;
|
||||
|
||||
do {
|
||||
success = true;
|
||||
mkDraft.Init(baseShape._Shape);
|
||||
|
||||
for (std::vector<std::string>::iterator it=SubVals.begin(); it != SubVals.end(); ++it) {
|
||||
TopoDS_Face face = TopoDS::Face(baseShape.getSubShape(it->c_str()));
|
||||
// TODO: What is the flag for?
|
||||
mkDraft.Add(face, pullDirection, angle, neutralPlane);
|
||||
if (!mkDraft.AddDone()) {
|
||||
// Note: the function ProblematicShape returns the face on which the error occurred
|
||||
// Note: mkDraft.Remove() stumbles on a bug in Draft_Modification::Remove() and is
|
||||
// therefore unusable. See https://sourceforge.net/apps/phpbb/free-cad/viewtopic.php?f=10&t=3209&start=10#p25341
|
||||
// The only solution is to discard mkDraft and start over without the current face
|
||||
// mkDraft.Remove(face);
|
||||
Base::Console().Error("Adding face failed on %s. Omitted\n", it->c_str());
|
||||
success = false;
|
||||
SubVals.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!success);
|
||||
|
||||
mkDraft.Build();
|
||||
if (!mkDraft.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Failed to create draft");
|
||||
|
||||
TopoDS_Shape shape = mkDraft.Shape();
|
||||
if (shape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Resulting shape is null");
|
||||
|
||||
this->Shape.setValue(shape);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
61
src/Mod/PartDesign/App/FeatureDraft.h
Normal file
61
src/Mod/PartDesign/App/FeatureDraft.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTDESIGN_FEATUREDRAFT_H
|
||||
#define PARTDESIGN_FEATUREDRAFT_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "FeatureDressUp.h"
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
||||
class PartDesignExport Draft : public DressUp
|
||||
{
|
||||
PROPERTY_HEADER(PartDesign::Draft);
|
||||
|
||||
public:
|
||||
Draft();
|
||||
|
||||
App::PropertyFloatConstraint Angle;
|
||||
App::PropertyLinkSub NeutralPlane;
|
||||
App::PropertyLinkSub PullDirection;
|
||||
App::PropertyBool Reversed;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderDraft";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
||||
|
||||
#endif // PARTDESIGN_FEATUREDRAFT_H
|
|
@ -33,6 +33,7 @@
|
|||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Cut.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Axis.h>
|
||||
|
@ -76,12 +77,12 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
return new App::DocumentObjectExecReturn("Angle of groove too small");
|
||||
if (angle > 360.0)
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too large");
|
||||
|
||||
|
||||
angle = Base::toRadians<double>(angle);
|
||||
// Reverse angle if selected
|
||||
if (Reversed.getValue() && !Midplane.getValue())
|
||||
angle *= (-1.0);
|
||||
|
||||
|
||||
Part::Part2DObject* sketch = 0;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
TopoDS_Shape support;
|
||||
|
@ -152,6 +153,10 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
support.Move(invObjLoc);
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||
if (checkLineCrossesFace(gp_Lin(pnt, dir), TopoDS::Face(sketchshape)))
|
||||
return new App::DocumentObjectExecReturn("Revolve axis intersects the sketch");
|
||||
|
||||
// revolve the face to a solid
|
||||
BRepPrimAPI_MakeRevol RevolMaker(sketchshape, gp_Ax1(pnt, dir), angle);
|
||||
|
||||
|
@ -159,7 +164,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
TopoDS_Shape result = RevolMaker.Shape();
|
||||
// set the subtractive shape property for later usage in e.g. pattern
|
||||
this->SubShape.setValue(result);
|
||||
|
||||
|
||||
// cut out groove to get one result object
|
||||
BRepAlgoAPI_Cut mkCut(support, result);
|
||||
// Let's check if the fusion has been successful
|
||||
|
@ -181,7 +186,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
if (std::string(e->GetMessageString()) == "TopoDS::Face")
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
"Intersecting sketch entities or multiple faces in a sketch are not allowed.");
|
||||
else
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
|
|
|
@ -141,6 +141,8 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
|||
// because the feature does not add any material. This only happens with the "2" option, though
|
||||
// Note: It might be possible to pass a shell or a compound containing multiple faces
|
||||
// as the Until parameter of Perform()
|
||||
// Note: Multiple independent wires are not supported, we should check for that and
|
||||
// warn the user
|
||||
BRepFeat_MakePrism PrismMaker;
|
||||
PrismMaker.Init(support, sketchshape, supportface, dir, 2, 1);
|
||||
PrismMaker.Perform(upToFace);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
# include <TopExp_Explorer.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Axis.h>
|
||||
|
@ -40,6 +41,7 @@
|
|||
#include <Base/Tools.h>
|
||||
|
||||
#include "FeatureRevolution.h"
|
||||
#include <Base/Console.h>
|
||||
|
||||
|
||||
using namespace PartDesign;
|
||||
|
@ -76,12 +78,12 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
return new App::DocumentObjectExecReturn("Angle of groove too small");
|
||||
if (angle > 360.0)
|
||||
return new App::DocumentObjectExecReturn("Angle of groove too large");
|
||||
|
||||
|
||||
angle = Base::toRadians<double>(angle);
|
||||
// Reverse angle if selected
|
||||
if (Reversed.getValue() && !Midplane.getValue())
|
||||
angle *= (-1.0);
|
||||
|
||||
|
||||
Part::Part2DObject* sketch = 0;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
try {
|
||||
|
@ -90,7 +92,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
} catch (const Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
|
||||
TopoDS_Shape support;
|
||||
try {
|
||||
support = getSupportShape();
|
||||
|
@ -158,6 +160,10 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
support.Move(invObjLoc);
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||
if (checkLineCrossesFace(gp_Lin(pnt, dir), TopoDS::Face(sketchshape)))
|
||||
return new App::DocumentObjectExecReturn("Revolve axis intersects the sketch");
|
||||
|
||||
// revolve the face to a solid
|
||||
BRepPrimAPI_MakeRevol RevolMaker(sketchshape, gp_Ax1(pnt, dir), angle);
|
||||
|
||||
|
@ -186,7 +192,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
if (std::string(e->GetMessageString()) == "TopoDS::Face")
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
"Intersecting sketch entities or multiple faces in a sketch are not allowed.");
|
||||
else
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
|
|
|
@ -52,6 +52,12 @@
|
|||
# include <ShapeAnalysis_Surface.hxx>
|
||||
# include <ShapeFix_Shape.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
# include <Extrema_ExtCC.hxx>
|
||||
# include <Extrema_POnCurv.hxx>
|
||||
# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -532,6 +538,65 @@ const bool SketchBased::checkWireInsideFace(const TopoDS_Wire& wire, const TopoD
|
|||
return (proj.More() && proj.Current().Closed());
|
||||
}
|
||||
|
||||
const bool SketchBased::checkLineCrossesFace(const gp_Lin &line, const TopoDS_Face &face) {
|
||||
// This is not as easy as it looks, because a distance of zero might be OK if
|
||||
// the axis touches the sketchshape in in a linear edge or a vertex
|
||||
// Note: This algorithm does not catch cases where the sketchshape touches the
|
||||
// axis in two or more points
|
||||
// Note: And it only works on closed outer wires
|
||||
TopoDS_Wire outerWire = ShapeAnalysis::OuterWire(face);
|
||||
BRepBuilderAPI_MakeEdge mkEdge(line);
|
||||
if (!mkEdge.IsDone())
|
||||
throw Base::Exception("Revolve: Unexpected OCE failure");
|
||||
BRepAdaptor_Curve axis(TopoDS::Edge(mkEdge.Shape()));
|
||||
|
||||
TopExp_Explorer ex;
|
||||
int intersections = 0;
|
||||
std::vector<gp_Pnt> intersectionpoints;
|
||||
|
||||
// Note: We need to look at evey edge separately to catch coincident lines
|
||||
for (ex.Init(outerWire, TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
BRepAdaptor_Curve edge(TopoDS::Edge(ex.Current()));
|
||||
Extrema_ExtCC intersector(axis, edge);
|
||||
|
||||
if (intersector.IsDone()) {
|
||||
for (int i = 1; i <= intersector.NbExt(); i++) {
|
||||
|
||||
|
||||
#if OCC_VERSION_HEX >= 0x060500
|
||||
if (intersector.SquareDistance(i) < Precision::Confusion()) {
|
||||
#else
|
||||
if (intersector.Value(i) < Precision::Confusion()) {
|
||||
#endif
|
||||
if (intersector.IsParallel()) {
|
||||
// A line that is coincident with the axis produces three intersections
|
||||
// 1 with the line itself and 2 with the adjacent edges
|
||||
intersections -= 2;
|
||||
} else {
|
||||
Extrema_POnCurv p1, p2;
|
||||
intersector.Points(i, p1, p2);
|
||||
intersectionpoints.push_back(p1.Value());
|
||||
intersections++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note: We might check this inside the loop but then we have to rely on TopExp_Explorer
|
||||
// returning the wire's edges in adjacent order (because of the coincident line checking)
|
||||
if (intersections > 1) {
|
||||
// Check that we don't touch the sketchface just in two identical vertices
|
||||
if ((intersectionpoints.size() == 2) &&
|
||||
(intersectionpoints[0].IsEqual(intersectionpoints[1], Precision::Confusion())))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SketchBased::remapSupportShape(const TopoDS_Shape& newShape)
|
||||
{
|
||||
TopTools_IndexedMapOfShape faceMap;
|
||||
|
|
|
@ -32,6 +32,7 @@ class TopoDS_Shape;
|
|||
class TopoDS_Face;
|
||||
class TopoDS_Wire;
|
||||
class gp_Dir;
|
||||
class gp_Lin;
|
||||
|
||||
namespace PartDesign
|
||||
{
|
||||
|
@ -102,7 +103,7 @@ protected:
|
|||
const std::string& method,
|
||||
const gp_Dir& direction,
|
||||
const double L,
|
||||
const double L2,
|
||||
const double L2,
|
||||
const bool midplane,
|
||||
const bool reversed);
|
||||
|
||||
|
@ -110,6 +111,10 @@ protected:
|
|||
static const bool checkWireInsideFace(const TopoDS_Wire& wire,
|
||||
const TopoDS_Face& face,
|
||||
const gp_Dir& dir);
|
||||
|
||||
/// Check whether the line crosses the face (line and face must be on the same plane)
|
||||
static const bool checkLineCrossesFace(const gp_Lin& line, const TopoDS_Face& face);
|
||||
|
||||
};
|
||||
|
||||
} //namespace PartDesign
|
||||
|
|
|
@ -15,6 +15,8 @@ libPartDesign_la_SOURCES=\
|
|||
FeaturePocket.h \
|
||||
FeatureChamfer.cpp \
|
||||
FeatureChamfer.h \
|
||||
FeatureDraft.cpp \
|
||||
FeatureDraft.h \
|
||||
FeatureDressUp.cpp \
|
||||
FeatureDressUp.h \
|
||||
FeatureGroove.cpp \
|
||||
|
|
|
@ -41,12 +41,14 @@ SET(WizardShaft_SRCS
|
|||
)
|
||||
SOURCE_GROUP("wizardshaft" FILES ${WizardShaft_SRCS})
|
||||
|
||||
SET(all_files ${WizardShaft_SRCS})
|
||||
SET(all_wizardshaft_files ${WizardShaft_SRCS})
|
||||
|
||||
ADD_CUSTOM_TARGET(WizardShaft ALL
|
||||
SOURCES ${all_files}
|
||||
SOURCES ${all_wizardshaft_files}
|
||||
)
|
||||
|
||||
SET(all_files ${all_wizardshaft_files})
|
||||
|
||||
fc_copy_sources(Mod/PartDesign "${CMAKE_BINARY_DIR}/Mod/PartDesign" ${all_files})
|
||||
|
||||
INSTALL(
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "ViewProviderPad.h"
|
||||
#include "ViewProviderChamfer.h"
|
||||
#include "ViewProviderFillet.h"
|
||||
#include "ViewProviderDraft.h"
|
||||
#include "ViewProviderRevolution.h"
|
||||
#include "ViewProviderGroove.h"
|
||||
#include "ViewProviderMirrored.h"
|
||||
|
@ -92,6 +93,7 @@ void PartDesignGuiExport initPartDesignGui()
|
|||
PartDesignGui::ViewProviderGroove ::init();
|
||||
PartDesignGui::ViewProviderChamfer ::init();
|
||||
PartDesignGui::ViewProviderFillet ::init();
|
||||
PartDesignGui::ViewProviderDraft ::init();
|
||||
PartDesignGui::ViewProviderMirrored ::init();
|
||||
PartDesignGui::ViewProviderLinearPattern ::init();
|
||||
PartDesignGui::ViewProviderPolarPattern ::init();
|
||||
|
|
|
@ -31,6 +31,7 @@ set(PartDesignGui_MOC_HDRS
|
|||
TaskPocketParameters.h
|
||||
TaskChamferParameters.h
|
||||
TaskFilletParameters.h
|
||||
TaskDraftParameters.h
|
||||
TaskHoleParameters.h
|
||||
TaskRevolutionParameters.h
|
||||
TaskGrooveParameters.h
|
||||
|
@ -53,6 +54,7 @@ set(PartDesignGui_UIC_SRCS
|
|||
TaskPocketParameters.ui
|
||||
TaskChamferParameters.ui
|
||||
TaskFilletParameters.ui
|
||||
TaskDraftParameters.ui
|
||||
TaskHoleParameters.ui
|
||||
TaskRevolutionParameters.ui
|
||||
TaskGrooveParameters.ui
|
||||
|
@ -78,6 +80,8 @@ SET(PartDesignGuiViewProvider_SRCS
|
|||
ViewProviderChamfer.h
|
||||
ViewProviderFillet.cpp
|
||||
ViewProviderFillet.h
|
||||
ViewProviderDraft.cpp
|
||||
ViewProviderDraft.h
|
||||
ViewProviderRevolution.cpp
|
||||
ViewProviderRevolution.h
|
||||
ViewProviderGroove.cpp
|
||||
|
@ -115,6 +119,9 @@ SET(PartDesignGuiTaskDlgs_SRCS
|
|||
TaskFilletParameters.ui
|
||||
TaskFilletParameters.cpp
|
||||
TaskFilletParameters.h
|
||||
TaskDraftParameters.ui
|
||||
TaskDraftParameters.cpp
|
||||
TaskDraftParameters.h
|
||||
TaskRevolutionParameters.ui
|
||||
TaskRevolutionParameters.cpp
|
||||
TaskRevolutionParameters.h
|
||||
|
|
|
@ -20,40 +20,41 @@
|
|||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopTools_ListOfShape.hxx>
|
||||
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Edge.hxx>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopTools_ListOfShape.hxx>
|
||||
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
|
||||
#include <Mod/Part/App/Part2DObject.h>
|
||||
#include <Mod/PartDesign/App/FeatureAdditive.h>
|
||||
#include <Mod/PartDesign/App/FeatureSubtractive.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "FeaturePickDialog.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "FeaturePickDialog.h"
|
||||
|
||||
namespace Gui {
|
||||
//===========================================================================
|
||||
// Common utility functions
|
||||
|
@ -62,7 +63,7 @@ namespace Gui {
|
|||
// Take a list of Part2DObjects and erase those which are not eligible for creating a
|
||||
// SketchBased feature. If supportRequired is true, also erase those that cannot be used to define
|
||||
// a Subtractive feature
|
||||
void validateSketches(std::vector<App::DocumentObject*>& sketches, const bool supportRequired)
|
||||
void validateSketches(std::vector<App::DocumentObject*>& sketches, const bool supportRequired)
|
||||
{
|
||||
std::vector<App::DocumentObject*>::iterator s = sketches.begin();
|
||||
|
||||
|
@ -448,130 +449,130 @@ CmdPartDesignFillet::CmdPartDesignFillet()
|
|||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Fillet";
|
||||
}
|
||||
|
||||
void CmdPartDesignFillet::activated(int iMsg)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Fillet works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
if (TopShape._Shape.IsNull()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Shape of selected Part is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfEdges;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
|
||||
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
|
||||
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
|
||||
|
||||
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i < SubNames.size())
|
||||
{
|
||||
std::string aSubName = static_cast<std::string>(SubNames.at(i));
|
||||
|
||||
if (aSubName.size() > 4 && aSubName.substr(0,4) == "Edge") {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(aSubName.c_str()));
|
||||
const TopTools_ListOfShape& los = mapEdgeFace.FindFromKey(edge);
|
||||
|
||||
if(los.Extent() != 2)
|
||||
{
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TopoDS_Shape& face1 = los.First();
|
||||
const TopoDS_Shape& face2 = los.Last();
|
||||
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
|
||||
TopoDS::Face(face1),
|
||||
TopoDS::Face(face2));
|
||||
if (cont != GeomAbs_C0) {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfFaces;
|
||||
TopExp::MapShapes(face, TopAbs_EDGE, mapOfFaces);
|
||||
|
||||
for(int j = 1; j <= mapOfFaces.Extent(); ++j) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(mapOfFaces.FindKey(j));
|
||||
|
||||
int id = mapOfEdges.FindIndex(edge);
|
||||
|
||||
std::stringstream buf;
|
||||
buf << "Edge";
|
||||
buf << id;
|
||||
|
||||
if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end())
|
||||
{
|
||||
SubNames.push_back(buf.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
// empty name or any other sub-element
|
||||
else {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
}
|
||||
|
||||
if (SubNames.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No fillet possible on selected faces/edges"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string SelString;
|
||||
SelString += "(App.";
|
||||
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
|
||||
SelString += ".";
|
||||
SelString += selection[0].getFeatName();
|
||||
SelString += ",[";
|
||||
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
SelString += "\"";
|
||||
SelString += *it;
|
||||
SelString += "\"";
|
||||
if(it != --SubNames.end())
|
||||
SelString += ",";
|
||||
}
|
||||
SelString += "])";
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Fillet");
|
||||
|
||||
openCommand("Make Fillet");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Fillet\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
|
||||
}
|
||||
|
||||
void CmdPartDesignFillet::activated(int iMsg)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Fillet works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
if (TopShape._Shape.IsNull()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Shape of selected Part is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfEdges;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
|
||||
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
|
||||
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
|
||||
|
||||
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i < SubNames.size())
|
||||
{
|
||||
std::string aSubName = static_cast<std::string>(SubNames.at(i));
|
||||
|
||||
if (aSubName.size() > 4 && aSubName.substr(0,4) == "Edge") {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(aSubName.c_str()));
|
||||
const TopTools_ListOfShape& los = mapEdgeFace.FindFromKey(edge);
|
||||
|
||||
if(los.Extent() != 2)
|
||||
{
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TopoDS_Shape& face1 = los.First();
|
||||
const TopoDS_Shape& face2 = los.Last();
|
||||
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
|
||||
TopoDS::Face(face1),
|
||||
TopoDS::Face(face2));
|
||||
if (cont != GeomAbs_C0) {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfFaces;
|
||||
TopExp::MapShapes(face, TopAbs_EDGE, mapOfFaces);
|
||||
|
||||
for(int j = 1; j <= mapOfFaces.Extent(); ++j) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(mapOfFaces.FindKey(j));
|
||||
|
||||
int id = mapOfEdges.FindIndex(edge);
|
||||
|
||||
std::stringstream buf;
|
||||
buf << "Edge";
|
||||
buf << id;
|
||||
|
||||
if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end())
|
||||
{
|
||||
SubNames.push_back(buf.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
// empty name or any other sub-element
|
||||
else {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
}
|
||||
|
||||
if (SubNames.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No fillet possible on selected faces/edges"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string SelString;
|
||||
SelString += "(App.";
|
||||
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
|
||||
SelString += ".";
|
||||
SelString += selection[0].getFeatName();
|
||||
SelString += ",[";
|
||||
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
SelString += "\"";
|
||||
SelString += *it;
|
||||
SelString += "\"";
|
||||
if(it != --SubNames.end())
|
||||
SelString += ",";
|
||||
}
|
||||
SelString += "])";
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Fillet");
|
||||
|
||||
openCommand("Make Fillet");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Fillet\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
|
||||
}
|
||||
|
||||
bool CmdPartDesignFillet::isActive(void)
|
||||
{
|
||||
|
@ -594,137 +595,248 @@ CmdPartDesignChamfer::CmdPartDesignChamfer()
|
|||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Chamfer";
|
||||
}
|
||||
|
||||
void CmdPartDesignChamfer::activated(int iMsg)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Chamfer works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
|
||||
if (TopShape._Shape.IsNull()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Shape of selected part is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfEdges;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
|
||||
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
|
||||
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
|
||||
|
||||
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i < SubNames.size())
|
||||
{
|
||||
std::string aSubName = static_cast<std::string>(SubNames.at(i));
|
||||
|
||||
if (aSubName.size() > 4 && aSubName.substr(0,4) == "Edge") {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(aSubName.c_str()));
|
||||
const TopTools_ListOfShape& los = mapEdgeFace.FindFromKey(edge);
|
||||
|
||||
if(los.Extent() != 2)
|
||||
{
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TopoDS_Shape& face1 = los.First();
|
||||
const TopoDS_Shape& face2 = los.Last();
|
||||
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
|
||||
TopoDS::Face(face1),
|
||||
TopoDS::Face(face2));
|
||||
if (cont != GeomAbs_C0) {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfFaces;
|
||||
TopExp::MapShapes(face, TopAbs_EDGE, mapOfFaces);
|
||||
|
||||
for(int j = 1; j <= mapOfFaces.Extent(); ++j) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(mapOfFaces.FindKey(j));
|
||||
|
||||
int id = mapOfEdges.FindIndex(edge);
|
||||
|
||||
std::stringstream buf;
|
||||
buf << "Edge";
|
||||
buf << id;
|
||||
|
||||
if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end())
|
||||
{
|
||||
SubNames.push_back(buf.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
// empty name or any other sub-element
|
||||
else {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
}
|
||||
|
||||
if (SubNames.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No chamfer possible on selected faces/edges"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string SelString;
|
||||
SelString += "(App.";
|
||||
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
|
||||
SelString += ".";
|
||||
SelString += selection[0].getFeatName();
|
||||
SelString += ",[";
|
||||
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
SelString += "\"";
|
||||
SelString += *it;
|
||||
SelString += "\"";
|
||||
if(it != --SubNames.end())
|
||||
SelString += ",";
|
||||
}
|
||||
SelString += "])";
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Chamfer");
|
||||
|
||||
openCommand("Make Chamfer");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Chamfer\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
|
||||
}
|
||||
|
||||
void CmdPartDesignChamfer::activated(int iMsg)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() != 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Chamfer works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
|
||||
if (TopShape._Shape.IsNull()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Shape of selected part is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfEdges;
|
||||
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeFace;
|
||||
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_FACE, mapEdgeFace);
|
||||
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
|
||||
|
||||
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i < SubNames.size())
|
||||
{
|
||||
std::string aSubName = static_cast<std::string>(SubNames.at(i));
|
||||
|
||||
if (aSubName.size() > 4 && aSubName.substr(0,4) == "Edge") {
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(aSubName.c_str()));
|
||||
const TopTools_ListOfShape& los = mapEdgeFace.FindFromKey(edge);
|
||||
|
||||
if(los.Extent() != 2)
|
||||
{
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
const TopoDS_Shape& face1 = los.First();
|
||||
const TopoDS_Shape& face2 = los.Last();
|
||||
GeomAbs_Shape cont = BRep_Tool::Continuity(TopoDS::Edge(edge),
|
||||
TopoDS::Face(face1),
|
||||
TopoDS::Face(face2));
|
||||
if (cont != GeomAbs_C0) {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
|
||||
|
||||
TopTools_IndexedMapOfShape mapOfFaces;
|
||||
TopExp::MapShapes(face, TopAbs_EDGE, mapOfFaces);
|
||||
|
||||
for(int j = 1; j <= mapOfFaces.Extent(); ++j) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(mapOfFaces.FindKey(j));
|
||||
|
||||
int id = mapOfEdges.FindIndex(edge);
|
||||
|
||||
std::stringstream buf;
|
||||
buf << "Edge";
|
||||
buf << id;
|
||||
|
||||
if(std::find(SubNames.begin(),SubNames.end(),buf.str()) == SubNames.end())
|
||||
{
|
||||
SubNames.push_back(buf.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
// empty name or any other sub-element
|
||||
else {
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
}
|
||||
|
||||
if (SubNames.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No chamfer possible on selected faces/edges"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string SelString;
|
||||
SelString += "(App.";
|
||||
SelString += "ActiveDocument";//getObject()->getDocument()->getName();
|
||||
SelString += ".";
|
||||
SelString += selection[0].getFeatName();
|
||||
SelString += ",[";
|
||||
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
SelString += "\"";
|
||||
SelString += *it;
|
||||
SelString += "\"";
|
||||
if(it != --SubNames.end())
|
||||
SelString += ",";
|
||||
}
|
||||
SelString += "])";
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Chamfer");
|
||||
|
||||
openCommand("Make Chamfer");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Chamfer\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
|
||||
}
|
||||
|
||||
bool CmdPartDesignChamfer::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Draft
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartDesignDraft);
|
||||
|
||||
CmdPartDesignDraft::CmdPartDesignDraft()
|
||||
:Command("PartDesign_Draft")
|
||||
{
|
||||
sAppModule = "PartDesign";
|
||||
sGroup = QT_TR_NOOP("PartDesign");
|
||||
sMenuText = QT_TR_NOOP("Draft");
|
||||
sToolTipText = QT_TR_NOOP("Make a draft on a face");
|
||||
sWhatsThis = sToolTipText;
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "PartDesign_Draft";
|
||||
}
|
||||
|
||||
void CmdPartDesignDraft::activated(int iMsg)
|
||||
{
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
|
||||
if (selection.size() < 1) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select one or more faces."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong object type"),
|
||||
QObject::tr("Draft works only on parts"));
|
||||
return;
|
||||
}
|
||||
|
||||
Part::Feature *base = static_cast<Part::Feature*>(selection[0].getObject());
|
||||
|
||||
const Part::TopoShape& TopShape = base->Shape.getShape();
|
||||
if (TopShape._Shape.IsNull()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Shape of selected Part is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> SubNames = std::vector<std::string>(selection[0].getSubNames());
|
||||
int i = 0;
|
||||
|
||||
while(i < SubNames.size())
|
||||
{
|
||||
std::string aSubName = static_cast<std::string>(SubNames.at(i));
|
||||
|
||||
if(aSubName.size() > 4 && aSubName.substr(0,4) == "Face") {
|
||||
// Check for valid face types
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(aSubName.c_str()));
|
||||
BRepAdaptor_Surface sf(face);
|
||||
if ((sf.GetType() != GeomAbs_Plane) && (sf.GetType() != GeomAbs_Cylinder) && (sf.GetType() != GeomAbs_Cone))
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
} else {
|
||||
// empty name or any other sub-element
|
||||
SubNames.erase(SubNames.begin()+i);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (SubNames.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No draft possible on selected faces"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string SelString;
|
||||
SelString += "(App.";
|
||||
SelString += "ActiveDocument";
|
||||
SelString += ".";
|
||||
SelString += selection[0].getFeatName();
|
||||
SelString += ",[";
|
||||
for(std::vector<std::string>::const_iterator it = SubNames.begin();it!=SubNames.end();++it){
|
||||
SelString += "\"";
|
||||
SelString += *it;
|
||||
SelString += "\"";
|
||||
if(it != --SubNames.end())
|
||||
SelString += ",";
|
||||
}
|
||||
SelString += "])";
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Draft");
|
||||
|
||||
// We don't create any defaults for neutral plane and pull direction, but Draft::execute()
|
||||
// will choose them.
|
||||
// Note: When the body feature is there, the best thing would be to get pull direction and
|
||||
// neutral plane from the preceding feature in the tree. Or even store them as default in
|
||||
// the Body feature itself
|
||||
openCommand("Make Draft");
|
||||
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Draft\",\"%s\")",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Angle = %f",FeatName.c_str(), 1.5);
|
||||
updateActive();
|
||||
if (isActiveObjectValid()) {
|
||||
doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",selection[0].getFeatName());
|
||||
}
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
copyVisual(FeatName.c_str(), "ShapeColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "LineColor", selection[0].getFeatName());
|
||||
copyVisual(FeatName.c_str(), "PointColor", selection[0].getFeatName());
|
||||
}
|
||||
|
||||
bool CmdPartDesignDraft::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// PartDesign_Mirrored
|
||||
//===========================================================================
|
||||
|
@ -744,36 +856,36 @@ CmdPartDesignMirrored::CmdPartDesignMirrored()
|
|||
|
||||
void CmdPartDesignMirrored::activated(int iMsg)
|
||||
{
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Mirrored");
|
||||
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -818,36 +930,36 @@ CmdPartDesignLinearPattern::CmdPartDesignLinearPattern()
|
|||
|
||||
void CmdPartDesignLinearPattern::activated(int iMsg)
|
||||
{
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("LinearPattern");
|
||||
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -892,36 +1004,36 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern()
|
|||
|
||||
void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
{
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("PolarPattern");
|
||||
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -966,36 +1078,36 @@ CmdPartDesignScaled::CmdPartDesignScaled()
|
|||
|
||||
void CmdPartDesignScaled::activated(int iMsg)
|
||||
{
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Scaled");
|
||||
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -1039,36 +1151,36 @@ CmdPartDesignMultiTransform::CmdPartDesignMultiTransform()
|
|||
|
||||
void CmdPartDesignMultiTransform::activated(int iMsg)
|
||||
{
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = getSelection().getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
std::vector<App::DocumentObject*> subtractive = getSelection().getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// Next create a list of all eligible objects
|
||||
if (features.size() == 0) {
|
||||
features = getDocument()->getObjectsOfType(PartDesign::Additive::getClassTypeId());
|
||||
subtractive = getDocument()->getObjectsOfType(PartDesign::Subtractive::getClassTypeId());
|
||||
features.insert(features.end(), subtractive.begin(), subtractive.end());
|
||||
// If there is more than one selected or eligible object, show dialog and let user pick one
|
||||
if (features.size() > 1) {
|
||||
PartDesignGui::FeaturePickDialog Dlg(features);
|
||||
if ((Dlg.exec() != QDialog::Accepted) || (features = Dlg.getFeatures()).empty())
|
||||
return; // Cancelled or nothing selected
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid features in this document"),
|
||||
QObject::tr("Please create a subtractive or additive feature first, please"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string FeatName = getUniqueObjectName("MultiTransform");
|
||||
|
||||
std::stringstream str;
|
||||
std::vector<std::string> tempSelNames;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
for (std::vector<App::DocumentObject*>::iterator it = features.begin(); it != features.end(); ++it){
|
||||
str << "App.activeDocument()." << (*it)->getNameInDocument() << ",";
|
||||
tempSelNames.push_back((*it)->getNameInDocument());
|
||||
}
|
||||
str << "]";
|
||||
|
||||
|
@ -1103,6 +1215,7 @@ void CreatePartDesignCommands(void)
|
|||
rcCmdMgr.addCommand(new CmdPartDesignRevolution());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignGroove());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignFillet());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignDraft());
|
||||
//rcCmdMgr.addCommand(new CmdPartDesignNewSketch());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignChamfer());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignMirrored());
|
||||
|
|
|
@ -8,6 +8,7 @@ BUILT_SOURCES=\
|
|||
moc_TaskPocketParameters.cpp \
|
||||
moc_TaskChamferParameters.cpp \
|
||||
moc_TaskFilletParameters.cpp \
|
||||
moc_TaskDraftParameters.cpp \
|
||||
moc_TaskGrooveParameters.cpp \
|
||||
moc_TaskHoleParameters.cpp \
|
||||
moc_TaskLinearPatternParameters.cpp \
|
||||
|
@ -24,6 +25,7 @@ BUILT_SOURCES=\
|
|||
ui_TaskPocketParameters.h \
|
||||
ui_TaskChamferParameters.h \
|
||||
ui_TaskFilletParameters.h \
|
||||
ui_TaskDraftParameters.h \
|
||||
ui_TaskHoleParameters.h \
|
||||
ui_TaskLinearPatternParameters.h \
|
||||
ui_TaskMirroredParameters.h \
|
||||
|
@ -40,6 +42,7 @@ libPartDesignGui_la_UI=\
|
|||
TaskPocketParameters.ui \
|
||||
TaskChamferParameters.ui \
|
||||
TaskFilletParameters.ui \
|
||||
TaskFilletParameters.ui \
|
||||
TaskHoleParameters.ui \
|
||||
TaskLinearPatternParameters.ui \
|
||||
TaskMirroredParameters.ui \
|
||||
|
@ -68,6 +71,8 @@ libPartDesignGui_la_SOURCES=\
|
|||
TaskChamferParameters.h \
|
||||
TaskFilletParameters.cpp \
|
||||
TaskFilletParameters.h \
|
||||
TaskDraftParameters.cpp \
|
||||
TaskDraftParameters.h \
|
||||
TaskLinearPatternParameters.cpp \
|
||||
TaskLinearPatternParameters.h \
|
||||
TaskMirroredParameters.cpp \
|
||||
|
@ -106,6 +111,8 @@ libPartDesignGui_la_SOURCES=\
|
|||
ViewProviderChamfer.h \
|
||||
ViewProviderFillet.cpp \
|
||||
ViewProviderFillet.h \
|
||||
ViewProviderDraft.cpp \
|
||||
ViewProviderDraft.h \
|
||||
ViewProviderGroove.cpp \
|
||||
ViewProviderGroove.h \
|
||||
ViewProviderRevolution.cpp \
|
||||
|
|
|
@ -53,6 +53,7 @@ EXTRA_DIST = \
|
|||
translations/PartDesign_tr.ts \
|
||||
icons/PartDesign_Chamfer.svg \
|
||||
icons/PartDesign_Fillet.svg \
|
||||
icons/PartDesign_Draft.svg \
|
||||
icons/PartDesign_Groove.svg \
|
||||
icons/PartDesign_Pad.svg \
|
||||
icons/PartDesign_Pocket.svg \
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<qresource>
|
||||
<file>icons/PartDesign_Chamfer.svg</file>
|
||||
<file>icons/PartDesign_Fillet.svg</file>
|
||||
<file>icons/PartDesign_Draft.svg</file>
|
||||
<file>icons/PartDesign_Groove.svg</file>
|
||||
<file>icons/PartDesign_Pad.svg</file>
|
||||
<file>icons/PartDesign_Pocket.svg</file>
|
||||
|
|
216
src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Draft.svg
Normal file
216
src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Draft.svg
Normal file
|
@ -0,0 +1,216 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64px"
|
||||
height="64px"
|
||||
id="svg3364"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.48.3.1 r9886"
|
||||
sodipodi:docname="PartDesign_DraftAngle.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
version="1.1">
|
||||
<defs
|
||||
id="defs3366">
|
||||
<linearGradient
|
||||
id="linearGradient3835">
|
||||
<stop
|
||||
id="stop3837"
|
||||
offset="0"
|
||||
style="stop-color:#637dca;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3839"
|
||||
offset="1"
|
||||
style="stop-color:#9eaede;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3827">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3829" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop3831" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3864">
|
||||
<stop
|
||||
id="stop3866"
|
||||
offset="0"
|
||||
style="stop-color:#840000;stop-opacity:0.80392158;" />
|
||||
<stop
|
||||
id="stop3868"
|
||||
offset="1"
|
||||
style="stop-color:#ff2b1e;stop-opacity:0.80392158;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3593">
|
||||
<stop
|
||||
style="stop-color:#00aff9;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3595" />
|
||||
<stop
|
||||
style="stop-color:#001ccc;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3597" />
|
||||
</linearGradient>
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="-24.909091 : 16.545455 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="116.36364 : 23.818182 : 1"
|
||||
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||
id="perspective3372" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3864"
|
||||
id="radialGradient2998"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.6696601,0.63911498,-0.09121381,0.31244488,-540.88725,-258.46199)"
|
||||
cx="342.58258"
|
||||
cy="27.256668"
|
||||
fx="342.58258"
|
||||
fy="27.256668"
|
||||
r="19.571428" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3593-0"
|
||||
id="radialGradient3004-8"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(-320.59978,-6.63068)"
|
||||
cx="330.63791"
|
||||
cy="39.962704"
|
||||
fx="330.63791"
|
||||
fy="39.962704"
|
||||
r="19.571428" />
|
||||
<linearGradient
|
||||
id="linearGradient3593-0">
|
||||
<stop
|
||||
style="stop-color:#c8e0f9;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3595-2" />
|
||||
<stop
|
||||
style="stop-color:#637dca;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3597-1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
r="19.571428"
|
||||
fy="39.962704"
|
||||
fx="330.63791"
|
||||
cy="39.962704"
|
||||
cx="330.63791"
|
||||
gradientTransform="matrix(-0.93227784,0,0,1.3554421,396.33347,-27.208207)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient3036"
|
||||
xlink:href="#linearGradient3593-0"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3593"
|
||||
id="linearGradient3799"
|
||||
x1="5.3636365"
|
||||
y1="34"
|
||||
x2="57"
|
||||
y2="34"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.2844364,0,0,1.2700541,-1.1984108,-15.131825)" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3864"
|
||||
id="linearGradient5146"
|
||||
x1="48.272724"
|
||||
y1="25.636364"
|
||||
x2="16.090908"
|
||||
y2="24.181818"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
spreadMethod="pad"
|
||||
gradientTransform="matrix(1.2080212,0,0,1.1944945,-0.12709377,-6.3964438)" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="7.7781746"
|
||||
inkscape:cx="31.234034"
|
||||
inkscape:cy="25.130096"
|
||||
inkscape:current-layer="g3780"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1863"
|
||||
inkscape:window-height="1056"
|
||||
inkscape:window-x="57"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata3369">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g3780"
|
||||
transform="matrix(0.82780005,0,0,0.83717425,-0.2499405,9.0601524)">
|
||||
<path
|
||||
style="fill:url(#linearGradient3799);fill-opacity:1;stroke:#000137;stroke-width:2.40247756;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="M 8.1568387,44.30919 38.639959,59.794495 68.861758,45.599851 70.730028,5.6508767 37.801749,-3.5858797 21.877105,0.78915639 C 16.678792,17.415402 14.11849,24.973181 8.1568387,44.30919 z"
|
||||
id="path3783"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000137;stroke-width:2.40247755999999990;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;opacity:0.5"
|
||||
d="M 22.033841,1.002891 21.636481,39.344 50.87597,53.542806"
|
||||
id="path3801"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccc" />
|
||||
<path
|
||||
style="opacity:0.5;fill:none;stroke:#000e38;stroke-width:2.4024775;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="M 21.755681,39.253777 8.3348853,44.271426"
|
||||
id="path3804-0"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:url(#linearGradient5146);fill-opacity:1;stroke:#000137;stroke-width:2.4024775;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="M 8.2192342,44.315275 38.639404,59.843705 52.257099,12.932649 21.836927,0.87911367 z"
|
||||
id="path3841"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000e38;stroke-width:2.4024775;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="M 70.573479,5.7920307 51.936227,13.035783"
|
||||
id="path3804"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000e38;stroke-width:2.40247755999999990;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;opacity:0.5"
|
||||
d="m 52.070209,13.209252 -0.79959,40.793483"
|
||||
id="path3804-7"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 7.5 KiB |
442
src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Normal file
442
src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Normal file
|
@ -0,0 +1,442 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "ui_TaskDraftParameters.h"
|
||||
#include "TaskDraftParameters.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Mod/PartDesign/App/FeatureDraft.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/PartDesign/Gui/ReferenceSelection.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
using namespace Gui;
|
||||
|
||||
/* TRANSLATOR PartDesignGui::TaskDraftParameters */
|
||||
|
||||
TaskDraftParameters::TaskDraftParameters(ViewProviderDraft *DraftView,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Draft"),tr("Draft parameters"),true, parent),DraftView(DraftView)
|
||||
{
|
||||
selectionMode = none;
|
||||
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskDraftParameters();
|
||||
ui->setupUi(proxy);
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
|
||||
connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(onAngleChanged(double)));
|
||||
connect(ui->checkReverse, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onReversedChanged(bool)));
|
||||
connect(ui->buttonFaceAdd, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonFaceAdd(bool)));
|
||||
connect(ui->buttonFaceRemove, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonFaceRemove(bool)));
|
||||
connect(ui->buttonPlane, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonPlane(bool)));
|
||||
connect(ui->buttonLine, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onButtonLine(bool)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
double a = pcDraft->Angle.getValue();
|
||||
|
||||
ui->doubleSpinBox->setMinimum(0.0);
|
||||
ui->doubleSpinBox->setMaximum(89.99);
|
||||
ui->doubleSpinBox->setValue(a);
|
||||
ui->doubleSpinBox->selectAll();
|
||||
QMetaObject::invokeMethod(ui->doubleSpinBox, "setFocus", Qt::QueuedConnection);
|
||||
|
||||
bool r = pcDraft->Reversed.getValue();
|
||||
ui->checkReverse->setChecked(r);
|
||||
|
||||
std::vector<std::string> strings = pcDraft->Base.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
{
|
||||
ui->listWidgetFaces->insertItem(0, QString::fromStdString(*i));
|
||||
}
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
ui->listWidgetFaces->addAction(action);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onFaceDeleted()));
|
||||
ui->listWidgetFaces->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
strings = pcDraft->NeutralPlane.getSubValues();
|
||||
std::string neutralPlane = (strings.empty() ? "" : strings[0]);
|
||||
ui->linePlane->setText(QString::fromStdString(neutralPlane));
|
||||
|
||||
strings = pcDraft->PullDirection.getSubValues();
|
||||
std::string pullDirection = (strings.empty() ? "" : strings[0]);
|
||||
ui->lineLine->setText(QString::fromStdString(pullDirection));
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode == none)
|
||||
return;
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
if (strcmp(msg.pDocName, DraftView->getObject()->getDocument()->getName()) != 0)
|
||||
return;
|
||||
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
App::DocumentObject* base = this->getBase();
|
||||
// TODO: Must we make a copy here instead of assigning to const char* ?
|
||||
const char* fname = base->getNameInDocument();
|
||||
std::string subName(msg.pSubName);
|
||||
|
||||
if ((selectionMode == faceAdd) && (subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
||||
|
||||
if (strcmp(msg.pObjectName, fname) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> faces = pcDraft->Base.getSubValues();
|
||||
if (std::find(faces.begin(), faces.end(), subName) == faces.end()) {
|
||||
faces.push_back(subName);
|
||||
pcDraft->Base.setValue(base, faces);
|
||||
ui->listWidgetFaces->insertItem(0, QString::fromStdString(subName));
|
||||
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
ui->buttonFaceAdd->setChecked(false);
|
||||
exitSelectionMode();
|
||||
}
|
||||
} else if ((selectionMode == faceRemove) && (subName.size() > 4 && subName.substr(0,4) == "Face")) {
|
||||
|
||||
if (strcmp(msg.pObjectName, fname) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> faces = pcDraft->Base.getSubValues();
|
||||
std::vector<std::string>::iterator f = std::find(faces.begin(), faces.end(), subName);
|
||||
if (f != faces.end()) {
|
||||
faces.erase(f);
|
||||
pcDraft->Base.setValue(base, faces);
|
||||
QList<QListWidgetItem*> items = ui->listWidgetFaces->findItems(QString::fromStdString(subName), Qt::MatchExactly);
|
||||
if (!items.empty()) {
|
||||
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
|
||||
QListWidgetItem* it = ui->listWidgetFaces->takeItem(ui->listWidgetFaces->row(*i));
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
ui->buttonFaceRemove->setChecked(false);
|
||||
exitSelectionMode();
|
||||
}
|
||||
} else if ((selectionMode == plane) && (subName.size() > 4) &&
|
||||
((subName.substr(0,4) == "Face") || (subName.substr(0,4) == "Edge"))) {
|
||||
|
||||
if (strcmp(msg.pObjectName, fname) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> planes(1,subName);
|
||||
pcDraft->NeutralPlane.setValue(base, planes);
|
||||
ui->linePlane->setText(QString::fromStdString(subName));
|
||||
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
ui->buttonPlane->setChecked(false);
|
||||
exitSelectionMode();
|
||||
} else if ((selectionMode == line) && (subName.size() > 4 && subName.substr(0,4) == "Edge")) {
|
||||
|
||||
if (strcmp(msg.pObjectName, fname) != 0)
|
||||
return;
|
||||
|
||||
std::vector<std::string> edges(1,subName);
|
||||
pcDraft->PullDirection.setValue(base, edges);
|
||||
ui->lineLine->setText(QString::fromStdString(subName));
|
||||
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
ui->buttonLine->setChecked(false);
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onButtonFaceAdd(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
selectionMode = faceAdd;
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), false, true, false));
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onButtonFaceRemove(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
selectionMode = faceRemove;
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), false, true, false));
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onButtonPlane(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
selectionMode = plane;
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), true, true, true));
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onButtonLine(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
hideObject();
|
||||
selectionMode = line;
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(this->getBase(), true, false, true));
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string> TaskDraftParameters::getFaces(void) const
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
for (int i = 0; i < ui->listWidgetFaces->count(); i++)
|
||||
result.push_back(ui->listWidgetFaces->item(i)->text().toStdString());
|
||||
return result;
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onFaceDeleted(void)
|
||||
{
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
App::DocumentObject* base = pcDraft->Base.getValue();
|
||||
std::vector<std::string> faces = pcDraft->Base.getSubValues();
|
||||
faces.erase(faces.begin() + ui->listWidgetFaces->currentRow());
|
||||
pcDraft->Base.setValue(base, faces);
|
||||
ui->listWidgetFaces->model()->removeRow(ui->listWidgetFaces->currentRow());
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
}
|
||||
|
||||
const std::string TaskDraftParameters::getPlane(void) const
|
||||
{
|
||||
return ui->linePlane->text().toStdString();
|
||||
}
|
||||
|
||||
const std::string TaskDraftParameters::getLine(void) const
|
||||
{
|
||||
return ui->lineLine->text().toStdString();
|
||||
}
|
||||
|
||||
void TaskDraftParameters::hideObject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
App::DocumentObject* base = getBase();
|
||||
if (doc != NULL && base != NULL) {
|
||||
doc->setHide(DraftView->getObject()->getNameInDocument());
|
||||
doc->setShow(base->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::showObject()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
App::DocumentObject* base = getBase();
|
||||
if (doc != NULL && base != NULL) {
|
||||
doc->setShow(DraftView->getObject()->getNameInDocument());
|
||||
doc->setHide(base->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onAngleChanged(double angle)
|
||||
{
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
pcDraft->Angle.setValue((float)angle);
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
}
|
||||
|
||||
const double TaskDraftParameters::getAngle(void) const
|
||||
{
|
||||
return ui->doubleSpinBox->value();
|
||||
}
|
||||
|
||||
void TaskDraftParameters::onReversedChanged(const bool on) {
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
pcDraft->Reversed.setValue(on);
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
}
|
||||
|
||||
const bool TaskDraftParameters::getReversed(void) const
|
||||
{
|
||||
return ui->checkReverse->isChecked();
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskDraftParameters::getBase(void) const
|
||||
{
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
return pcDraft->Base.getValue();
|
||||
}
|
||||
|
||||
TaskDraftParameters::~TaskDraftParameters()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskDraftParameters::changeEvent(QEvent *e)
|
||||
{
|
||||
TaskBox::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDraftParameters::exitSelectionMode()
|
||||
{
|
||||
selectionMode = none;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
showObject();
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
// TaskDialog
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgDraftParameters::TaskDlgDraftParameters(ViewProviderDraft *DraftView)
|
||||
: TaskDialog(),DraftView(DraftView)
|
||||
{
|
||||
assert(DraftView);
|
||||
parameter = new TaskDraftParameters(DraftView);
|
||||
|
||||
Content.push_back(parameter);
|
||||
}
|
||||
|
||||
TaskDlgDraftParameters::~TaskDlgDraftParameters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
|
||||
void TaskDlgDraftParameters::open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDlgDraftParameters::clicked(int)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool TaskDlgDraftParameters::accept()
|
||||
{
|
||||
parameter->showObject();
|
||||
|
||||
// Force the user to select a neutral plane
|
||||
if (parameter->getPlane().empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Missing neutral plane"),
|
||||
QObject::tr("Please select a plane or an edge plus a pull direction"));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string name = DraftView->getObject()->getNameInDocument();
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),parameter->getAngle());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),parameter->getReversed());
|
||||
try {
|
||||
std::vector<std::string> faces = parameter->getFaces();
|
||||
std::stringstream str;
|
||||
str << "App.ActiveDocument." << name.c_str() << ".Base = (App.ActiveDocument."
|
||||
<< parameter->getBase()->getNameInDocument() << ",[";
|
||||
for (std::vector<std::string>::const_iterator it = faces.begin(); it != faces.end(); ++it)
|
||||
str << "\"" << *it << "\",";
|
||||
str << "])";
|
||||
Gui::Command::doCommand(Gui::Command::Doc,str.str().c_str());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(parameter, tr("Input error"), QString::fromAscii(e.what()));
|
||||
return false;
|
||||
}
|
||||
std::string neutralPlane = parameter->getPlane();
|
||||
if (!neutralPlane.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(parameter->getBase()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(neutralPlane.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.NeutralPlane = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.NeutralPlane = None", name.c_str());
|
||||
std::string pullDirection = parameter->getLine();
|
||||
if (!pullDirection.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(parameter->getBase()->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(pullDirection.c_str()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.PullDirection = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.PullDirection = None", name.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgDraftParameters::reject()
|
||||
{
|
||||
// get the support
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
App::DocumentObject *pcSupport;
|
||||
pcSupport = pcDraft->Base.getValue();
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
|
||||
|
||||
// if abort command deleted the object the support is visible again
|
||||
if (!Gui::Application::Instance->getViewProvider(pcDraft)) {
|
||||
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
|
||||
Gui::Application::Instance->getViewProvider(pcSupport)->show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "moc_TaskDraftParameters.cpp"
|
127
src/Mod/PartDesign/Gui/TaskDraftParameters.h
Normal file
127
src/Mod/PartDesign/Gui/TaskDraftParameters.h
Normal file
|
@ -0,0 +1,127 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskDraftParameters_H
|
||||
#define GUI_TASKVIEW_TaskDraftParameters_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ViewProviderDraft.h"
|
||||
|
||||
class Ui_TaskDraftParameters;
|
||||
|
||||
namespace App {
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class TaskDraftParameters : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDraftParameters(ViewProviderDraft *DraftView, QWidget *parent=0);
|
||||
~TaskDraftParameters();
|
||||
|
||||
const double getAngle(void) const;
|
||||
const bool getReversed(void) const;
|
||||
const std::vector<std::string> getFaces(void) const;
|
||||
const std::string getPlane(void) const;
|
||||
const std::string getLine(void) const;
|
||||
App::DocumentObject *getBase(void) const;
|
||||
|
||||
void hideObject();
|
||||
void showObject();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAngleChanged(double angle);
|
||||
void onReversedChanged(bool reversed);
|
||||
void onButtonFaceAdd(const bool checked);
|
||||
void onButtonFaceRemove(const bool checked);
|
||||
void onButtonPlane(const bool checked);
|
||||
void onButtonLine(const bool checked);
|
||||
void onFaceDeleted(void);
|
||||
|
||||
protected:
|
||||
void exitSelectionMode();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskDraftParameters* ui;
|
||||
ViewProviderDraft *DraftView;
|
||||
|
||||
enum selectionModes { none, faceAdd, faceRemove, plane, line };
|
||||
selectionModes selectionMode;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
class TaskDlgDraftParameters : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgDraftParameters(ViewProviderDraft *DraftView);
|
||||
~TaskDlgDraftParameters();
|
||||
|
||||
ViewProviderDraft* getDraftView() const
|
||||
{ return DraftView; }
|
||||
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
virtual bool reject();
|
||||
/// is called by the framework if the user presses the help button
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
/// returns for Close and Help button
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
|
||||
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
|
||||
|
||||
protected:
|
||||
ViewProviderDraft *DraftView;
|
||||
|
||||
TaskDraftParameters *parameter;
|
||||
};
|
||||
|
||||
} //namespace PartDesignGui
|
||||
|
||||
#endif // GUI_TASKVIEW_TASKAPPERANCE_H
|
120
src/Mod/PartDesign/Gui/TaskDraftParameters.ui
Normal file
120
src/Mod/PartDesign/Gui/TaskDraftParameters.ui
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PartDesignGui::TaskDraftParameters</class>
|
||||
<widget class="QWidget" name="PartDesignGui::TaskDraftParameters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>257</width>
|
||||
<height>285</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonFaceAdd">
|
||||
<property name="text">
|
||||
<string>Add face</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonFaceRemove">
|
||||
<property name="text">
|
||||
<string>Remove face</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidgetFaces"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Draft angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>89.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPlane">
|
||||
<property name="text">
|
||||
<string>Neutral plane</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linePlane"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonLine">
|
||||
<property name="text">
|
||||
<string>Pull direction</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineLine"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkReverse">
|
||||
<property name="text">
|
||||
<string>Reverse pull direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>checkReverse</zorder>
|
||||
<zorder>listWidgetFaces</zorder>
|
||||
<zorder>buttonFaceAdd</zorder>
|
||||
<zorder>buttonFaceRemove</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
130
src/Mod/PartDesign/Gui/ViewProviderDraft.cpp
Normal file
130
src/Mod/PartDesign/Gui/ViewProviderDraft.cpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "ViewProviderDraft.h"
|
||||
#include "TaskDraftParameters.h"
|
||||
#include <Mod/PartDesign/App/FeatureDraft.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderDraft,PartDesignGui::ViewProvider)
|
||||
|
||||
ViewProviderDraft::ViewProviderDraft()
|
||||
{
|
||||
}
|
||||
|
||||
ViewProviderDraft::~ViewProviderDraft()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderDraft::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit draft"), receiver, member);
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
bool ViewProviderDraft::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// When double-clicking on the item for this fillet the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgDraftParameters *draftDlg = qobject_cast<TaskDlgDraftParameters *>(dlg);
|
||||
if (draftDlg && draftDlg->getDraftView() != this)
|
||||
draftDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !draftDlg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
|
||||
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Yes)
|
||||
Gui::Control().closeDialog();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
//if(ModNum == 1)
|
||||
// Gui::Command::openCommand("Change draft parameters");
|
||||
|
||||
// start the edit dialog
|
||||
if (draftDlg)
|
||||
Gui::Control().showDialog(draftDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgDraftParameters(this));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return PartGui::ViewProviderPart::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderDraft::unsetEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
// and update the draft
|
||||
//getSketchObject()->getDocument()->recompute();
|
||||
|
||||
// when pressing ESC make sure to close the dialog
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
PartGui::ViewProviderPart::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderDraft::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// get the support and Sketch
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(getObject());
|
||||
App::DocumentObject *pcSupport = 0;
|
||||
if (pcDraft->Base.getValue()){
|
||||
pcSupport = static_cast<Sketcher::SketchObject*>(pcDraft->Base.getValue());
|
||||
}
|
||||
|
||||
// if abort command deleted the object the support is visible again
|
||||
if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport))
|
||||
Gui::Application::Instance->getViewProvider(pcSupport)->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
58
src/Mod/PartDesign/Gui/ViewProviderDraft.h
Normal file
58
src/Mod/PartDesign/Gui/ViewProviderDraft.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2012 Jan Rheinländer <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library 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 library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTGUI_ViewProviderDraft_H
|
||||
#define PARTGUI_ViewProviderDraft_H
|
||||
|
||||
#include "ViewProvider.h"
|
||||
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
class PartDesignGuiExport ViewProviderDraft : public ViewProvider
|
||||
{
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderDraft);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderDraft();
|
||||
/// destructor
|
||||
virtual ~ViewProviderDraft();
|
||||
|
||||
/// grouping handling
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderDraft_H
|
|
@ -86,6 +86,7 @@ void Workbench::activated()
|
|||
"Sketcher_NewSketch",
|
||||
"PartDesign_Fillet",
|
||||
"PartDesign_Chamfer",
|
||||
"PartDesign_Draft",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Part::Feature SUBELEMENT Face COUNT 1",
|
||||
|
@ -97,6 +98,7 @@ void Workbench::activated()
|
|||
const char* Faces[] = {
|
||||
"PartDesign_Fillet",
|
||||
"PartDesign_Chamfer",
|
||||
"PartDesign_Draft",
|
||||
0};
|
||||
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
||||
"SELECT Part::Feature SUBELEMENT Face COUNT 2..",
|
||||
|
@ -212,6 +214,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_Fillet"
|
||||
<< "PartDesign_Chamfer"
|
||||
<< "PartDesign_Draft"
|
||||
<< "PartDesign_Mirrored"
|
||||
<< "PartDesign_LinearPattern"
|
||||
<< "PartDesign_PolarPattern"
|
||||
|
@ -243,6 +246,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
<< "PartDesign_Groove"
|
||||
<< "PartDesign_Fillet"
|
||||
<< "PartDesign_Chamfer"
|
||||
<< "PartDesign_Draft"
|
||||
<< "PartDesign_Mirrored"
|
||||
<< "PartDesign_LinearPattern"
|
||||
<< "PartDesign_PolarPattern"
|
||||
|
|
|
@ -28,13 +28,15 @@ from ShaftDiagram import Diagram
|
|||
class ShaftSegment:
|
||||
length = 0.0
|
||||
diameter = 0.0
|
||||
innerdiameter = 0.0
|
||||
loadType = "None"
|
||||
loadSize = 0.0
|
||||
loadLocation = 0.0
|
||||
|
||||
def __init__(self, l, d):
|
||||
def __init__(self, l, d, di):
|
||||
self.length = l
|
||||
self.diameter = d
|
||||
self.innerdiameter = di
|
||||
|
||||
class Shaft:
|
||||
"The axis of the shaft is always assumed to correspond to the X-axis"
|
||||
|
@ -62,20 +64,23 @@ class Shaft:
|
|||
result += self.segments[i].length
|
||||
return result
|
||||
|
||||
def addSegment(self, l, d):
|
||||
def addSegment(self, l, d, di):
|
||||
#print "Adding segment: ", l, " : ", d
|
||||
self.segments.append(ShaftSegment(l,d))
|
||||
self.sketch.addSegment(l, d)
|
||||
self.segments.append(ShaftSegment(l,d,di))
|
||||
self.sketch.addSegment(l, d, di)
|
||||
# We don't call equilibrium() here because the new segment has no loads defined yet
|
||||
|
||||
def updateSegment(self, index, length = None, diameter = None):
|
||||
def updateSegment(self, index, length = None, diameter = None, innerdiameter = None):
|
||||
oldLength = self.segments[index].length
|
||||
#print "Old length of ", index, ": ", oldLength, ", new Length: ", length, " diameter: ", diameter
|
||||
if length is not None:
|
||||
self.segments[index].length = length
|
||||
if diameter is not None:
|
||||
self.segments[index].diameter = diameter
|
||||
self.sketch.updateSegment(index, oldLength, self.segments[index].length, self.segments[index].diameter)
|
||||
if innerdiameter is not None:
|
||||
self.segments[index].innerdiameter = innerdiameter
|
||||
self.sketch.updateSegment(index, oldLength, self.segments[index].length,
|
||||
self.segments[index].diameter, self.segments[index].innerdiameter)
|
||||
self.equilibrium()
|
||||
self.updateDiagrams()
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class Diagram:
|
|||
if xlength is not None:
|
||||
self.xlength = xlength
|
||||
# Calculate points
|
||||
(self.xpoints, self.ypoints) = self.function.evaluate(self.xlength, self.numxpoints)
|
||||
(self.xpoints, self.ypoints) = self.function.evaluate(self.xlength, self.numxpoints)
|
||||
# Create plot
|
||||
self.plot()
|
||||
|
||||
|
@ -88,4 +88,11 @@ class Diagram:
|
|||
del self.thePlot.series[0]
|
||||
|
||||
self.thePlot.update()
|
||||
self.xpoints = [p * self.xscale for p in self.xpoints]
|
||||
self.ypoints = [p * self.yscale for p in self.ypoints]
|
||||
self.thePlot.plot(self.xpoints, self.ypoints)
|
||||
plots = self.thePlot.series
|
||||
axes = plots[0].axes
|
||||
axes.set_xlim(right = max(self.xpoints) * 1.05)
|
||||
axes.set_ylim(min(self.ypoints) * 1.05, max(self.ypoints) * 1.05)
|
||||
self.thePlot.update()
|
||||
|
|
|
@ -42,7 +42,7 @@ class ShaftFeature:
|
|||
self.sketch = self.Doc.addObject("Sketcher::SketchObject","SketchShaft")
|
||||
self.sketch.Placement = self.App.Placement(self.App.Vector(0,0,0),self.App.Rotation(0,0,0,1))
|
||||
|
||||
def addSegment(self, length, diameter):
|
||||
def addSegment(self, length, diameter, innerdiameter):
|
||||
"Add a segment at the end of the shaft"
|
||||
# Find constraint indices of vertical line constraint, horizontal line constraint
|
||||
# FIXME: Should have a unique id instead of indices that might change with user editing
|
||||
|
@ -53,6 +53,7 @@ class ShaftFeature:
|
|||
# etc. etc.
|
||||
constrRadius = 4 + self.segments * 6
|
||||
constrLength = 7 + self.segments * 6
|
||||
constrInnerRadius = 1 + self.segments * 6
|
||||
# Find line index of vertical segment, horizontal segment, last shaft segment
|
||||
# FIXME: Should have a unique id instead of indices that might change with user editing
|
||||
segRadius = 1 + self.segments * 2
|
||||
|
@ -62,6 +63,7 @@ class ShaftFeature:
|
|||
segEnd = prevSegEnd + 2
|
||||
|
||||
radius = diameter / 2
|
||||
innerradius = innerdiameter / 2
|
||||
oldLength = self.totalLength
|
||||
self.totalLength += length
|
||||
self.segments += 1
|
||||
|
@ -70,13 +72,13 @@ class ShaftFeature:
|
|||
# First segment of shaft
|
||||
# Create centerline
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(0,0,0), self.App.Vector(self.totalLength,0,0)))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceX',0, self.totalLength)) # Constraint1
|
||||
self.sketch.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-1)) # Constraint2
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceX',0, self.totalLength)) # Constraint1
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceY', -1,1,0,1,innerradius)) # Constraint2
|
||||
self.sketch.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-2)) # Constraint3
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Horizontal', 0)) # Constraint4
|
||||
# Create first segment
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(0,0,0), self.App.Vector(0,radius,0)))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceY',1,radius)) # Constraint5
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(0,innerradius,0), self.App.Vector(0,radius,0)))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceY',-1,1,1,2,radius)) # Constraint5
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Coincident',0,1,1,1)) # Constraint6
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Vertical',1)) # Constraint7
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(0,radius,0), self.App.Vector(length,radius,0)))
|
||||
|
@ -91,7 +93,7 @@ class ShaftFeature:
|
|||
self.sketch.setDatum(0,self.totalLength)
|
||||
# Add segment at the end
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength,self.lastRadius,0), self.App.Vector(oldLength,radius,0)))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceY', 0, 1, segRadius, 2, radius))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('DistanceY', -1,1, segRadius, 2, radius))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Coincident',segRadius,1,prevSegLength,2))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Vertical',segRadius))
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength,radius,0), self.App.Vector(oldLength+length,radius,0)))
|
||||
|
@ -100,10 +102,10 @@ class ShaftFeature:
|
|||
self.sketch.addConstraint(Sketcher.Constraint('Horizontal',segLength))
|
||||
|
||||
# close the sketch
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength+length,radius,0), self.App.Vector(oldLength+length,0,0)))
|
||||
self.sketch.addGeometry(Part.Line(self.App.Vector(oldLength+length,radius,0), self.App.Vector(oldLength+length,innerradius,0)))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Coincident',0,2,segEnd,2))
|
||||
self.sketch.addConstraint(Sketcher.Constraint('Coincident',segEnd,1,segLength,2))
|
||||
lastRadius = radius
|
||||
self.lastRadius = radius
|
||||
|
||||
if oldLength == 0:
|
||||
# create feature
|
||||
|
@ -118,16 +120,20 @@ class ShaftFeature:
|
|||
# FIXME: Will give a warning in the console if the active window is not the feature
|
||||
self.Gui.SendMsgToActiveView("ViewFit")
|
||||
|
||||
def updateSegment(self, segment, oldLength, length, diameter):
|
||||
def updateSegment(self, segment, oldLength, length, diameter, innerdiameter):
|
||||
constrRadius = 4 + segment * 6
|
||||
constrLength = 7 + segment * 6
|
||||
constrInnerRadius = 1 # Currently we don't allow multiple different innner diameters
|
||||
# update total length
|
||||
self.totalLength = self.totalLength - oldLength + length
|
||||
# Adjust length of centerline
|
||||
self.sketch.setDatum(0,self.totalLength)
|
||||
# Adjust segment length
|
||||
self.sketch.setDatum(constrLength, length)
|
||||
# Adjust diameter
|
||||
self.sketch.setDatum(constrRadius, diameter/2)
|
||||
# Adjust inner diameter
|
||||
self.sketch.setDatum(constrInnerRadius, innerdiameter/2)
|
||||
# Update feature
|
||||
self.Doc.recompute()
|
||||
self.Gui.SendMsgToActiveView("ViewFit")
|
||||
|
|
|
@ -516,6 +516,15 @@
|
|||
x2="13.874617"
|
||||
y2="43.090275"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3937"
|
||||
id="linearGradient3882"
|
||||
x1="-13.22155"
|
||||
y1="54.813248"
|
||||
x2="-13.508098"
|
||||
y2="40.945572"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
|
@ -525,8 +534,8 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="7.9999996"
|
||||
inkscape:cx="36.702399"
|
||||
inkscape:cy="28.247095"
|
||||
inkscape:cx="21.190358"
|
||||
inkscape:cy="23.779747"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
|
@ -558,7 +567,7 @@
|
|||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g3081">
|
||||
id="g3884">
|
||||
<path
|
||||
transform="matrix(1.0895226,-0.72891705,0.72727205,1.091987,23.576251,-35.797469)"
|
||||
d="m -1.5700722,48.122238 a 11.543545,16.777716 0 1 1 -23.0870898,0 11.543545,16.777716 0 1 1 23.0870898,0 z"
|
||||
|
@ -611,6 +620,16 @@
|
|||
id="path3815-2"
|
||||
style="fill:#ffc700;fill-opacity:1;fill-rule:evenodd;stroke:#5e3800;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(0.3792391,-0.25314756,0.25314756,0.3792391,8.8844614,24.305486)"
|
||||
d="m -2.2841215,48.122238 a 10.829495,16.777716 0 1 1 -21.6589905,0 10.829495,16.777716 0 1 1 21.6589905,0 z"
|
||||
sodipodi:ry="16.777716"
|
||||
sodipodi:rx="10.829495"
|
||||
sodipodi:cy="48.122238"
|
||||
sodipodi:cx="-13.113617"
|
||||
id="path3815-2-2"
|
||||
style="fill:url(#linearGradient3882);fill-opacity:1;fill-rule:evenodd;stroke:#5e3800;stroke-width:4.38628149;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
|
@ -30,17 +30,19 @@ class WizardShaftTable:
|
|||
rowDict = {
|
||||
"Length" : 0,
|
||||
"Diameter" : 1,
|
||||
"LoadType" : 2,
|
||||
"LoadSize" : 3,
|
||||
"LoadLocation" : 4,
|
||||
"StartEdgeType" : 5,
|
||||
"StartEdgeSize" : 6,
|
||||
"EndEdgeType" : 7,
|
||||
"EndEdgeSize" : 8
|
||||
"InnerDiameter" : 2,
|
||||
"LoadType" : 3,
|
||||
"LoadSize" : 4,
|
||||
"LoadLocation" : 5,
|
||||
"StartEdgeType" : 6,
|
||||
"StartEdgeSize" : 7,
|
||||
"EndEdgeType" : 8,
|
||||
"EndEdgeSize" : 9
|
||||
}
|
||||
rowDictReverse = {}
|
||||
headers = ["Length [mm]",
|
||||
"Diameter [mm]",
|
||||
"Inner diameter [mm]",
|
||||
"Load type",
|
||||
"Load [N]",
|
||||
"Location [mm]",
|
||||
|
@ -61,7 +63,7 @@ class WizardShaftTable:
|
|||
self.shaft = s
|
||||
# Create table widget
|
||||
self.widget = QtGui.QTableWidget(len(self.rowDict), 0)
|
||||
self.widget.resize(QtCore.QSize(300,100))
|
||||
self.widget.resize(QtCore.QSize(300,200))
|
||||
#self.widget.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
|
||||
# Label rows and columns
|
||||
|
@ -102,16 +104,18 @@ class WizardShaftTable:
|
|||
index = self.widget.columnCount()
|
||||
# Make an intelligent guess at the length/dia of the next segment
|
||||
if index > 0:
|
||||
length = self.shaft.segments[index-1].length
|
||||
length = self.shaft.segments[index-1].length
|
||||
diameter = self.shaft.segments[index-1].diameter
|
||||
if index > 2:
|
||||
diameter -= 5.0
|
||||
else:
|
||||
diameter += 5.0
|
||||
innerdiameter = self.shaft.segments[index-1].innerdiameter
|
||||
else:
|
||||
length = 20.0
|
||||
diameter = 10.0
|
||||
self.shaft.addSegment(length, diameter)
|
||||
innerdiameter = 0.0
|
||||
self.shaft.addSegment(length, diameter, innerdiameter)
|
||||
|
||||
self.widget.insertColumn(index)
|
||||
self.widget.setHorizontalHeaderItem(index + 1, QtGui.QTableWidgetItem("Section %s" % (index + 1)))
|
||||
|
@ -132,6 +136,14 @@ class WizardShaftTable:
|
|||
widget.setValue(diameter)
|
||||
widget.valueChanged.connect(self.slotValueChanged)
|
||||
widget.editingFinished.connect(self.slotEditingFinished)
|
||||
# inner Diameter
|
||||
widget = QtGui.QDoubleSpinBox(self.widget)
|
||||
widget.setMinimum(0)
|
||||
widget.setMaximum(1E9)
|
||||
self.widget.setCellWidget(self.rowDict["InnerDiameter"], index, widget)
|
||||
widget.setValue(innerdiameter)
|
||||
widget.valueChanged.connect(self.slotValueChanged)
|
||||
widget.editingFinished.connect(self.slotEditingFinished)
|
||||
# Load type
|
||||
widget = QtGui.QComboBox(self.widget)
|
||||
widget.insertItem(0, "None")
|
||||
|
@ -203,6 +215,8 @@ class WizardShaftTable:
|
|||
self.shaft.updateSegment(self.editedColumn, length = self.getDoubleValue(rowName, self.editedColumn))
|
||||
elif rowName == "Diameter":
|
||||
self.shaft.updateSegment(self.editedColumn, diameter = self.getDoubleValue(rowName, self.editedColumn))
|
||||
elif rowName == "InnerDiameter":
|
||||
self.shaft.updateSegment(self.editedColumn, innerdiameter = self.getDoubleValue(rowName, self.editedColumn))
|
||||
elif rowName == "LoadType":
|
||||
self.shaft.updateLoad(self.editedColumn, loadType = self.getListValue(rowName, self.editedColumn))
|
||||
elif rowName == "LoadSize":
|
||||
|
@ -232,6 +246,13 @@ class WizardShaftTable:
|
|||
def getDiameter(self, column):
|
||||
return self.getDoubleValue("Diameter", column)
|
||||
|
||||
def setInnerDiameter(self, column, d):
|
||||
self.setDoubleValue("InnerDiameter", column, d)
|
||||
self.shaft.updateSegment(column, innerdiameter = d)
|
||||
|
||||
def getInnerDiameter(self, column):
|
||||
return self.getDoubleValue("InnerDiameter", column)
|
||||
|
||||
@QtCore.pyqtSlot('QString')
|
||||
def slotLoadType(self, text):
|
||||
if text != "Fixed":
|
||||
|
|
Loading…
Reference in New Issue
Block a user