1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_View_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_View_i.hh"
29 #include "VISU_Gen_i.hh"
30 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Table_i.hh"
32 #include "VISU_PointMap3d_i.hh"
33 #include "VISU_ScalarMap_i.hh"
34 #include "VISU_ViewManager_i.hh"
36 #include "VisuGUI_TableDlg.h"
38 #include "VISU_Actor.h"
39 #include "VISU_ScalarMapAct.h"
40 #include "VISU_PointMap3dActor.h"
41 #include "VISU_DeformedGridPL.hxx"
43 #include "SALOME_Event.h"
45 #include "SUIT_ViewWindow.h"
46 #include "SUIT_ViewManager.h"
47 #include "SUIT_Tools.h"
49 #include "STD_MDIDesktop.h"
50 #include "STD_TabDesktop.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_ViewModel.h"
55 #include "SPlot2d_ViewModel.h"
56 #include "Plot2d_ViewFrame.h"
58 #include "SalomeApp_Application.h"
59 #include "SalomeApp_Study.h"
61 #include <QtxWorkstack.h>
62 #include <QtxWorkspace.h>
67 #include <vtkCamera.h>
68 #include <vtkRenderer.h>
74 static int MYDEBUG = 0;
76 static int MYDEBUG = 0;
81 typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
83 struct TNewViewEvent: public SALOME_Event
85 SalomeApp_Application* myApplication;
86 typedef QWidget* TResult;
89 TNewViewEvent (SalomeApp_Application* theApplication):
90 myApplication(theApplication),
98 if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
99 myResult = aDesktop->workspace();
105 View_i (SalomeApp_Application *theApplication,
106 SUIT_ViewManager* theViewManager):
107 myApplication(theApplication),
109 myViewManager(theViewManager)
111 if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
112 myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
118 if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
122 struct TApplicationEvent: public SALOME_Event
124 SalomeApp_Application* myApplication;
126 TApplicationEvent(SalomeApp_Application* theApplication):
127 myApplication(theApplication)
133 ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
134 CORBA::Boolean theState)
136 struct TEvent: public TApplicationEvent
138 VISU::View::ViewRepresentation myViewRepresentation;
139 CORBA::Boolean myState;
141 TEvent(SalomeApp_Application* theApplication,
142 VISU::View::ViewRepresentation theViewRepresentation,
143 CORBA::Boolean theState):
144 TApplicationEvent(theApplication),
145 myViewRepresentation(theViewRepresentation),
153 switch(myViewRepresentation){
154 case VISU::View::OBJECTBROWSER:
155 myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState );
157 case VISU::View::PYTHON:
158 myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState );
160 case VISU::View::MESSAGES:
161 myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState );
163 case VISU::View::VIEWER:
165 ViewManagerList mgrs = myApplication->viewManagers();
166 ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end();
167 for( ; anIt!=aLast; anIt++ )
169 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
170 for( int i=0; i<views.count(); i++ )
171 views[i]->setShown( myState );
178 ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
181 struct TPartShownEvent: public TApplicationEvent
183 VISU::View::ViewRepresentation myViewRepresentation;
184 typedef bool TResult;
187 TPartShownEvent(SalomeApp_Application* theApplication,
188 VISU::View::ViewRepresentation theViewRepresentation):
189 TApplicationEvent(theApplication),
190 myViewRepresentation(theViewRepresentation),
198 switch(myViewRepresentation){
199 case VISU::View::OBJECTBROWSER:
200 myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible();
202 case VISU::View::PYTHON:
203 myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible();
205 case VISU::View::MESSAGES:
206 myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible();
208 case VISU::View::VIEWER:{
209 ViewManagerList aViewManagerList = myApplication->viewManagers();
210 ViewManagerList::const_iterator anIt = aViewManagerList.begin();
211 for( ; anIt != aViewManagerList.end(); anIt++ )
213 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
214 for( int i=0; i<views.count(); i++ ) {
215 myResult = views[i]->isVisible();
227 IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
229 return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
232 // Begin: New methods for view parameters management
233 struct TSplitEvent: public SALOME_Event
235 SalomeApp_Application * myApplication;
236 SUIT_ViewWindow * myVW;
237 Qt::Orientation myOrientation;
238 QtxWorkstack::SplitType mySplitType;
241 TSplitEvent (SalomeApp_Application * theApplication,
242 SUIT_ViewWindow * theViewWindow,
243 Qt::Orientation theOrientation,
244 QtxWorkstack::SplitType theSplitType):
245 myApplication(theApplication),
247 myOrientation(theOrientation),
248 mySplitType(theSplitType)
251 virtual void Execute()
253 SUIT_Desktop* desk = myApplication->desktop();
254 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
256 QtxWorkstack* workstack = tabDesk->workstack();
258 workstack->Split(myVW, myOrientation, mySplitType);
268 SUIT_ViewWindow* aVW = GetViewWindow();
270 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
271 Qt::Horizontal, QtxWorkstack::SplitMove));
278 SUIT_ViewWindow* aVW = GetViewWindow();
280 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
281 Qt::Horizontal, QtxWorkstack::SplitStay));
288 SUIT_ViewWindow* aVW = GetViewWindow();
290 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
291 Qt::Vertical, QtxWorkstack::SplitMove));
298 SUIT_ViewWindow* aVW = GetViewWindow();
300 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
301 Qt::Vertical, QtxWorkstack::SplitStay));
308 struct TOnTopEvent: public SALOME_Event
310 SUIT_ViewWindow * myVW;
313 TOnTopEvent (SUIT_ViewWindow * theViewWindow):
317 virtual void Execute()
325 SUIT_ViewWindow* aVW = GetViewWindow();
327 ProcessVoidEvent(new TOnTopEvent(aVW));
330 struct TAttractEvent: public SALOME_Event
332 SalomeApp_Application * myApplication;
333 SUIT_ViewWindow * myVW1;
334 SUIT_ViewWindow * myVW2;
338 TAttractEvent (SalomeApp_Application * theApplication,
339 SUIT_ViewWindow * theViewWindow1,
340 SUIT_ViewWindow * theViewWindow2,
342 myApplication(theApplication),
343 myVW1(theViewWindow1),
344 myVW2(theViewWindow2),
345 myAttractAll(theAttractAll)
348 virtual void Execute()
350 SUIT_Desktop* desk = myApplication->desktop();
351 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
353 QtxWorkstack* workstack = tabDesk->workstack();
355 workstack->Attract(myVW1, myVW2, myAttractAll);
363 Attract (VISU::View_ptr theView)
365 if (!CORBA::is_nil(theView)) {
366 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
368 SUIT_ViewWindow* aVW1 = GetViewWindow();
369 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
371 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false));
379 AttractAll (VISU::View_ptr theView)
381 if (!CORBA::is_nil(theView)) {
382 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
384 SUIT_ViewWindow* aVW1 = GetViewWindow();
385 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
387 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true));
393 struct TSizePositionEvent: public SALOME_Event
395 SalomeApp_Application * myApplication;
396 SUIT_ViewWindow * myVW;
401 TSizePositionEvent (SalomeApp_Application * theApplication,
402 SUIT_ViewWindow * theViewWindow,
405 myApplication(theApplication),
411 virtual void Execute()
413 MESSAGE("TSizePositionEvent::Execute()");
414 SUIT_Desktop* desk = myApplication->desktop();
415 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
417 QtxWorkstack* workstack = tabDesk->workstack();
420 //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue);
422 workstack->SetRelativePositionInSplitter(myVW, myValue);
431 SetRelativePositionInSplitter (CORBA::Double thePosition)
433 if (thePosition < 0.0 || 1.0 < thePosition) {
436 SUIT_ViewWindow* aVW = GetViewWindow();
438 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false));
443 SetRelativeSizeInSplitter (CORBA::Double theSize)
445 if (theSize < 0.0 || 1.0 < theSize) {
448 SUIT_ViewWindow* aVW = GetViewWindow();
450 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true));
453 struct TWSSizePositionEvent: public SALOME_Event
455 SalomeApp_Application * myApplication;
456 SUIT_ViewWindow * myVW;
457 Qt::Orientation myOrientation;
462 TWSSizePositionEvent (SalomeApp_Application * theApplication,
463 SUIT_ViewWindow * theViewWindow,
464 Qt::Orientation theOrientation,
467 myApplication(theApplication),
469 myOrientation(theOrientation),
474 virtual void Execute()
476 MESSAGE("TWSSizePositionEvent::Execute()");
477 SUIT_Desktop* desk = myApplication->desktop();
478 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
480 QtxWorkstack* workstack = tabDesk->workstack();
483 //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue);
485 workstack->SetRelativePosition(myVW, myOrientation, myValue);
494 SetRelativePositionX (CORBA::Double thePosition)
496 if (thePosition < 0.0 || 1.0 < thePosition) {
499 SUIT_ViewWindow* aVW = GetViewWindow();
501 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
502 Qt::Horizontal, thePosition, false));
507 SetRelativePositionY (CORBA::Double thePosition)
509 if (thePosition < 0.0 || 1.0 < thePosition) {
512 SUIT_ViewWindow* aVW = GetViewWindow();
514 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
515 Qt::Vertical, thePosition, false));
520 SetRelativeSizeX (CORBA::Double theSize)
522 if (theSize < 0.0 || 1.0 < theSize) {
525 SUIT_ViewWindow* aVW = GetViewWindow();
527 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
528 Qt::Horizontal, theSize, true));
533 SetRelativeSizeY (CORBA::Double theSize)
535 if (theSize < 0.0 || 1.0 < theSize) {
538 SUIT_ViewWindow* aVW = GetViewWindow();
540 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
541 Qt::Vertical, theSize, true));
543 // End: New methods for view parameters management
545 // Begin: Old methods for view parameters management, they don't work now
546 struct TSetViewSize: public SALOME_Event
548 SUIT_ViewWindow* myVW;
549 typedef void (QRect::* TAction)(int);
554 TSetViewSize(SUIT_ViewWindow* theViewWindow,
556 CORBA::Long theSize):
566 if (QWidget* aParent = myVW->parentWidget()) {
567 QRect aQRect = aParent->frameGeometry();
568 (aQRect.*myAction)(mySize);
569 aParent->setGeometry(aQRect);
576 SetViewWidth(CORBA::Long theWidth)
578 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
583 SetViewHeight(CORBA::Long theHeight)
585 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
589 struct TGetViewSize: public SALOME_Event
591 SUIT_ViewWindow* myVW;
593 typedef int (QRect::* TAction)() const;
596 typedef CORBA::Long TResult;
600 TGetViewSize(SUIT_ViewWindow* theViewWindow,
610 if(QWidget* aParent = myVW->parentWidget()){
611 QRect aQRect = aParent->frameGeometry();
612 myResult = (aQRect.*myAction)();
622 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
629 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
633 class TWorkspaceEvent: public SALOME_Event
637 QWidget* myWorkspace;
640 TWorkspaceEvent(QWidget* theViewWindow,
641 QWidget* theWorkspace):
643 myWorkspace(theWorkspace)
648 class TAlignEvent: public TWorkspaceEvent
651 Qt::AlignmentFlag myAligment;
654 TAlignEvent(QWidget* theViewWindow,
655 QWidget* theWorkspace,
656 Qt::AlignmentFlag theAligment):
657 TWorkspaceEvent(theViewWindow,theWorkspace),
658 myAligment(theAligment)
665 if(QWidget* aParent = myVW->parentWidget())
666 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
673 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
676 switch (theViewPosition) {
677 case VISU::View::LEFT:
678 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
680 case VISU::View::CENTER:
681 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
683 case VISU::View::RIGHT:
684 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
693 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
696 switch (theViewPosition) {
697 case VISU::View::TOP:
698 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
700 case VISU::View::CENTER:
701 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
703 case VISU::View::BOTTOM:
704 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
711 class TXYEvent: public TWorkspaceEvent
714 CORBA::Double myX, myY;
717 TXYEvent(QWidget* theViewWindow,
718 QWidget* theWorkspace,
721 TWorkspaceEvent(theViewWindow,theWorkspace),
730 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
732 struct TEvent: public TXYEvent
735 TEvent(QWidget* theViewWindow,
736 QWidget* theWorkspace,
739 TXYEvent(theViewWindow,theWorkspace,theX,theY)
746 if(QWidget* aParent = myVW->parentWidget())
747 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
752 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
757 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
759 struct TEvent: public TXYEvent
762 TEvent(QWidget* theViewWindow,
763 QWidget* theWorkspace,
766 TXYEvent(theViewWindow,theWorkspace,theX,theY)
773 if(QWidget* aParent = myVW->parentWidget())
774 aParent->setGeometry(aParent->x(),
776 int(myX*myWorkspace->width()),
777 int(myY*myWorkspace->height()));
782 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
784 // End: Old methods for view parameters management, they don't work now
788 SetBackground (const SALOMEDS::Color& theColor)
790 struct TEvent: public SALOME_Event
792 SVTK_ViewWindow* myVW;
793 SALOMEDS::Color myColor;
795 TEvent(SVTK_ViewWindow* theViewWindow,
796 const SALOMEDS::Color& theColor):
800 virtual void Execute(){
802 aColor[0] = int(255.0*myColor.R);
803 aColor[1] = int(255.0*myColor.G);
804 aColor[2] = int(255.0*myColor.B);
805 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
806 myVW->setBackgroundColor(aNewColor);
810 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
812 ProcessVoidEvent(new TEvent(aVW, theColor));
816 struct TBackgroundEvent: public SALOME_Event
818 SVTK_ViewWindow* myVW;
819 typedef SALOMEDS::Color TResult;
822 TBackgroundEvent(SVTK_ViewWindow* theViewWindow):
830 vtkFloatingPointType backint[3];
831 GetRenderer(myVW)->GetBackground(backint);
832 myResult.R = backint[0];
833 myResult.G = backint[1];
834 myResult.B = backint[2];
842 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
844 return ProcessEvent(new TBackgroundEvent(aVW));
846 SALOMEDS::Color aBlack;
857 SUIT_ViewWindow* aVW = GetViewWindow();
859 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized));
866 SUIT_ViewWindow* aVW = GetViewWindow();
868 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal));
875 SUIT_ViewWindow* aVW = GetViewWindow();
877 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized));
892 Erase (PrsObject_ptr thePrsObj)
897 Display (PrsObject_ptr thePrsObj)
902 DisplayOnly (PrsObject_ptr thePrsObj)
910 class TSavePictureEvent: public SALOME_Event
912 SUIT_ViewWindow * myVW;
913 const char * myFileName;
915 typedef CORBA::Boolean TResult;
917 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
918 : myVW(theViewWindow),
919 myFileName(theFileName),
924 virtual void Execute()
927 QImage img = myVW->dumpView();
929 QString fileName (myFileName);
930 if (!fileName.isEmpty()) {
931 QString fmt = SUIT_Tools::extension(fileName).toUpper();
932 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
933 if (fmt == "JPG" ) fmt = "JPEG";
934 //QApplication::setOverrideCursor(Qt::waitCursor);
935 img.save(fileName, fmt.toLatin1().data());
937 //QApplication::restoreOverrideCursor();
945 View_i::SavePicture(const char* theFileName)
947 return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName));
951 View_i::GetComment() const
958 ToStream (std::ostringstream& theStr)
962 SUIT_ViewWindow* View_i::GetViewWindow()
965 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
966 int aPos = aViews.indexOf(myViewWindow);
973 void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow)
975 myViewWindow = theViewWindow;
979 //===========================================================================
980 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
981 : View_i(theApplication, NULL)
983 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
986 struct TCreatePlot2dViewEvent: public SALOME_Event
988 XYPlot_i * myPlot2dView;
991 typedef Plot2d_ViewFrame* TResult;
994 TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView,
996 myPlot2dView(thePlot2dView),
1005 if (!myPlot2dView->myApplication)
1008 SUIT_ViewManager* aViewMgr =
1009 myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false);
1010 SUIT_ViewWindow* aVW = NULL;
1014 aVW = aViewMgr->createViewWindow();
1016 aVW = aViewMgr->getActiveView();
1019 aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true);
1020 aVW = aViewMgr->getActiveView();
1022 return; // there are no current Plot2d view
1027 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(aVW);
1029 myResult = aPlot2dVW->getViewFrame();
1031 myResult->Repaint();
1034 myPlot2dView->myViewManager = aViewMgr;
1035 myPlot2dView->SetViewWindow(aVW);
1041 Storable* XYPlot_i::Create (int theNew)
1043 myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew));
1049 void XYPlot_i::Update()
1051 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1054 void XYPlot_i::Close()
1056 //jfa: may be need to be enclosed in SALOME_Event?
1057 SUIT_ViewWindow* aVW = GetViewWindow();
1060 //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
1061 //int aPos = aViews.find(myViewWindow);
1063 // myViewWindow->close();
1066 XYPlot_i::~XYPlot_i() {
1067 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1070 void XYPlot_i::SetTitle (const char* theTitle)
1072 SUIT_ViewWindow* aVW = GetViewWindow();
1074 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1075 (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle)));
1077 char* XYPlot_i::GetTitle()
1079 SUIT_ViewWindow* aVW = GetViewWindow();
1081 return CORBA::string_dup( aVW->windowTitle().toLatin1().data());
1082 return CORBA::string_dup("");
1085 void XYPlot_i::SetSubTitle (const char* theTitle)
1087 if (GetViewWindow())
1088 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1089 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1092 char* XYPlot_i::GetSubTitle()
1094 if (GetViewWindow())
1095 return CORBA::string_dup(myView->getTitle().toLatin1().data());
1096 return CORBA::string_dup("");
1099 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1101 if (GetViewWindow())
1102 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1103 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1106 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1108 if (GetViewWindow())
1109 return (VISU::XYPlot::CurveType)myView->getCurveType();
1110 return VISU::XYPlot::POINTS;
1113 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1115 if (GetViewWindow())
1116 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1117 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1120 CORBA::Long XYPlot_i::GetMarkerSize()
1122 if (GetViewWindow())
1123 return myView->getMarkerSize();
1127 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1128 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1130 class TEvent: public SALOME_Event
1133 TEvent (Plot2d_ViewFrame* theView,
1134 CORBA::Boolean theMajor,
1135 CORBA::Long theNumMajor,
1136 CORBA::Boolean theMinor,
1137 CORBA::Long theNumMinor):
1140 myNumMajor(theNumMajor),
1142 myNumMinor(theNumMinor)
1145 virtual void Execute()
1147 myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor );
1150 Plot2d_ViewFrame* myView;
1151 CORBA::Boolean myMajor, myMinor;
1152 CORBA::Long myNumMajor, myNumMinor;
1155 if ( GetViewWindow() )
1156 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) );
1158 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1159 CORBA::Long theNumMajor,
1160 CORBA::Boolean theMinor,
1161 CORBA::Long theNumMinor)
1163 this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 );
1166 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1167 CORBA::Long theNumMajor,
1168 CORBA::Boolean theMinor,
1169 CORBA::Long theNumMinor,
1170 CORBA::Boolean the2Major,
1171 CORBA::Long the2NumMajor,
1172 CORBA::Boolean the2Minor,
1173 CORBA::Long the2NumMinor)
1175 class TEvent: public SALOME_Event
1178 TEvent (Plot2d_ViewFrame* theView,
1179 CORBA::Boolean theMajor,
1180 CORBA::Long theNumMajor,
1181 CORBA::Boolean theMinor,
1182 CORBA::Long theNumMinor,
1183 CORBA::Boolean the2Major,
1184 CORBA::Long the2NumMajor,
1185 CORBA::Boolean the2Minor,
1186 CORBA::Long the2NumMinor):
1189 myNumMajor(theNumMajor),
1191 myNumMinor(theNumMinor),
1192 my2Major(the2Major),
1193 my2NumMajor(the2NumMajor),
1194 my2Minor(the2Minor),
1195 my2NumMinor(the2NumMinor)
1198 virtual void Execute()
1200 myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor,
1201 my2Major, my2NumMajor, my2Minor, my2NumMinor);
1204 Plot2d_ViewFrame* myView;
1205 CORBA::Boolean myMajor, myMinor, my2Major, my2Minor;
1206 CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor;
1209 if (GetViewWindow())
1210 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor,
1211 the2Major, the2NumMajor, the2Minor, the2NumMinor ) );
1214 class TSetScaleModeEvent: public SALOME_Event
1217 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1218 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1219 myView(theView), myFun(theFun), myScaling(theScaling)
1222 virtual void Execute()
1224 (myView->*myFun)(myScaling,true);
1227 Plot2d_ViewFrame* myView;
1232 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1234 if (GetViewWindow())
1235 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1236 theScaling == VISU::LOGARITHMIC));
1239 VISU::Scaling XYPlot_i::GetHorScaling()
1241 //jfa: may be need to be enclosed in SALOME_Event?
1242 if (GetViewWindow())
1243 return (VISU::Scaling)myView->getHorScaleMode();
1244 return VISU::LINEAR;
1247 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1249 if (GetViewWindow())
1250 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1251 theScaling == VISU::LOGARITHMIC));
1254 VISU::Scaling XYPlot_i::GetVerScaling()
1256 if (GetViewWindow())
1257 return (VISU::Scaling)myView->getVerScaleMode();
1258 return VISU::LINEAR;
1261 class TSetTitleEvent: public SALOME_Event
1264 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1265 myView(theView), myType(theType), myTitle(theTitle)
1267 virtual void Execute()
1269 myView->setTitle(true,myTitle,myType);
1272 Plot2d_ViewFrame* myView;
1273 Plot2d_ViewFrame::ObjectType myType;
1274 const char* myTitle;
1277 void XYPlot_i::SetXTitle (const char* theTitle)
1279 if (GetViewWindow())
1280 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1282 char* XYPlot_i::GetXTitle()
1284 if (GetViewWindow())
1285 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data());
1286 return CORBA::string_dup("");
1289 void XYPlot_i::SetYTitle (const char* theTitle)
1291 if (GetViewWindow())
1292 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1294 char* XYPlot_i::GetYTitle()
1296 if (GetViewWindow())
1297 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data());
1298 return CORBA::string_dup("");
1301 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1303 if (GetViewWindow())
1304 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1305 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1308 class TXYPlotViewEvent: public SALOME_Event
1310 SalomeApp_Application* myApplication;
1311 Plot2d_ViewFrame* myView;
1312 PrsObject_ptr myPrsObj;
1316 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1317 Plot2d_ViewFrame* theView,
1318 PrsObject_ptr thePrsObj,
1320 : myApplication(theApplication),
1322 myPrsObj(thePrsObj),
1323 myDisplaing(theDisplaing)
1327 virtual void Execute()
1330 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1331 UpdatePlot2d(myView,myDisplaing,aCurve);
1333 // is it Container ?
1334 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1335 int nbCurves = aContainer->GetNbCurves();
1336 for ( int i = 1; i <= nbCurves; i++ ) {
1337 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1338 if ( aCurve && aCurve->IsValid() ) {
1339 UpdatePlot2d(myView,myDisplaing,aCurve);
1345 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1346 _PTR(Study) aCStudy;
1347 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1348 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1349 aCStudy = aStudy->studyDS();
1352 if (!aCStudy) return;
1353 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
1355 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1356 for (; Iter->More(); Iter->Next()) {
1357 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1358 if (!CORBA::is_nil(childObject)) {
1359 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1360 if (!CORBA::is_nil(aCurve))
1361 UpdatePlot2d(myView, myDisplaing,
1362 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
1371 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1373 if (GetViewWindow())
1374 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1377 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1379 if (GetViewWindow())
1380 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1383 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1385 if (GetViewWindow())
1386 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1389 void XYPlot_i::EraseAll()
1391 if (GetViewWindow())
1392 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1395 void XYPlot_i::FitAll()
1397 if (GetViewWindow())
1398 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1401 class TFitRangeEvent: public SALOME_Event
1404 TFitRangeEvent (Plot2d_ViewFrame* theView,
1406 const double xMin, const double xMax,
1407 const double yMin, const double yMax):
1410 myXMin(xMin),myXMax(xMax),
1411 myYMin(yMin),myYMax(yMax)
1413 virtual void Execute()
1415 myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1419 const double myXMin;
1420 const double myXMax;
1421 const double myYMin;
1422 const double myYMax;
1423 Plot2d_ViewFrame* myView;
1426 void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1428 const CORBA::Long mode = 1;
1429 const CORBA::Double yMin = 0.0;
1430 const CORBA::Double yMax = 0.0;
1431 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1434 void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1436 const CORBA::Long mode = 2;
1437 const CORBA::Double xMin = 0.0;
1438 const CORBA::Double xMax = 0.0;
1439 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1442 void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1443 const CORBA::Double yMin,const CORBA::Double yMax)
1445 const CORBA::Long mode = 0;
1446 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1449 void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1452 myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1455 //===========================================================================
1456 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1457 : View_i(theApplication, NULL)
1461 struct TCreateTableViewEvent: public SALOME_Event
1463 SalomeApp_Application* myApplication;
1464 VISU::Table_i* myTable;
1466 typedef VisuGUI_TableDlg* TResult;
1469 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1470 VISU::Table_i* theTable):
1471 myApplication(theApplication),
1480 if (myTable != NULL) {
1481 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1482 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1483 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1484 _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1486 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1489 VisuGUI_TableDlg::ttAuto,
1500 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1502 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1503 if (!theTable->_is_nil()) {
1504 VISU::Table_i* table =
1505 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1506 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1508 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1515 TableView_i::~TableView_i()
1517 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1521 void TableView_i::SetTitle (const char* theTitle)
1523 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1524 (myView, &VisuGUI_TableDlg::setWindowTitle, QString(theTitle)));
1527 char* TableView_i::GetTitle()
1529 //jfa: may be need to be enclosed in SALOME_Event?
1530 return CORBA::string_dup(myView->windowTitle().toLatin1().data());
1533 void TableView_i::Close()
1535 //jfa: may be need to be enclosed in SALOME_Event?
1540 //===========================================================================
1541 int View3D_i::myNbViewParams = 0;
1542 const string View3D_i::myComment = "VIEW3D";
1543 const char* View3D_i::GetComment() const { return myComment.c_str();}
1545 QString View3D_i::GenerateViewParamsName()
1547 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1550 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1551 : View_i(theApplication, NULL)
1553 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1556 struct TCreateView3dEvent: public SALOME_Event
1558 SalomeApp_Application *myApplication;
1559 View3D_i * myView3D;
1562 typedef SUIT_ViewWindow* TResult;
1565 TCreateView3dEvent (SalomeApp_Application *theApplication,
1566 View3D_i * theView3D,
1568 myApplication(theApplication),
1569 myView3D(theView3D),
1582 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1583 myResult = aViewManager->createViewWindow();
1584 myView3D->myViewManager = aViewManager;
1586 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){
1587 myResult = aViewManager->getActiveView();
1588 myView3D->myViewManager = aViewManager;
1592 if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){
1593 if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){
1594 if(dynamic_cast<SVTK_ViewWindow*>(aView)){
1595 myView3D->myViewManager = aViewManager;
1596 myResult = aViewManager->getActiveView();
1600 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1601 myView3D->myViewManager = aViewManager;
1602 myResult = aViewManager->getActiveView();
1609 Storable* View3D_i::Create (int theNew)
1611 if (MYDEBUG) MESSAGE("View3D_i::Create");
1612 SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(myApplication, this, theNew));
1620 void View3D_i::Update()
1622 class TEvent: public SALOME_Event
1624 SUIT_ViewWindow* myViewWindow;
1626 TEvent(SUIT_ViewWindow* theViewWindow):
1627 myViewWindow(theViewWindow)
1629 virtual void Execute()
1631 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
1632 vtkRenderer* aRenderer = aViewWindow->getRenderer();
1633 vtkActorCollection* anActors = aRenderer->GetActors();
1634 anActors->InitTraversal();
1635 while (vtkActor *anAct = anActors->GetNextActor()) {
1636 if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
1637 if (anActor->GetVisibility())
1638 anActor->UpdateFromFactory();
1641 RepaintView(myViewWindow);
1645 if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
1646 ProcessVoidEvent(new TEvent(aViewWindow));
1649 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1651 MESSAGE("View3D_i::SaveViewParams()");
1653 if (!theViewManager || theName == "")
1656 _PTR(Study) aCStudy;
1657 if (SUIT_Study* aSStudy = theViewManager->study()) {
1658 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1659 aCStudy = aStudy->studyDS();
1665 if (theName != "") {
1666 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
1667 _PTR(GenericAttribute) anAttr;
1668 int iEnd = aList.size();
1669 for (int i = 0; i < iEnd; i++) {
1670 _PTR(SObject) anObj = aList[i];
1671 string anEntry = anObj->GetID();
1672 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1673 if (anObj->FindAttribute(anAttr, "AttributeString")) {
1674 _PTR(AttributeString) aCmnt (anAttr);
1675 string aComm (aCmnt->Value());
1676 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1677 if (aComm.compare(View3D_i::myComment) >= 0) {
1678 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1684 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1685 string aSComponentEntry = aSComponent->GetID();
1686 string anEntry = CreateAttributes(aCStudy,
1687 aSComponentEntry.c_str(),
1692 ToString(theViewManager->getActiveView()).c_str());
1696 class TSaveViewParamsEvent: public SALOME_Event
1698 SUIT_ViewManager* myViewMgr;
1701 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1702 const std::string& theName):
1703 myViewMgr(theViewManager),
1707 virtual void Execute()
1709 myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1711 typedef CORBA::Boolean TResult;
1715 CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
1717 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
1720 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1722 _PTR(Study) aCStudy;
1723 if (SUIT_Study* aSStudy = theViewManager->study()) {
1724 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1725 aCStudy = aStudy->studyDS();
1731 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1732 _PTR(GenericAttribute) anAttr;
1733 int iEnd = aList.size();
1734 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1735 for (int i = 0; i < iEnd; i++) {
1736 _PTR(SObject) anObj = aList[i];
1737 string anEntry = anObj->GetID();
1738 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1739 Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
1740 if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
1741 Restore(theViewManager->getActiveView(), aMap);
1748 class TRestoreViewParamsEvent: public SALOME_Event
1750 SUIT_ViewManager* myViewMgr;
1753 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1754 const std::string& theName):
1755 myViewMgr(theViewManager),
1759 virtual void Execute()
1761 myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1763 typedef CORBA::Boolean TResult;
1767 CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
1769 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
1772 void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1773 const Storable::TRestoringMap& theMap)
1775 SALOMEDS::Color aColor;
1776 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1777 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1778 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1780 double aPosition[3];
1781 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1782 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1783 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1785 double aFocalPnt[3];
1786 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1787 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1788 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1791 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1792 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1793 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1795 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1797 double aScaleFactor[3];
1798 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1799 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1800 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1802 SetBackground(theViewWindow,aColor);
1803 SetPointOfView(theViewWindow,aPosition);
1804 SetViewUp(theViewWindow,aViewUp);
1805 SetFocalPoint(theViewWindow,aFocalPnt);
1806 SetParallelScale(theViewWindow,aParallelScale);
1807 ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]);
1808 ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]);
1809 ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]);
1813 string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1815 ostringstream strOut;
1816 Storable::DataToStream(strOut, "myComment", myComment.c_str());
1817 ToStream(theViewWindow, strOut);
1819 if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1820 return strOut.str();
1823 void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1825 vtkFloatingPointType backint[3];
1826 GetRenderer(theViewWindow)->GetBackground(backint);
1827 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1828 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1829 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1831 double aPosition[3];
1832 GetPointOfView(theViewWindow,aPosition);
1833 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1834 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1835 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1837 double aFocalPnt[3];
1838 GetFocalPoint(theViewWindow,aFocalPnt);
1839 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1840 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1841 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1844 GetCamera(theViewWindow)->GetViewUp(aViewUp);
1845 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1846 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1847 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1849 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1851 double aScaleFactor[3];
1852 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->GetScale(aScaleFactor);
1853 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1854 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1855 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1858 void View3D_i::ToStream(std::ostringstream& theStr)
1860 SUIT_ViewWindow* aVW = GetViewWindow();
1862 ToStream(aVW, theStr);
1865 void View3D_i::Close()
1867 //jfa: may be need to be enclosed in SALOME_Event?
1868 SUIT_ViewWindow* aVW = GetViewWindow();
1871 //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
1872 //int aPos = aViews.find(myViewWindow);
1874 // myViewWindow->close();
1877 View3D_i::~View3D_i()
1879 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1882 void View3D_i::SetTitle (const char* theTitle)
1884 SUIT_ViewWindow* aVW = GetViewWindow();
1886 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1887 (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
1890 char* View3D_i::GetTitle()
1892 SUIT_ViewWindow* aVW = GetViewWindow();
1894 return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
1895 return CORBA::string_dup("");
1898 void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1899 const SALOMEDS::Color& theColor)
1901 //jfa: may be need to be enclosed in SALOME_Event?
1903 aColor[0] = int(255.0*theColor.R);
1904 aColor[1] = int(255.0*theColor.G);
1905 aColor[2] = int(255.0*theColor.B);
1906 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1907 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->setBackgroundColor(aNewColor);
1910 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1912 SALOMEDS::Color aColor;
1913 vtkFloatingPointType backint[3];
1914 GetRenderer(theViewWindow)->GetBackground(backint);
1915 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1919 class TUpdateViewerEvent: public SALOME_Event
1921 SUIT_ViewWindow* myVW;
1925 TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1928 myVW(theViewWindow),
1930 myDisplaing(theDisplaing)
1932 virtual void Execute(){
1933 UpdateViewer(myVW, myDisplaing, myPrs3d);
1937 class TDisplayTableEvent: public SALOME_Event
1939 SUIT_ViewWindow* myVW;
1940 PointMap3d_i* myTable;
1943 TDisplayTableEvent( SUIT_ViewWindow* theView,
1944 PointMap3d_i* theTable,
1945 int theDisplaying ) :
1948 myDisplaying (theDisplaying)
1950 virtual void Execute() {
1951 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
1952 VISU_PointMap3dActor* anActor = myTable->CreateActor();
1953 myTable->UpdateActor( anActor );
1954 aViewWindow->AddActor( anActor );
1958 void View3D_i::EraseAll()
1960 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1961 SUIT_ViewWindow* aVW = GetViewWindow();
1963 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1966 void View3D_i::DisplayAll()
1968 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1969 SUIT_ViewWindow* aVW = GetViewWindow();
1971 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1974 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1976 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1977 SUIT_ViewWindow* aVW = GetViewWindow();
1978 CORBA::Object_ptr anObj = thePrsObj;
1979 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1981 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1984 void View3D_i::Display (PrsObject_ptr thePrsObj)
1986 if(MYDEBUG) MESSAGE("View3D_i::Display");
1987 SUIT_ViewWindow* aVW = GetViewWindow();
1988 CORBA::Object_ptr anObj = thePrsObj;
1989 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1991 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
1992 else if (aVW && !aPrs) {
1993 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
1995 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
1999 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
2001 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
2002 SUIT_ViewWindow* aVW = GetViewWindow();
2003 CORBA::Object_ptr anObj = thePrsObj;
2004 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2006 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
2007 else if (aVW && !aPrs) {
2008 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2010 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
2014 void View3D_i::FitAll()
2016 SUIT_ViewWindow* aVW = GetViewWindow();
2018 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2019 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFitAll));
2024 void View3D_i::SetView (VISU::View3D::ViewType theType)
2026 SUIT_ViewWindow* aVW = GetViewWindow();
2031 case VISU::View3D::FRONT :
2032 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2033 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFrontView));
2035 case VISU::View3D::BACK :
2036 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2037 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onBackView));
2039 case VISU::View3D::LEFT :
2040 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2041 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onLeftView));
2043 case VISU::View3D::RIGHT :
2044 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2045 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onRightView));
2047 case VISU::View3D::TOP :
2048 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2049 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onTopView));
2051 case VISU::View3D::BOTTOM :
2052 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2053 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onBottomView));
2059 class TSet3DViewParamEvent: public SALOME_Event
2062 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
2063 TSet3DViewParamEvent (TFun theFun,
2064 SUIT_ViewWindow* theViewWindow,
2065 const CORBA::Double theParam[3]):
2067 myVW(theViewWindow),
2070 virtual void Execute() {
2071 myFun(myVW,myParam);
2075 SUIT_ViewWindow* myVW;
2076 const CORBA::Double* myParam;
2079 void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
2080 const CORBA::Double thePosition[3])
2082 //jfa: may be need to be enclosed in SALOME_Event?
2083 GetCamera(theViewWindow)->SetPosition(thePosition);
2086 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
2088 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
2089 SUIT_ViewWindow* aVW = GetViewWindow();
2091 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
2094 void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
2095 CORBA::Double thePosition[3])
2097 GetCamera(theViewWindow)->GetPosition(thePosition);
2100 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
2102 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
2103 CORBA::Double aPosition[3];
2104 SUIT_ViewWindow* aVW = GetViewWindow();
2106 GetPointOfView(aVW,aPosition);
2107 return VISU::View3D::XYZ_dup(aPosition);
2110 void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2111 const CORBA::Double theViewUp[3])
2113 GetCamera(theViewWindow)->SetViewUp(theViewUp);
2116 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2118 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2119 SUIT_ViewWindow* aVW = GetViewWindow();
2121 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
2124 void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2125 CORBA::Double theViewUp[3])
2127 GetCamera(theViewWindow)->GetViewUp(theViewUp);
2130 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2132 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2133 CORBA::Double aViewUp[3];
2134 SUIT_ViewWindow* aVW = GetViewWindow();
2136 GetCamera(aVW)->GetViewUp(aViewUp);
2137 return VISU::View3D::XYZ_dup(aViewUp);
2140 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2141 const CORBA::Double theFocalPnt[3])
2143 GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2146 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2148 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2149 SUIT_ViewWindow* aVW = GetViewWindow();
2151 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
2155 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2156 CORBA::Double theFocalPnt[3])
2158 GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2161 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2163 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2164 CORBA::Double aFocalPnt[3];
2165 SUIT_ViewWindow* aVW = GetViewWindow();
2167 GetFocalPoint(aVW,aFocalPnt);
2168 return VISU::View3D::XYZ_dup(aFocalPnt);
2171 class TSetViewParamEvent: public SALOME_Event
2174 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2175 TSetViewParamEvent (TFun theFun,
2176 SUIT_ViewWindow* theViewWindow,
2177 CORBA::Double theParam):
2179 myVW(theViewWindow),
2182 virtual void Execute()
2184 myFun(myVW,myParam);
2188 SUIT_ViewWindow* myVW;
2189 CORBA::Double myParam;
2192 void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2193 CORBA::Double theScale)
2195 GetCamera(theViewWindow)->SetParallelScale(theScale);
2198 void View3D_i::SetParallelScale (CORBA::Double theScale)
2200 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2201 SUIT_ViewWindow* aVW = GetViewWindow();
2203 ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
2206 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2208 return GetCamera(theViewWindow)->GetParallelScale();
2211 CORBA::Double View3D_i::GetParallelScale()
2213 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2214 SUIT_ViewWindow* aVW = GetViewWindow();
2216 return GetParallelScale(aVW);
2220 void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2221 VISU::View3D::Axis theAxis, CORBA::Double theParam)
2223 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
2224 double aScaleFactor[3];
2225 aViewWindow->GetScale(aScaleFactor);
2226 aScaleFactor[theAxis] = theParam;
2227 aViewWindow->SetScale(aScaleFactor);
2230 void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2232 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2233 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->SetScale(aScale);
2236 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2238 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2239 SUIT_ViewWindow* aVW = GetViewWindow();
2242 (dynamic_cast<SVTK_ViewWindow*>(aVW))->GetScale(aScale);
2243 aScale[theAxis] = theParam;
2244 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2248 void View3D_i::RemoveScale()
2250 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2251 SUIT_ViewWindow* aVW = GetViewWindow();
2253 double aScale[3] = {1.0, 1.0, 1.0};
2254 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2258 //================================================
2259 // Certain presentation view parameters management
2260 //================================================
2261 class TPrsManageEvent: public SALOME_Event
2265 ScalarMap_ptr myPrs;
2268 TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2269 myView3D(theView3D),
2270 myPrs(ScalarMap::_duplicate(thePrs)),
2271 myError("Unknown error occured")
2273 VISU_Actor* GetMyActor()
2275 SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
2276 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
2278 myError = "Corrupted view window";
2280 ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
2282 myError = "Corrupted presentation";
2284 VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
2286 myError = "No actor found. Display the presentation at first.";
2298 class TGetPrsTypeEvent: public TPrsManageEvent {
2300 typedef VISU::PresentationType TResult;
2302 TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2303 TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
2304 virtual void Execute() {
2305 if (VISU_Actor* anActor = GetMyActor())
2306 myResult = (VISU::PresentationType)anActor->GetRepresentation();
2310 class TGetShrinkedEvent: public TPrsManageEvent {
2312 typedef bool TResult;
2314 TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2315 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2316 virtual void Execute() {
2317 if (VISU_Actor* anActor = GetMyActor()) {
2318 if (anActor->IsShrunkable())
2319 myResult = anActor->IsShrunk();
2326 class TGetShadedEvent: public TPrsManageEvent {
2328 typedef bool TResult;
2330 TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2331 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2332 virtual void Execute() {
2333 if (VISU_Actor* anActor = GetMyActor())
2334 if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
2335 myResult = aScalarMapActor->IsShading();
2339 class TGetOpacityEvent: public TPrsManageEvent {
2341 typedef double TResult;
2343 TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2344 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2345 virtual void Execute() {
2346 if (VISU_Actor* anActor = GetMyActor()) {
2347 vtkFloatingPointType oldvalue = anActor->GetOpacity();
2348 myResult = (double)oldvalue;
2353 class TGetLineWidthEvent: public TPrsManageEvent {
2355 typedef double TResult;
2357 TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2358 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2359 virtual void Execute() {
2360 if (VISU_Actor* anActor = GetMyActor()) {
2361 vtkFloatingPointType oldvalue = anActor->GetLineWidth();
2362 myResult = (double)oldvalue;
2368 class TSetPrsTypeEvent: public TPrsManageEvent {
2370 PresentationType myPrsType;
2372 typedef string TResult;
2374 TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
2375 TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
2376 myResult("Unknown error occured")
2378 virtual void Execute() {
2379 switch (myPrsType) {
2380 case VISU::INSIDEFRAME:
2382 VISU::VISUType aType = myPrs->GetType();
2383 if (aType != VISU::TSCALARMAP &&
2384 aType != VISU::TDEFORMEDSHAPE &&
2385 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2386 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2387 myResult = "Insideframe representation is not available for this type of presentations.";
2392 case VISU::SURFACEFRAME:
2393 myResult = "Surfaceframe representation is available only for mesh presentation.";
2396 myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
2401 if (VISU_Actor* anActor = GetMyActor()) {
2402 anActor->SetRepresentation((int)myPrsType);
2403 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2412 class TSetShrinkedEvent: public TPrsManageEvent {
2416 typedef string TResult;
2418 TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2419 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2420 myResult("Unknown error occured")
2422 virtual void Execute() {
2423 VISU::VISUType aType = myPrs->GetType();
2424 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2425 myResult = "Shrinked representation is not available for this type of presentations.";
2427 if (VISU_Actor* anActor = GetMyActor()) {
2428 if (anActor->IsShrunkable()) {
2429 if (myIsOn) anActor->SetShrink();
2430 else anActor->UnShrink();
2431 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2435 myResult = "This presentation is not shrunkable.";
2444 class TSetShadedEvent: public TPrsManageEvent {
2448 typedef string TResult;
2450 TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2451 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2452 myResult("Unknown error occured")
2454 virtual void Execute() {
2455 if (VISU_Actor* anActor = GetMyActor()) {
2456 if (VISU_ScalarMapAct* aScalarMapActor =
2457 dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
2458 aScalarMapActor->SetShading(myIsOn);
2459 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2463 myResult = "Corrupted actor";
2471 class TSetOpacityEvent: public TPrsManageEvent {
2475 typedef string TResult;
2477 TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
2478 TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
2479 myResult("Unknown error occured")
2481 virtual void Execute() {
2482 VISU::VISUType aType = myPrs->GetType();
2483 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2484 myResult = "Opacity is meaningless for this type of presentations.";
2487 if (VISU_Actor* anActor = GetMyActor()) {
2488 anActor->SetOpacity((vtkFloatingPointType)myOpacity);
2489 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2498 class TSetLineWidthEvent: public TPrsManageEvent {
2502 typedef string TResult;
2504 TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
2505 TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
2506 myResult("Unknown error occured")
2508 virtual void Execute() {
2509 if (myPrs->GetType() == VISU::TVECTORS) {
2510 myResult = "Line Width is meaningless for Vectors presentation.";
2513 if (VISU_Actor* anActor = GetMyActor()) {
2514 anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
2515 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2524 PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
2526 return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
2528 CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
2530 return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
2532 CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
2534 return ProcessEvent(new TGetShadedEvent(this,thePrs));
2536 CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
2538 return ProcessEvent(new TGetOpacityEvent(this,thePrs));
2540 CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
2542 return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
2545 char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
2547 string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
2548 return CORBA::string_dup(aRet.c_str());
2550 char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
2552 string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
2553 return CORBA::string_dup(aRet.c_str());
2555 char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
2557 string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
2558 return CORBA::string_dup(aRet.c_str());
2560 char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
2562 string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
2563 return CORBA::string_dup(aRet.c_str());
2565 char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
2567 string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
2568 return CORBA::string_dup(aRet.c_str());