#include <XGUI_ContextMenuMgr.h>
#include <XGUI_ObjectsBrowser.h>
#include <XGUI_OperationMgr.h>
+#include <XGUI_Displayer.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_Preferences.h>
//******************************************************
void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr)
{
- if ((!mySelector)) {
+ if (!mySelector) {
mySelector = createSelector(theMgr);
}
}
+//******************************************************
+void NewGeom_Module::onViewManagerRemoved(SUIT_ViewManager* theMgr)
+{
+ if (mySelector) {
+ if (theMgr->getType() == OCCViewer_Viewer::Type()) {
+ OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
+ if (mySelector->viewer() == aViewer) {
+ myWorkshop->displayer()->eraseAll(false);
+ myProxyViewer->setSelector(0);
+ delete mySelector;
+ mySelector = 0;
+ }
+ }
+ }
+}
+
//******************************************************
QtxPopupMgr* NewGeom_Module::popupMgr()
{
protected slots:
virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
+ virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
+
void onDefaultPreferences();
// Obtains the current application and updates its actions
void onUpdateCommandStatus();
//**********************************************
Handle(V3d_Viewer) NewGeom_SalomeViewer::v3dViewer() const
{
- return mySelector->viewer()->getViewer3d();
+ if (mySelector)
+ return mySelector->viewer()->getViewer3d();
+ return Handle(V3d_Viewer)();
}
//**********************************************
Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
{
- OCCViewer_Viewer* aViewer = mySelector->viewer();
- SUIT_ViewManager* aMgr = aViewer->getViewManager();
- OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
- return aWnd->getViewPort()->getView();
+ if (mySelector) {
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ SUIT_ViewManager* aMgr = aViewer->getViewManager();
+ OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
+ return aWnd->getViewPort()->getView();
+ }
+ return Handle(V3d_View)();
}
//**********************************************
//mySelector->viewer()->enableSelection(isEnabled);
// The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
// After this is corrected, the first row should be recommented, the last - removed
- mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
- : SUIT_ViewModel::KEY_FREE);
+ if (mySelector)
+ mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+ : SUIT_ViewModel::KEY_FREE);
}
//**********************************************
bool NewGeom_SalomeViewer::isSelectionEnabled() const
{
- return mySelector->viewer()->isSelectionEnabled();
+ if (mySelector)
+ return mySelector->viewer()->isSelectionEnabled();
}
//**********************************************
void NewGeom_SalomeViewer::enableMultiselection(bool isEnable)
{
- mySelector->viewer()->enableMultiselection(isEnable);
+ if (mySelector)
+ mySelector->viewer()->enableMultiselection(isEnable);
}
//**********************************************
bool NewGeom_SalomeViewer::isMultiSelectionEnabled() const
{
- return mySelector->viewer()->isMultiSelectionEnabled();
+ if (mySelector)
+ return mySelector->viewer()->isMultiSelectionEnabled();
+ return false;
}
//**********************************************
void NewGeom_SalomeViewer::fitAll()
{
- SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
- OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
- if (aVFrame) {
- aVFrame->onFitAll();
+ if (mySelector) {
+ SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+ OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
+ if (aVFrame) {
+ aVFrame->onFitAll();
+ }
}
}
//**********************************************
void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ)
{
+ if (!mySelector)
+ return;
+
SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
if (aVFrame) {
// the selection is cleared after commit the create operation
// in order to do not use the same selected objects in the restarted operation
// for common behaviour, the selection is cleared even if the operation is not restarted
- myWorkshop->viewer()->AISContext()->ClearSelected();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ if (!aContext.IsNull())
+ aContext->ClearSelected();
/// Restart sketcher operations automatically
FeaturePtr aFeature = theOperation->feature();
}
myActiveSelectionModes = aNewModes;
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
// Open local context if there is no one
if (!aContext->HasOpenedContext())
return;
void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext.IsNull())
- return;
-
+ if (!aContext.IsNull()) {
foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
// erase an object
Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anIO.IsNull())
aContext->Remove(anIO, false);
}
- myResult2AISObjectMap.clear();
if (isUpdateViewer)
updateViewer();
- }
+ }
+ myResult2AISObjectMap.clear();
+}
void XGUI_Displayer::openLocalContext()
{
void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
aContext->Display(anAISIO, isUpdate);
void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
aContext->Remove(anAISIO, isUpdate);
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ if (aContext.IsNull())
+ return aPresentations;
+
if (aContext->HasOpenedContext()) {
for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
ModuleBase_ViewerPrs aPrs;
QObjectPtrList aSelectedList;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
- Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
- ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
- if (aResult)
- aSelectedList.append(aResult);
+ if (!aContext.IsNull()) {
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+ ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
+ if (aResult)
+ aSelectedList.append(aResult);
+ }
}
return aSelectedList;
}