Handle of operation presentation should be nullified when study is closed.
/// Returns data model object for representation of data tree in Object browser\r
virtual ModuleBase_IDocumentDataModel* dataModel() const = 0;\r
\r
+ virtual void closeDocument() = 0;\r
+\r
/// Returns a list of modes, where the AIS objects should be activated\r
/// \param theModes a list of modes\r
virtual void activeSelectionModes(QIntList& theModes) {}\r
/// If the operation works with feature which is sub-feature of another one
/// then this variable has to be initialised by parent feature
/// before operation feature creating
- CompositeFeaturePtr myParentFeature;
+ CompositeFeaturePtr myParentFeature;
/// Last current feature before editing operation. It is cashed when Edit operation is started
/// in order to restore the document current feature on commit/abort this operation.
PartSet_CustomPrs::PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop)
: myWorkshop(theWorkshop)
{
- myOperationPrs = AISObjectPtr(new GeomAPI_AISObject());
- myOperationPrs->setImpl(new Handle(AIS_InteractiveObject)(new PartSet_OperationPrs(theWorkshop)));
-
- std::vector<int> aColor = Config_PropManager::color("Visualization", "operation_parameter_color",
- OPERATION_PARAMETER_COLOR);
- myOperationPrs->setColor(aColor[0], aColor[1], aColor[2]);
-
- myOperationPrs->setPointMarker(5, 2.);
- myOperationPrs->setWidth(1);
+ initPrs();
}
-bool PartSet_CustomPrs::isActive() const
+bool PartSet_CustomPrs::isActive()
{
Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext->IsDisplayed(anOperationPrs)) {
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
- aContext->Display(anOperationPrs);
+
+ XGUI_Workshop* aWorkshop = workshop();
+ aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, true);
aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
}
else
void PartSet_CustomPrs::erasePresentation()
{
- Handle(AIS_InteractiveObject) anOperationPrs = myOperationPrs->impl<Handle(AIS_InteractiveObject)>();
- Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
- if (aContext->IsDisplayed(anOperationPrs))
- aContext->Remove(anOperationPrs);
+ XGUI_Workshop* aWorkshop = workshop();
+ aWorkshop->displayer()->eraseAIS(myOperationPrs, true);
}
-Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation() const
+Handle(PartSet_OperationPrs) PartSet_CustomPrs::getPresentation()
{
+ if (!myOperationPrs.get())
+ initPrs();
Handle(AIS_InteractiveObject) anAISIO = myOperationPrs->impl<Handle(AIS_InteractiveObject)>();
return Handle(PartSet_OperationPrs)::DownCast(anAISIO);
}
anOperationPrs->Redisplay();
}
}
+
+void PartSet_CustomPrs::clearPrs()
+{
+ Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+ if (!anOperationPrs.IsNull())
+ anOperationPrs.Nullify();
+
+ myOperationPrs = 0;
+}
+
+void PartSet_CustomPrs::initPrs()
+{
+ myOperationPrs = AISObjectPtr(new GeomAPI_AISObject());
+ myOperationPrs->setImpl(new Handle(AIS_InteractiveObject)(new PartSet_OperationPrs(myWorkshop)));
+
+ std::vector<int> aColor = Config_PropManager::color("Visualization", "operation_parameter_color",
+ OPERATION_PARAMETER_COLOR);
+ myOperationPrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+ myOperationPrs->setPointMarker(5, 2.);
+ myOperationPrs->setWidth(1);
+}
+
+XGUI_Workshop* PartSet_CustomPrs::workshop() const
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+ return aConnector->workshop();
+}
#include <GeomAPI_Shape.h>
class ModuleBase_IWorkshop;
+class XGUI_Workshop;
/**
* Interface of a class which can provide specific customization of
PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
/// Returns true if the presentation is active
- bool isActive() const;
+ bool isActive();
/// Initializes the presentation by the parameter object
void activate(const FeaturePtr& theObject);
/// Modifies the given presentation in the custom way.
void customize(const ObjectPtr& theObject);
+ void clearPrs();
+
+ void initPrs();
+
private:
/// Returns the AIS presentation
- Handle(PartSet_OperationPrs) getPresentation() const;
+ Handle(PartSet_OperationPrs) getPresentation();
+
+ //! Returns workshop
+ XGUI_Workshop* workshop() const;
/// Displays the internal presentation in the viewer of workshop
void displayPresentation();
return mySketchMgr->isMouseOverWindow();
}
+void PartSet_Module::closeDocument()
+{
+ myCustomPrs->clearPrs();
+}
+
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
/// Returns data model object for representation of data tree in Object browser
virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
+ virtual void closeDocument();
+
/// Event Listener method
/// \param theMessage an event message
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB);
}
XGUI_Displayer* aDisp = workshop()->displayer();
- aDisp->displayAIS(myYZPlane, false);
- aDisp->displayAIS(myXZPlane, false);
- aDisp->displayAIS(myXYPlane, false);
+ aDisp->displayAIS(myYZPlane, true, false);
+ aDisp->displayAIS(myXZPlane, true, false);
+ aDisp->displayAIS(myXYPlane, true, false);
myPreviewDisplayed = true;
}
//aContext->ClearSelected();
aContext->CloseAllContexts(false);
+ // From the moment when the AIS_DS_Displayed flag is used in the Display of AIS object,
+ // this code is obsolete. It is temporaty commented and should be removed after
+ // the test campaign.
// Redisplay all object if they were displayed in localContext
- Handle(AIS_InteractiveObject) aAISIO;
+ /*Handle(AIS_InteractiveObject) aAISIO;
foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
aContext->Display(aAISIO, false);
aContext->SetDisplayMode(aAISIO, Shading, false);
}
- }
+ }*/
// Append the filters from the local selection in the global selection context
SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
return myAndFilter;
}
-void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool theUpdateViewer)
+void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
+ bool theUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
if (aContext.IsNull())
return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
- aContext->Display(anAISIO, theUpdateViewer);
- if (aContext->HasOpenedContext()) {
- if (myActiveSelectionModes.size() == 0)
- activateAIS(anAISIO, 0, theUpdateViewer);
- else {
- foreach(int aMode, myActiveSelectionModes) {
- activateAIS(anAISIO, aMode, theUpdateViewer);
+ aContext->Display(anAISIO, 0/*wireframe*/, 0, theUpdateViewer, true, AIS_DS_Displayed);
+ aContext->Deactivate(anAISIO);
+ aContext->Load(anAISIO);
+ if (toActivateInSelectionModes) {
+ if (aContext->HasOpenedContext()) {
+ if (myActiveSelectionModes.size() == 0)
+ activateAIS(anAISIO, 0, theUpdateViewer);
+ else {
+ foreach(int aMode, myActiveSelectionModes) {
+ activateAIS(anAISIO, aMode, theUpdateViewer);
+ }
}
}
}
if (aContext.IsNull())
return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
- if (!anAISIO.IsNull()) {
+ if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) {
aContext->Remove(anAISIO, theUpdateViewer);
}
}
/// Returns true if the Feature succesfully displayed
void display(ObjectPtr theObject, bool theUpdateViewer = true);
- /// Display the given AIS object. To hide this object use corresponde erase method
+ /// Display the given AIS object. This object is not added to the displayer internal map of objects
+ /// So, it can not be obtained from displayer. This is just a wrap method of OCC display in order
+ /// to perform the display with correct flags.
/// \param theAIS AIOS object to display
+ /// \param toActivateInSelectionModes boolean value whether the presentation should be
+ /// activated in the current selection modes
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
- void displayAIS(AISObjectPtr theAIS, bool theUpdateViewer = true);
+ void displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
+ bool theUpdateViewer = true);
/** Redisplay the shape if it was displayed
* \param theObject an object instance
myDisplayer->eraseAll();
objectBrowser()->clearContent();
+ module()->closeDocument();
+
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->closeAll();
}