本文整理汇总了C++中base::Placement::setRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ Placement::setRotation方法的具体用法?C++ Placement::setRotation怎么用?C++ Placement::setRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::Placement
的用法示例。
在下文中一共展示了Placement::setRotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: Restore
//.........这里部分代码省略.........
bool location_xyz = false;
bool location_axis = false;
bool distance_lhw = false;
Base::Placement plm;
App::PropertyDistance x,y,z;
App::PropertyDistance l,w,h;
App::PropertyVector Axis, Location;
Axis.setValue(0.0f,0.0f,1.0f);
for (int i=0 ;i<Cnt;i++) {
reader.readElement("Property");
const char* PropName = reader.getAttribute("name");
const char* TypeName = reader.getAttribute("type");
App::Property* prop = getPropertyByName(PropName);
if (!prop) {
// in case this comes from an old document we must use the new properties
if (strcmp(PropName, "l") == 0) {
distance_lhw = true;
prop = &l;
}
else if (strcmp(PropName, "w") == 0) {
distance_lhw = true;
prop = &h; // by mistake w was considered as height
}
else if (strcmp(PropName, "h") == 0) {
distance_lhw = true;
prop = &w; // by mistake h was considered as width
}
else if (strcmp(PropName, "x") == 0) {
location_xyz = true;
prop = &x;
}
else if (strcmp(PropName, "y") == 0) {
location_xyz = true;
prop = &y;
}
else if (strcmp(PropName, "z") == 0) {
location_xyz = true;
prop = &z;
}
else if (strcmp(PropName, "Axis") == 0) {
location_axis = true;
prop = &Axis;
}
else if (strcmp(PropName, "Location") == 0) {
location_axis = true;
prop = &Location;
}
}
else if (strcmp(PropName, "Length") == 0 && strcmp(TypeName,"PropertyDistance") == 0) {
distance_lhw = true;
prop = &l;
}
else if (strcmp(PropName, "Height") == 0 && strcmp(TypeName,"PropertyDistance") == 0) {
distance_lhw = true;
prop = &h;
}
else if (strcmp(PropName, "Width") == 0 && strcmp(TypeName,"PropertyDistance") == 0) {
distance_lhw = true;
prop = &w;
}
// NOTE: We must also check the type of the current property because a subclass
// of PropertyContainer might change the type of a property but not its name.
// In this case we would force to read-in a wrong property type and the behaviour
// would be undefined.
std::string tn = TypeName;
if (strcmp(TypeName,"PropertyDistance") == 0) // missing prefix App::
tn = std::string("App::") + tn;
if (prop && strcmp(prop->getTypeId().getName(), tn.c_str()) == 0)
prop->Restore(reader);
reader.readEndElement("Property");
}
if (distance_lhw) {
this->Length.setValue(l.getValue());
this->Height.setValue(h.getValue());
this->Width.setValue(w.getValue());
}
// for 0.7 releases or earlier
if (location_xyz) {
plm.setPosition(Base::Vector3d(x.getValue(),y.getValue(),z.getValue()));
this->Placement.setValue(this->Placement.getValue() * plm);
this->Shape.setStatus(App::Property::User1, true); // override the shape's location later on
}
// for 0.8 releases
else if (location_axis) {
Base::Vector3d d = Axis.getValue();
Base::Vector3d p = Location.getValue();
Base::Rotation rot(Base::Vector3d(0.0,0.0,1.0),
Base::Vector3d(d.x,d.y,d.z));
plm.setRotation(rot);
plm.setPosition(Base::Vector3d(p.x,p.y,p.z));
this->Placement.setValue(this->Placement.getValue() * plm);
this->Shape.setStatus(App::Property::User1, true); // override the shape's location later on
}
reader.readEndElement("Properties");
}
示例4: updatePlacementFromDragger
void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoThis, SoFCCSysDragger* draggerIn)
{
App::DocumentObject *genericObject = sudoThis->getObject();
if (!genericObject->isDerivedFrom(App::GeoFeature::getClassTypeId()))
return;
App::GeoFeature *geoFeature = static_cast<App::GeoFeature *>(genericObject);
Base::Placement originalPlacement = geoFeature->Placement.getValue();
double pMatrix[16];
originalPlacement.toMatrix().getMatrix(pMatrix);
Base::Placement freshPlacement = originalPlacement;
//local cache for brevity.
double translationIncrement = draggerIn->translationIncrement.getValue();
double rotationIncrement = draggerIn->rotationIncrement.getValue();
int tCountX = draggerIn->translationIncrementCountX.getValue();
int tCountY = draggerIn->translationIncrementCountY.getValue();
int tCountZ = draggerIn->translationIncrementCountZ.getValue();
int rCountX = draggerIn->rotationIncrementCountX.getValue();
int rCountY = draggerIn->rotationIncrementCountY.getValue();
int rCountZ = draggerIn->rotationIncrementCountZ.getValue();
//just as a little sanity check make sure only 1 field has changed.
int numberOfFieldChanged = 0;
if (tCountX) numberOfFieldChanged++;
if (tCountY) numberOfFieldChanged++;
if (tCountZ) numberOfFieldChanged++;
if (rCountX) numberOfFieldChanged++;
if (rCountY) numberOfFieldChanged++;
if (rCountZ) numberOfFieldChanged++;
if (numberOfFieldChanged == 0)
return;
assert(numberOfFieldChanged == 1);
//helper lamdas.
auto getVectorX = [&pMatrix]() {return Base::Vector3d(pMatrix[0], pMatrix[4], pMatrix[8]);};
auto getVectorY = [&pMatrix]() {return Base::Vector3d(pMatrix[1], pMatrix[5], pMatrix[9]);};
auto getVectorZ = [&pMatrix]() {return Base::Vector3d(pMatrix[2], pMatrix[6], pMatrix[10]);};
if (tCountX)
{
Base::Vector3d movementVector(getVectorX());
movementVector *= (tCountX * translationIncrement);
freshPlacement.move(movementVector);
geoFeature->Placement.setValue(freshPlacement);
}
else if (tCountY)
{
Base::Vector3d movementVector(getVectorY());
movementVector *= (tCountY * translationIncrement);
freshPlacement.move(movementVector);
geoFeature->Placement.setValue(freshPlacement);
}
else if (tCountZ)
{
Base::Vector3d movementVector(getVectorZ());
movementVector *= (tCountZ * translationIncrement);
freshPlacement.move(movementVector);
geoFeature->Placement.setValue(freshPlacement);
}
else if (rCountX)
{
Base::Vector3d rotationVector(getVectorX());
Base::Rotation rotation(rotationVector, rCountX * rotationIncrement);
freshPlacement.setRotation(rotation * freshPlacement.getRotation());
geoFeature->Placement.setValue(freshPlacement);
}
else if (rCountY)
{
Base::Vector3d rotationVector(getVectorY());
Base::Rotation rotation(rotationVector, rCountY * rotationIncrement);
freshPlacement.setRotation(rotation * freshPlacement.getRotation());
geoFeature->Placement.setValue(freshPlacement);
}
else if (rCountZ)
{
Base::Vector3d rotationVector(getVectorZ());
Base::Rotation rotation(rotationVector, rCountZ * rotationIncrement);
freshPlacement.setRotation(rotation * freshPlacement.getRotation());
geoFeature->Placement.setValue(freshPlacement);
}
draggerIn->clearIncrementCounts();
}