Fix setting thickness to individual edges.
std::shared_ptr<GeomAPI_Shape> theSubShape,
int theEdgeThickness
) {
- if (!theResult || theSubShape->isNull())
+ std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() START" << std::endl;
+
+ if (!theResult || theSubShape->isNull()) {
+ std::wcout << "if (!theResult || theSubShape->isNull())" << std::endl;
+ std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
return;
+ }
- if (!theResult->shape()->isSubShape(theSubShape))
+ if (!theResult->shape()->isSubShape(theSubShape)) {
+ std::wcout << "if (!theResult->shape()->isSubShape(theSubShape))" << std::endl;
+ std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
return;
+ }
auto resultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
if (resultBody) {
+ std::wcout << "if (resultBody)" << std::endl;
resultBody = mainBody(resultBody);
resultBody->setSubShapeEdgeThickness(theResult, theSubShape, theEdgeThickness);
}
else {
+ std::wcout << "NOT if (resultBody)" << std::endl;
+
const auto resultPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(theResult);
- if (!resultPart)
+ if (!resultPart) {
+ std::wcout << "if (!resultPart)" << std::endl;
+ std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
return;
+ }
resultPart->setSubShapeEdgeThickness(theSubShape, theEdgeThickness);
}
static const Events_ID EVENT = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
ModelAPI_EventCreator::get()->sendUpdated(theResult, EVENT);
+ std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
}
//******************************************************
#include <set>
+#include <iostream>
+
#ifdef _MSC_VER
#pragma warning(disable: 4702)
#endif
// bos#40617: Apply clipping planes
// Retrieve the clipping plane from the OCCT Presentation Manager directly,
- // as they are stored in the ViewModel of the OCCViewer in GUI, where we
+ // as they are stored in the ViewModel of the OCCViewer in GUI, where we
// don't have access to.
Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anAISIO);
if (!aShape.IsNull() && aShape->IsClippable()) {
if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency()))
aAISObj->setTransparency(aTransparency);
- // Set edge thickness
+ // Set edge thickness.
const int aEdgeThickness = ModelAPI_Tools::getEdgeThickness(aResult);
- // std::cout << "aEdgeThickness " << aEdgeThickness << "\t";
- // std::cout << "aAISObj->width() " << aAISObj->width() << std::endl;
if ((aEdgeThickness > 0) && (aEdgeThickness != aAISObj->width()))
aAISObj->setWidth(aEdgeThickness);
+ { // Set subshapes' edge thickness.
+ std::wcout << "XGUI_Displayer::redisplay/Set subshapes' edge thickness. START" << std::endl;
+
+ std::map<GeomShapePtr, int> subShapesAndThicknesses;
+ ModelAPI_Tools::getSubShapesWithEdgeThickness(aResult, subShapesAndThicknesses);
+ Handle(AIS_ColoredShape) aResShape = Handle(AIS_ColoredShape)::DownCast(aAISIO);
+ Handle(ModuleBase_ResultPrs) aResPrsShape = Handle(ModuleBase_ResultPrs)::DownCast(aResShape);
+
+ std::wcout << "subShapesAndThicknesses.size = " << subShapesAndThicknesses.size() << std::endl;
+
+ if (!subShapesAndThicknesses.empty() && !aResPrsShape.IsNull()) {
+ for (auto it = subShapesAndThicknesses.cbegin(); it != subShapesAndThicknesses.cend(); ++it) {
+ const auto& subShape = it->first;
+ const auto& subShapeThickness = it->second;
+ std::wcout << "subShapeThickness = " << subShapeThickness << std::endl;
+
+ if (aAISObj->getShape()->isSubShape(subShape))
+ aResPrsShape->SetCustomWidth(subShape->impl<TopoDS_Shape>(), subShapeThickness);
+ }
+ }
+ else {
+ aResShape->ClearCustomAspects();
+ }
+
+ std::wcout << "XGUI_Displayer::redisplay/Set subshapes' edge thickness. END" << std::endl;
+ }
+
// Set Iso-Lines
Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
if (!aResPrs.IsNull())
//******************************************************
void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomShapePtr>>& theSelectedObjects, int theThickness)
{
+ std::wcout << "XGUI_Workshop::applyEdgeThicknessToCanvas( theThickness = " << theThickness << ") START" << std::endl;
+
const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness");
+ std::wcout << "isSubShapeWithEdgeThickness = " << (isSubShapeWithEdgeThickness ? "true" : "false") << std::endl;
// 3. Abort previous operation and start a new one.
SessionPtr session = ModelAPI_Session::get();
continue;
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;
+
foreach(GeomShapePtr shape, theSelectedObjects[result]) {
if (result->shape()->impl<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
+ std::wcout << "If 1" << std::endl;
+
if (result) {
+ std::wcout << "if (result)" << std::endl;
+
// Change edge thickness for all sub-solids.
std::list<ResultPtr> allSubResults;
ModelAPI_Tools::allSubs(bodyResult, allSubResults);
+ std::wcout << "allSubResults.size() = " << allSubResults.size() << std::endl;
+
for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) {
ModelAPI_Tools::setEdgeThickness(*itSubRes, theThickness);
}
if (!isSubShapeWithEdgeThickness)
break;
}
- else if (!shape->isNull())
+ else if (!shape->isNull()) {
+ std::wcout << "else if (!shape->isNull())" << std::endl;
ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness);
+ }
}
+ std::wcout << "foreach END" << std::endl;
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
session->finishOperation();
updateCommandStatus();
myViewerProxy->update();
+
+ std::wcout << "XGUI_Workshop::applyEdgeThicknessToCanvas( theThickness = " << theThickness << ") END" << std::endl;
}
//******************************************************
// 1. Find current thickness - thickness of AIS presentation.
// The objects are iterated until a first valid thickness is found.
int thickness;
+ 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()) {
if (!result)