From cdeebde6da5aa63733241cc889ed7c2d740aaead Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 24 Oct 2005 08:21:31 +0000 Subject: [PATCH] Fix for bugs 10287, 9986: SIGSEGV in VISU on Views management --- src/VISU_I/VISU_TimeAnimation.cxx | 4 +- src/VISU_I/VISU_View_i.cc | 738 ++++++++++++++++++------------ src/VISU_I/VISU_View_i.hh | 67 +-- 3 files changed, 473 insertions(+), 336 deletions(-) diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 46ec8a89..95b90d5b 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -59,9 +59,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, if (!CORBA::is_nil(theView3D)) { VISU::View3D_i* pView = dynamic_cast(GetServant(theView3D).in()); - //QAD_StudyFrame* aStudyFrame = pView->GetStudyFrame(); - //myView = VISU::GetViewFrame(aStudyFrame); - SUIT_ViewWindow* aVW = pView->myViewWindow; + SUIT_ViewWindow* aVW = pView->GetViewWindow(); myView = VISU::GetViewWindow(aVW); } diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index b927adb1..e655eac9 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -212,7 +212,7 @@ namespace VISU { struct TSplitEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; Qt::Orientation myOrientation; QtxWorkstack::SplitType mySplitType; @@ -222,7 +222,7 @@ namespace VISU { Qt::Orientation theOrientation, QtxWorkstack::SplitType theSplitType): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myOrientation(theOrientation), mySplitType(theSplitType) {} @@ -234,7 +234,7 @@ namespace VISU { if (tabDesk) { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { - workstack->Split(myViewWindow, myOrientation, mySplitType); + workstack->Split(myVW, myOrientation, mySplitType); } } } @@ -244,32 +244,40 @@ namespace VISU { View_i:: SplitRight() { - ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow, - Qt::Horizontal,QtxWorkstack::SPLIT_MOVE)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSplitEvent(myApplication, aVW, + Qt::Horizontal, QtxWorkstack::SPLIT_MOVE)); } void View_i:: SplitLeft() { - ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow, - Qt::Horizontal,QtxWorkstack::SPLIT_STAY)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSplitEvent(myApplication, aVW, + Qt::Horizontal, QtxWorkstack::SPLIT_STAY)); } void View_i:: SplitBottom() { - ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow, - Qt::Vertical,QtxWorkstack::SPLIT_MOVE)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSplitEvent(myApplication, aVW, + Qt::Vertical, QtxWorkstack::SPLIT_MOVE)); } void View_i:: SplitTop() { - ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow, - Qt::Vertical,QtxWorkstack::SPLIT_STAY)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSplitEvent(myApplication, aVW, + Qt::Vertical, QtxWorkstack::SPLIT_STAY)); } void @@ -278,29 +286,31 @@ namespace VISU { { struct TOnTopEvent: public SALOME_Event { - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; public: TOnTopEvent (SUIT_ViewWindow * theViewWindow): - myViewWindow(theViewWindow) + myVW(theViewWindow) {} virtual void Execute() { - if (myViewWindow) { - myViewWindow->setFocus(); + if (myVW) { + myVW->setFocus(); } } }; - ProcessVoidEvent(new TOnTopEvent(myViewWindow)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TOnTopEvent(aVW)); } struct TAttractEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow1; - SUIT_ViewWindow * myViewWindow2; + SUIT_ViewWindow * myVW1; + SUIT_ViewWindow * myVW2; bool myAttractAll; public: @@ -309,8 +319,8 @@ namespace VISU { SUIT_ViewWindow * theViewWindow2, bool theAttractAll): myApplication(theApplication), - myViewWindow1(theViewWindow1), - myViewWindow2(theViewWindow2), + myVW1(theViewWindow1), + myVW2(theViewWindow2), myAttractAll(theAttractAll) {} @@ -321,7 +331,7 @@ namespace VISU { if (tabDesk) { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { - workstack->Attract(myViewWindow1, myViewWindow2, myAttractAll); + workstack->Attract(myVW1, myVW2, myAttractAll); } } } @@ -333,7 +343,12 @@ namespace VISU { { if (!CORBA::is_nil(theView)) { if (VISU::View_i* pView = dynamic_cast(VISU::GetServant(theView).in())) { - ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,false)); + if (pView) { + SUIT_ViewWindow* aVW1 = GetViewWindow(); + SUIT_ViewWindow* aVW2 = pView->GetViewWindow(); + if (aVW1 && aVW2) + ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false)); + } } } } @@ -344,7 +359,12 @@ namespace VISU { { if (!CORBA::is_nil(theView)) { if (VISU::View_i* pView = dynamic_cast(VISU::GetServant(theView).in())) { - ProcessVoidEvent(new TAttractEvent(myApplication,myViewWindow,pView->myViewWindow,true)); + if (pView) { + SUIT_ViewWindow* aVW1 = GetViewWindow(); + SUIT_ViewWindow* aVW2 = pView->GetViewWindow(); + if (aVW1 && aVW2) + ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true)); + } } } } @@ -352,7 +372,7 @@ namespace VISU { struct TSizePositionEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; double myValue; bool myIsSize; @@ -362,7 +382,7 @@ namespace VISU { double theValue, bool theIsSize): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myValue(theValue), myIsSize(theIsSize) {} @@ -376,9 +396,9 @@ namespace VISU { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { if (myIsSize) { - //jfa to do:workstack->SetRelativeSizeInSplitter(myViewWindow, myValue); + //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue); } else { - workstack->SetRelativePositionInSplitter(myViewWindow, myValue); + workstack->SetRelativePositionInSplitter(myVW, myValue); } } } @@ -392,7 +412,9 @@ namespace VISU { if (thePosition < 0.0 || 1.0 < thePosition) { return; } - ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,thePosition,false)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false)); } void @@ -402,13 +424,15 @@ namespace VISU { if (theSize < 0.0 || 1.0 < theSize) { return; } - ProcessVoidEvent(new TSizePositionEvent(myApplication,myViewWindow,theSize,true)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true)); } struct TWSSizePositionEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; Qt::Orientation myOrientation; double myValue; bool myIsSize; @@ -420,7 +444,7 @@ namespace VISU { double theValue, bool theIsSize): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myOrientation(theOrientation), myValue(theValue), myIsSize(theIsSize) @@ -435,9 +459,9 @@ namespace VISU { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { if (myIsSize) { - //jfa to do:workstack->SetRelativeSize(myViewWindow, myOrientation, myValue); + //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue); } else { - workstack->SetRelativePosition(myViewWindow, myOrientation, myValue); + workstack->SetRelativePosition(myVW, myOrientation, myValue); } } } @@ -451,8 +475,10 @@ namespace VISU { if (thePosition < 0.0 || 1.0 < thePosition) { return; } - ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow, - Qt::Horizontal,thePosition,false)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW, + Qt::Horizontal, thePosition, false)); } void @@ -462,8 +488,10 @@ namespace VISU { if (thePosition < 0.0 || 1.0 < thePosition) { return; } - ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow, - Qt::Vertical,thePosition,false)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW, + Qt::Vertical, thePosition, false)); } void @@ -473,8 +501,10 @@ namespace VISU { if (theSize < 0.0 || 1.0 < theSize) { return; } - ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow, - Qt::Horizontal,theSize,true)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW, + Qt::Horizontal, theSize, true)); } void @@ -484,15 +514,17 @@ namespace VISU { if (theSize < 0.0 || 1.0 < theSize) { return; } - ProcessVoidEvent(new TWSSizePositionEvent(myApplication,myViewWindow, - Qt::Vertical,theSize,true)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW, + Qt::Vertical, theSize, true)); } // End: New methods for view parameters management // Begin: Old methods for view parameters management, they don't work now struct TSetViewSize: public SALOME_Event { - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; typedef void (QRect::* TAction)(int); TAction myAction; CORBA::Long mySize; @@ -501,7 +533,7 @@ namespace VISU { TSetViewSize(SUIT_ViewWindow* theViewWindow, TAction theAction, CORBA::Long theSize): - myViewWindow(theViewWindow), + myVW(theViewWindow), myAction(theAction), mySize(theSize) {} @@ -510,7 +542,7 @@ namespace VISU { void Execute() { - if (QWidget* aParent = myViewWindow->parentWidget(true)) { + if (QWidget* aParent = myVW->parentWidget(true)) { QRect aQRect = aParent->frameGeometry(); (aQRect.*myAction)(mySize); aParent->setGeometry(aQRect); @@ -535,7 +567,7 @@ namespace VISU { struct TGetViewSize: public SALOME_Event { - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; typedef int (QRect::* TAction)() const; TAction myAction; @@ -546,7 +578,7 @@ namespace VISU { public: TGetViewSize(SUIT_ViewWindow* theViewWindow, TAction theAction): - myViewWindow(theViewWindow), + myVW(theViewWindow), myAction(theAction) {} @@ -554,7 +586,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)){ + if(QWidget* aParent = myVW->parentWidget(true)){ QRect aQRect = aParent->frameGeometry(); myResult = (aQRect.*myAction)(); } @@ -580,13 +612,13 @@ namespace VISU { class TWorkspaceEvent: public SALOME_Event { protected: - QWidget* myViewWindow; + QWidget* myVW; QWidget* myWorkspace; public: TWorkspaceEvent(QWidget* theViewWindow, QWidget* theWorkspace): - myViewWindow(theViewWindow), + myVW(theViewWindow), myWorkspace(theWorkspace) {} }; @@ -609,7 +641,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget(true)) SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment); } }; @@ -690,7 +722,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget(true)) aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height())); } }; @@ -717,7 +749,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget(true)) aParent->setGeometry(aParent->x(), aParent->y(), int(myX*myWorkspace->width()), @@ -753,7 +785,9 @@ namespace VISU { } }; - ProcessVoidEvent(new TEvent(myViewWindow,theColor)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TEvent(aVW, theColor)); } @@ -782,28 +816,42 @@ namespace VISU { View_i:: GetBackground() { - return ProcessEvent(new TBackgroundEvent(myViewWindow)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + return ProcessEvent(new TBackgroundEvent(aVW)); + + SALOMEDS::Color aBlack; + aBlack.R = 0.0; + aBlack.G = 0.0; + aBlack.B = 0.0; + return aBlack; } void View_i:: Minimize() { - ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMinimized)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized)); } void View_i:: Restore() { - ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showNormal)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal)); } void View_i:: Maximize() { - ProcessVoidEvent(new TFrameActionEvent(myViewWindow,&SUIT_ViewWindow::showMaximized)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized)); } void @@ -838,13 +886,13 @@ namespace VISU { class TSavePictureEvent: public SALOME_Event { - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; const char * myFileName; public: typedef CORBA::Boolean TResult; TResult myResult; TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName) - : myViewWindow(theViewWindow), + : myVW(theViewWindow), myFileName(theFileName), myResult(false) { @@ -852,8 +900,8 @@ namespace VISU { virtual void Execute() { - if (myViewWindow) { - QImage img = myViewWindow->dumpView(); + if (myVW) { + QImage img = myVW->dumpView(); if (!img.isNull()) { QString fileName (myFileName); if (!fileName.isEmpty()) { @@ -862,6 +910,7 @@ namespace VISU { if (fmt == "JPG" ) fmt = "JPEG"; //QApplication::setOverrideCursor(Qt::waitCursor); img.save(fileName, fmt.latin1()); + myResult = true; //QApplication::restoreOverrideCursor(); } } @@ -872,12 +921,11 @@ namespace VISU { CORBA::Boolean View_i::SavePicture(const char* theFileName) { - return ProcessEvent(new TSavePictureEvent (myViewWindow,theFileName)); + return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName)); } const char* - View_i:: - GetComment() const + View_i::GetComment() const { return ""; } @@ -888,76 +936,40 @@ namespace VISU { { } - - //================= OLD CODE =================== - - //QAD_Study* CheckStudy (SALOMEDS::Study_ptr theStudy) - //{ - // //QAD_Desktop* aDesktop = QAD_Application::getDesktop(); - // //QAD_Study* aStudy = aDesktop->findStudy(theStudy); - // if (!aStudy) { - // CORBA::String_var aName = theStudy->Name(); - // aFileInfo.setFile(aName.in()); - // if (aFileInfo.exists()) - // aStudy = aDesktop->loadStudy(aFileInfo.baseName()); - // else - // aStudy = aDesktop->loadStudy(aName.in()); - // if (!aStudy) { - // MESSAGE("CheckStudy()::ERROR: Can't load study"); - // } - // } - // return aStudy; - //} - - template - struct TNewSpecViewEvent: public SALOME_Event + SUIT_ViewWindow* View_i::GetViewWindow() { - SalomeApp_Application* myApplication; - - typedef SUIT_ViewManager* TResult; - TResult myResult; + if (myViewWindow) { + QPtrVector aViews = myViewManager->getViews(); + int aPos = aViews.find(myViewWindow); + if (aPos < 0) + myViewWindow = NULL; + } + return myViewWindow; + } - TNewSpecViewEvent (SalomeApp_Application* theApplication): - myApplication(theApplication), - myResult(NULL) - {} + void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow) + { + myViewWindow = theViewWindow; + } - virtual - void - Execute() - { - myResult = myApplication->getViewManager(TViewer::Type(), false); - if (!myResult) { - myResult = myApplication->getViewManager(TViewer::Type(), true); - myResult->closeAllViews(); - } - } - }; //=========================================================================== XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication) : View_i(theApplication, NULL) { if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i"); - if (theApplication) { - myViewManager = ProcessEvent(new TNewSpecViewEvent(theApplication)); - } } - struct TCreatePlot2dViewEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; - XYPlot_i * myPlot2dView; - int myNew; + XYPlot_i * myPlot2dView; + int myNew; typedef Plot2d_ViewFrame* TResult; TResult myResult; - TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager, - XYPlot_i * thePlot2dView, - const int theNew): - myViewManager(theViewManager), + TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView, + const int theNew): myPlot2dView(thePlot2dView), myNew(theNew), myResult(NULL) @@ -967,27 +979,48 @@ namespace VISU { void Execute() { - if (myNew) { - myPlot2dView->myViewWindow = myViewManager->createViewWindow(); + if (!myPlot2dView->myApplication) + return; + + SUIT_ViewManager* aViewMgr = + myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false); + SUIT_ViewWindow* aVW = NULL; + + if (aViewMgr) { + if (myNew) + aVW = aViewMgr->createViewWindow(); + else + aVW = aViewMgr->getActiveView(); } else { - myPlot2dView->myViewWindow = myViewManager->getActiveView(); + if (myNew) { + aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true); + aVW = aViewMgr->getActiveView(); + } else { + return; // there are no current Plot2d view + } } - if (myPlot2dView->myViewWindow) { - Plot2d_ViewWindow* aPlot2dVW = dynamic_cast(myPlot2dView->myViewWindow); + + if (aVW) { + Plot2d_ViewWindow* aPlot2dVW = dynamic_cast(aVW); if (aPlot2dVW) { myResult = aPlot2dVW->getViewFrame(); if (myResult) { myResult->Repaint(); - } - } + } + + myPlot2dView->myViewManager = aViewMgr; + myPlot2dView->SetViewWindow(aVW); + } } } }; Storable* XYPlot_i::Create (int theNew) { - myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew)); - return this; + myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew)); + if (myView) + return this; + return NULL; } void XYPlot_i::Update() @@ -998,7 +1031,13 @@ namespace VISU { void XYPlot_i::Close() { //jfa: may be need to be enclosed in SALOME_Event? - myViewWindow->close(); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + aVW->close(); + //QPtrVector aViews = myViewManager->getViews(); + //int aPos = aViews.find(myViewWindow); + //if (aPos >= 0) + // myViewWindow->close(); } XYPlot_i::~XYPlot_i() { @@ -1007,49 +1046,59 @@ namespace VISU { void XYPlot_i::SetTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myViewWindow, &SUIT_ViewWindow::setCaption, QString(theTitle))); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (aVW, &SUIT_ViewWindow::setCaption, QString(theTitle))); } char* XYPlot_i::GetTitle() { - //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myViewWindow->caption().latin1()); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + return CORBA::string_dup(aVW->caption().latin1()); + return CORBA::string_dup(""); } void XYPlot_i::SetSubTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle))); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle))); } char* XYPlot_i::GetSubTitle() { - //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myView->getTitle()); + if (GetViewWindow()) + return CORBA::string_dup(myView->getTitle()); + return CORBA::string_dup(""); } void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType) { - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (myView,&Plot2d_ViewFrame::setCurveType,theType,true)); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setCurveType,theType,true)); } VISU::XYPlot::CurveType XYPlot_i::GetCurveType() { - //jfa: may be need to be enclosed in SALOME_Event? - return (VISU::XYPlot::CurveType)myView->getCurveType(); + if (GetViewWindow()) + return (VISU::XYPlot::CurveType)myView->getCurveType(); + return VISU::XYPlot::POINTS; } void XYPlot_i::SetMarkerSize (CORBA::Long theSize) { - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true)); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true)); } CORBA::Long XYPlot_i::GetMarkerSize() { - //jfa: may be need to be enclosed in SALOME_Event? - return myView->getMarkerSize(); + if (GetViewWindow()) + return myView->getMarkerSize(); + return -1; } class TEnableGridEvent: public SALOME_Event @@ -1078,15 +1127,17 @@ namespace VISU { void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor, CORBA::Boolean theMinor, CORBA::Long theNumMinor) { - ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid, - theMajor,theNumMajor,theMinor,theNumMinor)); + if (GetViewWindow()) + ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid, + theMajor,theNumMajor,theMinor,theNumMinor)); } void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, CORBA::Boolean theMinor, CORBA::Long theNumMinor) { //asl: Plot2d_ViewFrame::setYGrid has more parameters - //ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid, - // theMajor,theNumMajor,theMinor,theNumMinor)); + //if (GetViewWindow()) + // ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid, + // theMajor,theNumMajor,theMinor,theNumMinor)); } class TSetScaleModeEvent: public SALOME_Event @@ -1109,26 +1160,31 @@ namespace VISU { void XYPlot_i::SetHorScaling (VISU::Scaling theScaling) { - ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode, - theScaling == VISU::LOGARITHMIC)); + if (GetViewWindow()) + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetHorScaling() { //jfa: may be need to be enclosed in SALOME_Event? - return (VISU::Scaling)myView->getHorScaleMode(); + if (GetViewWindow()) + return (VISU::Scaling)myView->getHorScaleMode(); + return VISU::LINEAR; } void XYPlot_i::SetVerScaling(VISU::Scaling theScaling) { - ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode, - theScaling == VISU::LOGARITHMIC)); + if (GetViewWindow()) + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetVerScaling() { - //jfa: may be need to be enclosed in SALOME_Event? - return (VISU::Scaling)myView->getVerScaleMode(); + if (GetViewWindow()) + return (VISU::Scaling)myView->getVerScaleMode(); + return VISU::LINEAR; } class TSetTitleEvent: public SALOME_Event @@ -1149,28 +1205,33 @@ namespace VISU { void XYPlot_i::SetXTitle (const char* theTitle) { - ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle)); + if (GetViewWindow()) + ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle)); } char* XYPlot_i::GetXTitle() { - //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle)); + if (GetViewWindow()) + return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle)); + return CORBA::string_dup(""); } void XYPlot_i::SetYTitle (const char* theTitle) { - ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle)); + if (GetViewWindow()) + ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle)); } char* XYPlot_i::GetYTitle() { - //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle)); + if (GetViewWindow()) + return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle)); + return CORBA::string_dup(""); } void XYPlot_i::ShowLegend (CORBA::Boolean theShowing) { - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); } class TXYPlotViewEvent: public SALOME_Event @@ -1238,27 +1299,32 @@ namespace VISU { void XYPlot_i::Display (PrsObject_ptr thePrsObj) { - ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay)); + if (GetViewWindow()) + ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay)); } void XYPlot_i::Erase (PrsObject_ptr thePrsObj) { - ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase)); + if (GetViewWindow()) + ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase)); } void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj) { - ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly)); + if (GetViewWindow()) + ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly)); } void XYPlot_i::EraseAll() { - ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::EraseAll)); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::EraseAll)); } void XYPlot_i::FitAll() { - ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::fitAll)); + if (GetViewWindow()) + ProcessVoidEvent(new TVoidMemFunEvent (myView,&Plot2d_ViewFrame::fitAll)); } class TFitRangeEvent: public SALOME_Event @@ -1414,22 +1480,19 @@ namespace VISU { : View_i(theApplication, NULL) { if (MYDEBUG) MESSAGE("View3D_i::View3D_i"); - if (theApplication) { - myViewManager = ProcessEvent(new TNewSpecViewEvent(theApplication)); - } } struct TCreateView3dEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; - int myNew; + View3D_i * myView3D; + int myNew; typedef SUIT_ViewWindow* TResult; TResult myResult; - TCreateView3dEvent (SUIT_ViewManager* theViewManager, - const int theNew): - myViewManager(theViewManager), + TCreateView3dEvent (View3D_i * theView3D, + const int theNew): + myView3D(theView3D), myNew(theNew), myResult(NULL) {} @@ -1438,33 +1501,54 @@ namespace VISU { void Execute() { - if (myNew) { - myResult = myViewManager->createViewWindow(); + if (!myView3D->myApplication) + return; + + SUIT_ViewManager * aViewMgr = + myView3D->myApplication->getViewManager(SVTK_Viewer::Type(), false); + + if (aViewMgr) { + if (myNew) { + myResult = aViewMgr->createViewWindow(); + } else { + myResult = aViewMgr->getActiveView(); + } } else { - myResult = myViewManager->getActiveView(); + if (myNew) { + aViewMgr = myView3D->myApplication->getViewManager(SVTK_Viewer::Type(), true); + myResult = aViewMgr->getActiveView(); + } else { + return; // there are no current 3D view + } } + + myView3D->myViewManager = aViewMgr; } }; Storable* View3D_i::Create (int theNew) { if (MYDEBUG) MESSAGE("View3D_i::Create"); - myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew)); - return this; + SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(this, theNew)); + if (aVW) { + SetViewWindow(aVW); + return this; + } + return NULL; } void View3D_i::Update() { class TEvent: public SALOME_Event { - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; public: - TEvent(SUIT_ViewWindow* theStudyFrame): - myViewWindow(theStudyFrame) + TEvent(SUIT_ViewWindow* theViewWindow): + myVW(theViewWindow) {} virtual void Execute() { - SVTK_ViewWindow* vf = GetViewWindow(myViewWindow); + SVTK_ViewWindow* vf = VISU::GetViewWindow(myVW); vtkRenderer* Renderer = vf->getRenderer(); vtkActorCollection* theActors = Renderer->GetActors(); theActors->InitTraversal(); @@ -1477,15 +1561,22 @@ namespace VISU { } } } - RepaintView(myViewWindow); + RepaintView(myVW); } }; - ProcessVoidEvent(new TEvent(myViewWindow)); + + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TEvent(aVW)); } bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName) { MESSAGE("View3D_i::SaveViewParams()"); + + if (!theViewManager || !theName) + return false; + _PTR(Study) aCStudy; if (SUIT_Study* aSStudy = theViewManager->study()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { @@ -1495,7 +1586,7 @@ namespace VISU { if (!aCStudy) return false; - if (theName) { + if (strcmp(theName, "") != 0) { std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU"); _PTR(GenericAttribute) anAttr; int iEnd = aList.size(); @@ -1523,18 +1614,18 @@ namespace VISU { class TSaveViewParamsEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; + SUIT_ViewManager* myViewMgr; const char* myName; public: TSaveViewParamsEvent (SUIT_ViewManager* theViewManager, const char* theName): - myViewManager(theViewManager), + myViewMgr(theViewManager), myName(theName) {} virtual void Execute() { - myResult = View3D_i::SaveViewParams(myViewManager, myName); + myResult = View3D_i::SaveViewParams(myViewMgr, myName); } typedef CORBA::Boolean TResult; TResult myResult; @@ -1582,18 +1673,18 @@ namespace VISU { class TRestoreViewParamsEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; + SUIT_ViewManager* myViewMgr; const char* myName; public: TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager, const char* theName): - myViewManager(theViewManager), + myViewMgr(theViewManager), myName(theName) {} virtual void Execute() { - myResult = View3D_i::RestoreViewParams(myViewManager, myName); + myResult = View3D_i::RestoreViewParams(myViewMgr, myName); } typedef CORBA::Boolean TResult; TResult myResult; @@ -1604,7 +1695,7 @@ namespace VISU { return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName)); } - void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame, + void View3D_i::Restore (SUIT_ViewWindow* theViewWindow, const Storable::TRestoringMap& theMap) { SALOMEDS::Color aColor; @@ -1634,59 +1725,59 @@ namespace VISU { aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble(); aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble(); - SetBackground(theStudyFrame,aColor); - SetPointOfView(theStudyFrame,aPosition); - SetViewUp(theStudyFrame,aViewUp); - SetFocalPoint(theStudyFrame,aFocalPnt); - SetParallelScale(theStudyFrame,aParallelScale); - ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]); - ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]); - ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]); + SetBackground(theViewWindow,aColor); + SetPointOfView(theViewWindow,aPosition); + SetViewUp(theViewWindow,aViewUp); + SetFocalPoint(theViewWindow,aFocalPnt); + SetParallelScale(theViewWindow,aParallelScale); + ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]); + ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]); + ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]); } - string View3D_i::ToString (SUIT_ViewWindow* theStudyFrame) + string View3D_i::ToString (SUIT_ViewWindow* theViewWindow) { ostringstream strOut; - Storable::DataToStream( strOut, "myComment", myComment.c_str() ); - ToStream(theStudyFrame,strOut); - strOut<GetBackground(backint); + GetRenderer(theViewWindow)->GetBackground(backint); Storable::DataToStream(theStr,"myColor.R",backint[0]); Storable::DataToStream(theStr,"myColor.G",backint[1]); Storable::DataToStream(theStr,"myColor.B",backint[2]); double aPosition[3]; - GetPointOfView(theStudyFrame,aPosition); + GetPointOfView(theViewWindow,aPosition); Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]); Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]); Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]); double aFocalPnt[3]; - GetFocalPoint(theStudyFrame,aFocalPnt); + GetFocalPoint(theViewWindow,aFocalPnt); Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]); Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]); Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]); double aViewUp[3]; - GetCamera(theStudyFrame)->GetViewUp(aViewUp); + GetCamera(theViewWindow)->GetViewUp(aViewUp); Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]); Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]); Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]); - Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame)); + Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow)); double aScaleFactor[3]; - GetViewWindow(theStudyFrame)->GetScale(aScaleFactor); + VISU::GetViewWindow(theViewWindow)->GetScale(aScaleFactor); Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]); Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]); Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]); @@ -1694,13 +1785,21 @@ namespace VISU { void View3D_i::ToStream(std::ostringstream& theStr) { - ToStream(myViewWindow,theStr); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ToStream(aVW, theStr); } void View3D_i::Close() { //jfa: may be need to be enclosed in SALOME_Event? - myViewWindow->close(); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + aVW->close(); + //QPtrVector aViews = myViewManager->getViews(); + //int aPos = aViews.find(myViewWindow); + //if (aPos >= 0) + // myViewWindow->close(); } View3D_i::~View3D_i() @@ -1710,17 +1809,21 @@ namespace VISU { void View3D_i::SetTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myViewWindow,&SUIT_ViewWindow::setCaption,QString(theTitle))); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (aVW,&SUIT_ViewWindow::setCaption,QString(theTitle))); } char* View3D_i::GetTitle() { - //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myViewWindow->caption().latin1()); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + return CORBA::string_dup(aVW->caption().latin1()); + return CORBA::string_dup(""); } - void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame, + void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow, const SALOMEDS::Color& theColor) { //jfa: may be need to be enclosed in SALOME_Event? @@ -1728,110 +1831,123 @@ namespace VISU { aColor[0] = int(255.0*theColor.R); aColor[1] = int(255.0*theColor.G); aColor[2] = int(255.0*theColor.B); - QColor aNewColor(aColor[0],aColor[1],aColor[2]); - GetViewWindow(theStudyFrame)->setBackgroundColor(aNewColor); + QColor aNewColor (aColor[0],aColor[1],aColor[2]); + VISU::GetViewWindow(theViewWindow)->setBackgroundColor(aNewColor); } - SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame) + SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow) { - //jfa: may be need to be enclosed in SALOME_Event? SALOMEDS::Color aColor; float backint[3]; - GetRenderer(theStudyFrame)->GetBackground(backint); + GetRenderer(theViewWindow)->GetBackground(backint); aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2]; return aColor; } class TUpdateViewerEvent: public SALOME_Event { - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; Prs3d_i* myPrs3d; int myDisplaing; public: - TUpdateViewerEvent(SUIT_ViewWindow* theStudyFrame, + TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow, Prs3d_i* thePrs3d, int theDisplaing): - myViewWindow(theStudyFrame), + myVW(theViewWindow), myPrs3d(thePrs3d), myDisplaing(theDisplaing) {} virtual void Execute(){ - UpdateViewer(myViewWindow,myDisplaing,myPrs3d); + UpdateViewer(myVW, myDisplaing, myPrs3d); } }; void View3D_i::EraseAll() { if(MYDEBUG) MESSAGE("View3D_i::EraseAll"); - ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eEraseAll)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll)); } void View3D_i::DisplayAll() { if(MYDEBUG) MESSAGE("View3D_i::DisplayAll"); - ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,NULL,eDisplayAll)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll)); } void View3D_i::Erase (PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Erase"); + SUIT_ViewWindow* aVW = GetViewWindow(); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ - ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eErase)); - } + Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); + if (aVW && aPrs) + ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase)); } void View3D_i::Display (PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Display"); + SUIT_ViewWindow* aVW = GetViewWindow(); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ - ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplay)); - } + Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); + if (aVW && aPrs) + ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay)); } void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly"); + SUIT_ViewWindow* aVW = GetViewWindow(); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ - ProcessVoidEvent(new TUpdateViewerEvent(myViewWindow,aPrs,eDisplayOnly)); - } + Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in()); + if (aVW && aPrs) + ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly)); } void View3D_i::FitAll() { - ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll)); - Update(); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) { + ProcessVoidEvent(new TVoidMemFunEvent + (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFitAll)); + Update(); + } } void View3D_i::SetView (VISU::View3D::ViewType theType) { + SUIT_ViewWindow* aVW = GetViewWindow(); + if (!aVW) + return; + switch (theType) { case VISU::View3D::FRONT : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFrontView)); + (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFrontView)); break; case VISU::View3D::BACK : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView)); + (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onBackView)); break; case VISU::View3D::LEFT : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView)); + (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onLeftView)); break; case VISU::View3D::RIGHT : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView)); + (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onRightView)); break; case VISU::View3D::TOP : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView)); + (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onTopView)); break; case VISU::View3D::BOTTOM : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView)); + (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onBottomView)); break; } Update(); @@ -1840,181 +1956,199 @@ namespace VISU { class TSet3DViewParamEvent: public SALOME_Event { public: - typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, const CORBA::Double theParam[3]); + typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]); TSet3DViewParamEvent (TFun theFun, - SUIT_ViewWindow* theStudyFrame, + SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]): myFun(theFun), - myViewWindow(theStudyFrame), + myVW(theViewWindow), myParam(theParam) {} - virtual void Execute(){ - myFun(myViewWindow,myParam); + virtual void Execute() { + myFun(myVW,myParam); } private: TFun myFun; - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; const CORBA::Double* myParam; }; - void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame, + void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow, const CORBA::Double thePosition[3]) { //jfa: may be need to be enclosed in SALOME_Event? - GetCamera(theStudyFrame)->SetPosition(thePosition); + GetCamera(theViewWindow)->SetPosition(thePosition); } void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition) { if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView"); - ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myViewWindow,thePosition)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,aVW,thePosition)); } - void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame, + void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow, CORBA::Double thePosition[3]) { - //jfa: may be need to be enclosed in SALOME_Event? - GetCamera(theStudyFrame)->GetPosition(thePosition); + GetCamera(theViewWindow)->GetPosition(thePosition); } VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { - //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView"); CORBA::Double aPosition[3]; - GetPointOfView(myViewWindow,aPosition); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + GetPointOfView(aVW,aPosition); return VISU::View3D::XYZ_dup(aPosition); } - void View3D_i::SetViewUp (SUIT_ViewWindow* theStudyFrame, + void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow, const CORBA::Double theViewUp[3]) { - GetCamera(theStudyFrame)->SetViewUp(theViewUp); + GetCamera(theViewWindow)->SetViewUp(theViewUp); } void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp) { if(MYDEBUG) MESSAGE("View3D_i::SetViewUp"); - ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myViewWindow,theViewUp)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,aVW,theViewUp)); } - void View3D_i::GetViewUp (SUIT_ViewWindow* theStudyFrame, + void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow, CORBA::Double theViewUp[3]) { - GetCamera(theStudyFrame)->GetViewUp(theViewUp); + GetCamera(theViewWindow)->GetViewUp(theViewUp); } VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { - //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetViewUp"); CORBA::Double aViewUp[3]; - GetCamera(myViewWindow)->GetViewUp(aViewUp); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + GetCamera(aVW)->GetViewUp(aViewUp); return VISU::View3D::XYZ_dup(aViewUp); } - void View3D_i::SetFocalPoint (SUIT_ViewWindow* theStudyFrame, + void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow, const CORBA::Double theFocalPnt[3]) { - GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt); + GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt); } void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord) { if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint"); - ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myViewWindow,theCoord)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,aVW,theCoord)); } - void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame, + void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow, CORBA::Double theFocalPnt[3]) { - GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt); + GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt); } VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { - //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint"); CORBA::Double aFocalPnt[3]; - GetFocalPoint(myViewWindow,aFocalPnt); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + GetFocalPoint(aVW,aFocalPnt); return VISU::View3D::XYZ_dup(aFocalPnt); } class TSetViewParamEvent: public SALOME_Event { public: - typedef void (*TFun)(SUIT_ViewWindow* theStudyFrame, CORBA::Double theParam); + typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam); TSetViewParamEvent (TFun theFun, - SUIT_ViewWindow* theStudyFrame, + SUIT_ViewWindow* theViewWindow, CORBA::Double theParam): myFun(theFun), - myViewWindow(theStudyFrame), + myVW(theViewWindow), myParam(theParam) {} virtual void Execute() { - myFun(myViewWindow,myParam); + myFun(myVW,myParam); } private: TFun myFun; - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; CORBA::Double myParam; }; - void View3D_i::SetParallelScale (SUIT_ViewWindow* theStudyFrame, + void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow, CORBA::Double theScale) { - GetCamera(theStudyFrame)->SetParallelScale(theScale); + GetCamera(theViewWindow)->SetParallelScale(theScale); } void View3D_i::SetParallelScale (CORBA::Double theScale) { if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale"); - ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myViewWindow,theScale)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,aVW,theScale)); } - CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theStudyFrame) + CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow) { - return GetCamera(theStudyFrame)->GetParallelScale(); + return GetCamera(theViewWindow)->GetParallelScale(); } CORBA::Double View3D_i::GetParallelScale() { - //jfa: may be need to be enclosed in SALOME_Event? if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale"); - return GetParallelScale(myViewWindow); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) + return GetParallelScale(aVW); + return 1.0; } - void View3D_i::ScaleView (SUIT_ViewWindow* theStudyFrame, + void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow, VISU::View3D::Axis theAxis, CORBA::Double theParam) { - SVTK_ViewWindow* aViewFrame = GetViewWindow(theStudyFrame); + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theViewWindow); double aScaleFactor[3]; - aViewFrame->GetScale(aScaleFactor); + aViewWindow->GetScale(aScaleFactor); aScaleFactor[theAxis] = theParam; - aViewFrame->SetScale(aScaleFactor); + aViewWindow->SetScale(aScaleFactor); } - void SetScaleView (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theScale[3]) + void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3]) { double aScale[3] = {theScale[0], theScale[1], theScale[2]}; - GetViewWindow(theStudyFrame)->SetScale(aScale); + VISU::GetViewWindow(theViewWindow)->SetScale(aScale); } void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) { if(MYDEBUG) MESSAGE("View3D_i::ScaleView"); - double aScale[3]; - GetViewWindow(myViewWindow)->GetScale(aScale); - aScale[theAxis] = theParam; - ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) { + double aScale[3]; + VISU::GetViewWindow(aVW)->GetScale(aScale); + aScale[theAxis] = theParam; + ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale)); + } } void View3D_i::RemoveScale() { if(MYDEBUG) MESSAGE("View3D_i::RemoveScale"); - double aScale[3] = {1.0, 1.0, 1.0}; - ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myViewWindow,aScale)); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) { + double aScale[3] = {1.0, 1.0, 1.0}; + ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale)); + } } } diff --git a/src/VISU_I/VISU_View_i.hh b/src/VISU_I/VISU_View_i.hh index 4f9c8176..76b44da5 100644 --- a/src/VISU_I/VISU_View_i.hh +++ b/src/VISU_I/VISU_View_i.hh @@ -49,15 +49,8 @@ namespace VISU public virtual Storable { public: - QWidget *myWorkspace; - SUIT_ViewWindow *myViewWindow; - - protected: - SalomeApp_Application *myApplication; - SUIT_ViewManager *myViewManager; - View_i (SalomeApp_Application *theApplication, - SUIT_ViewManager* theViewManager); + SUIT_ViewManager* theViewManager); virtual ~View_i(); public: @@ -115,6 +108,18 @@ namespace VISU virtual void Close() = 0; virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; + + SUIT_ViewWindow* GetViewWindow(); + void SetViewWindow(SUIT_ViewWindow* theViewWindow); + + public: + QWidget *myWorkspace; + + SalomeApp_Application *myApplication; + SUIT_ViewManager *myViewManager; + + private: + SUIT_ViewWindow *myViewWindow; }; @@ -143,9 +148,9 @@ namespace VISU virtual CORBA::Long GetMarkerSize(); virtual void EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor); virtual void EnableYGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor); virtual void SetHorScaling (VISU::Scaling theScaling); virtual VISU::Scaling GetHorScaling(); @@ -220,10 +225,10 @@ namespace VISU virtual void SetTitle (const char* theTitle); virtual char* GetTitle(); - static void SetBackground (SUIT_ViewWindow* theStudyFrame, + static void SetBackground (SUIT_ViewWindow* theViewWindow, const SALOMEDS::Color& theColor); - static SALOMEDS::Color GetBackground (SUIT_ViewWindow* theStudyFrame); + static SALOMEDS::Color GetBackground (SUIT_ViewWindow* theViewWindow); virtual void EraseAll(); virtual void DisplayAll(); @@ -236,54 +241,54 @@ namespace VISU virtual void FitAll(); virtual void SetView (VISU::View3D::ViewType theType); - static void SetPointOfView (SUIT_ViewWindow* theStudyFrame, - const CORBA::Double thePosition[3]); + static void SetPointOfView (SUIT_ViewWindow* theViewWindow, + const CORBA::Double thePosition[3]); virtual void SetPointOfView (const VISU::View3D::XYZ theCoord); - static void GetPointOfView (SUIT_ViewWindow* theStudyFrame, - CORBA::Double thePosition[3]); + static void GetPointOfView (SUIT_ViewWindow* theViewWindow, + CORBA::Double thePosition[3]); virtual VISU::View3D::XYZ_slice* GetPointOfView(); - static void SetViewUp (SUIT_ViewWindow* theStudyFrame, - const CORBA::Double theViewUp[3]); + static void SetViewUp (SUIT_ViewWindow* theViewWindow, + const CORBA::Double theViewUp[3]); virtual void SetViewUp (const VISU::View3D::XYZ theDir); - static void GetViewUp (SUIT_ViewWindow* theStudyFrame, CORBA::Double theViewUp[3]); + static void GetViewUp (SUIT_ViewWindow* theViewWindow, CORBA::Double theViewUp[3]); virtual VISU::View3D::XYZ_slice* GetViewUp(); - static void SetFocalPoint (SUIT_ViewWindow* theStudyFrame, const CORBA::Double theFocalPnt[3]); + static void SetFocalPoint (SUIT_ViewWindow* theViewWindow, const CORBA::Double theFocalPnt[3]); virtual void SetFocalPoint (const VISU::View3D::XYZ theCoord); - static void View3D_i::GetFocalPoint (SUIT_ViewWindow* theStudyFrame, CORBA::Double theFocalPnt[3]); + static void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow, CORBA::Double theFocalPnt[3]); virtual VISU::View3D::XYZ_slice* GetFocalPoint(); - static void SetParallelScale (SUIT_ViewWindow* theStudyFrame, CORBA::Double theScale); + static void SetParallelScale (SUIT_ViewWindow* theViewWindow, CORBA::Double theScale); virtual void SetParallelScale (CORBA::Double theScale); - static CORBA::Double GetParallelScale (SUIT_ViewWindow* theStudyFrame); + static CORBA::Double GetParallelScale (SUIT_ViewWindow* theViewWindow); virtual CORBA::Double GetParallelScale (); - static void ScaleView (SUIT_ViewWindow* theStudyFrame, - VISU::View3D::Axis theAxis, CORBA::Double theParam); + static void ScaleView (SUIT_ViewWindow* theViewWindow, + VISU::View3D::Axis theAxis, CORBA::Double theParam); virtual void ScaleView (VISU::View3D::Axis theAxis, CORBA::Double theParam); virtual void RemoveScale(); - static std::string ToString (SUIT_ViewWindow* theStudyFrame); + static std::string ToString (SUIT_ViewWindow* theViewWindow); - static void ToStream (SUIT_ViewWindow* theStudyFrame, std::ostringstream& theStr); + static void ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr); static bool SaveViewParams (SUIT_ViewManager* theViewManager, - const char* theName); + const char* theName); virtual CORBA::Boolean SaveViewParams (const char* theName); static bool RestoreViewParams (SUIT_ViewManager* theViewManager, - const char* theName); + const char* theName); virtual CORBA::Boolean RestoreViewParams (const char* theName); static QString GenerateViewParamsName(); - static void Restore (SUIT_ViewWindow* theStudyFrame, - const Storable::TRestoringMap& theMap); + static void Restore (SUIT_ViewWindow* theViewWindow, + const Storable::TRestoringMap& theMap); virtual void Close(); -- 2.30.2