add options for pipe tool

This commit is contained in:
Stefan Tröger 2015-05-30 11:15:55 +02:00
parent e7803eca61
commit 9c4e1070eb
12 changed files with 1604 additions and 270 deletions

View File

@ -244,9 +244,9 @@ void Plane::onChanged(const App::Property *prop)
normal = new Base::Vector3d;
if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
*normal = Base::Vector3d(0,0,1);
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
*normal = Base::Vector3d(0,1,0);
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
*normal = Base::Vector3d(0,1,0);
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
*normal = Base::Vector3d(1,0,0);
} else if (refs[i]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
Part::Feature* feature = static_cast<Part::Feature*>(refs[i]);

View File

@ -41,6 +41,14 @@
# include <BRepAdaptor_Surface.hxx>
# include <gp_Pln.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#endif
#include <Base/Exception.h>
@ -57,7 +65,8 @@ using namespace PartDesign;
const char* Pipe::TypeEnums[] = {"FullPath","UpToFace",NULL};
const char* Pipe::TransitionEnums[] = {"Transformed","Right corner", "Round corner",NULL};
const char* Pipe::ModeEnums[] = {"Standart", "Fixed", "Binormal", "Frenet", NULL};
const char* Pipe::ModeEnums[] = {"Standart", "Fixed", "Binormal", "Frenet", "Auxillery", NULL};
const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Auxillery", NULL};
PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::SketchBased)
@ -66,10 +75,18 @@ Pipe::Pipe()
{
ADD_PROPERTY_TYPE(Sections,(0),"Sweep",App::Prop_None,"List of sections");
Sections.setSize(0);
ADD_PROPERTY_TYPE(Spine,(0,0),"Sweep",App::Prop_None,"Path to sweep along");
ADD_PROPERTY_TYPE(Mode,(long(1)),"Sweep",App::Prop_None,"Profile mode");
ADD_PROPERTY_TYPE(Transition,(long(1)),"Sweep",App::Prop_None,"Transition mode");
ADD_PROPERTY_TYPE(Spine,(0),"Sweep",App::Prop_None,"Path to sweep along");
ADD_PROPERTY_TYPE(SpineTangent,(false),"Sweep",App::Prop_None,"Include tangent edges into path");
ADD_PROPERTY_TYPE(AuxillerySpine,(0),"Sweep",App::Prop_None,"Secondary path to orient sweep");
ADD_PROPERTY_TYPE(AuxillerySpineTangent,(false),"Sweep",App::Prop_None,"Include tangent edges into secondary path");
ADD_PROPERTY_TYPE(AuxilleryCurvelinear, (true), "Sweep", App::Prop_None,"Calculate normal between equidistant points on both spines");
ADD_PROPERTY_TYPE(Mode,(long(0)),"Sweep",App::Prop_None,"Profile mode");
ADD_PROPERTY_TYPE(Binormal,(Base::Vector3d()),"Sweep",App::Prop_None,"Binormal vector for coresponding orientation mode");
ADD_PROPERTY_TYPE(Transition,(long(0)),"Sweep",App::Prop_None,"Transition mode");
ADD_PROPERTY_TYPE(Transformation,(long(0)),"Sweep",App::Prop_None,"Section transformation mode");
Mode.setEnums(ModeEnums);
Transition.setEnums(TransitionEnums);
Transformation.setEnums(TransformEnums);
}
short Pipe::mustExecute() const
@ -87,10 +104,234 @@ short Pipe::mustExecute() const
App::DocumentObjectExecReturn *Pipe::execute(void)
{
Part::Part2DObject* sketch = 0;
std::vector<TopoDS_Wire> wires;
try {
sketch = getVerifiedSketch();
wires = getSketchWires();
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopoDS_Shape sketchshape = makeFace(wires);
if (sketchshape.IsNull())
return new App::DocumentObjectExecReturn("Pipe: Creating a face from sketch failed");
// if the Base property has a valid shape, fuse the pipe into it
TopoDS_Shape base;
try {
base = getBaseShape();
} catch (const Base::Exception&) {
try {
// fall back to support (for legacy features)
base = getSupportShape();
} catch (const Base::Exception&) {
// ignore, because support isn't mandatory
base = TopoDS_Shape();
}
}
return SketchBased::execute();
try {
App::DocumentObject* spine = Spine.getValue();
if (!(spine && spine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
return new App::DocumentObjectExecReturn("No spine linked.");
std::vector<std::string> subedge = Spine.getSubValues();
TopoDS_Shape path;
const Part::TopoShape& shape = static_cast<Part::Feature*>(spine)->Shape.getValue();
buildPipePath(shape, subedge, path);
BRepOffsetAPI_MakePipeShell mkPipeShell(TopoDS::Wire(path));
mkPipeShell.SetTolerance(Precision::Confusion());
//mkPipeShell.SetMode(isFrenet);
switch(Transition.getValue()) {
case 0:
mkPipeShell.SetTransitionMode(BRepBuilderAPI_Transformed);
break;
case 1:
mkPipeShell.SetTransitionMode(BRepBuilderAPI_RightCorner);
break;
case 2:
mkPipeShell.SetTransitionMode(BRepBuilderAPI_RoundCorner);
break;
}
bool auxillery = false;
const Base::Vector3d& bVec = Binormal.getValue();
switch(Mode.getValue()) {
case 1:
mkPipeShell.SetMode(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1), gp_Dir(1,0,0)));
break;
case 2:
mkPipeShell.SetMode(gp_Dir(bVec.x,bVec.y,bVec.z));
break;
case 3:
mkPipeShell.SetMode(true);
break;
case 4:
auxillery = true;
}
if(auxillery) {
TopoDS_Shape auxpath;
App::DocumentObject* auxspine = AuxillerySpine.getValue();
if (!(auxspine && auxspine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
return new App::DocumentObjectExecReturn("No auxillery spine linked.");
std::vector<std::string> auxsubedge = AuxillerySpine.getSubValues();
TopoDS_Shape path;
const Part::TopoShape& auxshape = static_cast<Part::Feature*>(auxspine)->Shape.getValue();
buildPipePath(auxshape, auxsubedge, auxpath);
if(Transformation.getValue()!=2)
mkPipeShell.SetMode(TopoDS::Wire(auxshape._Shape), AuxilleryCurvelinear.getValue());
else
mkPipeShell.SetMode(TopoDS::Wire(auxshape._Shape), AuxilleryCurvelinear.getValue(), BRepFill_ContactOnBorder);
}
// TopTools_ListIteratorOfListOfShape iter;
// for (iter.Initialize(profiles); iter.More(); iter.Next()) {
// mkPipeShell.Add(TopoDS_Shape(iter.Value()));
// }
mkPipeShell.Add(wires.front());
if (!mkPipeShell.IsReady())
Standard_Failure::Raise("shape is not ready to build");
mkPipeShell.Build();
mkPipeShell.MakeSolid();
/*
TopTools_ListOfShape sim;
mkPipeShell.Simulate(5, sim);
BRep_Builder builder;
TopoDS_Compound Comp;
builder.MakeCompound(Comp);
TopTools_ListIteratorOfListOfShape simIt;
for (simIt.Initialize(sim); simIt.More(); simIt.Next())
builder.Add(Comp, simIt.Value()) ;
*/
this->Shape.setValue(mkPipeShell.Shape());
return App::DocumentObject::StdReturn;
return SketchBased::execute();
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
return new App::DocumentObjectExecReturn(e->GetMessageString());
}
catch (...) {
return new App::DocumentObjectExecReturn("A fatal error occurred when making the sweep");
}
}
void Pipe::getContiniusEdges(Part::TopoShape TopShape, std::vector< std::string >& SubNames) {
TopTools_IndexedMapOfShape mapOfEdges;
TopTools_IndexedDataMapOfShapeListOfShape mapEdgeEdge;
TopExp::MapShapesAndAncestors(TopShape._Shape, TopAbs_EDGE, TopAbs_EDGE, mapEdgeEdge);
TopExp::MapShapes(TopShape._Shape, TopAbs_EDGE, mapOfEdges);
Base::Console().Message("Initial edges:\n");
for(int i=0; i<SubNames.size(); ++i)
Base::Console().Message("Subname: %s\n", SubNames[i].c_str());
unsigned 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 = mapEdgeEdge.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++;
}
// empty name or any other sub-element
else {
SubNames.erase(SubNames.begin()+i);
}
}
Base::Console().Message("Final edges:\n");
for(int i=0; i<SubNames.size(); ++i)
Base::Console().Message("Subname: %s\n", SubNames[i].c_str());
}
void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector< std::string >& subedge, TopoDS_Shape& path) {
if (!shape._Shape.IsNull()) {
try {
if (!subedge.empty()) {
//if(SpineTangent.getValue())
//getContiniusEdges(shape, subedge);
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
path = mkWire.Wire();
}
else if (shape._Shape.ShapeType() == TopAbs_EDGE) {
path = shape._Shape;
}
else if (shape._Shape.ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
path = mkWire.Wire();
}
else if (shape._Shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape._Shape);
for (; it.More(); it.Next()) {
if (it.Value().IsNull())
throw Base::Exception("In valid element in spine.");
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
(it.Value().ShapeType() != TopAbs_WIRE)) {
throw Base::Exception("Element in spine is neither an edge nor a wire.");
}
}
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(shape._Shape, TopAbs_EDGE); xp.More(); xp.Next())
hEdges->Append(xp.Current());
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
int len = hWires->Length();
if (len != 1)
throw Base::Exception("Spine is not connected.");
path = hWires->Value(1);
}
else {
throw Base::Exception("Spine is neither an edge nor a wire.");
}
}
catch (Standard_Failure) {
throw Base::Exception("Invalid spine.");
}
}
}
PROPERTY_SOURCE(PartDesign::AdditivePipe, PartDesign::Pipe)
AdditivePipe::AdditivePipe() {
addSubType = Additive;

View File

@ -37,10 +37,17 @@ class PartDesignExport Pipe : public SketchBased
public:
Pipe();
App::PropertyLinkList Sections;
App::PropertyLinkSubList Spine;
App::PropertyLinkSub Spine;
App::PropertyBool SpineTangent;
App::PropertyLinkSub AuxillerySpine;
App::PropertyBool AuxillerySpineTangent;
App::PropertyBool AuxilleryCurvelinear;
App::PropertyEnumeration Mode;
App::PropertyVector Binormal;
App::PropertyEnumeration Transition;
App::PropertyEnumeration Transformation;
App::PropertyLinkList Sections;
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
@ -49,11 +56,17 @@ public:
return "PartDesignGui::ViewProviderPipe";
}
//@}
protected:
///get the given edges and all their tangent ones
void getContiniusEdges(Part::TopoShape TopShape, std::vector< std::string >& SubNames);
void buildPipePath(const Part::TopoShape& input, const std::vector<std::string>& edges, TopoDS_Shape& result);
private:
static const char* TypeEnums[];
static const char* TransitionEnums[];
static const char* ModeEnums[];
static const char* TransformEnums[];
};
class PartDesignExport AdditivePipe : public Pipe {

View File

@ -78,6 +78,8 @@ set(PartDesignGui_UIC_SRCS
TaskDatumParameters.ui
TaskPrimitiveParameters.ui
TaskPipeParameters.ui
TaskPipeOrientation.ui
TaskPipeScaling.ui
)
qt4_wrap_ui(PartDesignGui_UIC_HDRS ${PartDesignGui_UIC_SRCS})
@ -203,6 +205,8 @@ SET(PartDesignGuiTaskDlgs_SRCS
TaskPrimitiveParameters.h
TaskPrimitiveParameters.cpp
TaskPipeParameters.ui
TaskPipeOrientation.ui
TaskPipeScaling.ui
TaskPipeParameters.h
TaskPipeParameters.cpp
)

View File

@ -29,6 +29,7 @@
<file>icons/PartDesign_Body_Create_New.svg</file>
<file>icons/PartDesign_Body_Tree.svg</file>
<file>icons/PartDesign_Additive_Pipe.svg</file>
<file>icons/PartDesign_Subtractive_Pipe.svg</file>
<file>icons/PartDesign_Additive_Box.svg</file>
<file>icons/PartDesign_Additive_Cylinder.svg</file>
<file>icons/PartDesign_Additive_Sphere.svg</file>

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
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.91 r13725"
sodipodi:docname="PartDesign_Subtractive_Pipe.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs3366">
<linearGradient
osb:paint="gradient"
id="linearGradient4178">
<stop
style="stop-color:#860300;stop-opacity:0.75301206"
offset="0"
id="stop4180" />
<stop
style="stop-color:#ff1800;stop-opacity:1"
offset="1"
id="stop4182" />
</linearGradient>
<linearGradient
id="linearGradient4166">
<stop
style="stop-color:#2d0700;stop-opacity:1"
offset="0"
id="stop4168" />
<stop
style="stop-color:#ff1400;stop-opacity:1"
offset="1"
id="stop4170" />
</linearGradient>
<linearGradient
id="linearGradient4513"
osb:paint="solid">
<stop
style="stop-color:#ff0900;stop-opacity:1;"
offset="0"
id="stop4515" />
</linearGradient>
<marker
inkscape:stockid="Arrow2Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lstart"
style="overflow:visible">
<path
id="path3909"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) translate(1,0)" />
</marker>
<linearGradient
id="linearGradient3864"
osb:paint="gradient">
<stop
id="stop3866"
offset="0"
style="stop-color:#71b2f8;stop-opacity:0.44347826;" />
<stop
id="stop3868"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient2571"
gradientUnits="userSpaceOnUse"
cx="342.58258"
cy="27.256668"
fx="342.58258"
fy="27.256668"
r="19.571428"
gradientTransform="matrix(1.6258409,0.5434973,-8.8819886e-2,0.2656996,-215.02413,-170.90186)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3593"
id="radialGradient3352"
gradientUnits="userSpaceOnUse"
cx="345.28433"
cy="15.560534"
fx="345.28433"
fy="15.560534"
r="19.571428"
gradientTransform="translate(-0.1767767,-2.6516504)" />
<linearGradient
id="linearGradient3593">
<stop
style="stop-color:#c8e0f9;stop-opacity:1;"
offset="0"
id="stop3595" />
<stop
style="stop-color:#637dca;stop-opacity:1;"
offset="1"
id="stop3597" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3593"
id="radialGradient3354"
gradientUnits="userSpaceOnUse"
cx="330.63791"
cy="39.962704"
fx="330.63791"
fy="39.962704"
r="19.571428"
gradientTransform="translate(-0.1767767,-2.6516504)" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective3372" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3864"
id="radialGradient3369"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.6258409,0.5434973,-8.8819886e-2,0.2656996,-461.81066,-173.06271)"
cx="342.58258"
cy="27.256668"
fx="342.58258"
fy="27.256668"
r="19.571428" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4178"
id="linearGradient3828"
x1="27.457661"
y1="43.225605"
x2="49.506325"
y2="24.619841"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.1630793,0,0,1.1396343,-2.5165983,3.4151415)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3864-1"
id="linearGradient3828-2"
x1="20.383333"
y1="32.634235"
x2="52.726578"
y2="32.634235"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3864-1">
<stop
id="stop3866-6"
offset="0"
style="stop-color:#71b2f8;stop-opacity:1;" />
<stop
id="stop3868-7"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<linearGradient
gradientTransform="matrix(1.1630793,0,0,1.1396343,-26.255988,14.322778)"
y2="9.937151"
x2="49.863113"
y1="36.335907"
x1="34.891544"
gradientUnits="userSpaceOnUse"
id="linearGradient3845"
xlink:href="#linearGradient4166"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="9.0078335"
inkscape:cx="-1.1082183"
inkscape:cy="23.949442"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1848"
inkscape:window-height="1043"
inkscape:window-x="66"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="false" />
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="opacity:0.85;fill:url(#linearGradient3845);fill-opacity:1;stroke:#090909;stroke-width:2.187;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 11.201557,37.130882 c 0.252178,-0.07113 10.905391,3.84229 14.378208,5.296596 C 45.31682,39.628785 46.26631,22.510259 52.095791,10.58178 L 28.627124,6.652762 c -1.621192,11.174906 -3.334532,23.98441 -17.425567,30.47812 z"
id="path3820-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:#1a00ff;stroke-width:2.55285668;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 11.414852,53.329345 c -0.162971,-6.91565 0.10332,-4.922865 -0.144914,-16.265896"
id="path3918-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#1a00ff;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:30.29999924;stroke-opacity:1;stroke-dasharray:18, 6;stroke-dashoffset:0;marker-start:none"
d="M 0.88417837,48.039022 C 11.330775,48.513224 32.686249,53.004323 42.745293,41.872435 51.278061,32.429606 53.4974,19.758654 61.595219,2.2398862"
id="path3885"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<path
style="fill:url(#linearGradient3828);fill-opacity:1;fill-rule:nonzero;stroke:#090909;stroke-width:2.18746471;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 26.040147,42.43608 0.226329,18.152407 C 44.9786,59.94313 58.160467,44.639618 60.629125,31.212185 L 51.67214,11.437294 C 43.6375,30.278349 43.168055,38.742321 26.040147,42.43608 z"
id="path3820"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;stroke:#1a00ff;stroke-width:2.87824273;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 28.798855,6.2907134 23.256841,4.5887046 8.726353,20.099536"
id="path3864"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#1a00ff;stroke-width:2.55299997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 11.380951,37.174463 14.558836,5.397865 0.389553,17.96064 C 22.550473,59.403098 14.498258,55.027369 11.414853,53.551374"
id="path3918-3-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -197,6 +197,7 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
origin->setTemporaryVisibilityAxis(true);
origin->setTemporaryVisibilityPlanes(true);
}
}
}

View File

@ -0,0 +1,264 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskPipeOrientation</class>
<widget class="QWidget" name="PartDesignGui::TaskPipeOrientation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Orientation mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Standart</string>
</property>
</item>
<item>
<property name="text">
<string>Fixed</string>
</property>
</item>
<item>
<property name="text">
<string>Binormal</string>
</property>
</item>
<item>
<property name="text">
<string>Frenet</string>
</property>
</item>
<item>
<property name="text">
<string>Auxillery</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="standart"/>
<widget class="QWidget" name="fixed"/>
<widget class="QWidget" name="binormal">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Set the constant binormal vector used to calculate the profiles orientation</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="horizontalSpacing">
<number>20</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxX">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxY">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxZ">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="frenet"/>
<widget class="QWidget" name="auxillery">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="curvelinear">
<property name="text">
<string>Curvelinear equivalenz</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Profile</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="buttonProfileBase">
<property name="text">
<string>Object</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="profileBaseEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<widget class="QCheckBox" name="tangent">
<property name="text">
<string>Extend to tangent edges</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>comboBoxMode</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>241</x>
<y>24</y>
</hint>
<hint type="destinationlabel">
<x>176</x>
<y>231</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -32,6 +32,8 @@
#endif
#include "ui_TaskPipeParameters.h"
#include "ui_TaskPipeOrientation.h"
#include "ui_TaskPipeScaling.h"
#include "TaskPipeParameters.h"
#include <App/Application.h>
#include <App/Document.h>
@ -55,6 +57,12 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskPipeParameters */
//**************************************************************************
//**************************************************************************
// Task Parameter
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj, QWidget *parent)
: TaskSketchBasedParameters(PipeView, parent, "PartDesign_Pipe",tr("Pipe parameters"))
{
@ -63,195 +71,68 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj, Q
ui = new Ui_TaskPipeParameters();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
/*
connect(ui->lengthEdit, SIGNAL(valueChanged(double)),
this, SLOT(onLengthChanged(double)));
connect(ui->checkBoxMidplane, SIGNAL(toggled(bool)),
this, SLOT(onMidplane(bool)));
connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
this, SLOT(onReversed(bool)));
connect(ui->lengthEdit2, SIGNAL(valueChanged(double)),
this, SLOT(onLength2Changed(double)));
connect(ui->spinOffset, SIGNAL(valueChanged(double)),
this, SLOT(onOffsetChanged(double)));
connect(ui->changeMode, SIGNAL(currentIndexChanged(int)),
this, SLOT(onModeChanged(int)));
connect(ui->buttonFace, SIGNAL(clicked()),
this, SLOT(onButtonFace()));
connect(ui->lineFaceName, SIGNAL(textEdited(QString)),
this, SLOT(onFaceName(QString)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
*/
connect(ui->comboBoxTransition, SIGNAL(currentIndexChanged(int)),
this, SLOT(onTransitionChanged(int)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
connect(ui->tangent, SIGNAL(toggled(bool)),
this, SLOT(onTangentChanged(bool)));
connect(ui->buttonProfileBase, SIGNAL(toggled(bool)),
this, SLOT(onBaseButton(bool)));
this->groupLayout()->addWidget(proxy);
/*
// Temporarily prevent unnecessary feature recomputes
ui->lengthEdit->blockSignals(true);
ui->lengthEdit2->blockSignals(true);
ui->checkBoxMidplane->blockSignals(true);
ui->checkBoxReversed->blockSignals(true);
ui->buttonFace->blockSignals(true);
ui->lineFaceName->blockSignals(true);
ui->changeMode->blockSignals(true);
//add initial values
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
std::vector<std::string> strings = pipe->Spine.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue());
ui->tangent->setChecked(pipe->SpineTangent.getValue());
// set the history path
ui->lengthEdit->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength"));
ui->lengthEdit2->setParamGrpPath(QByteArray("User parameter:BaseApp/History/PipeLength2"));
// Get the feature data
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
Base::Quantity l = pcPipe->Length.getQuantityValue();
bool midplane = pcPipe->Midplane.getValue();
bool reversed = pcPipe->Reversed.getValue();
Base::Quantity l2 = pcPipe->Length2.getQuantityValue();
int index = pcPipe->Type.getValue(); // must extract value here, clear() kills it!
App::DocumentObject* obj = pcPipe->UpToFace.getValue();
std::vector<std::string> subStrings = pcPipe->UpToFace.getSubValues();
std::string upToFace;
int faceId = -1;
if ((obj != NULL) && !subStrings.empty()) {
upToFace = subStrings.front();
if (upToFace.substr(0,4) == "Face")
faceId = std::atoi(&upToFace[4]);
}
// Fill data into dialog elements
ui->lengthEdit->setMinimum(0);
ui->lengthEdit->setMaximum(INT_MAX);
ui->lengthEdit->setValue(l);
ui->lengthEdit2->setMinimum(0);
ui->lengthEdit2->setMaximum(INT_MAX);
ui->lengthEdit2->setValue(l2);
ui->checkBoxMidplane->setChecked(midplane);
// According to bug #0000521 the reversed option
// shouldn't be de-activated if the pad has a support face
ui->checkBoxReversed->setChecked(reversed);
if ((obj != NULL) && PartDesign::Feature::isDatum(obj))
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()));
else if (faceId >= 0)
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()) + QString::fromAscii(":") + tr("Face") +
QString::number(faceId));
else
ui->lineFaceName->setText(tr("No face selected"));
ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str()));
ui->changeMode->clear();
ui->changeMode->insertItem(0, tr("Dimension"));
ui->changeMode->insertItem(1, tr("To last"));
ui->changeMode->insertItem(2, tr("To first"));
ui->changeMode->insertItem(3, tr("Up to face"));
ui->changeMode->insertItem(4, tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
// activate and de-activate dialog elements as appropriate
ui->lengthEdit->blockSignals(false);
ui->lengthEdit2->blockSignals(false);
ui->checkBoxMidplane->blockSignals(false);
ui->checkBoxReversed->blockSignals(false);
ui->buttonFace->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
updateUI(index);
// if it is a newly created object use the last value of the history
if(newObj){
ui->lengthEdit->setToLastUsedValue();
ui->lengthEdit->selectNumber();
ui->lengthEdit2->setToLastUsedValue();
ui->lengthEdit2->selectNumber();
}*/
updateUI();
}
void TaskPipeParameters::updateUI(int index)
{/*
if (index == 0) { // dimension
ui->labelLength->setVisible(true);
ui->spinOffset->setVisible(false);
ui->spinOffset->setEnabled(false);
ui->labelOffset->setVisible(false);
ui->lengthEdit->setEnabled(true);
ui->lengthEdit->selectNumber();
// Make sure that the spin box has the focus to get key events
// Calling setFocus() directly doesn't work because the spin box is not
// yet visible.
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
ui->checkBoxMidplane->setEnabled(true);
// Reverse only makes sense if Midplane is not true
ui->checkBoxReversed->setEnabled(!ui->checkBoxMidplane->isChecked());
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
} else if (index == 1 || index == 2) { // up to first/last
ui->labelLength->setVisible(false);
ui->spinOffset->setVisible(true);
ui->spinOffset->setEnabled(true);
ui->labelOffset->setVisible(true);
ui->lengthEdit->setEnabled(false);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(true);
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
} else if (index == 3) { // up to face
ui->labelLength->setVisible(false);
ui->spinOffset->setVisible(true);
ui->spinOffset->setEnabled(true);
ui->labelOffset->setVisible(true);
ui->lengthEdit->setEnabled(false);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(false);
ui->lengthEdit2->setEnabled(false);
ui->buttonFace->setEnabled(true);
ui->lineFaceName->setEnabled(true);
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
// Go into reference selection mode if no face has been selected yet
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
onButtonFace(true);
} else { // two dimensions
ui->labelLength->setVisible(true);
ui->spinOffset->setVisible(false);
ui->spinOffset->setEnabled(false);
ui->labelOffset->setVisible(false);
ui->lengthEdit->setEnabled(true);
ui->lengthEdit->selectNumber();
QMetaObject::invokeMethod(ui->lengthEdit, "setFocus", Qt::QueuedConnection);
ui->checkBoxMidplane->setEnabled(false);
ui->checkBoxReversed->setEnabled(false);
ui->lengthEdit2->setEnabled(true);
ui->buttonFace->setEnabled(false);
ui->lineFaceName->setEnabled(false);
onButtonFace(false);
}*/
void TaskPipeParameters::updateUI()
{
}
void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{/*
if (msg.Type == Gui::SelectionChanges::AddSelection) {
QString refText = onAddSelection(msg);
if (refText.length() != 0) {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(refText);
ui->lineFaceName->setProperty("FaceName", QByteArray(msg.pSubName));
ui->lineFaceName->blockSignals(false);
// Turn off reference selection mode
onButtonFace(false);
} else {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(tr("No face selected"));
ui->lineFaceName->setProperty("FaceName", QByteArray());
ui->lineFaceName->blockSignals(false);
}
}
{
if (selectionMode == none)
return;
else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
ui->lineFaceName->blockSignals(true);
ui->lineFaceName->setText(tr(""));
ui->lineFaceName->setProperty("FaceName", QByteArray());
ui->lineFaceName->blockSignals(false);
}*/
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd) {
QString sub = QString::fromStdString(msg.pSubName);
if(!sub.isEmpty())
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
ui->profileBaseEdit->setText(QString::fromStdString(msg.pObjectName));
}
else if (selectionMode == refRemove) {
QString sub = QString::fromStdString(msg.pSubName);
if(!sub.isEmpty())
removeFromListWidget(ui->listWidgetReferences, QString::fromAscii(msg.pSubName));
else {
ui->profileBaseEdit->clear();
}
} else if(selectionMode == refObjAdd) {
ui->listWidgetReferences->clear();
ui->profileBaseEdit->setText(QString::fromAscii(msg.pObjectName));
}
//clearButtons(none);
recomputeFeature();
}
clearButtons();
exitSelectionMode();
}
}
TaskPipeParameters::~TaskPipeParameters()
@ -259,44 +140,404 @@ TaskPipeParameters::~TaskPipeParameters()
delete ui;
}
void TaskPipeParameters::changeEvent(QEvent *e)
{/*
TaskBox::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->spinOffset->blockSignals(true);
ui->lengthEdit->blockSignals(true);
ui->lengthEdit2->blockSignals(true);
ui->lineFaceName->blockSignals(true);
ui->changeMode->blockSignals(true);
int index = ui->changeMode->currentIndex();
ui->retranslateUi(proxy);
ui->changeMode->clear();
ui->changeMode->addItem(tr("Dimension"));
ui->changeMode->addItem(tr("To last"));
ui->changeMode->addItem(tr("To first"));
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->addItem(tr("Two dimensions"));
ui->changeMode->setCurrentIndex(index);
void TaskPipeParameters::onTransitionChanged(int idx) {
static_cast<PartDesign::Pipe*>(vp->getObject())->Transition.setValue(idx);
recomputeFeature();
}
QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':'));
QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray();
int faceId = -1;
bool ok = false;
if (upToFace.indexOf("Face") == 0) {
faceId = upToFace.remove(0,4).toInt(&ok);
void TaskPipeParameters::onButtonRefAdd(bool checked) {
if (checked) {
//clearButtons(refAdd);
//hideObject();
Gui::Selection().clearSelection();
selectionMode = refAdd;
//DressUpView->highlightReferences(true);
}
}
void TaskPipeParameters::onButtonRefRemove(bool checked) {
if (checked) {
//clearButtons(refRemove);
//hideObject();
Gui::Selection().clearSelection();
selectionMode = refRemove;
//DressUpView->highlightReferences(true);
}
}
void TaskPipeParameters::onBaseButton(bool checked) {
if (checked) {
//clearButtons(refRemove);
//hideObject();
Gui::Selection().clearSelection();
selectionMode = refObjAdd;
//DressUpView->highlightReferences(true);
}
}
void TaskPipeParameters::onTangentChanged(bool checked) {
static_cast<PartDesign::Pipe*>(vp->getObject())->SpineTangent.setValue(checked);
recomputeFeature();
}
void TaskPipeParameters::removeFromListWidget(QListWidget* widget, QString itemstr) {
QList<QListWidgetItem*> items = widget->findItems(itemstr, Qt::MatchExactly);
if (!items.empty()) {
for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
QListWidgetItem* it = widget->takeItem(widget->row(*i));
delete it;
}
#if QT_VERSION >= 0x040700
ui->lineFaceName->setPlaceholderText(tr("No face selected"));
#endif
ui->lineFaceName->setText(ok ?
parts[0] + QString::fromAscii(":") + tr("Face") + QString::number(faceId) :
tr("No face selected"));
ui->spinOffset->blockSignals(false);
ui->lengthEdit->blockSignals(false);
ui->lengthEdit2->blockSignals(false);
ui->lineFaceName->blockSignals(false);
ui->changeMode->blockSignals(false);
}*/
}
}
bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const {
if ((msg.Type == Gui::SelectionChanges::AddSelection) && (
(selectionMode == refAdd) || (selectionMode == refRemove)
|| (selectionMode == refObjAdd))) {
if (strcmp(msg.pDocName, vp->getObject()->getDocument()->getName()) != 0)
return false;
// not allowed to reference ourself
const char* fname = vp->getObject()->getNameInDocument();
if (strcmp(msg.pObjectName, fname) == 0)
return false;
//change the references
std::string subName(msg.pSubName);
std::vector<std::string> refs = static_cast<PartDesign::Pipe*>(vp->getObject())->Spine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
if(selectionMode != refObjAdd) {
if (selectionMode == refAdd) {
if (f == refs.end())
refs.push_back(subName);
else
return false; // duplicate selection
} else {
if (f != refs.end())
refs.erase(f);
else
return false;
}
}
else {
refs.clear();
}
static_cast<PartDesign::Pipe*>(vp->getObject())->Spine.setValue(vp->getObject()->getDocument()->getObject(msg.pObjectName),
refs);
return true;
}
return false;
}
void TaskPipeParameters::clearButtons() {
ui->buttonRefAdd->setChecked(false);
ui->buttonRefRemove->setChecked(false);
ui->buttonProfileBase->setChecked(false);
}
void TaskPipeParameters::exitSelectionMode() {
selectionMode = none;
Gui::Selection().clearSelection();
}
//**************************************************************************
//**************************************************************************
// Tassk Orientation
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool newObj, QWidget* parent)
: TaskSketchBasedParameters(PipeView, parent, "PartDesign_Pipe", tr("Section orientation")) {
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskPipeOrientation();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->comboBoxMode, SIGNAL(currentIndexChanged(int)),
this, SLOT(onOrientationChanged(int)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
connect(ui->tangent, SIGNAL(toggled(bool)),
this, SLOT(onTangentChanged(bool)));
connect(ui->buttonProfileBase, SIGNAL(toggled(bool)),
this, SLOT(onBaseButton(bool)));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)),
this, SLOT(updateUI(int)));
connect(ui->curvelinear, SIGNAL(toggled(bool)),
this, SLOT(onCurvelinearChanged(bool)));
connect(ui->doubleSpinBoxX, SIGNAL(valueChanged(double)),
this, SLOT(onBinormalChanged(double)));
connect(ui->doubleSpinBoxY, SIGNAL(valueChanged(double)),
this, SLOT(onBinormalChanged(double)));
connect(ui->doubleSpinBoxZ, SIGNAL(valueChanged(double)),
this, SLOT(onBinormalChanged(double)));
this->groupLayout()->addWidget(proxy);
//add initial values
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
std::vector<std::string> strings = pipe->AuxillerySpine.getSubValues();
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
ui->comboBoxMode->setCurrentIndex(pipe->Mode.getValue());
ui->tangent->setChecked(pipe->AuxillerySpineTangent.getValue());
ui->curvelinear->setChecked(pipe->AuxilleryCurvelinear.getValue());
updateUI(0);
}
TaskPipeOrientation::~TaskPipeOrientation() {
}
void TaskPipeOrientation::onOrientationChanged(int idx) {
static_cast<PartDesign::Pipe*>(vp->getObject())->Mode.setValue(idx);
recomputeFeature();
}
void TaskPipeOrientation::clearButtons() {
}
void TaskPipeOrientation::exitSelectionMode() {
}
void TaskPipeOrientation::onButtonRefAdd(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
selectionMode = refAdd;
}
}
void TaskPipeOrientation::onButtonRefRemove(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
selectionMode = refRemove;
}
}
void TaskPipeOrientation::onBaseButton(bool checked) {
if (checked) {
Gui::Selection().clearSelection();
selectionMode = refObjAdd;
}
}
void TaskPipeOrientation::onTangentChanged(bool checked) {
}
void TaskPipeOrientation::onCurvelinearChanged(bool checked) {
static_cast<PartDesign::Pipe*>(vp->getObject())->AuxilleryCurvelinear.setValue(checked);
recomputeFeature();
}
void TaskPipeOrientation::onBinormalChanged(double) {
Base::Vector3d vec(ui->doubleSpinBoxX->value(),
ui->doubleSpinBoxY->value(),
ui->doubleSpinBoxZ->value());
static_cast<PartDesign::Pipe*>(vp->getObject())->Binormal.setValue(vec);
recomputeFeature();
}
void TaskPipeOrientation::onSelectionChanged(const SelectionChanges& msg) {
if (selectionMode == none)
return;
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (referenceSelected(msg)) {
if (selectionMode == refAdd) {
QString sub = QString::fromStdString(msg.pSubName);
if(!sub.isEmpty())
ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName));
ui->profileBaseEdit->setText(QString::fromStdString(msg.pObjectName));
}
else if (selectionMode == refRemove) {
QString sub = QString::fromStdString(msg.pSubName);
if(!sub.isEmpty())
removeFromListWidget(ui->listWidgetReferences, QString::fromAscii(msg.pSubName));
else {
ui->profileBaseEdit->clear();
}
} else if(selectionMode == refObjAdd) {
ui->listWidgetReferences->clear();
ui->profileBaseEdit->setText(QString::fromAscii(msg.pObjectName));
}
//clearButtons(none);
recomputeFeature();
}
clearButtons();
exitSelectionMode();
}
}
bool TaskPipeOrientation::referenceSelected(const SelectionChanges& msg) const {
if ((msg.Type == Gui::SelectionChanges::AddSelection) && (
(selectionMode == refAdd) || (selectionMode == refRemove)
|| (selectionMode == refObjAdd))) {
if (strcmp(msg.pDocName, vp->getObject()->getDocument()->getName()) != 0)
return false;
// not allowed to reference ourself
const char* fname = vp->getObject()->getNameInDocument();
if (strcmp(msg.pObjectName, fname) == 0)
return false;
//change the references
std::string subName(msg.pSubName);
std::vector<std::string> refs = static_cast<PartDesign::Pipe*>(vp->getObject())->AuxillerySpine.getSubValues();
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
if(selectionMode != refObjAdd) {
if (selectionMode == refAdd) {
if (f == refs.end())
refs.push_back(subName);
else
return false; // duplicate selection
} else {
if (f != refs.end())
refs.erase(f);
else
return false;
}
}
else {
refs.clear();
}
static_cast<PartDesign::Pipe*>(vp->getObject())->AuxillerySpine.setValue(vp->getObject()->getDocument()->getObject(msg.pObjectName),
refs);
return true;
}
return false;
}
void TaskPipeOrientation::removeFromListWidget(QListWidget* w, QString name) {
}
void TaskPipeOrientation::updateUI(int idx) {
//make sure we resize to the size of the current page
for(int i=0; i<ui->stackedWidget->count(); ++i)
ui->stackedWidget->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ui->stackedWidget->widget(idx)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
//**************************************************************************
//**************************************************************************
// Task Scaling
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool newObj, QWidget* parent)
: TaskSketchBasedParameters(PipeView, parent, "PartDesign_Pipe", tr("Section transformation")) {
// we need a separate container widget to add all controls to
proxy = new QWidget(this);
ui = new Ui_TaskPipeScaling();
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->comboBoxScaling, SIGNAL(currentIndexChanged(int)),
this, SLOT(onScalingChanged(int)));
connect(ui->buttonRefAdd, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefAdd(bool)));
connect(ui->buttonRefRemove, SIGNAL(toggled(bool)),
this, SLOT(onButtonRefRemove(bool)));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)),
this, SLOT(updateUI(int)));
this->groupLayout()->addWidget(proxy);
// ui->comboBoxTransition->clear();
// ui->comboBoxTransition->insertItem(0, tr("Transformed"));
// ui->comboBoxTransition->insertItem(1, tr("Right Corner"));
// ui->comboBoxTransition->insertItem(2, tr("Round Corner"));
// ui->comboBoxTransition->setCurrentIndex(0);
updateUI(0);
}
TaskPipeScaling::~TaskPipeScaling() {
}
void TaskPipeScaling::clearButtons() {
}
void TaskPipeScaling::exitSelectionMode() {
}
void TaskPipeScaling::onButtonRefAdd(bool checked) {
}
void TaskPipeScaling::onButtonRefRemove(bool checked) {
}
void TaskPipeScaling::onScalingChanged(int idx) {
static_cast<PartDesign::Pipe*>(vp->getObject())->Transformation.setValue(idx);
recomputeFeature();
}
void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) {
}
bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const {
}
void TaskPipeScaling::removeFromListWidget(QListWidget* w, QString name) {
}
void TaskPipeScaling::updateUI(int idx) {
//make sure we resize to the size of the current page
for(int i=0; i<ui->stackedWidget->count(); ++i)
ui->stackedWidget->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
ui->stackedWidget->widget(idx)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
@ -309,9 +550,13 @@ TaskDlgPipeParameters::TaskDlgPipeParameters(ViewProviderPipe *PipeView,bool new
: TaskDlgSketchBasedParameters(PipeView)
{
assert(PipeView);
parameter = new TaskPipeParameters(PipeView,newObj);
parameter = new TaskPipeParameters(PipeView,newObj);
orientation = new TaskPipeOrientation(PipeView,newObj);
scaling = new TaskPipeScaling(PipeView,newObj);
Content.push_back(parameter);
Content.push_back(orientation);
Content.push_back(scaling);
}
TaskDlgPipeParameters::~TaskDlgPipeParameters()

View File

@ -30,8 +30,12 @@
#include "TaskSketchBasedParameters.h"
#include "ViewProviderPipe.h"
#include "TaskDressUpParameters.h"
class Ui_TaskPipeParameters;
class Ui_TaskPipeOrientation;
class Ui_TaskPipeScaling;
namespace App {
class Property;
@ -55,19 +59,100 @@ public:
private Q_SLOTS:
void onTangentChanged(bool checked);
void onTransitionChanged(int);
void onButtonRefAdd(bool checked);
void onButtonRefRemove(bool checked);
void onBaseButton(bool checked);
protected:
void changeEvent(QEvent *e);
enum selectionModes { none, refAdd, refRemove, refObjAdd };
selectionModes selectionMode = none;
void removeFromListWidget(QListWidget*w, QString name);
bool referenceSelected(const Gui::SelectionChanges& msg) const;
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
void updateUI(int index);
void updateUI();
void clearButtons();
void exitSelectionMode();
private:
QWidget* proxy;
Ui_TaskPipeParameters* ui;
};
class TaskPipeOrientation : public TaskSketchBasedParameters
{
Q_OBJECT
public:
TaskPipeOrientation(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0);
virtual ~TaskPipeOrientation();
private Q_SLOTS:
void onOrientationChanged(int);
void onButtonRefAdd(bool checked);
void onButtonRefRemove(bool checked);
void updateUI(int idx);
void onBaseButton(bool checked);
void onTangentChanged(bool checked);
void onCurvelinearChanged(bool checked);
void onBinormalChanged(double);
protected:
enum selectionModes { none, refAdd, refRemove, refObjAdd };
selectionModes selectionMode = none;
void removeFromListWidget(QListWidget*w, QString name);
bool referenceSelected(const Gui::SelectionChanges& msg) const;
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
void clearButtons();
void exitSelectionMode();
private:
QWidget* proxy;
Ui_TaskPipeOrientation* ui;
};
class TaskPipeScaling : public TaskSketchBasedParameters
{
Q_OBJECT
public:
TaskPipeScaling(ViewProviderPipe *PipeView,bool newObj=false,QWidget *parent = 0);
virtual ~TaskPipeScaling();
private Q_SLOTS:
void onScalingChanged(int);
void onButtonRefAdd(bool checked);
void onButtonRefRemove(bool checked);
void updateUI(int idx);
protected:
enum selectionModes { none, refAdd, refRemove };
selectionModes selectionMode = none;
void removeFromListWidget(QListWidget*w, QString name);
bool referenceSelected(const Gui::SelectionChanges& msg) const;
private:
void onSelectionChanged(const Gui::SelectionChanges& msg);
void clearButtons();
void exitSelectionMode();
private:
QWidget* proxy;
Ui_TaskPipeScaling* ui;
};
/// simulation dialog for the TaskView
class TaskDlgPipeParameters : public TaskDlgSketchBasedParameters
{
@ -88,6 +173,8 @@ public:
protected:
TaskPipeParameters *parameter;
TaskPipeOrientation *orientation;
TaskPipeScaling *scaling;
};
} //namespace PartDesignGui

View File

@ -6,65 +6,131 @@
<rect>
<x>0</x>
<y>0</y>
<width>257</width>
<height>305</height>
<width>306</width>
<height>421</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="buttonRefAdd">
<property name="text">
<string>Add Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Profile orientation</string>
<string>Corner Transition</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Transition type</string>
<widget class="QComboBox" name="comboBoxTransition">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Transformed</string>
</property>
</item>
<item>
<property name="text">
<string>Right Corner</string>
</property>
</item>
<item>
<property name="text">
<string>Round Corner</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Profile</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonProfileBase">
<property name="text">
<string>Object</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="profileBaseEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove Edge</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
<item>
<widget class="QCheckBox" name="tangent">
<property name="text">
<string>Extend to tangent edges</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartDesignGui::TaskPipeScaling</class>
<widget class="QWidget" name="PartDesignGui::TaskPipeScaling">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>353</width>
<height>407</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Transform mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxScaling">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Constant</string>
</property>
</item>
<item>
<property name="text">
<string>Multisection</string>
</property>
</item>
<item>
<property name="text">
<string>Auxillery</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="constant"/>
<widget class="QWidget" name="multisection">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Automaticly build profile from sections</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="buttonRefAdd">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Add Section</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonRefRemove">
<property name="text">
<string>Remove Section</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidgetReferences"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="auxillery">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>This mode is only available if the orientation is given by a secondary profile</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>comboBoxScaling</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>237</x>
<y>24</y>
</hint>
<hint type="destinationlabel">
<x>176</x>
<y>225</y>
</hint>
</hints>
</connection>
</connections>
</ui>