From 1f245a12321ab8aaa9e54050b0eedc2ab1bd650e Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 22 May 2015 21:13:12 +0300 Subject: [PATCH] 1. This is a fix for the disabled object visualized in the viewer. 2. Comment multi-selector using in the boolean operation. Scenario: create a sketch with a circle. Create an extrusion. Set extrusion height is 0. Set height more than 0. Apply. Hide extrusion result. A cylinder is visualized in the viewer. --- src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp | 2 +- src/FeaturesPlugin/boolean_widget.xml | 22 +++++----- src/ModuleBase/ModuleBase_Tools.cpp | 23 ++++++++-- src/XGUI/XGUI_Displayer.cpp | 42 ++++++++++++++----- src/XGUI/XGUI_Displayer.h | 9 ++++ src/XGUI/XGUI_Workshop.cpp | 3 +- 6 files changed, 75 insertions(+), 26 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index f52353397..913d8ade0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -15,7 +15,7 @@ #include using namespace std; -//#define DEBUG_ONE_OBJECT +#define DEBUG_ONE_OBJECT #define FACE 4 #define _MODIFY_TAG 1 diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index e1443e531..040124714 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -1,14 +1,7 @@ - - - - + + - --> + #include +#include + namespace ModuleBase_Tools { //****************************************************************** @@ -125,18 +127,33 @@ void setSpinValue(QDoubleSpinBox* theSpin, double theValue) QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { + QString aFeatureStr = "feature"; + if (!theObj.get()) + return aFeatureStr; + + std::ostringstream aPtrStr; + aPtrStr << "[" << theObj.get() << "]"; + ResultPtr aRes = std::dynamic_pointer_cast(theObj); FeaturePtr aFeature = std::dynamic_pointer_cast(theObj); - QString aFeatureStr = "feature"; if(aRes.get()) { - aFeatureStr.append("(Result)"); + aFeatureStr.append(QString("(result%1)").arg(aPtrStr.str().c_str()).toStdString() .c_str()); + if (aRes->isDisabled()) + aFeatureStr.append("[disabled]"); + if (aRes->isConcealed()) + aFeatureStr.append("[concealed]"); + aFeature = ModelAPI_Feature::feature(aRes); } + else + aFeatureStr.append(aPtrStr.str().c_str()); + if (aFeature.get()) { aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str()); - if (aFeature->data().get() && aFeature->data()->isValid()) + if (aFeature->data().get() && aFeature->data()->isValid()) { aFeatureStr.append(QString(", name=%1").arg(aFeature->data()->name().c_str()).toStdString() .c_str()); + } if (isUseAttributesInfo) { std::list anAttrs = aFeature->data()->attributes(""); std::list::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end(); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 83fa8010d..fd7e77079 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -93,14 +94,6 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) if (isVisible(theObject)) { redisplay(theObject, isUpdateViewer); } else { -#ifdef DEBUG_DISPLAY - FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - if (aFeature.get() != NULL) { - qDebug(QString("display feature: %1, displayed: %2"). - arg(aFeature->data()->name().c_str()). - arg(displayedObjects().size()).toStdString().c_str()); - } -#endif AISObjectPtr anAIS; GeomPresentablePtr aPrs = std::dynamic_pointer_cast(theObject); @@ -152,7 +145,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull()) { - myResult2AISObjectMap[theObject] = theAIS; + appendResultObject(theObject, theAIS); + bool aCanBeShaded = ::canBeShaded(anAISIO); // In order to avoid extra closing/opening context SelectMgr_IndexedMapOfOwner aSelectedOwners; @@ -217,7 +211,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) return; } if (aAIS_Obj != aAISObj) { - myResult2AISObjectMap[theObject] = aAIS_Obj; + appendResultObject(theObject, aAIS_Obj); } aAISIO = aAIS_Obj->impl(); } @@ -902,3 +896,31 @@ QColor XGUI_Displayer::setObjectColor(ObjectPtr theObject, const QColor& theColo updateViewer(); return QColor(aR, aG, aB); } + +void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS) +{ + myResult2AISObjectMap[theObject] = theAIS; + +#ifdef DEBUG_DISPLAY + std::ostringstream aPtrStr; + aPtrStr << theObject.get(); + qDebug(QString("display object: %1").arg(aPtrStr.str().c_str()).toStdString().c_str()); + qDebug(getResult2AISObjectMapInfo().c_str()); +#endif +} + +std::string XGUI_Displayer::getResult2AISObjectMapInfo() const +{ + QStringList aContent; + foreach (ObjectPtr aObj, myResult2AISObjectMap.keys()) { + AISObjectPtr aAISObj = myResult2AISObjectMap[aObj]; + std::ostringstream aPtrStr; + aPtrStr << "aObj = " << aObj.get() << ":"; + aPtrStr << "anAIS = " << aAISObj.get() << ":"; + aPtrStr << "[" << ModuleBase_Tools::objectInfo(aObj).toStdString().c_str() << "]"; + + aContent.append(aPtrStr.str().c_str()); + } + return QString("myResult2AISObjectMap: size = %1\n%2").arg(myResult2AISObjectMap.size()). + arg(aContent.join("\n")).toStdString().c_str(); +} diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 493a077a2..cf35c0083 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -251,6 +251,15 @@ private: */ bool customizeObject(ObjectPtr theObject); + /// Append the objects in the internal map. Checks whether the map already contains the object + /// \param theObject an object to display + /// \param theAIS AIOS object to display + void appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS); + + /// Returns an information about alredy displayed objects + /// \return a string representation + std::string getResult2AISObjectMapInfo() const; + protected: /// Reference to workshop XGUI_Workshop* myWorkshop; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8774bbf91..df417b4d9 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -514,7 +514,8 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptrdata() || !anObject->data()->isValid()) + // we should not display disabled objects + if (!anObject->data() || !anObject->data()->isValid() || anObject->isDisabled()) continue; //ResultPartPtr aPart = std::dynamic_pointer_cast(*aIt); //if (aPart) { -- 2.39.2