From 7388be593836a09b38cb6ed2331b3aca0974432e Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 31 Jul 2015 13:32:28 +0300 Subject: [PATCH] Compsolid: 1. a define to process the first shape as a shape of compsolid[debug purpose]; 2. "Color" on compsolid to change colors of all sub-solids. --- .../FeaturesPlugin_Extrusion.cpp | 22 +++++++++++++++++-- src/Model/Model_ResultCompSolid.cpp | 4 +++- src/XGUI/XGUI_Workshop.cpp | 14 ++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index 4b57ee2b7..092b37406 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -29,6 +29,7 @@ #define EDGE 6 #define DEBUG_COMPSOLID +//#define DEBUG_COMPSOLID_SHAPE //================================================================================================= FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() @@ -103,6 +104,11 @@ void FeaturesPlugin_Extrusion::execute() ResultCompSolidPtr aCompSolidResult = document()->createCompSolid(data(), aResultIndex); setResult(aCompSolidResult, aResultIndex); aResultIndex++; +#endif +#ifdef DEBUG_COMPSOLID_SHAPE + bool aFirstShapeInCompsolid = aFaceRefs->size() > 0; + if (aFirstShapeInCompsolid) + aResultIndex--; #endif for(; anIndex < aFaceRefs->size(); anIndex++) { std::shared_ptr aFaceRef = aFaceRefs->value(anIndex); @@ -128,10 +134,22 @@ void FeaturesPlugin_Extrusion::execute() } } for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) { + ResultBodyPtr aResultBody; + +#ifdef DEBUG_COMPSOLID_SHAPE + if (aFirstShapeInCompsolid && anIndex == 0) + aResultBody = aCompSolidResult; + else { +#endif + #ifdef DEBUG_COMPSOLID - ResultBodyPtr aResultBody = aCompSolidResult->addResult(aResultIndex); + aResultBody = aCompSolidResult->addResult(aResultIndex); #else - ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); + aResultBody = document()->createBody(data(), aResultIndex); +#endif + +#ifdef DEBUG_COMPSOLID_SHAPE + } #endif std::shared_ptr aBaseShape; if (aFacesNum == -1) { diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp index 2472d68e2..5cb50556c 100755 --- a/src/Model/Model_ResultCompSolid.cpp +++ b/src/Model/Model_ResultCompSolid.cpp @@ -38,7 +38,9 @@ std::shared_ptr Model_ResultCompSolid::addResult(const int int Model_ResultCompSolid::numberOfSubs(bool forTree) const { - return 0; + if (forTree) + return 0; + return data()->reflist(Model_ResultCompSolid::BODIES_ID())->size(); } std::shared_ptr Model_ResultCompSolid::subResult(const int theIndex, diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 0ce4e96c4..95db6cca3 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -42,6 +42,7 @@ #include #include #include +#include //#include @@ -1327,8 +1328,9 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) std::vector aColor; foreach(ObjectPtr anObject, theObjects) { ResultPtr aResult = std::dynamic_pointer_cast(anObject); - if (aResult.get()) + if (aResult.get()) { XGUI_CustomPrs::getResultColor(aResult, aColor); + } else { // TODO: remove the obtaining a color from the AIS object // this does not happen never because: @@ -1365,10 +1367,18 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) } // 4. set the value to all results + std::vector aColorResult = aDlg->getColor(); foreach(ObjectPtr anObj, theObjects) { ResultPtr aResult = std::dynamic_pointer_cast(anObj); if (aResult.get() != NULL) { - std::vector aColorResult = aDlg->getColor(); + ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(aResult); + if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids + for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) { + ResultPtr aSubResult = aCompsolidResult->subResult(i); + if (aSubResult.get()) + setColor(aSubResult, aColorResult); + } + } setColor(aResult, aColorResult); } } -- 2.39.2