Assembly: set the rotating joint visible when dragging.
This commit is contained in:
@@ -78,6 +78,7 @@ ViewProviderAssembly::ViewProviderAssembly()
|
||||
, canStartDragging(false)
|
||||
, partMoving(false)
|
||||
, enableMovement(true)
|
||||
, jointVisibilityBackup(false)
|
||||
, docsToMove({})
|
||||
{}
|
||||
|
||||
@@ -536,14 +537,14 @@ ViewProviderAssembly::MoveMode ViewProviderAssembly::findMoveMode()
|
||||
if (docsToMove.size() == 1) {
|
||||
auto* assemblyPart = static_cast<AssemblyObject*>(getObject());
|
||||
std::string partPropName;
|
||||
App::DocumentObject* joint =
|
||||
movingJoint =
|
||||
assemblyPart->getJointOfPartConnectingToGround(docsToMove[0].first, partPropName);
|
||||
|
||||
if (!joint) {
|
||||
if (!movingJoint) {
|
||||
return MoveMode::Translation;
|
||||
}
|
||||
|
||||
JointType jointType = AssemblyObject::getJointType(joint);
|
||||
JointType jointType = AssemblyObject::getJointType(movingJoint);
|
||||
if (jointType == JointType::Fixed) {
|
||||
// If fixed joint we need to find the upstream joint to find move mode.
|
||||
// For example : Gnd -(revolute)- A -(fixed)- B : if user try to move B, then we should
|
||||
@@ -561,27 +562,27 @@ ViewProviderAssembly::MoveMode ViewProviderAssembly::findMoveMode()
|
||||
docsToMove.emplace_back(upstreamPart, propPlacement->getValue());
|
||||
}
|
||||
|
||||
joint =
|
||||
movingJoint =
|
||||
assemblyPart->getJointOfPartConnectingToGround(docsToMove[0].first, partPropName);
|
||||
if (!joint) {
|
||||
if (!movingJoint) {
|
||||
return MoveMode::Translation;
|
||||
}
|
||||
jointType = AssemblyObject::getJointType(joint);
|
||||
jointType = AssemblyObject::getJointType(movingJoint);
|
||||
}
|
||||
|
||||
const char* plcPropName = (partPropName == "Part1") ? "Placement1" : "Placement2";
|
||||
const char* objPropName = (partPropName == "Part1") ? "Object1" : "Object2";
|
||||
|
||||
// jcsPlc is relative to the Object
|
||||
jcsPlc = AssemblyObject::getPlacementFromProp(joint, plcPropName);
|
||||
jcsPlc = AssemblyObject::getPlacementFromProp(movingJoint, plcPropName);
|
||||
|
||||
// Make jcsGlobalPlc relative to the origin of the doc
|
||||
Base::Placement global_plc =
|
||||
AssemblyObject::getGlobalPlacement(joint, objPropName, partPropName.c_str());
|
||||
AssemblyObject::getGlobalPlacement(movingJoint, objPropName, partPropName.c_str());
|
||||
jcsGlobalPlc = global_plc * jcsPlc;
|
||||
|
||||
// Add downstream parts so that they move together
|
||||
auto downstreamParts = assemblyPart->getDownstreamParts(docsToMove[0].first, joint);
|
||||
auto downstreamParts = assemblyPart->getDownstreamParts(docsToMove[0].first, movingJoint);
|
||||
for (auto part : downstreamParts) {
|
||||
auto* propPlacement =
|
||||
dynamic_cast<App::PropertyPlacement*>(part->getPropertyByName("Placement"));
|
||||
@@ -590,6 +591,11 @@ ViewProviderAssembly::MoveMode ViewProviderAssembly::findMoveMode()
|
||||
}
|
||||
}
|
||||
|
||||
jointVisibilityBackup = movingJoint->Visibility.getValue();
|
||||
if (!jointVisibilityBackup) {
|
||||
movingJoint->Visibility.setValue(true);
|
||||
}
|
||||
|
||||
if (jointType == JointType::Revolute) {
|
||||
return MoveMode::RotationOnPlane;
|
||||
}
|
||||
@@ -599,6 +605,10 @@ ViewProviderAssembly::MoveMode ViewProviderAssembly::findMoveMode()
|
||||
else if (jointType == JointType::Cylindrical) {
|
||||
return MoveMode::TranslationOnAxisAndRotationOnePlane;
|
||||
}
|
||||
else if (jointType == JointType::Distance) {
|
||||
// depends on the type of distance. For example plane-plane:
|
||||
// return MoveMode::TranslationOnPlane;
|
||||
}
|
||||
}
|
||||
return MoveMode::Translation;
|
||||
}
|
||||
@@ -633,6 +643,12 @@ void ViewProviderAssembly::endMove()
|
||||
partMoving = false;
|
||||
canStartDragging = false;
|
||||
|
||||
if (movingJoint && !jointVisibilityBackup) {
|
||||
movingJoint->Visibility.setValue(false);
|
||||
}
|
||||
|
||||
movingJoint = nullptr;
|
||||
|
||||
// enable selection after the move
|
||||
auto* view = dynamic_cast<Gui::View3DInventor*>(
|
||||
Gui::Application::Instance->editDocument()->getActiveView());
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
{
|
||||
Translation,
|
||||
TranslationOnAxis,
|
||||
TranslationOnPlane,
|
||||
Rotation,
|
||||
RotationOnPlane,
|
||||
TranslationOnAxisAndRotationOnePlane,
|
||||
@@ -119,12 +120,15 @@ public:
|
||||
bool canStartDragging;
|
||||
bool partMoving;
|
||||
bool enableMovement;
|
||||
bool jointVisibilityBackup;
|
||||
int numberOfSel;
|
||||
Base::Vector3d initialPosition;
|
||||
Base::Vector3d initialPositionRot;
|
||||
Base::Placement jcsPlc;
|
||||
Base::Placement jcsGlobalPlc;
|
||||
|
||||
App::DocumentObject* movingJoint;
|
||||
|
||||
std::vector<std::pair<App::DocumentObject*, double>> objectMasses;
|
||||
std::vector<std::pair<App::DocumentObject*, Base::Placement>> docsToMove;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user