本文整理汇总了C++中base::Placement::getRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ Placement::getRotation方法的具体用法?C++ Placement::getRotation怎么用?C++ Placement::getRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::Placement
的用法示例。
在下文中一共展示了Placement::getRotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTransform
void ViewProviderDragger::updateTransform(const Base::Placement& from, SoTransform* to)
{
float q0 = (float)from.getRotation().getValue()[0];
float q1 = (float)from.getRotation().getValue()[1];
float q2 = (float)from.getRotation().getValue()[2];
float q3 = (float)from.getRotation().getValue()[3];
float px = (float)from.getPosition().x;
float py = (float)from.getPosition().y;
float pz = (float)from.getPosition().z;
to->rotation.setValue(q0,q1,q2,q3);
to->translation.setValue(px,py,pz);
to->center.setValue(0.0f,0.0f,0.0f);
to->scaleFactor.setValue(1.0f,1.0f,1.0f);
}
示例2: transform
Command Command::transform(const Base::Placement other)
{
Base::Placement plac = getPlacement();
plac *= other;
double xval, yval, zval, aval, bval, cval;
xval = plac.getPosition().x;
yval = plac.getPosition().y;
zval = plac.getPosition().z;
plac.getRotation().getYawPitchRoll(aval,bval,cval);
Command c = Command();
c.Name = Name;
for(std::map<std::string,double>::const_iterator i = Parameters.begin(); i != Parameters.end(); ++i) {
std::string k = i->first;
double v = i->second;
if (k == "X")
v = xval;
if (k == "Y")
v = yval;
if (k == "Z")
v = zval;
if (k == "A")
v = aval;
if (k == "B")
v = bval;
if (k == "C")
v = cval;
c.Parameters[k] = v;
}
return c;
}
示例3: setFromPlacement
void Command::setFromPlacement (const Base::Placement &plac)
{
Name = "G1";
Parameters.clear();
std::string x = "X";
std::string y = "Y";
std::string z = "Z";
std::string a = "A";
std::string b = "B";
std::string c = "C";
double xval, yval, zval, aval, bval, cval;
xval = plac.getPosition().x;
yval = plac.getPosition().y;
zval = plac.getPosition().z;
plac.getRotation().getYawPitchRoll(aval,bval,cval);
if (xval != 0.0)
Parameters[x] = xval;
if (yval != 0.0)
Parameters[y] = yval;
if (zval != 0.0)
Parameters[z] = zval;
if (aval != 0.0)
Parameters[a] = aval;
if (bval != 0.0)
Parameters[b] = bval;
if (cval != 0.0)
Parameters[c] = cval;
}
示例4: setPlacementData
void Placement::setPlacementData(const Base::Placement& p)
{
signalMapper->blockSignals(true);
ui->xPos->setValue(Base::Quantity(p.getPosition().x, Base::Unit::Length));
ui->yPos->setValue(Base::Quantity(p.getPosition().y, Base::Unit::Length));
ui->zPos->setValue(Base::Quantity(p.getPosition().z, Base::Unit::Length));
double Y,P,R;
p.getRotation().getYawPitchRoll(Y,P,R);
ui->yawAngle->setValue(Base::Quantity(Y, Base::Unit::Angle));
ui->pitchAngle->setValue(Base::Quantity(P, Base::Unit::Angle));
ui->rollAngle->setValue(Base::Quantity(R, Base::Unit::Angle));
// check if the user-defined direction is already there
bool newitem = true;
double angle;
Base::Vector3d axis;
p.getRotation().getValue(axis, angle);
ui->angle->setValue(Base::Quantity(angle*180.0/D_PI, Base::Unit::Angle));
Base::Vector3d dir(axis.x,axis.y,axis.z);
for (int i=0; i<ui->direction->count()-1; i++) {
QVariant data = ui->direction->itemData (i);
if (data.canConvert<Base::Vector3d>()) {
const Base::Vector3d val = data.value<Base::Vector3d>();
if (val == dir) {
ui->direction->setCurrentIndex(i);
newitem = false;
break;
}
}
}
if (newitem) {
// add a new item before the very last item
QString display = QString::fromAscii("(%1,%2,%3)")
.arg(dir.x)
.arg(dir.y)
.arg(dir.z);
ui->direction->insertItem(ui->direction->count()-1, display,
QVariant::fromValue<Base::Vector3d>(dir));
ui->direction->setCurrentIndex(ui->direction->count()-2);
}
signalMapper->blockSignals(false);
}
示例5: setDragger
void ViewProviderRobotObject::setDragger()
{
assert(pcDragger==0);
pcDragger = new SoJackDragger();
pcDragger->addMotionCallback(sDraggerMotionCallback,this);
pcTcpRoot->addChild(pcDragger);
// set the actual TCP position
Robot::RobotObject* robObj = static_cast<Robot::RobotObject*>(pcObject);
Base::Placement loc = robObj->Tcp.getValue();
SbMatrix M;
M.setTransform(SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z),
SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]),
SbVec3f(150,150,150)
);
pcDragger->setMotionMatrix(M);
}
示例6: getLocation
TopLoc_Location FeatureReference::getLocation() const
{
Base::Placement pl = this->Placement.getValue();
Base::Rotation rot(pl.getRotation());
Base::Vector3d axis;
double angle;
rot.getValue(axis, angle);
gp_Trsf trf;
trf.SetRotation(gp_Ax1(gp_Pnt(), gp_Dir(axis.x, axis.y, axis.z)), angle);
trf.SetTranslationPart(gp_Vec(pl.getPosition().x,pl.getPosition().y,pl.getPosition().z));
return TopLoc_Location(trf);
}
示例7: updateSuperplacementUI
void TaskDatumParameters::updateSuperplacementUI()
{
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
Base::Placement pl = pcDatum->superPlacement.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->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);
auto expressions = pcDatum->ExpressionEngine.getExpressions();
bool bRotationBound = false;
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(pcDatum,std::string("superPlacement.Rotation.Angle"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(pcDatum,std::string("superPlacement.Rotation.Axis.x"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(pcDatum,std::string("superPlacement.Rotation.Axis.y"))) != expressions.end();
bRotationBound = bRotationBound ||
expressions.find(App::ObjectIdentifier::parse(pcDatum,std::string("superPlacement.Rotation.Axis.z"))) != expressions.end();
ui->superplacementYaw->setEnabled(!bRotationBound);
ui->superplacementPitch->setEnabled(!bRotationBound);
ui->superplacementRoll->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);
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);
}
示例8: activated
void CmdRobotSetDefaultOrientation::activated(int iMsg)
{
// create placement dialog
Gui::Dialog::Placement *Dlg = new Gui::Dialog::Placement();
Base::Placement place;
Dlg->setPlacement(place);
if(Dlg->exec() == QDialog::Accepted ){
place = Dlg->getPlacement();
Base::Rotation rot = place.getRotation();
Base::Vector3d disp = place.getPosition();
doCommand(Doc,"_DefOrientation = FreeCAD.Rotation(%f,%f,%f,%f)",rot[0],rot[1],rot[2],rot[3]);
doCommand(Doc,"_DefDisplacement = FreeCAD.Vector(%f,%f,%f)",disp[0],disp[1],disp[2]);
}
}
示例9:
void TaskRobot6Axis::viewTool(const Base::Placement pos)
{
double A,B,C;
pos.getRotation().getYawPitchRoll(A,B,C);
QString result = QString::fromAscii("Tool:( %1, %2, %3, %4, %5, %6 )")
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().x),0,'f',1)
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().y),0,'f',1)
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().z),0,'f',1)
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,A),0,'f',1)
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,B),0,'f',1)
.arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,C),0,'f',1);
ui->label_Tool->setText(result);
}
示例10: rotate
PyObject* GeometryPy::rotate(PyObject *args)
{
PyObject* o;
if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type),&o))
return 0;
Base::Placement* plm = static_cast<Base::PlacementPy*>(o)->getPlacementPtr();
Base::Rotation rot(plm->getRotation());
Base::Vector3d pnt, dir;
double angle;
rot.getValue(dir, angle);
pnt = plm->getPosition();
gp_Ax1 ax1(gp_Pnt(pnt.x,pnt.y,pnt.z), gp_Dir(dir.x,dir.y,dir.z));
getGeometryPtr()->handle()->Rotate(ax1, angle);
Py_Return;
}
示例11: onSuperplacementChanged
void TaskDatumParameters::onSuperplacementChanged(double /*val*/, int idx)
{
Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject());
Base::Placement pl = pcDatum->superPlacement.getValue();
Base::Vector3d pos = pl.getPosition();
if (idx == 0) {
pos.x = ui->superplacementX->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx == 1) {
pos.y = ui->superplacementY->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx == 2) {
pos.z = ui->superplacementZ->value().getValueAs(Base::Quantity::MilliMetre);
}
if (idx >= 0 && idx <= 2){
pl.setPosition(pos);
}
Base::Rotation rot = pl.getRotation();
double yaw, pitch, roll;
rot.getYawPitchRoll(yaw, pitch, roll);
if (idx == 3) {
yaw = ui->superplacementYaw->value().getValueAs(Base::Quantity::Degree);
}
if (idx == 4) {
pitch = ui->superplacementPitch->value().getValueAs(Base::Quantity::Degree);
}
if (idx == 5) {
roll = ui->superplacementRoll->value().getValueAs(Base::Quantity::Degree);
}
if (idx >= 3 && idx <= 5){
rot.setYawPitchRoll(yaw,pitch,roll);
pl.setRotation(rot);
}
pcDatum->superPlacement.setValue(pl);
updatePreview();
}
示例12: suggestReversed
bool Revolution::suggestReversed(void)
{
try {
updateAxis();
Part::Part2DObject* sketch = getVerifiedSketch();
std::vector<TopoDS_Wire> wires = getSketchWires();
TopoDS_Shape sketchshape = makeFace(wires);
Base::Vector3d b = Base.getValue();
Base::Vector3d v = Axis.getValue();
// get centre of gravity of the sketch face
GProp_GProps props;
BRepGProp::SurfaceProperties(sketchshape, props);
gp_Pnt cog = props.CentreOfMass();
Base::Vector3d p_cog(cog.X(), cog.Y(), cog.Z());
// get direction to cog from its projection on the revolve axis
Base::Vector3d perp_dir = p_cog - p_cog.Perpendicular(b, v);
// get cross product of projection direction with revolve axis direction
Base::Vector3d cross = v % perp_dir;
// get sketch vector pointing away from support material
Base::Placement SketchPos = sketch->Placement.getValue();
Base::Rotation SketchOrientation = SketchPos.getRotation();
Base::Vector3d SketchNormal(0,0,1);
SketchOrientation.multVec(SketchNormal,SketchNormal);
// simply convert double to float
Base::Vector3d norm(SketchNormal.x, SketchNormal.y, SketchNormal.z);
// return true if the angle between norm and cross is obtuse
return norm * cross < 0.f;
}
catch (...) {
return Reversed.getValue();
}
}
示例13: updateData
//.........这里部分代码省略.........
}
// Axis 5
searchAction.setName("FREECAD_AXIS5");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis5Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 6
searchAction.setName("FREECAD_AXIS6");
searchAction.setInterest(SoSearchAction::FIRST);
searchAction.setSearchingAll(FALSE);
searchAction.apply(pcRobotRoot);
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
Axis6Node = static_cast<SoVRMLTransform *>(node);
}
if(Axis1Node)
Axis1Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis1.getValue()*(M_PI/180));
if(Axis2Node)
Axis2Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis2.getValue()*(M_PI/180));
if(Axis3Node)
Axis3Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis3.getValue()*(M_PI/180));
if(Axis4Node)
Axis4Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis4.getValue()*(M_PI/180));
if(Axis5Node)
Axis5Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis5.getValue()*(M_PI/180));
if(Axis6Node)
Axis6Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis6.getValue()*(M_PI/180));
}else if (prop == &robObj->Axis1) {
if(Axis1Node){
Axis1Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis1.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Axis2) {
if(Axis2Node){
Axis2Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis2.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Axis3) {
if(Axis3Node){
Axis3Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis3.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Axis4) {
if(Axis4Node){
Axis4Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis4.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Axis5) {
if(Axis5Node){
Axis5Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis5.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Axis6) {
if(Axis6Node){
Axis6Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis6.getValue()*(M_PI/180));
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}
}else if (prop == &robObj->Tcp) {
Base::Placement loc = robObj->Tcp.getValue();
SbMatrix M;
M.setTransform(SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z),
SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]),
SbVec3f(150,150,150)
);
if(pcDragger)
pcDragger->setMotionMatrix(M);
if(toolShape)
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
//pcTcpTransform->translation = SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z);
//pcTcpTransform->rotation = SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]);
}else if (prop == &robObj->ToolShape) {
App::DocumentObject* o = robObj->ToolShape.getValue<App::DocumentObject*>();
if(o && (o->isDerivedFrom(Part::Feature::getClassTypeId()) || o->isDerivedFrom(App::VRMLObject::getClassTypeId())) ){
//Part::Feature *p = dynamic_cast<Part::Feature *>(o);
toolShape = Gui::Application::Instance->getViewProvider(o);
toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix());
}else
toolShape = 0;
}
}
示例14: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Pad::execute(void)
{
// Validate parameters
double L = Length.getValue();
if ((std::string(Type.getValueAsString()) == "Length") && (L < Precision::Confusion()))
return new App::DocumentObjectExecReturn("Length of pad too small");
double L2 = Length2.getValue();
if ((std::string(Type.getValueAsString()) == "TwoLengths") && (L < Precision::Confusion()))
return new App::DocumentObjectExecReturn("Second length of pad too small");
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 support;
try {
support = getSupportShape();
} catch (const Base::Exception&) {
// ignore, because support isn't mandatory
support = TopoDS_Shape();
}
// get the Sketch plane
Base::Placement SketchPos = sketch->Placement.getValue();
Base::Rotation SketchOrientation = SketchPos.getRotation();
Base::Vector3d SketchVector(0,0,1);
SketchOrientation.multVec(SketchVector,SketchVector);
this->positionBySketch();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
try {
support.Move(invObjLoc);
gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z);
dir.Transform(invObjLoc.Transformation());
TopoDS_Shape sketchshape = makeFace(wires);
if (sketchshape.IsNull())
return new App::DocumentObjectExecReturn("Pad: Creating a face from sketch failed");
sketchshape.Move(invObjLoc);
TopoDS_Shape prism;
std::string method(Type.getValueAsString());
if (method == "UpToFirst" || method == "UpToLast" || method == "UpToFace") {
TopoDS_Face supportface = getSupportFace();
supportface.Move(invObjLoc);
if (Reversed.getValue())
dir.Reverse();
// Find a valid face to extrude up to
TopoDS_Face upToFace;
if (method == "UpToFace") {
getUpToFaceFromLinkSub(upToFace, UpToFace);
upToFace.Move(invObjLoc);
}
getUpToFace(upToFace, support, supportface, sketchshape, method, dir);
// A support object is always required and we need to use BRepFeat_MakePrism
// Problem: For Pocket/UpToFirst (or an equivalent Pocket/UpToFace) the resulting shape is invalid
// because the feature does not add any material. This only happens with the "2" option, though
// Note: It might be possible to pass a shell or a compound containing multiple faces
// as the Until parameter of Perform()
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(support, sketchshape, supportface, dir, 2, 1);
PrismMaker.Perform(upToFace);
if (!PrismMaker.IsDone())
return new App::DocumentObjectExecReturn("Pad: Up to face: Could not extrude the sketch!");
prism = PrismMaker.Shape();
} else {
generatePrism(prism, sketchshape, method, dir, L, L2,
Midplane.getValue(), Reversed.getValue());
}
if (prism.IsNull())
return new App::DocumentObjectExecReturn("Pad: Resulting shape is empty");
// set the additive shape property for later usage in e.g. pattern
this->AddShape.setValue(prism);
// if the sketch has a support fuse them to get one result object
if (!support.IsNull()) {
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(support, prism);
// Let's check if the fusion has been successful
if (!mkFuse.IsDone())
return new App::DocumentObjectExecReturn("Pad: Fusion with support failed");
TopoDS_Shape result = mkFuse.Shape();
// we have to get the solids (fuse sometimes creates compounds)
TopoDS_Shape solRes = this->getSolid(result);
// lets check if the result is a solid
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Pad: Resulting shape is not a solid");
//.........这里部分代码省略.........
示例15: applyPlacement
void Placement::applyPlacement(const Base::Placement& p, bool incremental, bool data)
{
Gui::Document* document = Application::Instance->activeDocument();
if (!document) return;
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType
(App::DocumentObject::getClassTypeId(), document->getDocument()->getName());
if (!sel.empty()) {
if (data) {
document->openCommand("Placement");
for (std::vector<App::DocumentObject*>::iterator it=sel.begin();it!=sel.end();++it) {
std::map<std::string,App::Property*> props;
(*it)->getPropertyMap(props);
// search for the placement property
std::map<std::string,App::Property*>::iterator jt;
jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName));
if (jt != props.end()) {
Base::Placement cur = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
if (incremental)
cur = p * cur;
else
cur = p;
Base::Vector3d pos = cur.getPosition();
const Base::Rotation& rt = cur.getRotation();
QString cmd = QString::fromAscii(
"App.getDocument(\"%1\").%2.Placement="
"App.Placement("
"App.Vector(%3,%4,%5),"
"App.Rotation(%6,%7,%8,%9))\n")
.arg(QLatin1String((*it)->getDocument()->getName()))
.arg(QLatin1String((*it)->getNameInDocument()))
.arg(pos.x,0,'g',6)
.arg(pos.y,0,'g',6)
.arg(pos.z,0,'g',6)
.arg(rt[0],0,'g',6)
.arg(rt[1],0,'g',6)
.arg(rt[2],0,'g',6)
.arg(rt[3],0,'g',6);
Application::Instance->runPythonCode((const char*)cmd.toAscii());
}
}
document->commitCommand();
try {
document->getDocument()->recompute();
}
catch (...) {
}
}
// apply transformation only on view matrix not on placement property
else {
for (std::vector<App::DocumentObject*>::iterator it=sel.begin();it!=sel.end();++it) {
std::map<std::string,App::Property*> props;
(*it)->getPropertyMap(props);
// search for the placement property
std::map<std::string,App::Property*>::iterator jt;
jt = std::find_if(props.begin(), props.end(), find_placement(this->propertyName));
if (jt != props.end()) {
Base::Placement cur = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
if (incremental)
cur = p * cur;
else
cur = p;
Gui::ViewProvider* vp = document->getViewProvider(*it);
if (vp) vp->setTransformation(cur.toMatrix());
}
}
}
}
else {
Base::Console().Warning("No object selected.\n");
}
}