From 27d2715cfb1c7f294960bf1e094a1532cd016052 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 5 Dec 2013 09:35:02 +0000 Subject: [PATCH] Bug 158: Crash in profile edition --- src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 47 ++++++++++++++-------------- src/HYDROGUI/HYDROGUI_ProfileDlg.h | 4 +-- src/HYDROGUI/HYDROGUI_ProfileOp.cxx | 3 -- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index e05d4739..7af6f434 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -63,31 +63,30 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr anAddElementLayout->setMargin( 0 ); anAddElementLayout->setSpacing( 5 ); - - OCCViewer_ViewManager* aViewMgr = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); - myViewer = new OCCViewer_Viewer( true ); + myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); + OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( true ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - myViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT, - aResMgr->backgroundValue( "OCCViewer", "xz_background", myViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) ); - myViewer->setBackground( OCCViewer_ViewFrame::TOP_RIGHT, - aResMgr->backgroundValue( "OCCViewer", "yz_background", myViewer->background(OCCViewer_ViewFrame::TOP_RIGHT) ) ); - myViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT, - aResMgr->backgroundValue( "OCCViewer", "xy_background", myViewer->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) ); - myViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT, - aResMgr->backgroundValue( "OCCViewer", "background", myViewer->background(OCCViewer_ViewFrame::MAIN_VIEW) ) ); - - myViewer->setTrihedronSize( aResMgr->doubleValue( "3DViewer", "trihedron_size", myViewer->trihedronSize() ), - aResMgr->booleanValue( "3DViewer", "relative_size", myViewer->trihedronRelative() )); - myViewer->setInteractionStyle( aResMgr->integerValue( "3DViewer", "navigation_mode", myViewer->interactionStyle() ) ); - myViewer->setZoomingStyle( aResMgr->integerValue( "3DViewer", "zooming_mode", myViewer->zoomingStyle() ) ); - myViewer->enablePreselection( aResMgr->booleanValue( "OCCViewer", "enable_preselection", myViewer->isPreselectionEnabled() ) ); - myViewer->enableSelection( aResMgr->booleanValue( "OCCViewer", "enable_selection", myViewer->isSelectionEnabled() ) ); - - aViewMgr->setViewModel( myViewer );// custom view model, which extends SALOME_View interface - SUIT_ViewWindow* aViewWin = aViewMgr->createViewWindow(); + aViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT, + aResMgr->backgroundValue( "OCCViewer", "xz_background", aViewer->background(OCCViewer_ViewFrame::TOP_LEFT) ) ); + aViewer->setBackground( OCCViewer_ViewFrame::TOP_RIGHT, + aResMgr->backgroundValue( "OCCViewer", "yz_background", aViewer->background(OCCViewer_ViewFrame::TOP_RIGHT) ) ); + aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT, + aResMgr->backgroundValue( "OCCViewer", "xy_background", aViewer->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) ); + aViewer->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT, + aResMgr->backgroundValue( "OCCViewer", "background", aViewer->background(OCCViewer_ViewFrame::MAIN_VIEW) ) ); + + aViewer->setTrihedronSize( aResMgr->doubleValue( "3DViewer", "trihedron_size", aViewer->trihedronSize() ), + aResMgr->booleanValue( "3DViewer", "relative_size", aViewer->trihedronRelative() )); + aViewer->setInteractionStyle( aResMgr->integerValue( "3DViewer", "navigation_mode", aViewer->interactionStyle() ) ); + aViewer->setZoomingStyle( aResMgr->integerValue( "3DViewer", "zooming_mode", aViewer->zoomingStyle() ) ); + aViewer->enablePreselection( aResMgr->booleanValue( "OCCViewer", "enable_preselection", aViewer->isPreselectionEnabled() ) ); + aViewer->enableSelection( aResMgr->booleanValue( "OCCViewer", "enable_selection", aViewer->isSelectionEnabled() ) ); + + myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface + SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow(); addWidget( aViewWin, 4 ); - myEditorWidget->setOCCViewer( myViewer ); + myEditorWidget->setOCCViewer( aViewer ); connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*) ), this, SLOT( processStartedSubOperation(QWidget*) ) ); @@ -98,6 +97,7 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg() { + delete myViewManager; } void HYDROGUI_ProfileDlg::reset() @@ -107,7 +107,8 @@ void HYDROGUI_ProfileDlg::reset() Handle(AIS_InteractiveContext) HYDROGUI_ProfileDlg::getAISContext() { - return myViewer->getAISContext(); + OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)myViewManager->getViewModel(); + return aViewer ? aViewer->getAISContext() : 0; } void HYDROGUI_ProfileDlg::setProfileName( const QString& theName ) diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.h b/src/HYDROGUI/HYDROGUI_ProfileDlg.h index 96f37e7d..f4c76056 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.h +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.h @@ -30,7 +30,7 @@ class QLineEdit; class CurveCreator_Widget; class CurveCreator_ICurve; -class OCCViewer_Viewer; +class OCCViewer_ViewManager; class QGroupBox; class HYDROGUI_ProfileDlg : public HYDROGUI_InputPanel @@ -70,7 +70,7 @@ private: QLineEdit* myName; CurveCreator_Widget* myEditorWidget; QGroupBox* myAddElementBox; - OCCViewer_Viewer* myViewer; + OCCViewer_ViewManager* myViewManager; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 6ed7bd15..386e914a 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -200,9 +200,6 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, } aProfileObj->SetParametricPoints( aProfileParamPoints ); - if( !myIsEdit ) - module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aProfileObj, true ); - theUpdateFlags = UF_Model; return true; } -- 2.39.2