Commit 4ed9b1c2 authored by logari81's avatar logari81 Committed by jriegel
Browse files

PartDesign: Refactor pattern features and gui

- remove StdDirection,StdAxis and StdMirrorPlane properties
- support sketch H_Axis, V_Axis, N_axis as valid references in patterns
- polish reference selection gui (unified for standard axes and custom references)
parent 7da2ecac
......@@ -53,6 +53,7 @@ using namespace Part;
const int Part2DObject::H_Axis = -1;
const int Part2DObject::V_Axis = -2;
const int Part2DObject::N_Axis = -3;
PROPERTY_SOURCE(Part::Part2DObject, Part::Feature)
......@@ -215,6 +216,9 @@ Base::Axis Part2DObject::getAxis(int axId) const
else if (axId == V_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
}
else if (axId == N_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
}
return Base::Axis();
}
......
......@@ -92,6 +92,7 @@ public:
static const int H_Axis;
static const int V_Axis;
static const int N_Axis;
/** @name methods overide Feature */
//@{
......
......@@ -34,8 +34,9 @@
#include "FeatureLinearPattern.h"
#include <Mod/Part/App/TopoShape.h>
#include <Base/Axis.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
......@@ -47,7 +48,6 @@ PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed)
LinearPattern::LinearPattern()
{
ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",(App::PropertyType)(App::Prop_None),"Direction");
ADD_PROPERTY(StdDirection,(""));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY(Length,(100.0));
ADD_PROPERTY(Occurrences,(3));
......@@ -56,7 +56,6 @@ LinearPattern::LinearPattern()
short LinearPattern::mustExecute() const
{
if (Direction.isTouched() ||
StdDirection.isTouched() ||
Reversed.isTouched() ||
Length.isTouched() ||
Occurrences.isTouched())
......@@ -66,7 +65,6 @@ short LinearPattern::mustExecute() const
const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App::DocumentObject*>)
{
std::string stdDirection = StdDirection.getValue();
float distance = Length.getValue();
if (distance < Precision::Confusion())
throw Base::Exception("Pattern length too small");
......@@ -75,37 +73,35 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
throw Base::Exception("At least two occurrences required");
bool reversed = Reversed.getValue();
gp_Dir dir;
double offset = distance / (occurrences - 1);
if (!stdDirection.empty()) {
// Note: The placement code commented out below had the defect of working always on the
// absolute X,Y,Z direction, not on the relative coordinate system of the Body feature.
// It requires positionBySupport() to be called in Transformed::Execute() AFTER
// the call to getTransformations()
// New code thanks to logari81
if (stdDirection == "X") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
dir = gp_Dir(1,0,0);
} else if (stdDirection == "Y") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
dir = gp_Dir(0,1,0);
} else if(stdDirection == "Z") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
dir = gp_Dir(0,0,1);
} else {
throw Base::Exception("Invalid direction (must be X, Y or Z)");
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No direction reference specified");
gp_Dir dir;
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "N_Axis")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No direction reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
......@@ -119,8 +115,6 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
throw Base::Exception("Direction face must be planar");
dir = adapt.Plane().Axis().Direction();
//gp_Dir d = adapt.Plane().Axis().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
} else if (ref.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge refEdge = TopoDS::Edge(ref);
if (refEdge.IsNull())
......@@ -129,24 +123,14 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
if (adapt.GetType() != GeomAbs_Line)
throw Base::Exception("Direction edge must be a straight line");
//gp_Dir d = adapt.Line().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
dir = adapt.Line().Direction();
} else {
throw Base::Exception("Direction reference must be edge or face");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
dir *= supportPlacement;
gp_Vec direction(dir.getDirection().x, dir.getDirection().y, dir.getDirection().z);*/
gp_Vec direction(dir.X(), dir.Y(), dir.Z());
if (reversed)
......
......@@ -39,7 +39,6 @@ public:
LinearPattern();
App::PropertyLinkSub Direction;
App::PropertyString StdDirection;
App::PropertyBool Reversed;
App::PropertyFloat Length;
App::PropertyInteger Occurrences;
......@@ -58,8 +57,6 @@ public:
* Returns a list of (Occurrences - 1) transformations since the first, untransformed instance
* is not counted. Each transformation will move the shape it is applied to by the distance
* (Length / (Occurrences - 1)) so that the transformations will cover the total Length.
* If StdDirection is "X", "Y" or "Z" then the transformation direction will be parallel to the
* corresponding axis
* If Direction contains a feature and a face name, then the transformation direction will be
* the normal of the given face, which must be planar. If it contains an edge name, then the
* transformation direction will be parallel to the given edge, which must be linear
......
......@@ -33,6 +33,7 @@
#include "FeatureMirrored.h"
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
......@@ -44,45 +45,47 @@ PROPERTY_SOURCE(PartDesign::Mirrored, PartDesign::Transformed)
Mirrored::Mirrored()
{
ADD_PROPERTY_TYPE(MirrorPlane,(0),"Mirrored",(App::PropertyType)(App::Prop_None),"Mirror plane");
ADD_PROPERTY(StdMirrorPlane,(""));
}
short Mirrored::mustExecute() const
{
if (MirrorPlane.isTouched() ||
StdMirrorPlane.isTouched())
if (MirrorPlane.isTouched())
return 1;
return Transformed::mustExecute();
}
const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::DocumentObject*>)
{
App::DocumentObject* ref = MirrorPlane.getValue();
App::DocumentObject* refObject = MirrorPlane.getValue();
if (refObject == NULL)
throw Base::Exception("No mirror plane reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Mirror plane reference must be face of a feature");
std::vector<std::string> subStrings = MirrorPlane.getSubValues();
std::string stdPlane = StdMirrorPlane.getValue();
gp_Pnt p;
gp_Dir d;
if (!stdPlane.empty()) {
p = gp_Pnt(0,0,0);
if (stdPlane == "XY") {
d = gp_Dir(0,0,1);
} else if (stdPlane == "XZ") {
d = gp_Dir(0,1,0);
} else if(stdPlane == "YZ") {
d = gp_Dir(1,0,0);
} else {
throw Base::Exception("Invalid mirror plane (must be XY, XZ or YZ)");
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No mirror plane reference specified");
gp_Pnt axbase;
gp_Dir axdir;
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
if (ref == NULL)
throw Base::Exception("No mirror plane selected");
if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Mirror plane must be face of a feature");
Part::TopoShape baseShape = static_cast<Part::Feature*>(ref)->Shape.getShape();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No mirror plane defined");
Part::TopoShape baseShape = static_cast<Part::Feature*>(refObject)->Shape.getShape();
// TODO: Check for multiple mirror planes?
TopoDS_Face face = TopoDS::Face(baseShape.getSubShape(subStrings[0].c_str()));
......@@ -92,22 +95,14 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
if (adapt.GetType() != GeomAbs_Plane)
throw Base::Exception("Mirror face must be planar");
p = getPointFromFace(face);
d = adapt.Plane().Axis().Direction();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
p.Transform(invObjLoc.Transformation());
d.Transform(invObjLoc.Transformation());
axbase = getPointFromFace(face);
axdir = adapt.Plane().Axis().Direction();
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
ax *= supportPlacement;
gp_Ax2 mirrorAxis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/
gp_Ax2 mirrorAxis(p, d);
gp_Ax2 mirrorAxis(axbase, axdir);
std::list<gp_Trsf> transformations;
gp_Trsf trans;
......
......@@ -39,7 +39,6 @@ public:
Mirrored();
App::PropertyLinkSub MirrorPlane;
App::PropertyString StdMirrorPlane;
/** @name methods override feature */
//@{
......@@ -54,7 +53,6 @@ public:
/** Create transformations
* Returns a list containing one transformation since the first, untransformed instance
* is not counted. The transformation will mirror the shape it is applied to on a plane
* If StdMirrorPlane is "XY", "YZ" or "YZ" then the mirror plane will the corresponding plane
* If MirrorPlane contains a feature and an face name, then the mirror plane will be
* the the given face, which must be planar
*/
......
......@@ -32,9 +32,10 @@
#include "FeaturePolarPattern.h"
#include <Base/Tools.h>
#include <Base/Axis.h>
#include <Base/Tools.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
......@@ -46,7 +47,6 @@ PROPERTY_SOURCE(PartDesign::PolarPattern, PartDesign::Transformed)
PolarPattern::PolarPattern()
{
ADD_PROPERTY_TYPE(Axis,(0),"PolarPattern",(App::PropertyType)(App::Prop_None),"Direction");
ADD_PROPERTY(StdAxis,(""));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY(Angle,(360.0));
ADD_PROPERTY(Occurrences,(3));
......@@ -55,7 +55,6 @@ PolarPattern::PolarPattern()
short PolarPattern::mustExecute() const
{
if (Axis.isTouched() ||
StdAxis.isTouched() ||
Reversed.isTouched() ||
Angle.isTouched() ||
Occurrences.isTouched())
......@@ -65,7 +64,6 @@ short PolarPattern::mustExecute() const
const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App::DocumentObject*>)
{
std::string stdAxis = StdAxis.getValue();
float angle = Angle.getValue();
if (angle < Precision::Confusion())
throw Base::Exception("Pattern angle too small");
......@@ -80,32 +78,35 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
else
offset = Base::toRadians<double>(angle) / (occurrences - 1);
App::DocumentObject* refObject = Axis.getValue();
if (refObject == NULL)
throw Base::Exception("No axis reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Axis reference must be edge of a feature");
std::vector<std::string> subStrings = Axis.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No axis reference specified");
gp_Pnt axbase;
gp_Dir axdir;
if (!stdAxis.empty()) {
axbase = gp_Pnt(0,0,0);
if (stdAxis == "X") {
axdir = gp_Dir(1,0,0);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
} else if (stdAxis == "Y") {
axdir = gp_Dir(0,1,0);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
} else if(stdAxis == "Z") {
axdir = gp_Dir(0,0,1);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
} else {
throw Base::Exception("Invalid axis (must be X, Y or Z)");
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "N_Axis")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
App::DocumentObject* refObject = Axis.getValue();
if (refObject == NULL)
throw Base::Exception("No axis specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Axis reference must be edge of a feature");
std::vector<std::string> subStrings = Axis.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No axis reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
......@@ -123,20 +124,11 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
} else {
throw Base::Exception("Axis reference must be an edge");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
ax *= supportPlacement;
gp_Ax2 axis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/
gp_Ax2 axis(axbase, axdir);
if (reversed)
......
......@@ -39,7 +39,6 @@ public:
PolarPattern();
App::PropertyLinkSub Axis;
App::PropertyString StdAxis;
App::PropertyBool Reversed;
App::PropertyFloat Angle;
App::PropertyInteger Occurrences;
......@@ -60,7 +59,6 @@ public:
* (Angle / (Occurrences - 1)) so that the transformations will cover the total Angle. The only
* exception is Angle = 360 degrees in which case the transformation angle will be
* (Angle / Occurrences) so that the last transformed shape is not identical with the original shape
* If StdAxis is "X", "Y" or "Z" then the transformation axis will the corresponding axis
* If Axis contains a feature and an edge name, then the transformation axis will be
* the the given edge, which must be linear
* If Reversed is true, the direction of rotation will be opposite
......
......@@ -65,7 +65,6 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include "FeatureSketchBased.h"
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
......
......@@ -80,6 +80,15 @@ App::DocumentObject* Transformed::getSupportObject() const
return NULL;
}
App::DocumentObject* Transformed::getSketchObject() const
{
std::vector<DocumentObject*> originals = Originals.getValues();
if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::SketchBased::getClassTypeId()))
return (static_cast<PartDesign::SketchBased*>(originals.front()))->getVerifiedSketch();
else
return NULL;
}
short Transformed::mustExecute() const
{
if (Originals.isTouched())
......
......@@ -52,6 +52,9 @@ public:
/// Return first original, which serves as "Support" until Body feature becomes functional
App::DocumentObject* getSupportObject() const;
/// Return the sketch of the first original
App::DocumentObject* getSketchObject() const;
/// Get the list of transformations describing the members of the pattern
// Note: Only the Scaled feature requires the originals
virtual const std::list<gp_Trsf> getTransformations(const std::vector<App::DocumentObject*> originals) {
......
......@@ -895,7 +895,10 @@ void CmdPartDesignMirrored::activated(int iMsg)
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
updateActive(); // Helps to ensure that the object already exists when the next command comes up
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
......@@ -967,7 +970,10 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdDirection = \"X\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Length = 100", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
......@@ -1041,7 +1047,10 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdAxis = \"X\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Angle = 360", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
......
......@@ -93,14 +93,14 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam
void TaskLinearPatternParameters::setupUI()
{
connect(ui->comboDirection, SIGNAL(activated(int)),
this, SLOT(onDirectionChanged(int)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
connect(ui->spinLength, SIGNAL(valueChanged(double)),
this, SLOT(onLength(double)));
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
this, SLOT(onOccurrences(int)));
connect(ui->buttonReference, SIGNAL(toggled(bool)),
this, SLOT(onButtonReference(bool)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
......@@ -119,14 +119,10 @@ void TaskLinearPatternParameters::setupUI()
}
// ---------------------
//ui->buttonX->setEnabled(true);
//ui->buttonY->setEnabled(true);
//ui->buttonZ->setEnabled(true);
ui->comboDirection->setEnabled(true);
ui->checkReverse->setEnabled(true);
ui->spinLength->setEnabled(true);
ui->spinOccurrences->setEnabled(true);
ui->buttonReference->setEnabled(true);
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
updateUI();
}
......@@ -140,35 +136,31 @@ void TaskLinearPatternParameters::updateUI()
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
std::string stdDirection = pcLinearPattern->StdDirection.getValue();
bool reverse = pcLinearPattern->Reversed.getValue();
double length = pcLinearPattern->Length.getValue();
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
ui->buttonReference->setChecked(referenceSelectionMode);
if (!stdDirection.empty())
{
//ui->buttonX->setAutoExclusive(true);
//ui->buttonY->setAutoExclusive(true);
//ui->buttonZ->setAutoExclusive(true);
//ui->buttonX->setChecked(stdDirection == "X");
//ui->buttonY->setChecked(stdDirection == "Y");
//ui->buttonZ->setChecked(stdDirection == "Z");
ui->lineReference->setText(tr(""));
} else if (directionFeature != NULL && !directions.empty()) {
//ui->buttonX->setAutoExclusive(false);
//ui->buttonY->setAutoExclusive(false);
//ui->buttonZ->setAutoExclusive(false);
//ui->buttonX->setChecked(false);
//ui->buttonY->setChecked(false);
//ui->buttonZ->setChecked(false);
ui->lineReference->setText(QString::fromAscii(directions.front().c_str()));
for (int i=ui->comboDirection->count()-1; i >= 2; i--)
ui->comboDirection->removeItem(i);
if (directionFeature != NULL && !directions.empty()) {
if (directions.front() == "H_Axis")
ui->comboDirection->setCurrentIndex(0);
else if (directions.front() == "V_Axis")
ui->comboDirection->setCurrentIndex(1);
else if (directionFeature != NULL && !directions.empty()) {