#include <ModuleBase_ParamIntSpinBox.h>
#include <ModuleBase_ParamSpinBox.h>
+#include <ModuleBase_Preferences.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IModule.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeRefAttrList.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeString.h>
#include <ModelGeomAlgo_Point2D.h>
+#ifdef HAVE_SALOME
+#include <SUIT_Application.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#endif
+
#include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Iterator.hxx>
#include <AIS_InteractiveContext.hxx>
//******************************************************************
+ //! Waits for REDISPLAY message and set the Visible flag to the entities
+ //! according to Preferences choice.
+ class ModuleBase_RedisplayListener : public Events_Listener
+ {
+ public:
+ static std::shared_ptr<ModuleBase_RedisplayListener> instance()
+ {
+ static std::shared_ptr<ModuleBase_RedisplayListener>
+ anInstance(new ModuleBase_RedisplayListener);
+ return anInstance;
+ }
+
+ void processEvent(const std::shared_ptr<Events_Message>& theMessage)
+ {
+ if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY))
+ {
+#if HAVE_SALOME
+ // If the python script is being loaded now, the preferences should be used
+ // to display the required object
+ SUIT_Application * app = SUIT_Session::session()->activeApplication();
+ QVariant aVar = app->property("IsLoadedScript");
+ if (!aVar.isNull() && aVar.toBool()) {
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
+ if (aSize > 0) {
+ ObjectPtr anPartObject = aRootDoc->object(ModelAPI_ResultPart::group(), aSize - 1);
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anPartObject);
+ ModuleBase_Tools::setDisplaying(aPart, true);
+ }
+ }
+#endif
+ }
+ }
+
+ private:
+ ModuleBase_RedisplayListener()
+ {
+ Events_Loop::loop()->registerListener(this,
+ Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ }
+ };
+
+ static std::shared_ptr<ModuleBase_RedisplayListener>
+ RL = ModuleBase_RedisplayListener::instance();
+
//******************************************************************
void adjustMargins(QWidget* theWidget)
}
+// Set displaying status to every element on group
+static void setDisplayingByLoop(DocumentPtr theDoc, int theSize,
+ std::string theGroup, bool theDisplayFromScript)
+{
+ int aDisplayingId = -1;
+ if (theDisplayFromScript) {
+ aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
+ "part_visualization_script", -1);
+ // Increase ID to prevert using "As stored in HDF"
+ ++aDisplayingId;
+ }
+ else {
+ aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
+ "part_visualization_study", -1);
+
+ // if chosen "As stored in HDF" then don't change displaying
+ if (aDisplayingId == 0)
+ return;
+ }
+
+ for (int anIndex = theSize - 1; anIndex >= 0; --anIndex) {
+ ObjectPtr anObject = theDoc->object(theGroup, anIndex);
+ anObject->setDisplayed((aDisplayingId == 1 && anIndex == theSize - 1) || aDisplayingId == 2);
+ }
+}
+
+void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript)
+{
+ DocumentPtr aDoc = thePart->partDoc();
+ int aConstructionSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ int aGroupSize = aDoc->size(ModelAPI_ResultGroup::group());
+ int aFieldSize = aDoc->size(ModelAPI_ResultField::group());
+ int aResultSize = aDoc->size(ModelAPI_ResultBody::group());
+ setDisplayingByLoop(aDoc, aConstructionSize,
+ ModelAPI_ResultConstruction::group(), theDisplayFromScript);
+ setDisplayingByLoop(aDoc, aGroupSize, ModelAPI_ResultGroup::group(), theDisplayFromScript);
+ setDisplayingByLoop(aDoc, aFieldSize, ModelAPI_ResultField::group(), theDisplayFromScript);
+ setDisplayingByLoop(aDoc, aResultSize, ModelAPI_ResultBody::group(), theDisplayFromScript);
+}
+
} // namespace ModuleBase_Tools
/// Returns pixel ratio of a screen where main window is displayed
qreal MODULEBASE_EXPORT currentPixelRatio();
+
+/// Set displaying status for elements from part depending on the settings
+/// \param thePart a pointer of part
+void MODULEBASE_EXPORT setDisplaying(std::shared_ptr<ModelAPI_ResultPart> thePart,
+ bool theDisplayFromScript = false);
}
#endif
if (isFirstLoad) {
XGUI_Workshop* aWorkshop = myModule->getWorkshop();
XGUI_ObjectsBrowser* aObjBrowser = aWorkshop->objectBrowser();
- XGUI_Tools::setDisplaying(thePart);
+ ModuleBase_Tools::setDisplaying(thePart);
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aObjBrowser->onSelectionChanged();
DocumentPtr aDoc = thePart->partDoc();
#include "ModuleBase_IWorkshop.h"
#include "ModuleBase_Tools.h"
-#include "ModuleBase_Preferences.h"
#include <TopoDS_Shape.hxx>
#include <ModelAPI_Object.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultField.h>
#include <Events_InfoMessage.h>
-#include <SUIT_ResourceMgr.h>
-
#include <GeomAPI_Shape.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
}
}
-// Set displaying status to every element on group
-static void setDisplayingByLoop(DocumentPtr theDoc, int theSize,
- std::string theGroup, bool theDisplayFromScript)
-{
- int aDisplayingId = -1;
- if (theDisplayFromScript) {
- aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
- "part_visualization_script", -1);
- // Increase ID to prevert using "As stored in HDF"
- ++aDisplayingId;
- }
- else {
- aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
- "part_visualization_study", -1);
-
- // if chosen "As stored in HDF" then don't change displaying
- if (aDisplayingId == 0)
- return;
- }
-
- for (int anIndex = theSize - 1; anIndex >= 0; --anIndex) {
- ObjectPtr anObject = theDoc->object(theGroup, anIndex);
- anObject->setDisplayed((aDisplayingId == 1 && anIndex == theSize - 1) || aDisplayingId == 2);
- }
-}
-
-void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript)
-{
- DocumentPtr aDoc = thePart->partDoc();
- int aConstructionSize = aDoc->size(ModelAPI_ResultConstruction::group());
- int aGroupSize = aDoc->size(ModelAPI_ResultGroup::group());
- int aFieldSize = aDoc->size(ModelAPI_ResultField::group());
- int aResultSize = aDoc->size(ModelAPI_ResultBody::group());
- setDisplayingByLoop(aDoc, aConstructionSize,
- ModelAPI_ResultConstruction::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aGroupSize, ModelAPI_ResultGroup::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aFieldSize, ModelAPI_ResultField::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aResultSize, ModelAPI_ResultBody::group(), theDisplayFromScript);
-}
-
}
#include <QRect>
#include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultPart.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Definitions.h>
/// Removes files and directory where they are located
void removeTemporaryFiles(const std::string& theDirectory,
const std::list<std::string>& theFiles);
-
-/// Set displaying status for elements from part depending on the settings
-/// \param thePart a pointer of part
-XGUI_EXPORT void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript = false);
};
#endif
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anObject);
if (aPart.get()) {
aPart->activate();
- XGUI_Tools::setDisplaying(aPart);
+ ModuleBase_Tools::setDisplaying(aPart);
}
}
else if (anActivationId == 1) {
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anObject);
if (aPart.get()) {
aPart->activate();
- XGUI_Tools::setDisplaying(aPart);
+ ModuleBase_Tools::setDisplaying(aPart);
if (anIndex < aSize - 1) {
SessionPtr aMgr = ModelAPI_Session::get();
#include "XGUI_QtEvents.h"
#include "XGUI_SalomeConnector.h"
#include "XGUI_SelectionMgr.h"
-#include "XGUI_Tools.h"
#include "XGUI_Workshop.h"
#include <QAction>
}
}
- // If the python script is being loaded now, the preferences should be used
- // to display the required object
- SUIT_Application * app = SUIT_Session::session()->activeApplication();
- QVariant aVar = app->property("IsLoadedScript");
- if (!aVar.isNull() && aVar.toBool()) {
- DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
- if (aSize > 0) {
- ObjectPtr anPartObject = aRootDoc->object(ModelAPI_ResultPart::group(), aSize - 1);
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anPartObject);
- XGUI_Tools::setDisplaying(aPart, true);
- }
- }
-
// this processing should be moved in another place in order to do not cause problems in
// flush messages chain
//if (aHiddenObjects.size() > 0)