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.
#include <GeomAlgoAPI_Boolean.h>
using namespace std;
-//#define DEBUG_ONE_OBJECT
+#define DEBUG_ONE_OBJECT
#define FACE 4
#define _MODIFY_TAG 1
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <!--<shape_selector id="main_object"
- label="Main object"
- icon=":icons/cut_shape.png"
- tooltip="Select an object solid"
- shape_types="solid shell"
- concealment="true"
- />-->
- <multi_selector id="main_objects"
+ <!--<multi_selector id="main_objects"
label="Main object"
icon=":icons/cut_shape.png"
tooltip="Select an object solid"
type_choice="Solids"
concealment="true" >
<validator id="PartSet_DifferentObjects"/>
- </multi_selector>
- <!--<shape_selector id="tool_object"
+ </multi_selector>-->
+ <shape_selector id="main_object"
+ label="Main object"
+ icon=":icons/cut_shape.png"
+ tooltip="Select an object solid"
+ shape_types="solid shell"
+ concealment="true"
+ />
+ <shape_selector id="tool_object"
label="Tool object"
icon=":icons/cut_tool.png"
tooltip="Select a tool solid"
shape_types="solid"
concealment="true" >
<validator id="PartSet_DifferentObjects"/>
- </shape_selector>-->
+ </shape_selector>
<choice id="bool_type"
label="Type"
tooltip="Type of boolean operation"
#include <QBitmap>
#include <QDoubleSpinBox>
+#include <sstream>
+
namespace ModuleBase_Tools {
//******************************************************************
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<ModelAPI_Result>(theObj);
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(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<AttributePtr> anAttrs = aFeature->data()->attributes("");
std::list<AttributePtr>::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end();
#include <ModelAPI_AttributeIntArray.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_Tools.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
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<GeomAPI_IPresentable>(theObject);
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
- myResult2AISObjectMap[theObject] = theAIS;
+ appendResultObject(theObject, theAIS);
+
bool aCanBeShaded = ::canBeShaded(anAISIO);
// In order to avoid extra closing/opening context
SelectMgr_IndexedMapOfOwner aSelectedOwners;
return;
}
if (aAIS_Obj != aAISObj) {
- myResult2AISObjectMap[theObject] = aAIS_Obj;
+ appendResultObject(theObject, aAIS_Obj);
}
aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
}
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();
+}
*/
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;
ObjectPtr anObject = *aIt;
// the validity of the data should be checked here in order to avoid display of the objects,
// which were created, then deleted, but flush for the creation event happens after that
- if (!anObject->data() || !anObject->data()->isValid())
+ // we should not display disabled objects
+ if (!anObject->data() || !anObject->data()->isValid() || anObject->isDisabled())
continue;
//ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
//if (aPart) {