X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_View_i.cc;h=d80850e79a849f5cf9f1cfc9a0927115c42cbaa2;hb=ba9e93f27d47a0ac9eaa884a753b5676da4e7168;hp=a83055ce74a88a13f86fd93e63701dbb8325b08f;hpb=faf444bbd926d883397a11e3a63f2f911ddded5c;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index a83055ce..d80850e7 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or @@ -17,25 +17,31 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_View_i.cc // Author : Alexey PETROV // Module : VISU - +// #include "VISU_View_i.hh" +#include "VISU_Tools.h" #include "VISU_Gen_i.hh" #include "VISU_Prs3d_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" +#include "VISU_ScalarMap_i.hh" #include "VISU_ViewManager_i.hh" - -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" +#include "VISU_PointMap3dActor.h" +#include "VISU_DeformedGridPL.hxx" -#include "SALOME_Event.hxx" +#include "SALOME_Event.h" #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" @@ -46,21 +52,23 @@ #include "SVTK_ViewWindow.h" #include "SVTK_ViewModel.h" -#include "SVTK_RenderWindow.h" +#include "VTKViewer_Algorithm.h" #include "SPlot2d_ViewModel.h" #include "Plot2d_ViewFrame.h" -#include "Plot2d_ViewModel.h" #include "SalomeApp_Application.h" #include "SalomeApp_Study.h" #include +#include -#include +#include +#include #include #include +#include using namespace std; @@ -146,18 +154,24 @@ namespace VISU { { switch(myViewRepresentation){ case VISU::View::OBJECTBROWSER: - myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState); + myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState ); break; case VISU::View::PYTHON: - myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState); + myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState ); break; case VISU::View::MESSAGES: - myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState); + myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState ); break; - case VISU::View::VIEWER:{ - ViewManagerList aViewManagerList = myApplication->viewManagers(); - // to do something - // ... + case VISU::View::VIEWER: + { + ViewManagerList mgrs = myApplication->viewManagers(); + ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end(); + for( ; anIt!=aLast; anIt++ ) + { + const QVector& views = (*anIt)->getViews(); + for( int i=0; isetShown( myState ); + } break; }} } @@ -185,18 +199,26 @@ namespace VISU { { switch(myViewRepresentation){ case VISU::View::OBJECTBROWSER: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible(); break; case VISU::View::PYTHON: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible(); break; case VISU::View::MESSAGES: - myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow); + myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible(); break; case VISU::View::VIEWER:{ ViewManagerList aViewManagerList = myApplication->viewManagers(); - // to do something - // ... + ViewManagerList::const_iterator anIt = aViewManagerList.begin(); + for( ; anIt != aViewManagerList.end(); anIt++ ) + { + const QVector& views = (*anIt)->getViews(); + for( int i=0; iisVisible(); + return; + } + } + myResult = false; break; }} } @@ -213,7 +235,7 @@ namespace VISU { struct TSplitEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; Qt::Orientation myOrientation; QtxWorkstack::SplitType mySplitType; @@ -223,7 +245,7 @@ namespace VISU { Qt::Orientation theOrientation, QtxWorkstack::SplitType theSplitType): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myOrientation(theOrientation), mySplitType(theSplitType) {} @@ -235,7 +257,7 @@ namespace VISU { if (tabDesk) { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { - workstack->Split(myViewWindow, myOrientation, mySplitType); + workstack->Split(myVW, myOrientation, mySplitType); } } } @@ -245,32 +267,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::SplitMove)); } 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::SplitStay)); } 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::SplitMove)); } 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::SplitStay)); } void @@ -279,29 +309,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: @@ -310,8 +342,8 @@ namespace VISU { SUIT_ViewWindow * theViewWindow2, bool theAttractAll): myApplication(theApplication), - myViewWindow1(theViewWindow1), - myViewWindow2(theViewWindow2), + myVW1(theViewWindow1), + myVW2(theViewWindow2), myAttractAll(theAttractAll) {} @@ -322,7 +354,7 @@ namespace VISU { if (tabDesk) { QtxWorkstack* workstack = tabDesk->workstack(); if (workstack) { - workstack->Attract(myViewWindow1, myViewWindow2, myAttractAll); + workstack->Attract(myVW1, myVW2, myAttractAll); } } } @@ -334,7 +366,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)); + } } } } @@ -345,7 +382,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)); + } } } } @@ -353,7 +395,7 @@ namespace VISU { struct TSizePositionEvent: public SALOME_Event { SalomeApp_Application * myApplication; - SUIT_ViewWindow * myViewWindow; + SUIT_ViewWindow * myVW; double myValue; bool myIsSize; @@ -363,7 +405,7 @@ namespace VISU { double theValue, bool theIsSize): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myValue(theValue), myIsSize(theIsSize) {} @@ -377,9 +419,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); } } } @@ -393,7 +435,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 @@ -403,13 +447,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; @@ -421,7 +467,7 @@ namespace VISU { double theValue, bool theIsSize): myApplication(theApplication), - myViewWindow(theViewWindow), + myVW(theViewWindow), myOrientation(theOrientation), myValue(theValue), myIsSize(theIsSize) @@ -436,9 +482,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); } } } @@ -452,8 +498,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 @@ -463,8 +511,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 @@ -474,8 +524,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 @@ -485,15 +537,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; @@ -502,7 +556,7 @@ namespace VISU { TSetViewSize(SUIT_ViewWindow* theViewWindow, TAction theAction, CORBA::Long theSize): - myViewWindow(theViewWindow), + myVW(theViewWindow), myAction(theAction), mySize(theSize) {} @@ -511,7 +565,7 @@ namespace VISU { void Execute() { - if (QWidget* aParent = myViewWindow->parentWidget(true)) { + if (QWidget* aParent = myVW->parentWidget()) { QRect aQRect = aParent->frameGeometry(); (aQRect.*myAction)(mySize); aParent->setGeometry(aQRect); @@ -536,7 +590,7 @@ namespace VISU { struct TGetViewSize: public SALOME_Event { - SUIT_ViewWindow* myViewWindow; + SUIT_ViewWindow* myVW; typedef int (QRect::* TAction)() const; TAction myAction; @@ -547,7 +601,7 @@ namespace VISU { public: TGetViewSize(SUIT_ViewWindow* theViewWindow, TAction theAction): - myViewWindow(theViewWindow), + myVW(theViewWindow), myAction(theAction) {} @@ -555,7 +609,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)){ + if(QWidget* aParent = myVW->parentWidget()){ QRect aQRect = aParent->frameGeometry(); myResult = (aQRect.*myAction)(); } @@ -581,13 +635,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) {} }; @@ -596,12 +650,12 @@ namespace VISU { class TAlignEvent: public TWorkspaceEvent { protected: - Qt::AlignmentFlags myAligment; + Qt::AlignmentFlag myAligment; public: TAlignEvent(QWidget* theViewWindow, QWidget* theWorkspace, - Qt::AlignmentFlags theAligment): + Qt::AlignmentFlag theAligment): TWorkspaceEvent(theViewWindow,theWorkspace), myAligment(theAligment) {} @@ -610,7 +664,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment); } }; @@ -691,7 +745,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height())); } }; @@ -718,7 +772,7 @@ namespace VISU { void Execute() { - if(QWidget* aParent = myViewWindow->parentWidget(true)) + if(QWidget* aParent = myVW->parentWidget()) aParent->setGeometry(aParent->x(), aParent->y(), int(myX*myWorkspace->width()), @@ -737,12 +791,12 @@ namespace VISU { { struct TEvent: public SALOME_Event { - QWidget* myWidget; + SVTK_ViewWindow* myVW; SALOMEDS::Color myColor; public: - TEvent(QWidget* theWidget, + TEvent(SVTK_ViewWindow* theViewWindow, const SALOMEDS::Color& theColor): - myWidget(theWidget), + myVW(theViewWindow), myColor(theColor) {} virtual void Execute(){ @@ -750,32 +804,36 @@ namespace VISU { aColor[0] = int(255.0*myColor.R); aColor[1] = int(255.0*myColor.G); aColor[2] = int(255.0*myColor.B); - myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2])); + QColor aNewColor (aColor[0],aColor[1],aColor[2]); + myVW->setBackgroundColor(aNewColor); } }; - - ProcessVoidEvent(new TEvent(myViewWindow,theColor)); + + SVTK_ViewWindow* aVW = dynamic_cast(GetViewWindow()); + if (aVW) + ProcessVoidEvent(new TEvent(aVW, theColor)); } struct TBackgroundEvent: public SALOME_Event { - QWidget* myWidget; + SVTK_ViewWindow* myVW; typedef SALOMEDS::Color TResult; TResult myResult; - TBackgroundEvent(QWidget* theWidget): - myWidget(theWidget) + TBackgroundEvent(SVTK_ViewWindow* theViewWindow): + myVW(theViewWindow) {} virtual void Execute() { - const QColor& aColor = myWidget->backgroundColor(); - myResult.R = aColor.red()/255.0; - myResult.G = aColor.green()/255.0; - myResult.B = aColor.blue()/255.0; + vtkFloatingPointType backint[3]; + GetRenderer(myVW)->GetBackground(backint); + myResult.R = backint[0]; + myResult.G = backint[1]; + myResult.B = backint[2]; } }; @@ -783,28 +841,42 @@ namespace VISU { View_i:: GetBackground() { - return ProcessEvent(new TBackgroundEvent(myViewWindow)); + SVTK_ViewWindow* aVW = dynamic_cast(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 @@ -839,13 +911,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) { @@ -853,16 +925,17 @@ 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()) { - QString fmt = SUIT_Tools::extension(fileName).upper(); + QString fmt = SUIT_Tools::extension(fileName).toUpper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG" ) fmt = "JPEG"; //QApplication::setOverrideCursor(Qt::waitCursor); - img.save(fileName, fmt.latin1()); + img.save(fileName, fmt.toLatin1().data()); + myResult = true; //QApplication::restoreOverrideCursor(); } } @@ -873,12 +946,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 ""; } @@ -889,72 +961,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; + if (myViewWindow) { + QVector aViews = myViewManager->getViews(); + int aPos = aViews.indexOf(myViewWindow); + if (aPos < 0) + myViewWindow = NULL; + } + return myViewWindow; + } - typedef SUIT_ViewManager* TResult; - TResult myResult; + void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow) + { + myViewWindow = theViewWindow; + } - TNewSpecViewEvent (SalomeApp_Application* theApplication): - myApplication(theApplication), - myResult(NULL) - {} - - virtual - void - Execute() - { - myResult = myApplication->getViewManager(TViewer::Type(), true); - } - }; //=========================================================================== 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) @@ -964,27 +1004,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() @@ -992,10 +1053,23 @@ namespace VISU { ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::Repaint)); } + struct TCloseViewEvent: public SALOME_Event + { + SUIT_ViewWindow* myView; + TCloseViewEvent (SUIT_ViewWindow* theView): + myView(theView) + {} + + virtual void Execute() + { + if ( myView ) myView->close(); + } + }; + void XYPlot_i::Close() { - //jfa: may be need to be enclosed in SALOME_Event? - myViewWindow->close(); + ProcessVoidEvent(new TCloseViewEvent(GetViewWindow())); + QApplication::sendPostedEvents(); } XYPlot_i::~XYPlot_i() { @@ -1004,87 +1078,148 @@ 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::setWindowTitle, 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->windowTitle().toLatin1().data()); + 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().toLatin1().data()); + 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 - { - public: - typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool); - TEnableGridEvent (Plot2d_ViewFrame* theView, TFun theFun, - CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor): - myView(theView), myFun(theFun), - myMajor(theMajor), myNumMajor(theNumMajor), - myMinor(theMinor), myNumMinor(theNumMinor) - {} - - virtual void Execute() - { - (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor,true); - } - protected: - Plot2d_ViewFrame* myView; - TFun myFun; - CORBA::Boolean myMajor, myNumMajor; - CORBA::Boolean myMinor, myNumMinor; - }; - 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)); + class TEvent: public SALOME_Event + { + public: + TEvent (Plot2d_ViewFrame* theView, + CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor): + myView(theView), + myMajor(theMajor), + myNumMajor(theNumMajor), + myMinor(theMinor), + myNumMinor(theNumMinor) + {} + + virtual void Execute() + { + myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor ); + } + protected: + Plot2d_ViewFrame* myView; + CORBA::Boolean myMajor, myMinor; + CORBA::Long myNumMajor, myNumMinor; + }; + + if ( GetViewWindow() ) + ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) ); } - void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor) + void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor) { - //jfa tmp:ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid, - //jfa tmp: theMajor,theNumMajor,theMinor,theNumMinor)); + this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 ); } + void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor, + CORBA::Boolean the2Major, + CORBA::Long the2NumMajor, + CORBA::Boolean the2Minor, + CORBA::Long the2NumMinor) + { + class TEvent: public SALOME_Event + { + public: + TEvent (Plot2d_ViewFrame* theView, + CORBA::Boolean theMajor, + CORBA::Long theNumMajor, + CORBA::Boolean theMinor, + CORBA::Long theNumMinor, + CORBA::Boolean the2Major, + CORBA::Long the2NumMajor, + CORBA::Boolean the2Minor, + CORBA::Long the2NumMinor): + myView(theView), + myMajor(theMajor), + myNumMajor(theNumMajor), + myMinor(theMinor), + myNumMinor(theNumMinor), + my2Major(the2Major), + my2NumMajor(the2NumMajor), + my2Minor(the2Minor), + my2NumMinor(the2NumMinor) + {} + + virtual void Execute() + { + myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor, + my2Major, my2NumMajor, my2Minor, my2NumMinor); + } + protected: + Plot2d_ViewFrame* myView; + CORBA::Boolean myMajor, myMinor, my2Major, my2Minor; + CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor; + }; + + if (GetViewWindow()) + ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor, + the2Major, the2NumMajor, the2Minor, the2NumMinor ) ); + } + class TSetScaleModeEvent: public SALOME_Event { public: @@ -1105,26 +1240,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 @@ -1145,28 +1285,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).toLatin1().data()); + 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).toLatin1().data()); + 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 @@ -1190,17 +1335,23 @@ namespace VISU { virtual void Execute() { + Qtx::VisibilityState state = (myDisplaing == eDisplay ||myDisplaing == eDisplayOnly) ? + Qtx::ShownState : Qtx::HiddenState; // is it Curve ? if (Curve_i* aCurve = dynamic_cast(VISU::GetServant(myPrsObj).in())) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); + VISU::SetVisibilityState(aCurve->GetEntry(),state); + VISU::CurveVisibilityChanged(aCurve, myDisplaing , false, true, true); } // is it Container ? if (Container_i* aContainer = dynamic_cast(VISU::GetServant(myPrsObj).in())) { + VISU::SetVisibilityState(aContainer->GetEntry(),state); int nbCurves = aContainer->GetNbCurves(); for ( int i = 1; i <= nbCurves; i++ ) { VISU::Curve_i* aCurve = aContainer->GetCurve( i ); if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); + VISU::CurveVisibilityChanged(aCurve, myDisplaing , true, true, true); } } myView->Repaint(); @@ -1214,19 +1365,22 @@ namespace VISU { } } if (!aCStudy) return; - _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1()); + _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry()); if (TableSO) { _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO); for (; Iter->More(); Iter->Next()) { CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value()); if (!CORBA::is_nil(childObject)) { CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject); - if (!CORBA::is_nil(aCurve)) - UpdatePlot2d(myView, myDisplaing, - dynamic_cast(VISU::GetServant(aCurve).in())); + if (!CORBA::is_nil(aCurve)) { + Curve_i* crv = dynamic_cast(VISU::GetServant(aCurve).in()); + UpdatePlot2d(crv, myDisplaing, myView); + VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true); + } } } myView->Repaint(); + VISU::SetVisibilityState(aTable->GetEntry(),state); } } } @@ -1234,29 +1388,87 @@ 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 + { + public: + TFitRangeEvent (Plot2d_ViewFrame* theView, + const int mode, + const double xMin, const double xMax, + const double yMin, const double yMax): + myView(theView), + myMode(mode), + myXMin(xMin),myXMax(xMax), + myYMin(yMin),myYMax(yMax) + {} + virtual void Execute() + { + myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax); + } + protected: + const int myMode; + const double myXMin; + const double myXMax; + const double myYMin; + const double myYMax; + Plot2d_ViewFrame* myView; + }; + + void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax) + { + const CORBA::Long mode = 1; + const CORBA::Double yMin = 0.0; + const CORBA::Double yMax = 0.0; + ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax)); + } + + void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax) + { + const CORBA::Long mode = 2; + const CORBA::Double xMin = 0.0; + const CORBA::Double xMax = 0.0; + ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax)); + } + + void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax, + const CORBA::Double yMin,const CORBA::Double yMax) + { + const CORBA::Long mode = 0; + ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax)); + } + + void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax) + { + double y2Min,y2Max; + myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max); + } //=========================================================================== TableView_i::TableView_i (SalomeApp_Application* theApplication) @@ -1269,7 +1481,7 @@ namespace VISU { SalomeApp_Application* myApplication; VISU::Table_i* myTable; - typedef VisuGUI_TableDlg* TResult; + typedef VISU_TableDlg* TResult; TResult myResult; TCreateTableViewEvent (SalomeApp_Application* theApplication, @@ -1287,15 +1499,13 @@ namespace VISU { if (SUIT_Study* aSStudy = myApplication->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { - _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry()); - if (aSObject) { - myResult = new VisuGUI_TableDlg (myApplication->desktop(), - aSObject, - false, - VisuGUI_TableDlg::ttAuto, - Qt::Vertical); - myResult->show(); - } + myResult = new VISU_TableDlg (myApplication->desktop(), + aCStudy, + myTable, + false, + VISU_TableDlg::ttAuto, + Qt::Vertical); + myResult->show(); } } } @@ -1326,14 +1536,14 @@ namespace VISU { void TableView_i::SetTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle))); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle))); } char* TableView_i::GetTitle() { //jfa: may be need to be enclosed in SALOME_Event? - return CORBA::string_dup(myView->caption().latin1()); + return CORBA::string_dup(myView->windowTitle().toLatin1().data()); } void TableView_i::Close() @@ -1357,22 +1567,22 @@ 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; + SalomeApp_Application *myApplication; + View3D_i * myView3D; + int myNew; typedef SUIT_ViewWindow* TResult; TResult myResult; - TCreateView3dEvent (SUIT_ViewManager* theViewManager, - const int theNew): - myViewManager(theViewManager), + TCreateView3dEvent (SalomeApp_Application *theApplication, + View3D_i * theView3D, + const int theNew): + myApplication(theApplication), + myView3D(theView3D), myNew(theNew), myResult(NULL) {} @@ -1381,10 +1591,33 @@ namespace VISU { void Execute() { - if (myNew) { - myResult = myViewManager->createViewWindow(); - } else { - myResult = myViewManager->getActiveView(); + if (!myApplication) + return; + + if(myNew){ + if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){ + myResult = aViewManager->createViewWindow(); + myView3D->myViewManager = aViewManager; + }else{ + if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){ + myResult = aViewManager->getActiveView(); + myView3D->myViewManager = aViewManager; + } + } + }else{ + if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){ + if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){ + if(dynamic_cast(aView)){ + myView3D->myViewManager = aViewManager; + myResult = aViewManager->getActiveView(); + } + } + }else{ + if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){ + myView3D->myViewManager = aViewManager; + myResult = aViewManager->getActiveView(); + } + } } } }; @@ -1392,8 +1625,12 @@ namespace VISU { 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(myApplication, this, theNew)); + if (aVW) { + SetViewWindow(aVW); + return this; + } + return NULL; } void View3D_i::Update() @@ -1402,33 +1639,37 @@ namespace VISU { { SUIT_ViewWindow* myViewWindow; public: - TEvent(SUIT_ViewWindow* theStudyFrame): - myViewWindow(theStudyFrame) + TEvent(SUIT_ViewWindow* theViewWindow): + myViewWindow(theViewWindow) {} virtual void Execute() { - SVTK_ViewWindow* vf = GetViewWindow(myViewWindow); - vtkRenderer* Renderer = vf->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - while (vtkActor *anAct = theActors->GetNextActor()) { - if (VISU_Actor* anActor = dynamic_cast(anAct)) { - VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d(); - if (anActor->GetVisibility() && aPrs3d) { - aPrs3d->Update(); - aPrs3d->UpdateActor(anActor); - } + SVTK_ViewWindow* aViewWindow = dynamic_cast(myViewWindow); + vtkRenderer* aRenderer = aViewWindow->getRenderer(); + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection* anActors = aCopy.GetActors(); + anActors->InitTraversal(); + while (vtkActor *anAct = anActors->GetNextActor()) { + if (VISU_ActorBase* anActor = dynamic_cast(anAct)) { + if (anActor->GetVisibility()) + anActor->UpdateFromFactory(); } } RepaintView(myViewWindow); } }; - ProcessVoidEvent(new TEvent(myViewWindow)); + + if (SUIT_ViewWindow* aViewWindow = GetViewWindow()) + ProcessVoidEvent(new TEvent(aViewWindow)); } - bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName) + bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& 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)) { @@ -1438,16 +1679,16 @@ namespace VISU { if (!aCStudy) return false; - if (theName) { - std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU"); + if (theName != "") { + std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU"); _PTR(GenericAttribute) anAttr; int iEnd = aList.size(); for (int i = 0; i < iEnd; i++) { _PTR(SObject) anObj = aList[i]; string anEntry = anObj->GetID(); if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry); - if (anObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aCmnt (anAttr); + if (anObj->FindAttribute(anAttr, "AttributeString")) { + _PTR(AttributeString) aCmnt (anAttr); string aComm (aCmnt->Value()); if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm); if (aComm.compare(View3D_i::myComment) >= 0) { @@ -1459,36 +1700,41 @@ namespace VISU { } _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy); string aSComponentEntry = aSComponent->GetID(); - string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "", + string anEntry = CreateAttributes(aCStudy, + aSComponentEntry.c_str(), + "", + "", + theName, + "", ToString(theViewManager->getActiveView()).c_str()); return true; } class TSaveViewParamsEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; - const char* myName; + SUIT_ViewManager* myViewMgr; + std::string myName; public: TSaveViewParamsEvent (SUIT_ViewManager* theViewManager, - const char* theName): - myViewManager(theViewManager), + const std::string& theName): + 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; }; - CORBA::Boolean View3D_i::SaveViewParams (const char* theName) + CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName) { - return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName)); + return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName)); } - bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName) + bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName) { _PTR(Study) aCStudy; if (SUIT_Study* aSStudy = theViewManager->study()) { @@ -1507,17 +1753,10 @@ namespace VISU { _PTR(SObject) anObj = aList[i]; string anEntry = anObj->GetID(); if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry); - if (anObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aCmnt (anAttr); - QString strIn(aCmnt->Value().c_str()); - Storable::TRestoringMap aMap; - Storable::StrToMap(strIn, aMap); - if (Storable::FindValue(aMap, "myComment").compare - (View3D_i::myComment.c_str()) >= 0) { - if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn); - Restore(theViewManager->getActiveView(), aMap); - return true; - } + Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj); + if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) { + Restore(theViewManager->getActiveView(), aMap); + return true; } } return false; @@ -1525,29 +1764,29 @@ namespace VISU { class TRestoreViewParamsEvent: public SALOME_Event { - SUIT_ViewManager* myViewManager; - const char* myName; + SUIT_ViewManager* myViewMgr; + std::string myName; public: TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager, - const char* theName): - myViewManager(theViewManager), + const std::string& theName): + 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; }; - CORBA::Boolean View3D_i::RestoreViewParams (const char* theName) + CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName) { - return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName)); + return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName)); } - void View3D_i::Restore (SUIT_ViewWindow* theStudyFrame, + void View3D_i::Restore (SUIT_ViewWindow* theViewWindow, const Storable::TRestoringMap& theMap) { SALOMEDS::Color aColor; @@ -1577,59 +1816,57 @@ 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); + vtkFloatingPointType backint[3]; + 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); + (dynamic_cast(theViewWindow))->GetScale(aScaleFactor); Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]); Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]); Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]); @@ -1637,15 +1874,17 @@ 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(); + ProcessVoidEvent(new TCloseViewEvent(GetViewWindow())); + QApplication::sendPostedEvents(); } - + View3D_i::~View3D_i() { if(MYDEBUG) MESSAGE("View3D_i::~View3D_i"); @@ -1653,17 +1892,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::setWindowTitle,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->windowTitle().toLatin1().data()); + 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? @@ -1671,110 +1914,154 @@ 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]); + (dynamic_cast(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); + vtkFloatingPointType backint[3]; + 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); + } + }; + + class TDisplayTableEvent: public SALOME_Event + { + SUIT_ViewWindow* myVW; + PointMap3d_i* myTable; + int myDisplaying; + public: + TDisplayTableEvent( SUIT_ViewWindow* theView, + PointMap3d_i* theTable, + int theDisplaying ) : + myVW (theView), + myTable (theTable), + myDisplaying (theDisplaying) + {} + virtual void Execute() { + SVTK_ViewWindow* aViewWindow = dynamic_cast(myVW); + VISU_PointMap3dActor* anActor = myTable->CreateActor(); + myTable->UpdateActor( anActor ); + aViewWindow->AddActor( anActor ); } }; 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)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, 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)); + else if (aVW && !aPrs) { + PointMap3d_i* aTable = dynamic_cast(VISU::GetServant(anObj).in()); + if (aTable) + ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly)); } } void View3D_i::FitAll() { - ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onFitAll)); - Update(); + SUIT_ViewWindow* aVW = GetViewWindow(); + if (aVW) { + ProcessVoidEvent(new TVoidMemFunEvent + (dynamic_cast(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)); + (dynamic_cast(aVW), &SVTK_ViewWindow::onFrontView)); break; case VISU::View3D::BACK : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow), &SVTK_ViewWindow::onBackView)); + (dynamic_cast(aVW), &SVTK_ViewWindow::onBackView)); break; case VISU::View3D::LEFT : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onLeftView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onLeftView)); break; case VISU::View3D::RIGHT : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onRightView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onRightView)); break; case VISU::View3D::TOP : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onTopView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onTopView)); break; case VISU::View3D::BOTTOM : ProcessVoidEvent(new TVoidMemFunEvent - (GetViewWindow(myViewWindow),&SVTK_ViewWindow::onBottomView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onBottomView)); break; } Update(); @@ -1783,181 +2070,589 @@ 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(&View3D_i::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(&View3D_i::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(&View3D_i::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(&View3D_i::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 = dynamic_cast(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); + (dynamic_cast(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]; + (dynamic_cast(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)); + } + } + + //================================================ + // Certain presentation view parameters management + //================================================ + class TPrsManageEvent: public SALOME_Event + { + protected: + View3D_i* myView3D; + ScalarMap_ptr myPrs; + string myError; + + TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + myView3D(theView3D), + myPrs(ScalarMap::_duplicate(thePrs)), + myError("Unknown error occured") + {} + VISU_Actor* GetMyActor() + { + SUIT_ViewWindow* aVW = myView3D->GetViewWindow(); + SVTK_ViewWindow* vw = dynamic_cast(aVW); + if (!aVW) { + myError = "Corrupted view window"; + } else { + ScalarMap_i* aPrs = dynamic_cast(VISU::GetServant(myPrs).in()); + if (!aPrs) { + myError = "Corrupted presentation"; + } else { + VISU_Actor* anActor = VISU::FindActor(vw, aPrs); + if (!anActor) { + myError = "No actor found. Display the presentation at first."; + } else { + myError = ""; + return anActor; + } + } + } + return NULL; + } + }; + + // Get + class TGetPrsTypeEvent: public TPrsManageEvent { + public: + typedef VISU::PresentationType TResult; + TResult myResult; + TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) + myResult = (VISU::PresentationType)anActor->GetRepresentation(); + } + }; + + class TGetShrinkedEvent: public TPrsManageEvent { + public: + typedef bool TResult; + TResult myResult; + TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(false) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + if (anActor->IsShrunkable()) + myResult = anActor->IsShrunk(); + else + myResult = false; + } + } + }; + + class TGetShadedEvent: public TPrsManageEvent { + public: + typedef bool TResult; + TResult myResult; + TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(false) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) + if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor)) + myResult = aScalarMapActor->IsShading(); + } + }; + + class TGetOpacityEvent: public TPrsManageEvent { + public: + typedef double TResult; + TResult myResult; + TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + vtkFloatingPointType oldvalue = anActor->GetOpacity(); + myResult = (double)oldvalue; + } + } + }; + + class TGetLineWidthEvent: public TPrsManageEvent { + public: + typedef double TResult; + TResult myResult; + TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + vtkFloatingPointType oldvalue = anActor->GetLineWidth(); + myResult = (double)oldvalue; + } + } + }; + + // Set + class TSetPrsTypeEvent: public TPrsManageEvent { + private: + PresentationType myPrsType; + public: + typedef string TResult; + TResult myResult; + TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType): + TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType), + myResult("Unknown error occured") + {} + virtual void Execute() { + VISU::VISUType aType = myPrs->GetType(); + switch (myPrsType) { + case VISU::INSIDEFRAME: + { + if (aType != VISU::TSCALARMAP && + aType != VISU::TDEFORMEDSHAPE && + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) { + myResult = "Insideframe representation is not available for this type of presentations."; + return; + } + } + break; + case VISU::SURFACEFRAME: + { + if (aType != VISU::TSCALARMAP && + aType != VISU::TDEFORMEDSHAPE && + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP && + aType != VISU::TCUTPLANES && + aType != VISU::TISOSURFACES && + aType != VISU::TPLOT3D) { + myResult = "Surfaceframe representation is not available for this type of presentations."; + return; + } + } + break; + case VISU::SHRINK: + myResult = "Use SetShrinked() method to shrink/unshrink presentation."; + return; + default: + break; + } + if (VISU_Actor* anActor = GetMyActor()) { + anActor->SetRepresentation((int)myPrsType); + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = myError; + } + } + }; + + class TSetShrinkedEvent: public TPrsManageEvent { + private: + bool myIsOn; + public: + typedef string TResult; + TResult myResult; + TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn): + TPrsManageEvent(theView3D, thePrs), myIsOn(isOn), + myResult("Unknown error occured") + {} + virtual void Execute() { + VISU::VISUType aType = myPrs->GetType(); + if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) { + myResult = "Shrinked representation is not available for this type of presentations."; + } else { + if (VISU_Actor* anActor = GetMyActor()) { + if (anActor->IsShrunkable()) { + if (myIsOn) anActor->SetShrink(); + else anActor->UnShrink(); + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = "This presentation is not shrunkable."; + } + } else { + myResult = myError; + } + } + } + }; + + class TSetShadedEvent: public TPrsManageEvent { + private: + bool myIsOn; + public: + typedef string TResult; + TResult myResult; + TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn): + TPrsManageEvent(theView3D, thePrs), myIsOn(isOn), + myResult("Unknown error occured") + {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + if (VISU_ScalarMapAct* aScalarMapActor = + dynamic_cast(anActor)) { + aScalarMapActor->SetShading(myIsOn); + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = "Corrupted actor"; + } + } else { + myResult = myError; + } + } + }; + + class TSetOpacityEvent: public TPrsManageEvent { + private: + double myOpacity; + public: + typedef string TResult; + TResult myResult; + TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity): + TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity), + myResult("Unknown error occured") + {} + virtual void Execute() { + VISU::VISUType aType = myPrs->GetType(); + if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) { + myResult = "Opacity is meaningless for this type of presentations."; + return; + } + if (VISU_Actor* anActor = GetMyActor()) { + anActor->SetOpacity((vtkFloatingPointType)myOpacity); + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = myError; + } + } + }; + + class TSetLineWidthEvent: public TPrsManageEvent { + private: + double myLineWidth; + public: + typedef string TResult; + TResult myResult; + TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth): + TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth), + myResult("Unknown error occured") + {} + virtual void Execute() { + if (myPrs->GetType() == VISU::TVECTORS) { + myResult = "Line Width is meaningless for Vectors presentation."; + return; + } + if (VISU_Actor* anActor = GetMyActor()) { + anActor->SetLineWidth((vtkFloatingPointType)myLineWidth); + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = myError; + } + } + }; + + class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent { + private: + Quadratic2DPresentationType myPrsType; + public: + typedef string TResult; + TResult myResult; + TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, + ScalarMap_ptr thePrs, + Quadratic2DPresentationType theType): + TPrsManageEvent(theView3D, thePrs), myPrsType(theType), + myResult("Unknown error occured") + {} + virtual void Execute() + { + VISU::VISUType aType = myPrs->GetType(); + if (aType != VISU::TSCALARMAP && + aType != VISU::TDEFORMEDSHAPE && + aType != VISU::TSCALARMAPONDEFORMEDSHAPE && + aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) { + myResult = "2D Quadratic element representation is not available for this type of presentations."; + return; + } + if (VISU_Actor* anActor = GetMyActor()) { + if(myPrsType == VISU::LINES) + anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines); + else if(myPrsType == VISU::ARCS) + anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs); + + SVTK_ViewWindow* vw = dynamic_cast(myView3D->GetViewWindow()); + vw->Repaint(); + myResult = ""; + } else { + myResult = myError; + } + } + }; + + class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent { + public: + typedef VISU::Quadratic2DPresentationType TResult; + TResult myResult; + TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs): + TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {} + virtual void Execute() { + if (VISU_Actor* anActor = GetMyActor()) { + if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines) + myResult = VISU::LINES; + else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs) + myResult = VISU::ARCS; + } + } + }; + + PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetPrsTypeEvent(this,thePrs)); + } + CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetShrinkedEvent(this,thePrs)); + } + CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetShadedEvent(this,thePrs)); + } + CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetOpacityEvent(this,thePrs)); + } + CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetLineWidthEvent(this,thePrs)); + } + + Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs) + { + return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs)); + } + + char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType) + { + string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType)); + return CORBA::string_dup(aRet.c_str()); + } + char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked) + { + string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked)); + return CORBA::string_dup(aRet.c_str()); + } + char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded) + { + string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded)); + return CORBA::string_dup(aRet.c_str()); + } + char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity) + { + string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity)); + return CORBA::string_dup(aRet.c_str()); + } + char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth) + { + string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth)); + return CORBA::string_dup(aRet.c_str()); + } + + char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType) + { + string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType)); + return CORBA::string_dup(aRet.c_str()); } } + +