Store edge thickness as an integer with a custom ID, instead of TDataStd_Integer::GetID().
static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located
static const int TAG_RESULT_SHAPES = 2; ///< where the shapes are located
+/*static*/ const Standard_GUID Model_Objects::ATTR_ID_SHAPE_THICKNESS = Standard_GUID("7cd0b171-fb15-477b-909f-e66d36e541ff");
+
///
/// 0:1:2 - where features are located
/// 0:1:2:N:1 - data of the feature N
aResultLabel = resultLabel(theResult->data(), index(aMain));
else
aResultLabel = resultLabel(theResult->data(), index(theResult));
+
TDF_Label anAttributeLabel = subShapeLabel(aResultLabel, index(theResult, theShape)).FindChild(TAG_FEATURE_ARGUMENTS);
if (theAttribute->ID() == TDataStd_IntegerArray::GetID())
Handle(TDataStd_IntegerArray)::DownCast(theAttribute);
if (anAttributeLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anColor))
- {
anAttributeLabel.ForgetAttribute(TDataStd_IntegerArray::GetID());
- }
+
anAttributeLabel.AddAttribute(anAttr);
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent);
}
- else if (theAttribute->ID() == TDataStd_Integer::GetID()) {
+ else if (theAttribute->ID() == Model_Objects::ATTR_ID_SHAPE_THICKNESS) {
Handle(TDataStd_Integer) aThicknessAttr;
Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(theAttribute);
- if (anAttributeLabel.FindAttribute(TDataStd_Integer::GetID(), aThicknessAttr))
- anAttributeLabel.ForgetAttribute(TDataStd_Integer::GetID());
+ if (anAttributeLabel.FindAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, aThicknessAttr))
+ anAttributeLabel.ForgetAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS);
anAttributeLabel.AddAttribute(anAttr);
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
aSub->setImpl(new TopoDS_Shape(aNamedShape->Get()));
Handle(TDataStd_Integer) aEdgeThicknessAttr;
- aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).FindAttribute(TDataStd_Integer::GetID(), aEdgeThicknessAttr);
+ aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).FindAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, aEdgeThicknessAttr);
if (aEdgeThicknessAttr.IsNull())
continue;
if (aNamedShape.IsNull())
continue;
- aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).ForgetAttribute(TDataStd_Integer::GetID());
+ aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).ForgetAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS);
}
}
#include <NCollection_DataMap.hxx>
#include <TDF_Label.hxx>
#include <TDF_LabelList.hxx>
+#include <Standard_GUID.hxx>
#include <map>
#include <set>
#include <vector>
class Model_Objects
{
public:
+ static const Standard_GUID ATTR_ID_SHAPE_THICKNESS;
+
//! Registers the feature in the data structure
//! \param theFeature feature that must be added to the data structure
//! \param theAfterThis the feature will be added after this feature;
document()->storeShape(data(), theResult, theSubShape);
Handle(TDataStd_Integer) aThickness = new TDataStd_Integer();
+ aThickness->SetID(Model_Objects::ATTR_ID_SHAPE_THICKNESS);
aThickness->Set(theEdgeThickness);
anObjects->setAttribute(aThickness, theResult, theSubShape);
}
return -1;
Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
- auto anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(TDataStd_Integer::GetID(), theResult, theSubShape));
+ auto anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, theResult, theSubShape));
if (anAttr.IsNull())
- return;
+ return -1;
return anAttr->Get();
}
document()->storeShape(data(), original(), theSubShape);
Handle(TDataStd_Integer) aThickness = new TDataStd_Integer();
+ aThickness->SetID(Model_Objects::ATTR_ID_SHAPE_THICKNESS);
aThickness->Set(theThickness);
anObjects->setAttribute(aThickness, original(), theSubShape);
}
TopoDS_Shape aShape = shape()->impl<TopoDS_Shape>();
TopoDS_Shape aSubShape = theSubShape->impl<TopoDS_Shape>();
if (!shape()->isSubShape(theSubShape))
- return;
+ return -1;
Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
- Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(TDataStd_Integer::GetID(), original(), theSubShape));
+ Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, original(), theSubShape));
if (anAttr.IsNull())
- return;
+ return -1;
return anAttr->Get();
}
Handle(AIS_ColoredShape) aResShape = Handle(AIS_ColoredShape)::DownCast(aAISIO);
Handle(ModuleBase_ResultPrs) aResPrsShape = Handle(ModuleBase_ResultPrs)::DownCast(aResShape);
- if (!aColoredShapes.empty() && !aResPrsShape.IsNull())
- {
- for (std::map<GeomShapePtr, std::vector<int>>::const_iterator anIter(aColoredShapes.cbegin());
- anIter != aColoredShapes.cend(); ++anIter)
- {
- if (aAISObj->getShape()->isSubShape(anIter->first))
- {
- Quantity_Color aColorQ(anIter->second.at(0) / 255.,
+ if (!aColoredShapes.empty() && !aResPrsShape.IsNull()) {
+ for (auto anIter = aColoredShapes.cbegin(); anIter != aColoredShapes.cend(); ++anIter) {
+ if (aAISObj->getShape()->isSubShape(anIter->first)) {
+ Quantity_Color aColorQ(
+ anIter->second.at(0) / 255.,
anIter->second.at(1) / 255.,
anIter->second.at(2) / 255.,
- Quantity_TOC_RGB);
+ Quantity_TOC_RGB
+ );
aResPrsShape->SetCustomColor(anIter->first->impl<TopoDS_Shape>(), aColorQ);
}
}
}
- else
- {
+ else {
aResShape->ClearCustomAspects();
}
// Set deflection
return aSelectedList;
}
+/*
+ Quantity_Color aColorQ(anIter->second.at(0) / 255.,
+ anIter->second.at(1) / 255.,
+ anIter->second.at(2) / 255.,
+ Quantity_TOC_RGB);
+ aResPrsShape->SetCustomColor(anIter->first->impl<TopoDS_Shape>(), aColorQ);
+*/
+
QMap<ResultPtr, QList<GeomShapePtr>> XGUI_Selection::selectedObjectsAndSubObjects() const
{
QMap<ResultPtr, QList<GeomShapePtr>> aSelectedObjects;
- // Add all objects, which selected in Viewer
+ // Add all objects, which are selected in Viewer.
QList<ModuleBase_ViewerPrsPtr> aValues = getSelected(ModuleBase_ISelection::Viewer);
foreach(ModuleBase_ViewerPrsPtr aPrs, aValues)
{
GeomShapePtr aShape = aPrs->shape();
aSelectedObjects[aResult].push_back(aShape);
+
+ std::wcout << "aShape adress" << reinterpret_cast<void*>(aShape.get()) << std::endl;
}
- // Add object, which selected in browser, but not selected in Viewer
+ // Add object, which is selected in browser, but is not selected in Viewer.
QObjectPtrList anObjects = selectedObjects();
- foreach(ObjectPtr anObject, anObjects)
- {
+ foreach(ObjectPtr anObject, anObjects) {
ResultBodyPtr aResultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
if (!aResultBody.get())
continue;
+
GeomShapePtr aBodyShape = aResultBody->shape();
if (aSelectedObjects.contains(aResultBody))
continue;
+
bool isContains = false;
- foreach(GeomShapePtr aCurShape, aSelectedObjects[aResultBody])
- {
- if (aCurShape->impl<TopoDS_Shape>().IsEqual(aBodyShape->impl<TopoDS_Shape>()))
- {
+ foreach(GeomShapePtr aCurShape, aSelectedObjects[aResultBody]) {
+ if (aCurShape->impl<TopoDS_Shape>().IsEqual(aBodyShape->impl<TopoDS_Shape>())) {
isContains = true;
break;
}
}
+
if (!isContains)
aSelectedObjects[aResultBody].push_back(aBodyShape);
+
+ std::wcout << "aBodyShape adress" << reinterpret_cast<void*>(aBodyShape.get()) << std::endl;
}
return aSelectedObjects;
}
QString description = contextMenuMgr()->action("EDGE_THICKNESS_CMD")->text();
session->startOperation(description.toStdString());
+ std::wcout << "theSelectedObjects.size() = " << theSelectedObjects.size() << std::endl;
+ std::wcout << "foreach result START" << std::endl;
// 4. Set new value to all results and subshapes of results.
foreach(ResultPtr result, theSelectedObjects.keys()) {
if (!result)
ResultBodyPtr bodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(result);
- std::wcout << "theSelectedObjects.size() = " << theSelectedObjects.size() << std::endl;
- std::wcout << "foreach START" << std::endl;
- if (theSelectedObjects.contains(result))
- std::wcout << "theSelectedObjects[result].size = " << theSelectedObjects[result].size() << std::endl;
+ std::wcout << "foreach shape START" << std::endl;
+ std::wcout << "theSelectedObjects[result].size = " << theSelectedObjects[result].size() << std::endl;
foreach(GeomShapePtr shape, theSelectedObjects[result]) {
if (result->shape()->impl<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness);
}
}
- std::wcout << "foreach END" << std::endl;
+ std::wcout << "foreach shape END" << std::endl;
}
+ std::wcout << "foreach result END" << std::endl;
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
session->finishOperation();
{
// 1. Find current thickness - thickness of AIS presentation.
// The objects are iterated until a first valid thickness is found.
- int thickness;
+ int thickness = -1;
QList<ModuleBase_ViewerPrsPtr> aValues = mySelector->selection()->getSelected(ModuleBase_ISelection::Viewer);
const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness");
foreach(ResultPtr result, theSelectedObjects.keys()) {
const auto dialog = new XGUI_PropertyDialog(desktop());
dialog->setWindowTitle(tr("Edge Thickness"));
XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog);
+ edgeThicknessWidget->setValue(thickness);
+ dialog->setContent(edgeThicknessWidget);
mySelectedObjects = theSelectedObjects;
connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged(int)), this, SLOT(onEdgeThicknessValueChanged(int)));
- dialog->setContent(edgeThicknessWidget);
- edgeThicknessWidget->setValue(thickness);
if (dialog->exec() != QDialog::Accepted)
applyEdgeThicknessToCanvas(theSelectedObjects, thickness);