本文整理汇总了C++中base::Placement类的典型用法代码示例。如果您正苦于以下问题:C++ Placement类的具体用法?C++ Placement怎么用?C++ Placement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Placement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:rmamba,项目名称:FreeCAD_sf_master,代码行数:12,代码来源:PartFeature.cpp
示例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);
}
开发者ID:fandaL,项目名称:FreeCAD,代码行数:52,代码来源:TaskDatumParameters.cpp
示例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);
}
开发者ID:zhangli1049,项目名称:FreeCAD,代码行数:14,代码来源:ViewProviderDragger.cpp
示例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]);
}
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:15,代码来源:CommandTrajectory.cpp
示例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();
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:15,代码来源:Command.cpp
示例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);
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:15,代码来源:TaskRobot6Axis.cpp
示例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);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:17,代码来源:PointsFeature.cpp
示例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;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:17,代码来源:FemMeshPyImp.cpp
示例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;
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:18,代码来源:GeometryPyImp.cpp
示例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);
}
开发者ID:aromis,项目名称:FreeCAD_sf_master,代码行数:44,代码来源:Placement.cpp
示例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));
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:19,代码来源:ViewProviderRobotObject.cpp
示例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());
}
}
开发者ID:5263,项目名称:FreeCAD,代码行数:19,代码来源:Transform.cpp
示例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());
}
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:20,代码来源:Transform.cpp
示例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));
}
开发者ID:5263,项目名称:FreeCAD,代码行数:20,代码来源:Transform.cpp
示例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();
}
}
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:21,代码来源:ViewProvider2DObject.cpp
示例16: 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();
}
开发者ID:fandaL,项目名称:FreeCAD,代码行数:39,代码来源:TaskDatumParameters.cpp
示例17: onChanged
void Feature::onChanged(const App::Property* prop)
{
// if the placement has changed apply the change to the mesh data as well
if (prop == &this->Placement) {
MeshObject& mesh = const_cast<MeshObject&>(this->Mesh.getValue());
mesh.setTransform(this->Placement.getValue().toMatrix());
}
// if the mesh data has changed check and adjust the transformation as well
else if (prop == &this->Mesh) {
Base::Placement p;
p.fromMatrix(this->Mesh.getValue().getTransform());
if (p != this->Placement.getValue())
this->Placement.setValue(p);
}
// Note: If the Mesh property has changed the property and this object are marked as 'touched'
// but no recomputation of this objects needs to be done because the Mesh property is regarded
// as output of a previous recomputation The mustExecute() method returns 0 in that case.
// However, objects that reference this object the Mesh property can be an input parameter.
// As this object and the property are touched such objects can check this and return a value 1
// (or -1) in their mustExecute() to be recomputed the next time the document recomputes itself.
DocumentObject::onChanged(prop);
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:23,代码来源:MeshFeature.cpp
示例18: revertTransformation
void Placement::revertTransformation()
{
for (std::set<std::string>::iterator it = documents.begin(); it != documents.end(); ++it) {
Gui::Document* document = Application::Instance->getDocument(it->c_str());
if (!document) continue;
std::vector<App::DocumentObject*> obj = document->getDocument()->
getObjectsOfType(App::DocumentObject::getClassTypeId());
if (!obj.empty()) {
for (std::vector<App::DocumentObject*>::iterator it=obj.begin();it!=obj.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();
Gui::ViewProvider* vp = document->getViewProvider(*it);
if (vp) vp->setTransformation(cur.toMatrix());
}
}
}
}
}
开发者ID:aromis,项目名称:FreeCAD_sf_master,代码行数:24,代码来源:Placement.cpp
示例19: 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();
}
}
开发者ID:ADVALAIN596,项目名称:FreeCAD_sf_master,代码行数:36,代码来源:FeatureRevolution.cpp
示例20: 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);
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:19,代码来源:ViewProviderRobotObject.cpp
注:本文中的base::Placement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论