From 68ee7f4f278d1a6166d0bb227a6522ee0e416b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Mon, 1 Jun 2015 06:58:40 +0200 Subject: [PATCH] add two scaling modes --- src/Mod/PartDesign/App/FeaturePipe.cpp | 40 +++++- src/Mod/PartDesign/App/FeaturePipe.h | 1 + src/Mod/PartDesign/Gui/TaskPipeOrientation.ui | 9 ++ src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 32 ++++- src/Mod/PartDesign/Gui/TaskPipeParameters.h | 2 + src/Mod/PartDesign/Gui/TaskPipeScaling.ui | 125 ++++++++++++++++-- src/Mod/PartDesign/Gui/ViewProviderPipe.cpp | 2 +- 7 files changed, 192 insertions(+), 19 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index f7a97b9d9..91679d184 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -53,6 +53,9 @@ #include #include #include +#include +#include +#include #endif #include @@ -70,7 +73,7 @@ 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", "Frenet", "Auxillery", "Binormal", NULL}; -const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Auxillery", NULL}; +const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Linear", "S-shape", "Interpolation", NULL}; PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::SketchBased) @@ -88,6 +91,7 @@ Pipe::Pipe() 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"); + ADD_PROPERTY_TYPE(ScalingData, (), "Sweep", App::Prop_None, "Data for scaling laws"); Mode.setEnums(ModeEnums); Transition.setEnums(TransitionEnums); Transformation.setEnums(TransformEnums); @@ -163,7 +167,10 @@ App::DocumentObjectExecReturn *Pipe::execute(void) std::vector> wiresections; for(TopoDS_Wire& wire : wires) wiresections.push_back(std::vector(1, wire)); - + //maybe we need a sacling law + Handle(Law_Function) scalinglaw; + + //see if we shall use multiple sections if(Transformation.getValue() == 1) { //we need to order the sections to prevent occ from crahsing, as makepieshell connects @@ -188,6 +195,25 @@ App::DocumentObjectExecReturn *Pipe::execute(void) } } + //build the law functions instead + else if(Transformation.getValue() == 2) { + if(ScalingData.getValues().size()<1) + return new App::DocumentObjectExecReturn("No valid data given for liinear scaling mode"); + + Handle(Law_Linear) lin = new Law_Linear(); + lin->Set(0,1,1,ScalingData[0].x); + + scalinglaw = lin; + } + else if(Transformation.getValue() == 3) { + if(ScalingData.getValues().size()<1) + return new App::DocumentObjectExecReturn("No valid data given for liinear scaling mode"); + + Handle(Law_S) s = new Law_S(); + s->Set(0,1,ScalingData[0].y, 1, ScalingData[0].x, ScalingData[0].z); + + scalinglaw = s; + } //build all shells std::vector shells; @@ -197,8 +223,14 @@ App::DocumentObjectExecReturn *Pipe::execute(void) BRepOffsetAPI_MakePipeShell mkPS(TopoDS::Wire(path)); setupAlgorithm(mkPS, auxpath); - for(TopoDS_Wire& wire : wires) - mkPS.Add(wire); + if(!scalinglaw) { + for(TopoDS_Wire& wire : wires) + mkPS.Add(wire); + } + else { + for(TopoDS_Wire& wire : wires) + mkPS.SetLaw(wire, scalinglaw); + } if (!mkPS.IsReady()) return new App::DocumentObjectExecReturn("pipe could not be build"); diff --git a/src/Mod/PartDesign/App/FeaturePipe.h b/src/Mod/PartDesign/App/FeaturePipe.h index 08907abfc..f4c53e5c4 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.h +++ b/src/Mod/PartDesign/App/FeaturePipe.h @@ -49,6 +49,7 @@ public: App::PropertyEnumeration Transition; App::PropertyEnumeration Transformation; App::PropertyLinkList Sections; + App::PropertyVectorList ScalingData; App::DocumentObjectExecReturn *execute(void); short mustExecute() const; diff --git a/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui b/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui index 3dba7524a..1d42821e6 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui +++ b/src/Mod/PartDesign/Gui/TaskPipeOrientation.ui @@ -212,6 +212,9 @@ 0 + + -99.000000000000000 + @@ -222,6 +225,9 @@ 0 + + -99.000000000000000 + @@ -232,6 +238,9 @@ 0 + + -99.000000000000000 + diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 9426a77f3..525d2a4e5 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -537,6 +537,14 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool newObj, QWidge this, SLOT(onButtonRefRemove(bool))); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(updateUI(int))); + connect(ui->linearSpinBox, SIGNAL(valueChanged(double)), + this, SLOT(onLinearSpinBox(double))); + connect(ui->sshapeSpinBox, SIGNAL(valueChanged(double)), + this, SLOT(onSshapeChanged(double))); + connect(ui->sshapeStartDeriSpinBox, SIGNAL(valueChanged(double)), + this, SLOT(onSshapeChanged(double))); + connect(ui->sshapeEndDeriSpinBox, SIGNAL(valueChanged(double)), + this, SLOT(onSshapeChanged(double))); this->groupLayout()->addWidget(proxy); @@ -582,8 +590,13 @@ void TaskPipeScaling::onButtonRefRemove(bool checked) { void TaskPipeScaling::onScalingChanged(int idx) { + updateUI(idx); static_cast(vp->getObject())->Transformation.setValue(idx); - recomputeFeature(); + + if(idx==2) + onLinearSpinBox(ui->linearSpinBox->value()); + else if(idx==3) + onSshapeChanged(0); } void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) { @@ -666,6 +679,23 @@ void TaskPipeScaling::updateUI(int idx) { ui->stackedWidget->widget(idx)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } +void TaskPipeScaling::onLinearSpinBox(double val) { + + static_cast(vp->getObject())->ScalingData.setValue(Base::Vector3d(val,0,0)); + recomputeFeature(); +} + +void TaskPipeScaling::onSshapeChanged(double val) { + + double f, d0, d1; + f = ui->sshapeSpinBox->value(); + d0 = ui->sshapeStartDeriSpinBox->value(); + d1 = ui->sshapeEndDeriSpinBox->value(); + static_cast(vp->getObject())->ScalingData.setValue(Base::Vector3d(f, d0, d1)); + recomputeFeature(); +} + + //************************************************************************** //************************************************************************** diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.h b/src/Mod/PartDesign/Gui/TaskPipeParameters.h index b4eec5da6..5f797a2a5 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.h @@ -138,6 +138,8 @@ private Q_SLOTS: void onButtonRefAdd(bool checked); void onButtonRefRemove(bool checked); void updateUI(int idx); + void onLinearSpinBox(double val); + void onSshapeChanged(double val); protected: enum selectionModes { none, refAdd, refRemove }; diff --git a/src/Mod/PartDesign/Gui/TaskPipeScaling.ui b/src/Mod/PartDesign/Gui/TaskPipeScaling.ui index 211f328c3..206937968 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeScaling.ui +++ b/src/Mod/PartDesign/Gui/TaskPipeScaling.ui @@ -43,7 +43,12 @@ - Auxillery + Linear + + + + + S-Shape @@ -113,20 +118,114 @@ - + - - - This mode is only available if the orientation is given by a secondary profile - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - + + + + + Final scaling factor + + + + + + + + 0 + 0 + + + + 2 + + + 0.000000000000000 + + + 99999.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + + + + Scaling factor + + + + + + + + 0 + 0 + + + + -9999.000000000000000 + + + 9999.000000000000000 + + + 1.000000000000000 + + + + + + + Derivative at start + + + + + + + + 0 + 0 + + + + -99.000000000000000 + + + + + + + Derivative at end + + + + + + + + 0 + 0 + + + + -99.000000000000000 + + + + diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp index 9b2004d31..7489cffff 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp @@ -172,7 +172,7 @@ void ViewProviderPipe::highlightReferences(const bool on, bool auxillery) TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); originalLineColors = svp->LineColorArray.getValues(); std::vector colors = originalLineColors; - colors.resize(eMap.Extent(), LineColor.getValue()); + colors.resize(eMap.Extent(), svp->LineColor.getValue()); for (std::string e : edges) { int idx = atoi(e.substr(4).c_str()) - 1;