本文整理汇总了C++中base::Placement类的典型用法代码示例。如果您正苦于以下问题:C++ Placement类的具体用法?C++ Placement怎么用?C++ Placement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Placement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLocation
TopLoc_Location Feature::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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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]);
}
}
示例5: activated
void CmdPointsTransform::activated(int iMsg)
{
// This is a test command to transform a point cloud directly written in C++ (not Python)
Base::Placement trans;
trans.setRotation(Base::Rotation(Base::Vector3d(0.0, 0.0, 1.0), 1.570796));
openCommand("Transform points");
//std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
//for (std::vector<App::DocumentObject*>::const_iterator it = points.begin(); it != points.end(); ++it) {
// Base::Placement p = static_cast<Points::Feature*>(*it)->Placement.getValue();
// p._rot *= Base::Rotation(Base::Vector3d(0.0, 0.0, 1.0), 1.570796);
// static_cast<Points::Feature*>(*it)->Placement.setValue(p);
//}
commitCommand();
}
示例6:
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);
}
示例7: onChanged
void Feature::onChanged(const App::Property* prop)
{
// if the placement has changed apply the change to the point data as well
if (prop == &this->Placement) {
PointKernel& pts = const_cast<PointKernel&>(this->Points.getValue());
pts.setTransform(this->Placement.getValue().toMatrix());
}
// if the point data has changed check and adjust the transformation as well
else if (prop == &this->Points) {
Base::Placement p;
p.fromMatrix(this->Points.getValue().getTransform());
if (p != this->Placement.getValue())
this->Placement.setValue(p);
}
GeoFeature::onChanged(prop);
}
示例8: setTransform
PyObject* FemMeshPy::setTransform(PyObject *args)
{
PyObject* ptr;
if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type), &ptr))
return 0;
try {
Base::Placement* placement = static_cast<Base::PlacementPy*>(ptr)->getPlacementPtr();
Base::Matrix4D mat = placement->toMatrix();
getFemMeshPtr()->transformGeometry(mat);
}
catch (const std::exception& e) {
PyErr_SetString(PyExc_Exception, e.what());
return 0;
}
Py_Return;
}
示例9: 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;
}
示例10: 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);
}
示例11: DraggerMotionCallback
void ViewProviderRobotObject::DraggerMotionCallback(SoDragger *dragger)
{
float q0, q1, q2, q3;
Robot::RobotObject* robObj = static_cast<Robot::RobotObject*>(pcObject);
Base::Placement Tcp = robObj->Tcp.getValue();
const SbMatrix & M = dragger->getMotionMatrix ();
SbVec3f translation;
SbRotation rotation;
SbVec3f scaleFactor;
SbRotation scaleOrientation;
SbVec3f center(Tcp.getPosition().x,Tcp.getPosition().y,Tcp.getPosition().z);
M.getTransform(translation, rotation, scaleFactor, scaleOrientation);
rotation.getValue(q0, q1, q2, q3);
//Base::Console().Message("M %f %f %f\n", M[3][0], M[3][1], M[3][2]);
Base::Rotation rot(q0, q1, q2, q3);
Base::Vector3d pos(translation[0],translation[1],translation[2]);
robObj->Tcp.setValue(Base::Placement(pos,rot));
}
示例12: resetViewTransform
void TransformStrategy::resetViewTransform(App::DocumentObject* obj)
{
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
std::map<std::string,App::Property*> props;
obj->getPropertyMap(props);
// search for the placement property
std::map<std::string,App::Property*>::iterator jt;
jt = std::find_if(props.begin(), props.end(), find_transform());
if (jt != props.end()) {
Base::Placement local = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(local.toMatrix());
}
else {
// No placement found
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(Base::Matrix4D());
}
}
示例13: applyViewTransform
void TransformStrategy::applyViewTransform(const Base::Placement& plm, App::DocumentObject* obj)
{
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
std::map<std::string,App::Property*> props;
obj->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());
if (jt != props.end()) {
Base::Placement local = static_cast<App::PropertyPlacement*>(jt->second)->getValue();
local *= plm; // in case a placement is already set
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(local.toMatrix());
}
else {
// No placement found, so apply the transformation directly
Gui::ViewProvider* vp = doc->getViewProvider(obj);
if (vp) vp->setTransformation(plm.toMatrix());
}
}
示例14: on_applyButton_clicked
void Transform::on_applyButton_clicked()
{
Gui::WaitCursor wc;
Base::Placement plm = this->getPlacementData();
Base::Matrix4D mat = plm.toMatrix();
strategy->commitTransform(mat);
// nullify the values
QList<Gui::QuantitySpinBox*> sb = this->findChildren<Gui::QuantitySpinBox*>();
for (QList<Gui::QuantitySpinBox*>::iterator it = sb.begin(); it != sb.end(); ++it) {
(*it)->blockSignals(true);
(*it)->setValue(0.0);
(*it)->blockSignals(false);
}
Base::Vector3d cnt = strategy->getRotationCenter();
ui->xCnt->setValue(Base::Quantity(cnt.x, Base::Unit::Length));
ui->yCnt->setValue(Base::Quantity(cnt.y, Base::Unit::Length));
ui->zCnt->setValue(Base::Quantity(cnt.z, Base::Unit::Length));
}
示例15: proj
void ViewProvider2DObject::updateData(const App::Property* prop)
{
ViewProviderPart::updateData(prop);
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) {
Base::BoundBox3d bbox = static_cast<const Part::PropertyPartShape*>(prop)->getBoundingBox();
if (!bbox.IsValid()) return;
GridRoot->removeAllChildren();
Base::Placement place = static_cast<const Part::PropertyPartShape*>(prop)->getComplexData()->getPlacement();
place.invert();
Base::ViewProjMatrix proj(place.toMatrix());
Base::BoundBox2D bbox2d = bbox.ProjectBox(&proj);
this->MinX = bbox2d.fMinX;
this->MaxX = bbox2d.fMaxX;
this->MinY = bbox2d.fMinY;
this->MaxY = bbox2d.fMaxY;
if (ShowGrid.getValue()) {
createGrid();
}
}
}