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"
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(myView,myDisplaing,aCurve);
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(myView,myDisplaing,aCurve);
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(myView, myDisplaing,
1370 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
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 VisuGUI_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 _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
1494 myResult = new VisuGUI_TableDlg (myApplication->desktop(),
1497 VisuGUI_TableDlg::ttAuto,
1508 Storable* TableView_i::Create (VISU::Table_ptr theTable)
1510 if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
1511 if (!theTable->_is_nil()) {
1512 VISU::Table_i* table =
1513 dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1514 if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
1516 myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
1523 TableView_i::~TableView_i()
1525 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1529 void TableView_i::SetTitle (const char* theTitle)
1531 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
1532 (myView, &VisuGUI_TableDlg::setWindowTitle, QString(theTitle)));
1535 char* TableView_i::GetTitle()
1537 //jfa: may be need to be enclosed in SALOME_Event?
1538 return CORBA::string_dup(myView->windowTitle().toLatin1().data());
1541 void TableView_i::Close()
1543 //jfa: may be need to be enclosed in SALOME_Event?
1548 //===========================================================================
1549 int View3D_i::myNbViewParams = 0;
1550 const string View3D_i::myComment = "VIEW3D";
1551 const char* View3D_i::GetComment() const { return myComment.c_str();}
1553 QString View3D_i::GenerateViewParamsName()
1555 return VISU::GenerateName("ViewParams", ++myNbViewParams);
1558 View3D_i::View3D_i (SalomeApp_Application* theApplication)
1559 : View_i(theApplication, NULL)
1561 if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
1564 struct TCreateView3dEvent: public SALOME_Event
1566 SalomeApp_Application *myApplication;
1567 View3D_i * myView3D;
1570 typedef SUIT_ViewWindow* TResult;
1573 TCreateView3dEvent (SalomeApp_Application *theApplication,
1574 View3D_i * theView3D,
1576 myApplication(theApplication),
1577 myView3D(theView3D),
1590 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1591 myResult = aViewManager->createViewWindow();
1592 myView3D->myViewManager = aViewManager;
1594 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),true)){
1595 myResult = aViewManager->getActiveView();
1596 myView3D->myViewManager = aViewManager;
1600 if(SUIT_ViewManager* aViewManager = myApplication->activeViewManager()){
1601 if(SUIT_ViewWindow* aView = aViewManager->getActiveView()){
1602 if(dynamic_cast<SVTK_ViewWindow*>(aView)){
1603 myView3D->myViewManager = aViewManager;
1604 myResult = aViewManager->getActiveView();
1608 if(SUIT_ViewManager* aViewManager = myApplication->getViewManager(SVTK_Viewer::Type(),false)){
1609 myView3D->myViewManager = aViewManager;
1610 myResult = aViewManager->getActiveView();
1617 Storable* View3D_i::Create (int theNew)
1619 if (MYDEBUG) MESSAGE("View3D_i::Create");
1620 SUIT_ViewWindow* aVW = ProcessEvent(new TCreateView3dEvent(myApplication, this, theNew));
1628 void View3D_i::Update()
1630 class TEvent: public SALOME_Event
1632 SUIT_ViewWindow* myViewWindow;
1634 TEvent(SUIT_ViewWindow* theViewWindow):
1635 myViewWindow(theViewWindow)
1637 virtual void Execute()
1639 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
1640 vtkRenderer* aRenderer = aViewWindow->getRenderer();
1641 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1642 vtkActorCollection* anActors = aCopy.GetActors();
1643 anActors->InitTraversal();
1644 while (vtkActor *anAct = anActors->GetNextActor()) {
1645 if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
1646 if (anActor->GetVisibility())
1647 anActor->UpdateFromFactory();
1650 RepaintView(myViewWindow);
1654 if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
1655 ProcessVoidEvent(new TEvent(aViewWindow));
1658 bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1660 MESSAGE("View3D_i::SaveViewParams()");
1662 if (!theViewManager || theName == "")
1665 _PTR(Study) aCStudy;
1666 if (SUIT_Study* aSStudy = theViewManager->study()) {
1667 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1668 aCStudy = aStudy->studyDS();
1674 if (theName != "") {
1675 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
1676 _PTR(GenericAttribute) anAttr;
1677 int iEnd = aList.size();
1678 for (int i = 0; i < iEnd; i++) {
1679 _PTR(SObject) anObj = aList[i];
1680 string anEntry = anObj->GetID();
1681 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
1682 if (anObj->FindAttribute(anAttr, "AttributeString")) {
1683 _PTR(AttributeString) aCmnt (anAttr);
1684 string aComm (aCmnt->Value());
1685 if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
1686 if (aComm.compare(View3D_i::myComment) >= 0) {
1687 aCmnt->SetValue(ToString(theViewManager->getActiveView()).c_str());
1693 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1694 string aSComponentEntry = aSComponent->GetID();
1695 string anEntry = CreateAttributes(aCStudy,
1696 aSComponentEntry.c_str(),
1701 ToString(theViewManager->getActiveView()).c_str());
1705 class TSaveViewParamsEvent: public SALOME_Event
1707 SUIT_ViewManager* myViewMgr;
1710 TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
1711 const std::string& theName):
1712 myViewMgr(theViewManager),
1716 virtual void Execute()
1718 myResult = View3D_i::SaveViewParams(myViewMgr, myName);
1720 typedef CORBA::Boolean TResult;
1724 CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
1726 return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
1729 bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
1731 _PTR(Study) aCStudy;
1732 if (SUIT_Study* aSStudy = theViewManager->study()) {
1733 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1734 aCStudy = aStudy->studyDS();
1740 std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
1741 _PTR(GenericAttribute) anAttr;
1742 int iEnd = aList.size();
1743 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = " << iEnd);
1744 for (int i = 0; i < iEnd; i++) {
1745 _PTR(SObject) anObj = aList[i];
1746 string anEntry = anObj->GetID();
1747 if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
1748 Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
1749 if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
1750 Restore(theViewManager->getActiveView(), aMap);
1757 class TRestoreViewParamsEvent: public SALOME_Event
1759 SUIT_ViewManager* myViewMgr;
1762 TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
1763 const std::string& theName):
1764 myViewMgr(theViewManager),
1768 virtual void Execute()
1770 myResult = View3D_i::RestoreViewParams(myViewMgr, myName);
1772 typedef CORBA::Boolean TResult;
1776 CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
1778 return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
1781 void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
1782 const Storable::TRestoringMap& theMap)
1784 SALOMEDS::Color aColor;
1785 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1786 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1787 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1789 double aPosition[3];
1790 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1791 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1792 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1794 double aFocalPnt[3];
1795 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1796 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1797 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1800 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1801 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1802 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1804 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1806 double aScaleFactor[3];
1807 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1808 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1809 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1811 SetBackground(theViewWindow,aColor);
1812 SetPointOfView(theViewWindow,aPosition);
1813 SetViewUp(theViewWindow,aViewUp);
1814 SetFocalPoint(theViewWindow,aFocalPnt);
1815 SetParallelScale(theViewWindow,aParallelScale);
1816 ScaleView(theViewWindow,VISU::View3D::XAxis,aScaleFactor[0]);
1817 ScaleView(theViewWindow,VISU::View3D::YAxis,aScaleFactor[1]);
1818 ScaleView(theViewWindow,VISU::View3D::ZAxis,aScaleFactor[2]);
1822 string View3D_i::ToString (SUIT_ViewWindow* theViewWindow)
1824 ostringstream strOut;
1825 Storable::DataToStream(strOut, "myComment", myComment.c_str());
1826 ToStream(theViewWindow, strOut);
1828 if(MYDEBUG) MESSAGE("View3D_i::ToString - " << strOut.str());
1829 return strOut.str();
1832 void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
1834 vtkFloatingPointType backint[3];
1835 GetRenderer(theViewWindow)->GetBackground(backint);
1836 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1837 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1838 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1840 double aPosition[3];
1841 GetPointOfView(theViewWindow,aPosition);
1842 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1843 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1844 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1846 double aFocalPnt[3];
1847 GetFocalPoint(theViewWindow,aFocalPnt);
1848 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1849 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1850 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1853 GetCamera(theViewWindow)->GetViewUp(aViewUp);
1854 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1855 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1856 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1858 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theViewWindow));
1860 double aScaleFactor[3];
1861 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->GetScale(aScaleFactor);
1862 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1863 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1864 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1867 void View3D_i::ToStream(std::ostringstream& theStr)
1869 SUIT_ViewWindow* aVW = GetViewWindow();
1871 ToStream(aVW, theStr);
1874 void View3D_i::Close()
1876 ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
1877 QApplication::sendPostedEvents();
1880 View3D_i::~View3D_i()
1882 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1885 void View3D_i::SetTitle (const char* theTitle)
1887 SUIT_ViewWindow* aVW = GetViewWindow();
1889 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
1890 (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
1893 char* View3D_i::GetTitle()
1895 SUIT_ViewWindow* aVW = GetViewWindow();
1897 return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
1898 return CORBA::string_dup("");
1901 void View3D_i::SetBackground (SUIT_ViewWindow* theViewWindow,
1902 const SALOMEDS::Color& theColor)
1904 //jfa: may be need to be enclosed in SALOME_Event?
1906 aColor[0] = int(255.0*theColor.R);
1907 aColor[1] = int(255.0*theColor.G);
1908 aColor[2] = int(255.0*theColor.B);
1909 QColor aNewColor (aColor[0],aColor[1],aColor[2]);
1910 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->setBackgroundColor(aNewColor);
1913 SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow)
1915 SALOMEDS::Color aColor;
1916 vtkFloatingPointType backint[3];
1917 GetRenderer(theViewWindow)->GetBackground(backint);
1918 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1922 class TUpdateViewerEvent: public SALOME_Event
1924 SUIT_ViewWindow* myVW;
1928 TUpdateViewerEvent(SUIT_ViewWindow* theViewWindow,
1931 myVW(theViewWindow),
1933 myDisplaing(theDisplaing)
1935 virtual void Execute(){
1936 UpdateViewer(myVW, myDisplaing, myPrs3d);
1940 class TDisplayTableEvent: public SALOME_Event
1942 SUIT_ViewWindow* myVW;
1943 PointMap3d_i* myTable;
1946 TDisplayTableEvent( SUIT_ViewWindow* theView,
1947 PointMap3d_i* theTable,
1948 int theDisplaying ) :
1951 myDisplaying (theDisplaying)
1953 virtual void Execute() {
1954 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
1955 VISU_PointMap3dActor* anActor = myTable->CreateActor();
1956 myTable->UpdateActor( anActor );
1957 aViewWindow->AddActor( anActor );
1961 void View3D_i::EraseAll()
1963 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1964 SUIT_ViewWindow* aVW = GetViewWindow();
1966 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eEraseAll));
1969 void View3D_i::DisplayAll()
1971 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1972 SUIT_ViewWindow* aVW = GetViewWindow();
1974 ProcessVoidEvent(new TUpdateViewerEvent(aVW,NULL,eDisplayAll));
1977 void View3D_i::Erase (PrsObject_ptr thePrsObj)
1979 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1980 SUIT_ViewWindow* aVW = GetViewWindow();
1981 CORBA::Object_ptr anObj = thePrsObj;
1982 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1984 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eErase));
1987 void View3D_i::Display (PrsObject_ptr thePrsObj)
1989 if(MYDEBUG) MESSAGE("View3D_i::Display");
1990 SUIT_ViewWindow* aVW = GetViewWindow();
1991 CORBA::Object_ptr anObj = thePrsObj;
1992 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
1994 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
1995 else if (aVW && !aPrs) {
1996 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
1998 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
2002 void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
2004 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
2005 SUIT_ViewWindow* aVW = GetViewWindow();
2006 CORBA::Object_ptr anObj = thePrsObj;
2007 Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
2009 ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
2010 else if (aVW && !aPrs) {
2011 PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
2013 ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
2017 void View3D_i::FitAll()
2019 SUIT_ViewWindow* aVW = GetViewWindow();
2021 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2022 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFitAll));
2027 void View3D_i::SetView (VISU::View3D::ViewType theType)
2029 SUIT_ViewWindow* aVW = GetViewWindow();
2034 case VISU::View3D::FRONT :
2035 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2036 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onFrontView));
2038 case VISU::View3D::BACK :
2039 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2040 (dynamic_cast<SVTK_ViewWindow*>(aVW), &SVTK_ViewWindow::onBackView));
2042 case VISU::View3D::LEFT :
2043 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2044 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onLeftView));
2046 case VISU::View3D::RIGHT :
2047 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2048 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onRightView));
2050 case VISU::View3D::TOP :
2051 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2052 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onTopView));
2054 case VISU::View3D::BOTTOM :
2055 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
2056 (dynamic_cast<SVTK_ViewWindow*>(aVW),&SVTK_ViewWindow::onBottomView));
2062 class TSet3DViewParamEvent: public SALOME_Event
2065 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, const CORBA::Double theParam[3]);
2066 TSet3DViewParamEvent (TFun theFun,
2067 SUIT_ViewWindow* theViewWindow,
2068 const CORBA::Double theParam[3]):
2070 myVW(theViewWindow),
2073 virtual void Execute() {
2074 myFun(myVW,myParam);
2078 SUIT_ViewWindow* myVW;
2079 const CORBA::Double* myParam;
2082 void View3D_i::SetPointOfView (SUIT_ViewWindow* theViewWindow,
2083 const CORBA::Double thePosition[3])
2085 //jfa: may be need to be enclosed in SALOME_Event?
2086 GetCamera(theViewWindow)->SetPosition(thePosition);
2089 void View3D_i::SetPointOfView (const VISU::View3D::XYZ thePosition)
2091 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
2092 SUIT_ViewWindow* aVW = GetViewWindow();
2094 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
2097 void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
2098 CORBA::Double thePosition[3])
2100 GetCamera(theViewWindow)->GetPosition(thePosition);
2103 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
2105 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
2106 CORBA::Double aPosition[3];
2107 SUIT_ViewWindow* aVW = GetViewWindow();
2109 GetPointOfView(aVW,aPosition);
2110 return VISU::View3D::XYZ_dup(aPosition);
2113 void View3D_i::SetViewUp (SUIT_ViewWindow* theViewWindow,
2114 const CORBA::Double theViewUp[3])
2116 GetCamera(theViewWindow)->SetViewUp(theViewUp);
2119 void View3D_i::SetViewUp (const VISU::View3D::XYZ theViewUp)
2121 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
2122 SUIT_ViewWindow* aVW = GetViewWindow();
2124 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
2127 void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
2128 CORBA::Double theViewUp[3])
2130 GetCamera(theViewWindow)->GetViewUp(theViewUp);
2133 VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
2135 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
2136 CORBA::Double aViewUp[3];
2137 SUIT_ViewWindow* aVW = GetViewWindow();
2139 GetCamera(aVW)->GetViewUp(aViewUp);
2140 return VISU::View3D::XYZ_dup(aViewUp);
2143 void View3D_i::SetFocalPoint (SUIT_ViewWindow* theViewWindow,
2144 const CORBA::Double theFocalPnt[3])
2146 GetCamera(theViewWindow)->SetFocalPoint(theFocalPnt);
2149 void View3D_i::SetFocalPoint (const VISU::View3D::XYZ theCoord)
2151 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
2152 SUIT_ViewWindow* aVW = GetViewWindow();
2154 ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
2158 void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow,
2159 CORBA::Double theFocalPnt[3])
2161 GetCamera(theViewWindow)->GetFocalPoint(theFocalPnt);
2164 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
2166 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
2167 CORBA::Double aFocalPnt[3];
2168 SUIT_ViewWindow* aVW = GetViewWindow();
2170 GetFocalPoint(aVW,aFocalPnt);
2171 return VISU::View3D::XYZ_dup(aFocalPnt);
2174 class TSetViewParamEvent: public SALOME_Event
2177 typedef void (*TFun)(SUIT_ViewWindow* theViewWindow, CORBA::Double theParam);
2178 TSetViewParamEvent (TFun theFun,
2179 SUIT_ViewWindow* theViewWindow,
2180 CORBA::Double theParam):
2182 myVW(theViewWindow),
2185 virtual void Execute()
2187 myFun(myVW,myParam);
2191 SUIT_ViewWindow* myVW;
2192 CORBA::Double myParam;
2195 void View3D_i::SetParallelScale (SUIT_ViewWindow* theViewWindow,
2196 CORBA::Double theScale)
2198 GetCamera(theViewWindow)->SetParallelScale(theScale);
2201 void View3D_i::SetParallelScale (CORBA::Double theScale)
2203 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
2204 SUIT_ViewWindow* aVW = GetViewWindow();
2206 ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
2209 CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
2211 return GetCamera(theViewWindow)->GetParallelScale();
2214 CORBA::Double View3D_i::GetParallelScale()
2216 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
2217 SUIT_ViewWindow* aVW = GetViewWindow();
2219 return GetParallelScale(aVW);
2223 void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow,
2224 VISU::View3D::Axis theAxis, CORBA::Double theParam)
2226 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
2227 double aScaleFactor[3];
2228 aViewWindow->GetScale(aScaleFactor);
2229 aScaleFactor[theAxis] = theParam;
2230 aViewWindow->SetScale(aScaleFactor);
2233 void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3])
2235 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
2236 (dynamic_cast<SVTK_ViewWindow*>(theViewWindow))->SetScale(aScale);
2239 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam)
2241 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
2242 SUIT_ViewWindow* aVW = GetViewWindow();
2245 (dynamic_cast<SVTK_ViewWindow*>(aVW))->GetScale(aScale);
2246 aScale[theAxis] = theParam;
2247 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2251 void View3D_i::RemoveScale()
2253 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
2254 SUIT_ViewWindow* aVW = GetViewWindow();
2256 double aScale[3] = {1.0, 1.0, 1.0};
2257 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale));
2261 //================================================
2262 // Certain presentation view parameters management
2263 //================================================
2264 class TPrsManageEvent: public SALOME_Event
2268 ScalarMap_ptr myPrs;
2271 TPrsManageEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2272 myView3D(theView3D),
2273 myPrs(ScalarMap::_duplicate(thePrs)),
2274 myError("Unknown error occured")
2276 VISU_Actor* GetMyActor()
2278 SUIT_ViewWindow* aVW = myView3D->GetViewWindow();
2279 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aVW);
2281 myError = "Corrupted view window";
2283 ScalarMap_i* aPrs = dynamic_cast<ScalarMap_i*>(VISU::GetServant(myPrs).in());
2285 myError = "Corrupted presentation";
2287 VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
2289 myError = "No actor found. Display the presentation at first.";
2301 class TGetPrsTypeEvent: public TPrsManageEvent {
2303 typedef VISU::PresentationType TResult;
2305 TGetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2306 TPrsManageEvent(theView3D, thePrs), myResult(VISU::SHRINK) {}
2307 virtual void Execute() {
2308 if (VISU_Actor* anActor = GetMyActor())
2309 myResult = (VISU::PresentationType)anActor->GetRepresentation();
2313 class TGetShrinkedEvent: public TPrsManageEvent {
2315 typedef bool TResult;
2317 TGetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2318 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2319 virtual void Execute() {
2320 if (VISU_Actor* anActor = GetMyActor()) {
2321 if (anActor->IsShrunkable())
2322 myResult = anActor->IsShrunk();
2329 class TGetShadedEvent: public TPrsManageEvent {
2331 typedef bool TResult;
2333 TGetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2334 TPrsManageEvent(theView3D, thePrs), myResult(false) {}
2335 virtual void Execute() {
2336 if (VISU_Actor* anActor = GetMyActor())
2337 if (VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor))
2338 myResult = aScalarMapActor->IsShading();
2342 class TGetOpacityEvent: public TPrsManageEvent {
2344 typedef double TResult;
2346 TGetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2347 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2348 virtual void Execute() {
2349 if (VISU_Actor* anActor = GetMyActor()) {
2350 vtkFloatingPointType oldvalue = anActor->GetOpacity();
2351 myResult = (double)oldvalue;
2356 class TGetLineWidthEvent: public TPrsManageEvent {
2358 typedef double TResult;
2360 TGetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2361 TPrsManageEvent(theView3D, thePrs), myResult(-1.0) {}
2362 virtual void Execute() {
2363 if (VISU_Actor* anActor = GetMyActor()) {
2364 vtkFloatingPointType oldvalue = anActor->GetLineWidth();
2365 myResult = (double)oldvalue;
2371 class TSetPrsTypeEvent: public TPrsManageEvent {
2373 PresentationType myPrsType;
2375 typedef string TResult;
2377 TSetPrsTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, PresentationType thePrsType):
2378 TPrsManageEvent(theView3D, thePrs), myPrsType(thePrsType),
2379 myResult("Unknown error occured")
2381 virtual void Execute() {
2382 switch (myPrsType) {
2383 case VISU::INSIDEFRAME:
2385 VISU::VISUType aType = myPrs->GetType();
2386 if (aType != VISU::TSCALARMAP &&
2387 aType != VISU::TDEFORMEDSHAPE &&
2388 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2389 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2390 myResult = "Insideframe representation is not available for this type of presentations.";
2395 case VISU::SURFACEFRAME:
2396 myResult = "Surfaceframe representation is available only for mesh presentation.";
2399 myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
2404 if (VISU_Actor* anActor = GetMyActor()) {
2405 anActor->SetRepresentation((int)myPrsType);
2406 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2415 class TSetShrinkedEvent: public TPrsManageEvent {
2419 typedef string TResult;
2421 TSetShrinkedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2422 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2423 myResult("Unknown error occured")
2425 virtual void Execute() {
2426 VISU::VISUType aType = myPrs->GetType();
2427 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2428 myResult = "Shrinked representation is not available for this type of presentations.";
2430 if (VISU_Actor* anActor = GetMyActor()) {
2431 if (anActor->IsShrunkable()) {
2432 if (myIsOn) anActor->SetShrink();
2433 else anActor->UnShrink();
2434 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2438 myResult = "This presentation is not shrunkable.";
2447 class TSetShadedEvent: public TPrsManageEvent {
2451 typedef string TResult;
2453 TSetShadedEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, bool isOn):
2454 TPrsManageEvent(theView3D, thePrs), myIsOn(isOn),
2455 myResult("Unknown error occured")
2457 virtual void Execute() {
2458 if (VISU_Actor* anActor = GetMyActor()) {
2459 if (VISU_ScalarMapAct* aScalarMapActor =
2460 dynamic_cast<VISU_ScalarMapAct*>(anActor)) {
2461 aScalarMapActor->SetShading(myIsOn);
2462 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2466 myResult = "Corrupted actor";
2474 class TSetOpacityEvent: public TPrsManageEvent {
2478 typedef string TResult;
2480 TSetOpacityEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theOpacity):
2481 TPrsManageEvent(theView3D, thePrs), myOpacity(theOpacity),
2482 myResult("Unknown error occured")
2484 virtual void Execute() {
2485 VISU::VISUType aType = myPrs->GetType();
2486 if (aType == VISU::TVECTORS || aType == VISU::TSTREAMLINES) {
2487 myResult = "Opacity is meaningless for this type of presentations.";
2490 if (VISU_Actor* anActor = GetMyActor()) {
2491 anActor->SetOpacity((vtkFloatingPointType)myOpacity);
2492 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2501 class TSetLineWidthEvent: public TPrsManageEvent {
2505 typedef string TResult;
2507 TSetLineWidthEvent(View3D_i* theView3D, ScalarMap_ptr thePrs, double theLineWidth):
2508 TPrsManageEvent(theView3D, thePrs), myLineWidth(theLineWidth),
2509 myResult("Unknown error occured")
2511 virtual void Execute() {
2512 if (myPrs->GetType() == VISU::TVECTORS) {
2513 myResult = "Line Width is meaningless for Vectors presentation.";
2516 if (VISU_Actor* anActor = GetMyActor()) {
2517 anActor->SetLineWidth((vtkFloatingPointType)myLineWidth);
2518 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2527 class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2529 Quadratic2DPresentationType myPrsType;
2531 typedef string TResult;
2533 TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
2534 ScalarMap_ptr thePrs,
2535 Quadratic2DPresentationType theType):
2536 TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
2537 myResult("Unknown error occured")
2539 virtual void Execute()
2541 VISU::VISUType aType = myPrs->GetType();
2542 if (aType != VISU::TSCALARMAP &&
2543 aType != VISU::TDEFORMEDSHAPE &&
2544 aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
2545 aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2546 myResult = "2D Quadratic element representation is not available for this type of presentations.";
2549 if (VISU_Actor* anActor = GetMyActor()) {
2550 if(myPrsType == VISU::LINES)
2551 anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
2552 else if(myPrsType == VISU::ARCS)
2553 anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
2555 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
2564 class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
2566 typedef VISU::Quadratic2DPresentationType TResult;
2568 TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
2569 TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
2570 virtual void Execute() {
2571 if (VISU_Actor* anActor = GetMyActor()) {
2572 if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
2573 myResult = VISU::LINES;
2574 else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
2575 myResult = VISU::ARCS;
2580 PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
2582 return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
2584 CORBA::Boolean View3D_i::IsShrinked(ScalarMap_ptr thePrs)
2586 return ProcessEvent(new TGetShrinkedEvent(this,thePrs));
2588 CORBA::Boolean View3D_i::IsShaded(ScalarMap_ptr thePrs)
2590 return ProcessEvent(new TGetShadedEvent(this,thePrs));
2592 CORBA::Double View3D_i::GetOpacity(ScalarMap_ptr thePrs)
2594 return ProcessEvent(new TGetOpacityEvent(this,thePrs));
2596 CORBA::Double View3D_i::GetLineWidth(ScalarMap_ptr thePrs)
2598 return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
2601 Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
2603 return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
2606 char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
2608 string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
2609 return CORBA::string_dup(aRet.c_str());
2611 char* View3D_i::SetShrinked(ScalarMap_ptr thePrs, CORBA::Boolean isShrinked)
2613 string aRet = ProcessEvent(new TSetShrinkedEvent(this,thePrs,isShrinked));
2614 return CORBA::string_dup(aRet.c_str());
2616 char* View3D_i::SetShaded(ScalarMap_ptr thePrs, CORBA::Boolean isShaded)
2618 string aRet = ProcessEvent(new TSetShadedEvent(this,thePrs,isShaded));
2619 return CORBA::string_dup(aRet.c_str());
2621 char* View3D_i::SetOpacity(ScalarMap_ptr thePrs, CORBA::Double theOpacity)
2623 string aRet = ProcessEvent(new TSetOpacityEvent(this,thePrs,theOpacity));
2624 return CORBA::string_dup(aRet.c_str());
2626 char* View3D_i::SetLineWidth(ScalarMap_ptr thePrs, CORBA::Double theLineWidth)
2628 string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
2629 return CORBA::string_dup(aRet.c_str());
2632 char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
2634 string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
2635 return CORBA::string_dup(aRet.c_str());