Skip to content

Commit

Permalink
Gui: fix placement of reference shapes with redefined color
Browse files Browse the repository at this point in the history
Relates to GitHub #233
  • Loading branch information
HuguesDelorme committed Nov 14, 2023
1 parent d466625 commit 84cb80a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/app/dialog_inspect_xde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@ static void loadLabelAttributes(const TDF_Label& label, QTreeWidgetItem* treeIte
}
else if (attrId == TNaming_NamedShape::GetID()) {
const auto& namedShape = static_cast<const TNaming_NamedShape&>(*ptrAttr);
const TopoDS_Shape shape = namedShape.Get();
text = "TNaming_NamedShape";
value = DialogInspectXde::tr("ShapeType=%1, Evolution=%2")
.arg(MetaEnum::name(namedShape.Get().ShapeType()).data())
value = DialogInspectXde::tr("ShapeType=%1, ShapeLocation=%2, Evolution=%3")
.arg(MetaEnum::name(shape.ShapeType()).data())
.arg(shape.Location().Transformation().Form() != gp_Identity ?
QStringUtils::text(shape.Location(), appDefaultTextOptions())
: QString("id")
)
.arg(MetaEnum::name(namedShape.Evolution()).data());
}
else {
Expand Down
6 changes: 5 additions & 1 deletion src/gui/gui_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,15 @@ void GuiDocument::mapEntity(TreeNodeId entityTreeNodeId)
}

if (!docModelTree.nodeIsRoot(id)) {
const TDF_Label parentNodeLabel = docModelTree.nodeData(docModelTree.nodeParent(id));
const TreeNodeId parentNodeId = docModelTree.nodeParent(id);
const TDF_Label parentNodeLabel = docModelTree.nodeData(parentNodeId);
if (XCaf::isShapeReference(parentNodeLabel) && m_document->xcaf().hasShapeColor(parentNodeLabel)) {
// Parent node is a reference and it redefines color attribute, so the graphics
// can't be shared with the product
auto gfxObject = m_guiApp->createGraphicsObject(parentNodeLabel);
const TreeNodeId grandParentNodeId = docModelTree.nodeParent(parentNodeId);
const TopLoc_Location locGrandParentShape = XCaf::shapeAbsoluteLocation(docModelTree, grandParentNodeId);
gfxObject->SetLocalTransformation(locGrandParentShape);
gfxEntity.vecObject.push_back(gfxObject);
}
else {
Expand Down

0 comments on commit 84cb80a

Please sign in to comment.