add internal trafo for undo stack

This commit is contained in:
Michael Kirsch 2019-07-09 18:22:46 +02:00 committed by Joseph Lenox
parent c8a9ffc96b
commit 5bce2597e7
3 changed files with 24 additions and 0 deletions

View File

@ -836,9 +836,20 @@ ModelObject::mirror(const Axis &axis)
this->invalidate_bounding_box();
}
void ModelObject::reset_undo_trafo()
{
this->trafo_undo_stack = TransformationMatrix::mat_eye();
}
TransformationMatrix ModelObject::get_undo_trafo() const
{
return this->trafo_undo_stack;
}
void
ModelObject::apply_transformation(const TransformationMatrix & trafo)
{
this->trafo_undo_stack.applyLeft(trafo);
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
(*v)->apply_transformation(trafo);
}

View File

@ -405,6 +405,12 @@ class ModelObject
/// \param axis Axis enum member
void mirror(const Axis &axis);
/// Reset the internal collection of transformations
void reset_undo_trafo();
/// Get the accumulated collection of transformations since its reset
TransformationMatrix get_undo_trafo() const;
/// Transform the current ModelObject by a certain ModelInstance attributes.
/// Inverse transformation is applied to all the ModelInstances, so that the final size/position/rotation of the transformed objects doesn't change.
/// \param instance ModelInstance the instance used to transform the current ModelObject
@ -439,6 +445,7 @@ class ModelObject
/// Print the current info of this ModelObject
void print_info() const;
private:
Model* model; ///< Parent object, owning this ModelObject.
@ -455,6 +462,9 @@ class ModelObject
/// Apply transformation to all volumes
void apply_transformation(const TransformationMatrix & trafo);
/// Trafo to collect the transformation applied to all volumes over a series of manipulations
TransformationMatrix trafo_undo_stack;
/// = Operator overloading
/// \param other ModelObject the other ModelObject to be copied
/// \return ModelObject& the current ModelObject to enable operator cascading

View File

@ -233,6 +233,9 @@ ModelMaterial::attributes()
%code{% THIS->rotate(*origin, *target); %};
void mirror(Axis axis);
void reset_undo_trafo();
Clone<TransformationMatrix> get_undo_trafo()
%code{% RETVAL = THIS->get_undo_trafo(); %};
void transform_by_instance(ModelInstance* instance, bool dont_translate = false)
%code{% THIS->transform_by_instance(*instance, dont_translate); %};