1 // Copyright (C) 2007-2010 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_View_i.cc
25 // Author : Alexey PETROV
28 #include "VISU_View_i.hh"
30 #include "VISU_Gen_i.hh"
31 #include "VISU_Prs3d_i.hh"
32 #include "VISU_Table_i.hh"
33 #include "VISU_PointMap3d_i.hh"
34 #include "VISU_ScalarMap_i.hh"
35 #include "VISU_ViewManager_i.hh"
36 #include "VISU_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"
54 #include "VTKViewer_Algorithm.h"
56 #include "SPlot2d_ViewModel.h"
57 #include "Plot2d_ViewFrame.h"
59 #include "SalomeApp_Application.h"
60 #include "SalomeApp_Study.h"
62 #include <QtxWorkstack.h>
63 #include <QtxWorkspace.h>
68 #include <vtkCamera.h>
69 #include <vtkRenderer.h>
75 static int MYDEBUG = 0;
77 static int MYDEBUG = 0;
82 typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
84 struct TNewViewEvent: public SALOME_Event
86 SalomeApp_Application* myApplication;
87 typedef QWidget* TResult;
90 TNewViewEvent (SalomeApp_Application* theApplication):
91 myApplication(theApplication),
99 if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
100 myResult = aDesktop->workspace();
106 View_i (SalomeApp_Application *theApplication,
107 SUIT_ViewManager* theViewManager):
108 myApplication(theApplication),
110 myViewManager(theViewManager)
112 if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
113 myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
119 if(MYDEBUG) MESSAGE("View_i::~View_i - "<<this);
123 struct TApplicationEvent: public SALOME_Event
125 SalomeApp_Application* myApplication;
127 TApplicationEvent(SalomeApp_Application* theApplication):
128 myApplication(theApplication)
134 ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
135 CORBA::Boolean theState)
137 struct TEvent: public TApplicationEvent
139 VISU::View::ViewRepresentation myViewRepresentation;
140 CORBA::Boolean myState;
142 TEvent(SalomeApp_Application* theApplication,
143 VISU::View::ViewRepresentation theViewRepresentation,
144 CORBA::Boolean theState):
145 TApplicationEvent(theApplication),
146 myViewRepresentation(theViewRepresentation),
154 switch(myViewRepresentation){
155 case VISU::View::OBJECTBROWSER:
156 myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState );
158 case VISU::View::PYTHON:
159 myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState );
161 case VISU::View::MESSAGES:
162 myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState );
164 case VISU::View::VIEWER:
166 ViewManagerList mgrs = myApplication->viewManagers();
167 ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end();
168 for( ; anIt!=aLast; anIt++ )
170 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
171 for( int i=0; i<views.count(); i++ )
172 views[i]->setShown( myState );
179 ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
182 struct TPartShownEvent: public TApplicationEvent
184 VISU::View::ViewRepresentation myViewRepresentation;
185 typedef bool TResult;
188 TPartShownEvent(SalomeApp_Application* theApplication,
189 VISU::View::ViewRepresentation theViewRepresentation):
190 TApplicationEvent(theApplication),
191 myViewRepresentation(theViewRepresentation),
199 switch(myViewRepresentation){
200 case VISU::View::OBJECTBROWSER:
201 myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible();
203 case VISU::View::PYTHON:
204 myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible();
206 case VISU::View::MESSAGES:
207 myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible();
209 case VISU::View::VIEWER:{
210 ViewManagerList aViewManagerList = myApplication->viewManagers();
211 ViewManagerList::const_iterator anIt = aViewManagerList.begin();
212 for( ; anIt != aViewManagerList.end(); anIt++ )
214 const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
215 for( int i=0; i<views.count(); i++ ) {
216 myResult = views[i]->isVisible();
228 IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
230 return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
233 // Begin: New methods for view parameters management
234 struct TSplitEvent: public SALOME_Event
236 SalomeApp_Application * myApplication;
237 SUIT_ViewWindow * myVW;
238 Qt::Orientation myOrientation;
239 QtxWorkstack::SplitType mySplitType;
242 TSplitEvent (SalomeApp_Application * theApplication,
243 SUIT_ViewWindow * theViewWindow,
244 Qt::Orientation theOrientation,
245 QtxWorkstack::SplitType theSplitType):
246 myApplication(theApplication),
248 myOrientation(theOrientation),
249 mySplitType(theSplitType)
252 virtual void Execute()
254 SUIT_Desktop* desk = myApplication->desktop();
255 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
257 QtxWorkstack* workstack = tabDesk->workstack();
259 workstack->Split(myVW, myOrientation, mySplitType);
269 SUIT_ViewWindow* aVW = GetViewWindow();
271 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
272 Qt::Horizontal, QtxWorkstack::SplitMove));
279 SUIT_ViewWindow* aVW = GetViewWindow();
281 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
282 Qt::Horizontal, QtxWorkstack::SplitStay));
289 SUIT_ViewWindow* aVW = GetViewWindow();
291 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
292 Qt::Vertical, QtxWorkstack::SplitMove));
299 SUIT_ViewWindow* aVW = GetViewWindow();
301 ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
302 Qt::Vertical, QtxWorkstack::SplitStay));
309 struct TOnTopEvent: public SALOME_Event
311 SUIT_ViewWindow * myVW;
314 TOnTopEvent (SUIT_ViewWindow * theViewWindow):
318 virtual void Execute()
326 SUIT_ViewWindow* aVW = GetViewWindow();
328 ProcessVoidEvent(new TOnTopEvent(aVW));
331 struct TAttractEvent: public SALOME_Event
333 SalomeApp_Application * myApplication;
334 SUIT_ViewWindow * myVW1;
335 SUIT_ViewWindow * myVW2;
339 TAttractEvent (SalomeApp_Application * theApplication,
340 SUIT_ViewWindow * theViewWindow1,
341 SUIT_ViewWindow * theViewWindow2,
343 myApplication(theApplication),
344 myVW1(theViewWindow1),
345 myVW2(theViewWindow2),
346 myAttractAll(theAttractAll)
349 virtual void Execute()
351 SUIT_Desktop* desk = myApplication->desktop();
352 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
354 QtxWorkstack* workstack = tabDesk->workstack();
356 workstack->Attract(myVW1, myVW2, myAttractAll);
364 Attract (VISU::View_ptr theView)
366 if (!CORBA::is_nil(theView)) {
367 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
369 SUIT_ViewWindow* aVW1 = GetViewWindow();
370 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
372 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, false));
380 AttractAll (VISU::View_ptr theView)
382 if (!CORBA::is_nil(theView)) {
383 if (VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(theView).in())) {
385 SUIT_ViewWindow* aVW1 = GetViewWindow();
386 SUIT_ViewWindow* aVW2 = pView->GetViewWindow();
388 ProcessVoidEvent(new TAttractEvent(myApplication, aVW1, aVW2, true));
394 struct TSizePositionEvent: public SALOME_Event
396 SalomeApp_Application * myApplication;
397 SUIT_ViewWindow * myVW;
402 TSizePositionEvent (SalomeApp_Application * theApplication,
403 SUIT_ViewWindow * theViewWindow,
406 myApplication(theApplication),
412 virtual void Execute()
414 MESSAGE("TSizePositionEvent::Execute()");
415 SUIT_Desktop* desk = myApplication->desktop();
416 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
418 QtxWorkstack* workstack = tabDesk->workstack();
421 //jfa to do:workstack->SetRelativeSizeInSplitter(myVW, myValue);
423 workstack->SetRelativePositionInSplitter(myVW, myValue);
432 SetRelativePositionInSplitter (CORBA::Double thePosition)
434 if (thePosition < 0.0 || 1.0 < thePosition) {
437 SUIT_ViewWindow* aVW = GetViewWindow();
439 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, thePosition, false));
444 SetRelativeSizeInSplitter (CORBA::Double theSize)
446 if (theSize < 0.0 || 1.0 < theSize) {
449 SUIT_ViewWindow* aVW = GetViewWindow();
451 ProcessVoidEvent(new TSizePositionEvent(myApplication, aVW, theSize, true));
454 struct TWSSizePositionEvent: public SALOME_Event
456 SalomeApp_Application * myApplication;
457 SUIT_ViewWindow * myVW;
458 Qt::Orientation myOrientation;
463 TWSSizePositionEvent (SalomeApp_Application * theApplication,
464 SUIT_ViewWindow * theViewWindow,
465 Qt::Orientation theOrientation,
468 myApplication(theApplication),
470 myOrientation(theOrientation),
475 virtual void Execute()
477 MESSAGE("TWSSizePositionEvent::Execute()");
478 SUIT_Desktop* desk = myApplication->desktop();
479 STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
481 QtxWorkstack* workstack = tabDesk->workstack();
484 //jfa to do:workstack->SetRelativeSize(myVW, myOrientation, myValue);
486 workstack->SetRelativePosition(myVW, myOrientation, myValue);
495 SetRelativePositionX (CORBA::Double thePosition)
497 if (thePosition < 0.0 || 1.0 < thePosition) {
500 SUIT_ViewWindow* aVW = GetViewWindow();
502 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
503 Qt::Horizontal, thePosition, false));
508 SetRelativePositionY (CORBA::Double thePosition)
510 if (thePosition < 0.0 || 1.0 < thePosition) {
513 SUIT_ViewWindow* aVW = GetViewWindow();
515 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
516 Qt::Vertical, thePosition, false));
521 SetRelativeSizeX (CORBA::Double theSize)
523 if (theSize < 0.0 || 1.0 < theSize) {
526 SUIT_ViewWindow* aVW = GetViewWindow();
528 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
529 Qt::Horizontal, theSize, true));
534 SetRelativeSizeY (CORBA::Double theSize)
536 if (theSize < 0.0 || 1.0 < theSize) {
539 SUIT_ViewWindow* aVW = GetViewWindow();
541 ProcessVoidEvent(new TWSSizePositionEvent(myApplication, aVW,
542 Qt::Vertical, theSize, true));
544 // End: New methods for view parameters management
546 // Begin: Old methods for view parameters management, they don't work now
547 struct TSetViewSize: public SALOME_Event
549 SUIT_ViewWindow* myVW;
550 typedef void (QRect::* TAction)(int);
555 TSetViewSize(SUIT_ViewWindow* theViewWindow,
557 CORBA::Long theSize):
567 if (QWidget* aParent = myVW->parentWidget()) {
568 QRect aQRect = aParent->frameGeometry();
569 (aQRect.*myAction)(mySize);
570 aParent->setGeometry(aQRect);
577 SetViewWidth(CORBA::Long theWidth)
579 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
584 SetViewHeight(CORBA::Long theHeight)
586 ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setHeight,theHeight));
590 struct TGetViewSize: public SALOME_Event
592 SUIT_ViewWindow* myVW;
594 typedef int (QRect::* TAction)() const;
597 typedef CORBA::Long TResult;
601 TGetViewSize(SUIT_ViewWindow* theViewWindow,
611 if(QWidget* aParent = myVW->parentWidget()){
612 QRect aQRect = aParent->frameGeometry();
613 myResult = (aQRect.*myAction)();
623 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::width));
630 return ProcessEvent(new TGetViewSize(myViewWindow,&QRect::height));
634 class TWorkspaceEvent: public SALOME_Event
638 QWidget* myWorkspace;
641 TWorkspaceEvent(QWidget* theViewWindow,
642 QWidget* theWorkspace):
644 myWorkspace(theWorkspace)
649 class TAlignEvent: public TWorkspaceEvent
652 Qt::AlignmentFlag myAligment;
655 TAlignEvent(QWidget* theViewWindow,
656 QWidget* theWorkspace,
657 Qt::AlignmentFlag theAligment):
658 TWorkspaceEvent(theViewWindow,theWorkspace),
659 myAligment(theAligment)
666 if(QWidget* aParent = myVW->parentWidget())
667 SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
674 SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
677 switch (theViewPosition) {
678 case VISU::View::LEFT:
679 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
681 case VISU::View::CENTER:
682 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignHCenter));
684 case VISU::View::RIGHT:
685 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignRight));
694 SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
697 switch (theViewPosition) {
698 case VISU::View::TOP:
699 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
701 case VISU::View::CENTER:
702 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignVCenter));
704 case VISU::View::BOTTOM:
705 ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignBottom));
712 class TXYEvent: public TWorkspaceEvent
715 CORBA::Double myX, myY;
718 TXYEvent(QWidget* theViewWindow,
719 QWidget* theWorkspace,
722 TWorkspaceEvent(theViewWindow,theWorkspace),
731 SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
733 struct TEvent: public TXYEvent
736 TEvent(QWidget* theViewWindow,
737 QWidget* theWorkspace,
740 TXYEvent(theViewWindow,theWorkspace,theX,theY)
747 if(QWidget* aParent = myVW->parentWidget())
748 aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
753 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
758 SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
760 struct TEvent: public TXYEvent
763 TEvent(QWidget* theViewWindow,
764 QWidget* theWorkspace,
767 TXYEvent(theViewWindow,theWorkspace,theX,theY)
774 if(QWidget* aParent = myVW->parentWidget())
775 aParent->setGeometry(aParent->x(),
777 int(myX*myWorkspace->width()),
778 int(myY*myWorkspace->height()));
783 ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
785 // End: Old methods for view parameters management, they don't work now
789 SetBackground (const SALOMEDS::Color& theColor)
791 struct TEvent: public SALOME_Event
793 SVTK_ViewWindow* myVW;
794 SALOMEDS::Color myColor;
796 TEvent(SVTK_ViewWindow* theViewWindow,
797 const SALOMEDS::Color& theColor):
801 virtual void Execute(){
803 aColor[0] = int(255.0*myColor.R);
804 aColor[1] = int(255.0*myColor.G);
805 aColor[2] = int(255.0*myColor.B);
806 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
807 myVW->setBackgroundColor(aNewColor);
811 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
813 ProcessVoidEvent(new TEvent(aVW, theColor));
817 struct TBackgroundEvent: public SALOME_Event
819 SVTK_ViewWindow* myVW;
820 typedef SALOMEDS::Color TResult;
823 TBackgroundEvent(SVTK_ViewWindow* theViewWindow):
831 vtkFloatingPointType backint[3];
832 GetRenderer(myVW)->GetBackground(backint);
833 myResult.R = backint[0];
834 myResult.G = backint[1];
835 myResult.B = backint[2];
843 SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
845 return ProcessEvent(new TBackgroundEvent(aVW));
847 SALOMEDS::Color aBlack;
858 SUIT_ViewWindow* aVW = GetViewWindow();
860 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMinimized));
867 SUIT_ViewWindow* aVW = GetViewWindow();
869 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showNormal));
876 SUIT_ViewWindow* aVW = GetViewWindow();
878 ProcessVoidEvent(new TFrameActionEvent(aVW, &SUIT_ViewWindow::showMaximized));
893 Erase (PrsObject_ptr thePrsObj)
898 Display (PrsObject_ptr thePrsObj)
903 DisplayOnly (PrsObject_ptr thePrsObj)
911 class TSavePictureEvent: public SALOME_Event
913 SUIT_ViewWindow * myVW;
914 const char * myFileName;
916 typedef CORBA::Boolean TResult;
918 TSavePictureEvent (SUIT_ViewWindow * theViewWindow, const char * theFileName)
919 : myVW(theViewWindow),
920 myFileName(theFileName),
925 virtual void Execute()
928 QImage img = myVW->dumpView();
930 QString fileName (myFileName);
931 if (!fileName.isEmpty()) {
932 QString fmt = SUIT_Tools::extension(fileName).toUpper();
933 if (fmt.isEmpty()) fmt = QString("BMP"); // default format
934 if (fmt == "JPG" ) fmt = "JPEG";
935 //QApplication::setOverrideCursor(Qt::waitCursor);
936 img.save(fileName, fmt.toLatin1().data());
938 //QApplication::restoreOverrideCursor();
946 View_i::SavePicture(const char* theFileName)
948 return ProcessEvent(new TSavePictureEvent (GetViewWindow(), theFileName));
952 View_i::GetComment() const
959 ToStream (std::ostringstream& theStr)
963 SUIT_ViewWindow* View_i::GetViewWindow()
966 QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
967 int aPos = aViews.indexOf(myViewWindow);
974 void View_i::SetViewWindow(SUIT_ViewWindow* theViewWindow)
976 myViewWindow = theViewWindow;
980 //===========================================================================
981 XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
982 : View_i(theApplication, NULL)
984 if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
987 struct TCreatePlot2dViewEvent: public SALOME_Event
989 XYPlot_i * myPlot2dView;
992 typedef Plot2d_ViewFrame* TResult;
995 TCreatePlot2dViewEvent (XYPlot_i * thePlot2dView,
997 myPlot2dView(thePlot2dView),
1006 if (!myPlot2dView->myApplication)
1009 SUIT_ViewManager* aViewMgr =
1010 myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), false);
1011 SUIT_ViewWindow* aVW = NULL;
1015 aVW = aViewMgr->createViewWindow();
1017 aVW = aViewMgr->getActiveView();
1020 aViewMgr = myPlot2dView->myApplication->getViewManager(SPlot2d_Viewer::Type(), true);
1021 aVW = aViewMgr->getActiveView();
1023 return; // there are no current Plot2d view
1028 Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(aVW);
1030 myResult = aPlot2dVW->getViewFrame();
1032 myResult->Repaint();
1035 myPlot2dView->myViewManager = aViewMgr;
1036 myPlot2dView->SetViewWindow(aVW);
1042 Storable* XYPlot_i::Create (int theNew)
1044 myView = ProcessEvent(new TCreatePlot2dViewEvent(this, theNew));
1050 void XYPlot_i::Update()
1052 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
1055 struct TCloseViewEvent: public SALOME_Event
1057 SUIT_ViewWindow* myView;
1058 TCloseViewEvent (SUIT_ViewWindow* theView):
1062 virtual void Execute()
1064 if ( myView ) myView->close();
1068 void XYPlot_i::Close()
1070 ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1071 QApplication::sendPostedEvents();
1074 XYPlot_i::~XYPlot_i() {
1075 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
1078 void XYPlot_i::SetTitle (const char* theTitle)
1080 SUIT_ViewWindow* aVW = GetViewWindow();
1082 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1083 (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle)));
1085 char* XYPlot_i::GetTitle()
1087 SUIT_ViewWindow* aVW = GetViewWindow();
1089 return CORBA::string_dup( aVW->windowTitle().toLatin1().data());
1090 return CORBA::string_dup("");
1093 void XYPlot_i::SetSubTitle (const char* theTitle)
1095 if (GetViewWindow())
1096 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
1097 (myView, &Plot2d_ViewFrame::setTitle, QString(theTitle)));
1100 char* XYPlot_i::GetSubTitle()
1102 if (GetViewWindow())
1103 return CORBA::string_dup(myView->getTitle().toLatin1().data());
1104 return CORBA::string_dup("");
1107 void XYPlot_i::SetCurveType (VISU::XYPlot::CurveType theType)
1109 if (GetViewWindow())
1110 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1111 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
1114 VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
1116 if (GetViewWindow())
1117 return (VISU::XYPlot::CurveType)myView->getCurveType();
1118 return VISU::XYPlot::POINTS;
1121 void XYPlot_i::SetMarkerSize (CORBA::Long theSize)
1123 if (GetViewWindow())
1124 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
1125 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
1128 CORBA::Long XYPlot_i::GetMarkerSize()
1130 if (GetViewWindow())
1131 return myView->getMarkerSize();
1135 void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
1136 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
1138 class TEvent: public SALOME_Event
1141 TEvent (Plot2d_ViewFrame* theView,
1142 CORBA::Boolean theMajor,
1143 CORBA::Long theNumMajor,
1144 CORBA::Boolean theMinor,
1145 CORBA::Long theNumMinor):
1148 myNumMajor(theNumMajor),
1150 myNumMinor(theNumMinor)
1153 virtual void Execute()
1155 myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor );
1158 Plot2d_ViewFrame* myView;
1159 CORBA::Boolean myMajor, myMinor;
1160 CORBA::Long myNumMajor, myNumMinor;
1163 if ( GetViewWindow() )
1164 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) );
1166 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1167 CORBA::Long theNumMajor,
1168 CORBA::Boolean theMinor,
1169 CORBA::Long theNumMinor)
1171 this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 );
1174 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
1175 CORBA::Long theNumMajor,
1176 CORBA::Boolean theMinor,
1177 CORBA::Long theNumMinor,
1178 CORBA::Boolean the2Major,
1179 CORBA::Long the2NumMajor,
1180 CORBA::Boolean the2Minor,
1181 CORBA::Long the2NumMinor)
1183 class TEvent: public SALOME_Event
1186 TEvent (Plot2d_ViewFrame* theView,
1187 CORBA::Boolean theMajor,
1188 CORBA::Long theNumMajor,
1189 CORBA::Boolean theMinor,
1190 CORBA::Long theNumMinor,
1191 CORBA::Boolean the2Major,
1192 CORBA::Long the2NumMajor,
1193 CORBA::Boolean the2Minor,
1194 CORBA::Long the2NumMinor):
1197 myNumMajor(theNumMajor),
1199 myNumMinor(theNumMinor),
1200 my2Major(the2Major),
1201 my2NumMajor(the2NumMajor),
1202 my2Minor(the2Minor),
1203 my2NumMinor(the2NumMinor)
1206 virtual void Execute()
1208 myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor,
1209 my2Major, my2NumMajor, my2Minor, my2NumMinor);
1212 Plot2d_ViewFrame* myView;
1213 CORBA::Boolean myMajor, myMinor, my2Major, my2Minor;
1214 CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor;
1217 if (GetViewWindow())
1218 ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor,
1219 the2Major, the2NumMajor, the2Minor, the2NumMinor ) );
1222 class TSetScaleModeEvent: public SALOME_Event
1225 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool);
1226 TSetScaleModeEvent (Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
1227 myView(theView), myFun(theFun), myScaling(theScaling)
1230 virtual void Execute()
1232 (myView->*myFun)(myScaling,true);
1235 Plot2d_ViewFrame* myView;
1240 void XYPlot_i::SetHorScaling (VISU::Scaling theScaling)
1242 if (GetViewWindow())
1243 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
1244 theScaling == VISU::LOGARITHMIC));
1247 VISU::Scaling XYPlot_i::GetHorScaling()
1249 //jfa: may be need to be enclosed in SALOME_Event?
1250 if (GetViewWindow())
1251 return (VISU::Scaling)myView->getHorScaleMode();
1252 return VISU::LINEAR;
1255 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling)
1257 if (GetViewWindow())
1258 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
1259 theScaling == VISU::LOGARITHMIC));
1262 VISU::Scaling XYPlot_i::GetVerScaling()
1264 if (GetViewWindow())
1265 return (VISU::Scaling)myView->getVerScaleMode();
1266 return VISU::LINEAR;
1269 class TSetTitleEvent: public SALOME_Event
1272 TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
1273 myView(theView), myType(theType), myTitle(theTitle)
1275 virtual void Execute()
1277 myView->setTitle(true,myTitle,myType);
1280 Plot2d_ViewFrame* myView;
1281 Plot2d_ViewFrame::ObjectType myType;
1282 const char* myTitle;
1285 void XYPlot_i::SetXTitle (const char* theTitle)
1287 if (GetViewWindow())
1288 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
1290 char* XYPlot_i::GetXTitle()
1292 if (GetViewWindow())
1293 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data());
1294 return CORBA::string_dup("");
1297 void XYPlot_i::SetYTitle (const char* theTitle)
1299 if (GetViewWindow())
1300 ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
1302 char* XYPlot_i::GetYTitle()
1304 if (GetViewWindow())
1305 return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data());
1306 return CORBA::string_dup("");
1309 void XYPlot_i::ShowLegend (CORBA::Boolean theShowing)
1311 if (GetViewWindow())
1312 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
1313 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
1316 class TXYPlotViewEvent: public SALOME_Event
1318 SalomeApp_Application* myApplication;
1319 Plot2d_ViewFrame* myView;
1320 PrsObject_ptr myPrsObj;
1324 TXYPlotViewEvent(SalomeApp_Application* theApplication,
1325 Plot2d_ViewFrame* theView,
1326 PrsObject_ptr thePrsObj,
1328 : myApplication(theApplication),
1330 myPrsObj(thePrsObj),
1331 myDisplaing(theDisplaing)
1335 virtual void Execute()
1338 if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
1339 UpdatePlot2d(aCurve,myDisplaing,myView);
1341 // is it Container ?
1342 if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
1343 int nbCurves = aContainer->GetNbCurves();
1344 for ( int i = 1; i <= nbCurves; i++ ) {
1345 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
1346 if ( aCurve && aCurve->IsValid() ) {
1347 UpdatePlot2d(aCurve,myDisplaing,myView);
1353 if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
1354 _PTR(Study) aCStudy;
1355 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1356 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1357 aCStudy = aStudy->studyDS();
1360 if (!aCStudy) return;
1361 _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
1363 _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
1364 for (; Iter->More(); Iter->Next()) {
1365 CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
1366 if (!CORBA::is_nil(childObject)) {
1367 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
1368 if (!CORBA::is_nil(aCurve))
1369 UpdatePlot2d(dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()),
1370 myDisplaing, myView);
1379 void XYPlot_i::Display (PrsObject_ptr thePrsObj)
1381 if (GetViewWindow())
1382 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
1385 void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
1387 if (GetViewWindow())
1388 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
1391 void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
1393 if (GetViewWindow())
1394 ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
1397 void XYPlot_i::EraseAll()
1399 if (GetViewWindow())
1400 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::EraseAll));
1403 void XYPlot_i::FitAll()
1405 if (GetViewWindow())
1406 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
1409 class TFitRangeEvent: public SALOME_Event
1412 TFitRangeEvent (Plot2d_ViewFrame* theView,
1414 const double xMin, const double xMax,
1415 const double yMin, const double yMax):
1418 myXMin(xMin),myXMax(xMax),
1419 myYMin(yMin),myYMax(yMax)
1421 virtual void Execute()
1423 myView->fitData(myMode,myXMin,myXMax,myYMin,myYMax);
1427 const double myXMin;
1428 const double myXMax;
1429 const double myYMin;
1430 const double myYMax;
1431 Plot2d_ViewFrame* myView;
1434 void XYPlot_i::FitXRange(const CORBA::Double xMin,const CORBA::Double xMax)
1436 const CORBA::Long mode = 1;
1437 const CORBA::Double yMin = 0.0;
1438 const CORBA::Double yMax = 0.0;
1439 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1442 void XYPlot_i::FitYRange(const CORBA::Double yMin,const CORBA::Double yMax)
1444 const CORBA::Long mode = 2;
1445 const CORBA::Double xMin = 0.0;
1446 const CORBA::Double xMax = 0.0;
1447 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1450 void XYPlot_i::FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
1451 const CORBA::Double yMin,const CORBA::Double yMax)
1453 const CORBA::Long mode = 0;
1454 ProcessVoidEvent(new TFitRangeEvent(myView,mode,xMin,xMax,yMin,yMax));
1457 void XYPlot_i::GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax)
1460 myView->getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1463 //===========================================================================
1464 TableView_i::TableView_i (SalomeApp_Application* theApplication)
1465 : View_i(theApplication, NULL)
1469 struct TCreateTableViewEvent: public SALOME_Event
1471 SalomeApp_Application* myApplication;
1472 VISU::Table_i* myTable;
1474 typedef VISU_TableDlg* TResult;
1477 TCreateTableViewEvent (SalomeApp_Application* theApplication,
1478 VISU::Table_i* theTable):
1479 myApplication(theApplication),
1488 if (myTable != NULL) {
1489 if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
1490 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1491 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1492 myResult = new VISU_TableDlg (myApplication->desktop(),
1496 VISU_TableDlg::ttAuto,
1506 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1508 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1509 if (!theTable->_is_nil()) {
1510 VISU::Table_i* table =
1511 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1512 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1514 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1521 TableView_i::~TableView_i()
1523 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1527 void TableView_i::SetTitle (const char* theTitle)
1529 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TableDlg,const QString&,QString>
1530 (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle)));
1533 char* TableView_i::GetTitle()
1535 //jfa: may be need to be enclosed in SALOME_Event?
1536 return CORBA::string_dup(myView->windowTitle().toLatin1().data());
1539 void TableView_i::Close()
1541 //jfa: may be need to be enclosed in SALOME_Event?
1546 //===========================================================================
1547 int View3D_i::myNbViewParams = 0;
1548 const string View3D_i::myComment = "VIEW3D";
1549 const char* View3D_i::GetComment() const { return myComment.c_str();}
1551 QString View3D_i::GenerateViewParamsName()
1553 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1556 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1557 : View_i(theApplication, NULL)
1559 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1562 struct TCreateView3dEvent: public SALOME_Event
1564 SalomeApp_Application *myApplication;
1565 View3D_i * myView3D;
1568 typedef SUIT_ViewWindow* TResult;
1571 TCreateView3dEvent (SalomeApp_Application *theApplication,
1572 View3D_i * theView3D,
1574 myApplication(theApplication),
1575 myView3D(theView3D),
1588 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1589 myResult = aViewManager->createViewWindow();
1590 myView3D->myViewManager = aViewManager;
1592 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){
1593 myResult = aViewManager->getActiveView();
1594 myView3D->myViewManager = aViewManager;
1598 if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){
1599 if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){
1600 if(dynamic_cast<SVTK_ViewWindow*>(aView)){
1601 myView3D->myViewManager = aViewManager;
1602 myResult = aViewManager->getActiveView();
1606 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1607 myView3D->myViewManager = aViewManager;
1608 myResult = aViewManager->getActiveView();
1615 Storable* View3D_i::Create (int theNew)
1617 if (MYDEBUG) MESSAGE("View3D_i::Create");
1618 SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(myApplication, this, theNew));
1626 void View3D_i::Update()
1628 class TEvent: public SALOME_Event
1630 SUIT_ViewWindow* myViewWindow;
1632 TEvent(SUIT_ViewWindow* theViewWindow):
1633 myViewWindow(theViewWindow)
1635 virtual void Execute()
1637 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
1638 vtkRenderer* aRenderer = aViewWindow->getRenderer();
1639 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1640 vtkActorCollection* anActors = aCopy.GetActors();
1641 anActors->InitTraversal();
1642 while (vtkActor *anAct = anActors->GetNextActor()) {
1643 if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
1644 if (anActor->GetVisibility())
1645 anActor->UpdateFromFactory();
1648 RepaintView(myViewWindow);
1652 if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
1653 ProcessVoidEvent(new TEvent(aViewWindow));
1656 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1658 MESSAGE("View3D_i::SaveViewParams()");
1660 if (!theViewManager || theName == "")
1663 _PTR(Study) aCStudy;
1664 if (SUIT_Study* aSStudy = theViewManager->study()) {
1665 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1666 aCStudy = aStudy->studyDS();
1672 if (theName != "") {
1673 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
1674 _PTR(GenericAttribute) anAttr;
1675 int iEnd = aList.size();
1676 for (int i = 0; i < iEnd; i++) {
1677 _PTR(SObject) anObj = aList[i];
1678 string anEntry = anObj->GetID();
1679 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1680 if (anObj->FindAttribute(anAttr, "AttributeString")) {
1681 _PTR(AttributeString) aCmnt (anAttr);
1682 string aComm (aCmnt->Value());
1683 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1684 if (aComm.compare(View3D_i::myComment) >= 0) {
1685 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1691 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1692 string aSComponentEntry = aSComponent->GetID();
1693 string anEntry = CreateAttributes(aCStudy,
1694 aSComponentEntry.c_str(),
1699 ToString(theViewManager->getActiveView()).c_str());
1703 class TSaveViewParamsEvent: public SALOME_Event
1705 SUIT_ViewManager* myViewMgr;
1708 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1709 const std::string& theName):
1710 myViewMgr(theViewManager),
1714 virtual void Execute()
1716 myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1718 typedef CORBA::Boolean TResult;
1722 CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
1724 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
1727 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1729 _PTR(Study) aCStudy;
1730 if (SUIT_Study* aSStudy = theViewManager->study()) {
1731 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1732 aCStudy = aStudy->studyDS();
1738 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1739 _PTR(GenericAttribute) anAttr;
1740 int iEnd = aList.size();
1741 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1742 for (int i = 0; i < iEnd; i++) {
1743 _PTR(SObject) anObj = aList[i];
1744 string anEntry = anObj->GetID();
1745 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1746 Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
1747 if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
1748 Restore(theViewManager->getActiveView(), aMap);
1755 class TRestoreViewParamsEvent: public SALOME_Event
1757 SUIT_ViewManager* myViewMgr;
1760 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1761 const std::string& theName):
1762 myViewMgr(theViewManager),
1766 virtual void Execute()
1768 myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1770 typedef CORBA::Boolean TResult;
1774 CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
1776 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
1779 void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1780 const Storable::TRestoringMap& theMap)
1782 SALOMEDS::Color aColor;
1783 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1784 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1785 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1787 double aPosition[3];
1788 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1789 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1790 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1792 double aFocalPnt[3];
1793 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1794 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1795 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1798 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1799 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1800 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1802 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1804 double aScaleFactor[3];
1805 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1806 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1807 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1809 SetBackground(theViewWindow,aColor);
1810 SetPointOfView(theViewWindow,aPosition);
1811 SetViewUp(theViewWindow,aViewUp);
1812 SetFocalPoint(theViewWindow,aFocalPnt);
1813 SetParallelScale(theViewWindow,aParallelScale);
1814 ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]);
1815 ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]);
1816 ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]);
1820 string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1822 ostringstream strOut;
1823 Storable::DataToStream(strOut, "myComment", myComment.c_str());
1824 ToStream(theViewWindow, strOut);
1826 if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1827 return strOut.str();
1830 void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1832 vtkFloatingPointType backint[3];
1833 GetRenderer(theViewWindow)->GetBackground(backint);
1834 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1835 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1836 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1838 double aPosition[3];
1839 GetPointOfView(theViewWindow,aPosition);
1840 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1841 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1842 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1844 double aFocalPnt[3];
1845 GetFocalPoint(theViewWindow,aFocalPnt);
1846 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1847 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1848 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1851 GetCamera(theViewWindow)->GetViewUp(aViewUp);
1852 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1853 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1854 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1856 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1858 double aScaleFactor[3];
1859 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->GetScale(aScaleFactor);
1860 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1861 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1862 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1865 void View3D_i::ToStream(std::ostringstream& theStr)
1867 SUIT_ViewWindow* aVW = GetViewWindow();
1869 ToStream(aVW, theStr);
1872 void View3D_i::Close()
1874 ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1875 QApplication::sendPostedEvents();
1878 View3D_i::~View3D_i()
1880 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1883 void View3D_i::SetTitle (const char* theTitle)
1885 SUIT_ViewWindow* aVW = GetViewWindow();
1887 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1888 (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
1891 char* View3D_i::GetTitle()
1893 SUIT_ViewWindow* aVW = GetViewWindow();
1895 return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
1896 return CORBA::string_dup("");
1899 void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1900 const SALOMEDS::Color& theColor)
1902 //jfa: may be need to be enclosed in SALOME_Event?
1904 aColor[0] = int(255.0*theColor.R);
1905 aColor[1] = int(255.0*theColor.G);
1906 aColor[2] = int(255.0*theColor.B);
1907 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1908 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->setBackgroundColor(aNewColor);
1911 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1913 SALOMEDS::Color aColor;
1914 vtkFloatingPointType backint[3];
1915 GetRenderer(theViewWindow)->GetBackground(backint);
1916 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1920 class TUpdateViewerEvent: public SALOME_Event
1922 SUIT_ViewWindow* myVW;
1926 TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1929 myVW(theViewWindow),
1931 myDisplaing(theDisplaing)
1933 virtual void Execute(){
1934 UpdateViewer(myVW, myDisplaing, myPrs3d);
1938 class TDisplayTableEvent: public SALOME_Event
1940 SUIT_ViewWindow* myVW;
1941 PointMap3d_i* myTable;
1944 TDisplayTableEvent( SUIT_ViewWindow* theView,
1945 PointMap3d_i* theTable,
1946 int theDisplaying ) :
1949 myDisplaying (theDisplaying)
1951 virtual void Execute() {
1952 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
1953 VISU_PointMap3dActor* anActor = myTable->CreateActor();
1954 myTable->UpdateActor( anActor );
1955 aViewWindow->AddActor( anActor );
1959 void View3D_i::EraseAll()
1961 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1962 SUIT_ViewWindow* aVW = GetViewWindow();
1964 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1967 void View3D_i::DisplayAll()
1969 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1970 SUIT_ViewWindow* aVW = GetViewWindow();
1972 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1975 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1977 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1978 SUIT_ViewWindow* aVW = GetViewWindow();
1979 CORBA::Object_ptr anObj = thePrsObj;
1980 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1982 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1985 void View3D_i::Display (PrsObject_ptr thePrsObj)
1987 if(MYDEBUG) MESSAGE("View3D_i::Display");
1988 SUIT_ViewWindow* aVW = GetViewWindow();
1989 CORBA::Object_ptr anObj = thePrsObj;
1990 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1992 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
1993 else if (aVW && !aPrs) {
1994 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
1996 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
2000 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
2002 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
2003 SUIT_ViewWindow* aVW = GetViewWindow();
2004 CORBA::Object_ptr anObj = thePrsObj;
2005 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2007 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
2008 else if (aVW && !aPrs) {
2009 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2011 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
2015 void View3D_i::FitAll()
2017 SUIT_ViewWindow* aVW = GetViewWindow();
2019 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2020 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFitAll));
2025 void View3D_i::SetView (VISU::View3D::ViewType theType)
2027 SUIT_ViewWindow* aVW = GetViewWindow();
2032 case VISU::View3D::FRONT :
2033 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2034 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFrontView));
2036 case VISU::View3D::BACK :
2037 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2038 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onBackView));
2040 case VISU::View3D::LEFT :
2041 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2042 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onLeftView));
2044 case VISU::View3D::RIGHT :
2045 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2046 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onRightView));
2048 case VISU::View3D::TOP :
2049 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2050 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onTopView));
2052 case VISU::View3D::BOTTOM :
2053 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2054 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onBottomView));
2060 class TSet3DViewParamEvent: public SALOME_Event
2063 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
2064 TSet3DViewParamEvent (TFun theFun,
2065 SUIT_ViewWindow* theViewWindow,
2066 const CORBA::Double theParam[3]):
2068 myVW(theViewWindow),
2071 virtual void Execute() {
2072 myFun(myVW,myParam);
2076 SUIT_ViewWindow* myVW;
2077 const CORBA::Double* myParam;
2080 void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
2081 const CORBA::Double thePosition[3])
2083 //jfa: may be need to be enclosed in SALOME_Event?
2084 GetCamera(theViewWindow)->SetPosition(thePosition);
2087 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
2089 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
2090 SUIT_ViewWindow* aVW = GetViewWindow();
2092 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
2095 void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
2096 CORBA::Double thePosition[3])
2098 GetCamera(theViewWindow)->GetPosition(thePosition);
2101 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
2103 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
2104 CORBA::Double aPosition[3];
2105 SUIT_ViewWindow* aVW = GetViewWindow();
2107 GetPointOfView(aVW,aPosition);
2108 return VISU::View3D::XYZ_dup(aPosition);
2111 void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2112 const CORBA::Double theViewUp[3])
2114 GetCamera(theViewWindow)->SetViewUp(theViewUp);
2117 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2119 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2120 SUIT_ViewWindow* aVW = GetViewWindow();
2122 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
2125 void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2126 CORBA::Double theViewUp[3])
2128 GetCamera(theViewWindow)->GetViewUp(theViewUp);
2131 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2133 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2134 CORBA::Double aViewUp[3];
2135 SUIT_ViewWindow* aVW = GetViewWindow();
2137 GetCamera(aVW)->GetViewUp(aViewUp);
2138 return VISU::View3D::XYZ_dup(aViewUp);
2141 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2142 const CORBA::Double theFocalPnt[3])
2144 GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2147 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2149 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2150 SUIT_ViewWindow* aVW = GetViewWindow();
2152 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
2156 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2157 CORBA::Double theFocalPnt[3])
2159 GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2162 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2164 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2165 CORBA::Double aFocalPnt[3];
2166 SUIT_ViewWindow* aVW = GetViewWindow();
2168 GetFocalPoint(aVW,aFocalPnt);
2169 return VISU::View3D::XYZ_dup(aFocalPnt);
2172 class TSetViewParamEvent: public SALOME_Event
2175 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2176 TSetViewParamEvent (TFun theFun,
2177 SUIT_ViewWindow* theViewWindow,
2178 CORBA::Double theParam):
2180 myVW(theViewWindow),
2183 virtual void Execute()
2185 myFun(myVW,myParam);
2189 SUIT_ViewWindow* myVW;
2190 CORBA::Double myParam;
2193 void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2194 CORBA::Double theScale)
2196 GetCamera(theViewWindow)->SetParallelScale(theScale);
2199 void View3D_i::SetParallelScale (CORBA::Double theScale)
2201 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2202 SUIT_ViewWindow* aVW = GetViewWindow();
2204 ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
2207 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2209 return GetCamera(theViewWindow)->GetParallelScale();
2212 CORBA::Double View3D_i::GetParallelScale()
2214 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2215 SUIT_ViewWindow* aVW = GetViewWindow();
2217 return GetParallelScale(aVW);
2221 void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2222 VISU::View3D::Axis theAxis, CORBA::Double theParam)
2224 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
2225 double aScaleFactor[3];
2226 aViewWindow->GetScale(aScaleFactor);
2227 aScaleFactor[theAxis] = theParam;
2228 aViewWindow->SetScale(aScaleFactor);
2231 void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2233 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2234 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->SetScale(aScale);
2237 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2239 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2240 SUIT_ViewWindow* aVW = GetViewWindow();
2243 (dynamic_cast<SVTK_ViewWindow*>(aVW))->GetScale(aScale);
2244 aScale[theAxis] = theParam;
2245 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2249 void View3D_i::RemoveScale()
2251 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2252 SUIT_ViewWindow* aVW = GetViewWindow();
2254 double aScale[3] = {1.0, 1.0, 1.0};
2255 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2259 //================================================
2260 // Certain presentation view parameters management
2261 //================================================
2262 class TPrsManageEvent: public SALOME_Event
2266 ScalarMap_ptr myPrs;
2269 TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2270 myView3D(theView3D),
2271 myPrs(ScalarMap::_duplicate(thePrs)),
2272 myError("Unknown error occured")
2274 VISU_Actor* GetMyActor()
2276 SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
2277 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
2279 myError = "Corrupted view window";
2281 ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
2283 myError = "Corrupted presentation";
2285 VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
2287 myError = "No actor found. Display the presentation at first.";
2299 class TGetPrsTypeEvent: public TPrsManageEvent {
2301 typedef VISU::PresentationType TResult;
2303 TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2304 TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
2305 virtual void Execute() {
2306 if (VISU_Actor* anActor = GetMyActor())
2307 myResult = (VISU::PresentationType)anActor->GetRepresentation();
2311 class TGetShrinkedEvent: public TPrsManageEvent {
2313 typedef bool TResult;
2315 TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2316 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2317 virtual void Execute() {
2318 if (VISU_Actor* anActor = GetMyActor()) {
2319 if (anActor->IsShrunkable())
2320 myResult = anActor->IsShrunk();
2327 class TGetShadedEvent: public TPrsManageEvent {
2329 typedef bool TResult;
2331 TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2332 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2333 virtual void Execute() {
2334 if (VISU_Actor* anActor = GetMyActor())
2335 if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
2336 myResult = aScalarMapActor->IsShading();
2340 class TGetOpacityEvent: public TPrsManageEvent {
2342 typedef double TResult;
2344 TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2345 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2346 virtual void Execute() {
2347 if (VISU_Actor* anActor = GetMyActor()) {
2348 vtkFloatingPointType oldvalue = anActor->GetOpacity();
2349 myResult = (double)oldvalue;
2354 class TGetLineWidthEvent: public TPrsManageEvent {
2356 typedef double TResult;
2358 TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2359 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2360 virtual void Execute() {
2361 if (VISU_Actor* anActor = GetMyActor()) {
2362 vtkFloatingPointType oldvalue = anActor->GetLineWidth();
2363 myResult = (double)oldvalue;
2369 class TSetPrsTypeEvent: public TPrsManageEvent {
2371 PresentationType myPrsType;
2373 typedef string TResult;
2375 TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
2376 TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
2377 myResult("Unknown error occured")
2379 virtual void Execute() {
2380 VISU::VISUType aType = myPrs->GetType();
2381 switch (myPrsType) {
2382 case VISU::INSIDEFRAME:
2384 if (aType != VISU::TSCALARMAP &&
2385 aType != VISU::TDEFORMEDSHAPE &&
2386 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2387 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2388 myResult = "Insideframe representation is not available for this type of presentations.";
2393 case VISU::SURFACEFRAME:
2395 if (aType != VISU::TSCALARMAP &&
2396 aType != VISU::TDEFORMEDSHAPE &&
2397 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2398 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP &&
2399 aType != VISU::TCUTPLANES &&
2400 aType != VISU::TISOSURFACES &&
2401 aType != VISU::TPLOT3D) {
2402 myResult = "Surfaceframe representation is not available for this type of presentations.";
2408 myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
2413 if (VISU_Actor* anActor = GetMyActor()) {
2414 anActor->SetRepresentation((int)myPrsType);
2415 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2424 class TSetShrinkedEvent: public TPrsManageEvent {
2428 typedef string TResult;
2430 TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2431 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2432 myResult("Unknown error occured")
2434 virtual void Execute() {
2435 VISU::VISUType aType = myPrs->GetType();
2436 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2437 myResult = "Shrinked representation is not available for this type of presentations.";
2439 if (VISU_Actor* anActor = GetMyActor()) {
2440 if (anActor->IsShrunkable()) {
2441 if (myIsOn) anActor->SetShrink();
2442 else anActor->UnShrink();
2443 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2447 myResult = "This presentation is not shrunkable.";
2456 class TSetShadedEvent: public TPrsManageEvent {
2460 typedef string TResult;
2462 TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2463 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2464 myResult("Unknown error occured")
2466 virtual void Execute() {
2467 if (VISU_Actor* anActor = GetMyActor()) {
2468 if (VISU_ScalarMapAct* aScalarMapActor =
2469 dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
2470 aScalarMapActor->SetShading(myIsOn);
2471 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2475 myResult = "Corrupted actor";
2483 class TSetOpacityEvent: public TPrsManageEvent {
2487 typedef string TResult;
2489 TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
2490 TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
2491 myResult("Unknown error occured")
2493 virtual void Execute() {
2494 VISU::VISUType aType = myPrs->GetType();
2495 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2496 myResult = "Opacity is meaningless for this type of presentations.";
2499 if (VISU_Actor* anActor = GetMyActor()) {
2500 anActor->SetOpacity((vtkFloatingPointType)myOpacity);
2501 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2510 class TSetLineWidthEvent: public TPrsManageEvent {
2514 typedef string TResult;
2516 TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
2517 TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
2518 myResult("Unknown error occured")
2520 virtual void Execute() {
2521 if (myPrs->GetType() == VISU::TVECTORS) {
2522 myResult = "Line Width is meaningless for Vectors presentation.";
2525 if (VISU_Actor* anActor = GetMyActor()) {
2526 anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
2527 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2536 class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2538 Quadratic2DPresentationType myPrsType;
2540 typedef string TResult;
2542 TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
2543 ScalarMap_ptr thePrs,
2544 Quadratic2DPresentationType theType):
2545 TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
2546 myResult("Unknown error occured")
2548 virtual void Execute()
2550 VISU::VISUType aType = myPrs->GetType();
2551 if (aType != VISU::TSCALARMAP &&
2552 aType != VISU::TDEFORMEDSHAPE &&
2553 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2554 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2555 myResult = "2D Quadratic element representation is not available for this type of presentations.";
2558 if (VISU_Actor* anActor = GetMyActor()) {
2559 if(myPrsType == VISU::LINES)
2560 anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
2561 else if(myPrsType == VISU::ARCS)
2562 anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
2564 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2573 class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2575 typedef VISU::Quadratic2DPresentationType TResult;
2577 TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2578 TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
2579 virtual void Execute() {
2580 if (VISU_Actor* anActor = GetMyActor()) {
2581 if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
2582 myResult = VISU::LINES;
2583 else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
2584 myResult = VISU::ARCS;
2589 PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
2591 return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
2593 CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
2595 return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
2597 CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
2599 return ProcessEvent(new TGetShadedEvent(this,thePrs));
2601 CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
2603 return ProcessEvent(new TGetOpacityEvent(this,thePrs));
2605 CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
2607 return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
2610 Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
2612 return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
2615 char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
2617 string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
2618 return CORBA::string_dup(aRet.c_str());
2620 char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
2622 string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
2623 return CORBA::string_dup(aRet.c_str());
2625 char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
2627 string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
2628 return CORBA::string_dup(aRet.c_str());
2630 char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
2632 string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
2633 return CORBA::string_dup(aRet.c_str());
2635 char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
2637 string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
2638 return CORBA::string_dup(aRet.c_str());
2641 char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
2643 string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
2644 return CORBA::string_dup(aRet.c_str());