Rename superPlacement property to AttachmentOffset

The name Attachment Offset gives a better picture of what the
property does.
This commit is contained in:
Peter Lama
2017-10-28 10:47:26 -07:00
committed by wmayer
parent 98faf0c661
commit 033334474c
19 changed files with 192 additions and 165 deletions

View File

@@ -34,11 +34,11 @@
</Documentation>
<Parameter Name="References" Type="Object" />
</Attribute>
<Attribute Name="SuperPlacement" ReadOnly="false">
<Attribute Name="AttachmentOffset" ReadOnly="false">
<Documentation>
<UserDocu>Current attachment mode.</UserDocu>
</Documentation>
<Parameter Name="SuperPlacement" Type="Object" />
<Parameter Name="AttachmentOffset" Type="Object" />
</Attribute>
<Attribute Name="Reverse" ReadOnly="false">
<Documentation>
@@ -105,7 +105,7 @@
<Methode Name="calculateAttachedPlacement" Const="true">
<Documentation>
<UserDocu>calculateAttachedPlacement(orig_placement): returns result of attachment, based
on current Mode, References, etc. SuperPlacment is included.
on current Mode, References, etc. AttachmentOffset is included.
original_placement is the previous placement of the object being attached. It
is used to preserve orientation for Translate attachment mode. For other modes,

View File

@@ -123,21 +123,21 @@ void AttachEnginePy::setReferences(Py::Object arg)
} ATTACHERPY_STDCATCH_ATTR;
}
Py::Object AttachEnginePy::getSuperPlacement(void) const
Py::Object AttachEnginePy::getAttachmentOffset(void) const
{
try {
AttachEngine &attacher = *(this->getAttachEnginePtr());
return Py::Object(new Base::PlacementPy(new Base::Placement(attacher.superPlacement)),true);
return Py::Object(new Base::PlacementPy(new Base::Placement(attacher.attachmentOffset)),true);
} ATTACHERPY_STDCATCH_ATTR;
}
void AttachEnginePy::setSuperPlacement(Py::Object arg)
void AttachEnginePy::setAttachmentOffset(Py::Object arg)
{
try {
AttachEngine &attacher = *(this->getAttachEnginePtr());
if (PyObject_TypeCheck(arg.ptr(), &(Base::PlacementPy::Type))) {
const Base::PlacementPy* plmPy = static_cast<const Base::PlacementPy*>(arg.ptr());
attacher.superPlacement = *(plmPy->getPlacementPtr());
attacher.attachmentOffset = *(plmPy->getPlacementPtr());
} else {
std::string error = std::string("type must be 'Placement', not ");
error += arg.type().as_string();
@@ -519,7 +519,7 @@ PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args)
feat->MapReversed.getValue(),
feat->MapPathParameter.getValue(),
0.0,0.0,
feat->superPlacement.getValue());
feat->AttachmentOffset.getValue());
return Py::new_reference_to(Py::None());
} ATTACHERPY_STDCATCH_METH;
}
@@ -543,7 +543,7 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args)
feat->MapMode.setValue(attacher.mapMode);
feat->MapReversed.setValue(attacher.mapReverse);
feat->MapPathParameter.setValue(attacher.attachParameter);
feat->superPlacement.setValue(attacher.superPlacement);
feat->AttachmentOffset.setValue(attacher.attachmentOffset);
return Py::new_reference_to(Py::None());
} ATTACHERPY_STDCATCH_METH;
}

View File

@@ -57,12 +57,12 @@ AttachExtension::AttachExtension()
EXTENSION_ADD_PROPERTY_TYPE(MapPathParameter, (0.0), "Attachment", App::Prop_None, "Sets point of curve to map the sketch to. 0..1 = start..end");
EXTENSION_ADD_PROPERTY_TYPE(superPlacement, (Base::Placement()), "Attachment", App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)");
EXTENSION_ADD_PROPERTY_TYPE(AttachmentOffset, (Base::Placement()), "Attachment", App::Prop_None, "Extra placement to apply in addition to attachment (in local coordinates)");
// Only show these properties when applicable. Controlled by extensionOnChanged
this->MapPathParameter.setStatus(App::Property::Status::Hidden, true);
this->MapReversed.setStatus(App::Property::Status::Hidden, true);
this->superPlacement.setStatus(App::Property::Status::Hidden, true);
this->AttachmentOffset.setStatus(App::Property::Status::Hidden, true);
setAttacher(new AttachEngine3D);//default attacher
initExtensionType(AttachExtension::getExtensionClassTypeId());
@@ -164,7 +164,7 @@ void AttachExtension::extensionOnChanged(const App::Property* prop)
|| prop == &MapMode
|| prop == &MapPathParameter
|| prop == &MapReversed
|| prop == &superPlacement)){
|| prop == &AttachmentOffset)){
bool bAttached = false;
try{
@@ -194,7 +194,7 @@ void AttachExtension::extensionOnChanged(const App::Property* prop)
this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef));
this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached);
this->superPlacement.setStatus(App::Property::Status::Hidden, !bAttached);
this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached);
getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached.
}
@@ -207,6 +207,15 @@ void AttachExtension::extensionOnChanged(const App::Property* prop)
App::DocumentObjectExtension::extensionOnChanged(prop);
}
void AttachExtension::extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
{
// Was superPlacement
Base::Type type = Base::Type::fromName(TypeName);
if (AttachmentOffset.getClassTypeId() == type && strcmp(PropName, "superPlacement") == 0) {
AttachmentOffset.Restore(reader);
}
}
void AttachExtension::onExtendedDocumentRestored()
{
try {
@@ -230,7 +239,7 @@ void AttachExtension::onExtendedDocumentRestored()
this->MapPathParameter.setStatus(App::Property::Status::Hidden, !bAttached || !(modeIsPointOnCurve && hasOneRef));
this->MapReversed.setStatus(App::Property::Status::Hidden, !bAttached);
this->superPlacement.setStatus(App::Property::Status::Hidden, !bAttached);
this->AttachmentOffset.setStatus(App::Property::Status::Hidden, !bAttached);
getPlacement().setReadOnly(bAttached && mmode != mmTranslate); //for mmTranslate, orientation should remain editable even when attached.
}
catch (Base::Exception&) {
@@ -248,7 +257,7 @@ void AttachExtension::updateAttacherVals()
this->MapReversed.getValue(),
this->MapPathParameter.getValue(),
0.0,0.0,
this->superPlacement.getValue());
this->AttachmentOffset.getValue());
}
App::PropertyPlacement& AttachExtension::getPlacement() {

View File

@@ -82,7 +82,7 @@ public:
App::PropertyLinkSubList Support;
App::PropertyEnumeration MapMode; //see AttachEngine::eMapMode
App::PropertyBool MapReversed; //inverts Z and X internal axes
App::PropertyPlacement superPlacement;
App::PropertyPlacement AttachmentOffset;
/**
* @brief MapPathParameter is a parameter value for mmNormalToPath (the
@@ -107,6 +107,7 @@ public:
protected:
virtual void extensionOnChanged(const App::Property* /*prop*/);
virtual void extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName);
App::PropertyPlacement& getPlacement();

View File

@@ -177,7 +177,7 @@ void AttachEngine::setUp(const App::PropertyLinkSubList &references,
eMapMode mapMode, bool mapReverse,
double attachParameter,
double surfU, double surfV,
const Base::Placement &superPlacement)
const Base::Placement &attachmentOffset)
{
this->references.Paste(references);
this->mapMode = mapMode;
@@ -185,7 +185,7 @@ void AttachEngine::setUp(const App::PropertyLinkSubList &references,
this->attachParameter = attachParameter;
this->surfU = surfU;
this->surfV = surfV;
this->superPlacement = superPlacement;
this->attachmentOffset = attachmentOffset;
}
void AttachEngine::setUp(const AttachEngine &another)
@@ -196,7 +196,7 @@ void AttachEngine::setUp(const AttachEngine &another)
another.attachParameter,
another.surfU,
another.surfV,
another.superPlacement);
another.attachmentOffset);
}
Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis,
@@ -1017,7 +1017,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(sh));
Base::Placement plm = Base::Placement();
plm.setPosition(Base::Vector3d(p.X(), p.Y(), p.Z()));
plm.setPosition(plm.getPosition() + this->superPlacement.getPosition());
plm.setPosition(plm.getPosition() + this->attachmentOffset.getPosition());
plm.setRotation(origPlacement.getRotation());
return plm;
} break;
@@ -1552,7 +1552,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
Base::Placement plm =
Base::Placement(Base::Vector3d(SketchBasePoint.X(), SketchBasePoint.Y(), SketchBasePoint.Z()), rot);
plm *= this->superPlacement;
plm *= this->attachmentOffset;
return plm;
} break;
default:
@@ -1568,7 +1568,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP
/*makeYVertical = */ false,
/*makeLegacyFlatFaceOrientation = */ mmode == mmFlatFace,
&Place);
plm *= this->superPlacement;
plm *= this->attachmentOffset;
return plm;
}
@@ -1905,11 +1905,11 @@ Base::Placement AttachEngineLine::calculateAttachedPlacement(Base::Placement ori
AttachEngine3D attacher3D;
attacher3D.setUp(*this);
attacher3D.mapMode = mmode;
attacher3D.superPlacement = Base::Placement(); //superplacement is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice!
attacher3D.attachmentOffset = Base::Placement(); //AttachmentOffset is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice!
plm = attacher3D.calculateAttachedPlacement(origPlacement);
plm *= presuperPlacement;
}
plm *= this->superPlacement;
plm *= this->attachmentOffset;
return plm;
}
@@ -2080,10 +2080,10 @@ Base::Placement AttachEnginePoint::calculateAttachedPlacement(Base::Placement or
AttachEngine3D attacher3D;
attacher3D.setUp(*this);
attacher3D.mapMode = mmode;
attacher3D.superPlacement = Base::Placement(); //superplacement is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice!
attacher3D.attachmentOffset = Base::Placement(); //AttachmentOffset is applied separately here, afterwards. So we are resetting it in sub-attacher to avoid applying it twice!
plm = attacher3D.calculateAttachedPlacement(origPlacement);
}
plm *= this->superPlacement;
plm *= this->attachmentOffset;
return plm;
}

View File

@@ -222,7 +222,7 @@ public: //methods
bool mapReverse = false,
double attachParameter = 0.0,
double surfU = 0.0, double surfV = 0.0,
const Base::Placement &superPlacement = Base::Placement());
const Base::Placement &attachmentOffset = Base::Placement());
virtual void setUp(const AttachEngine &another);
virtual AttachEngine* copy() const = 0;
virtual Base::Placement calculateAttachedPlacement(Base::Placement origPlacement) const = 0;
@@ -370,7 +370,7 @@ public: //members
bool mapReverse;
double attachParameter;
double surfU, surfV;
Base::Placement superPlacement;
Base::Placement attachmentOffset;
/**
* @brief modeEnabled is an indicator, whether some mode is ever suggested

View File

@@ -61,3 +61,8 @@ TopoDS_Shape Datum::getShape() const
Base::Vector3d Datum::getBasePoint () const {
return Placement.getValue().getPosition();
}
void Datum::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
{
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
}

View File

@@ -56,6 +56,7 @@ public:
protected:
void onDocumentRestored();
void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName);
};
} //namespace Part

View File

@@ -243,6 +243,8 @@ void Part2DObject::Restore(Base::XMLReader &reader)
}
this->MapMode.setValue(Attacher::mmFlatFace);
}
} else {
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
}
}
catch (const Base::XMLParseException&) {

View File

@@ -151,6 +151,9 @@ void Primitive::Restore(Base::XMLReader &reader)
static_cast<App::PropertyFloat*>(prop)->setValue(floatProp.getValue());
}
}
else {
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
}
}
catch (const Base::XMLParseException&) {
throw; // re-throw

View File

@@ -161,7 +161,7 @@ class AttachmentEditorTaskPanel(FrozenClass):
self.block = False #when True, event handlers return without doing anything (instead of doing-undoing blockSignals to everything)
self.refLines = [] #reference lineEdit widgets, packed into a list for convenience
self.refButtons = [] #buttons next to reference lineEdits
self.superPlacementEdits = [] #all edit boxes related to superplacement
self.attachmentOffsetEdits = [] #all edit boxes related to attachmentOffset
self.i_active_ref = -1 #index of reference being selected (-1 means no reaction to selecting)
self.auto_next = False #if true, references being selected are appended ('Selecting' state is automatically advanced to next button)
@@ -237,12 +237,12 @@ class AttachmentEditorTaskPanel(FrozenClass):
self.form.buttonRef2,
self.form.buttonRef3,
self.form.buttonRef4]
self.superPlacementEdits = [self.form.superplacementX,
self.form.superplacementY,
self.form.superplacementZ,
self.form.superplacementYaw,
self.form.superplacementPitch,
self.form.superplacementRoll]
self.attachmentOffsetEdits = [self.form.attachmentOffsetX,
self.form.attachmentOffsetY,
self.form.attachmentOffsetZ,
self.form.attachmentOffsetYaw,
self.form.attachmentOffsetPitch,
self.form.attachmentOffsetRoll]
self.block = False
@@ -252,8 +252,8 @@ class AttachmentEditorTaskPanel(FrozenClass):
for i in range(len(self.refLines)):
QtCore.QObject.connect(self.refButtons[i], QtCore.SIGNAL('clicked()'), lambda i=i: self.refButtonClicked(i))
for i in range(len(self.superPlacementEdits)):
QtCore.QObject.connect(self.superPlacementEdits[i], QtCore.SIGNAL('valueChanged(double)'), lambda val, i=i: self.superplacementChanged(i,val))
for i in range(len(self.attachmentOffsetEdits)):
QtCore.QObject.connect(self.attachmentOffsetEdits[i], QtCore.SIGNAL('valueChanged(double)'), lambda val, i=i: self.attachmentOffsetChanged(i,val))
QtCore.QObject.connect(self.form.checkBoxFlip, QtCore.SIGNAL('clicked()'), self.checkBoxFlipClicked)
@@ -362,33 +362,33 @@ class AttachmentEditorTaskPanel(FrozenClass):
# slots
def superplacementChanged(self, index, value):
def attachmentOffsetChanged(self, index, value):
if self.block:
return
plm = self.attacher.SuperPlacement
plm = self.attacher.AttachmentOffset
pos = plm.Base
if index==0:
pos.x = Q(self.form.superplacementX.text()).getValueAs(mm)
pos.x = Q(self.form.attachmentOffsetX.text()).getValueAs(mm)
if index==1:
pos.y = Q(self.form.superplacementY.text()).getValueAs(mm)
pos.y = Q(self.form.attachmentOffsetY.text()).getValueAs(mm)
if index==2:
pos.z = Q(self.form.superplacementZ.text()).getValueAs(mm)
pos.z = Q(self.form.attachmentOffsetZ.text()).getValueAs(mm)
if index >= 0 and index <= 2:
plm.Base = pos
rot = plm.Rotation;
(yaw, pitch, roll) = rot.toEuler()
if index==3:
yaw = Q(self.form.superplacementYaw.text()).getValueAs(deg)
yaw = Q(self.form.attachmentOffsetYaw.text()).getValueAs(deg)
if index==4:
pitch = Q(self.form.superplacementPitch.text()).getValueAs(deg)
pitch = Q(self.form.attachmentOffsetPitch.text()).getValueAs(deg)
if index==5:
roll = Q(self.form.superplacementRoll.text()).getValueAs(deg)
roll = Q(self.form.attachmentOffsetRoll.text()).getValueAs(deg)
if index >= 3 and index <= 5:
rot = App.Rotation(yaw,pitch,roll)
plm.Rotation = rot
self.attacher.SuperPlacement = plm
self.attacher.AttachmentOffset = plm
self.updatePreview()
@@ -432,16 +432,16 @@ class AttachmentEditorTaskPanel(FrozenClass):
if self.obj_is_attachable:
self.attacher.readParametersFromFeature(self.obj)
plm = self.attacher.SuperPlacement
plm = self.attacher.AttachmentOffset
try:
old_selfblock = self.block
self.block = True
self.form.superplacementX.setText ((plm.Base.x * mm).UserString)
self.form.superplacementY.setText ((plm.Base.y * mm).UserString)
self.form.superplacementZ.setText ((plm.Base.z * mm).UserString)
self.form.superplacementYaw.setText ((plm.Rotation.toEuler()[0] * deg).UserString)
self.form.superplacementPitch.setText((plm.Rotation.toEuler()[1] * deg).UserString)
self.form.superplacementRoll.setText ((plm.Rotation.toEuler()[2] * deg).UserString)
self.form.attachmentOffsetX.setText ((plm.Base.x * mm).UserString)
self.form.attachmentOffsetY.setText ((plm.Base.y * mm).UserString)
self.form.attachmentOffsetZ.setText ((plm.Base.z * mm).UserString)
self.form.attachmentOffsetYaw.setText ((plm.Rotation.toEuler()[0] * deg).UserString)
self.form.attachmentOffsetPitch.setText((plm.Rotation.toEuler()[1] * deg).UserString)
self.form.attachmentOffsetRoll.setText ((plm.Rotation.toEuler()[2] * deg).UserString)
self.form.checkBoxFlip.setChecked(self.attacher.Reverse)
@@ -592,11 +592,11 @@ class AttachmentEditorTaskPanel(FrozenClass):
self.form.message.setText(_translate('AttachmentEditor',"Error: {err}",None).format(err= str(err)))
if new_plm is not None:
self.form.groupBox_superplacement.setTitle(_translate('AttachmentEditor',"Extra placement:",None))
self.form.groupBox_superplacement.setEnabled(True)
self.form.groupBox_AttachmentOffset.setTitle(_translate('AttachmentEditor',"Attachment Offset:",None))
self.form.groupBox_AttachmentOffset.setEnabled(True)
else:
self.form.groupBox_superplacement.setTitle(_translate('AttachmentEditor',"Extra placement (inactive - not attached):",None))
self.form.groupBox_superplacement.setEnabled(False)
self.form.groupBox_AttachmentOffset.setTitle(_translate('AttachmentEditor',"Attachment Offset (inactive - not attached):",None))
self.form.groupBox_AttachmentOffset.setEnabled(False)
def cleanUp(self):
'''stuff that needs to be done when dialog is closed.'''

View File

@@ -110,7 +110,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_superplacement">
<widget class="QGroupBox" name="groupBox_AttachmentOffset">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -118,10 +118,10 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Mirror of superPlacement property. Extra placement is expressed in local space of object being attached.</string>
<string>AttachmentOffset property. The placement is expressed in local space of object being attached.</string>
</property>
<property name="title">
<string>Extra placement:</string>
<string>Attachment Offset:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
@@ -154,7 +154,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="superplacementY" native="true">
<widget class="Gui::InputField" name="attachmentOffsetY" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -183,7 +183,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::InputField" name="superplacementZ" native="true">
<widget class="Gui::InputField" name="attachmentOffsetZ" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -238,7 +238,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::InputField" name="superplacementX" native="true">
<widget class="Gui::InputField" name="attachmentOffsetX" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -254,7 +254,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::InputField" name="superplacementYaw">
<widget class="Gui::InputField" name="attachmentOffsetYaw">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -276,7 +276,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::InputField" name="superplacementPitch">
<widget class="Gui::InputField" name="attachmentOffsetPitch">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -298,7 +298,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::InputField" name="superplacementRoll">
<widget class="Gui::InputField" name="attachmentOffsetRoll">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -355,12 +355,12 @@
<tabstop>buttonRef4</tabstop>
<tabstop>lineRef4</tabstop>
<tabstop>listOfModes</tabstop>
<tabstop>superplacementX</tabstop>
<tabstop>superplacementY</tabstop>
<tabstop>superplacementZ</tabstop>
<tabstop>superplacementYaw</tabstop>
<tabstop>superplacementPitch</tabstop>
<tabstop>superplacementRoll</tabstop>
<tabstop>attachmentOffsetX</tabstop>
<tabstop>attachmentOffsetY</tabstop>
<tabstop>attachmentOffsetZ</tabstop>
<tabstop>attachmentOffsetYaw</tabstop>
<tabstop>attachmentOffsetPitch</tabstop>
<tabstop>attachmentOffsetRoll</tabstop>
<tabstop>checkBoxFlip</tabstop>
</tabstops>
<resources/>

View File

@@ -120,12 +120,12 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider,QWidget
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);
connect(ui->superplacementX, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementXChanged(double)));
connect(ui->superplacementY, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementYChanged(double)));
connect(ui->superplacementZ, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementZChanged(double)));
connect(ui->superplacementYaw, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementYawChanged(double)));
connect(ui->superplacementPitch, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementPitchChanged(double)));
connect(ui->superplacementRoll, SIGNAL(valueChanged(double)), this, SLOT(onSuperplacementRollChanged(double)));
connect(ui->attachmentOffsetX, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetXChanged(double)));
connect(ui->attachmentOffsetY, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetYChanged(double)));
connect(ui->attachmentOffsetZ, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetZChanged(double)));
connect(ui->attachmentOffsetYaw, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetYawChanged(double)));
connect(ui->attachmentOffsetPitch, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetPitchChanged(double)));
connect(ui->attachmentOffsetRoll, SIGNAL(valueChanged(double)), this, SLOT(onAttachmentOffsetRollChanged(double)));
connect(ui->checkBoxFlip, SIGNAL(toggled(bool)),
this, SLOT(onCheckFlip(bool)));
connect(ui->buttonRef1, SIGNAL(clicked(bool)),
@@ -196,11 +196,11 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider,QWidget
autoNext = false;
}
ui->superplacementX->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.x")));
ui->superplacementY->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.y")));
ui->superplacementZ->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Base.z")));
ui->attachmentOffsetX->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.x")));
ui->attachmentOffsetY->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.y")));
ui->attachmentOffsetZ->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Base.z")));
visibilityAutomation(true);
updateSuperplacementUI();
updateAttachmentOffsetUI();
updateReferencesUI();
updateListOfModes();
selectMapMode(eMapMode(pcAttach->MapMode.getValue()));
@@ -295,9 +295,9 @@ bool TaskAttacher::updatePreview()
ui->message->setStyleSheet(QString::fromLatin1("QLabel{color: green;}"));
}
}
QString splmLabelText = attached ? tr("Extra placement:") : tr("Extra placement (inactive - not attached):");
ui->groupBox_superplacement->setTitle(splmLabelText);
ui->groupBox_superplacement->setEnabled(attached);
QString splmLabelText = attached ? tr("Attachment Offset:") : tr("Attachment Offset (inactive - not attached):");
ui->groupBox_AttachmentOffset->setTitle(splmLabelText);
ui->groupBox_AttachmentOffset->setEnabled(attached);
return attached;
}
@@ -399,20 +399,20 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
}
}
void TaskAttacher::onSuperplacementChanged(double /*val*/, int idx)
void TaskAttacher::onAttachmentOffsetChanged(double /*val*/, int idx)
{
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
Base::Placement pl = pcAttach->superPlacement.getValue();
Base::Placement pl = pcAttach->AttachmentOffset.getValue();
Base::Vector3d pos = pl.getPosition();
if (idx == 0) {
pos.x = ui->superplacementX->value().getValueAs(Base::Quantity::MilliMetre);
pos.x = ui->attachmentOffsetX->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx == 1) {
pos.y = ui->superplacementY->value().getValueAs(Base::Quantity::MilliMetre);
pos.y = ui->attachmentOffsetY->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx == 2) {
pos.z = ui->superplacementZ->value().getValueAs(Base::Quantity::MilliMetre);
pos.z = ui->attachmentOffsetZ->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx >= 0 && idx <= 2){
pl.setPosition(pos);
@@ -422,46 +422,46 @@ void TaskAttacher::onSuperplacementChanged(double /*val*/, int idx)
double yaw, pitch, roll;
rot.getYawPitchRoll(yaw, pitch, roll);
if (idx == 3) {
yaw = ui->superplacementYaw->value().getValueAs(Base::Quantity::Degree);
yaw = ui->attachmentOffsetYaw->value().getValueAs(Base::Quantity::Degree);
}
if (idx == 4) {
pitch = ui->superplacementPitch->value().getValueAs(Base::Quantity::Degree);
pitch = ui->attachmentOffsetPitch->value().getValueAs(Base::Quantity::Degree);
}
if (idx == 5) {
roll = ui->superplacementRoll->value().getValueAs(Base::Quantity::Degree);
roll = ui->attachmentOffsetRoll->value().getValueAs(Base::Quantity::Degree);
}
if (idx >= 3 && idx <= 5){
rot.setYawPitchRoll(yaw,pitch,roll);
pl.setRotation(rot);
}
pcAttach->superPlacement.setValue(pl);
pcAttach->AttachmentOffset.setValue(pl);
updatePreview();
}
void TaskAttacher::onSuperplacementXChanged(double val)
void TaskAttacher::onAttachmentOffsetXChanged(double val)
{
onSuperplacementChanged(val, 0);
onAttachmentOffsetChanged(val, 0);
}
void TaskAttacher::onSuperplacementYChanged(double val)
void TaskAttacher::onAttachmentOffsetYChanged(double val)
{
onSuperplacementChanged(val, 1);
onAttachmentOffsetChanged(val, 1);
}
void TaskAttacher::onSuperplacementZChanged(double val)
void TaskAttacher::onAttachmentOffsetZChanged(double val)
{
onSuperplacementChanged(val, 2);
onAttachmentOffsetChanged(val, 2);
}
void TaskAttacher::onSuperplacementYawChanged(double val)
void TaskAttacher::onAttachmentOffsetYawChanged(double val)
{
onSuperplacementChanged(val, 3);
onAttachmentOffsetChanged(val, 3);
}
void TaskAttacher::onSuperplacementPitchChanged(double val)
void TaskAttacher::onAttachmentOffsetPitchChanged(double val)
{
onSuperplacementChanged(val, 4);
onAttachmentOffsetChanged(val, 4);
}
void TaskAttacher::onSuperplacementRollChanged(double val)
void TaskAttacher::onAttachmentOffsetRollChanged(double val)
{
onSuperplacementChanged(val, 5);
onAttachmentOffsetChanged(val, 5);
}
void TaskAttacher::onCheckFlip(bool on)
@@ -648,57 +648,57 @@ void TaskAttacher::updateRefButton(int idx)
}
}
void TaskAttacher::updateSuperplacementUI()
void TaskAttacher::updateAttachmentOffsetUI()
{
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
Base::Placement pl = pcAttach->superPlacement.getValue();
Base::Placement pl = pcAttach->AttachmentOffset.getValue();
Base::Vector3d pos = pl.getPosition();
Base::Rotation rot = pl.getRotation();
double yaw, pitch, roll;
rot.getYawPitchRoll(yaw, pitch, roll);
bool bBlock = true;
ui->superplacementX->blockSignals(bBlock);
ui->superplacementY->blockSignals(bBlock);
ui->superplacementZ->blockSignals(bBlock);
ui->superplacementYaw->blockSignals(bBlock);
ui->superplacementPitch->blockSignals(bBlock);
ui->superplacementRoll->blockSignals(bBlock);
ui->attachmentOffsetX->blockSignals(bBlock);
ui->attachmentOffsetY->blockSignals(bBlock);
ui->attachmentOffsetZ->blockSignals(bBlock);
ui->attachmentOffsetYaw->blockSignals(bBlock);
ui->attachmentOffsetPitch->blockSignals(bBlock);
ui->attachmentOffsetRoll->blockSignals(bBlock);
ui->superplacementX->setValue(Base::Quantity(pos.x,Base::Unit::Length));
ui->superplacementY->setValue(Base::Quantity(pos.y,Base::Unit::Length));
ui->superplacementZ->setValue(Base::Quantity(pos.z,Base::Unit::Length));
ui->superplacementYaw->setValue(yaw);
ui->superplacementPitch->setValue(pitch);
ui->superplacementRoll->setValue(roll);
ui->attachmentOffsetX->setValue(Base::Quantity(pos.x,Base::Unit::Length));
ui->attachmentOffsetY->setValue(Base::Quantity(pos.y,Base::Unit::Length));
ui->attachmentOffsetZ->setValue(Base::Quantity(pos.z,Base::Unit::Length));
ui->attachmentOffsetYaw->setValue(yaw);
ui->attachmentOffsetPitch->setValue(pitch);
ui->attachmentOffsetRoll->setValue(roll);
auto expressions = ViewProvider->getObject()->ExpressionEngine.getExpressions();
bool bRotationBound = false;
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Angle"))) != expressions.end();
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Angle"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.x"))) != expressions.end();
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.x"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.y"))) != expressions.end();
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.y"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("superPlacement.Rotation.Axis.z"))) != expressions.end();
expressions.find(App::ObjectIdentifier::parse(ViewProvider->getObject(),std::string("AttachmentOffset.Rotation.Axis.z"))) != expressions.end();
ui->superplacementYaw->setEnabled(!bRotationBound);
ui->superplacementPitch->setEnabled(!bRotationBound);
ui->superplacementRoll->setEnabled(!bRotationBound);
ui->attachmentOffsetYaw->setEnabled(!bRotationBound);
ui->attachmentOffsetPitch->setEnabled(!bRotationBound);
ui->attachmentOffsetRoll->setEnabled(!bRotationBound);
QString tooltip = bRotationBound ? tr("Not editable because rotation part of superplacement is bound by expressions.") : QString();
ui->superplacementYaw->setToolTip(tooltip);
ui->superplacementPitch->setToolTip(tooltip);
ui->superplacementRoll->setToolTip(tooltip);
QString tooltip = bRotationBound ? tr("Not editable because rotation part of AttachmentOffset is bound by expressions.") : QString();
ui->attachmentOffsetYaw->setToolTip(tooltip);
ui->attachmentOffsetPitch->setToolTip(tooltip);
ui->attachmentOffsetRoll->setToolTip(tooltip);
bBlock = false;
ui->superplacementX->blockSignals(bBlock);
ui->superplacementY->blockSignals(bBlock);
ui->superplacementZ->blockSignals(bBlock);
ui->superplacementYaw->blockSignals(bBlock);
ui->superplacementPitch->blockSignals(bBlock);
ui->superplacementRoll->blockSignals(bBlock);
ui->attachmentOffsetX->blockSignals(bBlock);
ui->attachmentOffsetY->blockSignals(bBlock);
ui->attachmentOffsetZ->blockSignals(bBlock);
ui->attachmentOffsetYaw->blockSignals(bBlock);
ui->attachmentOffsetPitch->blockSignals(bBlock);
ui->attachmentOffsetRoll->blockSignals(bBlock);
}
void TaskAttacher::updateListOfModes()
@@ -964,11 +964,11 @@ bool TaskDlgAttacher::accept()
std::string name = ViewProvider->getObject()->getNameInDocument();
//DeepSOIC: changed this to heavily rely on dialog constantly updating feature properties
if (pcAttach->superPlacement.isTouched()){
Base::Placement plm = pcAttach->superPlacement.getValue();
if (pcAttach->AttachmentOffset.isTouched()){
Base::Placement plm = pcAttach->AttachmentOffset.getValue();
double yaw, pitch, roll;
plm.getRotation().getYawPitchRoll(yaw,pitch,roll);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.superPlacement = App.Placement(App.Vector(%.10f, %.10f, %.10f), App.Rotation(%.10f, %.10f, %.10f))",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.AttachmentOffset = App.Placement(App.Vector(%.10f, %.10f, %.10f), App.Rotation(%.10f, %.10f, %.10f))",
name.c_str(),
plm.getPosition().x, plm.getPosition().y, plm.getPosition().z,
yaw, pitch, roll);

View File

@@ -67,13 +67,13 @@ public:
bool isCompleted() const { return completed; }
private Q_SLOTS:
void onSuperplacementChanged(double, int idx);
void onSuperplacementXChanged(double);
void onSuperplacementYChanged(double);
void onSuperplacementZChanged(double);
void onSuperplacementYawChanged(double);
void onSuperplacementPitchChanged(double);
void onSuperplacementRollChanged(double);
void onAttachmentOffsetChanged(double, int idx);
void onAttachmentOffsetXChanged(double);
void onAttachmentOffsetYChanged(double);
void onAttachmentOffsetZChanged(double);
void onAttachmentOffsetYawChanged(double);
void onAttachmentOffsetPitchChanged(double);
void onAttachmentOffsetRollChanged(double);
void onCheckFlip(bool);
void onRefName1(const QString& text);
void onRefName2(const QString& text);
@@ -104,7 +104,7 @@ private:
void onButtonRef(const bool checked, unsigned idx);
void onRefName(const QString& text, unsigned idx);
void updateRefButton(int idx);
void updateSuperplacementUI();
void updateAttachmentOffsetUI();
/**
* @brief updateListOfModes Fills the mode list with modes that apply to

View File

@@ -110,7 +110,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_superplacement">
<widget class="QGroupBox" name="groupBox_AttachmentOffset">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -118,10 +118,10 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Mirror of superPlacement property. Extra placement is expressed in local space of object being attached.</string>
<string>AttachmentOffset property. The placement is expressed in local space of object being attached.</string>
</property>
<property name="title">
<string>Extra placement:</string>
<string>Attachment Offset:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
@@ -154,7 +154,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefQuantitySpinBox" name="superplacementY" native="true">
<widget class="Gui::PrefQuantitySpinBox" name="attachmentOffsetY" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -183,7 +183,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::PrefQuantitySpinBox" name="superplacementZ" native="true">
<widget class="Gui::PrefQuantitySpinBox" name="attachmentOffsetZ" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -238,7 +238,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefQuantitySpinBox" name="superplacementX" native="true">
<widget class="Gui::PrefQuantitySpinBox" name="attachmentOffsetX" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -254,7 +254,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::QuantitySpinBox" name="superplacementYaw" native="true">
<widget class="Gui::QuantitySpinBox" name="attachmentOffsetYaw" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -276,7 +276,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::QuantitySpinBox" name="superplacementPitch" native="true">
<widget class="Gui::QuantitySpinBox" name="attachmentOffsetPitch" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -298,7 +298,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="Gui::QuantitySpinBox" name="superplacementRoll" native="true">
<widget class="Gui::QuantitySpinBox" name="attachmentOffsetRoll" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -353,12 +353,12 @@
<tabstop>buttonRef4</tabstop>
<tabstop>lineRef4</tabstop>
<tabstop>listOfModes</tabstop>
<tabstop>superplacementX</tabstop>
<tabstop>superplacementY</tabstop>
<tabstop>superplacementZ</tabstop>
<tabstop>superplacementYaw</tabstop>
<tabstop>superplacementPitch</tabstop>
<tabstop>superplacementRoll</tabstop>
<tabstop>attachmentOffsetX</tabstop>
<tabstop>attachmentOffsetY</tabstop>
<tabstop>attachmentOffsetZ</tabstop>
<tabstop>attachmentOffsetYaw</tabstop>
<tabstop>attachmentOffsetPitch</tabstop>
<tabstop>attachmentOffsetRoll</tabstop>
<tabstop>checkBoxFlip</tabstop>
</tabstops>
<resources/>

View File

@@ -160,6 +160,11 @@ void FeaturePrimitive::onChanged(const App::Property* prop)
FeatureAddSub::onChanged(prop);
}
void FeaturePrimitive::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
{
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
}
PYTHON_TYPE_DEF(PrimitivePy, PartDesign::FeaturePy)
PYTHON_TYPE_IMP(PrimitivePy, PartDesign::FeaturePy)

View File

@@ -64,6 +64,7 @@ public:
return PartDesign::FeatureAddSub::execute();
}
protected:
void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName);
//make the boolean ops with the primitives provided by the derived features
App::DocumentObjectExecReturn* execute(const TopoDS_Shape& primitiveShape);
Type primitiveType = Box;

View File

@@ -258,7 +258,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch)
Datum.c_str(), refStr.toStdString().c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MapMode = '%s'",
Datum.c_str(), AttachEngine::getModeName(Attacher::mmFlatFace).c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.superPlacement.Base.z = %f",
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.AttachmentOffset.Base.z = %f",
Datum.c_str(), offset);
Gui::Command::doCommand(Gui::Command::Doc,
"App.activeDocument().%s.insertObject(App.activeDocument().%s, App.activeDocument().%s)",

View File

@@ -35,7 +35,7 @@ class TestDatumPoint(unittest.TestCase):
self.DatumPoint.MapMode = 'ObjectOrigin'
self.Body.addObject(self.DatumPoint)
self.Doc.recompute()
self.assertEqual(self.DatumPoint.superPlacement.Base, App.Vector(0))
self.assertEqual(self.DatumPoint.AttachmentOffset.Base, App.Vector(0))
def tearDown(self):
#closing doc