bool aErased = false;
Handle(AIS_InteractiveContext) aContext = AISContext();
if (!aContext.IsNull()) {
- foreach (ObjectPtr aObj, myResult2AISObjectMap.objects()) {
+#ifdef OPTIMIZE_PRS
+ foreach(ObjectPtr aObj, myResult2AISObjectMap.objects()) {
AISObjectPtr aAISObj = myResult2AISObjectMap.value(aObj);
+#else
+ foreach(ObjectPtr aObj, myResult2AISObjectMap.keys()) {
+ AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
+#endif
// erase an object
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull()) {
//**************************************************************
AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
{
+#ifdef OPTIMIZE_PRS
return myResult2AISObjectMap.value(theObject);
+#else
+ AISObjectPtr anIO;
+ if (myResult2AISObjectMap.contains(theObject))
+ anIO = myResult2AISObjectMap[theObject];
+ return anIO;
+#endif
}
//**************************************************************
//**************************************************************
ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
{
+#ifdef OPTIMIZE_PRS
ObjectPtr anObject = myResult2AISObjectMap.value(theIO);
+#else
+ ObjectPtr anObject;
+ ResultToAISMap::const_iterator aMapIter = myResult2AISObjectMap.cbegin();
+ for (; aMapIter != myResult2AISObjectMap.cend(); aMapIter++) {
+ const AISObjectPtr& aAIS = aMapIter.value();
+ Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (anAIS == theIO)
+ anObject = aMapIter.key();
+ if (anObject.get())
+ break;
+ }
+#endif
if (!anObject.get()) {
std::shared_ptr<GeomAPI_AISObject> anAISObj = AISObjectPtr(new GeomAPI_AISObject());
if (!theIO.IsNull()) {
//**************************************************************
void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
{
+#ifdef OPTIMIZE_PRS
QObjectPtrList aDispList = myResult2AISObjectMap.objects();
+#else
+ QObjectPtrList aDispList = myResult2AISObjectMap.keys();
+#endif
foreach(ObjectPtr aObj, aDispList) {
if (!theList.contains(aObj))
erase(aObj, false);
//**************************************************************
void XGUI_Displayer::appendResultObject(ObjectPtr theObject, AISObjectPtr theAIS)
{
+#ifdef OPTIMIZE_PRS
myResult2AISObjectMap.add(theObject, theAIS);
+#else
+ myResult2AISObjectMap[theObject] = theAIS;
+#endif
#ifdef DEBUG_DISPLAY
std::ostringstream aPtrStr;
std::string XGUI_Displayer::getResult2AISObjectMapInfo() const
{
QStringList aContent;
- foreach (ObjectPtr aObj, myResult2AISObjectMap.objects()) {
+#ifdef OPTIMIZE_PRS
+ foreach(ObjectPtr aObj, myResult2AISObjectMap.objects()) {
AISObjectPtr aAISObj = myResult2AISObjectMap.value(aObj);
+#else
+ foreach(ObjectPtr aObj, myResult2AISObjectMap.keys()) {
+ AISObjectPtr aAISObj = myResult2AISObjectMap[aObj];
+#endif
std::ostringstream aPtrStr;
aPtrStr << "aObj = " << aObj.get() << ":";
aPtrStr << "anAIS = " << aAISObj.get() << ":";
#endif
+#ifdef OPTIMIZE_PRS
class XGUI_TwoSidePresentationMap
{
public:
QMap<ObjectPtr, Handle(AIS_InteractiveObject)> myResultToAISMap;
QMap<Handle(AIS_InteractiveObject), ObjectPtr> myAIStoResultMap;
};
+#endif
/**\class XGUI_Displayer
* \ingroup GUI
* \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
*/
-class XGUI_EXPORT XGUI_Displayer: public QObject
+class XGUI_EXPORT XGUI_Displayer : public QObject
{
Q_OBJECT
- public:
- /// \enum DisplayMode display mode
- enum DisplayMode {
- NoMode = -1, ///< Mode is not defined
- Wireframe, ///< Wireframe display mode
- Shading ///< Shading display mode
- };
+public:
+ /// \enum DisplayMode display mode
+ enum DisplayMode {
+ NoMode = -1, ///< Mode is not defined
+ Wireframe, ///< Wireframe display mode
+ Shading ///< Shading display mode
+ };
/// Constructor
/// \param theWorkshop a workshop instance
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
/// \return true if the object visibility state is changed
bool displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
- const Standard_Integer theDisplayMode = 0, bool theUpdateViewer = true);
+ const Standard_Integer theDisplayMode = 0, bool theUpdateViewer = true);
/// Redisplay the shape if it was displayed
/// \param theObject an object instance
/// \param theValues a list of presentation to be selected
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
- bool theUpdateViewer = true);
+ bool theUpdateViewer = true);
/// Unselect all objects
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
/// \param theObjList - list of objects which has to be deactivated.
/// \param theUpdateViewer update viewer flag
void deactivateObjects(const QObjectPtrList& theObjList,
- const bool theUpdateViewer = true);
+ const bool theUpdateViewer = true);
/// Sets display mode for the given object if this object is displayed
void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool theUpdateViewer = true);
int objectsCount() const { return myResult2AISObjectMap.size(); }
/// Returns list of displayed objects
- QObjectPtrList displayedObjects() const { return myResult2AISObjectMap.objects(); }
+ QObjectPtrList displayedObjects() const {
+#ifdef OPTIMIZE_PRS
+ return myResult2AISObjectMap.objects();
+#else
+ return myResult2AISObjectMap.keys();
+#endif
+ }
/// Returns list of displayed objects
+#ifdef OPTIMIZE_PRS
QList<Handle(AIS_InteractiveObject)> displayedPresentations() const
{
return myResult2AISObjectMap.presentations();
}
+#else
+ QList<AISObjectPtr> displayedPresentations() const
+ {
+ return myResult2AISObjectMap.values();
+ }
+#endif
/// Returns true if the given object can be shown in shaded mode
/// \param theObject object to check
GeomCustomPrsPtr myCustomPrs;
/// Definition of a type of map which defines correspondance between objects and presentations
+#ifdef OPTIMIZE_PRS
XGUI_TwoSidePresentationMap myResult2AISObjectMap; ///< A map of displayed objects
+#else
+ typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
+ ResultToAISMap myResult2AISObjectMap; ///< A map of displayed objects
+#endif
/// Number of blocking of the viewer update. The viewer is updated only if it is zero
int myViewerBlockedRecursiveCount;